mirror of
https://github.com/ProjectLeonida/mandy.git
synced 2026-12-06 15:48:58 +00:00
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.
18 lines
787 B
C++
18 lines
787 B
C++
// The game's command line and exit, for `gta6rt --run` (shims/process.cpp).
|
|
#pragma once
|
|
#include <cstddef>
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
namespace rt::process {
|
|
|
|
// What the game sees as argv[0..] and GetCommandLine: `program` then `args`, quoted where needed.
|
|
void set_command_line(const std::string& program, const std::vector<std::string>& args);
|
|
|
|
// Runs a mapped EXE's entry point on a new thread with `stack_bytes` of reserved stack and returns the game's
|
|
// exit code: the entry point's return value, or what it passed to exit/ExitProcess (3 for abort). Returns when
|
|
// the first of those happens; other game threads are left running (the host process ends them when it exits).
|
|
int run_entry(void* entry, std::size_t stack_bytes = 8u << 20);
|
|
|
|
} // namespace rt::process
|