dpnet: Check if DirectDplay is installed

Alistair Leslie-Hughes leslie_alistair at hotmail.com
Sun Mar 2 04:41:17 CST 2014


Hi,
Hopefully this will solve the issue on windows where dpnet isn't 
installed and we get a timeout running the tests.


Changelog:
     dpnet: Check if DirectDplay is installed


Best Regards
  Alistair Leslie-Hughes
-------------- next part --------------
>From e0061a2953eddf15a1f6ec2ca3abe9398e71f5a0 Mon Sep 17 00:00:00 2001
From: Alistair Leslie-Hughes <leslie_alistair at hotmail.com>
Date: Fri, 28 Feb 2014 14:58:19 +1100
Subject: [PATCH] Check if dpnet is installed
To: wine-patches <wine-patches at winehq.org>

---
 dlls/dpnet/tests/Makefile.in |  2 +-
 dlls/dpnet/tests/address.c   |  8 ++++++++
 dlls/dpnet/tests/client.c    |  7 +++++++
 dlls/dpnet/tests/peer.c      |  7 +++++++
 dlls/dpnet/tests/server.c    | 49 ++++++++++++++++++++++++++++++++++++++++++++
 5 files changed, 72 insertions(+), 1 deletion(-)

diff --git a/dlls/dpnet/tests/Makefile.in b/dlls/dpnet/tests/Makefile.in
index f7f49ea..ca68ebf 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 = \
 	address.c \
diff --git a/dlls/dpnet/tests/address.c b/dlls/dpnet/tests/address.c
index ff30cc5..6eb77ab 100644
--- a/dlls/dpnet/tests/address.c
+++ b/dlls/dpnet/tests/address.c
@@ -25,6 +25,8 @@
 /* {6733C6E8-A0D6-450E-8C18-CEACF331DC27} */
 static const GUID IID_Random = {0x6733c6e8, 0xa0d6, 0x450e, { 0x8c, 0x18, 0xce, 0xac, 0xf3, 0x31, 0xdc, 0x27 } };
 
+extern BOOL IsStubDLL(const char *filename) DECLSPEC_HIDDEN;
+
 static void create_directplay_address(void)
 {
     HRESULT hr;
@@ -134,6 +136,12 @@ START_TEST(address)
 {
     HRESULT hr;
 
+    if(IsStubDLL("dpnet.dll"))
+    {
+        win_skip("dpnet 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/client.c b/dlls/dpnet/tests/client.c
index 439a0ba..43ab3d8 100644
--- a/dlls/dpnet/tests/client.c
+++ b/dlls/dpnet/tests/client.c
@@ -22,6 +22,7 @@
 #include <dplay8.h>
 #include "wine/test.h"
 
+extern BOOL IsStubDLL(const char *filename) DECLSPEC_HIDDEN;
 
 static IDirectPlay8Client* client = NULL;
 
@@ -207,6 +208,12 @@ static void test_cleanup_dp(void)
 
 START_TEST(client)
 {
+    if(IsStubDLL("dpnet.dll"))
+    {
+        win_skip("dpnet not installed.\n");
+        return;
+    }
+
     test_init_dp();
     test_enum_service_providers();
     test_enum_hosts();
diff --git a/dlls/dpnet/tests/peer.c b/dlls/dpnet/tests/peer.c
index 33d9fd9..84564ad 100644
--- a/dlls/dpnet/tests/peer.c
+++ b/dlls/dpnet/tests/peer.c
@@ -23,6 +23,7 @@
 #include <dplay8.h>
 #include "wine/test.h"
 
+extern BOOL IsStubDLL(const char *filename) DECLSPEC_HIDDEN;
 
 static IDirectPlay8Peer* peer = NULL;
 
@@ -207,6 +208,12 @@ static void test_cleanup_dp(void)
 
 START_TEST(peer)
 {
+    if(IsStubDLL("dpnet.dll"))
+    {
+        win_skip("dpnet 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..79c163d 100644
--- a/dlls/dpnet/tests/server.c
+++ b/dlls/dpnet/tests/server.c
@@ -96,10 +96,59 @@ static void create_server(void)
     }
 }
 
+/*
+ * We cannot just load a stub dll without triggering the "Feature not Installed"
+ *  dialog.  However we can check if the OrigialName matches a known stub name.
+ */
+BOOL IsStubDLL(const char *filename)
+{
+    DWORD size, ver;
+    BOOL isstub = FALSE;
+
+    size = GetFileVersionInfoSizeA(filename, &ver);
+    ok(size != 0, "failed %d,%d\n", size, GetLastError());
+    if(size != 0)
+    {
+        LPSTR data = HeapAlloc(GetProcessHeap(), 0, size);
+        char *p;
+        UINT translation;
+        char buf[MAX_PATH];
+
+        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);
+            trace("translation: %s\n", buf);
+            if (VerQueryValueA(data, buf, (LPVOID*)&p, &size))
+            {
+                trace("orig: '%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("dpnet 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