-/*\r
- * MIDL proxy/stub stuff\r
- *\r
- * Copyright 2002 Ove Kåven, TransGaming Technologies\r
- *\r
- * This library is free software; you can redistribute it and/or\r
- * modify it under the terms of the GNU Lesser General Public\r
- * License as published by the Free Software Foundation; either\r
- * version 2.1 of the License, or (at your option) any later version.\r
- *\r
- * This library is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
- * Lesser General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU Lesser General Public\r
- * License along with this library; if not, write to the Free Software\r
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
- *\r
- * TODO:\r
- * - figure out whether we *really* got this right\r
- * - check for errors and throw exceptions\r
- */\r
-\r
-#include <stdarg.h>\r
-#include <stdio.h>\r
-#include <string.h>\r
-#include <assert.h>\r
-\r
-#define COBJMACROS\r
-\r
-#include "windef.h"\r
-#include "winbase.h"\r
-#include "winerror.h"\r
-#include "winreg.h"\r
-\r
-#include "objbase.h"\r
-\r
-#include "rpcproxy.h"\r
-\r
-#include "wine/debug.h"\r
-\r
-#include "cpsf.h"\r
-#include "ndr_misc.h"\r
-#include "rpcndr.h"\r
-\r
-WINE_DEFAULT_DEBUG_CHANNEL(ole);\r
-\r
-/***********************************************************************\r
- * NdrProxyInitialize [RPCRT4.@]\r
- */\r
-void WINAPI NdrProxyInitialize(void *This,\r
- PRPC_MESSAGE pRpcMsg,\r
- PMIDL_STUB_MESSAGE pStubMsg,\r
- PMIDL_STUB_DESC pStubDescriptor,\r
- unsigned int ProcNum)\r
-{\r
- HRESULT hr;\r
-\r
- TRACE("(%p,%p,%p,%p,%d)\n", This, pRpcMsg, pStubMsg, pStubDescriptor, ProcNum);\r
- NdrClientInitializeNew(pRpcMsg, pStubMsg, pStubDescriptor, ProcNum);\r
- if (This) StdProxy_GetChannel(This, &pStubMsg->pRpcChannelBuffer);\r
- if (pStubMsg->pRpcChannelBuffer) {\r
- hr = IRpcChannelBuffer_GetDestCtx(pStubMsg->pRpcChannelBuffer,\r
- &pStubMsg->dwDestContext,\r
- &pStubMsg->pvDestContext);\r
- }\r
- TRACE("channel=%p\n", pStubMsg->pRpcChannelBuffer);\r
-}\r
-\r
-/***********************************************************************\r
- * NdrProxyGetBuffer [RPCRT4.@]\r
- */\r
-void WINAPI NdrProxyGetBuffer(void *This,\r
- PMIDL_STUB_MESSAGE pStubMsg)\r
-{\r
- HRESULT hr;\r
- const IID *riid = NULL;\r
-\r
- TRACE("(%p,%p)\n", This, pStubMsg);\r
- pStubMsg->RpcMsg->BufferLength = pStubMsg->BufferLength;\r
- pStubMsg->dwStubPhase = PROXY_GETBUFFER;\r
- hr = StdProxy_GetIID(This, &riid);\r
- hr = IRpcChannelBuffer_GetBuffer(pStubMsg->pRpcChannelBuffer,\r
- (RPCOLEMESSAGE*)pStubMsg->RpcMsg,\r
- riid);\r
- pStubMsg->BufferStart = pStubMsg->RpcMsg->Buffer;\r
- pStubMsg->BufferEnd = pStubMsg->BufferStart + pStubMsg->BufferLength;\r
- pStubMsg->Buffer = pStubMsg->BufferStart;\r
- pStubMsg->dwStubPhase = PROXY_MARSHAL;\r
-}\r
-\r
-/***********************************************************************\r
- * NdrProxySendReceive [RPCRT4.@]\r
- */\r
-void WINAPI NdrProxySendReceive(void *This,\r
- PMIDL_STUB_MESSAGE pStubMsg)\r
-{\r
- ULONG Status = 0;\r
- HRESULT hr;\r
-\r
- TRACE("(%p,%p)\n", This, pStubMsg);\r
- pStubMsg->dwStubPhase = PROXY_SENDRECEIVE;\r
- hr = IRpcChannelBuffer_SendReceive(pStubMsg->pRpcChannelBuffer,\r
- (RPCOLEMESSAGE*)pStubMsg->RpcMsg,\r
- &Status);\r
- pStubMsg->dwStubPhase = PROXY_UNMARSHAL;\r
- pStubMsg->BufferLength = pStubMsg->RpcMsg->BufferLength;\r
- pStubMsg->BufferStart = pStubMsg->RpcMsg->Buffer;\r
- pStubMsg->BufferEnd = pStubMsg->BufferStart + pStubMsg->BufferLength;\r
- pStubMsg->Buffer = pStubMsg->BufferStart;\r
-\r
- /* raise exception if call failed */\r
- if (hr == RPC_S_CALL_FAILED) RpcRaiseException(*(DWORD*)pStubMsg->Buffer);\r
- else if (FAILED(hr)) RpcRaiseException(hr);\r
-}\r
-\r
-/***********************************************************************\r
- * NdrProxyFreeBuffer [RPCRT4.@]\r
- */\r
-void WINAPI NdrProxyFreeBuffer(void *This,\r
- PMIDL_STUB_MESSAGE pStubMsg)\r
-{\r
- HRESULT hr;\r
-\r
- TRACE("(%p,%p)\n", This, pStubMsg);\r
- hr = IRpcChannelBuffer_FreeBuffer(pStubMsg->pRpcChannelBuffer,\r
- (RPCOLEMESSAGE*)pStubMsg->RpcMsg);\r
-}\r
-\r
-/***********************************************************************\r
- * NdrProxyErrorHandler [RPCRT4.@]\r
- */\r
-HRESULT WINAPI NdrProxyErrorHandler(DWORD dwExceptionCode)\r
-{\r
- FIXME("(0x%08lx): semi-stub\n", dwExceptionCode);\r
- return MAKE_HRESULT(SEVERITY_ERROR, FACILITY_RPC, RPC_S_CALL_FAILED);\r
-}\r
-\r
-/***********************************************************************\r
- * NdrStubInitialize [RPCRT4.@]\r
- */\r
-void WINAPI NdrStubInitialize(PRPC_MESSAGE pRpcMsg,\r
- PMIDL_STUB_MESSAGE pStubMsg,\r
- PMIDL_STUB_DESC pStubDescriptor,\r
- LPRPCCHANNELBUFFER pRpcChannelBuffer)\r
-{\r
- TRACE("(%p,%p,%p,%p)\n", pRpcMsg, pStubMsg, pStubDescriptor, pRpcChannelBuffer);\r
- NdrServerInitializeNew(pRpcMsg, pStubMsg, pStubDescriptor);\r
- pStubMsg->pRpcChannelBuffer = pRpcChannelBuffer;\r
-}\r
-\r
-/***********************************************************************\r
- * NdrStubGetBuffer [RPCRT4.@]\r
- */\r
-void WINAPI NdrStubGetBuffer(LPRPCSTUBBUFFER This,\r
- LPRPCCHANNELBUFFER pRpcChannelBuffer,\r
- PMIDL_STUB_MESSAGE pStubMsg)\r
-{\r
- TRACE("(%p,%p)\n", This, pStubMsg);\r
- pStubMsg->pRpcChannelBuffer = pRpcChannelBuffer;\r
- pStubMsg->RpcMsg->BufferLength = pStubMsg->BufferLength;\r
- I_RpcGetBuffer(pStubMsg->RpcMsg); /* ? */\r
- pStubMsg->BufferStart = pStubMsg->RpcMsg->Buffer;\r
- pStubMsg->BufferEnd = pStubMsg->BufferStart + pStubMsg->BufferLength;\r
- pStubMsg->Buffer = pStubMsg->BufferStart;\r
-}\r
-\r
-/************************************************************************\r
- * NdrClientInitializeNew [RPCRT4.@]\r
- */\r
-void WINAPI NdrClientInitializeNew( PRPC_MESSAGE pRpcMessage, PMIDL_STUB_MESSAGE pStubMsg, \r
- PMIDL_STUB_DESC pStubDesc, unsigned int ProcNum )\r
-{\r
- TRACE("(pRpcMessage == ^%p, pStubMsg == ^%p, pStubDesc == ^%p, ProcNum == %d)\n",\r
- pRpcMessage, pStubMsg, pStubDesc, ProcNum);\r
-\r
- assert( pRpcMessage && pStubMsg && pStubDesc );\r
-\r
- memset(pRpcMessage, 0, sizeof(RPC_MESSAGE));\r
-\r
- /* not everyone allocates stack space for w2kReserved */\r
- memset(pStubMsg, 0, FIELD_OFFSET(MIDL_STUB_MESSAGE,pCSInfo));\r
-\r
- pStubMsg->ReuseBuffer = FALSE;\r
- pStubMsg->IsClient = TRUE;\r
- pStubMsg->StubDesc = pStubDesc;\r
- pStubMsg->pfnAllocate = pStubDesc->pfnAllocate;\r
- pStubMsg->pfnFree = pStubDesc->pfnFree;\r
- pStubMsg->RpcMsg = pRpcMessage;\r
-\r
- pRpcMessage->ProcNum = ProcNum;\r
- pRpcMessage->RpcInterfaceInformation = pStubDesc->RpcInterfaceInformation;\r
-}\r
-\r
-/***********************************************************************\r
- * NdrServerInitializeNew [RPCRT4.@]\r
- */\r
-unsigned char* WINAPI NdrServerInitializeNew( PRPC_MESSAGE pRpcMsg, PMIDL_STUB_MESSAGE pStubMsg,\r
- PMIDL_STUB_DESC pStubDesc )\r
-{\r
- TRACE("(pRpcMsg == ^%p, pStubMsg == ^%p, pStubDesc == ^%p)\n", pRpcMsg, pStubMsg, pStubDesc);\r
-\r
- assert( pRpcMsg && pStubMsg && pStubDesc );\r
-\r
- /* not everyone allocates stack space for w2kReserved */\r
- memset(pStubMsg, 0, FIELD_OFFSET(MIDL_STUB_MESSAGE,pCSInfo));\r
-\r
- pStubMsg->ReuseBuffer = TRUE;\r
- pStubMsg->IsClient = FALSE;\r
- pStubMsg->StubDesc = pStubDesc;\r
- pStubMsg->pfnAllocate = pStubDesc->pfnAllocate;\r
- pStubMsg->pfnFree = pStubDesc->pfnFree;\r
- pStubMsg->RpcMsg = pRpcMsg;\r
- pStubMsg->Buffer = pStubMsg->BufferStart = pRpcMsg->Buffer;\r
- pStubMsg->BufferLength = pRpcMsg->BufferLength;\r
- pStubMsg->BufferEnd = pStubMsg->Buffer + pStubMsg->BufferLength;\r
-\r
- /* FIXME: determine the proper return value */\r
- return NULL;\r
-}\r
-\r
-/***********************************************************************\r
- * NdrGetBuffer [RPCRT4.@]\r
- */\r
-unsigned char *WINAPI NdrGetBuffer(MIDL_STUB_MESSAGE *stubmsg, unsigned long buflen, RPC_BINDING_HANDLE handle)\r
-{\r
- TRACE("(stubmsg == ^%p, buflen == %lu, handle == %p): wild guess.\n", stubmsg, buflen, handle);\r
- \r
- assert( stubmsg && stubmsg->RpcMsg );\r
-\r
- /* I guess this is our chance to put the binding handle into the RPC_MESSAGE */\r
- stubmsg->RpcMsg->Handle = handle;\r
- \r
- stubmsg->RpcMsg->BufferLength = buflen;\r
- if (I_RpcGetBuffer(stubmsg->RpcMsg) != S_OK)\r
- return NULL;\r
-\r
- stubmsg->Buffer = stubmsg->BufferStart = stubmsg->RpcMsg->Buffer;\r
- stubmsg->BufferLength = stubmsg->RpcMsg->BufferLength;\r
- stubmsg->BufferEnd = stubmsg->Buffer + stubmsg->BufferLength;\r
- return (stubmsg->Buffer = (unsigned char *)stubmsg->RpcMsg->Buffer);\r
-}\r
-/***********************************************************************\r
- * NdrFreeBuffer [RPCRT4.@]\r
- */\r
-void WINAPI NdrFreeBuffer(MIDL_STUB_MESSAGE *pStubMsg)\r
-{\r
- TRACE("(pStubMsg == ^%p): wild guess.\n", pStubMsg);\r
- I_RpcFreeBuffer(pStubMsg->RpcMsg);\r
- pStubMsg->BufferLength = 0;\r
- pStubMsg->Buffer = pStubMsg->BufferEnd = (unsigned char *)(pStubMsg->RpcMsg->Buffer = NULL);\r
-}\r
-\r
-/************************************************************************\r
- * NdrSendReceive [RPCRT4.@]\r
- */\r
-unsigned char *WINAPI NdrSendReceive( MIDL_STUB_MESSAGE *stubmsg, unsigned char *buffer )\r
-{\r
- TRACE("(stubmsg == ^%p, buffer == ^%p)\n", stubmsg, buffer);\r
-\r
- /* FIXME: how to handle errors? (raise exception?) */\r
- if (!stubmsg) {\r
- ERR("NULL stub message. No action taken.\n");\r
- return NULL;\r
- }\r
- if (!stubmsg->RpcMsg) {\r
- ERR("RPC Message not present in stub message. No action taken.\n");\r
- return NULL;\r
- }\r
-\r
- /* FIXME: Seems wrong. Where should this really come from, and when? */\r
- stubmsg->RpcMsg->DataRepresentation = NDR_LOCAL_DATA_REPRESENTATION;\r
-\r
- if (I_RpcSendReceive(stubmsg->RpcMsg) != RPC_S_OK) {\r
- WARN("I_RpcSendReceive did not return success.\n");\r
- /* FIXME: raise exception? */\r
- }\r
-\r
- /* FIXME: is this the right return value? */\r
- return NULL;\r
-}\r
+/*
+ * MIDL proxy/stub stuff
+ *
+ * Copyright 2002 Ove Kåven, TransGaming Technologies
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * TODO:
+ * - figure out whether we *really* got this right
+ * - check for errors and throw exceptions
+ */
+
+#include <stdarg.h>
+#include <stdio.h>
+#include <string.h>
+#include <assert.h>
+
+#define COBJMACROS
+
+#include "windef.h"
+#include "winbase.h"
+#include "winerror.h"
+#include "winreg.h"
+
+#include "objbase.h"
+
+#include "rpcproxy.h"
+
+#include "wine/debug.h"
+
+#include "cpsf.h"
+#include "ndr_misc.h"
+#include "rpcndr.h"
+
+WINE_DEFAULT_DEBUG_CHANNEL(rpc);
+
+/***********************************************************************
+ * NdrProxyInitialize [RPCRT4.@]
+ */
+void WINAPI NdrProxyInitialize(void *This,
+ PRPC_MESSAGE pRpcMsg,
+ PMIDL_STUB_MESSAGE pStubMsg,
+ PMIDL_STUB_DESC pStubDescriptor,
+ unsigned int ProcNum)
+{
+ HRESULT hr;
+
+ TRACE("(%p,%p,%p,%p,%d)\n", This, pRpcMsg, pStubMsg, pStubDescriptor, ProcNum);
+ NdrClientInitializeNew(pRpcMsg, pStubMsg, pStubDescriptor, ProcNum);
+ if (This) StdProxy_GetChannel(This, &pStubMsg->pRpcChannelBuffer);
+ if (pStubMsg->pRpcChannelBuffer) {
+ hr = IRpcChannelBuffer_GetDestCtx(pStubMsg->pRpcChannelBuffer,
+ &pStubMsg->dwDestContext,
+ &pStubMsg->pvDestContext);
+ }
+ TRACE("channel=%p\n", pStubMsg->pRpcChannelBuffer);
+}
+
+/***********************************************************************
+ * NdrProxyGetBuffer [RPCRT4.@]
+ */
+void WINAPI NdrProxyGetBuffer(void *This,
+ PMIDL_STUB_MESSAGE pStubMsg)
+{
+ HRESULT hr;
+ const IID *riid = NULL;
+
+ TRACE("(%p,%p)\n", This, pStubMsg);
+ pStubMsg->RpcMsg->BufferLength = pStubMsg->BufferLength;
+ pStubMsg->dwStubPhase = PROXY_GETBUFFER;
+ hr = StdProxy_GetIID(This, &riid);
+ hr = IRpcChannelBuffer_GetBuffer(pStubMsg->pRpcChannelBuffer,
+ (RPCOLEMESSAGE*)pStubMsg->RpcMsg,
+ riid);
+ pStubMsg->BufferStart = pStubMsg->RpcMsg->Buffer;
+ pStubMsg->BufferEnd = pStubMsg->BufferStart + pStubMsg->BufferLength;
+ pStubMsg->Buffer = pStubMsg->BufferStart;
+ pStubMsg->dwStubPhase = PROXY_MARSHAL;
+}
+
+/***********************************************************************
+ * NdrProxySendReceive [RPCRT4.@]
+ */
+void WINAPI NdrProxySendReceive(void *This,
+ PMIDL_STUB_MESSAGE pStubMsg)
+{
+ ULONG Status = 0;
+ HRESULT hr;
+
+ TRACE("(%p,%p)\n", This, pStubMsg);
+
+ if (!pStubMsg->pRpcChannelBuffer)
+ {
+ WARN("Trying to use disconnected proxy %p\n", This);
+ RpcRaiseException(RPC_E_DISCONNECTED);
+ }
+
+ pStubMsg->dwStubPhase = PROXY_SENDRECEIVE;
+ hr = IRpcChannelBuffer_SendReceive(pStubMsg->pRpcChannelBuffer,
+ (RPCOLEMESSAGE*)pStubMsg->RpcMsg,
+ &Status);
+ pStubMsg->dwStubPhase = PROXY_UNMARSHAL;
+ pStubMsg->BufferLength = pStubMsg->RpcMsg->BufferLength;
+ pStubMsg->BufferStart = pStubMsg->RpcMsg->Buffer;
+ pStubMsg->BufferEnd = pStubMsg->BufferStart + pStubMsg->BufferLength;
+ pStubMsg->Buffer = pStubMsg->BufferStart;
+
+ /* raise exception if call failed */
+ if (hr == RPC_S_CALL_FAILED) RpcRaiseException(*(DWORD*)pStubMsg->Buffer);
+ else if (FAILED(hr)) RpcRaiseException(hr);
+}
+
+/***********************************************************************
+ * NdrProxyFreeBuffer [RPCRT4.@]
+ */
+void WINAPI NdrProxyFreeBuffer(void *This,
+ PMIDL_STUB_MESSAGE pStubMsg)
+{
+ HRESULT hr;
+
+ TRACE("(%p,%p)\n", This, pStubMsg);
+ hr = IRpcChannelBuffer_FreeBuffer(pStubMsg->pRpcChannelBuffer,
+ (RPCOLEMESSAGE*)pStubMsg->RpcMsg);
+}
+
+/***********************************************************************
+ * NdrProxyErrorHandler [RPCRT4.@]
+ */
+HRESULT WINAPI NdrProxyErrorHandler(DWORD dwExceptionCode)
+{
+ FIXME("(0x%08lx): semi-stub\n", dwExceptionCode);
+ return MAKE_HRESULT(SEVERITY_ERROR, FACILITY_RPC, RPC_S_CALL_FAILED);
+}
+
+/***********************************************************************
+ * NdrStubInitialize [RPCRT4.@]
+ */
+void WINAPI NdrStubInitialize(PRPC_MESSAGE pRpcMsg,
+ PMIDL_STUB_MESSAGE pStubMsg,
+ PMIDL_STUB_DESC pStubDescriptor,
+ LPRPCCHANNELBUFFER pRpcChannelBuffer)
+{
+ TRACE("(%p,%p,%p,%p)\n", pRpcMsg, pStubMsg, pStubDescriptor, pRpcChannelBuffer);
+ NdrServerInitializeNew(pRpcMsg, pStubMsg, pStubDescriptor);
+ pStubMsg->pRpcChannelBuffer = pRpcChannelBuffer;
+}
+
+/***********************************************************************
+ * NdrStubGetBuffer [RPCRT4.@]
+ */
+void WINAPI NdrStubGetBuffer(LPRPCSTUBBUFFER This,
+ LPRPCCHANNELBUFFER pRpcChannelBuffer,
+ PMIDL_STUB_MESSAGE pStubMsg)
+{
+ TRACE("(%p,%p)\n", This, pStubMsg);
+ pStubMsg->pRpcChannelBuffer = pRpcChannelBuffer;
+ pStubMsg->RpcMsg->BufferLength = pStubMsg->BufferLength;
+ I_RpcGetBuffer(pStubMsg->RpcMsg); /* ? */
+ pStubMsg->BufferStart = pStubMsg->RpcMsg->Buffer;
+ pStubMsg->BufferEnd = pStubMsg->BufferStart + pStubMsg->BufferLength;
+ pStubMsg->Buffer = pStubMsg->BufferStart;
+}
+
+/************************************************************************
+ * NdrClientInitializeNew [RPCRT4.@]
+ */
+void WINAPI NdrClientInitializeNew( PRPC_MESSAGE pRpcMessage, PMIDL_STUB_MESSAGE pStubMsg,
+ PMIDL_STUB_DESC pStubDesc, unsigned int ProcNum )
+{
+ TRACE("(pRpcMessage == ^%p, pStubMsg == ^%p, pStubDesc == ^%p, ProcNum == %d)\n",
+ pRpcMessage, pStubMsg, pStubDesc, ProcNum);
+
+ assert( pRpcMessage && pStubMsg && pStubDesc );
+
+ memset(pRpcMessage, 0, sizeof(RPC_MESSAGE));
+ 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->IsClient = TRUE;
+ pStubMsg->StubDesc = pStubDesc;
+ pStubMsg->pfnAllocate = pStubDesc->pfnAllocate;
+ pStubMsg->pfnFree = pStubDesc->pfnFree;
+ pStubMsg->RpcMsg = pRpcMessage;
+
+ pRpcMessage->ProcNum = ProcNum;
+ pRpcMessage->RpcInterfaceInformation = pStubDesc->RpcInterfaceInformation;
+}
+
+/***********************************************************************
+ * NdrServerInitializeNew [RPCRT4.@]
+ */
+unsigned char* WINAPI NdrServerInitializeNew( PRPC_MESSAGE pRpcMsg, PMIDL_STUB_MESSAGE pStubMsg,
+ PMIDL_STUB_DESC pStubDesc )
+{
+ TRACE("(pRpcMsg == ^%p, pStubMsg == ^%p, pStubDesc == ^%p)\n", pRpcMsg, pStubMsg, pStubDesc);
+
+ assert( pRpcMsg && pStubMsg && pStubDesc );
+
+ /* not everyone allocates stack space for w2kReserved */
+ memset(pStubMsg, 0, FIELD_OFFSET(MIDL_STUB_MESSAGE,pCSInfo));
+
+ pStubMsg->ReuseBuffer = TRUE;
+ pStubMsg->IsClient = FALSE;
+ pStubMsg->StubDesc = pStubDesc;
+ pStubMsg->pfnAllocate = pStubDesc->pfnAllocate;
+ pStubMsg->pfnFree = pStubDesc->pfnFree;
+ pStubMsg->RpcMsg = pRpcMsg;
+ pStubMsg->Buffer = pStubMsg->BufferStart = pRpcMsg->Buffer;
+ pStubMsg->BufferLength = pRpcMsg->BufferLength;
+ pStubMsg->BufferEnd = pStubMsg->Buffer + pStubMsg->BufferLength;
+
+ /* FIXME: determine the proper return value */
+ return NULL;
+}
+
+/***********************************************************************
+ * NdrGetBuffer [RPCRT4.@]
+ */
+unsigned char *WINAPI NdrGetBuffer(MIDL_STUB_MESSAGE *stubmsg, unsigned long buflen, RPC_BINDING_HANDLE handle)
+{
+ TRACE("(stubmsg == ^%p, buflen == %lu, handle == %p): wild guess.\n", stubmsg, buflen, handle);
+
+ assert( stubmsg && stubmsg->RpcMsg );
+
+ /* I guess this is our chance to put the binding handle into the RPC_MESSAGE */
+ stubmsg->RpcMsg->Handle = handle;
+
+ stubmsg->RpcMsg->BufferLength = buflen;
+ if (I_RpcGetBuffer(stubmsg->RpcMsg) != S_OK)
+ return NULL;
+
+ stubmsg->Buffer = stubmsg->BufferStart = stubmsg->RpcMsg->Buffer;
+ stubmsg->BufferLength = stubmsg->RpcMsg->BufferLength;
+ stubmsg->BufferEnd = stubmsg->Buffer + stubmsg->BufferLength;
+ return (stubmsg->Buffer = (unsigned char *)stubmsg->RpcMsg->Buffer);
+}
+
+/***********************************************************************
+ * NdrFreeBuffer [RPCRT4.@]
+ */
+void WINAPI NdrFreeBuffer(MIDL_STUB_MESSAGE *pStubMsg)
+{
+ TRACE("(pStubMsg == ^%p): wild guess.\n", pStubMsg);
+ I_RpcFreeBuffer(pStubMsg->RpcMsg);
+ pStubMsg->BufferLength = 0;
+ pStubMsg->Buffer = pStubMsg->BufferEnd = (unsigned char *)(pStubMsg->RpcMsg->Buffer = NULL);
+}
+
+/************************************************************************
+ * NdrSendReceive [RPCRT4.@]
+ */
+unsigned char *WINAPI NdrSendReceive( MIDL_STUB_MESSAGE *pStubMsg, unsigned char *buffer )
+{
+ TRACE("(pStubMsg == ^%p, buffer == ^%p)\n", pStubMsg, buffer);
+
+ /* FIXME: how to handle errors? (raise exception?) */
+ if (!pStubMsg) {
+ ERR("NULL stub message. No action taken.\n");
+ return NULL;
+ }
+ if (!pStubMsg->RpcMsg) {
+ ERR("RPC Message not present in stub message. No action taken.\n");
+ return NULL;
+ }
+
+ if (I_RpcSendReceive(pStubMsg->RpcMsg) != RPC_S_OK) {
+ WARN("I_RpcSendReceive did not return success.\n");
+ /* FIXME: raise exception? */
+ return NULL;
+ }
+
+ pStubMsg->BufferLength = pStubMsg->RpcMsg->BufferLength;
+ pStubMsg->BufferStart = pStubMsg->RpcMsg->Buffer;
+ pStubMsg->BufferEnd = pStubMsg->BufferStart + pStubMsg->BufferLength;
+ pStubMsg->Buffer = pStubMsg->BufferStart;
+
+ /* FIXME: is this the right return value? */
+ return NULL;
+}
+
+/************************************************************************
+ * NdrMapCommAndFaultStatus [RPCRT4.@]
+ */
+RPC_STATUS RPC_ENTRY NdrMapCommAndFaultStatus( PMIDL_STUB_MESSAGE pStubMsg,
+ unsigned long *pCommStatus,
+ unsigned long *pFaultStatus,
+ RPC_STATUS Status )
+{
+ FIXME("(%p, %p, %p, %ld): stub\n", pStubMsg, pCommStatus, pFaultStatus, Status);
+
+ *pCommStatus = 0;
+ *pFaultStatus = 0;
+
+ return RPC_S_OK;
+}