From a87b8f72fae9c683b76f333c09a4ab83c2065bf0 Mon Sep 17 00:00:00 2001 From: Tau Date: Tue, 5 Nov 2019 18:03:24 -0500 Subject: [PATCH] Abort hook DLLs on startup error --- chunihook/dllmain.c | 27 +++++++++++++++++++++++---- divahook/dllmain.c | 28 ++++++++++++++++++++++++---- idzhook/dllmain.c | 26 +++++++++++++++++++++++--- mu3hook/dllmain.c | 33 +++++++++++++++++++++++++++++---- 4 files changed, 99 insertions(+), 15 deletions(-) diff --git a/chunihook/dllmain.c b/chunihook/dllmain.c index 6c1dcf7..b543402 100644 --- a/chunihook/dllmain.c +++ b/chunihook/dllmain.c @@ -30,6 +30,7 @@ static struct chuni_hook_config chuni_hook_cfg; static DWORD CALLBACK chuni_pre_startup(void) { HMODULE d3dc; + HRESULT hr; dprintf("--- Begin chuni_pre_startup ---\n"); @@ -54,15 +55,33 @@ static DWORD CALLBACK chuni_pre_startup(void) /* Initialize emulation hooks */ - platform_hook_init( + hr = platform_hook_init( &chuni_hook_cfg.platform, "SDBT", "AAV1", chuni_hook_mod); - amex_hook_init(&chuni_hook_cfg.amex, chunithm_jvs_init); - slider_hook_init(&chuni_hook_cfg.slider); - sg_reader_hook_init(&chuni_hook_cfg.aime, 12); + if (FAILED(hr)) { + return EXIT_FAILURE; + } + + hr = amex_hook_init(&chuni_hook_cfg.amex, chunithm_jvs_init); + + if (FAILED(hr)) { + return EXIT_FAILURE; + } + + hr = slider_hook_init(&chuni_hook_cfg.slider); + + if (FAILED(hr)) { + return EXIT_FAILURE; + } + + hr = sg_reader_hook_init(&chuni_hook_cfg.aime, 12); + + if (FAILED(hr)) { + return EXIT_FAILURE; + } /* Initialize debug helpers */ diff --git a/divahook/dllmain.c b/divahook/dllmain.c index 59e11ca..a194f84 100644 --- a/divahook/dllmain.c +++ b/divahook/dllmain.c @@ -27,6 +27,8 @@ static struct diva_hook_config diva_hook_cfg; static DWORD CALLBACK diva_pre_startup(void) { + HRESULT hr; + dprintf("--- Begin diva_pre_startup ---\n"); /* Config load */ @@ -39,15 +41,33 @@ static DWORD CALLBACK diva_pre_startup(void) /* Initialize emulation hooks */ - platform_hook_init( + hr = platform_hook_init( &diva_hook_cfg.platform, "SBZV", "AAV0", diva_hook_mod); - amex_hook_init(&diva_hook_cfg.amex, diva_jvs_init); - sg_reader_hook_init(&diva_hook_cfg.aime, 10); - slider_hook_init(); + if (FAILED(hr)) { + return EXIT_FAILURE; + } + + hr = amex_hook_init(&diva_hook_cfg.amex, diva_jvs_init); + + if (FAILED(hr)) { + return EXIT_FAILURE; + } + + hr = sg_reader_hook_init(&diva_hook_cfg.aime, 10); + + if (FAILED(hr)) { + return EXIT_FAILURE; + } + + hr = slider_hook_init(); + + if (FAILED(hr)) { + return EXIT_FAILURE; + } /* Initialize debug helpers */ diff --git a/idzhook/dllmain.c b/idzhook/dllmain.c index c02b991..a54e4bd 100644 --- a/idzhook/dllmain.c +++ b/idzhook/dllmain.c @@ -27,6 +27,8 @@ static struct idz_hook_config idz_hook_cfg; static DWORD CALLBACK idz_pre_startup(void) { + HRESULT hr; + dprintf("--- Begin idz_pre_startup ---\n"); /* Config load */ @@ -40,9 +42,27 @@ static DWORD CALLBACK idz_pre_startup(void) /* Initialize emulation hooks */ - platform_hook_init(&idz_hook_cfg.platform, "SDDF", "AAV2", idz_hook_mod); - amex_hook_init(&idz_hook_cfg.amex, idz_jvs_init); - sg_reader_hook_init(&idz_hook_cfg.aime, 10); + hr = platform_hook_init( + &idz_hook_cfg.platform, + "SDDF", + "AAV2", + idz_hook_mod); + + if (FAILED(hr)) { + return hr; + } + + hr = amex_hook_init(&idz_hook_cfg.amex, idz_jvs_init); + + if (FAILED(hr)) { + return hr; + } + + hr = sg_reader_hook_init(&idz_hook_cfg.aime, 10); + + if (FAILED(hr)) { + return hr; + } /* Initialize debug helpers */ diff --git a/mu3hook/dllmain.c b/mu3hook/dllmain.c index 11a0fbc..c34bc51 100644 --- a/mu3hook/dllmain.c +++ b/mu3hook/dllmain.c @@ -22,6 +22,8 @@ static struct mu3_hook_config mu3_hook_cfg; static DWORD CALLBACK mu3_pre_startup(void) { + HRESULT hr; + dprintf("--- Begin mu3_pre_startup ---\n"); /* Load config */ @@ -34,10 +36,33 @@ static DWORD CALLBACK mu3_pre_startup(void) /* Initialize emulation hooks */ - platform_hook_init(&mu3_hook_cfg.platform, "SDDT", "AAV2", mu3_hook_mod); - sg_reader_hook_init(&mu3_hook_cfg.aime, 1); - vfd_hook_init(2); - mu3_io4_hook_init(); + hr = platform_hook_init( + &mu3_hook_cfg.platform, + "SDDT", + "AAV2", + mu3_hook_mod); + + if (FAILED(hr)) { + return hr; + } + + hr = sg_reader_hook_init(&mu3_hook_cfg.aime, 1); + + if (FAILED(hr)) { + return hr; + } + + hr = vfd_hook_init(2); + + if (FAILED(hr)) { + return hr; + } + + hr = mu3_io4_hook_init(); + + if (FAILED(hr)) { + return hr; + } /* Initialize debug helpers */