From 0f2f3f5dacae1144fb4b5d5933c36ada451d1747 Mon Sep 17 00:00:00 2001 From: Felix Date: Mon, 25 Oct 2021 09:26:16 +0000 Subject: [PATCH] idzhook: Force framed window for ServerBox.exe in graphics hook --- idzhook/dllmain.c | 25 +++++++++++++++++++++++++ idzhook/meson.build | 1 + 2 files changed, 26 insertions(+) diff --git a/idzhook/dllmain.c b/idzhook/dllmain.c index d68df31b..545261d7 100644 --- a/idzhook/dllmain.c +++ b/idzhook/dllmain.c @@ -1,6 +1,9 @@ #include +#include +#include #include +#include #include "amex/amex.h" @@ -23,6 +26,7 @@ #include "platform/platform.h" #include "util/dprintf.h" +#include "util/lib.h" static HMODULE idz_hook_mod; static process_entry_t idz_startup; @@ -30,6 +34,8 @@ static struct idz_hook_config idz_hook_cfg; static DWORD CALLBACK idz_pre_startup(void) { + wchar_t *module_path; + wchar_t *file_name; HRESULT hr; dprintf("--- Begin idz_pre_startup ---\n"); @@ -38,6 +44,25 @@ static DWORD CALLBACK idz_pre_startup(void) idz_hook_config_load(&idz_hook_cfg, L".\\segatools.ini"); + module_path = module_file_name(NULL); + + if (module_path != NULL) { + file_name = PathFindFileNameW(module_path); + + _wcslwr(file_name); + + if (wcsstr(file_name, L"serverbox") != NULL) { + dprintf("Executable filename contains 'ServerBox', disabling full-screen mode\n"); + + idz_hook_cfg.gfx.windowed = true; + idz_hook_cfg.gfx.framed = true; + } + + free(module_path); + + module_path = NULL; + } + /* Hook Win32 APIs */ serial_hook_init(); diff --git a/idzhook/meson.build b/idzhook/meson.build index b89e4e3d..17b6484d 100644 --- a/idzhook/meson.build +++ b/idzhook/meson.build @@ -8,6 +8,7 @@ shared_library( dependencies : [ capnhook.get_variable('hook_dep'), capnhook.get_variable('hooklib_dep'), + shlwapi_lib, xinput_lib, ], link_with : [