draft
This commit is contained in:
parent
132f3c9d16
commit
c9fe0153e4
@ -12,7 +12,7 @@ import java.io.File;
|
||||
public class Main {
|
||||
public static void main(String[] args) throws Exception {
|
||||
FlashDecompiler decompiler = new FlashDecompiler();
|
||||
ShockwaveFile file = decompiler.loadFromFile(new File("catalogs.swf"));
|
||||
ShockwaveFile file = decompiler.loadFromFile(new File("D:\\Documents\\rtmpSpring\\static\\swf\\cache\\rus\\resources.swf"));
|
||||
|
||||
DoAction da = (DoAction) file.getTags()
|
||||
.stream()
|
||||
|
@ -0,0 +1,10 @@
|
||||
package com.alterdekim.flash.decompiler.action;
|
||||
|
||||
import com.alterdekim.flash.decompiler.util.ActionField;
|
||||
|
||||
public class ActionAdd extends ByteCodeAction {
|
||||
@Override
|
||||
public ActionField getType() {
|
||||
return ActionField.Add;
|
||||
}
|
||||
}
|
@ -5,6 +5,7 @@ import com.alterdekim.flash.decompiler.item.ActionPushType;
|
||||
import com.alterdekim.flash.decompiler.action.ByteCodeAction;
|
||||
import com.alterdekim.flash.decompiler.item.ByteCodeItem;
|
||||
import com.alterdekim.flash.decompiler.item.PoolIndexItem;
|
||||
import com.alterdekim.flash.decompiler.item.StringItem;
|
||||
import com.alterdekim.flash.decompiler.tag.DoAction;
|
||||
import com.alterdekim.flash.decompiler.util.ActionField;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@ -20,6 +21,7 @@ public class Flash2Java {
|
||||
this.pool = doAction.getActionPool();
|
||||
List<ByteCodeAction> actions = doAction.getActions();
|
||||
|
||||
// convert stack from List<ByteCodeAction> to List<ByteCodeItem> and rewrite all code accordingly.
|
||||
List<ByteCodeAction> stack = new ArrayList<>();
|
||||
Map<String, FlashVar> vars = new HashMap<>();
|
||||
for (ByteCodeAction action : actions) {
|
||||
@ -37,6 +39,9 @@ public class Flash2Java {
|
||||
setMember(vars, stack);
|
||||
stack.clear();
|
||||
break;
|
||||
case Add:
|
||||
reduceViaAdder(stack);
|
||||
break;
|
||||
default:
|
||||
stack.add(action);
|
||||
}
|
||||
@ -47,6 +52,24 @@ public class Flash2Java {
|
||||
return vars;
|
||||
}
|
||||
|
||||
private void reduceViaAdder(List<ByteCodeAction> stack) {
|
||||
// get last 2 elements from stack
|
||||
List<Integer> si = new ArrayList<>();
|
||||
List<ByteCodeItem> g = new ArrayList<>();
|
||||
for( int i = stack.size()-1; i >= 0; i-- ) {
|
||||
ByteCodeAction e = stack.get(i);
|
||||
if( e.getType() != ActionField.Push ) continue;
|
||||
ActionPush push = (ActionPush) e;
|
||||
if( push.getItems().size() >= 2 ) {
|
||||
StringItem from = (StringItem) push.getItems().get(push.getItems().size()-1);
|
||||
StringItem to = (StringItem) push.getItems().get(push.getItems().size()-2);
|
||||
push.getItems().remove()
|
||||
((String) to.getValue()) + ((String) from.getValue())
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void setMember(Map<String, FlashVar> vars, List<ByteCodeAction> stack) {
|
||||
String varKey = vars.keySet().stream().filter(k -> vars.get(k).isActive()).findFirst().get();
|
||||
FlashVar varVal = vars.get(varKey);
|
||||
@ -71,6 +94,8 @@ public class Flash2Java {
|
||||
private Object valConverter(ByteCodeItem item) {
|
||||
if ( item.getType() == ActionPushType.POOL_INDEX ) {
|
||||
return fromPool( (Integer) item.getValue() );
|
||||
} else if ( item.getType() == ActionPushType.STRING ) {
|
||||
return item.getValue();
|
||||
}
|
||||
return item.getValue();
|
||||
}
|
||||
|
@ -7,6 +7,7 @@ public enum ActionField {
|
||||
DefineLocal((byte) 0x3C),
|
||||
SetMember((byte)0x4F),
|
||||
GetVariable((byte) 0x1C),
|
||||
Add((byte) 0x47),
|
||||
Unknown((byte) 0x00);
|
||||
|
||||
public final byte id;
|
||||
|
Loading…
x
Reference in New Issue
Block a user