Problem with mod
Aug 12, 2024 4:03:03 GMT -8
Post by nanit76 on Aug 12, 2024 4:03:03 GMT -8
Hi guys,
I have problem with simple mod. I want show MessageBox when window with specified class name is created, but it crash everytime I use lpClassName, even in IF condition. Can somebody fix this code or explain to me, why this code does not work? Thank you.
I have problem with simple mod. I want show MessageBox when window with specified class name is created, but it crash everytime I use lpClassName, even in IF condition. Can somebody fix this code or explain to me, why this code does not work? Thank you.
// ==WindhawkMod==
// @id api-frame
// @name My frame Mod
// @description Test mod
// @version 0.1
// @author nanit76
// @include Project1.exe
// @compilerOptions -luser32
// ==/WindhawkMod==
// ==WindhawkModReadme==
/*
Test mod
*/
// ==/WindhawkModReadme==
#include <windows.h>
#include <objbase.h>
using CreateWindowExW_t = decltype(&CreateWindowExW);
CreateWindowExW_t CreateWindowExW_orig;
HWND WINAPI CreateWindowExW_hook(
DWORD dwExStyle,
LPCWSTR lpClassName,
LPCWSTR lpWindowName,
DWORD dwStyle,
int X,
int Y,
int nWidth,
int nHeight,
HWND hWndParent,
HMENU hMenu,
HINSTANCE hInstance,
LPVOID lpParam
)
{
//if (wcscmp(lpClassName, L"ThunderRT6FormDC") == 0)
if (lstrcmpW(lpClassName, L"ThunderRT6FormDC") == 0)
{
MessageBoxW(NULL, L"ThunderRT6FormDC opened", L"Surprise!", MB_OK);
//MessageBoxW(NULL, lpClassName, L"Surprise!", MB_OK);
}
return CreateWindowExW_orig(
dwExStyle,
lpClassName,
lpWindowName,
dwStyle,
X,
Y,
nWidth,
nHeight,
hWndParent,
hMenu,
hInstance,
lpParam
);
}
BOOL Wh_ModInit(void)
{
if (!Wh_SetFunctionHook(
(void *)CreateWindowExW,
(void *)CreateWindowExW_hook,
(void **)&CreateWindowExW_orig
))
{
Wh_Log(L"Failed to hook CreateWindowExW");
return FALSE;
}
return TRUE;
}