From: Alistair Leslie-Hughes Subject: dpnet: Check if DirectDplay is installed (try 4) Message-Id: <542B9233.7050801@hotmail.com> Date: Wed, 01 Oct 2014 15:33:39 +1000 Hi, Changelog: dpnet: Check if DirectDplay is installed Best Regards Alistair Leslie-Hughes From dc29c177728f93a16d755c3062b9e52077ad1b02 Mon Sep 17 00:00:00 2001 From: Alistair Leslie-Hughes Date: Wed, 1 Oct 2014 14:54:12 +1000 Subject: [PATCH] Check if DirectPlay is installed To: wine-patches --- dlls/dpnet/tests/Makefile.in | 2 +- dlls/dpnet/tests/address.c | 8 ++++++++ dlls/dpnet/tests/dpnet_private.h | 23 +++++++++++++++++++++ dlls/dpnet/tests/peer.c | 7 +++++++ dlls/dpnet/tests/server.c | 44 ++++++++++++++++++++++++++++++++++++++++ 5 files changed, 83 insertions(+), 1 deletion(-) create mode 100644 dlls/dpnet/tests/dpnet_private.h diff --git a/dlls/dpnet/tests/Makefile.in b/dlls/dpnet/tests/Makefile.in index f6e45ea..4944ff4 100644 --- a/dlls/dpnet/tests/Makefile.in +++ b/dlls/dpnet/tests/Makefile.in @@ -1,5 +1,5 @@ TESTDLL = dpnet.dll -IMPORTS = dxguid uuid dpnet ole32 +IMPORTS = dxguid uuid dpnet ole32 version C_SRCS = \ address.c \ diff --git a/dlls/dpnet/tests/address.c b/dlls/dpnet/tests/address.c index fc43db9..e27536f 100644 --- a/dlls/dpnet/tests/address.c +++ b/dlls/dpnet/tests/address.c @@ -22,6 +22,8 @@ #include #include "wine/test.h" +#include "dpnet_private.h" + /* {6733C6E8-A0D6-450E-8C18-CEACF331DC27} */ static const GUID IID_Random = {0x6733c6e8, 0xa0d6, 0x450e, { 0x8c, 0x18, 0xce, 0xac, 0xf3, 0x31, 0xdc, 0x27 } }; @@ -273,6 +275,12 @@ START_TEST(address) { HRESULT hr; + if(IsStubDLL("dpnet.dll")) + { + win_skip("DirectPlay not installed.\n"); + return; + } + hr = CoInitialize(0); ok(hr == S_OK, "failed to init com\n"); if(hr != S_OK) diff --git a/dlls/dpnet/tests/dpnet_private.h b/dlls/dpnet/tests/dpnet_private.h new file mode 100644 index 0000000..3ffdc60 --- /dev/null +++ b/dlls/dpnet/tests/dpnet_private.h @@ -0,0 +1,23 @@ +/* + * Copyright 2014 Alistair Leslie-Hughes + * + * 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 + */ +#ifndef __DPNET_PRIVATE_H__ +#define __DPNET_PRIVATE_H__ + +extern BOOL IsStubDLL(const char *filename) DECLSPEC_HIDDEN; + +#endif diff --git a/dlls/dpnet/tests/peer.c b/dlls/dpnet/tests/peer.c index 1fec1f2..b668815 100644 --- a/dlls/dpnet/tests/peer.c +++ b/dlls/dpnet/tests/peer.c @@ -23,6 +23,7 @@ #include #include "wine/test.h" +#include "dpnet_private.h" static IDirectPlay8Peer* peer = NULL; static IDirectPlay8LobbiedApplication* lobbied = NULL; @@ -234,6 +235,12 @@ static void test_cleanup_dp(void) START_TEST(peer) { + if(IsStubDLL("dpnet.dll")) + { + win_skip("DirectPlay not installed.\n"); + return; + } + test_init_dp(); test_enum_service_providers(); test_enum_hosts(); diff --git a/dlls/dpnet/tests/server.c b/dlls/dpnet/tests/server.c index 8279666..8032b09 100644 --- a/dlls/dpnet/tests/server.c +++ b/dlls/dpnet/tests/server.c @@ -22,6 +22,8 @@ #include #include "wine/test.h" +#include "dpnet_private.h" + /* {CD0C3D4B-E15E-4CF2-9EA8-6E1D6548C5A5} */ static const GUID appguid = { 0xcd0c3d4b, 0xe15e, 0x4cf2, { 0x9e, 0xa8, 0x6e, 0x1d, 0x65, 0x48, 0xc5, 0xa5 } }; static WCHAR sessionname[] = {'w','i','n','e','g','a','m','e','s','s','e','r','v','e','r',0}; @@ -98,10 +100,52 @@ static void create_server(void) } } +/* + * Windows 8 has a concept of stub DLL's. When DLLMain is called the user is prompted + * to install that component. To bypass this check we need to look at the version resource. + */ +BOOL IsStubDLL(const char *filename) +{ + DWORD size, ver; + BOOL isstub = FALSE; + + size = GetFileVersionInfoSizeA(filename, &ver); + if(size != 0) + { + LPSTR data = HeapAlloc(GetProcessHeap(), 0, size); + char *p; + + if(!data) + return isstub; + + if (GetFileVersionInfoA(filename, ver, size, data)) + { + if (VerQueryValueA(data, "\\StringFileInfo\\040904b0\\OriginalFilename", (LPVOID*)&p, &size)) + { + trace("OriginalFilename: %s\n", p); + if(lstrcmpiA("wcodstub.dll", p) == 0) + { + isstub = TRUE; + } + } + } + + HeapFree(GetProcessHeap(), 0, data); + } + + return isstub; +} + START_TEST(server) { HRESULT hr; + if(IsStubDLL("dpnet.dll")) + { + win_skip("DirectPlay not installed.\n"); + return; + } + hr = CoInitialize(0); ok( hr == S_OK, "failed to init com\n"); if (hr != S_OK) -- 1.9.1