ReactOS 0.4.16-dev-117-g38f21f9
ndr_marshall.c File Reference
#include <assert.h>
#include <stdarg.h>
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include "windef.h"
#include "winbase.h"
#include "winerror.h"
#include "ndr_misc.h"
#include "rpcndr.h"
#include "ndrtypes.h"
#include "wine/debug.h"
#include "pshpack1.h"
#include "poppack.h"
Include dependency graph for ndr_marshall.c:

Go to the source code of this file.

Classes

struct  _NDR_MEMORY_LIST
 
struct  NDR_RANGE
 
struct  _NDR_CSTRUCT_FORMAT
 
struct  NDR_SMFARRAY_FORMAT
 
struct  NDR_LGFARRAY_FORMAT
 

Macros

#define NONAMELESSUNION
 
#define LITTLE_ENDIAN_UINT32_WRITE(pchar, uint32)
 
#define LITTLE_ENDIAN_UINT32_READ(pchar)
 
#define BIG_ENDIAN_UINT32_WRITE(pchar, uint32)
 
#define BIG_ENDIAN_UINT32_READ(pchar)
 
#define NDR_LOCAL_UINT32_WRITE(pchar, uint32)    LITTLE_ENDIAN_UINT32_WRITE(pchar, uint32)
 
#define NDR_LOCAL_UINT32_READ(pchar)    LITTLE_ENDIAN_UINT32_READ(pchar)
 
#define STD_OVERFLOW_CHECK(_Msg)
 
#define NDR_POINTER_ID_BASE   0x20000
 
#define NDR_POINTER_ID(pStubMsg)   (NDR_POINTER_ID_BASE + ((pStubMsg)->UniquePtrCount++) * 4)
 
#define NDR_TABLE_SIZE   128
 
#define NDR_TABLE_MASK   127
 
#define MEML_MAGIC   ('M' << 24 | 'E' << 16 | 'M' << 8 | 'L')
 
#define BASE_TYPE_UNMARSHALL(type)
 
#define USER_MARSHAL_PTR_PREFIX
 
#define RANGE_UNMARSHALL(mem_type, wire_type, format_spec)
 
#define BASE_TYPE_UNMARSHALL(type)
 

Typedefs

typedef struct _NDR_MEMORY_LIST NDR_MEMORY_LIST
 
typedef struct _NDR_CSTRUCT_FORMAT NDR_CSTRUCT_FORMAT
 
typedef struct _NDR_CSTRUCT_FORMAT NDR_CVSTRUCT_FORMAT
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (ole)
 
static void align_length (ULONG *len, unsigned int align)
 
static void align_pointer (unsigned char **ptr, unsigned int align)
 
static void align_pointer_clear (unsigned char **ptr, unsigned int align)
 
static void align_pointer_offset (unsigned char **ptr, unsigned char *base, unsigned int align)
 
static void align_pointer_offset_clear (unsigned char **ptr, unsigned char *base, unsigned int align)
 
static unsigned char *WINAPI NdrBaseTypeMarshall (PMIDL_STUB_MESSAGE, unsigned char *, PFORMAT_STRING)
 
static unsigned char *WINAPI NdrBaseTypeUnmarshall (PMIDL_STUB_MESSAGE, unsigned char **, PFORMAT_STRING, unsigned char)
 
static void WINAPI NdrBaseTypeBufferSize (PMIDL_STUB_MESSAGE, unsigned char *, PFORMAT_STRING)
 
static void WINAPI NdrBaseTypeFree (PMIDL_STUB_MESSAGE, unsigned char *, PFORMAT_STRING)
 
static ULONG WINAPI NdrBaseTypeMemorySize (PMIDL_STUB_MESSAGE, PFORMAT_STRING)
 
static unsigned char *WINAPI NdrContextHandleMarshall (PMIDL_STUB_MESSAGE, unsigned char *, PFORMAT_STRING)
 
static void WINAPI NdrContextHandleBufferSize (PMIDL_STUB_MESSAGE, unsigned char *, PFORMAT_STRING)
 
static unsigned char *WINAPI NdrContextHandleUnmarshall (PMIDL_STUB_MESSAGE, unsigned char **, PFORMAT_STRING, unsigned char)
 
static unsigned char *WINAPI NdrRangeMarshall (PMIDL_STUB_MESSAGE, unsigned char *, PFORMAT_STRING)
 
static void WINAPI NdrRangeBufferSize (PMIDL_STUB_MESSAGE, unsigned char *, PFORMAT_STRING)
 
static ULONG WINAPI NdrRangeMemorySize (PMIDL_STUB_MESSAGE, PFORMAT_STRING)
 
static void WINAPI NdrRangeFree (PMIDL_STUB_MESSAGE, unsigned char *, PFORMAT_STRING)
 
static ULONG WINAPI NdrByteCountPointerMemorySize (PMIDL_STUB_MESSAGE, PFORMAT_STRING)
 
static unsigned charComplexBufferSize (PMIDL_STUB_MESSAGE pStubMsg, unsigned char *pMemory, PFORMAT_STRING pFormat, PFORMAT_STRING pPointer)
 
static unsigned charComplexMarshall (PMIDL_STUB_MESSAGE pStubMsg, unsigned char *pMemory, PFORMAT_STRING pFormat, PFORMAT_STRING pPointer)
 
static unsigned charComplexUnmarshall (PMIDL_STUB_MESSAGE pStubMsg, unsigned char *pMemory, PFORMAT_STRING pFormat, PFORMAT_STRING pPointer, unsigned char fMustAlloc)
 
static ULONG ComplexStructMemorySize (PMIDL_STUB_MESSAGE pStubMsg, PFORMAT_STRING pFormat, PFORMAT_STRING pPointer)
 
static unsigned charComplexFree (PMIDL_STUB_MESSAGE pStubMsg, unsigned char *pMemory, PFORMAT_STRING pFormat, PFORMAT_STRING pPointer)
 
void *WINAPI NdrAllocate (MIDL_STUB_MESSAGE *pStubMsg, SIZE_T len)
 
static voidNdrAllocateZero (MIDL_STUB_MESSAGE *stubmsg, SIZE_T len)
 
static void NdrFree (MIDL_STUB_MESSAGE *pStubMsg, unsigned char *Pointer)
 
static BOOL IsConformanceOrVariancePresent (PFORMAT_STRING pFormat)
 
static PFORMAT_STRING SkipConformance (const PMIDL_STUB_MESSAGE pStubMsg, const PFORMAT_STRING pFormat)
 
static PFORMAT_STRING ReadConformance (MIDL_STUB_MESSAGE *pStubMsg, PFORMAT_STRING pFormat)
 
static PFORMAT_STRING ReadVariance (MIDL_STUB_MESSAGE *pStubMsg, PFORMAT_STRING pFormat, ULONG MaxValue)
 
static void WriteConformance (MIDL_STUB_MESSAGE *pStubMsg)
 
static void WriteVariance (MIDL_STUB_MESSAGE *pStubMsg)
 
static void SizeConformance (MIDL_STUB_MESSAGE *pStubMsg)
 
static void SizeVariance (MIDL_STUB_MESSAGE *pStubMsg)
 
PFORMAT_STRING ComputeConformanceOrVariance (MIDL_STUB_MESSAGE *pStubMsg, unsigned char *pMemory, PFORMAT_STRING pFormat, ULONG_PTR def, ULONG_PTR *pCount)
 
static PFORMAT_STRING SkipVariance (PMIDL_STUB_MESSAGE pStubMsg, PFORMAT_STRING pFormat)
 
static ULONG safe_multiply (ULONG a, ULONG b)
 
static void safe_buffer_increment (MIDL_STUB_MESSAGE *pStubMsg, ULONG size)
 
static void safe_buffer_length_increment (MIDL_STUB_MESSAGE *pStubMsg, ULONG size)
 
static void safe_copy_from_buffer (MIDL_STUB_MESSAGE *pStubMsg, void *p, ULONG size)
 
static void safe_copy_to_buffer (MIDL_STUB_MESSAGE *pStubMsg, const void *p, ULONG size)
 
static void validate_string_data (MIDL_STUB_MESSAGE *pStubMsg, ULONG bufsize, ULONG esize)
 
static void dump_pointer_attr (unsigned char attr)
 
static void PointerMarshall (PMIDL_STUB_MESSAGE pStubMsg, unsigned char *Buffer, unsigned char *Pointer, PFORMAT_STRING pFormat)
 
static void PointerUnmarshall (PMIDL_STUB_MESSAGE pStubMsg, unsigned char *Buffer, unsigned char **pPointer, unsigned char *pSrcPointer, PFORMAT_STRING pFormat, unsigned char fMustAlloc)
 
static void PointerBufferSize (PMIDL_STUB_MESSAGE pStubMsg, unsigned char *Pointer, PFORMAT_STRING pFormat)
 
static ULONG PointerMemorySize (PMIDL_STUB_MESSAGE pStubMsg, unsigned char *Buffer, PFORMAT_STRING pFormat)
 
static void PointerFree (PMIDL_STUB_MESSAGE pStubMsg, unsigned char *Pointer, PFORMAT_STRING pFormat)
 
static unsigned charEmbeddedPointerMarshall (PMIDL_STUB_MESSAGE pStubMsg, unsigned char *pMemory, PFORMAT_STRING pFormat)
 
static unsigned charEmbeddedPointerUnmarshall (PMIDL_STUB_MESSAGE pStubMsg, unsigned char *pDstBuffer, unsigned char *pSrcMemoryPtrs, PFORMAT_STRING pFormat, unsigned char fMustAlloc)
 
static void EmbeddedPointerBufferSize (PMIDL_STUB_MESSAGE pStubMsg, unsigned char *pMemory, PFORMAT_STRING pFormat)
 
static ULONG EmbeddedPointerMemorySize (PMIDL_STUB_MESSAGE pStubMsg, PFORMAT_STRING pFormat)
 
static void EmbeddedPointerFree (PMIDL_STUB_MESSAGE pStubMsg, unsigned char *pMemory, PFORMAT_STRING pFormat)
 
unsigned char *WINAPI NdrPointerMarshall (PMIDL_STUB_MESSAGE pStubMsg, unsigned char *pMemory, PFORMAT_STRING pFormat)
 
unsigned char *WINAPI NdrPointerUnmarshall (PMIDL_STUB_MESSAGE pStubMsg, unsigned char **ppMemory, PFORMAT_STRING pFormat, unsigned char fMustAlloc)
 
void WINAPI NdrPointerBufferSize (PMIDL_STUB_MESSAGE pStubMsg, unsigned char *pMemory, PFORMAT_STRING pFormat)
 
ULONG WINAPI NdrPointerMemorySize (PMIDL_STUB_MESSAGE pStubMsg, PFORMAT_STRING pFormat)
 
void WINAPI NdrPointerFree (PMIDL_STUB_MESSAGE pStubMsg, unsigned char *pMemory, PFORMAT_STRING pFormat)
 
void WINAPI NdrSimpleTypeMarshall (PMIDL_STUB_MESSAGE pStubMsg, unsigned char *pMemory, unsigned char FormatChar)
 
void WINAPI NdrSimpleTypeUnmarshall (PMIDL_STUB_MESSAGE pStubMsg, unsigned char *pMemory, unsigned char FormatChar)
 
unsigned char *WINAPI NdrSimpleStructMarshall (PMIDL_STUB_MESSAGE pStubMsg, unsigned char *pMemory, PFORMAT_STRING pFormat)
 
unsigned char *WINAPI NdrSimpleStructUnmarshall (PMIDL_STUB_MESSAGE pStubMsg, unsigned char **ppMemory, PFORMAT_STRING pFormat, unsigned char fMustAlloc)
 
void WINAPI NdrSimpleStructBufferSize (PMIDL_STUB_MESSAGE pStubMsg, unsigned char *pMemory, PFORMAT_STRING pFormat)
 
ULONG WINAPI NdrSimpleStructMemorySize (PMIDL_STUB_MESSAGE pStubMsg, PFORMAT_STRING pFormat)
 
void WINAPI NdrSimpleStructFree (PMIDL_STUB_MESSAGE pStubMsg, unsigned char *pMemory, PFORMAT_STRING pFormat)
 
static void array_compute_and_size_conformance (unsigned char fc, PMIDL_STUB_MESSAGE pStubMsg, unsigned char *pMemory, PFORMAT_STRING pFormat)
 
static void array_buffer_size (unsigned char fc, PMIDL_STUB_MESSAGE pStubMsg, unsigned char *pMemory, PFORMAT_STRING pFormat, unsigned char fHasPointers)
 
static void array_compute_and_write_conformance (unsigned char fc, PMIDL_STUB_MESSAGE pStubMsg, unsigned char *pMemory, PFORMAT_STRING pFormat)
 
static void array_write_variance_and_marshall (unsigned char fc, PMIDL_STUB_MESSAGE pStubMsg, unsigned char *pMemory, PFORMAT_STRING pFormat, unsigned char fHasPointers)
 
static ULONG array_read_conformance (unsigned char fc, PMIDL_STUB_MESSAGE pStubMsg, PFORMAT_STRING pFormat)
 
static ULONG array_read_variance_and_unmarshall (unsigned char fc, PMIDL_STUB_MESSAGE pStubMsg, unsigned char **ppMemory, PFORMAT_STRING pFormat, unsigned char fMustAlloc, unsigned char fUseBufferMemoryServer, unsigned char fUnmarshall)
 
static void array_memory_size (unsigned char fc, PMIDL_STUB_MESSAGE pStubMsg, PFORMAT_STRING pFormat, unsigned char fHasPointers)
 
static void array_free (unsigned char fc, PMIDL_STUB_MESSAGE pStubMsg, unsigned char *pMemory, PFORMAT_STRING pFormat, unsigned char fHasPointers)
 
unsigned char *WINAPI NdrConformantStringMarshall (MIDL_STUB_MESSAGE *pStubMsg, unsigned char *pszMessage, PFORMAT_STRING pFormat)
 
void WINAPI NdrConformantStringBufferSize (PMIDL_STUB_MESSAGE pStubMsg, unsigned char *pMemory, PFORMAT_STRING pFormat)
 
ULONG WINAPI NdrConformantStringMemorySize (PMIDL_STUB_MESSAGE pStubMsg, PFORMAT_STRING pFormat)
 
unsigned char *WINAPI NdrConformantStringUnmarshall (PMIDL_STUB_MESSAGE pStubMsg, unsigned char **ppMemory, PFORMAT_STRING pFormat, unsigned char fMustAlloc)
 
unsigned char *WINAPI NdrNonConformantStringMarshall (PMIDL_STUB_MESSAGE pStubMsg, unsigned char *pMemory, PFORMAT_STRING pFormat)
 
unsigned char *WINAPI NdrNonConformantStringUnmarshall (PMIDL_STUB_MESSAGE pStubMsg, unsigned char **ppMemory, PFORMAT_STRING pFormat, unsigned char fMustAlloc)
 
void WINAPI NdrNonConformantStringBufferSize (PMIDL_STUB_MESSAGE pStubMsg, unsigned char *pMemory, PFORMAT_STRING pFormat)
 
ULONG WINAPI NdrNonConformantStringMemorySize (PMIDL_STUB_MESSAGE pStubMsg, PFORMAT_STRING pFormat)
 
static ULONG EmbeddedComplexSize (MIDL_STUB_MESSAGE *pStubMsg, PFORMAT_STRING pFormat)
 
static ULONG EmbeddedComplexMemorySize (PMIDL_STUB_MESSAGE pStubMsg, PFORMAT_STRING pFormat)
 
ULONG ComplexStructSize (PMIDL_STUB_MESSAGE pStubMsg, PFORMAT_STRING pFormat)
 
unsigned char *WINAPI NdrComplexStructMarshall (PMIDL_STUB_MESSAGE pStubMsg, unsigned char *pMemory, PFORMAT_STRING pFormat)
 
unsigned char *WINAPI NdrComplexStructUnmarshall (PMIDL_STUB_MESSAGE pStubMsg, unsigned char **ppMemory, PFORMAT_STRING pFormat, unsigned char fMustAlloc)
 
void WINAPI NdrComplexStructBufferSize (PMIDL_STUB_MESSAGE pStubMsg, unsigned char *pMemory, PFORMAT_STRING pFormat)
 
ULONG WINAPI NdrComplexStructMemorySize (PMIDL_STUB_MESSAGE pStubMsg, PFORMAT_STRING pFormat)
 
void WINAPI NdrComplexStructFree (PMIDL_STUB_MESSAGE pStubMsg, unsigned char *pMemory, PFORMAT_STRING pFormat)
 
unsigned char *WINAPI NdrConformantArrayMarshall (PMIDL_STUB_MESSAGE pStubMsg, unsigned char *pMemory, PFORMAT_STRING pFormat)
 
unsigned char *WINAPI NdrConformantArrayUnmarshall (PMIDL_STUB_MESSAGE pStubMsg, unsigned char **ppMemory, PFORMAT_STRING pFormat, unsigned char fMustAlloc)
 
void WINAPI NdrConformantArrayBufferSize (PMIDL_STUB_MESSAGE pStubMsg, unsigned char *pMemory, PFORMAT_STRING pFormat)
 
ULONG WINAPI NdrConformantArrayMemorySize (PMIDL_STUB_MESSAGE pStubMsg, PFORMAT_STRING pFormat)
 
void WINAPI NdrConformantArrayFree (PMIDL_STUB_MESSAGE pStubMsg, unsigned char *pMemory, PFORMAT_STRING pFormat)
 
unsigned char *WINAPI NdrConformantVaryingArrayMarshall (PMIDL_STUB_MESSAGE pStubMsg, unsigned char *pMemory, PFORMAT_STRING pFormat)
 
unsigned char *WINAPI NdrConformantVaryingArrayUnmarshall (PMIDL_STUB_MESSAGE pStubMsg, unsigned char **ppMemory, PFORMAT_STRING pFormat, unsigned char fMustAlloc)
 
void WINAPI NdrConformantVaryingArrayFree (PMIDL_STUB_MESSAGE pStubMsg, unsigned char *pMemory, PFORMAT_STRING pFormat)
 
void WINAPI NdrConformantVaryingArrayBufferSize (PMIDL_STUB_MESSAGE pStubMsg, unsigned char *pMemory, PFORMAT_STRING pFormat)
 
ULONG WINAPI NdrConformantVaryingArrayMemorySize (PMIDL_STUB_MESSAGE pStubMsg, PFORMAT_STRING pFormat)
 
unsigned char *WINAPI NdrComplexArrayMarshall (PMIDL_STUB_MESSAGE pStubMsg, unsigned char *pMemory, PFORMAT_STRING pFormat)
 
unsigned char *WINAPI NdrComplexArrayUnmarshall (PMIDL_STUB_MESSAGE pStubMsg, unsigned char **ppMemory, PFORMAT_STRING pFormat, unsigned char fMustAlloc)
 
void WINAPI NdrComplexArrayBufferSize (PMIDL_STUB_MESSAGE pStubMsg, unsigned char *pMemory, PFORMAT_STRING pFormat)
 
ULONG WINAPI NdrComplexArrayMemorySize (PMIDL_STUB_MESSAGE pStubMsg, PFORMAT_STRING pFormat)
 
void WINAPI NdrComplexArrayFree (PMIDL_STUB_MESSAGE pStubMsg, unsigned char *pMemory, PFORMAT_STRING pFormat)
 
static void UserMarshalCB (PMIDL_STUB_MESSAGE pStubMsg, USER_MARSHAL_CB_TYPE cbtype, PFORMAT_STRING pFormat, USER_MARSHAL_CB *umcb)
 
unsigned char *WINAPI NdrUserMarshalMarshall (PMIDL_STUB_MESSAGE pStubMsg, unsigned char *pMemory, PFORMAT_STRING pFormat)
 
unsigned char *WINAPI NdrUserMarshalUnmarshall (PMIDL_STUB_MESSAGE pStubMsg, unsigned char **ppMemory, PFORMAT_STRING pFormat, unsigned char fMustAlloc)
 
void WINAPI NdrUserMarshalBufferSize (PMIDL_STUB_MESSAGE pStubMsg, unsigned char *pMemory, PFORMAT_STRING pFormat)
 
ULONG WINAPI NdrUserMarshalMemorySize (PMIDL_STUB_MESSAGE pStubMsg, PFORMAT_STRING pFormat)
 
void WINAPI NdrUserMarshalFree (PMIDL_STUB_MESSAGE pStubMsg, unsigned char *pMemory, PFORMAT_STRING pFormat)
 
RPC_STATUS RPC_ENTRY NdrGetUserMarshalInfo (ULONG *flags, ULONG level, NDR_USER_MARSHAL_INFO *umi)
 
void WINAPI NdrClearOutParameters (PMIDL_STUB_MESSAGE pStubMsg, PFORMAT_STRING pFormat, void *ArgAddr)
 
void WINAPI NdrConvert (PMIDL_STUB_MESSAGE pStubMsg, PFORMAT_STRING pFormat)
 
void WINAPI NdrConvert2 (PMIDL_STUB_MESSAGE pStubMsg, PFORMAT_STRING pFormat, LONG NumberParams)
 
unsigned char *WINAPI NdrConformantStructMarshall (PMIDL_STUB_MESSAGE pStubMsg, unsigned char *pMemory, PFORMAT_STRING pFormat)
 
unsigned char *WINAPI NdrConformantStructUnmarshall (PMIDL_STUB_MESSAGE pStubMsg, unsigned char **ppMemory, PFORMAT_STRING pFormat, unsigned char fMustAlloc)
 
void WINAPI NdrConformantStructBufferSize (PMIDL_STUB_MESSAGE pStubMsg, unsigned char *pMemory, PFORMAT_STRING pFormat)
 
ULONG WINAPI NdrConformantStructMemorySize (PMIDL_STUB_MESSAGE pStubMsg, PFORMAT_STRING pFormat)
 
void WINAPI NdrConformantStructFree (PMIDL_STUB_MESSAGE pStubMsg, unsigned char *pMemory, PFORMAT_STRING pFormat)
 
unsigned char *WINAPI NdrConformantVaryingStructMarshall (PMIDL_STUB_MESSAGE pStubMsg, unsigned char *pMemory, PFORMAT_STRING pFormat)
 
unsigned char *WINAPI NdrConformantVaryingStructUnmarshall (PMIDL_STUB_MESSAGE pStubMsg, unsigned char **ppMemory, PFORMAT_STRING pFormat, unsigned char fMustAlloc)
 
void WINAPI NdrConformantVaryingStructBufferSize (PMIDL_STUB_MESSAGE pStubMsg, unsigned char *pMemory, PFORMAT_STRING pFormat)
 
ULONG WINAPI NdrConformantVaryingStructMemorySize (PMIDL_STUB_MESSAGE pStubMsg, PFORMAT_STRING pFormat)
 
void WINAPI NdrConformantVaryingStructFree (PMIDL_STUB_MESSAGE pStubMsg, unsigned char *pMemory, PFORMAT_STRING pFormat)
 
unsigned char *WINAPI NdrFixedArrayMarshall (PMIDL_STUB_MESSAGE pStubMsg, unsigned char *pMemory, PFORMAT_STRING pFormat)
 
unsigned char *WINAPI NdrFixedArrayUnmarshall (PMIDL_STUB_MESSAGE pStubMsg, unsigned char **ppMemory, PFORMAT_STRING pFormat, unsigned char fMustAlloc)
 
void WINAPI NdrFixedArrayBufferSize (PMIDL_STUB_MESSAGE pStubMsg, unsigned char *pMemory, PFORMAT_STRING pFormat)
 
ULONG WINAPI NdrFixedArrayMemorySize (PMIDL_STUB_MESSAGE pStubMsg, PFORMAT_STRING pFormat)
 
void WINAPI NdrFixedArrayFree (PMIDL_STUB_MESSAGE pStubMsg, unsigned char *pMemory, PFORMAT_STRING pFormat)
 
unsigned char *WINAPI NdrVaryingArrayMarshall (PMIDL_STUB_MESSAGE pStubMsg, unsigned char *pMemory, PFORMAT_STRING pFormat)
 
unsigned char *WINAPI NdrVaryingArrayUnmarshall (PMIDL_STUB_MESSAGE pStubMsg, unsigned char **ppMemory, PFORMAT_STRING pFormat, unsigned char fMustAlloc)
 
void WINAPI NdrVaryingArrayBufferSize (PMIDL_STUB_MESSAGE pStubMsg, unsigned char *pMemory, PFORMAT_STRING pFormat)
 
ULONG WINAPI NdrVaryingArrayMemorySize (PMIDL_STUB_MESSAGE pStubMsg, PFORMAT_STRING pFormat)
 
void WINAPI NdrVaryingArrayFree (PMIDL_STUB_MESSAGE pStubMsg, unsigned char *pMemory, PFORMAT_STRING pFormat)
 
static ULONG get_discriminant (unsigned char fc, const unsigned char *pMemory)
 
static PFORMAT_STRING get_arm_offset_from_union_arm_selector (PMIDL_STUB_MESSAGE pStubMsg, ULONG discriminant, PFORMAT_STRING pFormat)
 
static unsigned charunion_arm_marshall (PMIDL_STUB_MESSAGE pStubMsg, unsigned char *pMemory, ULONG discriminant, PFORMAT_STRING pFormat)
 
static unsigned charunion_arm_unmarshall (PMIDL_STUB_MESSAGE pStubMsg, unsigned char **ppMemory, ULONG discriminant, PFORMAT_STRING pFormat, unsigned char fMustAlloc)
 
static void union_arm_buffer_size (PMIDL_STUB_MESSAGE pStubMsg, unsigned char *pMemory, ULONG discriminant, PFORMAT_STRING pFormat)
 
static ULONG union_arm_memory_size (PMIDL_STUB_MESSAGE pStubMsg, ULONG discriminant, PFORMAT_STRING pFormat)
 
static void union_arm_free (PMIDL_STUB_MESSAGE pStubMsg, unsigned char *pMemory, ULONG discriminant, PFORMAT_STRING pFormat)
 
unsigned char *WINAPI NdrEncapsulatedUnionMarshall (PMIDL_STUB_MESSAGE pStubMsg, unsigned char *pMemory, PFORMAT_STRING pFormat)
 
unsigned char *WINAPI NdrEncapsulatedUnionUnmarshall (PMIDL_STUB_MESSAGE pStubMsg, unsigned char **ppMemory, PFORMAT_STRING pFormat, unsigned char fMustAlloc)
 
void WINAPI NdrEncapsulatedUnionBufferSize (PMIDL_STUB_MESSAGE pStubMsg, unsigned char *pMemory, PFORMAT_STRING pFormat)
 
ULONG WINAPI NdrEncapsulatedUnionMemorySize (PMIDL_STUB_MESSAGE pStubMsg, PFORMAT_STRING pFormat)
 
void WINAPI NdrEncapsulatedUnionFree (PMIDL_STUB_MESSAGE pStubMsg, unsigned char *pMemory, PFORMAT_STRING pFormat)
 
unsigned char *WINAPI NdrNonEncapsulatedUnionMarshall (PMIDL_STUB_MESSAGE pStubMsg, unsigned char *pMemory, PFORMAT_STRING pFormat)
 
static LONG unmarshall_discriminant (PMIDL_STUB_MESSAGE pStubMsg, PFORMAT_STRING *ppFormat)
 
unsigned char *WINAPI NdrNonEncapsulatedUnionUnmarshall (PMIDL_STUB_MESSAGE pStubMsg, unsigned char **ppMemory, PFORMAT_STRING pFormat, unsigned char fMustAlloc)
 
void WINAPI NdrNonEncapsulatedUnionBufferSize (PMIDL_STUB_MESSAGE pStubMsg, unsigned char *pMemory, PFORMAT_STRING pFormat)
 
ULONG WINAPI NdrNonEncapsulatedUnionMemorySize (PMIDL_STUB_MESSAGE pStubMsg, PFORMAT_STRING pFormat)
 
void WINAPI NdrNonEncapsulatedUnionFree (PMIDL_STUB_MESSAGE pStubMsg, unsigned char *pMemory, PFORMAT_STRING pFormat)
 
unsigned char *WINAPI NdrByteCountPointerMarshall (PMIDL_STUB_MESSAGE pStubMsg, unsigned char *pMemory, PFORMAT_STRING pFormat)
 
unsigned char *WINAPI NdrByteCountPointerUnmarshall (PMIDL_STUB_MESSAGE pStubMsg, unsigned char **ppMemory, PFORMAT_STRING pFormat, unsigned char fMustAlloc)
 
void WINAPI NdrByteCountPointerBufferSize (PMIDL_STUB_MESSAGE pStubMsg, unsigned char *pMemory, PFORMAT_STRING pFormat)
 
void WINAPI NdrByteCountPointerFree (PMIDL_STUB_MESSAGE pStubMsg, unsigned char *pMemory, PFORMAT_STRING pFormat)
 
unsigned char *WINAPI NdrXmitOrRepAsMarshall (PMIDL_STUB_MESSAGE pStubMsg, unsigned char *pMemory, PFORMAT_STRING pFormat)
 
unsigned char *WINAPI NdrXmitOrRepAsUnmarshall (PMIDL_STUB_MESSAGE pStubMsg, unsigned char **ppMemory, PFORMAT_STRING pFormat, unsigned char fMustAlloc)
 
void WINAPI NdrXmitOrRepAsBufferSize (PMIDL_STUB_MESSAGE pStubMsg, unsigned char *pMemory, PFORMAT_STRING pFormat)
 
ULONG WINAPI NdrXmitOrRepAsMemorySize (PMIDL_STUB_MESSAGE pStubMsg, PFORMAT_STRING pFormat)
 
void WINAPI NdrXmitOrRepAsFree (PMIDL_STUB_MESSAGE pStubMsg, unsigned char *pMemory, PFORMAT_STRING pFormat)
 
unsigned char *WINAPI NdrRangeUnmarshall (PMIDL_STUB_MESSAGE pStubMsg, unsigned char **ppMemory, PFORMAT_STRING pFormat, unsigned char fMustAlloc)
 
void WINAPI NdrClientContextMarshall (PMIDL_STUB_MESSAGE pStubMsg, NDR_CCONTEXT ContextHandle, int fCheck)
 
void WINAPI NdrClientContextUnmarshall (PMIDL_STUB_MESSAGE pStubMsg, NDR_CCONTEXT *pContextHandle, RPC_BINDING_HANDLE BindHandle)
 
void WINAPI NdrServerContextMarshall (PMIDL_STUB_MESSAGE pStubMsg, NDR_SCONTEXT ContextHandle, NDR_RUNDOWN RundownRoutine)
 
NDR_SCONTEXT WINAPI NdrServerContextUnmarshall (PMIDL_STUB_MESSAGE pStubMsg)
 
void WINAPI NdrContextHandleSize (PMIDL_STUB_MESSAGE pStubMsg, unsigned char *pMemory, PFORMAT_STRING pFormat)
 
NDR_SCONTEXT WINAPI NdrContextHandleInitialize (PMIDL_STUB_MESSAGE pStubMsg, PFORMAT_STRING pFormat)
 
void WINAPI NdrServerContextNewMarshall (PMIDL_STUB_MESSAGE pStubMsg, NDR_SCONTEXT ContextHandle, NDR_RUNDOWN RundownRoutine, PFORMAT_STRING pFormat)
 
NDR_SCONTEXT WINAPI NdrServerContextNewUnmarshall (PMIDL_STUB_MESSAGE pStubMsg, PFORMAT_STRING pFormat)
 
void WINAPI NdrCorrelationInitialize (PMIDL_STUB_MESSAGE pStubMsg, void *pMemory, ULONG CacheSize, ULONG Flags)
 
void WINAPI NdrCorrelationPass (PMIDL_STUB_MESSAGE pStubMsg)
 
void WINAPI NdrCorrelationFree (PMIDL_STUB_MESSAGE pStubMsg)
 

Variables

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

Macro Definition Documentation

◆ BASE_TYPE_UNMARSHALL [1/2]

#define BASE_TYPE_UNMARSHALL (   type)
Value:
align_pointer(&pStubMsg->Buffer, sizeof(type)); \
TRACE("pMemory: %p\n", pMemory); \
*(type *)pMemory = *(type *)pStubMsg->Buffer; \
pStubMsg->Buffer += sizeof(type);
static void align_pointer(unsigned char **ptr, unsigned int align)
Definition: ndr_marshall.c:97
FxMemoryObject * pMemory
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545

◆ BASE_TYPE_UNMARSHALL [2/2]

#define BASE_TYPE_UNMARSHALL (   type)
Value:
do { \
align_pointer(&pStubMsg->Buffer, sizeof(type)); \
if (!fMustAlloc && !pStubMsg->IsClient && !*ppMemory) \
{ \
*ppMemory = pStubMsg->Buffer; \
TRACE("*ppMemory: %p\n", *ppMemory); \
safe_buffer_increment(pStubMsg, sizeof(type)); \
} \
else \
{ \
if (fMustAlloc) \
*ppMemory = NdrAllocate(pStubMsg, sizeof(type)); \
TRACE("*ppMemory: %p\n", *ppMemory); \
safe_copy_from_buffer(pStubMsg, *ppMemory, sizeof(type)); \
} \
} while (0)
void *WINAPI NdrAllocate(MIDL_STUB_MESSAGE *pStubMsg, SIZE_T len)
Definition: ndr_marshall.c:419

◆ BIG_ENDIAN_UINT32_READ

#define BIG_ENDIAN_UINT32_READ (   pchar)
Value:
MAKEWORD(*((pchar)+3), *((pchar)+2)), \
MAKEWORD(*((pchar)+1), *(pchar))))
#define MAKEWORD(a, b)
Definition: typedefs.h:248
#define MAKELONG(a, b)
Definition: typedefs.h:249

Definition at line 75 of file ndr_marshall.c.

◆ BIG_ENDIAN_UINT32_WRITE

#define BIG_ENDIAN_UINT32_WRITE (   pchar,
  uint32 
)
Value:
(*((pchar)+3) = LOBYTE(LOWORD(uint32)), \
*((pchar)+2) = HIBYTE(LOWORD(uint32)), \
*((pchar)+1) = LOBYTE(HIWORD(uint32)), \
*(pchar) = HIBYTE(HIWORD(uint32)))
unsigned int uint32
Definition: types.h:32
#define LOBYTE(W)
Definition: jmemdos.c:487
#define HIBYTE(W)
Definition: jmemdos.c:486
#define LOWORD(l)
Definition: pedump.c:82
#define HIWORD(l)
Definition: typedefs.h:247

Definition at line 69 of file ndr_marshall.c.

◆ LITTLE_ENDIAN_UINT32_READ

#define LITTLE_ENDIAN_UINT32_READ (   pchar)
Value:
MAKEWORD(*(pchar), *((pchar)+1)), \
MAKEWORD(*((pchar)+2), *((pchar)+3))))

Definition at line 63 of file ndr_marshall.c.

◆ LITTLE_ENDIAN_UINT32_WRITE

#define LITTLE_ENDIAN_UINT32_WRITE (   pchar,
  uint32 
)
Value:
(*(pchar) = LOBYTE(LOWORD(uint32)), \
*((pchar)+1) = HIBYTE(LOWORD(uint32)), \
*((pchar)+2) = LOBYTE(HIWORD(uint32)), \
*((pchar)+3) = HIBYTE(HIWORD(uint32)))

Definition at line 57 of file ndr_marshall.c.

◆ MEML_MAGIC

#define MEML_MAGIC   ('M' << 24 | 'E' << 16 | 'M' << 8 | 'L')

Definition at line 400 of file ndr_marshall.c.

◆ NDR_LOCAL_UINT32_READ

#define NDR_LOCAL_UINT32_READ (   pchar)     LITTLE_ENDIAN_UINT32_READ(pchar)

Definition at line 88 of file ndr_marshall.c.

◆ NDR_LOCAL_UINT32_WRITE

#define NDR_LOCAL_UINT32_WRITE (   pchar,
  uint32 
)     LITTLE_ENDIAN_UINT32_WRITE(pchar, uint32)

Definition at line 86 of file ndr_marshall.c.

◆ NDR_POINTER_ID

#define NDR_POINTER_ID (   pStubMsg)    (NDR_POINTER_ID_BASE + ((pStubMsg)->UniquePtrCount++) * 4)

Definition at line 130 of file ndr_marshall.c.

◆ NDR_POINTER_ID_BASE

#define NDR_POINTER_ID_BASE   0x20000

Definition at line 129 of file ndr_marshall.c.

◆ NDR_TABLE_MASK

#define NDR_TABLE_MASK   127

Definition at line 132 of file ndr_marshall.c.

◆ NDR_TABLE_SIZE

#define NDR_TABLE_SIZE   128

Definition at line 131 of file ndr_marshall.c.

◆ NONAMELESSUNION

#define NONAMELESSUNION

Definition at line 36 of file ndr_marshall.c.

◆ RANGE_UNMARSHALL

#define RANGE_UNMARSHALL (   mem_type,
  wire_type,
  format_spec 
)
Value:
do \
{ \
align_pointer(&pStubMsg->Buffer, sizeof(wire_type)); \
if (!fMustAlloc && !*ppMemory) \
fMustAlloc = TRUE; \
if (fMustAlloc) \
*ppMemory = NdrAllocate(pStubMsg, sizeof(mem_type)); \
if (pStubMsg->Buffer + sizeof(wire_type) > pStubMsg->BufferEnd) \
{ \
ERR("buffer overflow - Buffer = %p, BufferEnd = %p\n", \
pStubMsg->Buffer, (unsigned char *)pStubMsg->RpcMsg->Buffer + pStubMsg->BufferLength); \
RpcRaiseException(RPC_X_BAD_STUB_DATA); \
} \
if ((*(wire_type *)pStubMsg->Buffer < (mem_type)pRange->low_value) || \
(*(wire_type *)pStubMsg->Buffer > (mem_type)pRange->high_value)) \
{ \
ERR("value exceeded bounds: " format_spec ", low: " format_spec ", high: " format_spec "\n", \
*(wire_type *)pStubMsg->Buffer, (mem_type)pRange->low_value, \
(mem_type)pRange->high_value); \
RpcRaiseException(RPC_S_INVALID_BOUND); \
return NULL; \
} \
TRACE("*ppMemory: %p\n", *ppMemory); \
**(mem_type **)ppMemory = *(wire_type *)pStubMsg->Buffer; \
pStubMsg->Buffer += sizeof(wire_type); \
} while (0)
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define RPC_S_INVALID_BOUND
Definition: winerror.h:1043
#define RPC_X_BAD_STUB_DATA
Definition: winerror.h:1090

◆ STD_OVERFLOW_CHECK

#define STD_OVERFLOW_CHECK (   _Msg)
Value:
do { \
TRACE("buffer=%d/%d\n", (ULONG)(_Msg->Buffer - (unsigned char *)_Msg->RpcMsg->Buffer), _Msg->BufferLength); \
if (_Msg->Buffer > (unsigned char *)_Msg->RpcMsg->Buffer + _Msg->BufferLength) \
ERR("buffer overflow %d bytes\n", (ULONG)(_Msg->Buffer - ((unsigned char *)_Msg->RpcMsg->Buffer + _Msg->BufferLength))); \
} while (0)
uint32_t ULONG
Definition: typedefs.h:59

Definition at line 123 of file ndr_marshall.c.

◆ USER_MARSHAL_PTR_PREFIX

#define USER_MARSHAL_PTR_PREFIX
Value:
( (DWORD)'U' | ( (DWORD)'s' << 8 ) | \
( (DWORD)'e' << 16 ) | ( (DWORD)'r' << 24 ) )
unsigned long DWORD
Definition: ntddk_ex.h:95
#define DWORD
Definition: nt_native.h:44

Definition at line 4389 of file ndr_marshall.c.

Typedef Documentation

◆ NDR_CSTRUCT_FORMAT

◆ NDR_CVSTRUCT_FORMAT

◆ NDR_MEMORY_LIST

Function Documentation

◆ align_length()

◆ align_pointer()

◆ align_pointer_clear()

◆ align_pointer_offset()

static void align_pointer_offset ( unsigned char **  ptr,
unsigned char base,
unsigned int  align 
)
inlinestatic

Definition at line 110 of file ndr_marshall.c.

111{
112 ULONG_PTR mask = align - 1;
113 *ptr = base + (((ULONG_PTR)(*ptr - base) + mask) & ~mask);
114}
#define ULONG_PTR
Definition: config.h:101

Referenced by ComplexBufferSize(), ComplexFree(), and ComplexMarshall().

◆ align_pointer_offset_clear()

static void align_pointer_offset_clear ( unsigned char **  ptr,
unsigned char base,
unsigned int  align 
)
inlinestatic

Definition at line 116 of file ndr_marshall.c.

117{
118 ULONG_PTR mask = align - 1;
119 memset( *ptr, 0, (align - (ULONG_PTR)(*ptr - base)) & mask );
120 *ptr = base + (((ULONG_PTR)(*ptr - base) + mask) & ~mask);
121}

Referenced by ComplexUnmarshall().

◆ array_buffer_size()

static void array_buffer_size ( unsigned char  fc,
PMIDL_STUB_MESSAGE  pStubMsg,
unsigned char pMemory,
PFORMAT_STRING  pFormat,
unsigned char  fHasPointers 
)
inlinestatic

Definition at line 1896 of file ndr_marshall.c.

1899{
1900 DWORD i, size;
1901 DWORD esize;
1902 unsigned char alignment;
1903
1904 switch (fc)
1905 {
1906 case FC_CARRAY:
1907 esize = *(const WORD*)(pFormat+2);
1908 alignment = pFormat[1] + 1;
1909
1910 pFormat = SkipConformance(pStubMsg, pFormat + 4);
1911
1912 align_length(&pStubMsg->BufferLength, alignment);
1913
1914 size = safe_multiply(esize, pStubMsg->MaxCount);
1915 /* conformance value plus array */
1917
1918 if (fHasPointers)
1919 EmbeddedPointerBufferSize(pStubMsg, pMemory, pFormat);
1920 break;
1921 case FC_CVARRAY:
1922 esize = *(const WORD*)(pFormat+2);
1923 alignment = pFormat[1] + 1;
1924
1925 pFormat = SkipConformance(pStubMsg, pFormat + 4);
1926 pFormat = SkipVariance(pStubMsg, pFormat);
1927
1928 SizeVariance(pStubMsg);
1929
1930 align_length(&pStubMsg->BufferLength, alignment);
1931
1932 size = safe_multiply(esize, pStubMsg->ActualCount);
1934
1935 if (fHasPointers)
1936 EmbeddedPointerBufferSize(pStubMsg, pMemory, pFormat);
1937 break;
1938 case FC_C_CSTRING:
1939 case FC_C_WSTRING:
1940 if (fc == FC_C_CSTRING)
1941 esize = 1;
1942 else
1943 esize = 2;
1944
1945 SizeVariance(pStubMsg);
1946
1947 size = safe_multiply(esize, pStubMsg->ActualCount);
1949 break;
1950 case FC_BOGUS_ARRAY:
1951 alignment = pFormat[1] + 1;
1952 pFormat = SkipConformance(pStubMsg, pFormat + 4);
1953 if (IsConformanceOrVariancePresent(pFormat)) SizeVariance(pStubMsg);
1954 pFormat = SkipVariance(pStubMsg, pFormat);
1955
1956 align_length(&pStubMsg->BufferLength, alignment);
1957
1958 size = pStubMsg->ActualCount;
1959 for (i = 0; i < size; i++)
1960 pMemory = ComplexBufferSize(pStubMsg, pMemory, pFormat, NULL);
1961 break;
1962 default:
1963 ERR("unknown array format 0x%x\n", fc);
1965 }
1966}
#define ERR(fmt,...)
Definition: precomp.h:57
PFOR_CONTEXT fc
Definition: for.c:57
static ULONG safe_multiply(ULONG a, ULONG b)
Definition: ndr_marshall.c:702
static void EmbeddedPointerBufferSize(PMIDL_STUB_MESSAGE pStubMsg, unsigned char *pMemory, PFORMAT_STRING pFormat)
static BOOL IsConformanceOrVariancePresent(PFORMAT_STRING pFormat)
Definition: ndr_marshall.c:463
static void SizeVariance(MIDL_STUB_MESSAGE *pStubMsg)
Definition: ndr_marshall.c:548
static PFORMAT_STRING SkipConformance(const PMIDL_STUB_MESSAGE pStubMsg, const PFORMAT_STRING pFormat)
Definition: ndr_marshall.c:468
static unsigned char * ComplexBufferSize(PMIDL_STUB_MESSAGE pStubMsg, unsigned char *pMemory, PFORMAT_STRING pFormat, PFORMAT_STRING pPointer)
static void align_length(ULONG *len, unsigned int align)
Definition: ndr_marshall.c:92
static PFORMAT_STRING SkipVariance(PMIDL_STUB_MESSAGE pStubMsg, PFORMAT_STRING pFormat)
Definition: ndr_marshall.c:695
static void safe_buffer_length_increment(MIDL_STUB_MESSAGE *pStubMsg, ULONG size)
Definition: ndr_marshall.c:721
unsigned short WORD
Definition: ntddk_ex.h:93
GLsizeiptr size
Definition: glext.h:5919
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
@ FC_C_CSTRING
Definition: ndrtypes.h:172
@ FC_C_WSTRING
Definition: ndrtypes.h:175
@ FC_BOGUS_ARRAY
Definition: ndrtypes.h:170
@ FC_CARRAY
Definition: ndrtypes.h:164
@ FC_CVARRAY
Definition: ndrtypes.h:165
void DECLSPEC_NORETURN WINAPI RpcRaiseException(RPC_STATUS exception)
Definition: rpcrt4_main.c:188
ULONG BufferLength
Definition: rpcndr.h:207
ULONG ActualCount
Definition: rpcndr.h:223
ULONG_PTR MaxCount
Definition: rpcndr.h:221

Referenced by NdrComplexArrayBufferSize(), NdrComplexStructBufferSize(), NdrConformantArrayBufferSize(), NdrConformantStringBufferSize(), NdrConformantVaryingArrayBufferSize(), and NdrConformantVaryingStructBufferSize().

◆ array_compute_and_size_conformance()

static void array_compute_and_size_conformance ( unsigned char  fc,
PMIDL_STUB_MESSAGE  pStubMsg,
unsigned char pMemory,
PFORMAT_STRING  pFormat 
)
inlinestatic

Definition at line 1846 of file ndr_marshall.c.

1849{
1850 DWORD count;
1851
1852 switch (fc)
1853 {
1854 case FC_CARRAY:
1855 ComputeConformance(pStubMsg, pMemory, pFormat+4, 0);
1856 SizeConformance(pStubMsg);
1857 break;
1858 case FC_CVARRAY:
1859 pFormat = ComputeConformance(pStubMsg, pMemory, pFormat + 4, 0);
1860 pFormat = ComputeVariance(pStubMsg, pMemory, pFormat, 0);
1861 SizeConformance(pStubMsg);
1862 break;
1863 case FC_C_CSTRING:
1864 case FC_C_WSTRING:
1865 if (fc == FC_C_CSTRING)
1866 {
1867 TRACE("string=%s\n", debugstr_a((const char *)pMemory));
1868 pStubMsg->ActualCount = strlen((const char *)pMemory)+1;
1869 }
1870 else
1871 {
1872 TRACE("string=%s\n", debugstr_w((LPCWSTR)pMemory));
1873 pStubMsg->ActualCount = lstrlenW((LPCWSTR)pMemory)+1;
1874 }
1875
1876 if (pFormat[1] == FC_STRING_SIZED)
1877 pFormat = ComputeConformance(pStubMsg, pMemory, pFormat + 2, 0);
1878 else
1879 pStubMsg->MaxCount = pStubMsg->ActualCount;
1880
1881 SizeConformance(pStubMsg);
1882 break;
1883 case FC_BOGUS_ARRAY:
1884 count = *(const WORD *)(pFormat + 2);
1885 pFormat += 4;
1886 if (IsConformanceOrVariancePresent(pFormat)) SizeConformance(pStubMsg);
1887 pFormat = ComputeConformance(pStubMsg, pMemory, pFormat, count);
1888 pFormat = ComputeVariance(pStubMsg, pMemory, pFormat, pStubMsg->MaxCount);
1889 break;
1890 default:
1891 ERR("unknown array format 0x%x\n", fc);
1893 }
1894}
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
#define lstrlenW
Definition: compat.h:750
static void SizeConformance(MIDL_STUB_MESSAGE *pStubMsg)
Definition: ndr_marshall.c:539
GLuint GLuint GLsizei count
Definition: gl.h:1545
#define debugstr_a
Definition: kernel32.h:31
#define debugstr_w
Definition: kernel32.h:32
static PFORMAT_STRING ComputeConformance(PMIDL_STUB_MESSAGE pStubMsg, unsigned char *pMemory, PFORMAT_STRING pFormat, ULONG def)
Definition: ndr_misc.h:37
static PFORMAT_STRING ComputeVariance(PMIDL_STUB_MESSAGE pStubMsg, unsigned char *pMemory, PFORMAT_STRING pFormat, ULONG def)
Definition: ndr_misc.h:42
@ FC_STRING_SIZED
Definition: ndrtypes.h:218
#define TRACE(s)
Definition: solgame.cpp:4
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185

Referenced by NdrComplexArrayBufferSize(), NdrComplexStructBufferSize(), NdrConformantArrayBufferSize(), NdrConformantStringBufferSize(), NdrConformantVaryingArrayBufferSize(), and NdrConformantVaryingStructBufferSize().

◆ array_compute_and_write_conformance()

static void array_compute_and_write_conformance ( unsigned char  fc,
PMIDL_STUB_MESSAGE  pStubMsg,
unsigned char pMemory,
PFORMAT_STRING  pFormat 
)
inlinestatic

Definition at line 1968 of file ndr_marshall.c.

1971{
1972 ULONG def;
1973 BOOL conformance_present;
1974
1975 switch (fc)
1976 {
1977 case FC_CARRAY:
1978 ComputeConformance(pStubMsg, pMemory, pFormat+4, 0);
1979 WriteConformance(pStubMsg);
1980 break;
1981 case FC_CVARRAY:
1982 pFormat = ComputeConformance(pStubMsg, pMemory, pFormat + 4, 0);
1983 pFormat = ComputeVariance(pStubMsg, pMemory, pFormat, 0);
1984 WriteConformance(pStubMsg);
1985 break;
1986 case FC_C_CSTRING:
1987 case FC_C_WSTRING:
1988 if (fc == FC_C_CSTRING)
1989 {
1990 TRACE("string=%s\n", debugstr_a((const char *)pMemory));
1991 pStubMsg->ActualCount = strlen((const char *)pMemory)+1;
1992 }
1993 else
1994 {
1995 TRACE("string=%s\n", debugstr_w((LPCWSTR)pMemory));
1996 pStubMsg->ActualCount = lstrlenW((LPCWSTR)pMemory)+1;
1997 }
1998 if (pFormat[1] == FC_STRING_SIZED)
1999 pFormat = ComputeConformance(pStubMsg, pMemory, pFormat + 2, 0);
2000 else
2001 pStubMsg->MaxCount = pStubMsg->ActualCount;
2002 pStubMsg->Offset = 0;
2003 WriteConformance(pStubMsg);
2004 break;
2005 case FC_BOGUS_ARRAY:
2006 def = *(const WORD *)(pFormat + 2);
2007 pFormat += 4;
2008 conformance_present = IsConformanceOrVariancePresent(pFormat);
2009 pFormat = ComputeConformance(pStubMsg, pMemory, pFormat, def);
2010 pFormat = ComputeVariance(pStubMsg, pMemory, pFormat, pStubMsg->MaxCount);
2011 if (conformance_present) WriteConformance(pStubMsg);
2012 break;
2013 default:
2014 ERR("unknown array format 0x%x\n", fc);
2016 }
2017}
static void WriteConformance(MIDL_STUB_MESSAGE *pStubMsg)
Definition: ndr_marshall.c:517
unsigned int BOOL
Definition: ntddk_ex.h:94

Referenced by NdrComplexArrayMarshall(), NdrComplexStructMarshall(), NdrConformantArrayMarshall(), NdrConformantStringMarshall(), NdrConformantVaryingArrayMarshall(), and NdrConformantVaryingStructMarshall().

◆ array_free()

static void array_free ( unsigned char  fc,
PMIDL_STUB_MESSAGE  pStubMsg,
unsigned char pMemory,
PFORMAT_STRING  pFormat,
unsigned char  fHasPointers 
)
inlinestatic

Definition at line 2401 of file ndr_marshall.c.

2404{
2405 DWORD i, count;
2406
2407 switch (fc)
2408 {
2409 case FC_CARRAY:
2410 pFormat = ComputeConformance(pStubMsg, pMemory, pFormat+4, 0);
2411 if (fHasPointers)
2412 EmbeddedPointerFree(pStubMsg, pMemory, pFormat);
2413 break;
2414 case FC_CVARRAY:
2415 pFormat = ComputeConformance(pStubMsg, pMemory, pFormat+4, 0);
2416 pFormat = ComputeVariance(pStubMsg, pMemory, pFormat, 0);
2417 if (fHasPointers)
2418 EmbeddedPointerFree(pStubMsg, pMemory, pFormat);
2419 break;
2420 case FC_C_CSTRING:
2421 case FC_C_WSTRING:
2422 /* No embedded pointers so nothing to do */
2423 break;
2424 case FC_BOGUS_ARRAY:
2425 count = *(const WORD *)(pFormat + 2);
2426 pFormat = ComputeConformance(pStubMsg, pMemory, pFormat + 4, count);
2427 pFormat = ComputeVariance(pStubMsg, pMemory, pFormat, pStubMsg->MaxCount);
2428
2429 count = pStubMsg->ActualCount;
2430 for (i = 0; i < count; i++)
2431 pMemory = ComplexFree(pStubMsg, pMemory, pFormat, NULL);
2432 break;
2433 default:
2434 ERR("unknown array format 0x%x\n", fc);
2436 }
2437}
static unsigned char * ComplexFree(PMIDL_STUB_MESSAGE pStubMsg, unsigned char *pMemory, PFORMAT_STRING pFormat, PFORMAT_STRING pPointer)
static void EmbeddedPointerFree(PMIDL_STUB_MESSAGE pStubMsg, unsigned char *pMemory, PFORMAT_STRING pFormat)

Referenced by NdrComplexStructFree(), NdrConformantArrayFree(), NdrConformantVaryingArrayFree(), and NdrConformantVaryingStructFree().

◆ array_memory_size()

static void array_memory_size ( unsigned char  fc,
PMIDL_STUB_MESSAGE  pStubMsg,
PFORMAT_STRING  pFormat,
unsigned char  fHasPointers 
)
inlinestatic

Definition at line 2300 of file ndr_marshall.c.

2303{
2304 ULONG i, count, SavedMemorySize;
2305 ULONG bufsize, memsize;
2306 DWORD esize;
2307 unsigned char alignment;
2308
2309 switch (fc)
2310 {
2311 case FC_CARRAY:
2312 esize = *(const WORD*)(pFormat+2);
2313 alignment = pFormat[1] + 1;
2314
2315 pFormat = SkipConformance(pStubMsg, pFormat + 4);
2316
2317 bufsize = memsize = safe_multiply(esize, pStubMsg->MaxCount);
2318 pStubMsg->MemorySize += memsize;
2319
2320 align_pointer(&pStubMsg->Buffer, alignment);
2321 if (fHasPointers)
2322 pStubMsg->BufferMark = pStubMsg->Buffer;
2323 safe_buffer_increment(pStubMsg, bufsize);
2324
2325 if (fHasPointers)
2326 EmbeddedPointerMemorySize(pStubMsg, pFormat);
2327 break;
2328 case FC_CVARRAY:
2329 esize = *(const WORD*)(pFormat+2);
2330 alignment = pFormat[1] + 1;
2331
2332 pFormat = SkipConformance(pStubMsg, pFormat + 4);
2333
2334 pFormat = ReadVariance(pStubMsg, pFormat, pStubMsg->MaxCount);
2335
2336 bufsize = safe_multiply(esize, pStubMsg->ActualCount);
2337 memsize = safe_multiply(esize, pStubMsg->MaxCount);
2338 pStubMsg->MemorySize += memsize;
2339
2340 align_pointer(&pStubMsg->Buffer, alignment);
2341 if (fHasPointers)
2342 pStubMsg->BufferMark = pStubMsg->Buffer;
2343 safe_buffer_increment(pStubMsg, bufsize);
2344
2345 if (fHasPointers)
2346 EmbeddedPointerMemorySize(pStubMsg, pFormat);
2347 break;
2348 case FC_C_CSTRING:
2349 case FC_C_WSTRING:
2350 if (fc == FC_C_CSTRING)
2351 esize = 1;
2352 else
2353 esize = 2;
2354
2355 ReadVariance(pStubMsg, NULL, pStubMsg->MaxCount);
2356
2357 if (pFormat[1] != FC_STRING_SIZED && (pStubMsg->MaxCount != pStubMsg->ActualCount))
2358 {
2359 ERR("buffer size %d must equal memory size %ld for non-sized conformant strings\n",
2360 pStubMsg->ActualCount, pStubMsg->MaxCount);
2362 }
2363 if (pStubMsg->Offset)
2364 {
2365 ERR("conformant strings can't have Offset (%d)\n", pStubMsg->Offset);
2367 }
2368
2369 memsize = safe_multiply(esize, pStubMsg->MaxCount);
2370 bufsize = safe_multiply(esize, pStubMsg->ActualCount);
2371
2372 validate_string_data(pStubMsg, bufsize, esize);
2373
2374 safe_buffer_increment(pStubMsg, bufsize);
2375 pStubMsg->MemorySize += memsize;
2376 break;
2377 case FC_BOGUS_ARRAY:
2378 alignment = pFormat[1] + 1;
2379 pFormat = SkipConformance(pStubMsg, pFormat + 4);
2380 pFormat = ReadVariance(pStubMsg, pFormat, pStubMsg->MaxCount);
2381
2382 align_pointer(&pStubMsg->Buffer, alignment);
2383
2384 SavedMemorySize = pStubMsg->MemorySize;
2385
2386 esize = ComplexStructSize(pStubMsg, pFormat);
2387 memsize = safe_multiply(pStubMsg->MaxCount, esize);
2388
2389 count = pStubMsg->ActualCount;
2390 for (i = 0; i < count; i++)
2391 ComplexStructMemorySize(pStubMsg, pFormat, NULL);
2392
2393 pStubMsg->MemorySize = SavedMemorySize + memsize;
2394 break;
2395 default:
2396 ERR("unknown array format 0x%x\n", fc);
2398 }
2399}
static void safe_buffer_increment(MIDL_STUB_MESSAGE *pStubMsg, ULONG size)
Definition: ndr_marshall.c:713
static PFORMAT_STRING ReadVariance(MIDL_STUB_MESSAGE *pStubMsg, PFORMAT_STRING pFormat, ULONG MaxValue)
Definition: ndr_marshall.c:484
static ULONG EmbeddedPointerMemorySize(PMIDL_STUB_MESSAGE pStubMsg, PFORMAT_STRING pFormat)
ULONG ComplexStructSize(PMIDL_STUB_MESSAGE pStubMsg, PFORMAT_STRING pFormat)
static ULONG ComplexStructMemorySize(PMIDL_STUB_MESSAGE pStubMsg, PFORMAT_STRING pFormat, PFORMAT_STRING pPointer)
static void validate_string_data(MIDL_STUB_MESSAGE *pStubMsg, ULONG bufsize, ULONG esize)
Definition: ndr_marshall.c:766
GLenum GLuint GLsizei bufsize
Definition: glext.h:7473
unsigned char * Buffer
Definition: rpcndr.h:203
ULONG MemorySize
Definition: rpcndr.h:208
unsigned char * BufferMark
Definition: rpcndr.h:206

Referenced by NdrComplexArrayMemorySize(), NdrComplexStructMemorySize(), NdrConformantArrayMemorySize(), NdrConformantStringMemorySize(), NdrConformantVaryingArrayMemorySize(), and NdrConformantVaryingStructMemorySize().

◆ array_read_conformance()

static ULONG array_read_conformance ( unsigned char  fc,
PMIDL_STUB_MESSAGE  pStubMsg,
PFORMAT_STRING  pFormat 
)
inlinestatic

Definition at line 2095 of file ndr_marshall.c.

2097{
2098 DWORD def, esize;
2099
2100 switch (fc)
2101 {
2102 case FC_CARRAY:
2103 esize = *(const WORD*)(pFormat+2);
2104 pFormat = ReadConformance(pStubMsg, pFormat+4);
2105 return safe_multiply(esize, pStubMsg->MaxCount);
2106 case FC_CVARRAY:
2107 esize = *(const WORD*)(pFormat+2);
2108 pFormat = ReadConformance(pStubMsg, pFormat+4);
2109 return safe_multiply(esize, pStubMsg->MaxCount);
2110 case FC_C_CSTRING:
2111 case FC_C_WSTRING:
2112 if (fc == FC_C_CSTRING)
2113 esize = 1;
2114 else
2115 esize = 2;
2116
2117 if (pFormat[1] == FC_STRING_SIZED)
2118 ReadConformance(pStubMsg, pFormat + 2);
2119 else
2120 ReadConformance(pStubMsg, NULL);
2121 return safe_multiply(esize, pStubMsg->MaxCount);
2122 case FC_BOGUS_ARRAY:
2123 def = *(const WORD *)(pFormat + 2);
2124 pFormat += 4;
2125 if (IsConformanceOrVariancePresent(pFormat)) pFormat = ReadConformance(pStubMsg, pFormat);
2126 else
2127 {
2128 pStubMsg->MaxCount = def;
2129 pFormat = SkipConformance( pStubMsg, pFormat );
2130 }
2131 pFormat = SkipVariance( pStubMsg, pFormat );
2132
2133 esize = ComplexStructSize(pStubMsg, pFormat);
2134 return safe_multiply(pStubMsg->MaxCount, esize);
2135 default:
2136 ERR("unknown array format 0x%x\n", fc);
2138 }
2139}
static PFORMAT_STRING ReadConformance(MIDL_STUB_MESSAGE *pStubMsg, PFORMAT_STRING pFormat)
Definition: ndr_marshall.c:473

Referenced by NdrComplexArrayMemorySize(), NdrComplexArrayUnmarshall(), NdrComplexStructMemorySize(), NdrComplexStructUnmarshall(), NdrConformantArrayMemorySize(), NdrConformantArrayUnmarshall(), NdrConformantStringMemorySize(), NdrConformantStringUnmarshall(), NdrConformantVaryingArrayMemorySize(), NdrConformantVaryingArrayUnmarshall(), NdrConformantVaryingStructMemorySize(), and NdrConformantVaryingStructUnmarshall().

◆ array_read_variance_and_unmarshall()

static ULONG array_read_variance_and_unmarshall ( unsigned char  fc,
PMIDL_STUB_MESSAGE  pStubMsg,
unsigned char **  ppMemory,
PFORMAT_STRING  pFormat,
unsigned char  fMustAlloc,
unsigned char  fUseBufferMemoryServer,
unsigned char  fUnmarshall 
)
inlinestatic

Definition at line 2141 of file ndr_marshall.c.

2145{
2146 ULONG bufsize, memsize;
2147 WORD esize;
2148 unsigned char alignment;
2149 unsigned char *saved_buffer, *pMemory;
2150 ULONG i, offset, count;
2151
2152 switch (fc)
2153 {
2154 case FC_CARRAY:
2155 esize = *(const WORD*)(pFormat+2);
2156 alignment = pFormat[1] + 1;
2157
2158 bufsize = memsize = safe_multiply(esize, pStubMsg->MaxCount);
2159
2160 pFormat = SkipConformance(pStubMsg, pFormat + 4);
2161
2162 align_pointer(&pStubMsg->Buffer, alignment);
2163
2164 if (fUnmarshall)
2165 {
2166 if (fMustAlloc)
2167 *ppMemory = NdrAllocateZero(pStubMsg, memsize);
2168 else
2169 {
2170 if (fUseBufferMemoryServer && !pStubMsg->IsClient && !*ppMemory)
2171 /* for servers, we just point straight into the RPC buffer */
2172 *ppMemory = pStubMsg->Buffer;
2173 }
2174
2175 saved_buffer = pStubMsg->Buffer;
2176 safe_buffer_increment(pStubMsg, bufsize);
2177
2178 pStubMsg->BufferMark = saved_buffer;
2179 EmbeddedPointerUnmarshall(pStubMsg, saved_buffer, *ppMemory, pFormat, fMustAlloc);
2180
2181 TRACE("copying %p to %p\n", saved_buffer, *ppMemory);
2182 if (*ppMemory != saved_buffer)
2183 memcpy(*ppMemory, saved_buffer, bufsize);
2184 }
2185 return bufsize;
2186 case FC_CVARRAY:
2187 esize = *(const WORD*)(pFormat+2);
2188 alignment = pFormat[1] + 1;
2189
2190 pFormat = SkipConformance(pStubMsg, pFormat + 4);
2191
2192 pFormat = ReadVariance(pStubMsg, pFormat, pStubMsg->MaxCount);
2193
2194 align_pointer(&pStubMsg->Buffer, alignment);
2195
2196 bufsize = safe_multiply(esize, pStubMsg->ActualCount);
2197 memsize = safe_multiply(esize, pStubMsg->MaxCount);
2198
2199 if (fUnmarshall)
2200 {
2201 offset = pStubMsg->Offset;
2202
2203 if (!fMustAlloc && !*ppMemory)
2204 fMustAlloc = TRUE;
2205 if (fMustAlloc)
2206 *ppMemory = NdrAllocateZero(pStubMsg, memsize);
2207 saved_buffer = pStubMsg->Buffer;
2208 safe_buffer_increment(pStubMsg, bufsize);
2209
2210 pStubMsg->BufferMark = saved_buffer;
2211 EmbeddedPointerUnmarshall(pStubMsg, saved_buffer, *ppMemory, pFormat,
2212 fMustAlloc);
2213
2214 memcpy(*ppMemory + offset, saved_buffer, bufsize);
2215 }
2216 return bufsize;
2217 case FC_C_CSTRING:
2218 case FC_C_WSTRING:
2219 if (fc == FC_C_CSTRING)
2220 esize = 1;
2221 else
2222 esize = 2;
2223
2224 ReadVariance(pStubMsg, NULL, pStubMsg->MaxCount);
2225
2226 if (pFormat[1] != FC_STRING_SIZED && (pStubMsg->MaxCount != pStubMsg->ActualCount))
2227 {
2228 ERR("buffer size %d must equal memory size %ld for non-sized conformant strings\n",
2229 pStubMsg->ActualCount, pStubMsg->MaxCount);
2231 }
2232 if (pStubMsg->Offset)
2233 {
2234 ERR("conformant strings can't have Offset (%d)\n", pStubMsg->Offset);
2236 }
2237
2238 memsize = safe_multiply(esize, pStubMsg->MaxCount);
2239 bufsize = safe_multiply(esize, pStubMsg->ActualCount);
2240
2241 validate_string_data(pStubMsg, bufsize, esize);
2242
2243 if (fUnmarshall)
2244 {
2245 if (fMustAlloc)
2246 *ppMemory = NdrAllocate(pStubMsg, memsize);
2247 else
2248 {
2249 if (fUseBufferMemoryServer && !pStubMsg->IsClient &&
2250 !*ppMemory && (pStubMsg->MaxCount == pStubMsg->ActualCount))
2251 /* if the data in the RPC buffer is big enough, we just point
2252 * straight into it */
2253 *ppMemory = pStubMsg->Buffer;
2254 else if (!*ppMemory)
2255 *ppMemory = NdrAllocate(pStubMsg, memsize);
2256 }
2257
2258 if (*ppMemory == pStubMsg->Buffer)
2259 safe_buffer_increment(pStubMsg, bufsize);
2260 else
2261 safe_copy_from_buffer(pStubMsg, *ppMemory, bufsize);
2262
2263 if (*pFormat == FC_C_CSTRING)
2264 TRACE("string=%s\n", debugstr_a((char*)*ppMemory));
2265 else
2266 TRACE("string=%s\n", debugstr_w((LPWSTR)*ppMemory));
2267 }
2268 return bufsize;
2269
2270 case FC_BOGUS_ARRAY:
2271 alignment = pFormat[1] + 1;
2272 pFormat = SkipConformance(pStubMsg, pFormat + 4);
2273 pFormat = ReadVariance(pStubMsg, pFormat, pStubMsg->MaxCount);
2274
2275 esize = ComplexStructSize(pStubMsg, pFormat);
2276 memsize = safe_multiply(esize, pStubMsg->MaxCount);
2277
2278 assert( fUnmarshall );
2279
2280 if (!fMustAlloc && !*ppMemory)
2281 fMustAlloc = TRUE;
2282 if (fMustAlloc)
2283 *ppMemory = NdrAllocateZero(pStubMsg, memsize);
2284
2285 align_pointer(&pStubMsg->Buffer, alignment);
2286 saved_buffer = pStubMsg->Buffer;
2287
2288 pMemory = *ppMemory;
2289 count = pStubMsg->ActualCount;
2290 for (i = 0; i < count; i++)
2291 pMemory = ComplexUnmarshall(pStubMsg, pMemory, pFormat, NULL, fMustAlloc);
2292 return pStubMsg->Buffer - saved_buffer;
2293
2294 default:
2295 ERR("unknown array format 0x%x\n", fc);
2297 }
2298}
static unsigned char * ComplexUnmarshall(PMIDL_STUB_MESSAGE pStubMsg, unsigned char *pMemory, PFORMAT_STRING pFormat, PFORMAT_STRING pPointer, unsigned char fMustAlloc)
static void safe_copy_from_buffer(MIDL_STUB_MESSAGE *pStubMsg, void *p, ULONG size)
Definition: ndr_marshall.c:734
static unsigned char * EmbeddedPointerUnmarshall(PMIDL_STUB_MESSAGE pStubMsg, unsigned char *pDstBuffer, unsigned char *pSrcMemoryPtrs, PFORMAT_STRING pFormat, unsigned char fMustAlloc)
static void * NdrAllocateZero(MIDL_STUB_MESSAGE *stubmsg, SIZE_T len)
Definition: ndr_marshall.c:449
#define assert(x)
Definition: debug.h:53
GLintptr offset
Definition: glext.h:5920
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
unsigned char IsClient
Definition: rpcndr.h:210
WCHAR * LPWSTR
Definition: xmlstorage.h:184

Referenced by NdrComplexArrayUnmarshall(), NdrComplexStructUnmarshall(), NdrConformantArrayUnmarshall(), NdrConformantStringUnmarshall(), NdrConformantVaryingArrayUnmarshall(), and NdrConformantVaryingStructUnmarshall().

◆ array_write_variance_and_marshall()

static void array_write_variance_and_marshall ( unsigned char  fc,
PMIDL_STUB_MESSAGE  pStubMsg,
unsigned char pMemory,
PFORMAT_STRING  pFormat,
unsigned char  fHasPointers 
)
inlinestatic

Definition at line 2019 of file ndr_marshall.c.

2022{
2023 DWORD i, size;
2024 DWORD esize;
2025 unsigned char alignment;
2026
2027 switch (fc)
2028 {
2029 case FC_CARRAY:
2030 esize = *(const WORD*)(pFormat+2);
2031 alignment = pFormat[1] + 1;
2032
2033 pFormat = SkipConformance(pStubMsg, pFormat + 4);
2034
2035 align_pointer_clear(&pStubMsg->Buffer, alignment);
2036
2037 size = safe_multiply(esize, pStubMsg->MaxCount);
2038 if (fHasPointers)
2039 pStubMsg->BufferMark = pStubMsg->Buffer;
2040 safe_copy_to_buffer(pStubMsg, pMemory, size);
2041
2042 if (fHasPointers)
2043 EmbeddedPointerMarshall(pStubMsg, pMemory, pFormat);
2044 break;
2045 case FC_CVARRAY:
2046 esize = *(const WORD*)(pFormat+2);
2047 alignment = pFormat[1] + 1;
2048
2049 pFormat = SkipConformance(pStubMsg, pFormat + 4);
2050 pFormat = SkipVariance(pStubMsg, pFormat);
2051
2052 WriteVariance(pStubMsg);
2053
2054 align_pointer_clear(&pStubMsg->Buffer, alignment);
2055
2056 size = safe_multiply(esize, pStubMsg->ActualCount);
2057
2058 if (fHasPointers)
2059 pStubMsg->BufferMark = pStubMsg->Buffer;
2060 safe_copy_to_buffer(pStubMsg, pMemory + pStubMsg->Offset, size);
2061
2062 if (fHasPointers)
2063 EmbeddedPointerMarshall(pStubMsg, pMemory, pFormat);
2064 break;
2065 case FC_C_CSTRING:
2066 case FC_C_WSTRING:
2067 if (fc == FC_C_CSTRING)
2068 esize = 1;
2069 else
2070 esize = 2;
2071
2072 WriteVariance(pStubMsg);
2073
2074 size = safe_multiply(esize, pStubMsg->ActualCount);
2075 safe_copy_to_buffer(pStubMsg, pMemory, size); /* the string itself */
2076 break;
2077 case FC_BOGUS_ARRAY:
2078 alignment = pFormat[1] + 1;
2079 pFormat = SkipConformance(pStubMsg, pFormat + 4);
2080 if (IsConformanceOrVariancePresent(pFormat)) WriteVariance(pStubMsg);
2081 pFormat = SkipVariance(pStubMsg, pFormat);
2082
2083 align_pointer_clear(&pStubMsg->Buffer, alignment);
2084
2085 size = pStubMsg->ActualCount;
2086 for (i = 0; i < size; i++)
2087 pMemory = ComplexMarshall(pStubMsg, pMemory, pFormat, NULL);
2088 break;
2089 default:
2090 ERR("unknown array format 0x%x\n", fc);
2092 }
2093}
static void safe_copy_to_buffer(MIDL_STUB_MESSAGE *pStubMsg, const void *p, ULONG size)
Definition: ndr_marshall.c:750
static unsigned char * ComplexMarshall(PMIDL_STUB_MESSAGE pStubMsg, unsigned char *pMemory, PFORMAT_STRING pFormat, PFORMAT_STRING pPointer)
static unsigned char * EmbeddedPointerMarshall(PMIDL_STUB_MESSAGE pStubMsg, unsigned char *pMemory, PFORMAT_STRING pFormat)
static void align_pointer_clear(unsigned char **ptr, unsigned int align)
Definition: ndr_marshall.c:103
static void WriteVariance(MIDL_STUB_MESSAGE *pStubMsg)
Definition: ndr_marshall.c:527

Referenced by NdrComplexArrayMarshall(), NdrComplexStructMarshall(), NdrConformantArrayMarshall(), NdrConformantStringMarshall(), NdrConformantVaryingArrayMarshall(), and NdrConformantVaryingStructMarshall().

◆ ComplexBufferSize()

static unsigned char * ComplexBufferSize ( PMIDL_STUB_MESSAGE  pStubMsg,
unsigned char pMemory,
PFORMAT_STRING  pFormat,
PFORMAT_STRING  pPointer 
)
static

Definition at line 3178 of file ndr_marshall.c.

3182{
3183 unsigned char *mem_base = pMemory;
3186 ULONG size;
3187
3188 while (*pFormat != FC_END) {
3189 switch (*pFormat) {
3190 case FC_BYTE:
3191 case FC_CHAR:
3192 case FC_SMALL:
3193 case FC_USMALL:
3194 safe_buffer_length_increment(pStubMsg, 1);
3195 pMemory += 1;
3196 break;
3197 case FC_WCHAR:
3198 case FC_SHORT:
3199 case FC_USHORT:
3200 safe_buffer_length_increment(pStubMsg, 2);
3201 pMemory += 2;
3202 break;
3203 case FC_ENUM16:
3204 safe_buffer_length_increment(pStubMsg, 2);
3205 pMemory += 4;
3206 break;
3207 case FC_LONG:
3208 case FC_ULONG:
3209 case FC_ENUM32:
3210 case FC_FLOAT:
3211 safe_buffer_length_increment(pStubMsg, 4);
3212 pMemory += 4;
3213 break;
3214 case FC_INT3264:
3215 case FC_UINT3264:
3216 safe_buffer_length_increment(pStubMsg, 4);
3217 pMemory += sizeof(INT_PTR);
3218 break;
3219 case FC_HYPER:
3220 case FC_DOUBLE:
3221 safe_buffer_length_increment(pStubMsg, 8);
3222 pMemory += 8;
3223 break;
3224 case FC_RP:
3225 case FC_UP:
3226 case FC_OP:
3227 case FC_FP:
3228 case FC_POINTER:
3229 if (*pFormat != FC_POINTER)
3230 pPointer = pFormat;
3231 if (!pStubMsg->IgnoreEmbeddedPointers)
3232 {
3233 int saved_buffer_length = pStubMsg->BufferLength;
3234 pStubMsg->BufferLength = pStubMsg->PointerLength;
3235 pStubMsg->PointerLength = 0;
3236 if(!pStubMsg->BufferLength)
3237 ERR("BufferLength == 0??\n");
3238 PointerBufferSize(pStubMsg, *(unsigned char**)pMemory, pPointer);
3239 pStubMsg->PointerLength = pStubMsg->BufferLength;
3240 pStubMsg->BufferLength = saved_buffer_length;
3241 }
3242 if (*pPointer != FC_RP)
3243 {
3244 align_length(&pStubMsg->BufferLength, 4);
3245 safe_buffer_length_increment(pStubMsg, 4);
3246 }
3247 if (*pFormat == FC_POINTER)
3248 pPointer += 4;
3249 else
3250 pFormat += 4;
3251 pMemory += sizeof(void*);
3252 break;
3253 case FC_ALIGNM2:
3254 align_pointer_offset(&pMemory, mem_base, 2);
3255 break;
3256 case FC_ALIGNM4:
3257 align_pointer_offset(&pMemory, mem_base, 4);
3258 break;
3259 case FC_ALIGNM8:
3260 align_pointer_offset(&pMemory, mem_base, 8);
3261 break;
3262 case FC_STRUCTPAD1:
3263 case FC_STRUCTPAD2:
3264 case FC_STRUCTPAD3:
3265 case FC_STRUCTPAD4:
3266 case FC_STRUCTPAD5:
3267 case FC_STRUCTPAD6:
3268 case FC_STRUCTPAD7:
3269 pMemory += *pFormat - FC_STRUCTPAD1 + 1;
3270 break;
3272 pMemory += pFormat[1];
3273 pFormat += 2;
3274 desc = pFormat + *(const SHORT*)pFormat;
3275 size = EmbeddedComplexSize(pStubMsg, desc);
3277 if (m)
3278 {
3279 /* for some reason interface pointers aren't generated as
3280 * FC_POINTER, but instead as FC_EMBEDDED_COMPLEX, yet
3281 * they still need the dereferencing treatment that pointers are
3282 * given */
3283 if (*desc == FC_IP)
3284 m(pStubMsg, *(unsigned char **)pMemory, desc);
3285 else
3286 m(pStubMsg, pMemory, desc);
3287 }
3288 else FIXME("no buffersizer for embedded type %02x\n", *desc);
3289 pMemory += size;
3290 pFormat += 2;
3291 continue;
3292 case FC_PAD:
3293 break;
3294 default:
3295 FIXME("unhandled format 0x%02x\n", *pFormat);
3296 }
3297 pFormat++;
3298 }
3299
3300 return pMemory;
3301}
#define FIXME(fmt,...)
Definition: precomp.h:53
static void align_pointer_offset(unsigned char **ptr, unsigned char *base, unsigned int align)
Definition: ndr_marshall.c:110
static void PointerBufferSize(PMIDL_STUB_MESSAGE pStubMsg, unsigned char *Pointer, PFORMAT_STRING pFormat)
static ULONG EmbeddedComplexSize(MIDL_STUB_MESSAGE *pStubMsg, PFORMAT_STRING pFormat)
const NDR_BUFFERSIZE NdrBufferSizer[NDR_TABLE_SIZE]
Definition: ndr_marshall.c:260
#define NDR_TABLE_MASK
Definition: ndr_marshall.c:132
const GLfloat * m
Definition: glext.h:10848
static const WCHAR desc[]
Definition: protectdata.c:36
void(WINAPI * NDR_BUFFERSIZE)(PMIDL_STUB_MESSAGE, unsigned char *, PFORMAT_STRING)
Definition: ndr_misc.h:55
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_IP
Definition: ndrtypes.h:189
@ FC_SHORT
Definition: ndrtypes.h:140
@ FC_WCHAR
Definition: ndrtypes.h:139
const unsigned char * PFORMAT_STRING
Definition: rpcndr.h:176
ULONG PointerLength
Definition: rpcndr.h:233
int IgnoreEmbeddedPointers
Definition: rpcndr.h:216
int32_t INT_PTR
Definition: typedefs.h:64

Referenced by array_buffer_size(), and NdrComplexStructBufferSize().

◆ ComplexFree()

static unsigned char * ComplexFree ( PMIDL_STUB_MESSAGE  pStubMsg,
unsigned char pMemory,
PFORMAT_STRING  pFormat,
PFORMAT_STRING  pPointer 
)
static

Definition at line 3303 of file ndr_marshall.c.

3307{
3308 unsigned char *mem_base = pMemory;
3310 NDR_FREE m;
3311 ULONG size;
3312
3313 while (*pFormat != FC_END) {
3314 switch (*pFormat) {
3315 case FC_BYTE:
3316 case FC_CHAR:
3317 case FC_SMALL:
3318 case FC_USMALL:
3319 pMemory += 1;
3320 break;
3321 case FC_WCHAR:
3322 case FC_SHORT:
3323 case FC_USHORT:
3324 pMemory += 2;
3325 break;
3326 case FC_LONG:
3327 case FC_ULONG:
3328 case FC_ENUM16:
3329 case FC_ENUM32:
3330 case FC_FLOAT:
3331 pMemory += 4;
3332 break;
3333 case FC_INT3264:
3334 case FC_UINT3264:
3335 pMemory += sizeof(INT_PTR);
3336 break;
3337 case FC_HYPER:
3338 case FC_DOUBLE:
3339 pMemory += 8;
3340 break;
3341 case FC_RP:
3342 case FC_UP:
3343 case FC_OP:
3344 case FC_FP:
3345 case FC_POINTER:
3346 if (*pFormat != FC_POINTER)
3347 pPointer = pFormat;
3348 NdrPointerFree(pStubMsg, *(unsigned char**)pMemory, pPointer);
3349 if (*pFormat == FC_POINTER)
3350 pPointer += 4;
3351 else
3352 pFormat += 4;
3353 pMemory += sizeof(void *);
3354 break;
3355 case FC_ALIGNM2:
3356 align_pointer_offset(&pMemory, mem_base, 2);
3357 break;
3358 case FC_ALIGNM4:
3359 align_pointer_offset(&pMemory, mem_base, 4);
3360 break;
3361 case FC_ALIGNM8:
3362 align_pointer_offset(&pMemory, mem_base, 8);
3363 break;
3364 case FC_STRUCTPAD1:
3365 case FC_STRUCTPAD2:
3366 case FC_STRUCTPAD3:
3367 case FC_STRUCTPAD4:
3368 case FC_STRUCTPAD5:
3369 case FC_STRUCTPAD6:
3370 case FC_STRUCTPAD7:
3371 pMemory += *pFormat - FC_STRUCTPAD1 + 1;
3372 break;
3374 pMemory += pFormat[1];
3375 pFormat += 2;
3376 desc = pFormat + *(const SHORT*)pFormat;
3377 size = EmbeddedComplexSize(pStubMsg, desc);
3379 if (m)
3380 {
3381 /* for some reason interface pointers aren't generated as
3382 * FC_POINTER, but instead as FC_EMBEDDED_COMPLEX, yet
3383 * they still need the dereferencing treatment that pointers are
3384 * given */
3385 if (*desc == FC_IP)
3386 m(pStubMsg, *(unsigned char **)pMemory, desc);
3387 else
3388 m(pStubMsg, pMemory, desc);
3389 }
3390 pMemory += size;
3391 pFormat += 2;
3392 continue;
3393 case FC_PAD:
3394 break;
3395 default:
3396 FIXME("unhandled format 0x%02x\n", *pFormat);
3397 }
3398 pFormat++;
3399 }
3400
3401 return pMemory;
3402}
void WINAPI NdrPointerFree(PMIDL_STUB_MESSAGE pStubMsg, unsigned char *pMemory, PFORMAT_STRING pFormat)
const NDR_FREE NdrFreer[NDR_TABLE_SIZE]
Definition: ndr_marshall.c:348
void(WINAPI * NDR_FREE)(PMIDL_STUB_MESSAGE, unsigned char *, PFORMAT_STRING)
Definition: ndr_misc.h:57

Referenced by array_free(), NdrComplexArrayFree(), and NdrComplexStructFree().

◆ ComplexMarshall()

static unsigned char * ComplexMarshall ( PMIDL_STUB_MESSAGE  pStubMsg,
unsigned char pMemory,
PFORMAT_STRING  pFormat,
PFORMAT_STRING  pPointer 
)
static

Definition at line 2842 of file ndr_marshall.c.

2846{
2847 unsigned char *mem_base = pMemory;
2850 ULONG size;
2851
2852 while (*pFormat != FC_END) {
2853 switch (*pFormat) {
2854 case FC_BYTE:
2855 case FC_CHAR:
2856 case FC_SMALL:
2857 case FC_USMALL:
2858 TRACE("byte=%d <= %p\n", *(WORD*)pMemory, pMemory);
2859 safe_copy_to_buffer(pStubMsg, pMemory, 1);
2860 pMemory += 1;
2861 break;
2862 case FC_WCHAR:
2863 case FC_SHORT:
2864 case FC_USHORT:
2865 TRACE("short=%d <= %p\n", *(WORD*)pMemory, pMemory);
2866 safe_copy_to_buffer(pStubMsg, pMemory, 2);
2867 pMemory += 2;
2868 break;
2869 case FC_ENUM16:
2870 {
2871 USHORT val = *(DWORD *)pMemory;
2872 TRACE("enum16=%d <= %p\n", *(DWORD*)pMemory, pMemory);
2873 if (32767 < *(DWORD*)pMemory)
2875 safe_copy_to_buffer(pStubMsg, &val, 2);
2876 pMemory += 4;
2877 break;
2878 }
2879 case FC_LONG:
2880 case FC_ULONG:
2881 case FC_ENUM32:
2882 TRACE("long=%d <= %p\n", *(DWORD*)pMemory, pMemory);
2883 safe_copy_to_buffer(pStubMsg, pMemory, 4);
2884 pMemory += 4;
2885 break;
2886 case FC_INT3264:
2887 case FC_UINT3264:
2888 {
2889 UINT val = *(UINT_PTR *)pMemory;
2890 TRACE("int3264=%ld <= %p\n", *(UINT_PTR *)pMemory, pMemory);
2891 safe_copy_to_buffer(pStubMsg, &val, sizeof(UINT));
2892 pMemory += sizeof(UINT_PTR);
2893 break;
2894 }
2895 case FC_FLOAT:
2896 TRACE("float=%f <= %p\n", *(float*)pMemory, pMemory);
2897 safe_copy_to_buffer(pStubMsg, pMemory, sizeof(float));
2898 pMemory += sizeof(float);
2899 break;
2900 case FC_HYPER:
2901 TRACE("longlong=%s <= %p\n", wine_dbgstr_longlong(*(ULONGLONG*)pMemory), pMemory);
2902 safe_copy_to_buffer(pStubMsg, pMemory, 8);
2903 pMemory += 8;
2904 break;
2905 case FC_DOUBLE:
2906 TRACE("double=%f <= %p\n", *(double*)pMemory, pMemory);
2907 safe_copy_to_buffer(pStubMsg, pMemory, sizeof(double));
2908 pMemory += sizeof(double);
2909 break;
2910 case FC_RP:
2911 case FC_UP:
2912 case FC_OP:
2913 case FC_FP:
2914 case FC_POINTER:
2915 {
2916 unsigned char *saved_buffer;
2917 BOOL pointer_buffer_mark_set = FALSE;
2918 TRACE("pointer=%p <= %p\n", *(unsigned char**)pMemory, pMemory);
2919 TRACE("pStubMsg->Buffer before %p\n", pStubMsg->Buffer);
2920 if (*pFormat != FC_POINTER)
2921 pPointer = pFormat;
2922 if (*pPointer != FC_RP)
2923 align_pointer_clear(&pStubMsg->Buffer, 4);
2924 saved_buffer = pStubMsg->Buffer;
2925 if (pStubMsg->PointerBufferMark)
2926 {
2927 pStubMsg->Buffer = pStubMsg->PointerBufferMark;
2928 pStubMsg->PointerBufferMark = NULL;
2929 pointer_buffer_mark_set = TRUE;
2930 }
2931 else if (*pPointer != FC_RP)
2932 safe_buffer_increment(pStubMsg, 4); /* for pointer ID */
2933 PointerMarshall(pStubMsg, saved_buffer, *(unsigned char**)pMemory, pPointer);
2934 if (pointer_buffer_mark_set)
2935 {
2936 STD_OVERFLOW_CHECK(pStubMsg);
2937 pStubMsg->PointerBufferMark = pStubMsg->Buffer;
2938 pStubMsg->Buffer = saved_buffer;
2939 if (*pPointer != FC_RP)
2940 safe_buffer_increment(pStubMsg, 4); /* for pointer ID */
2941 }
2942 TRACE("pStubMsg->Buffer after %p\n", pStubMsg->Buffer);
2943 if (*pFormat == FC_POINTER)
2944 pPointer += 4;
2945 else
2946 pFormat += 4;
2947 pMemory += sizeof(void *);
2948 break;
2949 }
2950 case FC_ALIGNM2:
2951 align_pointer_offset(&pMemory, mem_base, 2);
2952 break;
2953 case FC_ALIGNM4:
2954 align_pointer_offset(&pMemory, mem_base, 4);
2955 break;
2956 case FC_ALIGNM8:
2957 align_pointer_offset(&pMemory, mem_base, 8);
2958 break;
2959 case FC_STRUCTPAD1:
2960 case FC_STRUCTPAD2:
2961 case FC_STRUCTPAD3:
2962 case FC_STRUCTPAD4:
2963 case FC_STRUCTPAD5:
2964 case FC_STRUCTPAD6:
2965 case FC_STRUCTPAD7:
2966 pMemory += *pFormat - FC_STRUCTPAD1 + 1;
2967 break;
2969 pMemory += pFormat[1];
2970 pFormat += 2;
2971 desc = pFormat + *(const SHORT*)pFormat;
2972 size = EmbeddedComplexSize(pStubMsg, desc);
2973 TRACE("embedded complex (size=%d) <= %p\n", size, pMemory);
2975 if (m)
2976 {
2977 /* for some reason interface pointers aren't generated as
2978 * FC_POINTER, but instead as FC_EMBEDDED_COMPLEX, yet
2979 * they still need the dereferencing treatment that pointers are
2980 * given */
2981 if (*desc == FC_IP)
2982 m(pStubMsg, *(unsigned char **)pMemory, desc);
2983 else
2984 m(pStubMsg, pMemory, desc);
2985 }
2986 else FIXME("no marshaller for embedded type %02x\n", *desc);
2987 pMemory += size;
2988 pFormat += 2;
2989 continue;
2990 case FC_PAD:
2991 break;
2992 default:
2993 FIXME("unhandled format 0x%02x\n", *pFormat);
2994 }
2995 pFormat++;
2996 }
2997
2998 return pMemory;
2999}
#define FALSE
Definition: types.h:117
static __inline const char * wine_dbgstr_longlong(ULONGLONG ll)
Definition: compat.h:49
static void PointerMarshall(PMIDL_STUB_MESSAGE pStubMsg, unsigned char *Buffer, unsigned char *Pointer, PFORMAT_STRING pFormat)
Definition: ndr_marshall.c:813
const NDR_MARSHALL NdrMarshaller[NDR_TABLE_SIZE]
Definition: ndr_marshall.c:172
#define STD_OVERFLOW_CHECK(_Msg)
Definition: ndr_marshall.c:123
GLuint GLfloat * val
Definition: glext.h:7180
static const char mbstate_t *static wchar_t const char mbstate_t *static const wchar_t int *static double
Definition: string.c:80
static float(__cdecl *square_half_float)(float x
unsigned __int3264 UINT_PTR
Definition: mstsclib_h.h:274
unsigned int UINT
Definition: ndis.h:50
unsigned char *(WINAPI * NDR_MARSHALL)(PMIDL_STUB_MESSAGE, unsigned char *, PFORMAT_STRING)
Definition: ndr_misc.h:53
unsigned short USHORT
Definition: pedump.c:61
unsigned char * PointerBufferMark
Definition: rpcndr.h:217
uint64_t ULONGLONG
Definition: typedefs.h:67
#define RPC_X_ENUM_VALUE_OUT_OF_RANGE
Definition: winerror.h:1088

Referenced by array_write_variance_and_marshall(), and NdrComplexStructMarshall().

◆ ComplexStructMemorySize()

static ULONG ComplexStructMemorySize ( PMIDL_STUB_MESSAGE  pStubMsg,
PFORMAT_STRING  pFormat,
PFORMAT_STRING  pPointer 
)
static

Definition at line 3404 of file ndr_marshall.c.

3407{
3409 ULONG size = 0;
3410
3411 while (*pFormat != FC_END) {
3412 switch (*pFormat) {
3413 case FC_BYTE:
3414 case FC_CHAR:
3415 case FC_SMALL:
3416 case FC_USMALL:
3417 size += 1;
3418 safe_buffer_increment(pStubMsg, 1);
3419 break;
3420 case FC_WCHAR:
3421 case FC_SHORT:
3422 case FC_USHORT:
3423 size += 2;
3424 safe_buffer_increment(pStubMsg, 2);
3425 break;
3426 case FC_ENUM16:
3427 size += 4;
3428 safe_buffer_increment(pStubMsg, 2);
3429 break;
3430 case FC_LONG:
3431 case FC_ULONG:
3432 case FC_ENUM32:
3433 case FC_FLOAT:
3434 size += 4;
3435 safe_buffer_increment(pStubMsg, 4);
3436 break;
3437 case FC_INT3264:
3438 case FC_UINT3264:
3439 size += sizeof(INT_PTR);
3440 safe_buffer_increment(pStubMsg, 4);
3441 break;
3442 case FC_HYPER:
3443 case FC_DOUBLE:
3444 size += 8;
3445 safe_buffer_increment(pStubMsg, 8);
3446 break;
3447 case FC_RP:
3448 case FC_UP:
3449 case FC_OP:
3450 case FC_FP:
3451 case FC_POINTER:
3452 {
3453 unsigned char *saved_buffer;
3454 BOOL pointer_buffer_mark_set = FALSE;
3455 if (*pFormat != FC_POINTER)
3456 pPointer = pFormat;
3457 if (*pPointer != FC_RP)
3458 align_pointer(&pStubMsg->Buffer, 4);
3459 saved_buffer = pStubMsg->Buffer;
3460 if (pStubMsg->PointerBufferMark)
3461 {
3462 pStubMsg->Buffer = pStubMsg->PointerBufferMark;
3463 pStubMsg->PointerBufferMark = NULL;
3464 pointer_buffer_mark_set = TRUE;
3465 }
3466 else if (*pPointer != FC_RP)
3467 safe_buffer_increment(pStubMsg, 4); /* for pointer ID */
3468
3469 if (!pStubMsg->IgnoreEmbeddedPointers)
3470 PointerMemorySize(pStubMsg, saved_buffer, pPointer);
3471 if (pointer_buffer_mark_set)
3472 {
3473 STD_OVERFLOW_CHECK(pStubMsg);
3474 pStubMsg->PointerBufferMark = pStubMsg->Buffer;
3475 pStubMsg->Buffer = saved_buffer;
3476 if (*pPointer != FC_RP)
3477 safe_buffer_increment(pStubMsg, 4); /* for pointer ID */
3478 }
3479 if (*pFormat == FC_POINTER)
3480 pPointer += 4;
3481 else
3482 pFormat += 4;
3483 size += sizeof(void *);
3484 break;
3485 }
3486 case FC_ALIGNM2:
3487 align_length(&size, 2);
3488 break;
3489 case FC_ALIGNM4:
3490 align_length(&size, 4);
3491 break;
3492 case FC_ALIGNM8:
3493 align_length(&size, 8);
3494 break;
3495 case FC_STRUCTPAD1:
3496 case FC_STRUCTPAD2:
3497 case FC_STRUCTPAD3:
3498 case FC_STRUCTPAD4:
3499 case FC_STRUCTPAD5:
3500 case FC_STRUCTPAD6:
3501 case FC_STRUCTPAD7:
3502 size += *pFormat - FC_STRUCTPAD1 + 1;
3503 break;
3505 size += pFormat[1];
3506 pFormat += 2;
3507 desc = pFormat + *(const SHORT*)pFormat;
3508 size += EmbeddedComplexMemorySize(pStubMsg, desc);
3509 pFormat += 2;
3510 continue;
3511 case FC_PAD:
3512 break;
3513 default:
3514 FIXME("unhandled format 0x%02x\n", *pFormat);
3515 }
3516 pFormat++;
3517 }
3518
3519 return size;
3520}
static ULONG EmbeddedComplexMemorySize(PMIDL_STUB_MESSAGE pStubMsg, PFORMAT_STRING pFormat)
static ULONG PointerMemorySize(PMIDL_STUB_MESSAGE pStubMsg, unsigned char *Buffer, PFORMAT_STRING pFormat)

Referenced by array_memory_size(), and NdrComplexStructMemorySize().

◆ 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;
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}

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

◆ ComplexUnmarshall()

static unsigned char * ComplexUnmarshall ( PMIDL_STUB_MESSAGE  pStubMsg,
unsigned char pMemory,
PFORMAT_STRING  pFormat,
PFORMAT_STRING  pPointer,
unsigned char  fMustAlloc 
)
static

Definition at line 3001 of file ndr_marshall.c.

3006{
3007 unsigned char *mem_base = pMemory;
3010 ULONG size;
3011
3012 while (*pFormat != FC_END) {
3013 switch (*pFormat) {
3014 case FC_BYTE:
3015 case FC_CHAR:
3016 case FC_SMALL:
3017 case FC_USMALL:
3018 safe_copy_from_buffer(pStubMsg, pMemory, 1);
3019 TRACE("byte=%d => %p\n", *(WORD*)pMemory, pMemory);
3020 pMemory += 1;
3021 break;
3022 case FC_WCHAR:
3023 case FC_SHORT:
3024 case FC_USHORT:
3025 safe_copy_from_buffer(pStubMsg, pMemory, 2);
3026 TRACE("short=%d => %p\n", *(WORD*)pMemory, pMemory);
3027 pMemory += 2;
3028 break;
3029 case FC_ENUM16:
3030 {
3031 WORD val;
3032 safe_copy_from_buffer(pStubMsg, &val, 2);
3033 *(DWORD*)pMemory = val;
3034 TRACE("enum16=%d => %p\n", *(DWORD*)pMemory, pMemory);
3035 if (32767 < *(DWORD*)pMemory)
3037 pMemory += 4;
3038 break;
3039 }
3040 case FC_LONG:
3041 case FC_ULONG:
3042 case FC_ENUM32:
3043 safe_copy_from_buffer(pStubMsg, pMemory, 4);
3044 TRACE("long=%d => %p\n", *(DWORD*)pMemory, pMemory);
3045 pMemory += 4;
3046 break;
3047 case FC_INT3264:
3048 {
3049 INT val;
3050 safe_copy_from_buffer(pStubMsg, &val, 4);
3051 *(INT_PTR *)pMemory = val;
3052 TRACE("int3264=%ld => %p\n", *(INT_PTR*)pMemory, pMemory);
3053 pMemory += sizeof(INT_PTR);
3054 break;
3055 }
3056 case FC_UINT3264:
3057 {
3058 UINT val;
3059 safe_copy_from_buffer(pStubMsg, &val, 4);
3060 *(UINT_PTR *)pMemory = val;
3061 TRACE("uint3264=%ld => %p\n", *(UINT_PTR*)pMemory, pMemory);
3062 pMemory += sizeof(UINT_PTR);
3063 break;
3064 }
3065 case FC_FLOAT:
3066 safe_copy_from_buffer(pStubMsg, pMemory, sizeof(float));
3067 TRACE("float=%f => %p\n", *(float*)pMemory, pMemory);
3068 pMemory += sizeof(float);
3069 break;
3070 case FC_HYPER:
3071 safe_copy_from_buffer(pStubMsg, pMemory, 8);
3072 TRACE("longlong=%s => %p\n", wine_dbgstr_longlong(*(ULONGLONG*)pMemory), pMemory);
3073 pMemory += 8;
3074 break;
3075 case FC_DOUBLE:
3076 safe_copy_from_buffer(pStubMsg, pMemory, sizeof(double));
3077 TRACE("double=%f => %p\n", *(double*)pMemory, pMemory);
3078 pMemory += sizeof(double);
3079 break;
3080 case FC_RP:
3081 case FC_UP:
3082 case FC_OP:
3083 case FC_FP:
3084 case FC_POINTER:
3085 {
3086 unsigned char *saved_buffer;
3087 BOOL pointer_buffer_mark_set = FALSE;
3088 TRACE("pointer => %p\n", pMemory);
3089 if (*pFormat != FC_POINTER)
3090 pPointer = pFormat;
3091 if (*pPointer != FC_RP)
3092 align_pointer(&pStubMsg->Buffer, 4);
3093 saved_buffer = pStubMsg->Buffer;
3094 if (pStubMsg->PointerBufferMark)
3095 {
3096 pStubMsg->Buffer = pStubMsg->PointerBufferMark;
3097 pStubMsg->PointerBufferMark = NULL;
3098 pointer_buffer_mark_set = TRUE;
3099 }
3100 else if (*pPointer != FC_RP)
3101 safe_buffer_increment(pStubMsg, 4); /* for pointer ID */
3102
3103 PointerUnmarshall(pStubMsg, saved_buffer, (unsigned char**)pMemory, *(unsigned char**)pMemory, pPointer, fMustAlloc);
3104 if (pointer_buffer_mark_set)
3105 {
3106 STD_OVERFLOW_CHECK(pStubMsg);
3107 pStubMsg->PointerBufferMark = pStubMsg->Buffer;
3108 pStubMsg->Buffer = saved_buffer;
3109 if (*pPointer != FC_RP)
3110 safe_buffer_increment(pStubMsg, 4); /* for pointer ID */
3111 }
3112 if (*pFormat == FC_POINTER)
3113 pPointer += 4;
3114 else
3115 pFormat += 4;
3116 pMemory += sizeof(void *);
3117 break;
3118 }
3119 case FC_ALIGNM2:
3120 align_pointer_offset_clear(&pMemory, mem_base, 2);
3121 break;
3122 case FC_ALIGNM4:
3123 align_pointer_offset_clear(&pMemory, mem_base, 4);
3124 break;
3125 case FC_ALIGNM8:
3126 align_pointer_offset_clear(&pMemory, mem_base, 8);
3127 break;
3128 case FC_STRUCTPAD1:
3129 case FC_STRUCTPAD2:
3130 case FC_STRUCTPAD3:
3131 case FC_STRUCTPAD4:
3132 case FC_STRUCTPAD5:
3133 case FC_STRUCTPAD6:
3134 case FC_STRUCTPAD7:
3135 memset(pMemory, 0, *pFormat - FC_STRUCTPAD1 + 1);
3136 pMemory += *pFormat - FC_STRUCTPAD1 + 1;
3137 break;
3139 pMemory += pFormat[1];
3140 pFormat += 2;
3141 desc = pFormat + *(const SHORT*)pFormat;
3142 size = EmbeddedComplexSize(pStubMsg, desc);
3143 TRACE("embedded complex (size=%d) => %p\n", size, pMemory);
3144 if (fMustAlloc)
3145 /* we can't pass fMustAlloc=TRUE into the marshaller for this type
3146 * since the type is part of the memory block that is encompassed by
3147 * the whole complex type. Memory is forced to allocate when pointers
3148 * are set to NULL, so we emulate that part of fMustAlloc=TRUE by
3149 * clearing the memory we pass in to the unmarshaller */
3150 memset(pMemory, 0, size);
3152 if (m)
3153 {
3154 /* for some reason interface pointers aren't generated as
3155 * FC_POINTER, but instead as FC_EMBEDDED_COMPLEX, yet
3156 * they still need the dereferencing treatment that pointers are
3157 * given */
3158 if (*desc == FC_IP)
3159 m(pStubMsg, (unsigned char **)pMemory, desc, FALSE);
3160 else
3161 m(pStubMsg, &pMemory, desc, FALSE);
3162 }
3163 else FIXME("no unmarshaller for embedded type %02x\n", *desc);
3164 pMemory += size;
3165 pFormat += 2;
3166 continue;
3167 case FC_PAD:
3168 break;
3169 default:
3170 FIXME("unhandled format %d\n", *pFormat);
3171 }
3172 pFormat++;
3173 }
3174
3175 return pMemory;
3176}
static void align_pointer_offset_clear(unsigned char **ptr, unsigned char *base, unsigned int align)
Definition: ndr_marshall.c:116
const NDR_UNMARSHALL NdrUnmarshaller[NDR_TABLE_SIZE]
Definition: ndr_marshall.c:216
static void PointerUnmarshall(PMIDL_STUB_MESSAGE pStubMsg, unsigned char *Buffer, unsigned char **pPointer, unsigned char *pSrcPointer, PFORMAT_STRING pFormat, unsigned char fMustAlloc)
Definition: ndr_marshall.c:883
unsigned char *(WINAPI * NDR_UNMARSHALL)(PMIDL_STUB_MESSAGE, unsigned char **, PFORMAT_STRING, unsigned char)
Definition: ndr_misc.h:54
int32_t INT
Definition: typedefs.h:58

Referenced by array_read_variance_and_unmarshall(), and NdrComplexStructUnmarshall().

◆ 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
666done_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
689finish_conf:
690 TRACE("resulting conformance is %ld\n", *pCount);
691
692 return SkipConformance(pStubMsg, pFormat);
693}
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
#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
unsigned char * StackTop
Definition: rpcndr.h:226
unsigned char * Memory
Definition: rpcndr.h:209
const struct _MIDL_STUB_DESC * StubDesc
Definition: rpcndr.h:230
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().

◆ dump_pointer_attr()

static void dump_pointer_attr ( unsigned char  attr)
inlinestatic

Definition at line 795 of file ndr_marshall.c.

796{
798 TRACE(" FC_ALLOCATE_ALL_NODES");
799 if (attr & FC_DONT_FREE)
800 TRACE(" FC_DONT_FREE");
802 TRACE(" FC_ALLOCED_ON_STACK");
804 TRACE(" FC_SIMPLE_POINTER");
806 TRACE(" FC_POINTER_DEREF");
807 TRACE("\n");
808}
#define FC_POINTER_DEREF
Definition: ndrtypes.h:276
#define FC_DONT_FREE
Definition: ndrtypes.h:273
#define FC_ALLOCATE_ALL_NODES
Definition: ndrtypes.h:272
#define FC_SIMPLE_POINTER
Definition: ndrtypes.h:275
#define FC_ALLOCED_ON_STACK
Definition: ndrtypes.h:274
Definition: cookie.c:202

Referenced by PointerBufferSize(), PointerFree(), PointerMarshall(), PointerMemorySize(), and PointerUnmarshall().

◆ EmbeddedComplexMemorySize()

static ULONG EmbeddedComplexMemorySize ( PMIDL_STUB_MESSAGE  pStubMsg,
PFORMAT_STRING  pFormat 
)
static

Definition at line 2827 of file ndr_marshall.c.

2829{
2831
2832 if (!m)
2833 {
2834 FIXME("no memorysizer for data type=%02x\n", *pFormat);
2835 return 0;
2836 }
2837
2838 return m(pStubMsg, pFormat);
2839}
const NDR_MEMORYSIZE NdrMemorySizer[NDR_TABLE_SIZE]
Definition: ndr_marshall.c:304
ULONG(WINAPI * NDR_MEMORYSIZE)(PMIDL_STUB_MESSAGE, PFORMAT_STRING)
Definition: ndr_misc.h:56

Referenced by ComplexStructMemorySize().

◆ EmbeddedComplexSize()

static ULONG EmbeddedComplexSize ( MIDL_STUB_MESSAGE pStubMsg,
PFORMAT_STRING  pFormat 
)
static

Definition at line 2766 of file ndr_marshall.c.

2768{
2769 switch (*pFormat) {
2770 case FC_STRUCT:
2771 case FC_PSTRUCT:
2772 case FC_CSTRUCT:
2773 case FC_BOGUS_STRUCT:
2774 case FC_SMFARRAY:
2775 case FC_SMVARRAY:
2776 case FC_CSTRING:
2777 return *(const WORD*)&pFormat[2];
2778 case FC_LGFARRAY:
2779 case FC_LGVARRAY:
2780 return *(const ULONG*)&pFormat[2];
2781 case FC_USER_MARSHAL:
2782 return *(const WORD*)&pFormat[4];
2783 case FC_RANGE: {
2784 switch (((const NDR_RANGE *)pFormat)->flags_type & 0xf) {
2785 case FC_BYTE:
2786 case FC_CHAR:
2787 case FC_SMALL:
2788 case FC_USMALL:
2789 return sizeof(UCHAR);
2790 case FC_WCHAR:
2791 case FC_SHORT:
2792 case FC_USHORT:
2793 return sizeof(USHORT);
2794 case FC_LONG:
2795 case FC_ULONG:
2796 case FC_ENUM32:
2797 return sizeof(ULONG);
2798 case FC_FLOAT:
2799 return sizeof(float);
2800 case FC_DOUBLE:
2801 return sizeof(double);
2802 case FC_HYPER:
2803 return sizeof(ULONGLONG);
2804 case FC_ENUM16:
2805 return sizeof(UINT);
2806 default:
2807 ERR("unknown type 0x%x\n", ((const NDR_RANGE *)pFormat)->flags_type & 0xf);
2809 }
2810 }
2812 pFormat += 2;
2813 pFormat = SkipConformance(pStubMsg, pFormat);
2814 pFormat += *(const SHORT*)pFormat;
2815 return *(const SHORT*)pFormat;
2816 case FC_IP:
2817 return sizeof(void *);
2818 case FC_WSTRING:
2819 return *(const WORD*)&pFormat[2] * 2;
2820 default:
2821 FIXME("unhandled embedded type %02x\n", *pFormat);
2822 }
2823 return 0;
2824}
@ FC_STRUCT
Definition: ndrtypes.h:157
@ FC_BOGUS_STRUCT
Definition: ndrtypes.h:162
@ FC_SMFARRAY
Definition: ndrtypes.h:166
@ FC_RANGE
Definition: ndrtypes.h:266
@ FC_LGVARRAY
Definition: ndrtypes.h:169
@ FC_CSTRING
Definition: ndrtypes.h:176
@ FC_SMVARRAY
Definition: ndrtypes.h:168
@ FC_NON_ENCAPSULATED_UNION
Definition: ndrtypes.h:182
@ FC_PSTRUCT
Definition: ndrtypes.h:158
@ FC_WSTRING
Definition: ndrtypes.h:179
@ FC_USER_MARSHAL
Definition: ndrtypes.h:261
@ FC_CSTRUCT
Definition: ndrtypes.h:159
@ FC_LGFARRAY
Definition: ndrtypes.h:167

Referenced by ComplexBufferSize(), ComplexFree(), ComplexMarshall(), ComplexStructSize(), and ComplexUnmarshall().

◆ EmbeddedPointerBufferSize()

static void EmbeddedPointerBufferSize ( PMIDL_STUB_MESSAGE  pStubMsg,
unsigned char pMemory,
PFORMAT_STRING  pFormat 
)
static

Definition at line 1337 of file ndr_marshall.c.

1340{
1341 unsigned rep, count, stride;
1342 unsigned i;
1343 ULONG saved_buffer_length = 0;
1344
1345 TRACE("(%p,%p,%p)\n", pStubMsg, pMemory, pFormat);
1346
1347 if (pStubMsg->IgnoreEmbeddedPointers) return;
1348
1349 if (*pFormat != FC_PP) return;
1350 pFormat += 2;
1351
1352 if (pStubMsg->PointerLength)
1353 {
1354 saved_buffer_length = pStubMsg->BufferLength;
1355 pStubMsg->BufferLength = pStubMsg->PointerLength;
1356 pStubMsg->PointerLength = 0;
1357 }
1358
1359 while (pFormat[0] != FC_END) {
1360 switch (pFormat[0]) {
1361 default:
1362 FIXME("unknown repeat type %d; assuming no repeat\n", pFormat[0]);
1363 /* fallthrough */
1364 case FC_NO_REPEAT:
1365 rep = 1;
1366 stride = 0;
1367 count = 1;
1368 pFormat += 2;
1369 break;
1370 case FC_FIXED_REPEAT:
1371 rep = *(const WORD*)&pFormat[2];
1372 stride = *(const WORD*)&pFormat[4];
1373 count = *(const WORD*)&pFormat[8];
1374 pFormat += 10;
1375 break;
1376 case FC_VARIABLE_REPEAT:
1377 rep = (pFormat[1] == FC_VARIABLE_OFFSET) ? pStubMsg->ActualCount : pStubMsg->MaxCount;
1378 stride = *(const WORD*)&pFormat[2];
1379 count = *(const WORD*)&pFormat[6];
1380 pFormat += 8;
1381 break;
1382 }
1383 for (i = 0; i < rep; i++) {
1384 PFORMAT_STRING info = pFormat;
1385 unsigned char *membase = pMemory + (i * stride);
1386 unsigned u;
1387
1388 for (u=0; u<count; u++,info+=8) {
1389 unsigned char *memptr = membase + *(const SHORT*)&info[0];
1390 unsigned char *saved_memory = pStubMsg->Memory;
1391
1392 pStubMsg->Memory = membase;
1393 PointerBufferSize(pStubMsg, *(unsigned char**)memptr, info+4);
1394 pStubMsg->Memory = saved_memory;
1395 }
1396 }
1397 pFormat += 8 * count;
1398 }
1399
1400 if (saved_buffer_length)
1401 {
1402 pStubMsg->PointerLength = pStubMsg->BufferLength;
1403 pStubMsg->BufferLength = saved_buffer_length;
1404 }
1405}
GLsizei stride
Definition: glext.h:5848
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble * u
Definition: glfuncs.h:240
@ FC_NO_REPEAT
Definition: ndrtypes.h:222
@ FC_PP
Definition: ndrtypes.h:228
@ FC_FIXED_REPEAT
Definition: ndrtypes.h:223
@ FC_VARIABLE_OFFSET
Definition: ndrtypes.h:226
@ FC_VARIABLE_REPEAT
Definition: ndrtypes.h:224

Referenced by array_buffer_size(), NdrConformantStructBufferSize(), NdrConformantVaryingStructBufferSize(), NdrFixedArrayBufferSize(), NdrSimpleStructBufferSize(), and NdrVaryingArrayBufferSize().

◆ EmbeddedPointerFree()

static void EmbeddedPointerFree ( PMIDL_STUB_MESSAGE  pStubMsg,
unsigned char pMemory,
PFORMAT_STRING  pFormat 
)
static

Definition at line 1480 of file ndr_marshall.c.

1483{
1484 unsigned rep, count, stride;
1485 unsigned i;
1486
1487 TRACE("(%p,%p,%p)\n", pStubMsg, pMemory, pFormat);
1488 if (*pFormat != FC_PP) return;
1489 pFormat += 2;
1490
1491 while (pFormat[0] != FC_END) {
1492 switch (pFormat[0]) {
1493 default:
1494 FIXME("unknown repeat type %d; assuming no repeat\n", pFormat[0]);
1495 /* fallthrough */
1496 case FC_NO_REPEAT:
1497 rep = 1;
1498 stride = 0;
1499 count = 1;
1500 pFormat += 2;
1501 break;
1502 case FC_FIXED_REPEAT:
1503 rep = *(const WORD*)&pFormat[2];
1504 stride = *(const WORD*)&pFormat[4];
1505 count = *(const WORD*)&pFormat[8];
1506 pFormat += 10;
1507 break;
1508 case FC_VARIABLE_REPEAT:
1509 rep = (pFormat[1] == FC_VARIABLE_OFFSET) ? pStubMsg->ActualCount : pStubMsg->MaxCount;
1510 stride = *(const WORD*)&pFormat[2];
1511 count = *(const WORD*)&pFormat[6];
1512 pFormat += 8;
1513 break;
1514 }
1515 for (i = 0; i < rep; i++) {
1516 PFORMAT_STRING info = pFormat;
1517 unsigned char *membase = pMemory + (i * stride);
1518 unsigned u;
1519
1520 for (u=0; u<count; u++,info+=8) {
1521 unsigned char *memptr = membase + *(const SHORT*)&info[0];
1522 unsigned char *saved_memory = pStubMsg->Memory;
1523
1524 pStubMsg->Memory = membase;
1525 PointerFree(pStubMsg, *(unsigned char**)memptr, info+4);
1526 pStubMsg->Memory = saved_memory;
1527 }
1528 }
1529 pFormat += 8 * count;
1530 }
1531}
static void PointerFree(PMIDL_STUB_MESSAGE pStubMsg, unsigned char *Pointer, PFORMAT_STRING pFormat)

Referenced by array_free(), NdrConformantStructFree(), NdrConformantVaryingStructFree(), NdrFixedArrayFree(), NdrSimpleStructFree(), and NdrVaryingArrayFree().

◆ EmbeddedPointerMarshall()

static unsigned char * EmbeddedPointerMarshall ( PMIDL_STUB_MESSAGE  pStubMsg,
unsigned char pMemory,
PFORMAT_STRING  pFormat 
)
static

Definition at line 1177 of file ndr_marshall.c.

1180{
1181 unsigned char *Mark = pStubMsg->BufferMark;
1182 unsigned rep, count, stride;
1183 unsigned i;
1184 unsigned char *saved_buffer = NULL;
1185
1186 TRACE("(%p,%p,%p)\n", pStubMsg, pMemory, pFormat);
1187
1188 if (*pFormat != FC_PP) return NULL;
1189 pFormat += 2;
1190
1191 if (pStubMsg->PointerBufferMark)
1192 {
1193 saved_buffer = pStubMsg->Buffer;
1194 pStubMsg->Buffer = pStubMsg->PointerBufferMark;
1195 pStubMsg->PointerBufferMark = NULL;
1196 }
1197
1198 while (pFormat[0] != FC_END) {
1199 switch (pFormat[0]) {
1200 default:
1201 FIXME("unknown repeat type %d; assuming no repeat\n", pFormat[0]);
1202 /* fallthrough */
1203 case FC_NO_REPEAT:
1204 rep = 1;
1205 stride = 0;
1206 count = 1;
1207 pFormat += 2;
1208 break;
1209 case FC_FIXED_REPEAT:
1210 rep = *(const WORD*)&pFormat[2];
1211 stride = *(const WORD*)&pFormat[4];
1212 count = *(const WORD*)&pFormat[8];
1213 pFormat += 10;
1214 break;
1215 case FC_VARIABLE_REPEAT:
1216 rep = (pFormat[1] == FC_VARIABLE_OFFSET) ? pStubMsg->ActualCount : pStubMsg->MaxCount;
1217 stride = *(const WORD*)&pFormat[2];
1218 count = *(const WORD*)&pFormat[6];
1219 pFormat += 8;
1220 break;
1221 }
1222 for (i = 0; i < rep; i++) {
1223 PFORMAT_STRING info = pFormat;
1224 unsigned char *membase = pMemory + (i * stride);
1225 unsigned char *bufbase = Mark + (i * stride);
1226 unsigned u;
1227
1228 for (u=0; u<count; u++,info+=8) {
1229 unsigned char *memptr = membase + *(const SHORT*)&info[0];
1230 unsigned char *bufptr = bufbase + *(const SHORT*)&info[2];
1231 unsigned char *saved_memory = pStubMsg->Memory;
1232
1233 pStubMsg->Memory = membase;
1234 PointerMarshall(pStubMsg, bufptr, *(unsigned char**)memptr, info+4);
1235 pStubMsg->Memory = saved_memory;
1236 }
1237 }
1238 pFormat += 8 * count;
1239 }
1240
1241 if (saved_buffer)
1242 {
1243 pStubMsg->PointerBufferMark = pStubMsg->Buffer;
1244 pStubMsg->Buffer = saved_buffer;
1245 }
1246
1247 STD_OVERFLOW_CHECK(pStubMsg);
1248
1249 return NULL;
1250}
static VOID Mark(PGUI_CONSOLE_DATA GuiData)
Definition: conwnd.c:300
static unsigned int bufptr
Definition: tncon.cpp:77

Referenced by array_write_variance_and_marshall(), NdrConformantStructMarshall(), NdrConformantVaryingStructMarshall(), NdrFixedArrayMarshall(), NdrSimpleStructMarshall(), and NdrVaryingArrayMarshall().

◆ EmbeddedPointerMemorySize()

static ULONG EmbeddedPointerMemorySize ( PMIDL_STUB_MESSAGE  pStubMsg,
PFORMAT_STRING  pFormat 
)
static

Definition at line 1410 of file ndr_marshall.c.

1412{
1413 unsigned char *Mark = pStubMsg->BufferMark;
1414 unsigned rep, count, stride;
1415 unsigned i;
1416 unsigned char *saved_buffer = NULL;
1417
1418 TRACE("(%p,%p)\n", pStubMsg, pFormat);
1419
1420 if (pStubMsg->IgnoreEmbeddedPointers) return 0;
1421
1422 if (pStubMsg->PointerBufferMark)
1423 {
1424 saved_buffer = pStubMsg->Buffer;
1425 pStubMsg->Buffer = pStubMsg->PointerBufferMark;
1426 pStubMsg->PointerBufferMark = NULL;
1427 }
1428
1429 if (*pFormat != FC_PP) return 0;
1430 pFormat += 2;
1431
1432 while (pFormat[0] != FC_END) {
1433 switch (pFormat[0]) {
1434 default:
1435 FIXME("unknown repeat type %d; assuming no repeat\n", pFormat[0]);
1436 /* fallthrough */
1437 case FC_NO_REPEAT:
1438 rep = 1;
1439 stride = 0;
1440 count = 1;
1441 pFormat += 2;
1442 break;
1443 case FC_FIXED_REPEAT:
1444 rep = *(const WORD*)&pFormat[2];
1445 stride = *(const WORD*)&pFormat[4];
1446 count = *(const WORD*)&pFormat[8];
1447 pFormat += 10;
1448 break;
1449 case FC_VARIABLE_REPEAT:
1450 rep = (pFormat[1] == FC_VARIABLE_OFFSET) ? pStubMsg->ActualCount : pStubMsg->MaxCount;
1451 stride = *(const WORD*)&pFormat[2];
1452 count = *(const WORD*)&pFormat[6];
1453 pFormat += 8;
1454 break;
1455 }
1456 for (i = 0; i < rep; i++) {
1457 PFORMAT_STRING info = pFormat;
1458 unsigned char *bufbase = Mark + (i * stride);
1459 unsigned u;
1460 for (u=0; u<count; u++,info+=8) {
1461 unsigned char *bufptr = bufbase + *(const SHORT*)&info[2];
1462 PointerMemorySize(pStubMsg, bufptr, info+4);
1463 }
1464 }
1465 pFormat += 8 * count;
1466 }
1467
1468 if (saved_buffer)
1469 {
1470 pStubMsg->PointerBufferMark = pStubMsg->Buffer;
1471 pStubMsg->Buffer = saved_buffer;
1472 }
1473
1474 return 0;
1475}

Referenced by array_memory_size(), NdrConformantVaryingStructMemorySize(), NdrFixedArrayMemorySize(), NdrSimpleStructMemorySize(), and NdrVaryingArrayMemorySize().

◆ EmbeddedPointerUnmarshall()

static unsigned char * EmbeddedPointerUnmarshall ( PMIDL_STUB_MESSAGE  pStubMsg,
unsigned char pDstBuffer,
unsigned char pSrcMemoryPtrs,
PFORMAT_STRING  pFormat,
unsigned char  fMustAlloc 
)
static

Definition at line 1260 of file ndr_marshall.c.

1265{
1266 unsigned char *Mark = pStubMsg->BufferMark;
1267 unsigned rep, count, stride;
1268 unsigned i;
1269 unsigned char *saved_buffer = NULL;
1270
1271 TRACE("(%p,%p,%p,%p,%d)\n", pStubMsg, pDstBuffer, pSrcMemoryPtrs, pFormat, fMustAlloc);
1272
1273 if (*pFormat != FC_PP) return NULL;
1274 pFormat += 2;
1275
1276 if (pStubMsg->PointerBufferMark)
1277 {
1278 saved_buffer = pStubMsg->Buffer;
1279 pStubMsg->Buffer = pStubMsg->PointerBufferMark;
1280 pStubMsg->PointerBufferMark = NULL;
1281 }
1282
1283 while (pFormat[0] != FC_END) {
1284 TRACE("pFormat[0] = 0x%x\n", pFormat[0]);
1285 switch (pFormat[0]) {
1286 default:
1287 FIXME("unknown repeat type %d; assuming no repeat\n", pFormat[0]);
1288 /* fallthrough */
1289 case FC_NO_REPEAT:
1290 rep = 1;
1291 stride = 0;
1292 count = 1;
1293 pFormat += 2;
1294 break;
1295 case FC_FIXED_REPEAT:
1296 rep = *(const WORD*)&pFormat[2];
1297 stride = *(const WORD*)&pFormat[4];
1298 count = *(const WORD*)&pFormat[8];
1299 pFormat += 10;
1300 break;
1301 case FC_VARIABLE_REPEAT:
1302 rep = (pFormat[1] == FC_VARIABLE_OFFSET) ? pStubMsg->ActualCount : pStubMsg->MaxCount;
1303 stride = *(const WORD*)&pFormat[2];
1304 count = *(const WORD*)&pFormat[6];
1305 pFormat += 8;
1306 break;
1307 }
1308 for (i = 0; i < rep; i++) {
1309 PFORMAT_STRING info = pFormat;
1310 unsigned char *bufdstbase = pDstBuffer + (i * stride);
1311 unsigned char *memsrcbase = pSrcMemoryPtrs + (i * stride);
1312 unsigned char *bufbase = Mark + (i * stride);
1313 unsigned u;
1314
1315 for (u=0; u<count; u++,info+=8) {
1316 unsigned char **bufdstptr = (unsigned char **)(bufdstbase + *(const SHORT*)&info[2]);
1317 unsigned char **memsrcptr = (unsigned char **)(memsrcbase + *(const SHORT*)&info[0]);
1318 unsigned char *bufptr = bufbase + *(const SHORT*)&info[2];
1319 PointerUnmarshall(pStubMsg, bufptr, bufdstptr, *memsrcptr, info+4, fMustAlloc);
1320 }
1321 }
1322 pFormat += 8 * count;
1323 }
1324
1325 if (saved_buffer)
1326 {
1327 pStubMsg->PointerBufferMark = pStubMsg->Buffer;
1328 pStubMsg->Buffer = saved_buffer;
1329 }
1330
1331 return NULL;
1332}

Referenced by array_read_variance_and_unmarshall(), NdrConformantStructUnmarshall(), NdrConformantVaryingStructUnmarshall(), NdrFixedArrayUnmarshall(), NdrSimpleStructUnmarshall(), and NdrVaryingArrayUnmarshall().

◆ get_arm_offset_from_union_arm_selector()

static PFORMAT_STRING get_arm_offset_from_union_arm_selector ( PMIDL_STUB_MESSAGE  pStubMsg,
ULONG  discriminant,
PFORMAT_STRING  pFormat 
)
static

Definition at line 5685 of file ndr_marshall.c.

5688{
5689 unsigned short num_arms, arm, type;
5690
5691 num_arms = *(const SHORT*)pFormat & 0x0fff;
5692 pFormat += 2;
5693 for(arm = 0; arm < num_arms; arm++)
5694 {
5695 if(discriminant == *(const ULONG*)pFormat)
5696 {
5697 pFormat += 4;
5698 break;
5699 }
5700 pFormat += 6;
5701 }
5702
5703 type = *(const unsigned short*)pFormat;
5704 TRACE("type %04x\n", type);
5705 if(arm == num_arms) /* default arm extras */
5706 {
5707 if(type == 0xffff)
5708 {
5709 ERR("no arm for 0x%x and no default case\n", discriminant);
5711 return NULL;
5712 }
5713 if(type == 0)
5714 {
5715 TRACE("falling back to empty default case for 0x%x\n", discriminant);
5716 return NULL;
5717 }
5718 }
5719 return pFormat;
5720}
@ arm
Definition: optimize.h:109
#define RPC_S_INVALID_TAG
Definition: winerror.h:1042

Referenced by union_arm_buffer_size(), union_arm_free(), union_arm_marshall(), union_arm_memory_size(), and union_arm_unmarshall().

◆ get_discriminant()

static ULONG get_discriminant ( unsigned char  fc,
const unsigned char pMemory 
)
static

Definition at line 5661 of file ndr_marshall.c.

5662{
5663 switch (fc)
5664 {
5665 case FC_BYTE:
5666 case FC_CHAR:
5667 case FC_SMALL:
5668 case FC_USMALL:
5669 return *pMemory;
5670 case FC_WCHAR:
5671 case FC_SHORT:
5672 case FC_USHORT:
5673 case FC_ENUM16:
5674 return *(const USHORT *)pMemory;
5675 case FC_LONG:
5676 case FC_ULONG:
5677 case FC_ENUM32:
5678 return *(const ULONG *)pMemory;
5679 default:
5680 FIXME("Unhandled base type: 0x%02x\n", fc);
5681 return 0;
5682 }
5683}

Referenced by NdrEncapsulatedUnionBufferSize(), NdrEncapsulatedUnionFree(), NdrEncapsulatedUnionMarshall(), NdrEncapsulatedUnionMemorySize(), and NdrEncapsulatedUnionUnmarshall().

◆ IsConformanceOrVariancePresent()

static BOOL IsConformanceOrVariancePresent ( PFORMAT_STRING  pFormat)
inlinestatic

◆ NdrAllocate()

void *WINAPI NdrAllocate ( MIDL_STUB_MESSAGE pStubMsg,
SIZE_T  len 
)

Definition at line 419 of file ndr_marshall.c.

420{
421 SIZE_T aligned_len;
422 SIZE_T adjusted_len;
423 void *p;
424 NDR_MEMORY_LIST *mem_list;
425
426 aligned_len = (len + 7) & ~7;
427 adjusted_len = aligned_len + sizeof(NDR_MEMORY_LIST);
428 /* check for overflow */
429 if (adjusted_len < len)
430 {
431 ERR("overflow of adjusted_len %ld, len %ld\n", adjusted_len, len);
433 }
434
435 p = pStubMsg->pfnAllocate(adjusted_len);
437
438 mem_list = (NDR_MEMORY_LIST *)((char *)p + aligned_len);
439 mem_list->magic = MEML_MAGIC;
440 mem_list->size = aligned_len;
441 mem_list->reserved = 0;
442 mem_list->next = pStubMsg->pMemoryList;
443 pStubMsg->pMemoryList = mem_list;
444
445 TRACE("-- %p\n", p);
446 return p;
447}
#define MEML_MAGIC
Definition: ndr_marshall.c:400
struct _NDR_MEMORY_LIST NDR_MEMORY_LIST
GLfloat GLfloat p
Definition: glext.h:8902
#define RPC_X_NO_MEMORY
Definition: rpcnterr.h:35
void * pMemoryList
Definition: rpcndr.h:264
struct _NDR_MEMORY_LIST * next
Definition: ndr_marshall.c:397
ULONG_PTR SIZE_T
Definition: typedefs.h:80

Referenced by array_read_variance_and_unmarshall(), NdrAllocateZero(), NdrBaseTypeUnmarshall(), NdrEncapsulatedUnionUnmarshall(), NdrNonConformantStringUnmarshall(), NdrNonEncapsulatedUnionUnmarshall(), NdrUserMarshalUnmarshall(), stub_do_args(), and test_ndr_allocate().

◆ NdrAllocateZero()

◆ NdrBaseTypeBufferSize()

static void WINAPI NdrBaseTypeBufferSize ( PMIDL_STUB_MESSAGE  pStubMsg,
unsigned char pMemory,
PFORMAT_STRING  pFormat 
)
static

Definition at line 6811 of file ndr_marshall.c.

6815{
6816 TRACE("pStubMsg %p, pMemory %p, type 0x%02x\n", pStubMsg, pMemory, *pFormat);
6817
6818 switch(*pFormat)
6819 {
6820 case FC_BYTE:
6821 case FC_CHAR:
6822 case FC_SMALL:
6823 case FC_USMALL:
6824 safe_buffer_length_increment(pStubMsg, sizeof(UCHAR));
6825 break;
6826 case FC_WCHAR:
6827 case FC_SHORT:
6828 case FC_USHORT:
6829 case FC_ENUM16:
6830 align_length(&pStubMsg->BufferLength, sizeof(USHORT));
6831 safe_buffer_length_increment(pStubMsg, sizeof(USHORT));
6832 break;
6833 case FC_LONG:
6834 case FC_ULONG:
6835 case FC_ENUM32:
6836 case FC_INT3264:
6837 case FC_UINT3264:
6838 align_length(&pStubMsg->BufferLength, sizeof(ULONG));
6839 safe_buffer_length_increment(pStubMsg, sizeof(ULONG));
6840 break;
6841 case FC_FLOAT:
6842 align_length(&pStubMsg->BufferLength, sizeof(float));
6843 safe_buffer_length_increment(pStubMsg, sizeof(float));
6844 break;
6845 case FC_DOUBLE:
6846 align_length(&pStubMsg->BufferLength, sizeof(double));
6847 safe_buffer_length_increment(pStubMsg, sizeof(double));
6848 break;
6849 case FC_HYPER:
6850 align_length(&pStubMsg->BufferLength, sizeof(ULONGLONG));
6851 safe_buffer_length_increment(pStubMsg, sizeof(ULONGLONG));
6852 break;
6853 case FC_ERROR_STATUS_T:
6854 align_length(&pStubMsg->BufferLength, sizeof(error_status_t));
6856 break;
6857 case FC_IGNORE:
6858 break;
6859 default:
6860 FIXME("Unhandled base type: 0x%02x\n", *pFormat);
6861 }
6862}
unsigned long error_status_t
Definition: basetyps.h:83
@ FC_IGNORE
Definition: ndrtypes.h:149
@ FC_ERROR_STATUS_T
Definition: ndrtypes.h:150

Referenced by NdrEncapsulatedUnionBufferSize(), NdrNonEncapsulatedUnionBufferSize(), NdrRangeBufferSize(), and union_arm_buffer_size().

◆ NdrBaseTypeFree()

static void WINAPI NdrBaseTypeFree ( PMIDL_STUB_MESSAGE  pStubMsg,
unsigned char pMemory,
PFORMAT_STRING  pFormat 
)
static

Definition at line 6948 of file ndr_marshall.c.

6951{
6952 TRACE("pStubMsg %p pMemory %p type 0x%02x\n", pStubMsg, pMemory, *pFormat);
6953
6954 /* nothing to do */
6955}

◆ NdrBaseTypeMarshall()

static unsigned char *WINAPI NdrBaseTypeMarshall ( PMIDL_STUB_MESSAGE  pStubMsg,
unsigned char pMemory,
PFORMAT_STRING  pFormat 
)
static

Definition at line 6617 of file ndr_marshall.c.

6621{
6622 TRACE("pStubMsg %p, pMemory %p, type 0x%02x\n", pStubMsg, pMemory, *pFormat);
6623
6624 switch(*pFormat)
6625 {
6626 case FC_BYTE:
6627 case FC_CHAR:
6628 case FC_SMALL:
6629 case FC_USMALL:
6630 safe_copy_to_buffer(pStubMsg, pMemory, sizeof(UCHAR));
6631 TRACE("value: 0x%02x\n", *pMemory);
6632 break;
6633 case FC_WCHAR:
6634 case FC_SHORT:
6635 case FC_USHORT:
6636 align_pointer_clear(&pStubMsg->Buffer, sizeof(USHORT));
6637 safe_copy_to_buffer(pStubMsg, pMemory, sizeof(USHORT));
6638 TRACE("value: 0x%04x\n", *(USHORT *)pMemory);
6639 break;
6640 case FC_LONG:
6641 case FC_ULONG:
6642 case FC_ERROR_STATUS_T:
6643 case FC_ENUM32:
6644 align_pointer_clear(&pStubMsg->Buffer, sizeof(ULONG));
6645 safe_copy_to_buffer(pStubMsg, pMemory, sizeof(ULONG));
6646 TRACE("value: 0x%08x\n", *(ULONG *)pMemory);
6647 break;
6648 case FC_FLOAT:
6649 align_pointer_clear(&pStubMsg->Buffer, sizeof(float));
6650 safe_copy_to_buffer(pStubMsg, pMemory, sizeof(float));
6651 break;
6652 case FC_DOUBLE:
6653 align_pointer_clear(&pStubMsg->Buffer, sizeof(double));
6654 safe_copy_to_buffer(pStubMsg, pMemory, sizeof(double));
6655 break;
6656 case FC_HYPER:
6657 align_pointer_clear(&pStubMsg->Buffer, sizeof(ULONGLONG));
6658 safe_copy_to_buffer(pStubMsg, pMemory, sizeof(ULONGLONG));
6659 TRACE("value: %s\n", wine_dbgstr_longlong(*(ULONGLONG*)pMemory));
6660 break;
6661 case FC_ENUM16:
6662 {
6663 USHORT val = *(UINT *)pMemory;
6664 /* only 16-bits on the wire, so do a sanity check */
6665 if (*(UINT *)pMemory > SHRT_MAX)
6667 align_pointer_clear(&pStubMsg->Buffer, sizeof(USHORT));
6668 safe_copy_to_buffer(pStubMsg, &val, sizeof(val));
6669 TRACE("value: 0x%04x\n", *(UINT *)pMemory);
6670 break;
6671 }
6672 case FC_INT3264:
6673 case FC_UINT3264:
6674 {
6675 UINT val = *(UINT_PTR *)pMemory;
6676 align_pointer_clear(&pStubMsg->Buffer, sizeof(UINT));
6677 safe_copy_to_buffer(pStubMsg, &val, sizeof(val));
6678 break;
6679 }
6680 case FC_IGNORE:
6681 break;
6682 default:
6683 FIXME("Unhandled base type: 0x%02x\n", *pFormat);
6684 }
6685
6686 /* FIXME: what is the correct return value? */
6687 return NULL;
6688}
#define SHRT_MAX
Definition: limits.h:37

Referenced by NdrEncapsulatedUnionMarshall(), NdrNonEncapsulatedUnionMarshall(), NdrRangeMarshall(), NdrSimpleTypeMarshall(), and union_arm_marshall().

◆ NdrBaseTypeMemorySize()

static ULONG WINAPI NdrBaseTypeMemorySize ( PMIDL_STUB_MESSAGE  pStubMsg,
PFORMAT_STRING  pFormat 
)
static

Definition at line 6867 of file ndr_marshall.c.

6870{
6871 TRACE("pStubMsg %p, type 0x%02x\n", pStubMsg, *pFormat);
6872
6873 switch(*pFormat)
6874 {
6875 case FC_BYTE:
6876 case FC_CHAR:
6877 case FC_SMALL:
6878 case FC_USMALL:
6879 safe_buffer_increment(pStubMsg, sizeof(UCHAR));
6880 pStubMsg->MemorySize += sizeof(UCHAR);
6881 return sizeof(UCHAR);
6882 case FC_WCHAR:
6883 case FC_SHORT:
6884 case FC_USHORT:
6885 align_pointer(&pStubMsg->Buffer, sizeof(USHORT));
6886 safe_buffer_increment(pStubMsg, sizeof(USHORT));
6887 align_length(&pStubMsg->MemorySize, sizeof(USHORT));
6888 pStubMsg->MemorySize += sizeof(USHORT);
6889 return sizeof(USHORT);
6890 case FC_LONG:
6891 case FC_ULONG:
6892 case FC_ENUM32:
6893 align_pointer(&pStubMsg->Buffer, sizeof(ULONG));
6894 safe_buffer_increment(pStubMsg, sizeof(ULONG));
6895 align_length(&pStubMsg->MemorySize, sizeof(ULONG));
6896 pStubMsg->MemorySize += sizeof(ULONG);
6897 return sizeof(ULONG);
6898 case FC_FLOAT:
6899 align_pointer(&pStubMsg->Buffer, sizeof(float));
6900 safe_buffer_increment(pStubMsg, sizeof(float));
6901 align_length(&pStubMsg->MemorySize, sizeof(float));
6902 pStubMsg->MemorySize += sizeof(float);
6903 return sizeof(float);
6904 case FC_DOUBLE:
6905 align_pointer(&pStubMsg->Buffer, sizeof(double));
6906 safe_buffer_increment(pStubMsg, sizeof(double));
6907 align_length(&pStubMsg->MemorySize, sizeof(double));
6908 pStubMsg->MemorySize += sizeof(double);
6909 return sizeof(double);
6910 case FC_HYPER:
6911 align_pointer(&pStubMsg->Buffer, sizeof(ULONGLONG));
6912 safe_buffer_increment(pStubMsg, sizeof(ULONGLONG));
6913 align_length(&pStubMsg->MemorySize, sizeof(ULONGLONG));
6914 pStubMsg->MemorySize += sizeof(ULONGLONG);
6915 return sizeof(ULONGLONG);
6916 case FC_ERROR_STATUS_T:
6917 align_pointer(&pStubMsg->Buffer, sizeof(error_status_t));
6918 safe_buffer_increment(pStubMsg, sizeof(error_status_t));
6919 align_length(&pStubMsg->MemorySize, sizeof(error_status_t));
6920 pStubMsg->MemorySize += sizeof(error_status_t);
6921 return sizeof(error_status_t);
6922 case FC_ENUM16:
6923 align_pointer(&pStubMsg->Buffer, sizeof(USHORT));
6924 safe_buffer_increment(pStubMsg, sizeof(USHORT));
6925 align_length(&pStubMsg->MemorySize, sizeof(UINT));
6926 pStubMsg->MemorySize += sizeof(UINT);
6927 return sizeof(UINT);
6928 case FC_INT3264:
6929 case FC_UINT3264:
6930 align_pointer(&pStubMsg->Buffer, sizeof(UINT));
6931 safe_buffer_increment(pStubMsg, sizeof(UINT));
6932 align_length(&pStubMsg->MemorySize, sizeof(UINT_PTR));
6933 pStubMsg->MemorySize += sizeof(UINT_PTR);
6934 return sizeof(UINT_PTR);
6935 case FC_IGNORE:
6936 align_length(&pStubMsg->MemorySize, sizeof(void *));
6937 pStubMsg->MemorySize += sizeof(void *);
6938 return sizeof(void *);
6939 default:
6940 FIXME("Unhandled base type: 0x%02x\n", *pFormat);
6941 return 0;
6942 }
6943}

Referenced by NdrRangeMemorySize(), and union_arm_memory_size().

◆ NdrBaseTypeUnmarshall()

static unsigned char *WINAPI NdrBaseTypeUnmarshall ( PMIDL_STUB_MESSAGE  pStubMsg,
unsigned char **  ppMemory,
PFORMAT_STRING  pFormat,
unsigned char  fMustAlloc 
)
static

Definition at line 6693 of file ndr_marshall.c.

6698{
6699 TRACE("pStubMsg: %p, ppMemory: %p, type: 0x%02x, fMustAlloc: %s\n", pStubMsg, ppMemory, *pFormat, fMustAlloc ? "true" : "false");
6700
6701#define BASE_TYPE_UNMARSHALL(type) do { \
6702 align_pointer(&pStubMsg->Buffer, sizeof(type)); \
6703 if (!fMustAlloc && !pStubMsg->IsClient && !*ppMemory) \
6704 { \
6705 *ppMemory = pStubMsg->Buffer; \
6706 TRACE("*ppMemory: %p\n", *ppMemory); \
6707 safe_buffer_increment(pStubMsg, sizeof(type)); \
6708 } \
6709 else \
6710 { \
6711 if (fMustAlloc) \
6712 *ppMemory = NdrAllocate(pStubMsg, sizeof(type)); \
6713 TRACE("*ppMemory: %p\n", *ppMemory); \
6714 safe_copy_from_buffer(pStubMsg, *ppMemory, sizeof(type)); \
6715 } \
6716 } while (0)
6717
6718 switch(*pFormat)
6719 {
6720 case FC_BYTE:
6721 case FC_CHAR:
6722 case FC_SMALL:
6723 case FC_USMALL:
6725 TRACE("value: 0x%02x\n", **ppMemory);
6726 break;
6727 case FC_WCHAR:
6728 case FC_SHORT:
6729 case FC_USHORT:
6731 TRACE("value: 0x%04x\n", **(USHORT **)ppMemory);
6732 break;
6733 case FC_LONG:
6734 case FC_ULONG:
6735 case FC_ERROR_STATUS_T:
6736 case FC_ENUM32:
6738 TRACE("value: 0x%08x\n", **(ULONG **)ppMemory);
6739 break;
6740 case FC_FLOAT:
6741 BASE_TYPE_UNMARSHALL(float);
6742 TRACE("value: %f\n", **(float **)ppMemory);
6743 break;
6744 case FC_DOUBLE:
6745 BASE_TYPE_UNMARSHALL(double);
6746 TRACE("value: %f\n", **(double **)ppMemory);
6747 break;
6748 case FC_HYPER:
6750 TRACE("value: %s\n", wine_dbgstr_longlong(**(ULONGLONG **)ppMemory));
6751 break;
6752 case FC_ENUM16:
6753 {
6754 USHORT val;
6755 align_pointer(&pStubMsg->Buffer, sizeof(USHORT));
6756 if (!fMustAlloc && !*ppMemory)
6757 fMustAlloc = TRUE;
6758 if (fMustAlloc)
6759 *ppMemory = NdrAllocate(pStubMsg, sizeof(UINT));
6760 safe_copy_from_buffer(pStubMsg, &val, sizeof(USHORT));
6761 /* 16-bits on the wire, but int in memory */
6762 **(UINT **)ppMemory = val;
6763 TRACE("value: 0x%08x\n", **(UINT **)ppMemory);
6764 break;
6765 }
6766 case FC_INT3264:
6767 if (sizeof(INT_PTR) == sizeof(INT)) BASE_TYPE_UNMARSHALL(INT);
6768 else
6769 {
6770 INT val;
6771 align_pointer(&pStubMsg->Buffer, sizeof(INT));
6772 if (!fMustAlloc && !*ppMemory)
6773 fMustAlloc = TRUE;
6774 if (fMustAlloc)
6775 *ppMemory = NdrAllocate(pStubMsg, sizeof(INT_PTR));
6776 safe_copy_from_buffer(pStubMsg, &val, sizeof(INT));
6777 **(INT_PTR **)ppMemory = val;
6778 TRACE("value: 0x%08lx\n", **(INT_PTR **)ppMemory);
6779 }
6780 break;
6781 case FC_UINT3264:
6782 if (sizeof(UINT_PTR) == sizeof(UINT)) BASE_TYPE_UNMARSHALL(UINT);
6783 else
6784 {
6785 UINT val;
6786 align_pointer(&pStubMsg->Buffer, sizeof(UINT));
6787 if (!fMustAlloc && !*ppMemory)
6788 fMustAlloc = TRUE;
6789 if (fMustAlloc)
6790 *ppMemory = NdrAllocate(pStubMsg, sizeof(UINT_PTR));
6791 safe_copy_from_buffer(pStubMsg, &val, sizeof(UINT));
6792 **(UINT_PTR **)ppMemory = val;
6793 TRACE("value: 0x%08lx\n", **(UINT_PTR **)ppMemory);
6794 }
6795 break;
6796 case FC_IGNORE:
6797 break;
6798 default:
6799 FIXME("Unhandled base type: 0x%02x\n", *pFormat);
6800 }
6801#undef BASE_TYPE_UNMARSHALL
6802
6803 /* FIXME: what is the correct return value? */
6804
6805 return NULL;
6806}
#define BASE_TYPE_UNMARSHALL(type)

Referenced by NdrEncapsulatedUnionUnmarshall(), and union_arm_unmarshall().

◆ NdrByteCountPointerBufferSize()

void WINAPI NdrByteCountPointerBufferSize ( PMIDL_STUB_MESSAGE  pStubMsg,
unsigned char pMemory,
PFORMAT_STRING  pFormat 
)

Definition at line 6355 of file ndr_marshall.c.

6358{
6359 FIXME("stub\n");
6360}

◆ NdrByteCountPointerFree()

void WINAPI NdrByteCountPointerFree ( PMIDL_STUB_MESSAGE  pStubMsg,
unsigned char pMemory,
PFORMAT_STRING  pFormat 
)

Definition at line 6375 of file ndr_marshall.c.

6378{
6379 FIXME("stub\n");
6380}

◆ NdrByteCountPointerMarshall()

unsigned char *WINAPI NdrByteCountPointerMarshall ( PMIDL_STUB_MESSAGE  pStubMsg,
unsigned char pMemory,
PFORMAT_STRING  pFormat 
)

Definition at line 6332 of file ndr_marshall.c.

6335{
6336 FIXME("stub\n");
6337 return NULL;
6338}

◆ NdrByteCountPointerMemorySize()

static ULONG WINAPI NdrByteCountPointerMemorySize ( PMIDL_STUB_MESSAGE  pStubMsg,
PFORMAT_STRING  pFormat 
)
static

Definition at line 6365 of file ndr_marshall.c.

6367{
6368 FIXME("stub\n");
6369 return 0;
6370}

◆ NdrByteCountPointerUnmarshall()

unsigned char *WINAPI NdrByteCountPointerUnmarshall ( PMIDL_STUB_MESSAGE  pStubMsg,
unsigned char **  ppMemory,
PFORMAT_STRING  pFormat,
unsigned char  fMustAlloc 
)

Definition at line 6343 of file ndr_marshall.c.

6347{
6348 FIXME("stub\n");
6349 return NULL;
6350}

◆ NdrClearOutParameters()

void WINAPI NdrClearOutParameters ( PMIDL_STUB_MESSAGE  pStubMsg,
PFORMAT_STRING  pFormat,
void ArgAddr 
)

Definition at line 4661 of file ndr_marshall.c.

4664{
4665 FIXME("(%p,%p,%p): stub\n", pStubMsg, pFormat, ArgAddr);
4666}

Referenced by client_do_args().

◆ NdrClientContextMarshall()

void WINAPI NdrClientContextMarshall ( PMIDL_STUB_MESSAGE  pStubMsg,
NDR_CCONTEXT  ContextHandle,
int  fCheck 
)

Definition at line 7057 of file ndr_marshall.c.

7060{
7061 TRACE("(%p, %p, %d)\n", pStubMsg, ContextHandle, fCheck);
7062
7063 align_pointer_clear(&pStubMsg->Buffer, 4);
7064
7065 if (pStubMsg->Buffer + cbNDRContext > (unsigned char *)pStubMsg->RpcMsg->Buffer + pStubMsg->BufferLength)
7066 {
7067 ERR("buffer overflow - Buffer = %p, BufferEnd = %p\n",
7068 pStubMsg->Buffer, (unsigned char *)pStubMsg->RpcMsg->Buffer + pStubMsg->BufferLength);
7070 }
7071
7072 /* FIXME: what does fCheck do? */
7073 NDRCContextMarshall(ContextHandle,
7074 pStubMsg->Buffer);
7075
7076 pStubMsg->Buffer += cbNDRContext;
7077}
void WINAPI NDRCContextMarshall(NDR_CCONTEXT CContext, void *pBuff)
#define cbNDRContext
Definition: rpcndr.h:151
PRPC_MESSAGE RpcMsg
Definition: rpcndr.h:202
void * Buffer
Definition: rpcdcep.h:40

Referenced by CtxClose(), CtxHello(), m_CtxClose(), m_CtxHello(), m_CtxOpen2(), and NdrContextHandleMarshall().

◆ NdrClientContextUnmarshall()

void WINAPI NdrClientContextUnmarshall ( PMIDL_STUB_MESSAGE  pStubMsg,
NDR_CCONTEXT pContextHandle,
RPC_BINDING_HANDLE  BindHandle 
)

Definition at line 7082 of file ndr_marshall.c.

7085{
7086 TRACE("(%p, %p, %p)\n", pStubMsg, pContextHandle, BindHandle);
7087
7088 align_pointer(&pStubMsg->Buffer, 4);
7089
7090 if (pStubMsg->Buffer + cbNDRContext > pStubMsg->BufferEnd)
7092
7093 NDRCContextUnmarshall(pContextHandle,
7094 BindHandle,
7095 pStubMsg->Buffer,
7096 pStubMsg->RpcMsg->DataRepresentation);
7097
7098 pStubMsg->Buffer += cbNDRContext;
7099}
void WINAPI NDRCContextUnmarshall(NDR_CCONTEXT *CContext, RPC_BINDING_HANDLE hBinding, void *pBuff, ULONG DataRepresentation)
unsigned char * BufferEnd
Definition: rpcndr.h:205
ULONG DataRepresentation
Definition: rpcdcep.h:39

Referenced by CtxClose(), CtxOpen(), m_CtxClose(), m_CtxOpen(), m_CtxOpen2(), and NdrContextHandleUnmarshall().

◆ NdrComplexArrayBufferSize()

void WINAPI NdrComplexArrayBufferSize ( PMIDL_STUB_MESSAGE  pStubMsg,
unsigned char pMemory,
PFORMAT_STRING  pFormat 
)

Definition at line 4271 of file ndr_marshall.c.

4274{
4275 int pointer_length_set = 0;
4276
4277 TRACE("(%p,%p,%p)\n", pStubMsg, pMemory, pFormat);
4278
4279 if (pFormat[0] != FC_BOGUS_ARRAY)
4280 {
4281 ERR("invalid format type %x\n", pFormat[0]);
4283 return;
4284 }
4285
4286 if (!pStubMsg->IgnoreEmbeddedPointers && !pStubMsg->PointerLength)
4287 {
4288 /* save buffer fields that may be changed by buffer sizer functions
4289 * and that may be needed later on */
4290 int saved_ignore_embedded = pStubMsg->IgnoreEmbeddedPointers;
4291 ULONG saved_buffer_length = pStubMsg->BufferLength;
4292 ULONG_PTR saved_max_count = pStubMsg->MaxCount;
4293 ULONG saved_offset = pStubMsg->Offset;
4294 ULONG saved_actual_count = pStubMsg->ActualCount;
4295
4296 /* get the buffer pointer after complex array data, but before
4297 * pointer data */
4298 pStubMsg->IgnoreEmbeddedPointers = 1;
4299 NdrComplexArrayBufferSize(pStubMsg, pMemory, pFormat);
4300 pStubMsg->IgnoreEmbeddedPointers = saved_ignore_embedded;
4301
4302 /* save it for use by embedded pointer code later */
4303 pStubMsg->PointerLength = pStubMsg->BufferLength;
4304 pointer_length_set = 1;
4305
4306 /* restore fields */
4307 pStubMsg->ActualCount = saved_actual_count;
4308 pStubMsg->Offset = saved_offset;
4309 pStubMsg->MaxCount = saved_max_count;
4310 pStubMsg->BufferLength = saved_buffer_length;
4311 }
4312
4314 array_buffer_size(FC_BOGUS_ARRAY, pStubMsg, pMemory, pFormat, TRUE /* fHasPointers */);
4315
4316 if(pointer_length_set)
4317 {
4318 pStubMsg->BufferLength = pStubMsg->PointerLength;
4319 pStubMsg->PointerLength = 0;
4320 }
4321}
static void array_buffer_size(unsigned char fc, PMIDL_STUB_MESSAGE pStubMsg, unsigned char *pMemory, PFORMAT_STRING pFormat, unsigned char fHasPointers)
void WINAPI NdrComplexArrayBufferSize(PMIDL_STUB_MESSAGE pStubMsg, unsigned char *pMemory, PFORMAT_STRING pFormat)
static void array_compute_and_size_conformance(unsigned char fc, PMIDL_STUB_MESSAGE pStubMsg, unsigned char *pMemory, PFORMAT_STRING pFormat)
#define RPC_S_INTERNAL_ERROR
Definition: winerror.h:1074

Referenced by NdrComplexArrayBufferSize(), and NdrComplexArrayMarshall().

◆ NdrComplexArrayFree()

void WINAPI NdrComplexArrayFree ( PMIDL_STUB_MESSAGE  pStubMsg,
unsigned char pMemory,
PFORMAT_STRING  pFormat 
)

Definition at line 4346 of file ndr_marshall.c.

4349{
4350 ULONG i, count, def;
4351
4352 TRACE("(%p,%p,%p)\n", pStubMsg, pMemory, pFormat);
4353
4354 if (pFormat[0] != FC_BOGUS_ARRAY)
4355 {
4356 ERR("invalid format type %x\n", pFormat[0]);
4358 return;
4359 }
4360
4361 def = *(const WORD*)&pFormat[2];
4362 pFormat += 4;
4363
4364 pFormat = ComputeConformance(pStubMsg, pMemory, pFormat, def);
4365 TRACE("conformance = %ld\n", pStubMsg->MaxCount);
4366
4367 pFormat = ComputeVariance(pStubMsg, pMemory, pFormat, pStubMsg->MaxCount);
4368 TRACE("variance = %d\n", pStubMsg->ActualCount);
4369
4370 count = pStubMsg->ActualCount;
4371 for (i = 0; i < count; i++)
4372 pMemory = ComplexFree(pStubMsg, pMemory, pFormat, NULL);
4373}

◆ NdrComplexArrayMarshall()

unsigned char *WINAPI NdrComplexArrayMarshall ( PMIDL_STUB_MESSAGE  pStubMsg,
unsigned char pMemory,
PFORMAT_STRING  pFormat 
)

Definition at line 4155 of file ndr_marshall.c.

4158{
4159 BOOL pointer_buffer_mark_set = FALSE;
4160
4161 TRACE("(%p,%p,%p)\n", pStubMsg, pMemory, pFormat);
4162
4163 if (pFormat[0] != FC_BOGUS_ARRAY)
4164 {
4165 ERR("invalid format type %x\n", pFormat[0]);
4167 return NULL;
4168 }
4169
4170 if (!pStubMsg->PointerBufferMark)
4171 {
4172 /* save buffer fields that may be changed by buffer sizer functions
4173 * and that may be needed later on */
4174 int saved_ignore_embedded = pStubMsg->IgnoreEmbeddedPointers;
4175 ULONG saved_buffer_length = pStubMsg->BufferLength;
4176 ULONG_PTR saved_max_count = pStubMsg->MaxCount;
4177 ULONG saved_offset = pStubMsg->Offset;
4178 ULONG saved_actual_count = pStubMsg->ActualCount;
4179
4180 /* get the buffer pointer after complex array data, but before
4181 * pointer data */
4182 pStubMsg->BufferLength = pStubMsg->Buffer - (unsigned char *)pStubMsg->RpcMsg->Buffer;
4183 pStubMsg->IgnoreEmbeddedPointers = 1;
4184 NdrComplexArrayBufferSize(pStubMsg, pMemory, pFormat);
4185 pStubMsg->IgnoreEmbeddedPointers = saved_ignore_embedded;
4186
4187 /* save it for use by embedded pointer code later */
4188 pStubMsg->PointerBufferMark = (unsigned char *)pStubMsg->RpcMsg->Buffer + pStubMsg->BufferLength;
4189 TRACE("difference = 0x%x\n", (ULONG)(pStubMsg->Buffer - (unsigned char *)pStubMsg->RpcMsg->Buffer));
4190 pointer_buffer_mark_set = TRUE;
4191
4192 /* restore fields */
4193 pStubMsg->ActualCount = saved_actual_count;
4194 pStubMsg->Offset = saved_offset;
4195 pStubMsg->MaxCount = saved_max_count;
4196 pStubMsg->BufferLength = saved_buffer_length;
4197 }
4198
4201 pMemory, pFormat, TRUE /* fHasPointers */);
4202
4203 STD_OVERFLOW_CHECK(pStubMsg);
4204
4205 if (pointer_buffer_mark_set)
4206 {
4207 pStubMsg->Buffer = pStubMsg->PointerBufferMark;
4208 pStubMsg->PointerBufferMark = NULL;
4209 }
4210
4211 return NULL;
4212}
static void array_compute_and_write_conformance(unsigned char fc, PMIDL_STUB_MESSAGE pStubMsg, unsigned char *pMemory, PFORMAT_STRING pFormat)
static void array_write_variance_and_marshall(unsigned char fc, PMIDL_STUB_MESSAGE pStubMsg, unsigned char *pMemory, PFORMAT_STRING pFormat, unsigned char fHasPointers)

◆ NdrComplexArrayMemorySize()

ULONG WINAPI NdrComplexArrayMemorySize ( PMIDL_STUB_MESSAGE  pStubMsg,
PFORMAT_STRING  pFormat 
)

Definition at line 4326 of file ndr_marshall.c.

4328{
4329 TRACE("(%p,%p)\n", pStubMsg, pFormat);
4330
4331 if (pFormat[0] != FC_BOGUS_ARRAY)
4332 {
4333 ERR("invalid format type %x\n", pFormat[0]);
4335 return 0;
4336 }
4337
4338 array_read_conformance(FC_BOGUS_ARRAY, pStubMsg, pFormat);
4339 array_memory_size(FC_BOGUS_ARRAY, pStubMsg, pFormat, TRUE /* fHasPointers */);
4340 return pStubMsg->MemorySize;
4341}
static ULONG array_read_conformance(unsigned char fc, PMIDL_STUB_MESSAGE pStubMsg, PFORMAT_STRING pFormat)
static void array_memory_size(unsigned char fc, PMIDL_STUB_MESSAGE pStubMsg, PFORMAT_STRING pFormat, unsigned char fHasPointers)

Referenced by NdrComplexArrayUnmarshall().

◆ NdrComplexArrayUnmarshall()

unsigned char *WINAPI NdrComplexArrayUnmarshall ( PMIDL_STUB_MESSAGE  pStubMsg,
unsigned char **  ppMemory,
PFORMAT_STRING  pFormat,