From 3953827f4a47f9bda54d4b6e65d57ac846fbe487 Mon Sep 17 00:00:00 2001 From: sanasol Date: Tue, 27 Jan 2026 03:31:51 +0100 Subject: [PATCH] Add offset logging to debug which locations are being patched Shows hex offset, bytes before/after each patch location to help identify if we're patching false positives. Co-Authored-By: Claude Opus 4.5 --- backend/utils/clientPatcher.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/backend/utils/clientPatcher.js b/backend/utils/clientPatcher.js index 33e2df2..1922725 100644 --- a/backend/utils/clientPatcher.js +++ b/backend/utils/clientPatcher.js @@ -163,6 +163,14 @@ class ClientPatcher { const positions = this.findAllOccurrences(result, oldBytes); for (const pos of positions) { + // Log offset and surrounding bytes for debugging + const before = result.slice(Math.max(0, pos - 8), pos); + const after = result.slice(pos + oldBytes.length, Math.min(result.length, pos + oldBytes.length + 8)); + console.log(` Patching at offset 0x${pos.toString(16)} (${pos})`); + console.log(` Before: ${before.toString('hex')}`); + console.log(` Old pattern: ${oldBytes.slice(0, 20).toString('hex')}${oldBytes.length > 20 ? '...' : ''}`); + console.log(` After: ${after.toString('hex')}`); + // First fill the entire old pattern region with zeros // This prevents leftover bytes from causing memory corruption if (newBytes.length < oldBytes.length) {