From 47a45386e9b2d68ac697177699e6d27fd2a558fe Mon Sep 17 00:00:00 2001 From: Thorvald Natvig Date: Sat, 27 Feb 2010 23:43:59 +0100 Subject: [PATCH] Reprotect WindowFromPoint after patching --- src/mumble/GlobalShortcut_win.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/mumble/GlobalShortcut_win.cpp b/src/mumble/GlobalShortcut_win.cpp index 7dd78ceb8..4273c50f2 100644 --- a/src/mumble/GlobalShortcut_win.cpp +++ b/src/mumble/GlobalShortcut_win.cpp @@ -74,6 +74,7 @@ GlobalShortcutWin::GlobalShortcutWin() { f[i] = ucWindowFromPointNew[i]; FlushInstructionCache(GetCurrentProcess(), f, 6); + VirtualProtect(f, 6, oldProtect, &oldProtect); } else { qWarning("GlobalShortcutWin: Failed to patch WindowFromPoint"); } @@ -95,8 +96,11 @@ HWND WINAPI GlobalShortcutWin::HookWindowFromPoint(POINT p) { if (g.ocIntercept) return g.ocIntercept->qgv.winId(); + DWORD oldProtect; unsigned char *f = reinterpret_cast(&WindowFromPoint); + VirtualProtect(f, 6, PAGE_EXECUTE_READWRITE, &oldProtect); + for (int i=0;i<6;++i) f[i] = ucWindowFromPointOrig[i]; FlushInstructionCache(GetCurrentProcess(), f, 6); @@ -107,6 +111,8 @@ HWND WINAPI GlobalShortcutWin::HookWindowFromPoint(POINT p) { f[i] = ucWindowFromPointNew[i]; FlushInstructionCache(GetCurrentProcess(), f, 6); + VirtualProtect(f, 6, oldProtect, &oldProtect); + return hwnd; } #endif