Fix hook startup failure path

Returning from the EXE PE entry point merely terminates the main
thread and leaves the process hanging. We need to explicitly exit
from the process since the NTDLL RTL Start code won't do it for us.
This commit is contained in:
Tau
2021-05-23 14:17:14 -04:00
parent 1d6b7591ef
commit 972b3a5de8
5 changed files with 52 additions and 21 deletions

View File

@ -1,6 +1,5 @@
#include <windows.h>
#include <stddef.h>
#include <stdlib.h>
#include "amex/amex.h"
@ -73,25 +72,25 @@ static DWORD CALLBACK chuni_pre_startup(void)
chuni_hook_mod);
if (FAILED(hr)) {
return EXIT_FAILURE;
goto fail;
}
hr = amex_hook_init(&chuni_hook_cfg.amex, chunithm_jvs_init);
if (FAILED(hr)) {
return EXIT_FAILURE;
goto fail;
}
hr = slider_hook_init(&chuni_hook_cfg.slider);
if (FAILED(hr)) {
return EXIT_FAILURE;
goto fail;
}
hr = sg_reader_hook_init(&chuni_hook_cfg.aime, 12);
if (FAILED(hr)) {
return EXIT_FAILURE;
goto fail;
}
/* Initialize debug helpers */
@ -103,6 +102,9 @@ static DWORD CALLBACK chuni_pre_startup(void)
/* Jump to EXE start address */
return chuni_startup();
fail:
ExitProcess(EXIT_FAILURE);
}
BOOL WINAPI DllMain(HMODULE mod, DWORD cause, void *ctx)