ReactOS  0.4.14-dev-358-gbef841c
ndr_es.c File Reference
#include <stdarg.h>
#include <stdio.h>
#include "windef.h"
#include "winbase.h"
#include "winerror.h"
#include "rpc.h"
#include "midles.h"
#include "ndrtypes.h"
#include "ndr_misc.h"
#include "ndr_stubless.h"
#include "wine/debug.h"
Include dependency graph for ndr_es.c:

Go to the source code of this file.

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (ole)
 
static void init_MIDL_ES_MESSAGE (MIDL_ES_MESSAGE *pEsMsg)
 
RPC_STATUS WINAPI MesEncodeIncrementalHandleCreate (void *UserState, MIDL_ES_ALLOC AllocFn, MIDL_ES_WRITE WriteFn, handle_t *pHandle)
 
RPC_STATUS WINAPI MesDecodeIncrementalHandleCreate (void *UserState, MIDL_ES_READ ReadFn, handle_t *pHandle)
 
RPC_STATUS WINAPI MesIncrementalHandleReset (handle_t Handle, void *UserState, MIDL_ES_ALLOC AllocFn, MIDL_ES_WRITE WriteFn, MIDL_ES_READ ReadFn, MIDL_ES_CODE Operation)
 
RPC_STATUS WINAPI MesBufferHandleReset (handle_t Handle, ULONG HandleStyle, MIDL_ES_CODE Operation, char **Buffer, ULONG BufferSize, ULONG *EncodedSize)
 
RPC_STATUS WINAPI MesHandleFree (handle_t Handle)
 
static RPC_STATUS validate_mes_buffer_pointer (const char *Buffer)
 
RPC_STATUS RPC_ENTRY MesEncodeFixedBufferHandleCreate (char *Buffer, ULONG BufferSize, ULONG *pEncodedSize, handle_t *pHandle)
 
RPC_STATUS RPC_ENTRY MesEncodeDynBufferHandleCreate (char **Buffer, ULONG *pEncodedSize, handle_t *pHandle)
 
RPC_STATUS RPC_ENTRY MesDecodeBufferHandleCreate (char *Buffer, ULONG BufferSize, handle_t *pHandle)
 
static void es_data_alloc (MIDL_ES_MESSAGE *pEsMsg, ULONG size)
 
static void es_data_read (MIDL_ES_MESSAGE *pEsMsg, ULONG size)
 
static void es_data_write (MIDL_ES_MESSAGE *pEsMsg, ULONG size)
 
static ULONG mes_proc_header_buffer_size (void)
 
static void mes_proc_header_marshal (MIDL_ES_MESSAGE *pEsMsg)
 
static void mes_proc_header_unmarshal (MIDL_ES_MESSAGE *pEsMsg)
 
void WINAPIV NdrMesProcEncodeDecode (handle_t Handle, const MIDL_STUB_DESC *pStubDesc, PFORMAT_STRING pFormat,...)
 
void RPC_ENTRY NdrMesTypeDecode2 (handle_t Handle, const MIDL_TYPE_PICKLING_INFO *pPicklingInfo, const MIDL_STUB_DESC *pStubDesc, PFORMAT_STRING pFormatString, void *pObject)
 
void RPC_ENTRY NdrMesTypeEncode2 (handle_t Handle, const MIDL_TYPE_PICKLING_INFO *pPicklingInfo, const MIDL_STUB_DESC *pStubDesc, PFORMAT_STRING pFormatString, const void *pObject)
 
void RPC_ENTRY NdrMesTypeFree2 (handle_t Handle, const MIDL_TYPE_PICKLING_INFO *pPicklingInfo, const MIDL_STUB_DESC *pStubDesc, PFORMAT_STRING pFormatString, void *pObject)
 

Function Documentation

◆ es_data_alloc()

static void es_data_alloc ( MIDL_ES_MESSAGE pEsMsg,
ULONG  size 
)
static

Definition at line 275 of file ndr_es.c.

276 {
277  if (pEsMsg->HandleStyle == MES_INCREMENTAL_HANDLE)
278  {
279  unsigned int tmpsize = size;
280  TRACE("%d with incremental handle\n", size);
281  pEsMsg->Alloc(pEsMsg->UserState, (char **)&pEsMsg->StubMsg.Buffer, &tmpsize);
282  if (tmpsize < size)
283  {
284  ERR("not enough bytes allocated - requested %d, got %d\n", size, tmpsize);
286  }
287  }
288  else if (pEsMsg->HandleStyle == MES_FIXED_BUFFER_HANDLE)
289  {
290  TRACE("%d with fixed buffer handle\n", size);
291  pEsMsg->StubMsg.Buffer = pEsMsg->Buffer;
292  }
293  pEsMsg->StubMsg.RpcMsg->Buffer = pEsMsg->StubMsg.BufferStart = pEsMsg->StubMsg.Buffer;
294 }
ULONG HandleStyle
Definition: midles.h:54
void DECLSPEC_NORETURN WINAPI RpcRaiseException(RPC_STATUS exception)
Definition: rpcrt4_main.c:189
unsigned char * Buffer
Definition: rpcndr.h:203
PRPC_MESSAGE RpcMsg
Definition: rpcndr.h:202
unsigned char * Buffer
Definition: midles.h:60
void * Buffer
Definition: rpcdcep.h:40
#define RPC_S_OUT_OF_MEMORY
Definition: rpcnterr.h:24
MIDL_ES_ALLOC Alloc
Definition: midles.h:57
#define TRACE(s)
Definition: solgame.cpp:4
GLsizeiptr size
Definition: glext.h:5919
unsigned char * BufferStart
Definition: rpcndr.h:204
#define ERR(fmt,...)
Definition: debug.h:109
void * UserState
Definition: midles.h:52
MIDL_STUB_MESSAGE StubMsg
Definition: midles.h:50

Referenced by NdrMesProcEncodeDecode().

◆ es_data_read()

static void es_data_read ( MIDL_ES_MESSAGE pEsMsg,
ULONG  size 
)
static

Definition at line 296 of file ndr_es.c.

297 {
298  if (pEsMsg->HandleStyle == MES_INCREMENTAL_HANDLE)
299  {
300  unsigned int tmpsize = size;
301  TRACE("%d from incremental handle\n", size);
302  pEsMsg->Read(pEsMsg->UserState, (char **)&pEsMsg->StubMsg.Buffer, &tmpsize);
303  if (tmpsize < size)
304  {
305  ERR("not enough bytes read - requested %d, got %d\n", size, tmpsize);
307  }
308  }
309  else
310  {
311  TRACE("%d from fixed or dynamic buffer handle\n", size);
312  /* FIXME: validate BufferSize? */
313  pEsMsg->StubMsg.Buffer = pEsMsg->Buffer;
314  pEsMsg->Buffer += size;
315  pEsMsg->BufferSize -= size;
316  }
317  pEsMsg->StubMsg.BufferLength = size;
318  pEsMsg->StubMsg.RpcMsg->Buffer = pEsMsg->StubMsg.BufferStart = pEsMsg->StubMsg.Buffer;
319  pEsMsg->StubMsg.BufferEnd = pEsMsg->StubMsg.Buffer + size;
320 }
ULONG HandleStyle
Definition: midles.h:54
void DECLSPEC_NORETURN WINAPI RpcRaiseException(RPC_STATUS exception)
Definition: rpcrt4_main.c:189
unsigned char * Buffer
Definition: rpcndr.h:203
PRPC_MESSAGE RpcMsg
Definition: rpcndr.h:202
unsigned char * Buffer
Definition: midles.h:60
void * Buffer
Definition: rpcdcep.h:40
MIDL_ES_READ Read
Definition: midles.h:59
#define RPC_S_OUT_OF_MEMORY
Definition: rpcnterr.h:24
#define TRACE(s)
Definition: solgame.cpp:4
GLsizeiptr size
Definition: glext.h:5919
unsigned char * BufferStart
Definition: rpcndr.h:204
ULONG BufferLength
Definition: rpcndr.h:207
unsigned char * BufferEnd
Definition: rpcndr.h:205
#define ERR(fmt,...)
Definition: debug.h:109
ULONG BufferSize
Definition: midles.h:61
void * UserState
Definition: midles.h:52
MIDL_STUB_MESSAGE StubMsg
Definition: midles.h:50

Referenced by mes_proc_header_unmarshal(), and NdrMesProcEncodeDecode().

◆ es_data_write()

static void es_data_write ( MIDL_ES_MESSAGE pEsMsg,
ULONG  size 
)
static

Definition at line 322 of file ndr_es.c.

323 {
324  if (pEsMsg->HandleStyle == MES_INCREMENTAL_HANDLE)
325  {
326  TRACE("%d to incremental handle\n", size);
327  pEsMsg->Write(pEsMsg->UserState, (char *)pEsMsg->StubMsg.BufferStart, size);
328  }
329  else
330  {
331  TRACE("%d to dynamic or fixed buffer handle\n", size);
332  *pEsMsg->pEncodedSize += size;
333  }
334 }
ULONG HandleStyle
Definition: midles.h:54
ULONG * pEncodedSize
Definition: midles.h:63
#define TRACE(s)
Definition: solgame.cpp:4
GLsizeiptr size
Definition: glext.h:5919
MIDL_ES_WRITE Write
Definition: midles.h:58
unsigned char * BufferStart
Definition: rpcndr.h:204
void * UserState
Definition: midles.h:52
MIDL_STUB_MESSAGE StubMsg
Definition: midles.h:50

Referenced by NdrMesProcEncodeDecode().

◆ init_MIDL_ES_MESSAGE()

static void init_MIDL_ES_MESSAGE ( MIDL_ES_MESSAGE pEsMsg)
inlinestatic

Definition at line 38 of file ndr_es.c.

39 {
40  memset(pEsMsg, 0, sizeof(*pEsMsg));
41  /* even if we are unmarshalling, as we don't want pointers to be pointed
42  * to buffer memory */
43  pEsMsg->StubMsg.IsClient = TRUE;
44  pEsMsg->MesVersion = 1;
45 }
#define TRUE
Definition: types.h:120
ULONG MesVersion
Definition: midles.h:53
unsigned char IsClient
Definition: rpcndr.h:210
#define memset(x, y, z)
Definition: compat.h:39
MIDL_STUB_MESSAGE StubMsg
Definition: midles.h:50

Referenced by MesBufferHandleReset(), MesDecodeBufferHandleCreate(), MesDecodeIncrementalHandleCreate(), MesEncodeDynBufferHandleCreate(), MesEncodeFixedBufferHandleCreate(), MesEncodeIncrementalHandleCreate(), and MesIncrementalHandleReset().

◆ mes_proc_header_buffer_size()

static ULONG mes_proc_header_buffer_size ( void  )
inlinestatic

Definition at line 336 of file ndr_es.c.

337 {
338  return 4 + 2*sizeof(RPC_SYNTAX_IDENTIFIER) + 12;
339 }
struct _RPC_SYNTAX_IDENTIFIER RPC_SYNTAX_IDENTIFIER

Referenced by mes_proc_header_unmarshal(), and NdrMesProcEncodeDecode().

◆ mes_proc_header_marshal()

static void mes_proc_header_marshal ( MIDL_ES_MESSAGE pEsMsg)
static

Definition at line 341 of file ndr_es.c.

342 {
343  const RPC_CLIENT_INTERFACE *client_interface = pEsMsg->StubMsg.StubDesc->RpcInterfaceInformation;
344  *(WORD *)pEsMsg->StubMsg.Buffer = 0x0101;
345  pEsMsg->StubMsg.Buffer += 2;
346  *(WORD *)pEsMsg->StubMsg.Buffer = 0xcccc;
347  pEsMsg->StubMsg.Buffer += 2;
348  memcpy(pEsMsg->StubMsg.Buffer, &client_interface->TransferSyntax, sizeof(RPC_SYNTAX_IDENTIFIER));
349  pEsMsg->StubMsg.Buffer += sizeof(RPC_SYNTAX_IDENTIFIER);
350  memcpy(pEsMsg->StubMsg.Buffer, &pEsMsg->InterfaceId, sizeof(RPC_SYNTAX_IDENTIFIER));
351  pEsMsg->StubMsg.Buffer += sizeof(RPC_SYNTAX_IDENTIFIER);
352  *(DWORD *)pEsMsg->StubMsg.Buffer = pEsMsg->ProcNumber;
353  pEsMsg->StubMsg.Buffer += 4;
354  *(DWORD *)pEsMsg->StubMsg.Buffer = 0x00000001;
355  pEsMsg->StubMsg.Buffer += 4;
356  *(DWORD *)pEsMsg->StubMsg.Buffer = pEsMsg->ByteCount;
357  pEsMsg->StubMsg.Buffer += 4;
358 }
ULONG ProcNumber
Definition: midles.h:65
unsigned char * Buffer
Definition: rpcndr.h:203
const struct _MIDL_STUB_DESC * StubDesc
Definition: rpcndr.h:230
unsigned short WORD
Definition: ntddk_ex.h:93
unsigned long DWORD
Definition: ntddk_ex.h:95
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
RPC_SYNTAX_IDENTIFIER TransferSyntax
Definition: rpcdcep.h:118
RPC_SYNTAX_IDENTIFIER InterfaceId
Definition: midles.h:64
struct _RPC_SYNTAX_IDENTIFIER RPC_SYNTAX_IDENTIFIER
ULONG ByteCount
Definition: midles.h:68
MIDL_STUB_MESSAGE StubMsg
Definition: midles.h:50

Referenced by NdrMesProcEncodeDecode().

◆ mes_proc_header_unmarshal()

static void mes_proc_header_unmarshal ( MIDL_ES_MESSAGE pEsMsg)
static

Definition at line 360 of file ndr_es.c.

361 {
362  const RPC_CLIENT_INTERFACE *client_interface = pEsMsg->StubMsg.StubDesc->RpcInterfaceInformation;
363 
365 
366  if (*(WORD *)pEsMsg->StubMsg.Buffer != 0x0101)
367  {
368  FIXME("unknown value at Buffer[0] 0x%04x\n", *(WORD *)pEsMsg->StubMsg.Buffer);
370  }
371  pEsMsg->StubMsg.Buffer += 2;
372  if (*(WORD *)pEsMsg->StubMsg.Buffer != 0xcccc)
373  FIXME("unknown value at Buffer[2] 0x%04x\n", *(WORD *)pEsMsg->StubMsg.Buffer);
374  pEsMsg->StubMsg.Buffer += 2;
375  if (memcmp(pEsMsg->StubMsg.Buffer, &client_interface->TransferSyntax, sizeof(RPC_SYNTAX_IDENTIFIER)))
376  {
377  const RPC_SYNTAX_IDENTIFIER *AlienTransferSyntax = (const RPC_SYNTAX_IDENTIFIER *)pEsMsg->StubMsg.Buffer;
378  ERR("bad transfer syntax %s {%d.%d}\n", debugstr_guid(&AlienTransferSyntax->SyntaxGUID),
379  AlienTransferSyntax->SyntaxVersion.MajorVersion,
380  AlienTransferSyntax->SyntaxVersion.MinorVersion);
382  }
383  pEsMsg->StubMsg.Buffer += sizeof(RPC_SYNTAX_IDENTIFIER);
384  memcpy(&pEsMsg->InterfaceId, pEsMsg->StubMsg.Buffer, sizeof(RPC_SYNTAX_IDENTIFIER));
385  pEsMsg->StubMsg.Buffer += sizeof(RPC_SYNTAX_IDENTIFIER);
386  pEsMsg->ProcNumber = *(DWORD *)pEsMsg->StubMsg.Buffer;
387  pEsMsg->StubMsg.Buffer += 4;
388  if (*(DWORD *)pEsMsg->StubMsg.Buffer != 0x00000001)
389  FIXME("unknown value 0x%08x, expected 0x00000001\n", *(DWORD *)pEsMsg->StubMsg.Buffer);
390  pEsMsg->StubMsg.Buffer += 4;
391  pEsMsg->ByteCount = *(DWORD *)pEsMsg->StubMsg.Buffer;
392  pEsMsg->StubMsg.Buffer += 4;
393  if (pEsMsg->ByteCount + mes_proc_header_buffer_size() < pEsMsg->ByteCount)
395 }
#define RPC_S_UNSUPPORTED_TRANS_SYN
Definition: winerror.h:1040
#define RPC_S_INVALID_BOUND
Definition: winerror.h:1043
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
unsigned short MajorVersion
Definition: rpcdcep.h:27
void DECLSPEC_NORETURN WINAPI RpcRaiseException(RPC_STATUS exception)
Definition: rpcrt4_main.c:189
ULONG ProcNumber
Definition: midles.h:65
unsigned char * Buffer
Definition: rpcndr.h:203
const struct _MIDL_STUB_DESC * StubDesc
Definition: rpcndr.h:230
static ULONG mes_proc_header_buffer_size(void)
Definition: ndr_es.c:336
#define FIXME(fmt,...)
Definition: debug.h:110
RPC_VERSION SyntaxVersion
Definition: rpcdcep.h:33
#define debugstr_guid
Definition: kernel32.h:35
if(!(yy_init))
Definition: macro.lex.yy.c:714
unsigned short WORD
Definition: ntddk_ex.h:93
unsigned long DWORD
Definition: ntddk_ex.h:95
unsigned short MinorVersion
Definition: rpcdcep.h:28
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
RPC_SYNTAX_IDENTIFIER TransferSyntax
Definition: rpcdcep.h:118
#define ERR(fmt,...)
Definition: debug.h:109
RPC_SYNTAX_IDENTIFIER InterfaceId
Definition: midles.h:64
#define RPC_X_WRONG_ES_VERSION
Definition: winerror.h:1135
struct _RPC_SYNTAX_IDENTIFIER RPC_SYNTAX_IDENTIFIER
ULONG ByteCount
Definition: midles.h:68
static void es_data_read(MIDL_ES_MESSAGE *pEsMsg, ULONG size)
Definition: ndr_es.c:296
MIDL_STUB_MESSAGE StubMsg
Definition: midles.h:50

Referenced by NdrMesProcEncodeDecode().

◆ MesBufferHandleReset()

RPC_STATUS WINAPI MesBufferHandleReset ( handle_t  Handle,
ULONG  HandleStyle,
MIDL_ES_CODE  Operation,
char **  Buffer,
ULONG  BufferSize,
ULONG EncodedSize 
)

Definition at line 128 of file ndr_es.c.

130 {
132 
133  TRACE("(%p, %u, %d, %p, %u, %p)\n", Handle, HandleStyle, Operation, Buffer,
134  BufferSize, EncodedSize);
135 
136  if (!Handle || !Buffer || !EncodedSize)
137  return RPC_S_INVALID_ARG;
138 
140  return RPC_S_INVALID_ARG;
141 
142  if (HandleStyle != MES_FIXED_BUFFER_HANDLE && HandleStyle != MES_DYNAMIC_BUFFER_HANDLE)
143  return RPC_S_INVALID_ARG;
144 
145  init_MIDL_ES_MESSAGE(pEsMsg);
146 
147  pEsMsg->Operation = Operation;
148  pEsMsg->HandleStyle = HandleStyle;
149  if (HandleStyle == MES_FIXED_BUFFER_HANDLE)
150  pEsMsg->Buffer = (unsigned char*)*Buffer;
151  else
152  pEsMsg->pDynBuffer = (unsigned char**)Buffer;
153  pEsMsg->BufferSize = BufferSize;
154  pEsMsg->pEncodedSize = EncodedSize;
155 
156  return RPC_S_OK;
157 }
ULONG HandleStyle
Definition: midles.h:54
ULONG * pEncodedSize
Definition: midles.h:63
#define RPC_S_INVALID_ARG
Definition: rpcnterr.h:23
unsigned char * Buffer
Definition: midles.h:60
static void init_MIDL_ES_MESSAGE(MIDL_ES_MESSAGE *pEsMsg)
Definition: ndr_es.c:38
Definition: bufpool.h:45
_In_ HANDLE Handle
Definition: extypes.h:390
#define TRACE(s)
Definition: solgame.cpp:4
#define BufferSize
Definition: classpnp.h:419
unsigned char ** pDynBuffer
Definition: midles.h:62
MIDL_ES_CODE Operation
Definition: midles.h:51
_In_ FLT_SET_CONTEXT_OPERATION Operation
Definition: fltkernel.h:1468
ULONG BufferSize
Definition: midles.h:61
#define RPC_S_OK
Definition: rpcnterr.h:22

Referenced by test_MesEncodeFixedBufferHandleCreate().

◆ MesDecodeBufferHandleCreate()

RPC_STATUS RPC_ENTRY MesDecodeBufferHandleCreate ( char Buffer,
ULONG  BufferSize,
handle_t pHandle 
)

Definition at line 248 of file ndr_es.c.

250 {
251  MIDL_ES_MESSAGE *pEsMsg;
253 
254  TRACE("(%p, %d, %p)\n", Buffer, BufferSize, pHandle);
255 
257  return status;
258 
259  pEsMsg = HeapAlloc(GetProcessHeap(), 0, sizeof(*pEsMsg));
260  if (!pEsMsg)
261  return RPC_S_OUT_OF_MEMORY;
262 
263  init_MIDL_ES_MESSAGE(pEsMsg);
264 
265  pEsMsg->Operation = MES_DECODE;
267  pEsMsg->Buffer = (unsigned char *)Buffer;
268  pEsMsg->BufferSize = BufferSize;
269 
270  *pHandle = (handle_t)pEsMsg;
271 
272  return RPC_S_OK;
273 }
ULONG HandleStyle
Definition: midles.h:54
RPC_BINDING_HANDLE handle_t
Definition: rpcdce.h:51
unsigned char * Buffer
Definition: midles.h:60
static void init_MIDL_ES_MESSAGE(MIDL_ES_MESSAGE *pEsMsg)
Definition: ndr_es.c:38
long RPC_STATUS
Definition: rpc.h:52
#define RPC_S_OUT_OF_MEMORY
Definition: rpcnterr.h:24
Definition: bufpool.h:45
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:403
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
#define BufferSize
Definition: classpnp.h:419
static RPC_STATUS validate_mes_buffer_pointer(const char *Buffer)
Definition: ndr_es.c:169
MIDL_ES_CODE Operation
Definition: midles.h:51
static SERVICE_STATUS status
Definition: service.c:31
ULONG BufferSize
Definition: midles.h:61
#define RPC_S_OK
Definition: rpcnterr.h:22
Definition: ps.c:97

◆ MesDecodeIncrementalHandleCreate()

RPC_STATUS WINAPI MesDecodeIncrementalHandleCreate ( void UserState,
MIDL_ES_READ  ReadFn,
handle_t pHandle 
)

Definition at line 78 of file ndr_es.c.

80 {
81  MIDL_ES_MESSAGE *pEsMsg;
82 
83  TRACE("(%p, %p, %p)\n", UserState, ReadFn, pHandle);
84 
85  pEsMsg = HeapAlloc(GetProcessHeap(), 0, sizeof(*pEsMsg));
86  if (!pEsMsg)
87  return RPC_S_OUT_OF_MEMORY;
88 
89  init_MIDL_ES_MESSAGE(pEsMsg);
90 
91  pEsMsg->Operation = MES_DECODE;
92  pEsMsg->UserState = UserState;
94  pEsMsg->Read = ReadFn;
95 
96  *pHandle = (handle_t)pEsMsg;
97 
98  return RPC_S_OK;
99 }
ULONG HandleStyle
Definition: midles.h:54
RPC_BINDING_HANDLE handle_t
Definition: rpcdce.h:51
static void init_MIDL_ES_MESSAGE(MIDL_ES_MESSAGE *pEsMsg)
Definition: ndr_es.c:38
MIDL_ES_READ Read
Definition: midles.h:59
#define RPC_S_OUT_OF_MEMORY
Definition: rpcnterr.h:24
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:403
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
MIDL_ES_CODE Operation
Definition: midles.h:51
void * UserState
Definition: midles.h:52
#define RPC_S_OK
Definition: rpcnterr.h:22

◆ MesEncodeDynBufferHandleCreate()

RPC_STATUS RPC_ENTRY MesEncodeDynBufferHandleCreate ( char **  Buffer,
ULONG pEncodedSize,
handle_t pHandle 
)

Definition at line 219 of file ndr_es.c.

221 {
222  MIDL_ES_MESSAGE *pEsMsg;
223 
224  TRACE("(%p, %p, %p)\n", Buffer, pEncodedSize, pHandle);
225 
226  if (!pEncodedSize)
227  return RPC_S_INVALID_ARG;
228 
229  pEsMsg = HeapAlloc(GetProcessHeap(), 0, sizeof(*pEsMsg));
230  if (!pEsMsg)
231  return RPC_S_OUT_OF_MEMORY;
232 
233  init_MIDL_ES_MESSAGE(pEsMsg);
234 
235  pEsMsg->Operation = MES_ENCODE;
237  pEsMsg->pDynBuffer = (unsigned char **)Buffer;
238  pEsMsg->pEncodedSize = pEncodedSize;
239 
240  *pHandle = (handle_t)pEsMsg;
241 
242  return RPC_S_OK;
243 }
ULONG HandleStyle
Definition: midles.h:54
RPC_BINDING_HANDLE handle_t
Definition: rpcdce.h:51
ULONG * pEncodedSize
Definition: midles.h:63
#define RPC_S_INVALID_ARG
Definition: rpcnterr.h:23
static void init_MIDL_ES_MESSAGE(MIDL_ES_MESSAGE *pEsMsg)
Definition: ndr_es.c:38
#define RPC_S_OUT_OF_MEMORY
Definition: rpcnterr.h:24
Definition: bufpool.h:45
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:403
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
unsigned char ** pDynBuffer
Definition: midles.h:62
MIDL_ES_CODE Operation
Definition: midles.h:51
#define RPC_S_OK
Definition: rpcnterr.h:22

◆ MesEncodeFixedBufferHandleCreate()

RPC_STATUS RPC_ENTRY MesEncodeFixedBufferHandleCreate ( char Buffer,
ULONG  BufferSize,
ULONG pEncodedSize,
handle_t pHandle 
)

Definition at line 183 of file ndr_es.c.

185 {
186  MIDL_ES_MESSAGE *pEsMsg;
188 
189  TRACE("(%p, %d, %p, %p)\n", Buffer, BufferSize, pEncodedSize, pHandle);
190 
192  return status;
193 
194  if (!pEncodedSize)
195  return RPC_S_INVALID_ARG;
196 
197  /* FIXME: check BufferSize too */
198 
199  pEsMsg = HeapAlloc(GetProcessHeap(), 0, sizeof(*pEsMsg));
200  if (!pEsMsg)
201  return RPC_S_OUT_OF_MEMORY;
202 
203  init_MIDL_ES_MESSAGE(pEsMsg);
204 
205  pEsMsg->Operation = MES_ENCODE;
207  pEsMsg->Buffer = (unsigned char *)Buffer;
208  pEsMsg->BufferSize = BufferSize;
209  pEsMsg->pEncodedSize = pEncodedSize;
210 
211  *pHandle = (handle_t)pEsMsg;
212 
213  return RPC_S_OK;
214 }
ULONG HandleStyle
Definition: midles.h:54
RPC_BINDING_HANDLE handle_t
Definition: rpcdce.h:51
ULONG * pEncodedSize
Definition: midles.h:63
#define RPC_S_INVALID_ARG
Definition: rpcnterr.h:23
unsigned char * Buffer
Definition: midles.h:60
static void init_MIDL_ES_MESSAGE(MIDL_ES_MESSAGE *pEsMsg)
Definition: ndr_es.c:38
long RPC_STATUS
Definition: rpc.h:52
#define RPC_S_OUT_OF_MEMORY
Definition: rpcnterr.h:24
Definition: bufpool.h:45
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:403
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
#define BufferSize
Definition: classpnp.h:419
static RPC_STATUS validate_mes_buffer_pointer(const char *Buffer)
Definition: ndr_es.c:169
MIDL_ES_CODE Operation
Definition: midles.h:51
static SERVICE_STATUS status
Definition: service.c:31
ULONG BufferSize
Definition: midles.h:61
#define RPC_S_OK
Definition: rpcnterr.h:22
Definition: ps.c:97

Referenced by test_MesEncodeFixedBufferHandleCreate().

◆ MesEncodeIncrementalHandleCreate()

RPC_STATUS WINAPI MesEncodeIncrementalHandleCreate ( void UserState,
MIDL_ES_ALLOC  AllocFn,
MIDL_ES_WRITE  WriteFn,
handle_t pHandle 
)

Definition at line 50 of file ndr_es.c.

53 {
54  MIDL_ES_MESSAGE *pEsMsg;
55 
56  TRACE("(%p, %p, %p, %p)\n", UserState, AllocFn, WriteFn, pHandle);
57 
58  pEsMsg = HeapAlloc(GetProcessHeap(), 0, sizeof(*pEsMsg));
59  if (!pEsMsg)
60  return RPC_S_OUT_OF_MEMORY;
61 
62  init_MIDL_ES_MESSAGE(pEsMsg);
63 
64  pEsMsg->Operation = MES_ENCODE;
65  pEsMsg->UserState = UserState;
67  pEsMsg->Alloc = AllocFn;
68  pEsMsg->Write = WriteFn;
69 
70  *pHandle = (handle_t)pEsMsg;
71 
72  return RPC_S_OK;
73 }
ULONG HandleStyle
Definition: midles.h:54
RPC_BINDING_HANDLE handle_t
Definition: rpcdce.h:51
static void init_MIDL_ES_MESSAGE(MIDL_ES_MESSAGE *pEsMsg)
Definition: ndr_es.c:38
#define RPC_S_OUT_OF_MEMORY
Definition: rpcnterr.h:24
MIDL_ES_ALLOC Alloc
Definition: midles.h:57
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:403
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
MIDL_ES_WRITE Write
Definition: midles.h:58
MIDL_ES_CODE Operation
Definition: midles.h:51
void * UserState
Definition: midles.h:52
#define RPC_S_OK
Definition: rpcnterr.h:22

◆ MesHandleFree()

RPC_STATUS WINAPI MesHandleFree ( handle_t  Handle)

Definition at line 162 of file ndr_es.c.

163 {
164  TRACE("(%p)\n", Handle);
166  return RPC_S_OK;
167 }
_In_ HANDLE Handle
Definition: extypes.h:390
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:403
#define HeapFree(x, y, z)
Definition: compat.h:402
#define RPC_S_OK
Definition: rpcnterr.h:22

Referenced by test_MesEncodeFixedBufferHandleCreate().

◆ MesIncrementalHandleReset()

RPC_STATUS WINAPI MesIncrementalHandleReset ( handle_t  Handle,
void UserState,
MIDL_ES_ALLOC  AllocFn,
MIDL_ES_WRITE  WriteFn,
MIDL_ES_READ  ReadFn,
MIDL_ES_CODE  Operation 
)

Definition at line 104 of file ndr_es.c.

107 {
108  MIDL_ES_MESSAGE *pEsMsg = Handle;
109 
110  TRACE("(%p, %p, %p, %p, %p, %d)\n", Handle, UserState, AllocFn,
111  WriteFn, ReadFn, Operation);
112 
113  init_MIDL_ES_MESSAGE(pEsMsg);
114 
115  pEsMsg->Operation = Operation;
116  pEsMsg->UserState = UserState;
118  pEsMsg->Alloc = AllocFn;
119  pEsMsg->Write = WriteFn;
120  pEsMsg->Read = ReadFn;
121 
122  return RPC_S_OK;
123 }
ULONG HandleStyle
Definition: midles.h:54
static void init_MIDL_ES_MESSAGE(MIDL_ES_MESSAGE *pEsMsg)
Definition: ndr_es.c:38
MIDL_ES_READ Read
Definition: midles.h:59
MIDL_ES_ALLOC Alloc
Definition: midles.h:57
_In_ HANDLE Handle
Definition: extypes.h:390
#define TRACE(s)
Definition: solgame.cpp:4
MIDL_ES_WRITE Write
Definition: midles.h:58
MIDL_ES_CODE Operation
Definition: midles.h:51
_In_ FLT_SET_CONTEXT_OPERATION Operation
Definition: fltkernel.h:1468
void * UserState
Definition: midles.h:52
#define RPC_S_OK
Definition: rpcnterr.h:22

◆ NdrMesProcEncodeDecode()

void WINAPIV NdrMesProcEncodeDecode ( handle_t  Handle,
const MIDL_STUB_DESC pStubDesc,
PFORMAT_STRING  pFormat,
  ... 
)

Definition at line 400 of file ndr_es.c.

401 {
402  /* pointer to start of stack where arguments start */
403  RPC_MESSAGE rpcMsg;
404  MIDL_ES_MESSAGE *pEsMsg = Handle;
405  /* size of stack */
406  unsigned short stack_size;
407  /* header for procedure string */
408  const NDR_PROC_HEADER *pProcHeader = (const NDR_PROC_HEADER *)&pFormat[0];
409  const RPC_CLIENT_INTERFACE *client_interface;
411  unsigned int number_of_params;
412  ULONG_PTR arg_buffer[256];
413 
414  TRACE("Handle %p, pStubDesc %p, pFormat %p, ...\n", Handle, pStubDesc, pFormat);
415 
416  /* Later NDR language versions probably won't be backwards compatible */
417  if (pStubDesc->Version > 0x50002)
418  {
419  FIXME("Incompatible stub description version: 0x%x\n", pStubDesc->Version);
421  }
422 
423  client_interface = pStubDesc->RpcInterfaceInformation;
424  pEsMsg->InterfaceId = client_interface->InterfaceId;
425 
426  if (pProcHeader->Oi_flags & Oi_HAS_RPCFLAGS)
427  {
428  const NDR_PROC_HEADER_RPC *header_rpc = (const NDR_PROC_HEADER_RPC *)&pFormat[0];
429  stack_size = header_rpc->stack_size;
430  pEsMsg->ProcNumber = header_rpc->proc_num;
431  pFormat += sizeof(NDR_PROC_HEADER_RPC);
432  }
433  else
434  {
435  stack_size = pProcHeader->stack_size;
436  pEsMsg->ProcNumber = pProcHeader->proc_num;
437  pFormat += sizeof(NDR_PROC_HEADER);
438  }
439 
440  if (pProcHeader->handle_type == 0)
441  {
442  switch (*pFormat) /* handle_type */
443  {
444  case FC_BIND_PRIMITIVE: /* explicit primitive */
445  pFormat += sizeof(NDR_EHD_PRIMITIVE);
446  break;
447  case FC_BIND_GENERIC: /* explicit generic */
448  pFormat += sizeof(NDR_EHD_GENERIC);
449  break;
450  case FC_BIND_CONTEXT: /* explicit context */
451  pFormat += sizeof(NDR_EHD_CONTEXT);
452  break;
453  default:
454  ERR("bad explicit binding handle type (0x%02x)\n", pProcHeader->handle_type);
456  }
457  }
458 
459  TRACE("stack size: 0x%x\n", stack_size);
460  TRACE("proc num: %d\n", pEsMsg->ProcNumber);
461 
462  memset(&rpcMsg, 0, sizeof(rpcMsg));
463  pEsMsg->StubMsg.RpcMsg = &rpcMsg;
464  pEsMsg->StubMsg.StubDesc = pStubDesc;
465  pEsMsg->StubMsg.pfnAllocate = pStubDesc->pfnAllocate;
466  pEsMsg->StubMsg.pfnFree = pStubDesc->pfnFree;
467 
468  /* create the full pointer translation tables, if requested */
469  if (pProcHeader->Oi_flags & Oi_FULL_PTR_USED)
471 
472  TRACE("Oi_flags = 0x%02x\n", pProcHeader->Oi_flags);
473  TRACE("stubdesc version = 0x%x\n", pStubDesc->Version);
474  TRACE("MIDL stub version = 0x%x\n", pStubDesc->MIDLVersion);
475 
476  /* needed for conformance of top-level objects */
477  __ms_va_start( args, pFormat );
478  pEsMsg->StubMsg.StackTop = va_arg( args, unsigned char * );
479  __ms_va_end( args );
480 
481  pFormat = convert_old_args( &pEsMsg->StubMsg, pFormat, stack_size, FALSE,
482  arg_buffer, sizeof(arg_buffer), &number_of_params );
483 
484  switch (pEsMsg->Operation)
485  {
486  case MES_ENCODE:
488 
489  client_do_args( &pEsMsg->StubMsg, pFormat, STUBLESS_CALCSIZE, NULL, number_of_params, NULL );
490 
492  es_data_alloc(pEsMsg, pEsMsg->StubMsg.BufferLength);
493 
494  mes_proc_header_marshal(pEsMsg);
495 
496  client_do_args( &pEsMsg->StubMsg, pFormat, STUBLESS_MARSHAL, NULL, number_of_params, NULL );
497 
498  es_data_write(pEsMsg, pEsMsg->ByteCount);
499  break;
500  case MES_DECODE:
502 
503  es_data_read(pEsMsg, pEsMsg->ByteCount);
504 
505  client_do_args( &pEsMsg->StubMsg, pFormat, STUBLESS_UNMARSHAL, NULL, number_of_params, NULL );
506  break;
507  default:
509  return;
510  }
511  /* free the full pointer translation tables */
512  if (pProcHeader->Oi_flags & Oi_FULL_PTR_USED)
514 }
unsigned short stack_size
Definition: ndr_stubless.h:93
void * RpcInterfaceInformation
Definition: rpcndr.h:362
void client_do_args(PMIDL_STUB_MESSAGE pStubMsg, PFORMAT_STRING pFormat, enum stubless_phase phase, void **fpu_args, unsigned short number_of_params, unsigned char *pRetVal)
Definition: ndr_stubless.c:469
static static const char __ms_va_list
Definition: printf.c:76
struct _NDR_EHD_GENERIC NDR_EHD_GENERIC
void WINAPI NdrFullPointerXlatFree(PFULL_PTR_XLAT_TABLES pXlatTables)
void DECLSPEC_NORETURN WINAPI RpcRaiseException(RPC_STATUS exception)
Definition: rpcrt4_main.c:189
ULONG ProcNumber
Definition: midles.h:65
struct _FULL_PTR_XLAT_TABLES * FullPtrXlatTables
Definition: rpcndr.h:231
const struct _MIDL_STUB_DESC * StubDesc
Definition: rpcndr.h:230
static void mes_proc_header_marshal(MIDL_ES_MESSAGE *pEsMsg)
Definition: ndr_es.c:341
static ULONG mes_proc_header_buffer_size(void)
Definition: ndr_es.c:336
PRPC_MESSAGE RpcMsg
Definition: rpcndr.h:202
Definition: match.c:390
uint32_t ULONG_PTR
Definition: typedefs.h:63
#define FIXME(fmt,...)
Definition: debug.h:110
unsigned short proc_num
Definition: ndr_stubless.h:67
smooth NULL
Definition: ftsmooth.c:416
unsigned short proc_num
Definition: ndr_stubless.h:92
#define Oi_FULL_PTR_USED
Definition: ndrtypes.h:290
PFORMAT_STRING convert_old_args(PMIDL_STUB_MESSAGE pStubMsg, PFORMAT_STRING pFormat, unsigned int stack_size, BOOL object_proc, void *buffer, unsigned int size, unsigned int *count)
Definition: ndr_stubless.c:581
static void es_data_alloc(MIDL_ES_MESSAGE *pEsMsg, ULONG size)
Definition: ndr_es.c:275
struct _NDR_EHD_CONTEXT NDR_EHD_CONTEXT
_In_ HANDLE Handle
Definition: extypes.h:390
#define TRACE(s)
Definition: solgame.cpp:4
unsigned char handle_type
Definition: ndr_stubless.h:43
struct _NDR_PROC_HEADER NDR_PROC_HEADER
LONG MIDLVersion
Definition: rpcndr.h:378
#define Oi_HAS_RPCFLAGS
Definition: ndrtypes.h:293
ULONG BufferLength
Definition: rpcndr.h:207
unsigned char Oi_flags
Definition: ndr_stubless.h:64
#define RPC_S_INTERNAL_ERROR
Definition: winerror.h:1074
#define ERR(fmt,...)
Definition: debug.h:109
unsigned short stack_size
Definition: ndr_stubless.h:71
RPC_SYNTAX_IDENTIFIER InterfaceId
Definition: midles.h:64
#define va_arg(ap, T)
Definition: acmsvcex.h:89
PFULL_PTR_XLAT_TABLES WINAPI NdrFullPointerXlatInit(ULONG NumberOfPointers, XLAT_SIDE XlatSide)
struct _NDR_PROC_HEADER_RPC NDR_PROC_HEADER_RPC
unsigned char * StackTop
Definition: rpcndr.h:226
MIDL_ES_CODE Operation
Definition: midles.h:51
ULONG Version
Definition: rpcndr.h:376
#define RPC_X_WRONG_STUB_VERSION
Definition: winerror.h:1136
#define __ms_va_end(list)
Definition: windef.h:443
#define __ms_va_start(list, arg)
Definition: windef.h:442
struct _NDR_EHD_PRIMITIVE NDR_EHD_PRIMITIVE
#define RPC_X_BAD_STUB_DATA
Definition: winerror.h:1090
static void mes_proc_header_unmarshal(MIDL_ES_MESSAGE *pEsMsg)
Definition: ndr_es.c:360
ULONG ByteCount
Definition: midles.h:68
#define memset(x, y, z)
Definition: compat.h:39
RPC_SYNTAX_IDENTIFIER InterfaceId
Definition: rpcdcep.h:117
#define args
Definition: format.c:66
static void es_data_write(MIDL_ES_MESSAGE *pEsMsg, ULONG size)
Definition: ndr_es.c:322
static void es_data_read(MIDL_ES_MESSAGE *pEsMsg, ULONG size)
Definition: ndr_es.c:296
MIDL_STUB_MESSAGE StubMsg
Definition: midles.h:50

◆ NdrMesTypeDecode2()

void RPC_ENTRY NdrMesTypeDecode2 ( handle_t  Handle,
const MIDL_TYPE_PICKLING_INFO pPicklingInfo,
const MIDL_STUB_DESC pStubDesc,
PFORMAT_STRING  pFormatString,
void pObject 
)

Definition at line 516 of file ndr_es.c.

518 {
519  FIXME("(%p, %p, %p, %p, %p)\n", Handle, pPicklingInfo, pStubDesc, pFormatString, pObject);
520 }
#define FIXME(fmt,...)
Definition: debug.h:110
_In_ HANDLE Handle
Definition: extypes.h:390

◆ NdrMesTypeEncode2()

void RPC_ENTRY NdrMesTypeEncode2 ( handle_t  Handle,
const MIDL_TYPE_PICKLING_INFO pPicklingInfo,
const MIDL_STUB_DESC pStubDesc,
PFORMAT_STRING  pFormatString,
const void pObject 
)

Definition at line 522 of file ndr_es.c.

524 {
525  FIXME("(%p, %p, %p, %p, %p)\n", Handle, pPicklingInfo, pStubDesc, pFormatString, pObject);
526 }
#define FIXME(fmt,...)
Definition: debug.h:110
_In_ HANDLE Handle
Definition: extypes.h:390

◆ NdrMesTypeFree2()

void RPC_ENTRY NdrMesTypeFree2 ( handle_t  Handle,
const MIDL_TYPE_PICKLING_INFO pPicklingInfo,
const MIDL_STUB_DESC pStubDesc,
PFORMAT_STRING  pFormatString,
void pObject 
)

Definition at line 528 of file ndr_es.c.

530 {
531  FIXME("(%p, %p, %p, %p, %p)\n", Handle, pPicklingInfo, pStubDesc, pFormatString, pObject);
532 }
#define FIXME(fmt,...)
Definition: debug.h:110
_In_ HANDLE Handle
Definition: extypes.h:390

◆ validate_mes_buffer_pointer()

static RPC_STATUS validate_mes_buffer_pointer ( const char Buffer)
static

Definition at line 169 of file ndr_es.c.

170 {
171  if (!Buffer)
172  return RPC_S_INVALID_ARG;
173 
174  if (((ULONG_PTR)Buffer & 7) != 0)
175  return RPC_X_INVALID_BUFFER;
176 
177  return RPC_S_OK;
178 }
#define RPC_S_INVALID_ARG
Definition: rpcnterr.h:23
#define RPC_X_INVALID_BUFFER
Definition: rpcnterr.h:40
uint32_t ULONG_PTR
Definition: typedefs.h:63
Definition: bufpool.h:45
#define RPC_S_OK
Definition: rpcnterr.h:22

Referenced by MesDecodeBufferHandleCreate(), and MesEncodeFixedBufferHandleCreate().

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( ole  )