From db0dc8bd5ebce6e2bc27d47085f7f104eb3037d3 Mon Sep 17 00:00:00 2001 From: NotRexed Date: Fri, 20 Nov 2026 15:22:16 -0500 Subject: Initial commit: Leonida, build-it-yourself PC port groundwork Shader pipeline (carve, FSSM unpack, gfx1013 disassembly, RDNA2 to SPIR-V), asset export via rpf9-explorer's Core (submodule), PE loader and shim skeleton, and make_game.py, which builds from the user's own copy of the game. No game data, keys or executables are included. Co-Authored-By: Claude Opus 5.5 --- runtime/src/main.cpp | 72 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 runtime/src/main.cpp (limited to 'runtime/src/main.cpp') diff --git a/runtime/src/main.cpp b/runtime/src/main.cpp new file mode 100644 index 000000000..e69906c14 --- /dev/null +++ b/runtime/src/main.cpp @@ -0,0 +1,72 @@ +// gta6rt: native runtime for the Xbox Series build. +// +// gta6rt --dry-run [--game-dir DIR] +// Maps the image and its bundled modules, applies relocations, binds every import and prints a report. +// No code from the image runs. +#include + +#include +#include +#include + +#include "pe_loader.h" + +namespace { + +const char* binding_name(rt::Binding b) { + switch (b) { + case rt::Binding::Shim: return "shim"; + case rt::Binding::Host: return "host"; + case rt::Binding::Module: return "module"; + default: return "UNIMPLEMENTED"; + } +} + +int usage() { + std::fprintf(stderr, "usage: gta6rt --dry-run [--game-dir DIR]\n"); + return 2; +} + +} // namespace + +int wmain(int argc, wchar_t** argv) { + std::filesystem::path image, game_dir; + bool dry_run = false; + for (int i = 1; i < argc; ++i) { + std::wstring a = argv[i]; + if (a == L"--dry-run") dry_run = true; + else if (a == L"--game-dir" && i + 1 < argc) game_dir = argv[++i]; + else if (image.empty()) image = a; + else return usage(); + } + if (image.empty()) return usage(); + if (!dry_run) { + std::fprintf(stderr, "Only --dry-run exists so far: running game code needs the shims listed by it first.\n"); + return 2; + } + if (game_dir.empty()) game_dir = image.parent_path(); + + try { + rt::Loader loader(game_dir); + loader.load(image); + int unimplemented = 0; + for (auto* m : loader.modules()) { + std::map counts; + for (auto& r : m->imports) counts[r.binding]++; + std::printf("%-36s base=%p%s size=%u entry=+%#x shim=%d host=%d module=%d unimplemented=%d\n", + m->name.c_str(), m->base, m->relocated ? " (relocated)" : "", m->size, m->entry_rva, + counts[rt::Binding::Shim], counts[rt::Binding::Host], counts[rt::Binding::Module], + counts[rt::Binding::Unimplemented]); + for (auto& r : m->imports) + if (r.binding == rt::Binding::Unimplemented || r.binding == rt::Binding::Shim) { + std::printf(" %-13s %s!%s\n", binding_name(r.binding), r.dll.c_str(), r.name.c_str()); + unimplemented += r.binding == rt::Binding::Unimplemented; + } + } + std::printf("%zu module(s) mapped, %d unimplemented import(s)\n", loader.modules().size(), unimplemented); + return 0; + } catch (const std::exception& e) { + std::fprintf(stderr, "error: %s\n", e.what()); + return 1; + } +} -- cgit v1.2.3