2002-10-10 21:23:33 +02:00
|
|
|
/*
|
2006-01-05 12:19:05 +01:00
|
|
|
* NDR -Oi,-Oif,-Oicf Interpreter
|
2002-10-10 21:23:33 +02:00
|
|
|
*
|
2008-10-18 19:20:44 +02:00
|
|
|
* Copyright 2001 Ove Kåven, TransGaming Technologies
|
2006-01-05 12:19:05 +01:00
|
|
|
* Copyright 2003-5 Robert Shearman (for CodeWeavers)
|
2002-10-10 21:23:33 +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-10 21:23:33 +02:00
|
|
|
*
|
|
|
|
* TODO:
|
2006-01-05 12:19:05 +01:00
|
|
|
* - Pipes
|
|
|
|
* - Some types of binding handles
|
2002-10-10 21:23:33 +02:00
|
|
|
*/
|
|
|
|
|
2006-01-05 12:19:05 +01:00
|
|
|
#include "config.h"
|
|
|
|
#include "wine/port.h"
|
|
|
|
|
2003-09-06 01:08:26 +02:00
|
|
|
#include <stdarg.h>
|
2002-10-10 21:23:33 +02:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
#include "windef.h"
|
|
|
|
#include "winbase.h"
|
|
|
|
#include "winerror.h"
|
|
|
|
|
2006-01-05 12:19:05 +01:00
|
|
|
#include "objbase.h"
|
2002-10-10 21:23:33 +02:00
|
|
|
#include "rpc.h"
|
2006-01-05 12:19:05 +01:00
|
|
|
#include "rpcproxy.h"
|
2002-10-10 21:23:33 +02:00
|
|
|
|
2008-01-17 13:25:52 +01:00
|
|
|
#include "wine/exception.h"
|
2002-10-10 21:23:33 +02:00
|
|
|
#include "wine/debug.h"
|
2006-01-05 12:19:05 +01:00
|
|
|
#include "wine/rpcfc.h"
|
2002-10-10 21:23:33 +02:00
|
|
|
|
2006-01-05 12:19:05 +01:00
|
|
|
#include "cpsf.h"
|
2007-11-02 20:09:07 +01:00
|
|
|
#include "ndr_misc.h"
|
|
|
|
#include "ndr_stubless.h"
|
2002-10-10 21:23:33 +02:00
|
|
|
|
2006-01-05 12:19:05 +01:00
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(rpc);
|
2002-10-10 21:23:33 +02:00
|
|
|
|
2006-02-03 18:46:40 +01:00
|
|
|
#define NDR_TABLE_MASK 127
|
|
|
|
|
2006-01-05 12:19:05 +01:00
|
|
|
static inline void call_buffer_sizer(PMIDL_STUB_MESSAGE pStubMsg, unsigned char *pMemory, PFORMAT_STRING pFormat)
|
2002-10-10 21:23:33 +02:00
|
|
|
{
|
2006-02-03 18:46:40 +01:00
|
|
|
NDR_BUFFERSIZE m = NdrBufferSizer[pFormat[0] & NDR_TABLE_MASK];
|
2006-01-05 12:19:05 +01:00
|
|
|
if (m) m(pStubMsg, pMemory, pFormat);
|
|
|
|
else
|
|
|
|
{
|
|
|
|
FIXME("format type 0x%x not implemented\n", pFormat[0]);
|
|
|
|
RpcRaiseException(RPC_X_BAD_STUB_DATA);
|
|
|
|
}
|
|
|
|
}
|
2002-10-18 05:56:56 +02:00
|
|
|
|
2006-01-05 12:19:05 +01:00
|
|
|
static inline unsigned char *call_marshaller(PMIDL_STUB_MESSAGE pStubMsg, unsigned char *pMemory, PFORMAT_STRING pFormat)
|
|
|
|
{
|
2006-02-03 18:46:40 +01:00
|
|
|
NDR_MARSHALL m = NdrMarshaller[pFormat[0] & NDR_TABLE_MASK];
|
2006-01-05 12:19:05 +01:00
|
|
|
if (m) return m(pStubMsg, pMemory, pFormat);
|
|
|
|
else
|
|
|
|
{
|
|
|
|
FIXME("format type 0x%x not implemented\n", pFormat[0]);
|
|
|
|
RpcRaiseException(RPC_X_BAD_STUB_DATA);
|
|
|
|
return NULL;
|
|
|
|
}
|
2002-10-10 21:23:33 +02:00
|
|
|
}
|
|
|
|
|
2006-01-05 12:19:05 +01:00
|
|
|
static inline unsigned char *call_unmarshaller(PMIDL_STUB_MESSAGE pStubMsg, unsigned char **ppMemory, PFORMAT_STRING pFormat, unsigned char fMustAlloc)
|
|
|
|
{
|
2006-02-03 18:46:40 +01:00
|
|
|
NDR_UNMARSHALL m = NdrUnmarshaller[pFormat[0] & NDR_TABLE_MASK];
|
2006-01-05 12:19:05 +01:00
|
|
|
if (m) return m(pStubMsg, ppMemory, pFormat, fMustAlloc);
|
|
|
|
else
|
|
|
|
{
|
|
|
|
FIXME("format type 0x%x not implemented\n", pFormat[0]);
|
|
|
|
RpcRaiseException(RPC_X_BAD_STUB_DATA);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void call_freer(PMIDL_STUB_MESSAGE pStubMsg, unsigned char *pMemory, PFORMAT_STRING pFormat)
|
|
|
|
{
|
2006-02-03 18:46:40 +01:00
|
|
|
NDR_FREE m = NdrFreer[pFormat[0] & NDR_TABLE_MASK];
|
2006-01-05 12:19:05 +01:00
|
|
|
if (m) m(pStubMsg, pMemory, pFormat);
|
|
|
|
}
|
|
|
|
|
|
|
|
#define STUBLESS_UNMARSHAL 1
|
2008-01-14 12:56:13 +01:00
|
|
|
#define STUBLESS_INITOUT 2
|
|
|
|
#define STUBLESS_CALLSERVER 3
|
|
|
|
#define STUBLESS_CALCSIZE 4
|
|
|
|
#define STUBLESS_GETBUFFER 5
|
|
|
|
#define STUBLESS_MARSHAL 6
|
|
|
|
#define STUBLESS_FREE 7
|
2006-01-05 12:19:05 +01:00
|
|
|
|
|
|
|
void WINAPI NdrRpcSmSetClientToOsf(PMIDL_STUB_MESSAGE pMessage)
|
|
|
|
{
|
|
|
|
#if 0 /* these functions are not defined yet */
|
|
|
|
pMessage->pfnAllocate = NdrRpcSmClientAllocate;
|
|
|
|
pMessage->pfnFree = NdrRpcSmClientFree;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2006-03-01 13:22:26 +01:00
|
|
|
static void WINAPI dump_RPC_FC_PROC_PF(PARAM_ATTRIBUTES param_attributes)
|
2006-01-05 12:19:05 +01:00
|
|
|
{
|
2006-03-01 13:22:26 +01:00
|
|
|
if (param_attributes.MustSize) TRACE(" MustSize");
|
|
|
|
if (param_attributes.MustFree) TRACE(" MustFree");
|
|
|
|
if (param_attributes.IsPipe) TRACE(" IsPipe");
|
|
|
|
if (param_attributes.IsIn) TRACE(" IsIn");
|
|
|
|
if (param_attributes.IsOut) TRACE(" IsOut");
|
|
|
|
if (param_attributes.IsReturn) TRACE(" IsReturn");
|
|
|
|
if (param_attributes.IsBasetype) TRACE(" IsBasetype");
|
|
|
|
if (param_attributes.IsByValue) TRACE(" IsByValue");
|
|
|
|
if (param_attributes.IsSimpleRef) TRACE(" IsSimpleRef");
|
|
|
|
if (param_attributes.IsDontCallFreeInst) TRACE(" IsDontCallFreeInst");
|
|
|
|
if (param_attributes.SaveForAsyncFinish) TRACE(" SaveForAsyncFinish");
|
|
|
|
if (param_attributes.ServerAllocSize) TRACE(" ServerAllocSize = %d", param_attributes.ServerAllocSize * 8);
|
2006-01-05 12:19:05 +01:00
|
|
|
}
|
|
|
|
|
2006-04-20 12:44:27 +02:00
|
|
|
static void WINAPI dump_INTERPRETER_OPT_FLAGS(INTERPRETER_OPT_FLAGS Oi2Flags)
|
|
|
|
{
|
|
|
|
if (Oi2Flags.ServerMustSize) TRACE(" ServerMustSize");
|
|
|
|
if (Oi2Flags.ClientMustSize) TRACE(" ClientMustSize");
|
|
|
|
if (Oi2Flags.HasReturn) TRACE(" HasReturn");
|
|
|
|
if (Oi2Flags.HasPipes) TRACE(" HasPipes");
|
|
|
|
if (Oi2Flags.Unused) TRACE(" Unused");
|
|
|
|
if (Oi2Flags.HasAsyncUuid) TRACE(" HasAsyncUuid");
|
|
|
|
if (Oi2Flags.HasExtensions) TRACE(" HasExtensions");
|
|
|
|
if (Oi2Flags.HasAsyncHandle) TRACE(" HasAsyncHandle");
|
|
|
|
TRACE("\n");
|
|
|
|
}
|
|
|
|
|
2007-11-05 12:16:43 +01:00
|
|
|
#define ARG_FROM_OFFSET(args, offset) ((args) + (offset))
|
2006-05-25 00:03:29 +02:00
|
|
|
|
|
|
|
static PFORMAT_STRING client_get_handle(
|
|
|
|
PMIDL_STUB_MESSAGE pStubMsg, const NDR_PROC_HEADER *pProcHeader,
|
|
|
|
PFORMAT_STRING pFormat, handle_t *phBinding)
|
|
|
|
{
|
|
|
|
/* binding */
|
|
|
|
switch (pProcHeader->handle_type)
|
|
|
|
{
|
|
|
|
/* explicit binding: parse additional section */
|
|
|
|
case RPC_FC_BIND_EXPLICIT:
|
|
|
|
switch (*pFormat) /* handle_type */
|
|
|
|
{
|
|
|
|
case RPC_FC_BIND_PRIMITIVE: /* explicit primitive */
|
|
|
|
{
|
2006-09-25 22:25:45 +02:00
|
|
|
const NDR_EHD_PRIMITIVE *pDesc = (const NDR_EHD_PRIMITIVE *)pFormat;
|
2006-05-25 00:03:29 +02:00
|
|
|
|
|
|
|
TRACE("Explicit primitive handle @ %d\n", pDesc->offset);
|
|
|
|
|
|
|
|
if (pDesc->flag) /* pointer to binding */
|
2007-11-05 12:16:43 +01:00
|
|
|
*phBinding = **(handle_t **)ARG_FROM_OFFSET(pStubMsg->StackTop, pDesc->offset);
|
2006-05-25 00:03:29 +02:00
|
|
|
else
|
2007-11-05 12:16:43 +01:00
|
|
|
*phBinding = *(handle_t *)ARG_FROM_OFFSET(pStubMsg->StackTop, pDesc->offset);
|
2006-05-25 00:03:29 +02:00
|
|
|
return pFormat + sizeof(NDR_EHD_PRIMITIVE);
|
|
|
|
}
|
|
|
|
case RPC_FC_BIND_GENERIC: /* explicit generic */
|
2006-05-25 00:03:54 +02:00
|
|
|
{
|
2006-09-25 22:25:45 +02:00
|
|
|
const NDR_EHD_GENERIC *pDesc = (const NDR_EHD_GENERIC *)pFormat;
|
2006-05-25 00:03:54 +02:00
|
|
|
void *pObject = NULL;
|
|
|
|
void *pArg;
|
|
|
|
const GENERIC_BINDING_ROUTINE_PAIR *pGenPair;
|
|
|
|
|
|
|
|
TRACE("Explicit generic binding handle #%d\n", pDesc->binding_routine_pair_index);
|
|
|
|
|
|
|
|
if (pDesc->flag_and_size & HANDLE_PARAM_IS_VIA_PTR)
|
2007-11-05 12:16:43 +01:00
|
|
|
pArg = *(void **)ARG_FROM_OFFSET(pStubMsg->StackTop, pDesc->offset);
|
2006-05-25 00:03:54 +02:00
|
|
|
else
|
2007-11-05 12:16:43 +01:00
|
|
|
pArg = (void *)ARG_FROM_OFFSET(pStubMsg->StackTop, pDesc->offset);
|
2006-05-25 00:03:54 +02:00
|
|
|
memcpy(&pObject, pArg, pDesc->flag_and_size & 0xf);
|
|
|
|
pGenPair = &pStubMsg->StubDesc->aGenericBindingRoutinePairs[pDesc->binding_routine_pair_index];
|
|
|
|
*phBinding = pGenPair->pfnBind(pObject);
|
|
|
|
return pFormat + sizeof(NDR_EHD_GENERIC);
|
|
|
|
}
|
2006-05-25 00:03:29 +02:00
|
|
|
case RPC_FC_BIND_CONTEXT: /* explicit context */
|
|
|
|
{
|
2006-09-25 22:25:45 +02:00
|
|
|
const NDR_EHD_CONTEXT *pDesc = (const NDR_EHD_CONTEXT *)pFormat;
|
2006-05-25 00:03:29 +02:00
|
|
|
NDR_CCONTEXT context_handle;
|
|
|
|
TRACE("Explicit bind context\n");
|
|
|
|
if (pDesc->flags & HANDLE_PARAM_IS_VIA_PTR)
|
|
|
|
{
|
|
|
|
TRACE("\tHANDLE_PARAM_IS_VIA_PTR\n");
|
2007-11-05 12:16:43 +01:00
|
|
|
context_handle = **(NDR_CCONTEXT **)ARG_FROM_OFFSET(pStubMsg->StackTop, pDesc->offset);
|
2006-05-25 00:03:29 +02:00
|
|
|
}
|
|
|
|
else
|
2007-11-05 12:16:43 +01:00
|
|
|
context_handle = *(NDR_CCONTEXT *)ARG_FROM_OFFSET(pStubMsg->StackTop, pDesc->offset);
|
2006-05-25 00:03:29 +02:00
|
|
|
if ((pDesc->flags & NDR_CONTEXT_HANDLE_CANNOT_BE_NULL) &&
|
|
|
|
!context_handle)
|
|
|
|
{
|
|
|
|
ERR("null context handle isn't allowed\n");
|
|
|
|
RpcRaiseException(RPC_X_SS_IN_NULL_CONTEXT);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
*phBinding = NDRCContextBinding(context_handle);
|
|
|
|
/* FIXME: should we store this structure in stubMsg.pContext? */
|
|
|
|
return pFormat + sizeof(NDR_EHD_CONTEXT);
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
ERR("bad explicit binding handle type (0x%02x)\n", pProcHeader->handle_type);
|
|
|
|
RpcRaiseException(RPC_X_BAD_STUB_DATA);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case RPC_FC_BIND_GENERIC: /* implicit generic */
|
|
|
|
FIXME("RPC_FC_BIND_GENERIC\n");
|
|
|
|
RpcRaiseException(RPC_X_BAD_STUB_DATA); /* FIXME: remove when implemented */
|
|
|
|
break;
|
|
|
|
case RPC_FC_BIND_PRIMITIVE: /* implicit primitive */
|
|
|
|
TRACE("Implicit primitive handle\n");
|
|
|
|
*phBinding = *pStubMsg->StubDesc->IMPLICIT_HANDLE_INFO.pPrimitiveHandle;
|
|
|
|
break;
|
|
|
|
case RPC_FC_CALLBACK_HANDLE: /* implicit callback */
|
|
|
|
FIXME("RPC_FC_CALLBACK_HANDLE\n");
|
|
|
|
break;
|
|
|
|
case RPC_FC_AUTO_HANDLE: /* implicit auto handle */
|
|
|
|
/* strictly speaking, it isn't necessary to set hBinding here
|
|
|
|
* since it isn't actually used (hence the automatic in its name),
|
|
|
|
* but then why does MIDL generate a valid entry in the
|
|
|
|
* MIDL_STUB_DESC for it? */
|
|
|
|
TRACE("Implicit auto handle\n");
|
|
|
|
*phBinding = *pStubMsg->StubDesc->IMPLICIT_HANDLE_INFO.pAutoHandle;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
ERR("bad implicit binding handle type (0x%02x)\n", pProcHeader->handle_type);
|
|
|
|
RpcRaiseException(RPC_X_BAD_STUB_DATA);
|
|
|
|
}
|
|
|
|
return pFormat;
|
|
|
|
}
|
2006-01-05 12:19:05 +01:00
|
|
|
|
2006-05-25 00:03:54 +02:00
|
|
|
static void client_free_handle(
|
|
|
|
PMIDL_STUB_MESSAGE pStubMsg, const NDR_PROC_HEADER *pProcHeader,
|
|
|
|
PFORMAT_STRING pFormat, handle_t hBinding)
|
|
|
|
{
|
|
|
|
/* binding */
|
|
|
|
switch (pProcHeader->handle_type)
|
|
|
|
{
|
|
|
|
/* explicit binding: parse additional section */
|
|
|
|
case RPC_FC_BIND_EXPLICIT:
|
|
|
|
switch (*pFormat) /* handle_type */
|
|
|
|
{
|
|
|
|
case RPC_FC_BIND_GENERIC: /* explicit generic */
|
|
|
|
{
|
2006-09-25 22:25:45 +02:00
|
|
|
const NDR_EHD_GENERIC *pDesc = (const NDR_EHD_GENERIC *)pFormat;
|
2006-05-25 00:03:54 +02:00
|
|
|
void *pObject = NULL;
|
|
|
|
void *pArg;
|
|
|
|
const GENERIC_BINDING_ROUTINE_PAIR *pGenPair;
|
|
|
|
|
|
|
|
TRACE("Explicit generic binding handle #%d\n", pDesc->binding_routine_pair_index);
|
|
|
|
|
|
|
|
if (pDesc->flag_and_size & HANDLE_PARAM_IS_VIA_PTR)
|
2007-11-05 12:16:43 +01:00
|
|
|
pArg = *(void **)ARG_FROM_OFFSET(pStubMsg->StackTop, pDesc->offset);
|
2006-05-25 00:03:54 +02:00
|
|
|
else
|
2007-11-05 12:16:43 +01:00
|
|
|
pArg = (void *)ARG_FROM_OFFSET(pStubMsg->StackTop, pDesc->offset);
|
2006-05-25 00:03:54 +02:00
|
|
|
memcpy(&pObject, pArg, pDesc->flag_and_size & 0xf);
|
|
|
|
pGenPair = &pStubMsg->StubDesc->aGenericBindingRoutinePairs[pDesc->binding_routine_pair_index];
|
|
|
|
pGenPair->pfnUnbind(pObject, hBinding);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case RPC_FC_BIND_CONTEXT: /* explicit context */
|
|
|
|
case RPC_FC_BIND_PRIMITIVE: /* explicit primitive */
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
ERR("bad explicit binding handle type (0x%02x)\n", pProcHeader->handle_type);
|
|
|
|
RpcRaiseException(RPC_X_BAD_STUB_DATA);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case RPC_FC_BIND_GENERIC: /* implicit generic */
|
|
|
|
FIXME("RPC_FC_BIND_GENERIC\n");
|
|
|
|
RpcRaiseException(RPC_X_BAD_STUB_DATA); /* FIXME: remove when implemented */
|
|
|
|
break;
|
|
|
|
case RPC_FC_CALLBACK_HANDLE: /* implicit callback */
|
|
|
|
case RPC_FC_BIND_PRIMITIVE: /* implicit primitive */
|
|
|
|
case RPC_FC_AUTO_HANDLE: /* implicit auto handle */
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
ERR("bad implicit binding handle type (0x%02x)\n", pProcHeader->handle_type);
|
|
|
|
RpcRaiseException(RPC_X_BAD_STUB_DATA);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-08-16 13:29:12 +02:00
|
|
|
static void client_do_args(PMIDL_STUB_MESSAGE pStubMsg, PFORMAT_STRING pFormat,
|
2007-11-05 12:16:43 +01:00
|
|
|
int phase, unsigned char *args, unsigned short number_of_params,
|
|
|
|
unsigned char *pRetVal)
|
2006-08-16 13:29:12 +02:00
|
|
|
{
|
|
|
|
/* current format string offset */
|
|
|
|
int current_offset = 0;
|
|
|
|
/* current stack offset */
|
|
|
|
unsigned short current_stack_offset = 0;
|
|
|
|
/* counter */
|
|
|
|
unsigned short i;
|
|
|
|
|
|
|
|
for (i = 0; i < number_of_params; i++)
|
|
|
|
{
|
2006-09-25 22:25:45 +02:00
|
|
|
const NDR_PARAM_OIF_BASETYPE *pParam =
|
|
|
|
(const NDR_PARAM_OIF_BASETYPE *)&pFormat[current_offset];
|
2006-08-16 13:29:12 +02:00
|
|
|
unsigned char * pArg;
|
|
|
|
|
|
|
|
current_stack_offset = pParam->stack_offset;
|
2007-11-05 12:16:43 +01:00
|
|
|
pArg = ARG_FROM_OFFSET(args, current_stack_offset);
|
2006-08-16 13:29:12 +02:00
|
|
|
|
|
|
|
TRACE("param[%d]: new format\n", i);
|
|
|
|
TRACE("\tparam_attributes:"); dump_RPC_FC_PROC_PF(pParam->param_attributes); TRACE("\n");
|
|
|
|
TRACE("\tstack_offset: 0x%x\n", current_stack_offset);
|
|
|
|
TRACE("\tmemory addr (before): %p\n", pArg);
|
|
|
|
|
|
|
|
if (pParam->param_attributes.IsBasetype)
|
|
|
|
{
|
|
|
|
const unsigned char * pTypeFormat =
|
|
|
|
&pParam->type_format_char;
|
|
|
|
|
|
|
|
if (pParam->param_attributes.IsSimpleRef)
|
|
|
|
pArg = *(unsigned char **)pArg;
|
|
|
|
|
|
|
|
TRACE("\tbase type: 0x%02x\n", *pTypeFormat);
|
|
|
|
|
|
|
|
switch (phase)
|
|
|
|
{
|
|
|
|
case PROXY_CALCSIZE:
|
|
|
|
if (pParam->param_attributes.IsIn)
|
|
|
|
call_buffer_sizer(pStubMsg, pArg, pTypeFormat);
|
|
|
|
break;
|
|
|
|
case PROXY_MARSHAL:
|
|
|
|
if (pParam->param_attributes.IsIn)
|
|
|
|
call_marshaller(pStubMsg, pArg, pTypeFormat);
|
|
|
|
break;
|
|
|
|
case PROXY_UNMARSHAL:
|
|
|
|
if (pParam->param_attributes.IsOut)
|
|
|
|
{
|
|
|
|
if (pParam->param_attributes.IsReturn)
|
|
|
|
call_unmarshaller(pStubMsg, &pRetVal, pTypeFormat, 0);
|
|
|
|
else
|
|
|
|
call_unmarshaller(pStubMsg, &pArg, pTypeFormat, 0);
|
|
|
|
TRACE("pRetVal = %p\n", pRetVal);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
RpcRaiseException(RPC_S_INTERNAL_ERROR);
|
|
|
|
}
|
|
|
|
|
|
|
|
current_offset += sizeof(NDR_PARAM_OIF_BASETYPE);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2006-09-25 22:25:45 +02:00
|
|
|
const NDR_PARAM_OIF_OTHER *pParamOther =
|
|
|
|
(const NDR_PARAM_OIF_OTHER *)&pFormat[current_offset];
|
2006-08-16 13:29:12 +02:00
|
|
|
|
|
|
|
const unsigned char * pTypeFormat =
|
|
|
|
&(pStubMsg->StubDesc->pFormatTypes[pParamOther->type_offset]);
|
|
|
|
|
|
|
|
/* if a simple ref pointer then we have to do the
|
|
|
|
* check for the pointer being non-NULL. */
|
|
|
|
if (pParam->param_attributes.IsSimpleRef)
|
|
|
|
{
|
|
|
|
if (!*(unsigned char **)pArg)
|
|
|
|
RpcRaiseException(RPC_X_NULL_REF_POINTER);
|
|
|
|
}
|
|
|
|
|
|
|
|
TRACE("\tcomplex type: 0x%02x\n", *pTypeFormat);
|
|
|
|
|
|
|
|
switch (phase)
|
|
|
|
{
|
|
|
|
case PROXY_CALCSIZE:
|
|
|
|
if (pParam->param_attributes.IsIn)
|
|
|
|
{
|
|
|
|
if (pParam->param_attributes.IsByValue)
|
|
|
|
call_buffer_sizer(pStubMsg, pArg, pTypeFormat);
|
|
|
|
else
|
|
|
|
call_buffer_sizer(pStubMsg, *(unsigned char **)pArg, pTypeFormat);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case PROXY_MARSHAL:
|
|
|
|
if (pParam->param_attributes.IsIn)
|
|
|
|
{
|
|
|
|
if (pParam->param_attributes.IsByValue)
|
|
|
|
call_marshaller(pStubMsg, pArg, pTypeFormat);
|
|
|
|
else
|
|
|
|
call_marshaller(pStubMsg, *(unsigned char **)pArg, pTypeFormat);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case PROXY_UNMARSHAL:
|
|
|
|
if (pParam->param_attributes.IsOut)
|
|
|
|
{
|
|
|
|
if (pParam->param_attributes.IsReturn)
|
|
|
|
call_unmarshaller(pStubMsg, &pRetVal, pTypeFormat, 0);
|
|
|
|
else if (pParam->param_attributes.IsByValue)
|
|
|
|
call_unmarshaller(pStubMsg, &pArg, pTypeFormat, 0);
|
|
|
|
else
|
|
|
|
call_unmarshaller(pStubMsg, (unsigned char **)pArg, pTypeFormat, 0);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
RpcRaiseException(RPC_S_INTERNAL_ERROR);
|
|
|
|
}
|
|
|
|
|
|
|
|
current_offset += sizeof(NDR_PARAM_OIF_OTHER);
|
|
|
|
}
|
|
|
|
TRACE("\tmemory addr (after): %p\n", pArg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-03-10 18:05:59 +01:00
|
|
|
static unsigned int type_stack_size(unsigned char fc)
|
|
|
|
{
|
|
|
|
switch (fc)
|
|
|
|
{
|
|
|
|
case RPC_FC_BYTE:
|
|
|
|
case RPC_FC_CHAR:
|
|
|
|
case RPC_FC_SMALL:
|
|
|
|
case RPC_FC_USMALL:
|
|
|
|
return sizeof(char);
|
|
|
|
case RPC_FC_WCHAR:
|
|
|
|
case RPC_FC_SHORT:
|
|
|
|
case RPC_FC_USHORT:
|
|
|
|
return sizeof(short);
|
|
|
|
case RPC_FC_LONG:
|
|
|
|
case RPC_FC_ULONG:
|
|
|
|
case RPC_FC_ENUM16:
|
|
|
|
case RPC_FC_ENUM32:
|
|
|
|
return sizeof(int);
|
|
|
|
case RPC_FC_FLOAT:
|
|
|
|
return sizeof(float);
|
|
|
|
case RPC_FC_DOUBLE:
|
|
|
|
return sizeof(double);
|
|
|
|
case RPC_FC_HYPER:
|
|
|
|
return sizeof(ULONGLONG);
|
|
|
|
case RPC_FC_ERROR_STATUS_T:
|
|
|
|
return sizeof(error_status_t);
|
|
|
|
case RPC_FC_IGNORE:
|
|
|
|
return sizeof(void *);
|
|
|
|
default:
|
|
|
|
ERR("invalid base type 0x%x\n", fc);
|
|
|
|
RpcRaiseException(RPC_S_INTERNAL_ERROR);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-11-05 12:16:43 +01:00
|
|
|
void client_do_args_old_format(PMIDL_STUB_MESSAGE pStubMsg,
|
|
|
|
PFORMAT_STRING pFormat, int phase, unsigned char *args,
|
|
|
|
unsigned short stack_size,
|
2008-04-24 15:30:59 +02:00
|
|
|
unsigned char *pRetVal, BOOL object_proc, BOOL ignore_retval)
|
2006-08-16 13:29:12 +02:00
|
|
|
{
|
|
|
|
/* current format string offset */
|
|
|
|
int current_offset = 0;
|
|
|
|
/* current stack offset */
|
|
|
|
unsigned short current_stack_offset = 0;
|
|
|
|
/* counter */
|
|
|
|
unsigned short i;
|
|
|
|
|
2008-04-11 04:17:14 +02:00
|
|
|
/* NOTE: V1 style format doesn't terminate on the number_of_params
|
2006-08-16 13:29:12 +02:00
|
|
|
* condition as it doesn't have this attribute. Instead it
|
|
|
|
* terminates when the stack size given in the header is exceeded.
|
|
|
|
*/
|
|
|
|
for (i = 0; TRUE; i++)
|
|
|
|
{
|
2006-09-25 22:25:45 +02:00
|
|
|
const NDR_PARAM_OI_BASETYPE *pParam =
|
|
|
|
(const NDR_PARAM_OI_BASETYPE *)&pFormat[current_offset];
|
2006-08-16 13:29:12 +02:00
|
|
|
/* note: current_stack_offset starts after the This pointer
|
|
|
|
* if present, so adjust this */
|
|
|
|
unsigned short current_stack_offset_adjusted = current_stack_offset +
|
|
|
|
(object_proc ? sizeof(void *) : 0);
|
2007-11-05 12:16:43 +01:00
|
|
|
unsigned char * pArg = ARG_FROM_OFFSET(args, current_stack_offset_adjusted);
|
2006-08-16 13:29:12 +02:00
|
|
|
|
|
|
|
/* no more parameters; exit loop */
|
|
|
|
if (current_stack_offset_adjusted >= stack_size)
|
|
|
|
break;
|
|
|
|
|
|
|
|
TRACE("param[%d]: old format\n", i);
|
|
|
|
TRACE("\tparam_direction: 0x%x\n", pParam->param_direction);
|
|
|
|
TRACE("\tstack_offset: 0x%x\n", current_stack_offset_adjusted);
|
|
|
|
TRACE("\tmemory addr (before): %p\n", pArg);
|
|
|
|
|
|
|
|
if (pParam->param_direction == RPC_FC_IN_PARAM_BASETYPE ||
|
|
|
|
pParam->param_direction == RPC_FC_RETURN_PARAM_BASETYPE)
|
|
|
|
{
|
|
|
|
const unsigned char * pTypeFormat =
|
|
|
|
&pParam->type_format_char;
|
|
|
|
|
|
|
|
TRACE("\tbase type 0x%02x\n", *pTypeFormat);
|
|
|
|
|
|
|
|
switch (phase)
|
|
|
|
{
|
|
|
|
case PROXY_CALCSIZE:
|
|
|
|
if (pParam->param_direction == RPC_FC_IN_PARAM_BASETYPE)
|
|
|
|
call_buffer_sizer(pStubMsg, pArg, pTypeFormat);
|
|
|
|
break;
|
|
|
|
case PROXY_MARSHAL:
|
|
|
|
if (pParam->param_direction == RPC_FC_IN_PARAM_BASETYPE)
|
|
|
|
call_marshaller(pStubMsg, pArg, pTypeFormat);
|
|
|
|
break;
|
|
|
|
case PROXY_UNMARSHAL:
|
2008-04-24 15:30:59 +02:00
|
|
|
if (!ignore_retval &&
|
|
|
|
pParam->param_direction == RPC_FC_RETURN_PARAM_BASETYPE)
|
2006-08-16 13:29:12 +02:00
|
|
|
{
|
|
|
|
if (pParam->param_direction & RPC_FC_RETURN_PARAM)
|
2008-03-10 18:24:49 +01:00
|
|
|
call_unmarshaller(pStubMsg, &pRetVal, pTypeFormat, 0);
|
2006-08-16 13:29:12 +02:00
|
|
|
else
|
|
|
|
call_unmarshaller(pStubMsg, &pArg, pTypeFormat, 0);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
RpcRaiseException(RPC_S_INTERNAL_ERROR);
|
|
|
|
}
|
|
|
|
|
2008-03-10 18:05:59 +01:00
|
|
|
current_stack_offset += type_stack_size(*pTypeFormat);
|
2006-08-16 13:29:12 +02:00
|
|
|
current_offset += sizeof(NDR_PARAM_OI_BASETYPE);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2006-09-25 22:25:45 +02:00
|
|
|
const NDR_PARAM_OI_OTHER *pParamOther =
|
|
|
|
(const NDR_PARAM_OI_OTHER *)&pFormat[current_offset];
|
2006-08-16 13:29:12 +02:00
|
|
|
|
|
|
|
const unsigned char *pTypeFormat =
|
|
|
|
&pStubMsg->StubDesc->pFormatTypes[pParamOther->type_offset];
|
|
|
|
|
|
|
|
TRACE("\tcomplex type 0x%02x\n", *pTypeFormat);
|
|
|
|
|
|
|
|
switch (phase)
|
|
|
|
{
|
|
|
|
case PROXY_CALCSIZE:
|
|
|
|
if (pParam->param_direction == RPC_FC_IN_PARAM ||
|
|
|
|
pParam->param_direction & RPC_FC_IN_OUT_PARAM)
|
|
|
|
call_buffer_sizer(pStubMsg, *(unsigned char **)pArg, pTypeFormat);
|
|
|
|
break;
|
|
|
|
case PROXY_MARSHAL:
|
|
|
|
if (pParam->param_direction == RPC_FC_IN_PARAM ||
|
|
|
|
pParam->param_direction & RPC_FC_IN_OUT_PARAM)
|
|
|
|
call_marshaller(pStubMsg, *(unsigned char **)pArg, pTypeFormat);
|
|
|
|
break;
|
|
|
|
case PROXY_UNMARSHAL:
|
|
|
|
if (pParam->param_direction == RPC_FC_IN_OUT_PARAM ||
|
|
|
|
pParam->param_direction == RPC_FC_OUT_PARAM)
|
|
|
|
call_unmarshaller(pStubMsg, (unsigned char **)pArg, pTypeFormat, 0);
|
|
|
|
else if (pParam->param_direction == RPC_FC_RETURN_PARAM)
|
|
|
|
call_unmarshaller(pStubMsg, (unsigned char **)pRetVal, pTypeFormat, 0);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
RpcRaiseException(RPC_S_INTERNAL_ERROR);
|
|
|
|
}
|
|
|
|
|
|
|
|
current_stack_offset += pParamOther->stack_size * sizeof(INT);
|
|
|
|
current_offset += sizeof(NDR_PARAM_OI_OTHER);
|
|
|
|
}
|
|
|
|
TRACE("\tmemory addr (after): %p\n", pArg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-01-05 12:19:05 +01:00
|
|
|
/* the return type should be CLIENT_CALL_RETURN, but this is incompatible
|
|
|
|
* with the way gcc returns structures. "void *" should be the largest type
|
|
|
|
* that MIDL should allow you to return anyway */
|
|
|
|
LONG_PTR WINAPIV NdrClientCall2(PMIDL_STUB_DESC pStubDesc, PFORMAT_STRING pFormat, ...)
|
|
|
|
{
|
|
|
|
/* pointer to start of stack where arguments start */
|
|
|
|
RPC_MESSAGE rpcMsg;
|
|
|
|
MIDL_STUB_MESSAGE stubMsg;
|
|
|
|
handle_t hBinding = NULL;
|
|
|
|
/* procedure number */
|
|
|
|
unsigned short procedure_number;
|
|
|
|
/* size of stack */
|
|
|
|
unsigned short stack_size;
|
|
|
|
/* number of parameters. optional for client to give it to us */
|
|
|
|
unsigned char number_of_params = ~0;
|
|
|
|
/* cache of Oif_flags from v2 procedure header */
|
2006-04-20 12:44:27 +02:00
|
|
|
INTERPRETER_OPT_FLAGS Oif_flags = { 0 };
|
2006-04-20 12:44:41 +02:00
|
|
|
/* cache of extension flags from NDR_PROC_HEADER_EXTS */
|
|
|
|
INTERPRETER_OPT_FLAGS2 ext_flags = { 0 };
|
2006-01-05 12:19:05 +01:00
|
|
|
/* the type of pass we are currently doing */
|
|
|
|
int phase;
|
|
|
|
/* header for procedure string */
|
|
|
|
const NDR_PROC_HEADER * pProcHeader = (const NDR_PROC_HEADER *)&pFormat[0];
|
|
|
|
/* -Oif or -Oicf generated format */
|
|
|
|
BOOL bV2Format = FALSE;
|
|
|
|
/* the value to return to the client from the remote procedure */
|
|
|
|
LONG_PTR RetVal = 0;
|
|
|
|
/* the pointer to the object when in OLE mode */
|
|
|
|
void * This = NULL;
|
2006-05-25 00:03:54 +02:00
|
|
|
PFORMAT_STRING pHandleFormat;
|
2008-01-07 16:20:25 +01:00
|
|
|
/* correlation cache */
|
|
|
|
unsigned long NdrCorrCache[256];
|
2006-01-05 12:19:05 +01:00
|
|
|
|
|
|
|
TRACE("pStubDesc %p, pFormat %p, ...\n", pStubDesc, pFormat);
|
2006-05-25 00:03:10 +02:00
|
|
|
|
2006-01-05 12:19:05 +01:00
|
|
|
/* Later NDR language versions probably won't be backwards compatible */
|
|
|
|
if (pStubDesc->Version > 0x50002)
|
|
|
|
{
|
2006-11-09 23:04:48 +01:00
|
|
|
FIXME("Incompatible stub description version: 0x%x\n", pStubDesc->Version);
|
2006-01-05 12:19:05 +01:00
|
|
|
RpcRaiseException(RPC_X_WRONG_STUB_VERSION);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (pProcHeader->Oi_flags & RPC_FC_PROC_OIF_RPCFLAGS)
|
|
|
|
{
|
2006-09-25 22:25:45 +02:00
|
|
|
const NDR_PROC_HEADER_RPC *pProcHeader = (const NDR_PROC_HEADER_RPC *)&pFormat[0];
|
2006-01-05 12:19:05 +01:00
|
|
|
stack_size = pProcHeader->stack_size;
|
|
|
|
procedure_number = pProcHeader->proc_num;
|
2006-05-25 00:03:29 +02:00
|
|
|
pFormat += sizeof(NDR_PROC_HEADER_RPC);
|
2006-01-05 12:19:05 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
stack_size = pProcHeader->stack_size;
|
|
|
|
procedure_number = pProcHeader->proc_num;
|
2006-05-25 00:03:29 +02:00
|
|
|
pFormat += sizeof(NDR_PROC_HEADER);
|
2006-01-05 12:19:05 +01:00
|
|
|
}
|
2006-08-09 19:17:05 +02:00
|
|
|
TRACE("stack size: 0x%x\n", stack_size);
|
|
|
|
TRACE("proc num: %d\n", procedure_number);
|
2006-01-05 12:19:05 +01:00
|
|
|
|
2006-06-07 21:11:36 +02:00
|
|
|
/* create the full pointer translation tables, if requested */
|
|
|
|
if (pProcHeader->Oi_flags & RPC_FC_PROC_OIF_FULLPTR)
|
|
|
|
stubMsg.FullPtrXlatTables = NdrFullPointerXlatInit(0,XLAT_CLIENT);
|
|
|
|
|
2006-05-25 00:03:18 +02:00
|
|
|
if (pProcHeader->Oi_flags & RPC_FC_PROC_OIF_OBJECT)
|
|
|
|
{
|
|
|
|
/* object is always the first argument */
|
2006-11-11 15:57:53 +01:00
|
|
|
This = **(void *const **)(&pFormat+1);
|
2006-05-25 00:03:18 +02:00
|
|
|
NdrProxyInitialize(This, &rpcMsg, &stubMsg, pStubDesc, procedure_number);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
NdrClientInitializeNew(&rpcMsg, &stubMsg, pStubDesc, procedure_number);
|
|
|
|
|
2006-01-05 12:19:05 +01:00
|
|
|
TRACE("Oi_flags = 0x%02x\n", pProcHeader->Oi_flags);
|
2006-11-09 23:04:48 +01:00
|
|
|
TRACE("MIDL stub version = 0x%x\n", pStubDesc->MIDLVersion);
|
2006-01-05 12:19:05 +01:00
|
|
|
|
2006-05-25 00:03:18 +02:00
|
|
|
/* needed for conformance of top-level objects */
|
|
|
|
#ifdef __i386__
|
|
|
|
stubMsg.StackTop = *(unsigned char **)(&pFormat+1);
|
|
|
|
#else
|
|
|
|
# warning Stack not retrieved for your CPU architecture
|
|
|
|
#endif
|
|
|
|
|
2006-05-25 00:03:54 +02:00
|
|
|
pHandleFormat = pFormat;
|
|
|
|
|
2006-01-05 12:19:05 +01:00
|
|
|
/* we only need a handle if this isn't an object method */
|
|
|
|
if (!(pProcHeader->Oi_flags & RPC_FC_PROC_OIF_OBJECT))
|
|
|
|
{
|
2006-05-25 00:03:54 +02:00
|
|
|
pFormat = client_get_handle(&stubMsg, pProcHeader, pHandleFormat, &hBinding);
|
2006-05-25 00:03:29 +02:00
|
|
|
if (!pFormat) return 0;
|
2006-01-05 12:19:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
bV2Format = (pStubDesc->Version >= 0x20000);
|
|
|
|
|
|
|
|
if (bV2Format)
|
|
|
|
{
|
2006-09-25 22:25:45 +02:00
|
|
|
const NDR_PROC_PARTIAL_OIF_HEADER *pOIFHeader =
|
|
|
|
(const NDR_PROC_PARTIAL_OIF_HEADER *)pFormat;
|
2006-01-05 12:19:05 +01:00
|
|
|
|
2006-04-20 12:44:27 +02:00
|
|
|
Oif_flags = pOIFHeader->Oi2Flags;
|
2006-01-05 12:19:05 +01:00
|
|
|
number_of_params = pOIFHeader->number_of_params;
|
|
|
|
|
2006-05-25 00:03:29 +02:00
|
|
|
pFormat += sizeof(NDR_PROC_PARTIAL_OIF_HEADER);
|
2006-01-05 12:19:05 +01:00
|
|
|
}
|
|
|
|
|
2006-04-20 12:44:27 +02:00
|
|
|
TRACE("Oif_flags = "); dump_INTERPRETER_OPT_FLAGS(Oif_flags);
|
2006-01-05 12:19:05 +01:00
|
|
|
|
2006-04-20 12:44:27 +02:00
|
|
|
if (Oif_flags.HasExtensions)
|
2006-01-05 12:19:05 +01:00
|
|
|
{
|
2006-09-25 22:25:45 +02:00
|
|
|
const NDR_PROC_HEADER_EXTS *pExtensions =
|
|
|
|
(const NDR_PROC_HEADER_EXTS *)pFormat;
|
2006-04-20 12:44:41 +02:00
|
|
|
ext_flags = pExtensions->Flags2;
|
2006-05-25 00:03:29 +02:00
|
|
|
pFormat += pExtensions->Size;
|
2006-01-05 12:19:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
stubMsg.BufferLength = 0;
|
|
|
|
|
|
|
|
/* store the RPC flags away */
|
|
|
|
if (pProcHeader->Oi_flags & RPC_FC_PROC_OIF_RPCFLAGS)
|
2006-09-25 22:25:45 +02:00
|
|
|
rpcMsg.RpcFlags = ((const NDR_PROC_HEADER_RPC *)pProcHeader)->rpc_flags;
|
2006-01-05 12:19:05 +01:00
|
|
|
|
|
|
|
/* use alternate memory allocation routines */
|
|
|
|
if (pProcHeader->Oi_flags & RPC_FC_PROC_OIF_RPCSSALLOC)
|
|
|
|
NdrRpcSmSetClientToOsf(&stubMsg);
|
|
|
|
|
2006-04-20 12:44:27 +02:00
|
|
|
if (Oif_flags.HasPipes)
|
2006-01-05 12:19:05 +01:00
|
|
|
{
|
|
|
|
FIXME("pipes not supported yet\n");
|
|
|
|
RpcRaiseException(RPC_X_WRONG_STUB_VERSION); /* FIXME: remove when implemented */
|
|
|
|
/* init pipes package */
|
|
|
|
/* NdrPipesInitialize(...) */
|
|
|
|
}
|
2006-04-20 12:44:41 +02:00
|
|
|
if (ext_flags.HasNewCorrDesc)
|
2006-01-05 12:19:05 +01:00
|
|
|
{
|
|
|
|
/* initialize extra correlation package */
|
2008-01-07 16:20:25 +01:00
|
|
|
NdrCorrelationInitialize(&stubMsg, NdrCorrCache, sizeof(NdrCorrCache), 0);
|
2006-01-05 12:19:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* order of phases:
|
|
|
|
* 1. PROXY_CALCSIZE - calculate the buffer size
|
|
|
|
* 2. PROXY_GETBUFFER - allocate the buffer
|
|
|
|
* 3. PROXY_MARHSAL - marshal [in] params into the buffer
|
|
|
|
* 4. PROXY_SENDRECEIVE - send/receive buffer
|
|
|
|
* 5. PROXY_UNMARHSAL - unmarshal [out] params from buffer
|
|
|
|
*/
|
2008-01-17 13:25:52 +01:00
|
|
|
if (pProcHeader->Oi_flags & RPC_FC_PROC_OIF_OBJECT)
|
|
|
|
{
|
|
|
|
__TRY
|
|
|
|
{
|
|
|
|
for (phase = PROXY_CALCSIZE; phase <= PROXY_UNMARSHAL; phase++)
|
|
|
|
{
|
|
|
|
TRACE("phase = %d\n", phase);
|
|
|
|
switch (phase)
|
|
|
|
{
|
|
|
|
case PROXY_GETBUFFER:
|
|
|
|
/* allocate the buffer */
|
|
|
|
NdrProxyGetBuffer(This, &stubMsg);
|
|
|
|
break;
|
|
|
|
case PROXY_SENDRECEIVE:
|
|
|
|
/* send the [in] params and receive the [out] and [retval]
|
|
|
|
* params */
|
|
|
|
NdrProxySendReceive(This, &stubMsg);
|
|
|
|
|
|
|
|
/* convert strings, floating point values and endianess into our
|
|
|
|
* preferred format */
|
|
|
|
if ((rpcMsg.DataRepresentation & 0x0000FFFFUL) != NDR_LOCAL_DATA_REPRESENTATION)
|
|
|
|
NdrConvert(&stubMsg, pFormat);
|
|
|
|
|
|
|
|
break;
|
|
|
|
case PROXY_CALCSIZE:
|
|
|
|
case PROXY_MARSHAL:
|
|
|
|
case PROXY_UNMARSHAL:
|
|
|
|
if (bV2Format)
|
2007-11-05 12:16:43 +01:00
|
|
|
client_do_args(&stubMsg, pFormat, phase, stubMsg.StackTop,
|
|
|
|
number_of_params, (unsigned char *)&RetVal);
|
2008-01-17 13:25:52 +01:00
|
|
|
else
|
2007-11-05 12:16:43 +01:00
|
|
|
client_do_args_old_format(&stubMsg, pFormat, phase,
|
|
|
|
stubMsg.StackTop, stack_size, (unsigned char *)&RetVal,
|
2008-04-24 15:30:59 +02:00
|
|
|
(pProcHeader->Oi_flags & RPC_FC_PROC_OIF_OBJECT), FALSE);
|
2008-01-17 13:25:52 +01:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
ERR("shouldn't reach here. phase %d\n", phase);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2008-02-15 16:43:24 +01:00
|
|
|
__EXCEPT_ALL
|
2008-01-17 13:25:52 +01:00
|
|
|
{
|
|
|
|
RetVal = NdrProxyErrorHandler(GetExceptionCode());
|
|
|
|
}
|
|
|
|
__ENDTRY
|
|
|
|
}
|
|
|
|
else
|
2006-01-05 12:19:05 +01:00
|
|
|
{
|
2008-01-17 13:25:52 +01:00
|
|
|
/* order of phases:
|
|
|
|
* 1. PROXY_CALCSIZE - calculate the buffer size
|
|
|
|
* 2. PROXY_GETBUFFER - allocate the buffer
|
|
|
|
* 3. PROXY_MARHSAL - marshal [in] params into the buffer
|
|
|
|
* 4. PROXY_SENDRECEIVE - send/receive buffer
|
|
|
|
* 5. PROXY_UNMARHSAL - unmarshal [out] params from buffer
|
|
|
|
*/
|
|
|
|
for (phase = PROXY_CALCSIZE; phase <= PROXY_UNMARSHAL; phase++)
|
2006-01-05 12:19:05 +01:00
|
|
|
{
|
2008-01-17 13:25:52 +01:00
|
|
|
TRACE("phase = %d\n", phase);
|
|
|
|
switch (phase)
|
2006-01-05 12:19:05 +01:00
|
|
|
{
|
2008-01-17 13:25:52 +01:00
|
|
|
case PROXY_GETBUFFER:
|
|
|
|
/* allocate the buffer */
|
|
|
|
if (Oif_flags.HasPipes)
|
|
|
|
/* NdrGetPipeBuffer(...) */
|
|
|
|
FIXME("pipes not supported yet\n");
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (pProcHeader->handle_type == RPC_FC_AUTO_HANDLE)
|
2006-01-05 12:19:05 +01:00
|
|
|
#if 0
|
2008-01-17 13:25:52 +01:00
|
|
|
NdrNsGetBuffer(&stubMsg, stubMsg.BufferLength, hBinding);
|
2006-01-05 12:19:05 +01:00
|
|
|
#else
|
2008-01-17 13:25:52 +01:00
|
|
|
FIXME("using auto handle - call NdrNsGetBuffer when it gets implemented\n");
|
2006-01-05 12:19:05 +01:00
|
|
|
#endif
|
2008-01-17 13:25:52 +01:00
|
|
|
else
|
|
|
|
NdrGetBuffer(&stubMsg, stubMsg.BufferLength, hBinding);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case PROXY_SENDRECEIVE:
|
|
|
|
/* send the [in] params and receive the [out] and [retval]
|
|
|
|
* params */
|
|
|
|
if (Oif_flags.HasPipes)
|
|
|
|
/* NdrPipesSendReceive(...) */
|
|
|
|
FIXME("pipes not supported yet\n");
|
2006-01-05 12:19:05 +01:00
|
|
|
else
|
2008-01-17 13:25:52 +01:00
|
|
|
{
|
|
|
|
if (pProcHeader->handle_type == RPC_FC_AUTO_HANDLE)
|
2006-01-05 12:19:05 +01:00
|
|
|
#if 0
|
2008-01-17 13:25:52 +01:00
|
|
|
NdrNsSendReceive(&stubMsg, stubMsg.Buffer, pStubDesc->IMPLICIT_HANDLE_INFO.pAutoHandle);
|
2006-01-05 12:19:05 +01:00
|
|
|
#else
|
2008-01-17 13:25:52 +01:00
|
|
|
FIXME("using auto handle - call NdrNsSendReceive when it gets implemented\n");
|
2006-01-05 12:19:05 +01:00
|
|
|
#endif
|
2008-01-17 13:25:52 +01:00
|
|
|
else
|
|
|
|
NdrSendReceive(&stubMsg, stubMsg.Buffer);
|
|
|
|
}
|
2006-01-05 12:19:05 +01:00
|
|
|
|
2008-01-17 13:25:52 +01:00
|
|
|
/* convert strings, floating point values and endianess into our
|
|
|
|
* preferred format */
|
|
|
|
if ((rpcMsg.DataRepresentation & 0x0000FFFFUL) != NDR_LOCAL_DATA_REPRESENTATION)
|
|
|
|
NdrConvert(&stubMsg, pFormat);
|
2006-01-05 12:19:05 +01:00
|
|
|
|
2008-01-17 13:25:52 +01:00
|
|
|
break;
|
|
|
|
case PROXY_CALCSIZE:
|
|
|
|
case PROXY_MARSHAL:
|
|
|
|
case PROXY_UNMARSHAL:
|
|
|
|
if (bV2Format)
|
2007-11-05 12:16:43 +01:00
|
|
|
client_do_args(&stubMsg, pFormat, phase, stubMsg.StackTop,
|
|
|
|
number_of_params, (unsigned char *)&RetVal);
|
2008-01-17 13:25:52 +01:00
|
|
|
else
|
2007-11-05 12:16:43 +01:00
|
|
|
client_do_args_old_format(&stubMsg, pFormat, phase,
|
|
|
|
stubMsg.StackTop, stack_size, (unsigned char *)&RetVal,
|
2008-04-24 15:30:59 +02:00
|
|
|
(pProcHeader->Oi_flags & RPC_FC_PROC_OIF_OBJECT), FALSE);
|
2008-01-17 13:25:52 +01:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
ERR("shouldn't reach here. phase %d\n", phase);
|
|
|
|
break;
|
|
|
|
}
|
2006-01-05 12:19:05 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-04-20 12:44:41 +02:00
|
|
|
if (ext_flags.HasNewCorrDesc)
|
2006-01-05 12:19:05 +01:00
|
|
|
{
|
|
|
|
/* free extra correlation package */
|
2008-01-07 16:20:25 +01:00
|
|
|
NdrCorrelationFree(&stubMsg);
|
2006-01-05 12:19:05 +01:00
|
|
|
}
|
|
|
|
|
2006-04-20 12:44:27 +02:00
|
|
|
if (Oif_flags.HasPipes)
|
2006-01-05 12:19:05 +01:00
|
|
|
{
|
|
|
|
/* NdrPipesDone(...) */
|
|
|
|
}
|
|
|
|
|
|
|
|
/* free the full pointer translation tables */
|
|
|
|
if (pProcHeader->Oi_flags & RPC_FC_PROC_OIF_FULLPTR)
|
|
|
|
NdrFullPointerXlatFree(stubMsg.FullPtrXlatTables);
|
|
|
|
|
|
|
|
/* free marshalling buffer */
|
|
|
|
if (pProcHeader->Oi_flags & RPC_FC_PROC_OIF_OBJECT)
|
|
|
|
NdrProxyFreeBuffer(This, &stubMsg);
|
|
|
|
else
|
2006-05-25 00:03:54 +02:00
|
|
|
{
|
2006-01-05 12:19:05 +01:00
|
|
|
NdrFreeBuffer(&stubMsg);
|
2006-05-25 00:03:54 +02:00
|
|
|
client_free_handle(&stubMsg, pProcHeader, pHandleFormat, hBinding);
|
|
|
|
}
|
2006-01-05 12:19:05 +01:00
|
|
|
|
|
|
|
TRACE("RetVal = 0x%lx\n", RetVal);
|
|
|
|
|
|
|
|
return RetVal;
|
|
|
|
}
|
|
|
|
|
2008-04-11 04:17:14 +02:00
|
|
|
/* Calls a function with the specified arguments, restoring the stack
|
2006-01-05 12:19:05 +01:00
|
|
|
* properly afterwards as we don't know the calling convention of the
|
|
|
|
* function */
|
|
|
|
#if defined __i386__ && defined _MSC_VER
|
|
|
|
__declspec(naked) LONG_PTR __cdecl call_server_func(SERVER_ROUTINE func, unsigned char * args, unsigned int stack_size)
|
|
|
|
{
|
|
|
|
__asm
|
|
|
|
{
|
|
|
|
push ebp
|
|
|
|
push edi ; Save registers
|
|
|
|
push esi
|
|
|
|
mov ebp, esp
|
|
|
|
mov eax, [ebp+16] ; Get stack size
|
|
|
|
sub esp, eax ; Make room in stack for arguments
|
|
|
|
mov edi, esp
|
|
|
|
mov ecx, eax
|
|
|
|
mov esi, [ebp+12]
|
|
|
|
shr ecx, 2
|
|
|
|
cld
|
|
|
|
rep movsd ; Copy dword blocks
|
|
|
|
call [ebp+8] ; Call function
|
|
|
|
lea esp, [ebp-8] ; Restore stack
|
2006-04-20 12:42:03 +02:00
|
|
|
pop esi ; Restore registers
|
2006-01-05 12:19:05 +01:00
|
|
|
pop edi
|
2006-04-20 12:42:03 +02:00
|
|
|
pop ebp
|
2006-01-05 12:19:05 +01:00
|
|
|
ret
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#elif defined __i386__ && defined __GNUC__
|
|
|
|
LONG_PTR __cdecl call_server_func(SERVER_ROUTINE func, unsigned char * args, unsigned int stack_size);
|
|
|
|
__ASM_GLOBAL_FUNC(call_server_func,
|
|
|
|
"pushl %ebp\n\t"
|
|
|
|
"movl %esp, %ebp\n\t"
|
|
|
|
"pushl %edi\n\t" /* Save registers */
|
|
|
|
"pushl %esi\n\t"
|
|
|
|
"movl 16(%ebp), %eax\n\t" /* Get stack size */
|
|
|
|
"subl %eax, %esp\n\t" /* Make room in stack for arguments */
|
2006-12-04 19:55:35 +01:00
|
|
|
"andl $~15, %esp\n\t" /* Make sure stack has 16-byte alignment for Mac OS X */
|
2006-01-05 12:19:05 +01:00
|
|
|
"movl %esp, %edi\n\t"
|
|
|
|
"movl %eax, %ecx\n\t"
|
|
|
|
"movl 12(%ebp), %esi\n\t"
|
|
|
|
"shrl $2, %ecx\n\t" /* divide by 4 */
|
|
|
|
"cld\n\t"
|
2006-01-14 17:07:28 +01:00
|
|
|
"rep; movsl\n\t" /* Copy dword blocks */
|
2006-01-05 12:19:05 +01:00
|
|
|
"call *8(%ebp)\n\t" /* Call function */
|
|
|
|
"leal -8(%ebp), %esp\n\t" /* Restore stack */
|
|
|
|
"popl %esi\n\t" /* Restore registers */
|
|
|
|
"popl %edi\n\t"
|
|
|
|
"popl %ebp\n\t"
|
2007-01-13 00:38:07 +01:00
|
|
|
"ret\n" )
|
2006-01-05 12:19:05 +01:00
|
|
|
#else
|
|
|
|
#warning call_server_func not implemented for your architecture
|
|
|
|
LONG_PTR __cdecl call_server_func(SERVER_ROUTINE func, unsigned char * args, unsigned short stack_size)
|
2002-10-10 21:23:33 +02:00
|
|
|
{
|
2006-01-05 12:19:05 +01:00
|
|
|
FIXME("Not implemented for your architecture\n");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2006-06-16 11:32:27 +02:00
|
|
|
static DWORD calc_arg_size(MIDL_STUB_MESSAGE *pStubMsg, PFORMAT_STRING pFormat)
|
|
|
|
{
|
|
|
|
DWORD size;
|
|
|
|
switch(*pFormat)
|
|
|
|
{
|
2006-06-23 13:47:34 +02:00
|
|
|
case RPC_FC_STRUCT:
|
|
|
|
size = *(const WORD*)(pFormat + 2);
|
|
|
|
break;
|
2006-06-16 11:32:27 +02:00
|
|
|
case RPC_FC_CARRAY:
|
|
|
|
size = *(const WORD*)(pFormat + 2);
|
|
|
|
ComputeConformance(pStubMsg, NULL, pFormat + 4, 0);
|
|
|
|
size *= pStubMsg->MaxCount;
|
|
|
|
break;
|
2006-08-09 19:16:56 +02:00
|
|
|
case RPC_FC_SMFARRAY:
|
|
|
|
size = *(const WORD*)(pFormat + 2);
|
|
|
|
break;
|
|
|
|
case RPC_FC_LGFARRAY:
|
|
|
|
size = *(const DWORD*)(pFormat + 2);
|
|
|
|
break;
|
2008-01-14 12:54:32 +01:00
|
|
|
case RPC_FC_BOGUS_ARRAY:
|
|
|
|
pFormat = ComputeConformance(pStubMsg, NULL, pFormat + 4, *(const WORD*)&pFormat[2]);
|
|
|
|
TRACE("conformance = %ld\n", pStubMsg->MaxCount);
|
|
|
|
pFormat = ComputeVariance(pStubMsg, NULL, pFormat, pStubMsg->MaxCount);
|
|
|
|
size = ComplexStructSize(pStubMsg, pFormat);
|
|
|
|
size *= pStubMsg->MaxCount;
|
2008-01-14 12:56:13 +01:00
|
|
|
break;
|
2006-06-16 11:32:27 +02:00
|
|
|
default:
|
|
|
|
FIXME("Unhandled type %02x\n", *pFormat);
|
|
|
|
/* fallthrough */
|
|
|
|
case RPC_FC_RP:
|
|
|
|
size = sizeof(void *);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return size;
|
|
|
|
}
|
|
|
|
|
2007-11-02 20:09:23 +01:00
|
|
|
static LONG_PTR *stub_do_args(MIDL_STUB_MESSAGE *pStubMsg,
|
|
|
|
PFORMAT_STRING pFormat, int phase,
|
|
|
|
unsigned char *args,
|
|
|
|
unsigned short number_of_params)
|
|
|
|
{
|
|
|
|
/* counter */
|
|
|
|
unsigned short i;
|
|
|
|
/* current format string offset */
|
|
|
|
int current_offset = 0;
|
|
|
|
/* current stack offset */
|
|
|
|
unsigned short current_stack_offset = 0;
|
|
|
|
/* location to put retval into */
|
|
|
|
LONG_PTR *retval_ptr = NULL;
|
|
|
|
|
|
|
|
for (i = 0; i < number_of_params; i++)
|
|
|
|
{
|
|
|
|
const NDR_PARAM_OIF_BASETYPE *pParam =
|
|
|
|
(const NDR_PARAM_OIF_BASETYPE *)&pFormat[current_offset];
|
|
|
|
unsigned char *pArg;
|
|
|
|
|
|
|
|
current_stack_offset = pParam->stack_offset;
|
2008-01-16 22:57:31 +01:00
|
|
|
pArg = args + current_stack_offset;
|
2007-11-02 20:09:23 +01:00
|
|
|
|
|
|
|
TRACE("param[%d]: new format\n", i);
|
|
|
|
TRACE("\tparam_attributes:"); dump_RPC_FC_PROC_PF(pParam->param_attributes); TRACE("\n");
|
|
|
|
TRACE("\tstack_offset: 0x%x\n", current_stack_offset);
|
|
|
|
TRACE("\tmemory addr (before): %p -> %p\n", pArg, *(unsigned char **)pArg);
|
|
|
|
|
|
|
|
if (pParam->param_attributes.IsBasetype)
|
|
|
|
{
|
|
|
|
const unsigned char *pTypeFormat =
|
|
|
|
&pParam->type_format_char;
|
|
|
|
|
|
|
|
TRACE("\tbase type: 0x%02x\n", *pTypeFormat);
|
|
|
|
|
2008-01-15 21:55:40 +01:00
|
|
|
/* make a note of the address of the return value parameter for later */
|
|
|
|
if (pParam->param_attributes.IsReturn)
|
|
|
|
retval_ptr = (LONG_PTR *)pArg;
|
|
|
|
|
2007-11-02 20:09:23 +01:00
|
|
|
switch (phase)
|
|
|
|
{
|
|
|
|
case STUBLESS_MARSHAL:
|
|
|
|
if (pParam->param_attributes.IsOut || pParam->param_attributes.IsReturn)
|
|
|
|
{
|
|
|
|
if (pParam->param_attributes.IsSimpleRef)
|
|
|
|
call_marshaller(pStubMsg, *(unsigned char **)pArg, pTypeFormat);
|
|
|
|
else
|
|
|
|
call_marshaller(pStubMsg, pArg, pTypeFormat);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case STUBLESS_FREE:
|
|
|
|
if (pParam->param_attributes.ServerAllocSize)
|
|
|
|
HeapFree(GetProcessHeap(), 0, *(void **)pArg);
|
|
|
|
break;
|
2008-01-14 12:56:13 +01:00
|
|
|
case STUBLESS_INITOUT:
|
|
|
|
break;
|
2007-11-02 20:09:23 +01:00
|
|
|
case STUBLESS_UNMARSHAL:
|
|
|
|
if (pParam->param_attributes.ServerAllocSize)
|
|
|
|
*(void **)pArg = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
|
|
|
|
pParam->param_attributes.ServerAllocSize * 8);
|
|
|
|
|
|
|
|
if (pParam->param_attributes.IsIn)
|
|
|
|
{
|
|
|
|
if (pParam->param_attributes.IsSimpleRef)
|
|
|
|
call_unmarshaller(pStubMsg, (unsigned char **)pArg, pTypeFormat, 0);
|
|
|
|
else
|
|
|
|
call_unmarshaller(pStubMsg, &pArg, pTypeFormat, 0);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case STUBLESS_CALCSIZE:
|
|
|
|
if (pParam->param_attributes.IsOut || pParam->param_attributes.IsReturn)
|
|
|
|
{
|
|
|
|
if (pParam->param_attributes.IsSimpleRef)
|
|
|
|
call_buffer_sizer(pStubMsg, *(unsigned char **)pArg, pTypeFormat);
|
|
|
|
else
|
|
|
|
call_buffer_sizer(pStubMsg, pArg, pTypeFormat);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
RpcRaiseException(RPC_S_INTERNAL_ERROR);
|
|
|
|
}
|
|
|
|
|
|
|
|
current_offset += sizeof(NDR_PARAM_OIF_BASETYPE);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
const NDR_PARAM_OIF_OTHER *pParamOther =
|
|
|
|
(const NDR_PARAM_OIF_OTHER *)&pFormat[current_offset];
|
|
|
|
|
|
|
|
const unsigned char * pTypeFormat =
|
|
|
|
&(pStubMsg->StubDesc->pFormatTypes[pParamOther->type_offset]);
|
|
|
|
|
|
|
|
TRACE("\tcomplex type 0x%02x\n", *pTypeFormat);
|
|
|
|
|
|
|
|
switch (phase)
|
|
|
|
{
|
|
|
|
case STUBLESS_MARSHAL:
|
|
|
|
if (pParam->param_attributes.IsOut || pParam->param_attributes.IsReturn)
|
|
|
|
{
|
|
|
|
if (pParam->param_attributes.IsByValue)
|
|
|
|
call_marshaller(pStubMsg, pArg, pTypeFormat);
|
|
|
|
else
|
|
|
|
call_marshaller(pStubMsg, *(unsigned char **)pArg, pTypeFormat);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case STUBLESS_FREE:
|
|
|
|
if (pParam->param_attributes.MustFree)
|
|
|
|
{
|
|
|
|
if (pParam->param_attributes.IsByValue)
|
|
|
|
call_freer(pStubMsg, pArg, pTypeFormat);
|
|
|
|
else
|
|
|
|
call_freer(pStubMsg, *(unsigned char **)pArg, pTypeFormat);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (pParam->param_attributes.IsOut &&
|
|
|
|
!pParam->param_attributes.IsIn &&
|
|
|
|
!pParam->param_attributes.IsByValue &&
|
|
|
|
!pParam->param_attributes.ServerAllocSize)
|
|
|
|
{
|
|
|
|
pStubMsg->pfnFree(*(void **)pArg);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (pParam->param_attributes.ServerAllocSize)
|
|
|
|
HeapFree(GetProcessHeap(), 0, *(void **)pArg);
|
2008-01-14 12:56:13 +01:00
|
|
|
break;
|
|
|
|
case STUBLESS_INITOUT:
|
|
|
|
if (!pParam->param_attributes.IsIn &&
|
|
|
|
pParam->param_attributes.IsOut &&
|
|
|
|
!pParam->param_attributes.ServerAllocSize &&
|
|
|
|
!pParam->param_attributes.IsByValue)
|
|
|
|
{
|
|
|
|
DWORD size = calc_arg_size(pStubMsg, pTypeFormat);
|
|
|
|
|
|
|
|
if(size)
|
|
|
|
{
|
|
|
|
*(void **)pArg = NdrAllocate(pStubMsg, size);
|
|
|
|
memset(*(void **)pArg, 0, size);
|
|
|
|
}
|
|
|
|
}
|
2007-11-02 20:09:23 +01:00
|
|
|
break;
|
|
|
|
case STUBLESS_UNMARSHAL:
|
|
|
|
if (pParam->param_attributes.ServerAllocSize)
|
|
|
|
*(void **)pArg = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
|
|
|
|
pParam->param_attributes.ServerAllocSize * 8);
|
|
|
|
|
|
|
|
if (pParam->param_attributes.IsIn)
|
|
|
|
{
|
|
|
|
if (pParam->param_attributes.IsByValue)
|
|
|
|
call_unmarshaller(pStubMsg, &pArg, pTypeFormat, 0);
|
|
|
|
else
|
|
|
|
call_unmarshaller(pStubMsg, (unsigned char **)pArg, pTypeFormat, 0);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case STUBLESS_CALCSIZE:
|
|
|
|
if (pParam->param_attributes.IsOut || pParam->param_attributes.IsReturn)
|
|
|
|
{
|
|
|
|
if (pParam->param_attributes.IsByValue)
|
|
|
|
call_buffer_sizer(pStubMsg, pArg, pTypeFormat);
|
|
|
|
else
|
|
|
|
call_buffer_sizer(pStubMsg, *(unsigned char **)pArg, pTypeFormat);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
RpcRaiseException(RPC_S_INTERNAL_ERROR);
|
|
|
|
}
|
|
|
|
|
|
|
|
current_offset += sizeof(NDR_PARAM_OIF_OTHER);
|
|
|
|
}
|
|
|
|
TRACE("\tmemory addr (after): %p -> %p\n", pArg, *(unsigned char **)pArg);
|
|
|
|
}
|
|
|
|
|
|
|
|
return retval_ptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
static LONG_PTR *stub_do_old_args(MIDL_STUB_MESSAGE *pStubMsg,
|
|
|
|
PFORMAT_STRING pFormat, int phase,
|
|
|
|
unsigned char *args,
|
|
|
|
unsigned short stack_size, BOOL object)
|
|
|
|
{
|
|
|
|
/* counter */
|
|
|
|
unsigned short i;
|
|
|
|
/* current format string offset */
|
|
|
|
int current_offset = 0;
|
|
|
|
/* current stack offset */
|
|
|
|
unsigned short current_stack_offset = 0;
|
|
|
|
/* location to put retval into */
|
|
|
|
LONG_PTR *retval_ptr = NULL;
|
|
|
|
|
|
|
|
for (i = 0; TRUE; i++)
|
|
|
|
{
|
|
|
|
const NDR_PARAM_OI_BASETYPE *pParam =
|
|
|
|
(const NDR_PARAM_OI_BASETYPE *)&pFormat[current_offset];
|
|
|
|
/* note: current_stack_offset starts after the This pointer
|
|
|
|
* if present, so adjust this */
|
|
|
|
unsigned short current_stack_offset_adjusted = current_stack_offset +
|
|
|
|
(object ? sizeof(void *) : 0);
|
2008-01-16 22:57:31 +01:00
|
|
|
unsigned char *pArg = args + current_stack_offset_adjusted;
|
2007-11-02 20:09:23 +01:00
|
|
|
|
|
|
|
/* no more parameters; exit loop */
|
|
|
|
if (current_stack_offset_adjusted >= stack_size)
|
|
|
|
break;
|
|
|
|
|
|
|
|
TRACE("param[%d]: old format\n", i);
|
|
|
|
TRACE("\tparam_direction: 0x%x\n", pParam->param_direction);
|
|
|
|
TRACE("\tstack_offset: 0x%x\n", current_stack_offset_adjusted);
|
|
|
|
|
|
|
|
if (pParam->param_direction == RPC_FC_IN_PARAM_BASETYPE ||
|
|
|
|
pParam->param_direction == RPC_FC_RETURN_PARAM_BASETYPE)
|
|
|
|
{
|
|
|
|
const unsigned char *pTypeFormat =
|
|
|
|
&pParam->type_format_char;
|
|
|
|
|
|
|
|
TRACE("\tbase type 0x%02x\n", *pTypeFormat);
|
|
|
|
|
2008-01-15 21:55:40 +01:00
|
|
|
if (pParam->param_direction == RPC_FC_RETURN_PARAM_BASETYPE)
|
|
|
|
retval_ptr = (LONG_PTR *)pArg;
|
|
|
|
|
2007-11-02 20:09:23 +01:00
|
|
|
switch (phase)
|
|
|
|
{
|
|
|
|
case STUBLESS_MARSHAL:
|
|
|
|
if (pParam->param_direction == RPC_FC_RETURN_PARAM_BASETYPE)
|
|
|
|
call_marshaller(pStubMsg, pArg, pTypeFormat);
|
|
|
|
break;
|
|
|
|
case STUBLESS_FREE:
|
|
|
|
if (pParam->param_direction == RPC_FC_IN_PARAM_BASETYPE)
|
|
|
|
call_freer(pStubMsg, pArg, pTypeFormat);
|
|
|
|
break;
|
|
|
|
case STUBLESS_UNMARSHAL:
|
|
|
|
if (pParam->param_direction == RPC_FC_IN_PARAM_BASETYPE)
|
|
|
|
call_unmarshaller(pStubMsg, &pArg, pTypeFormat, 0);
|
2008-01-15 21:55:40 +01:00
|
|
|
break;
|
2007-11-02 20:09:23 +01:00
|
|
|
case STUBLESS_CALCSIZE:
|
|
|
|
if (pParam->param_direction == RPC_FC_RETURN_PARAM_BASETYPE)
|
|
|
|
call_buffer_sizer(pStubMsg, pArg, pTypeFormat);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
RpcRaiseException(RPC_S_INTERNAL_ERROR);
|
|
|
|
}
|
|
|
|
|
2008-03-10 18:05:59 +01:00
|
|
|
current_stack_offset += type_stack_size(*pTypeFormat);
|
2007-11-02 20:09:23 +01:00
|
|
|
current_offset += sizeof(NDR_PARAM_OI_BASETYPE);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
const NDR_PARAM_OI_OTHER *pParamOther =
|
|
|
|
(const NDR_PARAM_OI_OTHER *)&pFormat[current_offset];
|
|
|
|
|
|
|
|
const unsigned char * pTypeFormat =
|
|
|
|
&pStubMsg->StubDesc->pFormatTypes[pParamOther->type_offset];
|
|
|
|
|
|
|
|
TRACE("\tcomplex type 0x%02x\n", *pTypeFormat);
|
|
|
|
|
2008-01-15 21:55:40 +01:00
|
|
|
if (pParam->param_direction == RPC_FC_RETURN_PARAM)
|
|
|
|
retval_ptr = (LONG_PTR *)pArg;
|
|
|
|
|
2007-11-02 20:09:23 +01:00
|
|
|
switch (phase)
|
|
|
|
{
|
|
|
|
case STUBLESS_MARSHAL:
|
|
|
|
if (pParam->param_direction == RPC_FC_OUT_PARAM ||
|
|
|
|
pParam->param_direction == RPC_FC_IN_OUT_PARAM ||
|
|
|
|
pParam->param_direction == RPC_FC_RETURN_PARAM)
|
|
|
|
call_marshaller(pStubMsg, *(unsigned char **)pArg, pTypeFormat);
|
|
|
|
break;
|
|
|
|
case STUBLESS_FREE:
|
|
|
|
if (pParam->param_direction == RPC_FC_IN_OUT_PARAM ||
|
|
|
|
pParam->param_direction == RPC_FC_IN_PARAM)
|
|
|
|
call_freer(pStubMsg, *(unsigned char **)pArg, pTypeFormat);
|
|
|
|
else if (pParam->param_direction == RPC_FC_OUT_PARAM)
|
|
|
|
pStubMsg->pfnFree(*(void **)pArg);
|
2008-01-14 12:56:13 +01:00
|
|
|
break;
|
|
|
|
case STUBLESS_INITOUT:
|
|
|
|
if (pParam->param_direction == RPC_FC_OUT_PARAM)
|
2007-11-02 20:09:23 +01:00
|
|
|
{
|
|
|
|
DWORD size = calc_arg_size(pStubMsg, pTypeFormat);
|
|
|
|
|
|
|
|
if(size)
|
|
|
|
{
|
|
|
|
*(void **)pArg = NdrAllocate(pStubMsg, size);
|
|
|
|
memset(*(void **)pArg, 0, size);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
2008-01-14 12:56:13 +01:00
|
|
|
case STUBLESS_UNMARSHAL:
|
|
|
|
if (pParam->param_direction == RPC_FC_IN_OUT_PARAM ||
|
|
|
|
pParam->param_direction == RPC_FC_IN_PARAM)
|
|
|
|
call_unmarshaller(pStubMsg, (unsigned char **)pArg, pTypeFormat, 0);
|
|
|
|
break;
|
2007-11-02 20:09:23 +01:00
|
|
|
case STUBLESS_CALCSIZE:
|
|
|
|
if (pParam->param_direction == RPC_FC_OUT_PARAM ||
|
|
|
|
pParam->param_direction == RPC_FC_IN_OUT_PARAM ||
|
|
|
|
pParam->param_direction == RPC_FC_RETURN_PARAM)
|
|
|
|
call_buffer_sizer(pStubMsg, *(unsigned char **)pArg, pTypeFormat);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
RpcRaiseException(RPC_S_INTERNAL_ERROR);
|
|
|
|
}
|
|
|
|
|
|
|
|
current_stack_offset += pParamOther->stack_size * sizeof(INT);
|
|
|
|
current_offset += sizeof(NDR_PARAM_OI_OTHER);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return retval_ptr;
|
|
|
|
}
|
|
|
|
|
2007-11-02 20:08:57 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* NdrStubCall2 [RPCRT4.@]
|
|
|
|
*
|
|
|
|
* Unmarshals [in] parameters, calls either a method in an object or a server
|
|
|
|
* function, marshals any [out] parameters and frees any allocated data.
|
|
|
|
*
|
|
|
|
* NOTES
|
|
|
|
* Used by stubless MIDL-generated code.
|
|
|
|
*/
|
2006-11-09 23:02:09 +01:00
|
|
|
LONG WINAPI NdrStubCall2(
|
2006-01-05 12:19:05 +01:00
|
|
|
struct IRpcStubBuffer * pThis,
|
|
|
|
struct IRpcChannelBuffer * pChannel,
|
|
|
|
PRPC_MESSAGE pRpcMsg,
|
2006-11-09 23:02:09 +01:00
|
|
|
DWORD * pdwStubPhase)
|
2006-01-05 12:19:05 +01:00
|
|
|
{
|
|
|
|
const MIDL_SERVER_INFO *pServerInfo;
|
|
|
|
const MIDL_STUB_DESC *pStubDesc;
|
|
|
|
PFORMAT_STRING pFormat;
|
|
|
|
MIDL_STUB_MESSAGE stubMsg;
|
|
|
|
/* pointer to start of stack to pass into stub implementation */
|
|
|
|
unsigned char * args;
|
|
|
|
/* size of stack */
|
|
|
|
unsigned short stack_size;
|
|
|
|
/* number of parameters. optional for client to give it to us */
|
|
|
|
unsigned char number_of_params = ~0;
|
|
|
|
/* cache of Oif_flags from v2 procedure header */
|
2006-04-20 12:44:27 +02:00
|
|
|
INTERPRETER_OPT_FLAGS Oif_flags = { 0 };
|
2006-04-20 12:44:41 +02:00
|
|
|
/* cache of extension flags from NDR_PROC_HEADER_EXTS */
|
|
|
|
INTERPRETER_OPT_FLAGS2 ext_flags = { 0 };
|
2006-01-05 12:19:05 +01:00
|
|
|
/* the type of pass we are currently doing */
|
|
|
|
int phase;
|
|
|
|
/* header for procedure string */
|
|
|
|
const NDR_PROC_HEADER *pProcHeader;
|
|
|
|
/* offset in format string for start of params */
|
|
|
|
int parameter_start_offset;
|
|
|
|
/* current format string offset */
|
|
|
|
int current_offset;
|
|
|
|
/* -Oif or -Oicf generated format */
|
|
|
|
BOOL bV2Format = FALSE;
|
2006-04-20 12:43:22 +02:00
|
|
|
/* location to put retval into */
|
|
|
|
LONG_PTR *retval_ptr = NULL;
|
2006-01-05 12:19:05 +01:00
|
|
|
|
|
|
|
TRACE("pThis %p, pChannel %p, pRpcMsg %p, pdwStubPhase %p\n", pThis, pChannel, pRpcMsg, pdwStubPhase);
|
|
|
|
|
|
|
|
if (pThis)
|
|
|
|
pServerInfo = CStdStubBuffer_GetServerInfo(pThis);
|
|
|
|
else
|
|
|
|
pServerInfo = ((RPC_SERVER_INTERFACE *)pRpcMsg->RpcInterfaceInformation)->InterpreterInfo;
|
|
|
|
|
|
|
|
pStubDesc = pServerInfo->pStubDesc;
|
|
|
|
pFormat = pServerInfo->ProcString + pServerInfo->FmtStringOffset[pRpcMsg->ProcNum];
|
|
|
|
pProcHeader = (const NDR_PROC_HEADER *)&pFormat[0];
|
|
|
|
|
|
|
|
/* Later NDR language versions probably won't be backwards compatible */
|
|
|
|
if (pStubDesc->Version > 0x50002)
|
|
|
|
{
|
2006-11-09 23:04:48 +01:00
|
|
|
FIXME("Incompatible stub description version: 0x%x\n", pStubDesc->Version);
|
2006-01-05 12:19:05 +01:00
|
|
|
RpcRaiseException(RPC_X_WRONG_STUB_VERSION);
|
|
|
|
}
|
|
|
|
|
2006-06-07 21:11:36 +02:00
|
|
|
/* create the full pointer translation tables, if requested */
|
|
|
|
if (pProcHeader->Oi_flags & RPC_FC_PROC_OIF_FULLPTR)
|
|
|
|
stubMsg.FullPtrXlatTables = NdrFullPointerXlatInit(0,XLAT_SERVER);
|
|
|
|
|
2006-01-05 12:19:05 +01:00
|
|
|
if (pProcHeader->Oi_flags & RPC_FC_PROC_OIF_RPCFLAGS)
|
|
|
|
{
|
2006-09-25 22:25:45 +02:00
|
|
|
const NDR_PROC_HEADER_RPC *pProcHeader = (const NDR_PROC_HEADER_RPC *)&pFormat[0];
|
2006-01-05 12:19:05 +01:00
|
|
|
stack_size = pProcHeader->stack_size;
|
|
|
|
current_offset = sizeof(NDR_PROC_HEADER_RPC);
|
|
|
|
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
stack_size = pProcHeader->stack_size;
|
|
|
|
current_offset = sizeof(NDR_PROC_HEADER);
|
|
|
|
}
|
|
|
|
|
|
|
|
TRACE("Oi_flags = 0x%02x\n", pProcHeader->Oi_flags);
|
|
|
|
|
|
|
|
/* binding */
|
|
|
|
switch (pProcHeader->handle_type)
|
|
|
|
{
|
|
|
|
/* explicit binding: parse additional section */
|
|
|
|
case RPC_FC_BIND_EXPLICIT:
|
|
|
|
switch (pFormat[current_offset]) /* handle_type */
|
|
|
|
{
|
|
|
|
case RPC_FC_BIND_PRIMITIVE: /* explicit primitive */
|
|
|
|
current_offset += sizeof(NDR_EHD_PRIMITIVE);
|
|
|
|
break;
|
|
|
|
case RPC_FC_BIND_GENERIC: /* explicit generic */
|
|
|
|
current_offset += sizeof(NDR_EHD_GENERIC);
|
|
|
|
break;
|
|
|
|
case RPC_FC_BIND_CONTEXT: /* explicit context */
|
|
|
|
current_offset += sizeof(NDR_EHD_CONTEXT);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
ERR("bad explicit binding handle type (0x%02x)\n", pProcHeader->handle_type);
|
|
|
|
RpcRaiseException(RPC_X_BAD_STUB_DATA);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case RPC_FC_BIND_GENERIC: /* implicit generic */
|
|
|
|
case RPC_FC_BIND_PRIMITIVE: /* implicit primitive */
|
|
|
|
case RPC_FC_CALLBACK_HANDLE: /* implicit callback */
|
|
|
|
case RPC_FC_AUTO_HANDLE: /* implicit auto handle */
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
ERR("bad implicit binding handle type (0x%02x)\n", pProcHeader->handle_type);
|
|
|
|
RpcRaiseException(RPC_X_BAD_STUB_DATA);
|
|
|
|
}
|
|
|
|
|
|
|
|
bV2Format = (pStubDesc->Version >= 0x20000);
|
2002-10-10 21:23:33 +02:00
|
|
|
|
2006-01-05 12:19:05 +01:00
|
|
|
if (bV2Format)
|
|
|
|
{
|
2006-09-25 22:25:45 +02:00
|
|
|
const NDR_PROC_PARTIAL_OIF_HEADER *pOIFHeader =
|
|
|
|
(const NDR_PROC_PARTIAL_OIF_HEADER *)&pFormat[current_offset];
|
2002-10-10 21:23:33 +02:00
|
|
|
|
2006-04-20 12:44:27 +02:00
|
|
|
Oif_flags = pOIFHeader->Oi2Flags;
|
2006-01-05 12:19:05 +01:00
|
|
|
number_of_params = pOIFHeader->number_of_params;
|
|
|
|
|
|
|
|
current_offset += sizeof(NDR_PROC_PARTIAL_OIF_HEADER);
|
|
|
|
}
|
|
|
|
|
2006-04-20 12:44:27 +02:00
|
|
|
TRACE("Oif_flags = "); dump_INTERPRETER_OPT_FLAGS(Oif_flags);
|
2006-01-05 12:19:05 +01:00
|
|
|
|
2006-04-20 12:44:27 +02:00
|
|
|
if (Oif_flags.HasExtensions)
|
2006-01-05 12:19:05 +01:00
|
|
|
{
|
2006-09-25 22:25:45 +02:00
|
|
|
const NDR_PROC_HEADER_EXTS *pExtensions =
|
|
|
|
(const NDR_PROC_HEADER_EXTS *)&pFormat[current_offset];
|
2006-04-20 12:44:41 +02:00
|
|
|
ext_flags = pExtensions->Flags2;
|
|
|
|
current_offset += pExtensions->Size;
|
2006-01-05 12:19:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if (pProcHeader->Oi_flags & RPC_FC_PROC_OIF_OBJECT)
|
|
|
|
NdrStubInitialize(pRpcMsg, &stubMsg, pStubDesc, pChannel);
|
|
|
|
else
|
|
|
|
NdrServerInitializeNew(pRpcMsg, &stubMsg, pStubDesc);
|
|
|
|
|
|
|
|
/* store the RPC flags away */
|
|
|
|
if (pProcHeader->Oi_flags & RPC_FC_PROC_OIF_RPCFLAGS)
|
2006-09-25 22:25:45 +02:00
|
|
|
pRpcMsg->RpcFlags = ((const NDR_PROC_HEADER_RPC *)pProcHeader)->rpc_flags;
|
2006-01-05 12:19:05 +01:00
|
|
|
|
|
|
|
/* use alternate memory allocation routines */
|
|
|
|
if (pProcHeader->Oi_flags & RPC_FC_PROC_OIF_RPCSSALLOC)
|
|
|
|
#if 0
|
|
|
|
NdrRpcSsEnableAllocate(&stubMsg);
|
|
|
|
#else
|
|
|
|
FIXME("Set RPCSS memory allocation routines\n");
|
|
|
|
#endif
|
|
|
|
|
2006-04-20 12:44:27 +02:00
|
|
|
if (Oif_flags.HasPipes)
|
2006-01-05 12:19:05 +01:00
|
|
|
{
|
|
|
|
FIXME("pipes not supported yet\n");
|
|
|
|
RpcRaiseException(RPC_X_WRONG_STUB_VERSION); /* FIXME: remove when implemented */
|
|
|
|
/* init pipes package */
|
|
|
|
/* NdrPipesInitialize(...) */
|
|
|
|
}
|
2006-04-20 12:44:41 +02:00
|
|
|
if (ext_flags.HasNewCorrDesc)
|
2006-01-05 12:19:05 +01:00
|
|
|
{
|
|
|
|
/* initialize extra correlation package */
|
|
|
|
FIXME("new correlation description not implemented\n");
|
|
|
|
stubMsg.fHasNewCorrDesc = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* convert strings, floating point values and endianess into our
|
|
|
|
* preferred format */
|
|
|
|
if ((pRpcMsg->DataRepresentation & 0x0000FFFFUL) != NDR_LOCAL_DATA_REPRESENTATION)
|
|
|
|
NdrConvert(&stubMsg, pFormat);
|
|
|
|
|
|
|
|
parameter_start_offset = current_offset;
|
|
|
|
|
|
|
|
TRACE("allocating memory for stack of size %x\n", stack_size);
|
|
|
|
|
2006-04-20 12:41:45 +02:00
|
|
|
args = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, stack_size);
|
|
|
|
stubMsg.StackTop = args; /* used by conformance of top-level objects */
|
2006-01-05 12:19:05 +01:00
|
|
|
|
|
|
|
/* add the implicit This pointer as the first arg to the function if we
|
|
|
|
* are calling an object method */
|
|
|
|
if (pThis)
|
|
|
|
*(void **)args = ((CStdStubBuffer *)pThis)->pvServerObject;
|
|
|
|
|
|
|
|
/* order of phases:
|
|
|
|
* 1. STUBLESS_UNMARHSAL - unmarshal [in] params from buffer
|
|
|
|
* 2. STUBLESS_CALLSERVER - send/receive buffer
|
|
|
|
* 3. STUBLESS_CALCSIZE - get [out] buffer size
|
|
|
|
* 4. STUBLESS_GETBUFFER - allocate [out] buffer
|
|
|
|
* 5. STUBLESS_MARHSAL - marshal [out] params to buffer
|
|
|
|
*/
|
2007-06-25 15:22:29 +02:00
|
|
|
for (phase = STUBLESS_UNMARSHAL; phase <= STUBLESS_FREE; phase++)
|
2006-01-05 12:19:05 +01:00
|
|
|
{
|
|
|
|
TRACE("phase = %d\n", phase);
|
|
|
|
switch (phase)
|
|
|
|
{
|
|
|
|
case STUBLESS_CALLSERVER:
|
|
|
|
/* call the server function */
|
2006-04-20 12:42:16 +02:00
|
|
|
if (pServerInfo->ThunkTable && pServerInfo->ThunkTable[pRpcMsg->ProcNum])
|
2006-01-05 12:19:05 +01:00
|
|
|
pServerInfo->ThunkTable[pRpcMsg->ProcNum](&stubMsg);
|
|
|
|
else
|
2006-04-20 12:43:22 +02:00
|
|
|
{
|
|
|
|
SERVER_ROUTINE func;
|
|
|
|
LONG_PTR retval;
|
|
|
|
|
|
|
|
if (pProcHeader->Oi_flags & RPC_FC_PROC_OIF_OBJECT)
|
|
|
|
{
|
|
|
|
SERVER_ROUTINE *vtbl = *(SERVER_ROUTINE **)((CStdStubBuffer *)pThis)->pvServerObject;
|
|
|
|
func = vtbl[pRpcMsg->ProcNum];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
func = pServerInfo->DispatchTable[pRpcMsg->ProcNum];
|
2006-01-05 12:19:05 +01:00
|
|
|
|
2006-04-20 12:43:22 +02:00
|
|
|
/* FIXME: what happens with return values that don't fit into a single register on x86? */
|
|
|
|
retval = call_server_func(func, args, stack_size);
|
|
|
|
|
|
|
|
if (retval_ptr)
|
|
|
|
{
|
|
|
|
TRACE("stub implementation returned 0x%lx\n", retval);
|
|
|
|
*retval_ptr = retval;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
TRACE("void stub implementation\n");
|
|
|
|
}
|
2006-01-05 12:19:05 +01:00
|
|
|
|
|
|
|
stubMsg.Buffer = NULL;
|
|
|
|
stubMsg.BufferLength = 0;
|
|
|
|
|
|
|
|
break;
|
|
|
|
case STUBLESS_GETBUFFER:
|
|
|
|
if (pProcHeader->Oi_flags & RPC_FC_PROC_OIF_OBJECT)
|
|
|
|
NdrStubGetBuffer(pThis, pChannel, &stubMsg);
|
|
|
|
else
|
|
|
|
{
|
|
|
|
RPC_STATUS Status;
|
|
|
|
|
|
|
|
pRpcMsg->BufferLength = stubMsg.BufferLength;
|
|
|
|
/* allocate buffer for [out] and [ret] params */
|
|
|
|
Status = I_RpcGetBuffer(pRpcMsg);
|
|
|
|
if (Status)
|
|
|
|
RpcRaiseException(Status);
|
2008-01-21 15:14:00 +01:00
|
|
|
stubMsg.Buffer = pRpcMsg->Buffer;
|
2006-01-05 12:19:05 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case STUBLESS_UNMARSHAL:
|
2008-01-14 12:56:13 +01:00
|
|
|
case STUBLESS_INITOUT:
|
2006-01-05 12:19:05 +01:00
|
|
|
case STUBLESS_CALCSIZE:
|
2008-01-14 12:56:13 +01:00
|
|
|
case STUBLESS_MARSHAL:
|
2007-06-25 15:22:29 +02:00
|
|
|
case STUBLESS_FREE:
|
2007-11-02 20:09:23 +01:00
|
|
|
if (bV2Format)
|
|
|
|
retval_ptr = stub_do_args(&stubMsg, &pFormat[parameter_start_offset],
|
|
|
|
phase, args, number_of_params);
|
|
|
|
else
|
|
|
|
retval_ptr = stub_do_old_args(&stubMsg, &pFormat[parameter_start_offset],
|
|
|
|
phase, args, stack_size,
|
|
|
|
(pProcHeader->Oi_flags & RPC_FC_PROC_OIF_OBJECT));
|
2006-01-05 12:19:05 +01:00
|
|
|
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
ERR("shouldn't reach here. phase %d\n", phase);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pRpcMsg->BufferLength = (unsigned int)(stubMsg.Buffer - (unsigned char *)pRpcMsg->Buffer);
|
|
|
|
|
2006-04-20 12:44:41 +02:00
|
|
|
if (ext_flags.HasNewCorrDesc)
|
2006-01-05 12:19:05 +01:00
|
|
|
{
|
|
|
|
/* free extra correlation package */
|
|
|
|
/* NdrCorrelationFree(&stubMsg); */
|
|
|
|
}
|
|
|
|
|
2006-04-20 12:44:27 +02:00
|
|
|
if (Oif_flags.HasPipes)
|
2006-01-05 12:19:05 +01:00
|
|
|
{
|
|
|
|
/* NdrPipesDone(...) */
|
|
|
|
}
|
|
|
|
|
|
|
|
/* free the full pointer translation tables */
|
|
|
|
if (pProcHeader->Oi_flags & RPC_FC_PROC_OIF_FULLPTR)
|
|
|
|
NdrFullPointerXlatFree(stubMsg.FullPtrXlatTables);
|
|
|
|
|
|
|
|
/* free server function stack */
|
|
|
|
HeapFree(GetProcessHeap(), 0, args);
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2007-11-13 09:31:51 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* NdrServerCall2 [RPCRT4.@]
|
|
|
|
*/
|
2006-01-05 12:19:05 +01:00
|
|
|
void WINAPI NdrServerCall2(PRPC_MESSAGE pRpcMsg)
|
|
|
|
{
|
|
|
|
DWORD dwPhase;
|
|
|
|
NdrStubCall2(NULL, NULL, pRpcMsg, &dwPhase);
|
2002-10-10 21:23:33 +02:00
|
|
|
}
|