2002-10-11 01:26:53 +02:00
|
|
|
|
/*
|
|
|
|
|
* MIDL proxy/stub stuff
|
|
|
|
|
*
|
|
|
|
|
* Copyright 2002 Ove K<EFBFBD>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
|
2006-05-18 14:49:52 +02:00
|
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2002-10-11 01:26:53 +02:00
|
|
|
|
*
|
|
|
|
|
* TODO:
|
|
|
|
|
* - figure out whether we *really* got this right
|
|
|
|
|
* - check for errors and throw exceptions
|
|
|
|
|
*/
|
|
|
|
|
|
2003-09-06 01:08:26 +02:00
|
|
|
|
#include <stdarg.h>
|
2002-10-11 01:26:53 +02:00
|
|
|
|
#include <stdio.h>
|
|
|
|
|
#include <string.h>
|
2002-10-25 23:02:02 +02:00
|
|
|
|
#include <assert.h>
|
2002-10-11 01:26:53 +02:00
|
|
|
|
|
2004-10-07 05:06:48 +02:00
|
|
|
|
#define COBJMACROS
|
|
|
|
|
|
2002-10-11 01:26:53 +02:00
|
|
|
|
#include "windef.h"
|
|
|
|
|
#include "winbase.h"
|
|
|
|
|
#include "winerror.h"
|
|
|
|
|
#include "winreg.h"
|
|
|
|
|
|
2002-12-05 21:33:07 +01:00
|
|
|
|
#include "objbase.h"
|
2002-10-11 01:26:53 +02:00
|
|
|
|
|
|
|
|
|
#include "rpcproxy.h"
|
|
|
|
|
|
|
|
|
|
#include "wine/debug.h"
|
|
|
|
|
|
|
|
|
|
#include "ndr_misc.h"
|
2002-10-28 22:14:16 +01:00
|
|
|
|
#include "rpcndr.h"
|
2002-10-11 01:26:53 +02:00
|
|
|
|
|
2005-03-14 11:11:04 +01:00
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(rpc);
|
2002-10-11 01:26:53 +02:00
|
|
|
|
|
2002-10-19 21:14:25 +02:00
|
|
|
|
/************************************************************************
|
|
|
|
|
* NdrClientInitializeNew [RPCRT4.@]
|
|
|
|
|
*/
|
|
|
|
|
void WINAPI NdrClientInitializeNew( PRPC_MESSAGE pRpcMessage, PMIDL_STUB_MESSAGE pStubMsg,
|
2002-10-24 01:36:53 +02:00
|
|
|
|
PMIDL_STUB_DESC pStubDesc, unsigned int ProcNum )
|
2002-10-19 21:14:25 +02:00
|
|
|
|
{
|
2002-10-24 01:36:53 +02:00
|
|
|
|
TRACE("(pRpcMessage == ^%p, pStubMsg == ^%p, pStubDesc == ^%p, ProcNum == %d)\n",
|
|
|
|
|
pRpcMessage, pStubMsg, pStubDesc, ProcNum);
|
|
|
|
|
|
2002-10-28 22:14:16 +01:00
|
|
|
|
assert( pRpcMessage && pStubMsg && pStubDesc );
|
|
|
|
|
|
2006-06-01 21:24:34 +02:00
|
|
|
|
pRpcMessage->Handle = NULL;
|
|
|
|
|
pRpcMessage->ProcNum = ProcNum;
|
|
|
|
|
pRpcMessage->RpcInterfaceInformation = pStubDesc->RpcInterfaceInformation;
|
|
|
|
|
pRpcMessage->RpcFlags = 0;
|
2005-06-05 21:19:50 +02:00
|
|
|
|
pRpcMessage->DataRepresentation = NDR_LOCAL_DATA_REPRESENTATION;
|
2003-05-21 20:22:49 +02:00
|
|
|
|
|
2006-06-01 21:24:34 +02:00
|
|
|
|
pStubMsg->RpcMsg = pRpcMessage;
|
|
|
|
|
pStubMsg->BufferStart = NULL;
|
|
|
|
|
pStubMsg->BufferEnd = NULL;
|
|
|
|
|
pStubMsg->BufferLength = 0;
|
2002-10-24 01:36:53 +02:00
|
|
|
|
pStubMsg->IsClient = TRUE;
|
2006-06-01 21:24:34 +02:00
|
|
|
|
pStubMsg->ReuseBuffer = FALSE;
|
|
|
|
|
pStubMsg->pAllocAllNodesContext = NULL;
|
|
|
|
|
pStubMsg->pPointerQueueState = NULL;
|
|
|
|
|
pStubMsg->IgnoreEmbeddedPointers = 0;
|
|
|
|
|
pStubMsg->PointerBufferMark = NULL;
|
|
|
|
|
pStubMsg->fBufferValid = 0;
|
|
|
|
|
pStubMsg->uFlags = 0;
|
2002-10-24 01:36:53 +02:00
|
|
|
|
pStubMsg->pfnAllocate = pStubDesc->pfnAllocate;
|
|
|
|
|
pStubMsg->pfnFree = pStubDesc->pfnFree;
|
2006-06-01 21:24:34 +02:00
|
|
|
|
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;
|
2002-10-19 21:14:25 +02:00
|
|
|
|
}
|
|
|
|
|
|
2002-10-28 21:07:01 +01:00
|
|
|
|
/***********************************************************************
|
|
|
|
|
* NdrServerInitializeNew [RPCRT4.@]
|
|
|
|
|
*/
|
|
|
|
|
unsigned char* WINAPI NdrServerInitializeNew( PRPC_MESSAGE pRpcMsg, PMIDL_STUB_MESSAGE pStubMsg,
|
|
|
|
|
PMIDL_STUB_DESC pStubDesc )
|
|
|
|
|
{
|
2002-10-28 22:14:16 +01:00
|
|
|
|
TRACE("(pRpcMsg == ^%p, pStubMsg == ^%p, pStubDesc == ^%p)\n", pRpcMsg, pStubMsg, pStubDesc);
|
|
|
|
|
|
|
|
|
|
assert( pRpcMsg && pStubMsg && pStubDesc );
|
|
|
|
|
|
2003-05-21 20:22:49 +02:00
|
|
|
|
/* not everyone allocates stack space for w2kReserved */
|
2004-09-08 03:27:24 +02:00
|
|
|
|
memset(pStubMsg, 0, FIELD_OFFSET(MIDL_STUB_MESSAGE,pCSInfo));
|
2002-10-28 22:14:16 +01:00
|
|
|
|
|
|
|
|
|
pStubMsg->ReuseBuffer = TRUE;
|
|
|
|
|
pStubMsg->IsClient = FALSE;
|
|
|
|
|
pStubMsg->StubDesc = pStubDesc;
|
|
|
|
|
pStubMsg->pfnAllocate = pStubDesc->pfnAllocate;
|
|
|
|
|
pStubMsg->pfnFree = pStubDesc->pfnFree;
|
|
|
|
|
pStubMsg->RpcMsg = pRpcMsg;
|
2003-01-31 04:22:53 +01:00
|
|
|
|
pStubMsg->Buffer = pStubMsg->BufferStart = pRpcMsg->Buffer;
|
2002-10-29 00:53:23 +01:00
|
|
|
|
pStubMsg->BufferLength = pRpcMsg->BufferLength;
|
2003-01-31 04:22:53 +01:00
|
|
|
|
pStubMsg->BufferEnd = pStubMsg->Buffer + pStubMsg->BufferLength;
|
2002-10-28 22:14:16 +01:00
|
|
|
|
|
|
|
|
|
/* FIXME: determine the proper return value */
|
2002-10-28 21:07:01 +01:00
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
2002-10-19 21:14:25 +02:00
|
|
|
|
/***********************************************************************
|
|
|
|
|
* NdrGetBuffer [RPCRT4.@]
|
|
|
|
|
*/
|
2007-02-07 16:20:45 +01:00
|
|
|
|
unsigned char *WINAPI NdrGetBuffer(PMIDL_STUB_MESSAGE stubmsg, ULONG buflen, RPC_BINDING_HANDLE handle)
|
2002-10-19 21:14:25 +02:00
|
|
|
|
{
|
2006-11-09 23:04:48 +01:00
|
|
|
|
TRACE("(stubmsg == ^%p, buflen == %u, handle == %p): wild guess.\n", stubmsg, buflen, handle);
|
2002-10-25 21:03:43 +02:00
|
|
|
|
|
2002-10-25 23:02:02 +02:00
|
|
|
|
assert( stubmsg && stubmsg->RpcMsg );
|
|
|
|
|
|
|
|
|
|
/* I guess this is our chance to put the binding handle into the RPC_MESSAGE */
|
|
|
|
|
stubmsg->RpcMsg->Handle = handle;
|
2002-10-25 21:03:43 +02:00
|
|
|
|
|
|
|
|
|
stubmsg->RpcMsg->BufferLength = buflen;
|
|
|
|
|
if (I_RpcGetBuffer(stubmsg->RpcMsg) != S_OK)
|
|
|
|
|
return NULL;
|
|
|
|
|
|
2003-01-31 04:22:53 +01:00
|
|
|
|
stubmsg->Buffer = stubmsg->BufferStart = stubmsg->RpcMsg->Buffer;
|
2002-10-25 21:03:43 +02:00
|
|
|
|
stubmsg->BufferLength = stubmsg->RpcMsg->BufferLength;
|
2003-01-31 04:22:53 +01:00
|
|
|
|
stubmsg->BufferEnd = stubmsg->Buffer + stubmsg->BufferLength;
|
2002-10-25 21:03:43 +02:00
|
|
|
|
return (stubmsg->Buffer = (unsigned char *)stubmsg->RpcMsg->Buffer);
|
2002-10-19 21:14:25 +02:00
|
|
|
|
}
|
|
|
|
|
/***********************************************************************
|
|
|
|
|
* NdrFreeBuffer [RPCRT4.@]
|
|
|
|
|
*/
|
2007-02-07 16:20:45 +01:00
|
|
|
|
void WINAPI NdrFreeBuffer(PMIDL_STUB_MESSAGE pStubMsg)
|
2002-10-19 21:14:25 +02:00
|
|
|
|
{
|
2002-10-25 21:03:43 +02:00
|
|
|
|
TRACE("(pStubMsg == ^%p): wild guess.\n", pStubMsg);
|
|
|
|
|
I_RpcFreeBuffer(pStubMsg->RpcMsg);
|
|
|
|
|
pStubMsg->BufferLength = 0;
|
2003-01-31 04:22:53 +01:00
|
|
|
|
pStubMsg->Buffer = pStubMsg->BufferEnd = (unsigned char *)(pStubMsg->RpcMsg->Buffer = NULL);
|
2002-10-19 21:14:25 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/************************************************************************
|
|
|
|
|
* NdrSendReceive [RPCRT4.@]
|
|
|
|
|
*/
|
2007-02-07 16:20:45 +01:00
|
|
|
|
unsigned char *WINAPI NdrSendReceive( PMIDL_STUB_MESSAGE stubmsg, unsigned char *buffer )
|
2002-10-19 21:14:25 +02:00
|
|
|
|
{
|
2006-02-03 18:46:32 +01:00
|
|
|
|
RPC_STATUS status;
|
|
|
|
|
|
2002-10-25 23:02:02 +02:00
|
|
|
|
TRACE("(stubmsg == ^%p, buffer == ^%p)\n", stubmsg, buffer);
|
|
|
|
|
|
|
|
|
|
/* FIXME: how to handle errors? (raise exception?) */
|
|
|
|
|
if (!stubmsg) {
|
|
|
|
|
ERR("NULL stub message. No action taken.\n");
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
if (!stubmsg->RpcMsg) {
|
|
|
|
|
ERR("RPC Message not present in stub message. No action taken.\n");
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
2003-01-31 04:22:53 +01:00
|
|
|
|
|
2006-06-01 21:24:42 +02:00
|
|
|
|
stubmsg->RpcMsg->BufferLength = buffer - (unsigned char *)stubmsg->RpcMsg->Buffer;
|
2006-02-03 18:46:32 +01:00
|
|
|
|
status = I_RpcSendReceive(stubmsg->RpcMsg);
|
|
|
|
|
if (status != RPC_S_OK)
|
|
|
|
|
RpcRaiseException(status);
|
2002-10-25 23:02:02 +02:00
|
|
|
|
|
2005-11-28 11:31:04 +01:00
|
|
|
|
stubmsg->BufferLength = stubmsg->RpcMsg->BufferLength;
|
|
|
|
|
stubmsg->BufferStart = stubmsg->RpcMsg->Buffer;
|
|
|
|
|
stubmsg->BufferEnd = stubmsg->BufferStart + stubmsg->BufferLength;
|
|
|
|
|
stubmsg->Buffer = stubmsg->BufferStart;
|
|
|
|
|
|
2002-10-25 23:02:02 +02:00
|
|
|
|
/* FIXME: is this the right return value? */
|
2002-10-22 01:42:01 +02:00
|
|
|
|
return NULL;
|
2002-10-19 21:14:25 +02:00
|
|
|
|
}
|
2005-08-03 16:55:57 +02:00
|
|
|
|
|
|
|
|
|
/************************************************************************
|
|
|
|
|
* NdrMapCommAndFaultStatus [RPCRT4.@]
|
|
|
|
|
*/
|
|
|
|
|
RPC_STATUS RPC_ENTRY NdrMapCommAndFaultStatus( PMIDL_STUB_MESSAGE pStubMsg,
|
2006-11-09 23:02:09 +01:00
|
|
|
|
ULONG *pCommStatus,
|
|
|
|
|
ULONG *pFaultStatus,
|
2005-08-03 16:55:57 +02:00
|
|
|
|
RPC_STATUS Status )
|
|
|
|
|
{
|
|
|
|
|
FIXME("(%p, %p, %p, %ld): stub\n", pStubMsg, pCommStatus, pFaultStatus, Status);
|
|
|
|
|
|
|
|
|
|
*pCommStatus = 0;
|
|
|
|
|
*pFaultStatus = 0;
|
|
|
|
|
|
|
|
|
|
return RPC_S_OK;
|
|
|
|
|
}
|