wevtapi: Fix typo in spec file.
[wine/zf.git] / dlls / rpcrt4 / cstub.c
blob838ed03653123922f0b7615c16835e7751003150
1 /*
2 * COM stub (CStdStubBuffer) implementation
4 * Copyright 2001 Ove Kåven, TransGaming Technologies
5 * Copyright 2009 Alexandre Julliard
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
22 #include "config.h"
23 #include "wine/port.h"
25 #include <stdarg.h>
27 #define COBJMACROS
29 #include "windef.h"
30 #include "winbase.h"
31 #include "winerror.h"
32 #include "excpt.h"
34 #include "objbase.h"
35 #include "rpcproxy.h"
37 #include "wine/debug.h"
38 #include "wine/exception.h"
40 #include "cpsf.h"
42 WINE_DEFAULT_DEBUG_CHANNEL(ole);
44 #define STUB_HEADER(This) (((const CInterfaceStubHeader*)((This)->lpVtbl))[-1])
46 static LONG WINAPI stub_filter(EXCEPTION_POINTERS *eptr)
48 if (eptr->ExceptionRecord->ExceptionFlags & EXCEPTION_NONCONTINUABLE)
49 return EXCEPTION_CONTINUE_SEARCH;
50 return EXCEPTION_EXECUTE_HANDLER;
53 typedef struct
55 IUnknownVtbl *base_obj;
56 IRpcStubBuffer *base_stub;
57 CStdStubBuffer stub_buffer;
58 } cstdstubbuffer_delegating_t;
60 static inline cstdstubbuffer_delegating_t *impl_from_delegating( IRpcStubBuffer *iface )
62 return CONTAINING_RECORD(iface, cstdstubbuffer_delegating_t, stub_buffer);
65 HRESULT CStdStubBuffer_Construct(REFIID riid,
66 LPUNKNOWN pUnkServer,
67 PCInterfaceName name,
68 CInterfaceStubVtbl *vtbl,
69 LPPSFACTORYBUFFER pPSFactory,
70 LPRPCSTUBBUFFER *ppStub)
72 CStdStubBuffer *This;
73 IUnknown *pvServer;
74 HRESULT r;
75 TRACE("(%p,%p,%p,%p) %s\n", pUnkServer, vtbl, pPSFactory, ppStub, name);
76 TRACE("iid=%s\n", debugstr_guid(vtbl->header.piid));
77 TRACE("vtbl=%p\n", &vtbl->Vtbl);
79 if (!IsEqualGUID(vtbl->header.piid, riid)) {
80 ERR("IID mismatch during stub creation\n");
81 return RPC_E_UNEXPECTED;
84 r = IUnknown_QueryInterface(pUnkServer, riid, (void**)&pvServer);
85 if(FAILED(r))
86 return r;
88 This = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(CStdStubBuffer));
89 if (!This) {
90 IUnknown_Release(pvServer);
91 return E_OUTOFMEMORY;
94 This->lpVtbl = &vtbl->Vtbl;
95 This->RefCount = 1;
96 This->pvServerObject = pvServer;
97 This->pPSFactory = pPSFactory;
98 *ppStub = (LPRPCSTUBBUFFER)This;
100 IPSFactoryBuffer_AddRef(pPSFactory);
101 return S_OK;
104 static CRITICAL_SECTION delegating_vtbl_section;
105 static CRITICAL_SECTION_DEBUG critsect_debug =
107 0, 0, &delegating_vtbl_section,
108 { &critsect_debug.ProcessLocksList, &critsect_debug.ProcessLocksList },
109 0, 0, { (DWORD_PTR)(__FILE__ ": delegating_vtbl_section") }
111 static CRITICAL_SECTION delegating_vtbl_section = { &critsect_debug, -1, 0, 0, 0, 0 };
113 typedef struct
115 DWORD ref;
116 DWORD size;
117 IUnknownVtbl vtbl;
118 /* remaining entries in vtbl */
119 } ref_counted_vtbl;
121 static ref_counted_vtbl *current_vtbl;
124 static HRESULT WINAPI delegating_QueryInterface(IUnknown *pUnk, REFIID iid, void **ppv)
126 *ppv = pUnk;
127 return S_OK;
130 static ULONG WINAPI delegating_AddRef(IUnknown *pUnk)
132 return 1;
135 static ULONG WINAPI delegating_Release(IUnknown *pUnk)
137 return 1;
140 /* The idea here is to replace the first param on the stack
141 ie. This (which will point to cstdstubbuffer_delegating_t)
142 with This->stub_buffer.pvServerObject and then jump to the
143 relevant offset in This->stub_buffer.pvServerObject's vtbl.
145 #ifdef __i386__
147 #include "pshpack1.h"
148 typedef struct {
149 BYTE mov1[4]; /* mov 0x4(%esp),%eax 8b 44 24 04 */
150 BYTE mov2[3]; /* mov 0x10(%eax),%eax 8b 40 10 */
151 BYTE mov3[4]; /* mov %eax,0x4(%esp) 89 44 24 04 */
152 BYTE mov4[2]; /* mov (%eax),%eax 8b 00 */
153 BYTE mov5[2]; /* jmp *offset(%eax) ff a0 offset */
154 DWORD offset;
155 BYTE pad[1]; /* nop 90 */
156 } vtbl_method_t;
157 #include "poppack.h"
159 static const BYTE opcodes[20] = { 0x8b, 0x44, 0x24, 0x04, 0x8b, 0x40, 0x10, 0x89, 0x44, 0x24, 0x04,
160 0x8b, 0x00, 0xff, 0xa0, 0, 0, 0, 0, 0x90 };
162 #elif defined(__x86_64__)
164 #include "pshpack1.h"
165 typedef struct
167 BYTE mov1[4]; /* movq 0x20(%rcx),%rcx 48 8b 49 20 */
168 BYTE mov2[3]; /* movq (%rcx),%rax 48 8b 01 */
169 BYTE jmp[2]; /* jmp *offset(%rax) ff a0 offset */
170 DWORD offset;
171 BYTE pad[3]; /* lea 0x0(%rsi),%rsi 48 8d 36 */
172 } vtbl_method_t;
173 #include "poppack.h"
175 static const BYTE opcodes[16] = { 0x48, 0x8b, 0x49, 0x20, 0x48, 0x8b, 0x01,
176 0xff, 0xa0, 0, 0, 0, 0, 0x48, 0x8d, 0x36 };
177 #else
179 #warning You must implement delegated proxies/stubs for your CPU
180 typedef struct
182 DWORD offset;
183 } vtbl_method_t;
184 static const BYTE opcodes[1];
186 #endif
188 #define BLOCK_SIZE 1024
189 #define MAX_BLOCKS 64 /* 64k methods should be enough for anybody */
191 static const vtbl_method_t *method_blocks[MAX_BLOCKS];
193 static const vtbl_method_t *allocate_block( unsigned int num )
195 unsigned int i;
196 vtbl_method_t *prev, *block;
197 DWORD oldprot;
199 block = VirtualAlloc( NULL, BLOCK_SIZE * sizeof(*block),
200 MEM_COMMIT | MEM_RESERVE, PAGE_EXECUTE_READWRITE );
201 if (!block) return NULL;
203 for (i = 0; i < BLOCK_SIZE; i++)
205 memcpy( &block[i], opcodes, sizeof(opcodes) );
206 block[i].offset = (BLOCK_SIZE * num + i + 3) * sizeof(void *);
208 VirtualProtect( block, BLOCK_SIZE * sizeof(*block), PAGE_EXECUTE_READ, &oldprot );
209 prev = InterlockedCompareExchangePointer( (void **)&method_blocks[num], block, NULL );
210 if (prev) /* someone beat us to it */
212 VirtualFree( block, 0, MEM_RELEASE );
213 block = prev;
215 return block;
218 static BOOL fill_delegated_stub_table(IUnknownVtbl *vtbl, DWORD num)
220 const void **entry = (const void **)(vtbl + 1);
221 DWORD i, j;
223 if (num - 3 > BLOCK_SIZE * MAX_BLOCKS)
225 FIXME( "%u methods not supported\n", num );
226 return FALSE;
228 vtbl->QueryInterface = delegating_QueryInterface;
229 vtbl->AddRef = delegating_AddRef;
230 vtbl->Release = delegating_Release;
231 for (i = 0; i < (num - 3 + BLOCK_SIZE - 1) / BLOCK_SIZE; i++)
233 const vtbl_method_t *block = method_blocks[i];
234 if (!block && !(block = allocate_block( i ))) return FALSE;
235 for (j = 0; j < BLOCK_SIZE && j < num - 3 - i * BLOCK_SIZE; j++) *entry++ = &block[j];
237 return TRUE;
240 BOOL fill_delegated_proxy_table(IUnknownVtbl *vtbl, DWORD num)
242 const void **entry = (const void **)(vtbl + 1);
243 DWORD i, j;
245 if (num - 3 > BLOCK_SIZE * MAX_BLOCKS)
247 FIXME( "%u methods not supported\n", num );
248 return FALSE;
250 vtbl->QueryInterface = IUnknown_QueryInterface_Proxy;
251 vtbl->AddRef = IUnknown_AddRef_Proxy;
252 vtbl->Release = IUnknown_Release_Proxy;
253 for (i = 0; i < (num - 3 + BLOCK_SIZE - 1) / BLOCK_SIZE; i++)
255 const vtbl_method_t *block = method_blocks[i];
256 if (!block && !(block = allocate_block( i ))) return FALSE;
257 for (j = 0; j < BLOCK_SIZE && j < num - 3 - i * BLOCK_SIZE; j++, entry++)
258 if (!*entry) *entry = &block[j];
260 return TRUE;
263 static IUnknownVtbl *get_delegating_vtbl(DWORD num_methods)
265 IUnknownVtbl *ret;
267 if (num_methods < 256) num_methods = 256; /* avoid frequent reallocations */
269 EnterCriticalSection(&delegating_vtbl_section);
271 if(!current_vtbl || num_methods > current_vtbl->size)
273 ref_counted_vtbl *table = HeapAlloc(GetProcessHeap(), 0,
274 FIELD_OFFSET(ref_counted_vtbl, vtbl) + num_methods * sizeof(void*));
275 if (!table)
277 LeaveCriticalSection(&delegating_vtbl_section);
278 return NULL;
281 table->ref = 0;
282 table->size = num_methods;
283 fill_delegated_stub_table(&table->vtbl, num_methods);
285 if (current_vtbl && current_vtbl->ref == 0)
287 TRACE("freeing old table\n");
288 HeapFree(GetProcessHeap(), 0, current_vtbl);
290 current_vtbl = table;
293 current_vtbl->ref++;
294 ret = &current_vtbl->vtbl;
295 LeaveCriticalSection(&delegating_vtbl_section);
296 return ret;
299 static void release_delegating_vtbl(IUnknownVtbl *vtbl)
301 ref_counted_vtbl *table = (ref_counted_vtbl*)((DWORD *)vtbl - 1);
303 EnterCriticalSection(&delegating_vtbl_section);
304 table->ref--;
305 TRACE("ref now %d\n", table->ref);
306 if(table->ref == 0 && table != current_vtbl)
308 TRACE("... and we're not current so free'ing\n");
309 HeapFree(GetProcessHeap(), 0, table);
311 LeaveCriticalSection(&delegating_vtbl_section);
314 HRESULT CStdStubBuffer_Delegating_Construct(REFIID riid,
315 LPUNKNOWN pUnkServer,
316 PCInterfaceName name,
317 CInterfaceStubVtbl *vtbl,
318 REFIID delegating_iid,
319 LPPSFACTORYBUFFER pPSFactory,
320 LPRPCSTUBBUFFER *ppStub)
322 cstdstubbuffer_delegating_t *This;
323 IUnknown *pvServer;
324 HRESULT r;
326 TRACE("(%p,%p,%p,%p) %s\n", pUnkServer, vtbl, pPSFactory, ppStub, name);
327 TRACE("iid=%s delegating to %s\n", debugstr_guid(vtbl->header.piid), debugstr_guid(delegating_iid));
328 TRACE("vtbl=%p\n", &vtbl->Vtbl);
330 if (!IsEqualGUID(vtbl->header.piid, riid))
332 ERR("IID mismatch during stub creation\n");
333 return RPC_E_UNEXPECTED;
336 r = IUnknown_QueryInterface(pUnkServer, riid, (void**)&pvServer);
337 if(FAILED(r)) return r;
339 This = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*This));
340 if (!This)
342 IUnknown_Release(pvServer);
343 return E_OUTOFMEMORY;
346 This->base_obj = get_delegating_vtbl( vtbl->header.DispatchTableCount );
347 r = create_stub(delegating_iid, (IUnknown*)&This->base_obj, &This->base_stub);
348 if(FAILED(r))
350 release_delegating_vtbl(This->base_obj);
351 HeapFree(GetProcessHeap(), 0, This);
352 IUnknown_Release(pvServer);
353 return r;
356 This->stub_buffer.lpVtbl = &vtbl->Vtbl;
357 This->stub_buffer.RefCount = 1;
358 This->stub_buffer.pvServerObject = pvServer;
359 This->stub_buffer.pPSFactory = pPSFactory;
360 *ppStub = (LPRPCSTUBBUFFER)&This->stub_buffer;
362 IPSFactoryBuffer_AddRef(pPSFactory);
363 return S_OK;
366 HRESULT WINAPI CStdStubBuffer_QueryInterface(LPRPCSTUBBUFFER iface,
367 REFIID riid,
368 LPVOID *obj)
370 CStdStubBuffer *This = (CStdStubBuffer *)iface;
371 TRACE("(%p)->QueryInterface(%s,%p)\n",This,debugstr_guid(riid),obj);
373 if (IsEqualIID(&IID_IUnknown, riid) ||
374 IsEqualIID(&IID_IRpcStubBuffer, riid))
376 IRpcStubBuffer_AddRef(iface);
377 *obj = iface;
378 return S_OK;
380 *obj = NULL;
381 return E_NOINTERFACE;
384 ULONG WINAPI CStdStubBuffer_AddRef(LPRPCSTUBBUFFER iface)
386 CStdStubBuffer *This = (CStdStubBuffer *)iface;
387 TRACE("(%p)->AddRef()\n",This);
388 return InterlockedIncrement(&This->RefCount);
391 ULONG WINAPI NdrCStdStubBuffer_Release(LPRPCSTUBBUFFER iface,
392 LPPSFACTORYBUFFER pPSF)
394 CStdStubBuffer *This = (CStdStubBuffer *)iface;
395 ULONG refs;
397 TRACE("(%p)->Release()\n",This);
399 refs = InterlockedDecrement(&This->RefCount);
400 if (!refs)
402 /* test_Release shows that native doesn't call Disconnect here.
403 We'll leave it in for the time being. */
404 IRpcStubBuffer_Disconnect(iface);
406 IPSFactoryBuffer_Release(pPSF);
407 HeapFree(GetProcessHeap(),0,This);
409 return refs;
412 ULONG WINAPI NdrCStdStubBuffer2_Release(LPRPCSTUBBUFFER iface,
413 LPPSFACTORYBUFFER pPSF)
415 cstdstubbuffer_delegating_t *This = impl_from_delegating( iface );
416 ULONG refs;
418 TRACE("(%p)->Release()\n", This);
420 refs = InterlockedDecrement(&This->stub_buffer.RefCount);
421 if (!refs)
423 /* Just like NdrCStdStubBuffer_Release, we shouldn't call
424 Disconnect here */
425 IRpcStubBuffer_Disconnect((IRpcStubBuffer *)&This->stub_buffer);
427 IRpcStubBuffer_Release(This->base_stub);
428 release_delegating_vtbl(This->base_obj);
430 IPSFactoryBuffer_Release(pPSF);
431 HeapFree(GetProcessHeap(), 0, This);
434 return refs;
437 HRESULT WINAPI CStdStubBuffer_Connect(LPRPCSTUBBUFFER iface,
438 LPUNKNOWN lpUnkServer)
440 CStdStubBuffer *This = (CStdStubBuffer *)iface;
441 HRESULT r;
442 IUnknown *new = NULL;
444 TRACE("(%p)->Connect(%p)\n",This,lpUnkServer);
446 r = IUnknown_QueryInterface(lpUnkServer, STUB_HEADER(This).piid, (void**)&new);
447 new = InterlockedExchangePointer((void**)&This->pvServerObject, new);
448 if(new)
449 IUnknown_Release(new);
450 return r;
453 void WINAPI CStdStubBuffer_Disconnect(LPRPCSTUBBUFFER iface)
455 CStdStubBuffer *This = (CStdStubBuffer *)iface;
456 IUnknown *old;
457 TRACE("(%p)->Disconnect()\n",This);
459 old = InterlockedExchangePointer((void**)&This->pvServerObject, NULL);
461 if(old)
462 IUnknown_Release(old);
465 HRESULT WINAPI CStdStubBuffer_Invoke(LPRPCSTUBBUFFER iface,
466 PRPCOLEMESSAGE pMsg,
467 LPRPCCHANNELBUFFER pChannel)
469 CStdStubBuffer *This = (CStdStubBuffer *)iface;
470 DWORD dwPhase = STUB_UNMARSHAL;
471 HRESULT hr = S_OK;
473 TRACE("(%p)->Invoke(%p,%p)\n",This,pMsg,pChannel);
475 __TRY
477 if (STUB_HEADER(This).pDispatchTable)
478 STUB_HEADER(This).pDispatchTable[pMsg->iMethod](iface, pChannel, (PRPC_MESSAGE)pMsg, &dwPhase);
479 else /* pure interpreted */
480 NdrStubCall2(iface, pChannel, (PRPC_MESSAGE)pMsg, &dwPhase);
482 __EXCEPT(stub_filter)
484 DWORD dwExceptionCode = GetExceptionCode();
485 WARN("a stub call failed with exception 0x%08x (%d)\n", dwExceptionCode, dwExceptionCode);
486 if (FAILED(dwExceptionCode))
487 hr = dwExceptionCode;
488 else
489 hr = HRESULT_FROM_WIN32(dwExceptionCode);
491 __ENDTRY
493 return hr;
496 LPRPCSTUBBUFFER WINAPI CStdStubBuffer_IsIIDSupported(LPRPCSTUBBUFFER iface,
497 REFIID riid)
499 CStdStubBuffer *This = (CStdStubBuffer *)iface;
500 TRACE("(%p)->IsIIDSupported(%s)\n",This,debugstr_guid(riid));
501 return IsEqualGUID(STUB_HEADER(This).piid, riid) ? iface : NULL;
504 ULONG WINAPI CStdStubBuffer_CountRefs(LPRPCSTUBBUFFER iface)
506 CStdStubBuffer *This = (CStdStubBuffer *)iface;
507 TRACE("(%p)->CountRefs()\n",This);
508 return This->RefCount;
511 HRESULT WINAPI CStdStubBuffer_DebugServerQueryInterface(LPRPCSTUBBUFFER iface,
512 LPVOID *ppv)
514 CStdStubBuffer *This = (CStdStubBuffer *)iface;
515 TRACE("(%p)->DebugServerQueryInterface(%p)\n",This,ppv);
516 return S_OK;
519 void WINAPI CStdStubBuffer_DebugServerRelease(LPRPCSTUBBUFFER iface,
520 LPVOID pv)
522 CStdStubBuffer *This = (CStdStubBuffer *)iface;
523 TRACE("(%p)->DebugServerRelease(%p)\n",This,pv);
526 const IRpcStubBufferVtbl CStdStubBuffer_Vtbl =
528 CStdStubBuffer_QueryInterface,
529 CStdStubBuffer_AddRef,
530 NULL,
531 CStdStubBuffer_Connect,
532 CStdStubBuffer_Disconnect,
533 CStdStubBuffer_Invoke,
534 CStdStubBuffer_IsIIDSupported,
535 CStdStubBuffer_CountRefs,
536 CStdStubBuffer_DebugServerQueryInterface,
537 CStdStubBuffer_DebugServerRelease
540 static HRESULT WINAPI CStdStubBuffer_Delegating_Connect(LPRPCSTUBBUFFER iface,
541 LPUNKNOWN lpUnkServer)
543 cstdstubbuffer_delegating_t *This = impl_from_delegating(iface);
544 HRESULT r;
545 TRACE("(%p)->Connect(%p)\n", This, lpUnkServer);
547 r = CStdStubBuffer_Connect(iface, lpUnkServer);
548 if(SUCCEEDED(r))
549 r = IRpcStubBuffer_Connect(This->base_stub, (IUnknown*)&This->base_obj);
551 return r;
554 static void WINAPI CStdStubBuffer_Delegating_Disconnect(LPRPCSTUBBUFFER iface)
556 cstdstubbuffer_delegating_t *This = impl_from_delegating(iface);
557 TRACE("(%p)->Disconnect()\n", This);
559 IRpcStubBuffer_Disconnect(This->base_stub);
560 CStdStubBuffer_Disconnect(iface);
563 static ULONG WINAPI CStdStubBuffer_Delegating_CountRefs(LPRPCSTUBBUFFER iface)
565 cstdstubbuffer_delegating_t *This = impl_from_delegating(iface);
566 ULONG ret;
567 TRACE("(%p)->CountRefs()\n", This);
569 ret = CStdStubBuffer_CountRefs(iface);
570 ret += IRpcStubBuffer_CountRefs(This->base_stub);
572 return ret;
575 const IRpcStubBufferVtbl CStdStubBuffer_Delegating_Vtbl =
577 CStdStubBuffer_QueryInterface,
578 CStdStubBuffer_AddRef,
579 NULL,
580 CStdStubBuffer_Delegating_Connect,
581 CStdStubBuffer_Delegating_Disconnect,
582 CStdStubBuffer_Invoke,
583 CStdStubBuffer_IsIIDSupported,
584 CStdStubBuffer_Delegating_CountRefs,
585 CStdStubBuffer_DebugServerQueryInterface,
586 CStdStubBuffer_DebugServerRelease
589 const MIDL_SERVER_INFO *CStdStubBuffer_GetServerInfo(IRpcStubBuffer *iface)
591 CStdStubBuffer *This = (CStdStubBuffer *)iface;
592 return STUB_HEADER(This).pServerInfo;
595 /************************************************************************
596 * NdrStubForwardingFunction [RPCRT4.@]
598 void __RPC_STUB NdrStubForwardingFunction( IRpcStubBuffer *iface, IRpcChannelBuffer *pChannel,
599 PRPC_MESSAGE pMsg, DWORD *pdwStubPhase )
601 /* Note pMsg is passed intact since RPCOLEMESSAGE is basically a RPC_MESSAGE. */
603 cstdstubbuffer_delegating_t *This = impl_from_delegating(iface);
604 HRESULT r = IRpcStubBuffer_Invoke(This->base_stub, (RPCOLEMESSAGE*)pMsg, pChannel);
605 if(FAILED(r)) RpcRaiseException(r);
606 return;
609 /***********************************************************************
610 * NdrStubInitialize [RPCRT4.@]
612 void WINAPI NdrStubInitialize(PRPC_MESSAGE pRpcMsg,
613 PMIDL_STUB_MESSAGE pStubMsg,
614 PMIDL_STUB_DESC pStubDescriptor,
615 LPRPCCHANNELBUFFER pRpcChannelBuffer)
617 TRACE("(%p,%p,%p,%p)\n", pRpcMsg, pStubMsg, pStubDescriptor, pRpcChannelBuffer);
618 NdrServerInitializeNew(pRpcMsg, pStubMsg, pStubDescriptor);
619 pStubMsg->pRpcChannelBuffer = pRpcChannelBuffer;
620 IRpcChannelBuffer_GetDestCtx(pStubMsg->pRpcChannelBuffer,
621 &pStubMsg->dwDestContext,
622 &pStubMsg->pvDestContext);
625 /***********************************************************************
626 * NdrStubGetBuffer [RPCRT4.@]
628 void WINAPI NdrStubGetBuffer(LPRPCSTUBBUFFER iface,
629 LPRPCCHANNELBUFFER pRpcChannelBuffer,
630 PMIDL_STUB_MESSAGE pStubMsg)
632 CStdStubBuffer *This = (CStdStubBuffer *)iface;
633 HRESULT hr;
635 TRACE("(%p, %p, %p)\n", This, pRpcChannelBuffer, pStubMsg);
637 pStubMsg->RpcMsg->BufferLength = pStubMsg->BufferLength;
638 hr = IRpcChannelBuffer_GetBuffer(pRpcChannelBuffer,
639 (RPCOLEMESSAGE *)pStubMsg->RpcMsg, STUB_HEADER(This).piid);
640 if (FAILED(hr))
642 RpcRaiseException(hr);
643 return;
646 pStubMsg->Buffer = pStubMsg->RpcMsg->Buffer;