2 * MIDL proxy/stub stuff
4 * Copyright 2002 Ove Kåven, TransGaming Technologies
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 * - figure out whether we *really* got this right
22 * - check for errors and throw exceptions
33 #include "wine/obj_base.h"
34 #include "wine/obj_channel.h"
38 #include "wine/debug.h"
43 WINE_DEFAULT_DEBUG_CHANNEL(ole);
45 /***********************************************************************
46 * NdrProxyInitialize [RPCRT4.@]
48 void WINAPI NdrProxyInitialize(void *This,
50 PMIDL_STUB_MESSAGE pStubMsg,
51 PMIDL_STUB_DESC pStubDescriptor,
56 TRACE("(%p,%p,%p,%p,%d)\n", This, pRpcMsg, pStubMsg, pStubDescriptor, ProcNum);
57 memset(pRpcMsg, 0, sizeof(RPC_MESSAGE));
58 memset(pStubMsg, 0, sizeof(MIDL_STUB_MESSAGE));
59 pRpcMsg->ProcNum = ProcNum;
60 pRpcMsg->RpcInterfaceInformation = pStubDescriptor->RpcInterfaceInformation;
61 pStubMsg->RpcMsg = pRpcMsg;
62 pStubMsg->IsClient = 1;
63 pStubMsg->ReuseBuffer = 1;
64 pStubMsg->pfnAllocate = pStubDescriptor->pfnAllocate;
65 pStubMsg->pfnFree = pStubDescriptor->pfnFree;
66 pStubMsg->StubDesc = pStubDescriptor;
67 if (This) StdProxy_GetChannel(This, &pStubMsg->pRpcChannelBuffer);
68 if (pStubMsg->pRpcChannelBuffer) {
69 hr = IRpcChannelBuffer_GetDestCtx(pStubMsg->pRpcChannelBuffer,
70 &pStubMsg->dwDestContext,
71 &pStubMsg->pvDestContext);
73 TRACE("channel=%p\n", pStubMsg->pRpcChannelBuffer);
76 /***********************************************************************
77 * NdrProxyGetBuffer [RPCRT4.@]
79 void WINAPI NdrProxyGetBuffer(void *This,
80 PMIDL_STUB_MESSAGE pStubMsg)
83 const IID *riid = NULL;
85 TRACE("(%p,%p)\n", This, pStubMsg);
86 pStubMsg->RpcMsg->BufferLength = pStubMsg->BufferLength;
87 pStubMsg->dwStubPhase = PROXY_GETBUFFER;
88 hr = StdProxy_GetIID(This, &riid);
89 hr = IRpcChannelBuffer_GetBuffer(pStubMsg->pRpcChannelBuffer,
90 (RPCOLEMESSAGE*)pStubMsg->RpcMsg,
92 pStubMsg->BufferStart = pStubMsg->RpcMsg->Buffer;
93 pStubMsg->BufferEnd = pStubMsg->BufferStart + pStubMsg->BufferLength;
94 pStubMsg->Buffer = pStubMsg->BufferStart;
95 pStubMsg->dwStubPhase = PROXY_MARSHAL;
98 /***********************************************************************
99 * NdrProxySendReceive [RPCRT4.@]
101 void WINAPI NdrProxySendReceive(void *This,
102 PMIDL_STUB_MESSAGE pStubMsg)
107 TRACE("(%p,%p)\n", This, pStubMsg);
108 pStubMsg->dwStubPhase = PROXY_SENDRECEIVE;
109 hr = IRpcChannelBuffer_SendReceive(pStubMsg->pRpcChannelBuffer,
110 (RPCOLEMESSAGE*)pStubMsg->RpcMsg,
112 pStubMsg->dwStubPhase = PROXY_UNMARSHAL;
113 pStubMsg->BufferLength = pStubMsg->RpcMsg->BufferLength;
114 pStubMsg->BufferStart = pStubMsg->RpcMsg->Buffer;
115 pStubMsg->BufferEnd = pStubMsg->BufferStart + pStubMsg->BufferLength;
116 pStubMsg->Buffer = pStubMsg->BufferStart;
119 /***********************************************************************
120 * NdrProxyFreeBuffer [RPCRT4.@]
122 void WINAPI NdrProxyFreeBuffer(void *This,
123 PMIDL_STUB_MESSAGE pStubMsg)
127 TRACE("(%p,%p)\n", This, pStubMsg);
128 hr = IRpcChannelBuffer_FreeBuffer(pStubMsg->pRpcChannelBuffer,
129 (RPCOLEMESSAGE*)pStubMsg->RpcMsg);
132 /***********************************************************************
133 * NdrStubInitialize [RPCRT4.@]
135 void WINAPI NdrStubInitialize(PRPC_MESSAGE pRpcMsg,
136 PMIDL_STUB_MESSAGE pStubMsg,
137 PMIDL_STUB_DESC pStubDescriptor,
138 LPRPCCHANNELBUFFER pRpcChannelBuffer)
140 TRACE("(%p,%p,%p,%p)\n", pRpcMsg, pStubMsg, pStubDescriptor, pRpcChannelBuffer);
141 memset(pStubMsg, 0, sizeof(MIDL_STUB_MESSAGE));
142 pStubMsg->RpcMsg = pRpcMsg;
143 pStubMsg->IsClient = 0;
144 pStubMsg->ReuseBuffer = 1;
145 pStubMsg->pfnAllocate = pStubDescriptor->pfnAllocate;
146 pStubMsg->pfnFree = pStubDescriptor->pfnFree;
147 pStubMsg->StubDesc = pStubDescriptor;
148 pStubMsg->pRpcChannelBuffer = pRpcChannelBuffer;
149 pStubMsg->BufferLength = pStubMsg->RpcMsg->BufferLength;
150 pStubMsg->BufferStart = pStubMsg->RpcMsg->Buffer;
151 pStubMsg->BufferEnd = pStubMsg->BufferStart + pStubMsg->BufferLength;
152 pStubMsg->Buffer = pStubMsg->BufferStart;
155 /***********************************************************************
156 * NdrStubGetBuffer [RPCRT4.@]
158 void WINAPI NdrStubGetBuffer(LPRPCSTUBBUFFER This,
159 LPRPCCHANNELBUFFER pRpcChannelBuffer,
160 PMIDL_STUB_MESSAGE pStubMsg)
162 TRACE("(%p,%p)\n", This, pStubMsg);
163 pStubMsg->pRpcChannelBuffer = pRpcChannelBuffer;
164 pStubMsg->RpcMsg->BufferLength = pStubMsg->BufferLength;
165 I_RpcGetBuffer(pStubMsg->RpcMsg); /* ? */
166 pStubMsg->BufferStart = pStubMsg->RpcMsg->Buffer;
167 pStubMsg->BufferEnd = pStubMsg->BufferStart + pStubMsg->BufferLength;
168 pStubMsg->Buffer = pStubMsg->BufferStart;