FreeRDP
TestNdr.c
1 #include <rdpear-common/ndr.h>
2 
3 int TestNdr(int argc, char* argv[])
4 {
5  WINPR_UNUSED(argc);
6  WINPR_UNUSED(argv);
7 
8  int retCode = -2;
9  NdrContext* context = ndr_context_new(FALSE, 1);
10  if (!context)
11  return -1;
12 
13  BYTE payload[] = {
14  // == conformant array ==
15  0x02, 0x00, 0x00, 0x00, // (nitems)
16  0x30, 0x00, // content
17  0x00, 0x00 // (padding)
18  };
19  wStream staticS;
20  wStream* s = Stream_StaticInit(&staticS, payload, sizeof(payload));
21 
22  BYTE* target = NULL;
23  NdrArrayHints hints = { 2 };
24  NdrDeferredEntry e = { 0x020028, "arrayContent", &hints, (void*)&target,
25  ndr_uint8Array_descr() };
26 
27  if (!ndr_push_deferreds(context, &e, 1))
28  goto out;
29 
30  if (!ndr_treat_deferred_read(context, s))
31  goto out;
32 
33  NdrMessageType descr = ndr_uint8Array_descr();
34  descr->destroyFn(context, &hints, target);
35  free(target);
36  retCode = 0;
37 out:
38  ndr_context_destroy(&context);
39  return retCode;
40 }
hints for a conformant array
Definition: ndr.h:184
a deferred pointer
Definition: ndr.h:115
message descriptor
Definition: ndr.h:76