Issue #1244 Incorrect showing of NOP instructions

This commit is contained in:
honfika@gmail.com
2016-05-28 22:43:08 +02:00
parent de2b4739c8
commit aa117d7c75
5 changed files with 71 additions and 8 deletions

View File

@@ -18,7 +18,7 @@ package com.jpexs.decompiler.flash;
import com.jpexs.decompiler.flash.action.Action;
import com.jpexs.decompiler.flash.action.special.ActionEnd;
import com.jpexs.decompiler.flash.action.special.ActionNop;
import com.jpexs.decompiler.flash.action.special.ActionUnknown;
import com.jpexs.decompiler.flash.action.swf3.ActionGetURL;
import com.jpexs.decompiler.flash.action.swf3.ActionGoToLabel;
import com.jpexs.decompiler.flash.action.swf3.ActionGotoFrame;
@@ -1896,9 +1896,7 @@ public class SWFInputStream implements AutoCloseable {
//skip(actionLength);
}*/
//throw new UnknownActionException(actionCode);
Action r = new ActionNop();
r.actionCode = actionCode;
r.actionLength = actionLength;
Action r = new ActionUnknown(actionCode, actionLength);
if (Configuration.useDetailedLogging.get()) {
logger.log(Level.SEVERE, "Unknown action code: {0}", actionCode);
}

View File

@@ -117,12 +117,12 @@ public abstract class Action implements GraphSourceItem {
/**
* Action type identifier
*/
public int actionCode;
private int actionCode;
/**
* Length of action data
*/
public int actionLength;
protected int actionLength;
private long address;
@@ -187,6 +187,15 @@ public abstract class Action implements GraphSourceItem {
return address;
}
/**
* Return code of this action
*
* @return code of this action
*/
public int getActionCode() {
return actionCode;
}
/**
* Gets all addresses which are referenced from this action and/or
* subactions
@@ -1068,7 +1077,7 @@ public abstract class Action implements GraphSourceItem {
}
/*ActionJump && ActionIf removed*/
/*if ((action instanceof ActionEnumerate2) || (action instanceof ActionEnumerate)) {
/*if ((action instanceof ActionEnumerate2) || (action instanceof ActionEnumerate)) {
loopStart = ip + 1;
isForIn = true;
ip += 4;

View File

@@ -24,6 +24,7 @@ import com.jpexs.decompiler.flash.action.special.ActionDeobfuscateJump;
import com.jpexs.decompiler.flash.action.special.ActionEnd;
import com.jpexs.decompiler.flash.action.special.ActionNop;
import com.jpexs.decompiler.flash.action.special.ActionStore;
import com.jpexs.decompiler.flash.action.special.ActionUnknown;
import com.jpexs.decompiler.flash.action.swf4.ActionIf;
import com.jpexs.decompiler.flash.action.swf4.ActionJump;
import com.jpexs.decompiler.flash.action.swf4.ActionPush;
@@ -700,7 +701,7 @@ public class ActionListReader {
int actionLengthWithHeader = a.getTotalActionLength();
// unknown action, replace with jump
if (a instanceof ActionNop) {
if (a instanceof ActionUnknown && a.getActionCode() >= 0x80) {
ActionJump aJump = new ActionDeobfuscateJump(0);
int jumpLength = aJump.getTotalActionLength();
aJump.setAddress(a.getAddress());

View File

@@ -34,6 +34,10 @@ public class ActionNop extends Action {
super(-1, 0);
}
protected ActionNop(int actionCode) {
super(actionCode, 0);
}
@Override
public String toString() {
return "Nop";

View File

@@ -0,0 +1,51 @@
/*
* Copyright (C) 2010-2016 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.
*/
package com.jpexs.decompiler.flash.action.special;
import com.jpexs.decompiler.flash.action.LocalDataArea;
import com.jpexs.decompiler.graph.GraphSourceItem;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.TranslateStack;
import com.jpexs.helpers.Helper;
import java.util.HashMap;
import java.util.List;
/**
*
* @author JPEXS
*/
public class ActionUnknown extends ActionNop {
public ActionUnknown(int actionCode, int actionLength) {
super(actionCode);
this.actionLength = actionLength;
}
@Override
public String toString() {
return "Unknown_" + Helper.byteToHex((byte) getActionCode());
}
@Override
public boolean execute(LocalDataArea lda) {
return true;
}
@Override
public void translate(GraphSourceItem lineStartItem, TranslateStack stack, List<GraphTargetItem> output, HashMap<Integer, String> regNames, HashMap<String, GraphTargetItem> variables, HashMap<String, GraphTargetItem> functions, int staticOperation, String path) {
}
}