From 9cefca463a25ebed7a0eb8c60e7245201f8b69e0 Mon Sep 17 00:00:00 2001 From: FunkyFr3sh Date: Thu, 19 Dec 2024 06:58:42 +0100 Subject: [PATCH] add support for Seven Kingdoms II --- README.md | 1 + inc/hook.h | 4 +++- inc/winapi_hooks.h | 1 + src/config.c | 4 ++++ src/hook.c | 2 ++ src/winapi_hooks.c | 13 ++++++++++++- 6 files changed, 23 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 280812d875..195d80d00e 100644 --- a/README.md +++ b/README.md @@ -354,6 +354,7 @@ Wine (Linux/macOS/Android) only: override `ddraw` in [winecfg](https://wiki.wine - Sega Touring Car - Septerra Core - Settlers 3 +- Seven Kingdoms II - Shadow Flare - Shadow Watch - Shogo - Mobile Armor Division diff --git a/inc/hook.h b/inc/hook.h index a3e632adbd..f362562814 100644 --- a/inc/hook.h +++ b/inc/hook.h @@ -16,7 +16,7 @@ typedef struct HOOKLISTDATA { HMODULE mod; } HOOKLISTDATA; -typedef struct HOOKLIST { char module_name[32]; HOOKLISTDATA data[36]; } HOOKLIST; +typedef struct HOOKLIST { char module_name[32]; HOOKLISTDATA data[37]; } HOOKLIST; typedef BOOL(WINAPI* GETCURSORPOSPROC)(LPPOINT); typedef BOOL(WINAPI* CLIPCURSORPROC)(const RECT*); @@ -35,6 +35,7 @@ typedef BOOL(WINAPI* SETWINDOWPOSPROC)(HWND, HWND, int, int, int, int, UINT); typedef BOOL(WINAPI* MOVEWINDOWPROC)(HWND, int, int, int, int, BOOL); typedef LRESULT(WINAPI* SENDMESSAGEAPROC)(HWND, UINT, WPARAM, LPARAM); typedef LONG(WINAPI* SETWINDOWLONGAPROC)(HWND, int, LONG); +typedef LONG(WINAPI* SETWINDOWLONGWPROC)(HWND, int, LONG); typedef LONG(WINAPI* GETWINDOWLONGAPROC)(HWND, int); typedef BOOL(WINAPI* ENABLEWINDOWPROC)(HWND, BOOL); typedef HWND(WINAPI* CREATEWINDOWEXAPROC)(DWORD, LPCSTR, LPCSTR, DWORD, int, int, int, int, HWND, HMENU, HINSTANCE, LPVOID); @@ -99,6 +100,7 @@ extern SETWINDOWPOSPROC real_SetWindowPos; extern MOVEWINDOWPROC real_MoveWindow; extern SENDMESSAGEAPROC real_SendMessageA; extern SETWINDOWLONGAPROC real_SetWindowLongA; +extern SETWINDOWLONGWPROC real_SetWindowLongW; extern GETWINDOWLONGAPROC real_GetWindowLongA; extern ENABLEWINDOWPROC real_EnableWindow; extern CREATEWINDOWEXAPROC real_CreateWindowExA; diff --git a/inc/winapi_hooks.h b/inc/winapi_hooks.h index 1170ff0840..d9426fa3d1 100644 --- a/inc/winapi_hooks.h +++ b/inc/winapi_hooks.h @@ -21,6 +21,7 @@ BOOL WINAPI fake_SetWindowPos(HWND hWnd, HWND hWndInsertAfter, int X, int Y, int BOOL WINAPI fake_MoveWindow(HWND hWnd, int X, int Y, int nWidth, int nHeight, BOOL bRepaint); LRESULT WINAPI fake_SendMessageA(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam); LONG WINAPI fake_SetWindowLongA(HWND hWnd, int nIndex, LONG dwNewLong); +LONG WINAPI fake_SetWindowLongW(HWND hWnd, int nIndex, LONG dwNewLong); LONG WINAPI fake_GetWindowLongA(HWND hWnd, int nIndex); BOOL WINAPI fake_EnableWindow(HWND hWnd, BOOL bEnable); BOOL WINAPI fake_DestroyWindow(HWND hWnd); diff --git a/src/config.c b/src/config.c index cb5edce71e..591f2ec647 100644 --- a/src/config.c +++ b/src/config.c @@ -1550,6 +1550,10 @@ static void cfg_create_ini() "nonexclusive=true\n" "fake_mode=640x480x32\n" "\n" + "; Seven Kingdoms II\n" + "[7k2]\n" + "fake_mode=352x240x32\n" + "\n" "; Sid Meier's Simgolf\n" "[golf]\n" "fake_mode=640x480x16\n" diff --git a/src/hook.c b/src/hook.c index b6bab0a303..a7a9f56e10 100644 --- a/src/hook.c +++ b/src/hook.c @@ -34,6 +34,7 @@ SETWINDOWPOSPROC real_SetWindowPos = SetWindowPos; MOVEWINDOWPROC real_MoveWindow = MoveWindow; SENDMESSAGEAPROC real_SendMessageA = SendMessageA; SETWINDOWLONGAPROC real_SetWindowLongA = SetWindowLongA; +SETWINDOWLONGWPROC real_SetWindowLongW = SetWindowLongW; GETWINDOWLONGAPROC real_GetWindowLongA = GetWindowLongA; ENABLEWINDOWPROC real_EnableWindow = EnableWindow; CREATEWINDOWEXAPROC real_CreateWindowExA = CreateWindowExA; @@ -96,6 +97,7 @@ HOOKLIST g_hook_hooklist[] = { "MoveWindow", (PROC)fake_MoveWindow, (PROC*)&real_MoveWindow, 0 }, { "SendMessageA", (PROC)fake_SendMessageA, (PROC*)&real_SendMessageA, 0 }, { "SetWindowLongA", (PROC)fake_SetWindowLongA, (PROC*)&real_SetWindowLongA, 0 }, + { "SetWindowLongW", (PROC)fake_SetWindowLongW, (PROC*)&real_SetWindowLongW, 0 }, { "GetWindowLongA", (PROC)fake_GetWindowLongA, (PROC*)&real_GetWindowLongA, 0 }, { "EnableWindow", (PROC)fake_EnableWindow, (PROC*)&real_EnableWindow, 0 }, { "CreateWindowExA", (PROC)fake_CreateWindowExA, (PROC*)&real_CreateWindowExA, 0 }, diff --git a/src/winapi_hooks.c b/src/winapi_hooks.c index a2c5df918c..64b4e949ed 100644 --- a/src/winapi_hooks.c +++ b/src/winapi_hooks.c @@ -448,7 +448,7 @@ LRESULT WINAPI fake_SendMessageA(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lPar LONG WINAPI fake_SetWindowLongA(HWND hWnd, int nIndex, LONG dwNewLong) { - if (g_ddraw.ref && g_ddraw.hwnd == hWnd) + if (g_ddraw.ref && g_ddraw.hwnd && g_ddraw.hwnd == hWnd) { if (nIndex == GWL_STYLE) return 0; @@ -465,6 +465,17 @@ LONG WINAPI fake_SetWindowLongA(HWND hWnd, int nIndex, LONG dwNewLong) return real_SetWindowLongA(hWnd, nIndex, dwNewLong); } +LONG WINAPI fake_SetWindowLongW(HWND hWnd, int nIndex, LONG dwNewLong) +{ + if (g_ddraw.ref && g_ddraw.hwnd && g_ddraw.hwnd == hWnd) + { + if (nIndex == GWL_STYLE) + return 0; + } + + return real_SetWindowLongW(hWnd, nIndex, dwNewLong); +} + LONG WINAPI fake_GetWindowLongA(HWND hWnd, int nIndex) { if (g_ddraw.ref && g_ddraw.hwnd == hWnd)