mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-06-30 17:21:51 +00:00
small fixes, impovemnets
This commit is contained in:
@@ -790,7 +790,7 @@ public class AVM2Code implements Cloneable {
|
||||
List<Long> switchAddresses = new ArrayList<>();
|
||||
int availableBytes = ais.available();
|
||||
for (int i = 0; i < availableBytes; i++) {
|
||||
codeMap.put((long) i, new AVM2Instruction(i, new NopIns(), new int[]{}));
|
||||
codeMap.put((long) i, new AVM2Instruction(i, new NopIns(), null));
|
||||
}
|
||||
|
||||
long startPos = ais.getPosition();
|
||||
@@ -1267,7 +1267,7 @@ public class AVM2Code implements Cloneable {
|
||||
int fixBranch = ins.getFixBranch();
|
||||
if (fixBranch > -1) {
|
||||
if (ins.definition instanceof IfTypeIns) {
|
||||
for (int i = 0; i < -ins.definition.getStackDelta2(ins, null/*IfTypeIns do not require ABCs*/); i++) {
|
||||
for (int i = 0; i < -ins.definition.getStackDelta(ins, null/*IfTypeIns do not require ABCs*/); i++) {
|
||||
writer.appendNoHilight(new DeobfuscatePopIns().instructionName).newLine();
|
||||
}
|
||||
if (fixBranch == 0) { // jump
|
||||
@@ -2297,7 +2297,7 @@ public class AVM2Code implements Cloneable {
|
||||
stats.instructionStats[pos].stackpos = stack;
|
||||
stats.instructionStats[pos].scopepos = scope;
|
||||
|
||||
int stackDelta = ins.definition.getStackDelta2(ins, abc);
|
||||
int stackDelta = ins.definition.getStackDelta(ins, abc);
|
||||
int scopeDelta = ins.definition.getScopeStackDelta(ins, abc);
|
||||
int oldStack = stack;
|
||||
|
||||
@@ -2875,11 +2875,11 @@ public class AVM2Code implements Cloneable {
|
||||
if (ins2.isExit()) {
|
||||
code.set(i, new AVM2Instruction(ofs, ins2.definition, ins2.operands));
|
||||
AVM2Instruction nopIns;
|
||||
nopIns = new AVM2Instruction(ofs + 1, new NopIns(), new int[]{});
|
||||
nopIns = new AVM2Instruction(ofs + 1, new NopIns(), null);
|
||||
code.add(i + 1, nopIns);
|
||||
nopIns = new AVM2Instruction(ofs + 2, new NopIns(), new int[]{});
|
||||
nopIns = new AVM2Instruction(ofs + 2, new NopIns(), null);
|
||||
code.add(i + 2, nopIns);
|
||||
nopIns = new AVM2Instruction(ofs + 3, new NopIns(), new int[]{});
|
||||
nopIns = new AVM2Instruction(ofs + 3, new NopIns(), null);
|
||||
code.add(i + 3, nopIns);
|
||||
i += 3;
|
||||
csize = code.size();
|
||||
|
||||
@@ -47,7 +47,7 @@ public class CodeStats {
|
||||
int i = 0;
|
||||
int ms = 0;
|
||||
for (InstructionStats stats : instructionStats) {
|
||||
int deltastack = stats.ins.definition.getStackDelta2(stats.ins, abc);
|
||||
int deltastack = stats.ins.definition.getStackDelta(stats.ins, abc);
|
||||
if (stats.stackpos > ms) {
|
||||
ms = stats.stackpos;
|
||||
}
|
||||
|
||||
@@ -141,7 +141,7 @@ public class AVM2DeobfuscatorRegisters extends AVM2DeobfuscatorSimple {
|
||||
SetLocalTypeIns slt = (SetLocalTypeIns) ins.definition;
|
||||
int regId = slt.getRegisterId(ins);
|
||||
if (singleRegisters.containsKey(regId)) {
|
||||
code.replaceInstruction(i, new AVM2Instruction(ins.offset, new DeobfuscatePopIns(), new int[]{}), body);
|
||||
code.replaceInstruction(i, new AVM2Instruction(ins.offset, new DeobfuscatePopIns(), null), body);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -120,15 +120,15 @@ public class AVM2DeobfuscatorSimple implements SWFDecompilerListener {
|
||||
}
|
||||
if (ovalue instanceof Boolean) {
|
||||
if ((Boolean) ovalue) {
|
||||
return new AVM2Instruction(0, new PushTrueIns(), new int[]{});
|
||||
return new AVM2Instruction(0, new PushTrueIns(), null);
|
||||
}
|
||||
return new AVM2Instruction(0, new PushFalseIns(), new int[]{});
|
||||
return new AVM2Instruction(0, new PushFalseIns(), null);
|
||||
}
|
||||
if (ovalue instanceof Null) {
|
||||
return new AVM2Instruction(0, new PushNullIns(), new int[]{});
|
||||
return new AVM2Instruction(0, new PushNullIns(), null);
|
||||
}
|
||||
if (ovalue instanceof Undefined) {
|
||||
return new AVM2Instruction(0, new PushUndefinedIns(), new int[]{});
|
||||
return new AVM2Instruction(0, new PushUndefinedIns(), null);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -272,7 +272,7 @@ public class AVM2DeobfuscatorSimple implements SWFDecompilerListener {
|
||||
if (def instanceof SetLocalTypeIns) {
|
||||
int regId = ((SetLocalTypeIns) def).getRegisterId(ins);
|
||||
staticRegs.put(regId, localData.localRegs.get(regId).getNotCoerced());
|
||||
code.replaceInstruction(idx, new AVM2Instruction(0, new DeobfuscatePopIns(), new int[]{}), body);
|
||||
code.replaceInstruction(idx, new AVM2Instruction(0, new DeobfuscatePopIns(), null), body);
|
||||
}
|
||||
}
|
||||
if (def instanceof GetLocalTypeIns) {
|
||||
@@ -364,7 +364,7 @@ public class AVM2DeobfuscatorSimple implements SWFDecompilerListener {
|
||||
AVM2Instruction tarIns = code.code.get(nidx);
|
||||
|
||||
//Some IfType instructions need more than 1 operand, we must pop out all of them
|
||||
int stackCount = -def.getStackDelta2(ins, abc);
|
||||
int stackCount = -def.getStackDelta(ins, abc);
|
||||
|
||||
if (EcmaScript.toBoolean(res)) {
|
||||
//System.err.println("replacing " + ins + " on " + idx + " with jump");
|
||||
@@ -373,15 +373,15 @@ public class AVM2DeobfuscatorSimple implements SWFDecompilerListener {
|
||||
code.replaceInstruction(idx, jumpIns, body);
|
||||
jumpIns.operands[0] = (int) (tarIns.offset - jumpIns.offset - jumpIns.getBytesLength());
|
||||
for (int s = 0; s < stackCount; s++) {
|
||||
code.insertInstruction(idx, new AVM2Instruction(ins.offset, new DeobfuscatePopIns(), new int[]{}), true, body);
|
||||
code.insertInstruction(idx, new AVM2Instruction(ins.offset, new DeobfuscatePopIns(), null), true, body);
|
||||
}
|
||||
|
||||
idx = code.adr2pos(jumpIns.offset + jumpIns.getBytesLength() + jumpIns.operands[0]);
|
||||
} else {
|
||||
//System.err.println("replacing " + ins + " on " + idx + " with pop");
|
||||
code.replaceInstruction(idx, new AVM2Instruction(ins.offset, new DeobfuscatePopIns(), new int[]{}), body);
|
||||
code.replaceInstruction(idx, new AVM2Instruction(ins.offset, new DeobfuscatePopIns(), null), body);
|
||||
for (int s = 1 /*first is replaced*/; s < stackCount; s++) {
|
||||
code.insertInstruction(idx, new AVM2Instruction(ins.offset, new DeobfuscatePopIns(), new int[]{}), true, body);
|
||||
code.insertInstruction(idx, new AVM2Instruction(ins.offset, new DeobfuscatePopIns(), null), true, body);
|
||||
}
|
||||
//ins.definition = new DeobfuscatePopIns();
|
||||
idx++;
|
||||
|
||||
@@ -160,7 +160,7 @@ public class InstructionDefinition implements Serializable {
|
||||
return name + ns;
|
||||
}
|
||||
|
||||
public int getStackDelta2(AVM2Instruction ins, ABC abc) {
|
||||
public int getStackDelta(AVM2Instruction ins, ABC abc) {
|
||||
return getStackPushCount(ins, abc) - getStackPopCount(ins, abc);
|
||||
}
|
||||
|
||||
|
||||
@@ -142,19 +142,21 @@ public final class MethodBody implements Cloneable {
|
||||
|
||||
public List<Integer> getExceptionEntries() {
|
||||
List<Integer> ret = new ArrayList<>();
|
||||
AVM2Code code = getCode();
|
||||
for (ABCException e : exceptions) {
|
||||
ret.add(getCode().adr2pos(e.start, true));
|
||||
ret.add(getCode().adr2pos(e.end, true));
|
||||
ret.add(getCode().adr2pos(e.target));
|
||||
ret.add(code.adr2pos(e.start, true));
|
||||
ret.add(code.adr2pos(e.end, true));
|
||||
ret.add(code.adr2pos(e.target));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
public void markOffsets() {
|
||||
long offset = 0;
|
||||
for (int i = 0; i < getCode().code.size(); i++) {
|
||||
getCode().code.get(i).offset = offset;
|
||||
offset += getCode().code.get(i).getBytesLength();
|
||||
AVM2Code code = getCode();
|
||||
for (int i = 0; i < code.code.size(); i++) {
|
||||
code.code.get(i).offset = offset;
|
||||
offset += code.code.get(i).getBytesLength();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user