mirror of
https://git.sanhost.net/sanasol/hytale-f2p
synced 2026-02-26 11:41:49 -03:00
fix: Revert null-padding - was corrupting adjacent data
The null-fill before overwrite was likely corrupting data after the string, causing crashes. Reverted to develop behavior: only overwrite the bytes we need to change. Also re-enabled sentry patching. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -141,8 +141,8 @@ class ClientPatcher {
|
||||
}
|
||||
|
||||
/**
|
||||
* Replace bytes in buffer with null-padding for shorter replacements
|
||||
* When new pattern is shorter than old, pads with 0x00 to prevent leftover bytes
|
||||
* Replace bytes in buffer - only overwrites the length of new bytes
|
||||
* Does NOT null-pad to avoid corrupting adjacent data
|
||||
*/
|
||||
replaceBytes(buffer, oldBytes, newBytes) {
|
||||
let count = 0;
|
||||
@@ -156,10 +156,7 @@ class ClientPatcher {
|
||||
const positions = this.findAllOccurrences(result, oldBytes);
|
||||
|
||||
for (const pos of positions) {
|
||||
// Zero-fill the old region first if new is shorter (prevents leftover bytes)
|
||||
if (newBytes.length < oldBytes.length) {
|
||||
result.fill(0x00, pos, pos + oldBytes.length);
|
||||
}
|
||||
// Only overwrite the length of the new bytes - don't null-fill!
|
||||
newBytes.copy(result, pos);
|
||||
count++;
|
||||
}
|
||||
@@ -214,11 +211,7 @@ class ClientPatcher {
|
||||
const lastCharFirstByte = result[lastCharPos];
|
||||
|
||||
if (lastCharFirstByte === oldLastCharByte) {
|
||||
// Zero-fill first if new is shorter
|
||||
if (newUtf16NoLast.length < oldUtf16NoLast.length) {
|
||||
result.fill(0x00, pos, pos + oldUtf16NoLast.length);
|
||||
}
|
||||
|
||||
// Only overwrite, don't null-fill
|
||||
newUtf16NoLast.copy(result, pos);
|
||||
result[lastCharPos] = newLastCharByte;
|
||||
count++;
|
||||
@@ -238,21 +231,20 @@ class ClientPatcher {
|
||||
|
||||
console.log(` Patching strategy: ${strategy.description}`);
|
||||
|
||||
// 1. Patch telemetry/sentry URL - DISABLED: May cause crash on glibc 2.41+
|
||||
// The sentry string is near executable code and patching it may corrupt memory layout
|
||||
// const oldSentry = 'https://ca900df42fcf57d4dd8401a86ddd7da2@sentry.hytale.com/2';
|
||||
// const newSentry = `${protocol}t@${domain}/2`;
|
||||
// const sentryResult = this.replaceBytes(
|
||||
// result,
|
||||
// this.stringToLengthPrefixed(oldSentry),
|
||||
// this.stringToLengthPrefixed(newSentry)
|
||||
// );
|
||||
// result = sentryResult.buffer;
|
||||
// if (sentryResult.count > 0) {
|
||||
// console.log(` Patched ${sentryResult.count} sentry URL(s)`);
|
||||
// totalCount += sentryResult.count;
|
||||
// }
|
||||
console.log(` Skipping sentry patch (stability fix)`);
|
||||
// 1. Patch telemetry/sentry URL
|
||||
const oldSentry = 'https://ca900df42fcf57d4dd8401a86ddd7da2@sentry.hytale.com/2';
|
||||
const newSentry = `${protocol}t@${domain}/2`;
|
||||
|
||||
const sentryResult = this.replaceBytes(
|
||||
result,
|
||||
this.stringToLengthPrefixed(oldSentry),
|
||||
this.stringToLengthPrefixed(newSentry)
|
||||
);
|
||||
result = sentryResult.buffer;
|
||||
if (sentryResult.count > 0) {
|
||||
console.log(` Patched ${sentryResult.count} sentry URL(s)`);
|
||||
totalCount += sentryResult.count;
|
||||
}
|
||||
|
||||
// 2. Patch main domain (hytale.com -> mainDomain)
|
||||
const domainResult = this.replaceBytes(
|
||||
|
||||
Reference in New Issue
Block a user