-
I think, there was already a discussion on this on Discord, but I was unable to make a mod that hooks registry access. Is it possible to see an example mod that hooks a registry read operation for a key in HKLM? |
Beta Was this translation helpful? Give feedback.
Answered by
m417z
Aug 9, 2024
Replies: 1 comment 9 replies
-
I don't think there's a mod that demonstrates that. We indeed discussed it on Discord, and I posted a simple example. Posting it here too for reference. I do have it on my list to try implementing a Registry Redirect mod, but I'm not sure when I'll get to it. // ==WindhawkMod==
// @id registry-hook-demo
// @name registry-hook-demo
// @description registry-hook-demo
// @version 0.1
// @author You
// @include target.exe
// ==/WindhawkMod==
// ==WindhawkModReadme==
/*
# registry-hook-demo
*/
// ==/WindhawkModReadme==
typedef LONG (WINAPI *REGQUERYVALUEEXA)(HKEY hKey,LPCSTR lpValueName,LPDWORD lpReserved,LPDWORD lpType,LPBYTE lpData,LPDWORD lpcbData);
REGQUERYVALUEEXA pOriginalRegQueryValueExA;
LONG WINAPI RegQueryValueExAHook(HKEY hKey,LPCSTR lpValueName,LPDWORD lpReserved,LPDWORD lpType,LPBYTE lpData,LPDWORD lpcbData)
{
if(lstrcmpiA(lpValueName, "Value") == 0)
return ERROR_FILE_NOT_FOUND;
return pOriginalRegQueryValueExA(hKey,lpValueName,lpReserved,lpType,lpData,lpcbData);
}
BOOL Wh_ModInit(void)
{
Wh_Log(L"Init");
Wh_SetFunctionHook((void*)RegQueryValueExA, (void*)RegQueryValueExAHook, (void**)&pOriginalRegQueryValueExA);
return TRUE;
} |
Beta Was this translation helpful? Give feedback.
9 replies
Answer selected by
Anixx
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I don't think there's a mod that demonstrates that. We indeed discussed it on Discord, and I posted a simple example. Posting it here too for reference.
I do have it on my list to try implementing a Registry Redirect mod, but I'm not sure when I'll get to it.