From 443c4873fe23a0060767a4443dcc43efa284ebd0 Mon Sep 17 00:00:00 2001 From: chrg6 Date: Mon, 9 Nov 2026 05:57:18 -0500 Subject: [PATCH] Keep the cheat VM's main-module check from wrapping for addresses near the top of memory. Co-Authored-By: Claude Opus 5.5 --- runtime/cheats.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/runtime/cheats.c b/runtime/cheats.c index 2708b2ac..031cd643 100644 --- a/runtime/cheats.c +++ b/runtime/cheats.c @@ -152,7 +152,8 @@ static uint64_t region(int m) { } } -static int in_main(uint64_t a, unsigned n) { return a >= g_main && a + n <= g_main + g_main_size; } +// Without a + n: an address near 2^64 (a pointer chain that read -1) would wrap the sum and pass. +static int in_main(uint64_t a, unsigned n) { return a >= g_main && n <= g_main_size && a - g_main <= g_main_size - n; } static int guest_ok(uint64_t a, unsigned n, uint32_t perm) { if (in_main(a, n)) return 1;