Repository navigation
Runtime: the game's command line and ExitProcess under every import name (WinMain line, kernelbase, API sets) - #1786
Conversation
…port name The UCRT's _get_narrow_winmain_command_line and _get_wide_winmain_command_line were not shimmed, so a /MD WinMain executable got gta6rt's own command line as lpCmdLine. GetCommandLineA/W and ExitProcess were shimmed under kernel32.dll only, and the loader matches DLL names exactly. Imported from kernelbase.dll, or from the API sets the umbrella libraries bind them to (api-ms-win-core-processenvironment-l1-1-0, api-ms-win-core-processthreads-l1-1-0), they went to the host. The package's vcomp140.dll imports ExitProcess from the latter. process_cmdline_test checks every name and the WinMain line. docs/runtime_imports.md: the dry-run table regenerated at this commit. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…g it Without the shim, find() returns null and the WinMain check called it, ending the test with an access violation instead of a failure. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Flyander
left a comment
There was a problem hiding this comment.
Re-reviewed the import table and command-line tests. The new kernelbase/API-set names map to the existing process shims, and the WinMain line tests cover quoted names, no arguments, and non-ASCII executable names. No automated checks are visible for this head; I found no blocking issue in the diff.
|
Tested 7f67a9a on Intel(R) UHD Graphics (Tiger Lake (Xe-LP) iGPU 0x9a78, subgroup 8..32, no mesh), driver 32.0.101.7088, Windows 11, MSVC 14.44: pass Full runtime ctest (RelWithDebInfo): 85/89 pass. AI-assisted (GLM, operated by the account owner). |
Claimed in the coordination issue as: #1548 (comment) (new RT item)
What and why
gta6rt --rungives a mapped executable its own command line and turns itsExitProcessinto the end of the run (runtime/shims/process.cpp). Two import paths still reached the host:WinMain'slpCmdLine. The CRT's WinMain startup gets it from the UCRT's_get_narrow_winmain_command_line/_get_wide_winmain_command_line, and those weren't in the UCRT shim set. A/MDWinMain/wWinMainexecutable bound them to the host UCRT and got gta6rt's own command line (--run <exe> --game-dir … --) instead of the game's arguments.GetCommandLineA/WandExitProcesswere shimmed underkernel32.dllonly, and the loader matches DLL names exactly. The API-set umbrella libraries (OneCore_apiset.lib,mincore.libin SDK 10.0.26100) bind them toapi-ms-win-core-processenvironment-l1-1-0.dllandapi-ms-win-core-processthreads-l1-1-0.dll. The retail package's own DLLs import nearly everything that way;vcomp140.dlltakesExitProcessfrom thatprocessthreadsset. An executable built the same way would read gta6rt's command line, and itsExitProcesswould end the host before the exit code and the unimplemented-import summary are printed.The change:
_get_narrow_winmain_command_lineand_get_wide_winmain_command_linejoin the UCRT set (api-ms-win-crt-runtime-l1-1-0,ucrtbase,ucrtbased). They return the game's command line after the program name and the blanks that follow it, using the UCRT's own scan: the name ends at the first character up to' 'outside quotes. The compare is unsigned, so a non-ASCII byte of the narrow line stays part of the name.GetCommandLineA/WandExitProcessare also served underkernelbase.dlland those two API sets, aslibrary_loader.cppalready does for its functions.docs/runtime_imports.md: a paragraph on the above, and thegta6rt --dry-runtable regenerated. Againstmain's own build at89b047cd, onlyvcomp140.dllchanges: from 6 shim / 72 host to 7 / 71, itsExitProcess. ThelibHttpClient.GDK.dll,XCurl.dll,msvcp140.dllandvcomp140.dllrows were already behindmain; its build gives 10/188, 8/132, 9/178 and 6/72 for them.Tested
Windows 11, AMD Radeon RX 5700 (Adrenalin 26.11.2), MSVC 14.44, Ninja RelWithDebInfo, Vulkan SDK 1.4.363.1:
ctest: 102/102 pass. 5 were skipped: the package-gatedbink_decode,bink_audio,fsr_dispatchandbvh_builder(run withoutLEONIDA_GAME_DIR), andd3d12_rgb9e5_rtv(no RGB9E5 colour attachment on this GPU). The pass includesprocess_cmdline,loaderand everyrun_tiny_game*.process_cmdline_testnow checks two things. Everykernelbaseand API-set name hands out thekernel32shim. The WinMain line is right from bothapi-ms-win-crt-runtime-l1-1-0anducrtbasefor four cases: plain arguments, a quoted program name with a space, no arguments, and a non-ASCII program name.main'sprocess.cpp, the new checks fail (12 failures, exit 1). With this branch they pass.gta6rt --dry-runon all 16 package DLLs of my own 1.0.2.1 copy: every import binds, 0 unimplemented, with the counts in the table.AI-assisted (Claude Code).
Checklist
docs/runtime_imports.mdalready records.docs/design.md, with how it was confirmed. (N/A: no translator change.)🤖 Generated with Claude Code