foxygit / doom Log in
commit 0a94c0f99d6c34b30d2ac6fd7d5e516bd14dffb5
Author:     Simon Howard <fraggle@gmail.com>
AuthorDate: Sat Aug 17 20:53:22 2013 +0000
Commit:     Simon Howard <fraggle@gmail.com>
CommitDate: Sat Aug 17 20:53:22 2013 +0000

    Fix IWAD registry locations when using 64-bit Windows. Change imported
    from Odamex r4128 (thanks AlexMax).

    Subversion-branch: /branches/v2-branch
    Subversion-revision: 2618
---
 src/d_iwad.c | 30 +++++++++++++++++++-----------
 1 file changed, 19 insertions(+), 11 deletions(-)

diff --git a/src/d_iwad.c b/src/d_iwad.c
index 715687de..647dbbc7 100644
--- a/src/d_iwad.c
+++ b/src/d_iwad.c
@@ -100,13 +100,21 @@ typedef struct
 //
 // With some munging we can find where Doom was installed.

-static registry_value_t uninstall_values[] =
+// [AlexMax] From the persepctive of a 64-bit executable, 32-bit registry
+// keys are located in a different spot.
+#if _WIN64
+#define SOFTWARE_KEY "Software\\Wow6432Node"
+#else
+#define SOFTWARE_KEY "Software"
+#endif
+
+static registry_value_t uninstall_values[] =
 {
     // Ultimate Doom, CD version (Depths of Doom trilogy)

     {
-        HKEY_LOCAL_MACHINE,
-        "Software\\Microsoft\\Windows\\CurrentVersion\\"
+        HKEY_LOCAL_MACHINE,
+        SOFTWARE_KEY "\\Microsoft\\Windows\\CurrentVersion\\"
             "Uninstall\\Ultimate Doom for Windows 95",
         "UninstallString",
     },
@@ -114,8 +122,8 @@ static registry_value_t uninstall_values[] =
     // Doom II, CD version (Depths of Doom trilogy)

     {
-        HKEY_LOCAL_MACHINE,
-        "Software\\Microsoft\\Windows\\CurrentVersion\\"
+        HKEY_LOCAL_MACHINE,
+        SOFTWARE_KEY "\\Microsoft\\Windows\\CurrentVersion\\"
             "Uninstall\\Doom II for Windows 95",
         "UninstallString",
     },
@@ -123,8 +131,8 @@ static registry_value_t uninstall_values[] =
     // Final Doom

     {
-        HKEY_LOCAL_MACHINE,
-        "Software\\Microsoft\\Windows\\CurrentVersion\\"
+        HKEY_LOCAL_MACHINE,
+        SOFTWARE_KEY "\\Microsoft\\Windows\\CurrentVersion\\"
             "Uninstall\\Final Doom for Windows 95",
         "UninstallString",
     },
@@ -132,8 +140,8 @@ static registry_value_t uninstall_values[] =
     // Shareware version

     {
-        HKEY_LOCAL_MACHINE,
-        "Software\\Microsoft\\Windows\\CurrentVersion\\"
+        HKEY_LOCAL_MACHINE,
+        SOFTWARE_KEY "\\Microsoft\\Windows\\CurrentVersion\\"
             "Uninstall\\Doom Shareware for Windows 95",
         "UninstallString",
     },
@@ -144,7 +152,7 @@ static registry_value_t uninstall_values[] =
 static registry_value_t collectors_edition_value =
 {
     HKEY_LOCAL_MACHINE,
-    "Software\\Activision\\DOOM Collector's Edition\\v1.0",
+    SOFTWARE_KEY "\\Activision\\DOOM Collector's Edition\\v1.0",
     "INSTALLPATH",
 };

@@ -162,7 +170,7 @@ static char *collectors_edition_subdirs[] =
 static registry_value_t steam_install_location =
 {
     HKEY_LOCAL_MACHINE,
-    "Software\\Valve\\Steam",
+    SOFTWARE_KEY "\\Valve\\Steam",
     "InstallPath",
 };