diff --git a/.gitignore b/.gitignore index 02dfb39..2d0dbd0 100644 --- a/.gitignore +++ b/.gitignore @@ -3,4 +3,5 @@ build/ .idea .vscode .vs -version \ No newline at end of file +version +.DS_Store diff --git a/dist/iidx/iidxhook-27.conf b/dist/iidx/iidxhook-27.conf index 42f0709..b977db9 100644 --- a/dist/iidx/iidxhook-27.conf +++ b/dist/iidx/iidxhook-27.conf @@ -11,7 +11,7 @@ io.disable_poll_limiter=false io.lightning_mode=false # Disable camera connection -io.disable_cams=false +io.disable_cams=true # Disables the built in file hooks, requiring manual file creation io.disable_file_hooks=false diff --git a/src/main/inject/debugger.c b/src/main/inject/debugger.c index f42f774..536728d 100644 --- a/src/main/inject/debugger.c +++ b/src/main/inject/debugger.c @@ -13,6 +13,7 @@ #include "util/log.h" #include "util/mem.h" +#include "util/proc.h" #include "util/signal.h" #include "util/str.h" @@ -246,7 +247,7 @@ static bool debugger_create_process( return true; } -static bool debugger_loop() +static uint32_t debugger_loop() { DEBUG_EVENT de; DWORD continue_status; @@ -259,7 +260,7 @@ static bool debugger_loop() log_warning( "ERROR: WaitForDebugEvent failed: %08x", (unsigned int) GetLastError()); - return false; + return 1; } // Changed if applicable, e.g. on exceptions @@ -326,7 +327,7 @@ static bool debugger_loop() "EXIT_PROCESS_DEBUG_EVENT(pid %ld, tid %ld)", de.dwProcessId, de.dwThreadId); - return true; + return 0; case LOAD_DLL_DEBUG_EVENT: if (!debugger_get_file_name_from_handle( @@ -377,13 +378,15 @@ static bool debugger_loop() log_warning( "ERROR: ContinueDebugEvent failed: %08x", (unsigned int) GetLastError()); - return false; + return 1; } } } static DWORD WINAPI debugger_proc(LPVOID param) { + uint32_t debugger_loop_exit_code; + struct debugger_thread_params *params; params = (struct debugger_thread_params *) param; @@ -401,14 +404,24 @@ static DWORD WINAPI debugger_proc(LPVOID param) // Don't run our local debugger loop if the user wants to attach a remote // debugger or debugger is disabled if (params->local_debugger) { - debugger_loop(); + debugger_loop_exit_code = debugger_loop(); + + free(params); + + log_misc("Debugger loop quit"); + log_info("Terminating process, exit code: %d", debugger_loop_exit_code); + + proc_terminate_current_process(debugger_loop_exit_code); + + // Never reached + return 0; + } else { + free(params); + + log_misc("Debugger thread end"); + + return 0; } - - free(params); - - log_misc("Debugger thread end"); - - return 0; } bool debugger_init(bool local_debugger, const char *app_name, char *cmd_line) diff --git a/src/main/util/proc.c b/src/main/util/proc.c index eb2100e..8a3d518 100644 --- a/src/main/util/proc.c +++ b/src/main/util/proc.c @@ -11,5 +11,5 @@ void proc_terminate_current_process(uint32_t exit_code) TRUE, GetCurrentProcessId()); - TerminateProcess(hnd, 0); + TerminateProcess(hnd, exit_code); } \ No newline at end of file