From 704bbfd1f95e659e6df22b921baecfb47dbc38c5 Mon Sep 17 00:00:00 2001 From: NotRexed Date: Thu, 26 Nov 2026 02:28:26 -0500 Subject: process: log the title's debug output and its TerminateProcess Port VIctory's kernel.rs (GPL-3.0-or-later) OutputDebugStringA/W and TerminateProcess: the title's debug strings go to stderr as "[title] ..." (LEONIDA_TITLE_DEBUG_OUTPUT=0 silences them; the host still gets them for an attached debugger), and a TerminateProcess of the game's own process is logged with its code and caller before it is done, instead of ending gta6rt without a word. Co-Authored-By: Claude Opus 5.5 --- runtime/test/process_cmdline_test.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'runtime/test/process_cmdline_test.cpp') diff --git a/runtime/test/process_cmdline_test.cpp b/runtime/test/process_cmdline_test.cpp index fb0a0498c..89a1b7f03 100644 --- a/runtime/test/process_cmdline_test.cpp +++ b/runtime/test/process_cmdline_test.cpp @@ -269,6 +269,23 @@ int main() { SetProcessAffinityMask(GetCurrentProcess(), process_mask); } + // The title's debug output is served (and logged as "[title] ..."); TerminateProcess is served by the shim too. + { + using DebugA = void(WINAPI*)(LPCSTR); + using DebugW = void(WINAPI*)(LPCWSTR); + const auto debug_a = reinterpret_cast(rt::shims::find("kernelbase.dll", "OutputDebugStringA")); + const auto debug_w = + reinterpret_cast(rt::shims::find("api-ms-win-core-debug-l1-1-0.dll", "OutputDebugStringW")); + if (!debug_a || !debug_w || !rt::shims::find("kernel32.dll", "TerminateProcess")) { + std::fprintf(stderr, "FAIL OutputDebugStringA/W and TerminateProcess are not served\n"); + ++failures; + } else { + debug_a("process_cmdline: a narrow debug line\n"); + debug_w(L"process_cmdline: a wide debug line Δ"); + debug_a(nullptr); + } + } + if (failures) return 1; std::printf("process_cmdline: GetCommandLineW parses back to __wargv, non-ASCII arguments intact (code page %u); " "the WinMain line and the kernelbase/API-set names are the game's\n", -- cgit v1.2.3