po: Update Lithuanian translation.
[wine/multimedia.git] / dlls / rpcrt4 / cstub.c
blob74801f69b709a148d8a232692d541eae2a025e83
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 (cstdstubbuffer_delegating_t*)((char *)iface - FIELD_OFFSET(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;
198 block = VirtualAlloc( NULL, BLOCK_SIZE * sizeof(*block),
199 MEM_COMMIT | MEM_RESERVE, PAGE_EXECUTE_READWRITE );
200 if (!block) return NULL;
202 for (i = 0; i < BLOCK_SIZE; i++)
204 memcpy( &block[i], opcodes, sizeof(opcodes) );
205 block[i].offset = (BLOCK_SIZE * num + i + 3) * sizeof(void *);
207 VirtualProtect( block, BLOCK_SIZE * sizeof(*block), PAGE_EXECUTE_READ, NULL );
208 prev = InterlockedCompareExchangePointer( (void **)&method_blocks[num], block, NULL );
209 if (prev) /* someone beat us to it */
211 VirtualFree( block, 0, MEM_RELEASE );
212 block = prev;
214 return block;
217 static BOOL fill_delegated_stub_table(IUnknownVtbl *vtbl, DWORD num)
219 const void **entry = (const void **)(vtbl + 1);
220 DWORD i, j;
222 if (num - 3 > BLOCK_SIZE * MAX_BLOCKS)
224 FIXME( "%u methods not supported\n", num );
225 return FALSE;
227 vtbl->QueryInterface = delegating_QueryInterface;
228 vtbl->AddRef = delegating_AddRef;
229 vtbl->Release = delegating_Release;
230 for (i = 0; i < (num - 3 + BLOCK_SIZE - 1) / BLOCK_SIZE; i++)
232 const vtbl_method_t *block = method_blocks[i];
233 if (!block && !(block = allocate_block( i ))) return FALSE;
234 for (j = 0; j < BLOCK_SIZE && j < num - 3 - i * BLOCK_SIZE; j++) *entry++ = &block[j];
236 return TRUE;
239 BOOL fill_delegated_proxy_table(IUnknownVtbl *vtbl, DWORD num)
241 const void **entry = (const void **)(vtbl + 1);
242 DWORD i, j;
244 if (num - 3 > BLOCK_SIZE * MAX_BLOCKS)
246 FIXME( "%u methods not supported\n", num );
247 return FALSE;
249 vtbl->QueryInterface = IUnknown_QueryInterface_Proxy;
250 vtbl->AddRef = IUnknown_AddRef_Proxy;
251 vtbl->Release = IUnknown_Release_Proxy;
252 for (i = 0; i < (num - 3 + BLOCK_SIZE - 1) / BLOCK_SIZE; i++)
254 const vtbl_method_t *block = method_blocks[i];
255 if (!block && !(block = allocate_block( i ))) return FALSE;
256 for (j = 0; j < BLOCK_SIZE && j < num - 3 - i * BLOCK_SIZE; j++, entry++)
257 if (!*entry) *entry = &block[j];
259 return TRUE;
262 static IUnknownVtbl *get_delegating_vtbl(DWORD num_methods)
264 IUnknownVtbl *ret;
266 if (num_methods < 256) num_methods = 256; /* avoid frequent reallocations */
268 EnterCriticalSection(&delegating_vtbl_section);
270 if(!current_vtbl || num_methods > current_vtbl->size)
272 ref_counted_vtbl *table = HeapAlloc(GetProcessHeap(), 0,
273 FIELD_OFFSET(ref_counted_vtbl, vtbl) + num_methods * sizeof(void*));
274 if (!table)
276 LeaveCriticalSection(&delegating_vtbl_section);
277 return NULL;
280 table->ref = 0;
281 table->size = num_methods;
282 fill_delegated_stub_table(&table->vtbl, num_methods);
284 if (current_vtbl && current_vtbl->ref == 0)
286 TRACE("freeing old table\n");
287 HeapFree(GetProcessHeap(), 0, current_vtbl);
289 current_vtbl = table;
292 current_vtbl->ref++;
293 ret = &current_vtbl->vtbl;
294 LeaveCriticalSection(&delegating_vtbl_section);
295 return ret;
298 static void release_delegating_vtbl(IUnknownVtbl *vtbl)
300 ref_counted_vtbl *table = (ref_counted_vtbl*)((DWORD *)vtbl - 1);
302 EnterCriticalSection(&delegating_vtbl_section);
303 table->ref--;
304 TRACE("ref now %d\n", table->ref);
305 if(table->ref == 0 && table != current_vtbl)
307 TRACE("... and we're not current so free'ing\n");
308 HeapFree(GetProcessHeap(), 0, table);
310 LeaveCriticalSection(&delegating_vtbl_section);
313 HRESULT CStdStubBuffer_Delegating_Construct(REFIID riid,
314 LPUNKNOWN pUnkServer,
315 PCInterfaceName name,
316 CInterfaceStubVtbl *vtbl,
317 REFIID delegating_iid,
318 LPPSFACTORYBUFFER pPSFactory,
319 LPRPCSTUBBUFFER *ppStub)
321 cstdstubbuffer_delegating_t *This;
322 IUnknown *pvServer;
323 HRESULT r;
325 TRACE("(%p,%p,%p,%p) %s\n", pUnkServer, vtbl, pPSFactory, ppStub, name);
326 TRACE("iid=%s delegating to %s\n", debugstr_guid(vtbl->header.piid), debugstr_guid(delegating_iid));
327 TRACE("vtbl=%p\n", &vtbl->Vtbl);
329 if (!IsEqualGUID(vtbl->header.piid, riid))
331 ERR("IID mismatch during stub creation\n");
332 return RPC_E_UNEXPECTED;
335 r = IUnknown_QueryInterface(pUnkServer, riid, (void**)&pvServer);
336 if(FAILED(r)) return r;
338 This = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*This));
339 if (!This)
341 IUnknown_Release(pvServer);
342 return E_OUTOFMEMORY;
345 This->base_obj = get_delegating_vtbl( vtbl->header.DispatchTableCount );
346 r = create_stub(delegating_iid, (IUnknown*)&This->base_obj, &This->base_stub);
347 if(FAILED(r))
349 release_delegating_vtbl(This->base_obj);
350 HeapFree(GetProcessHeap(), 0, This);
351 IUnknown_Release(pvServer);
352 return r;
355 This->stub_buffer.lpVtbl = &vtbl->Vtbl;
356 This->stub_buffer.RefCount = 1;
357 This->stub_buffer.pvServerObject = pvServer;
358 This->stub_buffer.pPSFactory = pPSFactory;
359 *ppStub = (LPRPCSTUBBUFFER)&This->stub_buffer;
361 IPSFactoryBuffer_AddRef(pPSFactory);
362 return S_OK;
365 HRESULT WINAPI CStdStubBuffer_QueryInterface(LPRPCSTUBBUFFER iface,
366 REFIID riid,
367 LPVOID *obj)
369 CStdStubBuffer *This = (CStdStubBuffer *)iface;
370 TRACE("(%p)->QueryInterface(%s,%p)\n",This,debugstr_guid(riid),obj);
372 if (IsEqualIID(&IID_IUnknown, riid) ||
373 IsEqualIID(&IID_IRpcStubBuffer, riid))
375 IUnknown_AddRef(iface);
376 *obj = iface;
377 return S_OK;
379 *obj = NULL;
380 return E_NOINTERFACE;
383 ULONG WINAPI CStdStubBuffer_AddRef(LPRPCSTUBBUFFER iface)
385 CStdStubBuffer *This = (CStdStubBuffer *)iface;
386 TRACE("(%p)->AddRef()\n",This);
387 return InterlockedIncrement(&This->RefCount);
390 ULONG WINAPI NdrCStdStubBuffer_Release(LPRPCSTUBBUFFER iface,
391 LPPSFACTORYBUFFER pPSF)
393 CStdStubBuffer *This = (CStdStubBuffer *)iface;
394 ULONG refs;
396 TRACE("(%p)->Release()\n",This);
398 refs = InterlockedDecrement(&This->RefCount);
399 if (!refs)
401 /* test_Release shows that native doesn't call Disconnect here.
402 We'll leave it in for the time being. */
403 IRpcStubBuffer_Disconnect(iface);
405 IPSFactoryBuffer_Release(pPSF);
406 HeapFree(GetProcessHeap(),0,This);
408 return refs;
411 ULONG WINAPI NdrCStdStubBuffer2_Release(LPRPCSTUBBUFFER iface,
412 LPPSFACTORYBUFFER pPSF)
414 cstdstubbuffer_delegating_t *This = impl_from_delegating( iface );
415 ULONG refs;
417 TRACE("(%p)->Release()\n", This);
419 refs = InterlockedDecrement(&This->stub_buffer.RefCount);
420 if (!refs)
422 /* Just like NdrCStdStubBuffer_Release, we shouldn't call
423 Disconnect here */
424 IRpcStubBuffer_Disconnect((IRpcStubBuffer *)&This->stub_buffer);
426 IRpcStubBuffer_Release(This->base_stub);
427 release_delegating_vtbl(This->base_obj);
429 IPSFactoryBuffer_Release(pPSF);
430 HeapFree(GetProcessHeap(), 0, This);
433 return refs;
436 HRESULT WINAPI CStdStubBuffer_Connect(LPRPCSTUBBUFFER iface,
437 LPUNKNOWN lpUnkServer)
439 CStdStubBuffer *This = (CStdStubBuffer *)iface;
440 HRESULT r;
441 IUnknown *new = NULL;
443 TRACE("(%p)->Connect(%p)\n",This,lpUnkServer);
445 r = IUnknown_QueryInterface(lpUnkServer, STUB_HEADER(This).piid, (void**)&new);
446 new = InterlockedExchangePointer((void**)&This->pvServerObject, new);
447 if(new)
448 IUnknown_Release(new);
449 return r;
452 void WINAPI CStdStubBuffer_Disconnect(LPRPCSTUBBUFFER iface)
454 CStdStubBuffer *This = (CStdStubBuffer *)iface;
455 IUnknown *old;
456 TRACE("(%p)->Disconnect()\n",This);
458 old = InterlockedExchangePointer((void**)&This->pvServerObject, NULL);
460 if(old)
461 IUnknown_Release(old);
464 HRESULT WINAPI CStdStubBuffer_Invoke(LPRPCSTUBBUFFER iface,
465 PRPCOLEMESSAGE pMsg,
466 LPRPCCHANNELBUFFER pChannel)
468 CStdStubBuffer *This = (CStdStubBuffer *)iface;
469 DWORD dwPhase = STUB_UNMARSHAL;
470 HRESULT hr = S_OK;
472 TRACE("(%p)->Invoke(%p,%p)\n",This,pMsg,pChannel);
474 __TRY
476 if (STUB_HEADER(This).pDispatchTable)
477 STUB_HEADER(This).pDispatchTable[pMsg->iMethod](iface, pChannel, (PRPC_MESSAGE)pMsg, &dwPhase);
478 else /* pure interpreted */
479 NdrStubCall2(iface, pChannel, (PRPC_MESSAGE)pMsg, &dwPhase);
481 __EXCEPT(stub_filter)
483 DWORD dwExceptionCode = GetExceptionCode();
484 WARN("a stub call failed with exception 0x%08x (%d)\n", dwExceptionCode, dwExceptionCode);
485 if (FAILED(dwExceptionCode))
486 hr = dwExceptionCode;
487 else
488 hr = HRESULT_FROM_WIN32(dwExceptionCode);
490 __ENDTRY
492 return hr;
495 LPRPCSTUBBUFFER WINAPI CStdStubBuffer_IsIIDSupported(LPRPCSTUBBUFFER iface,
496 REFIID riid)
498 CStdStubBuffer *This = (CStdStubBuffer *)iface;
499 TRACE("(%p)->IsIIDSupported(%s)\n",This,debugstr_guid(riid));
500 return IsEqualGUID(STUB_HEADER(This).piid, riid) ? iface : NULL;
503 ULONG WINAPI CStdStubBuffer_CountRefs(LPRPCSTUBBUFFER iface)
505 CStdStubBuffer *This = (CStdStubBuffer *)iface;
506 TRACE("(%p)->CountRefs()\n",This);
507 return This->RefCount;
510 HRESULT WINAPI CStdStubBuffer_DebugServerQueryInterface(LPRPCSTUBBUFFER iface,
511 LPVOID *ppv)
513 CStdStubBuffer *This = (CStdStubBuffer *)iface;
514 TRACE("(%p)->DebugServerQueryInterface(%p)\n",This,ppv);
515 return S_OK;
518 void WINAPI CStdStubBuffer_DebugServerRelease(LPRPCSTUBBUFFER iface,
519 LPVOID pv)
521 CStdStubBuffer *This = (CStdStubBuffer *)iface;
522 TRACE("(%p)->DebugServerRelease(%p)\n",This,pv);
525 const IRpcStubBufferVtbl CStdStubBuffer_Vtbl =
527 CStdStubBuffer_QueryInterface,
528 CStdStubBuffer_AddRef,
529 NULL,
530 CStdStubBuffer_Connect,
531 CStdStubBuffer_Disconnect,
532 CStdStubBuffer_Invoke,
533 CStdStubBuffer_IsIIDSupported,
534 CStdStubBuffer_CountRefs,
535 CStdStubBuffer_DebugServerQueryInterface,
536 CStdStubBuffer_DebugServerRelease
539 static HRESULT WINAPI CStdStubBuffer_Delegating_Connect(LPRPCSTUBBUFFER iface,
540 LPUNKNOWN lpUnkServer)
542 cstdstubbuffer_delegating_t *This = impl_from_delegating(iface);
543 HRESULT r;
544 TRACE("(%p)->Connect(%p)\n", This, lpUnkServer);
546 r = CStdStubBuffer_Connect(iface, lpUnkServer);
547 if(SUCCEEDED(r))
548 r = IRpcStubBuffer_Connect(This->base_stub, (IUnknown*)&This->base_obj);
550 return r;
553 static void WINAPI CStdStubBuffer_Delegating_Disconnect(LPRPCSTUBBUFFER iface)
555 cstdstubbuffer_delegating_t *This = impl_from_delegating(iface);
556 TRACE("(%p)->Disconnect()\n", This);
558 IRpcStubBuffer_Disconnect(This->base_stub);
559 CStdStubBuffer_Disconnect(iface);
562 static ULONG WINAPI CStdStubBuffer_Delegating_CountRefs(LPRPCSTUBBUFFER iface)
564 cstdstubbuffer_delegating_t *This = impl_from_delegating(iface);
565 ULONG ret;
566 TRACE("(%p)->CountRefs()\n", This);
568 ret = CStdStubBuffer_CountRefs(iface);
569 ret += IRpcStubBuffer_CountRefs(This->base_stub);
571 return ret;
574 const IRpcStubBufferVtbl CStdStubBuffer_Delegating_Vtbl =
576 CStdStubBuffer_QueryInterface,
577 CStdStubBuffer_AddRef,
578 NULL,
579 CStdStubBuffer_Delegating_Connect,
580 CStdStubBuffer_Delegating_Disconnect,
581 CStdStubBuffer_Invoke,
582 CStdStubBuffer_IsIIDSupported,
583 CStdStubBuffer_Delegating_CountRefs,
584 CStdStubBuffer_DebugServerQueryInterface,
585 CStdStubBuffer_DebugServerRelease
588 const MIDL_SERVER_INFO *CStdStubBuffer_GetServerInfo(IRpcStubBuffer *iface)
590 CStdStubBuffer *This = (CStdStubBuffer *)iface;
591 return STUB_HEADER(This).pServerInfo;
594 /************************************************************************
595 * NdrStubForwardingFunction [RPCRT4.@]
597 void __RPC_STUB NdrStubForwardingFunction( IRpcStubBuffer *iface, IRpcChannelBuffer *pChannel,
598 PRPC_MESSAGE pMsg, DWORD *pdwStubPhase )
600 /* Note pMsg is passed intact since RPCOLEMESSAGE is basically a RPC_MESSAGE. */
602 cstdstubbuffer_delegating_t *This = impl_from_delegating(iface);
603 HRESULT r = IRpcStubBuffer_Invoke(This->base_stub, (RPCOLEMESSAGE*)pMsg, pChannel);
604 if(FAILED(r)) RpcRaiseException(r);
605 return;
608 /***********************************************************************
609 * NdrStubInitialize [RPCRT4.@]
611 void WINAPI NdrStubInitialize(PRPC_MESSAGE pRpcMsg,
612 PMIDL_STUB_MESSAGE pStubMsg,
613 PMIDL_STUB_DESC pStubDescriptor,
614 LPRPCCHANNELBUFFER pRpcChannelBuffer)
616 TRACE("(%p,%p,%p,%p)\n", pRpcMsg, pStubMsg, pStubDescriptor, pRpcChannelBuffer);
617 NdrServerInitializeNew(pRpcMsg, pStubMsg, pStubDescriptor);
618 pStubMsg->pRpcChannelBuffer = pRpcChannelBuffer;
619 IRpcChannelBuffer_GetDestCtx(pStubMsg->pRpcChannelBuffer,
620 &pStubMsg->dwDestContext,
621 &pStubMsg->pvDestContext);
624 /***********************************************************************
625 * NdrStubGetBuffer [RPCRT4.@]
627 void WINAPI NdrStubGetBuffer(LPRPCSTUBBUFFER iface,
628 LPRPCCHANNELBUFFER pRpcChannelBuffer,
629 PMIDL_STUB_MESSAGE pStubMsg)
631 CStdStubBuffer *This = (CStdStubBuffer *)iface;
632 HRESULT hr;
634 TRACE("(%p, %p, %p)\n", This, pRpcChannelBuffer, pStubMsg);
636 pStubMsg->RpcMsg->BufferLength = pStubMsg->BufferLength;
637 hr = IRpcChannelBuffer_GetBuffer(pRpcChannelBuffer,
638 (RPCOLEMESSAGE *)pStubMsg->RpcMsg, STUB_HEADER(This).piid);
639 if (FAILED(hr))
641 RpcRaiseException(hr);
642 return;
645 pStubMsg->Buffer = pStubMsg->RpcMsg->Buffer;