static void test_Connect(IPSFactoryBuffer *ppsf) { IUnknownVtbl *orig_vtbl = &connect_test_orig_vtbl; IUnknownVtbl *new_vtbl = &connect_test_new_vtbl; IUnknownVtbl *new_fail_vtbl = &connect_test_new_fail_vtbl; IUnknown *obj = (IUnknown*)&orig_vtbl; IRpcStubBuffer *pstub = create_stub(ppsf, &IID_if1, obj, S_OK); CStdStubBuffer *cstd_stub = (CStdStubBuffer*)pstub; IRpcStubBufferVtbl *base_stub_buf_vtbl = &connect_test_base_stub_buffer_vtbl; HRESULT r; obj = (IUnknown*)&new_vtbl; r = IRpcStubBuffer_Connect(pstub, obj); ok(r == S_OK, "r %08x\n", r); ok(connect_test_orig_release_called == 1, "release called %d\n", connect_test_orig_release_called); ok(cstd_stub->pvServerObject == (void*)0xcafebabe, "pvServerObject %p\n", cstd_stub->pvServerObject); cstd_stub->pvServerObject = (IUnknown*)&orig_vtbl; obj = (IUnknown*)&new_fail_vtbl; r = IRpcStubBuffer_Connect(pstub, obj); ok(r == E_NOINTERFACE, "r %08x\n", r); ok(cstd_stub->pvServerObject == (void*)0xdeadbeef, "pvServerObject %p\n", cstd_stub->pvServerObject); ok(connect_test_orig_release_called == 2, "release called %d\n", connect_test_orig_release_called); /* Now use a delegated stub. We know from the NdrStubForwardFunction test that (void**)pstub-1 is the base interface stub buffer. This shows that (void**)pstub-2 contains the address of a vtable that gets passed to the base interface's Connect method. Note that (void**)pstub-2 itself gets passed to Connect and not *((void**)pstub-2), so it should contain the vtable ptr and not an interface ptr. */ obj = (IUnknown*)&orig_vtbl; pstub = create_stub(ppsf, &IID_if2, obj, S_OK); *((void**)pstub-1) = &base_stub_buf_vtbl; *((void**)pstub-2) = (void*)0xbeefcafe; obj = (IUnknown*)&new_vtbl; r = IRpcStubBuffer_Connect(pstub, obj); ok(connect_test_base_Connect_called == 1, "connect_test_bsae_Connect called %d times\n", connect_test_base_Connect_called); ok(connect_test_orig_release_called == 3, "release called %d\n", connect_test_orig_release_called); cstd_stub = (CStdStubBuffer*)pstub; ok(cstd_stub->pvServerObject == (void*)0xcafebabe, "pvServerObject %p\n", cstd_stub->pvServerObject); }
static HRESULT WINAPI PSFacBuf_CreateStub( LPPSFACTORYBUFFER iface, REFIID riid,IUnknown *pUnkServer, IRpcStubBuffer** ppStub ) { HRESULT hres; TRACE("(%s,%p,%p)\n",debugstr_guid(riid),pUnkServer,ppStub); if (IsEqualIID(&IID_IClassFactory, riid) || IsEqualIID(&IID_IUnknown, riid) /* FIXME: fixup stub manager and remove this*/) { hres = CFStub_Construct(ppStub); if (!hres) IRpcStubBuffer_Connect((*ppStub),pUnkServer); return hres; } else if (IsEqualIID(&IID_IRemUnknown,riid)) { hres = RemUnkStub_Construct(ppStub); if (!hres) IRpcStubBuffer_Connect((*ppStub),pUnkServer); return hres; } FIXME("stubbing not implemented for (%s) yet!\n",debugstr_guid(riid)); return E_FAIL; }