mirror of
https://github.com/tangerineturtle1/NX2navi.git
synced 2026-11-17 13:39:58 -04:00
Add floor_watch: hardware watchpoints on the floor the scan finds log which game code reads and writes it, at 60 fps and again at 120 fps or more.
floor_watch.c takes up to twelve of the floor scan's survivors (the platform's rigid body controller unit first, then one per object at the pivot's height), watches them four at a time through the debug registers on every thread (platform.h plat_watch_set, Windows only), counts each access's call chain in a lock-free table and logs the chains with the executable's symbol names after each pass. prof_syms gains a callback form for that. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -24,7 +24,8 @@ static int cmp_u64(const void *a, const void *b) {
|
||||
static uint32_t rd32(const uint8_t *p) { return p[0] | p[1] << 8 | p[2] << 16 | (uint32_t)p[3] << 24; }
|
||||
static uint16_t rd16(const uint8_t *p) { return (uint16_t)(p[0] | p[1] << 8); }
|
||||
|
||||
int prof_syms_write(FILE *out, const char *exe_path, uint64_t base, const uint64_t *addr, size_t n) {
|
||||
int prof_syms_each(const char *exe_path, uint64_t base, const uint64_t *addr, size_t n,
|
||||
void (*fn)(void *ctx, uint64_t addr, const char *name, uint32_t offset), void *ctx) {
|
||||
FILE *f = fopen(exe_path, "rb");
|
||||
if (!f) return -1;
|
||||
uint8_t h[0x400];
|
||||
@@ -102,7 +103,7 @@ int prof_syms_write(FILE *out, const char *exe_path, uint64_t base, const uint64
|
||||
const CSym *c = &syms[j - 1];
|
||||
char sn[9] = {0};
|
||||
const char *nm = c->str ? (c->str < strsz ? strtab + c->str : "?") : (memcpy(sn, c->sname, 8), sn);
|
||||
fprintf(out, "sym %llx %s+0x%x\n", (unsigned long long)a[i], nm, rva - c->rva);
|
||||
fn(ctx, a[i], nm, rva - c->rva);
|
||||
named++;
|
||||
}
|
||||
done:
|
||||
@@ -110,3 +111,11 @@ done:
|
||||
fclose(f);
|
||||
return named;
|
||||
}
|
||||
|
||||
static void write_line(void *ctx, uint64_t addr, const char *name, uint32_t offset) {
|
||||
fprintf((FILE *)ctx, "sym %llx %s+0x%x\n", (unsigned long long)addr, name, offset);
|
||||
}
|
||||
|
||||
int prof_syms_write(FILE *out, const char *exe_path, uint64_t base, const uint64_t *addr, size_t n) {
|
||||
return prof_syms_each(exe_path, base, addr, n, write_line, out);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user