2002-10-22 02:41:17 +02:00
|
|
|
/*
|
|
|
|
* NDR data marshalling
|
|
|
|
*
|
|
|
|
* Copyright 2002 Greg Turner
|
2006-05-19 12:03:06 +02:00
|
|
|
* Copyright 2003-2006 CodeWeavers
|
2002-10-22 02:41:17 +02:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2002-10-22 02:41:17 +02:00
|
|
|
*
|
|
|
|
* TODO:
|
2006-05-19 12:03:06 +02:00
|
|
|
* - String structs
|
|
|
|
* - Byte count pointers
|
|
|
|
* - transmit_as/represent as
|
|
|
|
* - Multi-dimensional arrays
|
|
|
|
* - Conversion functions (NdrConvert)
|
2008-04-12 11:07:26 +02:00
|
|
|
* - Checks for integer addition overflow in user marshall functions
|
2002-10-22 02:41:17 +02:00
|
|
|
*/
|
|
|
|
|
2010-04-05 22:02:20 +02:00
|
|
|
#include <assert.h>
|
2003-09-06 01:08:26 +02:00
|
|
|
#include <stdarg.h>
|
2002-10-22 02:41:17 +02:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
2006-03-01 13:21:56 +01:00
|
|
|
#include <limits.h>
|
2002-10-22 02:41:17 +02:00
|
|
|
|
2009-08-31 11:53:00 +02:00
|
|
|
#define NONAMELESSUNION
|
2002-10-22 02:41:17 +02:00
|
|
|
#include "windef.h"
|
|
|
|
#include "winbase.h"
|
|
|
|
#include "winerror.h"
|
|
|
|
|
2002-10-25 21:03:43 +02:00
|
|
|
#include "ndr_misc.h"
|
2002-11-01 00:35:46 +01:00
|
|
|
#include "rpcndr.h"
|
2009-12-13 20:47:35 +01:00
|
|
|
#include "ndrtypes.h"
|
2002-10-25 21:03:43 +02:00
|
|
|
|
2002-10-22 02:41:17 +02:00
|
|
|
#include "wine/debug.h"
|
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(ole);
|
|
|
|
|
2002-10-28 19:47:41 +01:00
|
|
|
#if defined(__i386__)
|
2005-03-02 13:23:20 +01:00
|
|
|
# define LITTLE_ENDIAN_UINT32_WRITE(pchar, uint32) \
|
2002-11-01 00:35:46 +01:00
|
|
|
(*((UINT32 *)(pchar)) = (uint32))
|
2002-10-28 19:47:41 +01:00
|
|
|
|
2005-03-02 13:23:20 +01:00
|
|
|
# define LITTLE_ENDIAN_UINT32_READ(pchar) \
|
2002-10-28 19:47:41 +01:00
|
|
|
(*((UINT32 *)(pchar)))
|
|
|
|
#else
|
|
|
|
/* these would work for i386 too, but less efficient */
|
2005-03-02 13:23:20 +01:00
|
|
|
# define LITTLE_ENDIAN_UINT32_WRITE(pchar, uint32) \
|
2002-11-01 00:35:46 +01:00
|
|
|
(*(pchar) = LOBYTE(LOWORD(uint32)), \
|
|
|
|
*((pchar)+1) = HIBYTE(LOWORD(uint32)), \
|
|
|
|
*((pchar)+2) = LOBYTE(HIWORD(uint32)), \
|
2009-01-08 17:30:09 +01:00
|
|
|
*((pchar)+3) = HIBYTE(HIWORD(uint32)))
|
2002-10-28 19:47:41 +01:00
|
|
|
|
2005-03-02 13:23:20 +01:00
|
|
|
# define LITTLE_ENDIAN_UINT32_READ(pchar) \
|
2002-10-28 19:47:41 +01:00
|
|
|
(MAKELONG( \
|
2002-10-30 21:26:51 +01:00
|
|
|
MAKEWORD(*(pchar), *((pchar)+1)), \
|
|
|
|
MAKEWORD(*((pchar)+2), *((pchar)+3))))
|
2002-10-28 19:47:41 +01:00
|
|
|
#endif
|
|
|
|
|
2002-11-01 00:35:46 +01:00
|
|
|
#define BIG_ENDIAN_UINT32_WRITE(pchar, uint32) \
|
|
|
|
(*((pchar)+3) = LOBYTE(LOWORD(uint32)), \
|
|
|
|
*((pchar)+2) = HIBYTE(LOWORD(uint32)), \
|
|
|
|
*((pchar)+1) = LOBYTE(HIWORD(uint32)), \
|
2009-01-08 17:30:09 +01:00
|
|
|
*(pchar) = HIBYTE(HIWORD(uint32)))
|
2002-11-01 00:35:46 +01:00
|
|
|
|
|
|
|
#define BIG_ENDIAN_UINT32_READ(pchar) \
|
|
|
|
(MAKELONG( \
|
2002-11-01 02:47:04 +01:00
|
|
|
MAKEWORD(*((pchar)+3), *((pchar)+2)), \
|
2002-11-01 00:35:46 +01:00
|
|
|
MAKEWORD(*((pchar)+1), *(pchar))))
|
|
|
|
|
|
|
|
#ifdef NDR_LOCAL_IS_BIG_ENDIAN
|
2005-03-02 13:23:20 +01:00
|
|
|
# define NDR_LOCAL_UINT32_WRITE(pchar, uint32) \
|
2002-11-01 00:35:46 +01:00
|
|
|
BIG_ENDIAN_UINT32_WRITE(pchar, uint32)
|
2005-03-02 13:23:20 +01:00
|
|
|
# define NDR_LOCAL_UINT32_READ(pchar) \
|
2002-11-01 00:35:46 +01:00
|
|
|
BIG_ENDIAN_UINT32_READ(pchar)
|
|
|
|
#else
|
2005-03-02 13:23:20 +01:00
|
|
|
# define NDR_LOCAL_UINT32_WRITE(pchar, uint32) \
|
2002-11-01 00:35:46 +01:00
|
|
|
LITTLE_ENDIAN_UINT32_WRITE(pchar, uint32)
|
2005-03-02 13:23:20 +01:00
|
|
|
# define NDR_LOCAL_UINT32_READ(pchar) \
|
2002-11-01 00:35:46 +01:00
|
|
|
LITTLE_ENDIAN_UINT32_READ(pchar)
|
|
|
|
#endif
|
|
|
|
|
2010-04-02 21:54:55 +02:00
|
|
|
static inline void align_length( ULONG *len, unsigned int align )
|
|
|
|
{
|
|
|
|
*len = (*len + align - 1) & ~(align - 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void align_pointer( unsigned char **ptr, unsigned int align )
|
|
|
|
{
|
|
|
|
ULONG_PTR mask = align - 1;
|
|
|
|
*ptr = (unsigned char *)(((ULONG_PTR)*ptr + mask) & ~mask);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void align_pointer_clear( unsigned char **ptr, unsigned int align )
|
|
|
|
{
|
|
|
|
ULONG_PTR mask = align - 1;
|
|
|
|
memset( *ptr, 0, (align - (ULONG_PTR)*ptr) & mask );
|
|
|
|
*ptr = (unsigned char *)(((ULONG_PTR)*ptr + mask) & ~mask);
|
|
|
|
}
|
2003-02-01 01:44:51 +01:00
|
|
|
|
2018-11-19 17:02:00 +01:00
|
|
|
static inline void align_pointer_offset( unsigned char **ptr, unsigned char *base, unsigned int align )
|
|
|
|
{
|
|
|
|
ULONG_PTR mask = align - 1;
|
|
|
|
*ptr = base + (((ULONG_PTR)(*ptr - base) + mask) & ~mask);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void align_pointer_offset_clear( unsigned char **ptr, unsigned char *base, unsigned int align )
|
|
|
|
{
|
|
|
|
ULONG_PTR mask = align - 1;
|
|
|
|
memset( *ptr, 0, (align - (ULONG_PTR)(*ptr - base)) & mask );
|
|
|
|
*ptr = base + (((ULONG_PTR)(*ptr - base) + mask) & ~mask);
|
|
|
|
}
|
|
|
|
|
2003-02-17 02:48:24 +01:00
|
|
|
#define STD_OVERFLOW_CHECK(_Msg) do { \
|
2009-05-28 11:56:30 +02:00
|
|
|
TRACE("buffer=%d/%d\n", (ULONG)(_Msg->Buffer - (unsigned char *)_Msg->RpcMsg->Buffer), _Msg->BufferLength); \
|
2005-11-29 10:41:17 +01:00
|
|
|
if (_Msg->Buffer > (unsigned char *)_Msg->RpcMsg->Buffer + _Msg->BufferLength) \
|
2009-05-28 11:56:30 +02:00
|
|
|
ERR("buffer overflow %d bytes\n", (ULONG)(_Msg->Buffer - ((unsigned char *)_Msg->RpcMsg->Buffer + _Msg->BufferLength))); \
|
2003-02-17 02:48:24 +01:00
|
|
|
} while (0)
|
|
|
|
|
2008-06-20 11:15:17 +02:00
|
|
|
#define NDR_POINTER_ID_BASE 0x20000
|
|
|
|
#define NDR_POINTER_ID(pStubMsg) (NDR_POINTER_ID_BASE + ((pStubMsg)->UniquePtrCount++) * 4)
|
2003-02-01 01:44:51 +01:00
|
|
|
#define NDR_TABLE_SIZE 128
|
|
|
|
#define NDR_TABLE_MASK 127
|
|
|
|
|
2005-11-28 11:24:21 +01:00
|
|
|
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);
|
2006-11-09 23:02:49 +01:00
|
|
|
static ULONG WINAPI NdrBaseTypeMemorySize(PMIDL_STUB_MESSAGE, PFORMAT_STRING);
|
2005-11-28 11:24:21 +01:00
|
|
|
|
2007-06-25 15:29:15 +02:00
|
|
|
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);
|
|
|
|
|
2009-01-23 16:09:18 +01:00
|
|
|
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);
|
|
|
|
|
2010-04-05 22:01:46 +02:00
|
|
|
static unsigned char * ComplexBufferSize(PMIDL_STUB_MESSAGE pStubMsg,
|
|
|
|
unsigned char *pMemory,
|
|
|
|
PFORMAT_STRING pFormat,
|
|
|
|
PFORMAT_STRING pPointer);
|
|
|
|
static unsigned char * ComplexMarshall(PMIDL_STUB_MESSAGE pStubMsg,
|
|
|
|
unsigned char *pMemory,
|
|
|
|
PFORMAT_STRING pFormat,
|
|
|
|
PFORMAT_STRING pPointer);
|
|
|
|
static unsigned char * ComplexUnmarshall(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 char * ComplexFree(PMIDL_STUB_MESSAGE pStubMsg,
|
|
|
|
unsigned char *pMemory,
|
|
|
|
PFORMAT_STRING pFormat,
|
|
|
|
PFORMAT_STRING pPointer);
|
|
|
|
|
2006-04-14 14:38:41 +02:00
|
|
|
const NDR_MARSHALL NdrMarshaller[NDR_TABLE_SIZE] = {
|
2003-02-01 01:44:51 +01:00
|
|
|
0,
|
2005-11-28 11:24:21 +01:00
|
|
|
NdrBaseTypeMarshall, NdrBaseTypeMarshall, NdrBaseTypeMarshall,
|
|
|
|
NdrBaseTypeMarshall, NdrBaseTypeMarshall, NdrBaseTypeMarshall, NdrBaseTypeMarshall,
|
|
|
|
NdrBaseTypeMarshall, NdrBaseTypeMarshall, NdrBaseTypeMarshall, NdrBaseTypeMarshall,
|
|
|
|
NdrBaseTypeMarshall, NdrBaseTypeMarshall, NdrBaseTypeMarshall, NdrBaseTypeMarshall,
|
|
|
|
/* 0x10 */
|
|
|
|
NdrBaseTypeMarshall,
|
2003-02-01 01:44:51 +01:00
|
|
|
/* 0x11 */
|
|
|
|
NdrPointerMarshall, NdrPointerMarshall,
|
|
|
|
NdrPointerMarshall, NdrPointerMarshall,
|
|
|
|
/* 0x15 */
|
|
|
|
NdrSimpleStructMarshall, NdrSimpleStructMarshall,
|
2005-07-18 15:14:05 +02:00
|
|
|
NdrConformantStructMarshall, NdrConformantStructMarshall,
|
|
|
|
NdrConformantVaryingStructMarshall,
|
2003-02-01 01:44:51 +01:00
|
|
|
NdrComplexStructMarshall,
|
|
|
|
/* 0x1b */
|
2005-07-18 15:14:05 +02:00
|
|
|
NdrConformantArrayMarshall,
|
|
|
|
NdrConformantVaryingArrayMarshall,
|
|
|
|
NdrFixedArrayMarshall, NdrFixedArrayMarshall,
|
|
|
|
NdrVaryingArrayMarshall, NdrVaryingArrayMarshall,
|
2003-02-01 01:44:51 +01:00
|
|
|
NdrComplexArrayMarshall,
|
|
|
|
/* 0x22 */
|
|
|
|
NdrConformantStringMarshall, 0, 0,
|
2005-08-03 16:55:57 +02:00
|
|
|
NdrConformantStringMarshall,
|
|
|
|
NdrNonConformantStringMarshall, 0, 0, 0,
|
2003-02-01 01:44:51 +01:00
|
|
|
/* 0x2a */
|
2005-07-18 15:14:05 +02:00
|
|
|
NdrEncapsulatedUnionMarshall,
|
|
|
|
NdrNonEncapsulatedUnionMarshall,
|
2006-05-17 15:45:40 +02:00
|
|
|
NdrByteCountPointerMarshall,
|
2005-07-18 15:14:05 +02:00
|
|
|
NdrXmitOrRepAsMarshall, NdrXmitOrRepAsMarshall,
|
2003-02-01 01:44:51 +01:00
|
|
|
/* 0x2f */
|
|
|
|
NdrInterfacePointerMarshall,
|
2007-06-25 15:28:40 +02:00
|
|
|
/* 0x30 */
|
2007-06-25 15:29:15 +02:00
|
|
|
NdrContextHandleMarshall,
|
2007-06-25 15:28:40 +02:00
|
|
|
/* 0xb1 */
|
|
|
|
0, 0, 0,
|
|
|
|
NdrUserMarshalMarshall,
|
|
|
|
0, 0,
|
|
|
|
/* 0xb7 */
|
2015-05-07 10:56:02 +02:00
|
|
|
NdrRangeMarshall,
|
|
|
|
NdrBaseTypeMarshall,
|
|
|
|
NdrBaseTypeMarshall
|
2003-02-01 01:44:51 +01:00
|
|
|
};
|
2006-04-14 14:38:41 +02:00
|
|
|
const NDR_UNMARSHALL NdrUnmarshaller[NDR_TABLE_SIZE] = {
|
2003-02-01 01:44:51 +01:00
|
|
|
0,
|
2005-11-28 11:24:21 +01:00
|
|
|
NdrBaseTypeUnmarshall, NdrBaseTypeUnmarshall, NdrBaseTypeUnmarshall,
|
|
|
|
NdrBaseTypeUnmarshall, NdrBaseTypeUnmarshall, NdrBaseTypeUnmarshall, NdrBaseTypeUnmarshall,
|
|
|
|
NdrBaseTypeUnmarshall, NdrBaseTypeUnmarshall, NdrBaseTypeUnmarshall, NdrBaseTypeUnmarshall,
|
|
|
|
NdrBaseTypeUnmarshall, NdrBaseTypeUnmarshall, NdrBaseTypeUnmarshall, NdrBaseTypeUnmarshall,
|
|
|
|
/* 0x10 */
|
|
|
|
NdrBaseTypeUnmarshall,
|
2003-02-01 01:44:51 +01:00
|
|
|
/* 0x11 */
|
|
|
|
NdrPointerUnmarshall, NdrPointerUnmarshall,
|
|
|
|
NdrPointerUnmarshall, NdrPointerUnmarshall,
|
|
|
|
/* 0x15 */
|
|
|
|
NdrSimpleStructUnmarshall, NdrSimpleStructUnmarshall,
|
2005-07-18 15:14:05 +02:00
|
|
|
NdrConformantStructUnmarshall, NdrConformantStructUnmarshall,
|
|
|
|
NdrConformantVaryingStructUnmarshall,
|
2003-02-01 01:44:51 +01:00
|
|
|
NdrComplexStructUnmarshall,
|
|
|
|
/* 0x1b */
|
2005-07-18 15:14:05 +02:00
|
|
|
NdrConformantArrayUnmarshall,
|
|
|
|
NdrConformantVaryingArrayUnmarshall,
|
|
|
|
NdrFixedArrayUnmarshall, NdrFixedArrayUnmarshall,
|
|
|
|
NdrVaryingArrayUnmarshall, NdrVaryingArrayUnmarshall,
|
2003-02-01 01:44:51 +01:00
|
|
|
NdrComplexArrayUnmarshall,
|
|
|
|
/* 0x22 */
|
|
|
|
NdrConformantStringUnmarshall, 0, 0,
|
2005-08-03 16:55:57 +02:00
|
|
|
NdrConformantStringUnmarshall,
|
|
|
|
NdrNonConformantStringUnmarshall, 0, 0, 0,
|
2003-02-01 01:44:51 +01:00
|
|
|
/* 0x2a */
|
2005-07-18 15:14:05 +02:00
|
|
|
NdrEncapsulatedUnionUnmarshall,
|
|
|
|
NdrNonEncapsulatedUnionUnmarshall,
|
2006-05-17 15:45:40 +02:00
|
|
|
NdrByteCountPointerUnmarshall,
|
2005-07-18 15:14:05 +02:00
|
|
|
NdrXmitOrRepAsUnmarshall, NdrXmitOrRepAsUnmarshall,
|
2003-02-01 01:44:51 +01:00
|
|
|
/* 0x2f */
|
|
|
|
NdrInterfacePointerUnmarshall,
|
2007-06-25 15:28:40 +02:00
|
|
|
/* 0x30 */
|
2007-06-25 15:29:15 +02:00
|
|
|
NdrContextHandleUnmarshall,
|
2007-06-25 15:28:40 +02:00
|
|
|
/* 0xb1 */
|
|
|
|
0, 0, 0,
|
|
|
|
NdrUserMarshalUnmarshall,
|
|
|
|
0, 0,
|
|
|
|
/* 0xb7 */
|
2015-05-07 10:56:02 +02:00
|
|
|
NdrRangeUnmarshall,
|
|
|
|
NdrBaseTypeUnmarshall,
|
|
|
|
NdrBaseTypeUnmarshall
|
2003-02-01 01:44:51 +01:00
|
|
|
};
|
2006-04-14 14:38:41 +02:00
|
|
|
const NDR_BUFFERSIZE NdrBufferSizer[NDR_TABLE_SIZE] = {
|
2003-02-01 01:44:51 +01:00
|
|
|
0,
|
2005-11-28 11:24:21 +01:00
|
|
|
NdrBaseTypeBufferSize, NdrBaseTypeBufferSize, NdrBaseTypeBufferSize,
|
|
|
|
NdrBaseTypeBufferSize, NdrBaseTypeBufferSize, NdrBaseTypeBufferSize, NdrBaseTypeBufferSize,
|
|
|
|
NdrBaseTypeBufferSize, NdrBaseTypeBufferSize, NdrBaseTypeBufferSize, NdrBaseTypeBufferSize,
|
|
|
|
NdrBaseTypeBufferSize, NdrBaseTypeBufferSize, NdrBaseTypeBufferSize, NdrBaseTypeBufferSize,
|
|
|
|
/* 0x10 */
|
|
|
|
NdrBaseTypeBufferSize,
|
2003-02-01 01:44:51 +01:00
|
|
|
/* 0x11 */
|
|
|
|
NdrPointerBufferSize, NdrPointerBufferSize,
|
|
|
|
NdrPointerBufferSize, NdrPointerBufferSize,
|
|
|
|
/* 0x15 */
|
|
|
|
NdrSimpleStructBufferSize, NdrSimpleStructBufferSize,
|
2005-07-18 15:14:05 +02:00
|
|
|
NdrConformantStructBufferSize, NdrConformantStructBufferSize,
|
|
|
|
NdrConformantVaryingStructBufferSize,
|
2003-02-01 01:44:51 +01:00
|
|
|
NdrComplexStructBufferSize,
|
|
|
|
/* 0x1b */
|
2005-07-18 15:14:05 +02:00
|
|
|
NdrConformantArrayBufferSize,
|
|
|
|
NdrConformantVaryingArrayBufferSize,
|
|
|
|
NdrFixedArrayBufferSize, NdrFixedArrayBufferSize,
|
|
|
|
NdrVaryingArrayBufferSize, NdrVaryingArrayBufferSize,
|
2003-02-01 01:44:51 +01:00
|
|
|
NdrComplexArrayBufferSize,
|
|
|
|
/* 0x22 */
|
|
|
|
NdrConformantStringBufferSize, 0, 0,
|
2005-08-03 16:55:57 +02:00
|
|
|
NdrConformantStringBufferSize,
|
|
|
|
NdrNonConformantStringBufferSize, 0, 0, 0,
|
2003-02-01 01:44:51 +01:00
|
|
|
/* 0x2a */
|
2005-07-18 15:14:05 +02:00
|
|
|
NdrEncapsulatedUnionBufferSize,
|
|
|
|
NdrNonEncapsulatedUnionBufferSize,
|
2006-05-17 15:45:40 +02:00
|
|
|
NdrByteCountPointerBufferSize,
|
2005-07-18 15:14:05 +02:00
|
|
|
NdrXmitOrRepAsBufferSize, NdrXmitOrRepAsBufferSize,
|
2003-02-01 01:44:51 +01:00
|
|
|
/* 0x2f */
|
|
|
|
NdrInterfacePointerBufferSize,
|
2007-06-25 15:28:40 +02:00
|
|
|
/* 0x30 */
|
2007-06-25 15:29:15 +02:00
|
|
|
NdrContextHandleBufferSize,
|
2007-06-25 15:28:40 +02:00
|
|
|
/* 0xb1 */
|
|
|
|
0, 0, 0,
|
|
|
|
NdrUserMarshalBufferSize,
|
|
|
|
0, 0,
|
|
|
|
/* 0xb7 */
|
2015-05-07 10:56:02 +02:00
|
|
|
NdrRangeBufferSize,
|
|
|
|
NdrBaseTypeBufferSize,
|
|
|
|
NdrBaseTypeBufferSize
|
2003-02-01 01:44:51 +01:00
|
|
|
};
|
2006-04-14 14:38:41 +02:00
|
|
|
const NDR_MEMORYSIZE NdrMemorySizer[NDR_TABLE_SIZE] = {
|
2003-02-01 01:44:51 +01:00
|
|
|
0,
|
2005-11-28 11:24:21 +01:00
|
|
|
NdrBaseTypeMemorySize, NdrBaseTypeMemorySize, NdrBaseTypeMemorySize,
|
|
|
|
NdrBaseTypeMemorySize, NdrBaseTypeMemorySize, NdrBaseTypeMemorySize, NdrBaseTypeMemorySize,
|
|
|
|
NdrBaseTypeMemorySize, NdrBaseTypeMemorySize, NdrBaseTypeMemorySize, NdrBaseTypeMemorySize,
|
|
|
|
NdrBaseTypeMemorySize, NdrBaseTypeMemorySize, NdrBaseTypeMemorySize, NdrBaseTypeMemorySize,
|
|
|
|
/* 0x10 */
|
|
|
|
NdrBaseTypeMemorySize,
|
2003-02-01 01:44:51 +01:00
|
|
|
/* 0x11 */
|
|
|
|
NdrPointerMemorySize, NdrPointerMemorySize,
|
|
|
|
NdrPointerMemorySize, NdrPointerMemorySize,
|
|
|
|
/* 0x15 */
|
|
|
|
NdrSimpleStructMemorySize, NdrSimpleStructMemorySize,
|
2006-05-17 15:45:40 +02:00
|
|
|
NdrConformantStructMemorySize, NdrConformantStructMemorySize,
|
|
|
|
NdrConformantVaryingStructMemorySize,
|
2003-02-01 01:44:51 +01:00
|
|
|
NdrComplexStructMemorySize,
|
|
|
|
/* 0x1b */
|
2006-05-17 15:45:40 +02:00
|
|
|
NdrConformantArrayMemorySize,
|
|
|
|
NdrConformantVaryingArrayMemorySize,
|
|
|
|
NdrFixedArrayMemorySize, NdrFixedArrayMemorySize,
|
|
|
|
NdrVaryingArrayMemorySize, NdrVaryingArrayMemorySize,
|
2003-02-01 01:44:51 +01:00
|
|
|
NdrComplexArrayMemorySize,
|
|
|
|
/* 0x22 */
|
|
|
|
NdrConformantStringMemorySize, 0, 0,
|
2005-08-03 16:55:57 +02:00
|
|
|
NdrConformantStringMemorySize,
|
|
|
|
NdrNonConformantStringMemorySize, 0, 0, 0,
|
2003-02-01 01:44:51 +01:00
|
|
|
/* 0x2a */
|
2006-05-17 15:45:40 +02:00
|
|
|
NdrEncapsulatedUnionMemorySize,
|
|
|
|
NdrNonEncapsulatedUnionMemorySize,
|
|
|
|
NdrByteCountPointerMemorySize,
|
|
|
|
NdrXmitOrRepAsMemorySize, NdrXmitOrRepAsMemorySize,
|
2003-02-01 01:44:51 +01:00
|
|
|
/* 0x2f */
|
|
|
|
NdrInterfacePointerMemorySize,
|
2007-06-25 15:28:40 +02:00
|
|
|
/* 0x30 */
|
|
|
|
0,
|
|
|
|
/* 0xb1 */
|
|
|
|
0, 0, 0,
|
|
|
|
NdrUserMarshalMemorySize,
|
|
|
|
0, 0,
|
|
|
|
/* 0xb7 */
|
2015-05-07 10:56:02 +02:00
|
|
|
NdrRangeMemorySize,
|
|
|
|
NdrBaseTypeMemorySize,
|
|
|
|
NdrBaseTypeMemorySize
|
2003-02-01 01:44:51 +01:00
|
|
|
};
|
2006-04-14 14:38:41 +02:00
|
|
|
const NDR_FREE NdrFreer[NDR_TABLE_SIZE] = {
|
2003-02-01 01:44:51 +01:00
|
|
|
0,
|
2005-11-28 11:24:21 +01:00
|
|
|
NdrBaseTypeFree, NdrBaseTypeFree, NdrBaseTypeFree,
|
|
|
|
NdrBaseTypeFree, NdrBaseTypeFree, NdrBaseTypeFree, NdrBaseTypeFree,
|
|
|
|
NdrBaseTypeFree, NdrBaseTypeFree, NdrBaseTypeFree, NdrBaseTypeFree,
|
|
|
|
NdrBaseTypeFree, NdrBaseTypeFree, NdrBaseTypeFree, NdrBaseTypeFree,
|
|
|
|
/* 0x10 */
|
|
|
|
NdrBaseTypeFree,
|
2003-02-01 01:44:51 +01:00
|
|
|
/* 0x11 */
|
|
|
|
NdrPointerFree, NdrPointerFree,
|
|
|
|
NdrPointerFree, NdrPointerFree,
|
|
|
|
/* 0x15 */
|
|
|
|
NdrSimpleStructFree, NdrSimpleStructFree,
|
2005-07-18 15:14:05 +02:00
|
|
|
NdrConformantStructFree, NdrConformantStructFree,
|
|
|
|
NdrConformantVaryingStructFree,
|
2003-02-01 01:44:51 +01:00
|
|
|
NdrComplexStructFree,
|
|
|
|
/* 0x1b */
|
2005-07-18 15:14:05 +02:00
|
|
|
NdrConformantArrayFree,
|
|
|
|
NdrConformantVaryingArrayFree,
|
|
|
|
NdrFixedArrayFree, NdrFixedArrayFree,
|
|
|
|
NdrVaryingArrayFree, NdrVaryingArrayFree,
|
2003-02-01 01:44:51 +01:00
|
|
|
NdrComplexArrayFree,
|
|
|
|
/* 0x22 */
|
2005-07-18 15:14:05 +02:00
|
|
|
0, 0, 0,
|
2003-02-01 01:44:51 +01:00
|
|
|
0, 0, 0, 0, 0,
|
2005-07-18 15:14:05 +02:00
|
|
|
/* 0x2a */
|
|
|
|
NdrEncapsulatedUnionFree,
|
|
|
|
NdrNonEncapsulatedUnionFree,
|
|
|
|
0,
|
|
|
|
NdrXmitOrRepAsFree, NdrXmitOrRepAsFree,
|
2003-02-01 01:44:51 +01:00
|
|
|
/* 0x2f */
|
|
|
|
NdrInterfacePointerFree,
|
2007-06-25 15:28:40 +02:00
|
|
|
/* 0x30 */
|
|
|
|
0,
|
|
|
|
/* 0xb1 */
|
|
|
|
0, 0, 0,
|
|
|
|
NdrUserMarshalFree,
|
|
|
|
0, 0,
|
|
|
|
/* 0xb7 */
|
2015-05-07 10:56:02 +02:00
|
|
|
NdrRangeFree,
|
|
|
|
NdrBaseTypeFree,
|
|
|
|
NdrBaseTypeFree
|
2003-02-01 01:44:51 +01:00
|
|
|
};
|
|
|
|
|
2007-12-12 15:48:41 +01:00
|
|
|
typedef struct _NDR_MEMORY_LIST
|
|
|
|
{
|
|
|
|
ULONG magic;
|
|
|
|
ULONG size;
|
|
|
|
ULONG reserved;
|
|
|
|
struct _NDR_MEMORY_LIST *next;
|
|
|
|
} NDR_MEMORY_LIST;
|
|
|
|
|
|
|
|
#define MEML_MAGIC ('M' << 24 | 'E' << 16 | 'M' << 8 | 'L')
|
|
|
|
|
2007-12-13 17:14:51 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* NdrAllocate [RPCRT4.@]
|
|
|
|
*
|
|
|
|
* Allocates a block of memory using pStubMsg->pfnAllocate.
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* pStubMsg [I/O] MIDL_STUB_MESSAGE structure.
|
|
|
|
* len [I] Size of memory block to allocate.
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* The memory block of size len that was allocated.
|
|
|
|
*
|
|
|
|
* NOTES
|
|
|
|
* The memory block is always 8-byte aligned.
|
2015-03-03 08:41:57 +01:00
|
|
|
* If the function is unable to allocate memory an RPC_X_NO_MEMORY
|
2007-12-13 17:14:51 +01:00
|
|
|
* exception is raised.
|
|
|
|
*/
|
2008-09-05 23:07:56 +02:00
|
|
|
void * WINAPI NdrAllocate(MIDL_STUB_MESSAGE *pStubMsg, SIZE_T len)
|
2003-02-01 01:44:51 +01:00
|
|
|
{
|
2008-09-05 23:07:56 +02:00
|
|
|
SIZE_T aligned_len;
|
|
|
|
SIZE_T adjusted_len;
|
2007-12-12 15:48:41 +01:00
|
|
|
void *p;
|
|
|
|
NDR_MEMORY_LIST *mem_list;
|
|
|
|
|
2010-04-02 21:54:55 +02:00
|
|
|
aligned_len = (len + 7) & ~7;
|
2007-12-12 15:48:41 +01:00
|
|
|
adjusted_len = aligned_len + sizeof(NDR_MEMORY_LIST);
|
|
|
|
/* check for overflow */
|
|
|
|
if (adjusted_len < len)
|
|
|
|
{
|
2008-09-05 23:07:56 +02:00
|
|
|
ERR("overflow of adjusted_len %ld, len %ld\n", adjusted_len, len);
|
2007-12-12 15:48:41 +01:00
|
|
|
RpcRaiseException(RPC_X_BAD_STUB_DATA);
|
|
|
|
}
|
|
|
|
|
|
|
|
p = pStubMsg->pfnAllocate(adjusted_len);
|
2015-03-03 08:41:57 +01:00
|
|
|
if (!p) RpcRaiseException(RPC_X_NO_MEMORY);
|
2007-12-12 15:48:41 +01:00
|
|
|
|
|
|
|
mem_list = (NDR_MEMORY_LIST *)((char *)p + aligned_len);
|
|
|
|
mem_list->magic = MEML_MAGIC;
|
|
|
|
mem_list->size = aligned_len;
|
|
|
|
mem_list->reserved = 0;
|
|
|
|
mem_list->next = pStubMsg->pMemoryList;
|
|
|
|
pStubMsg->pMemoryList = mem_list;
|
|
|
|
|
|
|
|
TRACE("-- %p\n", p);
|
|
|
|
return p;
|
2003-02-01 01:44:51 +01:00
|
|
|
}
|
|
|
|
|
2018-10-28 23:25:47 +01:00
|
|
|
static void *NdrAllocateZero(MIDL_STUB_MESSAGE *stubmsg, SIZE_T len)
|
|
|
|
{
|
|
|
|
void *mem = NdrAllocate(stubmsg, len);
|
|
|
|
memset(mem, 0, len);
|
|
|
|
return mem;
|
|
|
|
}
|
|
|
|
|
2008-11-25 16:43:14 +01:00
|
|
|
static void NdrFree(MIDL_STUB_MESSAGE *pStubMsg, unsigned char *Pointer)
|
2003-02-17 02:48:24 +01:00
|
|
|
{
|
2007-12-12 15:48:41 +01:00
|
|
|
TRACE("(%p, %p)\n", pStubMsg, Pointer);
|
|
|
|
|
2007-12-13 17:13:59 +01:00
|
|
|
pStubMsg->pfnFree(Pointer);
|
2003-02-17 02:48:24 +01:00
|
|
|
}
|
|
|
|
|
2006-01-06 21:07:27 +01:00
|
|
|
static inline BOOL IsConformanceOrVariancePresent(PFORMAT_STRING pFormat)
|
|
|
|
{
|
|
|
|
return (*(const ULONG *)pFormat != -1);
|
|
|
|
}
|
|
|
|
|
2015-03-09 10:42:45 +01:00
|
|
|
static inline PFORMAT_STRING SkipConformance(const PMIDL_STUB_MESSAGE pStubMsg, const PFORMAT_STRING pFormat)
|
|
|
|
{
|
2015-07-13 14:11:38 +02:00
|
|
|
return pFormat + 4 + pStubMsg->CorrDespIncrement;
|
2015-03-09 10:42:45 +01:00
|
|
|
}
|
|
|
|
|
2006-05-23 13:06:23 +02:00
|
|
|
static PFORMAT_STRING ReadConformance(MIDL_STUB_MESSAGE *pStubMsg, PFORMAT_STRING pFormat)
|
2003-02-01 01:44:51 +01:00
|
|
|
{
|
2010-04-02 21:54:55 +02:00
|
|
|
align_pointer(&pStubMsg->Buffer, 4);
|
2007-07-16 16:02:38 +02:00
|
|
|
if (pStubMsg->Buffer + 4 > pStubMsg->BufferEnd)
|
|
|
|
RpcRaiseException(RPC_X_BAD_STUB_DATA);
|
2003-02-01 01:44:51 +01:00
|
|
|
pStubMsg->MaxCount = NDR_LOCAL_UINT32_READ(pStubMsg->Buffer);
|
|
|
|
pStubMsg->Buffer += 4;
|
|
|
|
TRACE("unmarshalled conformance is %ld\n", pStubMsg->MaxCount);
|
2015-03-09 10:42:45 +01:00
|
|
|
return SkipConformance(pStubMsg, pFormat);
|
2003-02-01 01:44:51 +01:00
|
|
|
}
|
|
|
|
|
2006-06-10 13:32:47 +02:00
|
|
|
static inline PFORMAT_STRING ReadVariance(MIDL_STUB_MESSAGE *pStubMsg, PFORMAT_STRING pFormat, ULONG MaxValue)
|
2005-11-28 11:16:44 +01:00
|
|
|
{
|
2006-05-13 17:58:31 +02:00
|
|
|
if (pFormat && !IsConformanceOrVariancePresent(pFormat))
|
2006-01-09 17:21:01 +01:00
|
|
|
{
|
|
|
|
pStubMsg->Offset = 0;
|
|
|
|
pStubMsg->ActualCount = pStubMsg->MaxCount;
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
2010-04-02 21:54:55 +02:00
|
|
|
align_pointer(&pStubMsg->Buffer, 4);
|
2007-07-16 16:02:38 +02:00
|
|
|
if (pStubMsg->Buffer + 8 > pStubMsg->BufferEnd)
|
|
|
|
RpcRaiseException(RPC_X_BAD_STUB_DATA);
|
2006-01-09 17:21:01 +01:00
|
|
|
pStubMsg->Offset = NDR_LOCAL_UINT32_READ(pStubMsg->Buffer);
|
|
|
|
pStubMsg->Buffer += 4;
|
2006-11-09 23:04:48 +01:00
|
|
|
TRACE("offset is %d\n", pStubMsg->Offset);
|
2005-11-28 11:16:44 +01:00
|
|
|
pStubMsg->ActualCount = NDR_LOCAL_UINT32_READ(pStubMsg->Buffer);
|
|
|
|
pStubMsg->Buffer += 4;
|
2006-11-09 23:04:48 +01:00
|
|
|
TRACE("variance is %d\n", pStubMsg->ActualCount);
|
2006-01-09 17:21:01 +01:00
|
|
|
|
2006-06-10 13:32:47 +02:00
|
|
|
if ((pStubMsg->ActualCount > MaxValue) ||
|
|
|
|
(pStubMsg->ActualCount + pStubMsg->Offset > MaxValue))
|
|
|
|
{
|
2006-11-09 23:04:48 +01:00
|
|
|
ERR("invalid array bound(s): ActualCount = %d, Offset = %d, MaxValue = %d\n",
|
2006-06-10 13:32:47 +02:00
|
|
|
pStubMsg->ActualCount, pStubMsg->Offset, MaxValue);
|
|
|
|
RpcRaiseException(RPC_S_INVALID_BOUND);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2006-01-09 17:21:01 +01:00
|
|
|
done:
|
2015-03-09 10:42:45 +01:00
|
|
|
return SkipConformance(pStubMsg, pFormat);
|
2005-11-28 11:16:44 +01:00
|
|
|
}
|
|
|
|
|
2006-05-10 14:13:15 +02:00
|
|
|
/* writes the conformance value to the buffer */
|
|
|
|
static inline void WriteConformance(MIDL_STUB_MESSAGE *pStubMsg)
|
|
|
|
{
|
2010-04-02 21:54:55 +02:00
|
|
|
align_pointer_clear(&pStubMsg->Buffer, 4);
|
2007-11-28 16:02:21 +01:00
|
|
|
if (pStubMsg->Buffer + 4 > (unsigned char *)pStubMsg->RpcMsg->Buffer + pStubMsg->BufferLength)
|
|
|
|
RpcRaiseException(RPC_X_BAD_STUB_DATA);
|
2006-05-10 14:13:15 +02:00
|
|
|
NDR_LOCAL_UINT32_WRITE(pStubMsg->Buffer, pStubMsg->MaxCount);
|
|
|
|
pStubMsg->Buffer += 4;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* writes the variance values to the buffer */
|
|
|
|
static inline void WriteVariance(MIDL_STUB_MESSAGE *pStubMsg)
|
|
|
|
{
|
2010-04-02 21:54:55 +02:00
|
|
|
align_pointer_clear(&pStubMsg->Buffer, 4);
|
2007-11-28 16:02:21 +01:00
|
|
|
if (pStubMsg->Buffer + 8 > (unsigned char *)pStubMsg->RpcMsg->Buffer + pStubMsg->BufferLength)
|
|
|
|
RpcRaiseException(RPC_X_BAD_STUB_DATA);
|
2006-05-10 14:13:15 +02:00
|
|
|
NDR_LOCAL_UINT32_WRITE(pStubMsg->Buffer, pStubMsg->Offset);
|
|
|
|
pStubMsg->Buffer += 4;
|
|
|
|
NDR_LOCAL_UINT32_WRITE(pStubMsg->Buffer, pStubMsg->ActualCount);
|
|
|
|
pStubMsg->Buffer += 4;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* requests buffer space for the conformance value */
|
|
|
|
static inline void SizeConformance(MIDL_STUB_MESSAGE *pStubMsg)
|
|
|
|
{
|
2010-04-02 21:54:55 +02:00
|
|
|
align_length(&pStubMsg->BufferLength, 4);
|
2007-11-28 16:02:21 +01:00
|
|
|
if (pStubMsg->BufferLength + 4 < pStubMsg->BufferLength)
|
|
|
|
RpcRaiseException(RPC_X_BAD_STUB_DATA);
|
2006-05-10 14:13:15 +02:00
|
|
|
pStubMsg->BufferLength += 4;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* requests buffer space for the variance values */
|
|
|
|
static inline void SizeVariance(MIDL_STUB_MESSAGE *pStubMsg)
|
|
|
|
{
|
2010-04-02 21:54:55 +02:00
|
|
|
align_length(&pStubMsg->BufferLength, 4);
|
2007-11-28 16:02:21 +01:00
|
|
|
if (pStubMsg->BufferLength + 8 < pStubMsg->BufferLength)
|
|
|
|
RpcRaiseException(RPC_X_BAD_STUB_DATA);
|
2006-05-10 14:13:15 +02:00
|
|
|
pStubMsg->BufferLength += 8;
|
|
|
|
}
|
|
|
|
|
2005-11-28 11:16:44 +01:00
|
|
|
PFORMAT_STRING ComputeConformanceOrVariance(
|
|
|
|
MIDL_STUB_MESSAGE *pStubMsg, unsigned char *pMemory,
|
2006-11-09 23:02:49 +01:00
|
|
|
PFORMAT_STRING pFormat, ULONG_PTR def, ULONG_PTR *pCount)
|
2003-02-01 01:44:51 +01:00
|
|
|
{
|
|
|
|
BYTE dtype = pFormat[0] & 0xf;
|
2006-09-25 23:20:20 +02:00
|
|
|
short ofs = *(const short *)&pFormat[2];
|
2003-02-01 01:44:51 +01:00
|
|
|
LPVOID ptr = NULL;
|
2011-06-17 14:11:12 +02:00
|
|
|
ULONG_PTR data = 0;
|
2003-02-01 01:44:51 +01:00
|
|
|
|
2006-01-06 21:07:27 +01:00
|
|
|
if (!IsConformanceOrVariancePresent(pFormat)) {
|
2003-02-01 01:44:51 +01:00
|
|
|
/* null descriptor */
|
2005-11-28 11:16:44 +01:00
|
|
|
*pCount = def;
|
2003-02-01 01:44:51 +01:00
|
|
|
goto finish_conf;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (pFormat[0] & 0xf0) {
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_NORMAL_CONFORMANCE:
|
2005-11-28 10:58:40 +01:00
|
|
|
TRACE("normal conformance, ofs=%d\n", ofs);
|
2006-04-20 12:45:40 +02:00
|
|
|
ptr = pMemory;
|
2003-02-01 01:44:51 +01:00
|
|
|
break;
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_POINTER_CONFORMANCE:
|
2005-11-28 10:58:40 +01:00
|
|
|
TRACE("pointer conformance, ofs=%d\n", ofs);
|
2006-04-20 12:45:40 +02:00
|
|
|
ptr = pStubMsg->Memory;
|
2003-02-01 01:44:51 +01:00
|
|
|
break;
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_TOP_LEVEL_CONFORMANCE:
|
2005-11-28 10:58:40 +01:00
|
|
|
TRACE("toplevel conformance, ofs=%d\n", ofs);
|
2003-02-01 01:44:51 +01:00
|
|
|
if (pStubMsg->StackTop) {
|
2006-04-20 12:45:40 +02:00
|
|
|
ptr = pStubMsg->StackTop;
|
2003-02-01 01:44:51 +01:00
|
|
|
}
|
|
|
|
else {
|
2005-11-28 11:16:44 +01:00
|
|
|
/* -Os mode, *pCount is already set */
|
2003-02-01 01:44:51 +01:00
|
|
|
goto finish_conf;
|
|
|
|
}
|
|
|
|
break;
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_CONSTANT_CONFORMANCE:
|
2003-02-01 01:44:51 +01:00
|
|
|
data = ofs | ((DWORD)pFormat[1] << 16);
|
2011-06-17 14:11:12 +02:00
|
|
|
TRACE("constant conformance, val=%ld\n", data);
|
2005-11-28 11:16:44 +01:00
|
|
|
*pCount = data;
|
2003-02-01 01:44:51 +01:00
|
|
|
goto finish_conf;
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_TOP_LEVEL_MULTID_CONFORMANCE:
|
2005-11-28 10:58:40 +01:00
|
|
|
FIXME("toplevel multidimensional conformance, ofs=%d\n", ofs);
|
2003-02-01 01:44:51 +01:00
|
|
|
if (pStubMsg->StackTop) {
|
2006-04-20 12:45:40 +02:00
|
|
|
ptr = pStubMsg->StackTop;
|
2003-02-01 01:44:51 +01:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
/* ? */
|
|
|
|
goto done_conf_grab;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
2009-12-15 11:44:37 +01:00
|
|
|
FIXME("unknown conformance type %x, expect crash.\n", pFormat[0] & 0xf0);
|
|
|
|
goto finish_conf;
|
2003-02-01 01:44:51 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
switch (pFormat[1]) {
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_DEREFERENCE:
|
2006-04-20 12:45:40 +02:00
|
|
|
ptr = *(LPVOID*)((char *)ptr + ofs);
|
2003-02-01 01:44:51 +01:00
|
|
|
break;
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_CALLBACK:
|
2006-01-03 12:07:17 +01:00
|
|
|
{
|
|
|
|
unsigned char *old_stack_top = pStubMsg->StackTop;
|
2011-06-14 12:57:30 +02:00
|
|
|
ULONG_PTR max_count, old_max_count = pStubMsg->MaxCount;
|
|
|
|
|
2006-01-03 12:07:17 +01:00
|
|
|
pStubMsg->StackTop = ptr;
|
|
|
|
|
2003-02-01 01:44:51 +01:00
|
|
|
/* ofs is index into StubDesc->apfnExprEval */
|
2006-01-03 12:07:17 +01:00
|
|
|
TRACE("callback conformance into apfnExprEval[%d]\n", ofs);
|
|
|
|
pStubMsg->StubDesc->apfnExprEval[ofs](pStubMsg);
|
|
|
|
|
|
|
|
pStubMsg->StackTop = old_stack_top;
|
2006-07-14 01:02:44 +02:00
|
|
|
|
|
|
|
/* the callback function always stores the computed value in MaxCount */
|
2011-06-14 12:57:30 +02:00
|
|
|
max_count = pStubMsg->MaxCount;
|
|
|
|
pStubMsg->MaxCount = old_max_count;
|
|
|
|
*pCount = max_count;
|
2003-02-01 01:44:51 +01:00
|
|
|
goto finish_conf;
|
2006-01-03 12:07:17 +01:00
|
|
|
}
|
2003-02-01 01:44:51 +01:00
|
|
|
default:
|
2006-04-20 12:45:40 +02:00
|
|
|
ptr = (char *)ptr + ofs;
|
2003-02-01 01:44:51 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (dtype) {
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_LONG:
|
|
|
|
case FC_ULONG:
|
2003-02-01 01:44:51 +01:00
|
|
|
data = *(DWORD*)ptr;
|
|
|
|
break;
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_SHORT:
|
2003-02-01 01:44:51 +01:00
|
|
|
data = *(SHORT*)ptr;
|
|
|
|
break;
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_USHORT:
|
2003-02-01 01:44:51 +01:00
|
|
|
data = *(USHORT*)ptr;
|
|
|
|
break;
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_CHAR:
|
|
|
|
case FC_SMALL:
|
2003-02-01 01:44:51 +01:00
|
|
|
data = *(CHAR*)ptr;
|
|
|
|
break;
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_BYTE:
|
|
|
|
case FC_USMALL:
|
2003-02-01 01:44:51 +01:00
|
|
|
data = *(UCHAR*)ptr;
|
|
|
|
break;
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_HYPER:
|
2011-06-17 14:11:12 +02:00
|
|
|
data = *(ULONGLONG *)ptr;
|
|
|
|
break;
|
2003-02-01 01:44:51 +01:00
|
|
|
default:
|
|
|
|
FIXME("unknown conformance data type %x\n", dtype);
|
|
|
|
goto done_conf_grab;
|
|
|
|
}
|
2011-06-17 14:11:12 +02:00
|
|
|
TRACE("dereferenced data type %x at %p, got %ld\n", dtype, ptr, data);
|
2003-02-01 01:44:51 +01:00
|
|
|
|
|
|
|
done_conf_grab:
|
|
|
|
switch (pFormat[1]) {
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_DEREFERENCE: /* already handled */
|
2003-02-01 01:44:51 +01:00
|
|
|
case 0: /* no op */
|
2005-11-28 11:16:44 +01:00
|
|
|
*pCount = data;
|
2003-02-01 01:44:51 +01:00
|
|
|
break;
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_ADD_1:
|
2006-05-15 17:56:45 +02:00
|
|
|
*pCount = data + 1;
|
|
|
|
break;
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_SUB_1:
|
2006-05-15 17:56:45 +02:00
|
|
|
*pCount = data - 1;
|
|
|
|
break;
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_MULT_2:
|
2006-05-15 17:56:45 +02:00
|
|
|
*pCount = data * 2;
|
|
|
|
break;
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_DIV_2:
|
2006-05-15 17:56:45 +02:00
|
|
|
*pCount = data / 2;
|
|
|
|
break;
|
2003-02-01 01:44:51 +01:00
|
|
|
default:
|
|
|
|
FIXME("unknown conformance op %d\n", pFormat[1]);
|
|
|
|
goto finish_conf;
|
|
|
|
}
|
|
|
|
|
|
|
|
finish_conf:
|
2005-11-28 11:16:44 +01:00
|
|
|
TRACE("resulting conformance is %ld\n", *pCount);
|
2003-02-01 01:44:51 +01:00
|
|
|
|
2015-03-09 10:42:45 +01:00
|
|
|
return SkipConformance(pStubMsg, pFormat);
|
2010-04-05 21:59:30 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline PFORMAT_STRING SkipVariance(PMIDL_STUB_MESSAGE pStubMsg, PFORMAT_STRING pFormat)
|
|
|
|
{
|
|
|
|
return SkipConformance( pStubMsg, pFormat );
|
2008-08-10 12:14:07 +02:00
|
|
|
}
|
|
|
|
|
2006-06-10 13:31:45 +02:00
|
|
|
/* multiply two numbers together, raising an RPC_S_INVALID_BOUND exception if
|
|
|
|
* the result overflows 32-bits */
|
2007-03-22 19:26:46 +01:00
|
|
|
static inline ULONG safe_multiply(ULONG a, ULONG b)
|
2006-06-10 13:31:45 +02:00
|
|
|
{
|
|
|
|
ULONGLONG ret = (ULONGLONG)a * b;
|
|
|
|
if (ret > 0xffffffff)
|
|
|
|
{
|
|
|
|
RpcRaiseException(RPC_S_INVALID_BOUND);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2007-07-16 16:02:38 +02:00
|
|
|
static inline void safe_buffer_increment(MIDL_STUB_MESSAGE *pStubMsg, ULONG size)
|
|
|
|
{
|
|
|
|
if ((pStubMsg->Buffer + size < pStubMsg->Buffer) || /* integer overflow of pStubMsg->Buffer */
|
2007-11-28 16:02:06 +01:00
|
|
|
(pStubMsg->Buffer + size > (unsigned char *)pStubMsg->RpcMsg->Buffer + pStubMsg->BufferLength))
|
2007-07-16 16:02:38 +02:00
|
|
|
RpcRaiseException(RPC_X_BAD_STUB_DATA);
|
|
|
|
pStubMsg->Buffer += size;
|
|
|
|
}
|
|
|
|
|
2007-11-28 16:01:53 +01:00
|
|
|
static inline void safe_buffer_length_increment(MIDL_STUB_MESSAGE *pStubMsg, ULONG size)
|
|
|
|
{
|
|
|
|
if (pStubMsg->BufferLength + size < pStubMsg->BufferLength) /* integer overflow of pStubMsg->BufferSize */
|
|
|
|
{
|
|
|
|
ERR("buffer length overflow - BufferLength = %u, size = %u\n",
|
|
|
|
pStubMsg->BufferLength, size);
|
|
|
|
RpcRaiseException(RPC_X_BAD_STUB_DATA);
|
|
|
|
}
|
|
|
|
pStubMsg->BufferLength += size;
|
|
|
|
}
|
|
|
|
|
2007-07-16 16:02:38 +02:00
|
|
|
/* copies data from the buffer, checking that there is enough data in the buffer
|
|
|
|
* to do so */
|
2007-11-28 16:01:53 +01:00
|
|
|
static inline void safe_copy_from_buffer(MIDL_STUB_MESSAGE *pStubMsg, void *p, ULONG size)
|
2007-07-16 16:02:38 +02:00
|
|
|
{
|
|
|
|
if ((pStubMsg->Buffer + size < pStubMsg->Buffer) || /* integer overflow of pStubMsg->Buffer */
|
|
|
|
(pStubMsg->Buffer + size > pStubMsg->BufferEnd))
|
2007-12-20 19:01:16 +01:00
|
|
|
{
|
|
|
|
ERR("buffer overflow - Buffer = %p, BufferEnd = %p, size = %u\n",
|
|
|
|
pStubMsg->Buffer, pStubMsg->BufferEnd, size);
|
2007-07-16 16:02:38 +02:00
|
|
|
RpcRaiseException(RPC_X_BAD_STUB_DATA);
|
2007-12-20 19:01:16 +01:00
|
|
|
}
|
|
|
|
if (p == pStubMsg->Buffer)
|
|
|
|
ERR("pointer is the same as the buffer\n");
|
2007-07-16 16:02:38 +02:00
|
|
|
memcpy(p, pStubMsg->Buffer, size);
|
|
|
|
pStubMsg->Buffer += size;
|
|
|
|
}
|
2003-02-01 01:44:51 +01:00
|
|
|
|
2007-11-28 16:02:06 +01:00
|
|
|
/* copies data to the buffer, checking that there is enough space to do so */
|
|
|
|
static inline void safe_copy_to_buffer(MIDL_STUB_MESSAGE *pStubMsg, const void *p, ULONG size)
|
|
|
|
{
|
|
|
|
if ((pStubMsg->Buffer + size < pStubMsg->Buffer) || /* integer overflow of pStubMsg->Buffer */
|
|
|
|
(pStubMsg->Buffer + size > (unsigned char *)pStubMsg->RpcMsg->Buffer + pStubMsg->BufferLength))
|
|
|
|
{
|
|
|
|
ERR("buffer overflow - Buffer = %p, BufferEnd = %p, size = %u\n",
|
|
|
|
pStubMsg->Buffer, (unsigned char *)pStubMsg->RpcMsg->Buffer + pStubMsg->BufferLength,
|
|
|
|
size);
|
|
|
|
RpcRaiseException(RPC_X_BAD_STUB_DATA);
|
|
|
|
}
|
|
|
|
memcpy(pStubMsg->Buffer, p, size);
|
|
|
|
pStubMsg->Buffer += size;
|
|
|
|
}
|
|
|
|
|
2008-06-23 13:56:29 +02:00
|
|
|
/* verify that string data sitting in the buffer is valid and safe to
|
|
|
|
* unmarshall */
|
|
|
|
static void validate_string_data(MIDL_STUB_MESSAGE *pStubMsg, ULONG bufsize, ULONG esize)
|
|
|
|
{
|
|
|
|
ULONG i;
|
|
|
|
|
|
|
|
/* verify the buffer is safe to access */
|
|
|
|
if ((pStubMsg->Buffer + bufsize < pStubMsg->Buffer) ||
|
|
|
|
(pStubMsg->Buffer + bufsize > pStubMsg->BufferEnd))
|
|
|
|
{
|
|
|
|
ERR("bufsize 0x%x exceeded buffer end %p of buffer %p\n", bufsize,
|
|
|
|
pStubMsg->BufferEnd, pStubMsg->Buffer);
|
|
|
|
RpcRaiseException(RPC_X_BAD_STUB_DATA);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* strings must always have null terminating bytes */
|
|
|
|
if (bufsize < esize)
|
|
|
|
{
|
|
|
|
ERR("invalid string length of %d\n", bufsize / esize);
|
|
|
|
RpcRaiseException(RPC_S_INVALID_BOUND);
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = bufsize - esize; i < bufsize; i++)
|
|
|
|
if (pStubMsg->Buffer[i] != 0)
|
|
|
|
{
|
|
|
|
ERR("string not null-terminated at byte position %d, data is 0x%x\n",
|
|
|
|
i, pStubMsg->Buffer[i]);
|
|
|
|
RpcRaiseException(RPC_S_INVALID_BOUND);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-06-01 13:04:03 +02:00
|
|
|
static inline void dump_pointer_attr(unsigned char attr)
|
|
|
|
{
|
2018-06-13 04:19:10 +02:00
|
|
|
if (attr & FC_ALLOCATE_ALL_NODES)
|
|
|
|
TRACE(" FC_ALLOCATE_ALL_NODES");
|
|
|
|
if (attr & FC_DONT_FREE)
|
|
|
|
TRACE(" FC_DONT_FREE");
|
|
|
|
if (attr & FC_ALLOCED_ON_STACK)
|
|
|
|
TRACE(" FC_ALLOCED_ON_STACK");
|
|
|
|
if (attr & FC_SIMPLE_POINTER)
|
|
|
|
TRACE(" FC_SIMPLE_POINTER");
|
|
|
|
if (attr & FC_POINTER_DEREF)
|
|
|
|
TRACE(" FC_POINTER_DEREF");
|
2005-06-01 13:04:03 +02:00
|
|
|
TRACE("\n");
|
|
|
|
}
|
|
|
|
|
2003-02-01 01:44:51 +01:00
|
|
|
/***********************************************************************
|
2006-11-12 20:23:02 +01:00
|
|
|
* PointerMarshall [internal]
|
2003-02-01 01:44:51 +01:00
|
|
|
*/
|
2006-05-19 17:02:41 +02:00
|
|
|
static void PointerMarshall(PMIDL_STUB_MESSAGE pStubMsg,
|
2003-02-01 01:44:51 +01:00
|
|
|
unsigned char *Buffer,
|
|
|
|
unsigned char *Pointer,
|
|
|
|
PFORMAT_STRING pFormat)
|
|
|
|
{
|
|
|
|
unsigned type = pFormat[0], attr = pFormat[1];
|
|
|
|
PFORMAT_STRING desc;
|
|
|
|
NDR_MARSHALL m;
|
2006-11-09 23:02:49 +01:00
|
|
|
ULONG pointer_id;
|
2013-12-03 00:02:50 +01:00
|
|
|
BOOL pointer_needs_marshaling;
|
2003-02-01 01:44:51 +01:00
|
|
|
|
|
|
|
TRACE("(%p,%p,%p,%p)\n", pStubMsg, Buffer, Pointer, pFormat);
|
2005-06-01 13:04:03 +02:00
|
|
|
TRACE("type=0x%x, attr=", type); dump_pointer_attr(attr);
|
2003-02-01 01:44:51 +01:00
|
|
|
pFormat += 2;
|
2018-06-13 04:19:10 +02:00
|
|
|
if (attr & FC_SIMPLE_POINTER) desc = pFormat;
|
2004-11-30 22:38:57 +01:00
|
|
|
else desc = pFormat + *(const SHORT*)pFormat;
|
2003-02-01 01:44:51 +01:00
|
|
|
|
|
|
|
switch (type) {
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_RP: /* ref pointer (always non-null) */
|
2005-06-01 13:04:03 +02:00
|
|
|
if (!Pointer)
|
2007-11-20 19:03:18 +01:00
|
|
|
{
|
|
|
|
ERR("NULL ref pointer is not allowed\n");
|
2005-06-01 13:04:03 +02:00
|
|
|
RpcRaiseException(RPC_X_NULL_REF_POINTER);
|
2007-11-20 19:03:18 +01:00
|
|
|
}
|
2013-12-03 00:02:50 +01:00
|
|
|
pointer_needs_marshaling = TRUE;
|
2005-06-01 13:04:03 +02:00
|
|
|
break;
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_UP: /* unique pointer */
|
|
|
|
case FC_OP: /* object pointer - same as unique here */
|
2006-05-29 17:27:27 +02:00
|
|
|
if (Pointer)
|
2013-12-03 00:02:50 +01:00
|
|
|
pointer_needs_marshaling = TRUE;
|
2006-05-29 17:27:27 +02:00
|
|
|
else
|
2013-12-03 00:02:50 +01:00
|
|
|
pointer_needs_marshaling = FALSE;
|
2008-06-20 11:15:17 +02:00
|
|
|
pointer_id = Pointer ? NDR_POINTER_ID(pStubMsg) : 0;
|
2006-11-09 23:04:48 +01:00
|
|
|
TRACE("writing 0x%08x to buffer\n", pointer_id);
|
2006-05-29 17:27:27 +02:00
|
|
|
NDR_LOCAL_UINT32_WRITE(Buffer, pointer_id);
|
2003-02-01 01:44:51 +01:00
|
|
|
break;
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_FP:
|
2006-05-29 17:27:27 +02:00
|
|
|
pointer_needs_marshaling = !NdrFullPointerQueryPointer(
|
|
|
|
pStubMsg->FullPtrXlatTables, Pointer, 1, &pointer_id);
|
2006-11-09 23:04:48 +01:00
|
|
|
TRACE("writing 0x%08x to buffer\n", pointer_id);
|
2006-05-29 17:27:27 +02:00
|
|
|
NDR_LOCAL_UINT32_WRITE(Buffer, pointer_id);
|
|
|
|
break;
|
2003-02-01 01:44:51 +01:00
|
|
|
default:
|
|
|
|
FIXME("unhandled ptr type=%02x\n", type);
|
2005-06-01 13:04:03 +02:00
|
|
|
RpcRaiseException(RPC_X_BAD_STUB_DATA);
|
2006-05-29 17:27:27 +02:00
|
|
|
return;
|
2003-02-01 01:44:51 +01:00
|
|
|
}
|
|
|
|
|
2005-06-01 13:04:03 +02:00
|
|
|
TRACE("calling marshaller for type 0x%x\n", (int)*desc);
|
|
|
|
|
2006-05-29 17:27:27 +02:00
|
|
|
if (pointer_needs_marshaling) {
|
2018-06-13 04:19:10 +02:00
|
|
|
if (attr & FC_POINTER_DEREF) {
|
2006-05-01 11:37:11 +02:00
|
|
|
Pointer = *(unsigned char**)Pointer;
|
|
|
|
TRACE("deref => %p\n", Pointer);
|
|
|
|
}
|
2005-06-01 13:04:03 +02:00
|
|
|
m = NdrMarshaller[*desc & NDR_TABLE_MASK];
|
|
|
|
if (m) m(pStubMsg, Pointer, desc);
|
|
|
|
else FIXME("no marshaller for data type=%02x\n", *desc);
|
|
|
|
}
|
2003-02-17 02:48:24 +01:00
|
|
|
|
|
|
|
STD_OVERFLOW_CHECK(pStubMsg);
|
2003-02-01 01:44:51 +01:00
|
|
|
}
|
|
|
|
|
2018-10-28 23:25:46 +01:00
|
|
|
/* pPointer is the pointer that we will unmarshal into; pSrcPointer is the
|
|
|
|
* pointer to memory which we may attempt to reuse if non-NULL. Usually these
|
2018-10-28 23:25:49 +01:00
|
|
|
* are the same; for the case when they aren't, see EmbeddedPointerUnmarshall().
|
|
|
|
*
|
|
|
|
* fMustAlloc seems to determine whether we can allocate from the buffer (if we
|
|
|
|
* are on the server side). It's ignored here, since we can't allocate a pointer
|
|
|
|
* from the buffer. */
|
2006-05-19 17:02:41 +02:00
|
|
|
static void PointerUnmarshall(PMIDL_STUB_MESSAGE pStubMsg,
|
2003-02-01 01:44:51 +01:00
|
|
|
unsigned char *Buffer,
|
|
|
|
unsigned char **pPointer,
|
2007-11-29 18:35:34 +01:00
|
|
|
unsigned char *pSrcPointer,
|
2003-02-01 01:44:51 +01:00
|
|
|
PFORMAT_STRING pFormat,
|
|
|
|
unsigned char fMustAlloc)
|
|
|
|
{
|
|
|
|
unsigned type = pFormat[0], attr = pFormat[1];
|
|
|
|
PFORMAT_STRING desc;
|
|
|
|
NDR_UNMARSHALL m;
|
2005-06-01 13:04:03 +02:00
|
|
|
DWORD pointer_id = 0;
|
2018-10-28 23:25:49 +01:00
|
|
|
BOOL pointer_needs_unmarshaling, need_alloc = FALSE, inner_must_alloc = FALSE;
|
2003-02-01 01:44:51 +01:00
|
|
|
|
2007-11-29 18:35:34 +01:00
|
|
|
TRACE("(%p,%p,%p,%p,%p,%d)\n", pStubMsg, Buffer, pPointer, pSrcPointer, pFormat, fMustAlloc);
|
2005-06-01 13:04:03 +02:00
|
|
|
TRACE("type=0x%x, attr=", type); dump_pointer_attr(attr);
|
2003-02-01 01:44:51 +01:00
|
|
|
pFormat += 2;
|
2018-06-13 04:19:10 +02:00
|
|
|
if (attr & FC_SIMPLE_POINTER) desc = pFormat;
|
2004-11-30 22:38:57 +01:00
|
|
|
else desc = pFormat + *(const SHORT*)pFormat;
|
2003-02-01 01:44:51 +01:00
|
|
|
|
|
|
|
switch (type) {
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_RP: /* ref pointer (always non-null) */
|
2013-12-03 00:02:50 +01:00
|
|
|
pointer_needs_unmarshaling = TRUE;
|
2005-06-01 13:04:03 +02:00
|
|
|
break;
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_UP: /* unique pointer */
|
2006-05-10 14:13:45 +02:00
|
|
|
pointer_id = NDR_LOCAL_UINT32_READ(Buffer);
|
2006-11-09 23:04:48 +01:00
|
|
|
TRACE("pointer_id is 0x%08x\n", pointer_id);
|
2006-05-29 17:27:27 +02:00
|
|
|
if (pointer_id)
|
2013-12-03 00:02:50 +01:00
|
|
|
pointer_needs_unmarshaling = TRUE;
|
2006-05-29 17:28:29 +02:00
|
|
|
else {
|
|
|
|
*pPointer = NULL;
|
2013-12-03 00:02:50 +01:00
|
|
|
pointer_needs_unmarshaling = FALSE;
|
2006-05-29 17:28:29 +02:00
|
|
|
}
|
2003-02-01 01:44:51 +01:00
|
|
|
break;
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_OP: /* object pointer - we must free data before overwriting it */
|
2006-05-10 14:13:45 +02:00
|
|
|
pointer_id = NDR_LOCAL_UINT32_READ(Buffer);
|
2006-11-09 23:04:48 +01:00
|
|
|
TRACE("pointer_id is 0x%08x\n", pointer_id);
|
2018-10-28 23:25:49 +01:00
|
|
|
|
|
|
|
/* An object pointer always allocates new memory (it cannot point to the
|
|
|
|
* buffer). */
|
|
|
|
inner_must_alloc = TRUE;
|
|
|
|
|
|
|
|
if (pSrcPointer)
|
2007-11-29 18:35:34 +01:00
|
|
|
FIXME("free object pointer %p\n", pSrcPointer);
|
2006-05-29 17:27:27 +02:00
|
|
|
if (pointer_id)
|
2013-12-03 00:02:50 +01:00
|
|
|
pointer_needs_unmarshaling = TRUE;
|
2006-05-29 17:27:27 +02:00
|
|
|
else
|
2008-10-01 20:43:37 +02:00
|
|
|
{
|
|
|
|
*pPointer = NULL;
|
2013-12-03 00:02:50 +01:00
|
|
|
pointer_needs_unmarshaling = FALSE;
|
2008-10-01 20:43:37 +02:00
|
|
|
}
|
2005-09-02 13:19:26 +02:00
|
|
|
break;
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_FP:
|
2006-05-29 17:27:27 +02:00
|
|
|
pointer_id = NDR_LOCAL_UINT32_READ(Buffer);
|
2006-11-09 23:04:48 +01:00
|
|
|
TRACE("pointer_id is 0x%08x\n", pointer_id);
|
2006-05-29 17:27:27 +02:00
|
|
|
pointer_needs_unmarshaling = !NdrFullPointerQueryRefId(
|
|
|
|
pStubMsg->FullPtrXlatTables, pointer_id, 1, (void **)pPointer);
|
|
|
|
break;
|
2003-02-01 01:44:51 +01:00
|
|
|
default:
|
|
|
|
FIXME("unhandled ptr type=%02x\n", type);
|
2005-06-01 13:04:03 +02:00
|
|
|
RpcRaiseException(RPC_X_BAD_STUB_DATA);
|
2006-05-29 17:27:27 +02:00
|
|
|
return;
|
2003-02-01 01:44:51 +01:00
|
|
|
}
|
|
|
|
|
2006-05-29 17:27:27 +02:00
|
|
|
if (pointer_needs_unmarshaling) {
|
2007-11-29 18:35:34 +01:00
|
|
|
unsigned char **current_ptr = pPointer;
|
|
|
|
if (pStubMsg->IsClient) {
|
|
|
|
TRACE("client\n");
|
2018-10-28 23:25:49 +01:00
|
|
|
/* Try to use the existing (source) pointer to unmarshall the data into
|
|
|
|
* so that [in, out] or [out, ref] parameters behave correctly. If the
|
|
|
|
* source pointer is NULL and we are not dereferencing, we must force the
|
|
|
|
* inner marshalling routine to allocate, since otherwise it will crash. */
|
|
|
|
if (pSrcPointer)
|
|
|
|
{
|
|
|
|
TRACE("setting *pPointer to %p\n", pSrcPointer);
|
|
|
|
*pPointer = pSrcPointer;
|
2007-11-29 18:35:34 +01:00
|
|
|
}
|
2018-10-28 23:25:49 +01:00
|
|
|
else
|
|
|
|
need_alloc = inner_must_alloc = TRUE;
|
2007-11-29 18:35:34 +01:00
|
|
|
} else {
|
|
|
|
TRACE("server\n");
|
2018-10-28 23:25:49 +01:00
|
|
|
/* We can use an existing source pointer here only if it is on-stack,
|
|
|
|
* probably since otherwise NdrPointerFree() might later try to free a
|
|
|
|
* pointer we don't know the provenance of. Otherwise we must always
|
|
|
|
* allocate if we are dereferencing. We never need to force the inner
|
|
|
|
* routine to allocate here, since it will either write into an existing
|
|
|
|
* pointer, or use a pointer to the buffer. */
|
2018-10-28 23:25:48 +01:00
|
|
|
if (attr & FC_POINTER_DEREF)
|
|
|
|
{
|
2018-10-17 01:49:54 +02:00
|
|
|
if (pSrcPointer && (attr & FC_ALLOCED_ON_STACK))
|
|
|
|
*pPointer = pSrcPointer;
|
|
|
|
else
|
2018-10-28 23:25:49 +01:00
|
|
|
need_alloc = TRUE;
|
2007-11-02 23:22:47 +01:00
|
|
|
}
|
2018-10-28 23:25:48 +01:00
|
|
|
else
|
|
|
|
*pPointer = NULL;
|
2007-11-29 18:35:34 +01:00
|
|
|
}
|
|
|
|
|
2018-06-13 04:19:10 +02:00
|
|
|
if (attr & FC_ALLOCATE_ALL_NODES)
|
|
|
|
FIXME("FC_ALLOCATE_ALL_NODES not implemented\n");
|
2007-12-15 14:57:06 +01:00
|
|
|
|
2018-06-13 04:19:10 +02:00
|
|
|
if (attr & FC_POINTER_DEREF) {
|
2018-10-28 23:25:49 +01:00
|
|
|
if (need_alloc)
|
2018-10-28 23:25:48 +01:00
|
|
|
*pPointer = NdrAllocateZero(pStubMsg, sizeof(void *));
|
|
|
|
|
|
|
|
current_ptr = *(unsigned char***)current_ptr;
|
2007-11-29 18:35:34 +01:00
|
|
|
TRACE("deref => %p\n", current_ptr);
|
2006-05-01 11:37:11 +02:00
|
|
|
}
|
2005-06-01 13:04:03 +02:00
|
|
|
m = NdrUnmarshaller[*desc & NDR_TABLE_MASK];
|
2018-10-28 23:25:49 +01:00
|
|
|
if (m) m(pStubMsg, current_ptr, desc, inner_must_alloc);
|
2005-06-01 13:04:03 +02:00
|
|
|
else FIXME("no unmarshaller for data type=%02x\n", *desc);
|
2006-05-29 17:27:27 +02:00
|
|
|
|
2018-06-13 04:19:10 +02:00
|
|
|
if (type == FC_FP)
|
2006-05-29 17:27:27 +02:00
|
|
|
NdrFullPointerInsertRefId(pStubMsg->FullPtrXlatTables, pointer_id,
|
2009-11-18 01:25:26 +01:00
|
|
|
*pPointer);
|
2005-06-01 13:04:03 +02:00
|
|
|
}
|
|
|
|
|
2003-02-01 01:44:51 +01:00
|
|
|
TRACE("pointer=%p\n", *pPointer);
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
2006-11-12 20:23:02 +01:00
|
|
|
* PointerBufferSize [internal]
|
2003-02-01 01:44:51 +01:00
|
|
|
*/
|
2006-05-19 17:02:41 +02:00
|
|
|
static void PointerBufferSize(PMIDL_STUB_MESSAGE pStubMsg,
|
2003-02-01 01:44:51 +01:00
|
|
|
unsigned char *Pointer,
|
|
|
|
PFORMAT_STRING pFormat)
|
|
|
|
{
|
|
|
|
unsigned type = pFormat[0], attr = pFormat[1];
|
|
|
|
PFORMAT_STRING desc;
|
|
|
|
NDR_BUFFERSIZE m;
|
2013-12-03 00:02:50 +01:00
|
|
|
BOOL pointer_needs_sizing;
|
2006-11-09 23:02:49 +01:00
|
|
|
ULONG pointer_id;
|
2003-02-01 01:44:51 +01:00
|
|
|
|
|
|
|
TRACE("(%p,%p,%p)\n", pStubMsg, Pointer, pFormat);
|
2006-05-01 11:36:52 +02:00
|
|
|
TRACE("type=0x%x, attr=", type); dump_pointer_attr(attr);
|
2003-02-01 01:44:51 +01:00
|
|
|
pFormat += 2;
|
2018-06-13 04:19:10 +02:00
|
|
|
if (attr & FC_SIMPLE_POINTER) desc = pFormat;
|
2004-11-30 22:38:57 +01:00
|
|
|
else desc = pFormat + *(const SHORT*)pFormat;
|
2002-10-30 00:07:33 +01:00
|
|
|
|
2003-02-01 01:44:51 +01:00
|
|
|
switch (type) {
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_RP: /* ref pointer (always non-null) */
|
2007-11-20 19:03:18 +01:00
|
|
|
if (!Pointer)
|
|
|
|
{
|
|
|
|
ERR("NULL ref pointer is not allowed\n");
|
|
|
|
RpcRaiseException(RPC_X_NULL_REF_POINTER);
|
|
|
|
}
|
2003-02-01 01:44:51 +01:00
|
|
|
break;
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_OP:
|
|
|
|
case FC_UP:
|
2005-06-01 13:04:03 +02:00
|
|
|
/* NULL pointer has no further representation */
|
|
|
|
if (!Pointer)
|
|
|
|
return;
|
|
|
|
break;
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_FP:
|
2006-05-29 17:27:27 +02:00
|
|
|
pointer_needs_sizing = !NdrFullPointerQueryPointer(
|
|
|
|
pStubMsg->FullPtrXlatTables, Pointer, 0, &pointer_id);
|
|
|
|
if (!pointer_needs_sizing)
|
|
|
|
return;
|
|
|
|
break;
|
2003-02-01 01:44:51 +01:00
|
|
|
default:
|
|
|
|
FIXME("unhandled ptr type=%02x\n", type);
|
2005-06-01 13:04:03 +02:00
|
|
|
RpcRaiseException(RPC_X_BAD_STUB_DATA);
|
2006-05-29 17:27:27 +02:00
|
|
|
return;
|
2003-02-01 01:44:51 +01:00
|
|
|
}
|
|
|
|
|
2018-06-13 04:19:10 +02:00
|
|
|
if (attr & FC_POINTER_DEREF) {
|
2006-05-01 11:37:11 +02:00
|
|
|
Pointer = *(unsigned char**)Pointer;
|
|
|
|
TRACE("deref => %p\n", Pointer);
|
|
|
|
}
|
|
|
|
|
2003-02-01 01:44:51 +01:00
|
|
|
m = NdrBufferSizer[*desc & NDR_TABLE_MASK];
|
|
|
|
if (m) m(pStubMsg, Pointer, desc);
|
|
|
|
else FIXME("no buffersizer for data type=%02x\n", *desc);
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
2006-11-12 20:23:02 +01:00
|
|
|
* PointerMemorySize [internal]
|
2003-02-01 01:44:51 +01:00
|
|
|
*/
|
2009-04-21 09:59:45 +02:00
|
|
|
static ULONG PointerMemorySize(PMIDL_STUB_MESSAGE pStubMsg,
|
|
|
|
unsigned char *Buffer, PFORMAT_STRING pFormat)
|
2003-02-01 01:44:51 +01:00
|
|
|
{
|
|
|
|
unsigned type = pFormat[0], attr = pFormat[1];
|
|
|
|
PFORMAT_STRING desc;
|
|
|
|
NDR_MEMORYSIZE m;
|
2007-12-08 18:46:34 +01:00
|
|
|
DWORD pointer_id = 0;
|
2013-12-03 00:02:50 +01:00
|
|
|
BOOL pointer_needs_sizing;
|
2002-10-29 00:53:23 +01:00
|
|
|
|
2007-12-08 18:46:34 +01:00
|
|
|
TRACE("(%p,%p,%p)\n", pStubMsg, Buffer, pFormat);
|
2006-05-01 11:36:52 +02:00
|
|
|
TRACE("type=0x%x, attr=", type); dump_pointer_attr(attr);
|
2003-02-01 01:44:51 +01:00
|
|
|
pFormat += 2;
|
2018-06-13 04:19:10 +02:00
|
|
|
if (attr & FC_SIMPLE_POINTER) desc = pFormat;
|
2004-11-30 22:38:57 +01:00
|
|
|
else desc = pFormat + *(const SHORT*)pFormat;
|
2003-02-01 01:44:51 +01:00
|
|
|
|
|
|
|
switch (type) {
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_RP: /* ref pointer (always non-null) */
|
2013-12-03 00:02:50 +01:00
|
|
|
pointer_needs_sizing = TRUE;
|
2007-12-08 18:46:34 +01:00
|
|
|
break;
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_UP: /* unique pointer */
|
|
|
|
case FC_OP: /* object pointer - we must free data before overwriting it */
|
2007-12-08 18:46:34 +01:00
|
|
|
pointer_id = NDR_LOCAL_UINT32_READ(Buffer);
|
|
|
|
TRACE("pointer_id is 0x%08x\n", pointer_id);
|
|
|
|
if (pointer_id)
|
2013-12-03 00:02:50 +01:00
|
|
|
pointer_needs_sizing = TRUE;
|
2007-12-08 18:46:34 +01:00
|
|
|
else
|
2013-12-03 00:02:50 +01:00
|
|
|
pointer_needs_sizing = FALSE;
|
2003-02-01 01:44:51 +01:00
|
|
|
break;
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_FP:
|
2007-12-08 18:46:34 +01:00
|
|
|
{
|
|
|
|
void *pointer;
|
|
|
|
pointer_id = NDR_LOCAL_UINT32_READ(Buffer);
|
|
|
|
TRACE("pointer_id is 0x%08x\n", pointer_id);
|
|
|
|
pointer_needs_sizing = !NdrFullPointerQueryRefId(
|
|
|
|
pStubMsg->FullPtrXlatTables, pointer_id, 1, &pointer);
|
|
|
|
break;
|
|
|
|
}
|
2003-02-01 01:44:51 +01:00
|
|
|
default:
|
|
|
|
FIXME("unhandled ptr type=%02x\n", type);
|
2005-06-01 13:04:03 +02:00
|
|
|
RpcRaiseException(RPC_X_BAD_STUB_DATA);
|
2007-12-08 18:46:34 +01:00
|
|
|
return 0;
|
2003-02-01 01:44:51 +01:00
|
|
|
}
|
|
|
|
|
2018-06-13 04:19:10 +02:00
|
|
|
if (attr & FC_POINTER_DEREF) {
|
2010-04-02 21:54:55 +02:00
|
|
|
align_length(&pStubMsg->MemorySize, sizeof(void*));
|
2009-05-28 11:52:36 +02:00
|
|
|
pStubMsg->MemorySize += sizeof(void*);
|
2006-05-01 11:37:11 +02:00
|
|
|
TRACE("deref\n");
|
|
|
|
}
|
|
|
|
|
2007-12-08 18:46:34 +01:00
|
|
|
if (pointer_needs_sizing) {
|
|
|
|
m = NdrMemorySizer[*desc & NDR_TABLE_MASK];
|
|
|
|
if (m) m(pStubMsg, desc);
|
|
|
|
else FIXME("no memorysizer for data type=%02x\n", *desc);
|
|
|
|
}
|
2003-02-01 01:44:51 +01:00
|
|
|
|
2007-12-08 18:46:34 +01:00
|
|
|
return pStubMsg->MemorySize;
|
2003-02-01 01:44:51 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
2006-11-12 20:23:02 +01:00
|
|
|
* PointerFree [internal]
|
2003-02-01 01:44:51 +01:00
|
|
|
*/
|
2006-05-19 17:02:41 +02:00
|
|
|
static void PointerFree(PMIDL_STUB_MESSAGE pStubMsg,
|
2003-02-01 01:44:51 +01:00
|
|
|
unsigned char *Pointer,
|
|
|
|
PFORMAT_STRING pFormat)
|
|
|
|
{
|
|
|
|
unsigned type = pFormat[0], attr = pFormat[1];
|
|
|
|
PFORMAT_STRING desc;
|
|
|
|
NDR_FREE m;
|
2007-12-13 17:13:20 +01:00
|
|
|
unsigned char *current_pointer = Pointer;
|
2003-02-01 01:44:51 +01:00
|
|
|
|
|
|
|
TRACE("(%p,%p,%p)\n", pStubMsg, Pointer, pFormat);
|
2006-05-01 11:36:52 +02:00
|
|
|
TRACE("type=0x%x, attr=", type); dump_pointer_attr(attr);
|
2018-06-13 04:19:10 +02:00
|
|
|
if (attr & FC_DONT_FREE) return;
|
2003-02-01 01:44:51 +01:00
|
|
|
pFormat += 2;
|
2018-06-13 04:19:10 +02:00
|
|
|
if (attr & FC_SIMPLE_POINTER) desc = pFormat;
|
2004-11-30 22:38:57 +01:00
|
|
|
else desc = pFormat + *(const SHORT*)pFormat;
|
2006-05-01 11:37:11 +02:00
|
|
|
|
|
|
|
if (!Pointer) return;
|
|
|
|
|
2018-06-13 04:19:10 +02:00
|
|
|
if (type == FC_FP) {
|
2006-05-29 17:27:27 +02:00
|
|
|
int pointer_needs_freeing = NdrFullPointerFree(
|
|
|
|
pStubMsg->FullPtrXlatTables, Pointer);
|
|
|
|
if (!pointer_needs_freeing)
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-06-13 04:19:10 +02:00
|
|
|
if (attr & FC_POINTER_DEREF) {
|
2007-12-13 17:13:20 +01:00
|
|
|
current_pointer = *(unsigned char**)Pointer;
|
|
|
|
TRACE("deref => %p\n", current_pointer);
|
2003-05-20 04:17:49 +02:00
|
|
|
}
|
2003-02-01 01:44:51 +01:00
|
|
|
|
|
|
|
m = NdrFreer[*desc & NDR_TABLE_MASK];
|
2007-12-13 17:13:20 +01:00
|
|
|
if (m) m(pStubMsg, current_pointer, desc);
|
2003-02-01 01:44:51 +01:00
|
|
|
|
2007-12-13 17:11:58 +01:00
|
|
|
/* this check stops us from trying to free buffer memory. we don't have to
|
|
|
|
* worry about clients, since they won't call this function.
|
|
|
|
* we don't have to check for the buffer being reallocated because
|
|
|
|
* BufferStart and BufferEnd won't be reset when allocating memory for
|
|
|
|
* sending the response. we don't have to check for the new buffer here as
|
|
|
|
* it won't be used a type memory, only for buffer memory */
|
2014-08-11 10:59:20 +02:00
|
|
|
if (Pointer >= pStubMsg->BufferStart && Pointer <= pStubMsg->BufferEnd)
|
2007-12-13 17:11:28 +01:00
|
|
|
goto notfree;
|
|
|
|
|
2018-06-13 04:19:10 +02:00
|
|
|
if (attr & FC_ALLOCED_ON_STACK) {
|
2003-02-01 01:44:51 +01:00
|
|
|
TRACE("not freeing stack ptr %p\n", Pointer);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
TRACE("freeing %p\n", Pointer);
|
2003-02-17 02:48:24 +01:00
|
|
|
NdrFree(pStubMsg, Pointer);
|
2003-02-01 01:44:51 +01:00
|
|
|
return;
|
2007-12-13 17:11:28 +01:00
|
|
|
notfree:
|
|
|
|
TRACE("not freeing %p\n", Pointer);
|
2003-02-01 01:44:51 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* EmbeddedPointerMarshall
|
|
|
|
*/
|
2006-05-19 17:02:41 +02:00
|
|
|
static unsigned char * EmbeddedPointerMarshall(PMIDL_STUB_MESSAGE pStubMsg,
|
2003-02-01 01:44:51 +01:00
|
|
|
unsigned char *pMemory,
|
|
|
|
PFORMAT_STRING pFormat)
|
|
|
|
{
|
|
|
|
unsigned char *Mark = pStubMsg->BufferMark;
|
2007-10-11 00:29:54 +02:00
|
|
|
unsigned rep, count, stride;
|
2006-05-15 14:34:47 +02:00
|
|
|
unsigned i;
|
2007-06-25 15:28:01 +02:00
|
|
|
unsigned char *saved_buffer = NULL;
|
2003-02-01 01:44:51 +01:00
|
|
|
|
|
|
|
TRACE("(%p,%p,%p)\n", pStubMsg, pMemory, pFormat);
|
|
|
|
|
2018-06-13 04:19:10 +02:00
|
|
|
if (*pFormat != FC_PP) return NULL;
|
2003-02-01 01:44:51 +01:00
|
|
|
pFormat += 2;
|
|
|
|
|
2007-06-25 15:28:01 +02:00
|
|
|
if (pStubMsg->PointerBufferMark)
|
|
|
|
{
|
|
|
|
saved_buffer = pStubMsg->Buffer;
|
|
|
|
pStubMsg->Buffer = pStubMsg->PointerBufferMark;
|
|
|
|
pStubMsg->PointerBufferMark = NULL;
|
|
|
|
}
|
|
|
|
|
2018-06-13 04:19:10 +02:00
|
|
|
while (pFormat[0] != FC_END) {
|
2003-02-01 01:44:51 +01:00
|
|
|
switch (pFormat[0]) {
|
|
|
|
default:
|
2012-01-20 09:54:24 +01:00
|
|
|
FIXME("unknown repeat type %d; assuming no repeat\n", pFormat[0]);
|
|
|
|
/* fallthrough */
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_NO_REPEAT:
|
2003-02-01 01:44:51 +01:00
|
|
|
rep = 1;
|
|
|
|
stride = 0;
|
|
|
|
count = 1;
|
|
|
|
pFormat += 2;
|
|
|
|
break;
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_FIXED_REPEAT:
|
2004-11-30 22:38:57 +01:00
|
|
|
rep = *(const WORD*)&pFormat[2];
|
|
|
|
stride = *(const WORD*)&pFormat[4];
|
|
|
|
count = *(const WORD*)&pFormat[8];
|
2003-02-01 01:44:51 +01:00
|
|
|
pFormat += 10;
|
|
|
|
break;
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_VARIABLE_REPEAT:
|
|
|
|
rep = (pFormat[1] == FC_VARIABLE_OFFSET) ? pStubMsg->ActualCount : pStubMsg->MaxCount;
|
2004-11-30 22:38:57 +01:00
|
|
|
stride = *(const WORD*)&pFormat[2];
|
|
|
|
count = *(const WORD*)&pFormat[6];
|
2003-02-01 01:44:51 +01:00
|
|
|
pFormat += 8;
|
|
|
|
break;
|
|
|
|
}
|
2006-05-15 14:34:47 +02:00
|
|
|
for (i = 0; i < rep; i++) {
|
2003-02-01 01:44:51 +01:00
|
|
|
PFORMAT_STRING info = pFormat;
|
2007-10-11 00:29:54 +02:00
|
|
|
unsigned char *membase = pMemory + (i * stride);
|
|
|
|
unsigned char *bufbase = Mark + (i * stride);
|
2003-02-01 01:44:51 +01:00
|
|
|
unsigned u;
|
2007-06-19 13:12:00 +02:00
|
|
|
|
2003-02-01 01:44:51 +01:00
|
|
|
for (u=0; u<count; u++,info+=8) {
|
2004-11-30 22:38:57 +01:00
|
|
|
unsigned char *memptr = membase + *(const SHORT*)&info[0];
|
2006-05-15 14:34:47 +02:00
|
|
|
unsigned char *bufptr = bufbase + *(const SHORT*)&info[2];
|
2006-05-25 00:04:35 +02:00
|
|
|
unsigned char *saved_memory = pStubMsg->Memory;
|
|
|
|
|
2014-09-18 14:22:20 +02:00
|
|
|
pStubMsg->Memory = membase;
|
2003-02-01 01:44:51 +01:00
|
|
|
PointerMarshall(pStubMsg, bufptr, *(unsigned char**)memptr, info+4);
|
2006-05-25 00:04:35 +02:00
|
|
|
pStubMsg->Memory = saved_memory;
|
2003-02-01 01:44:51 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
pFormat += 8 * count;
|
|
|
|
}
|
|
|
|
|
2007-06-25 15:28:01 +02:00
|
|
|
if (saved_buffer)
|
|
|
|
{
|
|
|
|
pStubMsg->PointerBufferMark = pStubMsg->Buffer;
|
|
|
|
pStubMsg->Buffer = saved_buffer;
|
|
|
|
}
|
|
|
|
|
2003-02-17 02:48:24 +01:00
|
|
|
STD_OVERFLOW_CHECK(pStubMsg);
|
|
|
|
|
2003-02-01 01:44:51 +01:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2018-10-28 23:25:46 +01:00
|
|
|
/* rpcrt4 does something bizarre with embedded pointers: instead of copying the
|
|
|
|
* struct/array/union from the buffer to memory and then unmarshalling pointers
|
|
|
|
* into it, it unmarshals pointers into the buffer itself and then copies it to
|
|
|
|
* memory. However, it will still attempt to use a user-supplied pointer where
|
|
|
|
* appropriate (i.e. one on stack). Therefore we need to pass both pointers to
|
|
|
|
* this function and to PointerUnmarshall: the pointer (to the buffer) that we
|
|
|
|
* will actually unmarshal into (pDstBuffer), and the pointer (to memory) that
|
|
|
|
* we will attempt to use for storage if possible (pSrcMemoryPtrs). */
|
2006-05-19 17:02:41 +02:00
|
|
|
static unsigned char * EmbeddedPointerUnmarshall(PMIDL_STUB_MESSAGE pStubMsg,
|
2008-06-23 13:56:49 +02:00
|
|
|
unsigned char *pDstBuffer,
|
2007-11-29 18:35:34 +01:00
|
|
|
unsigned char *pSrcMemoryPtrs,
|
2003-02-01 01:44:51 +01:00
|
|
|
PFORMAT_STRING pFormat,
|
|
|
|
unsigned char fMustAlloc)
|
|
|
|
{
|
|
|
|
unsigned char *Mark = pStubMsg->BufferMark;
|
2007-10-11 00:29:54 +02:00
|
|
|
unsigned rep, count, stride;
|
2006-05-15 14:34:47 +02:00
|
|
|
unsigned i;
|
2007-06-25 15:28:01 +02:00
|
|
|
unsigned char *saved_buffer = NULL;
|
2003-02-01 01:44:51 +01:00
|
|
|
|
2008-06-23 13:56:49 +02:00
|
|
|
TRACE("(%p,%p,%p,%p,%d)\n", pStubMsg, pDstBuffer, pSrcMemoryPtrs, pFormat, fMustAlloc);
|
2003-02-01 01:44:51 +01:00
|
|
|
|
2018-06-13 04:19:10 +02:00
|
|
|
if (*pFormat != FC_PP) return NULL;
|
2003-02-01 01:44:51 +01:00
|
|
|
pFormat += 2;
|
|
|
|
|
2007-06-25 15:28:01 +02:00
|
|
|
if (pStubMsg->PointerBufferMark)
|
|
|
|
{
|
|
|
|
saved_buffer = pStubMsg->Buffer;
|
|
|
|
pStubMsg->Buffer = pStubMsg->PointerBufferMark;
|
|
|
|
pStubMsg->PointerBufferMark = NULL;
|
|
|
|
}
|
|
|
|
|
2018-06-13 04:19:10 +02:00
|
|
|
while (pFormat[0] != FC_END) {
|
2006-05-15 14:34:47 +02:00
|
|
|
TRACE("pFormat[0] = 0x%x\n", pFormat[0]);
|
2003-02-01 01:44:51 +01:00
|
|
|
switch (pFormat[0]) {
|
|
|
|
default:
|
2012-01-20 09:54:24 +01:00
|
|
|
FIXME("unknown repeat type %d; assuming no repeat\n", pFormat[0]);
|
|
|
|
/* fallthrough */
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_NO_REPEAT:
|
2003-02-01 01:44:51 +01:00
|
|
|
rep = 1;
|
|
|
|
stride = 0;
|
|
|
|
count = 1;
|
|
|
|
pFormat += 2;
|
|
|
|
break;
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_FIXED_REPEAT:
|
2004-11-30 22:38:57 +01:00
|
|
|
rep = *(const WORD*)&pFormat[2];
|
|
|
|
stride = *(const WORD*)&pFormat[4];
|
|
|
|
count = *(const WORD*)&pFormat[8];
|
2003-02-01 01:44:51 +01:00
|
|
|
pFormat += 10;
|
|
|
|
break;
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_VARIABLE_REPEAT:
|
|
|
|
rep = (pFormat[1] == FC_VARIABLE_OFFSET) ? pStubMsg->ActualCount : pStubMsg->MaxCount;
|
2004-11-30 22:38:57 +01:00
|
|
|
stride = *(const WORD*)&pFormat[2];
|
|
|
|
count = *(const WORD*)&pFormat[6];
|
2003-02-01 01:44:51 +01:00
|
|
|
pFormat += 8;
|
|
|
|
break;
|
|
|
|
}
|
2006-05-15 14:34:47 +02:00
|
|
|
for (i = 0; i < rep; i++) {
|
2003-02-01 01:44:51 +01:00
|
|
|
PFORMAT_STRING info = pFormat;
|
2008-06-23 13:56:49 +02:00
|
|
|
unsigned char *bufdstbase = pDstBuffer + (i * stride);
|
2007-11-29 18:35:34 +01:00
|
|
|
unsigned char *memsrcbase = pSrcMemoryPtrs + (i * stride);
|
2007-10-11 00:29:54 +02:00
|
|
|
unsigned char *bufbase = Mark + (i * stride);
|
2003-02-01 01:44:51 +01:00
|
|
|
unsigned u;
|
2007-06-19 13:12:00 +02:00
|
|
|
|
2003-02-01 01:44:51 +01:00
|
|
|
for (u=0; u<count; u++,info+=8) {
|
2008-06-23 13:56:49 +02:00
|
|
|
unsigned char **bufdstptr = (unsigned char **)(bufdstbase + *(const SHORT*)&info[2]);
|
2007-11-29 18:35:34 +01:00
|
|
|
unsigned char **memsrcptr = (unsigned char **)(memsrcbase + *(const SHORT*)&info[0]);
|
2006-05-15 14:34:47 +02:00
|
|
|
unsigned char *bufptr = bufbase + *(const SHORT*)&info[2];
|
2008-06-23 13:56:49 +02:00
|
|
|
PointerUnmarshall(pStubMsg, bufptr, bufdstptr, *memsrcptr, info+4, fMustAlloc);
|
2003-02-01 01:44:51 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
pFormat += 8 * count;
|
|
|
|
}
|
|
|
|
|
2007-06-25 15:28:01 +02:00
|
|
|
if (saved_buffer)
|
|
|
|
{
|
|
|
|
pStubMsg->PointerBufferMark = pStubMsg->Buffer;
|
|
|
|
pStubMsg->Buffer = saved_buffer;
|
|
|
|
}
|
|
|
|
|
2003-02-01 01:44:51 +01:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* EmbeddedPointerBufferSize
|
|
|
|
*/
|
2006-05-19 17:02:41 +02:00
|
|
|
static void EmbeddedPointerBufferSize(PMIDL_STUB_MESSAGE pStubMsg,
|
2003-02-01 01:44:51 +01:00
|
|
|
unsigned char *pMemory,
|
|
|
|
PFORMAT_STRING pFormat)
|
|
|
|
{
|
2007-10-11 00:29:54 +02:00
|
|
|
unsigned rep, count, stride;
|
2006-05-15 14:34:47 +02:00
|
|
|
unsigned i;
|
2007-06-25 15:28:01 +02:00
|
|
|
ULONG saved_buffer_length = 0;
|
2003-02-01 01:44:51 +01:00
|
|
|
|
|
|
|
TRACE("(%p,%p,%p)\n", pStubMsg, pMemory, pFormat);
|
2006-05-15 14:34:47 +02:00
|
|
|
|
|
|
|
if (pStubMsg->IgnoreEmbeddedPointers) return;
|
|
|
|
|
2018-06-13 04:19:10 +02:00
|
|
|
if (*pFormat != FC_PP) return;
|
2003-02-01 01:44:51 +01:00
|
|
|
pFormat += 2;
|
|
|
|
|
2007-06-25 15:28:01 +02:00
|
|
|
if (pStubMsg->PointerLength)
|
|
|
|
{
|
|
|
|
saved_buffer_length = pStubMsg->BufferLength;
|
|
|
|
pStubMsg->BufferLength = pStubMsg->PointerLength;
|
|
|
|
pStubMsg->PointerLength = 0;
|
|
|
|
}
|
|
|
|
|
2018-06-13 04:19:10 +02:00
|
|
|
while (pFormat[0] != FC_END) {
|
2003-02-01 01:44:51 +01:00
|
|
|
switch (pFormat[0]) {
|
|
|
|
default:
|
2012-01-20 09:54:24 +01:00
|
|
|
FIXME("unknown repeat type %d; assuming no repeat\n", pFormat[0]);
|
|
|
|
/* fallthrough */
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_NO_REPEAT:
|
2003-02-01 01:44:51 +01:00
|
|
|
rep = 1;
|
|
|
|
stride = 0;
|
|
|
|
count = 1;
|
|
|
|
pFormat += 2;
|
|
|
|
break;
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_FIXED_REPEAT:
|
2004-11-30 22:38:57 +01:00
|
|
|
rep = *(const WORD*)&pFormat[2];
|
|
|
|
stride = *(const WORD*)&pFormat[4];
|
|
|
|
count = *(const WORD*)&pFormat[8];
|
2003-02-01 01:44:51 +01:00
|
|
|
pFormat += 10;
|
|
|
|
break;
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_VARIABLE_REPEAT:
|
|
|
|
rep = (pFormat[1] == FC_VARIABLE_OFFSET) ? pStubMsg->ActualCount : pStubMsg->MaxCount;
|
2004-11-30 22:38:57 +01:00
|
|
|
stride = *(const WORD*)&pFormat[2];
|
|
|
|
count = *(const WORD*)&pFormat[6];
|
2003-02-01 01:44:51 +01:00
|
|
|
pFormat += 8;
|
|
|
|
break;
|
|
|
|
}
|
2006-05-15 14:34:47 +02:00
|
|
|
for (i = 0; i < rep; i++) {
|
2003-02-01 01:44:51 +01:00
|
|
|
PFORMAT_STRING info = pFormat;
|
2007-10-11 00:29:54 +02:00
|
|
|
unsigned char *membase = pMemory + (i * stride);
|
2003-02-01 01:44:51 +01:00
|
|
|
unsigned u;
|
2007-06-19 13:12:00 +02:00
|
|
|
|
2003-02-01 01:44:51 +01:00
|
|
|
for (u=0; u<count; u++,info+=8) {
|
2004-11-30 22:38:57 +01:00
|
|
|
unsigned char *memptr = membase + *(const SHORT*)&info[0];
|
2006-05-25 00:04:35 +02:00
|
|
|
unsigned char *saved_memory = pStubMsg->Memory;
|
|
|
|
|
2014-09-18 14:22:20 +02:00
|
|
|
pStubMsg->Memory = membase;
|
2003-02-01 01:44:51 +01:00
|
|
|
PointerBufferSize(pStubMsg, *(unsigned char**)memptr, info+4);
|
2006-05-25 00:04:35 +02:00
|
|
|
pStubMsg->Memory = saved_memory;
|
2003-02-01 01:44:51 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
pFormat += 8 * count;
|
|
|
|
}
|
2007-06-25 15:28:01 +02:00
|
|
|
|
|
|
|
if (saved_buffer_length)
|
|
|
|
{
|
|
|
|
pStubMsg->PointerLength = pStubMsg->BufferLength;
|
|
|
|
pStubMsg->BufferLength = saved_buffer_length;
|
|
|
|
}
|
2003-02-01 01:44:51 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
2006-11-12 20:23:02 +01:00
|
|
|
* EmbeddedPointerMemorySize [internal]
|
2003-02-01 01:44:51 +01:00
|
|
|
*/
|
2009-04-21 09:59:45 +02:00
|
|
|
static ULONG EmbeddedPointerMemorySize(PMIDL_STUB_MESSAGE pStubMsg,
|
|
|
|
PFORMAT_STRING pFormat)
|
2003-02-01 01:44:51 +01:00
|
|
|
{
|
|
|
|
unsigned char *Mark = pStubMsg->BufferMark;
|
2007-10-11 00:29:54 +02:00
|
|
|
unsigned rep, count, stride;
|
2006-05-15 14:34:47 +02:00
|
|
|
unsigned i;
|
2007-12-08 18:46:57 +01:00
|
|
|
unsigned char *saved_buffer = NULL;
|
2003-02-01 01:44:51 +01:00
|
|
|
|
2007-06-25 15:28:01 +02:00
|
|
|
TRACE("(%p,%p)\n", pStubMsg, pFormat);
|
|
|
|
|
|
|
|
if (pStubMsg->IgnoreEmbeddedPointers) return 0;
|
|
|
|
|
2007-12-08 18:46:57 +01:00
|
|
|
if (pStubMsg->PointerBufferMark)
|
|
|
|
{
|
|
|
|
saved_buffer = pStubMsg->Buffer;
|
|
|
|
pStubMsg->Buffer = pStubMsg->PointerBufferMark;
|
|
|
|
pStubMsg->PointerBufferMark = NULL;
|
|
|
|
}
|
2006-05-15 14:34:47 +02:00
|
|
|
|
2018-06-13 04:19:10 +02:00
|
|
|
if (*pFormat != FC_PP) return 0;
|
2003-02-01 01:44:51 +01:00
|
|
|
pFormat += 2;
|
|
|
|
|
2018-06-13 04:19:10 +02:00
|
|
|
while (pFormat[0] != FC_END) {
|
2003-02-01 01:44:51 +01:00
|
|
|
switch (pFormat[0]) {
|
|
|
|
default:
|
2012-01-20 09:54:24 +01:00
|
|
|
FIXME("unknown repeat type %d; assuming no repeat\n", pFormat[0]);
|
|
|
|
/* fallthrough */
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_NO_REPEAT:
|
2003-02-01 01:44:51 +01:00
|
|
|
rep = 1;
|
|
|
|
stride = 0;
|
|
|
|
count = 1;
|
|
|
|
pFormat += 2;
|
|
|
|
break;
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_FIXED_REPEAT:
|
2004-11-30 22:38:57 +01:00
|
|
|
rep = *(const WORD*)&pFormat[2];
|
|
|
|
stride = *(const WORD*)&pFormat[4];
|
|
|
|
count = *(const WORD*)&pFormat[8];
|
2003-02-01 01:44:51 +01:00
|
|
|
pFormat += 10;
|
|
|
|
break;
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_VARIABLE_REPEAT:
|
|
|
|
rep = (pFormat[1] == FC_VARIABLE_OFFSET) ? pStubMsg->ActualCount : pStubMsg->MaxCount;
|
2004-11-30 22:38:57 +01:00
|
|
|
stride = *(const WORD*)&pFormat[2];
|
|
|
|
count = *(const WORD*)&pFormat[6];
|
2003-02-01 01:44:51 +01:00
|
|
|
pFormat += 8;
|
|
|
|
break;
|
|
|
|
}
|
2006-05-15 14:34:47 +02:00
|
|
|
for (i = 0; i < rep; i++) {
|
2003-02-01 01:44:51 +01:00
|
|
|
PFORMAT_STRING info = pFormat;
|
2007-10-11 00:29:54 +02:00
|
|
|
unsigned char *bufbase = Mark + (i * stride);
|
2003-02-01 01:44:51 +01:00
|
|
|
unsigned u;
|
|
|
|
for (u=0; u<count; u++,info+=8) {
|
2006-05-15 14:34:47 +02:00
|
|
|
unsigned char *bufptr = bufbase + *(const SHORT*)&info[2];
|
2003-02-01 01:44:51 +01:00
|
|
|
PointerMemorySize(pStubMsg, bufptr, info+4);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
pFormat += 8 * count;
|
|
|
|
}
|
|
|
|
|
2007-12-08 18:46:57 +01:00
|
|
|
if (saved_buffer)
|
|
|
|
{
|
|
|
|
pStubMsg->PointerBufferMark = pStubMsg->Buffer;
|
|
|
|
pStubMsg->Buffer = saved_buffer;
|
|
|
|
}
|
|
|
|
|
2003-02-01 01:44:51 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
2006-11-12 20:23:02 +01:00
|
|
|
* EmbeddedPointerFree [internal]
|
2003-02-01 01:44:51 +01:00
|
|
|
*/
|
2006-05-19 17:02:41 +02:00
|
|
|
static void EmbeddedPointerFree(PMIDL_STUB_MESSAGE pStubMsg,
|
2003-02-01 01:44:51 +01:00
|
|
|
unsigned char *pMemory,
|
|
|
|
PFORMAT_STRING pFormat)
|
|
|
|
{
|
2007-10-11 00:29:54 +02:00
|
|
|
unsigned rep, count, stride;
|
2006-05-15 14:34:47 +02:00
|
|
|
unsigned i;
|
2003-02-01 01:44:51 +01:00
|
|
|
|
|
|
|
TRACE("(%p,%p,%p)\n", pStubMsg, pMemory, pFormat);
|
2018-06-13 04:19:10 +02:00
|
|
|
if (*pFormat != FC_PP) return;
|
2003-02-01 01:44:51 +01:00
|
|
|
pFormat += 2;
|
|
|
|
|
2018-06-13 04:19:10 +02:00
|
|
|
while (pFormat[0] != FC_END) {
|
2003-02-01 01:44:51 +01:00
|
|
|
switch (pFormat[0]) {
|
|
|
|
default:
|
2012-01-20 09:54:24 +01:00
|
|
|
FIXME("unknown repeat type %d; assuming no repeat\n", pFormat[0]);
|
|
|
|
/* fallthrough */
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_NO_REPEAT:
|
2003-02-01 01:44:51 +01:00
|
|
|
rep = 1;
|
|
|
|
stride = 0;
|
|
|
|
count = 1;
|
|
|
|
pFormat += 2;
|
|
|
|
break;
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_FIXED_REPEAT:
|
2004-11-30 22:38:57 +01:00
|
|
|
rep = *(const WORD*)&pFormat[2];
|
|
|
|
stride = *(const WORD*)&pFormat[4];
|
|
|
|
count = *(const WORD*)&pFormat[8];
|
2003-02-01 01:44:51 +01:00
|
|
|
pFormat += 10;
|
|
|
|
break;
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_VARIABLE_REPEAT:
|
|
|
|
rep = (pFormat[1] == FC_VARIABLE_OFFSET) ? pStubMsg->ActualCount : pStubMsg->MaxCount;
|
2004-11-30 22:38:57 +01:00
|
|
|
stride = *(const WORD*)&pFormat[2];
|
|
|
|
count = *(const WORD*)&pFormat[6];
|
2003-02-01 01:44:51 +01:00
|
|
|
pFormat += 8;
|
|
|
|
break;
|
|
|
|
}
|
2006-05-15 14:34:47 +02:00
|
|
|
for (i = 0; i < rep; i++) {
|
2003-02-01 01:44:51 +01:00
|
|
|
PFORMAT_STRING info = pFormat;
|
2006-05-15 14:34:47 +02:00
|
|
|
unsigned char *membase = pMemory + (i * stride);
|
2003-02-01 01:44:51 +01:00
|
|
|
unsigned u;
|
2007-06-19 13:12:00 +02:00
|
|
|
|
2003-02-01 01:44:51 +01:00
|
|
|
for (u=0; u<count; u++,info+=8) {
|
2004-11-30 22:38:57 +01:00
|
|
|
unsigned char *memptr = membase + *(const SHORT*)&info[0];
|
2006-05-25 00:04:35 +02:00
|
|
|
unsigned char *saved_memory = pStubMsg->Memory;
|
|
|
|
|
2014-09-18 14:22:20 +02:00
|
|
|
pStubMsg->Memory = membase;
|
2003-02-01 01:44:51 +01:00
|
|
|
PointerFree(pStubMsg, *(unsigned char**)memptr, info+4);
|
2006-05-25 00:04:35 +02:00
|
|
|
pStubMsg->Memory = saved_memory;
|
2003-02-01 01:44:51 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
pFormat += 8 * count;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* NdrPointerMarshall [RPCRT4.@]
|
|
|
|
*/
|
|
|
|
unsigned char * WINAPI NdrPointerMarshall(PMIDL_STUB_MESSAGE pStubMsg,
|
|
|
|
unsigned char *pMemory,
|
|
|
|
PFORMAT_STRING pFormat)
|
|
|
|
{
|
2006-05-10 14:13:45 +02:00
|
|
|
unsigned char *Buffer;
|
|
|
|
|
2003-02-01 01:44:51 +01:00
|
|
|
TRACE("(%p,%p,%p)\n", pStubMsg, pMemory, pFormat);
|
|
|
|
|
2008-04-11 04:17:14 +02:00
|
|
|
/* Increment the buffer here instead of in PointerMarshall,
|
2006-05-10 14:13:45 +02:00
|
|
|
* as that is used by embedded pointers which already handle the incrementing
|
|
|
|
* the buffer, and shouldn't write any additional pointer data to the wire */
|
2018-06-13 04:19:10 +02:00
|
|
|
if (*pFormat != FC_RP)
|
2006-05-10 14:13:45 +02:00
|
|
|
{
|
2010-04-02 21:54:55 +02:00
|
|
|
align_pointer_clear(&pStubMsg->Buffer, 4);
|
2006-05-10 14:13:45 +02:00
|
|
|
Buffer = pStubMsg->Buffer;
|
2007-11-28 16:02:06 +01:00
|
|
|
safe_buffer_increment(pStubMsg, 4);
|
2006-05-10 14:13:45 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
Buffer = pStubMsg->Buffer;
|
|
|
|
|
2006-05-13 18:00:00 +02:00
|
|
|
PointerMarshall(pStubMsg, Buffer, pMemory, pFormat);
|
2003-02-17 02:48:24 +01:00
|
|
|
|
2003-02-01 01:44:51 +01:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* NdrPointerUnmarshall [RPCRT4.@]
|
|
|
|
*/
|
|
|
|
unsigned char * WINAPI NdrPointerUnmarshall(PMIDL_STUB_MESSAGE pStubMsg,
|
|
|
|
unsigned char **ppMemory,
|
|
|
|
PFORMAT_STRING pFormat,
|
|
|
|
unsigned char fMustAlloc)
|
|
|
|
{
|
2006-05-10 14:13:45 +02:00
|
|
|
unsigned char *Buffer;
|
|
|
|
|
2003-02-01 01:44:51 +01:00
|
|
|
TRACE("(%p,%p,%p,%d)\n", pStubMsg, ppMemory, pFormat, fMustAlloc);
|
|
|
|
|
2018-06-13 04:19:10 +02:00
|
|
|
if (*pFormat == FC_RP)
|
2006-05-10 14:13:45 +02:00
|
|
|
{
|
|
|
|
Buffer = pStubMsg->Buffer;
|
2009-03-11 00:41:39 +01:00
|
|
|
/* Do the NULL ref pointer check here because embedded pointers can be
|
|
|
|
* NULL if the type the pointer is embedded in was allocated rather than
|
|
|
|
* being passed in by the client */
|
|
|
|
if (pStubMsg->IsClient && !*ppMemory)
|
|
|
|
{
|
|
|
|
ERR("NULL ref pointer is not allowed\n");
|
|
|
|
RpcRaiseException(RPC_X_NULL_REF_POINTER);
|
|
|
|
}
|
2006-05-10 14:13:45 +02:00
|
|
|
}
|
|
|
|
else
|
2009-03-11 00:41:39 +01:00
|
|
|
{
|
|
|
|
/* Increment the buffer here instead of in PointerUnmarshall,
|
|
|
|
* as that is used by embedded pointers which already handle the incrementing
|
|
|
|
* the buffer, and shouldn't read any additional pointer data from the
|
|
|
|
* buffer */
|
2010-04-02 21:54:55 +02:00
|
|
|
align_pointer(&pStubMsg->Buffer, 4);
|
2006-05-10 14:13:45 +02:00
|
|
|
Buffer = pStubMsg->Buffer;
|
2009-03-11 00:41:39 +01:00
|
|
|
safe_buffer_increment(pStubMsg, 4);
|
|
|
|
}
|
2006-05-10 14:13:45 +02:00
|
|
|
|
2007-11-29 18:35:34 +01:00
|
|
|
PointerUnmarshall(pStubMsg, Buffer, ppMemory, *ppMemory, pFormat, fMustAlloc);
|
2003-02-01 01:44:51 +01:00
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* NdrPointerBufferSize [RPCRT4.@]
|
|
|
|
*/
|
|
|
|
void WINAPI NdrPointerBufferSize(PMIDL_STUB_MESSAGE pStubMsg,
|
|
|
|
unsigned char *pMemory,
|
|
|
|
PFORMAT_STRING pFormat)
|
|
|
|
{
|
|
|
|
TRACE("(%p,%p,%p)\n", pStubMsg, pMemory, pFormat);
|
2006-05-10 14:13:45 +02:00
|
|
|
|
2008-04-21 07:17:27 +02:00
|
|
|
/* Increment the buffer length here instead of in PointerBufferSize,
|
2006-05-10 14:13:45 +02:00
|
|
|
* as that is used by embedded pointers which already handle the buffer
|
|
|
|
* length, and shouldn't write anything more to the wire */
|
2018-06-13 04:19:10 +02:00
|
|
|
if (*pFormat != FC_RP)
|
2006-05-10 14:13:45 +02:00
|
|
|
{
|
2010-04-02 21:54:55 +02:00
|
|
|
align_length(&pStubMsg->BufferLength, 4);
|
2007-11-28 16:01:53 +01:00
|
|
|
safe_buffer_length_increment(pStubMsg, 4);
|
2006-05-10 14:13:45 +02:00
|
|
|
}
|
|
|
|
|
2003-02-17 02:48:24 +01:00
|
|
|
PointerBufferSize(pStubMsg, pMemory, pFormat);
|
2003-02-01 01:44:51 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* NdrPointerMemorySize [RPCRT4.@]
|
|
|
|
*/
|
2006-11-09 23:01:58 +01:00
|
|
|
ULONG WINAPI NdrPointerMemorySize(PMIDL_STUB_MESSAGE pStubMsg,
|
|
|
|
PFORMAT_STRING pFormat)
|
2003-02-01 01:44:51 +01:00
|
|
|
{
|
2009-05-28 11:52:36 +02:00
|
|
|
unsigned char *Buffer = pStubMsg->Buffer;
|
2018-06-13 04:19:10 +02:00
|
|
|
if (*pFormat != FC_RP)
|
2009-05-28 11:52:36 +02:00
|
|
|
{
|
2010-04-02 21:54:55 +02:00
|
|
|
align_pointer(&pStubMsg->Buffer, 4);
|
2009-05-28 11:52:36 +02:00
|
|
|
safe_buffer_increment(pStubMsg, 4);
|
|
|
|
}
|
2010-04-02 21:54:55 +02:00
|
|
|
align_length(&pStubMsg->MemorySize, sizeof(void *));
|
2009-05-28 11:52:36 +02:00
|
|
|
return PointerMemorySize(pStubMsg, Buffer, pFormat);
|
2003-02-01 01:44:51 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* NdrPointerFree [RPCRT4.@]
|
|
|
|
*/
|
|
|
|
void WINAPI NdrPointerFree(PMIDL_STUB_MESSAGE pStubMsg,
|
|
|
|
unsigned char *pMemory,
|
|
|
|
PFORMAT_STRING pFormat)
|
|
|
|
{
|
|
|
|
TRACE("(%p,%p,%p)\n", pStubMsg, pMemory, pFormat);
|
2003-02-17 02:48:24 +01:00
|
|
|
PointerFree(pStubMsg, pMemory, pFormat);
|
2003-02-01 01:44:51 +01:00
|
|
|
}
|
|
|
|
|
2006-05-23 12:54:17 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* NdrSimpleTypeMarshall [RPCRT4.@]
|
|
|
|
*/
|
|
|
|
void WINAPI NdrSimpleTypeMarshall( PMIDL_STUB_MESSAGE pStubMsg, unsigned char* pMemory,
|
|
|
|
unsigned char FormatChar )
|
|
|
|
{
|
2007-01-23 12:50:06 +01:00
|
|
|
NdrBaseTypeMarshall(pStubMsg, pMemory, &FormatChar);
|
2006-05-23 12:54:17 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* NdrSimpleTypeUnmarshall [RPCRT4.@]
|
2008-04-12 11:07:26 +02:00
|
|
|
*
|
|
|
|
* Unmarshall a base type.
|
|
|
|
*
|
|
|
|
* NOTES
|
|
|
|
* Doesn't check that the buffer is long enough before copying, so the caller
|
|
|
|
* should do this.
|
2006-05-23 12:54:17 +02:00
|
|
|
*/
|
|
|
|
void WINAPI NdrSimpleTypeUnmarshall( PMIDL_STUB_MESSAGE pStubMsg, unsigned char* pMemory,
|
|
|
|
unsigned char FormatChar )
|
|
|
|
{
|
2008-04-12 11:07:26 +02:00
|
|
|
#define BASE_TYPE_UNMARSHALL(type) \
|
2010-04-02 21:54:55 +02:00
|
|
|
align_pointer(&pStubMsg->Buffer, sizeof(type)); \
|
2008-04-12 11:07:26 +02:00
|
|
|
TRACE("pMemory: %p\n", pMemory); \
|
|
|
|
*(type *)pMemory = *(type *)pStubMsg->Buffer; \
|
|
|
|
pStubMsg->Buffer += sizeof(type);
|
|
|
|
|
|
|
|
switch(FormatChar)
|
|
|
|
{
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_BYTE:
|
|
|
|
case FC_CHAR:
|
|
|
|
case FC_SMALL:
|
|
|
|
case FC_USMALL:
|
2008-04-12 11:07:26 +02:00
|
|
|
BASE_TYPE_UNMARSHALL(UCHAR);
|
|
|
|
TRACE("value: 0x%02x\n", *pMemory);
|
|
|
|
break;
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_WCHAR:
|
|
|
|
case FC_SHORT:
|
|
|
|
case FC_USHORT:
|
2008-04-12 11:07:26 +02:00
|
|
|
BASE_TYPE_UNMARSHALL(USHORT);
|
|
|
|
TRACE("value: 0x%04x\n", *(USHORT *)pMemory);
|
|
|
|
break;
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_LONG:
|
|
|
|
case FC_ULONG:
|
|
|
|
case FC_ERROR_STATUS_T:
|
|
|
|
case FC_ENUM32:
|
2008-04-12 11:07:26 +02:00
|
|
|
BASE_TYPE_UNMARSHALL(ULONG);
|
|
|
|
TRACE("value: 0x%08x\n", *(ULONG *)pMemory);
|
|
|
|
break;
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_FLOAT:
|
2008-04-12 11:07:26 +02:00
|
|
|
BASE_TYPE_UNMARSHALL(float);
|
|
|
|
TRACE("value: %f\n", *(float *)pMemory);
|
|
|
|
break;
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_DOUBLE:
|
2008-04-12 11:07:26 +02:00
|
|
|
BASE_TYPE_UNMARSHALL(double);
|
|
|
|
TRACE("value: %f\n", *(double *)pMemory);
|
|
|
|
break;
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_HYPER:
|
2008-04-12 11:07:26 +02:00
|
|
|
BASE_TYPE_UNMARSHALL(ULONGLONG);
|
|
|
|
TRACE("value: %s\n", wine_dbgstr_longlong(*(ULONGLONG *)pMemory));
|
|
|
|
break;
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_ENUM16:
|
2010-04-02 21:54:55 +02:00
|
|
|
align_pointer(&pStubMsg->Buffer, sizeof(USHORT));
|
2008-04-12 11:07:26 +02:00
|
|
|
TRACE("pMemory: %p\n", pMemory);
|
|
|
|
/* 16-bits on the wire, but int in memory */
|
|
|
|
*(UINT *)pMemory = *(USHORT *)pStubMsg->Buffer;
|
|
|
|
pStubMsg->Buffer += sizeof(USHORT);
|
|
|
|
TRACE("value: 0x%08x\n", *(UINT *)pMemory);
|
|
|
|
break;
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_INT3264:
|
2010-04-07 13:08:46 +02:00
|
|
|
align_pointer(&pStubMsg->Buffer, sizeof(INT));
|
|
|
|
/* 32-bits on the wire, but int_ptr in memory */
|
|
|
|
*(INT_PTR *)pMemory = *(INT *)pStubMsg->Buffer;
|
|
|
|
pStubMsg->Buffer += sizeof(INT);
|
|
|
|
TRACE("value: 0x%08lx\n", *(INT_PTR *)pMemory);
|
|
|
|
break;
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_UINT3264:
|
2010-04-07 13:08:46 +02:00
|
|
|
align_pointer(&pStubMsg->Buffer, sizeof(UINT));
|
|
|
|
/* 32-bits on the wire, but int_ptr in memory */
|
|
|
|
*(UINT_PTR *)pMemory = *(UINT *)pStubMsg->Buffer;
|
|
|
|
pStubMsg->Buffer += sizeof(UINT);
|
|
|
|
TRACE("value: 0x%08lx\n", *(UINT_PTR *)pMemory);
|
|
|
|
break;
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_IGNORE:
|
2008-04-12 11:07:26 +02:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
FIXME("Unhandled base type: 0x%02x\n", FormatChar);
|
|
|
|
}
|
|
|
|
#undef BASE_TYPE_UNMARSHALL
|
2006-05-23 12:54:17 +02:00
|
|
|
}
|
|
|
|
|
2003-02-01 01:44:51 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* NdrSimpleStructMarshall [RPCRT4.@]
|
|
|
|
*/
|
|
|
|
unsigned char * WINAPI NdrSimpleStructMarshall(PMIDL_STUB_MESSAGE pStubMsg,
|
|
|
|
unsigned char *pMemory,
|
|
|
|
PFORMAT_STRING pFormat)
|
|
|
|
{
|
2004-11-30 22:38:57 +01:00
|
|
|
unsigned size = *(const WORD*)(pFormat+2);
|
2003-02-01 01:44:51 +01:00
|
|
|
TRACE("(%p,%p,%p)\n", pStubMsg, pMemory, pFormat);
|
|
|
|
|
2010-04-02 21:54:55 +02:00
|
|
|
align_pointer_clear(&pStubMsg->Buffer, pFormat[1] + 1);
|
2006-05-10 14:12:30 +02:00
|
|
|
|
2003-02-01 01:44:51 +01:00
|
|
|
pStubMsg->BufferMark = pStubMsg->Buffer;
|
2007-11-28 16:02:06 +01:00
|
|
|
safe_copy_to_buffer(pStubMsg, pMemory, size);
|
2003-02-01 01:44:51 +01:00
|
|
|
|
2018-06-13 04:19:10 +02:00
|
|
|
if (pFormat[0] != FC_STRUCT)
|
2003-02-01 01:44:51 +01:00
|
|
|
EmbeddedPointerMarshall(pStubMsg, pMemory, pFormat+4);
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* NdrSimpleStructUnmarshall [RPCRT4.@]
|
|
|
|
*/
|
|
|
|
unsigned char * WINAPI NdrSimpleStructUnmarshall(PMIDL_STUB_MESSAGE pStubMsg,
|
|
|
|
unsigned char **ppMemory,
|
|
|
|
PFORMAT_STRING pFormat,
|
|
|
|
unsigned char fMustAlloc)
|
|
|
|
{
|
2004-11-30 22:38:57 +01:00
|
|
|
unsigned size = *(const WORD*)(pFormat+2);
|
2007-11-29 18:35:40 +01:00
|
|
|
unsigned char *saved_buffer;
|
2003-02-01 01:44:51 +01:00
|
|
|
TRACE("(%p,%p,%p,%d)\n", pStubMsg, ppMemory, pFormat, fMustAlloc);
|
|
|
|
|
2010-04-02 21:54:55 +02:00
|
|
|
align_pointer(&pStubMsg->Buffer, pFormat[1] + 1);
|
2006-05-10 14:12:30 +02:00
|
|
|
|
2007-11-29 18:35:40 +01:00
|
|
|
if (fMustAlloc)
|
2018-10-28 23:25:47 +01:00
|
|
|
*ppMemory = NdrAllocateZero(pStubMsg, size);
|
2007-11-29 18:35:40 +01:00
|
|
|
else
|
|
|
|
{
|
|
|
|
if (!pStubMsg->IsClient && !*ppMemory)
|
2006-05-19 12:47:20 +02:00
|
|
|
/* for servers, we just point straight into the RPC buffer */
|
2003-02-01 01:44:51 +01:00
|
|
|
*ppMemory = pStubMsg->Buffer;
|
|
|
|
}
|
|
|
|
|
2007-11-29 18:35:40 +01:00
|
|
|
saved_buffer = pStubMsg->BufferMark = pStubMsg->Buffer;
|
|
|
|
safe_buffer_increment(pStubMsg, size);
|
2018-06-13 04:19:10 +02:00
|
|
|
if (pFormat[0] == FC_PSTRUCT)
|
2007-11-29 18:35:40 +01:00
|
|
|
EmbeddedPointerUnmarshall(pStubMsg, saved_buffer, *ppMemory, pFormat+4, fMustAlloc);
|
|
|
|
|
|
|
|
TRACE("copying %p to %p\n", saved_buffer, *ppMemory);
|
|
|
|
if (*ppMemory != saved_buffer)
|
|
|
|
memcpy(*ppMemory, saved_buffer, size);
|
2003-02-01 01:44:51 +01:00
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* NdrSimpleStructBufferSize [RPCRT4.@]
|
|
|
|
*/
|
|
|
|
void WINAPI NdrSimpleStructBufferSize(PMIDL_STUB_MESSAGE pStubMsg,
|
|
|
|
unsigned char *pMemory,
|
|
|
|
PFORMAT_STRING pFormat)
|
|
|
|
{
|
2004-11-30 22:38:57 +01:00
|
|
|
unsigned size = *(const WORD*)(pFormat+2);
|
2003-02-01 01:44:51 +01:00
|
|
|
TRACE("(%p,%p,%p)\n", pStubMsg, pMemory, pFormat);
|
2006-05-10 14:12:30 +02:00
|
|
|
|
2010-04-02 21:54:55 +02:00
|
|
|
align_length(&pStubMsg->BufferLength, pFormat[1] + 1);
|
2006-05-10 14:12:30 +02:00
|
|
|
|
2007-11-28 16:01:53 +01:00
|
|
|
safe_buffer_length_increment(pStubMsg, size);
|
2018-06-13 04:19:10 +02:00
|
|
|
if (pFormat[0] != FC_STRUCT)
|
2003-02-01 01:44:51 +01:00
|
|
|
EmbeddedPointerBufferSize(pStubMsg, pMemory, pFormat+4);
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* NdrSimpleStructMemorySize [RPCRT4.@]
|
|
|
|
*/
|
2006-11-09 23:01:58 +01:00
|
|
|
ULONG WINAPI NdrSimpleStructMemorySize(PMIDL_STUB_MESSAGE pStubMsg,
|
|
|
|
PFORMAT_STRING pFormat)
|
2003-02-01 01:44:51 +01:00
|
|
|
{
|
2006-09-25 23:20:20 +02:00
|
|
|
unsigned short size = *(const WORD *)(pFormat+2);
|
2006-05-15 14:34:58 +02:00
|
|
|
|
|
|
|
TRACE("(%p,%p)\n", pStubMsg, pFormat);
|
|
|
|
|
2010-04-02 21:54:55 +02:00
|
|
|
align_pointer(&pStubMsg->Buffer, pFormat[1] + 1);
|
2006-05-15 14:34:58 +02:00
|
|
|
pStubMsg->MemorySize += size;
|
2007-11-28 16:02:21 +01:00
|
|
|
safe_buffer_increment(pStubMsg, size);
|
2006-05-15 14:34:58 +02:00
|
|
|
|
2018-06-13 04:19:10 +02:00
|
|
|
if (pFormat[0] != FC_STRUCT)
|
2003-02-01 01:44:51 +01:00
|
|
|
EmbeddedPointerMemorySize(pStubMsg, pFormat+4);
|
2007-12-08 18:46:48 +01:00
|
|
|
return pStubMsg->MemorySize;
|
2003-02-01 01:44:51 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* NdrSimpleStructFree [RPCRT4.@]
|
|
|
|
*/
|
|
|
|
void WINAPI NdrSimpleStructFree(PMIDL_STUB_MESSAGE pStubMsg,
|
|
|
|
unsigned char *pMemory,
|
|
|
|
PFORMAT_STRING pFormat)
|
|
|
|
{
|
|
|
|
TRACE("(%p,%p,%p)\n", pStubMsg, pMemory, pFormat);
|
2018-06-13 04:19:10 +02:00
|
|
|
if (pFormat[0] != FC_STRUCT)
|
2003-02-01 01:44:51 +01:00
|
|
|
EmbeddedPointerFree(pStubMsg, pMemory, pFormat+4);
|
|
|
|
}
|
|
|
|
|
2008-08-10 12:14:07 +02:00
|
|
|
/* Array helpers */
|
|
|
|
|
|
|
|
static inline void array_compute_and_size_conformance(
|
|
|
|
unsigned char fc, PMIDL_STUB_MESSAGE pStubMsg, unsigned char *pMemory,
|
|
|
|
PFORMAT_STRING pFormat)
|
|
|
|
{
|
2010-04-05 22:01:46 +02:00
|
|
|
DWORD count;
|
|
|
|
|
2008-08-10 12:14:07 +02:00
|
|
|
switch (fc)
|
|
|
|
{
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_CARRAY:
|
2008-08-10 12:14:07 +02:00
|
|
|
ComputeConformance(pStubMsg, pMemory, pFormat+4, 0);
|
|
|
|
SizeConformance(pStubMsg);
|
|
|
|
break;
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_CVARRAY:
|
2008-08-10 12:14:21 +02:00
|
|
|
pFormat = ComputeConformance(pStubMsg, pMemory, pFormat + 4, 0);
|
|
|
|
pFormat = ComputeVariance(pStubMsg, pMemory, pFormat, 0);
|
|
|
|
SizeConformance(pStubMsg);
|
|
|
|
break;
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_C_CSTRING:
|
|
|
|
case FC_C_WSTRING:
|
|
|
|
if (fc == FC_C_CSTRING)
|
2008-08-10 12:14:25 +02:00
|
|
|
{
|
|
|
|
TRACE("string=%s\n", debugstr_a((const char *)pMemory));
|
|
|
|
pStubMsg->ActualCount = strlen((const char *)pMemory)+1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
TRACE("string=%s\n", debugstr_w((LPCWSTR)pMemory));
|
2019-06-19 10:32:06 +02:00
|
|
|
pStubMsg->ActualCount = lstrlenW((LPCWSTR)pMemory)+1;
|
2008-08-10 12:14:25 +02:00
|
|
|
}
|
|
|
|
|
2018-06-13 04:19:10 +02:00
|
|
|
if (pFormat[1] == FC_STRING_SIZED)
|
2008-08-10 12:14:25 +02:00
|
|
|
pFormat = ComputeConformance(pStubMsg, pMemory, pFormat + 2, 0);
|
|
|
|
else
|
|
|
|
pStubMsg->MaxCount = pStubMsg->ActualCount;
|
|
|
|
|
|
|
|
SizeConformance(pStubMsg);
|
|
|
|
break;
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_BOGUS_ARRAY:
|
2010-04-05 22:01:46 +02:00
|
|
|
count = *(const WORD *)(pFormat + 2);
|
|
|
|
pFormat += 4;
|
|
|
|
if (IsConformanceOrVariancePresent(pFormat)) SizeConformance(pStubMsg);
|
|
|
|
pFormat = ComputeConformance(pStubMsg, pMemory, pFormat, count);
|
|
|
|
pFormat = ComputeVariance(pStubMsg, pMemory, pFormat, pStubMsg->MaxCount);
|
|
|
|
break;
|
2008-08-10 12:14:25 +02:00
|
|
|
default:
|
|
|
|
ERR("unknown array format 0x%x\n", fc);
|
|
|
|
RpcRaiseException(RPC_X_BAD_STUB_DATA);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void array_buffer_size(
|
|
|
|
unsigned char fc, PMIDL_STUB_MESSAGE pStubMsg, unsigned char *pMemory,
|
2008-08-10 12:14:30 +02:00
|
|
|
PFORMAT_STRING pFormat, unsigned char fHasPointers)
|
2008-08-10 12:14:25 +02:00
|
|
|
{
|
2010-04-05 22:01:46 +02:00
|
|
|
DWORD i, size;
|
2008-08-10 12:14:25 +02:00
|
|
|
DWORD esize;
|
|
|
|
unsigned char alignment;
|
|
|
|
|
|
|
|
switch (fc)
|
|
|
|
{
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_CARRAY:
|
2008-08-10 12:14:25 +02:00
|
|
|
esize = *(const WORD*)(pFormat+2);
|
|
|
|
alignment = pFormat[1] + 1;
|
|
|
|
|
|
|
|
pFormat = SkipConformance(pStubMsg, pFormat + 4);
|
|
|
|
|
2010-04-02 21:54:55 +02:00
|
|
|
align_length(&pStubMsg->BufferLength, alignment);
|
2008-08-10 12:14:25 +02:00
|
|
|
|
|
|
|
size = safe_multiply(esize, pStubMsg->MaxCount);
|
|
|
|
/* conformance value plus array */
|
|
|
|
safe_buffer_length_increment(pStubMsg, size);
|
|
|
|
|
2008-08-10 12:14:30 +02:00
|
|
|
if (fHasPointers)
|
|
|
|
EmbeddedPointerBufferSize(pStubMsg, pMemory, pFormat);
|
2008-08-10 12:14:25 +02:00
|
|
|
break;
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_CVARRAY:
|
2008-08-10 12:14:25 +02:00
|
|
|
esize = *(const WORD*)(pFormat+2);
|
|
|
|
alignment = pFormat[1] + 1;
|
|
|
|
|
|
|
|
pFormat = SkipConformance(pStubMsg, pFormat + 4);
|
2010-04-05 21:59:30 +02:00
|
|
|
pFormat = SkipVariance(pStubMsg, pFormat);
|
2008-08-10 12:14:25 +02:00
|
|
|
|
|
|
|
SizeVariance(pStubMsg);
|
|
|
|
|
2010-04-02 21:54:55 +02:00
|
|
|
align_length(&pStubMsg->BufferLength, alignment);
|
2008-08-10 12:14:25 +02:00
|
|
|
|
|
|
|
size = safe_multiply(esize, pStubMsg->ActualCount);
|
|
|
|
safe_buffer_length_increment(pStubMsg, size);
|
|
|
|
|
2008-08-10 12:14:30 +02:00
|
|
|
if (fHasPointers)
|
|
|
|
EmbeddedPointerBufferSize(pStubMsg, pMemory, pFormat);
|
2008-08-10 12:14:25 +02:00
|
|
|
break;
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_C_CSTRING:
|
|
|
|
case FC_C_WSTRING:
|
|
|
|
if (fc == FC_C_CSTRING)
|
2008-08-10 12:14:25 +02:00
|
|
|
esize = 1;
|
|
|
|
else
|
|
|
|
esize = 2;
|
|
|
|
|
|
|
|
SizeVariance(pStubMsg);
|
|
|
|
|
|
|
|
size = safe_multiply(esize, pStubMsg->ActualCount);
|
|
|
|
safe_buffer_length_increment(pStubMsg, size);
|
|
|
|
break;
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_BOGUS_ARRAY:
|
2010-04-05 22:01:46 +02:00
|
|
|
alignment = pFormat[1] + 1;
|
|
|
|
pFormat = SkipConformance(pStubMsg, pFormat + 4);
|
|
|
|
if (IsConformanceOrVariancePresent(pFormat)) SizeVariance(pStubMsg);
|
|
|
|
pFormat = SkipVariance(pStubMsg, pFormat);
|
|
|
|
|
|
|
|
align_length(&pStubMsg->BufferLength, alignment);
|
|
|
|
|
|
|
|
size = pStubMsg->ActualCount;
|
|
|
|
for (i = 0; i < size; i++)
|
|
|
|
pMemory = ComplexBufferSize(pStubMsg, pMemory, pFormat, NULL);
|
|
|
|
break;
|
2008-08-10 12:14:25 +02:00
|
|
|
default:
|
|
|
|
ERR("unknown array format 0x%x\n", fc);
|
|
|
|
RpcRaiseException(RPC_X_BAD_STUB_DATA);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void array_compute_and_write_conformance(
|
|
|
|
unsigned char fc, PMIDL_STUB_MESSAGE pStubMsg, unsigned char *pMemory,
|
|
|
|
PFORMAT_STRING pFormat)
|
|
|
|
{
|
2010-04-05 22:01:46 +02:00
|
|
|
ULONG def;
|
|
|
|
BOOL conformance_present;
|
|
|
|
|
2008-08-10 12:14:25 +02:00
|
|
|
switch (fc)
|
|
|
|
{
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_CARRAY:
|
2008-08-10 12:14:25 +02:00
|
|
|
ComputeConformance(pStubMsg, pMemory, pFormat+4, 0);
|
|
|
|
WriteConformance(pStubMsg);
|
|
|
|
break;
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_CVARRAY:
|
2008-08-10 12:14:25 +02:00
|
|
|
pFormat = ComputeConformance(pStubMsg, pMemory, pFormat + 4, 0);
|
|
|
|
pFormat = ComputeVariance(pStubMsg, pMemory, pFormat, 0);
|
|
|
|
WriteConformance(pStubMsg);
|
|
|
|
break;
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_C_CSTRING:
|
|
|
|
case FC_C_WSTRING:
|
|
|
|
if (fc == FC_C_CSTRING)
|
2008-08-10 12:14:25 +02:00
|
|
|
{
|
|
|
|
TRACE("string=%s\n", debugstr_a((const char *)pMemory));
|
|
|
|
pStubMsg->ActualCount = strlen((const char *)pMemory)+1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
TRACE("string=%s\n", debugstr_w((LPCWSTR)pMemory));
|
2019-06-19 10:32:06 +02:00
|
|
|
pStubMsg->ActualCount = lstrlenW((LPCWSTR)pMemory)+1;
|
2008-08-10 12:14:25 +02:00
|
|
|
}
|
2018-06-13 04:19:10 +02:00
|
|
|
if (pFormat[1] == FC_STRING_SIZED)
|
2008-08-10 12:14:25 +02:00
|
|
|
pFormat = ComputeConformance(pStubMsg, pMemory, pFormat + 2, 0);
|
|
|
|
else
|
|
|
|
pStubMsg->MaxCount = pStubMsg->ActualCount;
|
|
|
|
pStubMsg->Offset = 0;
|
|
|
|
WriteConformance(pStubMsg);
|
|
|
|
break;
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_BOGUS_ARRAY:
|
2010-04-05 22:01:46 +02:00
|
|
|
def = *(const WORD *)(pFormat + 2);
|
|
|
|
pFormat += 4;
|
|
|
|
conformance_present = IsConformanceOrVariancePresent(pFormat);
|
|
|
|
pFormat = ComputeConformance(pStubMsg, pMemory, pFormat, def);
|
|
|
|
pFormat = ComputeVariance(pStubMsg, pMemory, pFormat, pStubMsg->MaxCount);
|
|
|
|
if (conformance_present) WriteConformance(pStubMsg);
|
|
|
|
break;
|
2008-08-10 12:14:25 +02:00
|
|
|
default:
|
|
|
|
ERR("unknown array format 0x%x\n", fc);
|
|
|
|
RpcRaiseException(RPC_X_BAD_STUB_DATA);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void array_write_variance_and_marshall(
|
|
|
|
unsigned char fc, PMIDL_STUB_MESSAGE pStubMsg, unsigned char *pMemory,
|
2008-08-10 12:14:30 +02:00
|
|
|
PFORMAT_STRING pFormat, unsigned char fHasPointers)
|
2008-08-10 12:14:25 +02:00
|
|
|
{
|
2010-04-05 22:01:46 +02:00
|
|
|
DWORD i, size;
|
2008-08-10 12:14:25 +02:00
|
|
|
DWORD esize;
|
|
|
|
unsigned char alignment;
|
|
|
|
|
|
|
|
switch (fc)
|
|
|
|
{
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_CARRAY:
|
2008-08-10 12:14:25 +02:00
|
|
|
esize = *(const WORD*)(pFormat+2);
|
|
|
|
alignment = pFormat[1] + 1;
|
|
|
|
|
|
|
|
pFormat = SkipConformance(pStubMsg, pFormat + 4);
|
|
|
|
|
2010-04-02 21:54:55 +02:00
|
|
|
align_pointer_clear(&pStubMsg->Buffer, alignment);
|
2008-08-10 12:14:25 +02:00
|
|
|
|
|
|
|
size = safe_multiply(esize, pStubMsg->MaxCount);
|
2008-08-10 12:14:30 +02:00
|
|
|
if (fHasPointers)
|
|
|
|
pStubMsg->BufferMark = pStubMsg->Buffer;
|
2008-08-10 12:14:25 +02:00
|
|
|
safe_copy_to_buffer(pStubMsg, pMemory, size);
|
|
|
|
|
2008-08-10 12:14:30 +02:00
|
|
|
if (fHasPointers)
|
|
|
|
EmbeddedPointerMarshall(pStubMsg, pMemory, pFormat);
|
2008-08-10 12:14:25 +02:00
|
|
|
break;
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_CVARRAY:
|
2008-08-10 12:14:25 +02:00
|
|
|
esize = *(const WORD*)(pFormat+2);
|
|
|
|
alignment = pFormat[1] + 1;
|
|
|
|
|
|
|
|
pFormat = SkipConformance(pStubMsg, pFormat + 4);
|
2010-04-05 21:59:30 +02:00
|
|
|
pFormat = SkipVariance(pStubMsg, pFormat);
|
2008-08-10 12:14:25 +02:00
|
|
|
|
|
|
|
WriteVariance(pStubMsg);
|
|
|
|
|
2010-04-02 21:54:55 +02:00
|
|
|
align_pointer_clear(&pStubMsg->Buffer, alignment);
|
2008-08-10 12:14:25 +02:00
|
|
|
|
|
|
|
size = safe_multiply(esize, pStubMsg->ActualCount);
|
|
|
|
|
2008-08-10 12:14:30 +02:00
|
|
|
if (fHasPointers)
|
|
|
|
pStubMsg->BufferMark = pStubMsg->Buffer;
|
2008-08-10 12:14:25 +02:00
|
|
|
safe_copy_to_buffer(pStubMsg, pMemory + pStubMsg->Offset, size);
|
|
|
|
|
2008-08-10 12:14:30 +02:00
|
|
|
if (fHasPointers)
|
|
|
|
EmbeddedPointerMarshall(pStubMsg, pMemory, pFormat);
|
2008-08-10 12:14:25 +02:00
|
|
|
break;
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_C_CSTRING:
|
|
|
|
case FC_C_WSTRING:
|
|
|
|
if (fc == FC_C_CSTRING)
|
2008-08-10 12:14:25 +02:00
|
|
|
esize = 1;
|
|
|
|
else
|
|
|
|
esize = 2;
|
|
|
|
|
|
|
|
WriteVariance(pStubMsg);
|
|
|
|
|
|
|
|
size = safe_multiply(esize, pStubMsg->ActualCount);
|
|
|
|
safe_copy_to_buffer(pStubMsg, pMemory, size); /* the string itself */
|
|
|
|
break;
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_BOGUS_ARRAY:
|
2010-04-05 22:01:46 +02:00
|
|
|
alignment = pFormat[1] + 1;
|
|
|
|
pFormat = SkipConformance(pStubMsg, pFormat + 4);
|
|
|
|
if (IsConformanceOrVariancePresent(pFormat)) WriteVariance(pStubMsg);
|
|
|
|
pFormat = SkipVariance(pStubMsg, pFormat);
|
|
|
|
|
|
|
|
align_pointer_clear(&pStubMsg->Buffer, alignment);
|
|
|
|
|
|
|
|
size = pStubMsg->ActualCount;
|
|
|
|
for (i = 0; i < size; i++)
|
|
|
|
pMemory = ComplexMarshall(pStubMsg, pMemory, pFormat, NULL);
|
|
|
|
break;
|
2008-08-10 12:14:25 +02:00
|
|
|
default:
|
|
|
|
ERR("unknown array format 0x%x\n", fc);
|
|
|
|
RpcRaiseException(RPC_X_BAD_STUB_DATA);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline ULONG array_read_conformance(
|
|
|
|
unsigned char fc, PMIDL_STUB_MESSAGE pStubMsg, PFORMAT_STRING pFormat)
|
|
|
|
{
|
2010-04-05 22:02:20 +02:00
|
|
|
DWORD def, esize;
|
2008-08-10 12:14:25 +02:00
|
|
|
|
|
|
|
switch (fc)
|
|
|
|
{
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_CARRAY:
|
2008-08-10 12:14:25 +02:00
|
|
|
esize = *(const WORD*)(pFormat+2);
|
|
|
|
pFormat = ReadConformance(pStubMsg, pFormat+4);
|
|
|
|
return safe_multiply(esize, pStubMsg->MaxCount);
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_CVARRAY:
|
2008-08-10 12:14:25 +02:00
|
|
|
esize = *(const WORD*)(pFormat+2);
|
|
|
|
pFormat = ReadConformance(pStubMsg, pFormat+4);
|
|
|
|
return safe_multiply(esize, pStubMsg->MaxCount);
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_C_CSTRING:
|
|
|
|
case FC_C_WSTRING:
|
|
|
|
if (fc == FC_C_CSTRING)
|
2008-08-10 12:14:25 +02:00
|
|
|
esize = 1;
|
|
|
|
else
|
|
|
|
esize = 2;
|
|
|
|
|
2018-06-13 04:19:10 +02:00
|
|
|
if (pFormat[1] == FC_STRING_SIZED)
|
2008-08-10 12:14:25 +02:00
|
|
|
ReadConformance(pStubMsg, pFormat + 2);
|
|
|
|
else
|
|
|
|
ReadConformance(pStubMsg, NULL);
|
|
|
|
return safe_multiply(esize, pStubMsg->MaxCount);
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_BOGUS_ARRAY:
|
2010-04-05 22:02:20 +02:00
|
|
|
def = *(const WORD *)(pFormat + 2);
|
|
|
|
pFormat += 4;
|
|
|
|
if (IsConformanceOrVariancePresent(pFormat)) pFormat = ReadConformance(pStubMsg, pFormat);
|
|
|
|
else
|
|
|
|
{
|
|
|
|
pStubMsg->MaxCount = def;
|
|
|
|
pFormat = SkipConformance( pStubMsg, pFormat );
|
|
|
|
}
|
|
|
|
pFormat = SkipVariance( pStubMsg, pFormat );
|
|
|
|
|
|
|
|
esize = ComplexStructSize(pStubMsg, pFormat);
|
|
|
|
return safe_multiply(pStubMsg->MaxCount, esize);
|
2008-08-10 12:14:07 +02:00
|
|
|
default:
|
|
|
|
ERR("unknown array format 0x%x\n", fc);
|
|
|
|
RpcRaiseException(RPC_X_BAD_STUB_DATA);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-08-10 12:14:30 +02:00
|
|
|
static inline ULONG array_read_variance_and_unmarshall(
|
2008-08-10 12:14:25 +02:00
|
|
|
unsigned char fc, PMIDL_STUB_MESSAGE pStubMsg, unsigned char **ppMemory,
|
|
|
|
PFORMAT_STRING pFormat, unsigned char fMustAlloc,
|
2008-08-10 12:14:30 +02:00
|
|
|
unsigned char fUseBufferMemoryServer, unsigned char fUnmarshall)
|
2008-08-10 12:14:07 +02:00
|
|
|
{
|
2008-08-10 12:14:25 +02:00
|
|
|
ULONG bufsize, memsize;
|
|
|
|
WORD esize;
|
2008-08-10 12:14:07 +02:00
|
|
|
unsigned char alignment;
|
2010-04-05 22:02:20 +02:00
|
|
|
unsigned char *saved_buffer, *pMemory;
|
|
|
|
ULONG i, offset, count;
|
2008-08-10 12:14:07 +02:00
|
|
|
|
|
|
|
switch (fc)
|
|
|
|
{
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_CARRAY:
|
2008-08-10 12:14:07 +02:00
|
|
|
esize = *(const WORD*)(pFormat+2);
|
|
|
|
alignment = pFormat[1] + 1;
|
|
|
|
|
2008-08-10 12:14:25 +02:00
|
|
|
bufsize = memsize = safe_multiply(esize, pStubMsg->MaxCount);
|
|
|
|
|
2008-08-10 12:14:07 +02:00
|
|
|
pFormat = SkipConformance(pStubMsg, pFormat + 4);
|
|
|
|
|
2010-04-02 21:54:55 +02:00
|
|
|
align_pointer(&pStubMsg->Buffer, alignment);
|
2008-08-10 12:14:07 +02:00
|
|
|
|
2008-08-10 12:14:30 +02:00
|
|
|
if (fUnmarshall)
|
2008-08-10 12:14:25 +02:00
|
|
|
{
|
2008-08-10 12:14:30 +02:00
|
|
|
if (fMustAlloc)
|
2018-10-28 23:25:47 +01:00
|
|
|
*ppMemory = NdrAllocateZero(pStubMsg, memsize);
|
2008-08-10 12:14:30 +02:00
|
|
|
else
|
|
|
|
{
|
|
|
|
if (fUseBufferMemoryServer && !pStubMsg->IsClient && !*ppMemory)
|
|
|
|
/* for servers, we just point straight into the RPC buffer */
|
|
|
|
*ppMemory = pStubMsg->Buffer;
|
|
|
|
}
|
2008-08-10 12:14:07 +02:00
|
|
|
|
2008-08-10 12:14:30 +02:00
|
|
|
saved_buffer = pStubMsg->Buffer;
|
|
|
|
safe_buffer_increment(pStubMsg, bufsize);
|
2008-08-10 12:14:25 +02:00
|
|
|
|
2008-08-10 12:14:30 +02:00
|
|
|
pStubMsg->BufferMark = saved_buffer;
|
|
|
|
EmbeddedPointerUnmarshall(pStubMsg, saved_buffer, *ppMemory, pFormat, fMustAlloc);
|
|
|
|
|
|
|
|
TRACE("copying %p to %p\n", saved_buffer, *ppMemory);
|
|
|
|
if (*ppMemory != saved_buffer)
|
|
|
|
memcpy(*ppMemory, saved_buffer, bufsize);
|
|
|
|
}
|
|
|
|
return bufsize;
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_CVARRAY:
|
2008-08-10 12:14:21 +02:00
|
|
|
esize = *(const WORD*)(pFormat+2);
|
|
|
|
alignment = pFormat[1] + 1;
|
|
|
|
|
|
|
|
pFormat = SkipConformance(pStubMsg, pFormat + 4);
|
|
|
|
|
2008-08-10 12:14:25 +02:00
|
|
|
pFormat = ReadVariance(pStubMsg, pFormat, pStubMsg->MaxCount);
|
2008-08-10 12:14:21 +02:00
|
|
|
|
2010-04-02 21:54:55 +02:00
|
|
|
align_pointer(&pStubMsg->Buffer, alignment);
|
2008-08-10 12:14:21 +02:00
|
|
|
|
2008-08-10 12:14:25 +02:00
|
|
|
bufsize = safe_multiply(esize, pStubMsg->ActualCount);
|
|
|
|
memsize = safe_multiply(esize, pStubMsg->MaxCount);
|
2008-08-10 12:14:21 +02:00
|
|
|
|
2008-08-10 12:14:30 +02:00
|
|
|
if (fUnmarshall)
|
|
|
|
{
|
|
|
|
offset = pStubMsg->Offset;
|
2008-08-10 12:14:07 +02:00
|
|
|
|
2008-08-10 12:14:30 +02:00
|
|
|
if (!fMustAlloc && !*ppMemory)
|
|
|
|
fMustAlloc = TRUE;
|
|
|
|
if (fMustAlloc)
|
2018-10-28 23:25:47 +01:00
|
|
|
*ppMemory = NdrAllocateZero(pStubMsg, memsize);
|
2008-08-10 12:14:30 +02:00
|
|
|
saved_buffer = pStubMsg->Buffer;
|
|
|
|
safe_buffer_increment(pStubMsg, bufsize);
|
2008-08-10 12:14:25 +02:00
|
|
|
|
2008-08-10 12:14:30 +02:00
|
|
|
pStubMsg->BufferMark = saved_buffer;
|
|
|
|
EmbeddedPointerUnmarshall(pStubMsg, saved_buffer, *ppMemory, pFormat,
|
|
|
|
fMustAlloc);
|
|
|
|
|
|
|
|
memcpy(*ppMemory + offset, saved_buffer, bufsize);
|
|
|
|
}
|
|
|
|
return bufsize;
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_C_CSTRING:
|
|
|
|
case FC_C_WSTRING:
|
|
|
|
if (fc == FC_C_CSTRING)
|
2008-08-10 12:14:25 +02:00
|
|
|
esize = 1;
|
|
|
|
else
|
|
|
|
esize = 2;
|
|
|
|
|
|
|
|
ReadVariance(pStubMsg, NULL, pStubMsg->MaxCount);
|
|
|
|
|
2018-06-13 04:19:10 +02:00
|
|
|
if (pFormat[1] != FC_STRING_SIZED && (pStubMsg->MaxCount != pStubMsg->ActualCount))
|
2008-08-10 12:14:25 +02:00
|
|
|
{
|
|
|
|
ERR("buffer size %d must equal memory size %ld for non-sized conformant strings\n",
|
|
|
|
pStubMsg->ActualCount, pStubMsg->MaxCount);
|
|
|
|
RpcRaiseException(RPC_S_INVALID_BOUND);
|
|
|
|
}
|
|
|
|
if (pStubMsg->Offset)
|
|
|
|
{
|
|
|
|
ERR("conformant strings can't have Offset (%d)\n", pStubMsg->Offset);
|
|
|
|
RpcRaiseException(RPC_S_INVALID_BOUND);
|
|
|
|
}
|
|
|
|
|
|
|
|
memsize = safe_multiply(esize, pStubMsg->MaxCount);
|
|
|
|
bufsize = safe_multiply(esize, pStubMsg->ActualCount);
|
|
|
|
|
|
|
|
validate_string_data(pStubMsg, bufsize, esize);
|
|
|
|
|
2008-08-10 12:14:30 +02:00
|
|
|
if (fUnmarshall)
|
2008-08-10 12:14:25 +02:00
|
|
|
{
|
2008-08-10 12:14:30 +02:00
|
|
|
if (fMustAlloc)
|
2008-08-10 12:14:25 +02:00
|
|
|
*ppMemory = NdrAllocate(pStubMsg, memsize);
|
2008-08-10 12:14:30 +02:00
|
|
|
else
|
|
|
|
{
|
|
|
|
if (fUseBufferMemoryServer && !pStubMsg->IsClient &&
|
|
|
|
!*ppMemory && (pStubMsg->MaxCount == pStubMsg->ActualCount))
|
|
|
|
/* if the data in the RPC buffer is big enough, we just point
|
|
|
|
* straight into it */
|
|
|
|
*ppMemory = pStubMsg->Buffer;
|
|
|
|
else if (!*ppMemory)
|
|
|
|
*ppMemory = NdrAllocate(pStubMsg, memsize);
|
|
|
|
}
|
2008-08-10 12:14:25 +02:00
|
|
|
|
2008-08-10 12:14:30 +02:00
|
|
|
if (*ppMemory == pStubMsg->Buffer)
|
|
|
|
safe_buffer_increment(pStubMsg, bufsize);
|
|
|
|
else
|
|
|
|
safe_copy_from_buffer(pStubMsg, *ppMemory, bufsize);
|
2008-08-10 12:14:25 +02:00
|
|
|
|
2018-06-13 04:19:10 +02:00
|
|
|
if (*pFormat == FC_C_CSTRING)
|
2008-08-10 12:14:30 +02:00
|
|
|
TRACE("string=%s\n", debugstr_a((char*)*ppMemory));
|
|
|
|
else
|
|
|
|
TRACE("string=%s\n", debugstr_w((LPWSTR)*ppMemory));
|
|
|
|
}
|
|
|
|
return bufsize;
|
2010-04-05 22:02:20 +02:00
|
|
|
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_BOGUS_ARRAY:
|
2010-04-05 22:02:20 +02:00
|
|
|
alignment = pFormat[1] + 1;
|
|
|
|
pFormat = SkipConformance(pStubMsg, pFormat + 4);
|
|
|
|
pFormat = ReadVariance(pStubMsg, pFormat, pStubMsg->MaxCount);
|
|
|
|
|
|
|
|
esize = ComplexStructSize(pStubMsg, pFormat);
|
|
|
|
memsize = safe_multiply(esize, pStubMsg->MaxCount);
|
|
|
|
|
|
|
|
assert( fUnmarshall );
|
|
|
|
|
|
|
|
if (!fMustAlloc && !*ppMemory)
|
|
|
|
fMustAlloc = TRUE;
|
|
|
|
if (fMustAlloc)
|
2018-10-28 23:25:47 +01:00
|
|
|
*ppMemory = NdrAllocateZero(pStubMsg, memsize);
|
2010-04-05 22:02:20 +02:00
|
|
|
|
|
|
|
align_pointer(&pStubMsg->Buffer, alignment);
|
|
|
|
saved_buffer = pStubMsg->Buffer;
|
|
|
|
|
|
|
|
pMemory = *ppMemory;
|
|
|
|
count = pStubMsg->ActualCount;
|
|
|
|
for (i = 0; i < count; i++)
|
|
|
|
pMemory = ComplexUnmarshall(pStubMsg, pMemory, pFormat, NULL, fMustAlloc);
|
|
|
|
return pStubMsg->Buffer - saved_buffer;
|
|
|
|
|
2008-08-10 12:14:07 +02:00
|
|
|
default:
|
|
|
|
ERR("unknown array format 0x%x\n", fc);
|
|
|
|
RpcRaiseException(RPC_X_BAD_STUB_DATA);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-08-10 12:14:25 +02:00
|
|
|
static inline void array_memory_size(
|
2008-08-10 12:14:30 +02:00
|
|
|
unsigned char fc, PMIDL_STUB_MESSAGE pStubMsg, PFORMAT_STRING pFormat,
|
|
|
|
unsigned char fHasPointers)
|
2008-08-10 12:14:07 +02:00
|
|
|
{
|
2010-04-05 22:02:20 +02:00
|
|
|
ULONG i, count, SavedMemorySize;
|
2008-08-10 12:14:25 +02:00
|
|
|
ULONG bufsize, memsize;
|
2008-08-10 12:14:07 +02:00
|
|
|
DWORD esize;
|
|
|
|
unsigned char alignment;
|
|
|
|
|
|
|
|
switch (fc)
|
|
|
|
{
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_CARRAY:
|
2008-08-10 12:14:07 +02:00
|
|
|
esize = *(const WORD*)(pFormat+2);
|
|
|
|
alignment = pFormat[1] + 1;
|
|
|
|
|
|
|
|
pFormat = SkipConformance(pStubMsg, pFormat + 4);
|
|
|
|
|
2008-08-10 12:14:25 +02:00
|
|
|
bufsize = memsize = safe_multiply(esize, pStubMsg->MaxCount);
|
|
|
|
pStubMsg->MemorySize += memsize;
|
2008-08-10 12:14:07 +02:00
|
|
|
|
2010-04-02 21:54:55 +02:00
|
|
|
align_pointer(&pStubMsg->Buffer, alignment);
|
2008-08-10 12:14:30 +02:00
|
|
|
if (fHasPointers)
|
|
|
|
pStubMsg->BufferMark = pStubMsg->Buffer;
|
2008-08-10 12:14:25 +02:00
|
|
|
safe_buffer_increment(pStubMsg, bufsize);
|
2008-08-10 12:14:07 +02:00
|
|
|
|
2008-08-10 12:14:30 +02:00
|
|
|
if (fHasPointers)
|
|
|
|
EmbeddedPointerMemorySize(pStubMsg, pFormat);
|
2008-08-10 12:14:21 +02:00
|
|
|
break;
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_CVARRAY:
|
2008-08-10 12:14:21 +02:00
|
|
|
esize = *(const WORD*)(pFormat+2);
|
|
|
|
alignment = pFormat[1] + 1;
|
|
|
|
|
|
|
|
pFormat = SkipConformance(pStubMsg, pFormat + 4);
|
|
|
|
|
2008-08-10 12:14:25 +02:00
|
|
|
pFormat = ReadVariance(pStubMsg, pFormat, pStubMsg->MaxCount);
|
2008-08-10 12:14:21 +02:00
|
|
|
|
2008-08-10 12:14:25 +02:00
|
|
|
bufsize = safe_multiply(esize, pStubMsg->ActualCount);
|
|
|
|
memsize = safe_multiply(esize, pStubMsg->MaxCount);
|
|
|
|
pStubMsg->MemorySize += memsize;
|
2008-08-10 12:14:21 +02:00
|
|
|
|
2010-04-02 21:54:55 +02:00
|
|
|
align_pointer(&pStubMsg->Buffer, alignment);
|
2008-08-10 12:14:30 +02:00
|
|
|
if (fHasPointers)
|
|
|
|
pStubMsg->BufferMark = pStubMsg->Buffer;
|
2008-08-10 12:14:25 +02:00
|
|
|
safe_buffer_increment(pStubMsg, bufsize);
|
2008-08-10 12:14:21 +02:00
|
|
|
|
2008-08-10 12:14:30 +02:00
|
|
|
if (fHasPointers)
|
|
|
|
EmbeddedPointerMemorySize(pStubMsg, pFormat);
|
2008-08-10 12:14:25 +02:00
|
|
|
break;
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_C_CSTRING:
|
|
|
|
case FC_C_WSTRING:
|
|
|
|
if (fc == FC_C_CSTRING)
|
2008-08-10 12:14:25 +02:00
|
|
|
esize = 1;
|
|
|
|
else
|
|
|
|
esize = 2;
|
|
|
|
|
|
|
|
ReadVariance(pStubMsg, NULL, pStubMsg->MaxCount);
|
|
|
|
|
2018-06-13 04:19:10 +02:00
|
|
|
if (pFormat[1] != FC_STRING_SIZED && (pStubMsg->MaxCount != pStubMsg->ActualCount))
|
2008-08-10 12:14:25 +02:00
|
|
|
{
|
|
|
|
ERR("buffer size %d must equal memory size %ld for non-sized conformant strings\n",
|
|
|
|
pStubMsg->ActualCount, pStubMsg->MaxCount);
|
|
|
|
RpcRaiseException(RPC_S_INVALID_BOUND);
|
|
|
|
}
|
|
|
|
if (pStubMsg->Offset)
|
|
|
|
{
|
|
|
|
ERR("conformant strings can't have Offset (%d)\n", pStubMsg->Offset);
|
|
|
|
RpcRaiseException(RPC_S_INVALID_BOUND);
|
|
|
|
}
|
|
|
|
|
|
|
|
memsize = safe_multiply(esize, pStubMsg->MaxCount);
|
|
|
|
bufsize = safe_multiply(esize, pStubMsg->ActualCount);
|
|
|
|
|
|
|
|
validate_string_data(pStubMsg, bufsize, esize);
|
|
|
|
|
|
|
|
safe_buffer_increment(pStubMsg, bufsize);
|
|
|
|
pStubMsg->MemorySize += memsize;
|
2008-08-10 12:14:07 +02:00
|
|
|
break;
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_BOGUS_ARRAY:
|
2010-04-05 22:02:20 +02:00
|
|
|
alignment = pFormat[1] + 1;
|
|
|
|
pFormat = SkipConformance(pStubMsg, pFormat + 4);
|
|
|
|
pFormat = ReadVariance(pStubMsg, pFormat, pStubMsg->MaxCount);
|
|
|
|
|
|
|
|
align_pointer(&pStubMsg->Buffer, alignment);
|
|
|
|
|
|
|
|
SavedMemorySize = pStubMsg->MemorySize;
|
|
|
|
|
|
|
|
esize = ComplexStructSize(pStubMsg, pFormat);
|
|
|
|
memsize = safe_multiply(pStubMsg->MaxCount, esize);
|
|
|
|
|
|
|
|
count = pStubMsg->ActualCount;
|
|
|
|
for (i = 0; i < count; i++)
|
|
|
|
ComplexStructMemorySize(pStubMsg, pFormat, NULL);
|
|
|
|
|
|
|
|
pStubMsg->MemorySize = SavedMemorySize + memsize;
|
|
|
|
break;
|
2008-08-10 12:14:07 +02:00
|
|
|
default:
|
|
|
|
ERR("unknown array format 0x%x\n", fc);
|
|
|
|
RpcRaiseException(RPC_X_BAD_STUB_DATA);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-08-10 12:14:25 +02:00
|
|
|
static inline void array_free(
|
|
|
|
unsigned char fc, PMIDL_STUB_MESSAGE pStubMsg,
|
2008-08-10 12:14:30 +02:00
|
|
|
unsigned char *pMemory, PFORMAT_STRING pFormat, unsigned char fHasPointers)
|
2008-08-10 12:14:07 +02:00
|
|
|
{
|
2010-04-05 22:02:20 +02:00
|
|
|
DWORD i, count;
|
|
|
|
|
2008-08-10 12:14:07 +02:00
|
|
|
switch (fc)
|
|
|
|
{
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_CARRAY:
|
2008-08-10 12:14:25 +02:00
|
|
|
pFormat = ComputeConformance(pStubMsg, pMemory, pFormat+4, 0);
|
2008-08-10 12:14:30 +02:00
|
|
|
if (fHasPointers)
|
|
|
|
EmbeddedPointerFree(pStubMsg, pMemory, pFormat);
|
2008-08-10 12:14:25 +02:00
|
|
|
break;
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_CVARRAY:
|
2008-08-10 12:14:25 +02:00
|
|
|
pFormat = ComputeConformance(pStubMsg, pMemory, pFormat+4, 0);
|
|
|
|
pFormat = ComputeVariance(pStubMsg, pMemory, pFormat, 0);
|
2008-08-10 12:14:30 +02:00
|
|
|
if (fHasPointers)
|
|
|
|
EmbeddedPointerFree(pStubMsg, pMemory, pFormat);
|
2008-08-10 12:14:25 +02:00
|
|
|
break;
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_C_CSTRING:
|
|
|
|
case FC_C_WSTRING:
|
2008-08-10 12:14:25 +02:00
|
|
|
/* No embedded pointers so nothing to do */
|
|
|
|
break;
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_BOGUS_ARRAY:
|
2010-04-05 22:02:20 +02:00
|
|
|
count = *(const WORD *)(pFormat + 2);
|
|
|
|
pFormat = ComputeConformance(pStubMsg, pMemory, pFormat + 4, count);
|
|
|
|
pFormat = ComputeVariance(pStubMsg, pMemory, pFormat, pStubMsg->MaxCount);
|
|
|
|
|
|
|
|
count = pStubMsg->ActualCount;
|
|
|
|
for (i = 0; i < count; i++)
|
|
|
|
pMemory = ComplexFree(pStubMsg, pMemory, pFormat, NULL);
|
|
|
|
break;
|
2008-08-10 12:14:07 +02:00
|
|
|
default:
|
|
|
|
ERR("unknown array format 0x%x\n", fc);
|
|
|
|
RpcRaiseException(RPC_X_BAD_STUB_DATA);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-08-10 12:14:25 +02:00
|
|
|
/*
|
|
|
|
* NdrConformantString:
|
|
|
|
*
|
|
|
|
* What MS calls a ConformantString is, in DCE terminology,
|
|
|
|
* a Varying-Conformant String.
|
|
|
|
* [
|
|
|
|
* maxlen: DWORD (max # of CHARTYPE characters, inclusive of '\0')
|
|
|
|
* offset: DWORD (actual string data begins at (offset) CHARTYPE's
|
|
|
|
* into unmarshalled string)
|
|
|
|
* length: DWORD (# of CHARTYPE characters, inclusive of '\0')
|
|
|
|
* [
|
|
|
|
* data: CHARTYPE[maxlen]
|
|
|
|
* ]
|
|
|
|
* ], where CHARTYPE is the appropriate character type (specified externally)
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* NdrConformantStringMarshall [RPCRT4.@]
|
|
|
|
*/
|
|
|
|
unsigned char *WINAPI NdrConformantStringMarshall(MIDL_STUB_MESSAGE *pStubMsg,
|
|
|
|
unsigned char *pszMessage, PFORMAT_STRING pFormat)
|
|
|
|
{
|
|
|
|
TRACE("(pStubMsg == ^%p, pszMessage == ^%p, pFormat == ^%p)\n", pStubMsg, pszMessage, pFormat);
|
|
|
|
|
2018-06-13 04:19:10 +02:00
|
|
|
if (pFormat[0] != FC_C_CSTRING && pFormat[0] != FC_C_WSTRING) {
|
2008-08-10 12:14:25 +02:00
|
|
|
ERR("Unhandled string type: %#x\n", pFormat[0]);
|
|
|
|
RpcRaiseException(RPC_X_BAD_STUB_DATA);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* allow compiler to optimise inline function by passing constant into
|
|
|
|
* these functions */
|
2018-06-13 04:19:10 +02:00
|
|
|
if (pFormat[0] == FC_C_CSTRING) {
|
|
|
|
array_compute_and_write_conformance(FC_C_CSTRING, pStubMsg, pszMessage,
|
2008-08-10 12:14:30 +02:00
|
|
|
pFormat);
|
2018-06-13 04:19:10 +02:00
|
|
|
array_write_variance_and_marshall(FC_C_CSTRING, pStubMsg, pszMessage,
|
2008-08-10 12:14:30 +02:00
|
|
|
pFormat, TRUE /* fHasPointers */);
|
2008-08-10 12:14:25 +02:00
|
|
|
} else {
|
2018-06-13 04:19:10 +02:00
|
|
|
array_compute_and_write_conformance(FC_C_WSTRING, pStubMsg, pszMessage,
|
2008-08-10 12:14:30 +02:00
|
|
|
pFormat);
|
2018-06-13 04:19:10 +02:00
|
|
|
array_write_variance_and_marshall(FC_C_WSTRING, pStubMsg, pszMessage,
|
2008-08-10 12:14:30 +02:00
|
|
|
pFormat, TRUE /* fHasPointers */);
|
2008-08-10 12:14:25 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* NdrConformantStringBufferSize [RPCRT4.@]
|
|
|
|
*/
|
|
|
|
void WINAPI NdrConformantStringBufferSize(PMIDL_STUB_MESSAGE pStubMsg,
|
|
|
|
unsigned char* pMemory, PFORMAT_STRING pFormat)
|
|
|
|
{
|
|
|
|
TRACE("(pStubMsg == ^%p, pMemory == ^%p, pFormat == ^%p)\n", pStubMsg, pMemory, pFormat);
|
|
|
|
|
2018-06-13 04:19:10 +02:00
|
|
|
if (pFormat[0] != FC_C_CSTRING && pFormat[0] != FC_C_WSTRING) {
|
2008-08-10 12:14:25 +02:00
|
|
|
ERR("Unhandled string type: %#x\n", pFormat[0]);
|
|
|
|
RpcRaiseException(RPC_X_BAD_STUB_DATA);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* allow compiler to optimise inline function by passing constant into
|
|
|
|
* these functions */
|
2018-06-13 04:19:10 +02:00
|
|
|
if (pFormat[0] == FC_C_CSTRING) {
|
|
|
|
array_compute_and_size_conformance(FC_C_CSTRING, pStubMsg, pMemory,
|
2008-08-10 12:14:30 +02:00
|
|
|
pFormat);
|
2018-06-13 04:19:10 +02:00
|
|
|
array_buffer_size(FC_C_CSTRING, pStubMsg, pMemory, pFormat,
|
2008-08-10 12:14:30 +02:00
|
|
|
TRUE /* fHasPointers */);
|
2008-08-10 12:14:25 +02:00
|
|
|
} else {
|
2018-06-13 04:19:10 +02:00
|
|
|
array_compute_and_size_conformance(FC_C_WSTRING, pStubMsg, pMemory,
|
2008-08-10 12:14:30 +02:00
|
|
|
pFormat);
|
2018-06-13 04:19:10 +02:00
|
|
|
array_buffer_size(FC_C_WSTRING, pStubMsg, pMemory, pFormat,
|
2008-08-10 12:14:30 +02:00
|
|
|
TRUE /* fHasPointers */);
|
2008-08-10 12:14:25 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/************************************************************************
|
|
|
|
* NdrConformantStringMemorySize [RPCRT4.@]
|
|
|
|
*/
|
|
|
|
ULONG WINAPI NdrConformantStringMemorySize( PMIDL_STUB_MESSAGE pStubMsg,
|
|
|
|
PFORMAT_STRING pFormat )
|
|
|
|
{
|
|
|
|
TRACE("(pStubMsg == ^%p, pFormat == ^%p)\n", pStubMsg, pFormat);
|
|
|
|
|
2018-06-13 04:19:10 +02:00
|
|
|
if (pFormat[0] != FC_C_CSTRING && pFormat[0] != FC_C_WSTRING) {
|
2008-08-10 12:14:25 +02:00
|
|
|
ERR("Unhandled string type: %#x\n", pFormat[0]);
|
|
|
|
RpcRaiseException(RPC_X_BAD_STUB_DATA);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* allow compiler to optimise inline function by passing constant into
|
|
|
|
* these functions */
|
2018-06-13 04:19:10 +02:00
|
|
|
if (pFormat[0] == FC_C_CSTRING) {
|
|
|
|
array_read_conformance(FC_C_CSTRING, pStubMsg, pFormat);
|
|
|
|
array_memory_size(FC_C_CSTRING, pStubMsg, pFormat,
|
2008-08-10 12:14:30 +02:00
|
|
|
TRUE /* fHasPointers */);
|
2008-08-10 12:14:25 +02:00
|
|
|
} else {
|
2018-06-13 04:19:10 +02:00
|
|
|
array_read_conformance(FC_C_WSTRING, pStubMsg, pFormat);
|
|
|
|
array_memory_size(FC_C_WSTRING, pStubMsg, pFormat,
|
2008-08-10 12:14:30 +02:00
|
|
|
TRUE /* fHasPointers */);
|
2008-08-10 12:14:25 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return pStubMsg->MemorySize;
|
|
|
|
}
|
|
|
|
|
|
|
|
/************************************************************************
|
|
|
|
* NdrConformantStringUnmarshall [RPCRT4.@]
|
|
|
|
*/
|
|
|
|
unsigned char *WINAPI NdrConformantStringUnmarshall( PMIDL_STUB_MESSAGE pStubMsg,
|
|
|
|
unsigned char** ppMemory, PFORMAT_STRING pFormat, unsigned char fMustAlloc )
|
|
|
|
{
|
|
|
|
TRACE("(pStubMsg == ^%p, *pMemory == ^%p, pFormat == ^%p, fMustAlloc == %u)\n",
|
|
|
|
pStubMsg, *ppMemory, pFormat, fMustAlloc);
|
|
|
|
|
2018-06-13 04:19:10 +02:00
|
|
|
if (pFormat[0] != FC_C_CSTRING && pFormat[0] != FC_C_WSTRING) {
|
2008-08-10 12:14:25 +02:00
|
|
|
ERR("Unhandled string type: %#x\n", *pFormat);
|
|
|
|
RpcRaiseException(RPC_X_BAD_STUB_DATA);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* allow compiler to optimise inline function by passing constant into
|
|
|
|
* these functions */
|
2018-06-13 04:19:10 +02:00
|
|
|
if (pFormat[0] == FC_C_CSTRING) {
|
|
|
|
array_read_conformance(FC_C_CSTRING, pStubMsg, pFormat);
|
|
|
|
array_read_variance_and_unmarshall(FC_C_CSTRING, pStubMsg, ppMemory,
|
2008-08-10 12:14:25 +02:00
|
|
|
pFormat, fMustAlloc,
|
2008-08-10 12:14:30 +02:00
|
|
|
TRUE /* fUseBufferMemoryServer */,
|
|
|
|
TRUE /* fUnmarshall */);
|
2008-08-10 12:14:25 +02:00
|
|
|
} else {
|
2018-06-13 04:19:10 +02:00
|
|
|
array_read_conformance(FC_C_WSTRING, pStubMsg, pFormat);
|
|
|
|
array_read_variance_and_unmarshall(FC_C_WSTRING, pStubMsg, ppMemory,
|
2008-08-10 12:14:25 +02:00
|
|
|
pFormat, fMustAlloc,
|
2008-08-10 12:14:30 +02:00
|
|
|
TRUE /* fUseBufferMemoryServer */,
|
|
|
|
TRUE /* fUnmarshall */);
|
2008-08-10 12:14:25 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* NdrNonConformantStringMarshall [RPCRT4.@]
|
|
|
|
*/
|
|
|
|
unsigned char * WINAPI NdrNonConformantStringMarshall(PMIDL_STUB_MESSAGE pStubMsg,
|
|
|
|
unsigned char *pMemory,
|
|
|
|
PFORMAT_STRING pFormat)
|
2008-08-10 12:14:07 +02:00
|
|
|
{
|
2008-08-10 12:14:25 +02:00
|
|
|
ULONG esize, size, maxsize;
|
2008-08-10 12:14:07 +02:00
|
|
|
|
2008-08-10 12:14:25 +02:00
|
|
|
TRACE("(pStubMsg == ^%p, pMemory == ^%p, pFormat == ^%p)\n", pStubMsg, pMemory, pFormat);
|
|
|
|
|
2010-03-26 21:53:36 +01:00
|
|
|
maxsize = *(const USHORT *)&pFormat[2];
|
2008-08-10 12:14:25 +02:00
|
|
|
|
2018-06-13 04:19:10 +02:00
|
|
|
if (*pFormat == FC_CSTRING)
|
2008-08-10 12:14:07 +02:00
|
|
|
{
|
2010-04-05 21:58:06 +02:00
|
|
|
ULONG i = 0;
|
2008-08-10 12:14:25 +02:00
|
|
|
const char *str = (const char *)pMemory;
|
2010-04-05 21:58:06 +02:00
|
|
|
while (i < maxsize && str[i]) i++;
|
2008-08-10 12:14:25 +02:00
|
|
|
TRACE("string=%s\n", debugstr_an(str, i));
|
|
|
|
pStubMsg->ActualCount = i + 1;
|
|
|
|
esize = 1;
|
|
|
|
}
|
2018-06-13 04:19:10 +02:00
|
|
|
else if (*pFormat == FC_WSTRING)
|
2008-08-10 12:14:25 +02:00
|
|
|
{
|
2010-04-05 21:58:06 +02:00
|
|
|
ULONG i = 0;
|
2008-08-10 12:14:25 +02:00
|
|
|
const WCHAR *str = (const WCHAR *)pMemory;
|
2010-04-05 21:58:06 +02:00
|
|
|
while (i < maxsize && str[i]) i++;
|
2008-08-10 12:14:25 +02:00
|
|
|
TRACE("string=%s\n", debugstr_wn(str, i));
|
|
|
|
pStubMsg->ActualCount = i + 1;
|
|
|
|
esize = 2;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ERR("Unhandled string type: %#x\n", *pFormat);
|
|
|
|
RpcRaiseException(RPC_X_BAD_STUB_DATA);
|
|
|
|
}
|
2008-08-10 12:14:07 +02:00
|
|
|
|
2008-08-10 12:14:25 +02:00
|
|
|
pStubMsg->Offset = 0;
|
|
|
|
WriteVariance(pStubMsg);
|
2008-08-10 12:14:07 +02:00
|
|
|
|
2008-08-10 12:14:25 +02:00
|
|
|
size = safe_multiply(esize, pStubMsg->ActualCount);
|
|
|
|
safe_copy_to_buffer(pStubMsg, pMemory, size); /* the string itself */
|
2008-08-10 12:14:07 +02:00
|
|
|
|
2008-08-10 12:14:25 +02:00
|
|
|
return NULL;
|
|
|
|
}
|
2008-08-10 12:14:07 +02:00
|
|
|
|
2008-08-10 12:14:25 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* NdrNonConformantStringUnmarshall [RPCRT4.@]
|
|
|
|
*/
|
|
|
|
unsigned char * WINAPI NdrNonConformantStringUnmarshall(PMIDL_STUB_MESSAGE pStubMsg,
|
|
|
|
unsigned char **ppMemory,
|
|
|
|
PFORMAT_STRING pFormat,
|
|
|
|
unsigned char fMustAlloc)
|
|
|
|
{
|
|
|
|
ULONG bufsize, memsize, esize, maxsize;
|
2008-08-10 12:14:07 +02:00
|
|
|
|
2008-08-10 12:14:25 +02:00
|
|
|
TRACE("(pStubMsg == ^%p, *pMemory == ^%p, pFormat == ^%p, fMustAlloc == %u)\n",
|
|
|
|
pStubMsg, *ppMemory, pFormat, fMustAlloc);
|
2008-08-10 12:14:07 +02:00
|
|
|
|
2010-03-26 21:53:36 +01:00
|
|
|
maxsize = *(const USHORT *)&pFormat[2];
|
2008-08-10 12:14:21 +02:00
|
|
|
|
2008-08-10 12:14:25 +02:00
|
|
|
ReadVariance(pStubMsg, NULL, maxsize);
|
|
|
|
if (pStubMsg->Offset)
|
|
|
|
{
|
|
|
|
ERR("non-conformant strings can't have Offset (%d)\n", pStubMsg->Offset);
|
|
|
|
RpcRaiseException(RPC_S_INVALID_BOUND);
|
|
|
|
}
|
2008-08-10 12:14:21 +02:00
|
|
|
|
2018-06-13 04:19:10 +02:00
|
|
|
if (*pFormat == FC_CSTRING) esize = 1;
|
|
|
|
else if (*pFormat == FC_WSTRING) esize = 2;
|
2008-08-10 12:14:25 +02:00
|
|
|
else
|
|
|
|
{
|
|
|
|
ERR("Unhandled string type: %#x\n", *pFormat);
|
|
|
|
RpcRaiseException(RPC_X_BAD_STUB_DATA);
|
|
|
|
}
|
2008-08-10 12:14:21 +02:00
|
|
|
|
2008-08-10 12:14:25 +02:00
|
|
|
memsize = esize * maxsize;
|
|
|
|
bufsize = safe_multiply(esize, pStubMsg->ActualCount);
|
2008-08-10 12:14:21 +02:00
|
|
|
|
2008-08-10 12:14:25 +02:00
|
|
|
validate_string_data(pStubMsg, bufsize, esize);
|
2008-08-10 12:14:21 +02:00
|
|
|
|
2009-01-10 23:17:15 +01:00
|
|
|
if (!fMustAlloc && !*ppMemory)
|
|
|
|
fMustAlloc = TRUE;
|
|
|
|
if (fMustAlloc)
|
2008-08-10 12:14:25 +02:00
|
|
|
*ppMemory = NdrAllocate(pStubMsg, memsize);
|
2008-08-10 12:14:21 +02:00
|
|
|
|
2008-08-10 12:14:25 +02:00
|
|
|
safe_copy_from_buffer(pStubMsg, *ppMemory, bufsize);
|
2008-08-10 12:14:21 +02:00
|
|
|
|
2018-06-13 04:19:10 +02:00
|
|
|
if (*pFormat == FC_CSTRING) {
|
2008-08-10 12:14:25 +02:00
|
|
|
TRACE("string=%s\n", debugstr_an((char*)*ppMemory, pStubMsg->ActualCount));
|
|
|
|
}
|
2018-06-13 04:19:10 +02:00
|
|
|
else if (*pFormat == FC_WSTRING) {
|
2008-08-10 12:14:25 +02:00
|
|
|
TRACE("string=%s\n", debugstr_wn((LPWSTR)*ppMemory, pStubMsg->ActualCount));
|
2008-08-10 12:14:07 +02:00
|
|
|
}
|
2008-08-10 12:14:25 +02:00
|
|
|
|
|
|
|
return NULL;
|
2008-08-10 12:14:07 +02:00
|
|
|
}
|
|
|
|
|
2008-08-10 12:14:25 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* NdrNonConformantStringBufferSize [RPCRT4.@]
|
|
|
|
*/
|
|
|
|
void WINAPI NdrNonConformantStringBufferSize(PMIDL_STUB_MESSAGE pStubMsg,
|
|
|
|
unsigned char *pMemory,
|
|
|
|
PFORMAT_STRING pFormat)
|
2008-08-10 12:14:07 +02:00
|
|
|
{
|
2008-08-10 12:14:25 +02:00
|
|
|
ULONG esize, maxsize;
|
2008-08-10 12:14:07 +02:00
|
|
|
|
2008-08-10 12:14:25 +02:00
|
|
|
TRACE("(pStubMsg == ^%p, pMemory == ^%p, pFormat == ^%p)\n", pStubMsg, pMemory, pFormat);
|
2008-08-10 12:14:07 +02:00
|
|
|
|
2010-03-26 21:53:36 +01:00
|
|
|
maxsize = *(const USHORT *)&pFormat[2];
|
2008-08-10 12:14:07 +02:00
|
|
|
|
2008-08-10 12:14:25 +02:00
|
|
|
SizeVariance(pStubMsg);
|
2008-08-10 12:14:07 +02:00
|
|
|
|
2018-06-13 04:19:10 +02:00
|
|
|
if (*pFormat == FC_CSTRING)
|
2008-08-10 12:14:25 +02:00
|
|
|
{
|
2010-04-05 21:58:06 +02:00
|
|
|
ULONG i = 0;
|
2008-08-10 12:14:25 +02:00
|
|
|
const char *str = (const char *)pMemory;
|
2010-04-05 21:58:06 +02:00
|
|
|
while (i < maxsize && str[i]) i++;
|
2008-08-10 12:14:25 +02:00
|
|
|
TRACE("string=%s\n", debugstr_an(str, i));
|
|
|
|
pStubMsg->ActualCount = i + 1;
|
|
|
|
esize = 1;
|
|
|
|
}
|
2018-06-13 04:19:10 +02:00
|
|
|
else if (*pFormat == FC_WSTRING)
|
2008-08-10 12:14:25 +02:00
|
|
|
{
|
2010-04-05 21:58:06 +02:00
|
|
|
ULONG i = 0;
|
2008-08-10 12:14:25 +02:00
|
|
|
const WCHAR *str = (const WCHAR *)pMemory;
|
2010-04-05 21:58:06 +02:00
|
|
|
while (i < maxsize && str[i]) i++;
|
2008-08-10 12:14:25 +02:00
|
|
|
TRACE("string=%s\n", debugstr_wn(str, i));
|
|
|
|
pStubMsg->ActualCount = i + 1;
|
|
|
|
esize = 2;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ERR("Unhandled string type: %#x\n", *pFormat);
|
|
|
|
RpcRaiseException(RPC_X_BAD_STUB_DATA);
|
|
|
|
}
|
2008-08-10 12:14:21 +02:00
|
|
|
|
2008-08-10 12:14:25 +02:00
|
|
|
safe_buffer_length_increment(pStubMsg, safe_multiply(esize, pStubMsg->ActualCount));
|
|
|
|
}
|
2008-08-10 12:14:21 +02:00
|
|
|
|
2008-08-10 12:14:25 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* NdrNonConformantStringMemorySize [RPCRT4.@]
|
|
|
|
*/
|
|
|
|
ULONG WINAPI NdrNonConformantStringMemorySize(PMIDL_STUB_MESSAGE pStubMsg,
|
|
|
|
PFORMAT_STRING pFormat)
|
|
|
|
{
|
|
|
|
ULONG bufsize, memsize, esize, maxsize;
|
2008-08-10 12:14:21 +02:00
|
|
|
|
2008-08-10 12:14:25 +02:00
|
|
|
TRACE("(pStubMsg == ^%p, pFormat == ^%p)\n", pStubMsg, pFormat);
|
2008-08-10 12:14:21 +02:00
|
|
|
|
2010-03-26 21:53:36 +01:00
|
|
|
maxsize = *(const USHORT *)&pFormat[2];
|
2008-08-10 12:14:21 +02:00
|
|
|
|
2008-08-10 12:14:25 +02:00
|
|
|
ReadVariance(pStubMsg, NULL, maxsize);
|
2008-08-10 12:14:07 +02:00
|
|
|
|
2008-08-10 12:14:25 +02:00
|
|
|
if (pStubMsg->Offset)
|
|
|
|
{
|
|
|
|
ERR("non-conformant strings can't have Offset (%d)\n", pStubMsg->Offset);
|
|
|
|
RpcRaiseException(RPC_S_INVALID_BOUND);
|
2008-08-10 12:14:07 +02:00
|
|
|
}
|
|
|
|
|
2018-06-13 04:19:10 +02:00
|
|
|
if (*pFormat == FC_CSTRING) esize = 1;
|
|
|
|
else if (*pFormat == FC_WSTRING) esize = 2;
|
2008-08-10 12:14:25 +02:00
|
|
|
else
|
2008-08-10 12:14:07 +02:00
|
|
|
{
|
2008-08-10 12:14:25 +02:00
|
|
|
ERR("Unhandled string type: %#x\n", *pFormat);
|
2008-08-10 12:14:07 +02:00
|
|
|
RpcRaiseException(RPC_X_BAD_STUB_DATA);
|
|
|
|
}
|
2008-08-10 12:14:25 +02:00
|
|
|
|
|
|
|
memsize = esize * maxsize;
|
|
|
|
bufsize = safe_multiply(esize, pStubMsg->ActualCount);
|
|
|
|
|
|
|
|
validate_string_data(pStubMsg, bufsize, esize);
|
|
|
|
|
|
|
|
safe_buffer_increment(pStubMsg, bufsize);
|
|
|
|
pStubMsg->MemorySize += memsize;
|
|
|
|
|
|
|
|
return pStubMsg->MemorySize;
|
2008-08-10 12:14:07 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Complex types */
|
2003-02-01 01:44:51 +01:00
|
|
|
|
2008-07-04 00:26:43 +02:00
|
|
|
#include "pshpack1.h"
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
unsigned char type;
|
|
|
|
unsigned char flags_type; /* flags in upper nibble, type in lower nibble */
|
|
|
|
ULONG low_value;
|
|
|
|
ULONG high_value;
|
|
|
|
} NDR_RANGE;
|
|
|
|
#include "poppack.h"
|
|
|
|
|
2009-04-21 09:59:45 +02:00
|
|
|
static ULONG EmbeddedComplexSize(MIDL_STUB_MESSAGE *pStubMsg,
|
|
|
|
PFORMAT_STRING pFormat)
|
2003-02-17 02:48:24 +01:00
|
|
|
{
|
|
|
|
switch (*pFormat) {
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_STRUCT:
|
|
|
|
case FC_PSTRUCT:
|
|
|
|
case FC_CSTRUCT:
|
|
|
|
case FC_BOGUS_STRUCT:
|
|
|
|
case FC_SMFARRAY:
|
|
|
|
case FC_SMVARRAY:
|
|
|
|
case FC_CSTRING:
|
2004-11-30 22:38:57 +01:00
|
|
|
return *(const WORD*)&pFormat[2];
|
2018-11-17 04:58:43 +01:00
|
|
|
case FC_LGFARRAY:
|
|
|
|
case FC_LGVARRAY:
|
|
|
|
return *(const ULONG*)&pFormat[2];
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_USER_MARSHAL:
|
2004-11-30 22:38:57 +01:00
|
|
|
return *(const WORD*)&pFormat[4];
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_RANGE: {
|
2008-07-04 00:26:43 +02:00
|
|
|
switch (((const NDR_RANGE *)pFormat)->flags_type & 0xf) {
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_BYTE:
|
|
|
|
case FC_CHAR:
|
|
|
|
case FC_SMALL:
|
|
|
|
case FC_USMALL:
|
2008-07-04 00:26:43 +02:00
|
|
|
return sizeof(UCHAR);
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_WCHAR:
|
|
|
|
case FC_SHORT:
|
|
|
|
case FC_USHORT:
|
2008-07-04 00:26:43 +02:00
|
|
|
return sizeof(USHORT);
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_LONG:
|
|
|
|
case FC_ULONG:
|
|
|
|
case FC_ENUM32:
|
2008-07-04 00:26:43 +02:00
|
|
|
return sizeof(ULONG);
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_FLOAT:
|
2008-07-04 00:26:43 +02:00
|
|
|
return sizeof(float);
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_DOUBLE:
|
2008-07-04 00:26:43 +02:00
|
|
|
return sizeof(double);
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_HYPER:
|
2008-07-04 00:26:43 +02:00
|
|
|
return sizeof(ULONGLONG);
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_ENUM16:
|
2008-07-04 00:26:43 +02:00
|
|
|
return sizeof(UINT);
|
|
|
|
default:
|
|
|
|
ERR("unknown type 0x%x\n", ((const NDR_RANGE *)pFormat)->flags_type & 0xf);
|
|
|
|
RpcRaiseException(RPC_X_BAD_STUB_DATA);
|
|
|
|
}
|
|
|
|
}
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_NON_ENCAPSULATED_UNION:
|
2006-05-15 14:35:07 +02:00
|
|
|
pFormat += 2;
|
2015-03-09 10:42:45 +01:00
|
|
|
pFormat = SkipConformance(pStubMsg, pFormat);
|
2006-05-15 14:35:07 +02:00
|
|
|
pFormat += *(const SHORT*)pFormat;
|
|
|
|
return *(const SHORT*)pFormat;
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_IP:
|
2006-05-18 04:40:06 +02:00
|
|
|
return sizeof(void *);
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_WSTRING:
|
2008-01-13 21:52:54 +01:00
|
|
|
return *(const WORD*)&pFormat[2] * 2;
|
2003-02-17 02:48:24 +01:00
|
|
|
default:
|
|
|
|
FIXME("unhandled embedded type %02x\n", *pFormat);
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-04-21 09:59:45 +02:00
|
|
|
static ULONG EmbeddedComplexMemorySize(PMIDL_STUB_MESSAGE pStubMsg,
|
|
|
|
PFORMAT_STRING pFormat)
|
2006-05-15 14:35:07 +02:00
|
|
|
{
|
|
|
|
NDR_MEMORYSIZE m = NdrMemorySizer[*pFormat & NDR_TABLE_MASK];
|
|
|
|
|
|
|
|
if (!m)
|
|
|
|
{
|
|
|
|
FIXME("no memorysizer for data type=%02x\n", *pFormat);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
return m(pStubMsg, pFormat);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-05-17 15:45:30 +02:00
|
|
|
static unsigned char * ComplexMarshall(PMIDL_STUB_MESSAGE pStubMsg,
|
2003-02-01 01:44:51 +01:00
|
|
|
unsigned char *pMemory,
|
|
|
|
PFORMAT_STRING pFormat,
|
|
|
|
PFORMAT_STRING pPointer)
|
|
|
|
{
|
2018-11-19 17:02:00 +01:00
|
|
|
unsigned char *mem_base = pMemory;
|
2003-02-01 01:44:51 +01:00
|
|
|
PFORMAT_STRING desc;
|
|
|
|
NDR_MARSHALL m;
|
2009-04-21 09:59:45 +02:00
|
|
|
ULONG size;
|
2003-02-01 01:44:51 +01:00
|
|
|
|
2018-06-13 04:19:10 +02:00
|
|
|
while (*pFormat != FC_END) {
|
2003-02-01 01:44:51 +01:00
|
|
|
switch (*pFormat) {
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_BYTE:
|
|
|
|
case FC_CHAR:
|
|
|
|
case FC_SMALL:
|
|
|
|
case FC_USMALL:
|
2006-06-09 18:24:49 +02:00
|
|
|
TRACE("byte=%d <= %p\n", *(WORD*)pMemory, pMemory);
|
2007-11-28 16:02:06 +01:00
|
|
|
safe_copy_to_buffer(pStubMsg, pMemory, 1);
|
2006-06-09 18:24:49 +02:00
|
|
|
pMemory += 1;
|
|
|
|
break;
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_WCHAR:
|
|
|
|
case FC_SHORT:
|
|
|
|
case FC_USHORT:
|
2003-02-17 02:48:24 +01:00
|
|
|
TRACE("short=%d <= %p\n", *(WORD*)pMemory, pMemory);
|
2007-11-28 16:02:06 +01:00
|
|
|
safe_copy_to_buffer(pStubMsg, pMemory, 2);
|
2003-02-01 01:44:51 +01:00
|
|
|
pMemory += 2;
|
|
|
|
break;
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_ENUM16:
|
2010-04-07 13:04:32 +02:00
|
|
|
{
|
|
|
|
USHORT val = *(DWORD *)pMemory;
|
2008-03-21 00:05:46 +01:00
|
|
|
TRACE("enum16=%d <= %p\n", *(DWORD*)pMemory, pMemory);
|
|
|
|
if (32767 < *(DWORD*)pMemory)
|
|
|
|
RpcRaiseException(RPC_X_ENUM_VALUE_OUT_OF_RANGE);
|
2010-04-07 13:04:32 +02:00
|
|
|
safe_copy_to_buffer(pStubMsg, &val, 2);
|
2008-03-21 00:05:46 +01:00
|
|
|
pMemory += 4;
|
|
|
|
break;
|
2010-04-07 13:04:32 +02:00
|
|
|
}
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_LONG:
|
|
|
|
case FC_ULONG:
|
|
|
|
case FC_ENUM32:
|
2006-11-09 23:04:48 +01:00
|
|
|
TRACE("long=%d <= %p\n", *(DWORD*)pMemory, pMemory);
|
2007-11-28 16:02:06 +01:00
|
|
|
safe_copy_to_buffer(pStubMsg, pMemory, 4);
|
2003-02-01 01:44:51 +01:00
|
|
|
pMemory += 4;
|
|
|
|
break;
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_INT3264:
|
|
|
|
case FC_UINT3264:
|
2010-04-07 13:08:46 +02:00
|
|
|
{
|
|
|
|
UINT val = *(UINT_PTR *)pMemory;
|
|
|
|
TRACE("int3264=%ld <= %p\n", *(UINT_PTR *)pMemory, pMemory);
|
|
|
|
safe_copy_to_buffer(pStubMsg, &val, sizeof(UINT));
|
|
|
|
pMemory += sizeof(UINT_PTR);
|
|
|
|
break;
|
|
|
|
}
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_FLOAT:
|
2010-02-22 12:49:19 +01:00
|
|
|
TRACE("float=%f <= %p\n", *(float*)pMemory, pMemory);
|
|
|
|
safe_copy_to_buffer(pStubMsg, pMemory, sizeof(float));
|
|
|
|
pMemory += sizeof(float);
|
|
|
|
break;
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_HYPER:
|
2006-07-24 12:45:24 +02:00
|
|
|
TRACE("longlong=%s <= %p\n", wine_dbgstr_longlong(*(ULONGLONG*)pMemory), pMemory);
|
2007-11-28 16:02:06 +01:00
|
|
|
safe_copy_to_buffer(pStubMsg, pMemory, 8);
|
2006-07-24 12:45:24 +02:00
|
|
|
pMemory += 8;
|
|
|
|
break;
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_DOUBLE:
|
2010-02-22 12:49:19 +01:00
|
|
|
TRACE("double=%f <= %p\n", *(double*)pMemory, pMemory);
|
|
|
|
safe_copy_to_buffer(pStubMsg, pMemory, sizeof(double));
|
|
|
|
pMemory += sizeof(double);
|
|
|
|
break;
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_RP:
|
|
|
|
case FC_UP:
|
|
|
|
case FC_OP:
|
|
|
|
case FC_FP:
|
|
|
|
case FC_POINTER:
|
2007-06-25 15:28:01 +02:00
|
|
|
{
|
|
|
|
unsigned char *saved_buffer;
|
2013-12-03 00:02:50 +01:00
|
|
|
BOOL pointer_buffer_mark_set = FALSE;
|
2003-02-17 02:48:24 +01:00
|
|
|
TRACE("pointer=%p <= %p\n", *(unsigned char**)pMemory, pMemory);
|
2008-07-04 00:28:02 +02:00
|
|
|
TRACE("pStubMsg->Buffer before %p\n", pStubMsg->Buffer);
|
2018-06-13 04:19:10 +02:00
|
|
|
if (*pFormat != FC_POINTER)
|
2010-03-15 22:18:46 +01:00
|
|
|
pPointer = pFormat;
|
2018-06-13 04:19:10 +02:00
|
|
|
if (*pPointer != FC_RP)
|
2010-04-02 21:54:55 +02:00
|
|
|
align_pointer_clear(&pStubMsg->Buffer, 4);
|
2007-06-25 15:28:01 +02:00
|
|
|
saved_buffer = pStubMsg->Buffer;
|
|
|
|
if (pStubMsg->PointerBufferMark)
|
|
|
|
{
|
|
|
|
pStubMsg->Buffer = pStubMsg->PointerBufferMark;
|
|
|
|
pStubMsg->PointerBufferMark = NULL;
|
2013-12-03 00:02:50 +01:00
|
|
|
pointer_buffer_mark_set = TRUE;
|
2007-06-25 15:28:01 +02:00
|
|
|
}
|
2018-06-13 04:19:10 +02:00
|
|
|
else if (*pPointer != FC_RP)
|
2007-11-28 16:02:21 +01:00
|
|
|
safe_buffer_increment(pStubMsg, 4); /* for pointer ID */
|
2007-06-25 15:28:01 +02:00
|
|
|
PointerMarshall(pStubMsg, saved_buffer, *(unsigned char**)pMemory, pPointer);
|
|
|
|
if (pointer_buffer_mark_set)
|
|
|
|
{
|
|
|
|
STD_OVERFLOW_CHECK(pStubMsg);
|
|
|
|
pStubMsg->PointerBufferMark = pStubMsg->Buffer;
|
2008-07-04 00:28:02 +02:00
|
|
|
pStubMsg->Buffer = saved_buffer;
|
2018-06-13 04:19:10 +02:00
|
|
|
if (*pPointer != FC_RP)
|
2008-07-04 00:28:02 +02:00
|
|
|
safe_buffer_increment(pStubMsg, 4); /* for pointer ID */
|
2007-06-25 15:28:01 +02:00
|
|
|
}
|
2008-07-04 00:28:02 +02:00
|
|
|
TRACE("pStubMsg->Buffer after %p\n", pStubMsg->Buffer);
|
2018-06-13 04:19:10 +02:00
|
|
|
if (*pFormat == FC_POINTER)
|
2010-03-15 22:18:46 +01:00
|
|
|
pPointer += 4;
|
|
|
|
else
|
|
|
|
pFormat += 4;
|
2009-06-19 12:49:35 +02:00
|
|
|
pMemory += sizeof(void *);
|
2003-02-01 01:44:51 +01:00
|
|
|
break;
|
2007-06-25 15:28:01 +02:00
|
|
|
}
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_ALIGNM2:
|
2018-11-19 17:02:00 +01:00
|
|
|
align_pointer_offset(&pMemory, mem_base, 2);
|
2009-08-17 15:35:31 +02:00
|
|
|
break;
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_ALIGNM4:
|
2018-11-19 17:02:00 +01:00
|
|
|
align_pointer_offset(&pMemory, mem_base, 4);
|
2003-02-01 01:44:51 +01:00
|
|
|
break;
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_ALIGNM8:
|
2018-11-19 17:02:00 +01:00
|
|
|
align_pointer_offset(&pMemory, mem_base, 8);
|
2003-02-01 01:44:51 +01:00
|
|
|
break;
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_STRUCTPAD1:
|
|
|
|
case FC_STRUCTPAD2:
|
|
|
|
case FC_STRUCTPAD3:
|
|
|
|
case FC_STRUCTPAD4:
|
|
|
|
case FC_STRUCTPAD5:
|
|
|
|
case FC_STRUCTPAD6:
|
|
|
|
case FC_STRUCTPAD7:
|
|
|
|
pMemory += *pFormat - FC_STRUCTPAD1 + 1;
|
2005-11-28 11:28:45 +01:00
|
|
|
break;
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_EMBEDDED_COMPLEX:
|
2003-02-01 01:44:51 +01:00
|
|
|
pMemory += pFormat[1];
|
|
|
|
pFormat += 2;
|
2004-11-30 22:38:57 +01:00
|
|
|
desc = pFormat + *(const SHORT*)pFormat;
|
2003-02-17 02:48:24 +01:00
|
|
|
size = EmbeddedComplexSize(pStubMsg, desc);
|
2009-04-21 09:59:45 +02:00
|
|
|
TRACE("embedded complex (size=%d) <= %p\n", size, pMemory);
|
2003-02-01 01:44:51 +01:00
|
|
|
m = NdrMarshaller[*desc & NDR_TABLE_MASK];
|
2007-06-25 15:29:52 +02:00
|
|
|
if (m)
|
|
|
|
{
|
|
|
|
/* for some reason interface pointers aren't generated as
|
2018-06-13 04:19:10 +02:00
|
|
|
* FC_POINTER, but instead as FC_EMBEDDED_COMPLEX, yet
|
2017-07-06 12:22:29 +02:00
|
|
|
* they still need the dereferencing treatment that pointers are
|
2007-06-25 15:29:52 +02:00
|
|
|
* given */
|
2018-06-13 04:19:10 +02:00
|
|
|
if (*desc == FC_IP)
|
2007-06-25 15:29:52 +02:00
|
|
|
m(pStubMsg, *(unsigned char **)pMemory, desc);
|
|
|
|
else
|
|
|
|
m(pStubMsg, pMemory, desc);
|
|
|
|
}
|
2003-02-01 01:44:51 +01:00
|
|
|
else FIXME("no marshaller for embedded type %02x\n", *desc);
|
2003-02-17 02:48:24 +01:00
|
|
|
pMemory += size;
|
2003-02-01 01:44:51 +01:00
|
|
|
pFormat += 2;
|
|
|
|
continue;
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_PAD:
|
2003-02-01 01:44:51 +01:00
|
|
|
break;
|
|
|
|
default:
|
2006-07-24 12:45:24 +02:00
|
|
|
FIXME("unhandled format 0x%02x\n", *pFormat);
|
2003-02-01 01:44:51 +01:00
|
|
|
}
|
|
|
|
pFormat++;
|
|
|
|
}
|
|
|
|
|
|
|
|
return pMemory;
|
|
|
|
}
|
|
|
|
|
2006-05-17 15:45:30 +02:00
|
|
|
static unsigned char * ComplexUnmarshall(PMIDL_STUB_MESSAGE pStubMsg,
|
2003-02-01 01:44:51 +01:00
|
|
|
unsigned char *pMemory,
|
|
|
|
PFORMAT_STRING pFormat,
|
2008-06-26 09:50:53 +02:00
|
|
|
PFORMAT_STRING pPointer,
|
|
|
|
unsigned char fMustAlloc)
|
2003-02-01 01:44:51 +01:00
|
|
|
{
|
2018-11-19 17:02:00 +01:00
|
|
|
unsigned char *mem_base = pMemory;
|
2003-02-01 01:44:51 +01:00
|
|
|
PFORMAT_STRING desc;
|
|
|
|
NDR_UNMARSHALL m;
|
2009-04-21 09:59:45 +02:00
|
|
|
ULONG size;
|
2003-02-01 01:44:51 +01:00
|
|
|
|
2018-06-13 04:19:10 +02:00
|
|
|
while (*pFormat != FC_END) {
|
2003-02-01 01:44:51 +01:00
|
|
|
switch (*pFormat) {
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_BYTE:
|
|
|
|
case FC_CHAR:
|
|
|
|
case FC_SMALL:
|
|
|
|
case FC_USMALL:
|
2007-11-28 16:01:53 +01:00
|
|
|
safe_copy_from_buffer(pStubMsg, pMemory, 1);
|
2006-06-09 18:24:49 +02:00
|
|
|
TRACE("byte=%d => %p\n", *(WORD*)pMemory, pMemory);
|
|
|
|
pMemory += 1;
|
|
|
|
break;
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_WCHAR:
|
|
|
|
case FC_SHORT:
|
|
|
|
case FC_USHORT:
|
2007-11-28 16:01:53 +01:00
|
|
|
safe_copy_from_buffer(pStubMsg, pMemory, 2);
|
2003-02-17 02:48:24 +01:00
|
|
|
TRACE("short=%d => %p\n", *(WORD*)pMemory, pMemory);
|
2003-02-01 01:44:51 +01:00
|
|
|
pMemory += 2;
|
|
|
|
break;
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_ENUM16:
|
2010-04-07 13:04:32 +02:00
|
|
|
{
|
|
|
|
WORD val;
|
|
|
|
safe_copy_from_buffer(pStubMsg, &val, 2);
|
|
|
|
*(DWORD*)pMemory = val;
|
2008-03-21 00:05:46 +01:00
|
|
|
TRACE("enum16=%d => %p\n", *(DWORD*)pMemory, pMemory);
|
|
|
|
if (32767 < *(DWORD*)pMemory)
|
|
|
|
RpcRaiseException(RPC_X_ENUM_VALUE_OUT_OF_RANGE);
|
|
|
|
pMemory += 4;
|
|
|
|
break;
|
2010-04-07 13:04:32 +02:00
|
|
|
}
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_LONG:
|
|
|
|
case FC_ULONG:
|
|
|
|
case FC_ENUM32:
|
2007-11-28 16:01:53 +01:00
|
|
|
safe_copy_from_buffer(pStubMsg, pMemory, 4);
|
2006-11-09 23:04:48 +01:00
|
|
|
TRACE("long=%d => %p\n", *(DWORD*)pMemory, pMemory);
|
2003-02-01 01:44:51 +01:00
|
|
|
pMemory += 4;
|
|
|
|
break;
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_INT3264:
|
2010-04-07 13:08:46 +02:00
|
|
|
{
|
|
|
|
INT val;
|
|
|
|
safe_copy_from_buffer(pStubMsg, &val, 4);
|
|
|
|
*(INT_PTR *)pMemory = val;
|
|
|
|
TRACE("int3264=%ld => %p\n", *(INT_PTR*)pMemory, pMemory);
|
|
|
|
pMemory += sizeof(INT_PTR);
|
|
|
|
break;
|
|
|
|
}
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_UINT3264:
|
2010-04-07 13:08:46 +02:00
|
|
|
{
|
|
|
|
UINT val;
|
|
|
|
safe_copy_from_buffer(pStubMsg, &val, 4);
|
|
|
|
*(UINT_PTR *)pMemory = val;
|
|
|
|
TRACE("uint3264=%ld => %p\n", *(UINT_PTR*)pMemory, pMemory);
|
|
|
|
pMemory += sizeof(UINT_PTR);
|
|
|
|
break;
|
|
|
|
}
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_FLOAT:
|
2010-02-22 12:49:19 +01:00
|
|
|
safe_copy_from_buffer(pStubMsg, pMemory, sizeof(float));
|
|
|
|
TRACE("float=%f => %p\n", *(float*)pMemory, pMemory);
|
|
|
|
pMemory += sizeof(float);
|
|
|
|
break;
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_HYPER:
|
2007-11-28 16:01:53 +01:00
|
|
|
safe_copy_from_buffer(pStubMsg, pMemory, 8);
|
2006-07-24 12:45:24 +02:00
|
|
|
TRACE("longlong=%s => %p\n", wine_dbgstr_longlong(*(ULONGLONG*)pMemory), pMemory);
|
|
|
|
pMemory += 8;
|
|
|
|
break;
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_DOUBLE:
|
2010-02-22 12:49:19 +01:00
|
|
|
safe_copy_from_buffer(pStubMsg, pMemory, sizeof(double));
|
|
|
|
TRACE("double=%f => %p\n", *(double*)pMemory, pMemory);
|
|
|
|
pMemory += sizeof(double);
|
|
|
|
break;
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_RP:
|
|
|
|
case FC_UP:
|
|
|
|
case FC_OP:
|
|
|
|
case FC_FP:
|
|
|
|
case FC_POINTER:
|
2007-06-25 15:28:01 +02:00
|
|
|
{
|
|
|
|
unsigned char *saved_buffer;
|
2013-12-03 00:02:50 +01:00
|
|
|
BOOL pointer_buffer_mark_set = FALSE;
|
2003-02-17 02:48:24 +01:00
|
|
|
TRACE("pointer => %p\n", pMemory);
|
2018-06-13 04:19:10 +02:00
|
|
|
if (*pFormat != FC_POINTER)
|
2010-03-15 22:18:46 +01:00
|
|
|
pPointer = pFormat;
|
2018-06-13 04:19:10 +02:00
|
|
|
if (*pPointer != FC_RP)
|
2010-04-02 21:54:55 +02:00
|
|
|
align_pointer(&pStubMsg->Buffer, 4);
|
2007-06-25 15:28:01 +02:00
|
|
|
saved_buffer = pStubMsg->Buffer;
|
|
|
|
if (pStubMsg->PointerBufferMark)
|
|
|
|
{
|
|
|
|
pStubMsg->Buffer = pStubMsg->PointerBufferMark;
|
|
|
|
pStubMsg->PointerBufferMark = NULL;
|
2013-12-03 00:02:50 +01:00
|
|
|
pointer_buffer_mark_set = TRUE;
|
2007-06-25 15:28:01 +02:00
|
|
|
}
|
2018-06-13 04:19:10 +02:00
|
|
|
else if (*pPointer != FC_RP)
|
2007-11-28 16:02:21 +01:00
|
|
|
safe_buffer_increment(pStubMsg, 4); /* for pointer ID */
|
2007-06-25 15:28:01 +02:00
|
|
|
|
2008-06-26 09:50:53 +02:00
|
|
|
PointerUnmarshall(pStubMsg, saved_buffer, (unsigned char**)pMemory, *(unsigned char**)pMemory, pPointer, fMustAlloc);
|
2007-06-25 15:28:01 +02:00
|
|
|
if (pointer_buffer_mark_set)
|
|
|
|
{
|
|
|
|
STD_OVERFLOW_CHECK(pStubMsg);
|
|
|
|
pStubMsg->PointerBufferMark = pStubMsg->Buffer;
|
2008-07-04 00:28:02 +02:00
|
|
|
pStubMsg->Buffer = saved_buffer;
|
2018-06-13 04:19:10 +02:00
|
|
|
if (*pPointer != FC_RP)
|
2008-07-04 00:28:02 +02:00
|
|
|
safe_buffer_increment(pStubMsg, 4); /* for pointer ID */
|
2007-06-25 15:28:01 +02:00
|
|
|
}
|
2018-06-13 04:19:10 +02:00
|
|
|
if (*pFormat == FC_POINTER)
|
2010-03-15 22:18:46 +01:00
|
|
|
pPointer += 4;
|
|
|
|
else
|
|
|
|
pFormat += 4;
|
2009-06-19 12:49:35 +02:00
|
|
|
pMemory += sizeof(void *);
|
2003-02-01 01:44:51 +01:00
|
|
|
break;
|
2007-06-25 15:28:01 +02:00
|
|
|
}
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_ALIGNM2:
|
2018-11-19 17:02:00 +01:00
|
|
|
align_pointer_offset_clear(&pMemory, mem_base, 2);
|
2009-08-17 15:35:31 +02:00
|
|
|
break;
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_ALIGNM4:
|
2018-11-19 17:02:00 +01:00
|
|
|
align_pointer_offset_clear(&pMemory, mem_base, 4);
|
2003-02-01 01:44:51 +01:00
|
|
|
break;
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_ALIGNM8:
|
2018-11-19 17:02:00 +01:00
|
|
|
align_pointer_offset_clear(&pMemory, mem_base, 8);
|
2003-02-01 01:44:51 +01:00
|
|
|
break;
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_STRUCTPAD1:
|
|
|
|
case FC_STRUCTPAD2:
|
|
|
|
case FC_STRUCTPAD3:
|
|
|
|
case FC_STRUCTPAD4:
|
|
|
|
case FC_STRUCTPAD5:
|
|
|
|
case FC_STRUCTPAD6:
|
|
|
|
case FC_STRUCTPAD7:
|
|
|
|
memset(pMemory, 0, *pFormat - FC_STRUCTPAD1 + 1);
|
|
|
|
pMemory += *pFormat - FC_STRUCTPAD1 + 1;
|
2005-11-28 11:28:45 +01:00
|
|
|
break;
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_EMBEDDED_COMPLEX:
|
2003-02-01 01:44:51 +01:00
|
|
|
pMemory += pFormat[1];
|
|
|
|
pFormat += 2;
|
2004-11-30 22:38:57 +01:00
|
|
|
desc = pFormat + *(const SHORT*)pFormat;
|
2003-02-17 02:48:24 +01:00
|
|
|
size = EmbeddedComplexSize(pStubMsg, desc);
|
2009-04-21 09:59:45 +02:00
|
|
|
TRACE("embedded complex (size=%d) => %p\n", size, pMemory);
|
2008-07-06 12:55:59 +02:00
|
|
|
if (fMustAlloc)
|
|
|
|
/* we can't pass fMustAlloc=TRUE into the marshaller for this type
|
|
|
|
* since the type is part of the memory block that is encompassed by
|
|
|
|
* the whole complex type. Memory is forced to allocate when pointers
|
|
|
|
* are set to NULL, so we emulate that part of fMustAlloc=TRUE by
|
|
|
|
* clearing the memory we pass in to the unmarshaller */
|
|
|
|
memset(pMemory, 0, size);
|
2003-02-01 01:44:51 +01:00
|
|
|
m = NdrUnmarshaller[*desc & NDR_TABLE_MASK];
|
2007-06-25 15:29:52 +02:00
|
|
|
if (m)
|
|
|
|
{
|
|
|
|
/* for some reason interface pointers aren't generated as
|
2018-06-13 04:19:10 +02:00
|
|
|
* FC_POINTER, but instead as FC_EMBEDDED_COMPLEX, yet
|
2017-07-06 12:22:29 +02:00
|
|
|
* they still need the dereferencing treatment that pointers are
|
2007-06-25 15:29:52 +02:00
|
|
|
* given */
|
2018-06-13 04:19:10 +02:00
|
|
|
if (*desc == FC_IP)
|
2007-06-25 15:29:52 +02:00
|
|
|
m(pStubMsg, (unsigned char **)pMemory, desc, FALSE);
|
|
|
|
else
|
|
|
|
m(pStubMsg, &pMemory, desc, FALSE);
|
|
|
|
}
|
2003-02-01 01:44:51 +01:00
|
|
|
else FIXME("no unmarshaller for embedded type %02x\n", *desc);
|
2003-02-17 02:48:24 +01:00
|
|
|
pMemory += size;
|
2003-02-01 01:44:51 +01:00
|
|
|
pFormat += 2;
|
|
|
|
continue;
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_PAD:
|
2003-02-01 01:44:51 +01:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
FIXME("unhandled format %d\n", *pFormat);
|
|
|
|
}
|
|
|
|
pFormat++;
|
|
|
|
}
|
|
|
|
|
|
|
|
return pMemory;
|
|
|
|
}
|
|
|
|
|
2006-05-17 15:45:30 +02:00
|
|
|
static unsigned char * ComplexBufferSize(PMIDL_STUB_MESSAGE pStubMsg,
|
2003-02-01 01:44:51 +01:00
|
|
|
unsigned char *pMemory,
|
|
|
|
PFORMAT_STRING pFormat,
|
|
|
|
PFORMAT_STRING pPointer)
|
|
|
|
{
|
2018-11-19 17:02:00 +01:00
|
|
|
unsigned char *mem_base = pMemory;
|
2003-02-01 01:44:51 +01:00
|
|
|
PFORMAT_STRING desc;
|
|
|
|
NDR_BUFFERSIZE m;
|
2009-04-21 09:59:45 +02:00
|
|
|
ULONG size;
|
2003-02-01 01:44:51 +01:00
|
|
|
|
2018-06-13 04:19:10 +02:00
|
|
|
while (*pFormat != FC_END) {
|
2003-02-01 01:44:51 +01:00
|
|
|
switch (*pFormat) {
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_BYTE:
|
|
|
|
case FC_CHAR:
|
|
|
|
case FC_SMALL:
|
|
|
|
case FC_USMALL:
|
2007-11-28 16:01:53 +01:00
|
|
|
safe_buffer_length_increment(pStubMsg, 1);
|
2006-06-09 18:24:49 +02:00
|
|
|
pMemory += 1;
|
|
|
|
break;
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_WCHAR:
|
|
|
|
case FC_SHORT:
|
|
|
|
case FC_USHORT:
|
2007-11-28 16:01:53 +01:00
|
|
|
safe_buffer_length_increment(pStubMsg, 2);
|
2003-02-01 01:44:51 +01:00
|
|
|
pMemory += 2;
|
|
|
|
break;
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_ENUM16:
|
2008-03-21 00:05:46 +01:00
|
|
|
safe_buffer_length_increment(pStubMsg, 2);
|
|
|
|
pMemory += 4;
|
|
|
|
break;
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_LONG:
|
|
|
|
case FC_ULONG:
|
|
|
|
case FC_ENUM32:
|
|
|
|
case FC_FLOAT:
|
2007-11-28 16:01:53 +01:00
|
|
|
safe_buffer_length_increment(pStubMsg, 4);
|
2003-02-01 01:44:51 +01:00
|
|
|
pMemory += 4;
|
|
|
|
break;
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_INT3264:
|
|
|
|
case FC_UINT3264:
|
2010-04-07 13:08:46 +02:00
|
|
|
safe_buffer_length_increment(pStubMsg, 4);
|
|
|
|
pMemory += sizeof(INT_PTR);
|
|
|
|
break;
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_HYPER:
|
|
|
|
case FC_DOUBLE:
|
2007-11-28 16:01:53 +01:00
|
|
|
safe_buffer_length_increment(pStubMsg, 8);
|
2006-07-24 12:45:24 +02:00
|
|
|
pMemory += 8;
|
|
|
|
break;
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_RP:
|
|
|
|
case FC_UP:
|
|
|
|
case FC_OP:
|
|
|
|
case FC_FP:
|
|
|
|
case FC_POINTER:
|
|
|
|
if (*pFormat != FC_POINTER)
|
2010-03-15 22:18:46 +01:00
|
|
|
pPointer = pFormat;
|
2007-06-25 15:28:01 +02:00
|
|
|
if (!pStubMsg->IgnoreEmbeddedPointers)
|
|
|
|
{
|
|
|
|
int saved_buffer_length = pStubMsg->BufferLength;
|
|
|
|
pStubMsg->BufferLength = pStubMsg->PointerLength;
|
|
|
|
pStubMsg->PointerLength = 0;
|
|
|
|
if(!pStubMsg->BufferLength)
|
|
|
|
ERR("BufferLength == 0??\n");
|
|
|
|
PointerBufferSize(pStubMsg, *(unsigned char**)pMemory, pPointer);
|
|
|
|
pStubMsg->PointerLength = pStubMsg->BufferLength;
|
|
|
|
pStubMsg->BufferLength = saved_buffer_length;
|
|
|
|
}
|
2018-06-13 04:19:10 +02:00
|
|
|
if (*pPointer != FC_RP)
|
2008-07-04 00:28:02 +02:00
|
|
|
{
|
2010-04-02 21:54:55 +02:00
|
|
|
align_length(&pStubMsg->BufferLength, 4);
|
2008-07-04 00:28:02 +02:00
|
|
|
safe_buffer_length_increment(pStubMsg, 4);
|
|
|
|
}
|
2018-06-13 04:19:10 +02:00
|
|
|
if (*pFormat == FC_POINTER)
|
2010-03-15 22:18:46 +01:00
|
|
|
pPointer += 4;
|
|
|
|
else
|
|
|
|
pFormat += 4;
|
2009-06-19 12:49:35 +02:00
|
|
|
pMemory += sizeof(void*);
|
2003-02-01 01:44:51 +01:00
|
|
|
break;
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_ALIGNM2:
|
2018-11-19 17:02:00 +01:00
|
|
|
align_pointer_offset(&pMemory, mem_base, 2);
|
2009-08-17 15:35:31 +02:00
|
|
|
break;
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_ALIGNM4:
|
2018-11-19 17:02:00 +01:00
|
|
|
align_pointer_offset(&pMemory, mem_base, 4);
|
2003-02-01 01:44:51 +01:00
|
|
|
break;
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_ALIGNM8:
|
2018-11-19 17:02:00 +01:00
|
|
|
align_pointer_offset(&pMemory, mem_base, 8);
|
2003-02-01 01:44:51 +01:00
|
|
|
break;
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_STRUCTPAD1:
|
|
|
|
case FC_STRUCTPAD2:
|
|
|
|
case FC_STRUCTPAD3:
|
|
|
|
case FC_STRUCTPAD4:
|
|
|
|
case FC_STRUCTPAD5:
|
|
|
|
case FC_STRUCTPAD6:
|
|
|
|
case FC_STRUCTPAD7:
|
|
|
|
pMemory += *pFormat - FC_STRUCTPAD1 + 1;
|
2005-11-28 11:28:45 +01:00
|
|
|
break;
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_EMBEDDED_COMPLEX:
|
2003-02-01 01:44:51 +01:00
|
|
|
pMemory += pFormat[1];
|
|
|
|
pFormat += 2;
|
2004-11-30 22:38:57 +01:00
|
|
|
desc = pFormat + *(const SHORT*)pFormat;
|
2003-02-17 02:48:24 +01:00
|
|
|
size = EmbeddedComplexSize(pStubMsg, desc);
|
2003-02-01 01:44:51 +01:00
|
|
|
m = NdrBufferSizer[*desc & NDR_TABLE_MASK];
|
2007-06-25 15:29:52 +02:00
|
|
|
if (m)
|
|
|
|
{
|
|
|
|
/* for some reason interface pointers aren't generated as
|
2018-06-13 04:19:10 +02:00
|
|
|
* FC_POINTER, but instead as FC_EMBEDDED_COMPLEX, yet
|
2017-07-06 12:22:29 +02:00
|
|
|
* they still need the dereferencing treatment that pointers are
|
2007-06-25 15:29:52 +02:00
|
|
|
* given */
|
2018-06-13 04:19:10 +02:00
|
|
|
if (*desc == FC_IP)
|
2007-06-25 15:29:52 +02:00
|
|
|
m(pStubMsg, *(unsigned char **)pMemory, desc);
|
|
|
|
else
|
|
|
|
m(pStubMsg, pMemory, desc);
|
|
|
|
}
|
2003-02-01 01:44:51 +01:00
|
|
|
else FIXME("no buffersizer for embedded type %02x\n", *desc);
|
2003-02-17 02:48:24 +01:00
|
|
|
pMemory += size;
|
2003-02-01 01:44:51 +01:00
|
|
|
pFormat += 2;
|
|
|
|
continue;
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_PAD:
|
2003-02-01 01:44:51 +01:00
|
|
|
break;
|
|
|
|
default:
|
2006-07-24 12:45:24 +02:00
|
|
|
FIXME("unhandled format 0x%02x\n", *pFormat);
|
2003-02-01 01:44:51 +01:00
|
|
|
}
|
|
|
|
pFormat++;
|
|
|
|
}
|
|
|
|
|
|
|
|
return pMemory;
|
|
|
|
}
|
|
|
|
|
2006-05-17 15:45:30 +02:00
|
|
|
static unsigned char * ComplexFree(PMIDL_STUB_MESSAGE pStubMsg,
|
2003-02-01 01:44:51 +01:00
|
|
|
unsigned char *pMemory,
|
|
|
|
PFORMAT_STRING pFormat,
|
|
|
|
PFORMAT_STRING pPointer)
|
|
|
|
{
|
2018-11-19 17:02:00 +01:00
|
|
|
unsigned char *mem_base = pMemory;
|
2003-02-01 01:44:51 +01:00
|
|
|
PFORMAT_STRING desc;
|
|
|
|
NDR_FREE m;
|
2009-04-21 09:59:45 +02:00
|
|
|
ULONG size;
|
2003-02-01 01:44:51 +01:00
|
|
|
|
2018-06-13 04:19:10 +02:00
|
|
|
while (*pFormat != FC_END) {
|
2003-02-01 01:44:51 +01:00
|
|
|
switch (*pFormat) {
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_BYTE:
|
|
|
|
case FC_CHAR:
|
|
|
|
case FC_SMALL:
|
|
|
|
case FC_USMALL:
|
2006-06-09 18:24:49 +02:00
|
|
|
pMemory += 1;
|
|
|
|
break;
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_WCHAR:
|
|
|
|
case FC_SHORT:
|
|
|
|
case FC_USHORT:
|
2003-02-01 01:44:51 +01:00
|
|
|
pMemory += 2;
|
|
|
|
break;
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_LONG:
|
|
|
|
case FC_ULONG:
|
|
|
|
case FC_ENUM16:
|
|
|
|
case FC_ENUM32:
|
|
|
|
case FC_FLOAT:
|
2003-02-01 01:44:51 +01:00
|
|
|
pMemory += 4;
|
|
|
|
break;
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_INT3264:
|
|
|
|
case FC_UINT3264:
|
2010-04-07 13:08:46 +02:00
|
|
|
pMemory += sizeof(INT_PTR);
|
|
|
|
break;
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_HYPER:
|
|
|
|
case FC_DOUBLE:
|
2006-07-24 12:45:24 +02:00
|
|
|
pMemory += 8;
|
|
|
|
break;
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_RP:
|
|
|
|
case FC_UP:
|
|
|
|
case FC_OP:
|
|
|
|
case FC_FP:
|
|
|
|
case FC_POINTER:
|
|
|
|
if (*pFormat != FC_POINTER)
|
2010-03-15 22:18:46 +01:00
|
|
|
pPointer = pFormat;
|
2003-02-17 02:48:24 +01:00
|
|
|
NdrPointerFree(pStubMsg, *(unsigned char**)pMemory, pPointer);
|
2018-06-13 04:19:10 +02:00
|
|
|
if (*pFormat == FC_POINTER)
|
2010-03-15 22:18:46 +01:00
|
|
|
pPointer += 4;
|
|
|
|
else
|
|
|
|
pFormat += 4;
|
2009-06-19 12:49:35 +02:00
|
|
|
pMemory += sizeof(void *);
|
2003-02-01 01:44:51 +01:00
|
|
|
break;
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_ALIGNM2:
|
2018-11-19 17:02:00 +01:00
|
|
|
align_pointer_offset(&pMemory, mem_base, 2);
|
2009-08-17 15:35:31 +02:00
|
|
|
break;
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_ALIGNM4:
|
2018-11-19 17:02:00 +01:00
|
|
|
align_pointer_offset(&pMemory, mem_base, 4);
|
2003-02-01 01:44:51 +01:00
|
|
|
break;
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_ALIGNM8:
|
2018-11-19 17:02:00 +01:00
|
|
|
align_pointer_offset(&pMemory, mem_base, 8);
|
2003-02-01 01:44:51 +01:00
|
|
|
break;
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_STRUCTPAD1:
|
|
|
|
case FC_STRUCTPAD2:
|
|
|
|
case FC_STRUCTPAD3:
|
|
|
|
case FC_STRUCTPAD4:
|
|
|
|
case FC_STRUCTPAD5:
|
|
|
|
case FC_STRUCTPAD6:
|
|
|
|
case FC_STRUCTPAD7:
|
|
|
|
pMemory += *pFormat - FC_STRUCTPAD1 + 1;
|
2005-11-28 11:28:45 +01:00
|
|
|
break;
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_EMBEDDED_COMPLEX:
|
2003-02-01 01:44:51 +01:00
|
|
|
pMemory += pFormat[1];
|
|
|
|
pFormat += 2;
|
2004-11-30 22:38:57 +01:00
|
|
|
desc = pFormat + *(const SHORT*)pFormat;
|
2003-02-17 02:48:24 +01:00
|
|
|
size = EmbeddedComplexSize(pStubMsg, desc);
|
2003-02-01 01:44:51 +01:00
|
|
|
m = NdrFreer[*desc & NDR_TABLE_MASK];
|
2007-06-25 15:29:52 +02:00
|
|
|
if (m)
|
|
|
|
{
|
|
|
|
/* for some reason interface pointers aren't generated as
|
2018-06-13 04:19:10 +02:00
|
|
|
* FC_POINTER, but instead as FC_EMBEDDED_COMPLEX, yet
|
2017-07-06 12:22:29 +02:00
|
|
|
* they still need the dereferencing treatment that pointers are
|
2007-06-25 15:29:52 +02:00
|
|
|
* given */
|
2018-06-13 04:19:10 +02:00
|
|
|
if (*desc == FC_IP)
|
2007-06-25 15:29:52 +02:00
|
|
|
m(pStubMsg, *(unsigned char **)pMemory, desc);
|
|
|
|
else
|
|
|
|
m(pStubMsg, pMemory, desc);
|
|
|
|
}
|
2003-02-17 02:48:24 +01:00
|
|
|
pMemory += size;
|
2003-02-01 01:44:51 +01:00
|
|
|
pFormat += 2;
|
|
|
|
continue;
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_PAD:
|
2003-02-01 01:44:51 +01:00
|
|
|
break;
|
|
|
|
default:
|
2006-07-24 12:45:24 +02:00
|
|
|
FIXME("unhandled format 0x%02x\n", *pFormat);
|
2003-02-01 01:44:51 +01:00
|
|
|
}
|
|
|
|
pFormat++;
|
|
|
|
}
|
|
|
|
|
|
|
|
return pMemory;
|
|
|
|
}
|
|
|
|
|
2009-04-21 09:59:45 +02:00
|
|
|
static ULONG ComplexStructMemorySize(PMIDL_STUB_MESSAGE pStubMsg,
|
|
|
|
PFORMAT_STRING pFormat,
|
|
|
|
PFORMAT_STRING pPointer)
|
2003-02-01 01:44:51 +01:00
|
|
|
{
|
|
|
|
PFORMAT_STRING desc;
|
2009-04-21 09:59:45 +02:00
|
|
|
ULONG size = 0;
|
2003-02-01 01:44:51 +01:00
|
|
|
|
2018-06-13 04:19:10 +02:00
|
|
|
while (*pFormat != FC_END) {
|
2003-02-01 01:44:51 +01:00
|
|
|
switch (*pFormat) {
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_BYTE:
|
|
|
|
case FC_CHAR:
|
|
|
|
case FC_SMALL:
|
|
|
|
case FC_USMALL:
|
2006-06-09 18:24:49 +02:00
|
|
|
size += 1;
|
2007-11-28 16:02:21 +01:00
|
|
|
safe_buffer_increment(pStubMsg, 1);
|
2006-06-09 18:24:49 +02:00
|
|
|
break;
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_WCHAR:
|
|
|
|
case FC_SHORT:
|
|
|
|
case FC_USHORT:
|
2003-02-01 01:44:51 +01:00
|
|
|
size += 2;
|
2007-11-28 16:02:21 +01:00
|
|
|
safe_buffer_increment(pStubMsg, 2);
|
2003-02-01 01:44:51 +01:00
|
|
|
break;
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_ENUM16:
|
2008-03-21 00:05:46 +01:00
|
|
|
size += 4;
|
|
|
|
safe_buffer_increment(pStubMsg, 2);
|
|
|
|
break;
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_LONG:
|
|
|
|
case FC_ULONG:
|
|
|
|
case FC_ENUM32:
|
|
|
|
case FC_FLOAT:
|
2003-02-01 01:44:51 +01:00
|
|
|
size += 4;
|
2007-11-28 16:02:21 +01:00
|
|
|
safe_buffer_increment(pStubMsg, 4);
|
2003-02-01 01:44:51 +01:00
|
|
|
break;
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_INT3264:
|
|
|
|
case FC_UINT3264:
|
2010-04-07 13:08:46 +02:00
|
|
|
size += sizeof(INT_PTR);
|
|
|
|
safe_buffer_increment(pStubMsg, 4);
|
|
|
|
break;
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_HYPER:
|
|
|
|
case FC_DOUBLE:
|
2006-07-24 12:45:24 +02:00
|
|
|
size += 8;
|
2007-11-28 16:02:21 +01:00
|
|
|
safe_buffer_increment(pStubMsg, 8);
|
2006-07-24 12:45:24 +02:00
|
|
|
break;
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_RP:
|
|
|
|
case FC_UP:
|
|
|
|
case FC_OP:
|
|
|
|
case FC_FP:
|
|
|
|
case FC_POINTER:
|
2008-07-04 00:27:14 +02:00
|
|
|
{
|
|
|
|
unsigned char *saved_buffer;
|
2013-12-03 00:02:50 +01:00
|
|
|
BOOL pointer_buffer_mark_set = FALSE;
|
2018-06-13 04:19:10 +02:00
|
|
|
if (*pFormat != FC_POINTER)
|
2010-03-15 22:18:46 +01:00
|
|
|
pPointer = pFormat;
|
2018-06-13 04:19:10 +02:00
|
|
|
if (*pPointer != FC_RP)
|
2010-04-02 21:54:55 +02:00
|
|
|
align_pointer(&pStubMsg->Buffer, 4);
|
2008-07-04 00:27:14 +02:00
|
|
|
saved_buffer = pStubMsg->Buffer;
|
|
|
|
if (pStubMsg->PointerBufferMark)
|
|
|
|
{
|
|
|
|
pStubMsg->Buffer = pStubMsg->PointerBufferMark;
|
|
|
|
pStubMsg->PointerBufferMark = NULL;
|
2013-12-03 00:02:50 +01:00
|
|
|
pointer_buffer_mark_set = TRUE;
|
2008-07-04 00:27:14 +02:00
|
|
|
}
|
2018-06-13 04:19:10 +02:00
|
|
|
else if (*pPointer != FC_RP)
|
2008-07-04 00:27:14 +02:00
|
|
|
safe_buffer_increment(pStubMsg, 4); /* for pointer ID */
|
|
|
|
|
2007-06-25 15:28:01 +02:00
|
|
|
if (!pStubMsg->IgnoreEmbeddedPointers)
|
2008-07-04 00:27:14 +02:00
|
|
|
PointerMemorySize(pStubMsg, saved_buffer, pPointer);
|
|
|
|
if (pointer_buffer_mark_set)
|
|
|
|
{
|
|
|
|
STD_OVERFLOW_CHECK(pStubMsg);
|
|
|
|
pStubMsg->PointerBufferMark = pStubMsg->Buffer;
|
2008-07-04 00:28:02 +02:00
|
|
|
pStubMsg->Buffer = saved_buffer;
|
2018-06-13 04:19:10 +02:00
|
|
|
if (*pPointer != FC_RP)
|
2008-07-04 00:28:02 +02:00
|
|
|
safe_buffer_increment(pStubMsg, 4); /* for pointer ID */
|
2008-07-04 00:27:14 +02:00
|
|
|
}
|
2018-06-13 04:19:10 +02:00
|
|
|
if (*pFormat == FC_POINTER)
|
2010-03-15 22:18:46 +01:00
|
|
|
pPointer += 4;
|
|
|
|
else
|
|
|
|
pFormat += 4;
|
2009-06-19 12:49:35 +02:00
|
|
|
size += sizeof(void *);
|
2003-02-01 01:44:51 +01:00
|
|
|
break;
|
2008-07-04 00:27:14 +02:00
|
|
|
}
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_ALIGNM2:
|
2010-04-02 21:54:55 +02:00
|
|
|
align_length(&size, 2);
|
2009-08-17 15:35:31 +02:00
|
|
|
break;
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_ALIGNM4:
|
2010-04-02 21:54:55 +02:00
|
|
|
align_length(&size, 4);
|
2003-02-01 01:44:51 +01:00
|
|
|
break;
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_ALIGNM8:
|
2010-04-02 21:54:55 +02:00
|
|
|
align_length(&size, 8);
|
2003-02-01 01:44:51 +01:00
|
|
|
break;
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_STRUCTPAD1:
|
|
|
|
case FC_STRUCTPAD2:
|
|
|
|
case FC_STRUCTPAD3:
|
|
|
|
case FC_STRUCTPAD4:
|
|
|
|
case FC_STRUCTPAD5:
|
|
|
|
case FC_STRUCTPAD6:
|
|
|
|
case FC_STRUCTPAD7:
|
|
|
|
size += *pFormat - FC_STRUCTPAD1 + 1;
|
2005-11-28 11:28:45 +01:00
|
|
|
break;
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_EMBEDDED_COMPLEX:
|
2003-02-01 01:44:51 +01:00
|
|
|
size += pFormat[1];
|
|
|
|
pFormat += 2;
|
2004-11-30 22:38:57 +01:00
|
|
|
desc = pFormat + *(const SHORT*)pFormat;
|
2006-05-15 14:35:07 +02:00
|
|
|
size += EmbeddedComplexMemorySize(pStubMsg, desc);
|
2003-02-01 01:44:51 +01:00
|
|
|
pFormat += 2;
|
|
|
|
continue;
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_PAD:
|
2003-02-01 01:44:51 +01:00
|
|
|
break;
|
|
|
|
default:
|
2006-07-24 12:45:24 +02:00
|
|
|
FIXME("unhandled format 0x%02x\n", *pFormat);
|
2003-02-01 01:44:51 +01:00
|
|
|
}
|
|
|
|
pFormat++;
|
|
|
|
}
|
|
|
|
|
|
|
|
return size;
|
|
|
|
}
|
|
|
|
|
2009-04-21 09:59:45 +02:00
|
|
|
ULONG ComplexStructSize(PMIDL_STUB_MESSAGE pStubMsg, PFORMAT_STRING pFormat)
|
2008-01-14 12:54:12 +01:00
|
|
|
{
|
|
|
|
PFORMAT_STRING desc;
|
2009-04-21 09:59:45 +02:00
|
|
|
ULONG size = 0;
|
2008-01-14 12:54:12 +01:00
|
|
|
|
2018-06-13 04:19:10 +02:00
|
|
|
while (*pFormat != FC_END) {
|
2008-01-14 12:54:12 +01:00
|
|
|
switch (*pFormat) {
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_BYTE:
|
|
|
|
case FC_CHAR:
|
|
|
|
case FC_SMALL:
|
|
|
|
case FC_USMALL:
|
2008-01-14 12:54:12 +01:00
|
|
|
size += 1;
|
|
|
|
break;
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_WCHAR:
|
|
|
|
case FC_SHORT:
|
|
|
|
case FC_USHORT:
|
2008-01-14 12:54:12 +01:00
|
|
|
size += 2;
|
|
|
|
break;
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_LONG:
|
|
|
|
case FC_ULONG:
|
|
|
|
case FC_ENUM16:
|
|
|
|
case FC_ENUM32:
|
|
|
|
case FC_FLOAT:
|
2008-01-14 12:54:12 +01:00
|
|
|
size += 4;
|
|
|
|
break;
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_INT3264:
|
|
|
|
case FC_UINT3264:
|
2010-04-07 13:08:46 +02:00
|
|
|
size += sizeof(INT_PTR);
|
|
|
|
break;
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_HYPER:
|
|
|
|
case FC_DOUBLE:
|
2008-01-14 12:54:12 +01:00
|
|
|
size += 8;
|
|
|
|
break;
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_RP:
|
|
|
|
case FC_UP:
|
|
|
|
case FC_OP:
|
|
|
|
case FC_FP:
|
|
|
|
case FC_POINTER:
|
2008-01-14 12:54:12 +01:00
|
|
|
size += sizeof(void *);
|
2018-06-13 04:19:10 +02:00
|
|
|
if (*pFormat != FC_POINTER)
|
2010-03-15 22:18:46 +01:00
|
|
|
pFormat += 4;
|
2008-01-14 12:54:12 +01:00
|
|
|
break;
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_ALIGNM2:
|
2010-04-02 21:54:55 +02:00
|
|
|
align_length(&size, 2);
|
2009-08-17 15:35:31 +02:00
|
|
|
break;
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_ALIGNM4:
|
2010-04-02 21:54:55 +02:00
|
|
|
align_length(&size, 4);
|
2008-01-14 12:54:12 +01:00
|
|
|
break;
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_ALIGNM8:
|
2010-04-02 21:54:55 +02:00
|
|
|
align_length(&size, 8);
|
2008-01-14 12:54:12 +01:00
|
|
|
break;
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_STRUCTPAD1:
|
|
|
|
case FC_STRUCTPAD2:
|
|
|
|
case FC_STRUCTPAD3:
|
|
|
|
case FC_STRUCTPAD4:
|
|
|
|
case FC_STRUCTPAD5:
|
|
|
|
case FC_STRUCTPAD6:
|
|
|
|
case FC_STRUCTPAD7:
|
|
|
|
size += *pFormat - FC_STRUCTPAD1 + 1;
|
2008-01-14 12:54:12 +01:00
|
|
|
break;
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_EMBEDDED_COMPLEX:
|
2008-01-14 12:54:12 +01:00
|
|
|
size += pFormat[1];
|
|
|
|
pFormat += 2;
|
|
|
|
desc = pFormat + *(const SHORT*)pFormat;
|
|
|
|
size += EmbeddedComplexSize(pStubMsg, desc);
|
|
|
|
pFormat += 2;
|
|
|
|
continue;
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_PAD:
|
2008-01-14 12:54:12 +01:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
FIXME("unhandled format 0x%02x\n", *pFormat);
|
|
|
|
}
|
|
|
|
pFormat++;
|
|
|
|
}
|
|
|
|
|
|
|
|
return size;
|
|
|
|
}
|
|
|
|
|
2003-02-01 01:44:51 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* NdrComplexStructMarshall [RPCRT4.@]
|
|
|
|
*/
|
|
|
|
unsigned char * WINAPI NdrComplexStructMarshall(PMIDL_STUB_MESSAGE pStubMsg,
|
|
|
|
unsigned char *pMemory,
|
|
|
|
PFORMAT_STRING pFormat)
|
|
|
|
{
|
|
|
|
PFORMAT_STRING conf_array = NULL;
|
|
|
|
PFORMAT_STRING pointer_desc = NULL;
|
|
|
|
unsigned char *OldMemory = pStubMsg->Memory;
|
2013-12-03 00:02:50 +01:00
|
|
|
BOOL pointer_buffer_mark_set = FALSE;
|
2008-08-10 12:14:07 +02:00
|
|
|
ULONG count = 0;
|
|
|
|
ULONG max_count = 0;
|
|
|
|
ULONG offset = 0;
|
2003-02-01 01:44:51 +01:00
|
|
|
|
|
|
|
TRACE("(%p,%p,%p)\n", pStubMsg, pMemory, pFormat);
|
|
|
|
|
2007-06-25 15:28:01 +02:00
|
|
|
if (!pStubMsg->PointerBufferMark)
|
|
|
|
{
|
|
|
|
int saved_ignore_embedded = pStubMsg->IgnoreEmbeddedPointers;
|
|
|
|
/* save buffer length */
|
2009-04-21 09:59:45 +02:00
|
|
|
ULONG saved_buffer_length = pStubMsg->BufferLength;
|
2007-06-25 15:28:01 +02:00
|
|
|
|
|
|
|
/* get the buffer pointer after complex array data, but before
|
|
|
|
* pointer data */
|
2009-03-12 11:51:35 +01:00
|
|
|
pStubMsg->BufferLength = pStubMsg->Buffer - (unsigned char *)pStubMsg->RpcMsg->Buffer;
|
2007-06-25 15:28:01 +02:00
|
|
|
pStubMsg->IgnoreEmbeddedPointers = 1;
|
|
|
|
NdrComplexStructBufferSize(pStubMsg, pMemory, pFormat);
|
|
|
|
pStubMsg->IgnoreEmbeddedPointers = saved_ignore_embedded;
|
|
|
|
|
|
|
|
/* save it for use by embedded pointer code later */
|
2009-03-12 11:51:35 +01:00
|
|
|
pStubMsg->PointerBufferMark = (unsigned char *)pStubMsg->RpcMsg->Buffer + pStubMsg->BufferLength;
|
2009-05-28 11:56:30 +02:00
|
|
|
TRACE("difference = 0x%x\n", (ULONG)(pStubMsg->PointerBufferMark - pStubMsg->Buffer));
|
2013-12-03 00:02:50 +01:00
|
|
|
pointer_buffer_mark_set = TRUE;
|
2007-06-25 15:28:01 +02:00
|
|
|
|
|
|
|
/* restore the original buffer length */
|
|
|
|
pStubMsg->BufferLength = saved_buffer_length;
|
|
|
|
}
|
|
|
|
|
2010-04-02 21:54:55 +02:00
|
|
|
align_pointer_clear(&pStubMsg->Buffer, pFormat[1] + 1);
|
2006-05-10 14:12:30 +02:00
|
|
|
|
2003-02-01 01:44:51 +01:00
|
|
|
pFormat += 4;
|
2008-07-04 00:27:00 +02:00
|
|
|
if (*(const SHORT*)pFormat) conf_array = pFormat + *(const SHORT*)pFormat;
|
2003-02-01 01:44:51 +01:00
|
|
|
pFormat += 2;
|
2004-11-30 22:38:57 +01:00
|
|
|
if (*(const WORD*)pFormat) pointer_desc = pFormat + *(const WORD*)pFormat;
|
2003-02-01 01:44:51 +01:00
|
|
|
pFormat += 2;
|
|
|
|
|
|
|
|
pStubMsg->Memory = pMemory;
|
|
|
|
|
2008-08-10 12:14:07 +02:00
|
|
|
if (conf_array)
|
|
|
|
{
|
2009-04-21 09:59:45 +02:00
|
|
|
ULONG struct_size = ComplexStructSize(pStubMsg, pFormat);
|
2008-08-10 12:14:07 +02:00
|
|
|
array_compute_and_write_conformance(conf_array[0], pStubMsg,
|
|
|
|
pMemory + struct_size, conf_array);
|
|
|
|
/* these could be changed in ComplexMarshall so save them for later */
|
|
|
|
max_count = pStubMsg->MaxCount;
|
|
|
|
count = pStubMsg->ActualCount;
|
|
|
|
offset = pStubMsg->Offset;
|
|
|
|
}
|
|
|
|
|
2008-07-16 00:35:40 +02:00
|
|
|
pMemory = ComplexMarshall(pStubMsg, pMemory, pFormat, pointer_desc);
|
2003-02-01 01:44:51 +01:00
|
|
|
|
|
|
|
if (conf_array)
|
2008-08-10 12:14:07 +02:00
|
|
|
{
|
|
|
|
pStubMsg->MaxCount = max_count;
|
|
|
|
pStubMsg->ActualCount = count;
|
|
|
|
pStubMsg->Offset = offset;
|
|
|
|
array_write_variance_and_marshall(conf_array[0], pStubMsg, pMemory,
|
2008-08-10 12:14:30 +02:00
|
|
|
conf_array, TRUE /* fHasPointers */);
|
2008-08-10 12:14:07 +02:00
|
|
|
}
|
2003-02-01 01:44:51 +01:00
|
|
|
|
|
|
|
pStubMsg->Memory = OldMemory;
|
|
|
|
|
2007-06-25 15:28:01 +02:00
|
|
|
if (pointer_buffer_mark_set)
|
|
|
|
{
|
|
|
|
pStubMsg->Buffer = pStubMsg->PointerBufferMark;
|
|
|
|
pStubMsg->PointerBufferMark = NULL;
|
|
|
|
}
|
|
|
|
|
2003-02-17 02:48:24 +01:00
|
|
|
STD_OVERFLOW_CHECK(pStubMsg);
|
|
|
|
|
2003-02-01 01:44:51 +01:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* NdrComplexStructUnmarshall [RPCRT4.@]
|
|
|
|
*/
|
|
|
|
unsigned char * WINAPI NdrComplexStructUnmarshall(PMIDL_STUB_MESSAGE pStubMsg,
|
|
|
|
unsigned char **ppMemory,
|
|
|
|
PFORMAT_STRING pFormat,
|
|
|
|
unsigned char fMustAlloc)
|
|
|
|
{
|
2004-11-30 22:38:57 +01:00
|
|
|
unsigned size = *(const WORD*)(pFormat+2);
|
2003-02-01 01:44:51 +01:00
|
|
|
PFORMAT_STRING conf_array = NULL;
|
|
|
|
PFORMAT_STRING pointer_desc = NULL;
|
|
|
|
unsigned char *pMemory;
|
2013-12-03 00:02:50 +01:00
|
|
|
BOOL pointer_buffer_mark_set = FALSE;
|
2008-08-10 12:14:07 +02:00
|
|
|
ULONG count = 0;
|
|
|
|
ULONG max_count = 0;
|
|
|
|
ULONG offset = 0;
|
|
|
|
ULONG array_size = 0;
|
2003-02-01 01:44:51 +01:00
|
|
|
|
|
|
|
TRACE("(%p,%p,%p,%d)\n", pStubMsg, ppMemory, pFormat, fMustAlloc);
|
|
|
|
|
2007-06-25 15:28:01 +02:00
|
|
|
if (!pStubMsg->PointerBufferMark)
|
|
|
|
{
|
|
|
|
int saved_ignore_embedded = pStubMsg->IgnoreEmbeddedPointers;
|
|
|
|
/* save buffer pointer */
|
|
|
|
unsigned char *saved_buffer = pStubMsg->Buffer;
|
|
|
|
|
|
|
|
/* get the buffer pointer after complex array data, but before
|
|
|
|
* pointer data */
|
|
|
|
pStubMsg->IgnoreEmbeddedPointers = 1;
|
|
|
|
NdrComplexStructMemorySize(pStubMsg, pFormat);
|
|
|
|
pStubMsg->IgnoreEmbeddedPointers = saved_ignore_embedded;
|
|
|
|
|
|
|
|
/* save it for use by embedded pointer code later */
|
|
|
|
pStubMsg->PointerBufferMark = pStubMsg->Buffer;
|
2009-05-28 11:56:30 +02:00
|
|
|
TRACE("difference = 0x%x\n", (ULONG)(pStubMsg->PointerBufferMark - saved_buffer));
|
2013-12-03 00:02:50 +01:00
|
|
|
pointer_buffer_mark_set = TRUE;
|
2007-06-25 15:28:01 +02:00
|
|
|
|
|
|
|
/* restore the original buffer */
|
|
|
|
pStubMsg->Buffer = saved_buffer;
|
|
|
|
}
|
|
|
|
|
2010-04-02 21:54:55 +02:00
|
|
|
align_pointer(&pStubMsg->Buffer, pFormat[1] + 1);
|
2006-05-10 14:12:30 +02:00
|
|
|
|
2003-02-01 01:44:51 +01:00
|
|
|
pFormat += 4;
|
2008-07-04 00:27:00 +02:00
|
|
|
if (*(const SHORT*)pFormat) conf_array = pFormat + *(const SHORT*)pFormat;
|
2003-02-01 01:44:51 +01:00
|
|
|
pFormat += 2;
|
2004-11-30 22:38:57 +01:00
|
|
|
if (*(const WORD*)pFormat) pointer_desc = pFormat + *(const WORD*)pFormat;
|
2003-02-01 01:44:51 +01:00
|
|
|
pFormat += 2;
|
|
|
|
|
2008-08-10 12:14:07 +02:00
|
|
|
if (conf_array)
|
|
|
|
{
|
|
|
|
array_size = array_read_conformance(conf_array[0], pStubMsg, conf_array);
|
|
|
|
size += array_size;
|
|
|
|
|
|
|
|
/* these could be changed in ComplexMarshall so save them for later */
|
|
|
|
max_count = pStubMsg->MaxCount;
|
|
|
|
count = pStubMsg->ActualCount;
|
|
|
|
offset = pStubMsg->Offset;
|
|
|
|
}
|
|
|
|
|
2009-01-10 23:17:15 +01:00
|
|
|
if (!fMustAlloc && !*ppMemory)
|
|
|
|
fMustAlloc = TRUE;
|
|
|
|
if (fMustAlloc)
|
2018-10-28 23:25:47 +01:00
|
|
|
*ppMemory = NdrAllocateZero(pStubMsg, size);
|
2008-08-10 12:14:07 +02:00
|
|
|
|
2008-06-26 09:50:53 +02:00
|
|
|
pMemory = ComplexUnmarshall(pStubMsg, *ppMemory, pFormat, pointer_desc, fMustAlloc);
|
2003-02-01 01:44:51 +01:00
|
|
|
|
|
|
|
if (conf_array)
|
2008-08-10 12:14:07 +02:00
|
|
|
{
|
|
|
|
pStubMsg->MaxCount = max_count;
|
|
|
|
pStubMsg->ActualCount = count;
|
|
|
|
pStubMsg->Offset = offset;
|
|
|
|
if (fMustAlloc)
|
|
|
|
memset(pMemory, 0, array_size);
|
|
|
|
array_read_variance_and_unmarshall(conf_array[0], pStubMsg, &pMemory,
|
|
|
|
conf_array, FALSE,
|
2008-08-10 12:14:30 +02:00
|
|
|
FALSE /* fUseBufferMemoryServer */,
|
|
|
|
TRUE /* fUnmarshall */);
|
2008-08-10 12:14:07 +02:00
|
|
|
}
|
2003-02-01 01:44:51 +01:00
|
|
|
|
2007-06-25 15:28:01 +02:00
|
|
|
if (pointer_buffer_mark_set)
|
|
|
|
{
|
|
|
|
pStubMsg->Buffer = pStubMsg->PointerBufferMark;
|
|
|
|
pStubMsg->PointerBufferMark = NULL;
|
|
|
|
}
|
|
|
|
|
2003-02-01 01:44:51 +01:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* NdrComplexStructBufferSize [RPCRT4.@]
|
|
|
|
*/
|
|
|
|
void WINAPI NdrComplexStructBufferSize(PMIDL_STUB_MESSAGE pStubMsg,
|
|
|
|
unsigned char *pMemory,
|
|
|
|
PFORMAT_STRING pFormat)
|
|
|
|
{
|
|
|
|
PFORMAT_STRING conf_array = NULL;
|
|
|
|
PFORMAT_STRING pointer_desc = NULL;
|
|
|
|
unsigned char *OldMemory = pStubMsg->Memory;
|
2007-06-25 15:28:01 +02:00
|
|
|
int pointer_length_set = 0;
|
2008-08-10 12:14:07 +02:00
|
|
|
ULONG count = 0;
|
|
|
|
ULONG max_count = 0;
|
|
|
|
ULONG offset = 0;
|
2003-02-01 01:44:51 +01:00
|
|
|
|
|
|
|
TRACE("(%p,%p,%p)\n", pStubMsg, pMemory, pFormat);
|
|
|
|
|
2010-04-02 21:54:55 +02:00
|
|
|
align_length(&pStubMsg->BufferLength, pFormat[1] + 1);
|
2006-05-10 14:12:30 +02:00
|
|
|
|
2007-06-25 15:28:01 +02:00
|
|
|
if(!pStubMsg->IgnoreEmbeddedPointers && !pStubMsg->PointerLength)
|
|
|
|
{
|
|
|
|
int saved_ignore_embedded = pStubMsg->IgnoreEmbeddedPointers;
|
2009-04-21 09:59:45 +02:00
|
|
|
ULONG saved_buffer_length = pStubMsg->BufferLength;
|
2007-06-25 15:28:01 +02:00
|
|
|
|
|
|
|
/* get the buffer length after complex struct data, but before
|
|
|
|
* pointer data */
|
|
|
|
pStubMsg->IgnoreEmbeddedPointers = 1;
|
|
|
|
NdrComplexStructBufferSize(pStubMsg, pMemory, pFormat);
|
|
|
|
pStubMsg->IgnoreEmbeddedPointers = saved_ignore_embedded;
|
|
|
|
|
|
|
|
/* save it for use by embedded pointer code later */
|
|
|
|
pStubMsg->PointerLength = pStubMsg->BufferLength;
|
|
|
|
pointer_length_set = 1;
|
2009-04-21 09:59:45 +02:00
|
|
|
TRACE("difference = 0x%x\n", pStubMsg->PointerLength - saved_buffer_length);
|
2007-06-25 15:28:01 +02:00
|
|
|
|
|
|
|
/* restore the original buffer length */
|
|
|
|
pStubMsg->BufferLength = saved_buffer_length;
|
|
|
|
}
|
|
|
|
|
2003-02-01 01:44:51 +01:00
|
|
|
pFormat += 4;
|
2008-07-04 00:27:00 +02:00
|
|
|
if (*(const SHORT*)pFormat) conf_array = pFormat + *(const SHORT*)pFormat;
|
2003-02-01 01:44:51 +01:00
|
|
|
pFormat += 2;
|
2004-11-30 22:38:57 +01:00
|
|
|
if (*(const WORD*)pFormat) pointer_desc = pFormat + *(const WORD*)pFormat;
|
2003-02-01 01:44:51 +01:00
|
|
|
pFormat += 2;
|
|
|
|
|
|
|
|
pStubMsg->Memory = pMemory;
|
|
|
|
|
2008-08-10 12:14:07 +02:00
|
|
|
if (conf_array)
|
|
|
|
{
|
2009-04-21 09:59:45 +02:00
|
|
|
ULONG struct_size = ComplexStructSize(pStubMsg, pFormat);
|
2008-08-10 12:14:07 +02:00
|
|
|
array_compute_and_size_conformance(conf_array[0], pStubMsg, pMemory + struct_size,
|
|
|
|
conf_array);
|
|
|
|
|
|
|
|
/* these could be changed in ComplexMarshall so save them for later */
|
|
|
|
max_count = pStubMsg->MaxCount;
|
|
|
|
count = pStubMsg->ActualCount;
|
|
|
|
offset = pStubMsg->Offset;
|
|
|
|
}
|
|
|
|
|
2003-02-01 01:44:51 +01:00
|
|
|
pMemory = ComplexBufferSize(pStubMsg, pMemory, pFormat, pointer_desc);
|
|
|
|
|
|
|
|
if (conf_array)
|
2008-08-10 12:14:07 +02:00
|
|
|
{
|
|
|
|
pStubMsg->MaxCount = max_count;
|
|
|
|
pStubMsg->ActualCount = count;
|
|
|
|
pStubMsg->Offset = offset;
|
2008-08-10 12:14:30 +02:00
|
|
|
array_buffer_size(conf_array[0], pStubMsg, pMemory, conf_array,
|
|
|
|
TRUE /* fHasPointers */);
|
2008-08-10 12:14:07 +02:00
|
|
|
}
|
2003-02-01 01:44:51 +01:00
|
|
|
|
|
|
|
pStubMsg->Memory = OldMemory;
|
2007-06-25 15:28:01 +02:00
|
|
|
|
|
|
|
if(pointer_length_set)
|
|
|
|
{
|
|
|
|
pStubMsg->BufferLength = pStubMsg->PointerLength;
|
|
|
|
pStubMsg->PointerLength = 0;
|
|
|
|
}
|
|
|
|
|
2003-02-01 01:44:51 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* NdrComplexStructMemorySize [RPCRT4.@]
|
|
|
|
*/
|
2006-11-09 23:01:58 +01:00
|
|
|
ULONG WINAPI NdrComplexStructMemorySize(PMIDL_STUB_MESSAGE pStubMsg,
|
|
|
|
PFORMAT_STRING pFormat)
|
2003-02-01 01:44:51 +01:00
|
|
|
{
|
2006-05-13 17:59:50 +02:00
|
|
|
unsigned size = *(const WORD*)(pFormat+2);
|
2003-02-01 01:44:51 +01:00
|
|
|
PFORMAT_STRING conf_array = NULL;
|
2008-07-04 00:27:14 +02:00
|
|
|
PFORMAT_STRING pointer_desc = NULL;
|
2008-08-10 12:14:07 +02:00
|
|
|
ULONG count = 0;
|
|
|
|
ULONG max_count = 0;
|
|
|
|
ULONG offset = 0;
|
2003-02-01 01:44:51 +01:00
|
|
|
|
2006-05-13 17:59:50 +02:00
|
|
|
TRACE("(%p,%p)\n", pStubMsg, pFormat);
|
|
|
|
|
2010-04-02 21:54:55 +02:00
|
|
|
align_pointer(&pStubMsg->Buffer, pFormat[1] + 1);
|
2003-02-01 01:44:51 +01:00
|
|
|
|
|
|
|
pFormat += 4;
|
2008-07-04 00:27:00 +02:00
|
|
|
if (*(const SHORT*)pFormat) conf_array = pFormat + *(const SHORT*)pFormat;
|
2008-07-04 00:27:14 +02:00
|
|
|
pFormat += 2;
|
|
|
|
if (*(const WORD*)pFormat) pointer_desc = pFormat + *(const WORD*)pFormat;
|
|
|
|
pFormat += 2;
|
2003-02-01 01:44:51 +01:00
|
|
|
|
2008-08-10 12:14:07 +02:00
|
|
|
if (conf_array)
|
|
|
|
{
|
|
|
|
array_read_conformance(conf_array[0], pStubMsg, conf_array);
|
|
|
|
|
|
|
|
/* these could be changed in ComplexStructMemorySize so save them for
|
|
|
|
* later */
|
|
|
|
max_count = pStubMsg->MaxCount;
|
|
|
|
count = pStubMsg->ActualCount;
|
|
|
|
offset = pStubMsg->Offset;
|
|
|
|
}
|
|
|
|
|
2008-07-04 00:27:14 +02:00
|
|
|
ComplexStructMemorySize(pStubMsg, pFormat, pointer_desc);
|
2006-05-13 17:59:50 +02:00
|
|
|
|
|
|
|
if (conf_array)
|
2008-08-10 12:14:07 +02:00
|
|
|
{
|
|
|
|
pStubMsg->MaxCount = max_count;
|
|
|
|
pStubMsg->ActualCount = count;
|
|
|
|
pStubMsg->Offset = offset;
|
2008-08-10 12:14:30 +02:00
|
|
|
array_memory_size(conf_array[0], pStubMsg, conf_array,
|
|
|
|
TRUE /* fHasPointers */);
|
2008-08-10 12:14:07 +02:00
|
|
|
}
|
2006-05-13 17:59:50 +02:00
|
|
|
|
|
|
|
return size;
|
2003-02-01 01:44:51 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* NdrComplexStructFree [RPCRT4.@]
|
|
|
|
*/
|
|
|
|
void WINAPI NdrComplexStructFree(PMIDL_STUB_MESSAGE pStubMsg,
|
|
|
|
unsigned char *pMemory,
|
|
|
|
PFORMAT_STRING pFormat)
|
|
|
|
{
|
|
|
|
PFORMAT_STRING conf_array = NULL;
|
|
|
|
PFORMAT_STRING pointer_desc = NULL;
|
|
|
|
unsigned char *OldMemory = pStubMsg->Memory;
|
|
|
|
|
|
|
|
TRACE("(%p,%p,%p)\n", pStubMsg, pMemory, pFormat);
|
|
|
|
|
|
|
|
pFormat += 4;
|
2008-07-04 00:27:00 +02:00
|
|
|
if (*(const SHORT*)pFormat) conf_array = pFormat + *(const SHORT*)pFormat;
|
2003-02-01 01:44:51 +01:00
|
|
|
pFormat += 2;
|
2004-11-30 22:38:57 +01:00
|
|
|
if (*(const WORD*)pFormat) pointer_desc = pFormat + *(const WORD*)pFormat;
|
2003-02-01 01:44:51 +01:00
|
|
|
pFormat += 2;
|
|
|
|
|
|
|
|
pStubMsg->Memory = pMemory;
|
|
|
|
|
|
|
|
pMemory = ComplexFree(pStubMsg, pMemory, pFormat, pointer_desc);
|
|
|
|
|
|
|
|
if (conf_array)
|
2008-08-10 12:14:30 +02:00
|
|
|
array_free(conf_array[0], pStubMsg, pMemory, conf_array,
|
|
|
|
TRUE /* fHasPointers */);
|
2003-02-01 01:44:51 +01:00
|
|
|
|
|
|
|
pStubMsg->Memory = OldMemory;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* NdrConformantArrayMarshall [RPCRT4.@]
|
|
|
|
*/
|
|
|
|
unsigned char * WINAPI NdrConformantArrayMarshall(PMIDL_STUB_MESSAGE pStubMsg,
|
|
|
|
unsigned char *pMemory,
|
|
|
|
PFORMAT_STRING pFormat)
|
|
|
|
{
|
|
|
|
TRACE("(%p,%p,%p)\n", pStubMsg, pMemory, pFormat);
|
2018-06-13 04:19:10 +02:00
|
|
|
if (pFormat[0] != FC_CARRAY)
|
2008-08-10 12:14:07 +02:00
|
|
|
{
|
|
|
|
ERR("invalid format = 0x%x\n", pFormat[0]);
|
|
|
|
RpcRaiseException(RPC_X_BAD_STUB_DATA);
|
|
|
|
}
|
2003-02-01 01:44:51 +01:00
|
|
|
|
2018-06-13 04:19:10 +02:00
|
|
|
array_compute_and_write_conformance(FC_CARRAY, pStubMsg, pMemory,
|
2008-08-10 12:14:07 +02:00
|
|
|
pFormat);
|
2018-06-13 04:19:10 +02:00
|
|
|
array_write_variance_and_marshall(FC_CARRAY, pStubMsg, pMemory, pFormat,
|
2008-08-10 12:14:30 +02:00
|
|
|
TRUE /* fHasPointers */);
|
2003-02-01 01:44:51 +01:00
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* NdrConformantArrayUnmarshall [RPCRT4.@]
|
|
|
|
*/
|
|
|
|
unsigned char * WINAPI NdrConformantArrayUnmarshall(PMIDL_STUB_MESSAGE pStubMsg,
|
|
|
|
unsigned char **ppMemory,
|
|
|
|
PFORMAT_STRING pFormat,
|
|
|
|
unsigned char fMustAlloc)
|
|
|
|
{
|
|
|
|
TRACE("(%p,%p,%p,%d)\n", pStubMsg, ppMemory, pFormat, fMustAlloc);
|
2018-06-13 04:19:10 +02:00
|
|
|
if (pFormat[0] != FC_CARRAY)
|
2007-12-08 18:14:10 +01:00
|
|
|
{
|
2008-08-10 12:14:07 +02:00
|
|
|
ERR("invalid format = 0x%x\n", pFormat[0]);
|
|
|
|
RpcRaiseException(RPC_X_BAD_STUB_DATA);
|
2007-12-08 18:14:10 +01:00
|
|
|
}
|
2005-09-02 13:19:26 +02:00
|
|
|
|
2018-06-13 04:19:10 +02:00
|
|
|
array_read_conformance(FC_CARRAY, pStubMsg, pFormat);
|
|
|
|
array_read_variance_and_unmarshall(FC_CARRAY, pStubMsg, ppMemory, pFormat,
|
2008-08-10 12:14:07 +02:00
|
|
|
fMustAlloc,
|
2008-08-10 12:14:30 +02:00
|
|
|
TRUE /* fUseBufferMemoryServer */,
|
|
|
|
TRUE /* fUnmarshall */);
|
2003-02-01 01:44:51 +01:00
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* NdrConformantArrayBufferSize [RPCRT4.@]
|
|
|
|
*/
|
|
|
|
void WINAPI NdrConformantArrayBufferSize(PMIDL_STUB_MESSAGE pStubMsg,
|
|
|
|
unsigned char *pMemory,
|
|
|
|
PFORMAT_STRING pFormat)
|
|
|
|
{
|
|
|
|
TRACE("(%p,%p,%p)\n", pStubMsg, pMemory, pFormat);
|
2018-06-13 04:19:10 +02:00
|
|
|
if (pFormat[0] != FC_CARRAY)
|
2008-08-10 12:14:07 +02:00
|
|
|
{
|
|
|
|
ERR("invalid format = 0x%x\n", pFormat[0]);
|
|
|
|
RpcRaiseException(RPC_X_BAD_STUB_DATA);
|
|
|
|
}
|
2003-02-01 01:44:51 +01:00
|
|
|
|
2018-06-13 04:19:10 +02:00
|
|
|
array_compute_and_size_conformance(FC_CARRAY, pStubMsg, pMemory, pFormat);
|
|
|
|
array_buffer_size(FC_CARRAY, pStubMsg, pMemory, pFormat,
|
2008-08-10 12:14:30 +02:00
|
|
|
TRUE /* fHasPointers */);
|
2003-02-01 01:44:51 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* NdrConformantArrayMemorySize [RPCRT4.@]
|
|
|
|
*/
|
2006-11-09 23:01:58 +01:00
|
|
|
ULONG WINAPI NdrConformantArrayMemorySize(PMIDL_STUB_MESSAGE pStubMsg,
|
|
|
|
PFORMAT_STRING pFormat)
|
2003-02-01 01:44:51 +01:00
|
|
|
{
|
2005-11-28 10:58:40 +01:00
|
|
|
TRACE("(%p,%p)\n", pStubMsg, pFormat);
|
2018-06-13 04:19:10 +02:00
|
|
|
if (pFormat[0] != FC_CARRAY)
|
2008-08-10 12:14:07 +02:00
|
|
|
{
|
|
|
|
ERR("invalid format = 0x%x\n", pFormat[0]);
|
|
|
|
RpcRaiseException(RPC_X_BAD_STUB_DATA);
|
|
|
|
}
|
2006-05-18 04:39:58 +02:00
|
|
|
|
2018-06-13 04:19:10 +02:00
|
|
|
array_read_conformance(FC_CARRAY, pStubMsg, pFormat);
|
|
|
|
array_memory_size(FC_CARRAY, pStubMsg, pFormat, TRUE /* fHasPointers */);
|
2003-02-01 01:44:51 +01:00
|
|
|
|
2006-05-18 04:39:58 +02:00
|
|
|
return pStubMsg->MemorySize;
|
2003-02-01 01:44:51 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* NdrConformantArrayFree [RPCRT4.@]
|
|
|
|
*/
|
|
|
|
void WINAPI NdrConformantArrayFree(PMIDL_STUB_MESSAGE pStubMsg,
|
|
|
|
unsigned char *pMemory,
|
|
|
|
PFORMAT_STRING pFormat)
|
|
|
|
{
|
|
|
|
TRACE("(%p,%p,%p)\n", pStubMsg, pMemory, pFormat);
|
2018-06-13 04:19:10 +02:00
|
|
|
if (pFormat[0] != FC_CARRAY)
|
2008-08-10 12:14:07 +02:00
|
|
|
{
|
|
|
|
ERR("invalid format = 0x%x\n", pFormat[0]);
|
|
|
|
RpcRaiseException(RPC_X_BAD_STUB_DATA);
|
|
|
|
}
|
2006-08-17 16:31:32 +02:00
|
|
|
|
2018-06-13 04:19:10 +02:00
|
|
|
array_free(FC_CARRAY, pStubMsg, pMemory, pFormat,
|
2008-08-10 12:14:30 +02:00
|
|
|
TRUE /* fHasPointers */);
|
2003-02-01 01:44:51 +01:00
|
|
|
}
|
|
|
|
|
2003-04-26 04:12:14 +02:00
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* NdrConformantVaryingArrayMarshall [RPCRT4.@]
|
|
|
|
*/
|
|
|
|
unsigned char* WINAPI NdrConformantVaryingArrayMarshall( PMIDL_STUB_MESSAGE pStubMsg,
|
|
|
|
unsigned char* pMemory,
|
|
|
|
PFORMAT_STRING pFormat )
|
|
|
|
{
|
2005-11-28 11:30:32 +01:00
|
|
|
TRACE("(%p, %p, %p)\n", pStubMsg, pMemory, pFormat);
|
|
|
|
|
2018-06-13 04:19:10 +02:00
|
|
|
if (pFormat[0] != FC_CVARRAY)
|
2005-11-28 11:30:32 +01:00
|
|
|
{
|
|
|
|
ERR("invalid format type %x\n", pFormat[0]);
|
|
|
|
RpcRaiseException(RPC_S_INTERNAL_ERROR);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2018-06-13 04:19:10 +02:00
|
|
|
array_compute_and_write_conformance(FC_CVARRAY, pStubMsg, pMemory,
|
2008-08-10 12:14:21 +02:00
|
|
|
pFormat);
|
2018-06-13 04:19:10 +02:00
|
|
|
array_write_variance_and_marshall(FC_CVARRAY, pStubMsg, pMemory,
|
2008-08-10 12:14:30 +02:00
|
|
|
pFormat, TRUE /* fHasPointers */);
|
2005-11-28 11:30:32 +01:00
|
|
|
|
2003-04-26 04:12:14 +02:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* NdrConformantVaryingArrayUnmarshall [RPCRT4.@]
|
|
|
|
*/
|
|
|
|
unsigned char* WINAPI NdrConformantVaryingArrayUnmarshall( PMIDL_STUB_MESSAGE pStubMsg,
|
|
|
|
unsigned char** ppMemory,
|
|
|
|
PFORMAT_STRING pFormat,
|
|
|
|
unsigned char fMustAlloc )
|
|
|
|
{
|
2005-11-28 11:30:32 +01:00
|
|
|
TRACE("(%p, %p, %p, %d)\n", pStubMsg, ppMemory, pFormat, fMustAlloc);
|
|
|
|
|
2018-06-13 04:19:10 +02:00
|
|
|
if (pFormat[0] != FC_CVARRAY)
|
2005-11-28 11:30:32 +01:00
|
|
|
{
|
|
|
|
ERR("invalid format type %x\n", pFormat[0]);
|
|
|
|
RpcRaiseException(RPC_S_INTERNAL_ERROR);
|
|
|
|
return NULL;
|
|
|
|
}
|
2006-05-10 14:12:52 +02:00
|
|
|
|
2018-06-13 04:19:10 +02:00
|
|
|
array_read_conformance(FC_CVARRAY, pStubMsg, pFormat);
|
|
|
|
array_read_variance_and_unmarshall(FC_CVARRAY, pStubMsg, ppMemory,
|
2008-08-10 12:14:21 +02:00
|
|
|
pFormat, fMustAlloc,
|
2008-08-10 12:14:30 +02:00
|
|
|
TRUE /* fUseBufferMemoryServer */,
|
|
|
|
TRUE /* fUnmarshall */);
|
2005-11-28 11:30:32 +01:00
|
|
|
|
2003-04-26 04:12:14 +02:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* NdrConformantVaryingArrayFree [RPCRT4.@]
|
|
|
|
*/
|
|
|
|
void WINAPI NdrConformantVaryingArrayFree( PMIDL_STUB_MESSAGE pStubMsg,
|
|
|
|
unsigned char* pMemory,
|
|
|
|
PFORMAT_STRING pFormat )
|
|
|
|
{
|
2006-05-01 11:38:02 +02:00
|
|
|
TRACE("(%p,%p,%p)\n", pStubMsg, pMemory, pFormat);
|
|
|
|
|
2018-06-13 04:19:10 +02:00
|
|
|
if (pFormat[0] != FC_CVARRAY)
|
2006-05-01 11:38:02 +02:00
|
|
|
{
|
|
|
|
ERR("invalid format type %x\n", pFormat[0]);
|
|
|
|
RpcRaiseException(RPC_S_INTERNAL_ERROR);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-06-13 04:19:10 +02:00
|
|
|
array_free(FC_CVARRAY, pStubMsg, pMemory, pFormat,
|
2008-08-10 12:14:30 +02:00
|
|
|
TRUE /* fHasPointers */);
|
2003-04-26 04:12:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* NdrConformantVaryingArrayBufferSize [RPCRT4.@]
|
|
|
|
*/
|
|
|
|
void WINAPI NdrConformantVaryingArrayBufferSize( PMIDL_STUB_MESSAGE pStubMsg,
|
|
|
|
unsigned char* pMemory, PFORMAT_STRING pFormat )
|
|
|
|
{
|
2005-11-28 11:30:32 +01:00
|
|
|
TRACE("(%p, %p, %p)\n", pStubMsg, pMemory, pFormat);
|
|
|
|
|
2018-06-13 04:19:10 +02:00
|
|
|
if (pFormat[0] != FC_CVARRAY)
|
2005-11-28 11:30:32 +01:00
|
|
|
{
|
|
|
|
ERR("invalid format type %x\n", pFormat[0]);
|
|
|
|
RpcRaiseException(RPC_S_INTERNAL_ERROR);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-06-13 04:19:10 +02:00
|
|
|
array_compute_and_size_conformance(FC_CVARRAY, pStubMsg, pMemory,
|
2008-08-10 12:14:21 +02:00
|
|
|
pFormat);
|
2018-06-13 04:19:10 +02:00
|
|
|
array_buffer_size(FC_CVARRAY, pStubMsg, pMemory, pFormat,
|
2008-08-10 12:14:30 +02:00
|
|
|
TRUE /* fHasPointers */);
|
2003-04-26 04:12:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* NdrConformantVaryingArrayMemorySize [RPCRT4.@]
|
|
|
|
*/
|
2006-11-09 23:01:58 +01:00
|
|
|
ULONG WINAPI NdrConformantVaryingArrayMemorySize( PMIDL_STUB_MESSAGE pStubMsg,
|
|
|
|
PFORMAT_STRING pFormat )
|
2003-04-26 04:12:14 +02:00
|
|
|
{
|
2007-12-09 19:22:24 +01:00
|
|
|
TRACE("(%p, %p)\n", pStubMsg, pFormat);
|
|
|
|
|
2018-06-13 04:19:10 +02:00
|
|
|
if (pFormat[0] != FC_CVARRAY)
|
2007-12-09 19:22:24 +01:00
|
|
|
{
|
|
|
|
ERR("invalid format type %x\n", pFormat[0]);
|
|
|
|
RpcRaiseException(RPC_S_INTERNAL_ERROR);
|
|
|
|
return pStubMsg->MemorySize;
|
|
|
|
}
|
|
|
|
|
2018-06-13 04:19:10 +02:00
|
|
|
array_read_conformance(FC_CVARRAY, pStubMsg, pFormat);
|
|
|
|
array_memory_size(FC_CVARRAY, pStubMsg, pFormat,
|
2008-08-10 12:14:30 +02:00
|
|
|
TRUE /* fHasPointers */);
|
2007-12-09 19:22:24 +01:00
|
|
|
|
|
|
|
return pStubMsg->MemorySize;
|
2003-04-26 04:12:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-02-01 01:44:51 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* NdrComplexArrayMarshall [RPCRT4.@]
|
|
|
|
*/
|
|
|
|
unsigned char * WINAPI NdrComplexArrayMarshall(PMIDL_STUB_MESSAGE pStubMsg,
|
|
|
|
unsigned char *pMemory,
|
|
|
|
PFORMAT_STRING pFormat)
|
|
|
|
{
|
2013-12-03 00:02:50 +01:00
|
|
|
BOOL pointer_buffer_mark_set = FALSE;
|
2006-01-06 21:07:27 +01:00
|
|
|
|
2003-02-01 01:44:51 +01:00
|
|
|
TRACE("(%p,%p,%p)\n", pStubMsg, pMemory, pFormat);
|
|
|
|
|
2018-06-13 04:19:10 +02:00
|
|
|
if (pFormat[0] != FC_BOGUS_ARRAY)
|
2006-01-09 17:20:19 +01:00
|
|
|
{
|
|
|
|
ERR("invalid format type %x\n", pFormat[0]);
|
|
|
|
RpcRaiseException(RPC_S_INTERNAL_ERROR);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2007-06-25 15:28:01 +02:00
|
|
|
if (!pStubMsg->PointerBufferMark)
|
|
|
|
{
|
|
|
|
/* save buffer fields that may be changed by buffer sizer functions
|
|
|
|
* and that may be needed later on */
|
|
|
|
int saved_ignore_embedded = pStubMsg->IgnoreEmbeddedPointers;
|
2009-04-21 09:59:45 +02:00
|
|
|
ULONG saved_buffer_length = pStubMsg->BufferLength;
|
|
|
|
ULONG_PTR saved_max_count = pStubMsg->MaxCount;
|
|
|
|
ULONG saved_offset = pStubMsg->Offset;
|
|
|
|
ULONG saved_actual_count = pStubMsg->ActualCount;
|
2007-06-25 15:28:01 +02:00
|
|
|
|
|
|
|
/* get the buffer pointer after complex array data, but before
|
|
|
|
* pointer data */
|
2009-03-12 11:51:35 +01:00
|
|
|
pStubMsg->BufferLength = pStubMsg->Buffer - (unsigned char *)pStubMsg->RpcMsg->Buffer;
|
2007-06-25 15:28:01 +02:00
|
|
|
pStubMsg->IgnoreEmbeddedPointers = 1;
|
|
|
|
NdrComplexArrayBufferSize(pStubMsg, pMemory, pFormat);
|
|
|
|
pStubMsg->IgnoreEmbeddedPointers = saved_ignore_embedded;
|
|
|
|
|
|
|
|
/* save it for use by embedded pointer code later */
|
2009-03-12 11:51:35 +01:00
|
|
|
pStubMsg->PointerBufferMark = (unsigned char *)pStubMsg->RpcMsg->Buffer + pStubMsg->BufferLength;
|
2009-05-28 11:56:30 +02:00
|
|
|
TRACE("difference = 0x%x\n", (ULONG)(pStubMsg->Buffer - (unsigned char *)pStubMsg->RpcMsg->Buffer));
|
2013-12-03 00:02:50 +01:00
|
|
|
pointer_buffer_mark_set = TRUE;
|
2007-06-25 15:28:01 +02:00
|
|
|
|
|
|
|
/* restore fields */
|
|
|
|
pStubMsg->ActualCount = saved_actual_count;
|
|
|
|
pStubMsg->Offset = saved_offset;
|
|
|
|
pStubMsg->MaxCount = saved_max_count;
|
|
|
|
pStubMsg->BufferLength = saved_buffer_length;
|
|
|
|
}
|
|
|
|
|
2018-06-13 04:19:10 +02:00
|
|
|
array_compute_and_write_conformance(FC_BOGUS_ARRAY, pStubMsg, pMemory, pFormat);
|
|
|
|
array_write_variance_and_marshall(FC_BOGUS_ARRAY, pStubMsg,
|
2010-04-05 22:01:46 +02:00
|
|
|
pMemory, pFormat, TRUE /* fHasPointers */);
|
2003-02-01 01:44:51 +01:00
|
|
|
|
2003-02-17 02:48:24 +01:00
|
|
|
STD_OVERFLOW_CHECK(pStubMsg);
|
|
|
|
|
2007-06-25 15:28:01 +02:00
|
|
|
if (pointer_buffer_mark_set)
|
|
|
|
{
|
|
|
|
pStubMsg->Buffer = pStubMsg->PointerBufferMark;
|
|
|
|
pStubMsg->PointerBufferMark = NULL;
|
|
|
|
}
|
|
|
|
|
2003-02-01 01:44:51 +01:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* NdrComplexArrayUnmarshall [RPCRT4.@]
|
|
|
|
*/
|
|
|
|
unsigned char * WINAPI NdrComplexArrayUnmarshall(PMIDL_STUB_MESSAGE pStubMsg,
|
|
|
|
unsigned char **ppMemory,
|
|
|
|
PFORMAT_STRING pFormat,
|
|
|
|
unsigned char fMustAlloc)
|
|
|
|
{
|
2007-06-25 15:28:01 +02:00
|
|
|
unsigned char *saved_buffer;
|
2013-12-03 00:02:50 +01:00
|
|
|
BOOL pointer_buffer_mark_set = FALSE;
|
2007-06-25 15:28:01 +02:00
|
|
|
int saved_ignore_embedded;
|
2006-01-06 21:07:27 +01:00
|
|
|
|
2003-02-01 01:44:51 +01:00
|
|
|
TRACE("(%p,%p,%p,%d)\n", pStubMsg, ppMemory, pFormat, fMustAlloc);
|
|
|
|
|
2018-06-13 04:19:10 +02:00
|
|
|
if (pFormat[0] != FC_BOGUS_ARRAY)
|
2006-01-09 17:20:19 +01:00
|
|
|
{
|
|
|
|
ERR("invalid format type %x\n", pFormat[0]);
|
|
|
|
RpcRaiseException(RPC_S_INTERNAL_ERROR);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2007-06-25 15:28:01 +02:00
|
|
|
saved_ignore_embedded = pStubMsg->IgnoreEmbeddedPointers;
|
|
|
|
/* save buffer pointer */
|
|
|
|
saved_buffer = pStubMsg->Buffer;
|
|
|
|
/* get the buffer pointer after complex array data, but before
|
|
|
|
* pointer data */
|
|
|
|
pStubMsg->IgnoreEmbeddedPointers = 1;
|
|
|
|
pStubMsg->MemorySize = 0;
|
|
|
|
NdrComplexArrayMemorySize(pStubMsg, pFormat);
|
|
|
|
pStubMsg->IgnoreEmbeddedPointers = saved_ignore_embedded;
|
|
|
|
|
2009-05-28 11:56:30 +02:00
|
|
|
TRACE("difference = 0x%x\n", (ULONG)(pStubMsg->Buffer - saved_buffer));
|
2007-06-25 15:28:01 +02:00
|
|
|
if (!pStubMsg->PointerBufferMark)
|
|
|
|
{
|
|
|
|
/* save it for use by embedded pointer code later */
|
|
|
|
pStubMsg->PointerBufferMark = pStubMsg->Buffer;
|
2013-12-03 00:02:50 +01:00
|
|
|
pointer_buffer_mark_set = TRUE;
|
2007-06-25 15:28:01 +02:00
|
|
|
}
|
|
|
|
/* restore the original buffer */
|
|
|
|
pStubMsg->Buffer = saved_buffer;
|
|
|
|
|
2018-06-13 04:19:10 +02:00
|
|
|
array_read_conformance(FC_BOGUS_ARRAY, pStubMsg, pFormat);
|
|
|
|
array_read_variance_and_unmarshall(FC_BOGUS_ARRAY, pStubMsg, ppMemory, pFormat, fMustAlloc,
|
2010-04-05 22:02:20 +02:00
|
|
|
TRUE /* fUseBufferMemoryServer */, TRUE /* fUnmarshall */);
|
2003-02-01 01:44:51 +01:00
|
|
|
|
2007-06-25 15:28:01 +02:00
|
|
|
if (pointer_buffer_mark_set)
|
|
|
|
{
|
|
|
|
pStubMsg->Buffer = pStubMsg->PointerBufferMark;
|
|
|
|
pStubMsg->PointerBufferMark = NULL;
|
|
|
|
}
|
|
|
|
|
2003-02-01 01:44:51 +01:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* NdrComplexArrayBufferSize [RPCRT4.@]
|
|
|
|
*/
|
|
|
|
void WINAPI NdrComplexArrayBufferSize(PMIDL_STUB_MESSAGE pStubMsg,
|
|
|
|
unsigned char *pMemory,
|
|
|
|
PFORMAT_STRING pFormat)
|
|
|
|
{
|
2007-06-25 15:28:01 +02:00
|
|
|
int pointer_length_set = 0;
|
2006-01-06 21:07:27 +01:00
|
|
|
|
2003-02-01 01:44:51 +01:00
|
|
|
TRACE("(%p,%p,%p)\n", pStubMsg, pMemory, pFormat);
|
|
|
|
|
2018-06-13 04:19:10 +02:00
|
|
|
if (pFormat[0] != FC_BOGUS_ARRAY)
|
2006-01-09 17:20:19 +01:00
|
|
|
{
|
|
|
|
ERR("invalid format type %x\n", pFormat[0]);
|
|
|
|
RpcRaiseException(RPC_S_INTERNAL_ERROR);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2007-06-25 15:28:01 +02:00
|
|
|
if (!pStubMsg->IgnoreEmbeddedPointers && !pStubMsg->PointerLength)
|
|
|
|
{
|
|
|
|
/* save buffer fields that may be changed by buffer sizer functions
|
|
|
|
* and that may be needed later on */
|
|
|
|
int saved_ignore_embedded = pStubMsg->IgnoreEmbeddedPointers;
|
2009-04-21 09:59:45 +02:00
|
|
|
ULONG saved_buffer_length = pStubMsg->BufferLength;
|
|
|
|
ULONG_PTR saved_max_count = pStubMsg->MaxCount;
|
|
|
|
ULONG saved_offset = pStubMsg->Offset;
|
|
|
|
ULONG saved_actual_count = pStubMsg->ActualCount;
|
2007-06-25 15:28:01 +02:00
|
|
|
|
|
|
|
/* get the buffer pointer after complex array data, but before
|
|
|
|
* pointer data */
|
|
|
|
pStubMsg->IgnoreEmbeddedPointers = 1;
|
|
|
|
NdrComplexArrayBufferSize(pStubMsg, pMemory, pFormat);
|
|
|
|
pStubMsg->IgnoreEmbeddedPointers = saved_ignore_embedded;
|
|
|
|
|
|
|
|
/* save it for use by embedded pointer code later */
|
|
|
|
pStubMsg->PointerLength = pStubMsg->BufferLength;
|
|
|
|
pointer_length_set = 1;
|
|
|
|
|
|
|
|
/* restore fields */
|
|
|
|
pStubMsg->ActualCount = saved_actual_count;
|
|
|
|
pStubMsg->Offset = saved_offset;
|
|
|
|
pStubMsg->MaxCount = saved_max_count;
|
|
|
|
pStubMsg->BufferLength = saved_buffer_length;
|
|
|
|
}
|
2003-02-01 01:44:51 +01:00
|
|
|
|
2018-06-13 04:19:10 +02:00
|
|
|
array_compute_and_size_conformance(FC_BOGUS_ARRAY, pStubMsg, pMemory, pFormat);
|
|
|
|
array_buffer_size(FC_BOGUS_ARRAY, pStubMsg, pMemory, pFormat, TRUE /* fHasPointers */);
|
2007-06-25 15:28:01 +02:00
|
|
|
|
|
|
|
if(pointer_length_set)
|
|
|
|
{
|
|
|
|
pStubMsg->BufferLength = pStubMsg->PointerLength;
|
|
|
|
pStubMsg->PointerLength = 0;
|
|
|
|
}
|
2003-02-01 01:44:51 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* NdrComplexArrayMemorySize [RPCRT4.@]
|
|
|
|
*/
|
2006-11-09 23:01:58 +01:00
|
|
|
ULONG WINAPI NdrComplexArrayMemorySize(PMIDL_STUB_MESSAGE pStubMsg,
|
|
|
|
PFORMAT_STRING pFormat)
|
2003-02-01 01:44:51 +01:00
|
|
|
{
|
2006-05-13 17:59:20 +02:00
|
|
|
TRACE("(%p,%p)\n", pStubMsg, pFormat);
|
2003-02-01 01:44:51 +01:00
|
|
|
|
2018-06-13 04:19:10 +02:00
|
|
|
if (pFormat[0] != FC_BOGUS_ARRAY)
|
2006-01-09 17:20:19 +01:00
|
|
|
{
|
|
|
|
ERR("invalid format type %x\n", pFormat[0]);
|
|
|
|
RpcRaiseException(RPC_S_INTERNAL_ERROR);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2018-06-13 04:19:10 +02:00
|
|
|
array_read_conformance(FC_BOGUS_ARRAY, pStubMsg, pFormat);
|
|
|
|
array_memory_size(FC_BOGUS_ARRAY, pStubMsg, pFormat, TRUE /* fHasPointers */);
|
2010-04-05 22:02:20 +02:00
|
|
|
return pStubMsg->MemorySize;
|
2003-02-01 01:44:51 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* NdrComplexArrayFree [RPCRT4.@]
|
|
|
|
*/
|
|
|
|
void WINAPI NdrComplexArrayFree(PMIDL_STUB_MESSAGE pStubMsg,
|
|
|
|
unsigned char *pMemory,
|
|
|
|
PFORMAT_STRING pFormat)
|
|
|
|
{
|
2006-05-15 14:35:51 +02:00
|
|
|
ULONG i, count, def;
|
2006-01-06 21:07:27 +01:00
|
|
|
|
2003-02-01 01:44:51 +01:00
|
|
|
TRACE("(%p,%p,%p)\n", pStubMsg, pMemory, pFormat);
|
|
|
|
|
2018-06-13 04:19:10 +02:00
|
|
|
if (pFormat[0] != FC_BOGUS_ARRAY)
|
2006-01-09 17:20:19 +01:00
|
|
|
{
|
|
|
|
ERR("invalid format type %x\n", pFormat[0]);
|
|
|
|
RpcRaiseException(RPC_S_INTERNAL_ERROR);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2004-11-30 22:38:57 +01:00
|
|
|
def = *(const WORD*)&pFormat[2];
|
2003-02-01 01:44:51 +01:00
|
|
|
pFormat += 4;
|
|
|
|
|
|
|
|
pFormat = ComputeConformance(pStubMsg, pMemory, pFormat, def);
|
2006-01-06 21:07:27 +01:00
|
|
|
TRACE("conformance = %ld\n", pStubMsg->MaxCount);
|
2003-02-01 01:44:51 +01:00
|
|
|
|
2006-01-06 21:07:27 +01:00
|
|
|
pFormat = ComputeVariance(pStubMsg, pMemory, pFormat, pStubMsg->MaxCount);
|
2006-11-09 23:04:48 +01:00
|
|
|
TRACE("variance = %d\n", pStubMsg->ActualCount);
|
2003-02-01 01:44:51 +01:00
|
|
|
|
2006-05-15 14:35:51 +02:00
|
|
|
count = pStubMsg->ActualCount;
|
|
|
|
for (i = 0; i < count; i++)
|
2003-02-01 01:44:51 +01:00
|
|
|
pMemory = ComplexFree(pStubMsg, pMemory, pFormat, NULL);
|
|
|
|
}
|
|
|
|
|
2007-12-09 19:22:57 +01:00
|
|
|
static void UserMarshalCB(PMIDL_STUB_MESSAGE pStubMsg,
|
|
|
|
USER_MARSHAL_CB_TYPE cbtype, PFORMAT_STRING pFormat,
|
|
|
|
USER_MARSHAL_CB *umcb)
|
2003-02-01 01:44:51 +01:00
|
|
|
{
|
2007-12-09 19:22:57 +01:00
|
|
|
umcb->Flags = MAKELONG(pStubMsg->dwDestContext,
|
|
|
|
pStubMsg->RpcMsg->DataRepresentation);
|
|
|
|
umcb->pStubMsg = pStubMsg;
|
|
|
|
umcb->pReserve = NULL;
|
|
|
|
umcb->Signature = USER_MARSHAL_CB_SIGNATURE;
|
|
|
|
umcb->CBType = cbtype;
|
|
|
|
umcb->pFormat = pFormat;
|
|
|
|
umcb->pTypeFormat = NULL /* FIXME */;
|
2003-02-01 01:44:51 +01:00
|
|
|
}
|
|
|
|
|
2006-05-18 04:39:27 +02:00
|
|
|
#define USER_MARSHAL_PTR_PREFIX \
|
|
|
|
( (DWORD)'U' | ( (DWORD)'s' << 8 ) | \
|
|
|
|
( (DWORD)'e' << 16 ) | ( (DWORD)'r' << 24 ) )
|
|
|
|
|
2003-02-01 01:44:51 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* NdrUserMarshalMarshall [RPCRT4.@]
|
|
|
|
*/
|
|
|
|
unsigned char * WINAPI NdrUserMarshalMarshall(PMIDL_STUB_MESSAGE pStubMsg,
|
|
|
|
unsigned char *pMemory,
|
|
|
|
PFORMAT_STRING pFormat)
|
|
|
|
{
|
2006-05-18 04:39:27 +02:00
|
|
|
unsigned flags = pFormat[1];
|
2004-11-30 22:38:57 +01:00
|
|
|
unsigned index = *(const WORD*)&pFormat[2];
|
2007-06-25 15:28:01 +02:00
|
|
|
unsigned char *saved_buffer = NULL;
|
2007-12-09 19:22:57 +01:00
|
|
|
USER_MARSHAL_CB umcb;
|
|
|
|
|
2003-02-01 01:44:51 +01:00
|
|
|
TRACE("(%p,%p,%p)\n", pStubMsg, pMemory, pFormat);
|
|
|
|
TRACE("index=%d\n", index);
|
|
|
|
|
2007-12-09 19:22:57 +01:00
|
|
|
UserMarshalCB(pStubMsg, USER_MARSHAL_CB_MARSHALL, pFormat, &umcb);
|
|
|
|
|
2006-05-18 04:39:27 +02:00
|
|
|
if (flags & USER_MARSHAL_POINTER)
|
|
|
|
{
|
2010-04-02 21:54:55 +02:00
|
|
|
align_pointer_clear(&pStubMsg->Buffer, 4);
|
2006-05-18 04:39:27 +02:00
|
|
|
NDR_LOCAL_UINT32_WRITE(pStubMsg->Buffer, USER_MARSHAL_PTR_PREFIX);
|
|
|
|
pStubMsg->Buffer += 4;
|
2007-06-25 15:28:01 +02:00
|
|
|
if (pStubMsg->PointerBufferMark)
|
|
|
|
{
|
|
|
|
saved_buffer = pStubMsg->Buffer;
|
|
|
|
pStubMsg->Buffer = pStubMsg->PointerBufferMark;
|
|
|
|
pStubMsg->PointerBufferMark = NULL;
|
|
|
|
}
|
2010-04-02 21:54:55 +02:00
|
|
|
align_pointer_clear(&pStubMsg->Buffer, 8);
|
2006-05-18 04:39:27 +02:00
|
|
|
}
|
|
|
|
else
|
2010-04-02 21:54:55 +02:00
|
|
|
align_pointer_clear(&pStubMsg->Buffer, (flags & 0xf) + 1);
|
2006-05-18 04:39:27 +02:00
|
|
|
|
2003-02-01 01:44:51 +01:00
|
|
|
pStubMsg->Buffer =
|
|
|
|
pStubMsg->StubDesc->aUserMarshalQuadruple[index].pfnMarshall(
|
2007-12-09 19:22:57 +01:00
|
|
|
&umcb.Flags, pStubMsg->Buffer, pMemory);
|
2003-02-01 01:44:51 +01:00
|
|
|
|
2007-06-25 15:28:01 +02:00
|
|
|
if (saved_buffer)
|
|
|
|
{
|
|
|
|
STD_OVERFLOW_CHECK(pStubMsg);
|
|
|
|
pStubMsg->PointerBufferMark = pStubMsg->Buffer;
|
|
|
|
pStubMsg->Buffer = saved_buffer;
|
|
|
|
}
|
|
|
|
|
2003-02-17 02:48:24 +01:00
|
|
|
STD_OVERFLOW_CHECK(pStubMsg);
|
|
|
|
|
2003-02-01 01:44:51 +01:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* NdrUserMarshalUnmarshall [RPCRT4.@]
|
|
|
|
*/
|
|
|
|
unsigned char * WINAPI NdrUserMarshalUnmarshall(PMIDL_STUB_MESSAGE pStubMsg,
|
|
|
|
unsigned char **ppMemory,
|
|
|
|
PFORMAT_STRING pFormat,
|
|
|
|
unsigned char fMustAlloc)
|
|
|
|
{
|
2006-05-18 04:39:27 +02:00
|
|
|
unsigned flags = pFormat[1];
|
2004-11-30 22:38:57 +01:00
|
|
|
unsigned index = *(const WORD*)&pFormat[2];
|
|
|
|
DWORD memsize = *(const WORD*)&pFormat[4];
|
2007-06-25 15:28:01 +02:00
|
|
|
unsigned char *saved_buffer = NULL;
|
2007-12-09 19:22:57 +01:00
|
|
|
USER_MARSHAL_CB umcb;
|
|
|
|
|
2003-02-01 01:44:51 +01:00
|
|
|
TRACE("(%p,%p,%p,%d)\n", pStubMsg, ppMemory, pFormat, fMustAlloc);
|
|
|
|
TRACE("index=%d\n", index);
|
|
|
|
|
2007-12-09 19:22:57 +01:00
|
|
|
UserMarshalCB(pStubMsg, USER_MARSHAL_CB_UNMARSHALL, pFormat, &umcb);
|
|
|
|
|
2006-05-18 04:39:27 +02:00
|
|
|
if (flags & USER_MARSHAL_POINTER)
|
|
|
|
{
|
2010-04-02 21:54:55 +02:00
|
|
|
align_pointer(&pStubMsg->Buffer, 4);
|
2006-05-18 04:39:27 +02:00
|
|
|
/* skip pointer prefix */
|
|
|
|
pStubMsg->Buffer += 4;
|
2007-06-25 15:28:01 +02:00
|
|
|
if (pStubMsg->PointerBufferMark)
|
|
|
|
{
|
|
|
|
saved_buffer = pStubMsg->Buffer;
|
|
|
|
pStubMsg->Buffer = pStubMsg->PointerBufferMark;
|
|
|
|
pStubMsg->PointerBufferMark = NULL;
|
|
|
|
}
|
2010-04-02 21:54:55 +02:00
|
|
|
align_pointer(&pStubMsg->Buffer, 8);
|
2006-05-18 04:39:27 +02:00
|
|
|
}
|
|
|
|
else
|
2010-04-02 21:54:55 +02:00
|
|
|
align_pointer(&pStubMsg->Buffer, (flags & 0xf) + 1);
|
2006-05-18 04:39:27 +02:00
|
|
|
|
2009-01-10 23:17:15 +01:00
|
|
|
if (!fMustAlloc && !*ppMemory)
|
|
|
|
fMustAlloc = TRUE;
|
|
|
|
if (fMustAlloc)
|
|
|
|
{
|
2003-02-01 01:44:51 +01:00
|
|
|
*ppMemory = NdrAllocate(pStubMsg, memsize);
|
2009-01-10 23:17:15 +01:00
|
|
|
memset(*ppMemory, 0, memsize);
|
|
|
|
}
|
2003-02-01 01:44:51 +01:00
|
|
|
|
|
|
|
pStubMsg->Buffer =
|
|
|
|
pStubMsg->StubDesc->aUserMarshalQuadruple[index].pfnUnmarshall(
|
2007-12-09 19:22:57 +01:00
|
|
|
&umcb.Flags, pStubMsg->Buffer, *ppMemory);
|
2003-02-01 01:44:51 +01:00
|
|
|
|
2007-06-25 15:28:01 +02:00
|
|
|
if (saved_buffer)
|
|
|
|
{
|
|
|
|
STD_OVERFLOW_CHECK(pStubMsg);
|
|
|
|
pStubMsg->PointerBufferMark = pStubMsg->Buffer;
|
|
|
|
pStubMsg->Buffer = saved_buffer;
|
|
|
|
}
|
|
|
|
|
2003-02-01 01:44:51 +01:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* NdrUserMarshalBufferSize [RPCRT4.@]
|
|
|
|
*/
|
|
|
|
void WINAPI NdrUserMarshalBufferSize(PMIDL_STUB_MESSAGE pStubMsg,
|
|
|
|
unsigned char *pMemory,
|
|
|
|
PFORMAT_STRING pFormat)
|
|
|
|
{
|
2006-05-18 04:39:27 +02:00
|
|
|
unsigned flags = pFormat[1];
|
2004-11-30 22:38:57 +01:00
|
|
|
unsigned index = *(const WORD*)&pFormat[2];
|
|
|
|
DWORD bufsize = *(const WORD*)&pFormat[6];
|
2007-12-09 19:22:57 +01:00
|
|
|
USER_MARSHAL_CB umcb;
|
2009-04-21 09:59:45 +02:00
|
|
|
ULONG saved_buffer_length = 0;
|
2007-12-09 19:22:57 +01:00
|
|
|
|
2003-02-01 01:44:51 +01:00
|
|
|
TRACE("(%p,%p,%p)\n", pStubMsg, pMemory, pFormat);
|
|
|
|
TRACE("index=%d\n", index);
|
|
|
|
|
2007-12-09 19:22:57 +01:00
|
|
|
UserMarshalCB(pStubMsg, USER_MARSHAL_CB_BUFFER_SIZE, pFormat, &umcb);
|
|
|
|
|
2006-05-18 04:39:27 +02:00
|
|
|
if (flags & USER_MARSHAL_POINTER)
|
|
|
|
{
|
2010-04-02 21:54:55 +02:00
|
|
|
align_length(&pStubMsg->BufferLength, 4);
|
2006-05-18 04:39:27 +02:00
|
|
|
/* skip pointer prefix */
|
2007-11-28 16:01:53 +01:00
|
|
|
safe_buffer_length_increment(pStubMsg, 4);
|
2007-06-25 15:28:01 +02:00
|
|
|
if (pStubMsg->IgnoreEmbeddedPointers)
|
|
|
|
return;
|
|
|
|
if (pStubMsg->PointerLength)
|
|
|
|
{
|
|
|
|
saved_buffer_length = pStubMsg->BufferLength;
|
|
|
|
pStubMsg->BufferLength = pStubMsg->PointerLength;
|
|
|
|
pStubMsg->PointerLength = 0;
|
|
|
|
}
|
2010-04-02 21:54:55 +02:00
|
|
|
align_length(&pStubMsg->BufferLength, 8);
|
2006-05-18 04:39:27 +02:00
|
|
|
}
|
|
|
|
else
|
2010-04-02 21:54:55 +02:00
|
|
|
align_length(&pStubMsg->BufferLength, (flags & 0xf) + 1);
|
2006-05-18 04:39:27 +02:00
|
|
|
|
2003-02-01 01:44:51 +01:00
|
|
|
if (bufsize) {
|
2006-11-09 23:04:48 +01:00
|
|
|
TRACE("size=%d\n", bufsize);
|
2007-11-28 16:01:53 +01:00
|
|
|
safe_buffer_length_increment(pStubMsg, bufsize);
|
2007-06-25 15:28:01 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
pStubMsg->BufferLength =
|
|
|
|
pStubMsg->StubDesc->aUserMarshalQuadruple[index].pfnBufferSize(
|
2007-12-09 19:22:57 +01:00
|
|
|
&umcb.Flags, pStubMsg->BufferLength, pMemory);
|
2007-06-25 15:28:01 +02:00
|
|
|
|
|
|
|
if (saved_buffer_length)
|
|
|
|
{
|
|
|
|
pStubMsg->PointerLength = pStubMsg->BufferLength;
|
|
|
|
pStubMsg->BufferLength = saved_buffer_length;
|
2003-02-01 01:44:51 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* NdrUserMarshalMemorySize [RPCRT4.@]
|
|
|
|
*/
|
2006-11-09 23:01:58 +01:00
|
|
|
ULONG WINAPI NdrUserMarshalMemorySize(PMIDL_STUB_MESSAGE pStubMsg,
|
|
|
|
PFORMAT_STRING pFormat)
|
2003-02-01 01:44:51 +01:00
|
|
|
{
|
2006-05-18 04:39:27 +02:00
|
|
|
unsigned flags = pFormat[1];
|
2004-11-30 22:38:57 +01:00
|
|
|
unsigned index = *(const WORD*)&pFormat[2];
|
2006-05-18 04:39:19 +02:00
|
|
|
DWORD memsize = *(const WORD*)&pFormat[4];
|
|
|
|
DWORD bufsize = *(const WORD*)&pFormat[6];
|
|
|
|
|
|
|
|
TRACE("(%p,%p)\n", pStubMsg, pFormat);
|
2003-02-17 02:48:24 +01:00
|
|
|
TRACE("index=%d\n", index);
|
|
|
|
|
2006-05-18 04:39:19 +02:00
|
|
|
pStubMsg->MemorySize += memsize;
|
2006-05-18 04:39:27 +02:00
|
|
|
|
|
|
|
if (flags & USER_MARSHAL_POINTER)
|
|
|
|
{
|
2010-04-02 21:54:55 +02:00
|
|
|
align_pointer(&pStubMsg->Buffer, 4);
|
2006-05-18 04:39:27 +02:00
|
|
|
/* skip pointer prefix */
|
|
|
|
pStubMsg->Buffer += 4;
|
2007-06-25 15:28:01 +02:00
|
|
|
if (pStubMsg->IgnoreEmbeddedPointers)
|
|
|
|
return pStubMsg->MemorySize;
|
2010-04-02 21:54:55 +02:00
|
|
|
align_pointer(&pStubMsg->Buffer, 8);
|
2006-05-18 04:39:27 +02:00
|
|
|
}
|
|
|
|
else
|
2010-04-02 21:54:55 +02:00
|
|
|
align_pointer(&pStubMsg->Buffer, (flags & 0xf) + 1);
|
2006-05-18 04:39:27 +02:00
|
|
|
|
2007-06-25 15:28:01 +02:00
|
|
|
if (!bufsize)
|
|
|
|
FIXME("not implemented for varying buffer size\n");
|
|
|
|
|
2006-05-18 04:39:19 +02:00
|
|
|
pStubMsg->Buffer += bufsize;
|
|
|
|
|
|
|
|
return pStubMsg->MemorySize;
|
2003-02-01 01:44:51 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* NdrUserMarshalFree [RPCRT4.@]
|
|
|
|
*/
|
|
|
|
void WINAPI NdrUserMarshalFree(PMIDL_STUB_MESSAGE pStubMsg,
|
|
|
|
unsigned char *pMemory,
|
|
|
|
PFORMAT_STRING pFormat)
|
|
|
|
{
|
|
|
|
/* unsigned flags = pFormat[1]; */
|
2004-11-30 22:38:57 +01:00
|
|
|
unsigned index = *(const WORD*)&pFormat[2];
|
2007-12-09 19:22:57 +01:00
|
|
|
USER_MARSHAL_CB umcb;
|
|
|
|
|
2003-02-01 01:44:51 +01:00
|
|
|
TRACE("(%p,%p,%p)\n", pStubMsg, pMemory, pFormat);
|
|
|
|
TRACE("index=%d\n", index);
|
|
|
|
|
2007-12-09 19:22:57 +01:00
|
|
|
UserMarshalCB(pStubMsg, USER_MARSHAL_CB_FREE, pFormat, &umcb);
|
|
|
|
|
2003-02-01 01:44:51 +01:00
|
|
|
pStubMsg->StubDesc->aUserMarshalQuadruple[index].pfnFree(
|
2007-12-09 19:22:57 +01:00
|
|
|
&umcb.Flags, pMemory);
|
2002-10-22 02:41:17 +02:00
|
|
|
}
|
2002-10-25 21:03:43 +02:00
|
|
|
|
2009-01-23 10:32:44 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* NdrGetUserMarshalInfo [RPCRT4.@]
|
|
|
|
*/
|
2009-01-28 13:58:37 +01:00
|
|
|
RPC_STATUS RPC_ENTRY NdrGetUserMarshalInfo(ULONG *flags, ULONG level, NDR_USER_MARSHAL_INFO *umi)
|
2009-01-23 10:32:44 +01:00
|
|
|
{
|
2009-01-28 13:58:37 +01:00
|
|
|
USER_MARSHAL_CB *umcb = CONTAINING_RECORD(flags, USER_MARSHAL_CB, Flags);
|
|
|
|
|
|
|
|
TRACE("(%p,%u,%p)\n", flags, level, umi);
|
|
|
|
|
|
|
|
if (level != 1)
|
|
|
|
return RPC_S_INVALID_ARG;
|
|
|
|
|
2009-08-31 11:53:00 +02:00
|
|
|
memset(&umi->u1.Level1, 0, sizeof(umi->u1.Level1));
|
2009-01-28 13:58:37 +01:00
|
|
|
umi->InformationLevel = level;
|
|
|
|
|
|
|
|
if (umcb->Signature != USER_MARSHAL_CB_SIGNATURE)
|
|
|
|
return RPC_S_INVALID_ARG;
|
|
|
|
|
2009-08-31 11:53:00 +02:00
|
|
|
umi->u1.Level1.pfnAllocate = umcb->pStubMsg->pfnAllocate;
|
|
|
|
umi->u1.Level1.pfnFree = umcb->pStubMsg->pfnFree;
|
|
|
|
umi->u1.Level1.pRpcChannelBuffer = umcb->pStubMsg->pRpcChannelBuffer;
|
2009-01-28 13:58:37 +01:00
|
|
|
|
|
|
|
switch (umcb->CBType)
|
|
|
|
{
|
|
|
|
case USER_MARSHAL_CB_MARSHALL:
|
|
|
|
case USER_MARSHAL_CB_UNMARSHALL:
|
|
|
|
{
|
|
|
|
RPC_MESSAGE *msg = umcb->pStubMsg->RpcMsg;
|
|
|
|
unsigned char *buffer_start = msg->Buffer;
|
|
|
|
unsigned char *buffer_end =
|
|
|
|
(unsigned char *)msg->Buffer + msg->BufferLength;
|
|
|
|
|
|
|
|
if (umcb->pStubMsg->Buffer < buffer_start ||
|
|
|
|
umcb->pStubMsg->Buffer > buffer_end)
|
2015-03-03 08:41:57 +01:00
|
|
|
return RPC_X_INVALID_BUFFER;
|
2009-01-28 13:58:37 +01:00
|
|
|
|
2009-08-31 11:53:00 +02:00
|
|
|
umi->u1.Level1.Buffer = umcb->pStubMsg->Buffer;
|
|
|
|
umi->u1.Level1.BufferSize = buffer_end - umcb->pStubMsg->Buffer;
|
2009-01-28 13:58:37 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case USER_MARSHAL_CB_BUFFER_SIZE:
|
|
|
|
case USER_MARSHAL_CB_FREE:
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
WARN("unrecognised CBType %d\n", umcb->CBType);
|
|
|
|
}
|
|
|
|
|
|
|
|
return RPC_S_OK;
|
2009-01-23 10:32:44 +01:00
|
|
|
}
|
|
|
|
|
2003-05-20 04:17:49 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* NdrClearOutParameters [RPCRT4.@]
|
|
|
|
*/
|
|
|
|
void WINAPI NdrClearOutParameters(PMIDL_STUB_MESSAGE pStubMsg,
|
|
|
|
PFORMAT_STRING pFormat,
|
|
|
|
void *ArgAddr)
|
|
|
|
{
|
|
|
|
FIXME("(%p,%p,%p): stub\n", pStubMsg, pFormat, ArgAddr);
|
|
|
|
}
|
|
|
|
|
2002-10-28 21:07:01 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* NdrConvert [RPCRT4.@]
|
|
|
|
*/
|
|
|
|
void WINAPI NdrConvert( PMIDL_STUB_MESSAGE pStubMsg, PFORMAT_STRING pFormat )
|
|
|
|
{
|
|
|
|
FIXME("(pStubMsg == ^%p, pFormat == ^%p): stub.\n", pStubMsg, pFormat);
|
2002-10-28 22:14:16 +01:00
|
|
|
/* FIXME: since this stub doesn't do any converting, the proper behavior
|
|
|
|
is to raise an exception */
|
2002-10-28 21:07:01 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* NdrConvert2 [RPCRT4.@]
|
|
|
|
*/
|
2006-11-09 23:01:58 +01:00
|
|
|
void WINAPI NdrConvert2( PMIDL_STUB_MESSAGE pStubMsg, PFORMAT_STRING pFormat, LONG NumberParams )
|
2002-10-28 21:07:01 +01:00
|
|
|
{
|
2006-11-09 23:04:48 +01:00
|
|
|
FIXME("(pStubMsg == ^%p, pFormat == ^%p, NumberParams == %d): stub.\n",
|
2002-11-01 00:35:46 +01:00
|
|
|
pStubMsg, pFormat, NumberParams);
|
2002-10-28 22:14:16 +01:00
|
|
|
/* FIXME: since this stub doesn't do any converting, the proper behavior
|
|
|
|
is to raise an exception */
|
2002-10-28 21:07:01 +01:00
|
|
|
}
|
2005-07-18 15:14:05 +02:00
|
|
|
|
2007-02-12 14:29:04 +01:00
|
|
|
#include "pshpack1.h"
|
2005-11-28 11:30:12 +01:00
|
|
|
typedef struct _NDR_CSTRUCT_FORMAT
|
|
|
|
{
|
|
|
|
unsigned char type;
|
|
|
|
unsigned char alignment;
|
|
|
|
unsigned short memory_size;
|
|
|
|
short offset_to_array_description;
|
2006-05-15 17:56:37 +02:00
|
|
|
} NDR_CSTRUCT_FORMAT, NDR_CVSTRUCT_FORMAT;
|
2007-02-12 14:29:04 +01:00
|
|
|
#include "poppack.h"
|
2005-11-28 11:30:12 +01:00
|
|
|
|
2005-07-18 15:14:05 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* NdrConformantStructMarshall [RPCRT4.@]
|
|
|
|
*/
|
|
|
|
unsigned char * WINAPI NdrConformantStructMarshall(PMIDL_STUB_MESSAGE pStubMsg,
|
|
|
|
unsigned char *pMemory,
|
|
|
|
PFORMAT_STRING pFormat)
|
|
|
|
{
|
2006-09-25 23:20:20 +02:00
|
|
|
const NDR_CSTRUCT_FORMAT *pCStructFormat = (const NDR_CSTRUCT_FORMAT *)pFormat;
|
2006-05-15 14:35:31 +02:00
|
|
|
PFORMAT_STRING pCArrayFormat;
|
2006-06-10 13:32:24 +02:00
|
|
|
ULONG esize, bufsize;
|
2005-11-28 11:30:12 +01:00
|
|
|
|
|
|
|
TRACE("(%p, %p, %p)\n", pStubMsg, pMemory, pFormat);
|
|
|
|
|
2006-05-15 14:35:31 +02:00
|
|
|
pFormat += sizeof(NDR_CSTRUCT_FORMAT);
|
2018-06-13 04:19:10 +02:00
|
|
|
if ((pCStructFormat->type != FC_CPSTRUCT) && (pCStructFormat->type != FC_CSTRUCT))
|
2005-11-28 11:30:12 +01:00
|
|
|
{
|
|
|
|
ERR("invalid format type %x\n", pCStructFormat->type);
|
|
|
|
RpcRaiseException(RPC_S_INTERNAL_ERROR);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2006-09-25 23:20:20 +02:00
|
|
|
pCArrayFormat = (const unsigned char *)&pCStructFormat->offset_to_array_description +
|
2006-05-15 14:35:31 +02:00
|
|
|
pCStructFormat->offset_to_array_description;
|
2018-06-13 04:19:10 +02:00
|
|
|
if (*pCArrayFormat != FC_CARRAY)
|
2006-05-15 14:35:31 +02:00
|
|
|
{
|
|
|
|
ERR("invalid array format type %x\n", pCStructFormat->type);
|
|
|
|
RpcRaiseException(RPC_S_INTERNAL_ERROR);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
esize = *(const WORD*)(pCArrayFormat+2);
|
|
|
|
|
|
|
|
ComputeConformance(pStubMsg, pMemory + pCStructFormat->memory_size,
|
|
|
|
pCArrayFormat + 4, 0);
|
|
|
|
|
|
|
|
WriteConformance(pStubMsg);
|
|
|
|
|
2010-04-02 21:54:55 +02:00
|
|
|
align_pointer_clear(&pStubMsg->Buffer, pCStructFormat->alignment + 1);
|
2006-05-10 14:12:30 +02:00
|
|
|
|
2005-11-28 11:30:12 +01:00
|
|
|
TRACE("memory_size = %d\n", pCStructFormat->memory_size);
|
|
|
|
|
2006-06-10 13:32:24 +02:00
|
|
|
bufsize = safe_multiply(esize, pStubMsg->MaxCount);
|
2007-11-28 16:02:39 +01:00
|
|
|
if (pCStructFormat->memory_size + bufsize < pCStructFormat->memory_size) /* integer overflow */
|
|
|
|
{
|
|
|
|
ERR("integer overflow of memory_size %u with bufsize %u\n",
|
|
|
|
pCStructFormat->memory_size, bufsize);
|
|
|
|
RpcRaiseException(RPC_X_BAD_STUB_DATA);
|
|
|
|
}
|
2005-11-28 11:30:12 +01:00
|
|
|
/* copy constant sized part of struct */
|
2006-05-15 14:35:31 +02:00
|
|
|
pStubMsg->BufferMark = pStubMsg->Buffer;
|
2007-11-28 16:02:06 +01:00
|
|
|
safe_copy_to_buffer(pStubMsg, pMemory, pCStructFormat->memory_size + bufsize);
|
2005-11-28 11:30:12 +01:00
|
|
|
|
2018-06-13 04:19:10 +02:00
|
|
|
if (pCStructFormat->type == FC_CPSTRUCT)
|
2005-11-28 11:30:12 +01:00
|
|
|
EmbeddedPointerMarshall(pStubMsg, pMemory, pFormat);
|
2006-05-15 14:35:31 +02:00
|
|
|
|
2005-07-18 15:14:05 +02:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* NdrConformantStructUnmarshall [RPCRT4.@]
|
|
|
|
*/
|
|
|
|
unsigned char * WINAPI NdrConformantStructUnmarshall(PMIDL_STUB_MESSAGE pStubMsg,
|
|
|
|
unsigned char **ppMemory,
|
|
|
|
PFORMAT_STRING pFormat,
|
|
|
|
unsigned char fMustAlloc)
|
|
|
|
{
|
2006-09-25 23:20:20 +02:00
|
|
|
const NDR_CSTRUCT_FORMAT *pCStructFormat = (const NDR_CSTRUCT_FORMAT *)pFormat;
|
2006-05-15 14:35:31 +02:00
|
|
|
PFORMAT_STRING pCArrayFormat;
|
2006-06-10 13:32:24 +02:00
|
|
|
ULONG esize, bufsize;
|
2007-12-08 18:14:24 +01:00
|
|
|
unsigned char *saved_buffer;
|
2005-11-28 11:30:12 +01:00
|
|
|
|
|
|
|
TRACE("(%p, %p, %p, %d)\n", pStubMsg, ppMemory, pFormat, fMustAlloc);
|
|
|
|
|
2006-05-15 14:35:31 +02:00
|
|
|
pFormat += sizeof(NDR_CSTRUCT_FORMAT);
|
2018-06-13 04:19:10 +02:00
|
|
|
if ((pCStructFormat->type != FC_CPSTRUCT) && (pCStructFormat->type != FC_CSTRUCT))
|
2005-11-28 11:30:12 +01:00
|
|
|
{
|
|
|
|
ERR("invalid format type %x\n", pCStructFormat->type);
|
|
|
|
RpcRaiseException(RPC_S_INTERNAL_ERROR);
|
|
|
|
return NULL;
|
|
|
|
}
|
2006-09-25 23:20:20 +02:00
|
|
|
pCArrayFormat = (const unsigned char *)&pCStructFormat->offset_to_array_description +
|
2006-05-15 14:35:31 +02:00
|
|
|
pCStructFormat->offset_to_array_description;
|
2018-06-13 04:19:10 +02:00
|
|
|
if (*pCArrayFormat != FC_CARRAY)
|
2006-05-15 14:35:31 +02:00
|
|
|
{
|
|
|
|
ERR("invalid array format type %x\n", pCStructFormat->type);
|
|
|
|
RpcRaiseException(RPC_S_INTERNAL_ERROR);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
esize = *(const WORD*)(pCArrayFormat+2);
|
|
|
|
|
|
|
|
pCArrayFormat = ReadConformance(pStubMsg, pCArrayFormat + 4);
|
2005-11-28 11:30:12 +01:00
|
|
|
|
2010-04-02 21:54:55 +02:00
|
|
|
align_pointer(&pStubMsg->Buffer, pCStructFormat->alignment + 1);
|
2006-05-10 14:12:30 +02:00
|
|
|
|
2005-11-28 11:30:12 +01:00
|
|
|
TRACE("memory_size = %d\n", pCStructFormat->memory_size);
|
|
|
|
|
2006-06-10 13:32:24 +02:00
|
|
|
bufsize = safe_multiply(esize, pStubMsg->MaxCount);
|
2007-11-28 16:02:39 +01:00
|
|
|
if (pCStructFormat->memory_size + bufsize < pCStructFormat->memory_size) /* integer overflow */
|
|
|
|
{
|
|
|
|
ERR("integer overflow of memory_size %u with bufsize %u\n",
|
|
|
|
pCStructFormat->memory_size, bufsize);
|
|
|
|
RpcRaiseException(RPC_X_BAD_STUB_DATA);
|
|
|
|
}
|
2007-12-08 18:14:24 +01:00
|
|
|
|
|
|
|
if (fMustAlloc)
|
2005-11-28 11:30:12 +01:00
|
|
|
{
|
2006-06-10 13:32:24 +02:00
|
|
|
SIZE_T size = pCStructFormat->memory_size + bufsize;
|
2018-10-28 23:25:47 +01:00
|
|
|
*ppMemory = NdrAllocateZero(pStubMsg, size);
|
2005-11-28 11:30:12 +01:00
|
|
|
}
|
2007-12-08 18:14:24 +01:00
|
|
|
else
|
|
|
|
{
|
|
|
|
if (!pStubMsg->IsClient && !*ppMemory)
|
|
|
|
/* for servers, we just point straight into the RPC buffer */
|
|
|
|
*ppMemory = pStubMsg->Buffer;
|
|
|
|
}
|
2005-11-28 11:30:12 +01:00
|
|
|
|
2007-12-08 18:14:24 +01:00
|
|
|
saved_buffer = pStubMsg->BufferMark = pStubMsg->Buffer;
|
|
|
|
safe_buffer_increment(pStubMsg, pCStructFormat->memory_size + bufsize);
|
2018-06-13 04:19:10 +02:00
|
|
|
if (pCStructFormat->type == FC_CPSTRUCT)
|
2007-12-08 18:14:24 +01:00
|
|
|
EmbeddedPointerUnmarshall(pStubMsg, saved_buffer, *ppMemory, pFormat, fMustAlloc);
|
|
|
|
|
|
|
|
TRACE("copying %p to %p\n", saved_buffer, *ppMemory);
|
|
|
|
if (*ppMemory != saved_buffer)
|
|
|
|
memcpy(*ppMemory, saved_buffer, pCStructFormat->memory_size + bufsize);
|
2006-05-15 14:35:31 +02:00
|
|
|
|
2005-07-18 15:14:05 +02:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* NdrConformantStructBufferSize [RPCRT4.@]
|
|
|
|
*/
|
|
|
|
void WINAPI NdrConformantStructBufferSize(PMIDL_STUB_MESSAGE pStubMsg,
|
|
|
|
unsigned char *pMemory,
|
|
|
|
PFORMAT_STRING pFormat)
|
|
|
|
{
|
2006-09-25 23:20:20 +02:00
|
|
|
const NDR_CSTRUCT_FORMAT * pCStructFormat = (const NDR_CSTRUCT_FORMAT *)pFormat;
|
2006-05-15 14:35:31 +02:00
|
|
|
PFORMAT_STRING pCArrayFormat;
|
|
|
|
ULONG esize;
|
|
|
|
|
2005-11-28 11:30:12 +01:00
|
|
|
TRACE("(%p, %p, %p)\n", pStubMsg, pMemory, pFormat);
|
|
|
|
|
2006-05-15 14:35:31 +02:00
|
|
|
pFormat += sizeof(NDR_CSTRUCT_FORMAT);
|
2018-06-13 04:19:10 +02:00
|
|
|
if ((pCStructFormat->type != FC_CPSTRUCT) && (pCStructFormat->type != FC_CSTRUCT))
|
2005-11-28 11:30:12 +01:00
|
|
|
{
|
|
|
|
ERR("invalid format type %x\n", pCStructFormat->type);
|
|
|
|
RpcRaiseException(RPC_S_INTERNAL_ERROR);
|
|
|
|
return;
|
|
|
|
}
|
2006-09-25 23:20:20 +02:00
|
|
|
pCArrayFormat = (const unsigned char *)&pCStructFormat->offset_to_array_description +
|
2006-05-15 14:35:31 +02:00
|
|
|
pCStructFormat->offset_to_array_description;
|
2018-06-13 04:19:10 +02:00
|
|
|
if (*pCArrayFormat != FC_CARRAY)
|
2006-05-15 14:35:31 +02:00
|
|
|
{
|
|
|
|
ERR("invalid array format type %x\n", pCStructFormat->type);
|
|
|
|
RpcRaiseException(RPC_S_INTERNAL_ERROR);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
esize = *(const WORD*)(pCArrayFormat+2);
|
|
|
|
|
|
|
|
pCArrayFormat = ComputeConformance(pStubMsg, pMemory + pCStructFormat->memory_size, pCArrayFormat+4, 0);
|
|
|
|
SizeConformance(pStubMsg);
|
2005-11-28 11:30:12 +01:00
|
|
|
|
2010-04-02 21:54:55 +02:00
|
|
|
align_length(&pStubMsg->BufferLength, pCStructFormat->alignment + 1);
|
2006-05-10 14:12:30 +02:00
|
|
|
|
2005-11-28 11:30:12 +01:00
|
|
|
TRACE("memory_size = %d\n", pCStructFormat->memory_size);
|
|
|
|
|
2007-11-28 16:01:53 +01:00
|
|
|
safe_buffer_length_increment(pStubMsg, pCStructFormat->memory_size);
|
|
|
|
safe_buffer_length_increment(pStubMsg, safe_multiply(pStubMsg->MaxCount, esize));
|
2005-11-28 11:30:12 +01:00
|
|
|
|
2018-06-13 04:19:10 +02:00
|
|
|
if (pCStructFormat->type == FC_CPSTRUCT)
|
2005-11-28 11:30:12 +01:00
|
|
|
EmbeddedPointerBufferSize(pStubMsg, pMemory, pFormat);
|
2005-07-18 15:14:05 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* NdrConformantStructMemorySize [RPCRT4.@]
|
|
|
|
*/
|
2006-11-09 23:01:58 +01:00
|
|
|
ULONG WINAPI NdrConformantStructMemorySize(PMIDL_STUB_MESSAGE pStubMsg,
|
2005-07-18 15:14:05 +02:00
|
|
|
PFORMAT_STRING pFormat)
|
|
|
|
{
|
|
|
|
FIXME("stub\n");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* NdrConformantStructFree [RPCRT4.@]
|
|
|
|
*/
|
|
|
|
void WINAPI NdrConformantStructFree(PMIDL_STUB_MESSAGE pStubMsg,
|
|
|
|
unsigned char *pMemory,
|
|
|
|
PFORMAT_STRING pFormat)
|
|
|
|
{
|
2007-12-06 15:06:02 +01:00
|
|
|
const NDR_CSTRUCT_FORMAT *pCStructFormat = (const NDR_CSTRUCT_FORMAT *)pFormat;
|
|
|
|
PFORMAT_STRING pCArrayFormat;
|
|
|
|
|
|
|
|
TRACE("(%p, %p, %p)\n", pStubMsg, pMemory, pFormat);
|
|
|
|
|
|
|
|
pFormat += sizeof(NDR_CSTRUCT_FORMAT);
|
2018-06-13 04:19:10 +02:00
|
|
|
if ((pCStructFormat->type != FC_CPSTRUCT) && (pCStructFormat->type != FC_CSTRUCT))
|
2007-12-06 15:06:02 +01:00
|
|
|
{
|
|
|
|
ERR("invalid format type %x\n", pCStructFormat->type);
|
|
|
|
RpcRaiseException(RPC_S_INTERNAL_ERROR);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
pCArrayFormat = (const unsigned char *)&pCStructFormat->offset_to_array_description +
|
|
|
|
pCStructFormat->offset_to_array_description;
|
2018-06-13 04:19:10 +02:00
|
|
|
if (*pCArrayFormat != FC_CARRAY)
|
2007-12-06 15:06:02 +01:00
|
|
|
{
|
|
|
|
ERR("invalid array format type %x\n", pCStructFormat->type);
|
|
|
|
RpcRaiseException(RPC_S_INTERNAL_ERROR);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
ComputeConformance(pStubMsg, pMemory + pCStructFormat->memory_size,
|
|
|
|
pCArrayFormat + 4, 0);
|
|
|
|
|
|
|
|
TRACE("memory_size = %d\n", pCStructFormat->memory_size);
|
|
|
|
|
|
|
|
/* copy constant sized part of struct */
|
|
|
|
pStubMsg->BufferMark = pStubMsg->Buffer;
|
|
|
|
|
2018-06-13 04:19:10 +02:00
|
|
|
if (pCStructFormat->type == FC_CPSTRUCT)
|
2007-12-06 15:06:02 +01:00
|
|
|
EmbeddedPointerFree(pStubMsg, pMemory, pFormat);
|
2005-07-18 15:14:05 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* NdrConformantVaryingStructMarshall [RPCRT4.@]
|
|
|
|
*/
|
|
|
|
unsigned char * WINAPI NdrConformantVaryingStructMarshall(PMIDL_STUB_MESSAGE pStubMsg,
|
|
|
|
unsigned char *pMemory,
|
|
|
|
PFORMAT_STRING pFormat)
|
|
|
|
{
|
2006-09-25 23:20:20 +02:00
|
|
|
const NDR_CVSTRUCT_FORMAT *pCVStructFormat = (const NDR_CVSTRUCT_FORMAT *)pFormat;
|
2006-05-15 17:56:37 +02:00
|
|
|
PFORMAT_STRING pCVArrayFormat;
|
|
|
|
|
|
|
|
TRACE("(%p, %p, %p)\n", pStubMsg, pMemory, pFormat);
|
|
|
|
|
|
|
|
pFormat += sizeof(NDR_CVSTRUCT_FORMAT);
|
2018-06-13 04:19:10 +02:00
|
|
|
if (pCVStructFormat->type != FC_CVSTRUCT)
|
2006-05-15 17:56:37 +02:00
|
|
|
{
|
|
|
|
ERR("invalid format type %x\n", pCVStructFormat->type);
|
|
|
|
RpcRaiseException(RPC_S_INTERNAL_ERROR);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2006-09-25 23:20:20 +02:00
|
|
|
pCVArrayFormat = (const unsigned char *)&pCVStructFormat->offset_to_array_description +
|
2006-05-15 17:56:37 +02:00
|
|
|
pCVStructFormat->offset_to_array_description;
|
|
|
|
|
2008-08-10 12:14:30 +02:00
|
|
|
array_compute_and_write_conformance(*pCVArrayFormat, pStubMsg,
|
|
|
|
pMemory + pCVStructFormat->memory_size,
|
|
|
|
pCVArrayFormat);
|
2006-05-15 17:56:37 +02:00
|
|
|
|
2010-04-02 21:54:55 +02:00
|
|
|
align_pointer_clear(&pStubMsg->Buffer, pCVStructFormat->alignment + 1);
|
2006-05-15 17:56:37 +02:00
|
|
|
|
|
|
|
TRACE("memory_size = %d\n", pCVStructFormat->memory_size);
|
|
|
|
|
2006-05-15 17:56:55 +02:00
|
|
|
/* write constant sized part */
|
2006-05-15 17:56:37 +02:00
|
|
|
pStubMsg->BufferMark = pStubMsg->Buffer;
|
2007-11-28 16:02:06 +01:00
|
|
|
safe_copy_to_buffer(pStubMsg, pMemory, pCVStructFormat->memory_size);
|
2006-05-15 17:56:55 +02:00
|
|
|
|
2008-08-10 12:14:30 +02:00
|
|
|
array_write_variance_and_marshall(*pCVArrayFormat, pStubMsg,
|
|
|
|
pMemory + pCVStructFormat->memory_size,
|
|
|
|
pCVArrayFormat, FALSE /* fHasPointers */);
|
2006-05-15 17:56:37 +02:00
|
|
|
|
|
|
|
EmbeddedPointerMarshall(pStubMsg, pMemory, pFormat);
|
|
|
|
|
2005-07-18 15:14:05 +02:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* NdrConformantVaryingStructUnmarshall [RPCRT4.@]
|
|
|
|
*/
|
|
|
|
unsigned char * WINAPI NdrConformantVaryingStructUnmarshall(PMIDL_STUB_MESSAGE pStubMsg,
|
|
|
|
unsigned char **ppMemory,
|
|
|
|
PFORMAT_STRING pFormat,
|
|
|
|
unsigned char fMustAlloc)
|
|
|
|
{
|
2006-09-25 23:20:20 +02:00
|
|
|
const NDR_CVSTRUCT_FORMAT *pCVStructFormat = (const NDR_CVSTRUCT_FORMAT *)pFormat;
|
2006-05-15 17:56:37 +02:00
|
|
|
PFORMAT_STRING pCVArrayFormat;
|
2008-08-10 12:14:30 +02:00
|
|
|
ULONG memsize, bufsize;
|
2008-06-23 13:56:49 +02:00
|
|
|
unsigned char *saved_buffer, *saved_array_buffer;
|
2008-08-10 12:14:30 +02:00
|
|
|
ULONG offset;
|
|
|
|
unsigned char *array_memory;
|
2006-05-15 17:56:37 +02:00
|
|
|
|
|
|
|
TRACE("(%p, %p, %p, %d)\n", pStubMsg, ppMemory, pFormat, fMustAlloc);
|
|
|
|
|
|
|
|
pFormat += sizeof(NDR_CVSTRUCT_FORMAT);
|
2018-06-13 04:19:10 +02:00
|
|
|
if (pCVStructFormat->type != FC_CVSTRUCT)
|
2006-05-15 17:56:37 +02:00
|
|
|
{
|
|
|
|
ERR("invalid format type %x\n", pCVStructFormat->type);
|
|
|
|
RpcRaiseException(RPC_S_INTERNAL_ERROR);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2006-09-25 23:20:20 +02:00
|
|
|
pCVArrayFormat = (const unsigned char *)&pCVStructFormat->offset_to_array_description +
|
2006-05-15 17:56:37 +02:00
|
|
|
pCVStructFormat->offset_to_array_description;
|
2008-08-10 12:14:30 +02:00
|
|
|
|
|
|
|
memsize = array_read_conformance(*pCVArrayFormat, pStubMsg,
|
|
|
|
pCVArrayFormat);
|
2006-05-15 17:56:37 +02:00
|
|
|
|
2010-04-02 21:54:55 +02:00
|
|
|
align_pointer(&pStubMsg->Buffer, pCVStructFormat->alignment + 1);
|
2006-05-15 17:56:37 +02:00
|
|
|
|
|
|
|
TRACE("memory_size = %d\n", pCVStructFormat->memory_size);
|
|
|
|
|
|
|
|
/* work out how much memory to allocate if we need to do so */
|
2009-01-10 23:17:15 +01:00
|
|
|
if (!fMustAlloc && !*ppMemory)
|
|
|
|
fMustAlloc = TRUE;
|
|
|
|
if (fMustAlloc)
|
2006-05-15 17:56:37 +02:00
|
|
|
{
|
2008-08-10 12:14:30 +02:00
|
|
|
SIZE_T size = pCVStructFormat->memory_size + memsize;
|
2018-10-28 23:25:47 +01:00
|
|
|
*ppMemory = NdrAllocateZero(pStubMsg, size);
|
2006-05-15 17:56:37 +02:00
|
|
|
}
|
|
|
|
|
2008-06-23 13:56:49 +02:00
|
|
|
/* mark the start of the constant data */
|
|
|
|
saved_buffer = pStubMsg->BufferMark = pStubMsg->Buffer;
|
|
|
|
safe_buffer_increment(pStubMsg, pCVStructFormat->memory_size);
|
2006-05-15 17:56:55 +02:00
|
|
|
|
2008-08-10 12:14:30 +02:00
|
|
|
array_memory = *ppMemory + pCVStructFormat->memory_size;
|
|
|
|
bufsize = array_read_variance_and_unmarshall(*pCVArrayFormat, pStubMsg,
|
|
|
|
&array_memory, pCVArrayFormat,
|
|
|
|
FALSE /* fMustAlloc */,
|
|
|
|
FALSE /* fUseServerBufferMemory */,
|
|
|
|
FALSE /* fUnmarshall */);
|
2006-06-10 13:32:35 +02:00
|
|
|
|
2008-08-10 12:14:30 +02:00
|
|
|
/* save offset in case unmarshalling pointers changes it */
|
|
|
|
offset = pStubMsg->Offset;
|
2006-06-10 13:32:35 +02:00
|
|
|
|
2008-06-23 13:56:49 +02:00
|
|
|
/* mark the start of the array data */
|
|
|
|
saved_array_buffer = pStubMsg->Buffer;
|
|
|
|
safe_buffer_increment(pStubMsg, bufsize);
|
|
|
|
|
|
|
|
EmbeddedPointerUnmarshall(pStubMsg, saved_buffer, *ppMemory, pFormat, fMustAlloc);
|
|
|
|
|
|
|
|
/* copy the constant data */
|
|
|
|
memcpy(*ppMemory, saved_buffer, pCVStructFormat->memory_size);
|
2006-05-15 17:56:55 +02:00
|
|
|
/* copy the array data */
|
2008-06-23 13:56:49 +02:00
|
|
|
TRACE("copying %p to %p\n", saved_array_buffer, *ppMemory + pCVStructFormat->memory_size);
|
2008-08-10 12:14:30 +02:00
|
|
|
memcpy(*ppMemory + pCVStructFormat->memory_size + offset,
|
|
|
|
saved_array_buffer, bufsize);
|
2006-05-15 17:56:37 +02:00
|
|
|
|
2018-06-13 04:19:10 +02:00
|
|
|
if (*pCVArrayFormat == FC_C_CSTRING)
|
2006-05-15 17:56:37 +02:00
|
|
|
TRACE("string=%s\n", debugstr_a((char *)(*ppMemory + pCVStructFormat->memory_size)));
|
2018-06-13 04:19:10 +02:00
|
|
|
else if (*pCVArrayFormat == FC_C_WSTRING)
|
2006-05-15 17:56:37 +02:00
|
|
|
TRACE("string=%s\n", debugstr_w((WCHAR *)(*ppMemory + pCVStructFormat->memory_size)));
|
|
|
|
|
2005-07-18 15:14:05 +02:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* NdrConformantVaryingStructBufferSize [RPCRT4.@]
|
|
|
|
*/
|
|
|
|
void WINAPI NdrConformantVaryingStructBufferSize(PMIDL_STUB_MESSAGE pStubMsg,
|
|
|
|
unsigned char *pMemory,
|
|
|
|
PFORMAT_STRING pFormat)
|
|
|
|
{
|
2006-09-25 23:20:20 +02:00
|
|
|
const NDR_CVSTRUCT_FORMAT *pCVStructFormat = (const NDR_CVSTRUCT_FORMAT *)pFormat;
|
2006-05-15 17:56:37 +02:00
|
|
|
PFORMAT_STRING pCVArrayFormat;
|
|
|
|
|
|
|
|
TRACE("(%p, %p, %p)\n", pStubMsg, pMemory, pFormat);
|
|
|
|
|
|
|
|
pFormat += sizeof(NDR_CVSTRUCT_FORMAT);
|
2018-06-13 04:19:10 +02:00
|
|
|
if (pCVStructFormat->type != FC_CVSTRUCT)
|
2006-05-15 17:56:37 +02:00
|
|
|
{
|
|
|
|
ERR("invalid format type %x\n", pCVStructFormat->type);
|
|
|
|
RpcRaiseException(RPC_S_INTERNAL_ERROR);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2006-09-25 23:20:20 +02:00
|
|
|
pCVArrayFormat = (const unsigned char *)&pCVStructFormat->offset_to_array_description +
|
2006-05-15 17:56:37 +02:00
|
|
|
pCVStructFormat->offset_to_array_description;
|
2008-08-10 12:14:30 +02:00
|
|
|
array_compute_and_size_conformance(*pCVArrayFormat, pStubMsg,
|
|
|
|
pMemory + pCVStructFormat->memory_size,
|
|
|
|
pCVArrayFormat);
|
2006-05-15 17:56:37 +02:00
|
|
|
|
2010-04-02 21:54:55 +02:00
|
|
|
align_length(&pStubMsg->BufferLength, pCVStructFormat->alignment + 1);
|
2006-05-15 17:56:37 +02:00
|
|
|
|
|
|
|
TRACE("memory_size = %d\n", pCVStructFormat->memory_size);
|
|
|
|
|
2007-11-28 16:01:53 +01:00
|
|
|
safe_buffer_length_increment(pStubMsg, pCVStructFormat->memory_size);
|
2008-08-10 12:14:30 +02:00
|
|
|
|
|
|
|
array_buffer_size(*pCVArrayFormat, pStubMsg,
|
|
|
|
pMemory + pCVStructFormat->memory_size, pCVArrayFormat,
|
|
|
|
FALSE /* fHasPointers */);
|
2006-05-15 17:56:37 +02:00
|
|
|
|
|
|
|
EmbeddedPointerBufferSize(pStubMsg, pMemory, pFormat);
|
2005-07-18 15:14:05 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* NdrConformantVaryingStructMemorySize [RPCRT4.@]
|
|
|
|
*/
|
2006-11-09 23:01:58 +01:00
|
|
|
ULONG WINAPI NdrConformantVaryingStructMemorySize(PMIDL_STUB_MESSAGE pStubMsg,
|
2005-07-18 15:14:05 +02:00
|
|
|
PFORMAT_STRING pFormat)
|
|
|
|
{
|
2006-09-25 23:20:20 +02:00
|
|
|
const NDR_CVSTRUCT_FORMAT *pCVStructFormat = (const NDR_CVSTRUCT_FORMAT *)pFormat;
|
2006-05-15 17:56:37 +02:00
|
|
|
PFORMAT_STRING pCVArrayFormat;
|
|
|
|
|
|
|
|
TRACE("(%p, %p)\n", pStubMsg, pFormat);
|
|
|
|
|
|
|
|
pFormat += sizeof(NDR_CVSTRUCT_FORMAT);
|
2018-06-13 04:19:10 +02:00
|
|
|
if (pCVStructFormat->type != FC_CVSTRUCT)
|
2006-05-15 17:56:37 +02:00
|
|
|
{
|
|
|
|
ERR("invalid format type %x\n", pCVStructFormat->type);
|
|
|
|
RpcRaiseException(RPC_S_INTERNAL_ERROR);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2006-09-25 23:20:20 +02:00
|
|
|
pCVArrayFormat = (const unsigned char *)&pCVStructFormat->offset_to_array_description +
|
2006-05-15 17:56:37 +02:00
|
|
|
pCVStructFormat->offset_to_array_description;
|
2008-08-10 12:14:30 +02:00
|
|
|
array_read_conformance(*pCVArrayFormat, pStubMsg, pCVArrayFormat);
|
2006-05-15 17:56:37 +02:00
|
|
|
|
2010-04-02 21:54:55 +02:00
|
|
|
align_pointer(&pStubMsg->Buffer, pCVStructFormat->alignment + 1);
|
2006-05-15 17:56:37 +02:00
|
|
|
|
|
|
|
TRACE("memory_size = %d\n", pCVStructFormat->memory_size);
|
|
|
|
|
2007-11-28 16:02:21 +01:00
|
|
|
safe_buffer_increment(pStubMsg, pCVStructFormat->memory_size);
|
2008-08-10 12:14:30 +02:00
|
|
|
array_memory_size(*pCVArrayFormat, pStubMsg, pCVArrayFormat,
|
|
|
|
FALSE /* fHasPointers */);
|
2006-05-15 17:56:55 +02:00
|
|
|
|
2008-08-10 12:14:30 +02:00
|
|
|
pStubMsg->MemorySize += pCVStructFormat->memory_size;
|
2006-05-15 17:56:37 +02:00
|
|
|
|
|
|
|
EmbeddedPointerMemorySize(pStubMsg, pFormat);
|
|
|
|
|
2008-08-10 12:14:30 +02:00
|
|
|
return pStubMsg->MemorySize;
|
2005-07-18 15:14:05 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* NdrConformantVaryingStructFree [RPCRT4.@]
|
|
|
|
*/
|
|
|
|
void WINAPI NdrConformantVaryingStructFree(PMIDL_STUB_MESSAGE pStubMsg,
|
|
|
|
unsigned char *pMemory,
|
|
|
|
PFORMAT_STRING pFormat)
|
|
|
|
{
|
2006-09-25 23:20:20 +02:00
|
|
|
const NDR_CVSTRUCT_FORMAT *pCVStructFormat = (const NDR_CVSTRUCT_FORMAT *)pFormat;
|
2006-05-15 17:56:37 +02:00
|
|
|
PFORMAT_STRING pCVArrayFormat;
|
|
|
|
|
|
|
|
TRACE("(%p, %p, %p)\n", pStubMsg, pMemory, pFormat);
|
|
|
|
|
|
|
|
pFormat += sizeof(NDR_CVSTRUCT_FORMAT);
|
2018-06-13 04:19:10 +02:00
|
|
|
if (pCVStructFormat->type != FC_CVSTRUCT)
|
2006-05-15 17:56:37 +02:00
|
|
|
{
|
|
|
|
ERR("invalid format type %x\n", pCVStructFormat->type);
|
|
|
|
RpcRaiseException(RPC_S_INTERNAL_ERROR);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2006-09-25 23:20:20 +02:00
|
|
|
pCVArrayFormat = (const unsigned char *)&pCVStructFormat->offset_to_array_description +
|
2006-05-15 17:56:37 +02:00
|
|
|
pCVStructFormat->offset_to_array_description;
|
2008-08-10 12:14:30 +02:00
|
|
|
array_free(*pCVArrayFormat, pStubMsg,
|
|
|
|
pMemory + pCVStructFormat->memory_size, pCVArrayFormat,
|
|
|
|
FALSE /* fHasPointers */);
|
2006-05-15 17:56:37 +02:00
|
|
|
|
|
|
|
TRACE("memory_size = %d\n", pCVStructFormat->memory_size);
|
|
|
|
|
|
|
|
EmbeddedPointerFree(pStubMsg, pMemory, pFormat);
|
2005-07-18 15:14:05 +02:00
|
|
|
}
|
|
|
|
|
2007-02-12 14:29:04 +01:00
|
|
|
#include "pshpack1.h"
|
2006-05-15 17:57:21 +02:00
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
unsigned char type;
|
|
|
|
unsigned char alignment;
|
|
|
|
unsigned short total_size;
|
|
|
|
} NDR_SMFARRAY_FORMAT;
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
unsigned char type;
|
|
|
|
unsigned char alignment;
|
2009-04-21 09:59:45 +02:00
|
|
|
ULONG total_size;
|
2006-05-15 17:57:21 +02:00
|
|
|
} NDR_LGFARRAY_FORMAT;
|
2007-02-12 14:29:04 +01:00
|
|
|
#include "poppack.h"
|
2006-05-15 17:57:21 +02:00
|
|
|
|
2005-07-18 15:14:05 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* NdrFixedArrayMarshall [RPCRT4.@]
|
|
|
|
*/
|
|
|
|
unsigned char * WINAPI NdrFixedArrayMarshall(PMIDL_STUB_MESSAGE pStubMsg,
|
|
|
|
unsigned char *pMemory,
|
|
|
|
PFORMAT_STRING pFormat)
|
|
|
|
{
|
2006-05-15 17:57:21 +02:00
|
|
|
const NDR_SMFARRAY_FORMAT *pSmFArrayFormat = (const NDR_SMFARRAY_FORMAT *)pFormat;
|
2009-04-21 09:59:45 +02:00
|
|
|
ULONG total_size;
|
2006-05-15 17:57:21 +02:00
|
|
|
|
|
|
|
TRACE("(%p, %p, %p)\n", pStubMsg, pMemory, pFormat);
|
|
|
|
|
2018-06-13 04:19:10 +02:00
|
|
|
if ((pSmFArrayFormat->type != FC_SMFARRAY) &&
|
|
|
|
(pSmFArrayFormat->type != FC_LGFARRAY))
|
2006-05-15 17:57:21 +02:00
|
|
|
{
|
|
|
|
ERR("invalid format type %x\n", pSmFArrayFormat->type);
|
|
|
|
RpcRaiseException(RPC_S_INTERNAL_ERROR);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2010-04-02 21:54:55 +02:00
|
|
|
align_pointer_clear(&pStubMsg->Buffer, pSmFArrayFormat->alignment + 1);
|
2006-05-15 17:57:21 +02:00
|
|
|
|
2018-06-13 04:19:10 +02:00
|
|
|
if (pSmFArrayFormat->type == FC_SMFARRAY)
|
2006-05-15 17:57:21 +02:00
|
|
|
{
|
|
|
|
total_size = pSmFArrayFormat->total_size;
|
2006-09-25 23:20:20 +02:00
|
|
|
pFormat = (const unsigned char *)(pSmFArrayFormat + 1);
|
2006-05-15 17:57:21 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
const NDR_LGFARRAY_FORMAT *pLgFArrayFormat = (const NDR_LGFARRAY_FORMAT *)pFormat;
|
|
|
|
total_size = pLgFArrayFormat->total_size;
|
2006-09-25 23:20:20 +02:00
|
|
|
pFormat = (const unsigned char *)(pLgFArrayFormat + 1);
|
2006-05-15 17:57:21 +02:00
|
|
|
}
|
2006-07-24 12:46:03 +02:00
|
|
|
|
|
|
|
pStubMsg->BufferMark = pStubMsg->Buffer;
|
2007-11-28 16:02:06 +01:00
|
|
|
safe_copy_to_buffer(pStubMsg, pMemory, total_size);
|
2006-05-15 17:57:21 +02:00
|
|
|
|
|
|
|
pFormat = EmbeddedPointerMarshall(pStubMsg, pMemory, pFormat);
|
|
|
|
|
2005-07-18 15:14:05 +02:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* NdrFixedArrayUnmarshall [RPCRT4.@]
|
|
|
|
*/
|
|
|
|
unsigned char * WINAPI NdrFixedArrayUnmarshall(PMIDL_STUB_MESSAGE pStubMsg,
|
|
|
|
unsigned char **ppMemory,
|
|
|
|
PFORMAT_STRING pFormat,
|
|
|
|
unsigned char fMustAlloc)
|
|
|
|
{
|
2006-05-15 17:57:21 +02:00
|
|
|
const NDR_SMFARRAY_FORMAT *pSmFArrayFormat = (const NDR_SMFARRAY_FORMAT *)pFormat;
|
2009-04-21 09:59:45 +02:00
|
|
|
ULONG total_size;
|
2007-12-08 18:14:16 +01:00
|
|
|
unsigned char *saved_buffer;
|
2006-05-15 17:57:21 +02:00
|
|
|
|
|
|
|
TRACE("(%p, %p, %p, %d)\n", pStubMsg, ppMemory, pFormat, fMustAlloc);
|
|
|
|
|
2018-06-13 04:19:10 +02:00
|
|
|
if ((pSmFArrayFormat->type != FC_SMFARRAY) &&
|
|
|
|
(pSmFArrayFormat->type != FC_LGFARRAY))
|
2006-05-15 17:57:21 +02:00
|
|
|
{
|
|
|
|
ERR("invalid format type %x\n", pSmFArrayFormat->type);
|
|
|
|
RpcRaiseException(RPC_S_INTERNAL_ERROR);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2010-04-02 21:54:55 +02:00
|
|
|
align_pointer(&pStubMsg->Buffer, pSmFArrayFormat->alignment + 1);
|
2006-05-15 17:57:21 +02:00
|
|
|
|
2018-06-13 04:19:10 +02:00
|
|
|
if (pSmFArrayFormat->type == FC_SMFARRAY)
|
2006-05-15 17:57:21 +02:00
|
|
|
{
|
|
|
|
total_size = pSmFArrayFormat->total_size;
|
2006-09-25 23:20:20 +02:00
|
|
|
pFormat = (const unsigned char *)(pSmFArrayFormat + 1);
|
2006-05-15 17:57:21 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
const NDR_LGFARRAY_FORMAT *pLgFArrayFormat = (const NDR_LGFARRAY_FORMAT *)pFormat;
|
|
|
|
total_size = pLgFArrayFormat->total_size;
|
2006-09-25 23:20:20 +02:00
|
|
|
pFormat = (const unsigned char *)(pLgFArrayFormat + 1);
|
2006-05-15 17:57:21 +02:00
|
|
|
}
|
|
|
|
|
2007-12-08 18:14:16 +01:00
|
|
|
if (fMustAlloc)
|
2018-10-28 23:25:47 +01:00
|
|
|
*ppMemory = NdrAllocateZero(pStubMsg, total_size);
|
2007-12-08 18:14:16 +01:00
|
|
|
else
|
|
|
|
{
|
|
|
|
if (!pStubMsg->IsClient && !*ppMemory)
|
|
|
|
/* for servers, we just point straight into the RPC buffer */
|
|
|
|
*ppMemory = pStubMsg->Buffer;
|
|
|
|
}
|
|
|
|
|
|
|
|
saved_buffer = pStubMsg->BufferMark = pStubMsg->Buffer;
|
|
|
|
safe_buffer_increment(pStubMsg, total_size);
|
|
|
|
pFormat = EmbeddedPointerUnmarshall(pStubMsg, saved_buffer, *ppMemory, pFormat, fMustAlloc);
|
2006-05-15 17:57:21 +02:00
|
|
|
|
2007-12-08 18:14:16 +01:00
|
|
|
TRACE("copying %p to %p\n", saved_buffer, *ppMemory);
|
|
|
|
if (*ppMemory != saved_buffer)
|
|
|
|
memcpy(*ppMemory, saved_buffer, total_size);
|
2006-05-15 17:57:21 +02:00
|
|
|
|
2005-07-18 15:14:05 +02:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* NdrFixedArrayBufferSize [RPCRT4.@]
|
|
|
|
*/
|
|
|
|
void WINAPI NdrFixedArrayBufferSize(PMIDL_STUB_MESSAGE pStubMsg,
|
|
|
|
unsigned char *pMemory,
|
|
|
|
PFORMAT_STRING pFormat)
|
|
|
|
{
|
2006-05-15 17:57:21 +02:00
|
|
|
const NDR_SMFARRAY_FORMAT *pSmFArrayFormat = (const NDR_SMFARRAY_FORMAT *)pFormat;
|
2009-04-21 09:59:45 +02:00
|
|
|
ULONG total_size;
|
2006-05-15 17:57:21 +02:00
|
|
|
|
|
|
|
TRACE("(%p, %p, %p)\n", pStubMsg, pMemory, pFormat);
|
|
|
|
|
2018-06-13 04:19:10 +02:00
|
|
|
if ((pSmFArrayFormat->type != FC_SMFARRAY) &&
|
|
|
|
(pSmFArrayFormat->type != FC_LGFARRAY))
|
2006-05-15 17:57:21 +02:00
|
|
|
{
|
|
|
|
ERR("invalid format type %x\n", pSmFArrayFormat->type);
|
|
|
|
RpcRaiseException(RPC_S_INTERNAL_ERROR);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2010-04-02 21:54:55 +02:00
|
|
|
align_length(&pStubMsg->BufferLength, pSmFArrayFormat->alignment + 1);
|
2006-05-15 17:57:21 +02:00
|
|
|
|
2018-06-13 04:19:10 +02:00
|
|
|
if (pSmFArrayFormat->type == FC_SMFARRAY)
|
2006-05-15 17:57:21 +02:00
|
|
|
{
|
|
|
|
total_size = pSmFArrayFormat->total_size;
|
2006-09-25 23:20:20 +02:00
|
|
|
pFormat = (const unsigned char *)(pSmFArrayFormat + 1);
|
2006-05-15 17:57:21 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
const NDR_LGFARRAY_FORMAT *pLgFArrayFormat = (const NDR_LGFARRAY_FORMAT *)pFormat;
|
|
|
|
total_size = pLgFArrayFormat->total_size;
|
2006-09-25 23:20:20 +02:00
|
|
|
pFormat = (const unsigned char *)(pLgFArrayFormat + 1);
|
2006-05-15 17:57:21 +02:00
|
|
|
}
|
2007-11-28 16:01:53 +01:00
|
|
|
safe_buffer_length_increment(pStubMsg, total_size);
|
2006-05-15 17:57:21 +02:00
|
|
|
|
|
|
|
EmbeddedPointerBufferSize(pStubMsg, pMemory, pFormat);
|
2005-07-18 15:14:05 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* NdrFixedArrayMemorySize [RPCRT4.@]
|
|
|
|
*/
|
2006-11-09 23:01:58 +01:00
|
|
|
ULONG WINAPI NdrFixedArrayMemorySize(PMIDL_STUB_MESSAGE pStubMsg,
|
2005-07-18 15:14:05 +02:00
|
|
|
PFORMAT_STRING pFormat)
|
|
|
|
{
|
2006-05-15 17:57:21 +02:00
|
|
|
const NDR_SMFARRAY_FORMAT *pSmFArrayFormat = (const NDR_SMFARRAY_FORMAT *)pFormat;
|
2006-11-09 23:01:58 +01:00
|
|
|
ULONG total_size;
|
2006-05-15 17:57:21 +02:00
|
|
|
|
|
|
|
TRACE("(%p, %p)\n", pStubMsg, pFormat);
|
|
|
|
|
2018-06-13 04:19:10 +02:00
|
|
|
if ((pSmFArrayFormat->type != FC_SMFARRAY) &&
|
|
|
|
(pSmFArrayFormat->type != FC_LGFARRAY))
|
2006-05-15 17:57:21 +02:00
|
|
|
{
|
|
|
|
ERR("invalid format type %x\n", pSmFArrayFormat->type);
|
|
|
|
RpcRaiseException(RPC_S_INTERNAL_ERROR);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2010-04-02 21:54:55 +02:00
|
|
|
align_pointer(&pStubMsg->Buffer, pSmFArrayFormat->alignment + 1);
|
2006-05-15 17:57:21 +02:00
|
|
|
|
2018-06-13 04:19:10 +02:00
|
|
|
if (pSmFArrayFormat->type == FC_SMFARRAY)
|
2006-05-15 17:57:21 +02:00
|
|
|
{
|
|
|
|
total_size = pSmFArrayFormat->total_size;
|
2006-09-25 23:20:20 +02:00
|
|
|
pFormat = (const unsigned char *)(pSmFArrayFormat + 1);
|
2006-05-15 17:57:21 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
const NDR_LGFARRAY_FORMAT *pLgFArrayFormat = (const NDR_LGFARRAY_FORMAT *)pFormat;
|
|
|
|
total_size = pLgFArrayFormat->total_size;
|
2006-09-25 23:20:20 +02:00
|
|
|
pFormat = (const unsigned char *)(pLgFArrayFormat + 1);
|
2006-05-15 17:57:21 +02:00
|
|
|
}
|
2006-07-24 12:46:03 +02:00
|
|
|
pStubMsg->BufferMark = pStubMsg->Buffer;
|
2007-11-28 16:02:21 +01:00
|
|
|
safe_buffer_increment(pStubMsg, total_size);
|
2006-05-15 17:57:21 +02:00
|
|
|
pStubMsg->MemorySize += total_size;
|
|
|
|
|
|
|
|
EmbeddedPointerMemorySize(pStubMsg, pFormat);
|
|
|
|
|
|
|
|
return total_size;
|
2005-07-18 15:14:05 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* NdrFixedArrayFree [RPCRT4.@]
|
|
|
|
*/
|
|
|
|
void WINAPI NdrFixedArrayFree(PMIDL_STUB_MESSAGE pStubMsg,
|
|
|
|
unsigned char *pMemory,
|
|
|
|
PFORMAT_STRING pFormat)
|
|
|
|
{
|
2006-05-15 17:57:21 +02:00
|
|
|
const NDR_SMFARRAY_FORMAT *pSmFArrayFormat = (const NDR_SMFARRAY_FORMAT *)pFormat;
|
|
|
|
|
|
|
|
TRACE("(%p, %p, %p)\n", pStubMsg, pMemory, pFormat);
|
|
|
|
|
2018-06-13 04:19:10 +02:00
|
|
|
if ((pSmFArrayFormat->type != FC_SMFARRAY) &&
|
|
|
|
(pSmFArrayFormat->type != FC_LGFARRAY))
|
2006-05-15 17:57:21 +02:00
|
|
|
{
|
|
|
|
ERR("invalid format type %x\n", pSmFArrayFormat->type);
|
|
|
|
RpcRaiseException(RPC_S_INTERNAL_ERROR);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-06-13 04:19:10 +02:00
|
|
|
if (pSmFArrayFormat->type == FC_SMFARRAY)
|
2006-09-25 23:20:20 +02:00
|
|
|
pFormat = (const unsigned char *)(pSmFArrayFormat + 1);
|
2006-05-15 17:57:21 +02:00
|
|
|
else
|
|
|
|
{
|
|
|
|
const NDR_LGFARRAY_FORMAT *pLgFArrayFormat = (const NDR_LGFARRAY_FORMAT *)pFormat;
|
2006-09-25 23:20:20 +02:00
|
|
|
pFormat = (const unsigned char *)(pLgFArrayFormat + 1);
|
2006-05-15 17:57:21 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
EmbeddedPointerFree(pStubMsg, pMemory, pFormat);
|
2005-07-18 15:14:05 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* NdrVaryingArrayMarshall [RPCRT4.@]
|
|
|
|
*/
|
|
|
|
unsigned char * WINAPI NdrVaryingArrayMarshall(PMIDL_STUB_MESSAGE pStubMsg,
|
|
|
|
unsigned char *pMemory,
|
|
|
|
PFORMAT_STRING pFormat)
|
|
|
|
{
|
2006-06-05 02:41:30 +02:00
|
|
|
unsigned char alignment;
|
|
|
|
DWORD elements, esize;
|
2006-06-10 13:32:24 +02:00
|
|
|
ULONG bufsize;
|
2006-06-05 02:41:30 +02:00
|
|
|
|
|
|
|
TRACE("(%p, %p, %p)\n", pStubMsg, pMemory, pFormat);
|
|
|
|
|
2018-06-13 04:19:10 +02:00
|
|
|
if ((pFormat[0] != FC_SMVARRAY) &&
|
|
|
|
(pFormat[0] != FC_LGVARRAY))
|
2006-06-05 02:41:30 +02:00
|
|
|
{
|
|
|
|
ERR("invalid format type %x\n", pFormat[0]);
|
|
|
|
RpcRaiseException(RPC_S_INTERNAL_ERROR);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
alignment = pFormat[1] + 1;
|
|
|
|
|
2018-06-13 04:19:10 +02:00
|
|
|
if (pFormat[0] == FC_SMVARRAY)
|
2006-06-05 02:41:30 +02:00
|
|
|
{
|
|
|
|
pFormat += 2;
|
|
|
|
pFormat += sizeof(WORD);
|
|
|
|
elements = *(const WORD*)pFormat;
|
|
|
|
pFormat += sizeof(WORD);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
pFormat += 2;
|
|
|
|
pFormat += sizeof(DWORD);
|
|
|
|
elements = *(const DWORD*)pFormat;
|
|
|
|
pFormat += sizeof(DWORD);
|
|
|
|
}
|
|
|
|
|
|
|
|
esize = *(const WORD*)pFormat;
|
|
|
|
pFormat += sizeof(WORD);
|
|
|
|
|
|
|
|
pFormat = ComputeVariance(pStubMsg, pMemory, pFormat, 0);
|
|
|
|
if ((pStubMsg->ActualCount > elements) ||
|
|
|
|
(pStubMsg->ActualCount + pStubMsg->Offset > elements))
|
|
|
|
{
|
|
|
|
RpcRaiseException(RPC_S_INVALID_BOUND);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
WriteVariance(pStubMsg);
|
|
|
|
|
2010-04-02 21:54:55 +02:00
|
|
|
align_pointer_clear(&pStubMsg->Buffer, alignment);
|
2006-06-05 02:41:30 +02:00
|
|
|
|
2006-06-10 13:32:24 +02:00
|
|
|
bufsize = safe_multiply(esize, pStubMsg->ActualCount);
|
2006-06-05 02:41:30 +02:00
|
|
|
pStubMsg->BufferMark = pStubMsg->Buffer;
|
2007-11-28 16:02:06 +01:00
|
|
|
safe_copy_to_buffer(pStubMsg, pMemory + pStubMsg->Offset, bufsize);
|
2006-06-05 02:41:30 +02:00
|
|
|
|
|
|
|
EmbeddedPointerMarshall(pStubMsg, pMemory, pFormat);
|
|
|
|
|
2005-07-18 15:14:05 +02:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* NdrVaryingArrayUnmarshall [RPCRT4.@]
|
|
|
|
*/
|
|
|
|
unsigned char * WINAPI NdrVaryingArrayUnmarshall(PMIDL_STUB_MESSAGE pStubMsg,
|
|
|
|
unsigned char **ppMemory,
|
|
|
|
PFORMAT_STRING pFormat,
|
|
|
|
unsigned char fMustAlloc)
|
|
|
|
{
|
2006-06-05 02:41:30 +02:00
|
|
|
unsigned char alignment;
|
|
|
|
DWORD size, elements, esize;
|
2006-06-10 13:32:24 +02:00
|
|
|
ULONG bufsize;
|
2007-12-24 18:01:40 +01:00
|
|
|
unsigned char *saved_buffer;
|
|
|
|
ULONG offset;
|
2006-06-05 02:41:30 +02:00
|
|
|
|
|
|
|
TRACE("(%p, %p, %p, %d)\n", pStubMsg, ppMemory, pFormat, fMustAlloc);
|
|
|
|
|
2018-06-13 04:19:10 +02:00
|
|
|
if ((pFormat[0] != FC_SMVARRAY) &&
|
|
|
|
(pFormat[0] != FC_LGVARRAY))
|
2006-06-05 02:41:30 +02:00
|
|
|
{
|
|
|
|
ERR("invalid format type %x\n", pFormat[0]);
|
|
|
|
RpcRaiseException(RPC_S_INTERNAL_ERROR);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
alignment = pFormat[1] + 1;
|
|
|
|
|
2018-06-13 04:19:10 +02:00
|
|
|
if (pFormat[0] == FC_SMVARRAY)
|
2006-06-05 02:41:30 +02:00
|
|
|
{
|
|
|
|
pFormat += 2;
|
|
|
|
size = *(const WORD*)pFormat;
|
|
|
|
pFormat += sizeof(WORD);
|
|
|
|
elements = *(const WORD*)pFormat;
|
|
|
|
pFormat += sizeof(WORD);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
pFormat += 2;
|
|
|
|
size = *(const DWORD*)pFormat;
|
|
|
|
pFormat += sizeof(DWORD);
|
|
|
|
elements = *(const DWORD*)pFormat;
|
|
|
|
pFormat += sizeof(DWORD);
|
|
|
|
}
|
|
|
|
|
|
|
|
esize = *(const WORD*)pFormat;
|
|
|
|
pFormat += sizeof(WORD);
|
|
|
|
|
2006-06-10 13:32:47 +02:00
|
|
|
pFormat = ReadVariance(pStubMsg, pFormat, elements);
|
2006-06-05 02:41:30 +02:00
|
|
|
|
2010-04-02 21:54:55 +02:00
|
|
|
align_pointer(&pStubMsg->Buffer, alignment);
|
2006-06-05 02:41:30 +02:00
|
|
|
|
2006-06-10 13:32:24 +02:00
|
|
|
bufsize = safe_multiply(esize, pStubMsg->ActualCount);
|
2007-12-24 18:01:40 +01:00
|
|
|
offset = pStubMsg->Offset;
|
2006-06-10 13:32:24 +02:00
|
|
|
|
2009-01-10 23:17:15 +01:00
|
|
|
if (!fMustAlloc && !*ppMemory)
|
|
|
|
fMustAlloc = TRUE;
|
|
|
|
if (fMustAlloc)
|
2018-10-28 23:25:47 +01:00
|
|
|
*ppMemory = NdrAllocateZero(pStubMsg, size);
|
2007-12-24 18:01:40 +01:00
|
|
|
saved_buffer = pStubMsg->BufferMark = pStubMsg->Buffer;
|
|
|
|
safe_buffer_increment(pStubMsg, bufsize);
|
2006-06-05 02:41:30 +02:00
|
|
|
|
2007-12-24 18:01:40 +01:00
|
|
|
EmbeddedPointerUnmarshall(pStubMsg, saved_buffer, *ppMemory, pFormat, fMustAlloc);
|
|
|
|
|
|
|
|
memcpy(*ppMemory + offset, saved_buffer, bufsize);
|
2006-06-05 02:41:30 +02:00
|
|
|
|
2005-07-18 15:14:05 +02:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* NdrVaryingArrayBufferSize [RPCRT4.@]
|
|
|
|
*/
|
|
|
|
void WINAPI NdrVaryingArrayBufferSize(PMIDL_STUB_MESSAGE pStubMsg,
|
|
|
|
unsigned char *pMemory,
|
|
|
|
PFORMAT_STRING pFormat)
|
|
|
|
{
|
2006-06-05 02:41:30 +02:00
|
|
|
unsigned char alignment;
|
|
|
|
DWORD elements, esize;
|
|
|
|
|
|
|
|
TRACE("(%p, %p, %p)\n", pStubMsg, pMemory, pFormat);
|
|
|
|
|
2018-06-13 04:19:10 +02:00
|
|
|
if ((pFormat[0] != FC_SMVARRAY) &&
|
|
|
|
(pFormat[0] != FC_LGVARRAY))
|
2006-06-05 02:41:30 +02:00
|
|
|
{
|
|
|
|
ERR("invalid format type %x\n", pFormat[0]);
|
|
|
|
RpcRaiseException(RPC_S_INTERNAL_ERROR);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
alignment = pFormat[1] + 1;
|
|
|
|
|
2018-06-13 04:19:10 +02:00
|
|
|
if (pFormat[0] == FC_SMVARRAY)
|
2006-06-05 02:41:30 +02:00
|
|
|
{
|
|
|
|
pFormat += 2;
|
|
|
|
pFormat += sizeof(WORD);
|
|
|
|
elements = *(const WORD*)pFormat;
|
|
|
|
pFormat += sizeof(WORD);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
pFormat += 2;
|
|
|
|
pFormat += sizeof(DWORD);
|
|
|
|
elements = *(const DWORD*)pFormat;
|
|
|
|
pFormat += sizeof(DWORD);
|
|
|
|
}
|
|
|
|
|
|
|
|
esize = *(const WORD*)pFormat;
|
|
|
|
pFormat += sizeof(WORD);
|
|
|
|
|
|
|
|
pFormat = ComputeVariance(pStubMsg, pMemory, pFormat, 0);
|
|
|
|
if ((pStubMsg->ActualCount > elements) ||
|
|
|
|
(pStubMsg->ActualCount + pStubMsg->Offset > elements))
|
|
|
|
{
|
|
|
|
RpcRaiseException(RPC_S_INVALID_BOUND);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
SizeVariance(pStubMsg);
|
|
|
|
|
2010-04-02 21:54:55 +02:00
|
|
|
align_length(&pStubMsg->BufferLength, alignment);
|
2006-06-05 02:41:30 +02:00
|
|
|
|
2007-11-28 16:01:53 +01:00
|
|
|
safe_buffer_length_increment(pStubMsg, safe_multiply(esize, pStubMsg->ActualCount));
|
2006-06-05 02:41:30 +02:00
|
|
|
|
|
|
|
EmbeddedPointerBufferSize(pStubMsg, pMemory, pFormat);
|
2005-07-18 15:14:05 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* NdrVaryingArrayMemorySize [RPCRT4.@]
|
|
|
|
*/
|
2006-11-09 23:01:58 +01:00
|
|
|
ULONG WINAPI NdrVaryingArrayMemorySize(PMIDL_STUB_MESSAGE pStubMsg,
|
2005-07-18 15:14:05 +02:00
|
|
|
PFORMAT_STRING pFormat)
|
|
|
|
{
|
2006-06-05 02:41:30 +02:00
|
|
|
unsigned char alignment;
|
|
|
|
DWORD size, elements, esize;
|
|
|
|
|
|
|
|
TRACE("(%p, %p)\n", pStubMsg, pFormat);
|
|
|
|
|
2018-06-13 04:19:10 +02:00
|
|
|
if ((pFormat[0] != FC_SMVARRAY) &&
|
|
|
|
(pFormat[0] != FC_LGVARRAY))
|
2006-06-05 02:41:30 +02:00
|
|
|
{
|
|
|
|
ERR("invalid format type %x\n", pFormat[0]);
|
|
|
|
RpcRaiseException(RPC_S_INTERNAL_ERROR);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
alignment = pFormat[1] + 1;
|
|
|
|
|
2018-06-13 04:19:10 +02:00
|
|
|
if (pFormat[0] == FC_SMVARRAY)
|
2006-06-05 02:41:30 +02:00
|
|
|
{
|
|
|
|
pFormat += 2;
|
|
|
|
size = *(const WORD*)pFormat;
|
|
|
|
pFormat += sizeof(WORD);
|
|
|
|
elements = *(const WORD*)pFormat;
|
|
|
|
pFormat += sizeof(WORD);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
pFormat += 2;
|
|
|
|
size = *(const DWORD*)pFormat;
|
|
|
|
pFormat += sizeof(DWORD);
|
|
|
|
elements = *(const DWORD*)pFormat;
|
|
|
|
pFormat += sizeof(DWORD);
|
|
|
|
}
|
|
|
|
|
|
|
|
esize = *(const WORD*)pFormat;
|
|
|
|
pFormat += sizeof(WORD);
|
|
|
|
|
2006-06-10 13:32:47 +02:00
|
|
|
pFormat = ReadVariance(pStubMsg, pFormat, elements);
|
2006-06-05 02:41:30 +02:00
|
|
|
|
2010-04-02 21:54:55 +02:00
|
|
|
align_pointer(&pStubMsg->Buffer, alignment);
|
2006-06-05 02:41:30 +02:00
|
|
|
|
2007-11-28 16:02:21 +01:00
|
|
|
safe_buffer_increment(pStubMsg, safe_multiply(esize, pStubMsg->ActualCount));
|
2006-06-05 02:41:30 +02:00
|
|
|
pStubMsg->MemorySize += size;
|
|
|
|
|
|
|
|
EmbeddedPointerMemorySize(pStubMsg, pFormat);
|
|
|
|
|
|
|
|
return pStubMsg->MemorySize;
|
2005-07-18 15:14:05 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* NdrVaryingArrayFree [RPCRT4.@]
|
|
|
|
*/
|
|
|
|
void WINAPI NdrVaryingArrayFree(PMIDL_STUB_MESSAGE pStubMsg,
|
|
|
|
unsigned char *pMemory,
|
|
|
|
PFORMAT_STRING pFormat)
|
|
|
|
{
|
2006-06-05 02:41:30 +02:00
|
|
|
DWORD elements;
|
|
|
|
|
|
|
|
TRACE("(%p, %p, %p)\n", pStubMsg, pMemory, pFormat);
|
|
|
|
|
2018-06-13 04:19:10 +02:00
|
|
|
if ((pFormat[0] != FC_SMVARRAY) &&
|
|
|
|
(pFormat[0] != FC_LGVARRAY))
|
2006-06-05 02:41:30 +02:00
|
|
|
{
|
|
|
|
ERR("invalid format type %x\n", pFormat[0]);
|
|
|
|
RpcRaiseException(RPC_S_INTERNAL_ERROR);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-06-13 04:19:10 +02:00
|
|
|
if (pFormat[0] == FC_SMVARRAY)
|
2006-06-05 02:41:30 +02:00
|
|
|
{
|
|
|
|
pFormat += 2;
|
|
|
|
pFormat += sizeof(WORD);
|
|
|
|
elements = *(const WORD*)pFormat;
|
|
|
|
pFormat += sizeof(WORD);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
pFormat += 2;
|
|
|
|
pFormat += sizeof(DWORD);
|
|
|
|
elements = *(const DWORD*)pFormat;
|
|
|
|
pFormat += sizeof(DWORD);
|
|
|
|
}
|
|
|
|
|
|
|
|
pFormat += sizeof(WORD);
|
|
|
|
|
|
|
|
pFormat = ComputeVariance(pStubMsg, pMemory, pFormat, 0);
|
|
|
|
if ((pStubMsg->ActualCount > elements) ||
|
|
|
|
(pStubMsg->ActualCount + pStubMsg->Offset > elements))
|
|
|
|
{
|
|
|
|
RpcRaiseException(RPC_S_INVALID_BOUND);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
EmbeddedPointerFree(pStubMsg, pMemory, pFormat);
|
2005-07-18 15:14:05 +02:00
|
|
|
}
|
|
|
|
|
2007-08-17 23:10:58 +02:00
|
|
|
static ULONG get_discriminant(unsigned char fc, const unsigned char *pMemory)
|
2005-07-18 15:14:05 +02:00
|
|
|
{
|
2007-06-18 12:47:49 +02:00
|
|
|
switch (fc)
|
|
|
|
{
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_BYTE:
|
|
|
|
case FC_CHAR:
|
|
|
|
case FC_SMALL:
|
|
|
|
case FC_USMALL:
|
2008-01-16 22:57:31 +01:00
|
|
|
return *pMemory;
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_WCHAR:
|
|
|
|
case FC_SHORT:
|
|
|
|
case FC_USHORT:
|
|
|
|
case FC_ENUM16:
|
2007-08-17 23:10:58 +02:00
|
|
|
return *(const USHORT *)pMemory;
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_LONG:
|
|
|
|
case FC_ULONG:
|
|
|
|
case FC_ENUM32:
|
2007-08-17 23:10:58 +02:00
|
|
|
return *(const ULONG *)pMemory;
|
2007-06-18 12:47:49 +02:00
|
|
|
default:
|
|
|
|
FIXME("Unhandled base type: 0x%02x\n", fc);
|
|
|
|
return 0;
|
|
|
|
}
|
2005-07-18 15:14:05 +02:00
|
|
|
}
|
|
|
|
|
2006-04-28 15:28:24 +02:00
|
|
|
static PFORMAT_STRING get_arm_offset_from_union_arm_selector(PMIDL_STUB_MESSAGE pStubMsg,
|
2009-04-21 09:59:45 +02:00
|
|
|
ULONG discriminant,
|
2006-04-28 15:28:24 +02:00
|
|
|
PFORMAT_STRING pFormat)
|
|
|
|
{
|
|
|
|
unsigned short num_arms, arm, type;
|
|
|
|
|
|
|
|
num_arms = *(const SHORT*)pFormat & 0x0fff;
|
|
|
|
pFormat += 2;
|
|
|
|
for(arm = 0; arm < num_arms; arm++)
|
|
|
|
{
|
|
|
|
if(discriminant == *(const ULONG*)pFormat)
|
|
|
|
{
|
|
|
|
pFormat += 4;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
pFormat += 6;
|
|
|
|
}
|
|
|
|
|
|
|
|
type = *(const unsigned short*)pFormat;
|
|
|
|
TRACE("type %04x\n", type);
|
|
|
|
if(arm == num_arms) /* default arm extras */
|
|
|
|
{
|
|
|
|
if(type == 0xffff)
|
|
|
|
{
|
2009-04-21 09:59:45 +02:00
|
|
|
ERR("no arm for 0x%x and no default case\n", discriminant);
|
2006-05-17 15:45:55 +02:00
|
|
|
RpcRaiseException(RPC_S_INVALID_TAG);
|
2006-04-28 15:28:24 +02:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
if(type == 0)
|
|
|
|
{
|
2009-04-21 09:59:45 +02:00
|
|
|
TRACE("falling back to empty default case for 0x%x\n", discriminant);
|
2006-04-28 15:28:24 +02:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return pFormat;
|
|
|
|
}
|
|
|
|
|
2007-06-18 12:47:49 +02:00
|
|
|
static unsigned char *union_arm_marshall(PMIDL_STUB_MESSAGE pStubMsg, unsigned char *pMemory, ULONG discriminant, PFORMAT_STRING pFormat)
|
2005-07-18 15:14:05 +02:00
|
|
|
{
|
2006-04-28 15:28:24 +02:00
|
|
|
unsigned short type;
|
|
|
|
|
2007-06-18 12:47:49 +02:00
|
|
|
pFormat += 2;
|
2006-05-15 17:56:27 +02:00
|
|
|
|
2007-06-18 12:47:49 +02:00
|
|
|
pFormat = get_arm_offset_from_union_arm_selector(pStubMsg, discriminant, pFormat);
|
2006-04-28 15:28:24 +02:00
|
|
|
if(!pFormat)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
type = *(const unsigned short*)pFormat;
|
2006-05-13 18:00:27 +02:00
|
|
|
if((type & 0xff00) == 0x8000)
|
2006-04-28 15:28:24 +02:00
|
|
|
{
|
2006-05-13 18:00:27 +02:00
|
|
|
unsigned char basetype = LOBYTE(type);
|
|
|
|
return NdrBaseTypeMarshall(pStubMsg, pMemory, &basetype);
|
2006-04-28 15:28:24 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
PFORMAT_STRING desc = pFormat + *(const SHORT*)pFormat;
|
|
|
|
NDR_MARSHALL m = NdrMarshaller[*desc & NDR_TABLE_MASK];
|
|
|
|
if (m)
|
|
|
|
{
|
2006-05-15 14:35:17 +02:00
|
|
|
unsigned char *saved_buffer = NULL;
|
2013-12-03 00:02:50 +01:00
|
|
|
BOOL pointer_buffer_mark_set = FALSE;
|
2006-04-28 15:28:24 +02:00
|
|
|
switch(*desc)
|
|
|
|
{
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_RP:
|
|
|
|
case FC_UP:
|
|
|
|
case FC_OP:
|
|
|
|
case FC_FP:
|
2010-04-02 21:54:55 +02:00
|
|
|
align_pointer_clear(&pStubMsg->Buffer, 4);
|
2006-05-15 14:35:17 +02:00
|
|
|
saved_buffer = pStubMsg->Buffer;
|
2007-06-25 15:28:01 +02:00
|
|
|
if (pStubMsg->PointerBufferMark)
|
|
|
|
{
|
|
|
|
pStubMsg->Buffer = pStubMsg->PointerBufferMark;
|
|
|
|
pStubMsg->PointerBufferMark = NULL;
|
2013-12-03 00:02:50 +01:00
|
|
|
pointer_buffer_mark_set = TRUE;
|
2007-06-25 15:28:01 +02:00
|
|
|
}
|
|
|
|
else
|
2007-11-28 16:02:21 +01:00
|
|
|
safe_buffer_increment(pStubMsg, 4); /* for pointer ID */
|
2007-06-25 15:28:01 +02:00
|
|
|
|
2006-05-15 14:35:17 +02:00
|
|
|
PointerMarshall(pStubMsg, saved_buffer, *(unsigned char **)pMemory, desc);
|
2007-06-25 15:28:01 +02:00
|
|
|
if (pointer_buffer_mark_set)
|
|
|
|
{
|
|
|
|
STD_OVERFLOW_CHECK(pStubMsg);
|
|
|
|
pStubMsg->PointerBufferMark = pStubMsg->Buffer;
|
2007-11-28 16:02:21 +01:00
|
|
|
if (saved_buffer + 4 > (unsigned char *)pStubMsg->RpcMsg->Buffer + pStubMsg->BufferLength)
|
|
|
|
{
|
|
|
|
ERR("buffer overflow - saved_buffer = %p, BufferEnd = %p\n",
|
|
|
|
saved_buffer, (unsigned char *)pStubMsg->RpcMsg->Buffer + pStubMsg->BufferLength);
|
|
|
|
RpcRaiseException(RPC_X_BAD_STUB_DATA);
|
|
|
|
}
|
2007-06-25 15:28:01 +02:00
|
|
|
pStubMsg->Buffer = saved_buffer + 4;
|
|
|
|
}
|
2006-04-28 15:28:24 +02:00
|
|
|
break;
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_IP:
|
2018-04-11 03:30:27 +02:00
|
|
|
/* must be dereferenced first */
|
|
|
|
m(pStubMsg, *(unsigned char **)pMemory, desc);
|
|
|
|
break;
|
2006-05-15 14:35:17 +02:00
|
|
|
default:
|
|
|
|
m(pStubMsg, pMemory, desc);
|
2006-04-28 15:28:24 +02:00
|
|
|
}
|
|
|
|
}
|
2018-04-11 03:30:28 +02:00
|
|
|
else if (*desc)
|
|
|
|
FIXME("no marshaller for embedded type %02x\n", *desc);
|
2006-04-28 15:28:24 +02:00
|
|
|
}
|
2005-07-18 15:14:05 +02:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2007-06-18 12:47:49 +02:00
|
|
|
static unsigned char *union_arm_unmarshall(PMIDL_STUB_MESSAGE pStubMsg,
|
2005-07-18 15:14:05 +02:00
|
|
|
unsigned char **ppMemory,
|
2007-06-18 12:47:49 +02:00
|
|
|
ULONG discriminant,
|
2005-07-18 15:14:05 +02:00
|
|
|
PFORMAT_STRING pFormat,
|
|
|
|
unsigned char fMustAlloc)
|
|
|
|
{
|
2007-06-18 12:47:49 +02:00
|
|
|
unsigned short type;
|
2006-04-28 15:28:24 +02:00
|
|
|
|
|
|
|
pFormat += 2;
|
|
|
|
|
|
|
|
pFormat = get_arm_offset_from_union_arm_selector(pStubMsg, discriminant, pFormat);
|
|
|
|
if(!pFormat)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
type = *(const unsigned short*)pFormat;
|
2006-05-13 18:00:27 +02:00
|
|
|
if((type & 0xff00) == 0x8000)
|
2006-04-28 15:28:24 +02:00
|
|
|
{
|
2006-05-13 18:00:27 +02:00
|
|
|
unsigned char basetype = LOBYTE(type);
|
2007-07-16 16:03:15 +02:00
|
|
|
return NdrBaseTypeUnmarshall(pStubMsg, ppMemory, &basetype, FALSE);
|
2006-04-28 15:28:24 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
PFORMAT_STRING desc = pFormat + *(const SHORT*)pFormat;
|
|
|
|
NDR_UNMARSHALL m = NdrUnmarshaller[*desc & NDR_TABLE_MASK];
|
|
|
|
if (m)
|
|
|
|
{
|
2006-05-15 14:35:17 +02:00
|
|
|
unsigned char *saved_buffer = NULL;
|
2013-12-03 00:02:50 +01:00
|
|
|
BOOL pointer_buffer_mark_set = FALSE;
|
2006-04-28 15:28:24 +02:00
|
|
|
switch(*desc)
|
|
|
|
{
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_RP:
|
|
|
|
case FC_UP:
|
|
|
|
case FC_OP:
|
|
|
|
case FC_FP:
|
2010-04-02 21:54:55 +02:00
|
|
|
align_pointer(&pStubMsg->Buffer, 4);
|
2006-05-15 14:35:17 +02:00
|
|
|
saved_buffer = pStubMsg->Buffer;
|
2007-06-25 15:28:01 +02:00
|
|
|
if (pStubMsg->PointerBufferMark)
|
|
|
|
{
|
|
|
|
pStubMsg->Buffer = pStubMsg->PointerBufferMark;
|
|
|
|
pStubMsg->PointerBufferMark = NULL;
|
2013-12-03 00:02:50 +01:00
|
|
|
pointer_buffer_mark_set = TRUE;
|
2007-06-25 15:28:01 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
pStubMsg->Buffer += 4; /* for pointer ID */
|
|
|
|
|
2007-07-16 16:02:38 +02:00
|
|
|
if (saved_buffer + 4 > pStubMsg->BufferEnd)
|
2007-11-28 16:02:21 +01:00
|
|
|
{
|
|
|
|
ERR("buffer overflow - saved_buffer = %p, BufferEnd = %p\n",
|
|
|
|
saved_buffer, pStubMsg->BufferEnd);
|
2007-07-16 16:02:38 +02:00
|
|
|
RpcRaiseException(RPC_X_BAD_STUB_DATA);
|
2007-11-28 16:02:21 +01:00
|
|
|
}
|
2007-07-16 16:02:38 +02:00
|
|
|
|
2007-11-29 18:35:34 +01:00
|
|
|
PointerUnmarshall(pStubMsg, saved_buffer, *(unsigned char ***)ppMemory, **(unsigned char ***)ppMemory, desc, fMustAlloc);
|
2007-06-25 15:28:01 +02:00
|
|
|
if (pointer_buffer_mark_set)
|
|
|
|
{
|
|
|
|
STD_OVERFLOW_CHECK(pStubMsg);
|
|
|
|
pStubMsg->PointerBufferMark = pStubMsg->Buffer;
|
|
|
|
pStubMsg->Buffer = saved_buffer + 4;
|
|
|
|
}
|
2006-04-28 15:28:24 +02:00
|
|
|
break;
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_IP:
|
2018-04-11 03:30:27 +02:00
|
|
|
/* must be dereferenced first */
|
|
|
|
m(pStubMsg, *(unsigned char ***)ppMemory, desc, fMustAlloc);
|
|
|
|
break;
|
2006-05-15 14:35:17 +02:00
|
|
|
default:
|
|
|
|
m(pStubMsg, ppMemory, desc, fMustAlloc);
|
2006-04-28 15:28:24 +02:00
|
|
|
}
|
|
|
|
}
|
2018-04-11 03:30:28 +02:00
|
|
|
else if (*desc)
|
|
|
|
FIXME("no marshaller for embedded type %02x\n", *desc);
|
2006-04-28 15:28:24 +02:00
|
|
|
}
|
2005-07-18 15:14:05 +02:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2007-06-18 12:47:49 +02:00
|
|
|
static void union_arm_buffer_size(PMIDL_STUB_MESSAGE pStubMsg,
|
|
|
|
unsigned char *pMemory,
|
|
|
|
ULONG discriminant,
|
|
|
|
PFORMAT_STRING pFormat)
|
2005-07-18 15:14:05 +02:00
|
|
|
{
|
2006-04-28 15:28:24 +02:00
|
|
|
unsigned short type;
|
2006-05-15 17:56:27 +02:00
|
|
|
|
2007-06-18 12:47:49 +02:00
|
|
|
pFormat += 2;
|
2006-04-28 15:28:24 +02:00
|
|
|
|
2007-06-18 12:47:49 +02:00
|
|
|
pFormat = get_arm_offset_from_union_arm_selector(pStubMsg, discriminant, pFormat);
|
2006-04-28 15:28:24 +02:00
|
|
|
if(!pFormat)
|
|
|
|
return;
|
|
|
|
|
|
|
|
type = *(const unsigned short*)pFormat;
|
2006-05-13 18:00:27 +02:00
|
|
|
if((type & 0xff00) == 0x8000)
|
2006-04-28 15:28:24 +02:00
|
|
|
{
|
2006-05-13 18:00:27 +02:00
|
|
|
unsigned char basetype = LOBYTE(type);
|
|
|
|
NdrBaseTypeBufferSize(pStubMsg, pMemory, &basetype);
|
2006-04-28 15:28:24 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
PFORMAT_STRING desc = pFormat + *(const SHORT*)pFormat;
|
|
|
|
NDR_BUFFERSIZE m = NdrBufferSizer[*desc & NDR_TABLE_MASK];
|
|
|
|
if (m)
|
|
|
|
{
|
|
|
|
switch(*desc)
|
|
|
|
{
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_RP:
|
|
|
|
case FC_UP:
|
|
|
|
case FC_OP:
|
|
|
|
case FC_FP:
|
2010-04-02 21:54:55 +02:00
|
|
|
align_length(&pStubMsg->BufferLength, 4);
|
2007-11-28 16:01:53 +01:00
|
|
|
safe_buffer_length_increment(pStubMsg, 4); /* for pointer ID */
|
2007-06-25 15:28:01 +02:00
|
|
|
if (!pStubMsg->IgnoreEmbeddedPointers)
|
|
|
|
{
|
|
|
|
int saved_buffer_length = pStubMsg->BufferLength;
|
|
|
|
pStubMsg->BufferLength = pStubMsg->PointerLength;
|
|
|
|
pStubMsg->PointerLength = 0;
|
|
|
|
if(!pStubMsg->BufferLength)
|
|
|
|
ERR("BufferLength == 0??\n");
|
|
|
|
PointerBufferSize(pStubMsg, *(unsigned char **)pMemory, desc);
|
|
|
|
pStubMsg->PointerLength = pStubMsg->BufferLength;
|
|
|
|
pStubMsg->BufferLength = saved_buffer_length;
|
|
|
|
}
|
2006-04-28 15:28:24 +02:00
|
|
|
break;
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_IP:
|
2018-04-11 03:30:27 +02:00
|
|
|
/* must be dereferenced first */
|
|
|
|
m(pStubMsg, *(unsigned char **)pMemory, desc);
|
|
|
|
break;
|
2006-05-15 14:35:17 +02:00
|
|
|
default:
|
|
|
|
m(pStubMsg, pMemory, desc);
|
2006-04-28 15:28:24 +02:00
|
|
|
}
|
|
|
|
}
|
2018-04-11 03:30:28 +02:00
|
|
|
else if (*desc)
|
|
|
|
FIXME("no buffersizer for embedded type %02x\n", *desc);
|
2006-04-28 15:28:24 +02:00
|
|
|
}
|
2005-07-18 15:14:05 +02:00
|
|
|
}
|
|
|
|
|
2007-06-18 12:47:49 +02:00
|
|
|
static ULONG union_arm_memory_size(PMIDL_STUB_MESSAGE pStubMsg,
|
|
|
|
ULONG discriminant,
|
|
|
|
PFORMAT_STRING pFormat)
|
2005-07-18 15:14:05 +02:00
|
|
|
{
|
2006-05-18 04:39:34 +02:00
|
|
|
unsigned short type, size;
|
|
|
|
|
|
|
|
size = *(const unsigned short*)pFormat;
|
2007-06-18 12:47:49 +02:00
|
|
|
pStubMsg->Memory += size;
|
2006-05-10 14:12:20 +02:00
|
|
|
pFormat += 2;
|
2006-05-18 04:39:34 +02:00
|
|
|
|
|
|
|
pFormat = get_arm_offset_from_union_arm_selector(pStubMsg, discriminant, pFormat);
|
|
|
|
if(!pFormat)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
type = *(const unsigned short*)pFormat;
|
|
|
|
if((type & 0xff00) == 0x8000)
|
|
|
|
{
|
|
|
|
return NdrBaseTypeMemorySize(pStubMsg, pFormat);
|
|
|
|
}
|
2006-05-10 14:12:20 +02:00
|
|
|
else
|
2006-05-18 04:39:34 +02:00
|
|
|
{
|
|
|
|
PFORMAT_STRING desc = pFormat + *(const SHORT*)pFormat;
|
|
|
|
NDR_MEMORYSIZE m = NdrMemorySizer[*desc & NDR_TABLE_MASK];
|
|
|
|
unsigned char *saved_buffer;
|
|
|
|
if (m)
|
|
|
|
{
|
|
|
|
switch(*desc)
|
|
|
|
{
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_RP:
|
|
|
|
case FC_UP:
|
|
|
|
case FC_OP:
|
|
|
|
case FC_FP:
|
2010-04-02 21:54:55 +02:00
|
|
|
align_pointer(&pStubMsg->Buffer, 4);
|
2006-05-18 04:39:34 +02:00
|
|
|
saved_buffer = pStubMsg->Buffer;
|
2007-11-28 16:02:21 +01:00
|
|
|
safe_buffer_increment(pStubMsg, 4);
|
2010-04-02 21:54:55 +02:00
|
|
|
align_length(&pStubMsg->MemorySize, sizeof(void *));
|
2009-06-19 12:49:35 +02:00
|
|
|
pStubMsg->MemorySize += sizeof(void *);
|
2007-06-25 15:28:01 +02:00
|
|
|
if (!pStubMsg->IgnoreEmbeddedPointers)
|
|
|
|
PointerMemorySize(pStubMsg, saved_buffer, pFormat);
|
2006-05-18 04:39:34 +02:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return m(pStubMsg, desc);
|
|
|
|
}
|
|
|
|
}
|
2018-04-11 03:30:28 +02:00
|
|
|
else if (*desc)
|
|
|
|
FIXME("no marshaller for embedded type %02x\n", *desc);
|
2006-05-18 04:39:34 +02:00
|
|
|
}
|
2006-05-10 14:12:20 +02:00
|
|
|
|
2006-05-18 04:39:34 +02:00
|
|
|
TRACE("size %d\n", size);
|
|
|
|
return size;
|
2005-07-18 15:14:05 +02:00
|
|
|
}
|
|
|
|
|
2007-06-18 12:47:49 +02:00
|
|
|
static void union_arm_free(PMIDL_STUB_MESSAGE pStubMsg,
|
|
|
|
unsigned char *pMemory,
|
|
|
|
ULONG discriminant,
|
|
|
|
PFORMAT_STRING pFormat)
|
|
|
|
{
|
|
|
|
unsigned short type;
|
|
|
|
|
|
|
|
pFormat += 2;
|
|
|
|
|
|
|
|
pFormat = get_arm_offset_from_union_arm_selector(pStubMsg, discriminant, pFormat);
|
|
|
|
if(!pFormat)
|
|
|
|
return;
|
|
|
|
|
|
|
|
type = *(const unsigned short*)pFormat;
|
|
|
|
if((type & 0xff00) != 0x8000)
|
|
|
|
{
|
|
|
|
PFORMAT_STRING desc = pFormat + *(const SHORT*)pFormat;
|
|
|
|
NDR_FREE m = NdrFreer[*desc & NDR_TABLE_MASK];
|
|
|
|
if (m)
|
|
|
|
{
|
|
|
|
switch(*desc)
|
|
|
|
{
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_RP:
|
|
|
|
case FC_UP:
|
|
|
|
case FC_OP:
|
|
|
|
case FC_FP:
|
2007-06-18 12:47:49 +02:00
|
|
|
PointerFree(pStubMsg, *(unsigned char **)pMemory, desc);
|
|
|
|
break;
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_IP:
|
2018-04-11 03:30:27 +02:00
|
|
|
/* must be dereferenced first */
|
|
|
|
m(pStubMsg, *(unsigned char **)pMemory, desc);
|
|
|
|
break;
|
2007-06-18 12:47:49 +02:00
|
|
|
default:
|
|
|
|
m(pStubMsg, pMemory, desc);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* NdrEncapsulatedUnionMarshall [RPCRT4.@]
|
|
|
|
*/
|
|
|
|
unsigned char * WINAPI NdrEncapsulatedUnionMarshall(PMIDL_STUB_MESSAGE pStubMsg,
|
|
|
|
unsigned char *pMemory,
|
|
|
|
PFORMAT_STRING pFormat)
|
|
|
|
{
|
|
|
|
unsigned char switch_type;
|
|
|
|
unsigned char increment;
|
|
|
|
ULONG switch_value;
|
|
|
|
|
|
|
|
TRACE("(%p, %p, %p)\n", pStubMsg, pMemory, pFormat);
|
|
|
|
pFormat++;
|
|
|
|
|
|
|
|
switch_type = *pFormat & 0xf;
|
2007-06-19 03:40:08 +02:00
|
|
|
increment = (*pFormat & 0xf0) >> 4;
|
2007-06-18 12:47:49 +02:00
|
|
|
pFormat++;
|
|
|
|
|
2010-04-02 21:54:55 +02:00
|
|
|
align_pointer_clear(&pStubMsg->Buffer, increment);
|
2007-06-18 12:47:49 +02:00
|
|
|
|
|
|
|
switch_value = get_discriminant(switch_type, pMemory);
|
|
|
|
TRACE("got switch value 0x%x\n", switch_value);
|
|
|
|
|
|
|
|
NdrBaseTypeMarshall(pStubMsg, pMemory, &switch_type);
|
|
|
|
pMemory += increment;
|
|
|
|
|
|
|
|
return union_arm_marshall(pStubMsg, pMemory, switch_value, pFormat);
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* NdrEncapsulatedUnionUnmarshall [RPCRT4.@]
|
|
|
|
*/
|
|
|
|
unsigned char * WINAPI NdrEncapsulatedUnionUnmarshall(PMIDL_STUB_MESSAGE pStubMsg,
|
|
|
|
unsigned char **ppMemory,
|
|
|
|
PFORMAT_STRING pFormat,
|
|
|
|
unsigned char fMustAlloc)
|
|
|
|
{
|
|
|
|
unsigned char switch_type;
|
|
|
|
unsigned char increment;
|
|
|
|
ULONG switch_value;
|
|
|
|
unsigned short size;
|
|
|
|
unsigned char *pMemoryArm;
|
|
|
|
|
|
|
|
TRACE("(%p, %p, %p, %d)\n", pStubMsg, ppMemory, pFormat, fMustAlloc);
|
|
|
|
pFormat++;
|
|
|
|
|
|
|
|
switch_type = *pFormat & 0xf;
|
2007-06-19 03:40:08 +02:00
|
|
|
increment = (*pFormat & 0xf0) >> 4;
|
2007-06-18 12:47:49 +02:00
|
|
|
pFormat++;
|
|
|
|
|
2010-04-02 21:54:55 +02:00
|
|
|
align_pointer(&pStubMsg->Buffer, increment);
|
2007-06-18 12:47:49 +02:00
|
|
|
switch_value = get_discriminant(switch_type, pStubMsg->Buffer);
|
|
|
|
TRACE("got switch value 0x%x\n", switch_value);
|
|
|
|
|
|
|
|
size = *(const unsigned short*)pFormat + increment;
|
2009-01-10 23:17:15 +01:00
|
|
|
if (!fMustAlloc && !*ppMemory)
|
|
|
|
fMustAlloc = TRUE;
|
|
|
|
if (fMustAlloc)
|
2007-06-18 12:47:49 +02:00
|
|
|
*ppMemory = NdrAllocate(pStubMsg, size);
|
|
|
|
|
2009-03-20 17:13:00 +01:00
|
|
|
/* we can't pass fMustAlloc=TRUE into the marshaller for the arm
|
|
|
|
* since the arm is part of the memory block that is encompassed by
|
|
|
|
* the whole union. Memory is forced to allocate when pointers
|
|
|
|
* are set to NULL, so we emulate that part of fMustAlloc=TRUE by
|
|
|
|
* clearing the memory we pass in to the unmarshaller */
|
|
|
|
if (fMustAlloc)
|
|
|
|
memset(*ppMemory, 0, size);
|
|
|
|
|
2007-06-18 12:47:49 +02:00
|
|
|
NdrBaseTypeUnmarshall(pStubMsg, ppMemory, &switch_type, FALSE);
|
|
|
|
pMemoryArm = *ppMemory + increment;
|
|
|
|
|
2009-03-20 17:13:00 +01:00
|
|
|
return union_arm_unmarshall(pStubMsg, &pMemoryArm, switch_value, pFormat, FALSE);
|
2007-06-18 12:47:49 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* NdrEncapsulatedUnionBufferSize [RPCRT4.@]
|
|
|
|
*/
|
|
|
|
void WINAPI NdrEncapsulatedUnionBufferSize(PMIDL_STUB_MESSAGE pStubMsg,
|
|
|
|
unsigned char *pMemory,
|
|
|
|
PFORMAT_STRING pFormat)
|
|
|
|
{
|
|
|
|
unsigned char switch_type;
|
|
|
|
unsigned char increment;
|
|
|
|
ULONG switch_value;
|
|
|
|
|
|
|
|
TRACE("(%p, %p, %p)\n", pStubMsg, pMemory, pFormat);
|
|
|
|
pFormat++;
|
|
|
|
|
|
|
|
switch_type = *pFormat & 0xf;
|
2007-06-19 03:40:08 +02:00
|
|
|
increment = (*pFormat & 0xf0) >> 4;
|
2007-06-18 12:47:49 +02:00
|
|
|
pFormat++;
|
|
|
|
|
2010-04-02 21:54:55 +02:00
|
|
|
align_length(&pStubMsg->BufferLength, increment);
|
2007-06-19 03:41:04 +02:00
|
|
|
switch_value = get_discriminant(switch_type, pMemory);
|
2007-06-18 12:47:49 +02:00
|
|
|
TRACE("got switch value 0x%x\n", switch_value);
|
|
|
|
|
|
|
|
/* Add discriminant size */
|
|
|
|
NdrBaseTypeBufferSize(pStubMsg, (unsigned char *)&switch_value, &switch_type);
|
|
|
|
pMemory += increment;
|
|
|
|
|
|
|
|
union_arm_buffer_size(pStubMsg, pMemory, switch_value, pFormat);
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* NdrEncapsulatedUnionMemorySize [RPCRT4.@]
|
|
|
|
*/
|
|
|
|
ULONG WINAPI NdrEncapsulatedUnionMemorySize(PMIDL_STUB_MESSAGE pStubMsg,
|
|
|
|
PFORMAT_STRING pFormat)
|
|
|
|
{
|
|
|
|
unsigned char switch_type;
|
|
|
|
unsigned char increment;
|
|
|
|
ULONG switch_value;
|
|
|
|
|
|
|
|
switch_type = *pFormat & 0xf;
|
2007-06-19 03:40:08 +02:00
|
|
|
increment = (*pFormat & 0xf0) >> 4;
|
2007-06-18 12:47:49 +02:00
|
|
|
pFormat++;
|
|
|
|
|
2010-04-02 21:54:55 +02:00
|
|
|
align_pointer(&pStubMsg->Buffer, increment);
|
2007-06-18 12:47:49 +02:00
|
|
|
switch_value = get_discriminant(switch_type, pStubMsg->Buffer);
|
|
|
|
TRACE("got switch value 0x%x\n", switch_value);
|
|
|
|
|
|
|
|
pStubMsg->Memory += increment;
|
|
|
|
|
|
|
|
return increment + union_arm_memory_size(pStubMsg, switch_value, pFormat + *(const SHORT*)pFormat);
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* NdrEncapsulatedUnionFree [RPCRT4.@]
|
|
|
|
*/
|
|
|
|
void WINAPI NdrEncapsulatedUnionFree(PMIDL_STUB_MESSAGE pStubMsg,
|
|
|
|
unsigned char *pMemory,
|
|
|
|
PFORMAT_STRING pFormat)
|
|
|
|
{
|
|
|
|
unsigned char switch_type;
|
|
|
|
unsigned char increment;
|
|
|
|
ULONG switch_value;
|
|
|
|
|
|
|
|
TRACE("(%p, %p, %p)\n", pStubMsg, pMemory, pFormat);
|
|
|
|
pFormat++;
|
|
|
|
|
|
|
|
switch_type = *pFormat & 0xf;
|
2007-06-19 03:40:08 +02:00
|
|
|
increment = (*pFormat & 0xf0) >> 4;
|
2007-06-18 12:47:49 +02:00
|
|
|
pFormat++;
|
|
|
|
|
|
|
|
switch_value = get_discriminant(switch_type, pMemory);
|
|
|
|
TRACE("got switch value 0x%x\n", switch_value);
|
|
|
|
|
|
|
|
pMemory += increment;
|
|
|
|
|
2008-03-29 20:10:17 +01:00
|
|
|
union_arm_free(pStubMsg, pMemory, switch_value, pFormat);
|
2007-06-18 12:47:49 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* NdrNonEncapsulatedUnionMarshall [RPCRT4.@]
|
|
|
|
*/
|
|
|
|
unsigned char * WINAPI NdrNonEncapsulatedUnionMarshall(PMIDL_STUB_MESSAGE pStubMsg,
|
|
|
|
unsigned char *pMemory,
|
|
|
|
PFORMAT_STRING pFormat)
|
|
|
|
{
|
|
|
|
unsigned char switch_type;
|
|
|
|
|
|
|
|
TRACE("(%p, %p, %p)\n", pStubMsg, pMemory, pFormat);
|
|
|
|
pFormat++;
|
|
|
|
|
|
|
|
switch_type = *pFormat;
|
|
|
|
pFormat++;
|
|
|
|
|
|
|
|
pFormat = ComputeConformance(pStubMsg, pMemory, pFormat, 0);
|
|
|
|
TRACE("got switch value 0x%lx\n", pStubMsg->MaxCount);
|
|
|
|
/* Marshall discriminant */
|
|
|
|
NdrBaseTypeMarshall(pStubMsg, (unsigned char *)&pStubMsg->MaxCount, &switch_type);
|
|
|
|
|
|
|
|
return union_arm_marshall(pStubMsg, pMemory, pStubMsg->MaxCount, pFormat + *(const SHORT*)pFormat);
|
|
|
|
}
|
|
|
|
|
2009-04-21 09:59:45 +02:00
|
|
|
static LONG unmarshall_discriminant(PMIDL_STUB_MESSAGE pStubMsg,
|
2007-06-18 12:47:49 +02:00
|
|
|
PFORMAT_STRING *ppFormat)
|
|
|
|
{
|
2009-04-21 09:59:45 +02:00
|
|
|
LONG discriminant = 0;
|
2007-06-18 12:47:49 +02:00
|
|
|
|
|
|
|
switch(**ppFormat)
|
|
|
|
{
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_BYTE:
|
|
|
|
case FC_CHAR:
|
|
|
|
case FC_SMALL:
|
|
|
|
case FC_USMALL:
|
2007-07-16 16:02:38 +02:00
|
|
|
{
|
|
|
|
UCHAR d;
|
2007-11-28 16:01:53 +01:00
|
|
|
safe_copy_from_buffer(pStubMsg, &d, sizeof(d));
|
2007-07-16 16:02:38 +02:00
|
|
|
discriminant = d;
|
2007-06-18 12:47:49 +02:00
|
|
|
break;
|
2007-07-16 16:02:38 +02:00
|
|
|
}
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_WCHAR:
|
|
|
|
case FC_SHORT:
|
|
|
|
case FC_USHORT:
|
|
|
|
case FC_ENUM16:
|
2007-07-16 16:02:38 +02:00
|
|
|
{
|
|
|
|
USHORT d;
|
2010-04-02 21:54:55 +02:00
|
|
|
align_pointer(&pStubMsg->Buffer, sizeof(USHORT));
|
2007-11-28 16:01:53 +01:00
|
|
|
safe_copy_from_buffer(pStubMsg, &d, sizeof(d));
|
2007-07-16 16:02:38 +02:00
|
|
|
discriminant = d;
|
2007-06-18 12:47:49 +02:00
|
|
|
break;
|
2007-07-16 16:02:38 +02:00
|
|
|
}
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_LONG:
|
|
|
|
case FC_ULONG:
|
2007-07-16 16:02:38 +02:00
|
|
|
{
|
|
|
|
ULONG d;
|
2010-04-02 21:54:55 +02:00
|
|
|
align_pointer(&pStubMsg->Buffer, sizeof(ULONG));
|
2007-11-28 16:01:53 +01:00
|
|
|
safe_copy_from_buffer(pStubMsg, &d, sizeof(d));
|
2007-07-16 16:02:38 +02:00
|
|
|
discriminant = d;
|
2007-06-18 12:47:49 +02:00
|
|
|
break;
|
2007-07-16 16:02:38 +02:00
|
|
|
}
|
2007-06-18 12:47:49 +02:00
|
|
|
default:
|
|
|
|
FIXME("Unhandled base type: 0x%02x\n", **ppFormat);
|
|
|
|
}
|
|
|
|
(*ppFormat)++;
|
|
|
|
|
2015-03-09 10:42:45 +01:00
|
|
|
*ppFormat = SkipConformance(pStubMsg, *ppFormat);
|
2007-06-18 12:47:49 +02:00
|
|
|
return discriminant;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**********************************************************************
|
|
|
|
* NdrNonEncapsulatedUnionUnmarshall [RPCRT4.@]
|
|
|
|
*/
|
|
|
|
unsigned char * WINAPI NdrNonEncapsulatedUnionUnmarshall(PMIDL_STUB_MESSAGE pStubMsg,
|
|
|
|
unsigned char **ppMemory,
|
|
|
|
PFORMAT_STRING pFormat,
|
|
|
|
unsigned char fMustAlloc)
|
|
|
|
{
|
2009-04-21 09:59:45 +02:00
|
|
|
LONG discriminant;
|
2007-06-18 12:47:49 +02:00
|
|
|
unsigned short size;
|
|
|
|
|
|
|
|
TRACE("(%p, %p, %p, %d)\n", pStubMsg, ppMemory, pFormat, fMustAlloc);
|
|
|
|
pFormat++;
|
|
|
|
|
|
|
|
/* Unmarshall discriminant */
|
|
|
|
discriminant = unmarshall_discriminant(pStubMsg, &pFormat);
|
2009-04-21 09:59:45 +02:00
|
|
|
TRACE("unmarshalled discriminant %x\n", discriminant);
|
2007-06-18 12:47:49 +02:00
|
|
|
|
|
|
|
pFormat += *(const SHORT*)pFormat;
|
|
|
|
|
|
|
|
size = *(const unsigned short*)pFormat;
|
|
|
|
|
2009-01-10 23:17:15 +01:00
|
|
|
if (!fMustAlloc && !*ppMemory)
|
|
|
|
fMustAlloc = TRUE;
|
|
|
|
if (fMustAlloc)
|
2007-06-18 12:47:49 +02:00
|
|
|
*ppMemory = NdrAllocate(pStubMsg, size);
|
|
|
|
|
2009-03-20 17:13:00 +01:00
|
|
|
/* we can't pass fMustAlloc=TRUE into the marshaller for the arm
|
|
|
|
* since the arm is part of the memory block that is encompassed by
|
|
|
|
* the whole union. Memory is forced to allocate when pointers
|
|
|
|
* are set to NULL, so we emulate that part of fMustAlloc=TRUE by
|
|
|
|
* clearing the memory we pass in to the unmarshaller */
|
|
|
|
if (fMustAlloc)
|
|
|
|
memset(*ppMemory, 0, size);
|
|
|
|
|
|
|
|
return union_arm_unmarshall(pStubMsg, ppMemory, discriminant, pFormat, FALSE);
|
2007-06-18 12:47:49 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* NdrNonEncapsulatedUnionBufferSize [RPCRT4.@]
|
|
|
|
*/
|
|
|
|
void WINAPI NdrNonEncapsulatedUnionBufferSize(PMIDL_STUB_MESSAGE pStubMsg,
|
|
|
|
unsigned char *pMemory,
|
|
|
|
PFORMAT_STRING pFormat)
|
|
|
|
{
|
|
|
|
unsigned char switch_type;
|
|
|
|
|
|
|
|
TRACE("(%p, %p, %p)\n", pStubMsg, pMemory, pFormat);
|
|
|
|
pFormat++;
|
|
|
|
|
|
|
|
switch_type = *pFormat;
|
|
|
|
pFormat++;
|
|
|
|
|
|
|
|
pFormat = ComputeConformance(pStubMsg, pMemory, pFormat, 0);
|
|
|
|
TRACE("got switch value 0x%lx\n", pStubMsg->MaxCount);
|
|
|
|
/* Add discriminant size */
|
|
|
|
NdrBaseTypeBufferSize(pStubMsg, (unsigned char *)&pStubMsg->MaxCount, &switch_type);
|
|
|
|
|
|
|
|
union_arm_buffer_size(pStubMsg, pMemory, pStubMsg->MaxCount, pFormat + *(const SHORT*)pFormat);
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* NdrNonEncapsulatedUnionMemorySize [RPCRT4.@]
|
|
|
|
*/
|
|
|
|
ULONG WINAPI NdrNonEncapsulatedUnionMemorySize(PMIDL_STUB_MESSAGE pStubMsg,
|
|
|
|
PFORMAT_STRING pFormat)
|
|
|
|
{
|
|
|
|
ULONG discriminant;
|
|
|
|
|
|
|
|
pFormat++;
|
|
|
|
/* Unmarshall discriminant */
|
|
|
|
discriminant = unmarshall_discriminant(pStubMsg, &pFormat);
|
|
|
|
TRACE("unmarshalled discriminant 0x%x\n", discriminant);
|
|
|
|
|
|
|
|
return union_arm_memory_size(pStubMsg, discriminant, pFormat + *(const SHORT*)pFormat);
|
|
|
|
}
|
|
|
|
|
2005-07-18 15:14:05 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* NdrNonEncapsulatedUnionFree [RPCRT4.@]
|
|
|
|
*/
|
|
|
|
void WINAPI NdrNonEncapsulatedUnionFree(PMIDL_STUB_MESSAGE pStubMsg,
|
|
|
|
unsigned char *pMemory,
|
|
|
|
PFORMAT_STRING pFormat)
|
|
|
|
{
|
2007-06-18 12:47:49 +02:00
|
|
|
TRACE("(%p, %p, %p)\n", pStubMsg, pMemory, pFormat);
|
|
|
|
pFormat++;
|
|
|
|
pFormat++;
|
|
|
|
|
|
|
|
pFormat = ComputeConformance(pStubMsg, pMemory, pFormat, 0);
|
|
|
|
TRACE("got switch value 0x%lx\n", pStubMsg->MaxCount);
|
|
|
|
|
2008-03-29 20:10:17 +01:00
|
|
|
union_arm_free(pStubMsg, pMemory, pStubMsg->MaxCount, pFormat + *(const SHORT*)pFormat);
|
2005-07-18 15:14:05 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* NdrByteCountPointerMarshall [RPCRT4.@]
|
|
|
|
*/
|
|
|
|
unsigned char * WINAPI NdrByteCountPointerMarshall(PMIDL_STUB_MESSAGE pStubMsg,
|
|
|
|
unsigned char *pMemory,
|
|
|
|
PFORMAT_STRING pFormat)
|
|
|
|
{
|
|
|
|
FIXME("stub\n");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* NdrByteCountPointerUnmarshall [RPCRT4.@]
|
|
|
|
*/
|
|
|
|
unsigned char * WINAPI NdrByteCountPointerUnmarshall(PMIDL_STUB_MESSAGE pStubMsg,
|
|
|
|
unsigned char **ppMemory,
|
|
|
|
PFORMAT_STRING pFormat,
|
|
|
|
unsigned char fMustAlloc)
|
|
|
|
{
|
|
|
|
FIXME("stub\n");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* NdrByteCountPointerBufferSize [RPCRT4.@]
|
|
|
|
*/
|
|
|
|
void WINAPI NdrByteCountPointerBufferSize(PMIDL_STUB_MESSAGE pStubMsg,
|
|
|
|
unsigned char *pMemory,
|
|
|
|
PFORMAT_STRING pFormat)
|
|
|
|
{
|
|
|
|
FIXME("stub\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
2009-01-23 16:09:18 +01:00
|
|
|
* NdrByteCountPointerMemorySize [internal]
|
2005-07-18 15:14:05 +02:00
|
|
|
*/
|
2009-01-23 16:09:18 +01:00
|
|
|
static ULONG WINAPI NdrByteCountPointerMemorySize(PMIDL_STUB_MESSAGE pStubMsg,
|
|
|
|
PFORMAT_STRING pFormat)
|
2005-07-18 15:14:05 +02:00
|
|
|
{
|
|
|
|
FIXME("stub\n");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* NdrByteCountPointerFree [RPCRT4.@]
|
|
|
|
*/
|
|
|
|
void WINAPI NdrByteCountPointerFree(PMIDL_STUB_MESSAGE pStubMsg,
|
|
|
|
unsigned char *pMemory,
|
|
|
|
PFORMAT_STRING pFormat)
|
|
|
|
{
|
|
|
|
FIXME("stub\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* NdrXmitOrRepAsMarshall [RPCRT4.@]
|
|
|
|
*/
|
|
|
|
unsigned char * WINAPI NdrXmitOrRepAsMarshall(PMIDL_STUB_MESSAGE pStubMsg,
|
|
|
|
unsigned char *pMemory,
|
|
|
|
PFORMAT_STRING pFormat)
|
|
|
|
{
|
|
|
|
FIXME("stub\n");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* NdrXmitOrRepAsUnmarshall [RPCRT4.@]
|
|
|
|
*/
|
|
|
|
unsigned char * WINAPI NdrXmitOrRepAsUnmarshall(PMIDL_STUB_MESSAGE pStubMsg,
|
|
|
|
unsigned char **ppMemory,
|
|
|
|
PFORMAT_STRING pFormat,
|
|
|
|
unsigned char fMustAlloc)
|
|
|
|
{
|
|
|
|
FIXME("stub\n");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* NdrXmitOrRepAsBufferSize [RPCRT4.@]
|
|
|
|
*/
|
|
|
|
void WINAPI NdrXmitOrRepAsBufferSize(PMIDL_STUB_MESSAGE pStubMsg,
|
|
|
|
unsigned char *pMemory,
|
|
|
|
PFORMAT_STRING pFormat)
|
|
|
|
{
|
|
|
|
FIXME("stub\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* NdrXmitOrRepAsMemorySize [RPCRT4.@]
|
|
|
|
*/
|
2006-11-09 23:01:58 +01:00
|
|
|
ULONG WINAPI NdrXmitOrRepAsMemorySize(PMIDL_STUB_MESSAGE pStubMsg,
|
2005-07-18 15:14:05 +02:00
|
|
|
PFORMAT_STRING pFormat)
|
|
|
|
{
|
|
|
|
FIXME("stub\n");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* NdrXmitOrRepAsFree [RPCRT4.@]
|
|
|
|
*/
|
|
|
|
void WINAPI NdrXmitOrRepAsFree(PMIDL_STUB_MESSAGE pStubMsg,
|
|
|
|
unsigned char *pMemory,
|
|
|
|
PFORMAT_STRING pFormat)
|
|
|
|
{
|
|
|
|
FIXME("stub\n");
|
|
|
|
}
|
|
|
|
|
2007-06-25 15:28:40 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* NdrRangeMarshall [internal]
|
|
|
|
*/
|
2009-01-23 16:09:18 +01:00
|
|
|
static unsigned char *WINAPI NdrRangeMarshall(
|
2007-06-25 15:28:40 +02:00
|
|
|
PMIDL_STUB_MESSAGE pStubMsg,
|
|
|
|
unsigned char *pMemory,
|
|
|
|
PFORMAT_STRING pFormat)
|
|
|
|
{
|
2010-03-26 21:53:36 +01:00
|
|
|
const NDR_RANGE *pRange = (const NDR_RANGE *)pFormat;
|
2007-06-25 15:28:40 +02:00
|
|
|
unsigned char base_type;
|
|
|
|
|
|
|
|
TRACE("pStubMsg %p, pMemory %p, type 0x%02x\n", pStubMsg, pMemory, *pFormat);
|
|
|
|
|
2018-06-13 04:19:10 +02:00
|
|
|
if (pRange->type != FC_RANGE)
|
2007-06-25 15:28:40 +02:00
|
|
|
{
|
|
|
|
ERR("invalid format type %x\n", pRange->type);
|
|
|
|
RpcRaiseException(RPC_S_INTERNAL_ERROR);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
base_type = pRange->flags_type & 0xf;
|
|
|
|
|
|
|
|
return NdrBaseTypeMarshall(pStubMsg, pMemory, &base_type);
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
2009-01-23 16:09:18 +01:00
|
|
|
* NdrRangeUnmarshall [RPCRT4.@]
|
2007-06-25 15:28:40 +02:00
|
|
|
*/
|
|
|
|
unsigned char *WINAPI NdrRangeUnmarshall(
|
|
|
|
PMIDL_STUB_MESSAGE pStubMsg,
|
|
|
|
unsigned char **ppMemory,
|
|
|
|
PFORMAT_STRING pFormat,
|
|
|
|
unsigned char fMustAlloc)
|
|
|
|
{
|
2010-03-26 21:53:36 +01:00
|
|
|
const NDR_RANGE *pRange = (const NDR_RANGE *)pFormat;
|
2007-06-25 15:28:40 +02:00
|
|
|
unsigned char base_type;
|
|
|
|
|
|
|
|
TRACE("pStubMsg: %p, ppMemory: %p, type: 0x%02x, fMustAlloc: %s\n", pStubMsg, ppMemory, *pFormat, fMustAlloc ? "true" : "false");
|
|
|
|
|
2018-06-13 04:19:10 +02:00
|
|
|
if (pRange->type != FC_RANGE)
|
2007-06-25 15:28:40 +02:00
|
|
|
{
|
|
|
|
ERR("invalid format type %x\n", pRange->type);
|
|
|
|
RpcRaiseException(RPC_S_INTERNAL_ERROR);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
base_type = pRange->flags_type & 0xf;
|
|
|
|
|
|
|
|
TRACE("base_type = 0x%02x, low_value = %d, high_value = %d\n",
|
|
|
|
base_type, pRange->low_value, pRange->high_value);
|
|
|
|
|
2009-03-20 17:11:58 +01:00
|
|
|
#define RANGE_UNMARSHALL(mem_type, wire_type, format_spec) \
|
2007-06-25 15:28:40 +02:00
|
|
|
do \
|
|
|
|
{ \
|
2010-04-02 21:54:55 +02:00
|
|
|
align_pointer(&pStubMsg->Buffer, sizeof(wire_type)); \
|
2009-01-10 23:17:15 +01:00
|
|
|
if (!fMustAlloc && !*ppMemory) \
|
|
|
|
fMustAlloc = TRUE; \
|
|
|
|
if (fMustAlloc) \
|
2009-03-20 17:11:58 +01:00
|
|
|
*ppMemory = NdrAllocate(pStubMsg, sizeof(mem_type)); \
|
|
|
|
if (pStubMsg->Buffer + sizeof(wire_type) > pStubMsg->BufferEnd) \
|
2007-11-28 16:02:21 +01:00
|
|
|
{ \
|
|
|
|
ERR("buffer overflow - Buffer = %p, BufferEnd = %p\n", \
|
|
|
|
pStubMsg->Buffer, (unsigned char *)pStubMsg->RpcMsg->Buffer + pStubMsg->BufferLength); \
|
|
|
|
RpcRaiseException(RPC_X_BAD_STUB_DATA); \
|
|
|
|
} \
|
2009-03-20 17:11:58 +01:00
|
|
|
if ((*(wire_type *)pStubMsg->Buffer < (mem_type)pRange->low_value) || \
|
|
|
|
(*(wire_type *)pStubMsg->Buffer > (mem_type)pRange->high_value)) \
|
2007-06-25 15:28:40 +02:00
|
|
|
{ \
|
|
|
|
ERR("value exceeded bounds: " format_spec ", low: " format_spec ", high: " format_spec "\n", \
|
2009-03-20 17:11:58 +01:00
|
|
|
*(wire_type *)pStubMsg->Buffer, (mem_type)pRange->low_value, \
|
|
|
|
(mem_type)pRange->high_value); \
|
2007-06-25 15:28:40 +02:00
|
|
|
RpcRaiseException(RPC_S_INVALID_BOUND); \
|
|
|
|
return NULL; \
|
|
|
|
} \
|
|
|
|
TRACE("*ppMemory: %p\n", *ppMemory); \
|
2009-03-20 17:11:58 +01:00
|
|
|
**(mem_type **)ppMemory = *(wire_type *)pStubMsg->Buffer; \
|
|
|
|
pStubMsg->Buffer += sizeof(wire_type); \
|
2007-06-25 15:28:40 +02:00
|
|
|
} while (0)
|
|
|
|
|
|
|
|
switch(base_type)
|
|
|
|
{
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_CHAR:
|
|
|
|
case FC_SMALL:
|
2009-03-20 17:11:58 +01:00
|
|
|
RANGE_UNMARSHALL(UCHAR, UCHAR, "%d");
|
2008-01-16 22:57:31 +01:00
|
|
|
TRACE("value: 0x%02x\n", **ppMemory);
|
2007-06-25 15:28:40 +02:00
|
|
|
break;
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_BYTE:
|
|
|
|
case FC_USMALL:
|
2009-03-20 17:11:58 +01:00
|
|
|
RANGE_UNMARSHALL(CHAR, CHAR, "%u");
|
2008-01-16 22:57:31 +01:00
|
|
|
TRACE("value: 0x%02x\n", **ppMemory);
|
2007-06-25 15:28:40 +02:00
|
|
|
break;
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_WCHAR: /* FIXME: valid? */
|
|
|
|
case FC_USHORT:
|
2009-03-20 17:11:58 +01:00
|
|
|
RANGE_UNMARSHALL(USHORT, USHORT, "%u");
|
2007-06-25 15:28:40 +02:00
|
|
|
TRACE("value: 0x%04x\n", **(USHORT **)ppMemory);
|
|
|
|
break;
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_SHORT:
|
2009-03-20 17:11:58 +01:00
|
|
|
RANGE_UNMARSHALL(SHORT, SHORT, "%d");
|
2007-06-25 15:28:40 +02:00
|
|
|
TRACE("value: 0x%04x\n", **(USHORT **)ppMemory);
|
|
|
|
break;
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_LONG:
|
|
|
|
case FC_ENUM32:
|
2009-03-20 17:11:58 +01:00
|
|
|
RANGE_UNMARSHALL(LONG, LONG, "%d");
|
2007-06-25 15:28:40 +02:00
|
|
|
TRACE("value: 0x%08x\n", **(ULONG **)ppMemory);
|
|
|
|
break;
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_ULONG:
|
2009-03-20 17:11:58 +01:00
|
|
|
RANGE_UNMARSHALL(ULONG, ULONG, "%u");
|
2007-06-25 15:28:40 +02:00
|
|
|
TRACE("value: 0x%08x\n", **(ULONG **)ppMemory);
|
|
|
|
break;
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_ENUM16:
|
2009-03-20 17:11:58 +01:00
|
|
|
RANGE_UNMARSHALL(UINT, USHORT, "%u");
|
|
|
|
TRACE("value: 0x%08x\n", **(UINT **)ppMemory);
|
2007-06-25 15:28:40 +02:00
|
|
|
break;
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_FLOAT:
|
|
|
|
case FC_DOUBLE:
|
|
|
|
case FC_HYPER:
|
2007-06-25 15:28:40 +02:00
|
|
|
default:
|
|
|
|
ERR("invalid range base type: 0x%02x\n", base_type);
|
|
|
|
RpcRaiseException(RPC_S_INTERNAL_ERROR);
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* NdrRangeBufferSize [internal]
|
|
|
|
*/
|
2009-01-23 16:09:18 +01:00
|
|
|
static void WINAPI NdrRangeBufferSize(
|
2007-06-25 15:28:40 +02:00
|
|
|
PMIDL_STUB_MESSAGE pStubMsg,
|
|
|
|
unsigned char *pMemory,
|
|
|
|
PFORMAT_STRING pFormat)
|
|
|
|
{
|
2010-03-26 21:53:36 +01:00
|
|
|
const NDR_RANGE *pRange = (const NDR_RANGE *)pFormat;
|
2007-06-25 15:28:40 +02:00
|
|
|
unsigned char base_type;
|
|
|
|
|
|
|
|
TRACE("pStubMsg %p, pMemory %p, type 0x%02x\n", pStubMsg, pMemory, *pFormat);
|
|
|
|
|
2018-06-13 04:19:10 +02:00
|
|
|
if (pRange->type != FC_RANGE)
|
2007-06-25 15:28:40 +02:00
|
|
|
{
|
|
|
|
ERR("invalid format type %x\n", pRange->type);
|
|
|
|
RpcRaiseException(RPC_S_INTERNAL_ERROR);
|
|
|
|
}
|
|
|
|
base_type = pRange->flags_type & 0xf;
|
|
|
|
|
|
|
|
NdrBaseTypeBufferSize(pStubMsg, pMemory, &base_type);
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* NdrRangeMemorySize [internal]
|
|
|
|
*/
|
2009-01-23 16:09:18 +01:00
|
|
|
static ULONG WINAPI NdrRangeMemorySize(
|
2007-06-25 15:28:40 +02:00
|
|
|
PMIDL_STUB_MESSAGE pStubMsg,
|
|
|
|
PFORMAT_STRING pFormat)
|
|
|
|
{
|
2010-03-26 21:53:36 +01:00
|
|
|
const NDR_RANGE *pRange = (const NDR_RANGE *)pFormat;
|
2007-06-25 15:28:40 +02:00
|
|
|
unsigned char base_type;
|
|
|
|
|
2018-06-13 04:19:10 +02:00
|
|
|
if (pRange->type != FC_RANGE)
|
2007-06-25 15:28:40 +02:00
|
|
|
{
|
|
|
|
ERR("invalid format type %x\n", pRange->type);
|
|
|
|
RpcRaiseException(RPC_S_INTERNAL_ERROR);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
base_type = pRange->flags_type & 0xf;
|
|
|
|
|
|
|
|
return NdrBaseTypeMemorySize(pStubMsg, &base_type);
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* NdrRangeFree [internal]
|
|
|
|
*/
|
2009-01-23 16:09:18 +01:00
|
|
|
static void WINAPI NdrRangeFree(PMIDL_STUB_MESSAGE pStubMsg,
|
2007-06-25 15:28:40 +02:00
|
|
|
unsigned char *pMemory,
|
|
|
|
PFORMAT_STRING pFormat)
|
|
|
|
{
|
|
|
|
TRACE("pStubMsg %p pMemory %p type 0x%02x\n", pStubMsg, pMemory, *pFormat);
|
|
|
|
|
|
|
|
/* nothing to do */
|
|
|
|
}
|
|
|
|
|
2005-11-28 11:24:21 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* NdrBaseTypeMarshall [internal]
|
|
|
|
*/
|
|
|
|
static unsigned char *WINAPI NdrBaseTypeMarshall(
|
|
|
|
PMIDL_STUB_MESSAGE pStubMsg,
|
|
|
|
unsigned char *pMemory,
|
|
|
|
PFORMAT_STRING pFormat)
|
|
|
|
{
|
|
|
|
TRACE("pStubMsg %p, pMemory %p, type 0x%02x\n", pStubMsg, pMemory, *pFormat);
|
|
|
|
|
|
|
|
switch(*pFormat)
|
|
|
|
{
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_BYTE:
|
|
|
|
case FC_CHAR:
|
|
|
|
case FC_SMALL:
|
|
|
|
case FC_USMALL:
|
2007-11-28 16:02:06 +01:00
|
|
|
safe_copy_to_buffer(pStubMsg, pMemory, sizeof(UCHAR));
|
2008-01-16 22:57:31 +01:00
|
|
|
TRACE("value: 0x%02x\n", *pMemory);
|
2005-11-28 11:24:21 +01:00
|
|
|
break;
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_WCHAR:
|
|
|
|
case FC_SHORT:
|
|
|
|
case FC_USHORT:
|
2010-04-02 21:54:55 +02:00
|
|
|
align_pointer_clear(&pStubMsg->Buffer, sizeof(USHORT));
|
2007-11-28 16:02:06 +01:00
|
|
|
safe_copy_to_buffer(pStubMsg, pMemory, sizeof(USHORT));
|
2005-11-28 11:24:21 +01:00
|
|
|
TRACE("value: 0x%04x\n", *(USHORT *)pMemory);
|
|
|
|
break;
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_LONG:
|
|
|
|
case FC_ULONG:
|
|
|
|
case FC_ERROR_STATUS_T:
|
|
|
|
case FC_ENUM32:
|
2010-04-02 21:54:55 +02:00
|
|
|
align_pointer_clear(&pStubMsg->Buffer, sizeof(ULONG));
|
2007-11-28 16:02:06 +01:00
|
|
|
safe_copy_to_buffer(pStubMsg, pMemory, sizeof(ULONG));
|
2006-11-09 23:04:48 +01:00
|
|
|
TRACE("value: 0x%08x\n", *(ULONG *)pMemory);
|
2005-11-28 11:24:21 +01:00
|
|
|
break;
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_FLOAT:
|
2010-04-02 21:54:55 +02:00
|
|
|
align_pointer_clear(&pStubMsg->Buffer, sizeof(float));
|
2007-11-28 16:02:06 +01:00
|
|
|
safe_copy_to_buffer(pStubMsg, pMemory, sizeof(float));
|
2005-11-28 11:24:21 +01:00
|
|
|
break;
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_DOUBLE:
|
2010-04-02 21:54:55 +02:00
|
|
|
align_pointer_clear(&pStubMsg->Buffer, sizeof(double));
|
2007-11-28 16:02:06 +01:00
|
|
|
safe_copy_to_buffer(pStubMsg, pMemory, sizeof(double));
|
2005-11-28 11:24:21 +01:00
|
|
|
break;
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_HYPER:
|
2010-04-02 21:54:55 +02:00
|
|
|
align_pointer_clear(&pStubMsg->Buffer, sizeof(ULONGLONG));
|
2007-11-28 16:02:06 +01:00
|
|
|
safe_copy_to_buffer(pStubMsg, pMemory, sizeof(ULONGLONG));
|
2005-11-28 11:24:21 +01:00
|
|
|
TRACE("value: %s\n", wine_dbgstr_longlong(*(ULONGLONG*)pMemory));
|
|
|
|
break;
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_ENUM16:
|
2010-04-07 13:04:32 +02:00
|
|
|
{
|
|
|
|
USHORT val = *(UINT *)pMemory;
|
2006-03-01 13:21:56 +01:00
|
|
|
/* only 16-bits on the wire, so do a sanity check */
|
2007-07-16 16:00:59 +02:00
|
|
|
if (*(UINT *)pMemory > SHRT_MAX)
|
2006-03-01 13:21:56 +01:00
|
|
|
RpcRaiseException(RPC_X_ENUM_VALUE_OUT_OF_RANGE);
|
2010-04-02 21:54:55 +02:00
|
|
|
align_pointer_clear(&pStubMsg->Buffer, sizeof(USHORT));
|
2010-04-07 13:04:32 +02:00
|
|
|
safe_copy_to_buffer(pStubMsg, &val, sizeof(val));
|
2006-03-01 13:21:56 +01:00
|
|
|
TRACE("value: 0x%04x\n", *(UINT *)pMemory);
|
|
|
|
break;
|
2010-04-07 13:04:32 +02:00
|
|
|
}
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_INT3264:
|
|
|
|
case FC_UINT3264:
|
2010-04-07 13:08:46 +02:00
|
|
|
{
|
|
|
|
UINT val = *(UINT_PTR *)pMemory;
|
|
|
|
align_pointer_clear(&pStubMsg->Buffer, sizeof(UINT));
|
|
|
|
safe_copy_to_buffer(pStubMsg, &val, sizeof(val));
|
|
|
|
break;
|
|
|
|
}
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_IGNORE:
|
2007-11-05 12:10:07 +01:00
|
|
|
break;
|
2005-11-28 11:24:21 +01:00
|
|
|
default:
|
|
|
|
FIXME("Unhandled base type: 0x%02x\n", *pFormat);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* FIXME: what is the correct return value? */
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* NdrBaseTypeUnmarshall [internal]
|
|
|
|
*/
|
|
|
|
static unsigned char *WINAPI NdrBaseTypeUnmarshall(
|
|
|
|
PMIDL_STUB_MESSAGE pStubMsg,
|
|
|
|
unsigned char **ppMemory,
|
|
|
|
PFORMAT_STRING pFormat,
|
|
|
|
unsigned char fMustAlloc)
|
|
|
|
{
|
|
|
|
TRACE("pStubMsg: %p, ppMemory: %p, type: 0x%02x, fMustAlloc: %s\n", pStubMsg, ppMemory, *pFormat, fMustAlloc ? "true" : "false");
|
|
|
|
|
2010-04-07 13:04:32 +02:00
|
|
|
#define BASE_TYPE_UNMARSHALL(type) do { \
|
2010-04-02 21:54:55 +02:00
|
|
|
align_pointer(&pStubMsg->Buffer, sizeof(type)); \
|
2007-12-05 12:56:32 +01:00
|
|
|
if (!fMustAlloc && !pStubMsg->IsClient && !*ppMemory) \
|
|
|
|
{ \
|
|
|
|
*ppMemory = pStubMsg->Buffer; \
|
|
|
|
TRACE("*ppMemory: %p\n", *ppMemory); \
|
2008-04-28 11:21:33 +02:00
|
|
|
safe_buffer_increment(pStubMsg, sizeof(type)); \
|
2007-12-05 12:56:32 +01:00
|
|
|
} \
|
|
|
|
else \
|
|
|
|
{ \
|
|
|
|
if (fMustAlloc) \
|
|
|
|
*ppMemory = NdrAllocate(pStubMsg, sizeof(type)); \
|
|
|
|
TRACE("*ppMemory: %p\n", *ppMemory); \
|
2008-04-28 11:21:33 +02:00
|
|
|
safe_copy_from_buffer(pStubMsg, *ppMemory, sizeof(type)); \
|
2010-04-07 13:04:32 +02:00
|
|
|
} \
|
|
|
|
} while (0)
|
2006-05-19 17:02:59 +02:00
|
|
|
|
2005-11-28 11:24:21 +01:00
|
|
|
switch(*pFormat)
|
|
|
|
{
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_BYTE:
|
|
|
|
case FC_CHAR:
|
|
|
|
case FC_SMALL:
|
|
|
|
case FC_USMALL:
|
2006-05-19 17:02:59 +02:00
|
|
|
BASE_TYPE_UNMARSHALL(UCHAR);
|
2008-01-16 22:57:31 +01:00
|
|
|
TRACE("value: 0x%02x\n", **ppMemory);
|
2005-11-28 11:24:21 +01:00
|
|
|
break;
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_WCHAR:
|
|
|
|
case FC_SHORT:
|
|
|
|
case FC_USHORT:
|
2006-05-19 17:02:59 +02:00
|
|
|
BASE_TYPE_UNMARSHALL(USHORT);
|
2005-11-28 11:24:21 +01:00
|
|
|
TRACE("value: 0x%04x\n", **(USHORT **)ppMemory);
|
|
|
|
break;
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_LONG:
|
|
|
|
case FC_ULONG:
|
|
|
|
case FC_ERROR_STATUS_T:
|
|
|
|
case FC_ENUM32:
|
2006-05-19 17:02:59 +02:00
|
|
|
BASE_TYPE_UNMARSHALL(ULONG);
|
2006-11-09 23:04:48 +01:00
|
|
|
TRACE("value: 0x%08x\n", **(ULONG **)ppMemory);
|
2005-11-28 11:24:21 +01:00
|
|
|
break;
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_FLOAT:
|
2006-05-19 17:02:59 +02:00
|
|
|
BASE_TYPE_UNMARSHALL(float);
|
2005-11-28 11:24:21 +01:00
|
|
|
TRACE("value: %f\n", **(float **)ppMemory);
|
|
|
|
break;
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_DOUBLE:
|
2006-05-19 17:02:59 +02:00
|
|
|
BASE_TYPE_UNMARSHALL(double);
|
2005-11-28 11:24:21 +01:00
|
|
|
TRACE("value: %f\n", **(double **)ppMemory);
|
|
|
|
break;
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_HYPER:
|
2006-05-19 17:02:59 +02:00
|
|
|
BASE_TYPE_UNMARSHALL(ULONGLONG);
|
2005-11-28 11:24:21 +01:00
|
|
|
TRACE("value: %s\n", wine_dbgstr_longlong(**(ULONGLONG **)ppMemory));
|
|
|
|
break;
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_ENUM16:
|
2010-04-07 13:04:32 +02:00
|
|
|
{
|
|
|
|
USHORT val;
|
2010-04-02 21:54:55 +02:00
|
|
|
align_pointer(&pStubMsg->Buffer, sizeof(USHORT));
|
2009-01-10 23:17:15 +01:00
|
|
|
if (!fMustAlloc && !*ppMemory)
|
|
|
|
fMustAlloc = TRUE;
|
|
|
|
if (fMustAlloc)
|
2006-06-05 02:41:18 +02:00
|
|
|
*ppMemory = NdrAllocate(pStubMsg, sizeof(UINT));
|
2010-04-07 13:04:32 +02:00
|
|
|
safe_copy_from_buffer(pStubMsg, &val, sizeof(USHORT));
|
2006-03-01 13:21:56 +01:00
|
|
|
/* 16-bits on the wire, but int in memory */
|
2010-04-07 13:04:32 +02:00
|
|
|
**(UINT **)ppMemory = val;
|
2006-03-01 13:21:56 +01:00
|
|
|
TRACE("value: 0x%08x\n", **(UINT **)ppMemory);
|
|
|
|
break;
|
2010-04-07 13:04:32 +02:00
|
|
|
}
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_INT3264:
|
2010-04-07 13:08:46 +02:00
|
|
|
if (sizeof(INT_PTR) == sizeof(INT)) BASE_TYPE_UNMARSHALL(INT);
|
|
|
|
else
|
|
|
|
{
|
|
|
|
INT val;
|
|
|
|
align_pointer(&pStubMsg->Buffer, sizeof(INT));
|
|
|
|
if (!fMustAlloc && !*ppMemory)
|
|
|
|
fMustAlloc = TRUE;
|
|
|
|
if (fMustAlloc)
|
|
|
|
*ppMemory = NdrAllocate(pStubMsg, sizeof(INT_PTR));
|
|
|
|
safe_copy_from_buffer(pStubMsg, &val, sizeof(INT));
|
|
|
|
**(INT_PTR **)ppMemory = val;
|
|
|
|
TRACE("value: 0x%08lx\n", **(INT_PTR **)ppMemory);
|
|
|
|
}
|
|
|
|
break;
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_UINT3264:
|
2010-04-07 13:08:46 +02:00
|
|
|
if (sizeof(UINT_PTR) == sizeof(UINT)) BASE_TYPE_UNMARSHALL(UINT);
|
|
|
|
else
|
|
|
|
{
|
|
|
|
UINT val;
|
|
|
|
align_pointer(&pStubMsg->Buffer, sizeof(UINT));
|
|
|
|
if (!fMustAlloc && !*ppMemory)
|
|
|
|
fMustAlloc = TRUE;
|
|
|
|
if (fMustAlloc)
|
|
|
|
*ppMemory = NdrAllocate(pStubMsg, sizeof(UINT_PTR));
|
|
|
|
safe_copy_from_buffer(pStubMsg, &val, sizeof(UINT));
|
|
|
|
**(UINT_PTR **)ppMemory = val;
|
|
|
|
TRACE("value: 0x%08lx\n", **(UINT_PTR **)ppMemory);
|
|
|
|
}
|
|
|
|
break;
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_IGNORE:
|
2007-11-05 12:10:07 +01:00
|
|
|
break;
|
2005-11-28 11:24:21 +01:00
|
|
|
default:
|
|
|
|
FIXME("Unhandled base type: 0x%02x\n", *pFormat);
|
|
|
|
}
|
2006-05-19 17:02:59 +02:00
|
|
|
#undef BASE_TYPE_UNMARSHALL
|
2005-11-28 11:24:21 +01:00
|
|
|
|
|
|
|
/* FIXME: what is the correct return value? */
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* NdrBaseTypeBufferSize [internal]
|
|
|
|
*/
|
|
|
|
static void WINAPI NdrBaseTypeBufferSize(
|
|
|
|
PMIDL_STUB_MESSAGE pStubMsg,
|
|
|
|
unsigned char *pMemory,
|
|
|
|
PFORMAT_STRING pFormat)
|
|
|
|
{
|
|
|
|
TRACE("pStubMsg %p, pMemory %p, type 0x%02x\n", pStubMsg, pMemory, *pFormat);
|
|
|
|
|
|
|
|
switch(*pFormat)
|
|
|
|
{
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_BYTE:
|
|
|
|
case FC_CHAR:
|
|
|
|
case FC_SMALL:
|
|
|
|
case FC_USMALL:
|
2007-11-28 16:01:53 +01:00
|
|
|
safe_buffer_length_increment(pStubMsg, sizeof(UCHAR));
|
2005-11-28 11:24:21 +01:00
|
|
|
break;
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_WCHAR:
|
|
|
|
case FC_SHORT:
|
|
|
|
case FC_USHORT:
|
|
|
|
case FC_ENUM16:
|
2010-04-02 21:54:55 +02:00
|
|
|
align_length(&pStubMsg->BufferLength, sizeof(USHORT));
|
2007-11-28 16:01:53 +01:00
|
|
|
safe_buffer_length_increment(pStubMsg, sizeof(USHORT));
|
2005-11-28 11:24:21 +01:00
|
|
|
break;
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_LONG:
|
|
|
|
case FC_ULONG:
|
|
|
|
case FC_ENUM32:
|
|
|
|
case FC_INT3264:
|
|
|
|
case FC_UINT3264:
|
2010-04-02 21:54:55 +02:00
|
|
|
align_length(&pStubMsg->BufferLength, sizeof(ULONG));
|
2007-11-28 16:01:53 +01:00
|
|
|
safe_buffer_length_increment(pStubMsg, sizeof(ULONG));
|
2005-11-28 11:24:21 +01:00
|
|
|
break;
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_FLOAT:
|
2010-04-02 21:54:55 +02:00
|
|
|
align_length(&pStubMsg->BufferLength, sizeof(float));
|
2007-11-28 16:01:53 +01:00
|
|
|
safe_buffer_length_increment(pStubMsg, sizeof(float));
|
2005-11-28 11:24:21 +01:00
|
|
|
break;
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_DOUBLE:
|
2010-04-02 21:54:55 +02:00
|
|
|
align_length(&pStubMsg->BufferLength, sizeof(double));
|
2007-11-28 16:01:53 +01:00
|
|
|
safe_buffer_length_increment(pStubMsg, sizeof(double));
|
2005-11-28 11:24:21 +01:00
|
|
|
break;
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_HYPER:
|
2010-04-02 21:54:55 +02:00
|
|
|
align_length(&pStubMsg->BufferLength, sizeof(ULONGLONG));
|
2007-11-28 16:01:53 +01:00
|
|
|
safe_buffer_length_increment(pStubMsg, sizeof(ULONGLONG));
|
2005-11-28 11:24:21 +01:00
|
|
|
break;
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_ERROR_STATUS_T:
|
2010-04-02 21:54:55 +02:00
|
|
|
align_length(&pStubMsg->BufferLength, sizeof(error_status_t));
|
2007-11-28 16:01:53 +01:00
|
|
|
safe_buffer_length_increment(pStubMsg, sizeof(error_status_t));
|
2005-11-28 11:24:21 +01:00
|
|
|
break;
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_IGNORE:
|
2007-11-05 12:10:07 +01:00
|
|
|
break;
|
2005-11-28 11:24:21 +01:00
|
|
|
default:
|
|
|
|
FIXME("Unhandled base type: 0x%02x\n", *pFormat);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* NdrBaseTypeMemorySize [internal]
|
|
|
|
*/
|
2006-11-09 23:02:49 +01:00
|
|
|
static ULONG WINAPI NdrBaseTypeMemorySize(
|
2005-11-28 11:24:21 +01:00
|
|
|
PMIDL_STUB_MESSAGE pStubMsg,
|
|
|
|
PFORMAT_STRING pFormat)
|
|
|
|
{
|
2007-12-08 18:46:41 +01:00
|
|
|
TRACE("pStubMsg %p, type 0x%02x\n", pStubMsg, *pFormat);
|
|
|
|
|
2005-11-28 11:24:21 +01:00
|
|
|
switch(*pFormat)
|
|
|
|
{
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_BYTE:
|
|
|
|
case FC_CHAR:
|
|
|
|
case FC_SMALL:
|
|
|
|
case FC_USMALL:
|
2007-11-28 16:02:21 +01:00
|
|
|
safe_buffer_increment(pStubMsg, sizeof(UCHAR));
|
2006-05-13 17:59:06 +02:00
|
|
|
pStubMsg->MemorySize += sizeof(UCHAR);
|
2005-11-28 11:24:21 +01:00
|
|
|
return sizeof(UCHAR);
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_WCHAR:
|
|
|
|
case FC_SHORT:
|
|
|
|
case FC_USHORT:
|
2010-04-02 21:54:55 +02:00
|
|
|
align_pointer(&pStubMsg->Buffer, sizeof(USHORT));
|
2007-11-28 16:02:21 +01:00
|
|
|
safe_buffer_increment(pStubMsg, sizeof(USHORT));
|
2010-04-02 21:54:55 +02:00
|
|
|
align_length(&pStubMsg->MemorySize, sizeof(USHORT));
|
2006-05-13 17:59:06 +02:00
|
|
|
pStubMsg->MemorySize += sizeof(USHORT);
|
2005-11-28 11:24:21 +01:00
|
|
|
return sizeof(USHORT);
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_LONG:
|
|
|
|
case FC_ULONG:
|
|
|
|
case FC_ENUM32:
|
2010-04-02 21:54:55 +02:00
|
|
|
align_pointer(&pStubMsg->Buffer, sizeof(ULONG));
|
2007-11-28 16:02:21 +01:00
|
|
|
safe_buffer_increment(pStubMsg, sizeof(ULONG));
|
2010-04-02 21:54:55 +02:00
|
|
|
align_length(&pStubMsg->MemorySize, sizeof(ULONG));
|
2006-05-13 17:59:06 +02:00
|
|
|
pStubMsg->MemorySize += sizeof(ULONG);
|
2005-11-28 11:24:21 +01:00
|
|
|
return sizeof(ULONG);
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_FLOAT:
|
2010-04-02 21:54:55 +02:00
|
|
|
align_pointer(&pStubMsg->Buffer, sizeof(float));
|
2007-11-28 16:02:21 +01:00
|
|
|
safe_buffer_increment(pStubMsg, sizeof(float));
|
2010-04-02 21:54:55 +02:00
|
|
|
align_length(&pStubMsg->MemorySize, sizeof(float));
|
2006-05-13 17:59:06 +02:00
|
|
|
pStubMsg->MemorySize += sizeof(float);
|
2005-11-28 11:24:21 +01:00
|
|
|
return sizeof(float);
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_DOUBLE:
|
2010-04-02 21:54:55 +02:00
|
|
|
align_pointer(&pStubMsg->Buffer, sizeof(double));
|
2007-11-28 16:02:21 +01:00
|
|
|
safe_buffer_increment(pStubMsg, sizeof(double));
|
2010-04-02 21:54:55 +02:00
|
|
|
align_length(&pStubMsg->MemorySize, sizeof(double));
|
2006-05-13 17:59:06 +02:00
|
|
|
pStubMsg->MemorySize += sizeof(double);
|
2005-11-28 11:24:21 +01:00
|
|
|
return sizeof(double);
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_HYPER:
|
2010-04-02 21:54:55 +02:00
|
|
|
align_pointer(&pStubMsg->Buffer, sizeof(ULONGLONG));
|
2007-11-28 16:02:21 +01:00
|
|
|
safe_buffer_increment(pStubMsg, sizeof(ULONGLONG));
|
2010-04-02 21:54:55 +02:00
|
|
|
align_length(&pStubMsg->MemorySize, sizeof(ULONGLONG));
|
2006-05-13 17:59:06 +02:00
|
|
|
pStubMsg->MemorySize += sizeof(ULONGLONG);
|
2005-11-28 11:24:21 +01:00
|
|
|
return sizeof(ULONGLONG);
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_ERROR_STATUS_T:
|
2010-04-02 21:54:55 +02:00
|
|
|
align_pointer(&pStubMsg->Buffer, sizeof(error_status_t));
|
2007-11-28 16:02:21 +01:00
|
|
|
safe_buffer_increment(pStubMsg, sizeof(error_status_t));
|
2010-04-02 21:54:55 +02:00
|
|
|
align_length(&pStubMsg->MemorySize, sizeof(error_status_t));
|
2006-05-13 17:59:06 +02:00
|
|
|
pStubMsg->MemorySize += sizeof(error_status_t);
|
2005-11-28 11:24:21 +01:00
|
|
|
return sizeof(error_status_t);
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_ENUM16:
|
2010-04-02 21:54:55 +02:00
|
|
|
align_pointer(&pStubMsg->Buffer, sizeof(USHORT));
|
2007-11-28 16:02:21 +01:00
|
|
|
safe_buffer_increment(pStubMsg, sizeof(USHORT));
|
2010-04-02 21:54:55 +02:00
|
|
|
align_length(&pStubMsg->MemorySize, sizeof(UINT));
|
2007-11-28 16:02:21 +01:00
|
|
|
pStubMsg->MemorySize += sizeof(UINT);
|
|
|
|
return sizeof(UINT);
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_INT3264:
|
|
|
|
case FC_UINT3264:
|
2010-04-07 13:08:46 +02:00
|
|
|
align_pointer(&pStubMsg->Buffer, sizeof(UINT));
|
|
|
|
safe_buffer_increment(pStubMsg, sizeof(UINT));
|
|
|
|
align_length(&pStubMsg->MemorySize, sizeof(UINT_PTR));
|
|
|
|
pStubMsg->MemorySize += sizeof(UINT_PTR);
|
|
|
|
return sizeof(UINT_PTR);
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_IGNORE:
|
2010-04-02 21:54:55 +02:00
|
|
|
align_length(&pStubMsg->MemorySize, sizeof(void *));
|
2007-11-05 12:10:07 +01:00
|
|
|
pStubMsg->MemorySize += sizeof(void *);
|
|
|
|
return sizeof(void *);
|
2005-11-28 11:24:21 +01:00
|
|
|
default:
|
|
|
|
FIXME("Unhandled base type: 0x%02x\n", *pFormat);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* NdrBaseTypeFree [internal]
|
|
|
|
*/
|
|
|
|
static void WINAPI NdrBaseTypeFree(PMIDL_STUB_MESSAGE pStubMsg,
|
|
|
|
unsigned char *pMemory,
|
|
|
|
PFORMAT_STRING pFormat)
|
|
|
|
{
|
|
|
|
TRACE("pStubMsg %p pMemory %p type 0x%02x\n", pStubMsg, pMemory, *pFormat);
|
|
|
|
|
|
|
|
/* nothing to do */
|
|
|
|
}
|
|
|
|
|
2007-06-25 15:29:15 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* NdrContextHandleBufferSize [internal]
|
|
|
|
*/
|
|
|
|
static void WINAPI NdrContextHandleBufferSize(
|
|
|
|
PMIDL_STUB_MESSAGE pStubMsg,
|
|
|
|
unsigned char *pMemory,
|
|
|
|
PFORMAT_STRING pFormat)
|
|
|
|
{
|
|
|
|
TRACE("pStubMsg %p, pMemory %p, type 0x%02x\n", pStubMsg, pMemory, *pFormat);
|
|
|
|
|
2018-06-13 04:19:10 +02:00
|
|
|
if (*pFormat != FC_BIND_CONTEXT)
|
2007-06-25 15:29:15 +02:00
|
|
|
{
|
|
|
|
ERR("invalid format type %x\n", *pFormat);
|
|
|
|
RpcRaiseException(RPC_S_INTERNAL_ERROR);
|
|
|
|
}
|
2010-04-02 21:54:55 +02:00
|
|
|
align_length(&pStubMsg->BufferLength, 4);
|
2007-11-28 16:01:53 +01:00
|
|
|
safe_buffer_length_increment(pStubMsg, cbNDRContext);
|
2007-06-25 15:29:15 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* NdrContextHandleMarshall [internal]
|
|
|
|
*/
|
|
|
|
static unsigned char *WINAPI NdrContextHandleMarshall(
|
|
|
|
PMIDL_STUB_MESSAGE pStubMsg,
|
|
|
|
unsigned char *pMemory,
|
|
|
|
PFORMAT_STRING pFormat)
|
|
|
|
{
|
|
|
|
TRACE("pStubMsg %p, pMemory %p, type 0x%02x\n", pStubMsg, pMemory, *pFormat);
|
|
|
|
|
2018-06-13 04:19:10 +02:00
|
|
|
if (*pFormat != FC_BIND_CONTEXT)
|
2007-06-25 15:29:15 +02:00
|
|
|
{
|
|
|
|
ERR("invalid format type %x\n", *pFormat);
|
|
|
|
RpcRaiseException(RPC_S_INTERNAL_ERROR);
|
|
|
|
}
|
2008-01-17 13:26:42 +01:00
|
|
|
TRACE("flags: 0x%02x\n", pFormat[1]);
|
2007-06-25 15:29:15 +02:00
|
|
|
|
2009-12-13 20:47:35 +01:00
|
|
|
if (pStubMsg->IsClient)
|
|
|
|
{
|
|
|
|
if (pFormat[1] & HANDLE_PARAM_IS_VIA_PTR)
|
|
|
|
NdrClientContextMarshall(pStubMsg, *(NDR_CCONTEXT **)pMemory, FALSE);
|
|
|
|
else
|
|
|
|
NdrClientContextMarshall(pStubMsg, pMemory, FALSE);
|
|
|
|
}
|
2007-06-25 15:29:15 +02:00
|
|
|
else
|
2009-12-13 20:47:35 +01:00
|
|
|
{
|
2019-05-07 20:16:21 +02:00
|
|
|
NDR_SCONTEXT ctxt = CONTAINING_RECORD(pMemory, struct _NDR_SCONTEXT, userContext);
|
2009-12-13 20:47:35 +01:00
|
|
|
NDR_RUNDOWN rundown = pStubMsg->StubDesc->apfnNdrRundownRoutines[pFormat[2]];
|
|
|
|
NdrServerContextNewMarshall(pStubMsg, ctxt, rundown, pFormat);
|
|
|
|
}
|
2007-06-25 15:29:15 +02:00
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* NdrContextHandleUnmarshall [internal]
|
|
|
|
*/
|
|
|
|
static unsigned char *WINAPI NdrContextHandleUnmarshall(
|
|
|
|
PMIDL_STUB_MESSAGE pStubMsg,
|
|
|
|
unsigned char **ppMemory,
|
|
|
|
PFORMAT_STRING pFormat,
|
|
|
|
unsigned char fMustAlloc)
|
|
|
|
{
|
2008-01-17 13:26:42 +01:00
|
|
|
TRACE("pStubMsg %p, ppMemory %p, pFormat %p, fMustAlloc %s\n", pStubMsg,
|
|
|
|
ppMemory, pFormat, fMustAlloc ? "TRUE": "FALSE");
|
|
|
|
|
2018-06-13 04:19:10 +02:00
|
|
|
if (*pFormat != FC_BIND_CONTEXT)
|
2007-06-25 15:29:15 +02:00
|
|
|
{
|
|
|
|
ERR("invalid format type %x\n", *pFormat);
|
|
|
|
RpcRaiseException(RPC_S_INTERNAL_ERROR);
|
|
|
|
}
|
2008-01-17 13:26:42 +01:00
|
|
|
TRACE("flags: 0x%02x\n", pFormat[1]);
|
2007-06-25 15:29:15 +02:00
|
|
|
|
2009-12-13 20:47:35 +01:00
|
|
|
if (pStubMsg->IsClient)
|
|
|
|
{
|
2019-01-25 12:01:23 +01:00
|
|
|
NDR_CCONTEXT *ccontext;
|
|
|
|
if (pFormat[1] & HANDLE_PARAM_IS_VIA_PTR)
|
|
|
|
ccontext = *(NDR_CCONTEXT **)ppMemory;
|
|
|
|
else
|
|
|
|
ccontext = (NDR_CCONTEXT *)ppMemory;
|
2009-12-13 20:47:35 +01:00
|
|
|
/* [out]-only or [ret] param */
|
|
|
|
if ((pFormat[1] & (HANDLE_PARAM_IS_IN|HANDLE_PARAM_IS_OUT)) == HANDLE_PARAM_IS_OUT)
|
2019-01-25 12:01:23 +01:00
|
|
|
*ccontext = NULL;
|
|
|
|
NdrClientContextUnmarshall(pStubMsg, ccontext, pStubMsg->RpcMsg->Handle);
|
2009-12-13 20:47:35 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
NDR_SCONTEXT ctxt;
|
|
|
|
ctxt = NdrServerContextNewUnmarshall(pStubMsg, pFormat);
|
|
|
|
if (pFormat[1] & HANDLE_PARAM_IS_VIA_PTR)
|
|
|
|
*(void **)ppMemory = NDRSContextValue(ctxt);
|
|
|
|
else
|
|
|
|
*(void **)ppMemory = *NDRSContextValue(ctxt);
|
|
|
|
}
|
2007-06-25 15:29:15 +02:00
|
|
|
|
2008-01-17 13:26:42 +01:00
|
|
|
return NULL;
|
2007-06-25 15:29:15 +02:00
|
|
|
}
|
|
|
|
|
2005-07-18 15:14:05 +02:00
|
|
|
/***********************************************************************
|
2006-11-12 20:23:02 +01:00
|
|
|
* NdrClientContextMarshall [RPCRT4.@]
|
2005-07-18 15:14:05 +02:00
|
|
|
*/
|
2005-08-03 16:55:57 +02:00
|
|
|
void WINAPI NdrClientContextMarshall(PMIDL_STUB_MESSAGE pStubMsg,
|
|
|
|
NDR_CCONTEXT ContextHandle,
|
|
|
|
int fCheck)
|
2005-07-18 15:14:05 +02:00
|
|
|
{
|
2006-06-02 21:44:18 +02:00
|
|
|
TRACE("(%p, %p, %d)\n", pStubMsg, ContextHandle, fCheck);
|
|
|
|
|
2010-04-02 21:54:55 +02:00
|
|
|
align_pointer_clear(&pStubMsg->Buffer, 4);
|
2006-06-02 21:44:18 +02:00
|
|
|
|
2007-11-28 16:02:21 +01:00
|
|
|
if (pStubMsg->Buffer + cbNDRContext > (unsigned char *)pStubMsg->RpcMsg->Buffer + pStubMsg->BufferLength)
|
|
|
|
{
|
|
|
|
ERR("buffer overflow - Buffer = %p, BufferEnd = %p\n",
|
|
|
|
pStubMsg->Buffer, (unsigned char *)pStubMsg->RpcMsg->Buffer + pStubMsg->BufferLength);
|
|
|
|
RpcRaiseException(RPC_X_BAD_STUB_DATA);
|
|
|
|
}
|
|
|
|
|
2006-05-26 10:56:49 +02:00
|
|
|
/* FIXME: what does fCheck do? */
|
2006-06-02 21:43:22 +02:00
|
|
|
NDRCContextMarshall(ContextHandle,
|
|
|
|
pStubMsg->Buffer);
|
|
|
|
|
|
|
|
pStubMsg->Buffer += cbNDRContext;
|
2005-07-18 15:14:05 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
2006-11-12 20:23:02 +01:00
|
|
|
* NdrClientContextUnmarshall [RPCRT4.@]
|
2005-07-18 15:14:05 +02:00
|
|
|
*/
|
2005-08-03 16:55:57 +02:00
|
|
|
void WINAPI NdrClientContextUnmarshall(PMIDL_STUB_MESSAGE pStubMsg,
|
|
|
|
NDR_CCONTEXT * pContextHandle,
|
|
|
|
RPC_BINDING_HANDLE BindHandle)
|
2005-07-18 15:14:05 +02:00
|
|
|
{
|
2006-06-02 21:44:18 +02:00
|
|
|
TRACE("(%p, %p, %p)\n", pStubMsg, pContextHandle, BindHandle);
|
|
|
|
|
2010-04-02 21:54:55 +02:00
|
|
|
align_pointer(&pStubMsg->Buffer, 4);
|
2006-06-02 21:44:18 +02:00
|
|
|
|
2007-07-16 16:02:38 +02:00
|
|
|
if (pStubMsg->Buffer + cbNDRContext > pStubMsg->BufferEnd)
|
|
|
|
RpcRaiseException(RPC_X_BAD_STUB_DATA);
|
|
|
|
|
2006-06-02 21:43:22 +02:00
|
|
|
NDRCContextUnmarshall(pContextHandle,
|
|
|
|
BindHandle,
|
|
|
|
pStubMsg->Buffer,
|
|
|
|
pStubMsg->RpcMsg->DataRepresentation);
|
|
|
|
|
|
|
|
pStubMsg->Buffer += cbNDRContext;
|
2005-08-03 16:55:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void WINAPI NdrServerContextMarshall(PMIDL_STUB_MESSAGE pStubMsg,
|
|
|
|
NDR_SCONTEXT ContextHandle,
|
2005-09-08 13:02:38 +02:00
|
|
|
NDR_RUNDOWN RundownRoutine )
|
2005-08-03 16:55:57 +02:00
|
|
|
{
|
2007-12-25 20:07:49 +01:00
|
|
|
TRACE("(%p, %p, %p)\n", pStubMsg, ContextHandle, RundownRoutine);
|
|
|
|
|
2010-04-02 21:54:55 +02:00
|
|
|
align_pointer(&pStubMsg->Buffer, 4);
|
2007-12-25 20:07:49 +01:00
|
|
|
|
|
|
|
if (pStubMsg->Buffer + cbNDRContext > (unsigned char *)pStubMsg->RpcMsg->Buffer + pStubMsg->BufferLength)
|
|
|
|
{
|
|
|
|
ERR("buffer overflow - Buffer = %p, BufferEnd = %p\n",
|
|
|
|
pStubMsg->Buffer, (unsigned char *)pStubMsg->RpcMsg->Buffer + pStubMsg->BufferLength);
|
|
|
|
RpcRaiseException(RPC_X_BAD_STUB_DATA);
|
|
|
|
}
|
|
|
|
|
|
|
|
NDRSContextMarshall2(pStubMsg->RpcMsg->Handle, ContextHandle,
|
2008-01-06 22:26:10 +01:00
|
|
|
pStubMsg->Buffer, RundownRoutine, NULL,
|
|
|
|
RPC_CONTEXT_HANDLE_DEFAULT_FLAGS);
|
2007-12-25 20:07:49 +01:00
|
|
|
pStubMsg->Buffer += cbNDRContext;
|
2005-08-03 16:55:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
NDR_SCONTEXT WINAPI NdrServerContextUnmarshall(PMIDL_STUB_MESSAGE pStubMsg)
|
|
|
|
{
|
2007-12-25 20:07:49 +01:00
|
|
|
NDR_SCONTEXT ContextHandle;
|
|
|
|
|
|
|
|
TRACE("(%p)\n", pStubMsg);
|
|
|
|
|
2010-04-02 21:54:55 +02:00
|
|
|
align_pointer(&pStubMsg->Buffer, 4);
|
2007-12-25 20:07:49 +01:00
|
|
|
|
|
|
|
if (pStubMsg->Buffer + cbNDRContext > (unsigned char *)pStubMsg->RpcMsg->Buffer + pStubMsg->BufferLength)
|
|
|
|
{
|
|
|
|
ERR("buffer overflow - Buffer = %p, BufferEnd = %p\n",
|
|
|
|
pStubMsg->Buffer, (unsigned char *)pStubMsg->RpcMsg->Buffer + pStubMsg->BufferLength);
|
|
|
|
RpcRaiseException(RPC_X_BAD_STUB_DATA);
|
|
|
|
}
|
|
|
|
|
|
|
|
ContextHandle = NDRSContextUnmarshall2(pStubMsg->RpcMsg->Handle,
|
|
|
|
pStubMsg->Buffer,
|
|
|
|
pStubMsg->RpcMsg->DataRepresentation,
|
2008-01-06 22:26:10 +01:00
|
|
|
NULL, RPC_CONTEXT_HANDLE_DEFAULT_FLAGS);
|
2007-12-25 20:07:49 +01:00
|
|
|
pStubMsg->Buffer += cbNDRContext;
|
|
|
|
|
|
|
|
return ContextHandle;
|
2005-08-03 16:55:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void WINAPI NdrContextHandleSize(PMIDL_STUB_MESSAGE pStubMsg,
|
|
|
|
unsigned char* pMemory,
|
|
|
|
PFORMAT_STRING pFormat)
|
|
|
|
{
|
|
|
|
FIXME("(%p, %p, %p): stub\n", pStubMsg, pMemory, pFormat);
|
|
|
|
}
|
|
|
|
|
|
|
|
NDR_SCONTEXT WINAPI NdrContextHandleInitialize(PMIDL_STUB_MESSAGE pStubMsg,
|
|
|
|
PFORMAT_STRING pFormat)
|
|
|
|
{
|
2008-01-06 22:21:21 +01:00
|
|
|
RPC_SYNTAX_IDENTIFIER *if_id = NULL;
|
2008-01-06 22:26:10 +01:00
|
|
|
ULONG flags = RPC_CONTEXT_HANDLE_DEFAULT_FLAGS;
|
2008-01-06 22:21:21 +01:00
|
|
|
|
2007-12-25 20:07:49 +01:00
|
|
|
TRACE("(%p, %p)\n", pStubMsg, pFormat);
|
2008-01-06 22:21:21 +01:00
|
|
|
|
2008-01-06 22:26:10 +01:00
|
|
|
if (pFormat[1] & NDR_CONTEXT_HANDLE_SERIALIZE)
|
|
|
|
flags |= RPC_CONTEXT_HANDLE_SERIALIZE;
|
2018-06-13 04:19:10 +02:00
|
|
|
if (pFormat[1] & NDR_CONTEXT_HANDLE_NOSERIALIZE)
|
2008-01-06 22:26:10 +01:00
|
|
|
flags |= RPC_CONTEXT_HANDLE_DONT_SERIALIZE;
|
2008-01-06 22:21:21 +01:00
|
|
|
if (pFormat[1] & NDR_STRICT_CONTEXT_HANDLE)
|
|
|
|
{
|
|
|
|
RPC_SERVER_INTERFACE *sif = pStubMsg->StubDesc->RpcInterfaceInformation;
|
|
|
|
if_id = &sif->InterfaceId;
|
|
|
|
}
|
|
|
|
|
2007-12-25 20:07:49 +01:00
|
|
|
return NDRSContextUnmarshall2(pStubMsg->RpcMsg->Handle, NULL,
|
2008-01-06 22:26:10 +01:00
|
|
|
pStubMsg->RpcMsg->DataRepresentation, if_id,
|
|
|
|
flags);
|
2005-08-03 16:55:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void WINAPI NdrServerContextNewMarshall(PMIDL_STUB_MESSAGE pStubMsg,
|
|
|
|
NDR_SCONTEXT ContextHandle,
|
|
|
|
NDR_RUNDOWN RundownRoutine,
|
|
|
|
PFORMAT_STRING pFormat)
|
|
|
|
{
|
2008-01-06 22:21:21 +01:00
|
|
|
RPC_SYNTAX_IDENTIFIER *if_id = NULL;
|
2008-01-06 22:26:10 +01:00
|
|
|
ULONG flags = RPC_CONTEXT_HANDLE_DEFAULT_FLAGS;
|
2008-01-06 22:21:21 +01:00
|
|
|
|
2007-12-25 20:07:49 +01:00
|
|
|
TRACE("(%p, %p, %p, %p)\n", pStubMsg, ContextHandle, RundownRoutine, pFormat);
|
|
|
|
|
2010-04-02 21:54:55 +02:00
|
|
|
align_pointer(&pStubMsg->Buffer, 4);
|
2007-12-25 20:07:49 +01:00
|
|
|
|
|
|
|
if (pStubMsg->Buffer + cbNDRContext > (unsigned char *)pStubMsg->RpcMsg->Buffer + pStubMsg->BufferLength)
|
|
|
|
{
|
|
|
|
ERR("buffer overflow - Buffer = %p, BufferEnd = %p\n",
|
|
|
|
pStubMsg->Buffer, (unsigned char *)pStubMsg->RpcMsg->Buffer + pStubMsg->BufferLength);
|
|
|
|
RpcRaiseException(RPC_X_BAD_STUB_DATA);
|
|
|
|
}
|
|
|
|
|
2008-01-06 22:26:10 +01:00
|
|
|
if (pFormat[1] & NDR_CONTEXT_HANDLE_SERIALIZE)
|
|
|
|
flags |= RPC_CONTEXT_HANDLE_SERIALIZE;
|
2018-06-13 04:19:10 +02:00
|
|
|
if (pFormat[1] & NDR_CONTEXT_HANDLE_NOSERIALIZE)
|
2008-01-06 22:26:10 +01:00
|
|
|
flags |= RPC_CONTEXT_HANDLE_DONT_SERIALIZE;
|
2008-01-06 22:21:21 +01:00
|
|
|
if (pFormat[1] & NDR_STRICT_CONTEXT_HANDLE)
|
|
|
|
{
|
|
|
|
RPC_SERVER_INTERFACE *sif = pStubMsg->StubDesc->RpcInterfaceInformation;
|
|
|
|
if_id = &sif->InterfaceId;
|
|
|
|
}
|
|
|
|
|
2007-12-25 20:07:49 +01:00
|
|
|
NDRSContextMarshall2(pStubMsg->RpcMsg->Handle, ContextHandle,
|
2008-01-06 22:26:10 +01:00
|
|
|
pStubMsg->Buffer, RundownRoutine, if_id, flags);
|
2007-12-25 20:07:49 +01:00
|
|
|
pStubMsg->Buffer += cbNDRContext;
|
2005-08-03 16:55:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
NDR_SCONTEXT WINAPI NdrServerContextNewUnmarshall(PMIDL_STUB_MESSAGE pStubMsg,
|
|
|
|
PFORMAT_STRING pFormat)
|
|
|
|
{
|
2007-12-25 20:07:49 +01:00
|
|
|
NDR_SCONTEXT ContextHandle;
|
2008-01-06 22:21:21 +01:00
|
|
|
RPC_SYNTAX_IDENTIFIER *if_id = NULL;
|
2008-01-06 22:26:10 +01:00
|
|
|
ULONG flags = RPC_CONTEXT_HANDLE_DEFAULT_FLAGS;
|
2007-12-25 20:07:49 +01:00
|
|
|
|
|
|
|
TRACE("(%p, %p)\n", pStubMsg, pFormat);
|
|
|
|
|
2010-04-02 21:54:55 +02:00
|
|
|
align_pointer(&pStubMsg->Buffer, 4);
|
2007-12-25 20:07:49 +01:00
|
|
|
|
|
|
|
if (pStubMsg->Buffer + cbNDRContext > (unsigned char *)pStubMsg->RpcMsg->Buffer + pStubMsg->BufferLength)
|
|
|
|
{
|
|
|
|
ERR("buffer overflow - Buffer = %p, BufferEnd = %p\n",
|
|
|
|
pStubMsg->Buffer, (unsigned char *)pStubMsg->RpcMsg->Buffer + pStubMsg->BufferLength);
|
|
|
|
RpcRaiseException(RPC_X_BAD_STUB_DATA);
|
|
|
|
}
|
|
|
|
|
2008-01-06 22:26:10 +01:00
|
|
|
if (pFormat[1] & NDR_CONTEXT_HANDLE_SERIALIZE)
|
|
|
|
flags |= RPC_CONTEXT_HANDLE_SERIALIZE;
|
2018-06-13 04:19:10 +02:00
|
|
|
if (pFormat[1] & NDR_CONTEXT_HANDLE_NOSERIALIZE)
|
2008-01-06 22:26:10 +01:00
|
|
|
flags |= RPC_CONTEXT_HANDLE_DONT_SERIALIZE;
|
2008-01-06 22:21:21 +01:00
|
|
|
if (pFormat[1] & NDR_STRICT_CONTEXT_HANDLE)
|
|
|
|
{
|
|
|
|
RPC_SERVER_INTERFACE *sif = pStubMsg->StubDesc->RpcInterfaceInformation;
|
|
|
|
if_id = &sif->InterfaceId;
|
|
|
|
}
|
|
|
|
|
2007-12-25 20:07:49 +01:00
|
|
|
ContextHandle = NDRSContextUnmarshall2(pStubMsg->RpcMsg->Handle,
|
|
|
|
pStubMsg->Buffer,
|
|
|
|
pStubMsg->RpcMsg->DataRepresentation,
|
2008-01-06 22:26:10 +01:00
|
|
|
if_id, flags);
|
2007-12-25 20:07:49 +01:00
|
|
|
pStubMsg->Buffer += cbNDRContext;
|
|
|
|
|
|
|
|
return ContextHandle;
|
2005-08-03 16:55:57 +02:00
|
|
|
}
|
2008-01-07 16:20:16 +01:00
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* NdrCorrelationInitialize [RPCRT4.@]
|
|
|
|
*
|
|
|
|
* Initializes correlation validity checking.
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* pStubMsg [I] MIDL_STUB_MESSAGE used during unmarshalling.
|
|
|
|
* pMemory [I] Pointer to memory to use as a cache.
|
|
|
|
* CacheSize [I] Size of the memory pointed to by pMemory.
|
|
|
|
* Flags [I] Reserved. Set to zero.
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Nothing.
|
|
|
|
*/
|
|
|
|
void WINAPI NdrCorrelationInitialize(PMIDL_STUB_MESSAGE pStubMsg, void *pMemory, ULONG CacheSize, ULONG Flags)
|
|
|
|
{
|
2019-04-16 16:36:58 +02:00
|
|
|
static int once;
|
|
|
|
|
|
|
|
if (!once++)
|
|
|
|
FIXME("(%p, %p, %d, 0x%x): semi-stub\n", pStubMsg, pMemory, CacheSize, Flags);
|
2015-07-13 14:11:36 +02:00
|
|
|
|
|
|
|
if (pStubMsg->CorrDespIncrement == 0)
|
|
|
|
pStubMsg->CorrDespIncrement = 2; /* size of the normal (non-range) /robust payload */
|
|
|
|
|
2008-01-07 16:20:16 +01:00
|
|
|
pStubMsg->fHasNewCorrDesc = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* NdrCorrelationPass [RPCRT4.@]
|
|
|
|
*
|
|
|
|
* Performs correlation validity checking.
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* pStubMsg [I] MIDL_STUB_MESSAGE used during unmarshalling.
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Nothing.
|
|
|
|
*/
|
|
|
|
void WINAPI NdrCorrelationPass(PMIDL_STUB_MESSAGE pStubMsg)
|
|
|
|
{
|
|
|
|
FIXME("(%p): stub\n", pStubMsg);
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* NdrCorrelationFree [RPCRT4.@]
|
|
|
|
*
|
|
|
|
* Frees any resources used while unmarshalling parameters that need
|
|
|
|
* correlation validity checking.
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* pStubMsg [I] MIDL_STUB_MESSAGE used during unmarshalling.
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Nothing.
|
|
|
|
*/
|
|
|
|
void WINAPI NdrCorrelationFree(PMIDL_STUB_MESSAGE pStubMsg)
|
|
|
|
{
|
2019-04-16 16:36:58 +02:00
|
|
|
static int once;
|
|
|
|
|
|
|
|
if (!once++)
|
|
|
|
FIXME("(%p): stub\n", pStubMsg);
|
2008-01-07 16:20:16 +01:00
|
|
|
}
|