From 244f4aa56aa46f4f4b353b82d8e64f9290fb2fe7 Mon Sep 17 00:00:00 2001 From: "[ ]" <[ ]> Date: Sun, 11 Jan 2026 21:11:55 +0900 Subject: [PATCH] refactor/fix: Resolve some wmisc issues > fix crashes around missing call convention/log hook > enable wmisc for M39 as well, see #8 --- games/iidx/iidx.cpp | 8 -------- hooks/sndbhook.cpp | 1 + hooks/wmischook.cpp | 8 ++++++-- launcher/launcher.cpp | 9 +++++++++ 4 files changed, 16 insertions(+), 10 deletions(-) diff --git a/games/iidx/iidx.cpp b/games/iidx/iidx.cpp index da27792..2ecc985 100644 --- a/games/iidx/iidx.cpp +++ b/games/iidx/iidx.cpp @@ -18,8 +18,6 @@ #endif #include "hooks/setupapihook.h" #include "hooks/sleephook.h" -#include "hooks/sndbhook.h" -#include "hooks/wmischook.h" #include "launcher/options.h" #include "touch/touch.h" #include "misc/wintouchemu.h" @@ -408,10 +406,6 @@ namespace games::iidx { // init cfgmgr32 hooks cfgmgr32hook_init(avs::game::DLL_INSTANCE); - // wine fixes - hooks::wmisc::apply_performance_hacks(avs::game::DLL_INSTANCE, avs::game::MODEL, avs::game::EXT); - hooks::soundbank::init(avs::game::DLL_INSTANCE, avs::game::MODEL, avs::game::EXT); - // report common errors on iidx31 and above if (avs::game::is_ext(2023091500, MAXINT) && GRAPHICS_9_ON_12_STATE == DX9ON12_FORCE_ON) { deferredlogs::defer_error_messages({ @@ -468,8 +462,6 @@ namespace games::iidx { } void IIDXGame::detach() { - hooks::soundbank::deinit(avs::game::DLL_INSTANCE); - Game::detach(); devicehook_dispose(); diff --git a/hooks/sndbhook.cpp b/hooks/sndbhook.cpp index 2b6a8c9..1fdc1f6 100644 --- a/hooks/sndbhook.cpp +++ b/hooks/sndbhook.cpp @@ -889,6 +889,7 @@ public: } tests_("sndb_test"); void init(HINSTANCE hmodule, const char *model, const char *ext) { + if (to_hash(model) != to_hash("LDJ")) return; if (false && IsDebuggerPresent()) { log_warning("hooks::soundbank", "Debugger detected, skipping.."); diff --git a/hooks/wmischook.cpp b/hooks/wmischook.cpp index c491cc2..1df3144 100644 --- a/hooks/wmischook.cpp +++ b/hooks/wmischook.cpp @@ -9,7 +9,7 @@ namespace hooks::wmisc::msacm { -typedef MMRESULT (*acmFormatSuggest_t)(HANDLE had, LPWAVEFORMATEX pwfxSrc, LPWAVEFORMATEX pwfxDst, DWORD cbwfxDst, DWORD fdwSuggest); +typedef MMRESULT (__stdcall *acmFormatSuggest_t)(HANDLE had, LPWAVEFORMATEX pwfxSrc, LPWAVEFORMATEX pwfxDst, DWORD cbwfxDst, DWORD fdwSuggest); static acmFormatSuggest_t acmFormatSuggest; static uint64_t hash_waveformatex(const WAVEFORMATEX *pwfx, DWORD fdwSuggest) @@ -129,7 +129,7 @@ extern "C" void __cdecl on_log_msg(char level, const char *scope, const char *ms } void attach(HINSTANCE hmodule) { - BmswLogInit_t BmswLogInit; + BmswLogInit_t BmswLogInit = nullptr; HMODULE bmsw; if ((bmsw = libutils::try_library(MODULE_PATH / "bmsound-wine.dll"))) { @@ -161,6 +161,10 @@ void apply_performance_hacks(HINSTANCE hmodule, const char *model, const char *e msacm::attach(hmodule); bmsound::attach(hmodule); break; + case to_hash("M39"): + msacm::attach(hmodule); + bmsound::attach(hmodule); + break; case to_hash("FORCE"): switch (to_hash(ext)) { diff --git a/launcher/launcher.cpp b/launcher/launcher.cpp index 525eaf7..2256a63 100644 --- a/launcher/launcher.cpp +++ b/launcher/launcher.cpp @@ -74,6 +74,8 @@ #include "hooks/lang.h" #include "hooks/networkhook.h" #include "hooks/unisintrhook.h" +#include "hooks/sndbhook.h" +#include "hooks/wmischook.h" #include "launcher/launcher.h" #include "launcher/logger.h" #include "launcher/signal.h" @@ -2077,6 +2079,10 @@ int main_implementation(int argc, char *argv[]) { game->attach(); } + // wine fixes + hooks::wmisc::apply_performance_hacks(avs::game::DLL_INSTANCE, avs::game::MODEL, avs::game::EXT); + hooks::soundbank::init(avs::game::DLL_INSTANCE, avs::game::MODEL, avs::game::EXT); + #ifdef SPICE64 if (!cfg::CONFIGURATOR_STANDALONE) { if (games::iidx::TDJ_CAMERA) { @@ -2268,6 +2274,9 @@ int main_implementation(int argc, char *argv[]) { // clear presence richpresence::shutdown(); + // cleanup wine fixes + hooks::soundbank::deinit(avs::game::DLL_INSTANCE); + // detach games for (auto game : games) { game->detach();