diff --git a/trunk/src/com/jpexs/decompiler/flash/SWFInputStream.java b/trunk/src/com/jpexs/decompiler/flash/SWFInputStream.java index fcfbbf2af..bd6d66019 100644 --- a/trunk/src/com/jpexs/decompiler/flash/SWFInputStream.java +++ b/trunk/src/com/jpexs/decompiler/flash/SWFInputStream.java @@ -546,155 +546,6 @@ public class SWFInputStream extends InputStream { return readActionList(listeners, containerSWFOffset, rri, version, rri.getPos(), rri.getPos() + maxlen, path); } -// @SuppressWarnings("unchecked") -// private static void getConstantPool(List listeners, ConstantPool cpool, List localData, Stack stack, List output, ActionGraphSource code, int ip, List constantPools, List visited, int version, int endIp, String path) { -// boolean debugMode = false; -// boolean deobfuscate = Configuration.getConfig("autoDeobfuscate", true); -// while (((endIp == -1) || (endIp > ip)) && (ip > -1) && ip < code.size()) { -// if (visited.contains(ip)) { -// break; -// } -// for (int i = 0; i < listeners.size(); i++) { -// listeners.get(i).progress("constantpool", ip + 1, code.size()); -// } -// GraphSourceItem ins = code.get(ip); -// if (ins.isIgnored()) { -// if (ins.isExit()) { -// break; -// } -// ip++; -// continue; -// } -// -// if (ins instanceof GraphSourceItemContainer) { -// GraphSourceItemContainer cnt = (GraphSourceItemContainer) ins; -// String cntName = cnt.getName(); -// if (ins instanceof Action) { -// List> output2s = new ArrayList<>(); -// long endAddr = ((Action) ins).getAddress() + cnt.getHeaderSize(); -// for (long size : cnt.getContainerSizes()) { -// if (size == 0) { -// output2s.add(new ArrayList()); -// continue; -// } -// List localData2 = Helper.toList(new HashMap(), new HashMap(), new HashMap()); -// List output2 = new ArrayList<>(); -// output2s.add(output2); -// getConstantPool(listeners, cpool, localData2, new Stack(), output2, code, code.adr2pos(endAddr), constantPools, visited, version, code.adr2pos(endAddr + size), path + (cntName == null ? "" : "/" + cntName)); -// endAddr += size; -// } -// if (deobfuscate) { -// cnt.translateContainer(output2s, stack, output, (HashMap) localData.get(0), (HashMap) localData.get(1), (HashMap) localData.get(2)); -// } -// ip = code.adr2pos(endAddr); -// continue; -// } -// } -// if (ins instanceof ActionPush) { -// if (cpool != null) { -// ((ActionPush) ins).constantPool = cpool.constants; -// cpool.count++; -// } -// } -// if (ins instanceof ActionDefineFunction) { -// if (cpool != null) { -// //((ActionDefineFunction) ins).setConstantPool(cpool.constants,code.getActions()); -// cpool.count++; -// } -// } -// if (ins instanceof ActionDefineFunction2) { -// if (cpool != null) { -// //((ActionDefineFunction2) ins).setConstantPool(cpool.constants,code.getActions()); -// cpool.count++; -// } -// } -// if (debugMode) { -// String add = ""; -// if (ins instanceof ActionIf) { -// add += " change:" + ((ActionIf) ins).getJumpOffset(); -// } -// if (ins instanceof ActionJump) { -// add += " change:" + (((ActionJump) ins).getJumpOffset()); -// } -// System.err.println("getConstantPool ip " + ip + ", addr " + Helper.formatAddress(((Action) ins).getAddress()) + ": " + ((Action) ins).getASMSource(new ArrayList(), new ArrayList(), cpool == null ? null : cpool.constants, version, false) + add + " stack:" + Helper.stackToString(stack, Helper.toList(cpool))); -// } -// if (ins instanceof ActionConstantPool) { -// constantPools.add(new ConstantPool(((ActionConstantPool) ins).constantPool)); -// if (cpool == null) { -// cpool = new ConstantPool(); -// } -// cpool.setNew(((ActionConstantPool) ins).constantPool); -// } -// -// //for..in return -// if (deobfuscate) { -// if (((ins instanceof ActionEquals) || (ins instanceof ActionEquals2)) && (stack.size() == 1) && (stack.peek() instanceof DirectValueActionItem)) { -// stack.push(new DirectValueActionItem(null, 0, new Null(), new ArrayList())); -// } -// try { -// ins.translate(localData, stack, output, Graph.SOP_USE_STATIC/*Graph.SOP_SKIP_STATIC*/, null); -// } catch (Exception ex) { -// Logger.getLogger(SWFInputStream.class.getName()).log(Level.SEVERE, "Error during getting constantpool", ex); -// } -// } -// if (ins.isExit()) { -// break; -// } -// -// if (ins.isBranch() || ins.isJump()) { -// -// if (deobfuscate && (ins instanceof ActionIf) && !stack.isEmpty() && (stack.peek().isCompileTime() && (!stack.peek().hasSideEffect()))) { -// boolean condition = EcmaScript.toBoolean(stack.peek().getResult()); -// if (debugMode) { -// if (condition) { -// System.err.println("JUMP"); -// } else { -// System.err.println("SKIP"); -// } -// } -// stack.pop(); -// getConstantPool(listeners, cpool, localData, stack, output, code, condition ? (code.adr2pos(((ActionIf) ins).getAddress() + ((ActionIf) ins).getBytes(code.version).length + ((ActionIf) ins).getJumpOffset())) : ip + 1, constantPools, visited, version, endIp, path); -// } else { -// if (deobfuscate && ins instanceof ActionIf) { -// stack.pop(); -// } -// visited.add(ip); -// List branches = ins.getBranches(code); -// for (int b : branches) { -// @SuppressWarnings("unchecked") -// Stack brStack = (Stack) stack.clone(); -// if (b >= 0) { -// getConstantPool(listeners, cpool, prepareLocalBranch(localData), brStack, output, code, b, constantPools, visited, version, endIp, path); -// } else { -// if (debugMode) { -// System.out.println("Negative branch:" + b); -// } -// } -// } -// } -// break; -// } -// ip++; -// }; -// if (ip < 0) { -// System.out.println("Visited Negative: " + ip); -// } -// for (DisassemblyListener listener : listeners) { -// listener.progress("constantpool", ip + 1, code.size()); -// } -// } -// -// public static List getConstantPool(List listeners, ActionGraphSource code, int addr, int version, String path) { -// List ret = new ArrayList<>(); -// List localData = Helper.toList(new HashMap(), new HashMap(), new HashMap()); -// try { -// getConstantPool(listeners, null, localData, new Stack(), new ArrayList(), code, code.adr2pos(addr), ret, new ArrayList(), version, -1, path); -// } catch (Exception ex) { -// log.log(Level.SEVERE, "Error during getting constantpool", ex); -// } -// return ret; -// } - private static List prepareLocalBranch(List localData) { @SuppressWarnings("unchecked") HashMap regNames = (HashMap) localData.get(0); diff --git a/trunk/src/com/jpexs/decompiler/flash/action/model/FunctionActionItem.java b/trunk/src/com/jpexs/decompiler/flash/action/model/FunctionActionItem.java index 8dfcadfd1..b83290982 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/model/FunctionActionItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/model/FunctionActionItem.java @@ -91,7 +91,7 @@ public class FunctionActionItem extends ActionItem { } ret += hilight(pname, highlight); } - ret += hilight(")", highlight) + "\r\n" + hilight("{", highlight) + "\r\n" + Graph.graphToString(actions, highlight, constants) + "}"; + ret += hilight(")", highlight) + "\r\n" + hilight("{", highlight) + "\r\n" + Graph.graphToString(actions, highlight, constants) + hilight("}", highlight); return ret; } diff --git a/trunk/src/com/jpexs/decompiler/graph/Graph.java b/trunk/src/com/jpexs/decompiler/graph/Graph.java index f58b4c09d..86ce3e7c8 100644 --- a/trunk/src/com/jpexs/decompiler/graph/Graph.java +++ b/trunk/src/com/jpexs/decompiler/graph/Graph.java @@ -2227,24 +2227,22 @@ public class Graph { if (strippedP.startsWith(":")) { continue; } - if (Highlighting.stripHilights(parts[p]).equals(INDENTOPEN)) { + strippedP = Highlighting.stripHilights(parts[p]).trim(); + if (strippedP.equals(INDENTOPEN)) { level++; continue; } - if (Highlighting.stripHilights(parts[p]).equals(INDENTCLOSE)) { + if (strippedP.equals(INDENTCLOSE)) { level--; continue; } - if (Highlighting.stripHilights(parts[p]).equals("}")) { - level--; - } - if (Highlighting.stripHilights(parts[p]).equals("};")) { + if (strippedP.startsWith("}")) { level--; } ret.append(tabString(level)); ret.append(parts[p]); ret.append("\r\n"); - if (Highlighting.stripHilights(parts[p]).equals("{")) { + if (strippedP.equals("{")) { level++; } }