mirror of
https://gitea.shironeko-all.duckdns.org/shironeko/Hytale-F2P-2.git
synced 2026-02-26 02:31:46 -03:00
Patch Discord invite URLs in client binary
This commit is contained in:
@@ -143,6 +143,29 @@ class ClientPatcher {
|
|||||||
return { buffer: result, count };
|
return { buffer: result, count };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Patch Discord invite URLs from .gg/hytale to .gg/MHkEjepMQ7
|
||||||
|
*/
|
||||||
|
patchDiscordUrl(data) {
|
||||||
|
let count = 0;
|
||||||
|
const result = Buffer.from(data);
|
||||||
|
|
||||||
|
const oldUrl = '.gg/hytale';
|
||||||
|
const newUrl = '.gg/MHkEjepMQ7';
|
||||||
|
|
||||||
|
const oldUtf16 = this.stringToUtf16LE(oldUrl);
|
||||||
|
const newUtf16 = this.stringToUtf16LE(newUrl);
|
||||||
|
|
||||||
|
const positions = this.findAllOccurrences(result, oldUtf16);
|
||||||
|
|
||||||
|
for (const pos of positions) {
|
||||||
|
newUtf16.copy(result, pos);
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
|
||||||
|
return { buffer: result, count };
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if the client binary has already been patched
|
* Check if the client binary has already been patched
|
||||||
*/
|
*/
|
||||||
@@ -256,9 +279,12 @@ class ClientPatcher {
|
|||||||
console.log('Patching domain references...');
|
console.log('Patching domain references...');
|
||||||
const { buffer: patchedData, count } = this.findAndReplaceDomainSmart(data, ORIGINAL_DOMAIN, newDomain);
|
const { buffer: patchedData, count } = this.findAndReplaceDomainSmart(data, ORIGINAL_DOMAIN, newDomain);
|
||||||
|
|
||||||
if (count === 0) {
|
console.log('Patching Discord URLs...');
|
||||||
console.log('No occurrences of hytale.com found - binary may already be modified or has different format');
|
const { buffer: finalData, count: discordCount } = this.patchDiscordUrl(patchedData);
|
||||||
return { success: true, patchCount: 0, warning: 'No domain occurrences found' };
|
|
||||||
|
if (count === 0 && discordCount === 0) {
|
||||||
|
console.log('No occurrences found - binary may already be modified or has different format');
|
||||||
|
return { success: true, patchCount: 0, warning: 'No occurrences found' };
|
||||||
}
|
}
|
||||||
|
|
||||||
if (progressCallback) {
|
if (progressCallback) {
|
||||||
@@ -266,7 +292,7 @@ class ClientPatcher {
|
|||||||
}
|
}
|
||||||
|
|
||||||
console.log('Writing patched binary...');
|
console.log('Writing patched binary...');
|
||||||
fs.writeFileSync(clientPath, patchedData);
|
fs.writeFileSync(clientPath, finalData);
|
||||||
|
|
||||||
this.markAsPatched(clientPath);
|
this.markAsPatched(clientPath);
|
||||||
|
|
||||||
@@ -274,10 +300,10 @@ class ClientPatcher {
|
|||||||
progressCallback('Patching complete', 100);
|
progressCallback('Patching complete', 100);
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log(`Successfully patched ${count} occurrences`);
|
console.log(`Successfully patched ${count} domain occurrences and ${discordCount} Discord URLs`);
|
||||||
console.log('=== Patching Complete ===');
|
console.log('=== Patching Complete ===');
|
||||||
|
|
||||||
return { success: true, patchCount: count };
|
return { success: true, patchCount: count + discordCount };
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user