From c49cfdfe8f10b938a5b4f6bea3f8369561529f2b Mon Sep 17 00:00:00 2001 From: sirjonasxx <36828922+sirjonasxx@users.noreply.github.com> Date: Thu, 10 Feb 2022 17:01:57 +0100 Subject: [PATCH] patch chacha setkey --- .../services/unity_tools/WasmCodePatcher.java | 2 +- .../unity_tools/codepatcher/SetKeyPatcher.java | 18 +++++++++++------- .../services/unity_tools/js_code/unity_code.js | 2 +- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/G-Earth/src/main/java/gearth/services/unity_tools/WasmCodePatcher.java b/G-Earth/src/main/java/gearth/services/unity_tools/WasmCodePatcher.java index 9d725f3..95c87f7 100644 --- a/G-Earth/src/main/java/gearth/services/unity_tools/WasmCodePatcher.java +++ b/G-Earth/src/main/java/gearth/services/unity_tools/WasmCodePatcher.java @@ -20,7 +20,7 @@ public class WasmCodePatcher { public void patch() throws IOException, InvalidOpCodeException { Module module = new Module(file, true, Arrays.asList( -// new SetKeyPatcher(), + new SetKeyPatcher(), new ReturnBytePatcher(), new OutgoingPacketPatcher(), new IncomingPacketPatcher() diff --git a/G-Earth/src/main/java/gearth/services/unity_tools/codepatcher/SetKeyPatcher.java b/G-Earth/src/main/java/gearth/services/unity_tools/codepatcher/SetKeyPatcher.java index 41fab8a..e012d15 100644 --- a/G-Earth/src/main/java/gearth/services/unity_tools/codepatcher/SetKeyPatcher.java +++ b/G-Earth/src/main/java/gearth/services/unity_tools/codepatcher/SetKeyPatcher.java @@ -2,6 +2,8 @@ package gearth.services.unity_tools.codepatcher; import wasm.disassembly.instructions.Instr; import wasm.disassembly.instructions.InstrType; +import wasm.disassembly.instructions.numeric.NumericI32ConstInstr; +import wasm.disassembly.instructions.variable.LocalVariableInstr; import wasm.disassembly.modules.sections.code.Func; import wasm.disassembly.modules.sections.code.Locals; import wasm.disassembly.types.FuncType; @@ -40,18 +42,20 @@ public class SetKeyPatcher implements StreamReplacement { public boolean codeMatches(Func code) { if (!(code.getLocalss().equals(Collections.singletonList(new Locals(1, ValType.I32))))) return false; - List expectedExpr = Arrays.asList(InstrType.I32_CONST, InstrType.I32_LOAD8_S, - InstrType.I32_EQZ, InstrType.IF, InstrType.BLOCK, InstrType.LOCAL_GET, InstrType.I32_CONST, - InstrType.LOCAL_GET, InstrType.I32_LOAD, InstrType.I32_CONST, InstrType.I32_CONST, InstrType.I32_CONST, - InstrType.CALL); + List expression = code.getExpression().getInstructions(); + List expectedExpr = Arrays.asList(InstrType.BLOCK, InstrType.LOCAL_GET, + InstrType.I32_CONST, InstrType.LOCAL_GET, InstrType.I32_LOAD, InstrType.I32_CONST, InstrType.I32_CONST, + InstrType.I32_CONST, InstrType.CALL ); - if (code.getExpression().getInstructions().size() != expectedExpr.size()) return false; + if (expression.size() != expectedExpr.size()) return false; - for (int j = 0; j < code.getExpression().getInstructions().size(); j++) { - Instr instr = code.getExpression().getInstructions().get(j); + for (int j = 0; j < expression.size(); j++) { + Instr instr = expression.get(j); if (instr.getInstrType() != expectedExpr.get(j)) return false; } +// if (((NumericI32ConstInstr)(expression.get(5))).getConstValue() != 14) 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 46b4145..2c98fe1 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 @@ -4,7 +4,7 @@ let revision = "{{RevisionName}}"; let g_ws; -let chachas = [-1, -1]; +let chachas = []; let chachaClass = -1; let out_send_param1 = -1;