From 9a4de1b727cf7b8226f23e056932f99c53246572 Mon Sep 17 00:00:00 2001 From: Haoyang Chen Date: Tue, 21 Nov 2023 09:31:46 +0800 Subject: [PATCH] rpcrt4: Support for explicit handle passing. If explicit_handle is defined in the idl file, c/s use explicit handles, then an explicit handle must be passed in to the server-side interface --- dlls/rpcrt4/ndr_stubless.c | 69 +++++++++++++++++++++----------------- 1 file changed, 38 insertions(+), 31 deletions(-) diff --git a/dlls/rpcrt4/ndr_stubless.c b/dlls/rpcrt4/ndr_stubless.c index 80cd0bbcb89..7aa2f79d10b 100644 --- a/dlls/rpcrt4/ndr_stubless.c +++ b/dlls/rpcrt4/ndr_stubless.c @@ -1365,37 +1365,6 @@ LONG WINAPI NdrStubCall2( 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) NdrStubInitialize(pRpcMsg, &stubMsg, pStubDesc, pChannel); else @@ -1422,6 +1391,44 @@ LONG WINAPI NdrStubCall2( args = calloc(1, stack_size); stubMsg.StackTop = args; /* used by conformance of top-level objects */ + /* binding */ + switch (pProcHeader->handle_type) + { + /* explicit binding: parse additional section */ + case 0: + switch (*pFormat) /* handle_type */ + { + case FC_BIND_PRIMITIVE: /* explicit primitive */ + { + const NDR_EHD_PRIMITIVE *pDesc = (const NDR_EHD_PRIMITIVE *)pFormat; + if (pDesc->flag) + **(handle_t **)ARG_FROM_OFFSET(stubMsg.StackTop, pDesc->offset) = pRpcMsg->Handle; + else + *(handle_t *)ARG_FROM_OFFSET(stubMsg.StackTop, pDesc->offset) = pRpcMsg->Handle; + 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); + } + /* add the implicit This pointer as the first arg to the function if we * are calling an object method */ if (pThis)