Robert Shearman : rpcrt4: Fix the wire protocol of the user marshal functions to match MS/RPC.

Alexandre Julliard julliard at wine.codeweavers.com
Thu May 18 03:56:53 CDT 2006


Module: wine
Branch: refs/heads/master
Commit: 62bbaf70b35182d4a733ca2f2207eb369acabf3a
URL:    http://source.winehq.org/git/?p=wine.git;a=commit;h=62bbaf70b35182d4a733ca2f2207eb369acabf3a

Author: Robert Shearman <rob at codeweavers.com>
Date:   Thu May 18 03:39:27 2006 +0100

rpcrt4: Fix the wire protocol of the user marshal functions to match MS/RPC.

---

 dlls/rpcrt4/ndr_marshall.c |   52 +++++++++++++++++++++++++++++++++++++++++---
 1 files changed, 49 insertions(+), 3 deletions(-)

diff --git a/dlls/rpcrt4/ndr_marshall.c b/dlls/rpcrt4/ndr_marshall.c
index 4c7791e..231f7a5 100644
--- a/dlls/rpcrt4/ndr_marshall.c
+++ b/dlls/rpcrt4/ndr_marshall.c
@@ -2518,6 +2518,10 @@ unsigned long UserMarshalFlags(PMIDL_STU
                   pStubMsg->RpcMsg->DataRepresentation);
 }
 
+#define USER_MARSHAL_PTR_PREFIX \
+        ( (DWORD)'U'         | ( (DWORD)'s' << 8 ) | \
+        ( (DWORD)'e' << 16 ) | ( (DWORD)'r' << 24 ) )
+
 /***********************************************************************
  *           NdrUserMarshalMarshall [RPCRT4.@]
  */
@@ -2525,12 +2529,22 @@ unsigned char * WINAPI NdrUserMarshalMar
                                               unsigned char *pMemory,
                                               PFORMAT_STRING pFormat)
 {
-/*  unsigned flags = pFormat[1]; */
+  unsigned flags = pFormat[1];
   unsigned index = *(const WORD*)&pFormat[2];
   unsigned long uflag = UserMarshalFlags(pStubMsg);
   TRACE("(%p,%p,%p)\n", pStubMsg, pMemory, pFormat);
   TRACE("index=%d\n", index);
 
+  if (flags & USER_MARSHAL_POINTER)
+  {
+    ALIGN_POINTER(pStubMsg->Buffer, 4);
+    NDR_LOCAL_UINT32_WRITE(pStubMsg->Buffer, USER_MARSHAL_PTR_PREFIX);
+    pStubMsg->Buffer += 4;
+    ALIGN_POINTER(pStubMsg->Buffer, 8);
+  }
+  else
+    ALIGN_POINTER(pStubMsg->Buffer, (flags & 0xf) + 1);
+
   pStubMsg->Buffer =
     pStubMsg->StubDesc->aUserMarshalQuadruple[index].pfnMarshall(
       &uflag, pStubMsg->Buffer, pMemory);
@@ -2548,13 +2562,23 @@ unsigned char * WINAPI NdrUserMarshalUnm
                                                  PFORMAT_STRING pFormat,
                                                  unsigned char fMustAlloc)
 {
-/*  unsigned flags = pFormat[1];*/
+  unsigned flags = pFormat[1];
   unsigned index = *(const WORD*)&pFormat[2];
   DWORD memsize = *(const WORD*)&pFormat[4];
   unsigned long uflag = UserMarshalFlags(pStubMsg);
   TRACE("(%p,%p,%p,%d)\n", pStubMsg, ppMemory, pFormat, fMustAlloc);
   TRACE("index=%d\n", index);
 
+  if (flags & USER_MARSHAL_POINTER)
+  {
+    ALIGN_POINTER(pStubMsg->Buffer, 4);
+    /* skip pointer prefix */
+    pStubMsg->Buffer += 4;
+    ALIGN_POINTER(pStubMsg->Buffer, 8);
+  }
+  else
+    ALIGN_POINTER(pStubMsg->Buffer, (flags & 0xf) + 1);
+
   if (fMustAlloc || !*ppMemory)
     *ppMemory = NdrAllocate(pStubMsg, memsize);
 
@@ -2572,13 +2596,23 @@ void WINAPI NdrUserMarshalBufferSize(PMI
                                       unsigned char *pMemory,
                                       PFORMAT_STRING pFormat)
 {
-/*  unsigned flags = pFormat[1];*/
+  unsigned flags = pFormat[1];
   unsigned index = *(const WORD*)&pFormat[2];
   DWORD bufsize = *(const WORD*)&pFormat[6];
   unsigned long uflag = UserMarshalFlags(pStubMsg);
   TRACE("(%p,%p,%p)\n", pStubMsg, pMemory, pFormat);
   TRACE("index=%d\n", index);
 
+  if (flags & USER_MARSHAL_POINTER)
+  {
+    ALIGN_LENGTH(pStubMsg->BufferLength, 4);
+    /* skip pointer prefix */
+    pStubMsg->BufferLength += 4;
+    ALIGN_LENGTH(pStubMsg->BufferLength, 8);
+  }
+  else
+    ALIGN_LENGTH(pStubMsg->BufferLength, (flags & 0xf) + 1);
+
   if (bufsize) {
     TRACE("size=%ld\n", bufsize);
     pStubMsg->BufferLength += bufsize;
@@ -2596,6 +2630,7 @@ void WINAPI NdrUserMarshalBufferSize(PMI
 unsigned long WINAPI NdrUserMarshalMemorySize(PMIDL_STUB_MESSAGE pStubMsg,
                                               PFORMAT_STRING pFormat)
 {
+  unsigned flags = pFormat[1];
   unsigned index = *(const WORD*)&pFormat[2];
   DWORD memsize = *(const WORD*)&pFormat[4];
   DWORD bufsize = *(const WORD*)&pFormat[6];
@@ -2604,6 +2639,17 @@ unsigned long WINAPI NdrUserMarshalMemor
   TRACE("index=%d\n", index);
 
   pStubMsg->MemorySize += memsize;
+
+  if (flags & USER_MARSHAL_POINTER)
+  {
+    ALIGN_POINTER(pStubMsg->Buffer, 4);
+    /* skip pointer prefix */
+    pStubMsg->Buffer += 4;
+    ALIGN_POINTER(pStubMsg->Buffer, 8);
+  }
+  else
+    ALIGN_POINTER(pStubMsg->Buffer, (flags & 0xf) + 1);
+
   pStubMsg->Buffer += bufsize;
 
   return pStubMsg->MemorySize;




More information about the wine-cvs mailing list