Modify Windows registry reading to check both 32-bit and 64-bit key locations.

git-svn-id: https://svn.eduke32.com/eduke32@6111 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
hendricks266 2017-04-09 13:08:53 +00:00
parent f4fa0ceafd
commit 8cf65eb180

View file

@ -13,6 +13,9 @@
# define NEED_SHLWAPI_H # define NEED_SHLWAPI_H
# include "windows_inc.h" # include "windows_inc.h"
# include "winbits.h" # include "winbits.h"
# ifndef KEY_WOW64_64KEY
# define KEY_WOW64_64KEY 0x0100
# endif
# ifndef KEY_WOW64_32KEY # ifndef KEY_WOW64_32KEY
# define KEY_WOW64_32KEY 0x0200 # define KEY_WOW64_32KEY 0x0200
# endif # endif
@ -509,18 +512,26 @@ void G_LoadGroups(int32_t autoload)
#ifdef _WIN32 #ifdef _WIN32
static int G_ReadRegistryValue(char const * const SubKey, char const * const Value, char * const Output, DWORD * OutputSize) static int G_ReadRegistryValue(char const * const SubKey, char const * const Value, char * const Output, DWORD * OutputSize)
{ {
HKEY hkey;
LONG keygood = RegOpenKeyEx(HKEY_LOCAL_MACHINE, NULL, 0, KEY_READ | KEY_WOW64_32KEY, &hkey);
// KEY_WOW64_32KEY gets us around Wow6432Node on 64-bit builds // KEY_WOW64_32KEY gets us around Wow6432Node on 64-bit builds
REGSAM const wow64keys[] = { KEY_WOW64_32KEY, KEY_WOW64_64KEY };
for (size_t k = 0; k < ARRAY_SIZE(wow64keys); ++k)
{
HKEY hkey;
LONG keygood = RegOpenKeyEx(HKEY_LOCAL_MACHINE, NULL, 0, KEY_READ | wow64keys[k], &hkey);
if (keygood != ERROR_SUCCESS) if (keygood != ERROR_SUCCESS)
return 0; continue;
LONG retval = SHGetValueA(hkey, SubKey, Value, NULL, Output, OutputSize); LONG retval = SHGetValueA(hkey, SubKey, Value, NULL, Output, OutputSize);
RegCloseKey(hkey); RegCloseKey(hkey);
return retval == ERROR_SUCCESS; if (retval == ERROR_SUCCESS)
return 1;
}
return 0;
} }
#endif #endif