From 275364d919e35da8261644eece44412faf6f2ef7 Mon Sep 17 00:00:00 2001 From: Alistair Leslie-Hughes Date: Thu, 11 Jun 2015 08:55:48 +1000 Subject: [PATCH] dpnet: Correct adding components in Duplicate. --- dlls/dpnet/address.c | 23 ++++++++++++++++++++++- dlls/dpnet/tests/address.c | 16 ++++++++++++++-- 2 files changed, 36 insertions(+), 3 deletions(-) diff --git a/dlls/dpnet/address.c b/dlls/dpnet/address.c index 7a33f8af141..d2a05f642d5 100644 --- a/dlls/dpnet/address.c +++ b/dlls/dpnet/address.c @@ -232,9 +232,30 @@ static HRESULT WINAPI IDirectPlay8AddressImpl_Duplicate(IDirectPlay8Address *ifa { struct component *entry = This->components[i]; - hr = IDirectPlay8Address_AddComponent(dup, entry->name, &entry->data, entry->size, entry->type); + switch (entry->type) + { + case DPNA_DATATYPE_DWORD: + hr = IDirectPlay8Address_AddComponent(dup, entry->name, &entry->data.value, entry->size, entry->type); + break; + case DPNA_DATATYPE_GUID: + hr = IDirectPlay8Address_AddComponent(dup, entry->name, &entry->data.guid, entry->size, entry->type); + break; + case DPNA_DATATYPE_STRING: + hr = IDirectPlay8Address_AddComponent(dup, entry->name, entry->data.string, entry->size, entry->type); + break; + case DPNA_DATATYPE_STRING_ANSI: + hr = IDirectPlay8Address_AddComponent(dup, entry->name, entry->data.ansi, entry->size, entry->type); + break; + case DPNA_DATATYPE_BINARY: + hr = IDirectPlay8Address_AddComponent(dup, entry->name, entry->data.binary, entry->size, entry->type); + break; + } + if(hr != S_OK) + { ERR("Failed to copy component: %s - 0x%08x\n", debugstr_w(entry->name), hr); + break; + } } *ppdpaNewAddress = dup; diff --git a/dlls/dpnet/tests/address.c b/dlls/dpnet/tests/address.c index ee589f56a82..cb226f9e6c1 100644 --- a/dlls/dpnet/tests/address.c +++ b/dlls/dpnet/tests/address.c @@ -24,6 +24,7 @@ /* {6733C6E8-A0D6-450E-8C18-CEACF331DC27} */ static const GUID IID_Random = {0x6733c6e8, 0xa0d6, 0x450e, { 0x8c, 0x18, 0xce, 0xac, 0xf3, 0x31, 0xdc, 0x27 } }; +static const WCHAR localhost[] = {'l','o','c','a','l','h','o','s','t',0}; static void create_directplay_address(void) { @@ -70,7 +71,6 @@ static void create_directplay_address(void) static void address_addcomponents(void) { static const WCHAR UNKNOWN[] = { 'u','n','k','n','o','w','n',0 }; - static const WCHAR localhost[] = {'l','o','c','a','l','h','o','s','t',0}; static const char testing[] = "testing"; HRESULT hr; IDirectPlay8Address *localaddr = NULL; @@ -309,14 +309,20 @@ static void address_duplicate(void) hr = IDirectPlay8Address_SetSP(localaddr, &CLSID_DP8SP_TCPIP); ok(hr == S_OK, "got 0x%08x\n", hr); + hr = IDirectPlay8Address_AddComponent(localaddr, DPNA_KEY_HOSTNAME, &localhost, sizeof(localhost), DPNA_DATATYPE_STRING); + ok(hr == S_OK, "got 0x%08x\n", hr); + hr = IDirectPlay8Address_GetNumComponents(localaddr, &components); ok(hr == S_OK, "got 0x%08x\n", hr); - ok(components == 1, "components=%d\n", components); + ok(components == 2, "components=%d\n", components); hr = IDirectPlay8Address_Duplicate(localaddr, &duplicate); ok(hr == S_OK, "got 0x%08x\n", hr); if(SUCCEEDED(hr)) { + DWORD size, type; + WCHAR buffer[256]; + hr = IDirectPlay8Address_GetSP(duplicate, &guid); ok(hr == S_OK, "got 0x%08x\n", hr); ok(IsEqualGUID(&guid, &CLSID_DP8SP_TCPIP), "wrong guid\n"); @@ -325,6 +331,12 @@ static void address_duplicate(void) ok(hr == S_OK, "got 0x%08x\n", hr); ok(components == dupcomps, "expected %d got %d\n", components, dupcomps); + size = sizeof(buffer); + hr = IDirectPlay8Address_GetComponentByName(duplicate, DPNA_KEY_HOSTNAME, buffer, &size, &type); + ok(hr == S_OK, "got 0x%08x\n", hr); + ok(type == DPNA_DATATYPE_STRING, "incorrect type %d\n", type); + ok(!lstrcmpW(buffer, localhost), "Invalid string: %s\n", wine_dbgstr_w(buffer)); + IDirectPlay8Address_Release(duplicate); }