diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/ABCMethodIndexing.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/ABCMethodIndexing.java index 56b8605c0..8ba494d85 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/ABCMethodIndexing.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/ABCMethodIndexing.java @@ -36,7 +36,7 @@ import java.util.Map; */ public class ABCMethodIndexing { - private ABC abc; + private final ABC abc; private Map bodyIdxFromMethod = new HashMap<>(); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/AVM2Code.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/AVM2Code.java index 41b3c7a01..e4189d543 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/AVM2Code.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/AVM2Code.java @@ -193,10 +193,10 @@ import com.jpexs.decompiler.flash.abc.avm2.instructions.other2.MultiplyPIns; import com.jpexs.decompiler.flash.abc.avm2.instructions.other2.NegatePIns; import com.jpexs.decompiler.flash.abc.avm2.instructions.other2.PrologueIns; import com.jpexs.decompiler.flash.abc.avm2.instructions.other2.PushConstantIns; -import com.jpexs.decompiler.flash.abc.avm2.instructions.other2.PushFloatIns; import com.jpexs.decompiler.flash.abc.avm2.instructions.other2.PushDNanIns; import com.jpexs.decompiler.flash.abc.avm2.instructions.other2.PushDecimalIns; import com.jpexs.decompiler.flash.abc.avm2.instructions.other2.PushFloat4Ins; +import com.jpexs.decompiler.flash.abc.avm2.instructions.other2.PushFloatIns; import com.jpexs.decompiler.flash.abc.avm2.instructions.other2.SendEnterIns; import com.jpexs.decompiler.flash.abc.avm2.instructions.other2.SetPropertyLateIns; import com.jpexs.decompiler.flash.abc.avm2.instructions.other2.Sf32x4Ins; @@ -306,7 +306,6 @@ import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.OutputStream; -import java.lang.reflect.Field; import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; @@ -427,6 +426,7 @@ public class AVM2Code implements Cloneable { } public static final InstructionDefinition[] instructionSet = new InstructionDefinition[256]; + public static final InstructionDefinition[] allInstructionSet = new InstructionDefinition[]{ /*0x00*/null, /*0x01*/ new BkptIns(), @@ -480,7 +480,7 @@ public class AVM2Code implements Cloneable { /*0x30*/ new PushScopeIns(), /*0x31*/ new PushNamespaceIns(), /*0x32*/ new HasNext2Ins(), - /*0x33*/ new PushDecimalIns(), //pushdecimal(minor 17), lix8 (internal-only) according to Tamarin + /*0x33*/ new PushDecimalIns(), //pushdecimal(minor 17), lix8 (internal-only) according to Tamarin /*0x34*/ new PushDNanIns(), //pushdnan according to Flex SDK, lix16 (internal-only) according to Tamarin /*0x35*/ new Li8Ins(), /*0x36*/ new Li16Ins(), @@ -717,6 +717,7 @@ public class AVM2Code implements Cloneable { } } + public static final String IDENTOPEN = "/*IDENTOPEN*/"; public static final String IDENTCLOSE = "/*IDENTCLOSE*/"; @@ -1637,7 +1638,7 @@ public class AVM2Code implements Cloneable { } }//*/ - /*if ((ip + 2 < code.size()) && (ins.definition instanceof NewCatchIns)) { // Filling local register in catch clause + /*if ((ip + 2 < code.size()) && (ins.definition instanceof NewCatchIns)) { // Filling local register in catch clause if (code.get(ip + 1).definition instanceof DupIns) { if (code.get(ip + 2).definition instanceof SetLocalTypeIns) { ins.definition.translate(isStatic, classIndex, localRegs, stack, scopeStack, constants, ins, method_info, output, body, abc, localRegNames, fullyQualifiedNames); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/AVM2ConstantPool.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/AVM2ConstantPool.java index 3f71ebe9c..1303e51f5 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/AVM2ConstantPool.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/AVM2ConstantPool.java @@ -16,6 +16,7 @@ */ package com.jpexs.decompiler.flash.abc.avm2; +import com.jpexs.decompiler.flash.abc.ABCVersionRequirements; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instructions; import com.jpexs.decompiler.flash.abc.types.Decimal; @@ -37,7 +38,6 @@ import java.util.List; import java.util.Map; import java.util.logging.Level; import java.util.logging.Logger; -import com.jpexs.decompiler.flash.abc.ABCVersionRequirements; /** * diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/deobfuscation/AVM2DeobfuscatorSimpleOld.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/deobfuscation/AVM2DeobfuscatorSimpleOld.java index d13e8e274..472aa6bdd 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/deobfuscation/AVM2DeobfuscatorSimpleOld.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/deobfuscation/AVM2DeobfuscatorSimpleOld.java @@ -87,7 +87,6 @@ import com.jpexs.decompiler.flash.abc.avm2.model.StringAVM2Item; import com.jpexs.decompiler.flash.abc.avm2.model.UndefinedAVM2Item; import com.jpexs.decompiler.flash.abc.types.MethodBody; import com.jpexs.decompiler.flash.abc.types.traits.Trait; -import com.jpexs.decompiler.flash.ecma.EcmaScript; import com.jpexs.decompiler.flash.ecma.Null; import com.jpexs.decompiler.flash.ecma.Undefined; import com.jpexs.decompiler.flash.helpers.SWFDecompilerAdapter; @@ -238,14 +237,14 @@ public class AVM2DeobfuscatorSimpleOld extends SWFDecompilerAdapter { InstructionDefinition def = ins.definition; //System.err.println("" + ins + " stack size:" + stack.size()); /*if (ins.definition instanceof NewFunctionIns) { - if (idx + 1 < code.code.size()) { - if (code.code.get(idx + 1).definition instanceof PopIns) { - code.removeInstruction(idx + 1, body); - code.removeInstruction(idx, body); - continue; - } - } - } else */ + if (idx + 1 < code.code.size()) { + if (code.code.get(idx + 1).definition instanceof PopIns) { + code.removeInstruction(idx + 1, body); + code.removeInstruction(idx, body); + continue; + } + } + } else */ { // do not throw EmptyStackException, much faster int requiredStackSize = ins.getStackPopCount(localData); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/AVM2Instruction.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/AVM2Instruction.java index dbe49cfdd..f53b17d80 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/AVM2Instruction.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/AVM2Instruction.java @@ -28,7 +28,6 @@ import com.jpexs.decompiler.flash.abc.avm2.instructions.other.ReturnVoidIns; import com.jpexs.decompiler.flash.abc.avm2.instructions.other.ThrowIns; import com.jpexs.decompiler.flash.abc.types.Float4; import com.jpexs.decompiler.flash.abc.types.Multiname; -import com.jpexs.decompiler.flash.abc.types.Namespace; import com.jpexs.decompiler.flash.helpers.GraphTextWriter; import com.jpexs.decompiler.graph.DottedChain; import com.jpexs.decompiler.graph.GraphSource; diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/construction/NewObjectIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/construction/NewObjectIns.java index 67051f05d..17faf3eae 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/construction/NewObjectIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/construction/NewObjectIns.java @@ -27,7 +27,6 @@ import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; import com.jpexs.decompiler.flash.abc.avm2.model.NameValuePair; import com.jpexs.decompiler.flash.abc.avm2.model.NewObjectAVM2Item; import com.jpexs.decompiler.flash.abc.avm2.model.NullAVM2Item; -import com.jpexs.decompiler.flash.ecma.ArrayType; import com.jpexs.decompiler.flash.ecma.ObjectType; import com.jpexs.decompiler.graph.GraphTargetItem; import com.jpexs.decompiler.graph.TranslateStack; diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/GetLocalTypeIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/GetLocalTypeIns.java index 1c2833e48..a9ca920cc 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/GetLocalTypeIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/GetLocalTypeIns.java @@ -28,13 +28,10 @@ import com.jpexs.decompiler.flash.abc.avm2.model.ScriptAVM2Item; import com.jpexs.decompiler.flash.abc.avm2.model.ThisAVM2Item; import com.jpexs.decompiler.flash.abc.types.Multiname; import com.jpexs.decompiler.flash.abc.types.traits.Trait; -import com.jpexs.decompiler.flash.abc.types.traits.TraitMethodGetterSetter; import com.jpexs.decompiler.flash.ecma.Undefined; -import com.jpexs.decompiler.graph.DottedChain; import com.jpexs.decompiler.graph.GraphTargetItem; import com.jpexs.decompiler.graph.NotCompileTimeItem; import com.jpexs.decompiler.graph.TranslateStack; -import java.util.ArrayList; import java.util.List; /** diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/GetPropertyIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/GetPropertyIns.java index 5830690d3..427973573 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/GetPropertyIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/GetPropertyIns.java @@ -29,7 +29,6 @@ import com.jpexs.decompiler.flash.abc.avm2.model.GetPropertyAVM2Item; import com.jpexs.decompiler.flash.abc.types.Multiname; import com.jpexs.decompiler.flash.ecma.ArrayType; import com.jpexs.decompiler.flash.ecma.EcmaScript; -import com.jpexs.decompiler.flash.ecma.EcmaType; import com.jpexs.decompiler.flash.ecma.ObjectType; import com.jpexs.decompiler.flash.ecma.Undefined; import com.jpexs.decompiler.graph.GraphTargetItem; diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other2/UnPlusIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other2/UnPlusIns.java index 5e24419e5..54aabcd47 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other2/UnPlusIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other2/UnPlusIns.java @@ -17,8 +17,6 @@ package com.jpexs.decompiler.flash.abc.avm2.instructions.other2; import com.jpexs.decompiler.flash.abc.ABC; -import com.jpexs.decompiler.flash.abc.avm2.AVM2ConstantPool; -import com.jpexs.decompiler.flash.abc.avm2.LocalDataArea; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2InstructionFlag; import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/AsTypeIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/AsTypeIns.java index 0256e9a6a..97a85c446 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/AsTypeIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/AsTypeIns.java @@ -26,7 +26,6 @@ import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; import com.jpexs.decompiler.flash.abc.avm2.model.FullMultinameAVM2Item; import com.jpexs.decompiler.flash.abc.avm2.model.operations.AsTypeAVM2Item; import com.jpexs.decompiler.flash.ecma.NotCompileTime; -import com.jpexs.decompiler.graph.DottedChain; import com.jpexs.decompiler.graph.GraphTargetItem; import com.jpexs.decompiler.graph.TranslateStack; import java.util.ArrayList; diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/CallAVM2Item.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/CallAVM2Item.java index 5035304f2..23eb8eeda 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/CallAVM2Item.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/CallAVM2Item.java @@ -16,24 +16,18 @@ */ package com.jpexs.decompiler.flash.abc.avm2.model; -import com.jpexs.decompiler.graph.model.Callable; import com.jpexs.decompiler.flash.ecma.EcmaScript; import com.jpexs.decompiler.flash.helpers.GraphTextWriter; import com.jpexs.decompiler.graph.GraphSourceItem; import com.jpexs.decompiler.graph.GraphTargetItem; import com.jpexs.decompiler.graph.TypeItem; +import com.jpexs.decompiler.graph.model.Callable; import com.jpexs.decompiler.graph.model.LocalData; -import com.jpexs.helpers.utf8.Utf8Helper; -import java.io.UnsupportedEncodingException; -import java.net.URLDecoder; -import java.net.URLEncoder; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Set; -import java.util.logging.Level; -import java.util.logging.Logger; /** * diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/GetLexAVM2Item.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/GetLexAVM2Item.java index 2c3a67ef6..00c7516e6 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/GetLexAVM2Item.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/GetLexAVM2Item.java @@ -24,7 +24,6 @@ import com.jpexs.decompiler.graph.GraphSourceItem; import com.jpexs.decompiler.graph.GraphTargetItem; import com.jpexs.decompiler.graph.TypeItem; import com.jpexs.decompiler.graph.model.LocalData; -import java.util.ArrayList; /** * @@ -33,7 +32,8 @@ import java.util.ArrayList; public class GetLexAVM2Item extends AVM2Item { public Multiname propertyName; - private DottedChain fullPropertyName; + + private final DottedChain fullPropertyName; public GetLexAVM2Item(GraphSourceItem instruction, GraphSourceItem lineStartIns, Multiname propertyName, AVM2ConstantPool constants) { super(instruction, lineStartIns, PRECEDENCE_PRIMARY); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/LocalRegAVM2Item.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/LocalRegAVM2Item.java index 242d3dc5f..7e87ac8f6 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/LocalRegAVM2Item.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/LocalRegAVM2Item.java @@ -27,7 +27,6 @@ import com.jpexs.decompiler.graph.GraphTargetItem; import com.jpexs.decompiler.graph.SourceGenerator; import com.jpexs.decompiler.graph.TypeItem; import com.jpexs.decompiler.graph.model.LocalData; -import java.util.HashSet; import java.util.List; import java.util.Set; diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/RegExpAvm2Item.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/RegExpAvm2Item.java index d5580f43d..b8fda568a 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/RegExpAvm2Item.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/RegExpAvm2Item.java @@ -1,6 +1,5 @@ package com.jpexs.decompiler.flash.abc.avm2.model; -import com.jpexs.decompiler.graph.model.Callable; import com.jpexs.decompiler.flash.SourceGeneratorLocalData; import com.jpexs.decompiler.flash.abc.ABC; import com.jpexs.decompiler.flash.abc.avm2.AVM2ConstantPool; @@ -18,6 +17,7 @@ import com.jpexs.decompiler.graph.GraphSourceItem; import com.jpexs.decompiler.graph.GraphTargetItem; import com.jpexs.decompiler.graph.SourceGenerator; import com.jpexs.decompiler.graph.TypeItem; +import com.jpexs.decompiler.graph.model.Callable; import com.jpexs.decompiler.graph.model.LocalData; import com.jpexs.helpers.Helper; import java.util.ArrayList; diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/ThisAVM2Item.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/ThisAVM2Item.java index 39a911205..9e998b479 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/ThisAVM2Item.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/ThisAVM2Item.java @@ -17,7 +17,6 @@ package com.jpexs.decompiler.flash.abc.avm2.model; import com.jpexs.decompiler.flash.SourceGeneratorLocalData; -import com.jpexs.decompiler.flash.abc.avm2.AVM2ConstantPool; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instructions; import com.jpexs.decompiler.flash.abc.types.Multiname; @@ -41,7 +40,9 @@ import java.util.Set; public class ThisAVM2Item extends AVM2Item { public DottedChain className; + public boolean basicObject; + public Multiname classMultiname; public ThisAVM2Item(GraphSourceItem instruction, GraphSourceItem lineStartIns, Multiname classMultiname, DottedChain className, boolean basicObject) { diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/UndefinedAVM2Item.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/UndefinedAVM2Item.java index 5e5de4c39..6817337e4 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/UndefinedAVM2Item.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/UndefinedAVM2Item.java @@ -22,7 +22,6 @@ import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instructions; import com.jpexs.decompiler.flash.ecma.Undefined; import com.jpexs.decompiler.flash.helpers.GraphTextWriter; import com.jpexs.decompiler.graph.CompilationException; -import com.jpexs.decompiler.graph.DottedChain; import com.jpexs.decompiler.graph.GraphSourceItem; import com.jpexs.decompiler.graph.GraphTargetItem; import com.jpexs.decompiler.graph.SimpleValue; diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/clauses/ForEachInAVM2Item.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/clauses/ForEachInAVM2Item.java index e97f80d82..433285894 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/clauses/ForEachInAVM2Item.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/clauses/ForEachInAVM2Item.java @@ -18,8 +18,6 @@ package com.jpexs.decompiler.flash.abc.avm2.model.clauses; import com.jpexs.decompiler.flash.SourceGeneratorLocalData; import com.jpexs.decompiler.flash.abc.avm2.model.InAVM2Item; -import com.jpexs.decompiler.flash.abc.avm2.model.LocalRegAVM2Item; -import com.jpexs.decompiler.flash.abc.avm2.model.SetTypeAVM2Item; import com.jpexs.decompiler.flash.abc.avm2.parser.script.AVM2SourceGenerator; import com.jpexs.decompiler.flash.helpers.GraphTextWriter; import com.jpexs.decompiler.flash.helpers.LoopWithType; @@ -62,39 +60,39 @@ public class ForEachInAVM2Item extends LoopItem implements Block { super(instruction, lineStartIns, loop); /* - Following was commented out: - - The code should fix following: - for each (var a in col) - { - var b = a; //a is temp reg - trace(b); - } - - but fails for following: - for each (var a in col) - { - c[a] = a; - } - - - */ - /* - if (!commands.isEmpty()) { - GraphTargetItem firstAssign = commands.get(0); - if (firstAssign instanceof SetTypeAVM2Item) { - if (expression.object instanceof LocalRegAVM2Item) { - if (((SetTypeAVM2Item) firstAssign).getValue().getNotCoerced() instanceof LocalRegAVM2Item) { - if (((LocalRegAVM2Item) ((SetTypeAVM2Item) firstAssign).getValue().getNotCoerced()).regIndex == ((LocalRegAVM2Item) expression.object).regIndex) { - commands.remove(0); - expression.object = ((SetTypeAVM2Item) firstAssign).getObject(); - } - } + Following was commented out: - } - //locAssign. - } - }*/ + The code should fix following: + for each (var a in col) + { + var b = a; //a is temp reg + trace(b); + } + + but fails for following: + for each (var a in col) + { + c[a] = a; + } + + + */ + /* + if (!commands.isEmpty()) { + GraphTargetItem firstAssign = commands.get(0); + if (firstAssign instanceof SetTypeAVM2Item) { + if (expression.object instanceof LocalRegAVM2Item) { + if (((SetTypeAVM2Item) firstAssign).getValue().getNotCoerced() instanceof LocalRegAVM2Item) { + if (((LocalRegAVM2Item) ((SetTypeAVM2Item) firstAssign).getValue().getNotCoerced()).regIndex == ((LocalRegAVM2Item) expression.object).regIndex) { + commands.remove(0); + expression.object = ((SetTypeAVM2Item) firstAssign).getObject(); + } + } + + } + //locAssign. + } + }*/ this.expression = expression; this.commands = commands; } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/ActionScript3Parser.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/ActionScript3Parser.java index 58ebbe8ec..4001a5606 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/ActionScript3Parser.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/ActionScript3Parser.java @@ -2236,7 +2236,7 @@ public class ActionScript3Parser { case REGEXP: String p = (String) s.value; p = p.substring(1); - int spos = p.lastIndexOf("/"); + int spos = p.lastIndexOf('/'); String mod = p.substring(spos + 1); p = p.substring(0, spos); p = p.replace("\\/", "/"); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/Namespace.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/Namespace.java index f40b6b29d..51ad54ea5 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/Namespace.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/Namespace.java @@ -133,7 +133,7 @@ public class Namespace { if (name == null) { return false; } - if (name.equals("") && name_index == 0) { + if (name.isEmpty() && name_index == 0) { return true; } if (name_index == 0) { diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/ActionListReader.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/ActionListReader.java index b2a283ed2..4047d480d 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/ActionListReader.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/ActionListReader.java @@ -67,6 +67,7 @@ public class ActionListReader { * @param ip * @param endIp * @param path + * @param deobfuscationMode * @return List of actions * @throws IOException * @throws java.lang.InterruptedException diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/model/RandomNumberActionItem.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/model/RandomNumberActionItem.java index 730032d5f..c8de43c07 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/model/RandomNumberActionItem.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/model/RandomNumberActionItem.java @@ -35,7 +35,7 @@ import java.util.Random; */ public class RandomNumberActionItem extends ActionItem { - private static Random rnd = new Random(); + private static final Random rnd = new Random(); public RandomNumberActionItem(GraphSourceItem instruction, GraphSourceItem lineStartIns, GraphTargetItem maximum) { super(instruction, lineStartIns, PRECEDENCE_PRIMARY, maximum); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionGotoFrame2.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionGotoFrame2.java index a5167ef6b..170700155 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionGotoFrame2.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionGotoFrame2.java @@ -116,8 +116,8 @@ public class ActionGotoFrame2 extends Action { String frame = EcmaScript.toString(lda.stack.pop()); String target = "/"; if (frame.contains(":")) { - target = frame.substring(0, frame.indexOf(":")); - frame = frame.substring(frame.indexOf(":") + 1); + target = frame.substring(0, frame.indexOf(':')); + frame = frame.substring(frame.indexOf(':') + 1); } if (frame.matches("[1-9][0-9]*|0")) { int frameNum = Integer.parseInt(frame); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf5/ActionInitObject.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf5/ActionInitObject.java index c991ac8ca..495406a04 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf5/ActionInitObject.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf5/ActionInitObject.java @@ -51,7 +51,7 @@ public class ActionInitObject extends Action { return false; } - int num = (int) (double) (Double) lda.popAsNumber(); + int num = (int) (double) lda.popAsNumber(); if (lda.stack.size() < 2 * num) { return false; } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf5/ActionNewObject.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf5/ActionNewObject.java index 3663e6c3a..c1ffdaf00 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf5/ActionNewObject.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf5/ActionNewObject.java @@ -52,7 +52,7 @@ public class ActionNewObject extends Action { } String objectName = lda.popAsString(); - int numArgs = (int) (double) (Double) lda.popAsNumber(); + int numArgs = (int) (double) lda.popAsNumber(); if (lda.stack.size() < numArgs) { return false; } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/ecma/EcmaFloatingDecimal.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/ecma/EcmaFloatingDecimal.java index 81fb79fd4..6b2abd741 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/ecma/EcmaFloatingDecimal.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/ecma/EcmaFloatingDecimal.java @@ -1038,6 +1038,7 @@ public class EcmaFloatingDecimal { // Per-thread buffer for string/stringbuffer conversion private static ThreadLocal perThreadBuffer = new ThreadLocal() { + @Override protected synchronized Object initialValue() { return new char[26]; } @@ -1657,6 +1658,7 @@ class FDBigInt { return ((long) (data[1]) << 32) | ((long) data[0] & 0xffffffffL); } + @Override public String toString() { StringBuffer r = new StringBuffer(30); r.append('['); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/ecma/EcmaType.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/ecma/EcmaType.java index 3ac919634..6e63a179a 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/ecma/EcmaType.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/ecma/EcmaType.java @@ -29,7 +29,7 @@ public enum EcmaType { OBJECT("Object"), BOOLEAN("Boolean"); - private String clsName; + private final String clsName; private EcmaType(String clsName) { this.clsName = clsName; diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/helpers/GraphTextWriter.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/helpers/GraphTextWriter.java index 6ef3ec732..65db3bcb0 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/helpers/GraphTextWriter.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/helpers/GraphTextWriter.java @@ -56,7 +56,7 @@ public abstract class GraphTextWriter { * Highlights specified text as instruction * * @param src - * @param firstLineItem + * @param startLineItem * @param pos Offset of instruction * @param data * @return GraphTextWriter diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/helpers/HighlightedTextWriter.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/helpers/HighlightedTextWriter.java index fb92b0624..a42adb45d 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/helpers/HighlightedTextWriter.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/helpers/HighlightedTextWriter.java @@ -80,6 +80,7 @@ public class HighlightedTextWriter extends GraphTextWriter { * Highlights specified text as instruction by adding special tags * * @param src + * @param startLineItem * @param pos Offset of instruction * @param data * @return HighlightedTextWriter diff --git a/libsrc/ffdec_lib/src/com/jpexs/helpers/MD5Crypt.java b/libsrc/ffdec_lib/src/com/jpexs/helpers/MD5Crypt.java index bd012aec4..8d74bd53d 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/helpers/MD5Crypt.java +++ b/libsrc/ffdec_lib/src/com/jpexs/helpers/MD5Crypt.java @@ -50,7 +50,7 @@ public class MD5Crypt { String checksum = hash.substring(magic.length()); String salt = ""; if (checksum.contains("$")) { - salt = checksum.substring(0, checksum.indexOf("$")); + salt = checksum.substring(0, checksum.indexOf('$')); } return hash.equals(crypt(password, salt, magic)); } diff --git a/libsrc/ffdec_lib/src/com/jpexs/helpers/SerializableImage.java b/libsrc/ffdec_lib/src/com/jpexs/helpers/SerializableImage.java index 7b24b095f..189f31210 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/helpers/SerializableImage.java +++ b/libsrc/ffdec_lib/src/com/jpexs/helpers/SerializableImage.java @@ -28,17 +28,12 @@ import java.awt.RenderingHints; import java.awt.image.BufferedImage; import java.awt.image.ColorModel; import java.awt.image.IndexColorModel; -import java.awt.image.VolatileImage; import java.awt.image.WritableRaster; -import java.io.File; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.io.Serializable; import java.util.Hashtable; -import java.util.logging.Level; -import java.util.logging.Logger; -import javax.imageio.ImageIO; /** * diff --git a/libsrc/plugins/src/FlashChatEncrypter.java b/libsrc/plugins/src/FlashChatEncrypter.java new file mode 100644 index 000000000..1737c84f9 --- /dev/null +++ b/libsrc/plugins/src/FlashChatEncrypter.java @@ -0,0 +1,153 @@ + +import com.jpexs.decompiler.flash.SWF; +import com.jpexs.decompiler.flash.abc.ABC; +import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; +import com.jpexs.decompiler.flash.abc.avm2.instructions.stack.PushIntIns; +import com.jpexs.decompiler.flash.abc.avm2.instructions.stack.PushStringIns; +import com.jpexs.decompiler.flash.abc.types.MethodBody; +import com.jpexs.decompiler.flash.abc.types.traits.Trait; +import com.jpexs.decompiler.flash.action.ActionList; +import com.jpexs.decompiler.flash.helpers.SWFDecompilerListener; +import com.jpexs.decompiler.flash.tags.Tag; +import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.helpers.Helper; +import java.io.FileOutputStream; +import java.io.IOException; +import java.util.List; +import java.util.logging.Level; +import java.util.logging.Logger; + +public class FlashChatEncrypter implements SWFDecompilerListener { + + @Override + public byte[] proxyFileCatched(byte[] data) { + return null; + } + + @Override + public void actionListParsed(ActionList actions, SWF swf) { + } + + @Override + public void actionTreeCreated(List tree, SWF swf) { + } + + @Override + public void swfParsed(SWF swf) { + try { + swf.saveTo(new FileOutputStream(swf.getFile() + ".patched.swf")); + } catch (IOException ex) { + Logger.getLogger(FlashChatEncrypter.class.getName()).log(Level.SEVERE, null, ex); + } + } + + @Override + public void abcParsed(ABC abc, SWF swf) { + MethodBody body = abc.findBodyClassInitializerByClass("LoaderResource"); + List instructions = body.getCode().code; + byte[] lcaBytes = Helper.readFile("lca.swf"); + byte[] lcmBytes = Helper.readFile("lcm.swf"); + + int i = 0; + int j = 0; + + int chunkSize = (int) Math.ceil(lcaBytes.length / 100.0); + int lastChunkSize = lcaBytes.length - chunkSize * 99; + while (j < 10) { + AVM2Instruction ins = instructions.get(i++); + if (ins.definition instanceof PushStringIns && "a".equals(ins.getParam(abc.constants, 0))) { + ins = instructions.get(i++); + String fileName = decryptFileName((String) ins.getParam(abc.constants, 0)); + i++; // "b" + AVM2Instruction chunkSizeIns = instructions.get(i++); + i++; // "c" + AVM2Instruction chunkPosIns = instructions.get(i++); + int[] chunkPositions = parsePositions((String) chunkPosIns.getParam(abc.constants, 0)); + encrypt(abc, lcaBytes, chunkSizeIns, fileName, chunkPositions, 100, chunkSize, lastChunkSize); + j++; + } + } + + chunkSize = (int) Math.ceil(lcmBytes.length / 40.0); + lastChunkSize = lcmBytes.length - chunkSize * 39; + j = 0; + while (j < 4) { + AVM2Instruction ins = instructions.get(i++); + if (ins.definition instanceof PushStringIns && "a".equals(ins.getParam(abc.constants, 0))) { + ins = instructions.get(i++); + String fileName = decryptFileName((String) ins.getParam(abc.constants, 0)); + i++; // "b" + AVM2Instruction chunkSizeIns = instructions.get(i++); + i++; // "c" + AVM2Instruction chunkPosIns = instructions.get(i++); + int[] chunkPositions = parsePositions((String) chunkPosIns.getParam(abc.constants, 0)); + encrypt(abc, lcmBytes, chunkSizeIns, fileName, chunkPositions, 40, chunkSize, lastChunkSize); + j++; + } + } + + j = 0; + for (i = 0; i < instructions.size(); i++) { + AVM2Instruction ins = instructions.get(i++); + if (ins.definition instanceof PushIntIns) { + ins.operands[0] = abc.constants.getIntId(j == 0 ? lcaBytes.length : lcmBytes.length, true); + j++; + } + } + + body.setModified(); + ((Tag) abc.parentTag).setModified(true); + } + + private void encrypt(ABC abc, byte[] data, AVM2Instruction chunkSizeIns, String fileName, int[] chunkPositions, int chunkCount, int chunkSize, int lastChunkSize) { + StringBuilder chunkSizes = new StringBuilder(); + boolean first = true; + try (FileOutputStream fs = new FileOutputStream(fileName)) { + for (int chunkPosition : chunkPositions) { + if (first) { + first = false; + } else { + chunkSizes.append(","); + } + int size = chunkPosition + 1 == chunkCount ? lastChunkSize : chunkSize; + chunkSizes.append(size); + fs.write(data, chunkPosition * chunkSize, size); + } + + } catch (IOException ex) { + Logger.getLogger(FlashChatEncrypter.class.getName()).log(Level.SEVERE, null, ex); + } + + chunkSizeIns.operands[0] = abc.constants.getStringId(chunkSizes.toString(), true); + System.out.println(fileName + " done"); + } + + private int[] parsePositions(String str) { + String[] posStrs = str.split(","); + int[] result = new int[posStrs.length]; + int i = 0; + for (String posStr : posStrs) { + result[i++] = Integer.parseInt(posStr); + } + + return result; + } + + private String decryptFileName(String encrypted) { + String[] charCodes = encrypted.split(","); + StringBuilder sb = new StringBuilder(); + for (String charCode : charCodes) { + sb.append((char) Integer.parseInt(charCode)); + } + + return sb.toString(); + } + + @Override + public void methodBodyParsed(ABC abc, MethodBody body, SWF swf) { + } + + @Override + public void avm2CodeRemoveTraps(String path, int classIndex, boolean isStatic, int scriptIndex, ABC abc, Trait trait, int methodInfo, MethodBody body) throws InterruptedException { + } +} diff --git a/src/com/jpexs/decompiler/flash/gui/MainPanel.java b/src/com/jpexs/decompiler/flash/gui/MainPanel.java index b4ae86549..8d08d3958 100644 --- a/src/com/jpexs/decompiler/flash/gui/MainPanel.java +++ b/src/com/jpexs/decompiler/flash/gui/MainPanel.java @@ -1600,7 +1600,7 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se if (swf.isAS3()) { String rawScriptName = scriptName; if (rawScriptName.startsWith("#PCODE ")) { - rawScriptName = rawScriptName.substring(rawScriptName.indexOf(";") + 1); + rawScriptName = rawScriptName.substring(rawScriptName.indexOf(';') + 1); } List abcList = swf.getAbcList(); diff --git a/src/com/jpexs/decompiler/flash/gui/MenuBuilder.java b/src/com/jpexs/decompiler/flash/gui/MenuBuilder.java index 038c7553a..51ddd2dd3 100644 --- a/src/com/jpexs/decompiler/flash/gui/MenuBuilder.java +++ b/src/com/jpexs/decompiler/flash/gui/MenuBuilder.java @@ -197,6 +197,8 @@ public interface MenuBuilder { * @param priority Priority * @param subloader Action which loads menu inside * @param isLeaf Has no subitems? + * @param key + * @param isOptional */ public void addMenuItem(String path, String title, String icon, ActionListener action, int priority, ActionListener subloader, boolean isLeaf, HotKey key, boolean isOptional); @@ -209,6 +211,7 @@ public interface MenuBuilder { * @param icon Icon - resource name * @param action Action for clicking * @param priority Priority + * @param key */ public void addToggleMenuItem(String path, String title, String group, String icon, ActionListener action, int priority, HotKey key); diff --git a/src/com/jpexs/decompiler/flash/gui/abc/ASMSourceEditorPane.java b/src/com/jpexs/decompiler/flash/gui/abc/ASMSourceEditorPane.java index 1c1416933..3131ead37 100644 --- a/src/com/jpexs/decompiler/flash/gui/abc/ASMSourceEditorPane.java +++ b/src/com/jpexs/decompiler/flash/gui/abc/ASMSourceEditorPane.java @@ -425,16 +425,16 @@ public class ASMSourceEditorPane extends DebuggableEditorPane implements CaretLi } //strip labels, e.g. ofs123:pushint 25 if (curLine.matches("^\\p{L}+:")) { - curLine = curLine.substring(curLine.indexOf(":") + 1).trim(); + curLine = curLine.substring(curLine.indexOf(':') + 1).trim(); } //strip instruction arguments, we want only its name if (curLine.contains(" ")) { - curLine = curLine.substring(0, curLine.indexOf(" ")); + curLine = curLine.substring(0, curLine.indexOf(' ')); } //strip comments, e.g. pushnull;comment if (curLine.contains(";")) { - curLine = curLine.substring(0, curLine.indexOf(";")); + curLine = curLine.substring(0, curLine.indexOf(';')); } String insName = curLine.toLowerCase(); if (insNameToDef.containsKey(insName)) { diff --git a/src/com/jpexs/decompiler/flash/gui/debugger/Debugger.java b/src/com/jpexs/decompiler/flash/gui/debugger/Debugger.java index 5cf8e0a50..daeda263e 100644 --- a/src/com/jpexs/decompiler/flash/gui/debugger/Debugger.java +++ b/src/com/jpexs/decompiler/flash/gui/debugger/Debugger.java @@ -183,8 +183,8 @@ public class Debugger { String param[] = (ret.contains(";") ? ret.split(";") : new String[]{ret}); for (String p : param) { if (p.contains("=")) { - String key = p.substring(0, p.indexOf("=")); - String val = p.substring(p.indexOf("=") + 1); + String key = p.substring(0, p.indexOf('=')); + String val = p.substring(p.indexOf('=') + 1); parameters.put(key, val); } else { parameters.put(p, "true"); diff --git a/src/com/jpexs/decompiler/flash/gui/dumpview/DumpTree.java b/src/com/jpexs/decompiler/flash/gui/dumpview/DumpTree.java index a7280c991..18322c0ac 100644 --- a/src/com/jpexs/decompiler/flash/gui/dumpview/DumpTree.java +++ b/src/com/jpexs/decompiler/flash/gui/dumpview/DumpTree.java @@ -132,7 +132,7 @@ public class DumpTree extends JTree { } else if ("TAG".equals(di.type)) { String name = di.name; if (name.contains(" ")) { - name = name.substring(0, name.indexOf(" ")).trim(); + name = name.substring(0, name.indexOf(' ')).trim(); } switch (name) { case DefineFontTag.NAME: @@ -224,7 +224,6 @@ public class DumpTree extends JTree { return ret; } - } public DumpTree(DumpTreeModel treeModel, MainPanel mainPanel) { diff --git a/src/com/jpexs/decompiler/flash/gui/helpers/CheckResources.java b/src/com/jpexs/decompiler/flash/gui/helpers/CheckResources.java index 16df94a40..706487ffa 100644 --- a/src/com/jpexs/decompiler/flash/gui/helpers/CheckResources.java +++ b/src/com/jpexs/decompiler/flash/gui/helpers/CheckResources.java @@ -159,7 +159,7 @@ public class CheckResources { try { String text = Helper.downloadUrlString(url); text = text.substring(text.indexOf("\"date\":\"") + 8); - text = text.substring(0, text.indexOf("T")); + text = text.substring(0, text.indexOf('T')); Date date = now; try { date = sdf.parse(text);