Fix redundant literals and handle basepaths for RegOpenKeyExW calls

This commit is contained in:
2026-06-02 18:56:14 +02:00
parent 2933a50916
commit e58bc44742

View File

@@ -3,24 +3,32 @@
#define WIN32_LEAN_AND_MEAN
#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
typedef LSTATUS (WINAPI *RegOpenKeyExW_t) (HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult);
RegOpenKeyExW_t OriginalRegOpenKeyExW = NULL;
// Original RegCreateKeyExW function pointer
typedef LSTATUS (WINAPI *RegCreateKeyExW_t) (HKEY hKey, LPCWSTR lpSubKey, DWORD Reserved, LPWSTR lpClass,
DWORD dwOptions, REGSAM samDesired, const LPSECURITY_ATTRIBUTES lpSecurityAttributes, PHKEY phkResult,
LPDWORD lpdwDisposition);
typedef LSTATUS (WINAPI *RegCreateKeyExW_t) (HKEY hKey, LPCWSTR lpSubKey, DWORD Reserved, LPWSTR lpClass, DWORD dwOptions,
REGSAM samDesired, const LPSECURITY_ATTRIBUTES lpSecurityAttributes, PHKEY phkResult, LPDWORD lpdwDisposition);
RegCreateKeyExW_t OriginalRegCreateKeyExW = NULL;
// Custom RegOpenKeyExW: Intercept registry calls and rewrite relevant subkeys
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) {
LPCWSTR lpNewKey = L"Software\\Blizzard Entertainment\\World of Warcraft Vanilla\\Client";
return OriginalRegOpenKeyExW(hKey, lpNewKey, ulOptions, samDesired, phkResult);
if (lstrcmpW(lpSubKey, SUBKEY_ORIGINAL_BASEPATH) == 0) {
lpSubKey = SUBKEY_REPLACEMENT_BASEPATH;
} else if (lstrcmpW(lpSubKey, SUBKEY_ORIGINAL_FULL) == 0) {
lpSubKey = SUBKEY_REPLACEMENT_FULL;
}
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,
REGSAM samDesired, const LPSECURITY_ATTRIBUTES lpSecurityAttributes, PHKEY phkResult, LPDWORD lpdwDisposition)
{
if (lstrcmpW(lpSubKey, L"Software\\Blizzard Entertainment\\World of Warcraft") == 0) {
LPCWSTR lpNewKey = L"Software\\Blizzard Entertainment\\World of Warcraft Vanilla";
return OriginalRegCreateKeyExW(hKey, lpNewKey, Reserved, lpClass, dwOptions,
samDesired, lpSecurityAttributes, phkResult, lpdwDisposition);
}
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);
if (lstrcmpW(lpSubKey, SUBKEY_ORIGINAL_BASEPATH) == 0) {
lpSubKey = SUBKEY_REPLACEMENT_BASEPATH;
} else if (lstrcmpW(lpSubKey, SUBKEY_ORIGINAL_FULL) == 0) {
lpSubKey = SUBKEY_REPLACEMENT_FULL;
}
return OriginalRegCreateKeyExW(hKey, lpSubKey, Reserved, lpClass, dwOptions,