1 Commits

Author SHA1 Message Date
e58bc44742 Fix redundant literals and handle basepaths for RegOpenKeyExW calls 2026-06-02 19:47:03 +02:00

View File

@@ -3,24 +3,32 @@
#define WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN
#include <windows.h> #include <windows.h>
// Configure suffix for registry subkey
#define SUBKEY_SUFFIX L"Vanilla"
// No need to change these internal values
#define SUBKEY_ORIGINAL_SUBDIR L"Client"
#define SUBKEY_ORIGINAL_BASEPATH L"Software\\Blizzard Entertainment\\World of Warcraft"
#define SUBKEY_ORIGINAL_FULL SUBKEY_ORIGINAL_BASEPATH L"\\" SUBKEY_ORIGINAL_SUBDIR
#define SUBKEY_REPLACEMENT_BASEPATH SUBKEY_ORIGINAL_BASEPATH L" " SUBKEY_SUFFIX
#define SUBKEY_REPLACEMENT_FULL SUBKEY_REPLACEMENT_BASEPATH L"\\" SUBKEY_ORIGINAL_SUBDIR
// Original RegOpenKeyExW function pointer // Original RegOpenKeyExW function pointer
typedef LSTATUS (WINAPI *RegOpenKeyExW_t) (HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult); typedef LSTATUS (WINAPI *RegOpenKeyExW_t) (HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult);
RegOpenKeyExW_t OriginalRegOpenKeyExW = NULL; RegOpenKeyExW_t OriginalRegOpenKeyExW = NULL;
// Original RegCreateKeyExW function pointer // Original RegCreateKeyExW function pointer
typedef LSTATUS (WINAPI *RegCreateKeyExW_t) (HKEY hKey, LPCWSTR lpSubKey, DWORD Reserved, LPWSTR lpClass, typedef LSTATUS (WINAPI *RegCreateKeyExW_t) (HKEY hKey, LPCWSTR lpSubKey, DWORD Reserved, LPWSTR lpClass, DWORD dwOptions,
DWORD dwOptions, REGSAM samDesired, const LPSECURITY_ATTRIBUTES lpSecurityAttributes, PHKEY phkResult, REGSAM samDesired, const LPSECURITY_ATTRIBUTES lpSecurityAttributes, PHKEY phkResult, LPDWORD lpdwDisposition);
LPDWORD lpdwDisposition);
RegCreateKeyExW_t OriginalRegCreateKeyExW = NULL; RegCreateKeyExW_t OriginalRegCreateKeyExW = NULL;
// Custom RegOpenKeyExW: Intercept registry calls and rewrite relevant subkeys // Custom RegOpenKeyExW: Intercept registry calls and rewrite relevant subkeys
LSTATUS WINAPI CustomRegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult) LSTATUS WINAPI CustomRegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
{ {
if (lstrcmpW(lpSubKey, L"Software\\Blizzard Entertainment\\World of Warcraft\\Client") == 0) { if (lstrcmpW(lpSubKey, SUBKEY_ORIGINAL_BASEPATH) == 0) {
LPCWSTR lpNewKey = L"Software\\Blizzard Entertainment\\World of Warcraft Vanilla\\Client"; lpSubKey = SUBKEY_REPLACEMENT_BASEPATH;
return OriginalRegOpenKeyExW(hKey, lpNewKey, ulOptions, samDesired, phkResult); } else if (lstrcmpW(lpSubKey, SUBKEY_ORIGINAL_FULL) == 0) {
lpSubKey = SUBKEY_REPLACEMENT_FULL;
} }
return OriginalRegOpenKeyExW(hKey, lpSubKey, ulOptions, samDesired, phkResult); return OriginalRegOpenKeyExW(hKey, lpSubKey, ulOptions, samDesired, phkResult);
@@ -30,16 +38,10 @@ LSTATUS WINAPI CustomRegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions,
LSTATUS WINAPI CustomRegCreateKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD Reserved, LPWSTR lpClass, DWORD dwOptions, LSTATUS WINAPI CustomRegCreateKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD Reserved, LPWSTR lpClass, DWORD dwOptions,
REGSAM samDesired, const LPSECURITY_ATTRIBUTES lpSecurityAttributes, PHKEY phkResult, LPDWORD lpdwDisposition) REGSAM samDesired, const LPSECURITY_ATTRIBUTES lpSecurityAttributes, PHKEY phkResult, LPDWORD lpdwDisposition)
{ {
if (lstrcmpW(lpSubKey, L"Software\\Blizzard Entertainment\\World of Warcraft") == 0) { if (lstrcmpW(lpSubKey, SUBKEY_ORIGINAL_BASEPATH) == 0) {
LPCWSTR lpNewKey = L"Software\\Blizzard Entertainment\\World of Warcraft Vanilla"; lpSubKey = SUBKEY_REPLACEMENT_BASEPATH;
return OriginalRegCreateKeyExW(hKey, lpNewKey, Reserved, lpClass, dwOptions, } else if (lstrcmpW(lpSubKey, SUBKEY_ORIGINAL_FULL) == 0) {
samDesired, lpSecurityAttributes, phkResult, lpdwDisposition); lpSubKey = SUBKEY_REPLACEMENT_FULL;
}
if (lstrcmpW(lpSubKey, L"Software\\Blizzard Entertainment\\World of Warcraft\\Client") == 0) {
LPCWSTR lpNewKey = L"Software\\Blizzard Entertainment\\World of Warcraft Vanilla\\Client";
return OriginalRegCreateKeyExW(hKey, lpNewKey, Reserved, lpClass, dwOptions,
samDesired, lpSecurityAttributes, phkResult, lpdwDisposition);
} }
return OriginalRegCreateKeyExW(hKey, lpSubKey, Reserved, lpClass, dwOptions, return OriginalRegCreateKeyExW(hKey, lpSubKey, Reserved, lpClass, dwOptions,