iphlpapi/tests: Fix crash on Vista.
[wine] / dlls / rpcrt4 / cstub.c
1 /*
2  * COM stub (CStdStubBuffer) implementation
3  *
4  * Copyright 2001 Ove Kåven, TransGaming Technologies
5  *
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.
10  *
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.
15  *
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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19  */
20
21 #include "config.h"
22 #include "wine/port.h"
23
24 #include <stdarg.h>
25
26 #define COBJMACROS
27
28 #include "windef.h"
29 #include "winbase.h"
30 #include "winerror.h"
31 #include "excpt.h"
32
33 #include "objbase.h"
34 #include "rpcproxy.h"
35
36 #include "wine/debug.h"
37 #include "wine/exception.h"
38
39 #include "cpsf.h"
40
41 WINE_DEFAULT_DEBUG_CHANNEL(ole);
42
43 #define STUB_HEADER(This) (((const CInterfaceStubHeader*)((This)->lpVtbl))[-1])
44
45 static LONG WINAPI stub_filter(EXCEPTION_POINTERS *eptr)
46 {
47     if (eptr->ExceptionRecord->ExceptionFlags & EXCEPTION_NONCONTINUABLE)
48         return EXCEPTION_CONTINUE_SEARCH;
49     return EXCEPTION_EXECUTE_HANDLER;
50 }
51
52 typedef struct
53 {
54     IUnknownVtbl *base_obj;
55     IRpcStubBuffer *base_stub;
56     CStdStubBuffer stub_buffer;
57 } cstdstubbuffer_delegating_t;
58
59 static inline cstdstubbuffer_delegating_t *impl_from_delegating( IRpcStubBuffer *iface )
60 {
61     return (cstdstubbuffer_delegating_t*)((char *)iface - FIELD_OFFSET(cstdstubbuffer_delegating_t, stub_buffer));
62 }
63
64 HRESULT WINAPI CStdStubBuffer_Construct(REFIID riid,
65                                        LPUNKNOWN pUnkServer,
66                                        PCInterfaceName name,
67                                        CInterfaceStubVtbl *vtbl,
68                                        LPPSFACTORYBUFFER pPSFactory,
69                                        LPRPCSTUBBUFFER *ppStub)
70 {
71   CStdStubBuffer *This;
72   IUnknown *pvServer;
73   HRESULT r;
74   TRACE("(%p,%p,%p,%p) %s\n", pUnkServer, vtbl, pPSFactory, ppStub, name);
75   TRACE("iid=%s\n", debugstr_guid(vtbl->header.piid));
76   TRACE("vtbl=%p\n", &vtbl->Vtbl);
77
78   if (!IsEqualGUID(vtbl->header.piid, riid)) {
79     ERR("IID mismatch during stub creation\n");
80     return RPC_E_UNEXPECTED;
81   }
82
83   r = IUnknown_QueryInterface(pUnkServer, riid, (void**)&pvServer);
84   if(FAILED(r))
85     return r;
86
87   This = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(CStdStubBuffer));
88   if (!This) {
89     IUnknown_Release(pvServer);
90     return E_OUTOFMEMORY;
91   }
92
93   This->lpVtbl = &vtbl->Vtbl;
94   This->RefCount = 1;
95   This->pvServerObject = pvServer;
96   This->pPSFactory = pPSFactory;
97   *ppStub = (LPRPCSTUBBUFFER)This;
98
99   IPSFactoryBuffer_AddRef(pPSFactory);
100   return S_OK;
101 }
102
103 static CRITICAL_SECTION delegating_vtbl_section;
104 static CRITICAL_SECTION_DEBUG critsect_debug =
105 {
106     0, 0, &delegating_vtbl_section,
107     { &critsect_debug.ProcessLocksList, &critsect_debug.ProcessLocksList },
108       0, 0, { (DWORD_PTR)(__FILE__ ": delegating_vtbl_section") }
109 };
110 static CRITICAL_SECTION delegating_vtbl_section = { &critsect_debug, -1, 0, 0, 0, 0 };
111
112 typedef struct
113 {
114     DWORD ref;
115     DWORD size;
116     void **methods;
117     IUnknownVtbl vtbl;
118     /* remaining entries in vtbl */
119 } ref_counted_vtbl;
120
121 static struct
122 {
123     ref_counted_vtbl *table;
124 } current_vtbl;
125
126
127 static HRESULT WINAPI delegating_QueryInterface(IUnknown *pUnk, REFIID iid, void **ppv)
128 {
129     *ppv = (void *)pUnk;
130     return S_OK;
131 }
132
133 static ULONG WINAPI delegating_AddRef(IUnknown *pUnk)
134 {
135     return 1;
136 }
137
138 static ULONG WINAPI delegating_Release(IUnknown *pUnk)
139 {
140     return 1;
141 }
142
143 #if defined(__i386__)
144
145 /* The idea here is to replace the first param on the stack
146    ie. This (which will point to cstdstubbuffer_delegating_t)
147    with This->stub_buffer.pvServerObject and then jump to the
148    relevant offset in This->stub_buffer.pvServerObject's vtbl.
149 */
150 #include "pshpack1.h"
151 typedef struct {
152     DWORD mov1;    /* mov 0x4(%esp), %eax      8b 44 24 04 */
153     WORD mov2;     /* mov 0x10(%eax), %eax     8b 40 */
154     BYTE sixteen;  /*                          10   */
155     DWORD mov3;    /* mov %eax, 0x4(%esp)      89 44 24 04 */
156     WORD mov4;     /* mov (%eax), %eax         8b 00 */
157     WORD mov5;     /* mov offset(%eax), %eax   8b 80 */
158     DWORD offset;  /*                          xx xx xx xx */
159     WORD jmp;      /* jmp *%eax                ff e0 */
160     BYTE pad[3];   /* lea 0x0(%esi), %esi      8d 76 00 */
161 } vtbl_method_t;
162 #include "poppack.h"
163
164 static void fill_table(IUnknownVtbl *vtbl, void **methods, DWORD num)
165 {
166     vtbl_method_t *method;
167     void **entry;
168     DWORD i;
169
170     vtbl->QueryInterface = delegating_QueryInterface;
171     vtbl->AddRef = delegating_AddRef;
172     vtbl->Release = delegating_Release;
173
174     method = (vtbl_method_t*)methods;
175     entry = (void**)(vtbl + 1);
176
177     for(i = 3; i < num; i++)
178     {
179         *entry = method;
180         method->mov1 = 0x0424448b;
181         method->mov2 = 0x408b;
182         method->sixteen = 0x10;
183         method->mov3 = 0x04244489;
184         method->mov4 = 0x008b;
185         method->mov5 = 0x808b;
186         method->offset = i << 2;
187         method->jmp = 0xe0ff;
188         method->pad[0] = 0x8d;
189         method->pad[1] = 0x76;
190         method->pad[2] = 0x00;
191
192         method++;
193         entry++;
194     }
195 }
196
197 #else  /* __i386__ */
198
199 typedef struct {int dummy;} vtbl_method_t;
200 static void fill_table(IUnknownVtbl *vtbl, void **methods, DWORD num)
201 {
202     ERR("delegated stubs are not supported on this architecture\n");
203 }
204
205 #endif  /* __i386__ */
206
207 void create_delegating_vtbl(DWORD num_methods)
208 {
209     TRACE("%d\n", num_methods);
210     if(num_methods <= 3)
211     {
212         ERR("should have more than %d methods\n", num_methods);
213         return;
214     }
215
216     EnterCriticalSection(&delegating_vtbl_section);
217     if(!current_vtbl.table || num_methods > current_vtbl.table->size)
218     {
219         DWORD size;
220         DWORD old_protect;
221         if(current_vtbl.table && current_vtbl.table->ref == 0)
222         {
223             TRACE("freeing old table\n");
224             VirtualFree(current_vtbl.table->methods,
225                         (current_vtbl.table->size - 3) * sizeof(vtbl_method_t),
226                         MEM_RELEASE);
227             HeapFree(GetProcessHeap(), 0, current_vtbl.table);
228         }
229         size = (num_methods - 3) * sizeof(vtbl_method_t);
230         current_vtbl.table = HeapAlloc(GetProcessHeap(), 0, FIELD_OFFSET(ref_counted_vtbl, vtbl) + num_methods * sizeof(void*));
231         current_vtbl.table->ref = 0;
232         current_vtbl.table->size = num_methods;
233         current_vtbl.table->methods = VirtualAlloc(NULL, size, MEM_COMMIT | MEM_RESERVE, PAGE_EXECUTE_READWRITE);
234         fill_table(&current_vtbl.table->vtbl, current_vtbl.table->methods, num_methods);
235         VirtualProtect(current_vtbl.table->methods, size, PAGE_EXECUTE_READ, &old_protect);
236     }
237     LeaveCriticalSection(&delegating_vtbl_section);
238 }
239
240 static IUnknownVtbl *get_delegating_vtbl(void)
241 {
242     IUnknownVtbl *ret;
243
244     EnterCriticalSection(&delegating_vtbl_section);
245     current_vtbl.table->ref++;
246     ret = &current_vtbl.table->vtbl;
247     LeaveCriticalSection(&delegating_vtbl_section);
248     return ret;
249 }
250
251 static void release_delegating_vtbl(IUnknownVtbl *vtbl)
252 {
253     ref_counted_vtbl *table = (ref_counted_vtbl*)((DWORD *)vtbl - 1);
254
255     EnterCriticalSection(&delegating_vtbl_section);
256     table->ref--;
257     TRACE("ref now %d\n", table->ref);
258     if(table->ref == 0 && table != current_vtbl.table)
259     {
260         TRACE("... and we're not current so free'ing\n");
261         VirtualFree(current_vtbl.table->methods,
262                     (current_vtbl.table->size - 3) * sizeof(vtbl_method_t),
263                     MEM_RELEASE);
264         HeapFree(GetProcessHeap(), 0, table);
265     }
266     LeaveCriticalSection(&delegating_vtbl_section);
267 }
268
269 HRESULT WINAPI CStdStubBuffer_Delegating_Construct(REFIID riid,
270                                                    LPUNKNOWN pUnkServer,
271                                                    PCInterfaceName name,
272                                                    CInterfaceStubVtbl *vtbl,
273                                                    REFIID delegating_iid,
274                                                    LPPSFACTORYBUFFER pPSFactory,
275                                                    LPRPCSTUBBUFFER *ppStub)
276 {
277     cstdstubbuffer_delegating_t *This;
278     IUnknown *pvServer;
279     HRESULT r;
280
281     TRACE("(%p,%p,%p,%p) %s\n", pUnkServer, vtbl, pPSFactory, ppStub, name);
282     TRACE("iid=%s delegating to %s\n", debugstr_guid(vtbl->header.piid), debugstr_guid(delegating_iid));
283     TRACE("vtbl=%p\n", &vtbl->Vtbl);
284
285     if (!IsEqualGUID(vtbl->header.piid, riid))
286     {
287         ERR("IID mismatch during stub creation\n");
288         return RPC_E_UNEXPECTED;
289     }
290
291     r = IUnknown_QueryInterface(pUnkServer, riid, (void**)&pvServer);
292     if(FAILED(r)) return r;
293
294     This = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*This));
295     if (!This)
296     {
297         IUnknown_Release(pvServer);
298         return E_OUTOFMEMORY;
299     }
300
301     This->base_obj = get_delegating_vtbl();
302     r = create_stub(delegating_iid, (IUnknown*)&This->base_obj, &This->base_stub);
303     if(FAILED(r))
304     {
305         release_delegating_vtbl(This->base_obj);
306         HeapFree(GetProcessHeap(), 0, This);
307         IUnknown_Release(pvServer);
308         return r;
309     }
310
311     This->stub_buffer.lpVtbl = &vtbl->Vtbl;
312     This->stub_buffer.RefCount = 1;
313     This->stub_buffer.pvServerObject = pvServer;
314     This->stub_buffer.pPSFactory = pPSFactory;
315     *ppStub = (LPRPCSTUBBUFFER)&This->stub_buffer;
316
317     IPSFactoryBuffer_AddRef(pPSFactory);
318     return S_OK;
319 }
320
321 HRESULT WINAPI CStdStubBuffer_QueryInterface(LPRPCSTUBBUFFER iface,
322                                             REFIID riid,
323                                             LPVOID *obj)
324 {
325   CStdStubBuffer *This = (CStdStubBuffer *)iface;
326   TRACE("(%p)->QueryInterface(%s,%p)\n",This,debugstr_guid(riid),obj);
327
328   if (IsEqualIID(&IID_IUnknown, riid) ||
329       IsEqualIID(&IID_IRpcStubBuffer, riid))
330   {
331     IUnknown_AddRef(iface);
332     *obj = iface;
333     return S_OK;
334   }
335   *obj = NULL;
336   return E_NOINTERFACE;
337 }
338
339 ULONG WINAPI CStdStubBuffer_AddRef(LPRPCSTUBBUFFER iface)
340 {
341   CStdStubBuffer *This = (CStdStubBuffer *)iface;
342   TRACE("(%p)->AddRef()\n",This);
343   return InterlockedIncrement(&This->RefCount);
344 }
345
346 ULONG WINAPI NdrCStdStubBuffer_Release(LPRPCSTUBBUFFER iface,
347                                       LPPSFACTORYBUFFER pPSF)
348 {
349   CStdStubBuffer *This = (CStdStubBuffer *)iface;
350   ULONG refs;
351
352   TRACE("(%p)->Release()\n",This);
353
354   refs = InterlockedDecrement(&This->RefCount);
355   if (!refs)
356   {
357     /* test_Release shows that native doesn't call Disconnect here.
358        We'll leave it in for the time being. */
359     IRpcStubBuffer_Disconnect(iface);
360
361     IPSFactoryBuffer_Release(pPSF);
362     HeapFree(GetProcessHeap(),0,This);
363   }
364   return refs;
365 }
366
367 ULONG WINAPI NdrCStdStubBuffer2_Release(LPRPCSTUBBUFFER iface,
368                                         LPPSFACTORYBUFFER pPSF)
369 {
370     cstdstubbuffer_delegating_t *This = impl_from_delegating( iface );
371     ULONG refs;
372
373     TRACE("(%p)->Release()\n", This);
374
375     refs = InterlockedDecrement(&This->stub_buffer.RefCount);
376     if (!refs)
377     {
378         /* Just like NdrCStdStubBuffer_Release, we shouldn't call
379            Disconnect here */
380         IRpcStubBuffer_Disconnect((IRpcStubBuffer *)&This->stub_buffer);
381
382         IRpcStubBuffer_Release(This->base_stub);
383         release_delegating_vtbl(This->base_obj);
384
385         IPSFactoryBuffer_Release(pPSF);
386         HeapFree(GetProcessHeap(), 0, This);
387     }
388
389     return refs;
390 }
391
392 HRESULT WINAPI CStdStubBuffer_Connect(LPRPCSTUBBUFFER iface,
393                                      LPUNKNOWN lpUnkServer)
394 {
395     CStdStubBuffer *This = (CStdStubBuffer *)iface;
396     HRESULT r;
397     IUnknown *new = NULL;
398
399     TRACE("(%p)->Connect(%p)\n",This,lpUnkServer);
400
401     r = IUnknown_QueryInterface(lpUnkServer, STUB_HEADER(This).piid, (void**)&new);
402     new = InterlockedExchangePointer((void**)&This->pvServerObject, new);
403     if(new)
404         IUnknown_Release(new);
405     return r;
406 }
407
408 void WINAPI CStdStubBuffer_Disconnect(LPRPCSTUBBUFFER iface)
409 {
410     CStdStubBuffer *This = (CStdStubBuffer *)iface;
411     IUnknown *old;
412     TRACE("(%p)->Disconnect()\n",This);
413
414     old = InterlockedExchangePointer((void**)&This->pvServerObject, NULL);
415
416     if(old)
417         IUnknown_Release(old);
418 }
419
420 HRESULT WINAPI CStdStubBuffer_Invoke(LPRPCSTUBBUFFER iface,
421                                     PRPCOLEMESSAGE pMsg,
422                                     LPRPCCHANNELBUFFER pChannel)
423 {
424   CStdStubBuffer *This = (CStdStubBuffer *)iface;
425   DWORD dwPhase = STUB_UNMARSHAL;
426   HRESULT hr = S_OK;
427
428   TRACE("(%p)->Invoke(%p,%p)\n",This,pMsg,pChannel);
429
430   __TRY
431   {
432     if (STUB_HEADER(This).pDispatchTable)
433       STUB_HEADER(This).pDispatchTable[pMsg->iMethod](iface, pChannel, (PRPC_MESSAGE)pMsg, &dwPhase);
434     else /* pure interpreted */
435       NdrStubCall2(iface, pChannel, (PRPC_MESSAGE)pMsg, &dwPhase);
436   }
437   __EXCEPT(stub_filter)
438   {
439     DWORD dwExceptionCode = GetExceptionCode();
440     WARN("a stub call failed with exception 0x%08x (%d)\n", dwExceptionCode, dwExceptionCode);
441     if (FAILED(dwExceptionCode))
442       hr = dwExceptionCode;
443     else
444       hr = HRESULT_FROM_WIN32(dwExceptionCode);
445   }
446   __ENDTRY
447
448   return hr;
449 }
450
451 LPRPCSTUBBUFFER WINAPI CStdStubBuffer_IsIIDSupported(LPRPCSTUBBUFFER iface,
452                                                     REFIID riid)
453 {
454   CStdStubBuffer *This = (CStdStubBuffer *)iface;
455   TRACE("(%p)->IsIIDSupported(%s)\n",This,debugstr_guid(riid));
456   return IsEqualGUID(STUB_HEADER(This).piid, riid) ? iface : NULL;
457 }
458
459 ULONG WINAPI CStdStubBuffer_CountRefs(LPRPCSTUBBUFFER iface)
460 {
461   CStdStubBuffer *This = (CStdStubBuffer *)iface;
462   TRACE("(%p)->CountRefs()\n",This);
463   return This->RefCount;
464 }
465
466 HRESULT WINAPI CStdStubBuffer_DebugServerQueryInterface(LPRPCSTUBBUFFER iface,
467                                                        LPVOID *ppv)
468 {
469   CStdStubBuffer *This = (CStdStubBuffer *)iface;
470   TRACE("(%p)->DebugServerQueryInterface(%p)\n",This,ppv);
471   return S_OK;
472 }
473
474 void WINAPI CStdStubBuffer_DebugServerRelease(LPRPCSTUBBUFFER iface,
475                                              LPVOID pv)
476 {
477   CStdStubBuffer *This = (CStdStubBuffer *)iface;
478   TRACE("(%p)->DebugServerRelease(%p)\n",This,pv);
479 }
480
481 const IRpcStubBufferVtbl CStdStubBuffer_Vtbl =
482 {
483     CStdStubBuffer_QueryInterface,
484     CStdStubBuffer_AddRef,
485     NULL,
486     CStdStubBuffer_Connect,
487     CStdStubBuffer_Disconnect,
488     CStdStubBuffer_Invoke,
489     CStdStubBuffer_IsIIDSupported,
490     CStdStubBuffer_CountRefs,
491     CStdStubBuffer_DebugServerQueryInterface,
492     CStdStubBuffer_DebugServerRelease
493 };
494
495 static HRESULT WINAPI CStdStubBuffer_Delegating_Connect(LPRPCSTUBBUFFER iface,
496                                                         LPUNKNOWN lpUnkServer)
497 {
498     cstdstubbuffer_delegating_t *This = impl_from_delegating(iface);
499     HRESULT r;
500     TRACE("(%p)->Connect(%p)\n", This, lpUnkServer);
501
502     r = CStdStubBuffer_Connect(iface, lpUnkServer);
503     if(SUCCEEDED(r))
504         r = IRpcStubBuffer_Connect(This->base_stub, (IUnknown*)&This->base_obj);
505
506     return r;
507 }
508
509 static void WINAPI CStdStubBuffer_Delegating_Disconnect(LPRPCSTUBBUFFER iface)
510 {
511     cstdstubbuffer_delegating_t *This = impl_from_delegating(iface);
512     TRACE("(%p)->Disconnect()\n", This);
513
514     IRpcStubBuffer_Disconnect(This->base_stub);
515     CStdStubBuffer_Disconnect(iface);
516 }
517
518 static ULONG WINAPI CStdStubBuffer_Delegating_CountRefs(LPRPCSTUBBUFFER iface)
519 {
520     cstdstubbuffer_delegating_t *This = impl_from_delegating(iface);
521     ULONG ret;
522     TRACE("(%p)->CountRefs()\n", This);
523
524     ret = CStdStubBuffer_CountRefs(iface);
525     ret += IRpcStubBuffer_CountRefs(This->base_stub);
526
527     return ret;
528 }
529
530 const IRpcStubBufferVtbl CStdStubBuffer_Delegating_Vtbl =
531 {
532     CStdStubBuffer_QueryInterface,
533     CStdStubBuffer_AddRef,
534     NULL,
535     CStdStubBuffer_Delegating_Connect,
536     CStdStubBuffer_Delegating_Disconnect,
537     CStdStubBuffer_Invoke,
538     CStdStubBuffer_IsIIDSupported,
539     CStdStubBuffer_Delegating_CountRefs,
540     CStdStubBuffer_DebugServerQueryInterface,
541     CStdStubBuffer_DebugServerRelease
542 };
543
544 const MIDL_SERVER_INFO *CStdStubBuffer_GetServerInfo(IRpcStubBuffer *iface)
545 {
546   CStdStubBuffer *This = (CStdStubBuffer *)iface;
547   return STUB_HEADER(This).pServerInfo;
548 }
549
550 /************************************************************************
551  *           NdrStubForwardingFunction [RPCRT4.@]
552  */
553 void __RPC_STUB NdrStubForwardingFunction( IRpcStubBuffer *iface, IRpcChannelBuffer *pChannel,
554                                            PRPC_MESSAGE pMsg, DWORD *pdwStubPhase )
555 {
556     /* Note pMsg is passed intact since RPCOLEMESSAGE is basically a RPC_MESSAGE. */
557
558     cstdstubbuffer_delegating_t *This = impl_from_delegating(iface);
559     HRESULT r = IRpcStubBuffer_Invoke(This->base_stub, (RPCOLEMESSAGE*)pMsg, pChannel);
560     if(FAILED(r)) RpcRaiseException(r);
561     return;
562 }
563
564 /***********************************************************************
565  *           NdrStubInitialize [RPCRT4.@]
566  */
567 void WINAPI NdrStubInitialize(PRPC_MESSAGE pRpcMsg,
568                              PMIDL_STUB_MESSAGE pStubMsg,
569                              PMIDL_STUB_DESC pStubDescriptor,
570                              LPRPCCHANNELBUFFER pRpcChannelBuffer)
571 {
572   TRACE("(%p,%p,%p,%p)\n", pRpcMsg, pStubMsg, pStubDescriptor, pRpcChannelBuffer);
573   NdrServerInitializeNew(pRpcMsg, pStubMsg, pStubDescriptor);
574   pStubMsg->pRpcChannelBuffer = pRpcChannelBuffer;
575   IRpcChannelBuffer_GetDestCtx(pStubMsg->pRpcChannelBuffer,
576                                &pStubMsg->dwDestContext,
577                                &pStubMsg->pvDestContext);
578 }
579
580 /***********************************************************************
581  *           NdrStubGetBuffer [RPCRT4.@]
582  */
583 void WINAPI NdrStubGetBuffer(LPRPCSTUBBUFFER iface,
584                             LPRPCCHANNELBUFFER pRpcChannelBuffer,
585                             PMIDL_STUB_MESSAGE pStubMsg)
586 {
587   CStdStubBuffer *This = (CStdStubBuffer *)iface;
588   HRESULT hr;
589
590   TRACE("(%p, %p, %p)\n", This, pRpcChannelBuffer, pStubMsg);
591
592   pStubMsg->RpcMsg->BufferLength = pStubMsg->BufferLength;
593   hr = IRpcChannelBuffer_GetBuffer(pRpcChannelBuffer,
594     (RPCOLEMESSAGE *)pStubMsg->RpcMsg, STUB_HEADER(This).piid);
595   if (FAILED(hr))
596   {
597     RpcRaiseException(hr);
598     return;
599   }
600
601   pStubMsg->Buffer = pStubMsg->RpcMsg->Buffer;
602 }