[RPCRT4] Set binding handle for server functions

This enables us to impersonate server functions using RpcImpersonateClient.
This commit is contained in:
Eric Kohl 2023-05-28 21:04:01 +02:00
parent 8f9ef68ea7
commit e54b32b434

View file

@ -1330,6 +1330,7 @@ LONG WINAPI NdrStubCall2(
LONG_PTR *retval_ptr = NULL;
/* correlation cache */
ULONG_PTR NdrCorrCache[256];
unsigned short BindingHandleOffset = (USHORT)-1;
TRACE("pThis %p, pChannel %p, pRpcMsg %p, pdwStubPhase %p\n", pThis, pChannel, pRpcMsg, pdwStubPhase);
@ -1367,12 +1368,15 @@ LONG WINAPI NdrStubCall2(
switch (*pFormat) /* handle_type */
{
case FC_BIND_PRIMITIVE: /* explicit primitive */
BindingHandleOffset = ((NDR_EHD_PRIMITIVE*)pFormat)->offset;
pFormat += sizeof(NDR_EHD_PRIMITIVE);
break;
case FC_BIND_GENERIC: /* explicit generic */
BindingHandleOffset = ((NDR_EHD_GENERIC*)pFormat)->offset;
pFormat += sizeof(NDR_EHD_GENERIC);
break;
case FC_BIND_CONTEXT: /* explicit context */
BindingHandleOffset = ((NDR_EHD_CONTEXT*)pFormat)->offset;
pFormat += sizeof(NDR_EHD_CONTEXT);
break;
default:
@ -1421,6 +1425,10 @@ LONG WINAPI NdrStubCall2(
if (pThis)
*(void **)args = ((CStdStubBuffer *)pThis)->pvServerObject;
/* add the binding handle to the stack if we are using explicit binding handles */
if (BindingHandleOffset != (USHORT)-1)
*(RPC_BINDING_HANDLE*)&(args[BindingHandleOffset]) = pRpcMsg->Handle;
if (is_oicf_stubdesc(pStubDesc))
{
const NDR_PROC_PARTIAL_OIF_HEADER *pOIFHeader = (const NDR_PROC_PARTIAL_OIF_HEADER *)pFormat;