Skip to content

Commit

Permalink
add support for Seven Kingdoms II
Browse files Browse the repository at this point in the history
  • Loading branch information
FunkyFr3sh committed Dec 19, 2024
1 parent 7ac70bd commit 9cefca4
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 2 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion inc/hook.h
Original file line number Diff line number Diff line change
Expand Up @@ -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*);
Expand All @@ -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);
Expand Down Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions inc/winapi_hooks.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 4 additions & 0 deletions src/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 2 additions & 0 deletions src/hook.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 },
Expand Down
13 changes: 12 additions & 1 deletion src/winapi_hooks.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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)
Expand Down

0 comments on commit 9cefca4

Please sign in to comment.