format source code

This commit is contained in:
honfika@gmail.com
2015-03-31 21:32:49 +02:00
parent 9813f62cdf
commit cc5f2ff4c2
18 changed files with 2245 additions and 2018 deletions

View File

@@ -49,7 +49,7 @@ public class IdentifiersDeobfuscation {
public static final String VALID_NEXT_CHARACTERS = VALID_FIRST_CHARACTERS + "\\p{Nl}\\p{Mn}\\p{Mc}\\p{Nd}\\p{Pc}";
private static final Pattern VALID_NAME_PATTERN = Pattern.compile("^[a-zA-Z_\\$][a-zA-Z0-9_\\$]*$");
private static final Pattern IDENTIFIER_PATTERN = Pattern.compile("^[" + VALID_FIRST_CHARACTERS + "][" + VALID_NEXT_CHARACTERS + "]*$");
public static final String FOO_CHARACTERS = "bcdfghjklmnpqrstvwz";

View File

@@ -50,7 +50,7 @@ public class ABCInputStream implements AutoCloseable {
public static final boolean DEBUG_READ = false;
public DumpInfo dumpInfo;
private byte[] stringDataBuffer = new byte[256];
public void startBuffer() {
@@ -477,17 +477,17 @@ public class ABCInputStream implements AutoCloseable {
public String readString(String name) throws IOException {
newDumpLevel(name, "String");
int length = readU30Internal();
// avoid creating new byte array every time
if (stringDataBuffer.length < length) {
int newLength = stringDataBuffer.length * 2;
while (newLength < length) {
newLength *= 2;
}
stringDataBuffer = new byte[newLength];
}
safeRead(length, stringDataBuffer);
String r = new String(stringDataBuffer, 0, length, Utf8Helper.charset);
endDumpLevel(r);

View File

@@ -33,11 +33,11 @@ public class ClassInfo {
public ClassInfo() {
static_traits = new Traits();
}
public ClassInfo(Traits traits) {
static_traits = traits;
}
@Override
public String toString() {
return "method_index=" + cinit_index + "\r\n" + static_traits.toString();

View File

@@ -56,11 +56,11 @@ public class InstanceInfo {
public InstanceInfo() {
instance_traits = new Traits();
}
public InstanceInfo(Traits traits) {
instance_traits = traits;
}
@Override
public String toString() {
return "name_index=" + name_index + " super_index=" + super_index + " flags=" + flags + " protectedNS=" + protectedNS + " interfaces=" + Helper.intArrToString(interfaces) + " method_index=" + iinit_index + "\r\n" + instance_traits.toString();

View File

@@ -85,13 +85,13 @@ public final class MethodBody implements Cloneable {
this.codeBytes = new byte[0];
this.exceptions = new ABCException[0];
}
public MethodBody(Traits traits, byte[] codeBytes, ABCException[] exceptions) {
this.traits = traits;
this.codeBytes = codeBytes;
this.exceptions = exceptions;
}
public synchronized void setCodeBytes(byte codeBytes[]) {
this.codeBytes = codeBytes;
this.code = null;

View File

@@ -70,7 +70,7 @@ public class ScriptInfo {
traitIndices.addAll(otherTraits);
otherTraits.clear();
}
if (packagePrefix == null || packageName.startsWith(packagePrefix)) {
ClassPath cp = new ClassPath(packageName, objectName);
ret.add(new ScriptPack(cp, abc, scriptIndex, traitIndices));

View File

@@ -32,7 +32,7 @@ import java.util.List;
public abstract class Trait implements Serializable {
private static final int[] EMPTY_METADATA_ARRAY = new int[0];
public int name_index;
public int kindType;

View File

@@ -39,11 +39,11 @@ public class Traits implements Serializable {
public Traits() {
traits = new ArrayList<>();
}
public Traits(int initialCapacity) {
traits = new ArrayList<>(initialCapacity);
}
public void delete(ABC abc, boolean d) {
for (Trait t : traits) {
t.delete(abc, d);

View File

@@ -149,7 +149,7 @@ public class FontExporter {
f.getEngine().setCopyrightYear(cop == null ? "" : cop);
f.setAuthor(ApplicationInfo.shortApplicationVerName);
f.setVersion("1.0");
SWF swf = t.getSwf();
if (swf != null && swf.swfList != null && swf.swfList.sourceInfo != null) {
String fileName = swf.swfList.sourceInfo.getFile();
@@ -278,7 +278,7 @@ public class FontExporter {
WritableFontData woffData = w.convert(font);
woffData.copyTo(fos);
}
ttfFile.delete();
}
}

View File

@@ -308,13 +308,13 @@ public class FrameExporter {
if (evl != null) {
evl.handleExportingEvent("frame", pos + 1, fframes.size(), tim.parentTag == null ? "" : tim.parentTag.getName());
}
BufferedImage result = SWF.frameToImageGet(ftim, fframes.get(pos++), 0, null, 0, ftim.displayRect, new Matrix(), new ColorTransform(), fbackgroundColor, false, settings.zoom).getBufferedImage();
if (evl != null) {
evl.handleExportedEvent("frame", pos + 1, fframes.size(), tim.parentTag == null ? "" : tim.parentTag.getName());
}
return result;
}
};

View File

@@ -99,11 +99,11 @@ public class SwfXmlExporter {
StringBuilder sb = new StringBuilder(data.length * 2);
for (int i = 0; i < data.length; i++) {
sb.append(String.format("%02x", data[i]));
}
}
return sb.toString();
}
private static void generateXml(Document doc, Node node, String name, Object obj, boolean isListItem, int level) {
Class cls = obj != null ? obj.getClass() : null;

View File

@@ -114,7 +114,7 @@ public class DefineTextTag extends TextTag {
ret += "\r\n";
}*/
}
if (fnt == null) {
ret.add(AppResources.translate("fontNotFound").replace("%fontId%", Integer.toString(rec.fontId)));
} else {

View File

@@ -57,7 +57,7 @@ public class AS2Package implements TreeItem {
result.addAll(scripts.values());
return result;
}
public TreeItem getChild(int index) {
if (index < subPackages.size()) {
for (AS2Package subPackage : subPackages.values()) {

View File

@@ -1299,16 +1299,16 @@ public class Graph {
currentLoop.phase = 0;
}
switch (part.stopPartType) {
case AND_OR:
part.setAndOrStack(stack); //Save stack for later use
break;
case AND_OR:
part.setAndOrStack(stack); //Save stack for later use
break;
case COMMONPART:
part.setCommonPartStack(stack); //Save stack for later use
break;
case COMMONPART:
part.setCommonPartStack(stack); //Save stack for later use
break;
case NONE:
break;
case NONE:
break;
}
return ret;
}
@@ -1603,7 +1603,7 @@ public class Graph {
List<GraphPart> stopPart2 = new ArrayList<>(stopPart);
GraphPart.CommonPartStack commonPartStack = null;
if ((!isEmpty) && (next != null)) {
commonPartStack=next.new CommonPartStack();
commonPartStack = next.new CommonPartStack();
if (next.commonPartStacks == null) {
next.commonPartStacks = new ArrayList<>();
}
@@ -1613,8 +1613,8 @@ public class Graph {
if (!isEmpty) {
if (next != null) {
next.commonPartStacks.add(commonPartStack);
commonPartStack.isTrueStack=true; //stopPart must know it needs to store trueStack
}
commonPartStack.isTrueStack = true; //stopPart must know it needs to store trueStack
}
onTrue = printGraph(visited, prepareBranchLocalData(localData), trueStack, allParts, part, nps.get(1), stopPart2, loops, null, staticOperation, path, recursionLevel + 1);
}
List<GraphTargetItem> onFalse = new ArrayList<>();
@@ -1626,16 +1626,16 @@ public class Graph {
onFalse = printGraph(visited, prepareBranchLocalData(localData), falseStack, allParts, part, nps.get(0), stopPart2, loops, null, staticOperation, path, recursionLevel + 1);
}
/* if there is a stopPart (next), then Graph will be further analyzed starting from the stopPart:
/* if there is a stopPart (next), then Graph will be further analyzed starting from the stopPart:
* trueStack and falseStack must be set equal to corresponding stack that was built upon reaching stopPart. */
if ((!isEmpty) && (next != null)) {
if ((commonPartStack.trueStack != null) && (commonPartStack.falseStack != null)) {
trueStack = commonPartStack.trueStack;
falseStack = commonPartStack.falseStack;
if ((commonPartStack.trueStack != null) && (commonPartStack.falseStack != null)) {
trueStack = commonPartStack.trueStack;
falseStack = commonPartStack.falseStack;
}
next.commonPartStacks.remove(next.commonPartStacks.size()-1);
next.commonPartStacks.remove(next.commonPartStacks.size() - 1);
if (next.commonPartStacks.isEmpty()) {
next.stopPartType = GraphPart.StopPartType.NONE; /* reset StopPartType */
next.stopPartType = GraphPart.StopPartType.NONE; // reset StopPartType
}
}

View File

@@ -58,6 +58,7 @@ public class GraphPart implements Serializable {
public List<GraphPart> throwParts = new ArrayList<>();
public enum StopPartType {
NONE, AND_OR, COMMONPART
}
@@ -66,24 +67,27 @@ public class GraphPart implements Serializable {
public TranslateStack andOrStack; // Stores stack when AND_OR stopPart has been reached
public class CommonPartStack { // Stores stack when COMMONPART stopPart has been reached
boolean isTrueStack;
TranslateStack trueStack;
TranslateStack falseStack;
boolean isTrueStack;
TranslateStack trueStack;
TranslateStack falseStack;
}
public ArrayList<CommonPartStack> commonPartStacks;
public void setAndOrStack(TranslateStack stack) {
andOrStack = stack;
andOrStack = stack;
}
public void setCommonPartStack(TranslateStack stack) {
CommonPartStack currentStack = commonPartStacks.get(commonPartStacks.size()-1);
if (currentStack.isTrueStack) {
currentStack.trueStack = stack;
} else {
currentStack.falseStack = stack;
}
CommonPartStack currentStack = commonPartStacks.get(commonPartStacks.size() - 1);
if (currentStack.isTrueStack) {
currentStack.trueStack = stack;
} else {
currentStack.falseStack = stack;
}
}
public int setTime(int time, List<GraphPart> ordered, List<GraphPart> visited) {