Robert Shearman : rpcrt4: NdrClientInitializeNew shouldn' t clear all of the stub message, only selected fields.

Alexandre Julliard julliard at wine.codeweavers.com
Fri Jun 2 04:55:50 CDT 2006


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

Author: Robert Shearman <rob at codeweavers.com>
Date:   Thu Jun  1 20:24:34 2006 +0100

rpcrt4: NdrClientInitializeNew shouldn't clear all of the stub message, only selected fields.

---

 dlls/rpcrt4/ndr_midl.c           |   46 ++++++++++++++++----
 dlls/rpcrt4/tests/ndr_marshall.c |   87 ++++++++++++++++++++++++++++++++++++++
 2 files changed, 123 insertions(+), 10 deletions(-)

diff --git a/dlls/rpcrt4/ndr_midl.c b/dlls/rpcrt4/ndr_midl.c
index b6665f6..3ac0aed 100644
--- a/dlls/rpcrt4/ndr_midl.c
+++ b/dlls/rpcrt4/ndr_midl.c
@@ -188,21 +188,47 @@ void WINAPI NdrClientInitializeNew( PRPC
 
   assert( pRpcMessage && pStubMsg && pStubDesc );
 
-  memset(pRpcMessage, 0, sizeof(RPC_MESSAGE));
+  pRpcMessage->Handle = NULL;
+  pRpcMessage->ProcNum = ProcNum;
+  pRpcMessage->RpcInterfaceInformation = pStubDesc->RpcInterfaceInformation;
+  pRpcMessage->RpcFlags = 0;
   pRpcMessage->DataRepresentation = NDR_LOCAL_DATA_REPRESENTATION;
 
-  /* not everyone allocates stack space for w2kReserved */
-  memset(pStubMsg, 0, FIELD_OFFSET(MIDL_STUB_MESSAGE,pCSInfo));
-
-  pStubMsg->ReuseBuffer = FALSE;
+  pStubMsg->RpcMsg = pRpcMessage;
+  pStubMsg->BufferStart = NULL;
+  pStubMsg->BufferEnd = NULL;
+  pStubMsg->BufferLength = 0;
   pStubMsg->IsClient = TRUE;
-  pStubMsg->StubDesc = pStubDesc;
+  pStubMsg->ReuseBuffer = FALSE;
+  pStubMsg->pAllocAllNodesContext = NULL;
+  pStubMsg->pPointerQueueState = NULL;
+  pStubMsg->IgnoreEmbeddedPointers = 0;
+  pStubMsg->PointerBufferMark = NULL;
+  pStubMsg->fBufferValid = 0;
+  pStubMsg->uFlags = 0;
   pStubMsg->pfnAllocate = pStubDesc->pfnAllocate;
   pStubMsg->pfnFree = pStubDesc->pfnFree;
-  pStubMsg->RpcMsg = pRpcMessage;
-
-  pRpcMessage->ProcNum = ProcNum;
-  pRpcMessage->RpcInterfaceInformation = pStubDesc->RpcInterfaceInformation;
+  pStubMsg->StackTop = NULL;
+  pStubMsg->StubDesc = pStubDesc;
+  pStubMsg->FullPtrRefId = 0;
+  pStubMsg->PointerLength = 0;
+  pStubMsg->fInDontFree = 0;
+  pStubMsg->fDontCallFreeInst = 0;
+  pStubMsg->fInOnlyParam = 0;
+  pStubMsg->fHasReturn = 0;
+  pStubMsg->fHasExtensions = 0;
+  pStubMsg->fHasNewCorrDesc = 0;
+  pStubMsg->fUnused = 0;
+  pStubMsg->dwDestContext = MSHCTX_DIFFERENTMACHINE;
+  pStubMsg->pvDestContext = NULL;
+  pStubMsg->pRpcChannelBuffer = NULL;
+  pStubMsg->pArrayInfo = NULL;
+  pStubMsg->dwStubPhase = 0;
+  /* FIXME: LowStackMark */
+  pStubMsg->pAsyncMsg = NULL;
+  pStubMsg->pCorrInfo = NULL;
+  pStubMsg->pCorrMemory = NULL;
+  pStubMsg->pMemoryList = NULL;
 }
 
 /***********************************************************************
diff --git a/dlls/rpcrt4/tests/ndr_marshall.c b/dlls/rpcrt4/tests/ndr_marshall.c
index 0a70b9a..ca9f5fd 100644
--- a/dlls/rpcrt4/tests/ndr_marshall.c
+++ b/dlls/rpcrt4/tests/ndr_marshall.c
@@ -815,9 +815,96 @@ static void test_fullpointer_xlat(void)
     NdrFullPointerXlatFree(pXlatTables);
 }
 
+static void test_client_init(void)
+{
+    MIDL_STUB_MESSAGE stubMsg;
+    RPC_MESSAGE rpcMsg;
+
+    memset(&stubMsg, 0xcc, sizeof(stubMsg));
+
+    NdrClientInitializeNew(&rpcMsg, &stubMsg, &Object_StubDesc, 1);
+
+#define TEST_ZERO(field, fmt) ok(stubMsg.field == 0, #field " should have be set to zero instead of " fmt "\n", stubMsg.field)
+#define TEST_POINTER_UNSET(field) ok(stubMsg.field == (void *)0xcccccccc, #field " should have be unset instead of %p\n", stubMsg.field)
+#define TEST_ULONG_UNSET(field) ok(stubMsg.field == 0xcccccccc, #field " should have be unset instead of 0x%lx\n", stubMsg.field)
+
+    ok(stubMsg.RpcMsg == &rpcMsg, "stubMsg.RpcMsg should have been %p instead of %p\n", &rpcMsg, stubMsg.RpcMsg);
+    TEST_POINTER_UNSET(Buffer);
+    TEST_ZERO(BufferStart, "%p");
+    TEST_ZERO(BufferEnd, "%p");
+    TEST_POINTER_UNSET(BufferMark);
+    TEST_ZERO(BufferLength, "%ld");
+    TEST_ULONG_UNSET(MemorySize);
+    TEST_POINTER_UNSET(Memory);
+    ok(stubMsg.IsClient == 1, "stubMsg.IsClient should have been 1 instead of %u\n", stubMsg.IsClient);
+    TEST_ZERO(ReuseBuffer, "%d");
+    TEST_ZERO(pAllocAllNodesContext, "%p");
+    TEST_ZERO(pPointerQueueState, "%p");
+    TEST_ZERO(IgnoreEmbeddedPointers, "%d");
+    TEST_ZERO(PointerBufferMark, "%p");
+    TEST_ZERO(fBufferValid, "%d");
+    TEST_ZERO(uFlags, "%d");
+    /* FIXME: UniquePtrCount */
+    TEST_ULONG_UNSET(MaxCount);
+    TEST_ULONG_UNSET(Offset);
+    TEST_ULONG_UNSET(ActualCount);
+    ok(stubMsg.pfnAllocate == my_alloc, "stubMsg.pfnAllocate should have been %p instead of %p\n", my_alloc, stubMsg.pfnAllocate);
+    ok(stubMsg.pfnFree == my_free, "stubMsg.pfnFree should have been %p instead of %p\n", my_free, stubMsg.pfnFree);
+    TEST_ZERO(StackTop, "%p");
+    TEST_POINTER_UNSET(pPresentedType);
+    TEST_POINTER_UNSET(pTransmitType);
+    TEST_POINTER_UNSET(SavedHandle);
+    ok(stubMsg.StubDesc == &Object_StubDesc, "stubMsg.StubDesc should have been %p instead of %p\n", &Object_StubDesc, stubMsg.StubDesc);
+    TEST_POINTER_UNSET(FullPtrXlatTables);
+    TEST_ZERO(FullPtrRefId, "%ld");
+    TEST_ZERO(PointerLength, "%ld");
+    TEST_ZERO(fInDontFree, "%d");
+    TEST_ZERO(fDontCallFreeInst, "%d");
+    TEST_ZERO(fInOnlyParam, "%d");
+    TEST_ZERO(fHasReturn, "%d");
+    TEST_ZERO(fHasExtensions, "%d");
+    TEST_ZERO(fHasNewCorrDesc, "%d");
+    TEST_ZERO(fUnused, "%d");
+    ok(stubMsg.fUnused2 == 0xffffcccc, "stubMsg.fUnused2 should have been 0xcccc instead of 0x%x\n", stubMsg.fUnused2);
+    ok(stubMsg.dwDestContext == MSHCTX_DIFFERENTMACHINE, "stubMsg.dwDestContext should have been MSHCTX_DIFFERENTMACHINE instead of %ld\n", stubMsg.dwDestContext);
+    TEST_ZERO(pvDestContext, "%p");
+    TEST_POINTER_UNSET(SavedContextHandles);
+    TEST_ULONG_UNSET(ParamNumber);
+    TEST_ZERO(pRpcChannelBuffer, "%p");
+    TEST_ZERO(pArrayInfo, "%p");
+    TEST_POINTER_UNSET(SizePtrCountArray);
+    TEST_POINTER_UNSET(SizePtrOffsetArray);
+    TEST_POINTER_UNSET(SizePtrLengthArray);
+    TEST_POINTER_UNSET(pArgQueue);
+    TEST_ZERO(dwStubPhase, "%ld");
+    /* FIXME: where does this value come from? */
+    trace("LowStackMark is %p\n", stubMsg.LowStackMark);
+    TEST_ZERO(pAsyncMsg, "%p");
+    TEST_ZERO(pCorrInfo, "%p");
+    TEST_ZERO(pCorrMemory, "%p");
+    TEST_ZERO(pMemoryList, "%p");
+    TEST_POINTER_UNSET(pCSInfo);
+    TEST_POINTER_UNSET(ConformanceMark);
+    TEST_POINTER_UNSET(VarianceMark);
+    ok(stubMsg.Unused == 0xcccccccc, "Unused should have be unset instead of 0x%x\n", stubMsg.Unused);
+    TEST_POINTER_UNSET(pContext);
+#if 0
+    TEST_ULONG_UNSET(Reserved51_1);
+    TEST_ULONG_UNSET(Reserved51_2);
+    TEST_ULONG_UNSET(Reserved51_3);
+    TEST_ULONG_UNSET(Reserved51_4);
+    TEST_ULONG_UNSET(Reserved51_5);
+#endif
+#undef TEST_ULONG_UNSET
+#undef TEST_POINTER_UNSET
+#undef TEST_ZERO
+
+}
+
 START_TEST( ndr_marshall )
 {
     test_simple_types();
     test_simple_struct();
     test_fullpointer_xlat();
+    test_client_init();
 }




More information about the wine-cvs mailing list