diff --git a/trunk/build.xml b/trunk/build.xml index fbfc22156..b8710abf8 100644 --- a/trunk/build.xml +++ b/trunk/build.xml @@ -45,7 +45,7 @@ - + diff --git a/trunk/lib/FlashPlayer.exe b/trunk/lib/FlashPlayer.exe index 6d168a784..28252f18f 100644 Binary files a/trunk/lib/FlashPlayer.exe and b/trunk/lib/FlashPlayer.exe differ diff --git a/trunk/libsrc/FlashPlayer/uMain.dcu b/trunk/libsrc/FlashPlayer/uMain.dcu index 9faed8f2a..02225922f 100644 Binary files a/trunk/libsrc/FlashPlayer/uMain.dcu and b/trunk/libsrc/FlashPlayer/uMain.dcu differ diff --git a/trunk/libsrc/FlashPlayer/uMain.dfm b/trunk/libsrc/FlashPlayer/uMain.dfm index a0629fa85..5ccb69124 100644 --- a/trunk/libsrc/FlashPlayer/uMain.dfm +++ b/trunk/libsrc/FlashPlayer/uMain.dfm @@ -1,6 +1,6 @@ object frmMain: TfrmMain - Left = 625 - Top = 484 + Left = 401 + Top = 190 Width = 1381 Height = 811 Caption = 'FFDec Flash Player' diff --git a/trunk/libsrc/FlashPlayer/uMain.pas b/trunk/libsrc/FlashPlayer/uMain.pas index aa760ed91..e71262821 100644 --- a/trunk/libsrc/FlashPlayer/uMain.pas +++ b/trunk/libsrc/FlashPlayer/uMain.pas @@ -99,13 +99,27 @@ buffer:TBuf; pipename:PAnsiChar; len:integer; cmd:integer; +written:cardinal; +val:cardinal; + +const + CMD_PLAY = 1; + CMD_RESIZE = 2; + CMD_BGCOLOR = 3; + CMD_CURRENT_FRAME = 4; + CMD_TOTAL_FRAMES = 5; + CMD_PAUSE = 6; + CMD_RESUME = 7; + CMD_PLAYING = 8; + CMD_REWIND = 9; + CMD_GOTO = 10; begin pipename:=PAnsiChar('\\.\\pipe\ffdec_flashplayer_'+ParamStr(1)); while (not self.Terminated) do begin - pipe:=CreateFile(pipename,GENERIC_READ, - FILE_SHARE_READ + FILE_SHARE_WRITE, + pipe:=CreateFile(pipename,GENERIC_READ or GENERIC_WRITE, + FILE_SHARE_READ or FILE_SHARE_WRITE, nil, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, @@ -117,7 +131,8 @@ begin begin ReadFile(pipe,buffer,1,numBytesRead,nil); cmd:=buffer[0]; - if(cmd=1) then + case cmd of + CMD_PLAY: begin ReadFile(pipe,buffer,1,numBytesRead,nil); if(numBytesRead>0) then @@ -128,19 +143,69 @@ begin Synchronize(displaySWF); end; end; - if(cmd=2) then + CMD_RESIZE: begin ReadFile(pipe,buffer,4,numBytesRead,nil); self.w:=buffer[0]*256+buffer[1]; self.h:=buffer[2]*256+buffer[3]; Synchronize(setPos); end; - if(cmd=3) then + CMD_BGCOLOR: begin ReadFile(pipe,buffer,3,numBytesRead,nil); self.bgColor := RGB(buffer[0],buffer[1],buffer[2]); Synchronize(setBGColor); end; + CMD_CURRENT_FRAME: + begin + if flaPreview.ReadyState = 4 then + val:=flaPreview.CurrentFrame + else + val:=0; + buffer[0]:=(val shr 8) mod 256; + buffer[1]:=val mod 256; + WriteFile(pipe,buffer,2,written,nil); + end; + CMD_TOTAL_FRAMES: + begin + if flaPreview.ReadyState = 4 then + val:=flaPreview.TotalFrames + else + val:=0; + buffer[0]:=(val shr 8) mod 256; + buffer[1]:=val mod 256; + WriteFile(pipe,buffer,2,written,nil); + end; + CMD_PAUSE: + begin + flaPreview.Stop; + end; + CMD_RESUME: + begin + flaPreview.Play; + end; + CMD_PLAYING: + begin + buffer[0]:=0; + if flaPreview.ReadyState = 4 then + if flaPreview.IsPlaying then + buffer[0]:=1; + + + WriteFile(pipe,buffer,1,written,nil); + end; + CMD_REWIND: + begin + flaPreview.Rewind; + end; + CMD_GOTO: + begin + ReadFile(pipe,buffer,2,numBytesRead,nil); + val := (buffer[0] shl 8) + buffer[1]; + flaPreview.GotoFrame(val); + end; + + end; end until numBytesRead<=0; CloseHandle(pipe); diff --git a/trunk/src/com/jpexs/decompiler/flash/Configuration.java b/trunk/src/com/jpexs/decompiler/flash/Configuration.java index e18c4be2c..c815b0872 100644 --- a/trunk/src/com/jpexs/decompiler/flash/Configuration.java +++ b/trunk/src/com/jpexs/decompiler/flash/Configuration.java @@ -64,28 +64,29 @@ public class Configuration { * List of replacements */ public static java.util.List replacements = new ArrayList<>(); - - private static HashMap configDefaults = new HashMap() {{ - put("decompile", true); - put("parallelSpeedUp", true); - put("autoDeobfuscate", true); - put("cacheOnDisk", true); - put("internalFlashViewer", false); - put("gotoMainClassOnStartup", false); - put("deobfuscateUsePrevTagOnly", true); - put("decompilationTimeoutSingleMethod", 60); - put("lastSaveDir", "."); - put("lastOpenDir", "."); - put("offeredAssociation", false); - put("locale", "en"); - put("lastUpdatesCheckDate", null); - put("gui.window.width", 1000); - put("gui.window.height", 700); - put("gui.window.maximized.horizontal", false); - put("gui.window.maximized.vertical", false); - put("lastRenameType", 1); - put("removeNops", true); - }}; + private static HashMap configDefaults = new HashMap() { + { + put("decompile", true); + put("parallelSpeedUp", true); + put("autoDeobfuscate", true); + put("cacheOnDisk", true); + put("internalFlashViewer", false); + put("gotoMainClassOnStartup", false); + put("deobfuscateUsePrevTagOnly", true); + put("decompilationTimeoutSingleMethod", 60); + put("lastSaveDir", "."); + put("lastOpenDir", "."); + put("offeredAssociation", false); + put("locale", "en"); + put("lastUpdatesCheckDate", null); + put("gui.window.width", 1000); + put("gui.window.height", 700); + put("gui.window.maximized.horizontal", false); + put("gui.window.maximized.vertical", false); + put("lastRenameType", 1); + put("removeNops", true); + } + }; /** * Saves replacements to file for future use @@ -137,7 +138,7 @@ public class Configuration { T defaultValue = null; if (configDefaults.containsKey(cfg)) { @SuppressWarnings("unchecked") - T def = (T)configDefaults.get(cfg); + T def = (T) configDefaults.get(cfg); defaultValue = def; } return getConfig(cfg, defaultValue); @@ -148,7 +149,7 @@ public class Configuration { return defaultValue; } @SuppressWarnings("unchecked") - T result = (T)config.get(cfg); + T result = (T) config.get(cfg); return result; } @@ -157,7 +158,7 @@ public class Configuration { cfg = "parallelSpeedUp"; } @SuppressWarnings("unchecked") - T result = (T)config.put(cfg, value); + T result = (T) config.put(cfg, value); return result; } diff --git a/trunk/src/com/jpexs/decompiler/flash/SWFInputStream.java b/trunk/src/com/jpexs/decompiler/flash/SWFInputStream.java index bd6d66019..c26af54ef 100644 --- a/trunk/src/com/jpexs/decompiler/flash/SWFInputStream.java +++ b/trunk/src/com/jpexs/decompiler/flash/SWFInputStream.java @@ -629,8 +629,8 @@ public class SWFInputStream extends InputStream { //pools = getConstantPool(listeners, new ActionGraphSource(ret, version, new HashMap(), new HashMap(), new HashMap()), 0, version, path); /*if (pools.size() == 1) { - Action.setConstantPool(ret, pools.get(0)); - }*/ + Action.setConstantPool(ret, pools.get(0)); + }*/ if (goesPrev && (!DEOBFUSCATION_ALL_CODE_IN_PREVIOUS_TAG)) { ActionJump aj = new ActionJump(ip); int skip = aj.getBytes(version).length; @@ -706,7 +706,7 @@ public class SWFInputStream extends InputStream { /*if(a instanceof ActionConstantPool){ throw new IllegalArgumentException("CP found"); - } */ + } */ if (a instanceof ActionPush) { if (cpool != null) { ((ActionPush) a).constantPool = cpool.constants; diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/BooleanAVM2Item.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/BooleanAVM2Item.java index a97d1a564..cffea146f 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/BooleanAVM2Item.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/BooleanAVM2Item.java @@ -32,7 +32,7 @@ public class BooleanAVM2Item extends AVM2Item { @Override public String toString(boolean highlight, ConstantPool constants, HashMap localRegNames, List fullyQualifiedNames) { - return hilight(value?"true":"false", highlight); + return hilight(value ? "true" : "false", highlight); } @Override diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/NewFunctionAVM2Item.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/NewFunctionAVM2Item.java index 1078e0e89..390859273 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/NewFunctionAVM2Item.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/NewFunctionAVM2Item.java @@ -39,6 +39,6 @@ public class NewFunctionAVM2Item extends AVM2Item { @Override public String toString(boolean highlight, ConstantPool constants, HashMap localRegNames, List fullyQualifiedNames) { - return hilight("function" + (!functionName.equals("") ? " " + functionName : "") + "(" + paramStr + "):" + returnStr + "\r\n{\r\n", highlight) + (highlight?functionBody:Highlighting.stripHilights(functionBody)) + "\r\n" + hilight("}", highlight); + return hilight("function" + (!functionName.equals("") ? " " + functionName : "") + "(" + paramStr + "):" + returnStr + "\r\n{\r\n", highlight) + (highlight ? functionBody : Highlighting.stripHilights(functionBody)) + "\r\n" + hilight("}", highlight); } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/clauses/TryAVM2Item.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/clauses/TryAVM2Item.java index 5f7246cd2..724eaacee 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/clauses/TryAVM2Item.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/clauses/TryAVM2Item.java @@ -62,7 +62,7 @@ public class TryAVM2Item extends AVM2Item implements Block { } ret += hilight("}", highlight); for (int e = 0; e < catchExceptions.size(); e++) { - ret += "\r\n" + hilight("catch(" + catchExceptions.get(e).getVarName(constants, fullyQualifiedNames) + ":" + catchExceptions.get(e).getTypeName(constants, fullyQualifiedNames) + ")", highlight) + "\r\n" + hilight("{", highlight) +"\r\n"; + ret += "\r\n" + hilight("catch(" + catchExceptions.get(e).getVarName(constants, fullyQualifiedNames) + ":" + catchExceptions.get(e).getTypeName(constants, fullyQualifiedNames) + ")", highlight) + "\r\n" + hilight("{", highlight) + "\r\n"; List commands = catchCommands.get(e); for (GraphTargetItem ti : commands) { if (!ti.isEmpty()) { @@ -72,7 +72,7 @@ public class TryAVM2Item extends AVM2Item implements Block { ret += hilight("}", highlight); } if (finallyCommands.size() > 0) { - ret += "\r\n" + hilight("finally", highlight) +"\r\n" + hilight("{", highlight) + "\r\n"; + ret += "\r\n" + hilight("finally", highlight) + "\r\n" + hilight("{", highlight) + "\r\n"; for (GraphTargetItem ti : finallyCommands) { if (!ti.isEmpty()) { ret += ti.toStringSemicoloned(highlight, Helper.toList(constants, localRegNames, fullyQualifiedNames)) + "\r\n"; diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/types/traits/TraitClass.java b/trunk/src/com/jpexs/decompiler/flash/abc/types/traits/TraitClass.java index 711b91bb3..294c7a420 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/types/traits/TraitClass.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/types/traits/TraitClass.java @@ -504,7 +504,7 @@ public class TraitClass extends Trait implements TraitWithSlot { String stripped = highlight ? Highlighting.stripHilights(s) : s; if (!stripped.trim().equals("")) { if (s.contains("/*classInitializer*/")) { - s = s.replace("/*classInitializer*/", ""); + s = s.replace("/*classInitializer*/", ""); s = s + "\r\n"; } else { if (!first) { diff --git a/trunk/src/com/jpexs/decompiler/flash/action/Action.java b/trunk/src/com/jpexs/decompiler/flash/action/Action.java index 330eb41b2..4666ce378 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/Action.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/Action.java @@ -419,9 +419,9 @@ public class Action implements GraphSourceItem { importantOffsets = getActionsAllRefs(list, version); } /*List cps = SWFInputStream.getConstantPool(new ArrayList(), new ActionGraphSource(list, version, new HashMap(), new HashMap(), new HashMap()), 0, version, path); - if (!cps.isEmpty()) { - setConstantPool(list, cps.get(cps.size() - 1)); - }*/ + if (!cps.isEmpty()) { + setConstantPool(list, cps.get(cps.size() - 1)); + }*/ HashMap> containers = new HashMap<>(); HashMap containersPos = new HashMap<>(); offset = address; diff --git a/trunk/src/com/jpexs/decompiler/flash/action/model/clauses/WithActionItem.java b/trunk/src/com/jpexs/decompiler/flash/action/model/clauses/WithActionItem.java index b82b9b941..647c6a41f 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/model/clauses/WithActionItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/model/clauses/WithActionItem.java @@ -49,7 +49,7 @@ public class WithActionItem extends ActionItem { String ret; List localData = new ArrayList<>(); localData.add(constants); - ret = hilight("with(", highlight) + scope.toString(highlight, localData) + hilight(")", highlight) + "\r\n" + hilight("{",highlight) + "\r\n"; + ret = hilight("with(", highlight) + scope.toString(highlight, localData) + hilight(")", highlight) + "\r\n" + hilight("{", highlight) + "\r\n"; for (GraphTargetItem ti : items) { ret += ti.toString(highlight, localData) + "\r\n"; } diff --git a/trunk/src/com/jpexs/decompiler/flash/action/parser/pcode/ASMParser.java b/trunk/src/com/jpexs/decompiler/flash/action/parser/pcode/ASMParser.java index e620e964d..8f10ebe59 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/parser/pcode/ASMParser.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/parser/pcode/ASMParser.java @@ -54,7 +54,7 @@ public class ASMParser { cpool.setAddress(address, version, false); address += cpool.getBytes(version).length; list.add(cpool); - + while (true) { ASMParsedSymbol symb = lexer.yylex(); if (symb.type == ASMParsedSymbol.TYPE_LABEL) { @@ -347,7 +347,7 @@ public class ASMParser { } return a; } - + private static List parseAllActions(FlasmLexer lexer, int version) throws IOException, ParseException { List list = new ArrayList<>(); Stack containers = new Stack<>(); @@ -380,14 +380,14 @@ public class ASMParser { public static List parse(long address, long containerSWFOffset, boolean ignoreNops, String source, int version) throws IOException, ParseException { FlasmLexer lexer = new FlasmLexer(new StringReader(source)); List list = parseAllActions(lexer, version); - + List constantPool = new ArrayList<>(); - for(Action a : list) { + for (Action a : list) { if (a instanceof ActionConstantPool) { constantPool.addAll(((ActionConstantPool) a).constantPool); } } - + lexer = new FlasmLexer(new StringReader(source)); List