totk.exe --plugin-init runs a mod plugin's init on our kernel and records what it did (#845)

The plugin service run loads the modules as boot does, runs sdk's DT_INIT and then each plugin's from nn::init::Start's
module-init callback (rtld initialises the last loaded module first), writes the record and exits before any game
constructor, graphics or audio. The record holds every word the init wrote into a game module, the plugin's image
before and after its init, the process-memory maps, and the svcs and imports it called.

exlaunch's init needs a Switch-like address space: QueryMemory shows the game's own rtld image below main and the
host's ranges as Inaccessible (it takes Code RX runs for modules), and a 64 GiB free pool for its random alias picks.
New svcs: GetSystemTick, GetInfo 65001 (current process handle), and Map/UnmapProcessMemory, which only the service
run serves: an alias is a copy whose changed words go back into the source when it is unmapped. Any other svc, such
as the CreateSession fallback, ends the run with a reason. nn::oe::GetDisplayVersion is answered with the build's game
version. The game calls none of these svcs; the SVC trace test is still one mask test per SVC.

After the design in #845 by itaskaev2, with the init run natively instead of under Unicorn.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Valiantsin DzerakhandClaude Opus 5.5 committed 2026-11-17 08:05:19 +03:00
1 parent b94e8127af
commit b488d9e41d
11 files changed
+559 -22

No files matched your search

+6 -1
View File
@@ -611,7 +611,7 @@ static int usage(const char *argv0) {
"--probe-cfg | --probe-dpi | --probe-mods | --probe-playtime | --probe-kernel | --probe-ipc | --probe-services | --probe-fs | --probe-gfx-abi | "
"--probe-nvn | --probe-nvn-tex | --probe-window | --probe-shader | --probe-vkmem | "
"--probe-vkexec | --probe-astc | --probe-movie | --probe-crash-call | --probe-crash-null | --probe-discord | "
"--prepare-shaders | --warm-shaders | --boot |--seconds S [--shot PNG]]\n", argv0);
"--prepare-shaders | --warm-shaders | --boot | --plugin-init DIR | --seconds S [--shot PNG]]\n", argv0);
return 2;
}
@@ -700,6 +700,10 @@ int main(int argc, char **argv) {
} else if (!strcmp(argv[i], "--shot")) {
if (++i == argc) return usage(argv[0]);
cfg.shot = argv[i];
} else if (!mode && !strcmp(argv[i], "--plugin-init")) { // the plugin service run (plugin_init.c)
if (++i == argc) return usage(argv[0]);
mode = argv[i - 1];
cfg.plugin_init = argv[i];
} else if (!mode && !strncmp(argv[i], "--", 2)) {
mode = argv[i];
} else {
@@ -744,5 +748,6 @@ int main(int argc, char **argv) {
if (!strcmp(mode, "--prepare-shaders")) return vk_pipeline_prepare_shaders();
if (!strcmp(mode, "--warm-shaders")) return vk_pipeline_warm_shaders();
if (!strcmp(mode, "--boot")) { cfg.boot = 1; rt_boot(); return 0; }
if (!strcmp(mode, "--plugin-init")) { rt_boot_plugin_init(); return 0; }
return usage(argv[0]);
}