#749 Internal viewer Sprite fill color is wrong sometimes: fixed

This commit is contained in:
2014-12-14 15:30:59 +01:00
parent caaee42318
commit 60f170dcda
32 changed files with 225 additions and 192 deletions
@@ -254,7 +254,7 @@ public class ABC {
Set<Integer> stringUsages = getStringUsages();
Set<Integer> namespaceUsages = getNsStringUsages();
int strIndex = constants.getMultiname(multinameIndex).name_index;
if (stringUsages.contains(strIndex) || namespaceUsages.contains(strIndex)) { //name is used elsewhere as string literal
if (stringUsages.contains(strIndex) || namespaceUsages.contains(strIndex)) { // name is used elsewhere as string literal
strIndex = constants.getStringId(newname, true);
constants.getMultiname(multinameIndex).name_index = strIndex;
} else {
@@ -291,13 +291,13 @@ public class ABC {
}
for (int i = 1; i < constants.getNamespaceCount(); i++) {
informListeners("deobfuscate", "namespace " + i + "/" + constants.getNamespaceCount());
if (constants.getNamespace(i).kind != Namespace.KIND_PACKAGE) { //only packages
if (constants.getNamespace(i).kind != Namespace.KIND_PACKAGE) { // only packages
continue;
}
constants.getNamespace(i).name_index = deobfuscation.deobfuscatePackageName(stringUsageTypes, stringUsages, namesMap, constants.getNamespace(i).name_index, renameType);
}
//process reflection using getDefinitionByName too
// process reflection using getDefinitionByName too
for (MethodBody body : bodies) {
for (int ip = 0; ip < body.getCode().code.size(); ip++) {
if (body.getCode().code.get(ip).definition instanceof CallPropertyIns) {
@@ -350,7 +350,7 @@ public class ABC {
deobfuscation = new AVM2Deobfuscation(constants);
ais.newDumpLevel("constant_pool", "cpool_info");
//constant integers
// constant integers
int constant_int_pool_count = ais.readU30("int_count");
constants.constant_int = new ArrayList<>(constant_int_pool_count);
if (constant_int_pool_count > 0) {
@@ -358,13 +358,13 @@ public class ABC {
}
if (constant_int_pool_count > 1) {
ais.newDumpLevel("integers", "integer[]");
for (int i = 1; i < constant_int_pool_count; i++) { //index 0 not used. Values 1..n-1
for (int i = 1; i < constant_int_pool_count; i++) { // index 0 not used. Values 1..n-1
constants.addInt(ais.readS32("int"));
}
ais.endDumpLevel();
}
//constant unsigned integers
// constant unsigned integers
int constant_uint_pool_count = ais.readU30("uint_count");
constants.constant_uint = new ArrayList<>(constant_uint_pool_count);
if (constant_uint_pool_count > 0) {
@@ -372,13 +372,13 @@ public class ABC {
}
if (constant_uint_pool_count > 1) {
ais.newDumpLevel("uintegers", "uinteger[]");
for (int i = 1; i < constant_uint_pool_count; i++) { //index 0 not used. Values 1..n-1
for (int i = 1; i < constant_uint_pool_count; i++) { // index 0 not used. Values 1..n-1
constants.addUInt(ais.readU32("uint"));
}
ais.endDumpLevel();
}
//constant double
// constant double
int constant_double_pool_count = ais.readU30("double_count");
constants.constant_double = new ArrayList<>(constant_double_pool_count);
if (constant_double_pool_count > 0) {
@@ -386,13 +386,13 @@ public class ABC {
}
if (constant_double_pool_count > 1) {
ais.newDumpLevel("doubles", "double[]");
for (int i = 1; i < constant_double_pool_count; i++) { //index 0 not used. Values 1..n-1
for (int i = 1; i < constant_double_pool_count; i++) { // index 0 not used. Values 1..n-1
constants.addDouble(ais.readDouble("double"));
}
ais.endDumpLevel();
}
//constant decimal
// constant decimal
if (minor_version >= MINORwithDECIMAL) {
int constant_decimal_pool_count = ais.readU30("decimal_count");
constants.constant_decimal = new ArrayList<>(constant_decimal_pool_count);
@@ -401,7 +401,7 @@ public class ABC {
}
if (constant_decimal_pool_count > 1) {
ais.newDumpLevel("decimals", "decimal[]");
for (int i = 1; i < constant_decimal_pool_count; i++) { //index 0 not used. Values 1..n-1
for (int i = 1; i < constant_decimal_pool_count; i++) { // index 0 not used. Values 1..n-1
constants.addDecimal(ais.readDecimal("decimal"));
}
ais.endDumpLevel();
@@ -410,7 +410,7 @@ public class ABC {
constants.constant_decimal = new ArrayList<>(0);
}
//constant string
// constant string
int constant_string_pool_count = ais.readU30("string_count");
constants.constant_string = new ArrayList<>(constant_string_pool_count);
stringOffsets = new long[constant_string_pool_count];
@@ -419,7 +419,7 @@ public class ABC {
}
if (constant_string_pool_count > 1) {
ais.newDumpLevel("strings", "string[]");
for (int i = 1; i < constant_string_pool_count; i++) { //index 0 not used. Values 1..n-1
for (int i = 1; i < constant_string_pool_count; i++) { // index 0 not used. Values 1..n-1
long pos = ais.getPosition();
constants.addString(ais.readString("string"));
stringOffsets[i] = pos;
@@ -427,7 +427,7 @@ public class ABC {
ais.endDumpLevel();
}
//constant namespace
// constant namespace
int constant_namespace_pool_count = ais.readU30("namespace_count");
constants.constant_namespace = new ArrayList<>(constant_namespace_pool_count);
if (constant_namespace_pool_count > 0) {
@@ -435,13 +435,13 @@ public class ABC {
}
if (constant_namespace_pool_count > 1) {
ais.newDumpLevel("namespaces", "namespace[]");
for (int i = 1; i < constant_namespace_pool_count; i++) { //index 0 not used. Values 1..n-1
for (int i = 1; i < constant_namespace_pool_count; i++) { // index 0 not used. Values 1..n-1
constants.addNamespace(ais.readNamespace("namespace"));
}
ais.endDumpLevel();
}
//constant namespace set
// constant namespace set
int constant_namespace_set_pool_count = ais.readU30("ns_set_count");
constants.constant_namespace_set = new ArrayList<>(constant_namespace_set_pool_count);
if (constant_namespace_set_pool_count > 0) {
@@ -449,7 +449,7 @@ public class ABC {
}
if (constant_namespace_set_pool_count > 1) {
ais.newDumpLevel("ns_sets", "ns_set[]");
for (int i = 1; i < constant_namespace_set_pool_count; i++) { //index 0 not used. Values 1..n-1
for (int i = 1; i < constant_namespace_set_pool_count; i++) { // index 0 not used. Values 1..n-1
ais.newDumpLevel("ns_set_infos", "ns_set_info[]");
constants.addNamespaceSet(new NamespaceSet());
int namespace_count = ais.readU30("count");
@@ -462,7 +462,7 @@ public class ABC {
ais.endDumpLevel();
}
//constant multiname
// constant multiname
int constant_multiname_pool_count = ais.readU30("multiname_count");
constants.constant_multiname = new ArrayList<>(constant_multiname_pool_count);
if (constant_multiname_pool_count > 0) {
@@ -470,24 +470,24 @@ public class ABC {
}
if (constant_multiname_pool_count > 1) {
ais.newDumpLevel("multiname", "multinames[]");
for (int i = 1; i < constant_multiname_pool_count; i++) { //index 0 not used. Values 1..n-1
for (int i = 1; i < constant_multiname_pool_count; i++) { // index 0 not used. Values 1..n-1
constants.addMultiname(ais.readMultiname("multiname"));
}
ais.endDumpLevel();
}
ais.endDumpLevel(); //cpool_info
ais.endDumpLevel(); // cpool_info
//method info
// method info
int methods_count = ais.readU30("methods_count");
method_info = new ArrayList<>(methods_count); //MethodInfo[methods_count];
bodyIdxFromMethodIdx = new ArrayList<>(methods_count); //[methods_count];
method_info = new ArrayList<>(methods_count); // MethodInfo[methods_count];
bodyIdxFromMethodIdx = new ArrayList<>(methods_count);
for (int i = 0; i < methods_count; i++) {
method_info.add(ais.readMethodInfo("method"));
bodyIdxFromMethodIdx.add(-1);
}
//metadata info
// metadata info
int metadata_count = ais.readU30("metadata_count");
metadata_info = new ArrayList<>(metadata_count);
for (int i = 0; i < metadata_count; i++) {
@@ -505,11 +505,11 @@ public class ABC {
}
int class_count = ais.readU30("class_count");
instance_info = new ArrayList<>(class_count); //InstanceInfo[class_count];
instance_info = new ArrayList<>(class_count);
for (int i = 0; i < class_count; i++) {
instance_info.add(ais.readInstanceInfo("instance"));
}
class_info = new ArrayList<>(class_count); //ClassInfo[class_count];
class_info = new ArrayList<>(class_count);
for (int i = 0; i < class_count; i++) {
ais.newDumpLevel("class", "class_info");
ClassInfo ci = new ClassInfo();
@@ -519,7 +519,7 @@ public class ABC {
ais.endDumpLevel();
}
int script_count = ais.readU30("script_count");
script_info = new ArrayList<>(script_count); //ScriptInfo[script_count];
script_info = new ArrayList<>(script_count);
for (int i = 0; i < script_count; i++) {
ais.newDumpLevel("script", "script_info");
ScriptInfo si = new ScriptInfo();
@@ -530,7 +530,7 @@ public class ABC {
}
int bodies_count = ais.readU30("bodies_count");
bodies = new ArrayList<>(bodies_count); //MethodBody[bodies_count];
bodies = new ArrayList<>(bodies_count);
for (int i = 0; i < bodies_count; i++) {
ais.newDumpLevel("method_body", "method_body_info");
MethodBody mb = new MethodBody();
@@ -737,7 +737,7 @@ public class ABC {
} else if (traitId < class_info.get(classIndex).static_traits.traits.size() + instance_info.get(classIndex).instance_traits.traits.size()) {
return false;
} else {
return true; //Can be class or instance initializer
return true; // Can be class or instance initializer
}
}
@@ -754,7 +754,7 @@ public class ABC {
traitId -= staticTraits.size();
return instanceTraits.get(traitId);
} else {
return null; //Can be class or instance initializer
return null; // Can be class or instance initializer
}
}
}
@@ -801,7 +801,7 @@ public class ABC {
if (t instanceof TraitSlotConst) {
TraitSlotConst s = ((TraitSlotConst) t);
if (s.isNamespace()) {
String key = constants.getNamespace(s.value_index).getName(constants, true); //assume not null
String key = constants.getNamespace(s.value_index).getName(constants, true); // assume not null
String val = constants.getMultiname(s.name_index).getNameWithNamespace(constants, true);
namespaceMap.put(key, val);
}
@@ -1219,10 +1219,10 @@ public class ABC {
}
}
ActionScriptParser.compile(as, this, new ArrayList<ABC>(), isDocumentClass, scriptName, newClassIndex);
//Move newly added script to its position
// Move newly added script to its position
script_info.set(oldIndex, script_info.get(newIndex));
script_info.remove(newIndex);
pack(); //removes old classes/methods
pack(); // removes old classes/methods
((Tag) parentTag).setModified(true);
}
@@ -309,10 +309,10 @@ public class ABCInputStream implements AutoCloseable {
} else if ((kind == Multiname.MULTINAMEL) || (kind == Multiname.MULTINAMELA)) {
namespace_set_index = readU30("namespace_set_index");
} else if (kind == Multiname.TYPENAME) {
qname_index = readU30("qname_index"); //Multiname index!!!
qname_index = readU30("qname_index"); // Multiname index!!!
int paramsLength = readU30("paramsLength");
for (int i = 0; i < paramsLength; i++) {
params.add(readU30("param")); //multiname indices!
params.add(readU30("param")); // multiname indices!
}
} else {
throw new IOException("Unknown kind of Multiname:0x" + Integer.toHexString(kind));
@@ -333,9 +333,9 @@ public class ABCInputStream implements AutoCloseable {
int name_index = readU30("name_index");
int flags = read("flags");
//// 1=need_arguments, 2=need_activation, 4=need_rest 8=has_optional (16=ignore_rest, 32=explicit,) 64=setsdxns, 128=has_paramnames
// 1=need_arguments, 2=need_activation, 4=need_rest 8=has_optional (16=ignore_rest, 32=explicit,) 64=setsdxns, 128=has_paramnames
ValueKind[] optional = new ValueKind[0];
if ((flags & 8) == 8) { //if has_optional
if ((flags & 8) == 8) { // if has_optional
int optional_count = readU30("optional_count");
optional = new ValueKind[optional_count];
for (int i = 0; i < optional_count; i++) {
@@ -344,7 +344,7 @@ public class ABCInputStream implements AutoCloseable {
}
int[] param_names = new int[param_count];
if ((flags & 128) == 128) { //if has_paramnames
if ((flags & 128) == 128) { // if has_paramnames
for (int i = 0; i < param_count; i++) {
param_names[i] = readU30("param_name");
}
@@ -365,8 +365,8 @@ public class ABCInputStream implements AutoCloseable {
Trait trait;
switch (kindType) {
case 0: //slot
case 6: //const
case 0: // slot
case 6: // const
TraitSlotConst t1 = new TraitSlotConst();
t1.slot_id = readU30("slot_id");
t1.type_index = readU30("type_index");
@@ -376,21 +376,21 @@ public class ABCInputStream implements AutoCloseable {
}
trait = t1;
break;
case 1: //method
case 2: //getter
case 3: //setter
case 1: // method
case 2: // getter
case 3: // setter
TraitMethodGetterSetter t2 = new TraitMethodGetterSetter();
t2.disp_id = readU30("disp_id");
t2.method_info = readU30("method_info");
trait = t2;
break;
case 4: //class
case 4: // class
TraitClass t3 = new TraitClass();
t3.slot_id = readU30("slot_id");
t3.class_info = readU30("class_info");
trait = t3;
break;
case 5: //function
case 5: // function
TraitFunction t4 = new TraitFunction();
t4.slot_id = readU30("slot_id");
t4.method_info = readU30("method_info");
@@ -12,7 +12,8 @@
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.␍ */
* License along with this library.
*/
package com.jpexs.decompiler.flash.abc;
import com.jpexs.decompiler.flash.abc.types.Decimal;
@@ -183,10 +184,10 @@ public class ABCOutputStream extends OutputStream {
writeU30(m.name_index);
writeU30(m.namespace_set_index);
}
if ((m.kind == 0xf) || (m.kind == 0x10)) { //CONSTANT_RTQName and CONSTANT_RTQNameA
if ((m.kind == 0xf) || (m.kind == 0x10)) { // CONSTANT_RTQName and CONSTANT_RTQNameA
writeU30(m.name_index);
}
if ((m.kind == 0x1B) || (m.kind == 0x1C)) { //CONSTANT_MultinameL and CONSTANT_MultinameLA
if ((m.kind == 0x1B) || (m.kind == 0x1C)) { // CONSTANT_MultinameL and CONSTANT_MultinameLA
writeU30(m.namespace_set_index);
}
if (m.kind == 0x1D) {
@@ -196,7 +197,7 @@ public class ABCOutputStream extends OutputStream {
writeU30(m.params.get(i));
}
}
//kind==0x11,0x12 nothing CONSTANT_RTQNameL and CONSTANT_RTQNameLA.
// kind==0x11,0x12 nothing CONSTANT_RTQNameL and CONSTANT_RTQNameLA.
}
public void writeMethodInfo(MethodInfo mi) throws IOException {
@@ -215,7 +216,7 @@ public class ABCOutputStream extends OutputStream {
}
}
if ((mi.flags & 128) == 128) { //if has_paramnames
if ((mi.flags & 128) == 128) { // if has_paramnames
for (int i = 0; i < mi.paramNames.length; i++) {
writeU30(mi.paramNames[i]);
}
@@ -76,7 +76,7 @@ public class ScriptPack extends AS3ClassTreeItem {
Multiname name = abc.script_info.get(scriptIndex).traits.traits.get(t).getName(abc);
Namespace ns = name.getNamespace(abc.constants);
if ((ns.kind == Namespace.KIND_PACKAGE) || (ns.kind == Namespace.KIND_PACKAGE_INTERNAL)) {
packageName = ns.getName(abc.constants, false); //assume not null
packageName = ns.getName(abc.constants, false); // assume not null
}
}
return packageName;
@@ -287,7 +287,7 @@ public class AVM2Code implements Cloneable {
new InstructionDefinition(0x9b, "add_d", new int[]{}) {
@Override
public int getStackDelta(AVM2Instruction ins, ABC abc) {
return -2 + 1; //?
return -2 + 1; // ?
}
},
new AddIIns(),
@@ -314,16 +314,16 @@ public class AVM2Code implements Cloneable {
new CheckFilterIns(),
new CoerceIns(),
new CoerceAIns(),
new InstructionDefinition(0x81, "coerce_b", new int[]{}), //stack:-1+1
new InstructionDefinition(0x84, "coerce_d", new int[]{}), //stack:-1+1
new InstructionDefinition(0x83, "coerce_i", new int[]{}), //stack:-1+1
new InstructionDefinition(0x89, "coerce_o", new int[]{}), //stack:-1+1
new InstructionDefinition(0x81, "coerce_b", new int[]{}), // stack:-1+1
new InstructionDefinition(0x84, "coerce_d", new int[]{}), // stack:-1+1
new InstructionDefinition(0x83, "coerce_i", new int[]{}), // stack:-1+1
new InstructionDefinition(0x89, "coerce_o", new int[]{}), // stack:-1+1
new CoerceSIns(),
new InstructionDefinition(0x88, "coerce_u", new int[]{}), //stack:-1+1
new InstructionDefinition(0x88, "coerce_u", new int[]{}), // stack:-1+1
new InstructionDefinition(0x9a, "concat", new int[]{}) {
@Override
public int getStackDelta(AVM2Instruction ins, ABC abc) {
return -2 + 1; //?
return -2 + 1; // ?
}
},
new ConstructIns(),
@@ -335,7 +335,7 @@ public class AVM2Code implements Cloneable {
new ConvertOIns(),
new ConvertUIns(),
new ConvertSIns(),
new InstructionDefinition(0x79, "convert_m", new int[]{}), //-1 +1
new InstructionDefinition(0x79, "convert_m", new int[]{}), // -1 +1
new InstructionDefinition(0x7a, "convert_m_p", new int[]{AVM2Code.DAT_DECIMAL_PARAMS}) {
@Override
public int getStackDelta(AVM2Instruction ins, ABC abc) {
@@ -366,7 +366,7 @@ public class AVM2Code implements Cloneable {
new InstructionDefinition(0xb8, "divide_p", new int[]{AVM2Code.DAT_DECIMAL_PARAMS}) {
@Override
public int getStackDelta(AVM2Instruction ins, ABC abc) {
return -2 + 1; //?
return -2 + 1; // ?
}
},
new DupIns(),
@@ -376,7 +376,7 @@ public class AVM2Code implements Cloneable {
new EscXAttrIns(),
new EscXElemIns(),
new FindDefIns(),
/* //Duplicate OPCODE with deldescendants. Prefering deldescendants (found in FLEX compiler)
/* // Duplicate OPCODE with deldescendants. Prefering deldescendants (found in FLEX compiler)
new InstructionDefinition(0x5b,"findpropglobalstrict",new int[]{AVM2Code.DAT_MULTINAME_INDEX}){
@Override
@@ -469,7 +469,7 @@ public class AVM2Code implements Cloneable {
new InstructionDefinition(0xb9, "modulo_p", new int[]{AVM2Code.DAT_DECIMAL_PARAMS}) {
@Override
public int getStackDelta(AVM2Instruction ins, ABC abc) {
return -2 + 1; //?
return -2 + 1; // ?
}
},
new MultiplyIns(),
@@ -477,7 +477,7 @@ public class AVM2Code implements Cloneable {
new InstructionDefinition(0xb7, "multiply_p", new int[]{AVM2Code.DAT_DECIMAL_PARAMS}) {
@Override
public int getStackDelta(AVM2Instruction ins, ABC abc) {
return -2 + 1; //?
return -2 + 1; // ?
}
},
new NegateIns(),
@@ -509,19 +509,19 @@ public class AVM2Code implements Cloneable {
new InstructionDefinition(0x22, "pushconstant", new int[]{AVM2Code.DAT_STRING_INDEX}) {
@Override
public int getStackDelta(AVM2Instruction ins, ABC abc) {
return 1; //?
return 1; // ?
}
},
new InstructionDefinition(0x33, "pushdecimal", new int[]{AVM2Code.DAT_DECIMAL_INDEX}) {
@Override
public int getStackDelta(AVM2Instruction ins, ABC abc) {
return 1; //?
return 1; // ?
}
},
new InstructionDefinition(0x34, "pushdnan", new int[]{}) {
@Override
public int getStackDelta(AVM2Instruction ins, ABC abc) {
return 1; //?
return 1; // ?
}
},
new PushDoubleIns(),
@@ -725,7 +725,8 @@ public class AVM2Code implements Cloneable {
}
}
};
//endoflist
// endoflist
public static InstructionDefinition[] instructionSetByCode = buildInstructionSetByCode();
public boolean hideTemporaryRegisters = true;
@@ -800,7 +801,7 @@ public class AVM2Code implements Cloneable {
if (codeMap.containsKey(address)) {
continue;
}
if (address < startPos) //no jump outside block
if (address < startPos) // no jump outside block
{
continue;
}
@@ -816,7 +817,7 @@ public class AVM2Code implements Cloneable {
}
if (instr != null) {
int[] actualOperands = null;
if (instructionCode == 0x1b) { //switch
if (instructionCode == 0x1b) { // switch
int firstOperand = ais.readS24("default_offset");
int case_count = ais.readU30("case_count");
actualOperands = new int[case_count + 3];
@@ -1155,13 +1156,13 @@ public class AVM2Code implements Cloneable {
for (int i = 0; i < -ins.definition.getStackDelta(ins, null/*IfTypeIns do not require ABCs*/); i++) {
writer.appendNoHilight(new DeobfuscatePopIns().instructionName).newLine();
}
if (fixBranch == 0) { //jump
if (fixBranch == 0) { // jump
writer.appendNoHilight(new JumpIns().instructionName + " ofs" + Helper.formatAddress(ofs + ins.getBytes().length + ins.operands[0]));
} else {
//nojump, ignore
// nojump, ignore
}
}
//TODO: lookupswitch ?
// TODO: lookupswitch ?
} else {
if (ins.changeJumpTo > -1) {
writer.appendNoHilight(ins.definition.instructionName + " ofs" + Helper.formatAddress(pos2adr(ins.changeJumpTo)));
@@ -1245,7 +1246,7 @@ public class AVM2Code implements Cloneable {
if (ins.definition instanceof DebugIns) {
if (ins.operands[0] == 1) {
String v = abc.constants.getString(ins.operands[1]);
//Same name already exists, it may be wrong names inserted by obfuscator
// Same name already exists, it may be wrong names inserted by obfuscator
if (localRegNames.values().contains(v)) {
return new HashMap<>();
}
@@ -1254,7 +1255,7 @@ public class AVM2Code implements Cloneable {
}
}
//TODO: Make this immune to using existing multinames (?)
// TODO: Make this immune to using existing multinames (?)
return localRegNames;
}
@@ -1278,7 +1279,7 @@ public class AVM2Code implements Cloneable {
}
} catch (InterruptedException ex) {
//ignored
// ignored
}
}
@@ -1415,7 +1416,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);
@@ -1428,7 +1429,7 @@ public class AVM2Code implements Cloneable {
SetLocalAVM2Item slt = (SetLocalAVM2Item) output.remove(output.size() - 1);
stack.push(slt.getValue());
ip++;
} else if ((ins.definition instanceof SetLocalTypeIns) && (ip + 1 <= end) && (isKilled(((SetLocalTypeIns) ins.definition).getRegisterId(ins), ip, end))) { //set_local_x,get_local_x..kill x
} else if ((ins.definition instanceof SetLocalTypeIns) && (ip + 1 <= end) && (isKilled(((SetLocalTypeIns) ins.definition).getRegisterId(ins), ip, end))) { // set_local_x,get_local_x..kill x
AVM2Instruction insAfter = code.get(ip + 1);
if ((insAfter.definition instanceof GetLocalTypeIns) && (((GetLocalTypeIns) insAfter.definition).getRegisterId(insAfter) == ((SetLocalTypeIns) ins.definition).getRegisterId(ins))) {
GraphTargetItem before = stack.peek();
@@ -1449,7 +1450,7 @@ public class AVM2Code implements Cloneable {
if (ip - 1 >= start) {
insBefore = code.get(ip - 1);
}
if (insAfter.definition instanceof ConvertBIns) { //SWF compiled with debug contain convert_b
if (insAfter.definition instanceof ConvertBIns) { // SWF compiled with debug contain convert_b
ip++;
//addr = pos2adr(ip);
insAfter = code.get(ip + 1);
@@ -1463,7 +1464,7 @@ public class AVM2Code implements Cloneable {
//stack.add("(" + stack.pop() + ")||");
isAnd = false;
} else if (insAfter.definition instanceof SetLocalTypeIns) {
//chained assignments
// chained assignments
int reg = (((SetLocalTypeIns) insAfter.definition).getRegisterId(insAfter));
for (int t = ip + 1; t <= end - 1; t++) {
if (code.get(t).definition instanceof KillIns) {
@@ -1490,7 +1491,7 @@ public class AVM2Code implements Cloneable {
for (int i = ip; i >= start; i--) {
if (code.get(i).definition instanceof DupIns) {
if (stack.isEmpty()) {
break;//FIXME?o
break; // FIXME?o
}
GraphTargetItem v = stack.pop();
stack.push(new LocalRegAVM2Item(ins, reg, v));
@@ -1537,9 +1538,9 @@ public class AVM2Code implements Cloneable {
if (code.get(ip + plus + 4).definition instanceof PopScopeIns) {
if (code.get(ip + plus + 3).definition instanceof SetPropertyIns) {
functionName = abc.constants.getMultiname(code.get(ip + plus + 3).operands[0]).getName(constants, fullyQualifiedNames, true);
scopeStack.pop();//with
output.remove(output.size() - 1); //with
ip = ip + plus + 4; //+1 below
scopeStack.pop();// with
output.remove(output.size() - 1); // with
ip = ip + plus + 4; // +1 below
}
}
}
@@ -1549,7 +1550,7 @@ public class AVM2Code implements Cloneable {
}
}
}
//What to do when hasDup is false?
// What to do when hasDup is false?
ins.definition.translate(isStatic, scriptIndex, classIndex, localRegs, stack, scopeStack, constants, ins, method_info, output, body, abc, localRegNames, fullyQualifiedNames, path, localRegAssigmentIps, ip, refs, this);
NewFunctionAVM2Item nft = (NewFunctionAVM2Item) stack.peek();
nft.functionName = functionName;
@@ -1763,7 +1764,7 @@ public class AVM2Code implements Cloneable {
}
}
} else {
//In obfuscated code, SetLocal instructions comes first
// In obfuscated code, SetLocal instructions comes first
//break;
}
}
@@ -1784,7 +1785,7 @@ public class AVM2Code implements Cloneable {
return list;
}
}
//Declarations
// Declarations
injectDeclarations(list, new boolean[regCount], new ArrayList<Slot>(), abc, body);
int lastPos = list.size() - 1;
@@ -1982,7 +1983,7 @@ public class AVM2Code implements Cloneable {
while (pos < code.size()) {
AVM2Instruction ins = code.get(pos);
if (stats.instructionStats[pos].seen) {
//check stack mismatch here
// check stack mismatch here
return true;
}
@@ -2032,11 +2033,11 @@ public class AVM2Code implements Cloneable {
}
}
if (ins.definition instanceof ReturnValueIns) {
//check stack=1
// check stack=1
return true;
}
if (ins.definition instanceof ReturnVoidIns) {
//check stack=0
// check stack=0
return true;
}
if (ins.definition instanceof JumpIns) {
@@ -2098,7 +2099,7 @@ public class AVM2Code implements Cloneable {
return null;
}
int maxIp = 0;
//searching for visited instruction in second run which has maximum position
// searching for visited instruction in second run which has maximum position
for (int i = 0; i < stats.instructionStats.length; i++) {
if (stats.instructionStats[i].seen && !visited.contains(i)) {
maxIp = i;
@@ -2118,7 +2119,7 @@ public class AVM2Code implements Cloneable {
for (int i = 0; i < stats.instructionStats.length; i++) {
stats.instructionStats[i].seen = false;
}
//Rerun rest with new scopePos, stackPos
// Rerun rest with new scopePos, stackPos
if (!walkCode(stats, nextIp, origStackPos + 1/*magic!*/, scopePos - 1 /*magic!*/, abc)) {
return null;
}
@@ -2127,7 +2128,7 @@ public class AVM2Code implements Cloneable {
}
prevStart = ex.start;
} catch (ConvertException ex1) {
//ignore
// ignore
}
}
//stats.maxscope+=initScope;
@@ -2753,7 +2754,7 @@ public class AVM2Code implements Cloneable {
}*/
AVM2Instruction ins = code.get(ip);
//Errorneous code inserted by some obfuscators
// Errorneous code inserted by some obfuscators
if (ins.definition instanceof NewObjectIns) {
if (ins.operands[0] > stack.size()) {
ins.setIgnored(true, 0);
@@ -231,8 +231,8 @@ public class AVM2Deobfuscation {
} else {
newname = fooString(namesMap, constants.getString(strIndex), firstUppercase, DEFAULT_FOO_SIZE, stringUsageTypes.get(strIndex), renameType);
}
if (stringUsages.contains(strIndex) || namespaceUsages.contains(strIndex)) { //this name is already referenced as String
strIndex = constants.addString(s); //add new index
if (stringUsages.contains(strIndex) || namespaceUsages.contains(strIndex)) { // this name is already referenced as String
strIndex = constants.addString(s); // add new index
}
constants.setString(strIndex, newname);
if (!namesMap.containsKey(s)) {
@@ -86,7 +86,7 @@ public class AVM2Instruction implements Cloneable, GraphSourceItem {
}
}
} catch (IOException ex) {
//ignored
// ignored
}
return bos.toByteArray();
}
@@ -1560,7 +1560,7 @@ public class ActionScriptParser {
try {
ui.resolve(null, new ArrayList<GraphTargetItem>(), new ArrayList<String>(), abc, otherABCs, new ArrayList<MethodBody>(), variables);
} catch (CompilationException ex) {
//ignore
// ignore
}
ui.setSlotNumber(e.getSlotNumber());
ui.setSlotScope(e.getSlotScope());
@@ -1583,7 +1583,7 @@ public class ActionScriptParser {
try {
ui.resolve(null, new ArrayList<GraphTargetItem>(), new ArrayList<String>(), abc, otherABCs, new ArrayList<MethodBody>(), variables);
} catch (CompilationException ex) {
//ignore
// ignore
}
ui.setSlotNumber(e.getSlotNumber());
ui.setSlotScope(e.getSlotScope());
@@ -12,7 +12,8 @@
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. */
* License along with this library.
*/
package com.jpexs.decompiler.flash.abc.usages;
import com.jpexs.decompiler.flash.abc.ABC;
@@ -50,7 +51,7 @@ public abstract class ConstVarMultinameUsage extends TraitMultinameUsage {
try {
((TraitSlotConst) traits.traits.get(traitIndex)).convertHeader(null, "", abcTags, abc, isStatic, ScriptExportMode.AS, -1/*FIXME*/, classIndex, nulWriter, new ArrayList<String>(), false);
} catch (InterruptedException ex) {
//ignore
// ignore
}
HighlightedTextWriter writer = new HighlightedTextWriter(Configuration.getCodeFormatting(), false);
@@ -65,7 +66,7 @@ public abstract class ConstVarMultinameUsage extends TraitMultinameUsage {
try {
((TraitSlotConst) traits.traits.get(traitIndex)).toStringHeader(null, "", abcTags, abc, isStatic, ScriptExportMode.AS, -1/*FIXME*/, classIndex, writer, new ArrayList<String>(), false);
} catch (InterruptedException ex) {
//ignore
// ignore
}
return writer.toString();
}