45 lines
2.2 KiB
Java
45 lines
2.2 KiB
Java
import com.jpexs.decompiler.flash.SWF;
|
|
import com.jpexs.decompiler.flash.abc.ScriptPack;
|
|
import java.io.BufferedInputStream;
|
|
import java.nio.file.Files;
|
|
import java.nio.file.Path;
|
|
import java.security.MessageDigest;
|
|
import java.util.Arrays;
|
|
import java.util.HexFormat;
|
|
|
|
/** Offline byte comparison of check/report methods; does not execute game code. */
|
|
public final class CompareBattleChecks {
|
|
private static byte[] method(SWF swf, String target, String name) {
|
|
for (ScriptPack pack : swf.getAS3Packs()) {
|
|
if (!pack.getClassPath().toString().equals(target)) continue;
|
|
int index = pack.abc.findMethodBodyByName(target, name);
|
|
if (index >= 0) return pack.abc.bodies.get(index).getCodeBytes();
|
|
}
|
|
throw new IllegalArgumentException("Method missing: " + target + "." + name);
|
|
}
|
|
|
|
public static void main(String[] args) throws Exception {
|
|
if (args.length != 2) throw new IllegalArgumentException("original.app patched.app");
|
|
try (var a = new BufferedInputStream(Files.newInputStream(Path.of(args[0])));
|
|
var b = new BufferedInputStream(Files.newInputStream(Path.of(args[1])))) {
|
|
SWF original = new SWF(a, false), patched = new SWF(b, false);
|
|
String[][] targets = {
|
|
{"net.pixvi.myr.panel.battle.BattlePanel", "cheatCheck"},
|
|
{"net.pixvi.myr.element.battle.BattleMonVo", "checkCheat"},
|
|
{"net.pixvi.myr.element.battle.BattleData", "getObj"},
|
|
{"net.pixvi.myr.battle.view.BattleMon", "beCure"},
|
|
{"net.pixvi.myr.battle.BattleGround", "deadHandler"},
|
|
{"net.pixvi.myr.net.NetStage", "finishStageBattle"}
|
|
};
|
|
for (var target : targets) {
|
|
byte[] left = method(original, target[0], target[1]);
|
|
byte[] right = method(patched, target[0], target[1]);
|
|
boolean same = Arrays.equals(left, right);
|
|
String digest = HexFormat.of().formatHex(MessageDigest.getInstance("SHA-256").digest(right));
|
|
System.out.println((same ? "UNCHANGED " : "CHANGED ") + target[0] + "." + target[1]
|
|
+ " bytes=" + right.length + " sha256=" + digest);
|
|
}
|
|
}
|
|
}
|
|
}
|