mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-08-02 15:51:16 +00:00
netbeans inpector fixes
This commit is contained in:
@@ -36,7 +36,7 @@ import java.util.Map;
|
||||
*/
|
||||
public class ABCMethodIndexing {
|
||||
|
||||
private ABC abc;
|
||||
private final ABC abc;
|
||||
|
||||
private Map<MethodInfo, Integer> bodyIdxFromMethod = new HashMap<>();
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
|
||||
/**
|
||||
*
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
/**
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
/**
|
||||
*
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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("\\/", "/");
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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('[');
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
/**
|
||||
*
|
||||
|
||||
153
libsrc/plugins/src/FlashChatEncrypter.java
Normal file
153
libsrc/plugins/src/FlashChatEncrypter.java
Normal file
@@ -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<GraphTargetItem> 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<AVM2Instruction> 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 {
|
||||
}
|
||||
}
|
||||
@@ -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<ABCContainerTag> abcList = swf.getAbcList();
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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)) {
|
||||
|
||||
@@ -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");
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user