mirror of
https://github.com/sirjonasxx/G-Earth.git
synced 2024-11-26 18:30:52 +01:00
progress fixing unity
This commit is contained in:
parent
620eb05101
commit
823f3a7e67
@ -125,6 +125,7 @@ public class UnityWebModifyer {
|
|||||||
contents = contents
|
contents = contents
|
||||||
.replace("var _free", "_free")
|
.replace("var _free", "_free")
|
||||||
.replace("var _malloc", "_malloc")
|
.replace("var _malloc", "_malloc")
|
||||||
|
.replace("var Module", "Module")
|
||||||
.replace("{{RevisionName}}", revision);
|
.replace("{{RevisionName}}", revision);
|
||||||
|
|
||||||
BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(new GZIPOutputStream(new FileOutputStream(frameworkFile))));
|
BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(new GZIPOutputStream(new FileOutputStream(frameworkFile))));
|
||||||
|
@ -19,12 +19,12 @@ public class WasmCodePatcher {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void patch() throws IOException, InvalidOpCodeException {
|
public void patch() throws IOException, InvalidOpCodeException {
|
||||||
Module module = new Module(file, 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()
|
||||||
));
|
));
|
||||||
module.assembleToFile(file);
|
module.assembleToFile(file, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,10 @@ 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.control.IfElseInstr;
|
||||||
|
import wasm.disassembly.instructions.memory.MemArg;
|
||||||
|
import wasm.disassembly.instructions.memory.MemInstr;
|
||||||
|
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;
|
||||||
@ -52,6 +56,9 @@ public class IncomingPacketPatcher implements StreamReplacement {
|
|||||||
if (instr.getInstrType() != expectedExpr.get(j)) return false;
|
if (instr.getInstrType() != expectedExpr.get(j)) return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (((MemInstr)(code.getExpression().getInstructions().get(5))).getMemArg().getAlign() != 2 ||
|
||||||
|
((MemInstr)(code.getExpression().getInstructions().get(5))).getMemArg().getOffset() != 32) return false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,6 +2,7 @@ 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.variable.LocalVariableInstr;
|
||||||
import wasm.disassembly.modules.sections.code.Func;
|
import wasm.disassembly.modules.sections.code.Func;
|
||||||
import wasm.disassembly.types.FuncType;
|
import wasm.disassembly.types.FuncType;
|
||||||
import wasm.disassembly.types.ResultType;
|
import wasm.disassembly.types.ResultType;
|
||||||
@ -45,6 +46,8 @@ public class OutgoingPacketPatcher implements StreamReplacement {
|
|||||||
if (expression.get(4).getInstrType() != InstrType.I32_CONST) return false;
|
if (expression.get(4).getInstrType() != InstrType.I32_CONST) return false;
|
||||||
if (expression.get(5).getInstrType() != InstrType.CALL) return false;
|
if (expression.get(5).getInstrType() != InstrType.CALL) return false;
|
||||||
|
|
||||||
|
if (((LocalVariableInstr)(expression.get(2))).getLocalIdx().getX() != 1) return false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,7 @@ let revision = "{{RevisionName}}";
|
|||||||
let g_ws;
|
let g_ws;
|
||||||
|
|
||||||
|
|
||||||
let chachas = [];
|
let chachas = [-1, -1];
|
||||||
let chachaClass = -1;
|
let chachaClass = -1;
|
||||||
|
|
||||||
let out_send_param1 = -1;
|
let out_send_param1 = -1;
|
||||||
@ -20,6 +20,7 @@ let _gearth_incoming_copy;
|
|||||||
|
|
||||||
let _malloc;
|
let _malloc;
|
||||||
let _free;
|
let _free;
|
||||||
|
let Module;
|
||||||
|
|
||||||
|
|
||||||
var packetBuff = {"out": [], "in": []};
|
var packetBuff = {"out": [], "in": []};
|
||||||
@ -97,10 +98,10 @@ function inject_out(packet) {
|
|||||||
let inject_amount = Math.min(_g_packet_split, packet.length - i);
|
let inject_amount = Math.min(_g_packet_split, packet.length - i);
|
||||||
|
|
||||||
let packet_location = _malloc(inject_amount + 16);
|
let packet_location = _malloc(inject_amount + 16);
|
||||||
unityInstance.Module.HEAPU8.set(out_packet_objid, packet_location);
|
Module.HEAPU8.set(out_packet_objid, packet_location);
|
||||||
unityInstance.Module.HEAPU8.fill(0, packet_location + 4, packet_location + 12);
|
Module.HEAPU8.fill(0, packet_location + 4, packet_location + 12);
|
||||||
unityInstance.Module.HEAPU8.set(writeLittleEndian(inject_amount), packet_location + 12);
|
Module.HEAPU8.set(writeLittleEndian(inject_amount), packet_location + 12);
|
||||||
unityInstance.Module.HEAPU8.set(packet.slice(i, i + inject_amount), packet_location + 16);
|
Module.HEAPU8.set(packet.slice(i, i + inject_amount), packet_location + 16);
|
||||||
|
|
||||||
_gearth_outgoing_copy(out_send_param1, packet_location, out_send_param3);
|
_gearth_outgoing_copy(out_send_param1, packet_location, out_send_param3);
|
||||||
_free(packet_location);
|
_free(packet_location);
|
||||||
@ -128,8 +129,8 @@ function inject_in(packet) {
|
|||||||
let inject_amount = Math.min(_g_packet_split, packet.length - i);
|
let inject_amount = Math.min(_g_packet_split, packet.length - i);
|
||||||
|
|
||||||
let packet_location = _malloc(inject_amount + 16);
|
let packet_location = _malloc(inject_amount + 16);
|
||||||
unityInstance.Module.HEAPU8.set(in_packet_prefix, packet_location);
|
Module.HEAPU8.set(in_packet_prefix, packet_location);
|
||||||
unityInstance.Module.HEAPU8.set(packet.slice(i, i + inject_amount), packet_location + 16);
|
Module.HEAPU8.set(packet.slice(i, i + inject_amount), packet_location + 16);
|
||||||
|
|
||||||
_gearth_incoming_copy(in_recv_param1, packet_location, 0, inject_amount, 0);
|
_gearth_incoming_copy(in_recv_param1, packet_location, 0, inject_amount, 0);
|
||||||
_free(packet_location);
|
_free(packet_location);
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
function g_outgoing_packet(param1, param2, param3) {
|
function g_outgoing_packet(param1, param2, param3) {
|
||||||
out_send_param1 = param1;
|
out_send_param1 = param1;
|
||||||
out_send_param3 = param3;
|
out_send_param3 = param3;
|
||||||
out_packet_objid = unityInstance.Module.HEAPU8.slice(param2, param2 + 4);
|
out_packet_objid = Module.HEAPU8.slice(param2, param2 + 4);
|
||||||
|
|
||||||
let length = readLittleEndian(unityInstance.Module.HEAPU8.subarray(param2 + 12, param2 + 12 + 4));
|
let length = readLittleEndian(Module.HEAPU8.subarray(param2 + 12, param2 + 12 + 4));
|
||||||
let array = [].slice.call(unityInstance.Module.HEAPU8.subarray(param2 + 12 + 4, param2 + 12 + 4 + length));
|
let array = [].slice.call(Module.HEAPU8.subarray(param2 + 12 + 4, param2 + 12 + 4 + length));
|
||||||
|
|
||||||
packetBuff["out"] = packetBuff["out"].concat(array);
|
packetBuff["out"] = packetBuff["out"].concat(array);
|
||||||
|
|
||||||
@ -15,9 +15,9 @@ function g_outgoing_packet(param1, param2, param3) {
|
|||||||
|
|
||||||
function g_incoming_packet(param1, param2, param3, param4, param5) {
|
function g_incoming_packet(param1, param2, param3, param4, param5) {
|
||||||
in_recv_param1 = param1;
|
in_recv_param1 = param1;
|
||||||
in_packet_prefix = unityInstance.Module.HEAPU8.slice(param2, param2 + 16);
|
in_packet_prefix = Module.HEAPU8.slice(param2, param2 + 16);
|
||||||
|
|
||||||
let buffer = unityInstance.Module.HEAPU8.slice(param2 + 16, param2 + 16 + param4);
|
let buffer = Module.HEAPU8.slice(param2 + 16, param2 + 16 + param4);
|
||||||
packetBuff["in"] = packetBuff["in"].concat([].slice.call(buffer));
|
packetBuff["in"] = packetBuff["in"].concat([].slice.call(buffer));
|
||||||
|
|
||||||
let packets = collect_packets("in");
|
let packets = collect_packets("in");
|
||||||
@ -30,20 +30,27 @@ function g_incoming_packet(param1, param2, param3, param4, param5) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function g_chacha_setkey(param1, param2, param3, param4) {
|
// function g_chacha_setkey(param1, param2, param3, param4) {
|
||||||
if (chachas.length === 2) {
|
// if (chachas.length === 2) {
|
||||||
chachas = [];
|
// chachas = [];
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
chachas.push(param1);
|
// chachas.push(param1);
|
||||||
}
|
// }
|
||||||
|
|
||||||
function g_chacha_returnbyte(param1, param2, param3) {
|
function g_chacha_returnbyte(param1, param2, param3) {
|
||||||
|
console.log("hi");
|
||||||
chachaClass = param3;
|
chachaClass = param3;
|
||||||
|
if (chachas[0] === -1) {
|
||||||
|
chachas[0] = param1;
|
||||||
|
}
|
||||||
|
else if (chachas[1] === -1 && chachas[0] !== param1) {
|
||||||
|
chachas[1] = param1;
|
||||||
|
}
|
||||||
return param2;
|
return param2;
|
||||||
}
|
}
|
||||||
|
|
||||||
env["g_outgoing_packet"] = g_outgoing_packet;
|
env["g_outgoing_packet"] = g_outgoing_packet;
|
||||||
env["g_incoming_packet"] = g_incoming_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;
|
env["g_chacha_returnbyte"] = g_chacha_returnbyte;
|
Loading…
Reference in New Issue
Block a user