patch chacha setkey

This commit is contained in:
sirjonasxx 2022-02-10 17:01:57 +01:00
parent ad46a76bbf
commit c49cfdfe8f
3 changed files with 13 additions and 9 deletions

View File

@ -20,7 +20,7 @@ public class WasmCodePatcher {
public void patch() throws IOException, InvalidOpCodeException { public void patch() throws IOException, InvalidOpCodeException {
Module module = new Module(file, true, Arrays.asList( Module module = new Module(file, true, Arrays.asList(
// new SetKeyPatcher(), new SetKeyPatcher(),
new ReturnBytePatcher(), new ReturnBytePatcher(),
new OutgoingPacketPatcher(), new OutgoingPacketPatcher(),
new IncomingPacketPatcher() new IncomingPacketPatcher()

View File

@ -2,6 +2,8 @@ package gearth.services.unity_tools.codepatcher;
import wasm.disassembly.instructions.Instr; import wasm.disassembly.instructions.Instr;
import wasm.disassembly.instructions.InstrType; 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.Func;
import wasm.disassembly.modules.sections.code.Locals; import wasm.disassembly.modules.sections.code.Locals;
import wasm.disassembly.types.FuncType; import wasm.disassembly.types.FuncType;
@ -40,18 +42,20 @@ public class SetKeyPatcher implements StreamReplacement {
public boolean codeMatches(Func code) { public boolean codeMatches(Func code) {
if (!(code.getLocalss().equals(Collections.singletonList(new Locals(1, ValType.I32))))) if (!(code.getLocalss().equals(Collections.singletonList(new Locals(1, ValType.I32)))))
return false; return false;
List<InstrType> expectedExpr = Arrays.asList(InstrType.I32_CONST, InstrType.I32_LOAD8_S, List<Instr> expression = code.getExpression().getInstructions();
InstrType.I32_EQZ, InstrType.IF, InstrType.BLOCK, InstrType.LOCAL_GET, InstrType.I32_CONST, List<InstrType> expectedExpr = Arrays.asList(InstrType.BLOCK, InstrType.LOCAL_GET,
InstrType.LOCAL_GET, InstrType.I32_LOAD, InstrType.I32_CONST, InstrType.I32_CONST, InstrType.I32_CONST, InstrType.I32_CONST, InstrType.LOCAL_GET, InstrType.I32_LOAD, InstrType.I32_CONST, InstrType.I32_CONST,
InstrType.CALL); 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++) { for (int j = 0; j < expression.size(); j++) {
Instr instr = code.getExpression().getInstructions().get(j); Instr instr = expression.get(j);
if (instr.getInstrType() != expectedExpr.get(j)) return false; if (instr.getInstrType() != expectedExpr.get(j)) return false;
} }
// if (((NumericI32ConstInstr)(expression.get(5))).getConstValue() != 14) return false;
return true; return true;
} }
} }

View File

@ -4,7 +4,7 @@ let revision = "{{RevisionName}}";
let g_ws; let g_ws;
let chachas = [-1, -1]; let chachas = [];
let chachaClass = -1; let chachaClass = -1;
let out_send_param1 = -1; let out_send_param1 = -1;