mirror of
https://github.com/valentderah/totk-pc-recomp.git
synced 2026-11-21 21:05:56 +00:00
A mod plugin's init runs at every start and its hooks go on when it writes what the build recorded (#845)
After the design in #845 by itaskaev2, with one change: no image taken after a build-time run. When a plugin's patch set is on, sdk's DT_INIT runs first, then the plugin's, in the environment of the service run (rtld image below main, the QueryMemory view, the alias pool, process-memory aliases), then the game's constructors. That is rtld's order on the Switch (oss-rtld, librtld/source/ld.cpp __rtld_modules_init runs the modules from the last loaded to the first). sdk's first DT_INIT only registers it with its musl and main's DT_INIT finishes it, so its flag stays 1 and it is not called a second time. The plugin keeps its heap blocks, GOT and alias addresses. The words the init wrote into the game modules and the plugin's .text after it are compared with patches.h: equal, the set stays on; different, it goes off for this run, the reason is logged, the Mods tab row says so and build-cache/plugins.stale has the next start run the rebuild. The branches written into main's .text are taken back. mods.c reads build-cache/plugins.status: a built plugin's set joins its mod's sets and the Mods tab order, a refused one keeps its mod off with the reason (the catalog texts in en, ru, pt-BR, zh-Hans), a plugin without a line waits for the rebuild. A plugin file changed after the build is left out by the loader. TOTK_PLUGIN_TRACE=1 logs the first call of each hook entry. Without a plugin in the build nothing of this runs. --probe-mods covers a plugin set against another mod's patch on one site, a refused plugin, one the build lacks and one whose start differs. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
db6d548ba2
commit
d865000929
15 files changed
+631
-33
No files matched your search
+19
-3
@@ -1270,7 +1270,13 @@ static void tab_mods(float scale) {
|
||||
if (count) snprintf(cheat, sizeof cheat, menu_text(UI_MENU_MODS_CHEATS), count);
|
||||
else snprintf(cheat, sizeof cheat, menu_text(UI_MENU_MODS_CHEATS_FILE), cheats_file());
|
||||
}
|
||||
char code[512] = "", problem[512] = "", skipped[512] = "", left[512] = "";
|
||||
char code[512] = "", problem[768] = "", skipped[512] = "", left[512] = "", plugin[512] = "";
|
||||
if (m->plugin_off[0]) // its plugin's start differed from the build (plugin_init.c)
|
||||
snprintf(plugin, sizeof plugin, menu_text(UI_MENU_MODS_PLUGIN_OFF), m->plugin_off);
|
||||
else if (m->plugin_hooks && m->problem == MOD_OK)
|
||||
snprintf(plugin, sizeof plugin, menu_text(UI_MENU_MODS_PLUGIN_ON), m->plugin_hooks);
|
||||
else if (m->plugin_note[0] && m->problem != MOD_PLUGIN) // used without its code: the refusal stays visible
|
||||
snprintf(plugin, sizeof plugin, menu_text(UI_MENU_MODS_PLUGIN_REFUSED), m->plugin_file, m->plugin_note);
|
||||
if (m->code[0] && m->problem != MOD_PLUGIN) // used without its code
|
||||
snprintf(skipped, sizeof skipped, menu_text(UI_MENU_MODS_CODE_SKIPPED), m->code);
|
||||
if (m->unsupported && m->problem != MOD_EXEFS_UNSUPPORTED)
|
||||
@@ -1281,7 +1287,16 @@ static void tab_mods(float scale) {
|
||||
snprintf(code, sizeof code, menu_text(UI_MENU_MODS_EXEFS_ON), m->nsets + m->ndata);
|
||||
switch (m->problem) {
|
||||
case MOD_EMPTY: snprintf(problem, sizeof problem, "%s", menu_text(UI_MENU_MODS_EMPTY)); break;
|
||||
case MOD_PLUGIN: snprintf(problem, sizeof problem, "%s", menu_text(UI_MENU_MODS_SUBSDK)); break;
|
||||
case MOD_PLUGIN:
|
||||
if (m->plugin_note[0]) { // the build refused its plugin, and says why
|
||||
int n = snprintf(problem, sizeof problem, menu_text(UI_MENU_MODS_PLUGIN_REFUSED), m->plugin_file,
|
||||
m->plugin_note);
|
||||
if (n >= 0 && n < (int)sizeof problem)
|
||||
snprintf(problem + n, sizeof problem - n, " %s", menu_text(UI_MENU_MODS_PLUGIN_STAYS_OFF));
|
||||
} else {
|
||||
snprintf(problem, sizeof problem, "%s", menu_text(UI_MENU_MODS_SUBSDK));
|
||||
}
|
||||
break;
|
||||
case MOD_EXEFS_LATER: snprintf(problem, sizeof problem, "%s", menu_text(UI_MENU_MODS_EXEFS_LATER)); break;
|
||||
case MOD_EXEFS_UNSUPPORTED:
|
||||
snprintf(problem, sizeof problem, menu_text(UI_MENU_MODS_EXEFS_UNSUPPORTED), m->note);
|
||||
@@ -1291,7 +1306,8 @@ static void tab_mods(float scale) {
|
||||
default: break;
|
||||
}
|
||||
int k = snprintf(desc, sizeof desc, menu_text(UI_MENU_MODS_ROW_DESC), m->replaced, m->added);
|
||||
const char *parts[] = {over, other, cheat, code, skipped, left, problem, menu_text(UI_MENU_MODS_MOVE_HINT)};
|
||||
const char *parts[] = {over, other, cheat, code, plugin, skipped, left, problem,
|
||||
menu_text(UI_MENU_MODS_MOVE_HINT)};
|
||||
for (const char *part : parts)
|
||||
if (*part && k >= 0 && k < (int)sizeof desc) k += snprintf(desc + k, sizeof desc - k, "\n\n%s", part);
|
||||
const char *note = m->enabled && m->problem != MOD_OK ? menu_text(UI_MENU_MODS_UNUSED) : after;
|
||||
|
||||
Reference in new issue
Block a user