sync rpcrt4 winetest with wine 1.1.26

svn path=/trunk/; revision=42482
This commit is contained in:
Christoph von Wittich 2009-08-07 21:02:55 +00:00
parent cf7b35520e
commit 3a66251576
9 changed files with 1466 additions and 695 deletions

View file

@ -48,7 +48,7 @@ static GUID IID_if4 = {0x1234567b, 1234, 5678, {12,34,56,78,90,0xab,0xcd,0xef}};
static int my_alloc_called;
static int my_free_called;
static void * CALLBACK my_alloc(size_t size)
static void * CALLBACK my_alloc(SIZE_T size)
{
my_alloc_called++;
return NdrOleAllocate(size);
@ -259,13 +259,14 @@ static CInterfaceStubVtbl if2_stub_vtbl =
{ CStdStubBuffer_DELEGATING_METHODS }
};
static CINTERFACE_PROXY_VTABLE(4) if3_proxy_vtbl =
static CINTERFACE_PROXY_VTABLE(5) if3_proxy_vtbl =
{
{ &IID_if3 },
{ IUnknown_QueryInterface_Proxy,
IUnknown_AddRef_Proxy,
IUnknown_Release_Proxy ,
if1_fn1_Proxy
if1_fn1_Proxy,
0
}
};
@ -298,7 +299,7 @@ static CInterfaceStubVtbl if3_stub_vtbl =
{
&IID_if3,
&if3_server_info,
4,
5,
&if1_table[-3]
},
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
@ -368,10 +369,10 @@ static const CInterfaceProxyVtbl *cstub_ProxyVtblList[] =
static const CInterfaceStubVtbl *cstub_StubVtblList[] =
{
(const CInterfaceStubVtbl *) &if1_stub_vtbl,
(const CInterfaceStubVtbl *) &if2_stub_vtbl,
(const CInterfaceStubVtbl *) &if3_stub_vtbl,
(const CInterfaceStubVtbl *) &if4_stub_vtbl,
&if1_stub_vtbl,
&if2_stub_vtbl,
&if3_stub_vtbl,
&if4_stub_vtbl,
NULL
};
@ -430,11 +431,16 @@ static const ProxyFileInfo *proxy_file_list[] = {
static IPSFactoryBuffer *test_NdrDllGetClassObject(void)
{
HMODULE rpcrt4 = GetModuleHandleA("rpcrt4.dll");
IPSFactoryBuffer *ppsf = NULL;
const PCInterfaceProxyVtblList* proxy_vtbl;
const PCInterfaceStubVtblList* stub_vtbl;
const CLSID PSDispatch = {0x20420, 0, 0, {0xc0, 0, 0, 0, 0, 0, 0, 0x46}};
const CLSID CLSID_Unknown = {0x45678, 0x1234, 0x6666, {0xff, 0x67, 0x45, 0x98, 0x76, 0x12, 0x34, 0x56}};
static const GUID * const interfaces[] = { &IID_if1, &IID_if2, &IID_if3, &IID_if4 };
UINT i;
HRESULT r;
HMODULE hmod = LoadLibraryA("rpcrt4.dll");
HMODULE hmod = GetModuleHandleA("rpcrt4.dll");
void *CStd_QueryInterface = GetProcAddress(hmod, "CStdStubBuffer_QueryInterface");
void *CStd_AddRef = GetProcAddress(hmod, "CStdStubBuffer_AddRef");
void *CStd_Release = GetProcAddress(hmod, "NdrCStdStubBuffer_Release");
@ -457,22 +463,26 @@ static IPSFactoryBuffer *test_NdrDllGetClassObject(void)
ok(r == S_OK, "ret %08x\n", r);
ok(ppsf != NULL, "ppsf == NULL\n");
proxy_vtbl = PSFactoryBuffer.pProxyFileList[0]->pProxyVtblList;
stub_vtbl = PSFactoryBuffer.pProxyFileList[0]->pStubVtblList;
ok(PSFactoryBuffer.pProxyFileList == proxy_file_list, "pfl not the same\n");
ok(PSFactoryBuffer.pProxyFileList[0]->pStubVtblList == (PCInterfaceStubVtblList *) &cstub_StubVtblList, "stub vtbllist not the same\n");
ok(proxy_vtbl == (PCInterfaceProxyVtblList *) &cstub_ProxyVtblList, "proxy vtbllist not the same\n");
ok(stub_vtbl == (PCInterfaceStubVtblList *) &cstub_StubVtblList, "stub vtbllist not the same\n");
/* if1 is non-delegating, if2 is delegating, if3 is non-delegating
but I've zero'ed the vtbl entries, similarly if4 is delegating
with zero'ed vtbl entries */
#define VTBL_TEST_NOT_CHANGE_TO(name, i) \
ok(PSFactoryBuffer.pProxyFileList[0]->pStubVtblList[i]->Vtbl.name != CStd_##name, #name "vtbl %d updated %p %p\n", \
i, PSFactoryBuffer.pProxyFileList[0]->pStubVtblList[i]->Vtbl.name, CStd_##name );
ok(stub_vtbl[i]->Vtbl.name != CStd_##name, #name "vtbl %d updated %p %p\n", \
i, stub_vtbl[i]->Vtbl.name, CStd_##name )
#define VTBL_TEST_CHANGE_TO(name, i) \
ok(PSFactoryBuffer.pProxyFileList[0]->pStubVtblList[i]->Vtbl.name == CStd_##name, #name "vtbl %d not updated %p %p\n", \
i, PSFactoryBuffer.pProxyFileList[0]->pStubVtblList[i]->Vtbl.name, CStd_##name );
ok(stub_vtbl[i]->Vtbl.name == CStd_##name, #name "vtbl %d not updated %p %p\n", \
i, stub_vtbl[i]->Vtbl.name, CStd_##name )
#define VTBL_TEST_ZERO(name, i) \
ok(PSFactoryBuffer.pProxyFileList[0]->pStubVtblList[i]->Vtbl.name == NULL, #name "vtbl %d not null %p\n", \
i, PSFactoryBuffer.pProxyFileList[0]->pStubVtblList[i]->Vtbl.name );
ok(stub_vtbl[i]->Vtbl.name == NULL, #name "vtbl %d not null %p\n", \
i, stub_vtbl[i]->Vtbl.name )
VTBL_TEST_NOT_CHANGE_TO(QueryInterface, 0);
VTBL_TEST_NOT_CHANGE_TO(AddRef, 0);
VTBL_TEST_NOT_CHANGE_TO(Release, 0);
@ -517,11 +527,55 @@ static IPSFactoryBuffer *test_NdrDllGetClassObject(void)
VTBL_TEST_CHANGE_TO(DebugServerQueryInterface, 3);
VTBL_TEST_CHANGE_TO(DebugServerRelease, 3);
#define VTBL_PROXY_TEST(i,num,ptr) \
ok( proxy_vtbl[i]->Vtbl[num] == (ptr), "wrong proxy %u func %u %p/%p\n", \
(i), (num), proxy_vtbl[i]->Vtbl[num], (ptr) )
#define VTBL_PROXY_TEST_NOT_ZERO(i,num) \
ok( proxy_vtbl[i]->Vtbl[num] != NULL, "wrong proxy %u func %u is NULL\n", (i), (num))
VTBL_PROXY_TEST(0, 0, IUnknown_QueryInterface_Proxy);
VTBL_PROXY_TEST(0, 1, IUnknown_AddRef_Proxy);
VTBL_PROXY_TEST(0, 2, IUnknown_Release_Proxy);
VTBL_PROXY_TEST(0, 3, if1_fn1_Proxy);
VTBL_PROXY_TEST(0, 4, if1_fn2_Proxy);
VTBL_PROXY_TEST(1, 0, GetProcAddress(rpcrt4,"IUnknown_QueryInterface_Proxy"));
VTBL_PROXY_TEST(1, 1, GetProcAddress(rpcrt4,"IUnknown_AddRef_Proxy"));
VTBL_PROXY_TEST(1, 2, GetProcAddress(rpcrt4,"IUnknown_Release_Proxy"));
VTBL_PROXY_TEST_NOT_ZERO(1, 3);
VTBL_PROXY_TEST_NOT_ZERO(1, 4);
VTBL_PROXY_TEST_NOT_ZERO(1, 5);
VTBL_PROXY_TEST_NOT_ZERO(1, 6);
VTBL_PROXY_TEST_NOT_ZERO(1, 7);
VTBL_PROXY_TEST_NOT_ZERO(1, 8);
VTBL_PROXY_TEST_NOT_ZERO(1, 9);
VTBL_PROXY_TEST_NOT_ZERO(1, 10);
VTBL_PROXY_TEST_NOT_ZERO(1, 11);
VTBL_PROXY_TEST_NOT_ZERO(1, 12);
VTBL_PROXY_TEST(2, 0, IUnknown_QueryInterface_Proxy);
VTBL_PROXY_TEST(2, 1, IUnknown_AddRef_Proxy);
VTBL_PROXY_TEST(2, 2, IUnknown_Release_Proxy);
VTBL_PROXY_TEST(2, 3, if1_fn1_Proxy);
todo_wine VTBL_PROXY_TEST_NOT_ZERO(2, 4);
VTBL_PROXY_TEST(3, 0, GetProcAddress(rpcrt4,"IUnknown_QueryInterface_Proxy"));
VTBL_PROXY_TEST(3, 1, GetProcAddress(rpcrt4,"IUnknown_AddRef_Proxy"));
VTBL_PROXY_TEST(3, 2, GetProcAddress(rpcrt4,"IUnknown_Release_Proxy"));
VTBL_PROXY_TEST_NOT_ZERO(3, 3);
VTBL_PROXY_TEST_NOT_ZERO(3, 4);
VTBL_PROXY_TEST_NOT_ZERO(3, 5);
VTBL_PROXY_TEST_NOT_ZERO(3, 6);
#undef VTBL_TEST_NOT_CHANGE_TO
#undef VTBL_TEST_CHANGE_TO
#undef VTBL_TEST_ZERO
#undef VTBL_PROXY_TEST
#undef VTBL_PROXY_TEST_NOT_ZERO
for (i = 0; i < sizeof(interfaces)/sizeof(interfaces[0]); i++)
ok( proxy_vtbl[i]->header.piid == interfaces[i],
"wrong proxy %u iid %p/%p\n", i, proxy_vtbl[i]->header.piid, interfaces[i] );
ok(PSFactoryBuffer.RefCount == 1, "ref count %d\n", PSFactoryBuffer.RefCount);
IPSFactoryBuffer_Release(ppsf);
@ -613,19 +667,87 @@ static IUnknownVtbl create_stub_test_fail_vtbl =
NULL
};
struct dummy_unknown
{
const IUnknownVtbl *vtbl;
LONG ref;
};
static HRESULT WINAPI dummy_QueryInterface(IUnknown *This, REFIID iid, void **ppv)
{
*ppv = NULL;
return E_NOINTERFACE;
}
static ULONG WINAPI dummy_AddRef(LPUNKNOWN iface)
{
struct dummy_unknown *this = (struct dummy_unknown *)iface;
return InterlockedIncrement( &this->ref );
}
static ULONG WINAPI dummy_Release(LPUNKNOWN iface)
{
struct dummy_unknown *this = (struct dummy_unknown *)iface;
return InterlockedDecrement( &this->ref );
}
static IUnknownVtbl dummy_unknown_vtbl =
{
dummy_QueryInterface,
dummy_AddRef,
dummy_Release
};
static struct dummy_unknown dummy_unknown = { &dummy_unknown_vtbl, 0 };
static void create_proxy_test( IPSFactoryBuffer *ppsf, REFIID iid, const void *expected_vtbl )
{
IRpcProxyBuffer *proxy = NULL;
IUnknown *iface = NULL;
HRESULT r;
ULONG count;
r = IPSFactoryBuffer_CreateProxy(ppsf, NULL, iid, &proxy, (void **)&iface);
ok( r == S_OK, "IPSFactoryBuffer_CreateProxy failed %x\n", r );
ok( *(void **)iface == expected_vtbl, "wrong iface pointer %p/%p\n", *(void **)iface, expected_vtbl );
count = IUnknown_Release( iface );
ok( count == 1, "wrong refcount %u\n", count );
count = IRpcProxyBuffer_Release( proxy );
ok( count == 0, "wrong refcount %u\n", count );
dummy_unknown.ref = 4;
r = IPSFactoryBuffer_CreateProxy(ppsf, (IUnknown *)&dummy_unknown, iid, &proxy, (void **)&iface);
ok( r == S_OK, "IPSFactoryBuffer_CreateProxy failed %x\n", r );
ok( dummy_unknown.ref == 5, "wrong refcount %u\n", dummy_unknown.ref );
ok( *(void **)iface == expected_vtbl, "wrong iface pointer %p/%p\n", *(void **)iface, expected_vtbl );
count = IUnknown_Release( iface );
ok( count == 4, "wrong refcount %u\n", count );
ok( dummy_unknown.ref == 4, "wrong refcount %u\n", dummy_unknown.ref );
count = IRpcProxyBuffer_Release( proxy );
ok( count == 0, "wrong refcount %u\n", count );
ok( dummy_unknown.ref == 4, "wrong refcount %u\n", dummy_unknown.ref );
}
static void test_CreateProxy( IPSFactoryBuffer *ppsf )
{
create_proxy_test( ppsf, &IID_if1, if1_proxy_vtbl.Vtbl );
create_proxy_test( ppsf, &IID_if2, if2_proxy_vtbl.Vtbl );
create_proxy_test( ppsf, &IID_if3, if3_proxy_vtbl.Vtbl );
create_proxy_test( ppsf, &IID_if4, if4_proxy_vtbl.Vtbl );
}
static void test_CreateStub(IPSFactoryBuffer *ppsf)
{
IUnknownVtbl *vtbl = &create_stub_test_vtbl;
IUnknown *obj = (IUnknown*)&vtbl;
IRpcStubBuffer *pstub = create_stub(ppsf, &IID_if1, obj, S_OK);
CStdStubBuffer *cstd_stub = (CStdStubBuffer*)pstub;
const CInterfaceStubHeader *header = ((const CInterfaceStubHeader *)cstd_stub->lpVtbl) - 1;
const CInterfaceStubHeader *header = &CONTAINING_RECORD(cstd_stub->lpVtbl, const CInterfaceStubVtbl, Vtbl)->header;
ok(IsEqualIID(header->piid, &IID_if1), "header iid differs\n");
ok(cstd_stub->RefCount == 1, "ref count %d\n", cstd_stub->RefCount);
/* 0xdeadbeef returned from create_stub_test_QI */
ok(cstd_stub->pvServerObject == (void*)0xdeadbeef, "pvServerObject %p\n", cstd_stub->pvServerObject);
ok(cstd_stub->pPSFactory == ppsf, "pPSFactory %p\n", cstd_stub->pPSFactory);
ok(cstd_stub->pPSFactory != NULL, "pPSFactory was NULL\n");
vtbl = &create_stub_test_fail_vtbl;
pstub = create_stub(ppsf, &IID_if1, obj, E_NOINTERFACE);
@ -951,6 +1073,7 @@ START_TEST( cstub )
ppsf = test_NdrDllGetClassObject();
test_NdrStubForwardingFunction();
test_CreateProxy(ppsf);
test_CreateStub(ppsf);
test_Connect(ppsf);
test_Disconnect(ppsf);

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -225,67 +225,68 @@ static void test_rpc_ncacn_ip_tcp(void)
status = RpcMgmtStopServerListening(NULL);
todo_wine {
ok(status == RPC_S_NOT_LISTENING,
"wrong RpcMgmtStopServerListening error (%lu)\n", status);
"wrong RpcMgmtStopServerListening error (%u)\n", status);
}
status = RpcMgmtWaitServerListen();
ok(status == RPC_S_NOT_LISTENING,
"wrong RpcMgmtWaitServerListen error status (%lu)\n", status);
"wrong RpcMgmtWaitServerListen error status (%u)\n", status);
status = RpcServerListen(1, 20, FALSE);
ok(status == RPC_S_NO_PROTSEQS_REGISTERED,
"wrong RpcServerListen error (%lu)\n", status);
"wrong RpcServerListen error (%u)\n", status);
status = RpcServerUseProtseqEp(ncacn_ip_tcp, 20, endpoint, NULL);
ok(status == RPC_S_OK, "RpcServerUseProtseqEp failed (%lu)\n", status);
ok(status == RPC_S_OK, "RpcServerUseProtseqEp failed (%u)\n", status);
status = RpcServerRegisterIf(IFoo_v0_0_s_ifspec, NULL, NULL);
ok(status == RPC_S_OK, "RpcServerRegisterIf failed (%lu)\n", status);
ok(status == RPC_S_OK, "RpcServerRegisterIf failed (%u)\n", status);
status = RpcServerListen(1, 20, TRUE);
todo_wine {
ok(status == RPC_S_OK, "RpcServerListen failed (%lu)\n", status);
ok(status == RPC_S_OK, "RpcServerListen failed (%u)\n", status);
}
status = RpcServerListen(1, 20, TRUE);
todo_wine {
ok(status == RPC_S_ALREADY_LISTENING,
"wrong RpcServerListen error (%lu)\n", status);
"wrong RpcServerListen error (%u)\n", status);
}
status = RpcStringBindingCompose(NULL, ncacn_ip_tcp, address,
endpoint, NULL, &binding);
ok(status == RPC_S_OK, "RpcStringBindingCompose failed (%lu)\n", status);
ok(status == RPC_S_OK, "RpcStringBindingCompose failed (%u)\n", status);
status = RpcBindingFromStringBinding(binding, &IFoo_IfHandle);
ok(status == RPC_S_OK, "RpcBindingFromStringBinding failed (%lu)\n",
ok(status == RPC_S_OK, "RpcBindingFromStringBinding failed (%u)\n",
status);
status = RpcBindingSetAuthInfo(IFoo_IfHandle, NULL, RPC_C_AUTHN_LEVEL_NONE,
RPC_C_AUTHN_WINNT, NULL, RPC_C_AUTHZ_NAME);
ok(status == RPC_S_OK, "RpcBindingSetAuthInfo failed (%lu)\n", status);
ok(status == RPC_S_OK || broken(status == RPC_S_UNKNOWN_AUTHN_SERVICE), /* win9x */
"RpcBindingSetAuthInfo failed (%u)\n", status);
status = RpcMgmtStopServerListening(NULL);
ok(status == RPC_S_OK, "RpcMgmtStopServerListening failed (%lu)\n",
ok(status == RPC_S_OK, "RpcMgmtStopServerListening failed (%u)\n",
status);
status = RpcMgmtStopServerListening(NULL);
ok(status == RPC_S_OK, "RpcMgmtStopServerListening failed (%lu)\n",
ok(status == RPC_S_OK, "RpcMgmtStopServerListening failed (%u)\n",
status);
status = RpcServerUnregisterIf(NULL, NULL, FALSE);
ok(status == RPC_S_OK, "RpcServerUnregisterIf failed (%lu)\n", status);
ok(status == RPC_S_OK, "RpcServerUnregisterIf failed (%u)\n", status);
status = RpcMgmtWaitServerListen();
todo_wine {
ok(status == RPC_S_OK, "RpcMgmtWaitServerListen failed (%lu)\n", status);
ok(status == RPC_S_OK, "RpcMgmtWaitServerListen failed (%u)\n", status);
}
status = RpcStringFree(&binding);
ok(status == RPC_S_OK, "RpcStringFree failed (%lu)\n", status);
ok(status == RPC_S_OK, "RpcStringFree failed (%u)\n", status);
status = RpcBindingFree(&IFoo_IfHandle);
ok(status == RPC_S_OK, "RpcBindingFree failed (%lu)\n", status);
ok(status == RPC_S_OK, "RpcBindingFree failed (%u)\n", status);
}
/* this is what's generated with MS/RPC - it includes an extra 2
@ -331,11 +332,11 @@ static void test_towers(void)
ret = TowerConstruct(&mapi_if_id, &ndr_syntax, "ncacn_ip_tcp", "135", "10.0.0.1", &tower);
ok(ret == RPC_S_OK ||
broken(ret == RPC_S_INVALID_RPC_PROTSEQ), /* Vista */
"TowerConstruct failed with error %ld\n", ret);
"TowerConstruct failed with error %d\n", ret);
if (ret == RPC_S_INVALID_RPC_PROTSEQ)
{
/* Windows Vista fails with this error and crashes if we continue */
skip("TowerConstruct failed, we are most likely on Windows Vista\n");
win_skip("TowerConstruct failed, we are most likely on Windows Vista\n");
return;
}
@ -364,7 +365,7 @@ static void test_towers(void)
}
ret = TowerExplode(tower, &object, &syntax, &protseq, &endpoint, &address);
ok(ret == RPC_S_OK, "TowerExplode failed with error %ld\n", ret);
ok(ret == RPC_S_OK, "TowerExplode failed with error %d\n", ret);
ok(!memcmp(&object, &mapi_if_id, sizeof(mapi_if_id)), "object id didn't match\n");
ok(!memcmp(&syntax, &ndr_syntax, sizeof(syntax)), "syntax id didn't match\n");
ok(!strcmp(protseq, "ncacn_ip_tcp"), "protseq was \"%s\" instead of \"ncacn_ip_tcp\"\n", protseq);
@ -376,15 +377,15 @@ static void test_towers(void)
I_RpcFree(address);
ret = TowerExplode(tower, NULL, NULL, NULL, NULL, NULL);
ok(ret == RPC_S_OK, "TowerExplode failed with error %ld\n", ret);
ok(ret == RPC_S_OK, "TowerExplode failed with error %d\n", ret);
I_RpcFree(tower);
/* test the behaviour for ip_tcp with name instead of dotted IP notation */
ret = TowerConstruct(&mapi_if_id, &ndr_syntax, "ncacn_ip_tcp", "135", "localhost", &tower);
ok(ret == RPC_S_OK, "TowerConstruct failed with error %ld\n", ret);
ok(ret == RPC_S_OK, "TowerConstruct failed with error %d\n", ret);
ret = TowerExplode(tower, NULL, NULL, NULL, NULL, &address);
ok(ret == RPC_S_OK, "TowerExplode failed with error %ld\n", ret);
ok(ret == RPC_S_OK, "TowerExplode failed with error %d\n", ret);
ok(!strcmp(address, "0.0.0.0") ||
broken(!strcmp(address, "255.255.255.255")),
"address was \"%s\" instead of \"0.0.0.0\"\n", address);
@ -394,13 +395,13 @@ static void test_towers(void)
/* test the behaviour for np with no address */
ret = TowerConstruct(&mapi_if_id, &ndr_syntax, "ncacn_np", "\\pipe\\test", NULL, &tower);
ok(ret == RPC_S_OK, "TowerConstruct failed with error %ld\n", ret);
ok(ret == RPC_S_OK, "TowerConstruct failed with error %d\n", ret);
ret = TowerExplode(tower, NULL, NULL, NULL, NULL, &address);
ok(ret == RPC_S_OK ||
broken(ret != RPC_S_OK), /* win2k, indeterminate */
"TowerExplode failed with error %ld\n", ret);
"TowerExplode failed with error %d\n", ret);
/* Windows XP SP3 sets address to NULL */
ok(!address || !strcmp(address, ""), "address was \"%s\" instead of \"\"\n or NULL (XP SP3)", address);
ok(!address || !strcmp(address, ""), "address was \"%s\" instead of \"\" or NULL (XP SP3)\n", address);
I_RpcFree(address);
I_RpcFree(tower);
@ -556,7 +557,7 @@ static void test_I_RpcMapWin32Status(void)
ok(win32status == expected_win32status ||
broken(missing && win32status == rpc_status),
"I_RpcMapWin32Status(%ld) should have returned 0x%x instead of 0x%x%s\n",
"I_RpcMapWin32Status(%d) should have returned 0x%x instead of 0x%x%s\n",
rpc_status, expected_win32status, win32status,
broken(missing) ? " (or have returned with the given status)" : "");
}
@ -578,7 +579,7 @@ static void test_RpcStringBindingParseA(void)
/* test all parameters */
status = RpcStringBindingParseA(valid_binding, &uuid, &protseq, &network_addr, &endpoint, &options);
ok(status == RPC_S_OK, "RpcStringBindingParseA failed with error %ld\n", status);
ok(status == RPC_S_OK, "RpcStringBindingParseA failed with error %d\n", status);
ok(!strcmp((char *)uuid, "00000000-0000-0000-c000-000000000046"), "uuid should have been 00000000-0000-0000-C000-000000000046 instead of %s\n", uuid);
ok(!strcmp((char *)protseq, "ncacn_np"), "protseq should have been ncacn_np instead of %s\n", protseq);
ok(!strcmp((char *)network_addr, "."), "network_addr should have been . instead of %s\n", network_addr);
@ -593,7 +594,7 @@ static void test_RpcStringBindingParseA(void)
/* test all parameters with different type of string binding */
status = RpcStringBindingParseA(valid_binding2, &uuid, &protseq, &network_addr, &endpoint, &options);
ok(status == RPC_S_OK, "RpcStringBindingParseA failed with error %ld\n", status);
ok(status == RPC_S_OK, "RpcStringBindingParseA failed with error %d\n", status);
ok(!strcmp((char *)uuid, "00000000-0000-0000-c000-000000000046"), "uuid should have been 00000000-0000-0000-C000-000000000046 instead of %s\n", uuid);
ok(!strcmp((char *)protseq, "ncacn_np"), "protseq should have been ncacn_np instead of %s\n", protseq);
ok(!strcmp((char *)network_addr, "."), "network_addr should have been . instead of %s\n", network_addr);
@ -608,24 +609,24 @@ static void test_RpcStringBindingParseA(void)
/* test with as many parameters NULL as possible */
status = RpcStringBindingParseA(valid_binding, NULL, &protseq, NULL, NULL, NULL);
ok(status == RPC_S_OK, "RpcStringBindingParseA failed with error %ld\n", status);
ok(status == RPC_S_OK, "RpcStringBindingParseA failed with error %d\n", status);
ok(!strcmp((char *)protseq, "ncacn_np"), "protseq should have been ncacn_np instead of %s\n", protseq);
RpcStringFreeA(&protseq);
/* test with invalid uuid */
status = RpcStringBindingParseA(invalid_uuid_binding, NULL, &protseq, NULL, NULL, NULL);
ok(status == RPC_S_INVALID_STRING_UUID, "RpcStringBindingParseA should have returned RPC_S_INVALID_STRING_UUID instead of %ld\n", status);
ok(status == RPC_S_INVALID_STRING_UUID, "RpcStringBindingParseA should have returned RPC_S_INVALID_STRING_UUID instead of %d\n", status);
ok(protseq == NULL, "protseq was %p instead of NULL\n", protseq);
/* test with invalid endpoint */
status = RpcStringBindingParseA(invalid_ep_binding, NULL, &protseq, NULL, NULL, NULL);
ok(status == RPC_S_OK, "RpcStringBindingParseA failed with error %ld\n", status);
ok(status == RPC_S_OK, "RpcStringBindingParseA failed with error %d\n", status);
RpcStringFreeA(&protseq);
/* test with invalid binding */
status = RpcStringBindingParseA(invalid_binding, &uuid, &protseq, &network_addr, &endpoint, &options);
todo_wine
ok(status == RPC_S_INVALID_STRING_BINDING, "RpcStringBindingParseA should have returned RPC_S_INVALID_STRING_BINDING instead of %ld\n", status);
ok(status == RPC_S_INVALID_STRING_BINDING, "RpcStringBindingParseA should have returned RPC_S_INVALID_STRING_BINDING instead of %d\n", status);
todo_wine
ok(uuid == NULL, "uuid was %p instead of NULL\n", uuid);
ok(protseq == NULL, "protseq was %p instead of NULL\n", protseq);
@ -680,60 +681,6 @@ static void test_I_RpcExceptionFilter(void)
}
}
static void test_endpoint_mapper(RPC_CSTR protseq, RPC_CSTR address,
RPC_CSTR endpoint)
{
static unsigned char annotation[] = "Test annotation string.";
RPC_STATUS status;
RPC_BINDING_VECTOR *binding_vector;
handle_t handle;
unsigned char *binding;
status = RpcServerUseProtseqEp(protseq, 20, endpoint, NULL);
ok(status == RPC_S_OK, "%s: RpcServerUseProtseqEp failed (%lu)\n", protseq, status);
status = RpcServerRegisterIf(IFoo_v0_0_s_ifspec, NULL, NULL);
ok(status == RPC_S_OK, "%s: RpcServerRegisterIf failed (%lu)\n", protseq, status);
status = RpcServerInqBindings(&binding_vector);
ok(status == RPC_S_OK, "%s: RpcServerInqBindings failed with error %lu\n", protseq, status);
status = RpcEpRegisterA(IFoo_v0_0_s_ifspec, binding_vector, NULL, annotation);
ok(status == RPC_S_OK, "%s: RpcEpRegisterA failed with error %lu\n", protseq, status);
status = RpcStringBindingCompose(NULL, protseq, address,
NULL, NULL, &binding);
ok(status == RPC_S_OK, "%s: RpcStringBindingCompose failed (%lu)\n", protseq, status);
status = RpcBindingFromStringBinding(binding, &handle);
ok(status == RPC_S_OK, "%s: RpcBindingFromStringBinding failed (%lu)\n", protseq, status);
RpcStringFree(&binding);
status = RpcBindingReset(handle);
ok(status == RPC_S_OK, "%s: RpcBindingReset failed with error %lu\n", protseq, status);
RpcStringFree(&binding);
status = RpcEpResolveBinding(handle, IFoo_v0_0_s_ifspec);
ok(status == RPC_S_OK, "%s: RpcEpResolveBinding failed with error %lu\n", protseq, status);
status = RpcBindingReset(handle);
ok(status == RPC_S_OK, "%s: RpcBindingReset failed with error %lu\n", protseq, status);
status = RpcBindingFree(&handle);
ok(status == RPC_S_OK, "%s: RpcBindingFree failed with error %lu\n", protseq, status);
status = RpcServerUnregisterIf(NULL, NULL, FALSE);
ok(status == RPC_S_OK, "%s: RpcServerUnregisterIf failed (%lu)\n", protseq, status);
status = RpcEpUnregister(IFoo_v0_0_s_ifspec, binding_vector, NULL);
ok(status == RPC_S_OK, "%s: RpcEpUnregisterA failed with error %lu\n", protseq, status);
status = RpcBindingVectorFree(&binding_vector);
ok(status == RPC_S_OK, "%s: RpcBindingVectorFree failed with error %lu\n", protseq, status);
}
static void test_RpcStringBindingFromBinding(void)
{
static unsigned char ncacn_np[] = "ncacn_np";
@ -745,26 +692,26 @@ static void test_RpcStringBindingFromBinding(void)
status = RpcStringBindingCompose(NULL, ncacn_np, address,
endpoint, NULL, &binding);
ok(status == RPC_S_OK, "RpcStringBindingCompose failed (%lu)\n", status);
ok(status == RPC_S_OK, "RpcStringBindingCompose failed (%u)\n", status);
status = RpcBindingFromStringBinding(binding, &handle);
ok(status == RPC_S_OK, "RpcBindingFromStringBinding failed (%lu)\n", status);
ok(status == RPC_S_OK, "RpcBindingFromStringBinding failed (%u)\n", status);
RpcStringFree(&binding);
status = RpcBindingToStringBinding(handle, &binding);
ok(status == RPC_S_OK, "RpcStringBindingFromBinding failed with error %lu\n", status);
ok(status == RPC_S_OK, "RpcStringBindingFromBinding failed with error %u\n", status);
ok(!strcmp((const char *)binding, "ncacn_np:.[\\\\pipe\\\\wine_rpc_test]"),
"binding string didn't match what was expected: \"%s\"\n", binding);
RpcStringFree(&binding);
status = RpcBindingFree(&handle);
ok(status == RPC_S_OK, "RpcBindingFree failed with error %lu\n", status);
ok(status == RPC_S_OK, "RpcBindingFree failed with error %u\n", status);
}
static char *printGuid(char *buf, const UUID *guid)
static char *printGuid(char *buf, int size, const UUID *guid)
{
sprintf(buf, "{%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}\n",
snprintf(buf, size, "{%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}",
guid->Data1, guid->Data2, guid->Data3, guid->Data4[0], guid->Data4[1],
guid->Data4[2], guid->Data4[3], guid->Data4[4], guid->Data4[5],
guid->Data4[6], guid->Data4[7]);
@ -778,7 +725,6 @@ static void test_UuidCreate(void)
UuidCreate(&guid);
version = (guid.Data3 & 0xf000) >> 12;
todo_wine
ok(version == 4 || broken(version == 1), "unexpected version %d\n",
version);
if (version == 4)
@ -791,8 +737,8 @@ static void test_UuidCreate(void)
int i;
char buf[39];
memcpy(&and, &guid, sizeof(guid));
memcpy(&or, &guid, sizeof(guid));
and = guid;
or = guid;
/* Generate a bunch of UUIDs and mask them. By the end, we expect
* every randomly generated bit to have been zero at least once,
* resulting in no bits set in the and mask except those which are not
@ -813,9 +759,9 @@ static void test_UuidCreate(void)
*dst |= *src;
}
ok(UuidEqual(&and, &v4and, &rslt),
"unexpected bits set in V4 UUID: %s\n", printGuid(buf, &and));
"unexpected bits set in V4 UUID: %s\n", printGuid(buf, sizeof(buf), &and));
ok(UuidEqual(&or, &v4or, &rslt),
"unexpected bits set in V4 UUID: %s\n", printGuid(buf, &or));
"unexpected bits set in V4 UUID: %s\n", printGuid(buf, sizeof(buf), &or));
}
else
{
@ -824,7 +770,6 @@ static void test_UuidCreate(void)
* present. Just check that Data4[0]'s most significant bits are
* set as expected.
*/
todo_wine
ok((guid.Data4[0] & 0xc0) == 0x80,
"unexpected value in Data4[0]: %02x\n", guid.Data4[0] & 0xc0);
}
@ -832,12 +777,6 @@ static void test_UuidCreate(void)
START_TEST( rpc )
{
static unsigned char ncacn_np[] = "ncacn_np";
static unsigned char ncalrpc[] = "ncalrpc";
static unsigned char np_address[] = ".";
static unsigned char np_endpoint[] = "\\pipe\\wine_rpc_test";
static unsigned char lrpc_endpoint[] = "wine_rpc_test";
UuidConversionAndComparison();
TestDceErrorInqText();
test_rpc_ncacn_ip_tcp();
@ -845,8 +784,6 @@ START_TEST( rpc )
test_I_RpcMapWin32Status();
test_RpcStringBindingParseA();
test_I_RpcExceptionFilter();
test_endpoint_mapper(ncacn_np, np_address, np_endpoint);
test_endpoint_mapper(ncalrpc, NULL, lrpc_endpoint);
test_RpcStringBindingFromBinding();
test_UuidCreate();
}

View file

@ -34,23 +34,25 @@ static void test_RpcAsyncInitializeHandle(void)
RPC_ASYNC_STATE async;
RPC_STATUS status;
int i;
void *unset_ptr;
status = pRpcAsyncInitializeHandle((PRPC_ASYNC_STATE)buffer, sizeof(buffer));
ok(status == ERROR_INVALID_PARAMETER, "RpcAsyncInitializeHandle with large Size should have returned ERROR_INVALID_PARAMETER instead of %ld\n", status);
ok(status == ERROR_INVALID_PARAMETER, "RpcAsyncInitializeHandle with large Size should have returned ERROR_INVALID_PARAMETER instead of %d\n", status);
status = pRpcAsyncInitializeHandle(&async, sizeof(async) - 1);
ok(status == ERROR_INVALID_PARAMETER, "RpcAsyncInitializeHandle with small Size should have returned ERROR_INVALID_PARAMETER instead of %ld\n", status);
ok(status == ERROR_INVALID_PARAMETER, "RpcAsyncInitializeHandle with small Size should have returned ERROR_INVALID_PARAMETER instead of %d\n", status);
memset(&async, 0xcc, sizeof(async));
memset(&unset_ptr, 0xcc, sizeof(unset_ptr));
status = pRpcAsyncInitializeHandle(&async, sizeof(async));
ok(status == RPC_S_OK, "RpcAsyncInitializeHandle failed with error %ld\n", status);
ok(status == RPC_S_OK, "RpcAsyncInitializeHandle failed with error %d\n", status);
ok(async.Size == sizeof(async), "async.Size wrong: %d\n", async.Size);
ok(async.Signature == 0x43595341, "async.Signature should be 0x43595341, but is 0x%x instead\n", async.Signature);
ok(async.Lock == 0, "async.Lock should be 0, but is %d instead\n", async.Lock);
ok(async.Flags == 0, "async.Flags should be 0, but is %d instead\n", async.Flags);
ok(async.StubInfo == NULL, "async.StubInfo should be NULL, not %p\n", async.StubInfo);
ok(async.UserInfo == (void *)0xcccccccc, "async.UserInfo should be unset, not %p\n", async.UserInfo);
ok(async.UserInfo == unset_ptr, "async.UserInfo should be unset, not %p\n", async.UserInfo);
ok(async.RuntimeInfo == NULL, "async.RuntimeInfo should be NULL, not %p\n", async.RuntimeInfo);
ok(async.Event == 0xcccccccc, "async.Event should be unset, not %d\n", async.Event);
ok(async.NotificationType == 0xcccccccc, "async.NotificationType should be unset, not %d\n", async.NotificationType);
@ -64,16 +66,16 @@ static void test_RpcAsyncGetCallStatus(void)
RPC_STATUS status;
status = pRpcAsyncInitializeHandle(&async, sizeof(async));
ok(status == RPC_S_OK, "RpcAsyncInitializeHandle failed with error %ld\n", status);
ok(status == RPC_S_OK, "RpcAsyncInitializeHandle failed with error %d\n", status);
status = pRpcAsyncGetCallStatus(&async);
todo_wine
ok(status == RPC_S_INVALID_BINDING, "RpcAsyncGetCallStatus should have returned RPC_S_INVALID_BINDING instead of %ld\n", status);
ok(status == RPC_S_INVALID_BINDING, "RpcAsyncGetCallStatus should have returned RPC_S_INVALID_BINDING instead of %d\n", status);
memset(&async, 0, sizeof(async));
status = pRpcAsyncGetCallStatus(&async);
todo_wine
ok(status == RPC_S_INVALID_BINDING, "RpcAsyncGetCallStatus should have returned RPC_S_INVALID_BINDING instead of %ld\n", status);
ok(status == RPC_S_INVALID_BINDING, "RpcAsyncGetCallStatus should have returned RPC_S_INVALID_BINDING instead of %d\n", status);
}
START_TEST( rpc_async )
@ -83,7 +85,7 @@ START_TEST( rpc_async )
pRpcAsyncGetCallStatus = (void *)GetProcAddress(hRpcRt4, "RpcAsyncGetCallStatus");
if (!pRpcAsyncInitializeHandle || !pRpcAsyncGetCallStatus)
{
skip("asynchronous functions not available\n");
win_skip("asynchronous functions not available\n");
return;
}
test_RpcAsyncInitializeHandle();

View file

@ -0,0 +1,204 @@
/*
* RPC Protocol Sequence Server Tests
*
* Copyright 2008-2009 Robert Shearman
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <stdarg.h>
#include <stdio.h>
#include "wine/test.h"
#include <windef.h>
#include <winbase.h>
#include <winnt.h>
#include <winerror.h>
#include "rpc.h"
#include "rpcdce.h"
static void test_RpcServerUseProtseq(void)
{
RPC_STATUS status;
RPC_BINDING_VECTOR *bindings;
ULONG i;
ULONG binding_count_before;
ULONG binding_count_after1;
ULONG binding_count_after2;
ULONG endpoints_registered = 0;
static unsigned char iptcp[] = "ncacn_ip_tcp";
static unsigned char np[] = "ncacn_np";
static unsigned char ncalrpc[] = "ncalrpc";
status = RpcServerInqBindings(&bindings);
if (status == RPC_S_NO_BINDINGS)
binding_count_before = 0;
else
{
binding_count_before = bindings->Count;
ok(status == RPC_S_OK, "RpcServerInqBindings failed with status %d\n", status);
RpcBindingVectorFree(&bindings);
}
/* show that RpcServerUseProtseqEp(..., NULL, ...) is the same as
* RpcServerUseProtseq(...) */
status = RpcServerUseProtseqEp(ncalrpc, 0, NULL, NULL);
ok(status == RPC_S_OK || broken(status == RPC_S_INVALID_ENDPOINT_FORMAT),
"RpcServerUseProtseqEp with NULL endpoint failed with status %d\n",
status);
/* register protocol sequences without explicit endpoints */
status = RpcServerUseProtseq(np, 0, NULL);
if (status == RPC_S_PROTSEQ_NOT_SUPPORTED)
win_skip("ncacn_np not supported\n");
else
ok(status == RPC_S_OK, "RpcServerUseProtseq(ncacn_np) failed with status %d\n", status);
if (status == RPC_S_OK) endpoints_registered++;
status = RpcServerUseProtseq(iptcp, 0, NULL);
ok(status == RPC_S_OK, "RpcServerUseProtseq(ncacn_ip_tcp) failed with status %d\n", status);
if (status == RPC_S_OK) endpoints_registered++;
status = RpcServerUseProtseq(ncalrpc, 0, NULL);
ok(status == RPC_S_OK, "RpcServerUseProtseqEp(ncalrpc) failed with status %d\n", status);
if (status == RPC_S_OK) endpoints_registered++;
status = RpcServerInqBindings(&bindings);
ok(status == RPC_S_OK, "RpcServerInqBindings failed with status %d\n", status);
binding_count_after1 = bindings->Count;
ok(binding_count_after1 == binding_count_before + endpoints_registered,
"wrong binding count - before: %u, after %u, endpoints registered %u\n",
binding_count_before, binding_count_after1, endpoints_registered);
for (i = 0; i < bindings->Count; i++)
{
RPC_CSTR str_bind;
status = RpcBindingToStringBinding(bindings->BindingH[i], &str_bind);
ok(status == RPC_S_OK, "RpcBindingToStringBinding failed with status %d\n", status);
trace("string binding: %s\n", str_bind);
RpcStringFree(&str_bind);
}
RpcBindingVectorFree(&bindings);
/* re-register - endpoints should be reused */
status = RpcServerUseProtseq(np, 0, NULL);
if (status == RPC_S_PROTSEQ_NOT_SUPPORTED)
win_skip("ncacn_np not supported\n");
else
ok(status == RPC_S_OK, "RpcServerUseProtseq(ncacn_np) failed with status %d\n", status);
status = RpcServerUseProtseq(iptcp, 0, NULL);
ok(status == RPC_S_OK, "RpcServerUseProtseq(ncacn_ip_tcp) failed with status %d\n", status);
status = RpcServerUseProtseq(ncalrpc, 0, NULL);
ok(status == RPC_S_OK, "RpcServerUseProtseqEp(ncalrpc) failed with status %d\n", status);
status = RpcServerInqBindings(&bindings);
ok(status == RPC_S_OK, "RpcServerInqBindings failed with status %d\n", status);
binding_count_after2 = bindings->Count;
ok(binding_count_after2 == binding_count_after1,
"bindings should have been re-used - after1: %u after2: %u\n",
binding_count_after1, binding_count_after2);
RpcBindingVectorFree(&bindings);
}
static RPC_DISPATCH_FUNCTION IFoo_table[] =
{
0
};
static RPC_DISPATCH_TABLE IFoo_v0_0_DispatchTable =
{
0,
IFoo_table
};
static const RPC_SERVER_INTERFACE IFoo___RpcServerInterface =
{
sizeof(RPC_SERVER_INTERFACE),
{{0x00000000,0x0000,0x0000,{0x00,0x00,0x00,0x00,0x00,0x00,0x12,0x34}},{0,0}},
{{0x8a885d04,0x1ceb,0x11c9,{0x9f,0xe8,0x08,0x00,0x2b,0x10,0x48,0x60}},{2,0}},
&IFoo_v0_0_DispatchTable,
0,
0,
0,
0,
0,
};
static RPC_IF_HANDLE IFoo_v0_0_s_ifspec = (RPC_IF_HANDLE)& IFoo___RpcServerInterface;
static void test_endpoint_mapper(RPC_CSTR protseq, RPC_CSTR address)
{
static unsigned char annotation[] = "Test annotation string.";
RPC_STATUS status;
RPC_BINDING_VECTOR *binding_vector;
handle_t handle;
unsigned char *binding;
status = RpcServerRegisterIf(IFoo_v0_0_s_ifspec, NULL, NULL);
ok(status == RPC_S_OK, "%s: RpcServerRegisterIf failed (%u)\n", protseq, status);
status = RpcServerInqBindings(&binding_vector);
ok(status == RPC_S_OK, "%s: RpcServerInqBindings failed with error %u\n", protseq, status);
/* register endpoints created in test_RpcServerUseProtseq */
status = RpcEpRegisterA(IFoo_v0_0_s_ifspec, binding_vector, NULL, annotation);
ok(status == RPC_S_OK, "%s: RpcEpRegisterA failed with error %u\n", protseq, status);
status = RpcStringBindingCompose(NULL, protseq, address,
NULL, NULL, &binding);
ok(status == RPC_S_OK, "%s: RpcStringBindingCompose failed (%u)\n", protseq, status);
status = RpcBindingFromStringBinding(binding, &handle);
ok(status == RPC_S_OK, "%s: RpcBindingFromStringBinding failed (%u)\n", protseq, status);
RpcStringFree(&binding);
status = RpcBindingReset(handle);
ok(status == RPC_S_OK, "%s: RpcBindingReset failed with error %u\n", protseq, status);
RpcStringFree(&binding);
status = RpcEpResolveBinding(handle, IFoo_v0_0_s_ifspec);
ok(status == RPC_S_OK || broken(status == RPC_S_SERVER_UNAVAILABLE), /* win9x */
"%s: RpcEpResolveBinding failed with error %u\n", protseq, status);
status = RpcBindingReset(handle);
ok(status == RPC_S_OK, "%s: RpcBindingReset failed with error %u\n", protseq, status);
status = RpcBindingFree(&handle);
ok(status == RPC_S_OK, "%s: RpcBindingFree failed with error %u\n", protseq, status);
status = RpcServerUnregisterIf(NULL, NULL, FALSE);
ok(status == RPC_S_OK, "%s: RpcServerUnregisterIf failed (%u)\n", protseq, status);
status = RpcEpUnregister(IFoo_v0_0_s_ifspec, binding_vector, NULL);
ok(status == RPC_S_OK, "%s: RpcEpUnregisterA failed with error %u\n", protseq, status);
status = RpcBindingVectorFree(&binding_vector);
ok(status == RPC_S_OK, "%s: RpcBindingVectorFree failed with error %u\n", protseq, status);
}
START_TEST( rpc_protseq )
{
static unsigned char ncacn_np[] = "ncacn_np";
static unsigned char ncalrpc[] = "ncalrpc";
static unsigned char np_address[] = ".";
test_RpcServerUseProtseq();
test_endpoint_mapper(ncacn_np, np_address);
test_endpoint_mapper(ncalrpc, NULL);
}

View file

@ -25,6 +25,7 @@
<file>ndr_marshall.c</file>
<file>rpc.c</file>
<file>rpc_async.c</file>
<file>rpc_protseq.c</file>
<file>server.c</file>
<file>testlist.c</file>
</module>

View file

@ -33,11 +33,14 @@
#define INT_CODE 4198
static const char *progname;
static BOOL old_windows_version;
static HANDLE stop_event;
static void (WINAPI *pNDRSContextMarshall2)(RPC_BINDING_HANDLE, NDR_SCONTEXT, void*, NDR_RUNDOWN, void*, ULONG);
static NDR_SCONTEXT (WINAPI *pNDRSContextUnmarshall2)(RPC_BINDING_HANDLE, void*, ULONG, void*, ULONG);
static RPC_STATUS (WINAPI *pRpcServerRegisterIfEx)(RPC_IF_HANDLE,UUID*, RPC_MGR_EPV*, unsigned int,
unsigned int,RPC_IF_CALLBACK_FN*);
static void InitFunctionPointers(void)
{
@ -45,18 +48,21 @@ static void InitFunctionPointers(void)
pNDRSContextMarshall2 = (void *)GetProcAddress(hrpcrt4, "NDRSContextMarshall2");
pNDRSContextUnmarshall2 = (void *)GetProcAddress(hrpcrt4, "NDRSContextUnmarshall2");
pRpcServerRegisterIfEx = (void *)GetProcAddress(hrpcrt4, "RpcServerRegisterIfEx");
if (!pNDRSContextMarshall2) old_windows_version = TRUE;
}
void __RPC_FAR *__RPC_USER
midl_user_allocate(size_t n)
midl_user_allocate(SIZE_T n)
{
return malloc(n);
return HeapAlloc(GetProcessHeap(), 0, n);
}
void __RPC_USER
midl_user_free(void __RPC_FAR *p)
{
free(p);
HeapFree(GetProcessHeap(), 0, p);
}
static char *
@ -138,8 +144,8 @@ s_square_half_float(float x, float *y)
return x * x;
}
long
s_square_half_long(long x, long *y)
LONG
s_square_half_long(LONG x, LONG *y)
{
*y = x / 2;
return x * x;
@ -223,6 +229,23 @@ s_sum_conf_array(int x[], int n)
return sum;
}
int
s_sum_conf_ptr_by_conf_ptr(int n1, int *n2_then_x1, int *x2)
{
int i;
int sum = 0;
if(n1 == 0)
return 0;
for(i = 1; i < n1; ++i)
sum += n2_then_x1[i];
for(i = 0; i < *n2_then_x1; ++i)
sum += x2[i];
return sum;
}
int
s_sum_unique_conf_array(int x[], int n)
{
@ -351,6 +374,12 @@ s_check_se2(se_t *s)
ok(s->f == E2, "check_se2\n");
}
int
s_sum_parr(int *a[3])
{
return s_sum_pcarr(a, 3);
}
int
s_sum_pcarr(int *a[], int n)
{
@ -360,12 +389,6 @@ s_sum_pcarr(int *a[], int n)
return s;
}
int
s_sum_parr(int *a[3])
{
return s_sum_pcarr(a, 3);
}
int
s_enum_ord(e_t e)
{
@ -571,6 +594,12 @@ s_context_handle_test(void)
binding = I_RpcGetCurrentCallHandle();
ok(binding != NULL, "I_RpcGetCurrentCallHandle returned NULL\n");
if (!pNDRSContextMarshall2 || !pNDRSContextUnmarshall2)
{
win_skip("NDRSContextMarshall2 or NDRSContextUnmarshall2 not exported from rpcrt4.dll\n");
return;
}
h = pNDRSContextUnmarshall2(binding, NULL, NDR_LOCAL_DATA_REPRESENTATION, NULL, 0);
ok(h != NULL, "NDRSContextUnmarshall2 returned NULL\n");
@ -590,6 +619,9 @@ s_context_handle_test(void)
ok(*(ULONG *)buf == 0, "attributes should have been set to 0 instead of 0x%x\n", *(ULONG *)buf);
ok(!UuidIsNil((UUID *)&buf[4], &status), "uuid should not have been nil\n");
/* raises ERROR_INVALID_HANDLE exception on Vista upwards */
if (0)
{
h = pNDRSContextUnmarshall2(binding, buf, NDR_LOCAL_DATA_REPRESENTATION, NULL, 0);
ok(h != NULL, "NDRSContextUnmarshall2 returned NULL\n");
ok(h->userContext == (void *)0xdeadbeef, "userContext of interface didn't unmarshal properly: %p\n", h->userContext);
@ -607,6 +639,7 @@ s_context_handle_test(void)
h = pNDRSContextUnmarshall2(binding, buf, NDR_LOCAL_DATA_REPRESENTATION, &server_if.InterfaceId, 0);
ok(h != NULL, "NDRSContextUnmarshall2 returned NULL\n");
ok(h->userContext == (void *)0xcafebabe, "userContext of interface didn't unmarshal properly: %p\n", h->userContext);
}
/* test same interface data, but different pointer */
/* raises ERROR_INVALID_HANDLE exception */
@ -639,19 +672,6 @@ s_context_handle_test(void)
}
}
void
s_get_5numbers(int count, pints_t n[5])
{
int i;
for (i = 0; i < count; i++)
{
n[i].pi = midl_user_allocate(sizeof(*n[i].pi));
*n[i].pi = i;
n[i].ppi = NULL;
n[i].pppi = NULL;
}
}
void
s_get_numbers(int length, int size, pints_t n[])
{
@ -734,7 +754,7 @@ basic_tests(void)
int i1, i2, i3, *pi2, *pi3, **ppi3;
double u, v;
float s, t;
long q, r;
LONG q, r;
short h;
char c;
int x;
@ -1079,12 +1099,15 @@ pointer_tests(void)
free_list(list);
name.size = 10;
name.name = buffer = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, name.size);
get_name(&name);
ok(name.name == buffer, "[in,out] pointer should have stayed as %p but instead changed to %p\n", name.name, buffer);
ok(!strcmp(name.name, "Jeremy Wh"), "name didn't unmarshall properly, expected \"Jeremy Wh\", but got \"%s\"\n", name.name);
HeapFree(GetProcessHeap(), 0, name.name);
if (!old_windows_version)
{
name.size = 10;
name.name = buffer = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, name.size);
get_name(&name);
ok(name.name == buffer, "[in,out] pointer should have stayed as %p but instead changed to %p\n", name.name, buffer);
ok(!strcmp(name.name, "Jeremy Wh"), "name didn't unmarshall properly, expected \"Jeremy Wh\", but got \"%s\"\n", name.name);
HeapFree(GetProcessHeap(), 0, name.name);
}
pa2 = a;
ok(sum_pcarr2(4, &pa2) == 10, "RPC sum_pcarr2\n");
@ -1117,13 +1140,13 @@ free_pyramid_doub_carr(doub_carr_t *dc)
static void
array_tests(void)
{
const char str1[25] = "Hello";
int m[2][3][4] =
{
{{1, 2, 3, 4}, {-1, -3, -5, -7}, {0, 2, 4, 6}},
{{1, -2, 3, -4}, {2, 3, 5, 7}, {-4, -1, -14, 4114}}
};
int c[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
int c2[] = {10, 100, 200};
vector_t vs[2] = {{1, -2, 3}, {4, -5, -6}};
cps_t cps;
cpsc_t cpsc;
@ -1135,7 +1158,11 @@ array_tests(void)
pints_t api[5];
numbers_struct_t *ns;
ok(cstr_length(str1, sizeof str1) == strlen(str1), "RPC cstr_length\n");
if (!old_windows_version)
{
const char str1[25] = "Hello";
ok(cstr_length(str1, sizeof str1) == strlen(str1), "RPC cstr_length\n");
}
ok(sum_fixed_int_3d(m) == 4116, "RPC sum_fixed_int_3d\n");
@ -1144,6 +1171,11 @@ array_tests(void)
ok(sum_conf_array(&c[7], 1) == 7, "RPC sum_conf_array\n");
ok(sum_conf_array(&c[2], 0) == 0, "RPC sum_conf_array\n");
ok(sum_conf_ptr_by_conf_ptr(1, c2, c) == 45, "RPC sum_conf_ptr_by_conf_ptr\n");
ok(sum_conf_ptr_by_conf_ptr(3, c2, c) == 345, "RPC sum_conf_ptr_by_conf_ptr\n");
c2[0] = 0;
ok(sum_conf_ptr_by_conf_ptr(3, c2, c) == 300, "RPC sum_conf_ptr_by_conf_ptr\n");
ok(sum_unique_conf_array(ca, 4) == -2, "RPC sum_unique_conf_array\n");
ok(sum_unique_conf_ptr(ca, 5) == 3, "RPC sum_unique_conf_array\n");
ok(sum_unique_conf_ptr(NULL, 10) == 0, "RPC sum_unique_conf_array\n");
@ -1186,21 +1218,21 @@ array_tests(void)
ok(sum_toplev_conf_cond(c, 5, 6, 1) == 10, "RPC sum_toplev_conf_cond\n");
ok(sum_toplev_conf_cond(c, 5, 6, 0) == 15, "RPC sum_toplev_conf_cond\n");
dc = malloc(FIELD_OFFSET(doub_carr_t, a[2]));
dc = HeapAlloc(GetProcessHeap(), 0, FIELD_OFFSET(doub_carr_t, a[2]));
dc->n = 2;
dc->a[0] = malloc(FIELD_OFFSET(doub_carr_1_t, a[3]));
dc->a[0] = HeapAlloc(GetProcessHeap(), 0, FIELD_OFFSET(doub_carr_1_t, a[3]));
dc->a[0]->n = 3;
dc->a[0]->a[0] = 5;
dc->a[0]->a[1] = 1;
dc->a[0]->a[2] = 8;
dc->a[1] = malloc(FIELD_OFFSET(doub_carr_1_t, a[2]));
dc->a[1] = HeapAlloc(GetProcessHeap(), 0, FIELD_OFFSET(doub_carr_1_t, a[2]));
dc->a[1]->n = 2;
dc->a[1]->a[0] = 2;
dc->a[1]->a[1] = 3;
ok(sum_doub_carr(dc) == 19, "RPC sum_doub_carr\n");
free(dc->a[0]);
free(dc->a[1]);
free(dc);
HeapFree(GetProcessHeap(), 0, dc->a[0]);
HeapFree(GetProcessHeap(), 0, dc->a[1]);
HeapFree(GetProcessHeap(), 0, dc);
dc = NULL;
make_pyramid_doub_carr(4, &dc);
@ -1212,25 +1244,22 @@ array_tests(void)
memset(api, 0, sizeof(api));
pi = HeapAlloc(GetProcessHeap(), 0, sizeof(*pi));
*pi = -1;
api[0].pi = pi;
get_5numbers(1, api);
ok(api[0].pi == pi, "RPC varying array [out] pointer changed from %p to %p\n", pi, api[0].pi);
ok(*api[0].pi == 0, "pi unmarshalled incorrectly %d\n", *api[0].pi);
api[0].pi = pi;
get_numbers(1, 1, api);
ok(api[0].pi == pi, "RPC conformant varying array [out] pointer changed from %p to %p\n", pi, api[0].pi);
ok(*api[0].pi == 0, "pi unmarshalled incorrectly %d\n", *api[0].pi);
ns = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, FIELD_OFFSET(numbers_struct_t, numbers[5]));
ns->length = 5;
ns->size = 5;
ns->numbers[0].pi = pi;
get_numbers_struct(&ns);
ok(ns->numbers[0].pi == pi, "RPC conformant varying struct embedded pointer changed from %p to %p\n", pi, ns->numbers[0].pi);
ok(*ns->numbers[0].pi == 5, "pi unmarshalled incorrectly %d\n", *ns->numbers[0].pi);
HeapFree(GetProcessHeap(), 0, ns);
if (!old_windows_version)
{
ns = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, FIELD_OFFSET(numbers_struct_t, numbers[5]));
ns->length = 5;
ns->size = 5;
ns->numbers[0].pi = pi;
get_numbers_struct(&ns);
ok(ns->numbers[0].pi == pi, "RPC conformant varying struct embedded pointer changed from %p to %p\n", pi, ns->numbers[0].pi);
ok(*ns->numbers[0].pi == 5, "pi unmarshalled incorrectly %d\n", *ns->numbers[0].pi);
HeapFree(GetProcessHeap(), 0, ns);
}
HeapFree(GetProcessHeap(), 0, pi);
}
@ -1288,19 +1317,16 @@ server(void)
static unsigned char np[] = "ncacn_np";
static unsigned char pipe[] = PIPE;
RPC_STATUS status, iptcp_status, np_status;
RPC_STATUS (RPC_ENTRY *pRpcServerRegisterIfEx)(RPC_IF_HANDLE,UUID*,
RPC_MGR_EPV*, unsigned int,unsigned int,RPC_IF_CALLBACK_FN*);
DWORD ret;
iptcp_status = RpcServerUseProtseqEp(iptcp, 20, port, NULL);
ok(iptcp_status == RPC_S_OK, "RpcServerUseProtseqEp(ncacn_ip_tcp) failed with status %ld\n", iptcp_status);
ok(iptcp_status == RPC_S_OK, "RpcServerUseProtseqEp(ncacn_ip_tcp) failed with status %d\n", iptcp_status);
np_status = RpcServerUseProtseqEp(np, 0, pipe, NULL);
if (np_status == RPC_S_PROTSEQ_NOT_SUPPORTED)
skip("Protocol sequence ncacn_np is not supported\n");
else
ok(np_status == RPC_S_OK, "RpcServerUseProtseqEp(ncacn_np) failed with status %ld\n", np_status);
ok(np_status == RPC_S_OK, "RpcServerUseProtseqEp(ncacn_np) failed with status %d\n", np_status);
pRpcServerRegisterIfEx = (void *)GetProcAddress(GetModuleHandle("rpcrt4.dll"), "RpcServerRegisterIfEx");
if (pRpcServerRegisterIfEx)
{
trace("Using RpcServerRegisterIfEx\n");
@ -1310,9 +1336,9 @@ server(void)
}
else
status = RpcServerRegisterIf(IServer_v0_0_s_ifspec, NULL, NULL);
ok(status == RPC_S_OK, "RpcServerRegisterIf failed with status %ld\n", status);
ok(status == RPC_S_OK, "RpcServerRegisterIf failed with status %d\n", status);
status = RpcServerListen(1, 20, TRUE);
ok(status == RPC_S_OK, "RpcServerListen failed with status %ld\n", status);
ok(status == RPC_S_OK, "RpcServerListen failed with status %d\n", status);
stop_event = CreateEvent(NULL, FALSE, FALSE, NULL);
ok(stop_event != NULL, "CreateEvent failed with error %d\n", GetLastError());
@ -1338,7 +1364,7 @@ server(void)
{
status = RpcMgmtWaitServerListen();
todo_wine {
ok(status == RPC_S_OK, "RpcMgmtWaitServerListening failed with status %ld\n", status);
ok(status == RPC_S_OK, "RpcMgmtWaitServerListening failed with status %d\n", status);
}
}
}

View file

@ -121,6 +121,7 @@ cpp_quote("#endif")
int test_list_length(test_list_t *ls);
int sum_fixed_int_3d(int m[2][3][4]);
int sum_conf_array([size_is(n)] int x[], int n);
int sum_conf_ptr_by_conf_ptr(int n1, [size_is(n1)] int *n2_then_x1, [size_is(*n2_then_x1)] int *x2);
int sum_unique_conf_array([size_is(n), unique] int x[], int n);
int sum_unique_conf_ptr([size_is(n), unique] int *x, int n);
int sum_var_array([length_is(n)] int x[20], int n);
@ -334,7 +335,6 @@ cpp_quote("#endif")
[size_is(size), length_is(length)] pints_t numbers[];
} numbers_struct_t;
void get_5numbers([in] int count, [out, length_is(count)] pints_t pn[5]);
void get_numbers([in] int length, [in] int size, [out, length_is(length), size_is(size)] pints_t pn[]);
void get_numbers_struct([out] numbers_struct_t **ns);