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
|
|
|
*/
|
|
|
|
|
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"
|
2019-05-14 12:30:46 +02:00
|
|
|
#include "wine/asm.h"
|
2002-10-10 21:23:33 +02:00
|
|
|
#include "wine/debug.h"
|
|
|
|
|
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
|
|
|
|
|
2015-03-06 12:35:42 +01:00
|
|
|
static inline BOOL is_oicf_stubdesc(const PMIDL_STUB_DESC pStubDesc)
|
|
|
|
{
|
|
|
|
return pStubDesc->Version >= 0x20000;
|
|
|
|
}
|
|
|
|
|
2011-07-28 22:13:45 +02:00
|
|
|
static inline void call_buffer_sizer(PMIDL_STUB_MESSAGE pStubMsg, unsigned char *pMemory,
|
|
|
|
const NDR_PARAM_OIF *param)
|
2002-10-10 21:23:33 +02:00
|
|
|
{
|
2011-07-28 22:13:45 +02:00
|
|
|
PFORMAT_STRING pFormat;
|
|
|
|
NDR_BUFFERSIZE m;
|
|
|
|
|
|
|
|
if (param->attr.IsBasetype)
|
|
|
|
{
|
|
|
|
pFormat = ¶m->u.type_format_char;
|
|
|
|
if (param->attr.IsSimpleRef) pMemory = *(unsigned char **)pMemory;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
pFormat = &pStubMsg->StubDesc->pFormatTypes[param->u.type_offset];
|
|
|
|
if (!param->attr.IsByValue) pMemory = *(unsigned char **)pMemory;
|
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
|
2011-07-28 22:13:45 +02:00
|
|
|
static inline unsigned char *call_marshaller(PMIDL_STUB_MESSAGE pStubMsg, unsigned char *pMemory,
|
|
|
|
const NDR_PARAM_OIF *param)
|
2006-01-05 12:19:05 +01:00
|
|
|
{
|
2011-07-28 22:13:45 +02:00
|
|
|
PFORMAT_STRING pFormat;
|
|
|
|
NDR_MARSHALL m;
|
|
|
|
|
|
|
|
if (param->attr.IsBasetype)
|
|
|
|
{
|
|
|
|
pFormat = ¶m->u.type_format_char;
|
|
|
|
if (param->attr.IsSimpleRef) pMemory = *(unsigned char **)pMemory;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
pFormat = &pStubMsg->StubDesc->pFormatTypes[param->u.type_offset];
|
|
|
|
if (!param->attr.IsByValue) pMemory = *(unsigned char **)pMemory;
|
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2011-07-28 22:13:45 +02:00
|
|
|
static inline unsigned char *call_unmarshaller(PMIDL_STUB_MESSAGE pStubMsg, unsigned char **ppMemory,
|
|
|
|
const NDR_PARAM_OIF *param, unsigned char fMustAlloc)
|
2006-01-05 12:19:05 +01:00
|
|
|
{
|
2011-07-28 22:13:45 +02:00
|
|
|
PFORMAT_STRING pFormat;
|
|
|
|
NDR_UNMARSHALL m;
|
|
|
|
|
|
|
|
if (param->attr.IsBasetype)
|
|
|
|
{
|
|
|
|
pFormat = ¶m->u.type_format_char;
|
|
|
|
if (param->attr.IsSimpleRef) ppMemory = (unsigned char **)*ppMemory;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
pFormat = &pStubMsg->StubDesc->pFormatTypes[param->u.type_offset];
|
|
|
|
if (!param->attr.IsByValue) ppMemory = (unsigned char **)*ppMemory;
|
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-07-28 22:13:45 +02:00
|
|
|
static inline void call_freer(PMIDL_STUB_MESSAGE pStubMsg, unsigned char *pMemory,
|
|
|
|
const NDR_PARAM_OIF *param)
|
2006-01-05 12:19:05 +01:00
|
|
|
{
|
2011-07-28 22:13:45 +02:00
|
|
|
PFORMAT_STRING pFormat;
|
|
|
|
NDR_FREE m;
|
|
|
|
|
|
|
|
if (param->attr.IsBasetype) return; /* nothing to do */
|
|
|
|
pFormat = &pStubMsg->StubDesc->pFormatTypes[param->u.type_offset];
|
|
|
|
if (!param->attr.IsByValue) pMemory = *(unsigned char **)pMemory;
|
|
|
|
|
|
|
|
m = NdrFreer[pFormat[0] & NDR_TABLE_MASK];
|
2006-01-05 12:19:05 +01:00
|
|
|
if (m) m(pStubMsg, pMemory, pFormat);
|
|
|
|
}
|
|
|
|
|
2011-07-28 22:43:12 +02:00
|
|
|
static DWORD calc_arg_size(MIDL_STUB_MESSAGE *pStubMsg, PFORMAT_STRING pFormat)
|
|
|
|
{
|
|
|
|
DWORD size;
|
|
|
|
switch(*pFormat)
|
|
|
|
{
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_RP:
|
|
|
|
if (pFormat[1] & FC_SIMPLE_POINTER)
|
2011-09-22 21:40:06 +02:00
|
|
|
{
|
2018-10-11 18:59:18 +02:00
|
|
|
size = 0;
|
2011-09-22 21:40:06 +02:00
|
|
|
break;
|
|
|
|
}
|
2011-11-15 23:57:44 +01:00
|
|
|
size = calc_arg_size(pStubMsg, &pFormat[2] + *(const SHORT*)&pFormat[2]);
|
2011-09-22 21:40:06 +02:00
|
|
|
break;
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_STRUCT:
|
|
|
|
case FC_PSTRUCT:
|
2011-07-28 22:43:12 +02:00
|
|
|
size = *(const WORD*)(pFormat + 2);
|
|
|
|
break;
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_BOGUS_STRUCT:
|
2011-07-28 22:43:12 +02:00
|
|
|
size = *(const WORD*)(pFormat + 2);
|
|
|
|
if(*(const WORD*)(pFormat + 4))
|
|
|
|
FIXME("Unhandled conformant description\n");
|
|
|
|
break;
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_CARRAY:
|
|
|
|
case FC_CVARRAY:
|
2011-07-28 22:43:12 +02:00
|
|
|
size = *(const WORD*)(pFormat + 2);
|
|
|
|
ComputeConformance(pStubMsg, NULL, pFormat + 4, 0);
|
|
|
|
size *= pStubMsg->MaxCount;
|
|
|
|
break;
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_SMFARRAY:
|
|
|
|
case FC_SMVARRAY:
|
2011-07-28 22:43:12 +02:00
|
|
|
size = *(const WORD*)(pFormat + 2);
|
|
|
|
break;
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_LGFARRAY:
|
|
|
|
case FC_LGVARRAY:
|
2011-07-28 22:43:12 +02:00
|
|
|
size = *(const DWORD*)(pFormat + 2);
|
|
|
|
break;
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_BOGUS_ARRAY:
|
2011-07-28 22:43:12 +02:00
|
|
|
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;
|
|
|
|
break;
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_USER_MARSHAL:
|
2011-07-29 12:08:47 +02:00
|
|
|
size = *(const WORD*)(pFormat + 4);
|
|
|
|
break;
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_CSTRING:
|
2011-07-29 12:08:47 +02:00
|
|
|
size = *(const WORD*)(pFormat + 2);
|
|
|
|
break;
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_WSTRING:
|
2011-07-29 12:08:47 +02:00
|
|
|
size = *(const WORD*)(pFormat + 2) * sizeof(WCHAR);
|
|
|
|
break;
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_C_CSTRING:
|
|
|
|
case FC_C_WSTRING:
|
|
|
|
if (*pFormat == FC_C_CSTRING)
|
2011-07-28 22:43:12 +02:00
|
|
|
size = sizeof(CHAR);
|
|
|
|
else
|
|
|
|
size = sizeof(WCHAR);
|
2018-06-13 04:19:10 +02:00
|
|
|
if (pFormat[1] == FC_STRING_SIZED)
|
2011-07-28 22:43:12 +02:00
|
|
|
ComputeConformance(pStubMsg, NULL, pFormat + 2, 0);
|
|
|
|
else
|
|
|
|
pStubMsg->MaxCount = 0;
|
|
|
|
size *= pStubMsg->MaxCount;
|
|
|
|
break;
|
2020-04-05 01:15:29 +02:00
|
|
|
case FC_NON_ENCAPSULATED_UNION:
|
|
|
|
{
|
|
|
|
DWORD offset = *(const WORD *)(pFormat + 6 + pStubMsg->CorrDespIncrement);
|
|
|
|
size = *(const WORD *)(pFormat + 8 + pStubMsg->CorrDespIncrement + offset);
|
|
|
|
break;
|
|
|
|
}
|
2011-07-28 22:43:12 +02:00
|
|
|
default:
|
|
|
|
FIXME("Unhandled type %02x\n", *pFormat);
|
2011-11-16 16:24:39 +01:00
|
|
|
/* fallthrough */
|
2018-10-11 18:59:17 +02:00
|
|
|
case FC_UP:
|
|
|
|
case FC_OP:
|
|
|
|
case FC_FP:
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_IP:
|
2011-07-28 22:43:12 +02:00
|
|
|
size = sizeof(void *);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return size;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
2011-07-28 12:57:51 +02:00
|
|
|
static const char *debugstr_PROC_PF(PARAM_ATTRIBUTES param_attributes)
|
2006-01-05 12:19:05 +01:00
|
|
|
{
|
2011-07-28 12:57:51 +02:00
|
|
|
char buffer[160];
|
|
|
|
|
|
|
|
buffer[0] = 0;
|
|
|
|
if (param_attributes.MustSize) strcat(buffer, " MustSize");
|
|
|
|
if (param_attributes.MustFree) strcat(buffer, " MustFree");
|
|
|
|
if (param_attributes.IsPipe) strcat(buffer, " IsPipe");
|
|
|
|
if (param_attributes.IsIn) strcat(buffer, " IsIn");
|
|
|
|
if (param_attributes.IsOut) strcat(buffer, " IsOut");
|
|
|
|
if (param_attributes.IsReturn) strcat(buffer, " IsReturn");
|
|
|
|
if (param_attributes.IsBasetype) strcat(buffer, " IsBasetype");
|
|
|
|
if (param_attributes.IsByValue) strcat(buffer, " IsByValue");
|
|
|
|
if (param_attributes.IsSimpleRef) strcat(buffer, " IsSimpleRef");
|
|
|
|
if (param_attributes.IsDontCallFreeInst) strcat(buffer, " IsDontCallFreeInst");
|
|
|
|
if (param_attributes.SaveForAsyncFinish) strcat(buffer, " SaveForAsyncFinish");
|
|
|
|
if (param_attributes.ServerAllocSize)
|
|
|
|
sprintf( buffer + strlen(buffer), " ServerAllocSize = %d", param_attributes.ServerAllocSize * 8);
|
|
|
|
return buffer[0] ? wine_dbg_sprintf( "%s", buffer + 1 ) : "";
|
2006-01-05 12:19:05 +01:00
|
|
|
}
|
|
|
|
|
2011-07-28 12:57:51 +02:00
|
|
|
static const char *debugstr_INTERPRETER_OPT_FLAGS(INTERPRETER_OPT_FLAGS Oi2Flags)
|
2006-04-20 12:44:27 +02:00
|
|
|
{
|
2011-07-28 12:57:51 +02:00
|
|
|
char buffer[160];
|
|
|
|
|
|
|
|
buffer[0] = 0;
|
|
|
|
if (Oi2Flags.ServerMustSize) strcat(buffer, " ServerMustSize");
|
|
|
|
if (Oi2Flags.ClientMustSize) strcat(buffer, " ClientMustSize");
|
|
|
|
if (Oi2Flags.HasReturn) strcat(buffer, " HasReturn");
|
|
|
|
if (Oi2Flags.HasPipes) strcat(buffer, " HasPipes");
|
|
|
|
if (Oi2Flags.Unused) strcat(buffer, " Unused");
|
|
|
|
if (Oi2Flags.HasAsyncUuid) strcat(buffer, " HasAsyncUuid");
|
|
|
|
if (Oi2Flags.HasExtensions) strcat(buffer, " HasExtensions");
|
|
|
|
if (Oi2Flags.HasAsyncHandle) strcat(buffer, " HasAsyncHandle");
|
|
|
|
return buffer[0] ? wine_dbg_sprintf( "%s", buffer + 1 ) : "";
|
2006-04-20 12:44:27 +02:00
|
|
|
}
|
|
|
|
|
2007-11-05 12:16:43 +01:00
|
|
|
#define ARG_FROM_OFFSET(args, offset) ((args) + (offset))
|
2006-05-25 00:03:29 +02:00
|
|
|
|
2019-05-21 06:30:54 +02:00
|
|
|
static size_t get_handle_desc_size(const NDR_PROC_HEADER *proc_header, PFORMAT_STRING format)
|
|
|
|
{
|
|
|
|
if (!proc_header->handle_type)
|
|
|
|
{
|
|
|
|
if (*format == FC_BIND_PRIMITIVE)
|
|
|
|
return sizeof(NDR_EHD_PRIMITIVE);
|
|
|
|
else if (*format == FC_BIND_GENERIC)
|
|
|
|
return sizeof(NDR_EHD_GENERIC);
|
|
|
|
else if (*format == FC_BIND_CONTEXT)
|
|
|
|
return sizeof(NDR_EHD_CONTEXT);
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static handle_t client_get_handle(const MIDL_STUB_MESSAGE *pStubMsg,
|
|
|
|
const NDR_PROC_HEADER *pProcHeader, const PFORMAT_STRING pFormat)
|
2006-05-25 00:03:29 +02:00
|
|
|
{
|
|
|
|
/* binding */
|
|
|
|
switch (pProcHeader->handle_type)
|
|
|
|
{
|
|
|
|
/* explicit binding: parse additional section */
|
2018-06-13 04:19:10 +02:00
|
|
|
case 0:
|
2006-05-25 00:03:29 +02:00
|
|
|
switch (*pFormat) /* handle_type */
|
|
|
|
{
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_BIND_PRIMITIVE: /* explicit primitive */
|
2006-05-25 00:03:29 +02:00
|
|
|
{
|
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 */
|
2019-05-21 06:30:54 +02:00
|
|
|
return **(handle_t **)ARG_FROM_OFFSET(pStubMsg->StackTop, pDesc->offset);
|
2006-05-25 00:03:29 +02:00
|
|
|
else
|
2019-05-21 06:30:54 +02:00
|
|
|
return *(handle_t *)ARG_FROM_OFFSET(pStubMsg->StackTop, pDesc->offset);
|
2006-05-25 00:03:29 +02:00
|
|
|
}
|
2018-06-13 04:19:10 +02:00
|
|
|
case 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
|
2009-02-16 09:54:10 +01:00
|
|
|
pArg = 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];
|
2019-05-21 06:30:54 +02:00
|
|
|
return pGenPair->pfnBind(pObject);
|
2006-05-25 00:03:54 +02:00
|
|
|
}
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_BIND_CONTEXT: /* explicit context */
|
2006-05-25 00:03:29 +02:00
|
|
|
{
|
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);
|
2011-06-09 17:45:14 +02:00
|
|
|
|
2019-05-21 06:30:54 +02:00
|
|
|
if (context_handle) return NDRCContextBinding(context_handle);
|
2011-06-09 17:45:14 +02:00
|
|
|
else if (pDesc->flags & NDR_CONTEXT_HANDLE_CANNOT_BE_NULL)
|
2006-05-25 00:03:29 +02:00
|
|
|
{
|
|
|
|
ERR("null context handle isn't allowed\n");
|
|
|
|
RpcRaiseException(RPC_X_SS_IN_NULL_CONTEXT);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
/* FIXME: should we store this structure in stubMsg.pContext? */
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
ERR("bad explicit binding handle type (0x%02x)\n", pProcHeader->handle_type);
|
|
|
|
RpcRaiseException(RPC_X_BAD_STUB_DATA);
|
|
|
|
}
|
|
|
|
break;
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_BIND_GENERIC: /* implicit generic */
|
|
|
|
FIXME("FC_BIND_GENERIC\n");
|
2006-05-25 00:03:29 +02:00
|
|
|
RpcRaiseException(RPC_X_BAD_STUB_DATA); /* FIXME: remove when implemented */
|
|
|
|
break;
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_BIND_PRIMITIVE: /* implicit primitive */
|
2006-05-25 00:03:29 +02:00
|
|
|
TRACE("Implicit primitive handle\n");
|
2019-05-21 06:30:54 +02:00
|
|
|
return *pStubMsg->StubDesc->IMPLICIT_HANDLE_INFO.pPrimitiveHandle;
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_CALLBACK_HANDLE: /* implicit callback */
|
|
|
|
TRACE("FC_CALLBACK_HANDLE\n");
|
2015-03-05 23:19:29 +01:00
|
|
|
/* server calls callback procedures only in response to remote call, and most recent
|
|
|
|
binding handle is used. Calling back to a client can potentially result in another
|
|
|
|
callback with different current handle. */
|
2019-05-21 06:30:54 +02:00
|
|
|
return I_RpcGetCurrentCallHandle();
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_AUTO_HANDLE: /* implicit auto handle */
|
2006-05-25 00:03:29 +02:00
|
|
|
/* 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");
|
2019-05-21 06:30:54 +02:00
|
|
|
return *pStubMsg->StubDesc->IMPLICIT_HANDLE_INFO.pAutoHandle;
|
2006-05-25 00:03:29 +02:00
|
|
|
default:
|
|
|
|
ERR("bad implicit binding handle type (0x%02x)\n", pProcHeader->handle_type);
|
|
|
|
RpcRaiseException(RPC_X_BAD_STUB_DATA);
|
|
|
|
}
|
2019-05-21 06:30:54 +02:00
|
|
|
return NULL;
|
2006-05-25 00:03:29 +02:00
|
|
|
}
|
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 */
|
2018-06-13 04:19:10 +02:00
|
|
|
case 0:
|
2006-05-25 00:03:54 +02:00
|
|
|
switch (*pFormat) /* handle_type */
|
|
|
|
{
|
2018-06-13 04:19:10 +02:00
|
|
|
case 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
|
2009-02-16 09:54:10 +01:00
|
|
|
pArg = 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;
|
|
|
|
}
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_BIND_CONTEXT: /* explicit context */
|
|
|
|
case FC_BIND_PRIMITIVE: /* explicit primitive */
|
2006-05-25 00:03:54 +02:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
ERR("bad explicit binding handle type (0x%02x)\n", pProcHeader->handle_type);
|
|
|
|
RpcRaiseException(RPC_X_BAD_STUB_DATA);
|
|
|
|
}
|
|
|
|
break;
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_BIND_GENERIC: /* implicit generic */
|
|
|
|
FIXME("FC_BIND_GENERIC\n");
|
2006-05-25 00:03:54 +02:00
|
|
|
RpcRaiseException(RPC_X_BAD_STUB_DATA); /* FIXME: remove when implemented */
|
|
|
|
break;
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_CALLBACK_HANDLE: /* implicit callback */
|
|
|
|
case FC_BIND_PRIMITIVE: /* implicit primitive */
|
|
|
|
case FC_AUTO_HANDLE: /* implicit auto handle */
|
2006-05-25 00:03:54 +02:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
ERR("bad implicit binding handle type (0x%02x)\n", pProcHeader->handle_type);
|
|
|
|
RpcRaiseException(RPC_X_BAD_STUB_DATA);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-10-11 18:59:19 +02:00
|
|
|
static inline BOOL param_needs_alloc( PARAM_ATTRIBUTES attr )
|
|
|
|
{
|
|
|
|
return attr.IsOut && !attr.IsIn && !attr.IsBasetype && !attr.IsByValue;
|
|
|
|
}
|
|
|
|
|
2018-10-14 00:46:43 +02:00
|
|
|
static inline BOOL param_is_out_basetype( PARAM_ATTRIBUTES attr )
|
|
|
|
{
|
|
|
|
return attr.IsOut && !attr.IsIn && attr.IsBasetype && attr.IsSimpleRef;
|
|
|
|
}
|
|
|
|
|
|
|
|
static size_t basetype_arg_size( unsigned char fc )
|
|
|
|
{
|
|
|
|
switch (fc)
|
|
|
|
{
|
|
|
|
case FC_BYTE:
|
|
|
|
case FC_CHAR:
|
|
|
|
case FC_SMALL:
|
|
|
|
case FC_USMALL:
|
|
|
|
return sizeof(char);
|
|
|
|
case FC_WCHAR:
|
|
|
|
case FC_SHORT:
|
|
|
|
case FC_USHORT:
|
|
|
|
return sizeof(short);
|
|
|
|
case FC_LONG:
|
|
|
|
case FC_ULONG:
|
|
|
|
case FC_ENUM16:
|
|
|
|
case FC_ENUM32:
|
|
|
|
case FC_ERROR_STATUS_T:
|
|
|
|
return sizeof(int);
|
|
|
|
case FC_FLOAT:
|
|
|
|
return sizeof(float);
|
|
|
|
case FC_HYPER:
|
|
|
|
return sizeof(LONGLONG);
|
|
|
|
case FC_DOUBLE:
|
|
|
|
return sizeof(double);
|
|
|
|
case FC_INT3264:
|
|
|
|
case FC_UINT3264:
|
|
|
|
return sizeof(INT_PTR);
|
|
|
|
default:
|
|
|
|
FIXME("Unhandled basetype %#x.\n", fc);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-07-28 22:34:57 +02:00
|
|
|
void client_do_args( PMIDL_STUB_MESSAGE pStubMsg, PFORMAT_STRING pFormat, enum stubless_phase phase,
|
|
|
|
void **fpu_args, unsigned short number_of_params, unsigned char *pRetVal )
|
2006-08-16 13:29:12 +02:00
|
|
|
{
|
2011-07-28 12:43:27 +02:00
|
|
|
const NDR_PARAM_OIF *params = (const NDR_PARAM_OIF *)pFormat;
|
|
|
|
unsigned int i;
|
2006-08-16 13:29:12 +02:00
|
|
|
|
|
|
|
for (i = 0; i < number_of_params; i++)
|
|
|
|
{
|
2011-07-28 12:48:39 +02:00
|
|
|
unsigned char *pArg = pStubMsg->StackTop + params[i].stack_offset;
|
2011-07-28 22:43:12 +02:00
|
|
|
PFORMAT_STRING pTypeFormat = (PFORMAT_STRING)&pStubMsg->StubDesc->pFormatTypes[params[i].u.type_offset];
|
2006-08-16 13:29:12 +02:00
|
|
|
|
2011-06-13 13:39:21 +02:00
|
|
|
#ifdef __x86_64__ /* floats are passed as doubles through varargs functions */
|
2011-07-28 22:13:45 +02:00
|
|
|
float f;
|
2006-08-16 13:29:12 +02:00
|
|
|
|
2011-07-28 22:13:45 +02:00
|
|
|
if (params[i].attr.IsBasetype &&
|
2018-06-13 04:19:10 +02:00
|
|
|
params[i].u.type_format_char == FC_FLOAT &&
|
2011-07-28 22:13:45 +02:00
|
|
|
!params[i].attr.IsSimpleRef &&
|
|
|
|
!fpu_args)
|
2006-08-16 13:29:12 +02:00
|
|
|
{
|
2011-07-28 22:13:45 +02:00
|
|
|
f = *(double *)pArg;
|
|
|
|
pArg = (unsigned char *)&f;
|
|
|
|
}
|
|
|
|
#endif
|
2006-08-16 13:29:12 +02:00
|
|
|
|
2011-07-28 22:13:45 +02:00
|
|
|
TRACE("param[%d]: %p type %02x %s\n", i, pArg,
|
2011-07-28 22:43:12 +02:00
|
|
|
params[i].attr.IsBasetype ? params[i].u.type_format_char : *pTypeFormat,
|
2011-07-28 22:13:45 +02:00
|
|
|
debugstr_PROC_PF( params[i].attr ));
|
2006-08-16 13:29:12 +02:00
|
|
|
|
2011-07-28 22:13:45 +02:00
|
|
|
switch (phase)
|
|
|
|
{
|
2011-07-28 22:43:12 +02:00
|
|
|
case STUBLESS_INITOUT:
|
2018-10-14 00:46:43 +02:00
|
|
|
if (*(unsigned char **)pArg)
|
|
|
|
{
|
|
|
|
if (param_needs_alloc(params[i].attr))
|
|
|
|
memset( *(unsigned char **)pArg, 0, calc_arg_size( pStubMsg, pTypeFormat ));
|
|
|
|
else if (param_is_out_basetype(params[i].attr))
|
|
|
|
memset( *(unsigned char **)pArg, 0, basetype_arg_size( params[i].u.type_format_char ));
|
|
|
|
}
|
2011-07-28 22:43:12 +02:00
|
|
|
break;
|
2011-07-28 22:34:57 +02:00
|
|
|
case STUBLESS_CALCSIZE:
|
2011-07-28 22:43:12 +02:00
|
|
|
if (params[i].attr.IsSimpleRef && !*(unsigned char **)pArg)
|
|
|
|
RpcRaiseException(RPC_X_NULL_REF_POINTER);
|
2011-07-28 22:13:45 +02:00
|
|
|
if (params[i].attr.IsIn) call_buffer_sizer(pStubMsg, pArg, ¶ms[i]);
|
|
|
|
break;
|
2011-07-28 22:34:57 +02:00
|
|
|
case STUBLESS_MARSHAL:
|
2011-07-28 22:13:45 +02:00
|
|
|
if (params[i].attr.IsIn) call_marshaller(pStubMsg, pArg, ¶ms[i]);
|
|
|
|
break;
|
2011-07-28 22:34:57 +02:00
|
|
|
case STUBLESS_UNMARSHAL:
|
2011-07-28 22:13:45 +02:00
|
|
|
if (params[i].attr.IsOut)
|
2006-08-16 13:29:12 +02:00
|
|
|
{
|
2011-07-28 22:13:45 +02:00
|
|
|
if (params[i].attr.IsReturn && pRetVal) pArg = pRetVal;
|
|
|
|
call_unmarshaller(pStubMsg, &pArg, ¶ms[i], 0);
|
2006-08-16 13:29:12 +02:00
|
|
|
}
|
2011-07-28 22:13:45 +02:00
|
|
|
break;
|
2011-07-28 22:43:12 +02:00
|
|
|
case STUBLESS_FREE:
|
|
|
|
if (!params[i].attr.IsBasetype && params[i].attr.IsOut && !params[i].attr.IsByValue)
|
|
|
|
NdrClearOutParameters( pStubMsg, pTypeFormat, *(unsigned char **)pArg );
|
|
|
|
break;
|
2011-07-28 22:13:45 +02:00
|
|
|
default:
|
|
|
|
RpcRaiseException(RPC_S_INTERNAL_ERROR);
|
2006-08-16 13:29:12 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-03-10 18:05:59 +01:00
|
|
|
static unsigned int type_stack_size(unsigned char fc)
|
|
|
|
{
|
|
|
|
switch (fc)
|
|
|
|
{
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_BYTE:
|
|
|
|
case FC_CHAR:
|
|
|
|
case FC_SMALL:
|
|
|
|
case FC_USMALL:
|
|
|
|
case FC_WCHAR:
|
|
|
|
case FC_SHORT:
|
|
|
|
case FC_USHORT:
|
|
|
|
case FC_LONG:
|
|
|
|
case FC_ULONG:
|
|
|
|
case FC_INT3264:
|
|
|
|
case FC_UINT3264:
|
|
|
|
case FC_ENUM16:
|
|
|
|
case FC_ENUM32:
|
|
|
|
case FC_FLOAT:
|
|
|
|
case FC_ERROR_STATUS_T:
|
|
|
|
case FC_IGNORE:
|
2011-06-07 20:44:16 +02:00
|
|
|
return sizeof(void *);
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_DOUBLE:
|
2008-03-10 18:05:59 +01:00
|
|
|
return sizeof(double);
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_HYPER:
|
2008-03-10 18:05:59 +01:00
|
|
|
return sizeof(ULONGLONG);
|
|
|
|
default:
|
|
|
|
ERR("invalid base type 0x%x\n", fc);
|
|
|
|
RpcRaiseException(RPC_S_INTERNAL_ERROR);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-06-07 20:41:17 +02:00
|
|
|
static BOOL is_by_value( PFORMAT_STRING format )
|
|
|
|
{
|
|
|
|
switch (*format)
|
|
|
|
{
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_USER_MARSHAL:
|
|
|
|
case FC_STRUCT:
|
|
|
|
case FC_PSTRUCT:
|
|
|
|
case FC_CSTRUCT:
|
|
|
|
case FC_CPSTRUCT:
|
|
|
|
case FC_CVSTRUCT:
|
|
|
|
case FC_BOGUS_STRUCT:
|
2011-06-07 20:41:17 +02:00
|
|
|
return TRUE;
|
|
|
|
default:
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-07-28 17:30:40 +02:00
|
|
|
PFORMAT_STRING convert_old_args( PMIDL_STUB_MESSAGE pStubMsg, PFORMAT_STRING pFormat,
|
|
|
|
unsigned int stack_size, BOOL object_proc,
|
|
|
|
void *buffer, unsigned int size, unsigned int *count )
|
2011-07-28 16:54:01 +02:00
|
|
|
{
|
|
|
|
NDR_PARAM_OIF *args = buffer;
|
|
|
|
unsigned int i, stack_offset = object_proc ? sizeof(void *) : 0;
|
|
|
|
|
|
|
|
for (i = 0; stack_offset < stack_size; i++)
|
|
|
|
{
|
|
|
|
const NDR_PARAM_OI_BASETYPE *param = (const NDR_PARAM_OI_BASETYPE *)pFormat;
|
|
|
|
const NDR_PARAM_OI_OTHER *other = (const NDR_PARAM_OI_OTHER *)pFormat;
|
|
|
|
|
|
|
|
if (i + 1 > size / sizeof(*args))
|
|
|
|
{
|
|
|
|
FIXME( "%u args not supported\n", i );
|
|
|
|
RpcRaiseException( RPC_S_INTERNAL_ERROR );
|
|
|
|
}
|
|
|
|
|
|
|
|
args[i].stack_offset = stack_offset;
|
|
|
|
memset( &args[i].attr, 0, sizeof(args[i].attr) );
|
|
|
|
|
|
|
|
switch (param->param_direction)
|
|
|
|
{
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_IN_PARAM_BASETYPE:
|
2011-07-28 16:54:01 +02:00
|
|
|
args[i].attr.IsIn = 1;
|
|
|
|
args[i].attr.IsBasetype = 1;
|
|
|
|
break;
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_RETURN_PARAM_BASETYPE:
|
2011-07-28 16:54:01 +02:00
|
|
|
args[i].attr.IsOut = 1;
|
|
|
|
args[i].attr.IsReturn = 1;
|
|
|
|
args[i].attr.IsBasetype = 1;
|
|
|
|
break;
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_IN_PARAM:
|
2011-07-28 16:54:01 +02:00
|
|
|
args[i].attr.IsIn = 1;
|
2011-07-28 17:48:19 +02:00
|
|
|
args[i].attr.MustFree = 1;
|
2011-07-28 16:54:01 +02:00
|
|
|
break;
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_IN_PARAM_NO_FREE_INST:
|
2011-07-28 16:54:01 +02:00
|
|
|
args[i].attr.IsIn = 1;
|
|
|
|
args[i].attr.IsDontCallFreeInst = 1;
|
|
|
|
break;
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_IN_OUT_PARAM:
|
2011-07-28 16:54:01 +02:00
|
|
|
args[i].attr.IsIn = 1;
|
|
|
|
args[i].attr.IsOut = 1;
|
2011-07-28 17:48:19 +02:00
|
|
|
args[i].attr.MustFree = 1;
|
2011-07-28 16:54:01 +02:00
|
|
|
break;
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_OUT_PARAM:
|
2011-07-28 16:54:01 +02:00
|
|
|
args[i].attr.IsOut = 1;
|
|
|
|
break;
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_RETURN_PARAM:
|
2011-07-28 16:54:01 +02:00
|
|
|
args[i].attr.IsOut = 1;
|
|
|
|
args[i].attr.IsReturn = 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (args[i].attr.IsBasetype)
|
|
|
|
{
|
|
|
|
args[i].u.type_format_char = param->type_format_char;
|
|
|
|
stack_offset += type_stack_size( param->type_format_char );
|
|
|
|
pFormat += sizeof(NDR_PARAM_OI_BASETYPE);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
args[i].u.type_offset = other->type_offset;
|
|
|
|
args[i].attr.IsByValue = is_by_value( &pStubMsg->StubDesc->pFormatTypes[other->type_offset] );
|
|
|
|
stack_offset += other->stack_size * sizeof(void *);
|
|
|
|
pFormat += sizeof(NDR_PARAM_OI_OTHER);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
*count = i;
|
|
|
|
return (PFORMAT_STRING)args;
|
|
|
|
}
|
|
|
|
|
2019-05-21 06:30:56 +02:00
|
|
|
struct ndr_client_call_ctx
|
|
|
|
{
|
|
|
|
MIDL_STUB_MESSAGE *stub_msg;
|
|
|
|
INTERPRETER_OPT_FLAGS Oif_flags;
|
|
|
|
INTERPRETER_OPT_FLAGS2 ext_flags;
|
|
|
|
const NDR_PROC_HEADER *proc_header;
|
|
|
|
void *This;
|
|
|
|
PFORMAT_STRING handle_format;
|
|
|
|
handle_t hbinding;
|
|
|
|
};
|
|
|
|
|
|
|
|
static void CALLBACK ndr_client_call_finally(BOOL normal, void *arg)
|
|
|
|
{
|
|
|
|
struct ndr_client_call_ctx *ctx = arg;
|
|
|
|
|
|
|
|
if (ctx->ext_flags.HasNewCorrDesc)
|
|
|
|
{
|
|
|
|
/* free extra correlation package */
|
|
|
|
NdrCorrelationFree(ctx->stub_msg);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ctx->Oif_flags.HasPipes)
|
|
|
|
{
|
|
|
|
/* NdrPipesDone(...) */
|
|
|
|
}
|
|
|
|
|
|
|
|
/* free the full pointer translation tables */
|
|
|
|
if (ctx->proc_header->Oi_flags & Oi_FULL_PTR_USED)
|
|
|
|
NdrFullPointerXlatFree(ctx->stub_msg->FullPtrXlatTables);
|
|
|
|
|
|
|
|
/* free marshalling buffer */
|
|
|
|
if (ctx->proc_header->Oi_flags & Oi_OBJECT_PROC)
|
|
|
|
NdrProxyFreeBuffer(ctx->This, ctx->stub_msg);
|
|
|
|
else
|
|
|
|
{
|
|
|
|
NdrFreeBuffer(ctx->stub_msg);
|
|
|
|
client_free_handle(ctx->stub_msg, ctx->proc_header, ctx->handle_format, ctx->hbinding);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-05-21 06:30:55 +02:00
|
|
|
/* Helper for ndr_client_call, to factor out the part that may or may not be
|
|
|
|
* guarded by a try/except block. */
|
|
|
|
static LONG_PTR do_ndr_client_call( const MIDL_STUB_DESC *stub_desc, const PFORMAT_STRING format,
|
|
|
|
const PFORMAT_STRING handle_format, void **stack_top, void **fpu_stack, MIDL_STUB_MESSAGE *stub_msg,
|
|
|
|
unsigned short procedure_number, unsigned short stack_size, unsigned int number_of_params,
|
|
|
|
INTERPRETER_OPT_FLAGS Oif_flags, INTERPRETER_OPT_FLAGS2 ext_flags, const NDR_PROC_HEADER *proc_header )
|
|
|
|
{
|
2019-05-21 06:30:56 +02:00
|
|
|
struct ndr_client_call_ctx finally_ctx;
|
2019-05-21 06:30:55 +02:00
|
|
|
RPC_MESSAGE rpc_msg;
|
|
|
|
handle_t hbinding = NULL;
|
|
|
|
/* 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;
|
|
|
|
/* correlation cache */
|
|
|
|
ULONG_PTR NdrCorrCache[256];
|
|
|
|
|
|
|
|
/* create the full pointer translation tables, if requested */
|
|
|
|
if (proc_header->Oi_flags & Oi_FULL_PTR_USED)
|
|
|
|
stub_msg->FullPtrXlatTables = NdrFullPointerXlatInit(0,XLAT_CLIENT);
|
|
|
|
|
|
|
|
if (proc_header->Oi_flags & Oi_OBJECT_PROC)
|
|
|
|
{
|
|
|
|
/* object is always the first argument */
|
|
|
|
This = stack_top[0];
|
|
|
|
NdrProxyInitialize(This, &rpc_msg, stub_msg, stub_desc, procedure_number);
|
|
|
|
}
|
|
|
|
|
2019-05-21 06:30:56 +02:00
|
|
|
finally_ctx.stub_msg = stub_msg;
|
|
|
|
finally_ctx.Oif_flags = Oif_flags;
|
|
|
|
finally_ctx.ext_flags = ext_flags;
|
|
|
|
finally_ctx.proc_header = proc_header;
|
|
|
|
finally_ctx.This = This;
|
|
|
|
finally_ctx.handle_format = handle_format;
|
|
|
|
finally_ctx.hbinding = hbinding;
|
2019-05-21 06:30:55 +02:00
|
|
|
|
2019-05-21 06:30:56 +02:00
|
|
|
__TRY
|
2019-05-21 06:30:55 +02:00
|
|
|
{
|
2019-05-21 06:30:56 +02:00
|
|
|
if (!(proc_header->Oi_flags & Oi_OBJECT_PROC))
|
|
|
|
NdrClientInitializeNew(&rpc_msg, stub_msg, stub_desc, procedure_number);
|
2019-05-21 06:30:55 +02:00
|
|
|
|
2019-05-21 06:30:56 +02:00
|
|
|
stub_msg->StackTop = (unsigned char *)stack_top;
|
2019-05-21 06:30:55 +02:00
|
|
|
|
2019-05-21 06:30:56 +02:00
|
|
|
/* we only need a handle if this isn't an object method */
|
|
|
|
if (!(proc_header->Oi_flags & Oi_OBJECT_PROC))
|
|
|
|
{
|
|
|
|
hbinding = client_get_handle(stub_msg, proc_header, handle_format);
|
|
|
|
if (!hbinding) return 0;
|
|
|
|
}
|
2019-05-21 06:30:55 +02:00
|
|
|
|
2019-05-21 06:30:56 +02:00
|
|
|
stub_msg->BufferLength = 0;
|
2019-05-21 06:30:55 +02:00
|
|
|
|
2019-05-21 06:30:56 +02:00
|
|
|
/* store the RPC flags away */
|
|
|
|
if (proc_header->Oi_flags & Oi_HAS_RPCFLAGS)
|
|
|
|
rpc_msg.RpcFlags = ((const NDR_PROC_HEADER_RPC *)proc_header)->rpc_flags;
|
2019-05-21 06:30:55 +02:00
|
|
|
|
2019-05-21 06:30:56 +02:00
|
|
|
/* use alternate memory allocation routines */
|
|
|
|
if (proc_header->Oi_flags & Oi_RPCSS_ALLOC_USED)
|
|
|
|
NdrRpcSmSetClientToOsf(stub_msg);
|
|
|
|
|
|
|
|
if (Oif_flags.HasPipes)
|
|
|
|
{
|
|
|
|
FIXME("pipes not supported yet\n");
|
|
|
|
RpcRaiseException(RPC_X_WRONG_STUB_VERSION); /* FIXME: remove when implemented */
|
|
|
|
/* init pipes package */
|
|
|
|
/* NdrPipesInitialize(...) */
|
|
|
|
}
|
|
|
|
if (ext_flags.HasNewCorrDesc)
|
|
|
|
{
|
|
|
|
/* initialize extra correlation package */
|
|
|
|
NdrCorrelationInitialize(stub_msg, NdrCorrCache, sizeof(NdrCorrCache), 0);
|
|
|
|
if (ext_flags.Unused & 0x2) /* has range on conformance */
|
|
|
|
stub_msg->CorrDespIncrement = 12;
|
|
|
|
}
|
2019-05-21 06:30:55 +02:00
|
|
|
|
2019-05-21 06:30:56 +02:00
|
|
|
/* order of phases:
|
|
|
|
* 1. INITOUT - zero [out] parameters (proxies only)
|
|
|
|
* 2. CALCSIZE - calculate the buffer size
|
|
|
|
* 3. GETBUFFER - allocate the buffer
|
|
|
|
* 4. MARSHAL - marshal [in] params into the buffer
|
|
|
|
* 5. SENDRECEIVE - send/receive buffer
|
|
|
|
* 6. UNMARSHAL - unmarshal [out] params from buffer
|
|
|
|
* 7. FREE - clear [out] parameters (for proxies, and only on error)
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* 1. INITOUT */
|
|
|
|
if (proc_header->Oi_flags & Oi_OBJECT_PROC)
|
|
|
|
{
|
|
|
|
TRACE( "INITOUT\n" );
|
|
|
|
client_do_args(stub_msg, format, STUBLESS_INITOUT, fpu_stack,
|
|
|
|
number_of_params, (unsigned char *)&retval);
|
|
|
|
}
|
2019-05-21 06:30:55 +02:00
|
|
|
|
2019-05-21 06:30:56 +02:00
|
|
|
/* 2. CALCSIZE */
|
|
|
|
TRACE( "CALCSIZE\n" );
|
|
|
|
client_do_args(stub_msg, format, STUBLESS_CALCSIZE, fpu_stack,
|
|
|
|
number_of_params, (unsigned char *)&retval);
|
|
|
|
|
|
|
|
/* 3. GETBUFFER */
|
|
|
|
TRACE( "GETBUFFER\n" );
|
|
|
|
if (proc_header->Oi_flags & Oi_OBJECT_PROC)
|
|
|
|
NdrProxyGetBuffer(This, stub_msg);
|
|
|
|
else if (Oif_flags.HasPipes)
|
|
|
|
FIXME("pipes not supported yet\n");
|
|
|
|
else if (proc_header->handle_type == FC_AUTO_HANDLE)
|
2019-05-21 06:30:55 +02:00
|
|
|
#if 0
|
2019-05-21 06:30:56 +02:00
|
|
|
NdrNsGetBuffer(stub_msg, stub_msg->BufferLength, hBinding);
|
2019-05-21 06:30:55 +02:00
|
|
|
#else
|
2019-05-21 06:30:56 +02:00
|
|
|
FIXME("using auto handle - call NdrNsGetBuffer when it gets implemented\n");
|
2019-05-21 06:30:55 +02:00
|
|
|
#endif
|
2019-05-21 06:30:56 +02:00
|
|
|
else
|
|
|
|
NdrGetBuffer(stub_msg, stub_msg->BufferLength, hbinding);
|
2019-05-21 06:30:55 +02:00
|
|
|
|
2019-05-21 06:30:56 +02:00
|
|
|
/* 4. MARSHAL */
|
|
|
|
TRACE( "MARSHAL\n" );
|
|
|
|
client_do_args(stub_msg, format, STUBLESS_MARSHAL, fpu_stack,
|
|
|
|
number_of_params, (unsigned char *)&retval);
|
2019-05-21 06:30:55 +02:00
|
|
|
|
2019-05-21 06:30:56 +02:00
|
|
|
/* 5. SENDRECEIVE */
|
|
|
|
TRACE( "SENDRECEIVE\n" );
|
|
|
|
if (proc_header->Oi_flags & Oi_OBJECT_PROC)
|
|
|
|
NdrProxySendReceive(This, stub_msg);
|
|
|
|
else if (Oif_flags.HasPipes)
|
|
|
|
/* NdrPipesSendReceive(...) */
|
|
|
|
FIXME("pipes not supported yet\n");
|
|
|
|
else if (proc_header->handle_type == FC_AUTO_HANDLE)
|
2019-05-21 06:30:55 +02:00
|
|
|
#if 0
|
2019-05-21 06:30:56 +02:00
|
|
|
NdrNsSendReceive(stub_msg, stub_msg->Buffer, pStubDesc->IMPLICIT_HANDLE_INFO.pAutoHandle);
|
2019-05-21 06:30:55 +02:00
|
|
|
#else
|
2019-05-21 06:30:56 +02:00
|
|
|
FIXME("using auto handle - call NdrNsSendReceive when it gets implemented\n");
|
2019-05-21 06:30:55 +02:00
|
|
|
#endif
|
2019-05-21 06:30:56 +02:00
|
|
|
else
|
|
|
|
NdrSendReceive(stub_msg, stub_msg->Buffer);
|
2019-05-21 06:30:55 +02:00
|
|
|
|
2019-05-21 06:30:56 +02:00
|
|
|
/* convert strings, floating point values and endianness into our
|
|
|
|
* preferred format */
|
|
|
|
if ((rpc_msg.DataRepresentation & 0x0000FFFFUL) != NDR_LOCAL_DATA_REPRESENTATION)
|
|
|
|
NdrConvert(stub_msg, format);
|
2019-05-21 06:30:55 +02:00
|
|
|
|
2019-05-21 06:30:56 +02:00
|
|
|
/* 6. UNMARSHAL */
|
|
|
|
TRACE( "UNMARSHAL\n" );
|
|
|
|
client_do_args(stub_msg, format, STUBLESS_UNMARSHAL, fpu_stack,
|
|
|
|
number_of_params, (unsigned char *)&retval);
|
2019-05-21 06:30:55 +02:00
|
|
|
}
|
2019-05-21 06:30:56 +02:00
|
|
|
__FINALLY_CTX(ndr_client_call_finally, &finally_ctx)
|
2019-05-21 06:30:55 +02:00
|
|
|
|
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
2017-07-25 11:48:54 +02:00
|
|
|
LONG_PTR CDECL DECLSPEC_HIDDEN ndr_client_call( PMIDL_STUB_DESC pStubDesc, PFORMAT_STRING pFormat,
|
|
|
|
void **stack_top, void **fpu_stack )
|
2006-01-05 12:19:05 +01:00
|
|
|
{
|
|
|
|
/* pointer to start of stack where arguments start */
|
|
|
|
MIDL_STUB_MESSAGE stubMsg;
|
|
|
|
/* procedure number */
|
|
|
|
unsigned short procedure_number;
|
|
|
|
/* size of stack */
|
|
|
|
unsigned short stack_size;
|
|
|
|
/* number of parameters. optional for client to give it to us */
|
2011-07-28 16:54:01 +02:00
|
|
|
unsigned int number_of_params;
|
2006-01-05 12:19:05 +01:00
|
|
|
/* 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
|
|
|
/* header for procedure string */
|
|
|
|
const NDR_PROC_HEADER * pProcHeader = (const NDR_PROC_HEADER *)&pFormat[0];
|
|
|
|
/* the value to return to the client from the remote procedure */
|
|
|
|
LONG_PTR RetVal = 0;
|
2006-05-25 00:03:54 +02:00
|
|
|
PFORMAT_STRING pHandleFormat;
|
2019-05-21 06:30:55 +02:00
|
|
|
NDR_PARAM_OIF old_args[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
|
|
|
|
2009-01-23 16:09:42 +01:00
|
|
|
TRACE("NDR Version: 0x%x\n", pStubDesc->Version);
|
2006-01-05 12:19:05 +01:00
|
|
|
|
2018-06-13 04:19:10 +02:00
|
|
|
if (pProcHeader->Oi_flags & Oi_HAS_RPCFLAGS)
|
2006-01-05 12:19:05 +01:00
|
|
|
{
|
2012-04-27 17:13:44 +02:00
|
|
|
const NDR_PROC_HEADER_RPC *header_rpc = (const NDR_PROC_HEADER_RPC *)&pFormat[0];
|
|
|
|
stack_size = header_rpc->stack_size;
|
|
|
|
procedure_number = header_rpc->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
|
|
|
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: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 */
|
2018-06-13 04:19:10 +02:00
|
|
|
if (!(pProcHeader->Oi_flags & Oi_OBJECT_PROC))
|
2019-05-21 06:30:54 +02:00
|
|
|
pFormat += get_handle_desc_size(pProcHeader, pFormat);
|
2006-01-05 12:19:05 +01:00
|
|
|
|
2015-03-06 12:35:42 +01:00
|
|
|
if (is_oicf_stubdesc(pStubDesc)) /* -Oicf format */
|
2006-01-05 12:19:05 +01:00
|
|
|
{
|
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
|
|
|
|
2011-07-28 12:57:51 +02:00
|
|
|
TRACE("Oif_flags = %s\n", debugstr_INTERPRETER_OPT_FLAGS(Oif_flags) );
|
2006-01-05 12:19:05 +01:00
|
|
|
|
2011-06-13 13:39:21 +02:00
|
|
|
if (Oif_flags.HasExtensions)
|
|
|
|
{
|
|
|
|
const NDR_PROC_HEADER_EXTS *pExtensions = (const NDR_PROC_HEADER_EXTS *)pFormat;
|
|
|
|
ext_flags = pExtensions->Flags2;
|
|
|
|
pFormat += pExtensions->Size;
|
|
|
|
#ifdef __x86_64__
|
|
|
|
if (pExtensions->Size > sizeof(*pExtensions) && fpu_stack)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
unsigned short fpu_mask = *(unsigned short *)(pExtensions + 1);
|
|
|
|
for (i = 0; i < 4; i++, fpu_mask >>= 2)
|
|
|
|
switch (fpu_mask & 3)
|
|
|
|
{
|
|
|
|
case 1: *(float *)&stack_top[i] = *(float *)&fpu_stack[i]; break;
|
|
|
|
case 2: *(double *)&stack_top[i] = *(double *)&fpu_stack[i]; break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
2006-01-05 12:19:05 +01:00
|
|
|
}
|
2011-07-28 16:54:01 +02:00
|
|
|
else
|
|
|
|
{
|
|
|
|
pFormat = convert_old_args( &stubMsg, pFormat, stack_size,
|
2018-06-13 04:19:10 +02:00
|
|
|
pProcHeader->Oi_flags & Oi_OBJECT_PROC,
|
2019-05-21 06:30:55 +02:00
|
|
|
old_args, sizeof(old_args), &number_of_params );
|
2006-01-05 12:19:05 +01:00
|
|
|
}
|
|
|
|
|
2019-05-21 06:30:55 +02:00
|
|
|
if (pProcHeader->Oi_flags & Oi_OBJECT_PROC)
|
2008-01-17 13:25:52 +01:00
|
|
|
{
|
|
|
|
__TRY
|
|
|
|
{
|
2019-05-21 06:30:55 +02:00
|
|
|
RetVal = do_ndr_client_call(pStubDesc, pFormat, pHandleFormat,
|
|
|
|
stack_top, fpu_stack, &stubMsg, procedure_number, stack_size,
|
|
|
|
number_of_params, Oif_flags, ext_flags, pProcHeader);
|
2008-01-17 13:25:52 +01:00
|
|
|
}
|
2008-02-15 16:43:24 +01:00
|
|
|
__EXCEPT_ALL
|
2008-01-17 13:25:52 +01:00
|
|
|
{
|
2019-05-21 06:30:55 +02:00
|
|
|
/* 7. FREE */
|
|
|
|
TRACE( "FREE\n" );
|
|
|
|
client_do_args(&stubMsg, pFormat, STUBLESS_FREE, fpu_stack,
|
|
|
|
number_of_params, (unsigned char *)&RetVal);
|
|
|
|
RetVal = NdrProxyErrorHandler(GetExceptionCode());
|
2008-01-17 13:25:52 +01:00
|
|
|
}
|
|
|
|
__ENDTRY
|
|
|
|
}
|
2019-05-21 06:30:55 +02:00
|
|
|
else if (pProcHeader->Oi_flags & Oi_HAS_COMM_OR_FAULT)
|
2006-01-05 12:19:05 +01:00
|
|
|
{
|
2019-05-21 06:30:55 +02:00
|
|
|
__TRY
|
2006-01-05 12:19:05 +01:00
|
|
|
{
|
2019-05-21 06:30:55 +02:00
|
|
|
RetVal = do_ndr_client_call(pStubDesc, pFormat, pHandleFormat,
|
|
|
|
stack_top, fpu_stack, &stubMsg, procedure_number, stack_size,
|
|
|
|
number_of_params, Oif_flags, ext_flags, pProcHeader);
|
2011-07-28 22:34:57 +02:00
|
|
|
}
|
2019-05-21 06:30:55 +02:00
|
|
|
__EXCEPT_ALL
|
2011-07-28 22:34:57 +02:00
|
|
|
{
|
2019-05-21 06:30:55 +02:00
|
|
|
const COMM_FAULT_OFFSETS *comm_fault_offsets = &pStubDesc->CommFaultOffsets[procedure_number];
|
|
|
|
ULONG *comm_status;
|
|
|
|
ULONG *fault_status;
|
2006-01-05 12:19:05 +01:00
|
|
|
|
2019-05-21 06:30:55 +02:00
|
|
|
TRACE("comm_fault_offsets = {0x%hx, 0x%hx}\n", comm_fault_offsets->CommOffset, comm_fault_offsets->FaultOffset);
|
2006-01-05 12:19:05 +01:00
|
|
|
|
2019-05-21 06:30:55 +02:00
|
|
|
if (comm_fault_offsets->CommOffset == -1)
|
|
|
|
comm_status = (ULONG *)&RetVal;
|
|
|
|
else if (comm_fault_offsets->CommOffset >= 0)
|
|
|
|
comm_status = *(ULONG **)ARG_FROM_OFFSET(stubMsg.StackTop, comm_fault_offsets->CommOffset);
|
|
|
|
else
|
|
|
|
comm_status = NULL;
|
2006-01-05 12:19:05 +01:00
|
|
|
|
2019-05-21 06:30:55 +02:00
|
|
|
if (comm_fault_offsets->FaultOffset == -1)
|
|
|
|
fault_status = (ULONG *)&RetVal;
|
|
|
|
else if (comm_fault_offsets->FaultOffset >= 0)
|
|
|
|
fault_status = *(ULONG **)ARG_FROM_OFFSET(stubMsg.StackTop, comm_fault_offsets->FaultOffset);
|
|
|
|
else
|
|
|
|
fault_status = NULL;
|
2006-01-05 12:19:05 +01:00
|
|
|
|
2019-05-21 06:30:55 +02:00
|
|
|
NdrMapCommAndFaultStatus(&stubMsg, comm_status, fault_status,
|
|
|
|
GetExceptionCode());
|
|
|
|
}
|
|
|
|
__ENDTRY
|
2006-01-05 12:19:05 +01:00
|
|
|
}
|
|
|
|
else
|
2006-05-25 00:03:54 +02:00
|
|
|
{
|
2019-05-21 06:30:55 +02:00
|
|
|
RetVal = do_ndr_client_call(pStubDesc, pFormat, pHandleFormat,
|
|
|
|
stack_top, fpu_stack, &stubMsg, procedure_number, stack_size,
|
|
|
|
number_of_params, Oif_flags, ext_flags, pProcHeader);
|
2006-05-25 00:03:54 +02:00
|
|
|
}
|
2006-01-05 12:19:05 +01:00
|
|
|
|
|
|
|
TRACE("RetVal = 0x%lx\n", RetVal);
|
2011-06-13 12:39:47 +02:00
|
|
|
return RetVal;
|
|
|
|
}
|
|
|
|
|
2011-06-13 12:40:30 +02:00
|
|
|
#ifdef __x86_64__
|
|
|
|
|
|
|
|
__ASM_GLOBAL_FUNC( NdrClientCall2,
|
|
|
|
"movq %r8,0x18(%rsp)\n\t"
|
|
|
|
"movq %r9,0x20(%rsp)\n\t"
|
|
|
|
"leaq 0x18(%rsp),%r8\n\t"
|
2011-06-13 13:39:21 +02:00
|
|
|
"xorq %r9,%r9\n\t"
|
2011-06-13 12:40:30 +02:00
|
|
|
"subq $0x28,%rsp\n\t"
|
|
|
|
__ASM_CFI(".cfi_adjust_cfa_offset 0x28\n\t")
|
|
|
|
"call " __ASM_NAME("ndr_client_call") "\n\t"
|
|
|
|
"addq $0x28,%rsp\n\t"
|
|
|
|
__ASM_CFI(".cfi_adjust_cfa_offset -0x28\n\t")
|
|
|
|
"ret" );
|
|
|
|
|
|
|
|
#else /* __x86_64__ */
|
|
|
|
|
2011-06-13 12:39:47 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* NdrClientCall2 [RPCRT4.@]
|
|
|
|
*/
|
|
|
|
CLIENT_CALL_RETURN WINAPIV NdrClientCall2( PMIDL_STUB_DESC desc, PFORMAT_STRING format, ... )
|
|
|
|
{
|
|
|
|
__ms_va_list args;
|
|
|
|
LONG_PTR ret;
|
|
|
|
|
|
|
|
__ms_va_start( args, format );
|
2011-06-13 13:39:21 +02:00
|
|
|
ret = ndr_client_call( desc, format, va_arg( args, void ** ), NULL );
|
2011-06-13 12:39:47 +02:00
|
|
|
__ms_va_end( args );
|
|
|
|
return *(CLIENT_CALL_RETURN *)&ret;
|
2006-01-05 12:19:05 +01:00
|
|
|
}
|
|
|
|
|
2011-06-13 12:40:30 +02:00
|
|
|
#endif /* __x86_64__ */
|
2011-06-13 12:39:47 +02:00
|
|
|
|
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
|
2012-09-22 12:38:11 +02:00
|
|
|
mov ebp, esp
|
2006-01-05 12:19:05 +01:00
|
|
|
push edi ; Save registers
|
|
|
|
push esi
|
|
|
|
mov eax, [ebp+16] ; Get stack size
|
|
|
|
sub esp, eax ; Make room in stack for arguments
|
2012-09-22 12:38:11 +02:00
|
|
|
and esp, 0xFFFFFFF0
|
2006-01-05 12:19:05 +01:00
|
|
|
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"
|
2009-06-25 11:51:30 +02:00
|
|
|
__ASM_CFI(".cfi_adjust_cfa_offset 4\n\t")
|
|
|
|
__ASM_CFI(".cfi_rel_offset %ebp,0\n\t")
|
|
|
|
"movl %esp,%ebp\n\t"
|
|
|
|
__ASM_CFI(".cfi_def_cfa_register %ebp\n\t")
|
2006-01-05 12:19:05 +01:00
|
|
|
"pushl %edi\n\t" /* Save registers */
|
2009-06-25 11:51:30 +02:00
|
|
|
__ASM_CFI(".cfi_rel_offset %edi,-4\n\t")
|
2006-01-05 12:19:05 +01:00
|
|
|
"pushl %esi\n\t"
|
2009-06-25 11:51:30 +02:00
|
|
|
__ASM_CFI(".cfi_rel_offset %esi,-8\n\t")
|
2006-01-05 12:19:05 +01:00
|
|
|
"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 */
|
2009-06-25 11:51:30 +02:00
|
|
|
__ASM_CFI(".cfi_same_value %esi\n\t")
|
2006-01-05 12:19:05 +01:00
|
|
|
"popl %edi\n\t"
|
2009-06-25 11:51:30 +02:00
|
|
|
__ASM_CFI(".cfi_same_value %edi\n\t")
|
2006-01-05 12:19:05 +01:00
|
|
|
"popl %ebp\n\t"
|
2009-06-25 11:51:30 +02:00
|
|
|
__ASM_CFI(".cfi_def_cfa %esp,4\n\t")
|
|
|
|
__ASM_CFI(".cfi_same_value %ebp\n\t")
|
|
|
|
"ret" )
|
2011-06-13 12:43:12 +02:00
|
|
|
#elif defined __x86_64__
|
|
|
|
LONG_PTR __cdecl call_server_func(SERVER_ROUTINE func, unsigned char * args, unsigned int stack_size);
|
|
|
|
__ASM_GLOBAL_FUNC( call_server_func,
|
|
|
|
"pushq %rbp\n\t"
|
2019-08-21 11:28:26 +02:00
|
|
|
__ASM_SEH(".seh_pushreg %rbp\n\t")
|
2011-06-13 12:43:12 +02:00
|
|
|
__ASM_CFI(".cfi_adjust_cfa_offset 8\n\t")
|
|
|
|
__ASM_CFI(".cfi_rel_offset %rbp,0\n\t")
|
|
|
|
"movq %rsp,%rbp\n\t"
|
2019-08-21 11:28:26 +02:00
|
|
|
__ASM_SEH(".seh_setframe %rbp,0\n\t")
|
2011-06-13 12:43:12 +02:00
|
|
|
__ASM_CFI(".cfi_def_cfa_register %rbp\n\t")
|
|
|
|
"pushq %rsi\n\t"
|
2019-08-21 11:28:26 +02:00
|
|
|
__ASM_SEH(".seh_pushreg %rsi\n\t")
|
2011-06-13 12:43:12 +02:00
|
|
|
__ASM_CFI(".cfi_rel_offset %rsi,-8\n\t")
|
|
|
|
"pushq %rdi\n\t"
|
2019-08-21 11:28:26 +02:00
|
|
|
__ASM_SEH(".seh_pushreg %rdi\n\t")
|
|
|
|
__ASM_SEH(".seh_endprologue\n\t")
|
2011-06-13 12:43:12 +02:00
|
|
|
__ASM_CFI(".cfi_rel_offset %rdi,-16\n\t")
|
|
|
|
"movq %rcx,%rax\n\t" /* function to call */
|
|
|
|
"movq $32,%rcx\n\t" /* allocate max(32,stack_size) bytes of stack space */
|
|
|
|
"cmpq %rcx,%r8\n\t"
|
|
|
|
"cmovgq %r8,%rcx\n\t"
|
|
|
|
"subq %rcx,%rsp\n\t"
|
|
|
|
"andq $~15,%rsp\n\t"
|
|
|
|
"movq %r8,%rcx\n\t"
|
|
|
|
"shrq $3,%rcx\n\t"
|
|
|
|
"movq %rsp,%rdi\n\t"
|
|
|
|
"movq %rdx,%rsi\n\t"
|
|
|
|
"rep; movsq\n\t" /* copy arguments */
|
|
|
|
"movq 0(%rsp),%rcx\n\t"
|
|
|
|
"movq 8(%rsp),%rdx\n\t"
|
|
|
|
"movq 16(%rsp),%r8\n\t"
|
|
|
|
"movq 24(%rsp),%r9\n\t"
|
2015-04-28 16:20:13 +02:00
|
|
|
"movq 0(%rsp),%xmm0\n\t"
|
|
|
|
"movq 8(%rsp),%xmm1\n\t"
|
|
|
|
"movq 16(%rsp),%xmm2\n\t"
|
|
|
|
"movq 24(%rsp),%xmm3\n\t"
|
2011-06-13 12:43:12 +02:00
|
|
|
"callq *%rax\n\t"
|
|
|
|
"leaq -16(%rbp),%rsp\n\t" /* restore stack */
|
|
|
|
"popq %rdi\n\t"
|
|
|
|
__ASM_CFI(".cfi_same_value %rdi\n\t")
|
|
|
|
"popq %rsi\n\t"
|
|
|
|
__ASM_CFI(".cfi_same_value %rsi\n\t")
|
|
|
|
__ASM_CFI(".cfi_def_cfa_register %rsp\n\t")
|
|
|
|
"popq %rbp\n\t"
|
|
|
|
__ASM_CFI(".cfi_adjust_cfa_offset -8\n\t")
|
|
|
|
__ASM_CFI(".cfi_same_value %rbp\n\t")
|
|
|
|
"ret")
|
2015-08-09 14:09:24 +02:00
|
|
|
#elif defined __arm__
|
|
|
|
LONG_PTR __cdecl call_server_func(SERVER_ROUTINE func, unsigned char *args, unsigned int stack_size);
|
|
|
|
__ASM_GLOBAL_FUNC( call_server_func,
|
|
|
|
"push {r4, r5, LR}\n\t"
|
|
|
|
"mov r4, r0\n\t"
|
|
|
|
"mov r5, SP\n\t"
|
|
|
|
"lsr r3, r2, #2\n\t"
|
|
|
|
"cmp r3, #0\n\t"
|
|
|
|
"beq 5f\n\t"
|
|
|
|
"sub SP, SP, r2\n\t"
|
|
|
|
"tst r3, #1\n\t"
|
2021-01-18 11:44:10 +01:00
|
|
|
"it eq\n\t"
|
2015-08-09 14:09:24 +02:00
|
|
|
"subeq SP, SP, #4\n\t"
|
|
|
|
"1:\tsub r2, r2, #4\n\t"
|
|
|
|
"ldr r0, [r1, r2]\n\t"
|
|
|
|
"str r0, [SP, r2]\n\t"
|
|
|
|
"cmp r2, #0\n\t"
|
|
|
|
"bgt 1b\n\t"
|
|
|
|
"cmp r3, #1\n\t"
|
|
|
|
"bgt 2f\n\t"
|
|
|
|
"pop {r0}\n\t"
|
|
|
|
"b 5f\n\t"
|
|
|
|
"2:\tcmp r3, #2\n\t"
|
|
|
|
"bgt 3f\n\t"
|
|
|
|
"pop {r0-r1}\n\t"
|
|
|
|
"b 5f\n\t"
|
|
|
|
"3:\tcmp r3, #3\n\t"
|
|
|
|
"bgt 4f\n\t"
|
|
|
|
"pop {r0-r2}\n\t"
|
|
|
|
"b 5f\n\t"
|
|
|
|
"4:\tpop {r0-r3}\n\t"
|
|
|
|
"5:\tblx r4\n\t"
|
|
|
|
"mov SP, r5\n\t"
|
|
|
|
"pop {r4, r5, PC}" )
|
2019-09-27 12:39:49 +02:00
|
|
|
#elif defined __aarch64__
|
|
|
|
LONG_PTR __cdecl call_server_func(SERVER_ROUTINE func, unsigned char *args, unsigned int stack_size);
|
|
|
|
__ASM_GLOBAL_FUNC( call_server_func,
|
|
|
|
"stp x29, x30, [sp, #-16]!\n\t"
|
|
|
|
"mov x29, sp\n\t"
|
2020-09-18 02:52:46 +02:00
|
|
|
"add x9, x2, #15\n\t"
|
|
|
|
"lsr x9, x9, #4\n\t"
|
|
|
|
"sub sp, sp, x9, lsl #4\n\t"
|
2019-09-27 12:39:49 +02:00
|
|
|
"cbz x2, 2f\n"
|
|
|
|
"1:\tsub x2, x2, #8\n\t"
|
|
|
|
"ldr x4, [x1, x2]\n\t"
|
|
|
|
"str x4, [sp, x2]\n\t"
|
|
|
|
"cbnz x2, 1b\n"
|
|
|
|
"2:\tmov x8, x0\n\t"
|
2020-09-18 02:52:46 +02:00
|
|
|
"cbz x9, 3f\n\t"
|
2019-09-27 12:39:49 +02:00
|
|
|
"ldp x0, x1, [sp], #16\n\t"
|
2020-09-18 02:52:46 +02:00
|
|
|
"cmp x9, #1\n\t"
|
2019-09-27 12:39:49 +02:00
|
|
|
"b.le 3f\n\t"
|
|
|
|
"ldp x2, x3, [sp], #16\n\t"
|
2020-09-18 02:52:46 +02:00
|
|
|
"cmp x9, #2\n\t"
|
2019-09-27 12:39:49 +02:00
|
|
|
"b.le 3f\n\t"
|
|
|
|
"ldp x4, x5, [sp], #16\n\t"
|
2020-09-18 02:52:46 +02:00
|
|
|
"cmp x9, #3\n\t"
|
2019-09-27 12:39:49 +02:00
|
|
|
"b.le 3f\n\t"
|
|
|
|
"ldp x6, x7, [sp], #16\n"
|
|
|
|
"3:\tblr x8\n\t"
|
|
|
|
"mov sp, x29\n\t"
|
|
|
|
"ldp x29, x30, [sp], #16\n\t"
|
|
|
|
"ret" )
|
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
|
|
|
|
|
2007-11-02 20:09:23 +01:00
|
|
|
static LONG_PTR *stub_do_args(MIDL_STUB_MESSAGE *pStubMsg,
|
2011-07-28 22:34:57 +02:00
|
|
|
PFORMAT_STRING pFormat, enum stubless_phase phase,
|
2007-11-02 20:09:23 +01:00
|
|
|
unsigned short number_of_params)
|
|
|
|
{
|
2011-07-28 12:43:27 +02:00
|
|
|
const NDR_PARAM_OIF *params = (const NDR_PARAM_OIF *)pFormat;
|
|
|
|
unsigned int i;
|
2007-11-02 20:09:23 +01:00
|
|
|
LONG_PTR *retval_ptr = NULL;
|
|
|
|
|
|
|
|
for (i = 0; i < number_of_params; i++)
|
|
|
|
{
|
2011-07-28 12:48:39 +02:00
|
|
|
unsigned char *pArg = pStubMsg->StackTop + params[i].stack_offset;
|
2011-07-28 22:13:45 +02:00
|
|
|
const unsigned char *pTypeFormat = &pStubMsg->StubDesc->pFormatTypes[params[i].u.type_offset];
|
2007-11-02 20:09:23 +01:00
|
|
|
|
2011-07-28 22:13:45 +02:00
|
|
|
TRACE("param[%d]: %p -> %p type %02x %s\n", i,
|
|
|
|
pArg, *(unsigned char **)pArg,
|
|
|
|
params[i].attr.IsBasetype ? params[i].u.type_format_char : *pTypeFormat,
|
|
|
|
debugstr_PROC_PF( params[i].attr ));
|
2007-11-02 20:09:23 +01:00
|
|
|
|
2011-07-28 22:13:45 +02:00
|
|
|
switch (phase)
|
2007-11-02 20:09:23 +01:00
|
|
|
{
|
2011-07-28 22:13:45 +02:00
|
|
|
case STUBLESS_MARSHAL:
|
|
|
|
if (params[i].attr.IsOut || params[i].attr.IsReturn)
|
|
|
|
call_marshaller(pStubMsg, pArg, ¶ms[i]);
|
|
|
|
break;
|
2015-09-07 18:45:10 +02:00
|
|
|
case STUBLESS_MUSTFREE:
|
2011-07-28 22:13:45 +02:00
|
|
|
if (params[i].attr.MustFree)
|
2007-11-02 20:09:23 +01:00
|
|
|
{
|
2011-07-28 22:13:45 +02:00
|
|
|
call_freer(pStubMsg, pArg, ¶ms[i]);
|
2007-11-02 20:09:23 +01:00
|
|
|
}
|
2015-09-07 18:45:10 +02:00
|
|
|
break;
|
|
|
|
case STUBLESS_FREE:
|
|
|
|
if (params[i].attr.ServerAllocSize)
|
2007-11-02 20:09:23 +01:00
|
|
|
{
|
2011-07-28 22:13:45 +02:00
|
|
|
HeapFree(GetProcessHeap(), 0, *(void **)pArg);
|
|
|
|
}
|
2017-11-08 12:19:56 +01:00
|
|
|
else if (param_needs_alloc(params[i].attr) &&
|
|
|
|
(!params[i].attr.MustFree || params[i].attr.IsSimpleRef))
|
2011-07-28 22:13:45 +02:00
|
|
|
{
|
2018-06-13 04:19:10 +02:00
|
|
|
if (*pTypeFormat != FC_BIND_CONTEXT) pStubMsg->pfnFree(*(void **)pArg);
|
2011-07-28 22:13:45 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case STUBLESS_INITOUT:
|
2017-11-08 12:19:56 +01:00
|
|
|
if (param_needs_alloc(params[i].attr) && !params[i].attr.ServerAllocSize)
|
2011-07-28 22:13:45 +02:00
|
|
|
{
|
2018-06-13 04:19:10 +02:00
|
|
|
if (*pTypeFormat == FC_BIND_CONTEXT)
|
2011-07-28 22:13:45 +02:00
|
|
|
{
|
|
|
|
NDR_SCONTEXT ctxt = NdrContextHandleInitialize(pStubMsg, pTypeFormat);
|
|
|
|
*(void **)pArg = NDRSContextValue(ctxt);
|
2019-01-25 12:01:16 +01:00
|
|
|
if (params[i].attr.IsReturn) retval_ptr = (LONG_PTR *)NDRSContextValue(ctxt);
|
2011-07-28 22:13:45 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
DWORD size = calc_arg_size(pStubMsg, pTypeFormat);
|
|
|
|
if (size)
|
2007-11-02 20:09:23 +01:00
|
|
|
{
|
2011-07-28 22:13:45 +02:00
|
|
|
*(void **)pArg = NdrAllocate(pStubMsg, size);
|
|
|
|
memset(*(void **)pArg, 0, size);
|
2007-11-02 20:09:23 +01:00
|
|
|
}
|
2011-07-28 22:13:45 +02:00
|
|
|
}
|
2007-11-02 20:09:23 +01:00
|
|
|
}
|
2019-01-25 12:01:16 +01:00
|
|
|
if (!retval_ptr && params[i].attr.IsReturn) retval_ptr = (LONG_PTR *)pArg;
|
2011-07-28 22:13:45 +02:00
|
|
|
break;
|
|
|
|
case STUBLESS_UNMARSHAL:
|
|
|
|
if (params[i].attr.ServerAllocSize)
|
|
|
|
*(void **)pArg = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
|
|
|
|
params[i].attr.ServerAllocSize * 8);
|
|
|
|
|
|
|
|
if (params[i].attr.IsIn)
|
|
|
|
call_unmarshaller(pStubMsg, &pArg, ¶ms[i], 0);
|
|
|
|
break;
|
|
|
|
case STUBLESS_CALCSIZE:
|
|
|
|
if (params[i].attr.IsOut || params[i].attr.IsReturn)
|
|
|
|
call_buffer_sizer(pStubMsg, pArg, ¶ms[i]);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
RpcRaiseException(RPC_S_INTERNAL_ERROR);
|
2007-11-02 20:09:23 +01:00
|
|
|
}
|
|
|
|
TRACE("\tmemory addr (after): %p -> %p\n", pArg, *(unsigned char **)pArg);
|
|
|
|
}
|
|
|
|
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 */
|
2011-07-28 17:48:19 +02:00
|
|
|
unsigned int number_of_params;
|
2006-01-05 12:19:05 +01:00
|
|
|
/* 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 */
|
2011-07-28 22:34:57 +02:00
|
|
|
enum stubless_phase phase;
|
2006-01-05 12:19:05 +01:00
|
|
|
/* header for procedure string */
|
|
|
|
const NDR_PROC_HEADER *pProcHeader;
|
2006-04-20 12:43:22 +02:00
|
|
|
/* location to put retval into */
|
|
|
|
LONG_PTR *retval_ptr = NULL;
|
2011-07-28 17:48:19 +02:00
|
|
|
/* correlation cache */
|
|
|
|
ULONG_PTR NdrCorrCache[256];
|
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];
|
|
|
|
|
2009-01-23 16:09:42 +01:00
|
|
|
TRACE("NDR Version: 0x%x\n", pStubDesc->Version);
|
2006-01-05 12:19:05 +01:00
|
|
|
|
2018-06-13 04:19:10 +02:00
|
|
|
if (pProcHeader->Oi_flags & Oi_HAS_RPCFLAGS)
|
2006-01-05 12:19:05 +01:00
|
|
|
{
|
2012-04-27 17:13:44 +02:00
|
|
|
const NDR_PROC_HEADER_RPC *header_rpc = (const NDR_PROC_HEADER_RPC *)&pFormat[0];
|
|
|
|
stack_size = header_rpc->stack_size;
|
2011-07-28 17:48:19 +02:00
|
|
|
pFormat += sizeof(NDR_PROC_HEADER_RPC);
|
2006-01-05 12:19:05 +01:00
|
|
|
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
stack_size = pProcHeader->stack_size;
|
2011-07-28 17:48:19 +02:00
|
|
|
pFormat += sizeof(NDR_PROC_HEADER);
|
2006-01-05 12:19:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
TRACE("Oi_flags = 0x%02x\n", pProcHeader->Oi_flags);
|
|
|
|
|
|
|
|
/* binding */
|
|
|
|
switch (pProcHeader->handle_type)
|
|
|
|
{
|
|
|
|
/* explicit binding: parse additional section */
|
2018-06-13 04:19:10 +02:00
|
|
|
case 0:
|
2011-07-28 17:48:19 +02:00
|
|
|
switch (*pFormat) /* handle_type */
|
2006-01-05 12:19:05 +01:00
|
|
|
{
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_BIND_PRIMITIVE: /* explicit primitive */
|
2011-07-28 17:48:19 +02:00
|
|
|
pFormat += sizeof(NDR_EHD_PRIMITIVE);
|
2006-01-05 12:19:05 +01:00
|
|
|
break;
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_BIND_GENERIC: /* explicit generic */
|
2011-07-28 17:48:19 +02:00
|
|
|
pFormat += sizeof(NDR_EHD_GENERIC);
|
2006-01-05 12:19:05 +01:00
|
|
|
break;
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_BIND_CONTEXT: /* explicit context */
|
2011-07-28 17:48:19 +02:00
|
|
|
pFormat += sizeof(NDR_EHD_CONTEXT);
|
2006-01-05 12:19:05 +01:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
ERR("bad explicit binding handle type (0x%02x)\n", pProcHeader->handle_type);
|
|
|
|
RpcRaiseException(RPC_X_BAD_STUB_DATA);
|
|
|
|
}
|
|
|
|
break;
|
2018-06-13 04:19:10 +02:00
|
|
|
case FC_BIND_GENERIC: /* implicit generic */
|
|
|
|
case FC_BIND_PRIMITIVE: /* implicit primitive */
|
|
|
|
case FC_CALLBACK_HANDLE: /* implicit callback */
|
|
|
|
case FC_AUTO_HANDLE: /* implicit auto handle */
|
2006-01-05 12:19:05 +01:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
ERR("bad implicit binding handle type (0x%02x)\n", pProcHeader->handle_type);
|
|
|
|
RpcRaiseException(RPC_X_BAD_STUB_DATA);
|
|
|
|
}
|
|
|
|
|
2018-06-13 04:19:10 +02:00
|
|
|
if (pProcHeader->Oi_flags & Oi_OBJECT_PROC)
|
2006-01-05 12:19:05 +01:00
|
|
|
NdrStubInitialize(pRpcMsg, &stubMsg, pStubDesc, pChannel);
|
|
|
|
else
|
|
|
|
NdrServerInitializeNew(pRpcMsg, &stubMsg, pStubDesc);
|
|
|
|
|
2009-10-26 12:33:39 +01:00
|
|
|
/* create the full pointer translation tables, if requested */
|
2018-06-13 04:19:10 +02:00
|
|
|
if (pProcHeader->Oi_flags & Oi_FULL_PTR_USED)
|
2009-10-26 12:33:39 +01:00
|
|
|
stubMsg.FullPtrXlatTables = NdrFullPointerXlatInit(0,XLAT_SERVER);
|
|
|
|
|
2006-01-05 12:19:05 +01:00
|
|
|
/* store the RPC flags away */
|
2018-06-13 04:19:10 +02:00
|
|
|
if (pProcHeader->Oi_flags & Oi_HAS_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 */
|
2018-06-13 04:19:10 +02:00
|
|
|
if (pProcHeader->Oi_flags & Oi_RPCSS_ALLOC_USED)
|
2006-01-05 12:19:05 +01:00
|
|
|
#if 0
|
|
|
|
NdrRpcSsEnableAllocate(&stubMsg);
|
|
|
|
#else
|
|
|
|
FIXME("Set RPCSS memory allocation routines\n");
|
|
|
|
#endif
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
2015-03-06 12:35:42 +01:00
|
|
|
if (is_oicf_stubdesc(pStubDesc))
|
2011-07-28 17:48:19 +02:00
|
|
|
{
|
|
|
|
const NDR_PROC_PARTIAL_OIF_HEADER *pOIFHeader = (const NDR_PROC_PARTIAL_OIF_HEADER *)pFormat;
|
|
|
|
|
|
|
|
Oif_flags = pOIFHeader->Oi2Flags;
|
|
|
|
number_of_params = pOIFHeader->number_of_params;
|
|
|
|
|
|
|
|
pFormat += sizeof(NDR_PROC_PARTIAL_OIF_HEADER);
|
|
|
|
|
|
|
|
TRACE("Oif_flags = %s\n", debugstr_INTERPRETER_OPT_FLAGS(Oif_flags) );
|
|
|
|
|
|
|
|
if (Oif_flags.HasExtensions)
|
|
|
|
{
|
|
|
|
const NDR_PROC_HEADER_EXTS *pExtensions = (const NDR_PROC_HEADER_EXTS *)pFormat;
|
|
|
|
ext_flags = pExtensions->Flags2;
|
|
|
|
pFormat += pExtensions->Size;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (Oif_flags.HasPipes)
|
|
|
|
{
|
|
|
|
FIXME("pipes not supported yet\n");
|
|
|
|
RpcRaiseException(RPC_X_WRONG_STUB_VERSION); /* FIXME: remove when implemented */
|
|
|
|
/* init pipes package */
|
|
|
|
/* NdrPipesInitialize(...) */
|
|
|
|
}
|
|
|
|
if (ext_flags.HasNewCorrDesc)
|
|
|
|
{
|
|
|
|
/* initialize extra correlation package */
|
2015-07-13 14:11:37 +02:00
|
|
|
NdrCorrelationInitialize(&stubMsg, NdrCorrCache, sizeof(NdrCorrCache), 0);
|
2015-07-13 14:11:39 +02:00
|
|
|
if (ext_flags.Unused & 0x2) /* has range on conformance */
|
|
|
|
stubMsg.CorrDespIncrement = 12;
|
2011-07-28 17:48:19 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
pFormat = convert_old_args( &stubMsg, pFormat, stack_size,
|
2018-06-13 04:19:10 +02:00
|
|
|
pProcHeader->Oi_flags & Oi_OBJECT_PROC,
|
2011-07-28 17:48:19 +02:00
|
|
|
/* reuse the correlation cache, it's not needed for v1 format */
|
|
|
|
NdrCorrCache, sizeof(NdrCorrCache), &number_of_params );
|
|
|
|
}
|
|
|
|
|
2011-08-24 15:28:14 +02:00
|
|
|
/* convert strings, floating point values and endianness into our
|
2011-07-28 17:48:19 +02:00
|
|
|
* preferred format */
|
|
|
|
if ((pRpcMsg->DataRepresentation & 0x0000FFFFUL) != NDR_LOCAL_DATA_REPRESENTATION)
|
|
|
|
NdrConvert(&stubMsg, pFormat);
|
|
|
|
|
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;
|
|
|
|
|
2018-06-13 04:19:10 +02:00
|
|
|
if (pProcHeader->Oi_flags & Oi_OBJECT_PROC)
|
2006-04-20 12:43:22 +02:00
|
|
|
{
|
|
|
|
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:
|
2018-06-13 04:19:10 +02:00
|
|
|
if (pProcHeader->Oi_flags & Oi_OBJECT_PROC)
|
2006-01-05 12:19:05 +01:00
|
|
|
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:
|
2015-09-07 18:45:10 +02:00
|
|
|
case STUBLESS_MUSTFREE:
|
2007-06-25 15:22:29 +02:00
|
|
|
case STUBLESS_FREE:
|
2011-07-28 17:48:19 +02:00
|
|
|
retval_ptr = stub_do_args(&stubMsg, pFormat, phase, number_of_params);
|
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 */
|
2015-07-13 14:11:37 +02: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 */
|
2018-06-13 04:19:10 +02:00
|
|
|
if (pProcHeader->Oi_flags & Oi_FULL_PTR_USED)
|
2006-01-05 12:19:05 +01:00
|
|
|
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
|
|
|
}
|
2009-03-18 11:59:35 +01:00
|
|
|
|
2011-06-02 14:40:01 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* NdrStubCall [RPCRT4.@]
|
|
|
|
*/
|
|
|
|
LONG WINAPI NdrStubCall( struct IRpcStubBuffer *This, struct IRpcChannelBuffer *channel,
|
|
|
|
PRPC_MESSAGE msg, DWORD *phase )
|
|
|
|
{
|
|
|
|
return NdrStubCall2( This, channel, msg, phase );
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* NdrServerCall [RPCRT4.@]
|
|
|
|
*/
|
|
|
|
void WINAPI NdrServerCall( PRPC_MESSAGE msg )
|
|
|
|
{
|
|
|
|
DWORD phase;
|
|
|
|
NdrStubCall( NULL, NULL, msg, &phase );
|
|
|
|
}
|
|
|
|
|
2019-05-06 20:09:47 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* NdrServerCallAll [RPCRT4.@]
|
|
|
|
*/
|
|
|
|
void WINAPI NdrServerCallAll( PRPC_MESSAGE msg )
|
|
|
|
{
|
|
|
|
FIXME("%p stub\n", msg);
|
|
|
|
}
|
|
|
|
|
2019-08-28 11:51:48 +02:00
|
|
|
/* Helper for ndr_async_client_call, to factor out the part that may or may not be
|
|
|
|
* guarded by a try/except block. */
|
|
|
|
static void do_ndr_async_client_call( const MIDL_STUB_DESC *pStubDesc, PFORMAT_STRING pFormat, void **stack_top )
|
2009-03-18 11:59:35 +01:00
|
|
|
{
|
|
|
|
/* pointer to start of stack where arguments start */
|
|
|
|
PRPC_MESSAGE pRpcMsg;
|
|
|
|
PMIDL_STUB_MESSAGE pStubMsg;
|
|
|
|
RPC_ASYNC_STATE *pAsync;
|
|
|
|
struct async_call_data *async_call_data;
|
|
|
|
/* procedure number */
|
|
|
|
unsigned short procedure_number;
|
|
|
|
/* cache of Oif_flags from v2 procedure header */
|
|
|
|
INTERPRETER_OPT_FLAGS Oif_flags = { 0 };
|
|
|
|
/* cache of extension flags from NDR_PROC_HEADER_EXTS */
|
|
|
|
INTERPRETER_OPT_FLAGS2 ext_flags = { 0 };
|
|
|
|
/* header for procedure string */
|
|
|
|
const NDR_PROC_HEADER * pProcHeader = (const NDR_PROC_HEADER *)&pFormat[0];
|
2011-07-28 22:34:57 +02:00
|
|
|
RPC_STATUS status;
|
2009-03-18 11:59:35 +01:00
|
|
|
|
|
|
|
/* Later NDR language versions probably won't be backwards compatible */
|
2020-04-05 01:15:32 +02:00
|
|
|
if (pStubDesc->Version > 0x60001)
|
2009-03-18 11:59:35 +01:00
|
|
|
{
|
|
|
|
FIXME("Incompatible stub description version: 0x%x\n", pStubDesc->Version);
|
|
|
|
RpcRaiseException(RPC_X_WRONG_STUB_VERSION);
|
|
|
|
}
|
|
|
|
|
|
|
|
async_call_data = I_RpcAllocate(sizeof(*async_call_data) + sizeof(MIDL_STUB_MESSAGE) + sizeof(RPC_MESSAGE));
|
2015-03-03 08:41:57 +01:00
|
|
|
if (!async_call_data) RpcRaiseException(RPC_X_NO_MEMORY);
|
2009-03-18 11:59:35 +01:00
|
|
|
async_call_data->pProcHeader = pProcHeader;
|
|
|
|
|
|
|
|
async_call_data->pStubMsg = pStubMsg = (PMIDL_STUB_MESSAGE)(async_call_data + 1);
|
|
|
|
pRpcMsg = (PRPC_MESSAGE)(pStubMsg + 1);
|
|
|
|
|
2018-06-13 04:19:10 +02:00
|
|
|
if (pProcHeader->Oi_flags & Oi_HAS_RPCFLAGS)
|
2009-03-18 11:59:35 +01:00
|
|
|
{
|
2012-04-27 17:13:44 +02:00
|
|
|
const NDR_PROC_HEADER_RPC *header_rpc = (const NDR_PROC_HEADER_RPC *)&pFormat[0];
|
|
|
|
async_call_data->stack_size = header_rpc->stack_size;
|
|
|
|
procedure_number = header_rpc->proc_num;
|
2009-03-18 11:59:35 +01:00
|
|
|
pFormat += sizeof(NDR_PROC_HEADER_RPC);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
async_call_data->stack_size = pProcHeader->stack_size;
|
|
|
|
procedure_number = pProcHeader->proc_num;
|
|
|
|
pFormat += sizeof(NDR_PROC_HEADER);
|
|
|
|
}
|
|
|
|
TRACE("stack size: 0x%x\n", async_call_data->stack_size);
|
|
|
|
TRACE("proc num: %d\n", procedure_number);
|
|
|
|
|
|
|
|
/* create the full pointer translation tables, if requested */
|
2018-06-13 04:19:10 +02:00
|
|
|
if (pProcHeader->Oi_flags & Oi_FULL_PTR_USED)
|
2009-03-18 11:59:35 +01:00
|
|
|
pStubMsg->FullPtrXlatTables = NdrFullPointerXlatInit(0,XLAT_CLIENT);
|
|
|
|
|
2018-06-13 04:19:10 +02:00
|
|
|
if (pProcHeader->Oi_flags & Oi_OBJECT_PROC)
|
2009-03-18 11:59:35 +01:00
|
|
|
{
|
|
|
|
ERR("objects not supported\n");
|
|
|
|
I_RpcFree(async_call_data);
|
|
|
|
RpcRaiseException(RPC_X_BAD_STUB_DATA);
|
|
|
|
}
|
|
|
|
|
|
|
|
NdrClientInitializeNew(pRpcMsg, pStubMsg, pStubDesc, procedure_number);
|
|
|
|
|
|
|
|
TRACE("Oi_flags = 0x%02x\n", pProcHeader->Oi_flags);
|
|
|
|
TRACE("MIDL stub version = 0x%x\n", pStubDesc->MIDLVersion);
|
|
|
|
|
|
|
|
/* needed for conformance of top-level objects */
|
|
|
|
pStubMsg->StackTop = I_RpcAllocate(async_call_data->stack_size);
|
2011-06-15 17:30:49 +02:00
|
|
|
memcpy(pStubMsg->StackTop, stack_top, async_call_data->stack_size);
|
2009-03-18 11:59:35 +01:00
|
|
|
|
|
|
|
pAsync = *(RPC_ASYNC_STATE **)pStubMsg->StackTop;
|
|
|
|
pAsync->StubInfo = async_call_data;
|
|
|
|
async_call_data->pHandleFormat = pFormat;
|
|
|
|
|
2019-09-19 03:43:27 +02:00
|
|
|
TRACE("pAsync %p, pAsync->StubInfo %p, NotificationType %d\n", pAsync, pAsync->StubInfo, pAsync->NotificationType);
|
|
|
|
|
2019-05-21 06:30:54 +02:00
|
|
|
pFormat += get_handle_desc_size(pProcHeader, pFormat);
|
|
|
|
async_call_data->hBinding = client_get_handle(pStubMsg, pProcHeader, async_call_data->pHandleFormat);
|
2019-08-28 11:51:48 +02:00
|
|
|
if (!async_call_data->hBinding) return;
|
2009-03-18 11:59:35 +01:00
|
|
|
|
2015-03-06 12:35:42 +01:00
|
|
|
if (is_oicf_stubdesc(pStubDesc))
|
2009-03-18 11:59:35 +01:00
|
|
|
{
|
|
|
|
const NDR_PROC_PARTIAL_OIF_HEADER *pOIFHeader =
|
|
|
|
(const NDR_PROC_PARTIAL_OIF_HEADER *)pFormat;
|
|
|
|
|
|
|
|
Oif_flags = pOIFHeader->Oi2Flags;
|
|
|
|
async_call_data->number_of_params = pOIFHeader->number_of_params;
|
|
|
|
|
|
|
|
pFormat += sizeof(NDR_PROC_PARTIAL_OIF_HEADER);
|
|
|
|
|
2011-07-28 12:57:51 +02:00
|
|
|
TRACE("Oif_flags = %s\n", debugstr_INTERPRETER_OPT_FLAGS(Oif_flags) );
|
2009-03-18 11:59:35 +01:00
|
|
|
|
2011-07-28 12:57:51 +02:00
|
|
|
if (Oif_flags.HasExtensions)
|
|
|
|
{
|
|
|
|
const NDR_PROC_HEADER_EXTS *pExtensions =
|
|
|
|
(const NDR_PROC_HEADER_EXTS *)pFormat;
|
|
|
|
ext_flags = pExtensions->Flags2;
|
|
|
|
pFormat += pExtensions->Size;
|
|
|
|
}
|
2009-03-18 11:59:35 +01:00
|
|
|
}
|
2011-07-28 16:54:01 +02:00
|
|
|
else
|
|
|
|
{
|
|
|
|
pFormat = convert_old_args( pStubMsg, pFormat, async_call_data->stack_size,
|
2018-06-13 04:19:10 +02:00
|
|
|
pProcHeader->Oi_flags & Oi_OBJECT_PROC,
|
2011-07-28 16:54:01 +02:00
|
|
|
async_call_data->NdrCorrCache, sizeof(async_call_data->NdrCorrCache),
|
|
|
|
&async_call_data->number_of_params );
|
|
|
|
}
|
2009-03-18 11:59:35 +01:00
|
|
|
|
|
|
|
async_call_data->pParamFormat = pFormat;
|
|
|
|
|
|
|
|
pStubMsg->BufferLength = 0;
|
|
|
|
|
|
|
|
/* store the RPC flags away */
|
2018-06-13 04:19:10 +02:00
|
|
|
if (pProcHeader->Oi_flags & Oi_HAS_RPCFLAGS)
|
2009-03-18 11:59:35 +01:00
|
|
|
pRpcMsg->RpcFlags = ((const NDR_PROC_HEADER_RPC *)pProcHeader)->rpc_flags;
|
|
|
|
|
|
|
|
/* use alternate memory allocation routines */
|
2018-06-13 04:19:10 +02:00
|
|
|
if (pProcHeader->Oi_flags & Oi_RPCSS_ALLOC_USED)
|
2009-03-18 11:59:35 +01:00
|
|
|
NdrRpcSmSetClientToOsf(pStubMsg);
|
|
|
|
|
|
|
|
if (Oif_flags.HasPipes)
|
|
|
|
{
|
|
|
|
FIXME("pipes not supported yet\n");
|
|
|
|
RpcRaiseException(RPC_X_WRONG_STUB_VERSION); /* FIXME: remove when implemented */
|
|
|
|
/* init pipes package */
|
|
|
|
/* NdrPipesInitialize(...) */
|
|
|
|
}
|
|
|
|
if (ext_flags.HasNewCorrDesc)
|
|
|
|
{
|
|
|
|
/* initialize extra correlation package */
|
|
|
|
NdrCorrelationInitialize(pStubMsg, async_call_data->NdrCorrCache, sizeof(async_call_data->NdrCorrCache), 0);
|
2015-07-13 14:11:39 +02:00
|
|
|
if (ext_flags.Unused & 0x2) /* has range on conformance */
|
|
|
|
pStubMsg->CorrDespIncrement = 12;
|
2009-03-18 11:59:35 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* order of phases:
|
2011-07-28 22:34:57 +02:00
|
|
|
* 1. CALCSIZE - calculate the buffer size
|
|
|
|
* 2. GETBUFFER - allocate the buffer
|
|
|
|
* 3. MARSHAL - marshal [in] params into the buffer
|
|
|
|
* 4. SENDRECEIVE - send buffer
|
2009-03-18 11:59:35 +01:00
|
|
|
* Then in NdrpCompleteAsyncClientCall:
|
2011-07-28 22:34:57 +02:00
|
|
|
* 1. SENDRECEIVE - receive buffer
|
|
|
|
* 2. UNMARSHAL - unmarshal [out] params from buffer
|
2009-03-18 11:59:35 +01:00
|
|
|
*/
|
2011-07-28 22:34:57 +02:00
|
|
|
|
|
|
|
/* 1. CALCSIZE */
|
|
|
|
TRACE( "CALCSIZE\n" );
|
|
|
|
client_do_args(pStubMsg, pFormat, STUBLESS_CALCSIZE, NULL, async_call_data->number_of_params, NULL);
|
|
|
|
|
|
|
|
/* 2. GETBUFFER */
|
|
|
|
TRACE( "GETBUFFER\n" );
|
|
|
|
if (Oif_flags.HasPipes)
|
|
|
|
/* NdrGetPipeBuffer(...) */
|
|
|
|
FIXME("pipes not supported yet\n");
|
|
|
|
else
|
2009-03-18 11:59:35 +01:00
|
|
|
{
|
2018-06-13 04:19:10 +02:00
|
|
|
if (pProcHeader->handle_type == FC_AUTO_HANDLE)
|
2009-03-18 11:59:35 +01:00
|
|
|
#if 0
|
2011-07-28 22:34:57 +02:00
|
|
|
NdrNsGetBuffer(pStubMsg, pStubMsg->BufferLength, async_call_data->hBinding);
|
2009-03-18 11:59:35 +01:00
|
|
|
#else
|
2011-07-28 22:34:57 +02:00
|
|
|
FIXME("using auto handle - call NdrNsGetBuffer when it gets implemented\n");
|
2009-03-18 11:59:35 +01:00
|
|
|
#endif
|
2011-07-28 22:34:57 +02:00
|
|
|
else
|
|
|
|
NdrGetBuffer(pStubMsg, pStubMsg->BufferLength, async_call_data->hBinding);
|
|
|
|
}
|
|
|
|
pRpcMsg->RpcFlags |= RPC_BUFFER_ASYNC;
|
|
|
|
status = I_RpcAsyncSetHandle(pRpcMsg, pAsync);
|
|
|
|
if (status != RPC_S_OK)
|
|
|
|
RpcRaiseException(status);
|
|
|
|
|
|
|
|
/* 3. MARSHAL */
|
|
|
|
TRACE( "MARSHAL\n" );
|
|
|
|
client_do_args(pStubMsg, pFormat, STUBLESS_MARSHAL, NULL, async_call_data->number_of_params, NULL);
|
|
|
|
|
|
|
|
/* 4. SENDRECEIVE */
|
|
|
|
TRACE( "SEND\n" );
|
|
|
|
pRpcMsg->RpcFlags |= RPC_BUFFER_ASYNC;
|
|
|
|
/* send the [in] params only */
|
|
|
|
if (Oif_flags.HasPipes)
|
|
|
|
/* NdrPipesSend(...) */
|
|
|
|
FIXME("pipes not supported yet\n");
|
|
|
|
else
|
|
|
|
{
|
2018-06-13 04:19:10 +02:00
|
|
|
if (pProcHeader->handle_type == FC_AUTO_HANDLE)
|
2009-03-18 11:59:35 +01:00
|
|
|
#if 0
|
2011-07-28 22:34:57 +02:00
|
|
|
NdrNsSend(&stubMsg, stubMsg.Buffer, pStubDesc->IMPLICIT_HANDLE_INFO.pAutoHandle);
|
2009-03-18 11:59:35 +01:00
|
|
|
#else
|
2011-07-28 22:34:57 +02:00
|
|
|
FIXME("using auto handle - call NdrNsSend when it gets implemented\n");
|
2009-03-18 11:59:35 +01:00
|
|
|
#endif
|
2011-07-28 22:34:57 +02:00
|
|
|
else
|
|
|
|
{
|
|
|
|
pStubMsg->RpcMsg->BufferLength = pStubMsg->Buffer - (unsigned char *)pStubMsg->RpcMsg->Buffer;
|
|
|
|
status = I_RpcSend(pStubMsg->RpcMsg);
|
|
|
|
if (status != RPC_S_OK)
|
|
|
|
RpcRaiseException(status);
|
2009-03-18 11:59:35 +01:00
|
|
|
}
|
|
|
|
}
|
2019-08-28 11:51:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
LONG_PTR CDECL DECLSPEC_HIDDEN ndr_async_client_call( PMIDL_STUB_DESC pStubDesc, PFORMAT_STRING pFormat,
|
|
|
|
void **stack_top )
|
|
|
|
{
|
2019-09-02 09:45:42 +02:00
|
|
|
LONG_PTR ret = 0;
|
2019-08-28 11:51:48 +02:00
|
|
|
const NDR_PROC_HEADER *pProcHeader = (const NDR_PROC_HEADER *)&pFormat[0];
|
|
|
|
|
|
|
|
TRACE("pStubDesc %p, pFormat %p, ...\n", pStubDesc, pFormat);
|
|
|
|
|
|
|
|
if (pProcHeader->Oi_flags & Oi_HAS_COMM_OR_FAULT)
|
|
|
|
{
|
|
|
|
__TRY
|
|
|
|
{
|
|
|
|
do_ndr_async_client_call( pStubDesc, pFormat, stack_top );
|
|
|
|
}
|
|
|
|
__EXCEPT_ALL
|
|
|
|
{
|
|
|
|
FIXME("exception %x during ndr_async_client_call()\n", GetExceptionCode());
|
2019-09-02 09:45:42 +02:00
|
|
|
ret = GetExceptionCode();
|
2019-08-28 11:51:48 +02:00
|
|
|
}
|
|
|
|
__ENDTRY
|
|
|
|
}
|
|
|
|
else
|
|
|
|
do_ndr_async_client_call( pStubDesc, pFormat, stack_top);
|
2009-03-18 11:59:35 +01:00
|
|
|
|
2019-09-02 09:45:42 +02:00
|
|
|
TRACE("returning %ld\n", ret);
|
|
|
|
return ret;
|
2009-03-18 11:59:35 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
RPC_STATUS NdrpCompleteAsyncClientCall(RPC_ASYNC_STATE *pAsync, void *Reply)
|
|
|
|
{
|
|
|
|
/* pointer to start of stack where arguments start */
|
|
|
|
PMIDL_STUB_MESSAGE pStubMsg;
|
|
|
|
struct async_call_data *async_call_data;
|
|
|
|
/* header for procedure string */
|
|
|
|
const NDR_PROC_HEADER * pProcHeader;
|
|
|
|
RPC_STATUS status = RPC_S_OK;
|
|
|
|
|
|
|
|
if (!pAsync->StubInfo)
|
|
|
|
return RPC_S_INVALID_ASYNC_HANDLE;
|
|
|
|
|
|
|
|
async_call_data = pAsync->StubInfo;
|
|
|
|
pStubMsg = async_call_data->pStubMsg;
|
|
|
|
pProcHeader = async_call_data->pProcHeader;
|
|
|
|
|
|
|
|
/* order of phases:
|
2011-07-28 22:34:57 +02:00
|
|
|
* 1. CALCSIZE - calculate the buffer size
|
|
|
|
* 2. GETBUFFER - allocate the buffer
|
|
|
|
* 3. MARSHAL - marshal [in] params into the buffer
|
|
|
|
* 4. SENDRECEIVE - send buffer
|
2009-03-18 11:59:35 +01:00
|
|
|
* Then in NdrpCompleteAsyncClientCall:
|
2011-07-28 22:34:57 +02:00
|
|
|
* 1. SENDRECEIVE - receive buffer
|
|
|
|
* 2. UNMARSHAL - unmarshal [out] params from buffer
|
2009-03-18 11:59:35 +01:00
|
|
|
*/
|
2011-07-28 22:34:57 +02:00
|
|
|
|
|
|
|
/* 1. SENDRECEIVE */
|
|
|
|
TRACE( "RECEIVE\n" );
|
|
|
|
pStubMsg->RpcMsg->RpcFlags |= RPC_BUFFER_ASYNC;
|
|
|
|
/* receive the [out] params */
|
2018-06-13 04:19:10 +02:00
|
|
|
if (pProcHeader->handle_type == FC_AUTO_HANDLE)
|
2009-03-18 11:59:35 +01:00
|
|
|
#if 0
|
2011-07-28 22:34:57 +02:00
|
|
|
NdrNsReceive(&stubMsg, stubMsg.Buffer, pStubDesc->IMPLICIT_HANDLE_INFO.pAutoHandle);
|
2009-03-18 11:59:35 +01:00
|
|
|
#else
|
2011-07-28 22:34:57 +02:00
|
|
|
FIXME("using auto handle - call NdrNsReceive when it gets implemented\n");
|
2009-03-18 11:59:35 +01:00
|
|
|
#endif
|
2011-07-28 22:34:57 +02:00
|
|
|
else
|
|
|
|
{
|
|
|
|
status = I_RpcReceive(pStubMsg->RpcMsg);
|
|
|
|
if (status != RPC_S_OK)
|
|
|
|
goto cleanup;
|
|
|
|
pStubMsg->BufferLength = pStubMsg->RpcMsg->BufferLength;
|
|
|
|
pStubMsg->BufferStart = pStubMsg->RpcMsg->Buffer;
|
|
|
|
pStubMsg->BufferEnd = pStubMsg->BufferStart + pStubMsg->BufferLength;
|
|
|
|
pStubMsg->Buffer = pStubMsg->BufferStart;
|
|
|
|
}
|
2009-03-18 11:59:35 +01:00
|
|
|
|
2011-08-02 22:20:32 +02:00
|
|
|
/* convert strings, floating point values and endianness into our
|
2011-07-28 22:34:57 +02:00
|
|
|
* preferred format */
|
2009-03-18 11:59:35 +01:00
|
|
|
#if 0
|
2011-07-28 22:34:57 +02:00
|
|
|
if ((pStubMsg->RpcMsg.DataRepresentation & 0x0000FFFFUL) != NDR_LOCAL_DATA_REPRESENTATION)
|
|
|
|
NdrConvert(pStubMsg, pFormat);
|
2009-03-18 11:59:35 +01:00
|
|
|
#endif
|
|
|
|
|
2011-07-28 22:34:57 +02:00
|
|
|
/* 2. UNMARSHAL */
|
|
|
|
TRACE( "UNMARSHAL\n" );
|
|
|
|
client_do_args(pStubMsg, async_call_data->pParamFormat, STUBLESS_UNMARSHAL,
|
|
|
|
NULL, async_call_data->number_of_params, Reply);
|
2009-03-18 11:59:35 +01:00
|
|
|
|
|
|
|
cleanup:
|
|
|
|
if (pStubMsg->fHasNewCorrDesc)
|
|
|
|
{
|
|
|
|
/* free extra correlation package */
|
|
|
|
NdrCorrelationFree(pStubMsg);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* free the full pointer translation tables */
|
2018-06-13 04:19:10 +02:00
|
|
|
if (pProcHeader->Oi_flags & Oi_FULL_PTR_USED)
|
2009-03-18 11:59:35 +01:00
|
|
|
NdrFullPointerXlatFree(pStubMsg->FullPtrXlatTables);
|
|
|
|
|
|
|
|
/* free marshalling buffer */
|
|
|
|
NdrFreeBuffer(pStubMsg);
|
|
|
|
client_free_handle(pStubMsg, pProcHeader, async_call_data->pHandleFormat, async_call_data->hBinding);
|
|
|
|
|
|
|
|
I_RpcFree(pStubMsg->StackTop);
|
|
|
|
I_RpcFree(async_call_data);
|
|
|
|
|
|
|
|
TRACE("-- 0x%x\n", status);
|
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
2011-06-15 17:30:49 +02:00
|
|
|
#ifdef __x86_64__
|
|
|
|
|
|
|
|
__ASM_GLOBAL_FUNC( NdrAsyncClientCall,
|
|
|
|
"subq $0x28,%rsp\n\t"
|
2019-08-21 11:28:26 +02:00
|
|
|
__ASM_SEH(".seh_stackalloc 0x28\n\t")
|
|
|
|
__ASM_SEH(".seh_endprologue\n\t")
|
2011-06-15 17:30:49 +02:00
|
|
|
__ASM_CFI(".cfi_adjust_cfa_offset 0x28\n\t")
|
2019-08-21 11:28:26 +02:00
|
|
|
"movq %r8,0x40(%rsp)\n\t"
|
|
|
|
"movq %r9,0x48(%rsp)\n\t"
|
|
|
|
"leaq 0x40(%rsp),%r8\n\t"
|
2011-06-15 17:30:49 +02:00
|
|
|
"call " __ASM_NAME("ndr_async_client_call") "\n\t"
|
|
|
|
"addq $0x28,%rsp\n\t"
|
|
|
|
__ASM_CFI(".cfi_adjust_cfa_offset -0x28\n\t")
|
|
|
|
"ret" );
|
|
|
|
|
|
|
|
#else /* __x86_64__ */
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* NdrAsyncClientCall [RPCRT4.@]
|
|
|
|
*/
|
|
|
|
CLIENT_CALL_RETURN WINAPIV NdrAsyncClientCall( PMIDL_STUB_DESC desc, PFORMAT_STRING format, ... )
|
|
|
|
{
|
|
|
|
__ms_va_list args;
|
|
|
|
LONG_PTR ret;
|
|
|
|
|
|
|
|
__ms_va_start( args, format );
|
|
|
|
ret = ndr_async_client_call( desc, format, va_arg( args, void ** ));
|
|
|
|
__ms_va_end( args );
|
|
|
|
return *(CLIENT_CALL_RETURN *)&ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* __x86_64__ */
|
|
|
|
|
2009-03-18 11:59:35 +01:00
|
|
|
RPCRTAPI LONG RPC_ENTRY NdrAsyncStubCall(struct IRpcStubBuffer* pThis,
|
|
|
|
struct IRpcChannelBuffer* pChannel, PRPC_MESSAGE pRpcMsg,
|
|
|
|
DWORD * pdwStubPhase)
|
|
|
|
{
|
|
|
|
FIXME("unimplemented, expect crash!\n");
|
|
|
|
return 0;
|
|
|
|
}
|
2016-07-28 17:17:16 +02:00
|
|
|
|
|
|
|
void RPC_ENTRY NdrAsyncServerCall(PRPC_MESSAGE pRpcMsg)
|
|
|
|
{
|
2019-09-13 07:34:33 +02:00
|
|
|
const MIDL_SERVER_INFO *pServerInfo;
|
|
|
|
const MIDL_STUB_DESC *pStubDesc;
|
|
|
|
PFORMAT_STRING pFormat;
|
|
|
|
/* pointer to start of stack to pass into stub implementation */
|
|
|
|
unsigned char *args;
|
|
|
|
/* header for procedure string */
|
|
|
|
const NDR_PROC_HEADER *pProcHeader;
|
|
|
|
struct async_call_data *async_call_data;
|
|
|
|
PRPC_ASYNC_STATE pAsync;
|
|
|
|
RPC_STATUS status;
|
|
|
|
|
|
|
|
TRACE("%p\n", pRpcMsg);
|
|
|
|
|
|
|
|
pServerInfo = ((RPC_SERVER_INTERFACE *)pRpcMsg->RpcInterfaceInformation)->InterpreterInfo;
|
|
|
|
|
|
|
|
pStubDesc = pServerInfo->pStubDesc;
|
|
|
|
pFormat = pServerInfo->ProcString + pServerInfo->FmtStringOffset[pRpcMsg->ProcNum];
|
|
|
|
pProcHeader = (const NDR_PROC_HEADER *)&pFormat[0];
|
|
|
|
|
|
|
|
TRACE("NDR Version: 0x%x\n", pStubDesc->Version);
|
|
|
|
|
|
|
|
async_call_data = I_RpcAllocate(sizeof(*async_call_data) + sizeof(MIDL_STUB_MESSAGE) + sizeof(RPC_MESSAGE));
|
|
|
|
if (!async_call_data) RpcRaiseException(RPC_X_NO_MEMORY);
|
|
|
|
async_call_data->pProcHeader = pProcHeader;
|
|
|
|
|
|
|
|
async_call_data->pStubMsg = (PMIDL_STUB_MESSAGE)(async_call_data + 1);
|
|
|
|
*(PRPC_MESSAGE)(async_call_data->pStubMsg + 1) = *pRpcMsg;
|
|
|
|
|
|
|
|
if (pProcHeader->Oi_flags & Oi_HAS_RPCFLAGS)
|
|
|
|
{
|
|
|
|
const NDR_PROC_HEADER_RPC *header_rpc = (const NDR_PROC_HEADER_RPC *)&pFormat[0];
|
|
|
|
async_call_data->stack_size = header_rpc->stack_size;
|
|
|
|
pFormat += sizeof(NDR_PROC_HEADER_RPC);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
async_call_data->stack_size = pProcHeader->stack_size;
|
|
|
|
pFormat += sizeof(NDR_PROC_HEADER);
|
|
|
|
}
|
|
|
|
|
|
|
|
TRACE("Oi_flags = 0x%02x\n", pProcHeader->Oi_flags);
|
|
|
|
|
|
|
|
/* binding */
|
|
|
|
switch (pProcHeader->handle_type)
|
|
|
|
{
|
|
|
|
/* explicit binding: parse additional section */
|
|
|
|
case 0:
|
|
|
|
switch (*pFormat) /* handle_type */
|
|
|
|
{
|
|
|
|
case FC_BIND_PRIMITIVE: /* explicit primitive */
|
|
|
|
pFormat += sizeof(NDR_EHD_PRIMITIVE);
|
|
|
|
break;
|
|
|
|
case FC_BIND_GENERIC: /* explicit generic */
|
|
|
|
pFormat += sizeof(NDR_EHD_GENERIC);
|
|
|
|
break;
|
|
|
|
case FC_BIND_CONTEXT: /* explicit context */
|
|
|
|
pFormat += 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 FC_BIND_GENERIC: /* implicit generic */
|
|
|
|
case FC_BIND_PRIMITIVE: /* implicit primitive */
|
|
|
|
case FC_CALLBACK_HANDLE: /* implicit callback */
|
|
|
|
case 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);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (pProcHeader->Oi_flags & Oi_OBJECT_PROC)
|
|
|
|
{
|
|
|
|
ERR("objects not supported\n");
|
|
|
|
I_RpcFree(async_call_data);
|
|
|
|
RpcRaiseException(RPC_X_BAD_STUB_DATA);
|
|
|
|
}
|
|
|
|
|
|
|
|
NdrServerInitializeNew(pRpcMsg, async_call_data->pStubMsg, pStubDesc);
|
|
|
|
|
|
|
|
/* create the full pointer translation tables, if requested */
|
|
|
|
if (pProcHeader->Oi_flags & Oi_FULL_PTR_USED)
|
|
|
|
async_call_data->pStubMsg->FullPtrXlatTables = NdrFullPointerXlatInit(0, XLAT_SERVER);
|
|
|
|
|
|
|
|
/* use alternate memory allocation routines */
|
|
|
|
if (pProcHeader->Oi_flags & Oi_RPCSS_ALLOC_USED)
|
|
|
|
#if 0
|
|
|
|
NdrRpcSsEnableAllocate(&stubMsg);
|
|
|
|
#else
|
|
|
|
FIXME("Set RPCSS memory allocation routines\n");
|
|
|
|
#endif
|
|
|
|
|
|
|
|
TRACE("allocating memory for stack of size %x\n", async_call_data->stack_size);
|
|
|
|
|
|
|
|
args = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, async_call_data->stack_size);
|
|
|
|
async_call_data->pStubMsg->StackTop = args; /* used by conformance of top-level objects */
|
|
|
|
|
|
|
|
pAsync = I_RpcAllocate(sizeof(*pAsync));
|
|
|
|
if (!pAsync) RpcRaiseException(RPC_X_NO_MEMORY);
|
|
|
|
|
|
|
|
status = RpcAsyncInitializeHandle(pAsync, sizeof(*pAsync));
|
|
|
|
if (status != RPC_S_OK)
|
|
|
|
RpcRaiseException(status);
|
|
|
|
|
|
|
|
pAsync->StubInfo = async_call_data;
|
|
|
|
TRACE("pAsync %p, pAsync->StubInfo %p, pFormat %p\n", pAsync, pAsync->StubInfo, async_call_data->pHandleFormat);
|
|
|
|
|
|
|
|
/* add the implicit pAsync pointer as the first arg to the function */
|
|
|
|
*(void **)args = pAsync;
|
|
|
|
|
|
|
|
if (is_oicf_stubdesc(pStubDesc))
|
|
|
|
{
|
|
|
|
const NDR_PROC_PARTIAL_OIF_HEADER *pOIFHeader = (const NDR_PROC_PARTIAL_OIF_HEADER *)pFormat;
|
|
|
|
/* cache of Oif_flags from v2 procedure header */
|
|
|
|
INTERPRETER_OPT_FLAGS Oif_flags;
|
|
|
|
/* cache of extension flags from NDR_PROC_HEADER_EXTS */
|
|
|
|
INTERPRETER_OPT_FLAGS2 ext_flags = { 0 };
|
|
|
|
|
|
|
|
Oif_flags = pOIFHeader->Oi2Flags;
|
|
|
|
async_call_data->number_of_params = pOIFHeader->number_of_params;
|
|
|
|
|
|
|
|
pFormat += sizeof(NDR_PROC_PARTIAL_OIF_HEADER);
|
|
|
|
|
|
|
|
TRACE("Oif_flags = %s\n", debugstr_INTERPRETER_OPT_FLAGS(Oif_flags) );
|
|
|
|
|
|
|
|
if (Oif_flags.HasExtensions)
|
|
|
|
{
|
|
|
|
const NDR_PROC_HEADER_EXTS *pExtensions = (const NDR_PROC_HEADER_EXTS *)pFormat;
|
|
|
|
ext_flags = pExtensions->Flags2;
|
|
|
|
pFormat += pExtensions->Size;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (Oif_flags.HasPipes)
|
|
|
|
{
|
|
|
|
FIXME("pipes not supported yet\n");
|
|
|
|
RpcRaiseException(RPC_X_WRONG_STUB_VERSION); /* FIXME: remove when implemented */
|
|
|
|
/* init pipes package */
|
|
|
|
/* NdrPipesInitialize(...) */
|
|
|
|
}
|
|
|
|
if (ext_flags.HasNewCorrDesc)
|
|
|
|
{
|
|
|
|
/* initialize extra correlation package */
|
|
|
|
NdrCorrelationInitialize(async_call_data->pStubMsg, async_call_data->NdrCorrCache, sizeof(async_call_data->NdrCorrCache), 0);
|
|
|
|
if (ext_flags.Unused & 0x2) /* has range on conformance */
|
|
|
|
async_call_data->pStubMsg->CorrDespIncrement = 12;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
pFormat = convert_old_args( async_call_data->pStubMsg, pFormat, async_call_data->stack_size,
|
|
|
|
pProcHeader->Oi_flags & Oi_OBJECT_PROC,
|
|
|
|
/* reuse the correlation cache, it's not needed for v1 format */
|
|
|
|
async_call_data->NdrCorrCache, sizeof(async_call_data->NdrCorrCache), &async_call_data->number_of_params );
|
|
|
|
}
|
|
|
|
|
|
|
|
/* convert strings, floating point values and endianness into our
|
|
|
|
* preferred format */
|
|
|
|
if ((pRpcMsg->DataRepresentation & 0x0000FFFFUL) != NDR_LOCAL_DATA_REPRESENTATION)
|
|
|
|
NdrConvert(async_call_data->pStubMsg, pFormat);
|
|
|
|
|
|
|
|
async_call_data->pHandleFormat = pFormat;
|
|
|
|
|
|
|
|
/* 1. UNMARSHAL */
|
|
|
|
TRACE("UNMARSHAL\n");
|
|
|
|
stub_do_args(async_call_data->pStubMsg, pFormat, STUBLESS_UNMARSHAL, async_call_data->number_of_params);
|
|
|
|
|
2019-09-19 03:43:27 +02:00
|
|
|
/* 2. INITOUT */
|
|
|
|
TRACE("INITOUT\n");
|
|
|
|
async_call_data->retval_ptr = stub_do_args(async_call_data->pStubMsg, pFormat, STUBLESS_INITOUT, async_call_data->number_of_params);
|
|
|
|
|
|
|
|
/* 3. CALLSERVER */
|
2019-09-13 07:34:33 +02:00
|
|
|
TRACE("CALLSERVER\n");
|
|
|
|
if (pServerInfo->ThunkTable && pServerInfo->ThunkTable[pRpcMsg->ProcNum])
|
|
|
|
pServerInfo->ThunkTable[pRpcMsg->ProcNum](async_call_data->pStubMsg);
|
|
|
|
else
|
|
|
|
call_server_func(pServerInfo->DispatchTable[pRpcMsg->ProcNum], args, async_call_data->stack_size);
|
2016-07-28 17:17:16 +02:00
|
|
|
}
|
2019-09-13 07:34:40 +02:00
|
|
|
|
|
|
|
RPC_STATUS NdrpCompleteAsyncServerCall(RPC_ASYNC_STATE *pAsync, void *Reply)
|
|
|
|
{
|
|
|
|
/* pointer to start of stack where arguments start */
|
|
|
|
PMIDL_STUB_MESSAGE pStubMsg;
|
|
|
|
struct async_call_data *async_call_data;
|
|
|
|
/* the type of pass we are currently doing */
|
|
|
|
enum stubless_phase phase;
|
|
|
|
RPC_STATUS status = RPC_S_OK;
|
|
|
|
|
|
|
|
if (!pAsync->StubInfo)
|
|
|
|
return RPC_S_INVALID_ASYNC_HANDLE;
|
|
|
|
|
|
|
|
async_call_data = pAsync->StubInfo;
|
|
|
|
pStubMsg = async_call_data->pStubMsg;
|
|
|
|
|
|
|
|
TRACE("pAsync %p, pAsync->StubInfo %p, pFormat %p\n", pAsync, pAsync->StubInfo, async_call_data->pHandleFormat);
|
|
|
|
|
2019-09-19 03:43:27 +02:00
|
|
|
if (async_call_data->retval_ptr)
|
2019-09-13 07:34:40 +02:00
|
|
|
{
|
|
|
|
TRACE("stub implementation returned 0x%lx\n", *(LONG_PTR *)Reply);
|
2019-09-19 03:43:27 +02:00
|
|
|
*async_call_data->retval_ptr = *(LONG_PTR *)Reply;
|
2019-09-13 07:34:40 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
TRACE("void stub implementation\n");
|
|
|
|
|
|
|
|
for (phase = STUBLESS_CALCSIZE; phase <= STUBLESS_FREE; phase++)
|
|
|
|
{
|
|
|
|
TRACE("phase = %d\n", phase);
|
|
|
|
switch (phase)
|
|
|
|
{
|
|
|
|
case STUBLESS_GETBUFFER:
|
|
|
|
if (async_call_data->pProcHeader->Oi_flags & Oi_OBJECT_PROC)
|
|
|
|
{
|
|
|
|
ERR("objects not supported\n");
|
|
|
|
HeapFree(GetProcessHeap(), 0, async_call_data->pStubMsg->StackTop);
|
|
|
|
I_RpcFree(async_call_data);
|
|
|
|
I_RpcFree(pAsync);
|
|
|
|
RpcRaiseException(RPC_X_BAD_STUB_DATA);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
pStubMsg->RpcMsg->BufferLength = pStubMsg->BufferLength;
|
|
|
|
/* allocate buffer for [out] and [ret] params */
|
|
|
|
status = I_RpcGetBuffer(pStubMsg->RpcMsg);
|
|
|
|
if (status)
|
|
|
|
RpcRaiseException(status);
|
|
|
|
pStubMsg->Buffer = pStubMsg->RpcMsg->Buffer;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case STUBLESS_CALCSIZE:
|
|
|
|
case STUBLESS_MARSHAL:
|
|
|
|
case STUBLESS_MUSTFREE:
|
|
|
|
case STUBLESS_FREE:
|
|
|
|
stub_do_args(pStubMsg, async_call_data->pHandleFormat, phase, async_call_data->number_of_params);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
ERR("shouldn't reach here. phase %d\n", phase);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#if 0 /* FIXME */
|
|
|
|
if (ext_flags.HasNewCorrDesc)
|
|
|
|
{
|
|
|
|
/* free extra correlation package */
|
|
|
|
NdrCorrelationFree(pStubMsg);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (Oif_flags.HasPipes)
|
|
|
|
{
|
|
|
|
/* NdrPipesDone(...) */
|
|
|
|
}
|
|
|
|
|
|
|
|
/* free the full pointer translation tables */
|
|
|
|
if (async_call_data->pProcHeader->Oi_flags & Oi_FULL_PTR_USED)
|
|
|
|
NdrFullPointerXlatFree(pStubMsg->FullPtrXlatTables);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* free server function stack */
|
|
|
|
HeapFree(GetProcessHeap(), 0, async_call_data->pStubMsg->StackTop);
|
|
|
|
I_RpcFree(async_call_data);
|
|
|
|
I_RpcFree(pAsync);
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
2020-04-05 01:15:30 +02:00
|
|
|
|
|
|
|
static const RPC_SYNTAX_IDENTIFIER ndr_syntax_id =
|
|
|
|
{{0x8a885d04, 0x1ceb, 0x11c9, {0x9f, 0xe8, 0x08, 0x00, 0x2b, 0x10, 0x48, 0x60}}, {2, 0}};
|
|
|
|
|
|
|
|
LONG_PTR CDECL DECLSPEC_HIDDEN ndr64_client_call( MIDL_STUBLESS_PROXY_INFO *info,
|
|
|
|
ULONG proc, void *retval, void **stack_top, void **fpu_stack )
|
|
|
|
{
|
|
|
|
ULONG_PTR i;
|
|
|
|
|
|
|
|
TRACE("info %p, proc %u, retval %p, stack_top %p, fpu_stack %p\n",
|
|
|
|
info, proc, retval, stack_top, fpu_stack);
|
|
|
|
|
|
|
|
for (i = 0; i < info->nCount; ++i)
|
|
|
|
{
|
|
|
|
const MIDL_SYNTAX_INFO *syntax_info = &info->pSyntaxInfo[i];
|
|
|
|
const RPC_SYNTAX_IDENTIFIER *id = &syntax_info->TransferSyntax;
|
|
|
|
|
|
|
|
TRACE("Found syntax %s, version %u.%u.\n", debugstr_guid(&id->SyntaxGUID),
|
|
|
|
id->SyntaxVersion.MajorVersion, id->SyntaxVersion.MinorVersion);
|
|
|
|
if (!memcmp(id, &ndr_syntax_id, sizeof(RPC_SYNTAX_IDENTIFIER)))
|
|
|
|
{
|
|
|
|
if (retval)
|
|
|
|
FIXME("Complex return types are not supported.\n");
|
|
|
|
|
|
|
|
return ndr_client_call( info->pStubDesc,
|
|
|
|
syntax_info->ProcString + syntax_info->FmtStringOffset[proc], stack_top, fpu_stack );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
FIXME("NDR64 syntax is not supported.\n");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef __x86_64__
|
|
|
|
|
|
|
|
__ASM_GLOBAL_FUNC( NdrClientCall3,
|
|
|
|
"movq %r9,0x20(%rsp)\n\t"
|
|
|
|
"leaq 0x20(%rsp),%r9\n\t"
|
|
|
|
"pushq $0\n\t"
|
|
|
|
"subq $0x20,%rsp\n\t"
|
|
|
|
__ASM_CFI(".cfi_adjust_cfa_offset 0x28\n\t")
|
|
|
|
"call " __ASM_NAME("ndr64_client_call") "\n\t"
|
|
|
|
"addq $0x28,%rsp\n\t"
|
|
|
|
__ASM_CFI(".cfi_adjust_cfa_offset -0x28\n\t")
|
|
|
|
"ret" );
|
|
|
|
|
|
|
|
#elif defined(_WIN64)
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* NdrClientCall3 [RPCRT4.@]
|
|
|
|
*/
|
|
|
|
CLIENT_CALL_RETURN WINAPIV NdrClientCall3( MIDL_STUBLESS_PROXY_INFO *info, ULONG proc, void *retval, ... )
|
|
|
|
{
|
|
|
|
__ms_va_list args;
|
|
|
|
LONG_PTR ret;
|
|
|
|
|
|
|
|
__ms_va_start( args, retval );
|
|
|
|
ret = ndr64_client_call( info, proc, retval, va_arg( args, void ** ), NULL );
|
|
|
|
__ms_va_end( args );
|
|
|
|
return *(CLIENT_CALL_RETURN *)&ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
2020-04-05 01:15:31 +02:00
|
|
|
|
|
|
|
LONG_PTR CDECL DECLSPEC_HIDDEN ndr64_async_client_call( MIDL_STUBLESS_PROXY_INFO *info,
|
|
|
|
ULONG proc, void *retval, void **stack_top, void **fpu_stack )
|
|
|
|
{
|
|
|
|
ULONG_PTR i;
|
|
|
|
|
|
|
|
TRACE("info %p, proc %u, retval %p, stack_top %p, fpu_stack %p\n",
|
|
|
|
info, proc, retval, stack_top, fpu_stack);
|
|
|
|
|
|
|
|
for (i = 0; i < info->nCount; ++i)
|
|
|
|
{
|
|
|
|
const MIDL_SYNTAX_INFO *syntax_info = &info->pSyntaxInfo[i];
|
|
|
|
const RPC_SYNTAX_IDENTIFIER *id = &syntax_info->TransferSyntax;
|
|
|
|
|
|
|
|
TRACE("Found syntax %s, version %u.%u.\n", debugstr_guid(&id->SyntaxGUID),
|
|
|
|
id->SyntaxVersion.MajorVersion, id->SyntaxVersion.MinorVersion);
|
|
|
|
if (!memcmp(id, &ndr_syntax_id, sizeof(RPC_SYNTAX_IDENTIFIER)))
|
|
|
|
{
|
|
|
|
if (retval)
|
|
|
|
FIXME("Complex return types are not supported.\n");
|
|
|
|
|
|
|
|
return ndr_async_client_call( info->pStubDesc,
|
|
|
|
syntax_info->ProcString + syntax_info->FmtStringOffset[proc], stack_top );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
FIXME("NDR64 syntax is not supported.\n");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef __x86_64__
|
|
|
|
|
|
|
|
__ASM_GLOBAL_FUNC( Ndr64AsyncClientCall,
|
|
|
|
"movq %r9,0x20(%rsp)\n\t"
|
|
|
|
"leaq 0x20(%rsp),%r9\n\t"
|
|
|
|
"pushq $0\n\t"
|
|
|
|
"subq $0x20,%rsp\n\t"
|
|
|
|
__ASM_CFI(".cfi_adjust_cfa_offset 0x28\n\t")
|
|
|
|
"call " __ASM_NAME("ndr64_async_client_call") "\n\t"
|
|
|
|
"addq $0x28,%rsp\n\t"
|
|
|
|
__ASM_CFI(".cfi_adjust_cfa_offset -0x28\n\t")
|
|
|
|
"ret" );
|
|
|
|
|
|
|
|
#elif defined(_WIN64)
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* Ndr64AsyncClientCall [RPCRT4.@]
|
|
|
|
*/
|
|
|
|
CLIENT_CALL_RETURN WINAPIV Ndr64AsyncClientCall( MIDL_STUBLESS_PROXY_INFO *info, ULONG proc, void *retval, ... )
|
|
|
|
{
|
|
|
|
__ms_va_list args;
|
|
|
|
LONG_PTR ret;
|
|
|
|
|
|
|
|
__ms_va_start( args, retval );
|
|
|
|
ret = ndr64_async_client_call( info, proc, retval, va_arg( args, void ** ), NULL );
|
|
|
|
__ms_va_end( args );
|
|
|
|
return *(CLIENT_CALL_RETURN *)&ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|