mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-07-18 17:38:17 +00:00
Fixed #2094 AS3 Getting register names from debug info - do not allow assigning _locX_ name to other register than X
This commit is contained in:
@@ -1434,15 +1434,27 @@ public class AVM2Code implements Cloneable {
|
||||
|
||||
private int toSourceCount = 0;
|
||||
|
||||
public Map<Integer, String> getLocalRegNamesFromDebug(ABC abc) {
|
||||
public Map<Integer, String> getLocalRegNamesFromDebug(ABC abc, int maxRegs) {
|
||||
Map<Integer, String> regIndexToName = new HashMap<>();
|
||||
Map<String, Integer> regNameToIndex = new HashMap<>();
|
||||
|
||||
Set<String> reservedRegNames = new HashSet<>();
|
||||
for (int i = 0; i < maxRegs; i++) {
|
||||
reservedRegNames.add(String.format(Configuration.registerNameFormat.get(), i));
|
||||
}
|
||||
|
||||
for (AVM2Instruction ins : code) {
|
||||
if (ins.definition instanceof DebugIns) {
|
||||
if (ins.operands[0] == 1) {
|
||||
String v = abc.constants.getString(ins.operands[1]);
|
||||
int regIndex = ins.operands[2] + 1;
|
||||
|
||||
if (reservedRegNames.contains(v)) {
|
||||
//do not allow reassigning reserved _loc%d_ format to other local regs
|
||||
continue;
|
||||
}
|
||||
|
||||
int regIndex = ins.operands[2] + 1;
|
||||
|
||||
// Same name already exists, it may be wrong names inserted by obfuscator
|
||||
if (regNameToIndex.containsKey(v)) {
|
||||
int existingIndex = regNameToIndex.get(v);
|
||||
|
||||
@@ -277,7 +277,7 @@ public final class MethodBody implements Cloneable {
|
||||
}
|
||||
|
||||
if (Configuration.getLocalNamesFromDebugInfo.get()) {
|
||||
Map<Integer, String> debugRegNames = getCode().getLocalRegNamesFromDebug(abc);
|
||||
Map<Integer, String> debugRegNames = getCode().getLocalRegNamesFromDebug(abc, max_regs);
|
||||
for (int k : debugRegNames.keySet()) {
|
||||
ret.put(k, debugRegNames.get(k));
|
||||
}
|
||||
|
||||
@@ -310,7 +310,7 @@ public class MethodInfo {
|
||||
public GraphTextWriter getParamStr(GraphTextWriter writer, AVM2ConstantPool constants, MethodBody body, ABC abc, List<DottedChain> fullyQualifiedNames) {
|
||||
Map<Integer, String> localRegNames = new HashMap<>();
|
||||
if (body != null && Configuration.getLocalNamesFromDebugInfo.get()) {
|
||||
localRegNames = body.getCode().getLocalRegNamesFromDebug(abc);
|
||||
localRegNames = body.getCode().getLocalRegNamesFromDebug(abc, body.max_regs);
|
||||
}
|
||||
|
||||
for (int i = 0; i < param_types.length; i++) {
|
||||
|
||||
Reference in New Issue
Block a user