mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-06-19 21:01:54 +00:00
Issue #306 editing AS directly - ActionStore fix (ifFrameLoaded)
This commit is contained in:
@@ -46,6 +46,7 @@ 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;
|
||||
import com.jpexs.decompiler.flash.action.special.ActionStore;
|
||||
import com.jpexs.decompiler.flash.action.swf4.ActionEquals;
|
||||
import com.jpexs.decompiler.flash.action.swf4.ActionIf;
|
||||
import com.jpexs.decompiler.flash.action.swf4.ActionJump;
|
||||
@@ -1006,7 +1007,14 @@ public class Action implements GraphSourceItem {
|
||||
action.translate(stack, constants, output, registerNames);
|
||||
}
|
||||
} */ else {
|
||||
try {
|
||||
|
||||
if(action instanceof ActionStore){
|
||||
ActionStore store=(ActionStore)action;
|
||||
store.setStore(actions.subList(ip+1, ip+1+store.getStoreSize()));
|
||||
ip = ip + 1 + store.getStoreSize() -1/*ip++ will be next*/;
|
||||
}
|
||||
|
||||
try {
|
||||
action.translate(localData, stack, output, staticOperation, path);
|
||||
} catch (EmptyStackException ese) {
|
||||
Logger.getLogger(Action.class.getName()).log(Level.SEVERE, "Decompilation error in: " + path, ese);
|
||||
|
||||
@@ -190,7 +190,7 @@ public class ActionListReader {
|
||||
}
|
||||
|
||||
updateJumps(actions, jumps, containerLastActions, endAddress, version);
|
||||
updateActionStores(actions, jumps);
|
||||
//updateActionStores(actions, jumps);
|
||||
updateContainerSizes(actions, containerLastActions);
|
||||
updateActionLengths(actions, version);
|
||||
|
||||
@@ -589,7 +589,7 @@ public class ActionListReader {
|
||||
|
||||
updateAddresses(actions, startIp, version);
|
||||
updateJumps(actions, jumps, containerLastActions, endAddress, version);
|
||||
updateActionStores(actions, jumps);
|
||||
//updateActionStores(actions, jumps);
|
||||
updateContainerSizes(actions, containerLastActions);
|
||||
updateActionLengths(actions, version);
|
||||
|
||||
|
||||
@@ -137,9 +137,6 @@ public class ASMParser {
|
||||
public static List<Action> parse(long containerSWFOffset, boolean ignoreNops, List<Label> labels, long address, FlasmLexer lexer, List<String> constantPool, int version) throws IOException, ParseException {
|
||||
List<Action> list = new ArrayList<>();
|
||||
Stack<GraphSourceItemContainer> containers = new Stack<>();
|
||||
Stack<ActionStore> stores = new Stack<>();
|
||||
Stack<Integer> storeLengths = new Stack<>();
|
||||
int actualLen = 0;
|
||||
|
||||
ActionConstantPool cpool = new ActionConstantPool(constantPool);
|
||||
cpool.containerSWFOffset = containerSWFOffset;
|
||||
@@ -197,30 +194,6 @@ public class ASMParser {
|
||||
}
|
||||
if (a != null) {
|
||||
list.add(a);
|
||||
if (!stores.isEmpty()) {
|
||||
actualLen++;
|
||||
if (actualLen == stores.peek().getStoreSize()) {
|
||||
ActionStore st = stores.pop();
|
||||
List<Action> sl = new ArrayList<>();
|
||||
sl.addAll(list.subList(list.size() - actualLen, list.size()));
|
||||
st.setStore(sl);
|
||||
|
||||
List<Action> sl2 = list.subList(0, list.size() - actualLen);
|
||||
list = new ArrayList<>();
|
||||
list.addAll(sl2);
|
||||
if (!stores.isEmpty()) {
|
||||
actualLen = storeLengths.pop();
|
||||
}
|
||||
}
|
||||
}
|
||||
if (a instanceof ActionStore) {
|
||||
if (!stores.isEmpty()) {
|
||||
storeLengths.push(actualLen);
|
||||
}
|
||||
stores.push((ActionStore) a);
|
||||
actualLen = 0;
|
||||
|
||||
}
|
||||
}
|
||||
} else if (symb.type == ASMParsedSymbol.TYPE_EOL) {
|
||||
} else if ((symb.type == ASMParsedSymbol.TYPE_BLOCK_END) || (symb.type == ASMParsedSymbol.TYPE_EOF)) {
|
||||
|
||||
@@ -26,6 +26,6 @@ import java.util.List;
|
||||
public interface ActionStore {
|
||||
|
||||
public int getStoreSize();
|
||||
|
||||
|
||||
public void setStore(List<Action> store);
|
||||
}
|
||||
|
||||
@@ -26,7 +26,6 @@ import com.jpexs.decompiler.flash.action.model.DirectValueActionItem;
|
||||
import com.jpexs.decompiler.flash.action.model.clauses.IfFrameLoadedActionItem;
|
||||
import com.jpexs.decompiler.flash.action.parser.ParseException;
|
||||
import com.jpexs.decompiler.flash.action.parser.pcode.FlasmLexer;
|
||||
import com.jpexs.decompiler.flash.action.special.ActionEnd;
|
||||
import com.jpexs.decompiler.flash.action.special.ActionStore;
|
||||
import com.jpexs.decompiler.graph.ExportMode;
|
||||
import com.jpexs.decompiler.graph.GraphSourceItem;
|
||||
@@ -49,39 +48,6 @@ public class ActionWaitForFrame extends Action implements ActionStore {
|
||||
frame = sis.readUI16();
|
||||
skipCount = sis.readUI8();
|
||||
skipped = new ArrayList<>();
|
||||
/*for (int i = 0; i < skipCount; i++) {
|
||||
Action a = sis.readAction(cpool);
|
||||
if (a instanceof ActionEnd) {
|
||||
skipCount = i;
|
||||
break;
|
||||
}
|
||||
if (a == null) {
|
||||
skipCount = i;
|
||||
break;
|
||||
}
|
||||
if (a instanceof ActionPush) {
|
||||
if (cpool != null) {
|
||||
((ActionPush) a).constantPool = cpool.constants;
|
||||
}
|
||||
}
|
||||
skipped.add(a);
|
||||
}
|
||||
boolean deobfuscate = Configuration.getConfig("autoDeobfuscate", true);
|
||||
if (deobfuscate) {
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
for (int i = 0; i < skipCount; i++) {
|
||||
baos.write(skipped.get(i).getBytes(sis.getVersion()));
|
||||
}
|
||||
baos.write(new ActionEnd().getBytes(sis.getVersion()));
|
||||
SWFInputStream sis2 = new SWFInputStream(new ByteArrayInputStream(baos.toByteArray()), sis.getVersion());
|
||||
skipped = sis2.readActionList(new ArrayList<DisassemblyListener>(), 0, "");
|
||||
if (!skipped.isEmpty()) {
|
||||
if (skipped.get(skipped.size() - 1) instanceof ActionEnd) {
|
||||
skipped.remove(skipped.size() - 1);
|
||||
}
|
||||
}
|
||||
skipCount = skipped.size();
|
||||
}*/
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -92,12 +58,6 @@ public class ActionWaitForFrame extends Action implements ActionStore {
|
||||
@Override
|
||||
public String getASMSource(List<? extends GraphSourceItem> container, List<Long> knownAddreses, List<String> constantPool, int version, ExportMode exportMode) {
|
||||
String ret = "WaitForFrame " + frame + " " + skipCount;
|
||||
for (int i = 0; i < skipped.size(); i++) {
|
||||
if (skipped.get(i) instanceof ActionEnd) {
|
||||
break;
|
||||
}
|
||||
ret += "\r\n" + skipped.get(i).getASMSource(container, knownAddreses, constantPool, version, exportMode);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -108,9 +68,6 @@ public class ActionWaitForFrame extends Action implements ActionStore {
|
||||
try {
|
||||
sos.writeUI16(frame);
|
||||
sos.writeUI8(skipCount);
|
||||
for (int i = 0; i < skipped.size(); i++) {
|
||||
sos.write(skipped.get(i).getBytes(SWF.DEFAULT_VERSION));
|
||||
}
|
||||
sos.close();
|
||||
} catch (IOException e) {
|
||||
}
|
||||
|
||||
@@ -119,12 +119,12 @@ public class ActionWaitForFrame2 extends Action implements ActionStore {
|
||||
@Override
|
||||
public String getASMSource(List<? extends GraphSourceItem> container, List<Long> knownAddreses, List<String> constantPool, int version, ExportMode exportMode) {
|
||||
String ret = "WaitForFrame2 " + skipCount;
|
||||
for (int i = 0; i < skipped.size(); i++) {
|
||||
/*for (int i = 0; i < skipped.size(); i++) {
|
||||
if (skipped.get(i) instanceof ActionEnd) {
|
||||
break;
|
||||
}
|
||||
ret += "\r\n" + skipped.get(i).getASMSource(container, knownAddreses, constantPool, version, exportMode);
|
||||
}
|
||||
}*/
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user