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 <noreply@anthropic.com>
This commit is contained in:
sanasol
2026-01-27 03:31:51 +01:00
parent 81d1e7c113
commit 3953827f4a

View File

@@ -163,6 +163,14 @@ class ClientPatcher {
const positions = this.findAllOccurrences(result, oldBytes); const positions = this.findAllOccurrences(result, oldBytes);
for (const pos of positions) { 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 // First fill the entire old pattern region with zeros
// This prevents leftover bytes from causing memory corruption // This prevents leftover bytes from causing memory corruption
if (newBytes.length < oldBytes.length) { if (newBytes.length < oldBytes.length) {