1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
| #include <windows.h>
#include <TlHelp32.h>
#include <Shlwapi.h>
#include <Psapi.h>
LRESULT CALLBACK msgBoxHook(int nCode, WPARAM wParam, LPARAM lParam) {
LRESULT CALLBACK msgBoxHook(int, WPARAM, LPARAM);
DWORD WINAPI messageBoxThread(LPVOID);
if (nCode == HCBT_CREATEWND) {
CREATESTRUCT *pcs = ((CBT_CREATEWND *)lParam)->lpcs;
if ((pcs->style & WS_DLGFRAME) || (pcs->style & WS_POPUP)) {
HWND hwnd = (HWND)wParam;
int x = rand() % (GetSystemMetrics(SM_CXSCREEN) - pcs->cx);
int y = rand() % (GetSystemMetrics(SM_CYSCREEN) - pcs->cy);
pcs->x = x;
pcs->y = y;
}
}
return CallNextHookEx(0, nCode, wParam, lParam);
}
int main() {
HHOOK hook = SetWindowsHookEx(WH_CBT, msgBoxHook, 0, GetCurrentThreadId());
MessageBoxW(NULL, L"Msgbox | Test", L"MessageBox", MB_SYSTEMMODAL | MB_OK | MB_ICONIFORMATION);
UnhookWindowsHookEx(hook);
} |
Partager