2 * Unit test suite for cstubs
4 * Copyright 2006 Huw Davies
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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
23 #define PROXY_DELEGATION
26 #include "wine/test.h"
37 static CStdPSFactoryBuffer PSFactoryBuffer;
39 CSTDSTUBBUFFERRELEASE(&PSFactoryBuffer)
40 CSTDSTUBBUFFER2RELEASE(&PSFactoryBuffer)
42 static GUID IID_if1 = {0x12345678, 1234, 5678, {12,34,56,78,90,0xab,0xcd,0xef}};
43 static GUID IID_if2 = {0x12345679, 1234, 5678, {12,34,56,78,90,0xab,0xcd,0xef}};
44 static GUID IID_if3 = {0x1234567a, 1234, 5678, {12,34,56,78,90,0xab,0xcd,0xef}};
45 static GUID IID_if4 = {0x1234567b, 1234, 5678, {12,34,56,78,90,0xab,0xcd,0xef}};
47 static int my_alloc_called;
48 static int my_free_called;
50 static void * CALLBACK my_alloc(size_t size)
53 return NdrOleAllocate(size);
56 static void CALLBACK my_free(void *ptr)
62 typedef struct _MIDL_PROC_FORMAT_STRING
65 unsigned char Format[ 2 ];
66 } MIDL_PROC_FORMAT_STRING;
68 typedef struct _MIDL_TYPE_FORMAT_STRING
71 unsigned char Format[ 2 ];
72 } MIDL_TYPE_FORMAT_STRING;
75 static const MIDL_PROC_FORMAT_STRING __MIDL_ProcFormatString =
83 static const MIDL_TYPE_FORMAT_STRING __MIDL_TypeFormatString =
91 static const MIDL_STUB_DESC Object_StubDesc =
101 __MIDL_TypeFormatString.Format,
102 1, /* -error bounds_check flag */
103 0x20000, /* Ndr library version */
105 0x50100a4, /* MIDL Version 5.1.164 */
108 0, /* notify & notify_flag routine table */
115 static HRESULT WINAPI if1_fn1_Proxy(void *This)
120 static void __RPC_STUB if1_fn1_Stub(
121 IRpcStubBuffer *This,
122 IRpcChannelBuffer *_pRpcChannelBuffer,
123 PRPC_MESSAGE _pRpcMessage,
124 DWORD *_pdwStubPhase)
129 static HRESULT WINAPI if1_fn2_Proxy(void *This)
134 static void __RPC_STUB if1_fn2_Stub(
135 IRpcStubBuffer *This,
136 IRpcChannelBuffer *_pRpcChannelBuffer,
137 PRPC_MESSAGE _pRpcMessage,
138 DWORD *_pdwStubPhase)
143 static CINTERFACE_PROXY_VTABLE(5) if1_proxy_vtbl =
146 { IUnknown_QueryInterface_Proxy,
147 IUnknown_AddRef_Proxy,
148 IUnknown_Release_Proxy ,
155 static const unsigned short if1_FormatStringOffsetTable[] =
161 static const MIDL_SERVER_INFO if1_server_info =
165 __MIDL_ProcFormatString.Format,
166 &if1_FormatStringOffsetTable[-3],
173 static const PRPC_STUB_FUNCTION if1_table[] =
179 static CInterfaceStubVtbl if1_stub_vtbl =
187 { CStdStubBuffer_METHODS }
190 static CINTERFACE_PROXY_VTABLE(13) if2_proxy_vtbl =
193 { IUnknown_QueryInterface_Proxy,
194 IUnknown_AddRef_Proxy,
195 IUnknown_Release_Proxy ,
209 static const unsigned short if2_FormatStringOffsetTable[] =
224 static const MIDL_SERVER_INFO if2_server_info =
228 __MIDL_ProcFormatString.Format,
229 &if2_FormatStringOffsetTable[-3],
236 static const PRPC_STUB_FUNCTION if2_table[] =
238 STUB_FORWARDING_FUNCTION,
239 STUB_FORWARDING_FUNCTION,
240 STUB_FORWARDING_FUNCTION,
241 STUB_FORWARDING_FUNCTION,
242 STUB_FORWARDING_FUNCTION,
243 STUB_FORWARDING_FUNCTION,
244 STUB_FORWARDING_FUNCTION,
245 STUB_FORWARDING_FUNCTION,
246 STUB_FORWARDING_FUNCTION,
247 STUB_FORWARDING_FUNCTION
250 static CInterfaceStubVtbl if2_stub_vtbl =
258 { CStdStubBuffer_DELEGATING_METHODS }
261 static CINTERFACE_PROXY_VTABLE(4) if3_proxy_vtbl =
264 { IUnknown_QueryInterface_Proxy,
265 IUnknown_AddRef_Proxy,
266 IUnknown_Release_Proxy ,
272 static const unsigned short if3_FormatStringOffsetTable[] =
278 static const MIDL_SERVER_INFO if3_server_info =
282 __MIDL_ProcFormatString.Format,
283 &if3_FormatStringOffsetTable[-3],
290 static const PRPC_STUB_FUNCTION if3_table[] =
295 static CInterfaceStubVtbl if3_stub_vtbl =
303 { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
306 static CINTERFACE_PROXY_VTABLE(7) if4_proxy_vtbl =
309 { IUnknown_QueryInterface_Proxy,
310 IUnknown_AddRef_Proxy,
311 IUnknown_Release_Proxy ,
319 static const unsigned short if4_FormatStringOffsetTable[] =
328 static const MIDL_SERVER_INFO if4_server_info =
332 __MIDL_ProcFormatString.Format,
333 &if4_FormatStringOffsetTable[-3],
340 static const PRPC_STUB_FUNCTION if4_table[] =
342 STUB_FORWARDING_FUNCTION,
343 STUB_FORWARDING_FUNCTION,
344 STUB_FORWARDING_FUNCTION,
345 STUB_FORWARDING_FUNCTION,
348 static CInterfaceStubVtbl if4_stub_vtbl =
356 { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
359 static const CInterfaceProxyVtbl *cstub_ProxyVtblList[] =
361 (const CInterfaceProxyVtbl *) &if1_proxy_vtbl,
362 (const CInterfaceProxyVtbl *) &if2_proxy_vtbl,
363 (const CInterfaceProxyVtbl *) &if3_proxy_vtbl,
364 (const CInterfaceProxyVtbl *) &if4_proxy_vtbl,
368 static const CInterfaceStubVtbl *cstub_StubVtblList[] =
370 (const CInterfaceStubVtbl *) &if1_stub_vtbl,
371 (const CInterfaceStubVtbl *) &if2_stub_vtbl,
372 (const CInterfaceStubVtbl *) &if3_stub_vtbl,
373 (const CInterfaceStubVtbl *) &if4_stub_vtbl,
377 static PCInterfaceName const if_name_list[] =
386 static const IID *base_iid_list[] =
395 #define cstub_CHECK_IID(n) IID_GENERIC_CHECK_IID( cstub, pIID, n)
397 static int __stdcall iid_lookup( const IID * pIID, int * pIndex )
401 IID_BS_LOOKUP_INITIAL_TEST( cstub, 4, 4 )
402 IID_BS_LOOKUP_NEXT_TEST( cstub, 2 )
403 IID_BS_LOOKUP_NEXT_TEST( cstub, 1 )
404 IID_BS_LOOKUP_RETURN_RESULT( cstub, 4, *pIndex )
409 static const ExtendedProxyFileInfo my_proxy_file_info =
411 (const PCInterfaceProxyVtblList *) &cstub_ProxyVtblList,
412 (const PCInterfaceStubVtblList *) &cstub_StubVtblList,
413 (const PCInterfaceName *) &if_name_list,
414 (const IID **) &base_iid_list,
424 static const ProxyFileInfo *proxy_file_list[] = {
430 static IPSFactoryBuffer *test_NdrDllGetClassObject(void)
432 IPSFactoryBuffer *ppsf = NULL;
433 const CLSID PSDispatch = {0x20420, 0, 0, {0xc0, 0, 0, 0, 0, 0, 0, 0x46}};
435 HMODULE hmod = LoadLibraryA("rpcrt4.dll");
436 void *CStd_QueryInterface = GetProcAddress(hmod, "CStdStubBuffer_QueryInterface");
437 void *CStd_AddRef = GetProcAddress(hmod, "CStdStubBuffer_AddRef");
438 void *CStd_Release = GetProcAddress(hmod, "NdrCStdStubBuffer_Release");
439 void *CStd_Connect = GetProcAddress(hmod, "CStdStubBuffer_Connect");
440 void *CStd_Disconnect = GetProcAddress(hmod, "CStdStubBuffer_Disconnect");
441 void *CStd_Invoke = GetProcAddress(hmod, "CStdStubBuffer_Invoke");
442 void *CStd_IsIIDSupported = GetProcAddress(hmod, "CStdStubBuffer_IsIIDSupported");
443 void *CStd_CountRefs = GetProcAddress(hmod, "CStdStubBuffer_CountRefs");
444 void *CStd_DebugServerQueryInterface = GetProcAddress(hmod, "CStdStubBuffer_DebugServerQueryInterface");
445 void *CStd_DebugServerRelease = GetProcAddress(hmod, "CStdStubBuffer_DebugServerRelease");
447 r = NdrDllGetClassObject(&PSDispatch, &IID_IPSFactoryBuffer, (void**)&ppsf, proxy_file_list,
448 &PSDispatch, &PSFactoryBuffer);
450 ok(r == S_OK, "ret %08x\n", r);
451 ok(ppsf != NULL, "ppsf == NULL\n");
453 ok(PSFactoryBuffer.pProxyFileList == proxy_file_list, "pfl not the same\n");
454 ok(PSFactoryBuffer.pProxyFileList[0]->pStubVtblList == (PCInterfaceStubVtblList *) &cstub_StubVtblList, "stub vtbllist not the same\n");
456 /* if1 is non-delegating, if2 is delegating, if3 is non-delegating
457 but I've zero'ed the vtbl entries, similarly if4 is delegating
458 with zero'ed vtbl entries */
460 #define VTBL_TEST_NOT_CHANGE_TO(name, i) \
461 ok(PSFactoryBuffer.pProxyFileList[0]->pStubVtblList[i]->Vtbl.name != CStd_##name, #name "vtbl %d updated %p %p\n", \
462 i, PSFactoryBuffer.pProxyFileList[0]->pStubVtblList[i]->Vtbl.name, CStd_##name );
463 #define VTBL_TEST_CHANGE_TO(name, i) \
464 ok(PSFactoryBuffer.pProxyFileList[0]->pStubVtblList[i]->Vtbl.name == CStd_##name, #name "vtbl %d not updated %p %p\n", \
465 i, PSFactoryBuffer.pProxyFileList[0]->pStubVtblList[i]->Vtbl.name, CStd_##name );
466 #define VTBL_TEST_ZERO(name, i) \
467 ok(PSFactoryBuffer.pProxyFileList[0]->pStubVtblList[i]->Vtbl.name == NULL, #name "vtbl %d not null %p\n", \
468 i, PSFactoryBuffer.pProxyFileList[0]->pStubVtblList[i]->Vtbl.name );
469 VTBL_TEST_NOT_CHANGE_TO(QueryInterface, 0);
470 VTBL_TEST_NOT_CHANGE_TO(AddRef, 0);
471 VTBL_TEST_NOT_CHANGE_TO(Release, 0);
472 VTBL_TEST_NOT_CHANGE_TO(Connect, 0);
473 VTBL_TEST_NOT_CHANGE_TO(Disconnect, 0);
474 VTBL_TEST_NOT_CHANGE_TO(Invoke, 0);
475 VTBL_TEST_NOT_CHANGE_TO(IsIIDSupported, 0);
476 VTBL_TEST_NOT_CHANGE_TO(CountRefs, 0);
477 VTBL_TEST_NOT_CHANGE_TO(DebugServerQueryInterface, 0);
478 VTBL_TEST_NOT_CHANGE_TO(DebugServerRelease, 0);
480 VTBL_TEST_CHANGE_TO(QueryInterface, 1);
481 VTBL_TEST_CHANGE_TO(AddRef, 1);
482 VTBL_TEST_NOT_CHANGE_TO(Release, 1);
483 VTBL_TEST_NOT_CHANGE_TO(Connect, 1);
484 VTBL_TEST_NOT_CHANGE_TO(Disconnect, 1);
485 VTBL_TEST_CHANGE_TO(Invoke, 1);
486 VTBL_TEST_CHANGE_TO(IsIIDSupported, 1);
487 VTBL_TEST_NOT_CHANGE_TO(CountRefs, 1);
488 VTBL_TEST_CHANGE_TO(DebugServerQueryInterface, 1);
489 VTBL_TEST_CHANGE_TO(DebugServerRelease, 1);
491 VTBL_TEST_CHANGE_TO(QueryInterface, 2);
492 VTBL_TEST_CHANGE_TO(AddRef, 2);
493 VTBL_TEST_ZERO(Release, 2);
494 VTBL_TEST_CHANGE_TO(Connect, 2);
495 VTBL_TEST_CHANGE_TO(Disconnect, 2);
496 VTBL_TEST_CHANGE_TO(Invoke, 2);
497 VTBL_TEST_CHANGE_TO(IsIIDSupported, 2);
498 VTBL_TEST_CHANGE_TO(CountRefs, 2);
499 VTBL_TEST_CHANGE_TO(DebugServerQueryInterface, 2);
500 VTBL_TEST_CHANGE_TO(DebugServerRelease, 2);
502 VTBL_TEST_CHANGE_TO(QueryInterface, 3);
503 VTBL_TEST_CHANGE_TO(AddRef, 3);
504 VTBL_TEST_ZERO(Release, 3);
505 VTBL_TEST_NOT_CHANGE_TO(Connect, 3);
506 VTBL_TEST_NOT_CHANGE_TO(Disconnect, 3);
507 VTBL_TEST_CHANGE_TO(Invoke, 3);
508 VTBL_TEST_CHANGE_TO(IsIIDSupported, 3);
509 VTBL_TEST_NOT_CHANGE_TO(CountRefs, 3);
510 VTBL_TEST_CHANGE_TO(DebugServerQueryInterface, 3);
511 VTBL_TEST_CHANGE_TO(DebugServerRelease, 3);
515 #undef VTBL_TEST_NOT_CHANGE_TO
516 #undef VTBL_TEST_CHANGE_TO
517 #undef VTBL_TEST_ZERO
519 ok(PSFactoryBuffer.RefCount == 1, "ref count %d\n", PSFactoryBuffer.RefCount);
523 static int base_buffer_invoke_called;
524 static HRESULT WINAPI base_buffer_Invoke(IRpcStubBuffer *This, RPCOLEMESSAGE *msg, IRpcChannelBuffer *channel)
526 base_buffer_invoke_called++;
527 ok(msg == (RPCOLEMESSAGE*)0xcafebabe, "msg ptr changed\n");
528 ok(channel == (IRpcChannelBuffer*)0xdeadbeef, "channel ptr changed\n");
529 return S_OK; /* returning any failure here results in an exception */
532 static IRpcStubBufferVtbl base_buffer_vtbl = {
545 static void test_NdrStubForwardingFunction(void)
549 IRpcChannelBuffer *channel = (IRpcChannelBuffer*)0xdeadbeef;
550 RPC_MESSAGE *msg = (RPC_MESSAGE*)0xcafebabe;
551 DWORD *phase = (DWORD*)0x12345678;
552 IRpcStubBufferVtbl *base_buffer_vtbl_ptr = &base_buffer_vtbl;
553 IRpcStubBuffer *base_stub_buffer = (IRpcStubBuffer*)&base_buffer_vtbl_ptr;
555 memset(This, 0xcc, sizeof(This));
556 This[0] = base_stub_buffer;
557 real_this = &This[1];
559 NdrStubForwardingFunction( real_this, channel, msg, phase );
560 ok(base_buffer_invoke_called == 1, "base_buffer_invoke called %d times\n", base_buffer_invoke_called);
564 static IRpcStubBuffer *create_stub(IPSFactoryBuffer *ppsf, REFIID iid, IUnknown *obj, HRESULT expected_result)
566 IRpcStubBuffer *pstub = NULL;
569 r = IPSFactoryBuffer_CreateStub(ppsf, iid, obj, &pstub);
570 ok(r == expected_result, "CreateStub returned %08x expected %08x\n", r, expected_result);
574 static HRESULT WINAPI create_stub_test_QI(IUnknown *This, REFIID iid, void **ppv)
576 ok(IsEqualIID(iid, &IID_if1), "incorrect iid\n");
577 *ppv = (void*)0xdeadbeef;
581 static IUnknownVtbl create_stub_test_vtbl =
588 static HRESULT WINAPI create_stub_test_fail_QI(IUnknown *This, REFIID iid, void **ppv)
590 ok(IsEqualIID(iid, &IID_if1), "incorrect iid\n");
592 return E_NOINTERFACE;
595 static IUnknownVtbl create_stub_test_fail_vtbl =
597 create_stub_test_fail_QI,
602 static void test_CreateStub(IPSFactoryBuffer *ppsf)
604 IUnknownVtbl *vtbl = &create_stub_test_vtbl;
605 IUnknown *obj = (IUnknown*)&vtbl;
606 IRpcStubBuffer *pstub = create_stub(ppsf, &IID_if1, obj, S_OK);
607 CStdStubBuffer *cstd_stub = (CStdStubBuffer*)pstub;
608 const CInterfaceStubHeader *header = ((const CInterfaceStubHeader *)cstd_stub->lpVtbl) - 1;
610 ok(IsEqualIID(header->piid, &IID_if1), "header iid differs\n");
611 ok(cstd_stub->RefCount == 1, "ref count %d\n", cstd_stub->RefCount);
612 /* 0xdeadbeef returned from create_stub_test_QI */
613 ok(cstd_stub->pvServerObject == (void*)0xdeadbeef, "pvServerObject %p\n", cstd_stub->pvServerObject);
614 ok(cstd_stub->pPSFactory == ppsf, "pPSFactory %p\n", cstd_stub->pPSFactory);
616 vtbl = &create_stub_test_fail_vtbl;
617 pstub = create_stub(ppsf, &IID_if1, obj, E_NOINTERFACE);
621 static HRESULT WINAPI connect_test_orig_QI(IUnknown *This, REFIID iid, void **ppv)
623 ok(IsEqualIID(iid, &IID_if1) ||
624 IsEqualIID(iid, &IID_if2), "incorrect iid\n");
629 static int connect_test_orig_release_called;
630 static ULONG WINAPI connect_test_orig_release(IUnknown *This)
632 connect_test_orig_release_called++;
636 static IUnknownVtbl connect_test_orig_vtbl =
638 connect_test_orig_QI,
640 connect_test_orig_release
643 static HRESULT WINAPI connect_test_new_QI(IUnknown *This, REFIID iid, void **ppv)
645 ok(IsEqualIID(iid, &IID_if1) ||
646 IsEqualIID(iid, &IID_if2), "incorrect iid\n");
647 *ppv = (void*)0xcafebabe;
651 static IUnknownVtbl connect_test_new_vtbl =
658 static HRESULT WINAPI connect_test_new_fail_QI(IUnknown *This, REFIID iid, void **ppv)
660 ok(IsEqualIID(iid, &IID_if1), "incorrect iid\n");
661 *ppv = (void*)0xdeadbeef;
662 return E_NOINTERFACE;
665 static IUnknownVtbl connect_test_new_fail_vtbl =
667 connect_test_new_fail_QI,
672 static int connect_test_base_Connect_called;
673 static HRESULT WINAPI connect_test_base_Connect(IRpcStubBuffer *pstub, IUnknown *obj)
675 connect_test_base_Connect_called++;
676 ok(*(void**)obj == (void*)0xbeefcafe, "unexpected obj %p\n", obj);
680 static IRpcStubBufferVtbl connect_test_base_stub_buffer_vtbl =
685 connect_test_base_Connect,
694 static void test_Connect(IPSFactoryBuffer *ppsf)
696 IUnknownVtbl *orig_vtbl = &connect_test_orig_vtbl;
697 IUnknownVtbl *new_vtbl = &connect_test_new_vtbl;
698 IUnknownVtbl *new_fail_vtbl = &connect_test_new_fail_vtbl;
699 IUnknown *obj = (IUnknown*)&orig_vtbl;
700 IRpcStubBuffer *pstub = create_stub(ppsf, &IID_if1, obj, S_OK);
701 CStdStubBuffer *cstd_stub = (CStdStubBuffer*)pstub;
702 IRpcStubBufferVtbl *base_stub_buf_vtbl = &connect_test_base_stub_buffer_vtbl;
705 obj = (IUnknown*)&new_vtbl;
706 r = IRpcStubBuffer_Connect(pstub, obj);
707 ok(r == S_OK, "r %08x\n", r);
708 ok(connect_test_orig_release_called == 1, "release called %d\n", connect_test_orig_release_called);
709 ok(cstd_stub->pvServerObject == (void*)0xcafebabe, "pvServerObject %p\n", cstd_stub->pvServerObject);
711 cstd_stub->pvServerObject = (IUnknown*)&orig_vtbl;
712 obj = (IUnknown*)&new_fail_vtbl;
713 r = IRpcStubBuffer_Connect(pstub, obj);
714 ok(r == E_NOINTERFACE, "r %08x\n", r);
715 ok(cstd_stub->pvServerObject == (void*)0xdeadbeef, "pvServerObject %p\n", cstd_stub->pvServerObject);
716 ok(connect_test_orig_release_called == 2, "release called %d\n", connect_test_orig_release_called);
718 /* Now use a delegated stub.
720 We know from the NdrStubForwardFunction test that
721 (void**)pstub-1 is the base interface stub buffer. This shows
722 that (void**)pstub-2 contains the address of a vtable that gets
723 passed to the base interface's Connect method. Note that
724 (void**)pstub-2 itself gets passed to Connect and not
725 *((void**)pstub-2), so it should contain the vtable ptr and not
728 obj = (IUnknown*)&orig_vtbl;
729 pstub = create_stub(ppsf, &IID_if2, obj, S_OK);
730 *((void**)pstub-1) = &base_stub_buf_vtbl;
731 *((void**)pstub-2) = (void*)0xbeefcafe;
733 obj = (IUnknown*)&new_vtbl;
734 r = IRpcStubBuffer_Connect(pstub, obj);
735 ok(connect_test_base_Connect_called == 1, "connect_test_bsae_Connect called %d times\n",
736 connect_test_base_Connect_called);
737 ok(connect_test_orig_release_called == 3, "release called %d\n", connect_test_orig_release_called);
738 cstd_stub = (CStdStubBuffer*)pstub;
739 ok(cstd_stub->pvServerObject == (void*)0xcafebabe, "pvServerObject %p\n", cstd_stub->pvServerObject);
742 static void test_Disconnect(IPSFactoryBuffer *ppsf)
744 IUnknownVtbl *orig_vtbl = &connect_test_orig_vtbl;
745 IUnknown *obj = (IUnknown*)&orig_vtbl;
746 IRpcStubBuffer *pstub = create_stub(ppsf, &IID_if1, obj, S_OK);
747 CStdStubBuffer *cstd_stub = (CStdStubBuffer*)pstub;
749 connect_test_orig_release_called = 0;
750 IRpcStubBuffer_Disconnect(pstub);
751 ok(connect_test_orig_release_called == 1, "release called %d\n", connect_test_orig_release_called);
752 ok(cstd_stub->pvServerObject == NULL, "pvServerObject %p\n", cstd_stub->pvServerObject);
756 static int release_test_psfacbuf_release_called;
757 static ULONG WINAPI release_test_pretend_psfacbuf_release(IUnknown *pUnk)
759 release_test_psfacbuf_release_called++;
763 static IUnknownVtbl release_test_pretend_psfacbuf_vtbl =
767 release_test_pretend_psfacbuf_release
770 static void test_Release(IPSFactoryBuffer *ppsf)
773 IUnknownVtbl *orig_vtbl = &connect_test_orig_vtbl;
774 IUnknown *obj = (IUnknown*)&orig_vtbl;
775 IUnknownVtbl *pretend_psfacbuf_vtbl = &release_test_pretend_psfacbuf_vtbl;
776 IUnknown *pretend_psfacbuf = (IUnknown *)&pretend_psfacbuf_vtbl;
777 IRpcStubBuffer *pstub = create_stub(ppsf, &IID_if1, obj, S_OK);
778 CStdStubBuffer *cstd_stub = (CStdStubBuffer*)pstub;
780 facbuf_refs = PSFactoryBuffer.RefCount;
782 /* This shows that NdrCStdStubBuffer_Release doesn't call Disconnect */
783 ok(cstd_stub->RefCount == 1, "ref count %d\n", cstd_stub->RefCount);
784 connect_test_orig_release_called = 0;
785 IRpcStubBuffer_Release(pstub);
787 ok(connect_test_orig_release_called == 0, "release called %d\n", connect_test_orig_release_called);
789 ok(PSFactoryBuffer.RefCount == facbuf_refs - 1, "factory buffer refs %d orig %d\n", PSFactoryBuffer.RefCount, facbuf_refs);
791 /* This shows that NdrCStdStubBuffer_Release calls Release on its 2nd arg, rather than on This->pPSFactory
792 (which are usually the same and indeed it's odd that _Release requires this 2nd arg). */
793 pstub = create_stub(ppsf, &IID_if1, obj, S_OK);
794 ok(PSFactoryBuffer.RefCount == facbuf_refs, "factory buffer refs %d orig %d\n", PSFactoryBuffer.RefCount, facbuf_refs);
795 NdrCStdStubBuffer_Release(pstub, (IPSFactoryBuffer*)pretend_psfacbuf);
796 ok(release_test_psfacbuf_release_called == 1, "pretend_psfacbuf_release called %d\n", release_test_psfacbuf_release_called);
797 ok(PSFactoryBuffer.RefCount == facbuf_refs, "factory buffer refs %d orig %d\n", PSFactoryBuffer.RefCount, facbuf_refs);
800 static HRESULT WINAPI delegating_invoke_test_QI(ITypeLib *pUnk, REFIID iid, void** ppv)
807 static ULONG WINAPI delegating_invoke_test_addref(ITypeLib *pUnk)
812 static ULONG WINAPI delegating_invoke_test_release(ITypeLib *pUnk)
817 static UINT WINAPI delegating_invoke_test_get_type_info_count(ITypeLib *pUnk)
822 static ITypeLibVtbl delegating_invoke_test_obj_vtbl =
824 delegating_invoke_test_QI,
825 delegating_invoke_test_addref,
826 delegating_invoke_test_release,
827 delegating_invoke_test_get_type_info_count,
839 static HRESULT WINAPI delegating_invoke_test_get_buffer(IRpcChannelBuffer *pchan,
843 msg->Buffer = HeapAlloc(GetProcessHeap(), 0, msg->cbBuffer);
847 static IRpcChannelBufferVtbl delegating_invoke_test_rpc_chan_vtbl =
852 delegating_invoke_test_get_buffer,
859 static void test_delegating_Invoke(IPSFactoryBuffer *ppsf)
861 ITypeLibVtbl *obj_vtbl = &delegating_invoke_test_obj_vtbl;
862 IUnknown *obj = (IUnknown*)&obj_vtbl;
863 IRpcStubBuffer *pstub = create_stub(ppsf, &IID_if2, obj, S_OK);
864 IRpcChannelBufferVtbl *pchan_vtbl = &delegating_invoke_test_rpc_chan_vtbl;
865 IRpcChannelBuffer *pchan = (IRpcChannelBuffer *)&pchan_vtbl;
869 memset(&msg, 0, sizeof(msg));
870 msg.dataRepresentation = NDR_LOCAL_DATA_REPRESENTATION;
872 /* FIXME: Figure out why this fails on Windows */
873 r = IRpcStubBuffer_Invoke(pstub, &msg, pchan);
874 ok(r == S_OK, "ret %08x\n", r);
877 ok(*(DWORD*)msg.Buffer == 0xabcdef, "buf[0] %08x\n", *(DWORD*)msg.Buffer);
878 ok(*((DWORD*)msg.Buffer + 1) == S_OK, "buf[1] %08x\n", *((DWORD*)msg.Buffer + 1));
880 IRpcStubBuffer_Release(pstub);
885 IPSFactoryBuffer *ppsf;
889 ppsf = test_NdrDllGetClassObject();
890 test_NdrStubForwardingFunction();
891 test_CreateStub(ppsf);
893 test_Disconnect(ppsf);
895 test_delegating_Invoke(ppsf);