From a215f6b21ace26cc21e839ced0e4775b1a27baad Mon Sep 17 00:00:00 2001 From: Greg Turner Date: Mon, 28 Oct 2002 21:14:16 +0000 Subject: [PATCH] - Clean up and add some comments. - Add NDR Data representation constants. - Propagate DataRepresentation into and out of packet headers. - Implement NdrServerInitializeNew --- dlls/rpcrt4/ndr_marshall.c | 6 +++++- dlls/rpcrt4/ndr_midl.c | 21 ++++++++++++++++++++- dlls/rpcrt4/rpc_message.c | 4 ++++ dlls/rpcrt4/rpc_server.c | 6 ++++++ include/rpcndr.h | 10 ++++++++++ 5 files changed, 45 insertions(+), 2 deletions(-) diff --git a/dlls/rpcrt4/ndr_marshall.c b/dlls/rpcrt4/ndr_marshall.c index de0f02a64ba..732e7b0cbab 100644 --- a/dlls/rpcrt4/ndr_marshall.c +++ b/dlls/rpcrt4/ndr_marshall.c @@ -105,7 +105,7 @@ void WINAPI NdrConformantStringBufferSize(PMIDL_STUB_MESSAGE pStubMsg, unsigned TRACE("(pStubMsg == ^%p, pMemory == ^%p, pFormat == ^%p)\n", pStubMsg, pMemory, pFormat); if (*pFormat == RPC_FC_C_CSTRING) { - /* we need 12 chars for the [maxlen, offset, len] DWORDS, + 1 byte for '\0' */ + /* we need 12 octets for the [maxlen, offset, len] DWORDS, + 1 octet for '\0' */ pStubMsg->BufferLength = strlen(pMemory) + 13 + BUFFER_PARANOIA; } else { ERR("Unhandled string type: %#x\n", *pFormat); @@ -139,6 +139,8 @@ unsigned char *WINAPI NdrConformantStringUnmarshall( PMIDL_STUB_MESSAGE pStubMsg void WINAPI NdrConvert( PMIDL_STUB_MESSAGE pStubMsg, PFORMAT_STRING pFormat ) { FIXME("(pStubMsg == ^%p, pFormat == ^%p): stub.\n", pStubMsg, pFormat); + /* FIXME: since this stub doesn't do any converting, the proper behavior + is to raise an exception */ } /*********************************************************************** @@ -147,4 +149,6 @@ void WINAPI NdrConvert( PMIDL_STUB_MESSAGE pStubMsg, PFORMAT_STRING pFormat ) void WINAPI NdrConvert2( PMIDL_STUB_MESSAGE pStubMsg, PFORMAT_STRING pFormat, long NumberParams ) { FIXME("(pStubMsg == ^%p, pFormat == ^%p, NumberParams == %ld): stub.\n", pStubMsg, pFormat, NumberParams); + /* FIXME: since this stub doesn't do any converting, the proper behavior + is to raise an exception */ } diff --git a/dlls/rpcrt4/ndr_midl.c b/dlls/rpcrt4/ndr_midl.c index 02c35c11bb7..a7cc82d8ee9 100644 --- a/dlls/rpcrt4/ndr_midl.c +++ b/dlls/rpcrt4/ndr_midl.c @@ -40,6 +40,7 @@ #include "cpsf.h" #include "ndr_misc.h" +#include "rpcndr.h" WINE_DEFAULT_DEBUG_CHANNEL(ole); @@ -178,6 +179,8 @@ void WINAPI NdrClientInitializeNew( PRPC_MESSAGE pRpcMessage, PMIDL_STUB_MESSAGE TRACE("(pRpcMessage == ^%p, pStubMsg == ^%p, pStubDesc == ^%p, ProcNum == %d)\n", pRpcMessage, pStubMsg, pStubDesc, ProcNum); + assert( pRpcMessage && pStubMsg && pStubDesc ); + memset(pRpcMessage, 0, sizeof(RPC_MESSAGE)); memset(pStubMsg, 0, sizeof(MIDL_STUB_MESSAGE)); @@ -198,7 +201,20 @@ void WINAPI NdrClientInitializeNew( PRPC_MESSAGE pRpcMessage, PMIDL_STUB_MESSAGE unsigned char* WINAPI NdrServerInitializeNew( PRPC_MESSAGE pRpcMsg, PMIDL_STUB_MESSAGE pStubMsg, PMIDL_STUB_DESC pStubDesc ) { - FIXME("(pRpcMsg == ^%p, pStubMsg == ^%p, pStubDesc == ^%p): stub.\n", pRpcMsg, pStubMsg, pStubDesc); + TRACE("(pRpcMsg == ^%p, pStubMsg == ^%p, pStubDesc == ^%p)\n", pRpcMsg, pStubMsg, pStubDesc); + + assert( pRpcMsg && pStubMsg && pStubDesc ); + + memset(pStubMsg, 0, sizeof(MIDL_STUB_MESSAGE)); + + pStubMsg->ReuseBuffer = TRUE; + pStubMsg->IsClient = FALSE; + pStubMsg->StubDesc = pStubDesc; + pStubMsg->pfnAllocate = pStubDesc->pfnAllocate; + pStubMsg->pfnFree = pStubDesc->pfnFree; + pStubMsg->RpcMsg = pRpcMsg; + + /* FIXME: determine the proper return value */ return NULL; } @@ -253,6 +269,9 @@ unsigned char *WINAPI NdrSendReceive( MIDL_STUB_MESSAGE *stubmsg, unsigned char ERR("Ambiguous buffer doesn't match rpc message buffer. No action taken.\n"); return NULL; } + + /* not sure where MS does this; for now I'll stick it here */ + stubmsg->RpcMsg->DataRepresentation = NDR_LOCAL_DATA_REPRESENTATION; if (I_RpcSendReceive(stubmsg->RpcMsg) != RPC_S_OK) { WARN("I_RpcSendReceive did not return success.\n"); diff --git a/dlls/rpcrt4/rpc_message.c b/dlls/rpcrt4/rpc_message.c index 2245e65666f..9564e070e52 100644 --- a/dlls/rpcrt4/rpc_message.c +++ b/dlls/rpcrt4/rpc_message.c @@ -102,6 +102,10 @@ RPC_STATUS WINAPI I_RpcSend(PRPC_MESSAGE pMsg) MAKELONG(sif->InterfaceId.SyntaxVersion.MinorVersion, sif->InterfaceId.SyntaxVersion.MajorVersion) : MAKELONG(cif->InterfaceId.SyntaxVersion.MinorVersion, cif->InterfaceId.SyntaxVersion.MajorVersion); hdr.opnum = pMsg->ProcNum; + /* only the low-order 3 octets of the DataRepresentation go in the header */ + hdr.drep[0] = LOBYTE(LOWORD(pMsg->DataRepresentation)); + hdr.drep[1] = HIBYTE(LOWORD(pMsg->DataRepresentation)); + hdr.drep[2] = LOBYTE(HIWORD(pMsg->DataRepresentation)); hdr.len = pMsg->BufferLength; /* transmit packet */ diff --git a/dlls/rpcrt4/rpc_server.c b/dlls/rpcrt4/rpc_server.c index 99c3a2f1a4e..0574b9411fb 100644 --- a/dlls/rpcrt4/rpc_server.c +++ b/dlls/rpcrt4/rpc_server.c @@ -144,6 +144,12 @@ static DWORD CALLBACK RPCRT4_io_thread(LPVOID the_arg) } func = sif->If->DispatchTable->DispatchTable[msg.ProcNum]; } + + /* put in the drep. FIXME: is this more universally applicable? + perhaps we should move this outward... */ + msg.DataRepresentation = + MAKELONG( MAKEWORD(hdr.drep[0], hdr.drep[1]), + MAKEWORD(hdr.drep[2], 0)); /* dispatch */ if (func) func(&msg); diff --git a/include/rpcndr.h b/include/rpcndr.h index ad53a4392d9..77600ae62df 100644 --- a/include/rpcndr.h +++ b/include/rpcndr.h @@ -26,6 +26,16 @@ #include "rpc.h" +#define NDR_LITTLE_ENDIAN ((UINT32) 0x00000010) +#define NDR_BIG_ENDIAN ((UINT32) 0x00000000) + +/* Character Representation: ASCII + * Integer Representation: Little Endian + * FP Representation: IEEE + */ +#define NDR_LOCAL_DATA_REPRESENTATION ((UINT32) 0x00000010) +#define NDR_LOCAL_ENDIAN NDR_LITTLE_ENDIAN + #define TARGET_IS_NT40_OR_LATER 1 #define TARGET_IS_NT351_OR_WIN95_OR_LATER 1 -- 2.11.4.GIT