Skip to content

Commit

Permalink
removed some unnecessary parameters + small fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
honfika committed Oct 21, 2015
1 parent a093b25 commit 099bffd
Show file tree
Hide file tree
Showing 70 changed files with 270 additions and 158 deletions.
13 changes: 13 additions & 0 deletions examples/DeobfuscatorSample.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@
import com.jpexs.decompiler.flash.SWF;
import com.jpexs.decompiler.flash.abc.ABC;
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.base.ASMSource;
import com.jpexs.decompiler.graph.GraphTargetItem;
import java.util.List;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;
Expand All @@ -22,6 +25,11 @@ public void actionListParsed(ActionList actions, SWF swf) {
System.out.println("actionListParsed");
}

@Override
public void actionTreeCreated(List<GraphTargetItem> tree, SWF swf) {
System.out.println("actionTreeCreated");
}

@Override
public void swfParsed(SWF swf) {
System.out.println("swfParsed");
Expand All @@ -44,4 +52,9 @@ public void abcParsed(ABC abc, SWF swf) {
public void methodBodyParsed(MethodBody body, SWF swf) {
System.out.println("methodBodyParsed");
}

@Override
public void avm2CodeRemoveTraps(String path, int classIndex, boolean isStatic, int scriptIndex, ABC abc, Trait trait, int methodInfo, MethodBody body) throws InterruptedException {
System.out.println("avm2CodeRemoveTraps");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ public class IdentifiersDeobfuscation {

private static final Pattern IDENTIFIER_PATTERN = Pattern.compile("^[" + VALID_FIRST_CHARACTERS + "][" + VALID_NEXT_CHARACTERS + "]*$");

private static final Pattern VALID_NAME_PATTERN_DOT = Pattern.compile("^[a-zA-Z_\\$][a-zA-Z0-9_.\\$]*$");

private static final Pattern IDENTIFIER_PATTERN_DOT = Pattern.compile("^[" + VALID_FIRST_CHARACTERS + "][" + VALID_NEXT_CHARACTERS + ".]*$");

public static final String FOO_CHARACTERS = "bcdfghjklmnpqrstvwz";

public static final String FOO_JOIN_CHARACTERS = "aeiouy";
Expand Down Expand Up @@ -228,6 +232,28 @@ public String deobfuscateNameWithPackage(boolean as3, String n, HashMap<DottedCh
return null;
}

public static boolean isValidNameWithDot(boolean as3, String s, String... exceptions) {
for (String e : exceptions) {
if (e.equals(s)) {
return true;
}
}

if (isReservedWord(s, as3)) {
return false;
}

// simple fast test
if (VALID_NAME_PATTERN_DOT.matcher(s).matches()) {
return true;
}
// unicode test
if (IDENTIFIER_PATTERN_DOT.matcher(s).matches()) {
return true;
}
return false;
}

public static boolean isValidName(boolean as3, String s, String... exceptions) {
for (String e : exceptions) {
if (e.equals(s)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@
import com.jpexs.decompiler.flash.abc.avm2.AVM2Code;
import com.jpexs.decompiler.flash.abc.avm2.AVM2ConstantPool;
import com.jpexs.decompiler.flash.abc.types.ABCException;
import com.jpexs.decompiler.flash.abc.types.InstanceInfo;
import com.jpexs.decompiler.flash.abc.types.MethodBody;
import com.jpexs.decompiler.flash.abc.types.MethodInfo;
import com.jpexs.decompiler.flash.abc.types.ScriptInfo;
import com.jpexs.decompiler.graph.DottedChain;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.ScopeStack;
Expand All @@ -44,10 +46,6 @@ public class AVM2LocalData extends BaseLocalData {

public ScopeStack scopeStack;

public AVM2ConstantPool constants;

public List<MethodInfo> methodInfo;

public MethodBody methodBody;

public ABC abc;
Expand Down Expand Up @@ -83,8 +81,6 @@ public AVM2LocalData(AVM2LocalData localData) {
classIndex = localData.classIndex;
localRegs = localData.localRegs;
scopeStack = localData.scopeStack;
constants = localData.constants;
methodInfo = localData.methodInfo;
methodBody = localData.methodBody;
abc = localData.abc;
localRegNames = localData.localRegNames;
Expand All @@ -99,4 +95,20 @@ public AVM2LocalData(AVM2LocalData localData) {
refs = localData.refs;
code = localData.code;
}

public AVM2ConstantPool getConstants() {
return abc.constants;
}

public List<MethodInfo> getMethodInfo() {
return abc.method_info;
}

public List<InstanceInfo> getInstanceInfo() {
return abc.instance_info;
}

public List<ScriptInfo> getScriptInfo() {
return abc.script_info;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ public class ScriptPack extends AS3ClassTreeItem {
private final ClassPath path;

public boolean isSimple = false;

public boolean scriptInitializerIsEmpty = false;

@Override
Expand Down Expand Up @@ -162,7 +163,7 @@ public void convert(final NulWriter writer, final List<Trait> traits, final Scri
}

writer.mark();
abc.bodies.get(bodyIndex).convert(path +/*packageName +*/ "/.scriptinitializer", exportMode, true, script_init, scriptIndex, -1, abc, null, abc.constants, abc.method_info, new ScopeStack(), GraphTextWriter.TRAIT_SCRIPT_INITIALIZER, writer, new ArrayList<DottedChain>(), ts, true);
abc.bodies.get(bodyIndex).convert(path +/*packageName +*/ "/.scriptinitializer", exportMode, true, script_init, scriptIndex, -1, abc, null, new ScopeStack(), GraphTextWriter.TRAIT_SCRIPT_INITIALIZER, writer, new ArrayList<DottedChain>(), ts, true);
scriptInitializerIsEmpty = !writer.getMark();

}
Expand Down Expand Up @@ -190,7 +191,7 @@ private void appendTo(GraphTextWriter writer, List<Trait> traits, ScriptExportMo
writer.startMethod(script_init);
if (!scriptInitializerIsEmpty) {
writer.startBlock();
abc.bodies.get(bodyIndex).toString(path +/*packageName +*/ "/.scriptinitializer", exportMode, abc, null, abc.constants, abc.method_info, writer, new ArrayList<DottedChain>());
abc.bodies.get(bodyIndex).toString(path +/*packageName +*/ "/.scriptinitializer", exportMode, abc, null, writer, new ArrayList<>());
writer.endBlock();
} else {
writer.append(" ");
Expand Down
Loading

0 comments on commit 099bffd

Please sign in to comment.