ReactOS  0.4.15-dev-1374-g8d3e80e
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

Definition at line 57 of file ndr_misc.h.

◆ NDR_MARSHALL

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

Definition at line 54 of file ndr_misc.h.

Function Documentation

◆ ComplexStructSize()

ULONG ComplexStructSize ( PMIDL_STUB_MESSAGE  pStubMsg,
PFORMAT_STRING  pFormat 
)

Definition at line 3522 of file ndr_marshall.c.

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

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