From d9d1785a338323451a0e70f004c1a1a6bc5f8e53 Mon Sep 17 00:00:00 2001 From: sirjonasxx <36828922+sirjonasxx@users.noreply.github.com> Date: Fri, 26 Nov 2021 00:51:46 +0100 Subject: [PATCH] updated for gwasm minimal 1.0.1 --- G-Earth/pom.xml | 2 +- .../codepatcher/IncomingPacketPatcher.java | 29 +++++++++---------- .../codepatcher/OutgoingPacketPatcher.java | 23 +++++++-------- .../codepatcher/ReturnBytePatcher.java | 15 ++++------ .../codepatcher/SetKeyPatcher.java | 29 +++++++++---------- 5 files changed, 44 insertions(+), 54 deletions(-) diff --git a/G-Earth/pom.xml b/G-Earth/pom.xml index 37b04bb..09b1b80 100644 --- a/G-Earth/pom.xml +++ b/G-Earth/pom.xml @@ -232,7 +232,7 @@ G-Earth G-Wasm - 1.0 + 1.0.1 diff --git a/G-Earth/src/main/java/gearth/services/unity_tools/codepatcher/IncomingPacketPatcher.java b/G-Earth/src/main/java/gearth/services/unity_tools/codepatcher/IncomingPacketPatcher.java index 48e269b..b3482cd 100644 --- a/G-Earth/src/main/java/gearth/services/unity_tools/codepatcher/IncomingPacketPatcher.java +++ b/G-Earth/src/main/java/gearth/services/unity_tools/codepatcher/IncomingPacketPatcher.java @@ -7,7 +7,6 @@ import wasm.disassembly.modules.sections.code.Locals; import wasm.disassembly.types.FuncType; import wasm.disassembly.types.ResultType; import wasm.disassembly.types.ValType; -import wasm.misc.CodeCompare; import wasm.misc.StreamReplacement; import java.util.Arrays; @@ -38,23 +37,23 @@ public class IncomingPacketPatcher implements StreamReplacement { } @Override - public CodeCompare getCodeCompare() { - return code -> { - if (!(code.getLocalss().equals(Collections.singletonList(new Locals(1, ValType.I32))))) - return false; + 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.LOCAL_GET, InstrType.I32_LOAD, InstrType.LOCAL_TEE, - InstrType.IF); + List expectedExpr = Arrays.asList(InstrType.I32_CONST, InstrType.I32_LOAD8_S, + InstrType.I32_EQZ, InstrType.IF, InstrType.LOCAL_GET, InstrType.I32_LOAD, InstrType.LOCAL_TEE, + InstrType.IF); - if (code.getExpression().getInstructions().size() != expectedExpr.size()) return false; + if (code.getExpression().getInstructions().size() != expectedExpr.size()) return false; - for (int j = 0; j < code.getExpression().getInstructions().size(); j++) { - Instr instr = code.getExpression().getInstructions().get(j); - if (instr.getInstrType() != expectedExpr.get(j)) return false; - } + for (int j = 0; j < code.getExpression().getInstructions().size(); j++) { + Instr instr = code.getExpression().getInstructions().get(j); + if (instr.getInstrType() != expectedExpr.get(j)) return false; + } - return true; - }; + return true; } + + } diff --git a/G-Earth/src/main/java/gearth/services/unity_tools/codepatcher/OutgoingPacketPatcher.java b/G-Earth/src/main/java/gearth/services/unity_tools/codepatcher/OutgoingPacketPatcher.java index 86921e3..026fee3 100644 --- a/G-Earth/src/main/java/gearth/services/unity_tools/codepatcher/OutgoingPacketPatcher.java +++ b/G-Earth/src/main/java/gearth/services/unity_tools/codepatcher/OutgoingPacketPatcher.java @@ -6,7 +6,6 @@ import wasm.disassembly.modules.sections.code.Func; import wasm.disassembly.types.FuncType; import wasm.disassembly.types.ResultType; import wasm.disassembly.types.ValType; -import wasm.misc.CodeCompare; import wasm.misc.StreamReplacement; import java.util.Arrays; @@ -36,18 +35,16 @@ public class OutgoingPacketPatcher implements StreamReplacement { } @Override - public CodeCompare getCodeCompare() { - return code -> { - if (code.getLocalss().size() != 0) return false; - List expression = code.getExpression().getInstructions(); - if (expression.get(0).getInstrType() != InstrType.LOCAL_GET) return false; - if (expression.get(1).getInstrType() != InstrType.LOCAL_GET) return false; - if (expression.get(2).getInstrType() != InstrType.LOCAL_GET) return false; - if (expression.get(3).getInstrType() != InstrType.I32_LOAD) return false; - if (expression.get(4).getInstrType() != InstrType.I32_CONST) return false; - if (expression.get(5).getInstrType() != InstrType.CALL) return false; + public boolean codeMatches(Func code) { + if (code.getLocalss().size() != 0) return false; + List expression = code.getExpression().getInstructions(); + if (expression.get(0).getInstrType() != InstrType.LOCAL_GET) return false; + if (expression.get(1).getInstrType() != InstrType.LOCAL_GET) return false; + if (expression.get(2).getInstrType() != InstrType.LOCAL_GET) return false; + if (expression.get(3).getInstrType() != InstrType.I32_LOAD) return false; + if (expression.get(4).getInstrType() != InstrType.I32_CONST) return false; + if (expression.get(5).getInstrType() != InstrType.CALL) return false; - return true; - }; + return true; } } 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 4d90c5c..6f8040c 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 @@ -6,7 +6,6 @@ import wasm.disassembly.modules.sections.code.Func; import wasm.disassembly.types.FuncType; import wasm.disassembly.types.ResultType; import wasm.disassembly.types.ValType; -import wasm.misc.CodeCompare; import wasm.misc.StreamReplacement; import java.util.Arrays; @@ -36,13 +35,11 @@ public class ReturnBytePatcher implements StreamReplacement { } @Override - public CodeCompare getCodeCompare() { - return code -> { - if (code.getLocalss().size() != 0) return false; - if (code.getExpression().getInstructions().size() != 30) return false; - List expr = code.getExpression().getInstructions(); - if (expr.get(expr.size() - 1).getInstrType() != InstrType.I32_XOR) return false; - return true; - }; + public boolean codeMatches(Func code) { + if (code.getLocalss().size() != 0) return false; + if (code.getExpression().getInstructions().size() != 30) 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/java/gearth/services/unity_tools/codepatcher/SetKeyPatcher.java b/G-Earth/src/main/java/gearth/services/unity_tools/codepatcher/SetKeyPatcher.java index f952105..41fab8a 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 @@ -7,7 +7,6 @@ import wasm.disassembly.modules.sections.code.Locals; import wasm.disassembly.types.FuncType; import wasm.disassembly.types.ResultType; import wasm.disassembly.types.ValType; -import wasm.misc.CodeCompare; import wasm.misc.StreamReplacement; import java.util.Arrays; @@ -38,23 +37,21 @@ public class SetKeyPatcher implements StreamReplacement { } @Override - public CodeCompare getCodeCompare() { - return 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); + 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); - if (code.getExpression().getInstructions().size() != expectedExpr.size()) return false; + if (code.getExpression().getInstructions().size() != expectedExpr.size()) return false; - for (int j = 0; j < code.getExpression().getInstructions().size(); j++) { - Instr instr = code.getExpression().getInstructions().get(j); - if (instr.getInstrType() != expectedExpr.get(j)) return false; - } + for (int j = 0; j < code.getExpression().getInstructions().size(); j++) { + Instr instr = code.getExpression().getInstructions().get(j); + if (instr.getInstrType() != expectedExpr.get(j)) return false; + } - return true; - }; + return true; } }