From 38808740b432fec57a75d16f3741bf16425e9fc9 Mon Sep 17 00:00:00 2001 From: Tau Date: Sat, 12 Jun 2021 12:41:37 -0400 Subject: [PATCH] Statically link idzio --- idzhook/meson.build | 2 +- idzio/dllmain.c | 22 +++++++++++----------- idzio/meson.build | 3 +-- 3 files changed, 13 insertions(+), 14 deletions(-) diff --git a/idzhook/meson.build b/idzhook/meson.build index 668ad8a..b89e4e3 100644 --- a/idzhook/meson.build +++ b/idzhook/meson.build @@ -15,7 +15,7 @@ shared_library( amex_lib, board_lib, hooklib_lib, - idzio_dll, + idzio_lib, jvs_lib, platform_lib, util_lib, diff --git a/idzio/dllmain.c b/idzio/dllmain.c index 5edf67c..754e87a 100644 --- a/idzio/dllmain.c +++ b/idzio/dllmain.c @@ -13,7 +13,6 @@ #include "util/dprintf.h" #include "util/str.h" -static HMODULE idz_io_hmodule; static struct idz_io_config idz_io_cfg; static const struct idz_io_backend *idz_io_backend; static bool idz_io_coin; @@ -21,14 +20,24 @@ static uint16_t idz_io_coins; HRESULT idz_io_jvs_init(void) { + HINSTANCE inst; HRESULT hr; assert(idz_io_backend == NULL); + inst = GetModuleHandleW(NULL); + + if (inst == NULL) { + hr = HRESULT_FROM_WIN32(GetLastError()); + dprintf("GetModuleHandleW failed: %x\n", hr); + + return hr; + } + idz_io_config_load(&idz_io_cfg, L".\\segatools.ini"); if (wstr_ieq(idz_io_cfg.mode, L"dinput")) { - hr = idz_di_init(&idz_io_cfg.di, idz_io_hmodule, &idz_io_backend); + hr = idz_di_init(&idz_io_cfg.di, inst, &idz_io_backend); } else if (wstr_ieq(idz_io_cfg.mode, L"xinput")) { hr = idz_xi_init(&idz_io_cfg.xi, &idz_io_backend); } else { @@ -109,12 +118,3 @@ void idz_io_jvs_read_coin_counter(uint16_t *out) *out = idz_io_coins; } - -BOOL WINAPI DllMain(HMODULE self, DWORD reason, void *ctx) -{ - if (reason == DLL_PROCESS_ATTACH) { - idz_io_hmodule = self; - } - - return TRUE; -} diff --git a/idzio/meson.build b/idzio/meson.build index ce1668c..bfab168 100644 --- a/idzio/meson.build +++ b/idzio/meson.build @@ -1,9 +1,8 @@ -idzio_dll = shared_library( +idzio_lib = static_library( 'idzio', name_prefix : '', include_directories : inc, implicit_include_directories : false, - vs_module_defs : 'idzio.def', c_pch : '../precompiled.h', dependencies : [ dinput8_lib,