Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| a3fbfad1c3 | |||
| e58bc44742 |
45
src/main.c
45
src/main.c
@@ -3,24 +3,34 @@
|
|||||||
#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) {
|
// TODO: Skip redundant compare by not checking for the full
|
||||||
LPCWSTR lpNewKey = L"Software\\Blizzard Entertainment\\World of Warcraft Vanilla\\Client";
|
// BASEPATH again but rather only for the additional SUBDIR
|
||||||
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);
|
return OriginalRegOpenKeyExW(hKey, lpSubKey, ulOptions, samDesired, phkResult);
|
||||||
@@ -30,16 +40,12 @@ 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) {
|
// TODO: Skip redundant compare by not checking for the full
|
||||||
LPCWSTR lpNewKey = L"Software\\Blizzard Entertainment\\World of Warcraft Vanilla";
|
// BASEPATH again but rather only for the additional SUBDIR
|
||||||
return OriginalRegCreateKeyExW(hKey, lpNewKey, Reserved, lpClass, dwOptions,
|
if (lstrcmpW(lpSubKey, SUBKEY_ORIGINAL_BASEPATH) == 0) {
|
||||||
samDesired, lpSecurityAttributes, phkResult, lpdwDisposition);
|
lpSubKey = SUBKEY_REPLACEMENT_BASEPATH;
|
||||||
}
|
} else if (lstrcmpW(lpSubKey, SUBKEY_ORIGINAL_FULL) == 0) {
|
||||||
|
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,
|
||||||
@@ -73,9 +79,6 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
|
|||||||
|
|
||||||
// Detach handler
|
// Detach handler
|
||||||
case DLL_PROCESS_DETACH:
|
case DLL_PROCESS_DETACH:
|
||||||
// If the DLL's entry-point function returns FALSE following a DLL_PROCESS_ATTACH
|
|
||||||
// notification, it receives a DLL_PROCESS_DETACH notification and the DLL is
|
|
||||||
// unloaded immediately. So all clean up code can be added here.
|
|
||||||
MH_DisableHook(MH_ALL_HOOKS);
|
MH_DisableHook(MH_ALL_HOOKS);
|
||||||
MH_Uninitialize();
|
MH_Uninitialize();
|
||||||
break;
|
break;
|
||||||
|
|||||||
Reference in New Issue
Block a user