Release 1.1.37.
[wine/gsoc-2012-control.git] / dlls / rpcrt4 / cstub.c
blob95ac1d89af2279ef8da94956235299bed418f893
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 #if defined(__i386__)
142 /* The idea here is to replace the first param on the stack
143 ie. This (which will point to cstdstubbuffer_delegating_t)
144 with This->stub_buffer.pvServerObject and then jump to the
145 relevant offset in This->stub_buffer.pvServerObject's vtbl.
147 #include "pshpack1.h"
148 typedef struct {
149 DWORD mov1; /* mov 0x4(%esp), %eax 8b 44 24 04 */
150 WORD mov2; /* mov 0x10(%eax), %eax 8b 40 */
151 BYTE sixteen; /* 10 */
152 DWORD mov3; /* mov %eax, 0x4(%esp) 89 44 24 04 */
153 WORD mov4; /* mov (%eax), %eax 8b 00 */
154 WORD mov5; /* mov offset(%eax), %eax 8b 80 */
155 DWORD offset; /* xx xx xx xx */
156 WORD jmp; /* jmp *%eax ff e0 */
157 BYTE pad[3]; /* lea 0x0(%esi), %esi 8d 76 00 */
158 } vtbl_method_t;
159 #include "poppack.h"
161 #define BLOCK_SIZE 1024
162 #define MAX_BLOCKS 64 /* 64k methods should be enough for anybody */
164 static const vtbl_method_t *method_blocks[MAX_BLOCKS];
166 static const vtbl_method_t *allocate_block( unsigned int num )
168 unsigned int i;
169 vtbl_method_t *prev, *block;
171 block = VirtualAlloc( NULL, BLOCK_SIZE * sizeof(*block),
172 MEM_COMMIT | MEM_RESERVE, PAGE_EXECUTE_READWRITE );
173 if (!block) return NULL;
175 for (i = 0; i < BLOCK_SIZE; i++)
177 block[i].mov1 = 0x0424448b;
178 block[i].mov2 = 0x408b;
179 block[i].sixteen = 0x10;
180 block[i].mov3 = 0x04244489;
181 block[i].mov4 = 0x008b;
182 block[i].mov5 = 0x808b;
183 block[i].offset = (BLOCK_SIZE * num + i + 3) << 2;
184 block[i].jmp = 0xe0ff;
185 block[i].pad[0] = 0x8d;
186 block[i].pad[1] = 0x76;
187 block[i].pad[2] = 0x00;
189 VirtualProtect( block, BLOCK_SIZE * sizeof(*block), PAGE_EXECUTE_READ, NULL );
190 prev = InterlockedCompareExchangePointer( (void **)&method_blocks[num], block, NULL );
191 if (prev) /* someone beat us to it */
193 VirtualFree( block, 0, MEM_RELEASE );
194 block = prev;
196 return block;
199 static BOOL fill_delegated_stub_table(IUnknownVtbl *vtbl, DWORD num)
201 const void **entry = (const void **)(vtbl + 1);
202 DWORD i, j;
204 if (num - 3 > BLOCK_SIZE * MAX_BLOCKS)
206 FIXME( "%u methods not supported\n", num );
207 return FALSE;
209 vtbl->QueryInterface = delegating_QueryInterface;
210 vtbl->AddRef = delegating_AddRef;
211 vtbl->Release = delegating_Release;
212 for (i = 0; i < (num - 3 + BLOCK_SIZE - 1) / BLOCK_SIZE; i++)
214 const vtbl_method_t *block = method_blocks[i];
215 if (!block && !(block = allocate_block( i ))) return FALSE;
216 for (j = 0; j < BLOCK_SIZE && j < num - 3 - i * BLOCK_SIZE; j++) *entry++ = &block[j];
218 return TRUE;
221 BOOL fill_delegated_proxy_table(IUnknownVtbl *vtbl, DWORD num)
223 const void **entry = (const void **)(vtbl + 1);
224 DWORD i, j;
226 if (num - 3 > BLOCK_SIZE * MAX_BLOCKS)
228 FIXME( "%u methods not supported\n", num );
229 return FALSE;
231 vtbl->QueryInterface = IUnknown_QueryInterface_Proxy;
232 vtbl->AddRef = IUnknown_AddRef_Proxy;
233 vtbl->Release = IUnknown_Release_Proxy;
234 for (i = 0; i < (num - 3 + BLOCK_SIZE - 1) / BLOCK_SIZE; i++)
236 const vtbl_method_t *block = method_blocks[i];
237 if (!block && !(block = allocate_block( i ))) return FALSE;
238 for (j = 0; j < BLOCK_SIZE && j < num - 3 - i * BLOCK_SIZE; j++, entry++)
239 if (!*entry) *entry = &block[j];
241 return TRUE;
244 #else /* __i386__ */
246 static BOOL fill_delegated_stub_table(IUnknownVtbl *vtbl, DWORD num)
248 ERR("delegated stubs are not supported on this architecture\n");
249 return FALSE;
252 BOOL fill_delegated_proxy_table(IUnknownVtbl *vtbl, DWORD num)
254 ERR("delegated proxies are not supported on this architecture\n");
255 return FALSE;
258 #endif /* __i386__ */
260 static IUnknownVtbl *get_delegating_vtbl(DWORD num_methods)
262 IUnknownVtbl *ret;
264 if (num_methods < 256) num_methods = 256; /* avoid frequent reallocations */
266 EnterCriticalSection(&delegating_vtbl_section);
268 if(!current_vtbl || num_methods > current_vtbl->size)
270 ref_counted_vtbl *table = HeapAlloc(GetProcessHeap(), 0,
271 FIELD_OFFSET(ref_counted_vtbl, vtbl) + num_methods * sizeof(void*));
272 if (!table)
274 LeaveCriticalSection(&delegating_vtbl_section);
275 return NULL;
278 table->ref = 0;
279 table->size = num_methods;
280 fill_delegated_stub_table(&table->vtbl, num_methods);
282 if (current_vtbl && current_vtbl->ref == 0)
284 TRACE("freeing old table\n");
285 HeapFree(GetProcessHeap(), 0, current_vtbl);
287 current_vtbl = table;
290 current_vtbl->ref++;
291 ret = &current_vtbl->vtbl;
292 LeaveCriticalSection(&delegating_vtbl_section);
293 return ret;
296 static void release_delegating_vtbl(IUnknownVtbl *vtbl)
298 ref_counted_vtbl *table = (ref_counted_vtbl*)((DWORD *)vtbl - 1);
300 EnterCriticalSection(&delegating_vtbl_section);
301 table->ref--;
302 TRACE("ref now %d\n", table->ref);
303 if(table->ref == 0 && table != current_vtbl)
305 TRACE("... and we're not current so free'ing\n");
306 HeapFree(GetProcessHeap(), 0, table);
308 LeaveCriticalSection(&delegating_vtbl_section);
311 HRESULT CStdStubBuffer_Delegating_Construct(REFIID riid,
312 LPUNKNOWN pUnkServer,
313 PCInterfaceName name,
314 CInterfaceStubVtbl *vtbl,
315 REFIID delegating_iid,
316 LPPSFACTORYBUFFER pPSFactory,
317 LPRPCSTUBBUFFER *ppStub)
319 cstdstubbuffer_delegating_t *This;
320 IUnknown *pvServer;
321 HRESULT r;
323 TRACE("(%p,%p,%p,%p) %s\n", pUnkServer, vtbl, pPSFactory, ppStub, name);
324 TRACE("iid=%s delegating to %s\n", debugstr_guid(vtbl->header.piid), debugstr_guid(delegating_iid));
325 TRACE("vtbl=%p\n", &vtbl->Vtbl);
327 if (!IsEqualGUID(vtbl->header.piid, riid))
329 ERR("IID mismatch during stub creation\n");
330 return RPC_E_UNEXPECTED;
333 r = IUnknown_QueryInterface(pUnkServer, riid, (void**)&pvServer);
334 if(FAILED(r)) return r;
336 This = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*This));
337 if (!This)
339 IUnknown_Release(pvServer);
340 return E_OUTOFMEMORY;
343 This->base_obj = get_delegating_vtbl( vtbl->header.DispatchTableCount );
344 r = create_stub(delegating_iid, (IUnknown*)&This->base_obj, &This->base_stub);
345 if(FAILED(r))
347 release_delegating_vtbl(This->base_obj);
348 HeapFree(GetProcessHeap(), 0, This);
349 IUnknown_Release(pvServer);
350 return r;
353 This->stub_buffer.lpVtbl = &vtbl->Vtbl;
354 This->stub_buffer.RefCount = 1;
355 This->stub_buffer.pvServerObject = pvServer;
356 This->stub_buffer.pPSFactory = pPSFactory;
357 *ppStub = (LPRPCSTUBBUFFER)&This->stub_buffer;
359 IPSFactoryBuffer_AddRef(pPSFactory);
360 return S_OK;
363 HRESULT WINAPI CStdStubBuffer_QueryInterface(LPRPCSTUBBUFFER iface,
364 REFIID riid,
365 LPVOID *obj)
367 CStdStubBuffer *This = (CStdStubBuffer *)iface;
368 TRACE("(%p)->QueryInterface(%s,%p)\n",This,debugstr_guid(riid),obj);
370 if (IsEqualIID(&IID_IUnknown, riid) ||
371 IsEqualIID(&IID_IRpcStubBuffer, riid))
373 IUnknown_AddRef(iface);
374 *obj = iface;
375 return S_OK;
377 *obj = NULL;
378 return E_NOINTERFACE;
381 ULONG WINAPI CStdStubBuffer_AddRef(LPRPCSTUBBUFFER iface)
383 CStdStubBuffer *This = (CStdStubBuffer *)iface;
384 TRACE("(%p)->AddRef()\n",This);
385 return InterlockedIncrement(&This->RefCount);
388 ULONG WINAPI NdrCStdStubBuffer_Release(LPRPCSTUBBUFFER iface,
389 LPPSFACTORYBUFFER pPSF)
391 CStdStubBuffer *This = (CStdStubBuffer *)iface;
392 ULONG refs;
394 TRACE("(%p)->Release()\n",This);
396 refs = InterlockedDecrement(&This->RefCount);
397 if (!refs)
399 /* test_Release shows that native doesn't call Disconnect here.
400 We'll leave it in for the time being. */
401 IRpcStubBuffer_Disconnect(iface);
403 IPSFactoryBuffer_Release(pPSF);
404 HeapFree(GetProcessHeap(),0,This);
406 return refs;
409 ULONG WINAPI NdrCStdStubBuffer2_Release(LPRPCSTUBBUFFER iface,
410 LPPSFACTORYBUFFER pPSF)
412 cstdstubbuffer_delegating_t *This = impl_from_delegating( iface );
413 ULONG refs;
415 TRACE("(%p)->Release()\n", This);
417 refs = InterlockedDecrement(&This->stub_buffer.RefCount);
418 if (!refs)
420 /* Just like NdrCStdStubBuffer_Release, we shouldn't call
421 Disconnect here */
422 IRpcStubBuffer_Disconnect((IRpcStubBuffer *)&This->stub_buffer);
424 IRpcStubBuffer_Release(This->base_stub);
425 release_delegating_vtbl(This->base_obj);
427 IPSFactoryBuffer_Release(pPSF);
428 HeapFree(GetProcessHeap(), 0, This);
431 return refs;
434 HRESULT WINAPI CStdStubBuffer_Connect(LPRPCSTUBBUFFER iface,
435 LPUNKNOWN lpUnkServer)
437 CStdStubBuffer *This = (CStdStubBuffer *)iface;
438 HRESULT r;
439 IUnknown *new = NULL;
441 TRACE("(%p)->Connect(%p)\n",This,lpUnkServer);
443 r = IUnknown_QueryInterface(lpUnkServer, STUB_HEADER(This).piid, (void**)&new);
444 new = InterlockedExchangePointer((void**)&This->pvServerObject, new);
445 if(new)
446 IUnknown_Release(new);
447 return r;
450 void WINAPI CStdStubBuffer_Disconnect(LPRPCSTUBBUFFER iface)
452 CStdStubBuffer *This = (CStdStubBuffer *)iface;
453 IUnknown *old;
454 TRACE("(%p)->Disconnect()\n",This);
456 old = InterlockedExchangePointer((void**)&This->pvServerObject, NULL);
458 if(old)
459 IUnknown_Release(old);
462 HRESULT WINAPI CStdStubBuffer_Invoke(LPRPCSTUBBUFFER iface,
463 PRPCOLEMESSAGE pMsg,
464 LPRPCCHANNELBUFFER pChannel)
466 CStdStubBuffer *This = (CStdStubBuffer *)iface;
467 DWORD dwPhase = STUB_UNMARSHAL;
468 HRESULT hr = S_OK;
470 TRACE("(%p)->Invoke(%p,%p)\n",This,pMsg,pChannel);
472 __TRY
474 if (STUB_HEADER(This).pDispatchTable)
475 STUB_HEADER(This).pDispatchTable[pMsg->iMethod](iface, pChannel, (PRPC_MESSAGE)pMsg, &dwPhase);
476 else /* pure interpreted */
477 NdrStubCall2(iface, pChannel, (PRPC_MESSAGE)pMsg, &dwPhase);
479 __EXCEPT(stub_filter)
481 DWORD dwExceptionCode = GetExceptionCode();
482 WARN("a stub call failed with exception 0x%08x (%d)\n", dwExceptionCode, dwExceptionCode);
483 if (FAILED(dwExceptionCode))
484 hr = dwExceptionCode;
485 else
486 hr = HRESULT_FROM_WIN32(dwExceptionCode);
488 __ENDTRY
490 return hr;
493 LPRPCSTUBBUFFER WINAPI CStdStubBuffer_IsIIDSupported(LPRPCSTUBBUFFER iface,
494 REFIID riid)
496 CStdStubBuffer *This = (CStdStubBuffer *)iface;
497 TRACE("(%p)->IsIIDSupported(%s)\n",This,debugstr_guid(riid));
498 return IsEqualGUID(STUB_HEADER(This).piid, riid) ? iface : NULL;
501 ULONG WINAPI CStdStubBuffer_CountRefs(LPRPCSTUBBUFFER iface)
503 CStdStubBuffer *This = (CStdStubBuffer *)iface;
504 TRACE("(%p)->CountRefs()\n",This);
505 return This->RefCount;
508 HRESULT WINAPI CStdStubBuffer_DebugServerQueryInterface(LPRPCSTUBBUFFER iface,
509 LPVOID *ppv)
511 CStdStubBuffer *This = (CStdStubBuffer *)iface;
512 TRACE("(%p)->DebugServerQueryInterface(%p)\n",This,ppv);
513 return S_OK;
516 void WINAPI CStdStubBuffer_DebugServerRelease(LPRPCSTUBBUFFER iface,
517 LPVOID pv)
519 CStdStubBuffer *This = (CStdStubBuffer *)iface;
520 TRACE("(%p)->DebugServerRelease(%p)\n",This,pv);
523 const IRpcStubBufferVtbl CStdStubBuffer_Vtbl =
525 CStdStubBuffer_QueryInterface,
526 CStdStubBuffer_AddRef,
527 NULL,
528 CStdStubBuffer_Connect,
529 CStdStubBuffer_Disconnect,
530 CStdStubBuffer_Invoke,
531 CStdStubBuffer_IsIIDSupported,
532 CStdStubBuffer_CountRefs,
533 CStdStubBuffer_DebugServerQueryInterface,
534 CStdStubBuffer_DebugServerRelease
537 static HRESULT WINAPI CStdStubBuffer_Delegating_Connect(LPRPCSTUBBUFFER iface,
538 LPUNKNOWN lpUnkServer)
540 cstdstubbuffer_delegating_t *This = impl_from_delegating(iface);
541 HRESULT r;
542 TRACE("(%p)->Connect(%p)\n", This, lpUnkServer);
544 r = CStdStubBuffer_Connect(iface, lpUnkServer);
545 if(SUCCEEDED(r))
546 r = IRpcStubBuffer_Connect(This->base_stub, (IUnknown*)&This->base_obj);
548 return r;
551 static void WINAPI CStdStubBuffer_Delegating_Disconnect(LPRPCSTUBBUFFER iface)
553 cstdstubbuffer_delegating_t *This = impl_from_delegating(iface);
554 TRACE("(%p)->Disconnect()\n", This);
556 IRpcStubBuffer_Disconnect(This->base_stub);
557 CStdStubBuffer_Disconnect(iface);
560 static ULONG WINAPI CStdStubBuffer_Delegating_CountRefs(LPRPCSTUBBUFFER iface)
562 cstdstubbuffer_delegating_t *This = impl_from_delegating(iface);
563 ULONG ret;
564 TRACE("(%p)->CountRefs()\n", This);
566 ret = CStdStubBuffer_CountRefs(iface);
567 ret += IRpcStubBuffer_CountRefs(This->base_stub);
569 return ret;
572 const IRpcStubBufferVtbl CStdStubBuffer_Delegating_Vtbl =
574 CStdStubBuffer_QueryInterface,
575 CStdStubBuffer_AddRef,
576 NULL,
577 CStdStubBuffer_Delegating_Connect,
578 CStdStubBuffer_Delegating_Disconnect,
579 CStdStubBuffer_Invoke,
580 CStdStubBuffer_IsIIDSupported,
581 CStdStubBuffer_Delegating_CountRefs,
582 CStdStubBuffer_DebugServerQueryInterface,
583 CStdStubBuffer_DebugServerRelease
586 const MIDL_SERVER_INFO *CStdStubBuffer_GetServerInfo(IRpcStubBuffer *iface)
588 CStdStubBuffer *This = (CStdStubBuffer *)iface;
589 return STUB_HEADER(This).pServerInfo;
592 /************************************************************************
593 * NdrStubForwardingFunction [RPCRT4.@]
595 void __RPC_STUB NdrStubForwardingFunction( IRpcStubBuffer *iface, IRpcChannelBuffer *pChannel,
596 PRPC_MESSAGE pMsg, DWORD *pdwStubPhase )
598 /* Note pMsg is passed intact since RPCOLEMESSAGE is basically a RPC_MESSAGE. */
600 cstdstubbuffer_delegating_t *This = impl_from_delegating(iface);
601 HRESULT r = IRpcStubBuffer_Invoke(This->base_stub, (RPCOLEMESSAGE*)pMsg, pChannel);
602 if(FAILED(r)) RpcRaiseException(r);
603 return;
606 /***********************************************************************
607 * NdrStubInitialize [RPCRT4.@]
609 void WINAPI NdrStubInitialize(PRPC_MESSAGE pRpcMsg,
610 PMIDL_STUB_MESSAGE pStubMsg,
611 PMIDL_STUB_DESC pStubDescriptor,
612 LPRPCCHANNELBUFFER pRpcChannelBuffer)
614 TRACE("(%p,%p,%p,%p)\n", pRpcMsg, pStubMsg, pStubDescriptor, pRpcChannelBuffer);
615 NdrServerInitializeNew(pRpcMsg, pStubMsg, pStubDescriptor);
616 pStubMsg->pRpcChannelBuffer = pRpcChannelBuffer;
617 IRpcChannelBuffer_GetDestCtx(pStubMsg->pRpcChannelBuffer,
618 &pStubMsg->dwDestContext,
619 &pStubMsg->pvDestContext);
622 /***********************************************************************
623 * NdrStubGetBuffer [RPCRT4.@]
625 void WINAPI NdrStubGetBuffer(LPRPCSTUBBUFFER iface,
626 LPRPCCHANNELBUFFER pRpcChannelBuffer,
627 PMIDL_STUB_MESSAGE pStubMsg)
629 CStdStubBuffer *This = (CStdStubBuffer *)iface;
630 HRESULT hr;
632 TRACE("(%p, %p, %p)\n", This, pRpcChannelBuffer, pStubMsg);
634 pStubMsg->RpcMsg->BufferLength = pStubMsg->BufferLength;
635 hr = IRpcChannelBuffer_GetBuffer(pRpcChannelBuffer,
636 (RPCOLEMESSAGE *)pStubMsg->RpcMsg, STUB_HEADER(This).piid);
637 if (FAILED(hr))
639 RpcRaiseException(hr);
640 return;
643 pStubMsg->Buffer = pStubMsg->RpcMsg->Buffer;