ReactOS 0.4.16-dev-1946-g52006dd
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)
 
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)
 

Variables

const NDR_MARSHALL NdrMarshaller []
 
const NDR_UNMARSHALL NdrUnmarshaller []
 
const NDR_BUFFERSIZE NdrBufferSizer []
 
const NDR_MEMORYSIZE NdrMemorySizer []
 
const NDR_FREE NdrFreer []
 

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 3521 of file ndr_marshall.c.

3522{
3524 ULONG size = 0;
3525
3526 while (*pFormat != FC_END) {
3527 switch (*pFormat) {
3528 case FC_BYTE:
3529 case FC_CHAR:
3530 case FC_SMALL:
3531 case FC_USMALL:
3532 size += 1;
3533 break;
3534 case FC_WCHAR:
3535 case FC_SHORT:
3536 case FC_USHORT:
3537 size += 2;
3538 break;
3539 case FC_LONG:
3540 case FC_ULONG:
3541 case FC_ENUM16:
3542 case FC_ENUM32:
3543 case FC_FLOAT:
3544 size += 4;
3545 break;
3546 case FC_INT3264:
3547 case FC_UINT3264:
3548 size += sizeof(INT_PTR);
3549 break;
3550 case FC_HYPER:
3551 case FC_DOUBLE:
3552 size += 8;
3553 break;
3554 case FC_RP:
3555 case FC_UP:
3556 case FC_OP:
3557 case FC_FP:
3558 case FC_POINTER:
3559 size += sizeof(void *);
3560 if (*pFormat != FC_POINTER)
3561 pFormat += 4;
3562 break;
3563 case FC_ALIGNM2:
3564 align_length(&size, 2);
3565 break;
3566 case FC_ALIGNM4:
3567 align_length(&size, 4);
3568 break;
3569 case FC_ALIGNM8:
3570 align_length(&size, 8);
3571 break;
3572 case FC_STRUCTPAD1:
3573 case FC_STRUCTPAD2:
3574 case FC_STRUCTPAD3:
3575 case FC_STRUCTPAD4:
3576 case FC_STRUCTPAD5:
3577 case FC_STRUCTPAD6:
3578 case FC_STRUCTPAD7:
3579 size += *pFormat - FC_STRUCTPAD1 + 1;
3580 break;
3582 size += pFormat[1];
3583 pFormat += 2;
3584 desc = pFormat + *(const SHORT*)pFormat;
3585 size += EmbeddedComplexSize(pStubMsg, desc);
3586 pFormat += 2;
3587 continue;
3588 case FC_PAD:
3589 break;
3590 default:
3591 FIXME("unhandled format 0x%02x\n", *pFormat);
3592 }
3593 pFormat++;
3594 }
3595
3596 return size;
3597}
#define FIXME(fmt,...)
Definition: precomp.h:53
static void align_length(ULONG *len, unsigned int align)
Definition: ndr_marshall.c:91
static ULONG EmbeddedComplexSize(MIDL_STUB_MESSAGE *pStubMsg, PFORMAT_STRING pFormat)
GLsizeiptr size
Definition: glext.h:5919
D3D11_SHADER_VARIABLE_DESC desc
Definition: reflection.c:1204
short SHORT
Definition: pedump.c:59
@ FC_STRUCTPAD4
Definition: ndrtypes.h:213
@ FC_USMALL
Definition: ndrtypes.h:138
@ FC_INT3264
Definition: ndrtypes.h:268
@ FC_SMALL
Definition: ndrtypes.h:137
@ FC_ALIGNM4
Definition: ndrtypes.h:203
@ FC_DOUBLE
Definition: ndrtypes.h:146
@ FC_USHORT
Definition: ndrtypes.h:141
@ FC_ALIGNM2
Definition: ndrtypes.h:202
@ FC_ENUM16
Definition: ndrtypes.h:147
@ FC_LONG
Definition: ndrtypes.h:142
@ FC_CHAR
Definition: ndrtypes.h:136
@ FC_OP
Definition: ndrtypes.h:154
@ FC_HYPER
Definition: ndrtypes.h:145
@ FC_STRUCTPAD1
Definition: ndrtypes.h:210
@ FC_EMBEDDED_COMPLEX
Definition: ndrtypes.h:233
@ FC_ULONG
Definition: ndrtypes.h:143
@ FC_STRUCTPAD7
Definition: ndrtypes.h:216
@ FC_ALIGNM8
Definition: ndrtypes.h:204
@ FC_UP
Definition: ndrtypes.h:153
@ FC_POINTER
Definition: ndrtypes.h:200
@ FC_PAD
Definition: ndrtypes.h:254
@ FC_RP
Definition: ndrtypes.h:152
@ FC_STRUCTPAD5
Definition: ndrtypes.h:214
@ FC_FLOAT
Definition: ndrtypes.h:144
@ FC_STRUCTPAD2
Definition: ndrtypes.h:211
@ FC_ENUM32
Definition: ndrtypes.h:148
@ FC_STRUCTPAD6
Definition: ndrtypes.h:215
@ FC_FP
Definition: ndrtypes.h:155
@ FC_BYTE
Definition: ndrtypes.h:135
@ FC_END
Definition: ndrtypes.h:253
@ FC_UINT3264
Definition: ndrtypes.h:269
@ FC_STRUCTPAD3
Definition: ndrtypes.h:212
@ FC_SHORT
Definition: ndrtypes.h:140
@ FC_WCHAR
Definition: ndrtypes.h:139
const unsigned char * PFORMAT_STRING
Definition: rpcndr.h:159
int32_t INT_PTR
Definition: typedefs.h:64
uint32_t ULONG
Definition: typedefs.h:59

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)
Definition: ndr_marshall.c:555
ULONG_PTR MaxCount
Definition: rpcndr.h:204

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 555 of file ndr_marshall.c.

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

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}
return ret
Definition: mutex.c:146
ULONG ActualCount
Definition: rpcndr.h:206

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

Variable Documentation

◆ NdrBufferSizer

const NDR_BUFFERSIZE NdrBufferSizer[]
extern

◆ NdrFreer

const NDR_FREE NdrFreer[]
extern

Definition at line 347 of file ndr_marshall.c.

Referenced by call_freer(), ComplexFree(), PointerFree(), and union_arm_free().

◆ NdrMarshaller

const NDR_MARSHALL NdrMarshaller[]
extern

◆ NdrMemorySizer

const NDR_MEMORYSIZE NdrMemorySizer[]
extern

◆ NdrUnmarshaller

const NDR_UNMARSHALL NdrUnmarshaller[]
extern