20 #ifndef CHANNELS_RDPEAR_NDR_H_
21 #define CHANNELS_RDPEAR_NDR_H_
23 #include <winpr/stream.h>
24 #include <freerdp/api.h>
26 #define NDR_PTR_NULL (0UL)
28 #define NDR_SIMPLE_TYPE_DECL(LOWER, UPPER) \
29 BOOL ndr_read_##LOWER(NdrContext* context, wStream* s, UPPER* v); \
30 BOOL ndr_read_##LOWER##_(NdrContext* context, wStream* s, const void* hints, void* v); \
31 BOOL ndr_write_##LOWER(NdrContext* context, wStream* s, UPPER v); \
32 BOOL ndr_write_##LOWER##_(NdrContext* context, wStream* s, const void* hints, const void* v); \
33 extern const NdrMessageDescr ndr_##LOWER##_descr_s; \
34 NdrMessageType ndr_##LOWER##_descr(void)
36 #define NDR_ARRAY_OF_TYPE_DECL(TYPE, UPPERTYPE) \
37 BOOL ndr_read_##TYPE##Array(NdrContext* context, wStream* s, const void* hints, void* v); \
38 BOOL ndr_write_##TYPE##Array(NdrContext* context, wStream* s, const void* hints, \
40 void ndr_destroy_##TYPE##Array(NdrContext* context, const void* hints, void* obj); \
41 extern const NdrMessageDescr ndr_##TYPE##Array_descr_s; \
42 NdrMessageType ndr_##TYPE##Array_descr(void); \
44 BOOL ndr_read_##TYPE##VaryingArray(NdrContext* context, wStream* s, const void* hints, \
46 BOOL ndr_write_##TYPE##VaryingArray(NdrContext* context, wStream* s, const void* hints, \
48 extern const NdrMessageDescr ndr_##TYPE##VaryingArray_descr_s; \
49 NdrMessageType ndr_##TYPE##VaryingArray_descr(void)
56 typedef struct NdrContext_s NdrContext;
58 typedef UINT32 ndr_refid;
60 typedef BOOL (*NDR_READER_FN)(NdrContext* context,
wStream* s,
const void* hints,
void* target);
61 typedef BOOL (*NDR_WRITER_FN)(NdrContext* context,
wStream* s,
const void* hints,
63 typedef void (*NDR_DESTROY_FN)(NdrContext* context,
const void* hints,
void* obj);
64 typedef void (*NDR_DUMP_FN)(wLog* logger, UINT32 lvl,
size_t indentLevel,
const void* obj);
71 NDR_ARITY_VARYING_ARRAYOF,
80 NDR_WRITER_FN writeFn;
81 NDR_DESTROY_FN destroyFn;
100 NdrPointerType pointerType;
123 void ndr_context_free(NdrContext* context);
125 static INLINE
void ndr_context_destroy(NdrContext** pcontext)
127 WINPR_ASSERT(pcontext);
128 ndr_context_free(*pcontext);
132 WINPR_ATTR_MALLOC(ndr_context_free, 1)
133 NdrContext* ndr_context_new(BOOL bigEndianDrep, BYTE version);
135 void ndr_context_reset(NdrContext* context);
137 WINPR_ATTR_MALLOC(ndr_context_free, 1)
138 NdrContext* ndr_context_copy(const NdrContext* src);
140 WINPR_ATTR_MALLOC(ndr_context_free, 1)
141 NdrContext* ndr_read_header(
wStream* s);
143 BOOL ndr_write_header(NdrContext* context,
wStream* s);
145 NDR_SIMPLE_TYPE_DECL(uint8, UINT8);
146 NDR_SIMPLE_TYPE_DECL(uint16, UINT16);
147 NDR_SIMPLE_TYPE_DECL(uint32, UINT32);
148 NDR_SIMPLE_TYPE_DECL(uint64, UINT64);
150 NDR_ARRAY_OF_TYPE_DECL(uint8, BYTE);
151 NDR_ARRAY_OF_TYPE_DECL(uint16, UINT16);
153 BOOL ndr_skip_bytes(NdrContext* context,
wStream* s,
size_t nbytes);
154 BOOL ndr_read_align(NdrContext* context,
wStream* s,
size_t sz);
155 BOOL ndr_write_align(NdrContext* context,
wStream* s,
size_t sz);
157 BOOL ndr_read_pickle(NdrContext* context,
wStream* s);
158 BOOL ndr_write_pickle(NdrContext* context,
wStream* s);
160 BOOL ndr_read_constructed(NdrContext* context,
wStream* s,
wStream* target);
161 BOOL ndr_write_constructed(NdrContext* context,
wStream* s,
wStream* payload);
163 BOOL ndr_start_constructed(NdrContext* context,
wStream* s);
164 BOOL ndr_end_constructed(NdrContext* context,
wStream* s);
166 BOOL ndr_read_wchar(NdrContext* context,
wStream* s, WCHAR* ptr);
175 BOOL ndr_read_uconformant_varying_array(NdrContext* context,
wStream* s,
178 BOOL ndr_write_uconformant_varying_array(NdrContext* context,
wStream* s,
190 BOOL ndr_write_uconformant_array(NdrContext* context,
wStream* s, UINT32 len,
197 void ndr_struct_dump_fromDescr(wLog* logger, UINT32 lvl,
size_t identLevel,
199 void ndr_struct_destroy(NdrContext* context,
const NdrStructDescr* descr,
void* pptr);
201 ndr_refid ndr_pointer_refid(
const void* ptr);
202 BOOL ndr_read_refpointer(NdrContext* context,
wStream* s, UINT32* refId);
203 BOOL ndr_context_allocatePtr(NdrContext* context,
const void* ptr, ndr_refid* prefId,
206 BOOL ndr_read_pointedMessageEx(NdrContext* context,
wStream* s, ndr_refid ptrId,
209 BOOL ndr_push_deferreds(NdrContext* context,
NdrDeferredEntry* deferreds,
size_t ndeferred);
210 BOOL ndr_treat_deferred_read(NdrContext* context,
wStream* s);
211 BOOL ndr_treat_deferred_write(NdrContext* context,
wStream* s);
hints for a conformant array
descriptor of a field in a structure
hints for a varying conformant array