https://git.reactos.org/?p=reactos.git;a=commitdiff;h=e54b32b434ca7704c63709e8c45128e0fc170fcb

commit e54b32b434ca7704c63709e8c45128e0fc170fcb
Author:     Eric Kohl <[email protected]>
AuthorDate: Sun May 28 21:04:01 2023 +0200
Commit:     Eric Kohl <[email protected]>
CommitDate: Sun May 28 21:04:01 2023 +0200

    [RPCRT4] Set binding handle for server functions
    
    This enables us to impersonate server functions using RpcImpersonateClient.
---
 dll/win32/rpcrt4/ndr_stubless.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/dll/win32/rpcrt4/ndr_stubless.c b/dll/win32/rpcrt4/ndr_stubless.c
index 47d03b13564..c84d8977c10 100644
--- a/dll/win32/rpcrt4/ndr_stubless.c
+++ b/dll/win32/rpcrt4/ndr_stubless.c
@@ -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;

Reply via email to