From: Alistair Leslie-Hughes Subject: [2/3] dpnet: Return valid value from IDirectPlay8Address GetNumComponents Message-Id: <52DC92B3.40008@hotmail.com> Date: Mon, 20 Jan 2014 14:06:27 +1100 Hi, Changelog: dpnet: Return valid value from IDirectPlay8Address GetNumComponents Best Regards Alistair Leslie-Hughes >From 010c361c781327a60d6440c70010582cbd6c3e41 Mon Sep 17 00:00:00 2001 From: Alistair Leslie-Hughes Date: Mon, 20 Jan 2014 12:02:25 +1100 Subject: [PATCH] Return valid value from IDirectPlay8Address GetNumComponents To: wine-patches --- dlls/dpnet/address.c | 13 ++++++++++--- dlls/dpnet/tests/address.c | 45 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+), 3 deletions(-) diff --git a/dlls/dpnet/address.c b/dlls/dpnet/address.c index d12ef01..e7a62bb 100644 --- a/dlls/dpnet/address.c +++ b/dlls/dpnet/address.c @@ -215,9 +215,16 @@ static HRESULT WINAPI IDirectPlay8AddressImpl_SetUserData(IDirectPlay8Address *i static HRESULT WINAPI IDirectPlay8AddressImpl_GetNumComponents(IDirectPlay8Address *iface, DWORD *pdwNumComponents) { - IDirectPlay8AddressImpl *This = impl_from_IDirectPlay8Address(iface); - TRACE("(%p): stub\n", This); - return DPN_OK; + IDirectPlay8AddressImpl *This = impl_from_IDirectPlay8Address(iface); + TRACE("(%p): stub\n", This); + + if(!pdwNumComponents) + return DPNERR_INVALIDPOINTER; + + FIXME("Always returning 0\n"); + *pdwNumComponents = 0; + + return DPN_OK; } static HRESULT WINAPI IDirectPlay8AddressImpl_GetComponentByName(IDirectPlay8Address *iface, diff --git a/dlls/dpnet/tests/address.c b/dlls/dpnet/tests/address.c index 3baf50a..bf68fbb 100644 --- a/dlls/dpnet/tests/address.c +++ b/dlls/dpnet/tests/address.c @@ -44,6 +44,8 @@ static void create_directplay_address(void) if( SUCCEEDED(hr) ) { GUID guidsp; + DWORD components; + DWORD i; hr = IDirectPlay8Address_GetSP(localaddr, NULL); ok(hr == DPNERR_INVALIDPOINTER, "GetSP failed 0x%08x\n", hr); @@ -61,6 +63,49 @@ static void create_directplay_address(void) ok(hr == S_OK, "got 0x%08x\n", hr); ok(IsEqualGUID(&guidsp, &CLSID_DP8SP_TCPIP), "wrong guid: %s\n", show_guid(&guidsp)); + hr = IDirectPlay8Address_GetNumComponents(localaddr, NULL); + ok(hr == DPNERR_INVALIDPOINTER, "got 0x%08x\n", hr); + + hr = IDirectPlay8Address_GetNumComponents(localaddr, &components); + ok(hr == S_OK, "got 0x%08x\n", hr); + + trace("GetNumComponents=%d\n", components); + for(i=0; i < components; i++) + { + /* For most cases, 256 will be enough for testing. */ + WCHAR name[256]; + DWORD namelen = 256; + void *buffer = malloc(256); + DWORD bufflen = 256; + DWORD type; + + hr = IDirectPlay8Address_GetComponentByIndex(localaddr, i, name, &namelen, buffer, &bufflen, &type); + ok(hr == S_OK, "got 0x%08x\n", hr); + if(hr == S_OK) + { + switch(type) + { + case DPNA_DATATYPE_STRING: + trace("%d: %s: %s\n", i, wine_dbgstr_w(name), wine_dbgstr_w(buffer)); + break; + case DPNA_DATATYPE_DWORD: + trace("%d: %s: %d\n", i, wine_dbgstr_w(name), *(DWORD*)&buffer); + break; + case DPNA_DATATYPE_GUID: + trace("%d: %s: %s\n", i, wine_dbgstr_w(name), show_guid( (GUID*)&buffer)); + break; + case DPNA_DATATYPE_BINARY: + trace("%d: %s: Binary Data %d\n", i, wine_dbgstr_w(name), bufflen); + break; + default: + trace(" Unknown\n"); + break; + } + } + + free(buffer); + } + IDirectPlay8Address_Release(localaddr); } } -- 1.8.3.2