mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-09-25 03:40:47 +00:00
AS3: Edit obfuscated identifiers
build script: running from lib too, clean lib from gui clean
This commit is contained in:
@@ -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.EventListener;
|
||||
@@ -299,7 +300,7 @@ public class ABC {
|
||||
int mIndex = body.code.code.get(ip).operands[0];
|
||||
if (mIndex > 0) {
|
||||
Multiname m = constants.getMultiname(mIndex);
|
||||
if (m.getNameWithNamespace(constants).equals("flash.utils.getDefinitionByName")) {
|
||||
if (m.getNameWithNamespace(constants,true).equals("flash.utils.getDefinitionByName")) {
|
||||
if (ip > 0) {
|
||||
if (body.code.code.get(ip - 1).definition instanceof PushStringIns) {
|
||||
int strIndex = body.code.code.get(ip - 1).operands[0];
|
||||
@@ -693,11 +694,11 @@ public class ABC {
|
||||
|
||||
public MethodBody findBodyByClassAndName(String className, String methodName) {
|
||||
for (int i = 0; i < instance_info.size(); i++) {
|
||||
if (className.equals(constants.getMultiname(instance_info.get(i).name_index).getName(constants, new ArrayList<String>()))) {
|
||||
if (className.equals(constants.getMultiname(instance_info.get(i).name_index).getName(constants, new ArrayList<String>(),true))) {
|
||||
for (Trait t : instance_info.get(i).instance_traits.traits) {
|
||||
if (t instanceof TraitMethodGetterSetter) {
|
||||
TraitMethodGetterSetter t2 = (TraitMethodGetterSetter) t;
|
||||
if (methodName.equals(t2.getName(this).getName(constants, new ArrayList<String>()))) {
|
||||
if (methodName.equals(t2.getName(this).getName(constants, new ArrayList<String>(),true))) {
|
||||
for (MethodBody body : bodies) {
|
||||
if (body.method_info == t2.method_info) {
|
||||
return body;
|
||||
@@ -710,11 +711,11 @@ public class ABC {
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < class_info.size(); i++) {
|
||||
if (className.equals(constants.getMultiname(instance_info.get(i).name_index).getName(constants, new ArrayList<String>()))) {
|
||||
if (className.equals(constants.getMultiname(instance_info.get(i).name_index).getName(constants, new ArrayList<String>(),true))) {
|
||||
for (Trait t : class_info.get(i).static_traits.traits) {
|
||||
if (t instanceof TraitMethodGetterSetter) {
|
||||
TraitMethodGetterSetter t2 = (TraitMethodGetterSetter) t;
|
||||
if (methodName.equals(t2.getName(this).getName(constants, new ArrayList<String>()))) {
|
||||
if (methodName.equals(t2.getName(this).getName(constants, new ArrayList<String>(),true))) {
|
||||
for (MethodBody body : bodies) {
|
||||
if (body.method_info == t2.method_info) {
|
||||
return body;
|
||||
@@ -793,7 +794,7 @@ public class ABC {
|
||||
TraitSlotConst s = ((TraitSlotConst) t);
|
||||
if (s.isNamespace()) {
|
||||
String key = constants.getNamespace(s.value_index).getName(constants); //assume not null
|
||||
String val = constants.getMultiname(s.name_index).getNameWithNamespace(constants);
|
||||
String val = constants.getMultiname(s.name_index).getNameWithNamespace(constants,true);
|
||||
namespaceMap.put(key, val);
|
||||
}
|
||||
}
|
||||
@@ -954,7 +955,7 @@ public class ABC {
|
||||
if (classId > -1) {
|
||||
for (Trait t : instance_info.get(classId).instance_traits.traits) {
|
||||
if (t instanceof TraitMethodGetterSetter) {
|
||||
if (t.getName(this).getName(constants, new ArrayList<String>()).equals(methodName)) {
|
||||
if (t.getName(this).getName(constants, new ArrayList<String>(),true).equals(methodName)) {
|
||||
return ((TraitMethodGetterSetter) t).method_info;
|
||||
}
|
||||
}
|
||||
@@ -967,7 +968,7 @@ public class ABC {
|
||||
if (classId > -1) {
|
||||
for (Trait t : instance_info.get(classId).instance_traits.traits) {
|
||||
if (t instanceof TraitMethodGetterSetter) {
|
||||
if (t.getName(this).getName(constants, new ArrayList<String>()).equals(methodName)) {
|
||||
if (t.getName(this).getName(constants, new ArrayList<String>(),true).equals(methodName)) {
|
||||
return findBodyIndex(((TraitMethodGetterSetter) t).method_info);
|
||||
}
|
||||
}
|
||||
@@ -983,7 +984,7 @@ public class ABC {
|
||||
|
||||
public int findClassByName(String name) {
|
||||
for (int c = 0; c < instance_info.size(); c++) {
|
||||
String s = constants.getMultiname(instance_info.get(c).name_index).getNameWithNamespace(constants);
|
||||
String s = constants.getMultiname(instance_info.get(c).name_index).getNameWithNamespace(constants,true);
|
||||
if (name.equals(s)) {
|
||||
return c;
|
||||
}
|
||||
|
||||
@@ -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.SWF;
|
||||
@@ -86,7 +87,7 @@ public class ScriptPack implements TreeElementItem {
|
||||
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)) {
|
||||
scriptName = name.getName(abc.constants, new ArrayList<String>());
|
||||
scriptName = name.getName(abc.constants, new ArrayList<String>(),false);
|
||||
}
|
||||
}
|
||||
return scriptName;
|
||||
|
||||
@@ -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.avm2;
|
||||
|
||||
import com.jpexs.decompiler.flash.abc.ABC;
|
||||
@@ -1464,7 +1465,7 @@ public class AVM2Code implements Serializable {
|
||||
if (code.get(ip + plus + 2).definition instanceof SwapIns) {
|
||||
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);
|
||||
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
|
||||
|
||||
@@ -12,16 +12,20 @@
|
||||
* 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.avm2;
|
||||
|
||||
import com.jpexs.decompiler.flash.abc.types.Decimal;
|
||||
import com.jpexs.decompiler.flash.abc.types.Multiname;
|
||||
import com.jpexs.decompiler.flash.abc.types.Namespace;
|
||||
import com.jpexs.decompiler.flash.abc.types.NamespaceSet;
|
||||
import com.jpexs.decompiler.flash.action.Deobfuscation;
|
||||
import com.jpexs.helpers.utf8.Utf8PrintWriter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class ConstantPool {
|
||||
|
||||
@@ -34,7 +38,7 @@ public class ConstantPool {
|
||||
public List<Namespace> constant_namespace = new ArrayList<>();
|
||||
public List<NamespaceSet> constant_namespace_set = new ArrayList<>();
|
||||
public List<Multiname> constant_multiname = new ArrayList<>();
|
||||
|
||||
|
||||
public synchronized int addInt(long value) {
|
||||
constant_int.add(value);
|
||||
return constant_int.size() - 1;
|
||||
|
||||
+3
-2
@@ -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.avm2.instructions;
|
||||
|
||||
import com.jpexs.decompiler.flash.abc.ABC;
|
||||
@@ -118,7 +119,7 @@ public class InstructionDefinition implements Serializable {
|
||||
if (constants.getMultiname(multinameIndex).needsName()) {
|
||||
name = stack.get(pos).toString();
|
||||
} else {
|
||||
name = GraphTextWriter.hilighOffset(constants.getMultiname(multinameIndex).getName(constants, fullyQualifiedNames), ins.offset);
|
||||
name = GraphTextWriter.hilighOffset(constants.getMultiname(multinameIndex).getName(constants, fullyQualifiedNames,false), ins.offset);
|
||||
}
|
||||
return name + ns;
|
||||
}
|
||||
|
||||
+3
-2
@@ -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.avm2.instructions.construction;
|
||||
|
||||
import com.jpexs.decompiler.flash.abc.ABC;
|
||||
@@ -95,7 +96,7 @@ public class ConstructIns extends InstructionDefinition {
|
||||
}
|
||||
if (obj instanceof GetLexAVM2Item) {
|
||||
GetLexAVM2Item glt = (GetLexAVM2Item) obj;
|
||||
isXML = glt.propertyName.getName(constants, fullyQualifiedNames).equals("XML");
|
||||
isXML = glt.propertyName.getName(constants, fullyQualifiedNames,true).equals("XML");
|
||||
}
|
||||
|
||||
if (isXML) {
|
||||
|
||||
+3
-2
@@ -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.avm2.instructions.construction;
|
||||
|
||||
import com.jpexs.decompiler.flash.abc.ABC;
|
||||
@@ -44,7 +45,7 @@ public class NewClassIns extends InstructionDefinition {
|
||||
HilightedTextWriter writer = new HilightedTextWriter(Configuration.getCodeFormatting(), false);
|
||||
stack.pop().toString(writer, LocalData.create(constants, localRegNames, fullyQualifiedNames));
|
||||
String baseType = writer.toString();
|
||||
stack.push(new UnparsedAVM2Item(ins, "new " + abc.constants.getMultiname(abc.instance_info.get(clsIndex).name_index).getName(constants, fullyQualifiedNames) + ".class extends " + baseType));
|
||||
stack.push(new UnparsedAVM2Item(ins, "new " + abc.constants.getMultiname(abc.instance_info.get(clsIndex).name_index).getName(constants, fullyQualifiedNames,false) + ".class extends " + baseType));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+4
-3
@@ -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.avm2.instructions.other;
|
||||
|
||||
import com.jpexs.decompiler.flash.abc.ABC;
|
||||
@@ -97,7 +98,7 @@ public class SetSlotIns extends InstructionDefinition implements SetTypeIns {
|
||||
if (slotname != null) {
|
||||
if (value instanceof LocalRegAVM2Item) {
|
||||
LocalRegAVM2Item lr = (LocalRegAVM2Item) value;
|
||||
String slotNameStr = slotname.getName(constants, fullyQualifiedNames);
|
||||
String slotNameStr = slotname.getName(constants, fullyQualifiedNames, true);
|
||||
if (localRegNames.containsKey(lr.regIndex)) {
|
||||
if (localRegNames.get(lr.regIndex).equals(slotNameStr)) {
|
||||
return; //Register with same name to slot
|
||||
@@ -167,7 +168,7 @@ public class SetSlotIns extends InstructionDefinition implements SetTypeIns {
|
||||
for (int t = 0; t < body.traits.traits.size(); t++) {
|
||||
if (body.traits.traits.get(t) instanceof TraitSlotConst) {
|
||||
if (((TraitSlotConst) body.traits.traits.get(t)).slot_id == slotIndex) {
|
||||
slotname = body.traits.traits.get(t).getName(abc).getName(abc.constants, fullyQualifiedNames);
|
||||
slotname = body.traits.traits.get(t).getName(abc).getName(abc.constants, fullyQualifiedNames, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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.avm2.model;
|
||||
|
||||
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
|
||||
@@ -20,6 +21,7 @@ import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.stack.PopIns;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.parser.script.AVM2SourceGenerator;
|
||||
import com.jpexs.decompiler.flash.action.Deobfuscation;
|
||||
import com.jpexs.decompiler.flash.configuration.Configuration;
|
||||
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
|
||||
import com.jpexs.decompiler.graph.CompilationException;
|
||||
@@ -96,7 +98,7 @@ public abstract class AVM2Item extends GraphTargetItem {
|
||||
|
||||
public static String localRegName(HashMap<Integer, String> localRegNames, int reg) {
|
||||
if (localRegNames.containsKey(reg)) {
|
||||
return localRegNames.get(reg);
|
||||
return Deobfuscation.printIdentifier(localRegNames.get(reg));
|
||||
} else {
|
||||
if (reg == 0) {
|
||||
return "this";
|
||||
|
||||
@@ -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.avm2.model;
|
||||
|
||||
import com.jpexs.decompiler.flash.abc.types.Multiname;
|
||||
@@ -32,7 +33,7 @@ public class ClassAVM2Item extends AVM2Item {
|
||||
|
||||
@Override
|
||||
public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) {
|
||||
return writer.append(className.getName(localData.constantsAvm2, localData.fullyQualifiedNames));
|
||||
return writer.append(className.getName(localData.constantsAvm2, localData.fullyQualifiedNames,false));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+4
-3
@@ -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.avm2.model;
|
||||
|
||||
import com.jpexs.decompiler.flash.abc.avm2.ConstantPool;
|
||||
@@ -61,7 +62,7 @@ public class FullMultinameAVM2Item extends AVM2Item {
|
||||
if (name != null) {
|
||||
cname = name.toString(LocalData.create(constants, localRegNames, fullyQualifiedNames));
|
||||
} else {
|
||||
cname = (constants.getMultiname(multinameIndex).getName(constants, fullyQualifiedNames));
|
||||
cname = (constants.getMultiname(multinameIndex).getName(constants, fullyQualifiedNames,true));
|
||||
}
|
||||
String cns = "";
|
||||
if (namespace != null) {
|
||||
@@ -93,7 +94,7 @@ public class FullMultinameAVM2Item extends AVM2Item {
|
||||
} else {
|
||||
ConstantPool constants = localData.constantsAvm2;
|
||||
List<String> fullyQualifiedNames = localData.fullyQualifiedNames;
|
||||
writer.append(constants.getMultiname(multinameIndex).getName(constants, fullyQualifiedNames));
|
||||
writer.append(constants.getMultiname(multinameIndex).getName(constants, fullyQualifiedNames,false));
|
||||
}
|
||||
return writer;
|
||||
}
|
||||
|
||||
@@ -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.avm2.model;
|
||||
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
|
||||
@@ -33,7 +34,7 @@ public class GetLexAVM2Item extends AVM2Item {
|
||||
|
||||
@Override
|
||||
public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) {
|
||||
return writer.append(propertyName.getName(localData.constantsAvm2, localData.fullyQualifiedNames));
|
||||
return writer.append(propertyName.getName(localData.constantsAvm2, localData.fullyQualifiedNames,false));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -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.avm2.model;
|
||||
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
|
||||
@@ -38,7 +39,7 @@ public class GetSlotAVM2Item extends AVM2Item {
|
||||
if (slotName == null) {
|
||||
return writer.append("/*UnknownSlot*/");
|
||||
}
|
||||
return writer.append(slotName.getName(localData.constantsAvm2, localData.fullyQualifiedNames));
|
||||
return writer.append(slotName.getName(localData.constantsAvm2, localData.fullyQualifiedNames,false));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -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.avm2.model;
|
||||
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
|
||||
@@ -64,7 +65,7 @@ public class SetSlotAVM2Item extends AVM2Item implements SetTypeAVM2Item, Assign
|
||||
if (slotName == null) {
|
||||
return writer.append("/*UnknownSlot*/");
|
||||
}
|
||||
return writer.append(slotName.getName(localData.constantsAvm2, localData.fullyQualifiedNames));
|
||||
return writer.append(slotName.getName(localData.constantsAvm2, localData.fullyQualifiedNames,false));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+16
-15
@@ -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.avm2.parser.script;
|
||||
|
||||
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
|
||||
@@ -1629,9 +1630,9 @@ public class AVM2SourceGenerator implements SourceGenerator {
|
||||
TraitSlotConst tsc = (TraitSlotConst) mbody.traits.traits.get(i);
|
||||
GraphTargetItem type = TypeItem.UNBOUNDED;
|
||||
if (tsc.type_index > 0) {
|
||||
type = new TypeItem(abc.constants.constant_multiname.get(tsc.type_index).getNameWithNamespace(abc.constants));
|
||||
type = new TypeItem(abc.constants.constant_multiname.get(tsc.type_index).getNameWithNamespace(abc.constants,true));
|
||||
}
|
||||
NameAVM2Item d = new NameAVM2Item(type, 0, tsc.getName(abc).getName(abc.constants, new ArrayList<String>()), NameAVM2Item.getDefaultValue("" + type), true, new ArrayList<Integer>());
|
||||
NameAVM2Item d = new NameAVM2Item(type, 0, tsc.getName(abc).getName(abc.constants, new ArrayList<String>(),true), NameAVM2Item.getDefaultValue("" + type), true, new ArrayList<Integer>());
|
||||
d.setSlotNumber(tsc.slot_id);
|
||||
d.setSlotScope(slotScope);
|
||||
mbody.code.code.addAll(0, toInsList(d.toSourceIgnoreReturnValue(localData, this)));
|
||||
@@ -1818,7 +1819,7 @@ public class AVM2SourceGenerator implements SourceGenerator {
|
||||
for (ScriptInfo si : a.script_info) {
|
||||
for (Trait t : si.traits.traits) {
|
||||
Multiname m = t.getName(a);
|
||||
if (fullCustom.equals(m.getNameWithNamespace(a.constants))) {
|
||||
if (fullCustom.equals(m.getNameWithNamespace(a.constants,true))) {
|
||||
if (t instanceof TraitSlotConst) {
|
||||
if (((TraitSlotConst) t).isNamespace()) {
|
||||
return ((TraitSlotConst) t).value_index;
|
||||
@@ -2132,7 +2133,7 @@ public class AVM2SourceGenerator implements SourceGenerator {
|
||||
indices.add(
|
||||
abc.constants.getMultinameId(
|
||||
new Multiname(Multiname.QNAME,
|
||||
abc.constants.getStringId(superName.getName(a.constants, new ArrayList<String>()), true),
|
||||
abc.constants.getStringId(superName.getName(a.constants, new ArrayList<String>(),true), true),
|
||||
abc.constants.getNamespaceId(new Namespace(superName.getNamespace(a.constants).kind, abc.constants.getStringId(superName.getNamespace(a.constants).getName(a.constants), true)), 0, true), 0, 0, new ArrayList<Integer>()), true)
|
||||
);
|
||||
}
|
||||
@@ -2188,7 +2189,7 @@ public class AVM2SourceGenerator implements SourceGenerator {
|
||||
}
|
||||
for (Trait t : ii.traits.traits) {
|
||||
if (eq(pkg, t.getName(abc).getNamespace(abc.constants).getName(abc.constants))) {
|
||||
if (propertyName.equals(t.getName(abc).getName(abc.constants, new ArrayList<String>()))) {
|
||||
if (propertyName.equals(t.getName(abc).getName(abc.constants, new ArrayList<String>(),true))) {
|
||||
outName.setVal(obj);
|
||||
outNs.setVal(pkg);
|
||||
outPropNs.setVal(t.getName(abc).getNamespace(abc.constants).getName(abc.constants));
|
||||
@@ -2211,7 +2212,7 @@ public class AVM2SourceGenerator implements SourceGenerator {
|
||||
continue;
|
||||
}
|
||||
Multiname clsName = ii.getName(abc.constants);
|
||||
if (obj.equals(clsName.getName(abc.constants, new ArrayList<String>()))) {
|
||||
if (obj.equals(clsName.getName(abc.constants, new ArrayList<String>(),true))) {
|
||||
if (eq(pkg, clsName.getNamespace(abc.constants).getName(abc.constants))) {
|
||||
//class found
|
||||
|
||||
@@ -2219,7 +2220,7 @@ public class AVM2SourceGenerator implements SourceGenerator {
|
||||
if (t.getName(abc) == null) { //in traits phase 2
|
||||
continue;
|
||||
}
|
||||
if (propertyName.equals(t.getName(abc).getName(abc.constants, new ArrayList<String>()))) {
|
||||
if (propertyName.equals(t.getName(abc).getName(abc.constants, new ArrayList<String>(),true))) {
|
||||
outName.setVal(obj);
|
||||
outNs.setVal(pkg);
|
||||
outPropNs.setVal(t.getName(abc).getNamespace(abc.constants).getName(abc.constants));
|
||||
@@ -2239,7 +2240,7 @@ public class AVM2SourceGenerator implements SourceGenerator {
|
||||
if (t.getName(abc) == null) { //in traits phase 2
|
||||
continue;
|
||||
}
|
||||
if (propertyName.equals(t.getName(abc).getName(abc.constants, new ArrayList<String>()))) {
|
||||
if (propertyName.equals(t.getName(abc).getName(abc.constants, new ArrayList<String>(),true))) {
|
||||
outName.setVal(obj);
|
||||
outNs.setVal(pkg);
|
||||
outPropNs.setVal(t.getName(abc).getNamespace(abc.constants).getName(abc.constants));
|
||||
@@ -2257,7 +2258,7 @@ public class AVM2SourceGenerator implements SourceGenerator {
|
||||
|
||||
Multiname superName = abc.constants.constant_multiname.get(ii.super_index);
|
||||
if (superName != null) {
|
||||
return searchPrototypeChain(instanceOnly, abcs, superName.getNamespace(abc.constants).getName(abc.constants), superName.getName(abc.constants, new ArrayList<String>()), propertyName, outName, outNs, outPropNs, outPropNsKind, outPropNsIndex, outPropType, outPropValue);
|
||||
return searchPrototypeChain(instanceOnly, abcs, superName.getNamespace(abc.constants).getName(abc.constants), superName.getName(abc.constants, new ArrayList<String>(),true), propertyName, outName, outNs, outPropNs, outPropNsKind, outPropNsIndex, outPropType, outPropValue);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
@@ -2270,7 +2271,7 @@ public class AVM2SourceGenerator implements SourceGenerator {
|
||||
|
||||
public static void parentNames(ABC abc, List<ABC> allABCs, int name_index, List<Integer> indices, List<String> names, List<String> namespaces, List<ABC> outABCs) {
|
||||
indices.add(name_index);
|
||||
names.add(abc.constants.constant_multiname.get(name_index).getName(abc.constants, new ArrayList<String>()));
|
||||
names.add(abc.constants.constant_multiname.get(name_index).getName(abc.constants, new ArrayList<String>(),true));
|
||||
namespaces.add(abc.constants.constant_multiname.get(name_index).getNamespace(abc.constants).getName(abc.constants));
|
||||
Multiname mname = abc.constants.constant_multiname.get(name_index);
|
||||
|
||||
@@ -2283,7 +2284,7 @@ public class AVM2SourceGenerator implements SourceGenerator {
|
||||
for (ABC a : abcs) {
|
||||
for (int i = 0; i < a.instance_info.size(); i++) {
|
||||
Multiname m = a.constants.constant_multiname.get(a.instance_info.get(i).name_index);
|
||||
if (m.getName(a.constants, new ArrayList<String>()).equals(mname.getName(abc.constants, new ArrayList<String>()))) {
|
||||
if (m.getName(a.constants, new ArrayList<String>(),true).equals(mname.getName(abc.constants, new ArrayList<String>(),true))) {
|
||||
|
||||
if (m.getNamespace(a.constants).hasName(a.constants, mname.getNamespace(abc.constants).getName(abc.constants))) {
|
||||
//Multiname superName = a.constants.constant_multiname.get(a.instance_info.get(i).super_index);
|
||||
@@ -2379,7 +2380,7 @@ public class AVM2SourceGenerator implements SourceGenerator {
|
||||
}
|
||||
for (InstanceInfo ii : abc.instance_info) {
|
||||
Multiname mname = abc.constants.constant_multiname.get(ii.name_index);
|
||||
if (mname != null && name.equals(mname.getName(abc.constants, new ArrayList<String>()))) {
|
||||
if (mname != null && name.equals(mname.getName(abc.constants, new ArrayList<String>(),true))) {
|
||||
if (mname.getNamespace(abc.constants).hasName(pkg, abc.constants)) {
|
||||
name_index = ii.name_index;
|
||||
break;
|
||||
@@ -2388,7 +2389,7 @@ public class AVM2SourceGenerator implements SourceGenerator {
|
||||
}
|
||||
for (int i = 1; i < abc.constants.constant_multiname.size(); i++) {
|
||||
Multiname mname = abc.constants.constant_multiname.get(i);
|
||||
if (mname != null && name.equals(mname.getName(abc.constants, new ArrayList<String>()))) {
|
||||
if (mname != null && name.equals(mname.getName(abc.constants, new ArrayList<String>(),true))) {
|
||||
if (mname.getNamespace(abc.constants) != null && pkg.equals(mname.getNamespace(abc.constants).getName(abc.constants))) {
|
||||
name_index = i;
|
||||
break;
|
||||
@@ -2398,7 +2399,7 @@ public class AVM2SourceGenerator implements SourceGenerator {
|
||||
if (name_index == 0) {
|
||||
if (pkg.isEmpty() && localData.currentScript != null /*FIXME!*/) {
|
||||
for (Trait t : localData.currentScript.traits.traits) {
|
||||
if (t.getName(abc).getName(abc.constants, new ArrayList<String>()).equals(name)) {
|
||||
if (t.getName(abc).getName(abc.constants, new ArrayList<String>(),true).equals(name)) {
|
||||
name_index = t.name_index;
|
||||
break;
|
||||
}
|
||||
|
||||
+3
-2
@@ -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.avm2.parser.script;
|
||||
|
||||
import com.jpexs.decompiler.flash.SWC;
|
||||
@@ -125,7 +126,7 @@ import java.util.logging.Logger;
|
||||
public class ActionScriptParser {
|
||||
|
||||
private long uniqLast = 0;
|
||||
private final boolean debugMode = false;
|
||||
private final boolean debugMode = true;
|
||||
private static final String AS3_NAMESPACE = "http://adobe.com/AS3/2006/builtin";
|
||||
|
||||
private final ABC abc;
|
||||
|
||||
+7
-6
@@ -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.avm2.parser.script;
|
||||
|
||||
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
|
||||
@@ -108,7 +109,7 @@ public class PropertyAVM2Item extends AssignableAVM2Item {
|
||||
}
|
||||
return new ApplyTypeAVM2Item(null, obj, params);
|
||||
} else {
|
||||
return new TypeItem(m.getNameWithNamespace(constants));
|
||||
return new TypeItem(m.getNameWithNamespace(constants,true));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -218,7 +219,7 @@ public class PropertyAVM2Item extends AssignableAVM2Item {
|
||||
Reference<Integer> outPropNsIndex = new Reference<>(0);
|
||||
Reference<GraphTargetItem> outPropType = new Reference<>(null);
|
||||
Reference<ValueKind> outPropValue = new Reference<>(null);
|
||||
if (AVM2SourceGenerator.searchPrototypeChain(false, abcs, m.getNamespace(a.constants).getName(a.constants), m.getName(a.constants, new ArrayList<String>()), propertyName, outName, outNs, outPropNs, outPropNsKind, outPropNsIndex, outPropType, outPropValue)) {
|
||||
if (AVM2SourceGenerator.searchPrototypeChain(false, abcs, m.getNamespace(a.constants).getName(a.constants), m.getName(a.constants, new ArrayList<String>(),true), propertyName, outName, outNs, outPropNs, outPropNsKind, outPropNsIndex, outPropType, outPropValue)) {
|
||||
objType = new TypeItem("".equals(outNs.getVal()) ? outName.getVal() : outNs.getVal() + "." + outName.getVal());
|
||||
propType = outPropType.getVal();
|
||||
propIndex = abc.constants.getMultinameId(new Multiname(Multiname.QNAME,
|
||||
@@ -238,7 +239,7 @@ public class PropertyAVM2Item extends AssignableAVM2Item {
|
||||
for (MethodBody b : callStack) {
|
||||
for (int i = 0; i < b.traits.traits.size(); i++) {
|
||||
Trait t = b.traits.traits.get(i);
|
||||
if (t.getName(abc).getName(abc.constants, new ArrayList<String>()).equals(propertyName)) {
|
||||
if (t.getName(abc).getName(abc.constants, new ArrayList<String>(),true).equals(propertyName)) {
|
||||
if (t instanceof TraitSlotConst) {
|
||||
TraitSlotConst tsc = (TraitSlotConst) t;
|
||||
objType = new TypeItem("Function");
|
||||
@@ -261,7 +262,7 @@ public class PropertyAVM2Item extends AssignableAVM2Item {
|
||||
int name_index = 0;
|
||||
for (int m = 1; m < abc.constants.constant_multiname.size(); m++) {
|
||||
Multiname mname = abc.constants.constant_multiname.get(m);
|
||||
if (mname.kind == Multiname.QNAME && mname.getName(abc.constants, new ArrayList<String>()).equals(propertyName) && mname.namespace_index == nsindex) {
|
||||
if (mname.kind == Multiname.QNAME && mname.getName(abc.constants, new ArrayList<String>(),true).equals(propertyName) && mname.namespace_index == nsindex) {
|
||||
name_index = m;
|
||||
break;
|
||||
}
|
||||
@@ -336,7 +337,7 @@ public class PropertyAVM2Item extends AssignableAVM2Item {
|
||||
Reference<GraphTargetItem> outPropType = new Reference<>(null);
|
||||
Reference<ValueKind> outPropValue = new Reference<>(null);
|
||||
|
||||
if (propertyName != null && AVM2SourceGenerator.searchPrototypeChain(false, abcs, nsname, n.getName(a.constants, new ArrayList<String>()), propertyName, outName, outNs, outPropNs, outPropNsKind, outPropNsIndex, outPropType, outPropValue)) {
|
||||
if (propertyName != null && AVM2SourceGenerator.searchPrototypeChain(false, abcs, nsname, n.getName(a.constants, new ArrayList<String>(),true), propertyName, outName, outNs, outPropNs, outPropNsKind, outPropNsIndex, outPropType, outPropValue)) {
|
||||
objType = new TypeItem("".equals(outNs.getVal()) ? outName.getVal() : outNs.getVal() + "." + outName.getVal());
|
||||
propType = outPropType.getVal();
|
||||
propIndex = abc.constants.getMultinameId(new Multiname(Multiname.QNAME,
|
||||
|
||||
+5
-4
@@ -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.avm2.parser.script;
|
||||
|
||||
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
|
||||
@@ -363,7 +364,7 @@ public class UnresolvedAVM2Item extends AssignableAVM2Item {
|
||||
if (a.instance_info.get(c).deleted) {
|
||||
continue;
|
||||
}
|
||||
if (a.instance_info.get(c).name_index > 0 && fname.equals(a.instance_info.get(c).getName(a.constants).getNameWithNamespace(a.constants))) {
|
||||
if (a.instance_info.get(c).name_index > 0 && fname.equals(a.instance_info.get(c).getName(a.constants).getNameWithNamespace(a.constants,true))) {
|
||||
if (!subtypes.isEmpty() && parts.size() > i + 1) {
|
||||
continue;
|
||||
}
|
||||
@@ -407,12 +408,12 @@ public class UnresolvedAVM2Item extends AssignableAVM2Item {
|
||||
}
|
||||
if ((a.instance_info.get(c).getName(a.constants) != null && a == abc && a.instance_info.get(c).getName(a.constants).namespace_index == ni)
|
||||
|| (ons.kind != Namespace.KIND_PRIVATE && a.instance_info.get(c).getName(a.constants) != null && a.instance_info.get(c).getName(a.constants).getNamespace(a.constants) != null && a.instance_info.get(c).getName(a.constants).getNamespace(a.constants).hasName(ons.getName(abc.constants), a.constants))) {
|
||||
String cname = a.instance_info.get(c).getName(a.constants).getName(a.constants, new ArrayList<String>());
|
||||
String cname = a.instance_info.get(c).getName(a.constants).getName(a.constants, new ArrayList<String>(),true);
|
||||
if (parts.get(0).equals(cname)) {
|
||||
if (!subtypes.isEmpty() && parts.size() > 1) {
|
||||
continue;
|
||||
}
|
||||
TypeItem ret = new TypeItem(a.instance_info.get(c).getName(a.constants).getNameWithNamespace(a.constants));
|
||||
TypeItem ret = new TypeItem(a.instance_info.get(c).getName(a.constants).getNameWithNamespace(a.constants,true));
|
||||
/*for (String s : subtypes) {
|
||||
UnresolvedAVM2Item su = new UnresolvedAVM2Item(new ArrayList<String>(), importedClasses, true, null, line, s, null, openedNamespaces);
|
||||
su.resolve(thisType, paramTypes, paramNames, abc, otherAbcs, callStack, variables);
|
||||
|
||||
@@ -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.types;
|
||||
|
||||
import com.jpexs.decompiler.flash.abc.avm2.AVM2Code;
|
||||
@@ -55,13 +56,13 @@ public class ABCException implements Serializable {
|
||||
if (name_index == 0) {
|
||||
return "";
|
||||
}
|
||||
return constants.getMultiname(name_index).getName(constants, fullyQualifiedNames);
|
||||
return constants.getMultiname(name_index).getName(constants, fullyQualifiedNames,false);
|
||||
}
|
||||
|
||||
public String getTypeName(ConstantPool constants, List<String> fullyQualifiedNames) {
|
||||
if (type_index == 0) {
|
||||
return "*";
|
||||
}
|
||||
return constants.getMultiname(type_index).getName(constants, fullyQualifiedNames);
|
||||
return constants.getMultiname(type_index).getName(constants, fullyQualifiedNames,false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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.types;
|
||||
|
||||
import com.jpexs.decompiler.flash.abc.ABC;
|
||||
@@ -54,7 +55,7 @@ public class InstanceInfo {
|
||||
public String getClassHeaderStr(ABC abc, List<String> fullyQualifiedNames) {
|
||||
String supIndexStr = "";
|
||||
if (super_index > 0) {
|
||||
supIndexStr = " extends " + abc.constants.getMultiname(super_index).getName(abc.constants, fullyQualifiedNames);////+" flags="+flags+" protectedNS="+protectedNS+" interfaces="+Helper.intArrToString(interfaces)+" method_index="+iinit_index
|
||||
supIndexStr = " extends " + abc.constants.getMultiname(super_index).getName(abc.constants, fullyQualifiedNames,false);////+" flags="+flags+" protectedNS="+protectedNS+" interfaces="+Helper.intArrToString(interfaces)+" method_index="+iinit_index
|
||||
}
|
||||
String implStr = "";
|
||||
if (interfaces.length > 0) {
|
||||
@@ -67,7 +68,7 @@ public class InstanceInfo {
|
||||
if (i > 0) {
|
||||
implStr += ", ";
|
||||
}
|
||||
implStr += abc.constants.getMultiname(interfaces[i]).getName(abc.constants, fullyQualifiedNames);
|
||||
implStr += abc.constants.getMultiname(interfaces[i]).getName(abc.constants, fullyQualifiedNames,false);
|
||||
}
|
||||
}
|
||||
String modifiers;
|
||||
@@ -87,7 +88,7 @@ public class InstanceInfo {
|
||||
if (isInterface()) {
|
||||
objType = "interface ";
|
||||
}
|
||||
return modifiers + objType + abc.constants.getMultiname(name_index).getName(abc.constants, new ArrayList<String>()/* No full names here*/) + supIndexStr + implStr;
|
||||
return modifiers + objType + abc.constants.getMultiname(name_index).getName(abc.constants, new ArrayList<String>()/* No full names here*/,false) + supIndexStr + implStr;
|
||||
}
|
||||
|
||||
public Multiname getName(ConstantPool constants) {
|
||||
|
||||
@@ -12,13 +12,15 @@
|
||||
* 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.types;
|
||||
|
||||
import com.jpexs.decompiler.flash.abc.ABC;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.ConstantPool;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.construction.NewFunctionIns;
|
||||
import com.jpexs.decompiler.flash.action.Deobfuscation;
|
||||
import com.jpexs.decompiler.flash.configuration.Configuration;
|
||||
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
|
||||
import com.jpexs.helpers.Helper;
|
||||
@@ -274,9 +276,9 @@ public class MethodInfo {
|
||||
writer.appendNoHilight(", ");
|
||||
}
|
||||
if (!localRegNames.isEmpty()) {
|
||||
writer.appendNoHilight(localRegNames.get(i + 1));
|
||||
writer.appendNoHilight(Deobfuscation.printIdentifier(localRegNames.get(i + 1)));
|
||||
} else if ((paramNames.length > i) && (paramNames[i] != 0) && Configuration.paramNamesEnable.get()) {
|
||||
writer.appendNoHilight(constants.getString(paramNames[i]));
|
||||
writer.appendNoHilight(Deobfuscation.printIdentifier(constants.getString(paramNames[i])));
|
||||
} else {
|
||||
writer.appendNoHilight("param" + (i + 1));
|
||||
}
|
||||
@@ -284,7 +286,7 @@ public class MethodInfo {
|
||||
if (param_types[i] == 0) {
|
||||
writer.hilightSpecial("*", "param", i);
|
||||
} else {
|
||||
writer.hilightSpecial(constants.getMultiname(param_types[i]).getName(constants, fullyQualifiedNames), "param", i);
|
||||
writer.hilightSpecial(constants.getMultiname(param_types[i]).getName(constants, fullyQualifiedNames,false), "param", i);
|
||||
}
|
||||
if (optional != null) {
|
||||
if (i >= param_types.length - optional.length) {
|
||||
@@ -311,7 +313,7 @@ public class MethodInfo {
|
||||
}
|
||||
|
||||
public GraphTextWriter getReturnTypeStr(GraphTextWriter writer, ConstantPool constants, List<String> fullyQualifiedNames) {
|
||||
return writer.hilightSpecial(ret_type == 0 ? "*" : constants.getMultiname(ret_type).getName(constants, fullyQualifiedNames), "returns");
|
||||
return writer.hilightSpecial(ret_type == 0 ? "*" : constants.getMultiname(ret_type).getName(constants, fullyQualifiedNames,false), "returns");
|
||||
}
|
||||
|
||||
public void setBody(MethodBody body) {
|
||||
|
||||
@@ -12,10 +12,12 @@
|
||||
* 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.types;
|
||||
|
||||
import com.jpexs.decompiler.flash.abc.avm2.ConstantPool;
|
||||
import com.jpexs.decompiler.flash.action.Deobfuscation;
|
||||
import com.jpexs.helpers.Helper;
|
||||
import java.util.List;
|
||||
|
||||
@@ -226,11 +228,11 @@ public class Multiname {
|
||||
return null;
|
||||
}
|
||||
|
||||
private String typeNameToStr(ConstantPool constants, List<String> fullyQualifiedNames) {
|
||||
private String typeNameToStr(ConstantPool constants, List<String> fullyQualifiedNames, boolean raw) {
|
||||
if (constants.getMultiname(qname_index).name_index == name_index) {
|
||||
return "ambiguousTypeName";
|
||||
}
|
||||
String typeNameStr = constants.getMultiname(qname_index).getName(constants, fullyQualifiedNames);
|
||||
String typeNameStr = constants.getMultiname(qname_index).getName(constants, fullyQualifiedNames,raw);
|
||||
if (!params.isEmpty()) {
|
||||
typeNameStr += ".<";
|
||||
for (int i = 0; i < params.size(); i++) {
|
||||
@@ -240,7 +242,7 @@ public class Multiname {
|
||||
if (params.get(i) == 0) {
|
||||
typeNameStr += "*";
|
||||
} else {
|
||||
typeNameStr += constants.getMultiname(params.get(i)).getName(constants, fullyQualifiedNames);
|
||||
typeNameStr += constants.getMultiname(params.get(i)).getName(constants, fullyQualifiedNames,raw);
|
||||
}
|
||||
}
|
||||
typeNameStr += ">";
|
||||
@@ -248,9 +250,9 @@ public class Multiname {
|
||||
return typeNameStr;
|
||||
}
|
||||
|
||||
public String getName(ConstantPool constants, List<String> fullyQualifiedNames) {
|
||||
public String getName(ConstantPool constants, List<String> fullyQualifiedNames, boolean raw) {
|
||||
if (kind == TYPENAME) {
|
||||
return typeNameToStr(constants, fullyQualifiedNames);
|
||||
return typeNameToStr(constants, fullyQualifiedNames,raw);
|
||||
}
|
||||
if (name_index == -1) {
|
||||
return "";
|
||||
@@ -260,13 +262,13 @@ public class Multiname {
|
||||
} else {
|
||||
String name = constants.getString(name_index);
|
||||
if ((fullyQualifiedNames != null) && fullyQualifiedNames.contains(name)) {
|
||||
return getNameWithNamespace(constants);
|
||||
return getNameWithNamespace(constants,raw);
|
||||
}
|
||||
return (isAttribute() ? "@" : "") + name;
|
||||
return (isAttribute() ? "@" : "") + (raw?name:Deobfuscation.printIdentifier(name));
|
||||
}
|
||||
}
|
||||
|
||||
public String getNameWithNamespace(ConstantPool constants) {
|
||||
public String getNameWithNamespace(ConstantPool constants,boolean raw) {
|
||||
String ret = "";
|
||||
Namespace ns = getNamespace(constants);
|
||||
if (ns != null) {
|
||||
@@ -275,7 +277,7 @@ public class Multiname {
|
||||
ret += nsname + ".";
|
||||
}
|
||||
}
|
||||
ret += getName(constants, null);
|
||||
ret += getName(constants, null, raw);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
@@ -12,11 +12,13 @@
|
||||
* 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.types;
|
||||
|
||||
import com.jpexs.decompiler.flash.abc.ABC;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.ConstantPool;
|
||||
import com.jpexs.decompiler.flash.action.Deobfuscation;
|
||||
|
||||
public class Namespace {
|
||||
|
||||
@@ -99,7 +101,7 @@ public class Namespace {
|
||||
if (name_index == 0) {
|
||||
return null;
|
||||
}
|
||||
return constants.getString(name_index);
|
||||
return Deobfuscation.printNamespace(constants.getString(name_index));
|
||||
}
|
||||
|
||||
public boolean hasName(ConstantPool constants, String name) {
|
||||
|
||||
@@ -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.types;
|
||||
|
||||
import com.jpexs.decompiler.flash.abc.ABC;
|
||||
@@ -50,7 +51,7 @@ public class ScriptInfo {
|
||||
if ((ns.kind == Namespace.KIND_PACKAGE_INTERNAL)
|
||||
|| (ns.kind == Namespace.KIND_PACKAGE)) {
|
||||
String packageName = ns.getName(abc.constants); //assume not null package
|
||||
String objectName = name.getName(abc.constants, new ArrayList<String>());
|
||||
String objectName = name.getName(abc.constants, new ArrayList<String>(),false);
|
||||
List<Integer> traitIndices = new ArrayList<>();
|
||||
|
||||
traitIndices.add(j);
|
||||
|
||||
@@ -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.types.traits;
|
||||
|
||||
import com.jpexs.decompiler.flash.abc.ABC;
|
||||
@@ -174,7 +175,7 @@ public abstract class Trait implements Serializable {
|
||||
Multiname name = getName(abc);
|
||||
Namespace ns = name.getNamespace(abc.constants);
|
||||
String packageName = ns.getName(abc.constants);
|
||||
String objectName = name.getName(abc.constants, new ArrayList<String>());
|
||||
String objectName = name.getName(abc.constants, new ArrayList<String>(),false);
|
||||
return packageName + "." + objectName; //assume not null name
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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.types.traits;
|
||||
|
||||
import com.jpexs.decompiler.flash.abc.ABC;
|
||||
@@ -202,7 +203,7 @@ public class TraitClass extends Trait implements TraitWithSlot {
|
||||
return;
|
||||
}
|
||||
Namespace ns = m.getNamespace(abc.constants);
|
||||
String name = m.getName(abc.constants, fullyQualifiedNames);
|
||||
String name = m.getName(abc.constants, fullyQualifiedNames,false);
|
||||
NamespaceSet nss = m.getNamespaceSet(abc.constants);
|
||||
if (ns != null) {
|
||||
parseUsagesFromNS(abcTags, abc, imports, uses, m.namespace_index, ignorePackage, name);
|
||||
@@ -233,7 +234,7 @@ public class TraitClass extends Trait implements TraitWithSlot {
|
||||
return;
|
||||
}
|
||||
Namespace ns = m.getNamespace(abc.constants);
|
||||
String name = m.getName(abc.constants, fullyQualifiedNames);
|
||||
String name = m.getName(abc.constants, fullyQualifiedNames,false);
|
||||
NamespaceSet nss = m.getNamespaceSet(abc.constants);
|
||||
if (ns != null) {
|
||||
parseImportsUsagesFromNS(abcTags, abc, imports, uses, m.namespace_index, ignorePackage, name);
|
||||
@@ -458,7 +459,7 @@ public class TraitClass extends Trait implements TraitWithSlot {
|
||||
writer.newLine();
|
||||
writer.startTrait(abc.class_info.get(class_info).static_traits.traits.size() + abc.instance_info.get(class_info).instance_traits.traits.size() + 1);
|
||||
writer.appendNoHilight("{").newLine();
|
||||
abc.bodies.get(bodyIndex).toString(path +/*packageName +*/ "/" + abc.instance_info.get(class_info).getName(abc.constants).getName(abc.constants, fullyQualifiedNames) + ".staticinitializer", exportMode, abc, this, abc.constants, abc.method_info, writer, fullyQualifiedNames);
|
||||
abc.bodies.get(bodyIndex).toString(path +/*packageName +*/ "/" + abc.instance_info.get(class_info).getName(abc.constants).getName(abc.constants, fullyQualifiedNames,false) + ".staticinitializer", exportMode, abc, this, abc.constants, abc.method_info, writer, fullyQualifiedNames);
|
||||
writer.appendNoHilight("}").newLine();
|
||||
writer.endTrait();
|
||||
}
|
||||
@@ -487,7 +488,7 @@ public class TraitClass extends Trait implements TraitWithSlot {
|
||||
writer.startTrait(abc.class_info.get(class_info).static_traits.traits.size() + abc.instance_info.get(class_info).instance_traits.traits.size());
|
||||
writer.appendNoHilight(modifier);
|
||||
writer.appendNoHilight("function ");
|
||||
writer.appendNoHilight(abc.constants.getMultiname(abc.instance_info.get(class_info).name_index).getName(abc.constants, new ArrayList<String>()/*do not want full names here*/));
|
||||
writer.appendNoHilight(abc.constants.getMultiname(abc.instance_info.get(class_info).name_index).getName(abc.constants, new ArrayList<String>()/*do not want full names here*/,false));
|
||||
writer.appendNoHilight("(");
|
||||
bodyIndex = abc.findBodyIndex(abc.instance_info.get(class_info).iinit_index);
|
||||
if (bodyIndex != -1) {
|
||||
@@ -497,16 +498,16 @@ public class TraitClass extends Trait implements TraitWithSlot {
|
||||
}
|
||||
writer.appendNoHilight(")").startBlock();
|
||||
if (bodyIndex != -1) {
|
||||
abc.bodies.get(bodyIndex).toString(path +/*packageName +*/ "/" + abc.instance_info.get(class_info).getName(abc.constants).getName(abc.constants, fullyQualifiedNames) + ".initializer", exportMode, abc, this, abc.constants, abc.method_info, writer, fullyQualifiedNames);
|
||||
abc.bodies.get(bodyIndex).toString(path +/*packageName +*/ "/" + abc.instance_info.get(class_info).getName(abc.constants).getName(abc.constants, fullyQualifiedNames,false) + ".initializer", exportMode, abc, this, abc.constants, abc.method_info, writer, fullyQualifiedNames);
|
||||
}
|
||||
writer.endBlock().newLine();
|
||||
writer.endTrait();
|
||||
}
|
||||
|
||||
//static variables,constants & methods
|
||||
abc.class_info.get(class_info).static_traits.toString(this, path +/*packageName +*/ "/" + abc.instance_info.get(class_info).getName(abc.constants).getName(abc.constants, fullyQualifiedNames), abcTags, abc, true, exportMode, false, scriptIndex, class_info, writer, fullyQualifiedNames, parallel);
|
||||
abc.class_info.get(class_info).static_traits.toString(this, path +/*packageName +*/ "/" + abc.instance_info.get(class_info).getName(abc.constants).getName(abc.constants, fullyQualifiedNames,false), abcTags, abc, true, exportMode, false, scriptIndex, class_info, writer, fullyQualifiedNames, parallel);
|
||||
|
||||
abc.instance_info.get(class_info).instance_traits.toString(this, path +/*packageName +*/ "/" + abc.instance_info.get(class_info).getName(abc.constants).getName(abc.constants, fullyQualifiedNames), abcTags, abc, false, exportMode, false, scriptIndex, class_info, writer, fullyQualifiedNames, parallel);
|
||||
abc.instance_info.get(class_info).instance_traits.toString(this, path +/*packageName +*/ "/" + abc.instance_info.get(class_info).getName(abc.constants).getName(abc.constants, fullyQualifiedNames,false), abcTags, abc, false, exportMode, false, scriptIndex, class_info, writer, fullyQualifiedNames, parallel);
|
||||
|
||||
writer.endBlock(); // class
|
||||
writer.endClass();
|
||||
@@ -522,7 +523,7 @@ public class TraitClass extends Trait implements TraitWithSlot {
|
||||
int bodyIndex = abc.findBodyIndex(abc.class_info.get(class_info).cinit_index);
|
||||
if (bodyIndex != -1) {
|
||||
writer.mark();
|
||||
abc.bodies.get(bodyIndex).convert(path +/*packageName +*/ "/" + abc.instance_info.get(class_info).getName(abc.constants).getName(abc.constants, fullyQualifiedNames) + ".staticinitializer", exportMode, true, scriptIndex, class_info, abc, this, abc.constants, abc.method_info, new ScopeStack(), true, writer, fullyQualifiedNames, abc.class_info.get(class_info).static_traits, true);
|
||||
abc.bodies.get(bodyIndex).convert(path +/*packageName +*/ "/" + abc.instance_info.get(class_info).getName(abc.constants).getName(abc.constants, fullyQualifiedNames,false) + ".staticinitializer", exportMode, true, scriptIndex, class_info, abc, this, abc.constants, abc.method_info, new ScopeStack(), true, writer, fullyQualifiedNames, abc.class_info.get(class_info).static_traits, true);
|
||||
classInitializerIsEmpty = !writer.getMark();
|
||||
}
|
||||
|
||||
@@ -530,14 +531,14 @@ public class TraitClass extends Trait implements TraitWithSlot {
|
||||
if (!abc.instance_info.get(class_info).isInterface()) {
|
||||
bodyIndex = abc.findBodyIndex(abc.instance_info.get(class_info).iinit_index);
|
||||
if (bodyIndex != -1) {
|
||||
abc.bodies.get(bodyIndex).convert(path +/*packageName +*/ "/" + abc.instance_info.get(class_info).getName(abc.constants).getName(abc.constants, fullyQualifiedNames) + ".initializer", exportMode, false, scriptIndex, class_info, abc, this, abc.constants, abc.method_info, new ScopeStack(), false, writer, fullyQualifiedNames, abc.instance_info.get(class_info).instance_traits, true);
|
||||
abc.bodies.get(bodyIndex).convert(path +/*packageName +*/ "/" + abc.instance_info.get(class_info).getName(abc.constants).getName(abc.constants, fullyQualifiedNames,false) + ".initializer", exportMode, false, scriptIndex, class_info, abc, this, abc.constants, abc.method_info, new ScopeStack(), false, writer, fullyQualifiedNames, abc.instance_info.get(class_info).instance_traits, true);
|
||||
}
|
||||
}
|
||||
|
||||
//static variables,constants & methods
|
||||
abc.class_info.get(class_info).static_traits.convert(this, path +/*packageName +*/ "/" + abc.instance_info.get(class_info).getName(abc.constants).getName(abc.constants, fullyQualifiedNames), abcTags, abc, true, exportMode, false, scriptIndex, class_info, writer, fullyQualifiedNames, parallel);
|
||||
abc.class_info.get(class_info).static_traits.convert(this, path +/*packageName +*/ "/" + abc.instance_info.get(class_info).getName(abc.constants).getName(abc.constants, fullyQualifiedNames,false), abcTags, abc, true, exportMode, false, scriptIndex, class_info, writer, fullyQualifiedNames, parallel);
|
||||
|
||||
abc.instance_info.get(class_info).instance_traits.convert(this, path +/*packageName +*/ "/" + abc.instance_info.get(class_info).getName(abc.constants).getName(abc.constants, fullyQualifiedNames), abcTags, abc, false, exportMode, false, scriptIndex, class_info, writer, fullyQualifiedNames, parallel);
|
||||
abc.instance_info.get(class_info).instance_traits.convert(this, path +/*packageName +*/ "/" + abc.instance_info.get(class_info).getName(abc.constants).getName(abc.constants, fullyQualifiedNames,false), abcTags, abc, false, exportMode, false, scriptIndex, class_info, writer, fullyQualifiedNames, parallel);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -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.types.traits;
|
||||
|
||||
import com.jpexs.decompiler.flash.abc.ABC;
|
||||
@@ -58,7 +59,7 @@ public class TraitFunction extends Trait implements TraitWithSlot {
|
||||
}
|
||||
writer.appendNoHilight(modifier);
|
||||
writer.hilightSpecial("function ", "traittype");
|
||||
writer.hilightSpecial(abc.constants.getMultiname(name_index).getName(abc.constants, fullyQualifiedNames), "traitname");
|
||||
writer.hilightSpecial(abc.constants.getMultiname(name_index).getName(abc.constants, fullyQualifiedNames,false), "traitname");
|
||||
writer.appendNoHilight("(");
|
||||
abc.method_info.get(method_info).getParamStr(writer, abc.constants, body, abc, fullyQualifiedNames);
|
||||
writer.appendNoHilight(") : ");
|
||||
@@ -79,7 +80,7 @@ public class TraitFunction extends Trait implements TraitWithSlot {
|
||||
writer.appendNoHilight(" {").newLine();
|
||||
int bodyIndex = abc.findBodyIndex(method_info);
|
||||
if (bodyIndex != -1) {
|
||||
abc.bodies.get(bodyIndex).toString(path + "." + abc.constants.getMultiname(name_index).getName(abc.constants, fullyQualifiedNames), exportMode, abc, this, abc.constants, abc.method_info, writer, fullyQualifiedNames);
|
||||
abc.bodies.get(bodyIndex).toString(path + "." + abc.constants.getMultiname(name_index).getName(abc.constants, fullyQualifiedNames,false), exportMode, abc, this, abc.constants, abc.method_info, writer, fullyQualifiedNames);
|
||||
}
|
||||
writer.newLine();
|
||||
writer.appendNoHilight("}");
|
||||
@@ -94,7 +95,7 @@ public class TraitFunction extends Trait implements TraitWithSlot {
|
||||
if (!abc.instance_info.get(classIndex).isInterface()) {
|
||||
int bodyIndex = abc.findBodyIndex(method_info);
|
||||
if (bodyIndex != -1) {
|
||||
abc.bodies.get(bodyIndex).convert(path + "." + abc.constants.getMultiname(name_index).getName(abc.constants, fullyQualifiedNames), exportMode, isStatic, scriptIndex, classIndex, abc, this, abc.constants, abc.method_info, new ScopeStack(), false, writer, fullyQualifiedNames, null, true);
|
||||
abc.bodies.get(bodyIndex).convert(path + "." + abc.constants.getMultiname(name_index).getName(abc.constants, fullyQualifiedNames,false), exportMode, isStatic, scriptIndex, classIndex, abc, this, abc.constants, abc.method_info, new ScopeStack(), false, writer, fullyQualifiedNames, null, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+6
-4
@@ -12,11 +12,13 @@
|
||||
* 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.types.traits;
|
||||
|
||||
import com.jpexs.decompiler.flash.abc.ABC;
|
||||
import com.jpexs.decompiler.flash.abc.types.MethodBody;
|
||||
import com.jpexs.decompiler.flash.action.Deobfuscation;
|
||||
import com.jpexs.decompiler.flash.exporters.modes.ScriptExportMode;
|
||||
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
|
||||
import com.jpexs.decompiler.flash.helpers.NulWriter;
|
||||
@@ -66,7 +68,7 @@ public class TraitMethodGetterSetter extends Trait {
|
||||
|
||||
writer.appendNoHilight(modifier);
|
||||
writer.hilightSpecial("function " + addKind, "traittype");
|
||||
writer.hilightSpecial(getName(abc).getName(abc.constants, fullyQualifiedNames), "traitname");
|
||||
writer.hilightSpecial(getName(abc).getName(abc.constants, fullyQualifiedNames,false), "traitname");
|
||||
writer.appendNoHilight("(");
|
||||
abc.method_info.get(method_info).getParamStr(writer, abc.constants, body, abc, fullyQualifiedNames);
|
||||
writer.appendNoHilight(") : ");
|
||||
@@ -76,7 +78,7 @@ public class TraitMethodGetterSetter extends Trait {
|
||||
|
||||
@Override
|
||||
public void convert(Trait parent, String path, List<ABCContainerTag> abcTags, ABC abc, boolean isStatic, ScriptExportMode exportMode, int scriptIndex, int classIndex, NulWriter writer, List<String> fullyQualifiedNames, boolean parallel) throws InterruptedException {
|
||||
path = path + "." + getName(abc).getName(abc.constants, fullyQualifiedNames);
|
||||
path = path + "." + getName(abc).getName(abc.constants, fullyQualifiedNames,false);
|
||||
convertHeader(parent, path, abcTags, abc, isStatic, exportMode, scriptIndex, classIndex, writer, fullyQualifiedNames, parallel);
|
||||
int bodyIndex = abc.findBodyIndex(method_info);
|
||||
if (!(classIndex != -1 && abc.instance_info.get(classIndex).isInterface() || bodyIndex == -1)) {
|
||||
@@ -88,7 +90,7 @@ public class TraitMethodGetterSetter extends Trait {
|
||||
|
||||
@Override
|
||||
public GraphTextWriter toString(Trait parent, String path, List<ABCContainerTag> abcTags, ABC abc, boolean isStatic, ScriptExportMode exportMode, int scriptIndex, int classIndex, GraphTextWriter writer, List<String> fullyQualifiedNames, boolean parallel) throws InterruptedException {
|
||||
path = path + "." + getName(abc).getName(abc.constants, fullyQualifiedNames);
|
||||
path = path + "." + getName(abc).getName(abc.constants, fullyQualifiedNames,false);
|
||||
toStringHeader(parent, path, abcTags, abc, isStatic, exportMode, scriptIndex, classIndex, writer, fullyQualifiedNames, parallel);
|
||||
int bodyIndex = abc.findBodyIndex(method_info);
|
||||
if (classIndex != -1 && abc.instance_info.get(classIndex).isInterface() || bodyIndex == -1) {
|
||||
|
||||
+4
-3
@@ -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.types.traits;
|
||||
|
||||
import com.jpexs.decompiler.flash.abc.ABC;
|
||||
@@ -60,7 +61,7 @@ public class TraitSlotConst extends Trait implements TraitWithSlot {
|
||||
public String getType(ConstantPool constants, List<String> fullyQualifiedNames) {
|
||||
String typeStr = "*";
|
||||
if (type_index > 0) {
|
||||
typeStr = constants.getMultiname(type_index).getName(constants, fullyQualifiedNames);
|
||||
typeStr = constants.getMultiname(type_index).getName(constants, fullyQualifiedNames, false);
|
||||
}
|
||||
return typeStr;
|
||||
}
|
||||
@@ -85,7 +86,7 @@ public class TraitSlotConst extends Trait implements TraitWithSlot {
|
||||
slotconst = "namespace";
|
||||
}
|
||||
writer.hilightSpecial(slotconst + " ", "traittype");
|
||||
writer.hilightSpecial(getName(abc).getName(abc.constants, fullyQualifiedNames), "traitname");
|
||||
writer.hilightSpecial(getName(abc).getName(abc.constants, fullyQualifiedNames, false), "traitname");
|
||||
writer.hilightSpecial(typeStr, "traittypename");
|
||||
return writer;
|
||||
}
|
||||
|
||||
+3
-2
@@ -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;
|
||||
@@ -31,6 +32,6 @@ public class ClassNameMultinameUsage extends InsideClassMultinameUsage implement
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "class " + abc.constants.getMultiname(abc.instance_info.get(classIndex).name_index).getNameWithNamespace(abc.constants);
|
||||
return "class " + abc.constants.getMultiname(abc.instance_info.get(classIndex).name_index).getNameWithNamespace(abc.constants,false);
|
||||
}
|
||||
}
|
||||
|
||||
+3
-2
@@ -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;
|
||||
@@ -36,7 +37,7 @@ public abstract class InsideClassMultinameUsage extends MultinameUsage {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "class " + abc.constants.getMultiname(abc.instance_info.get(classIndex).name_index).getNameWithNamespace(abc.constants);
|
||||
return "class " + abc.constants.getMultiname(abc.instance_info.get(classIndex).name_index).getNameWithNamespace(abc.constants,false);
|
||||
}
|
||||
|
||||
public int getMultinameIndex() {
|
||||
|
||||
@@ -20,6 +20,7 @@ import com.jpexs.decompiler.flash.abc.RenameType;
|
||||
import com.jpexs.decompiler.flash.tags.DefineSpriteTag;
|
||||
import com.jpexs.decompiler.flash.tags.Tag;
|
||||
import com.jpexs.decompiler.flash.tags.base.PlaceObjectTypeTag;
|
||||
import com.jpexs.helpers.Cache;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
@@ -174,7 +175,7 @@ public class Deobfuscation {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
public static boolean isValidName(String s,String ...exceptions) {
|
||||
boolean isValid = true;
|
||||
|
||||
@@ -250,9 +251,59 @@ public class Deobfuscation {
|
||||
}
|
||||
|
||||
public static String makeObfuscatedIdentifier(String s){
|
||||
return "§"+escapeOIdentifier(s)+"§";
|
||||
return "\u00A7"+escapeOIdentifier(s)+"\u00A7";
|
||||
}
|
||||
|
||||
|
||||
private static Cache<String> nameCache = Cache.getInstance(false);
|
||||
|
||||
/**
|
||||
* Ensures identifier is valid and if not, uses paragraph syntax
|
||||
* @param s Identifier
|
||||
* @param validExceptions Exceptions which are valid (e.g. some reserved words)
|
||||
* @return
|
||||
*/
|
||||
public static String printIdentifier(String s,String ...validExceptions){
|
||||
if(s.startsWith("\u00A7")&&s.endsWith("\u00A7")){ //Assuming already printed - TODO:detect better
|
||||
return s;
|
||||
}
|
||||
if(nameCache.contains(s)){
|
||||
return nameCache.get(s);
|
||||
}
|
||||
if(isValidName(s, validExceptions)){
|
||||
nameCache.put(s, s);
|
||||
return s;
|
||||
}
|
||||
String ret = makeObfuscatedIdentifier(s);
|
||||
nameCache.put(s, ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static String printNamespace(String pkg,String ...validNameExceptions){
|
||||
if(nameCache.contains(pkg)){
|
||||
return nameCache.get(pkg);
|
||||
}
|
||||
if(pkg.equals("")){
|
||||
nameCache.put(pkg, pkg);
|
||||
return pkg;
|
||||
}
|
||||
String[] parts = null;
|
||||
if (pkg.contains(".")) {
|
||||
parts = pkg.split("\\.");
|
||||
} else {
|
||||
parts = new String[]{pkg};
|
||||
}
|
||||
String ret="";
|
||||
for(int i=0;i<parts.length;i++){
|
||||
if(i>0){
|
||||
ret+=".";
|
||||
}
|
||||
ret += printIdentifier(parts[i], validNameExceptions);
|
||||
}
|
||||
nameCache.put(pkg, ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
public static String escapeOIdentifier(String s) {
|
||||
StringBuilder ret = new StringBuilder(s.length());
|
||||
@@ -273,7 +324,7 @@ public class Deobfuscation {
|
||||
} else if (c == '\\') {
|
||||
ret.append("\\\\");
|
||||
} else if (c == '\u00A7') {
|
||||
ret.append("\\\\u00A7");
|
||||
ret.append("\\\u00A7");
|
||||
} else {
|
||||
ret.append(c);
|
||||
}
|
||||
|
||||
@@ -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.helpers;
|
||||
|
||||
import java.io.File;
|
||||
@@ -89,14 +90,14 @@ public class Cache<E> {
|
||||
}
|
||||
|
||||
public boolean contains(Object key) {
|
||||
if (storageType == STORAGE_FILES) {
|
||||
if (storageType == STORAGE_FILES) {
|
||||
return cacheFiles.containsKey(key);
|
||||
} else if (storageType == STORAGE_MEMORY) {
|
||||
return cacheMemory.containsKey(key);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
public void clear() {
|
||||
cacheMemory.clear();
|
||||
for (File f : cacheFiles.values()) {
|
||||
|
||||
Reference in New Issue
Block a user