Código:
#define eWndProc (WNDPROC) (0x414190)
HWND(WINAPI* pCreateWindowEx)(DWORD, LPCSTR, LPCSTR, DWORD, int, int, int, int, HWND, HMENU, HINSTANCE, LPVOID) = CreateWindowEx;
LONG(WINAPI* pChangeDisplaySettings)(DEVMODEA*, DWORD) = ChangeDisplaySettings;
HWND WINAPI dCreateWindowEx(DWORD ExStyle, LPCSTR ClassName, LPCSTR WindowName, DWORD Style, int X, int Y, int Width, int Height, HWND Parent, HMENU Menu, HINSTANCE Instance, LPVOID Parameter)
{
if (IS_INTRESOURCE(ClassName))
{
return pCreateWindowEx(ExStyle, ClassName, WindowName, Style, X, Y, Width, Height, Parent, Menu, Instance, Parameter);
}
if (_stricmp(ClassName, VMProtectDecryptStringA("MU")) == 0)
{
int SizeX = Width,
SizeY = Height,
ScreenX = GetSystemMetrics(SM_CXSCREEN),
ScreenY = GetSystemMetrics(SM_CYSCREEN),
X2 = (ScreenX / 2) - (SizeX / 2),
Y2 = (ScreenY / 2) - (SizeY / 2);
HWND Window = pCreateWindowEx(0, ClassName, WindowName, WS_POPUP | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | WS_BORDER, X2, Y2, SizeX, SizeY, 0, 0, Instance, Parameter);
SetWindowPos(Window, nullptr, X2, Y2, 0, 0, SWP_NOSIZE);
return Window;
}
return pCreateWindowEx(ExStyle, ClassName, WindowName, Style, X, Y, Width, Height, Parent, Menu, Instance, Parameter);
}
LONG WINAPI dChangeDisplaySettings(DEVMODEA* DevMode, DWORD Flag)
{
return DISP_CHANGE_SUCCESSFUL;
}
LRESULT CALLBACK WndProc(HWND Window, UINT Message, WPARAM W, LPARAM L)
{
switch (Message)
{
case WM_NCACTIVATE:
return 0;
}
return CallWindowProc(eWndProc, Window, Message, W, L);
}
void Hook()
{
DetourTransactionBegin();
DetourUpdateThread(GetCurrentThread());
DetourAttach((&(LPVOID&)(pCreateWindowEx)), dCreateWindowEx);
DetourAttach((&(LPVOID&)(pChangeDisplaySettings)), dChangeDisplaySettings);
DetourTransactionCommit();
*(DWORD*)(0x41D37B) = (DWORD)(&WndProc);
}
void Unhook()
{
DetourTransactionBegin();
DetourUpdateThread(GetCurrentThread());
DetourDetach((&(LPVOID&)(pCreateWindowEx)), dCreateWindowEx);
DetourDetach((&(LPVOID&)(pChangeDisplaySettings)), dChangeDisplaySettings);
DetourTransactionCommit();
}