quote() escaped quotes but ignored CommandLineToArgvW's backslash rules,
so GetCommandLineA/W and __argv disagreed for an argument ending in a
backslash ("C:\My Games\" next" parsed back as 2 arguments, not 3) or
holding a backslash before a quote. A backslash run before a quote, or
before the closing quote, is now doubled.
widen() decoded the arguments as UTF-8, but main.cpp passes
std::filesystem::path::string(), which is ANSI code page text, so cafe
with an accent reached __wargv as caf\uFFFD. It widens from CP_ACP now;
under a UTF-8 activeCodePage that is the same thing.
New process_cmdline_test (ctest process_cmdline) checks that
GetCommandLineW parses back to __wargv.
Under Wine before 11.2, gta6rt --run sometimes exited 0 although the game
ended with 1 (run_tiny_game_exit_code in CI's Wine 9.0 job: 13 of 64 runs).
end_run signalled the host and called ExitThread; the host's ExitProcess
could then send SIGQUIT to that thread while it was exiting, Wine counted
the thread out twice and the process ended with _exit(0). Upstream fixed
it by blocking SIGQUIT during thread exit (4a9bc42a, wine-11.2).
end_run now parks every caller while a run is in progress (the first one
after recording the code and signalling), so no game thread is mid-exit
when the host calls ExitProcess. This also fixes two threads calling exit
at once: the second one called ExitProcess itself, sometimes before the
first had stored its code, and ended the process with 0 on any OS.
CI requires run_tiny_game_exit_code again.
A Debug build of the stand-in game links ucrtbased.dll rather than
ucrtbase.dll. The process shim only covered api-ms-win-crt-runtime and
ucrtbase, so __p___argc/__p___argv went to the host CRT. The game then got
gta6rt's own arguments (argc=6) and run_tiny_game failed in the Debug
configuration, which is the Visual Studio generator's default.
With runtime/shims on the include path, <thread>'s #include <process.h> found #316's header, so
_beginthreadex was undeclared in d3d12_com.cpp.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
gta6rt --run <exe> [-- args] maps and binds the executable, initialises its
modules and calls its entry point on a game thread. shims/process.cpp answers
the process-level imports through the game's own import table: argv/argc and
GetCommandLine are the game's (UCRT api-set/ucrtbase and msvcrt forms), and
exit/_exit/quick_exit/ExitProcess/abort end the run with that exit code
instead of the host. gta6rt then exits with the game's code directly, so the
game's atexit handlers don't run during host shutdown.
tiny_game.exe (CTest run_tiny_game, run_tiny_game_exit_code) does what a title
does in its first second: arguments, a static initializer, a 4 MiB allocation,
a file round trip, a thread, and xgameruntime.dll imports, which the shim
registry answers instead of the link-time stub. thread_local and a C++
exception are opt-in (LEONIDA_RUN_TLS / LEONIDA_RUN_EH) until #93 and #176.