Files
totk-pc-recomp/runtime/plugin_writes.h
T
Valiantsin DzerakhandClaude Opus 5.5 cc749d8679 A plugin's write into main's data that points at no plugin code is matched by place only at start (#1437, #1388)
The expect line of such a word says `* *` (tools/exefs_plugins.py plugin_lines), recomp/patches.py carries it into
RT_PLUGIN_WRITES as a flag, and runtime/plugin_init.c check_writes accepts any value there through
runtime/plugin_writes.h plugin_write_find. Hook branches in .text and pointers into a plugin's .text keep the exact
match. Zonai Fieldworks' Self Recall takes its storage off a pool size at main+0x3ad6eb8 that grows with the texture
heap of render_scale, so its plugin went off at every start with a grown heap.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-24 21:46:33 +03:00

32 lines
1.5 KiB
C

// The build's record of what a mod plugin's init writes into the game modules (patches.h RT_PLUGIN_WRITES, from the
// `expect` lines of recomp/patches.py), and the lookup plugin_init.c check_writes makes for every word an init changed
// at the start of the game.
#pragma once
#include <stdint.h>
#include <string.h>
// any: the expect line said `* *`, a word of main's .data or .bss that shapes no lifted code (tools/exefs_plugins.py
// plugin_lines). The game may hold another value there at play than in the service run (Zonai Fieldworks' Self Recall
// takes its storage off a pool size that grows with the resolution's texture heap), so it matches by place only. A
// hook branch in .text and a pointer into a plugin's .text match by place and both words.
typedef struct {
int plugin;
const char *module;
uint64_t off;
uint32_t old, now;
int any;
} PluginWrite;
// The X of RT_PLUGIN_WRITES for a table of PluginWrite.
#define PLUGIN_WRITE(p, mod, off, old, now, any) {p, mod, off, old, now, any},
// The index of the entry of plugin that records the write of module+off from old to now, or -1.
static inline int plugin_write_find(const PluginWrite *tab, int n, int plugin, const char *module, uint64_t off,
uint32_t old, uint32_t now) {
for (int k = 0; k < n; k++)
if (tab[k].plugin == plugin && tab[k].off == off && !strcmp(tab[k].module, module) &&
(tab[k].any || (tab[k].old == old && tab[k].now == now)))
return k;
return -1;
}