shown only the constant pool(s) in pcode editor

This commit is contained in:
honfika@gmail.com
2015-05-07 15:25:28 +02:00
parent e7c8a8bf06
commit 732087f20f
11 changed files with 147 additions and 30 deletions

View File

@@ -50,6 +50,7 @@ import com.jpexs.decompiler.flash.action.swf4.ActionIf;
import com.jpexs.decompiler.flash.action.swf4.ActionNot;
import com.jpexs.decompiler.flash.action.swf4.ActionPush;
import com.jpexs.decompiler.flash.action.swf4.RegisterNumber;
import com.jpexs.decompiler.flash.action.swf5.ActionConstantPool;
import com.jpexs.decompiler.flash.action.swf5.ActionDefineFunction;
import com.jpexs.decompiler.flash.action.swf5.ActionEquals2;
import com.jpexs.decompiler.flash.action.swf7.ActionDefineFunction2;
@@ -412,6 +413,10 @@ public abstract class Action implements GraphSourceItem {
* @return GraphTextWriter
*/
public static GraphTextWriter actionsToString(List<DisassemblyListener> listeners, long address, ActionList list, int version, ScriptExportMode exportMode, GraphTextWriter writer) {
if (exportMode == ScriptExportMode.CONSTANTS) {
return constantPoolActionsToString(listeners, address, list, version, exportMode, writer);
}
long offset;
Set<Long> importantOffsets = getActionsAllRefs(list);
/*List<ConstantPool> cps = SWFInputStream.getConstantPool(new ArrayList<DisassemblyListener>(), new ActionGraphSource(list, version, new HashMap<Integer, String>(), new HashMap<String, GraphTargetItem>(), new HashMap<String, GraphTargetItem>()), 0, version, path);
@@ -423,14 +428,13 @@ public abstract class Action implements GraphSourceItem {
offset = address;
int pos = 0;
boolean lastPush = false;
for (GraphSourceItem s : list) {
for (Action a : list) {
if (pos % INFORM_LISTENER_RESOLUTION == 0) {
for (DisassemblyListener listener : listeners) {
listener.progressToString(pos + 1, list.size());
}
}
Action a = (Action) s;
if (exportMode == ScriptExportMode.PCODE_HEX) {
if (lastPush) {
writer.newLine();
@@ -585,6 +589,30 @@ public abstract class Action implements GraphSourceItem {
return writer;
}
public static GraphTextWriter constantPoolActionsToString(List<DisassemblyListener> listeners, long address, ActionList list, int version, ScriptExportMode exportMode, GraphTextWriter writer) {
int poolIdx = 0;
writer.appendNoHilight(Helper.constants).newLine();
for (Action a : list) {
if (a instanceof ActionConstantPool) {
ActionConstantPool cPool = (ActionConstantPool) a;
int constIdx = 0;
for (String c : cPool.constantPool) {
writer.appendNoHilight(poolIdx);
writer.appendNoHilight("|");
writer.appendNoHilight(constIdx);
writer.appendNoHilight("|");
writer.appendNoHilight(c);
writer.newLine();
constIdx++;
}
poolIdx++;
}
}
return writer;
}
/**
* Convert action to ASM source
*

View File

@@ -1,18 +1,19 @@
/*
* Copyright (C) 2010-2015 JPEXS, All rights reserved.
*
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
*
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
* License along with this library.
*/
package com.jpexs.decompiler.flash.exporters.modes;
/**
@@ -21,5 +22,5 @@ package com.jpexs.decompiler.flash.exporters.modes;
*/
public enum ScriptExportMode {
AS, PCODE, PCODE_HEX, HEX, CONSTANTS;
}

View File

@@ -110,6 +110,7 @@ public class DoActionTag extends Tag implements ASMSource {
if (actions == null) {
actions = getActions();
}
return Action.actionsToString(listeners, 0, actions, swf.version, exportMode, writer);
}

View File

@@ -66,6 +66,10 @@ public class Helper {
public static String newLine = System.getProperty("line.separator");
public static String hexData = "#hexdata";
public static String constants = "#constants";
public static String decompilationErrorAdd = null;
private static final Map<String, Area> shapeCache = new HashMap<>();