From 4e6385ea27c902374f1dae18380d51fee5de07ce Mon Sep 17 00:00:00 2001 From: icex2 Date: Thu, 15 Aug 2024 13:24:43 +0200 Subject: [PATCH] feat(iidxhook1): Implement hook cleanup Summary: Test Plan: --- src/main/iidxhook1/iidxhook1.c | 45 +++++++++++++++++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-) diff --git a/src/main/iidxhook1/iidxhook1.c b/src/main/iidxhook1/iidxhook1.c index a1e8922..e302589 100644 --- a/src/main/iidxhook1/iidxhook1.c +++ b/src/main/iidxhook1/iidxhook1.c @@ -70,6 +70,12 @@ static void _iidxhook1_io_iidx_init(module_io_t **module) bt_io_iidx_api_set(&api); } +static void _iidxhook1_io_iidx_fini(module_io_t **module) +{ + bt_io_iidx_api_clear(); + module_io_free(module); +} + static void _iidxhook1_io_eam_init(module_io_t **module) { bt_io_eam_api_t api; @@ -80,6 +86,12 @@ static void _iidxhook1_io_eam_init(module_io_t **module) bt_io_eam_api_set(&api); } +static void _iidxhook1_io_eam_fini(module_io_t **module) +{ + bt_io_eam_api_clear(); + module_io_free(module); +} + static void iidxhook1_setup_d3d9_hooks( const struct iidxhook_config_gfx *config_gfx) { @@ -177,6 +189,8 @@ _iidxhook1_main_init(HMODULE game_module, const bt_core_config_t *config) // this needs to be launched before bm2dx.exe even loads the rteffect.dll // and runs DllMain of it (see also how this is done with the proxy // ezusb.dll) + + // TODO the default should also be off and the config should ask for enabling it if (config_misc.rteffect_stub) { effector_hook_init(); } @@ -193,6 +207,7 @@ _iidxhook1_main_init(HMODULE game_module, const bt_core_config_t *config) /* Disable operator menu clock setting system clock time */ + // TODO this should be inverted as the default is probably to not want it to be set if (config_misc.disable_clock_set) { iidxhook_util_clock_hook_init(); } @@ -236,7 +251,35 @@ _iidxhook1_main_init(HMODULE game_module, const bt_core_config_t *config) } static void _iidxhook1_main_fini() { - // TODO cleanup + // TODO guard these as they are config driven + ezusb_mon_hook_fini(); + ezusb_log_hook_fini(); + + ezusb_emu_device_hook_fini(); + hook_setupapi_fini(); + + // TODO how to cleanup iohook_push_handler? + + bt_io_eam_fini(); + + _iidxhook1_io_eam_fini(&_iidxhook1_module_io_eam); + + bt_io_iidx_fini(); + + _iidxhook1_io_iidx_fini(&_iidxhook1_module_io_iidx); + + // TODO guard because config driven + iidxhook_util_clock_hook_fini(); + + // TODO how to cleanup hook_d3d9_init? + + // TODO guard because config driven + effector_hook_fini(); + + settings_hook_fini(); + eamuse_hook_fini(); + adapter_hook_fini(); + acp_hook_fini(); } void bt_module_core_config_api_set(const bt_core_config_api_t *api)