mirror of
https://github.com/FunkyFr3sh/cnc-ddraw.git
synced 2025-03-25 01:57:47 +01:00
hook GetForegroundWindow
This commit is contained in:
parent
876160cbb6
commit
24d66d8a30
@ -9,7 +9,7 @@
|
|||||||
#define SKIP_HOOK3 0x00000002l
|
#define SKIP_HOOK3 0x00000002l
|
||||||
|
|
||||||
typedef struct HOOKLISTDATA { char function_name[32]; PROC new_function; PROC* function; DWORD flags; } HOOKLISTDATA;
|
typedef struct HOOKLISTDATA { char function_name[32]; PROC new_function; PROC* function; DWORD flags; } HOOKLISTDATA;
|
||||||
typedef struct HOOKLIST { char module_name[32]; HOOKLISTDATA data[25]; } HOOKLIST;
|
typedef struct HOOKLIST { char module_name[32]; HOOKLISTDATA data[26]; } HOOKLIST;
|
||||||
|
|
||||||
typedef BOOL(WINAPI* GETCURSORPOSPROC)(LPPOINT);
|
typedef BOOL(WINAPI* GETCURSORPOSPROC)(LPPOINT);
|
||||||
typedef BOOL(WINAPI* CLIPCURSORPROC)(const RECT*);
|
typedef BOOL(WINAPI* CLIPCURSORPROC)(const RECT*);
|
||||||
@ -35,6 +35,7 @@ typedef BOOL(WINAPI* DESTROYWINDOWPROC)(HWND);
|
|||||||
typedef int (WINAPI* MAPWINDOWPOINTSPROC)(HWND, HWND, LPPOINT, UINT);
|
typedef int (WINAPI* MAPWINDOWPOINTSPROC)(HWND, HWND, LPPOINT, UINT);
|
||||||
typedef BOOL (WINAPI* SHOWWINDOWPROC)(HWND, int);
|
typedef BOOL (WINAPI* SHOWWINDOWPROC)(HWND, int);
|
||||||
typedef HWND(WINAPI* GETTOPWINDOWPROC)(HWND);
|
typedef HWND(WINAPI* GETTOPWINDOWPROC)(HWND);
|
||||||
|
typedef HWND(WINAPI* GETFOREGROUNDWINDOWPROC)();
|
||||||
typedef BOOL(WINAPI* STRETCHBLTPROC)(HDC, int, int, int, int, HDC, int, int, int, int, DWORD);
|
typedef BOOL(WINAPI* STRETCHBLTPROC)(HDC, int, int, int, int, HDC, int, int, int, int, DWORD);
|
||||||
|
|
||||||
typedef int (WINAPI* SETDIBITSTODEVICEPROC)(
|
typedef int (WINAPI* SETDIBITSTODEVICEPROC)(
|
||||||
@ -76,6 +77,7 @@ extern DESTROYWINDOWPROC real_DestroyWindow;
|
|||||||
extern MAPWINDOWPOINTSPROC real_MapWindowPoints;
|
extern MAPWINDOWPOINTSPROC real_MapWindowPoints;
|
||||||
extern SHOWWINDOWPROC real_ShowWindow;
|
extern SHOWWINDOWPROC real_ShowWindow;
|
||||||
extern GETTOPWINDOWPROC real_GetTopWindow;
|
extern GETTOPWINDOWPROC real_GetTopWindow;
|
||||||
|
extern GETFOREGROUNDWINDOWPROC real_GetForegroundWindow;
|
||||||
extern STRETCHBLTPROC real_StretchBlt;
|
extern STRETCHBLTPROC real_StretchBlt;
|
||||||
extern SETDIBITSTODEVICEPROC real_SetDIBitsToDevice;
|
extern SETDIBITSTODEVICEPROC real_SetDIBitsToDevice;
|
||||||
extern STRETCHDIBITSPROC real_StretchDIBits;
|
extern STRETCHDIBITSPROC real_StretchDIBits;
|
||||||
|
@ -28,6 +28,7 @@ BOOL WINAPI fake_DestroyWindow(HWND hWnd);
|
|||||||
int WINAPI fake_MapWindowPoints(HWND hWndFrom, HWND hWndTo, LPPOINT lpPoints, UINT cPoints);
|
int WINAPI fake_MapWindowPoints(HWND hWndFrom, HWND hWndTo, LPPOINT lpPoints, UINT cPoints);
|
||||||
BOOL WINAPI fake_ShowWindow(HWND hWnd, int nCmdShow);
|
BOOL WINAPI fake_ShowWindow(HWND hWnd, int nCmdShow);
|
||||||
HWND WINAPI fake_GetTopWindow(HWND hWnd);
|
HWND WINAPI fake_GetTopWindow(HWND hWnd);
|
||||||
|
HWND WINAPI fake_GetForegroundWindow(void);
|
||||||
HHOOK WINAPI fake_SetWindowsHookExA(int idHook, HOOKPROC lpfn, HINSTANCE hmod, DWORD dwThreadId);
|
HHOOK WINAPI fake_SetWindowsHookExA(int idHook, HOOKPROC lpfn, HINSTANCE hmod, DWORD dwThreadId);
|
||||||
int WINAPI fake_GetDeviceCaps(HDC hdc, int index);
|
int WINAPI fake_GetDeviceCaps(HDC hdc, int index);
|
||||||
|
|
||||||
|
2
src/dd.c
2
src/dd.c
@ -781,7 +781,7 @@ HRESULT dd_SetDisplayMode(DWORD dwWidth, DWORD dwHeight, DWORD dwBPP, DWORD dwFl
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (lock_mouse || (g_ddraw->fullscreen && GetForegroundWindow() == g_ddraw->hwnd))
|
if (lock_mouse || (g_ddraw->fullscreen && real_GetForegroundWindow() == g_ddraw->hwnd))
|
||||||
mouse_lock();
|
mouse_lock();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -41,6 +41,7 @@ DESTROYWINDOWPROC real_DestroyWindow = DestroyWindow;
|
|||||||
MAPWINDOWPOINTSPROC real_MapWindowPoints = MapWindowPoints;
|
MAPWINDOWPOINTSPROC real_MapWindowPoints = MapWindowPoints;
|
||||||
SHOWWINDOWPROC real_ShowWindow = ShowWindow;
|
SHOWWINDOWPROC real_ShowWindow = ShowWindow;
|
||||||
GETTOPWINDOWPROC real_GetTopWindow = GetTopWindow;
|
GETTOPWINDOWPROC real_GetTopWindow = GetTopWindow;
|
||||||
|
GETFOREGROUNDWINDOWPROC real_GetForegroundWindow = GetForegroundWindow;
|
||||||
STRETCHBLTPROC real_StretchBlt = StretchBlt;
|
STRETCHBLTPROC real_StretchBlt = StretchBlt;
|
||||||
SETDIBITSTODEVICEPROC real_SetDIBitsToDevice = SetDIBitsToDevice;
|
SETDIBITSTODEVICEPROC real_SetDIBitsToDevice = SetDIBitsToDevice;
|
||||||
STRETCHDIBITSPROC real_StretchDIBits = StretchDIBits;
|
STRETCHDIBITSPROC real_StretchDIBits = StretchDIBits;
|
||||||
@ -82,6 +83,7 @@ static HOOKLIST g_hooks[] =
|
|||||||
{ "MapWindowPoints", (PROC)fake_MapWindowPoints, (PROC*)&real_MapWindowPoints, 0 },
|
{ "MapWindowPoints", (PROC)fake_MapWindowPoints, (PROC*)&real_MapWindowPoints, 0 },
|
||||||
{ "ShowWindow", (PROC)fake_ShowWindow, (PROC*)&real_ShowWindow, 0 },
|
{ "ShowWindow", (PROC)fake_ShowWindow, (PROC*)&real_ShowWindow, 0 },
|
||||||
{ "GetTopWindow", (PROC)fake_GetTopWindow, (PROC*)&real_GetTopWindow, 0 },
|
{ "GetTopWindow", (PROC)fake_GetTopWindow, (PROC*)&real_GetTopWindow, 0 },
|
||||||
|
{ "GetForegroundWindow", (PROC)fake_GetForegroundWindow, (PROC*)&real_GetForegroundWindow, 0 },
|
||||||
{ "", NULL, NULL, 0 }
|
{ "", NULL, NULL, 0 }
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -527,6 +527,16 @@ HWND WINAPI fake_GetTopWindow(HWND hWnd)
|
|||||||
return real_GetTopWindow(hWnd);
|
return real_GetTopWindow(hWnd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
HWND WINAPI fake_GetForegroundWindow()
|
||||||
|
{
|
||||||
|
if (g_ddraw && g_ddraw->windowed && g_ddraw->hwnd)
|
||||||
|
{
|
||||||
|
return g_ddraw->hwnd;
|
||||||
|
}
|
||||||
|
|
||||||
|
return real_GetForegroundWindow();
|
||||||
|
}
|
||||||
|
|
||||||
HHOOK WINAPI fake_SetWindowsHookExA(int idHook, HOOKPROC lpfn, HINSTANCE hmod, DWORD dwThreadId)
|
HHOOK WINAPI fake_SetWindowsHookExA(int idHook, HOOKPROC lpfn, HINSTANCE hmod, DWORD dwThreadId)
|
||||||
{
|
{
|
||||||
if (idHook == WH_KEYBOARD_LL && hmod && GetModuleHandle("AcGenral") == hmod)
|
if (idHook == WH_KEYBOARD_LL && hmod && GetModuleHandle("AcGenral") == hmod)
|
||||||
|
@ -486,7 +486,7 @@ LRESULT CALLBACK fake_WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam
|
|||||||
{
|
{
|
||||||
mouse_unlock();
|
mouse_unlock();
|
||||||
|
|
||||||
if (GetForegroundWindow() == g_ddraw->hwnd)
|
if (real_GetForegroundWindow() == g_ddraw->hwnd)
|
||||||
mouse_lock();
|
mouse_lock();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -525,7 +525,7 @@ LRESULT CALLBACK fake_WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam
|
|||||||
mouse_lock();
|
mouse_lock();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (g_ddraw->fullscreen && GetForegroundWindow() == g_ddraw->hwnd)
|
else if (g_ddraw->fullscreen && real_GetForegroundWindow() == g_ddraw->hwnd)
|
||||||
{
|
{
|
||||||
mouse_lock();
|
mouse_lock();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user