diff --git a/G-Earth/src/main/java/gearth/services/unity_tools/UnityWebModifyer.java b/G-Earth/src/main/java/gearth/services/unity_tools/UnityWebModifyer.java index b9a7c8d..e0cc5fb 100644 --- a/G-Earth/src/main/java/gearth/services/unity_tools/UnityWebModifyer.java +++ b/G-Earth/src/main/java/gearth/services/unity_tools/UnityWebModifyer.java @@ -125,7 +125,7 @@ public class UnityWebModifyer { contents = contents .replace("var _free", "_free") .replace("var _malloc", "_malloc") - .replace("var Module", "Module") + .replace("var Module=typeof Module!==\"undefined\"?Module:{};", "var Module=typeof Module!==\"undefined\"?Module:{}; _module = Module") .replace("{{RevisionName}}", revision); BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(new GZIPOutputStream(new FileOutputStream(frameworkFile)))); diff --git a/G-Earth/src/main/java/gearth/services/unity_tools/codepatcher/ReturnBytePatcher.java b/G-Earth/src/main/java/gearth/services/unity_tools/codepatcher/ReturnBytePatcher.java index 6f8040c..c2ac300 100644 --- a/G-Earth/src/main/java/gearth/services/unity_tools/codepatcher/ReturnBytePatcher.java +++ b/G-Earth/src/main/java/gearth/services/unity_tools/codepatcher/ReturnBytePatcher.java @@ -37,7 +37,7 @@ public class ReturnBytePatcher implements StreamReplacement { @Override public boolean codeMatches(Func code) { if (code.getLocalss().size() != 0) return false; - if (code.getExpression().getInstructions().size() != 30) return false; + if (code.getExpression().getInstructions().size() != 26) return false; List expr = code.getExpression().getInstructions(); if (expr.get(expr.size() - 1).getInstrType() != InstrType.I32_XOR) return false; return true; diff --git a/G-Earth/src/main/resources/gearth/services/unity_tools/js_code/unity_code.js b/G-Earth/src/main/resources/gearth/services/unity_tools/js_code/unity_code.js index ce04a2f..46b4145 100644 --- a/G-Earth/src/main/resources/gearth/services/unity_tools/js_code/unity_code.js +++ b/G-Earth/src/main/resources/gearth/services/unity_tools/js_code/unity_code.js @@ -20,7 +20,7 @@ let _gearth_incoming_copy; let _malloc; let _free; -let Module; +let _module; var packetBuff = {"out": [], "in": []}; @@ -98,10 +98,10 @@ function inject_out(packet) { let inject_amount = Math.min(_g_packet_split, packet.length - i); let packet_location = _malloc(inject_amount + 16); - Module.HEAPU8.set(out_packet_objid, packet_location); - Module.HEAPU8.fill(0, packet_location + 4, packet_location + 12); - Module.HEAPU8.set(writeLittleEndian(inject_amount), packet_location + 12); - Module.HEAPU8.set(packet.slice(i, i + inject_amount), packet_location + 16); + _module.HEAPU8.set(out_packet_objid, packet_location); + _module.HEAPU8.fill(0, packet_location + 4, packet_location + 12); + _module.HEAPU8.set(writeLittleEndian(inject_amount), packet_location + 12); + _module.HEAPU8.set(packet.slice(i, i + inject_amount), packet_location + 16); _gearth_outgoing_copy(out_send_param1, packet_location, out_send_param3); _free(packet_location); @@ -129,8 +129,8 @@ function inject_in(packet) { let inject_amount = Math.min(_g_packet_split, packet.length - i); let packet_location = _malloc(inject_amount + 16); - Module.HEAPU8.set(in_packet_prefix, packet_location); - Module.HEAPU8.set(packet.slice(i, i + inject_amount), packet_location + 16); + _module.HEAPU8.set(in_packet_prefix, packet_location); + _module.HEAPU8.set(packet.slice(i, i + inject_amount), packet_location + 16); _gearth_incoming_copy(in_recv_param1, packet_location, 0, inject_amount, 0); _free(packet_location); diff --git a/G-Earth/src/main/resources/gearth/services/unity_tools/js_code/unity_imports.js b/G-Earth/src/main/resources/gearth/services/unity_tools/js_code/unity_imports.js index e602910..e5da2fb 100644 --- a/G-Earth/src/main/resources/gearth/services/unity_tools/js_code/unity_imports.js +++ b/G-Earth/src/main/resources/gearth/services/unity_tools/js_code/unity_imports.js @@ -30,27 +30,20 @@ function g_incoming_packet(param1, param2, param3, param4, param5) { } } -// function g_chacha_setkey(param1, param2, param3, param4) { -// if (chachas.length === 2) { -// chachas = []; -// } -// -// chachas.push(param1); -// } +function g_chacha_setkey(param1, param2, param3, param4) { + if (chachas.length === 2) { + chachas = []; + } + + chachas.push(param1); +} function g_chacha_returnbyte(param1, param2, param3) { - console.log("hi"); chachaClass = param3; - if (chachas[0] === -1) { - chachas[0] = param1; - } - else if (chachas[1] === -1 && chachas[0] !== param1) { - chachas[1] = param1; - } return param2; } env["g_outgoing_packet"] = g_outgoing_packet; env["g_incoming_packet"] = g_incoming_packet; -// env["g_chacha_setkey"] = g_chacha_setkey; +env["g_chacha_setkey"] = g_chacha_setkey; env["g_chacha_returnbyte"] = g_chacha_returnbyte; \ No newline at end of file