ReactOS  0.4.14-dev-317-g96040ec
ndr_misc.h File Reference
#include <stdarg.h>
#include "windef.h"
#include "winbase.h"
#include "rpc.h"
#include "rpcndr.h"
Include dependency graph for ndr_misc.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Typedefs

typedef unsigned char *(WINAPINDR_MARSHALL) (PMIDL_STUB_MESSAGE, unsigned char *, PFORMAT_STRING)
 
typedef unsigned char *(WINAPINDR_UNMARSHALL) (PMIDL_STUB_MESSAGE, unsigned char **, PFORMAT_STRING, unsigned char)
 
typedef void(WINAPINDR_BUFFERSIZE) (PMIDL_STUB_MESSAGE, unsigned char *, PFORMAT_STRING)
 
typedef ULONG(WINAPINDR_MEMORYSIZE) (PMIDL_STUB_MESSAGE, PFORMAT_STRING)
 
typedef void(WINAPINDR_FREE) (PMIDL_STUB_MESSAGE, unsigned char *, PFORMAT_STRING)
 

Functions

PFORMAT_STRING ComputeConformanceOrVariance (MIDL_STUB_MESSAGE *pStubMsg, unsigned char *pMemory, PFORMAT_STRING pFormat, ULONG_PTR def, ULONG_PTR *pCount) DECLSPEC_HIDDEN
 
static PFORMAT_STRING ComputeConformance (PMIDL_STUB_MESSAGE pStubMsg, unsigned char *pMemory, PFORMAT_STRING pFormat, ULONG def)
 
static PFORMAT_STRING ComputeVariance (PMIDL_STUB_MESSAGE pStubMsg, unsigned char *pMemory, PFORMAT_STRING pFormat, ULONG def)
 
ULONG ComplexStructSize (PMIDL_STUB_MESSAGE pStubMsg, PFORMAT_STRING pFormat) DECLSPEC_HIDDEN
 

Variables

const NDR_MARSHALL NdrMarshaller [] DECLSPEC_HIDDEN
 

Typedef Documentation

◆ NDR_BUFFERSIZE

typedef void(WINAPI * NDR_BUFFERSIZE) (PMIDL_STUB_MESSAGE, unsigned char *, PFORMAT_STRING)

Definition at line 55 of file ndr_misc.h.

◆ NDR_FREE

typedef void(WINAPI * NDR_FREE) (PMIDL_STUB_MESSAGE, unsigned char *, PFORMAT_STRING)

Definition at line 57 of file ndr_misc.h.

◆ NDR_MARSHALL

typedef unsigned char*(WINAPI * NDR_MARSHALL) (PMIDL_STUB_MESSAGE, unsigned char *, PFORMAT_STRING)

Definition at line 53 of file ndr_misc.h.

◆ NDR_MEMORYSIZE

typedef ULONG(WINAPI * NDR_MEMORYSIZE) (PMIDL_STUB_MESSAGE, PFORMAT_STRING)

Definition at line 56 of file ndr_misc.h.

◆ NDR_UNMARSHALL

typedef unsigned char*(WINAPI * NDR_UNMARSHALL) (PMIDL_STUB_MESSAGE, unsigned char **, PFORMAT_STRING, unsigned char)

Definition at line 54 of file ndr_misc.h.

Function Documentation

◆ ComplexStructSize()

ULONG ComplexStructSize ( PMIDL_STUB_MESSAGE  pStubMsg,
PFORMAT_STRING  pFormat 
)

Definition at line 3525 of file ndr_marshall.c.

3526 {
3528  ULONG size = 0;
3529 
3530  while (*pFormat != FC_END) {
3531  switch (*pFormat) {
3532  case FC_BYTE:
3533  case FC_CHAR:
3534  case FC_SMALL:
3535  case FC_USMALL:
3536  size += 1;
3537  break;
3538  case FC_WCHAR:
3539  case FC_SHORT:
3540  case FC_USHORT:
3541  size += 2;
3542  break;
3543  case FC_LONG:
3544  case FC_ULONG:
3545  case FC_ENUM16:
3546  case FC_ENUM32:
3547  case FC_FLOAT:
3548  size += 4;
3549  break;
3550  case FC_INT3264:
3551  case FC_UINT3264:
3552  size += sizeof(INT_PTR);
3553  break;
3554  case FC_HYPER:
3555  case FC_DOUBLE:
3556  size += 8;
3557  break;
3558  case FC_RP:
3559  case FC_UP:
3560  case FC_OP:
3561  case FC_FP:
3562  case FC_POINTER:
3563  size += sizeof(void *);
3564  if (*pFormat != FC_POINTER)
3565  pFormat += 4;
3566  break;
3567  case FC_ALIGNM2:
3568  align_length(&size, 2);
3569  break;
3570  case FC_ALIGNM4:
3571  align_length(&size, 4);
3572  break;
3573  case FC_ALIGNM8:
3574  align_length(&size, 8);
3575  break;
3576  case FC_STRUCTPAD1:
3577  case FC_STRUCTPAD2:
3578  case FC_STRUCTPAD3:
3579  case FC_STRUCTPAD4:
3580  case FC_STRUCTPAD5:
3581  case FC_STRUCTPAD6:
3582  case FC_STRUCTPAD7:
3583  size += *pFormat - FC_STRUCTPAD1 + 1;
3584  break;
3585  case FC_EMBEDDED_COMPLEX:
3586  size += pFormat[1];
3587  pFormat += 2;
3588  desc = pFormat + *(const SHORT*)pFormat;
3589  size += EmbeddedComplexSize(pStubMsg, desc);
3590  pFormat += 2;
3591  continue;
3592  case FC_PAD:
3593  break;
3594  default:
3595  FIXME("unhandled format 0x%02x\n", *pFormat);
3596  }
3597  pFormat++;
3598  }
3599 
3600  return size;
3601 }
static ULONG EmbeddedComplexSize(MIDL_STUB_MESSAGE *pStubMsg, PFORMAT_STRING pFormat)
int32_t INT_PTR
Definition: typedefs.h:62
static void align_length(ULONG *len, unsigned int align)
Definition: ndr_marshall.c:93
short SHORT
Definition: pedump.c:59
static const WCHAR desc[]
Definition: protectdata.c:36
#define FIXME(fmt,...)
Definition: debug.h:110
GLsizeiptr size
Definition: glext.h:5919
const unsigned char * PFORMAT_STRING
Definition: rpcndr.h:176
unsigned int ULONG
Definition: retypes.h:1

Referenced by array_memory_size(), array_read_conformance(), array_read_variance_and_unmarshall(), calc_arg_size(), NdrComplexStructBufferSize(), and NdrComplexStructMarshall().

◆ ComputeConformance()

static PFORMAT_STRING ComputeConformance ( PMIDL_STUB_MESSAGE  pStubMsg,
unsigned char pMemory,
PFORMAT_STRING  pFormat,
ULONG  def 
)
inlinestatic

Definition at line 37 of file ndr_misc.h.

38 {
39  return ComputeConformanceOrVariance(pStubMsg, pMemory, pFormat, def, &pStubMsg->MaxCount);
40 }
PFORMAT_STRING ComputeConformanceOrVariance(MIDL_STUB_MESSAGE *pStubMsg, unsigned char *pMemory, PFORMAT_STRING pFormat, ULONG_PTR def, ULONG_PTR *pCount) DECLSPEC_HIDDEN
Definition: ndr_marshall.c:559
ULONG_PTR MaxCount
Definition: rpcndr.h:221

Referenced by array_compute_and_size_conformance(), array_compute_and_write_conformance(), array_free(), calc_arg_size(), get_ip_iid(), NdrComplexArrayFree(), NdrConformantStructBufferSize(), NdrConformantStructFree(), NdrConformantStructMarshall(), NdrNonEncapsulatedUnionBufferSize(), NdrNonEncapsulatedUnionFree(), and NdrNonEncapsulatedUnionMarshall().

◆ ComputeConformanceOrVariance()

PFORMAT_STRING ComputeConformanceOrVariance ( MIDL_STUB_MESSAGE pStubMsg,
unsigned char pMemory,
PFORMAT_STRING  pFormat,
ULONG_PTR  def,
ULONG_PTR pCount 
)

Definition at line 559 of file ndr_marshall.c.

562 {
563  BYTE dtype = pFormat[0] & 0xf;
564  short ofs = *(const short *)&pFormat[2];
565  LPVOID ptr = NULL;
566  ULONG_PTR data = 0;
567 
568  if (!IsConformanceOrVariancePresent(pFormat)) {
569  /* null descriptor */
570  *pCount = def;
571  goto finish_conf;
572  }
573 
574  switch (pFormat[0] & 0xf0) {
576  TRACE("normal conformance, ofs=%d\n", ofs);
577  ptr = pMemory;
578  break;
580  TRACE("pointer conformance, ofs=%d\n", ofs);
581  ptr = pStubMsg->Memory;
582  break;
584  TRACE("toplevel conformance, ofs=%d\n", ofs);
585  if (pStubMsg->StackTop) {
586  ptr = pStubMsg->StackTop;
587  }
588  else {
589  /* -Os mode, *pCount is already set */
590  goto finish_conf;
591  }
592  break;
594  data = ofs | ((DWORD)pFormat[1] << 16);
595  TRACE("constant conformance, val=%ld\n", data);
596  *pCount = data;
597  goto finish_conf;
599  FIXME("toplevel multidimensional conformance, ofs=%d\n", ofs);
600  if (pStubMsg->StackTop) {
601  ptr = pStubMsg->StackTop;
602  }
603  else {
604  /* ? */
605  goto done_conf_grab;
606  }
607  break;
608  default:
609  FIXME("unknown conformance type %x, expect crash.\n", pFormat[0] & 0xf0);
610  goto finish_conf;
611  }
612 
613  switch (pFormat[1]) {
614  case FC_DEREFERENCE:
615  ptr = *(LPVOID*)((char *)ptr + ofs);
616  break;
617  case FC_CALLBACK:
618  {
619  unsigned char *old_stack_top = pStubMsg->StackTop;
620  ULONG_PTR max_count, old_max_count = pStubMsg->MaxCount;
621 
622  pStubMsg->StackTop = ptr;
623 
624  /* ofs is index into StubDesc->apfnExprEval */
625  TRACE("callback conformance into apfnExprEval[%d]\n", ofs);
626  pStubMsg->StubDesc->apfnExprEval[ofs](pStubMsg);
627 
628  pStubMsg->StackTop = old_stack_top;
629 
630  /* the callback function always stores the computed value in MaxCount */
631  max_count = pStubMsg->MaxCount;
632  pStubMsg->MaxCount = old_max_count;
633  *pCount = max_count;
634  goto finish_conf;
635  }
636  default:
637  ptr = (char *)ptr + ofs;
638  break;
639  }
640 
641  switch (dtype) {
642  case FC_LONG:
643  case FC_ULONG:
644  data = *(DWORD*)ptr;
645  break;
646  case FC_SHORT:
647  data = *(SHORT*)ptr;
648  break;
649  case FC_USHORT:
650  data = *(USHORT*)ptr;
651  break;
652  case FC_CHAR:
653  case FC_SMALL:
654  data = *(CHAR*)ptr;
655  break;
656  case FC_BYTE:
657  case FC_USMALL:
658  data = *(UCHAR*)ptr;
659  break;
660  case FC_HYPER:
661  data = *(ULONGLONG *)ptr;
662  break;
663  default:
664  FIXME("unknown conformance data type %x\n", dtype);
665  goto done_conf_grab;
666  }
667  TRACE("dereferenced data type %x at %p, got %ld\n", dtype, ptr, data);
668 
669 done_conf_grab:
670  switch (pFormat[1]) {
671  case FC_DEREFERENCE: /* already handled */
672  case 0: /* no op */
673  *pCount = data;
674  break;
675  case FC_ADD_1:
676  *pCount = data + 1;
677  break;
678  case FC_SUB_1:
679  *pCount = data - 1;
680  break;
681  case FC_MULT_2:
682  *pCount = data * 2;
683  break;
684  case FC_DIV_2:
685  *pCount = data / 2;
686  break;
687  default:
688  FIXME("unknown conformance op %d\n", pFormat[1]);
689  goto finish_conf;
690  }
691 
692 finish_conf:
693  TRACE("resulting conformance is %ld\n", *pCount);
694 
695  return SkipConformance(pStubMsg, pFormat);
696 }
#define FC_TOP_LEVEL_CONFORMANCE
Definition: ndrtypes.h:300
char CHAR
Definition: xmlstorage.h:175
const struct _MIDL_STUB_DESC * StubDesc
Definition: rpcndr.h:230
#define FC_TOP_LEVEL_MULTID_CONFORMANCE
Definition: ndrtypes.h:302
#define DWORD
Definition: nt_native.h:44
uint32_t ULONG_PTR
Definition: typedefs.h:63
#define FC_NORMAL_CONFORMANCE
Definition: ndrtypes.h:298
short SHORT
Definition: pedump.c:59
#define FIXME(fmt,...)
Definition: debug.h:110
static PVOID ptr
Definition: dispmode.c:27
unsigned char * Memory
Definition: rpcndr.h:209
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
ULONG_PTR MaxCount
Definition: rpcndr.h:221
uint64_t ULONGLONG
Definition: typedefs.h:65
unsigned long DWORD
Definition: ntddk_ex.h:95
static BOOL IsConformanceOrVariancePresent(PFORMAT_STRING pFormat)
Definition: ndr_marshall.c:466
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
static PFORMAT_STRING SkipConformance(const PMIDL_STUB_MESSAGE pStubMsg, const PFORMAT_STRING pFormat)
Definition: ndr_marshall.c:471
unsigned char UCHAR
Definition: xmlstorage.h:181
unsigned char BYTE
Definition: mem.h:68
#define FC_CONSTANT_CONFORMANCE
Definition: ndrtypes.h:301
unsigned short USHORT
Definition: pedump.c:61
unsigned char * StackTop
Definition: rpcndr.h:226
#define FC_POINTER_CONFORMANCE
Definition: ndrtypes.h:299

Referenced by ComputeConformance(), and ComputeVariance().

◆ ComputeVariance()

static PFORMAT_STRING ComputeVariance ( PMIDL_STUB_MESSAGE  pStubMsg,
unsigned char pMemory,
PFORMAT_STRING  pFormat,
ULONG  def 
)
inlinestatic

Definition at line 42 of file ndr_misc.h.

43 {
45  ULONG_PTR ActualCount = pStubMsg->ActualCount;
46 
47  pStubMsg->Offset = 0;
48  ret = ComputeConformanceOrVariance(pStubMsg, pMemory, pFormat, def, &ActualCount);
49  pStubMsg->ActualCount = (ULONG)ActualCount;
50  return ret;
51 }
uint32_t ULONG_PTR
Definition: typedefs.h:63
PFORMAT_STRING ComputeConformanceOrVariance(MIDL_STUB_MESSAGE *pStubMsg, unsigned char *pMemory, PFORMAT_STRING pFormat, ULONG_PTR def, ULONG_PTR *pCount) DECLSPEC_HIDDEN
Definition: ndr_marshall.c:559
ULONG ActualCount
Definition: rpcndr.h:223
const unsigned char * PFORMAT_STRING
Definition: rpcndr.h:176
int ret
unsigned int ULONG
Definition: retypes.h:1

Referenced by array_compute_and_size_conformance(), array_compute_and_write_conformance(), array_free(), calc_arg_size(), NdrComplexArrayFree(), NdrVaryingArrayBufferSize(), NdrVaryingArrayFree(), and NdrVaryingArrayMarshall().

Variable Documentation

◆ DECLSPEC_HIDDEN

const NDR_FREE NdrFreer [] DECLSPEC_HIDDEN

Definition at line 60 of file ndr_misc.h.