mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-05-28 17:45:30 +00:00
small action reading cleanup
This commit is contained in:
@@ -19,8 +19,6 @@ package com.jpexs.decompiler.flash.action;
|
||||
import com.jpexs.decompiler.flash.AppStrings;
|
||||
import com.jpexs.decompiler.flash.BaseLocalData;
|
||||
import com.jpexs.decompiler.flash.DisassemblyListener;
|
||||
import com.jpexs.decompiler.flash.SWF;
|
||||
import com.jpexs.decompiler.flash.SWFInputStream;
|
||||
import com.jpexs.decompiler.flash.SWFOutputStream;
|
||||
import com.jpexs.decompiler.flash.action.model.ActionItem;
|
||||
import com.jpexs.decompiler.flash.action.model.ConstantPool;
|
||||
@@ -42,7 +40,6 @@ import com.jpexs.decompiler.flash.action.model.clauses.ClassActionItem;
|
||||
import com.jpexs.decompiler.flash.action.model.clauses.InterfaceActionItem;
|
||||
import com.jpexs.decompiler.flash.action.parser.ParseException;
|
||||
import com.jpexs.decompiler.flash.action.parser.pcode.ASMParsedSymbol;
|
||||
import com.jpexs.decompiler.flash.action.parser.pcode.ASMParser;
|
||||
import com.jpexs.decompiler.flash.action.parser.pcode.FlasmLexer;
|
||||
import com.jpexs.decompiler.flash.action.parser.script.VariableActionItem;
|
||||
import com.jpexs.decompiler.flash.action.special.ActionEnd;
|
||||
@@ -59,7 +56,6 @@ import com.jpexs.decompiler.flash.configuration.Configuration;
|
||||
import com.jpexs.decompiler.flash.ecma.Null;
|
||||
import com.jpexs.decompiler.flash.exporters.modes.ScriptExportMode;
|
||||
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
|
||||
import com.jpexs.decompiler.flash.helpers.HilightedTextWriter;
|
||||
import com.jpexs.decompiler.flash.helpers.NulWriter;
|
||||
import com.jpexs.decompiler.flash.helpers.collections.MyEntry;
|
||||
import com.jpexs.decompiler.flash.tags.base.ASMSource;
|
||||
@@ -402,11 +398,10 @@ public class Action implements GraphSourceItem {
|
||||
* @param version SWF version
|
||||
* @param exportMode PCode or hex?
|
||||
* @param writer
|
||||
* @param path
|
||||
* @return HilightedTextWriter
|
||||
*/
|
||||
public static GraphTextWriter actionsToString(List<DisassemblyListener> listeners, long address, List<Action> list, int version, ScriptExportMode exportMode, GraphTextWriter writer, String path) {
|
||||
return actionsToString(listeners, address, list, new ArrayList<String>(), version, exportMode, writer, path);
|
||||
public static GraphTextWriter actionsToString(List<DisassemblyListener> listeners, long address, List<Action> list, int version, ScriptExportMode exportMode, GraphTextWriter writer) {
|
||||
return actionsToString(listeners, address, list, new ArrayList<String>(), version, exportMode, writer);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -419,10 +414,9 @@ public class Action implements GraphSourceItem {
|
||||
* @param constantPool Constant pool
|
||||
* @param version SWF version
|
||||
* @param hex Add hexadecimal?
|
||||
* @param path
|
||||
* @return HilightedTextWriter
|
||||
*/
|
||||
private static GraphTextWriter actionsToString(List<DisassemblyListener> listeners, long address, List<Action> list, List<String> constantPool, int version, ScriptExportMode exportMode, GraphTextWriter writer, String path) {
|
||||
private static GraphTextWriter actionsToString(List<DisassemblyListener> listeners, long address, List<Action> list, List<String> constantPool, int version, ScriptExportMode exportMode, GraphTextWriter writer) {
|
||||
long offset;
|
||||
List<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);
|
||||
@@ -544,8 +538,9 @@ public class Action implements GraphSourceItem {
|
||||
}
|
||||
|
||||
if (fixBranch > -1) {
|
||||
writer.appendNoHilight("FFDec_DeobfuscatePop").newLine();
|
||||
if (fixBranch == 0) { //jump
|
||||
writer.appendNoHilight("FFDec_DeobfuscatePop");
|
||||
if (fixBranch == 0) { //jump
|
||||
writer.newLine();
|
||||
writer.appendNoHilight("Jump loc");
|
||||
writer.appendNoHilight(Helper.formatAddress(a.getAddress() + a.getTotalActionLength() + ((ActionIf) a).getJumpOffset()));
|
||||
} else {
|
||||
@@ -598,7 +593,6 @@ public class Action implements GraphSourceItem {
|
||||
* @param container
|
||||
* @param knownAddreses List of important offsets to mark as labels
|
||||
* @param constantPool Constant pool
|
||||
* @param version SWF version
|
||||
* @param exportMode PCode or hex?
|
||||
* @return String of P-code source
|
||||
*/
|
||||
|
||||
@@ -142,7 +142,7 @@ public class ActionListReader {
|
||||
if (actionMap.isEmpty()) {
|
||||
return actions;
|
||||
}
|
||||
|
||||
|
||||
Map<Action, List<Action>> containerLastActions = new HashMap<>();
|
||||
List<Long> addresses = new ArrayList<>(actionMap.keySet());
|
||||
getContainerLastActions(actionMap, addresses, containerLastActions);
|
||||
@@ -259,11 +259,9 @@ public class ActionListReader {
|
||||
Action lastAction = actions.get(actions.size() - 1);
|
||||
int endIp = (int) lastAction.getAddress();
|
||||
|
||||
List<Action> retdups = new ArrayList<>(endIp);
|
||||
List<Action> retMap = new ArrayList<>(endIp);
|
||||
for (int i = 0; i < endIp; i++) {
|
||||
Action a = new ActionNop();
|
||||
a.setAddress(i);
|
||||
retdups.add(a);
|
||||
retMap.add(null);
|
||||
}
|
||||
List<Action> actionMap = new ArrayList<>(endIp);
|
||||
for (int i = 0; i <= endIp; i++) {
|
||||
@@ -292,15 +290,15 @@ public class ActionListReader {
|
||||
new ActionLocalData(),
|
||||
new Stack<GraphTargetItem>(),
|
||||
new ConstantPool(),
|
||||
actionMap, ip, retdups, ip, endIp, path,
|
||||
actionMap, ip, retMap, ip, endIp, path,
|
||||
new HashMap<Integer, Integer>(), false,
|
||||
new HashMap<Integer, HashMap<String, GraphTargetItem>>(),
|
||||
version, 0, maxRecursionLevel);
|
||||
|
||||
ActionList ret = new ActionList();
|
||||
Action last = null;
|
||||
for (Action a : retdups) {
|
||||
if (a != last) {
|
||||
for (Action a : retMap) {
|
||||
if (a != last && a != null) {
|
||||
ret.add(a);
|
||||
}
|
||||
last = a;
|
||||
@@ -849,18 +847,7 @@ public class ActionListReader {
|
||||
}
|
||||
}
|
||||
}
|
||||
int nopos = -1;
|
||||
for (int i = 0; i < actionLen; i++) {
|
||||
if (a instanceof ActionNop) {
|
||||
int prevPos = (int) a.getAddress();
|
||||
a = new ActionNop();
|
||||
a.setAddress(prevPos);
|
||||
nopos++;
|
||||
if (nopos > 0) {
|
||||
a.setAddress(a.getAddress() + 1);
|
||||
}
|
||||
|
||||
}
|
||||
ret.set(ip + i, a);
|
||||
}
|
||||
|
||||
|
||||
@@ -66,7 +66,7 @@ public class ActionWaitForFrame extends Action implements ActionStore {
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
SWFOutputStream sos = new SWFOutputStream(baos, version);
|
||||
try {
|
||||
sos.writeUI16(frame);
|
||||
sos.writeUI16(frame);
|
||||
sos.writeUI8(skipCount);
|
||||
sos.close();
|
||||
} catch (IOException e) {
|
||||
|
||||
@@ -19,7 +19,6 @@ package com.jpexs.decompiler.flash.action.swf4;
|
||||
import com.jpexs.decompiler.flash.SWFInputStream;
|
||||
import com.jpexs.decompiler.flash.SWFOutputStream;
|
||||
import com.jpexs.decompiler.flash.action.Action;
|
||||
import com.jpexs.decompiler.flash.action.ActionGraphSource;
|
||||
import com.jpexs.decompiler.flash.action.parser.ParseException;
|
||||
import com.jpexs.decompiler.flash.action.parser.pcode.FlasmLexer;
|
||||
import com.jpexs.decompiler.flash.exporters.modes.ScriptExportMode;
|
||||
|
||||
@@ -146,7 +146,7 @@ public class DefineButtonTag extends ButtonTag implements ASMSource {
|
||||
if (actions == null) {
|
||||
actions = getActions();
|
||||
}
|
||||
return Action.actionsToString(listeners, 0, actions, swf.version, exportMode, writer, toString()/*FIXME?*/);
|
||||
return Action.actionsToString(listeners, 0, actions, swf.version, exportMode, writer);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -96,7 +96,7 @@ public class DoActionTag extends Tag implements ASMSource {
|
||||
if (actions == null) {
|
||||
actions = getActions();
|
||||
}
|
||||
return Action.actionsToString(listeners, 0, actions, swf.version, exportMode, writer, toString()/*FIXME?*/);
|
||||
return Action.actionsToString(listeners, 0, actions, swf.version, exportMode, writer);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -110,7 +110,7 @@ public class DoInitActionTag extends CharacterIdTag implements ASMSource {
|
||||
if (actions == null) {
|
||||
actions = getActions();
|
||||
}
|
||||
return Action.actionsToString(listeners, 0, actions, swf.version, exportMode, writer, toString()/*FIXME?*/);
|
||||
return Action.actionsToString(listeners, 0, actions, swf.version, exportMode, writer);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -165,7 +165,7 @@ public class BUTTONCONDACTION implements ASMSource, Exportable, ContainerItem, S
|
||||
if (actions == null) {
|
||||
actions = getActions();
|
||||
}
|
||||
return Action.actionsToString(listeners, 0, actions, swf.version, exportMode, writer, toString()/*FIXME?*/);
|
||||
return Action.actionsToString(listeners, 0, actions, swf.version, exportMode, writer);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -181,7 +181,7 @@ public class CLIPACTIONRECORD implements ASMSource, Exportable, ContainerItem, S
|
||||
if (actions == null) {
|
||||
actions = getActions();
|
||||
}
|
||||
return Action.actionsToString(listeners, 0, actions, swf.version, exportMode, writer, toString()/*FIXME?*/);
|
||||
return Action.actionsToString(listeners, 0, actions, swf.version, exportMode, writer);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user