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, &target, ndr_uint8Array_descr() };
25 
26  if (!ndr_push_deferreds(context, &e, 1))
27  goto out;
28 
29  if (!ndr_treat_deferred_read(context, s))
30  goto out;
31 
32  NdrMessageType descr = ndr_uint8Array_descr();
33  descr->destroyFn(context, &hints, target);
34  free(target);
35  retCode = 0;
36 out:
37  ndr_context_destroy(&context);
38  return retCode;
39 }
hints for a conformant array
Definition: ndr.h:184
a deferred pointer
Definition: ndr.h:115
message descriptor
Definition: ndr.h:76