mirror of
https://gitea.tendokyu.moe/TeamTofuShop/capnhook.git
synced 2026-09-30 02:48:05 +03:00
Make inject return the injected program's exit code (#8)
This adds that if a process has ran successfully with inject, the exit code from the child process is returned, instead of always success. Reviewed-on: https://gitea.tendokyu.moe/TeamTofuShop/capnhook/pulls/8 Co-authored-by: kyoubate-haruka <46010460+kyoubate-haruka@users.noreply.github.com> Co-committed-by: kyoubate-haruka <46010460+kyoubate-haruka@users.noreply.github.com>
This commit is contained in:
+7
-1
@@ -21,6 +21,7 @@ int main(int argc, char **argv)
|
||||
STARTUPINFO si;
|
||||
HRESULT hr;
|
||||
BOOL ok;
|
||||
DWORD exitCode;
|
||||
|
||||
hr = options_init(&opt, argc, argv);
|
||||
|
||||
@@ -102,11 +103,16 @@ int main(int argc, char **argv)
|
||||
}
|
||||
|
||||
end:
|
||||
|
||||
exitCode = ERROR_SUCCESS;
|
||||
|
||||
if (pi.hProcess != NULL) {
|
||||
if (FAILED(hr)) {
|
||||
TerminateProcess(pi.hProcess, EXIT_FAILURE);
|
||||
}
|
||||
|
||||
GetExitCodeProcess(pi.hProcess, &exitCode);
|
||||
|
||||
CloseHandle(pi.hProcess);
|
||||
}
|
||||
|
||||
@@ -116,7 +122,7 @@ end:
|
||||
|
||||
free(cmdline);
|
||||
|
||||
return FAILED(hr) ? EXIT_FAILURE : EXIT_SUCCESS;
|
||||
return FAILED(hr) ? EXIT_FAILURE : exitCode;
|
||||
}
|
||||
|
||||
static HRESULT inject_dll(HANDLE process, const char *dll_name)
|
||||
|
||||
Reference in New Issue
Block a user