dpnet: Check if DirectPlay is installed (try 4)

Alistair Leslie-Hughes leslie_alistair at hotmail.com
Mon Mar 17 22:12:06 CDT 2014


Hi,
Corrected Comment and add a memory check.

Changelog:
       dpnet: Check if DirectPlay is installed


Best Regards
   Alistair Leslie-Hughes
-------------- next part --------------
>From f225edd5bfe3a506ae40742f6a26771614c44bf9 Mon Sep 17 00:00:00 2001
From: Alistair Leslie-Hughes <leslie_alistair at hotmail.com>
Date: Mon, 3 Mar 2014 09:58:51 +1100
Subject: [PATCH] Check if DirectPlay is installed
To: wine-patches <wine-patches at winehq.org>

---
 dlls/dpnet/tests/Makefile.in     |  2 +-
 dlls/dpnet/tests/dpnet_private.h | 23 ++++++++++++++++++
 dlls/dpnet/tests/peer.c          |  7 ++++++
 dlls/dpnet/tests/server.c        | 52 ++++++++++++++++++++++++++++++++++++++++
 4 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 9220121..64d7808 100644
--- a/dlls/dpnet/tests/Makefile.in
+++ b/dlls/dpnet/tests/Makefile.in
@@ -1,5 +1,5 @@
 TESTDLL   = dpnet.dll
-IMPORTS   = dpnet ole32
+IMPORTS   = dpnet ole32 version
 
 C_SRCS = \
 	peer.c \
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 aea67c9..394e2ab 100644
--- a/dlls/dpnet/tests/peer.c
+++ b/dlls/dpnet/tests/peer.c
@@ -23,6 +23,7 @@
 #include <dplay8.h>
 #include "wine/test.h"
 
+#include "dpnet_private.h"
 
 static IDirectPlay8Peer* peer = NULL;
 
@@ -200,6 +201,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 c4de81e..e16a745 100644
--- a/dlls/dpnet/tests/server.c
+++ b/dlls/dpnet/tests/server.c
@@ -22,6 +22,8 @@
 #include <dplay8.h>
 #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};
@@ -96,10 +98,60 @@ 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;
+        UINT translation;
+        char buf[MAX_PATH];
+
+        if(!data)
+            return isstub;
+
+        if (GetFileVersionInfoA(filename, ver, size, data))
+        {
+            VerQueryValueA(data, "\\VarFileInfo\\Translation", (LPVOID*)&p, &size);
+
+            translation = *(UINT *)p;
+            translation = MAKELONG(HIWORD(translation), LOWORD(translation));
+
+            sprintf(buf, "\\StringFileInfo\\%08x\\OriginalFilename", translation);
+            if (VerQueryValueA(data, buf, (LPVOID*)&p, &size))
+            {
+                trace("OriginalFilename: %s", 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.8.3.2



More information about the wine-patches mailing list