From 12ab8af322eace262bb2e9d79dd52c3e67d314db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jindra=20Pet=C5=99=C3=ADk?= Date: Fri, 25 Jul 2025 10:49:33 +0200 Subject: [PATCH] WIP Safe strings handling --- .../flash/IdentifiersDeobfuscation.java | 9 +- .../src/com/jpexs/decompiler/flash/SWF.java | 54 ++++++--- .../com/jpexs/decompiler/flash/abc/ABC.java | 107 ++++++++++++++++-- .../jpexs/decompiler/flash/abc/ClassPath.java | 12 +- .../decompiler/flash/abc/ScriptPack.java | 8 +- .../decompiler/flash/abc/avm2/AVM2Code.java | 33 +++--- .../flash/abc/avm2/AVM2ConstantPool.java | 17 ++- .../flash/abc/avm2/AVM2Deobfuscation.java | 69 +++++++---- .../flash/abc/avm2/graph/AVM2Graph.java | 6 +- .../instructions/InstructionDefinition.java | 2 +- .../construction/ConstructIns.java | 4 +- .../construction/NewClassIns.java | 2 +- .../localregs/GetLocalTypeIns.java | 2 +- .../instructions/other/GetGlobalSlotIns.java | 2 +- .../avm2/instructions/other/GetLexIns.java | 12 +- .../instructions/other/GetPropertyIns.java | 10 +- .../avm2/instructions/other/GetSlotIns.java | 2 +- .../avm2/instructions/other/SetSlotIns.java | 4 +- .../other/decimalsupport/ConvertMIns.java | 4 +- .../other/decimalsupport/ConvertMPIns.java | 4 +- .../other/deprecated/CoerceBIns.java | 2 +- .../other/deprecated/CoerceDIns.java | 2 +- .../other/deprecated/CoerceIIns.java | 2 +- .../other/deprecated/CoerceUIns.java | 2 +- .../other/floatsupport/ConvertF4Ins.java | 4 +- .../other/floatsupport/ConvertFIns.java | 4 +- .../avm2/instructions/types/AsTypeIns.java | 2 +- .../avm2/instructions/types/CoerceAIns.java | 4 +- .../avm2/instructions/types/CoerceIns.java | 6 +- .../avm2/instructions/types/CoerceOIns.java | 2 +- .../types/CoerceOrConvertTypeIns.java | 4 +- .../avm2/instructions/types/CoerceSIns.java | 4 +- .../avm2/instructions/types/ConvertBIns.java | 4 +- .../avm2/instructions/types/ConvertDIns.java | 4 +- .../avm2/instructions/types/ConvertIIns.java | 4 +- .../avm2/instructions/types/ConvertOIns.java | 4 +- .../avm2/instructions/types/ConvertSIns.java | 4 +- .../avm2/instructions/types/ConvertUIns.java | 4 +- .../avm2/instructions/types/IsTypeIns.java | 2 +- .../flash/abc/avm2/model/AVM2Item.java | 6 +- .../flash/abc/avm2/model/ClassAVM2Item.java | 6 +- .../abc/avm2/model/DecLocalAVM2Item.java | 2 +- .../flash/abc/avm2/model/FindDefAVM2Item.java | 2 +- .../abc/avm2/model/FullMultinameAVM2Item.java | 8 +- .../flash/abc/avm2/model/GetLexAVM2Item.java | 8 +- .../flash/abc/avm2/model/GetSlotAVM2Item.java | 2 +- .../abc/avm2/model/IncLocalAVM2Item.java | 2 +- .../abc/avm2/model/LocalRegAVM2Item.java | 2 +- .../abc/avm2/model/NameSpaceAVM2Item.java | 2 +- .../abc/avm2/model/NewFunctionAVM2Item.java | 2 +- .../flash/abc/avm2/model/PackageAVM2Item.java | 2 +- .../abc/avm2/model/SetLocalAVM2Item.java | 2 +- .../flash/abc/avm2/model/SetSlotAVM2Item.java | 2 +- .../flash/abc/avm2/model/ThisAVM2Item.java | 4 +- .../model/clauses/DeclarationAVM2Item.java | 6 +- .../avm2/model/clauses/ExceptionAVM2Item.java | 2 +- .../abc/avm2/model/clauses/TryAVM2Item.java | 6 +- .../parser/script/AVM2SourceGenerator.java | 28 ++--- .../abc/avm2/parser/script/AbcIndexing.java | 43 +++---- .../abc/avm2/parser/script/CallAVM2Item.java | 2 +- .../abc/avm2/parser/script/NameAVM2Item.java | 2 +- .../avm2/parser/script/PropertyAVM2Item.java | 4 +- .../parser/script/UnresolvedAVM2Item.java | 4 +- .../flash/abc/types/ABCException.java | 21 ++-- .../flash/abc/types/InstanceInfo.java | 16 +-- .../flash/abc/types/MethodBody.java | 2 +- .../flash/abc/types/MethodInfo.java | 16 +-- .../decompiler/flash/abc/types/Multiname.java | 47 ++++---- .../decompiler/flash/abc/types/Namespace.java | 7 +- .../flash/abc/types/ScriptInfo.java | 14 +-- .../flash/abc/types/traits/Trait.java | 32 +++--- .../flash/abc/types/traits/TraitClass.java | 20 ++-- .../flash/abc/types/traits/TraitFunction.java | 12 +- .../types/traits/TraitMethodGetterSetter.java | 18 +-- .../abc/types/traits/TraitSlotConst.java | 13 ++- .../flash/abc/types/traits/Traits.java | 2 +- .../multinames/ClassNameMultinameUsage.java | 2 +- .../abc/usages/multinames/MultinameUsage.java | 4 +- .../multinames/SuperClassMultinameUsage.java | 2 +- .../SuperInterfaceMultinameUsage.java | 2 +- .../multinames/TraitMultinameUsage.java | 4 +- .../flash/action/StoreTypeAction.java | 4 +- .../as2/UninitializedClassFieldsDetector.java | 2 +- .../action/model/DirectValueActionItem.java | 6 +- .../action/model/GetMemberActionItem.java | 2 +- .../action/model/GetVariableActionItem.java | 2 +- .../action/model/InitObjectActionItem.java | 2 +- .../action/model/NewObjectActionItem.java | 2 +- .../action/model/SetVariableActionItem.java | 2 +- .../action/model/StoreRegisterActionItem.java | 2 +- .../action/model/clauses/ClassActionItem.java | 2 +- .../parser/script/ActionScript2Parser.java | 7 +- .../flash/action/swf4/ActionSetVariable.java | 5 +- .../action/swf5/ActionStoreRegister.java | 3 +- .../flash/configuration/Configuration.java | 4 + .../exporters/script/AS3ScriptExporter.java | 10 +- .../exporters/script/DependencyParser.java | 6 +- .../exporters/script/LinkReportExporter.java | 2 +- .../flash/flexsdk/MxmlcAs3ScriptReplacer.java | 4 +- .../flash/search/ABCSearchResult.java | 4 +- .../flash/tags/DefineEditTextTag.java | 4 +- .../flash/tags/DoInitActionTag.java | 2 +- .../flash/tags/ExportAssetsTag.java | 2 +- .../flash/tags/ImportAssets2Tag.java | 2 +- .../flash/tags/ImportAssetsTag.java | 2 +- .../flash/tags/PlaceObject2Tag.java | 2 +- .../flash/tags/PlaceObject3Tag.java | 2 +- .../flash/tags/PlaceObject4Tag.java | 2 +- .../flash/tags/base/CharacterTag.java | 4 +- .../flash/tags/base/PlaceObjectTypeTag.java | 2 +- .../decompiler/flash/tags/base/RemoveTag.java | 2 +- .../decompiler/flash/timeline/AS2Package.java | 2 +- .../decompiler/flash/timeline/AS3Package.java | 2 +- .../flash/treeitems/AS3ClassTreeItem.java | 14 ++- .../decompiler/flash/xfl/XFLConverter.java | 16 +-- .../jpexs/decompiler/graph/DottedChain.java | 19 ++-- .../com/jpexs/decompiler/graph/TypeItem.java | 4 +- .../decompiler/graph/model/LocalData.java | 12 +- .../src/com/jpexs/helpers/Helper.java | 6 +- .../flash/generators/AS3Generator.java | 2 +- .../console/CommandLineArgumentParser.java | 4 +- .../flash/easygui/LibraryTreeTable.java | 4 +- .../decompiler/flash/gui/DebuggerHandler.java | 2 +- .../decompiler/flash/gui/FolderListPanel.java | 4 +- .../flash/gui/GenericTagTreePanel.java | 26 +++-- .../jpexs/decompiler/flash/gui/MainPanel.java | 4 +- .../flash/gui/abc/ABCExplorerDialog.java | 18 +-- .../decompiler/flash/gui/abc/ABCPanel.java | 12 +- .../flash/gui/abc/ClassesListTreeModel.java | 2 +- .../flash/gui/abc/DecompiledEditorPane.java | 12 +- .../decompiler/flash/gui/abc/DetailPanel.java | 2 +- .../flash/gui/abc/TraitsListItem.java | 4 +- .../decompiler/flash/gui/abc/UsageFrame.java | 8 +- .../abc/tablemodels/MultinameTableModel.java | 2 +- .../flash/gui/debugger/DebuggerTools.java | 12 +- .../gui/generictageditors/StringEditor.java | 11 +- .../locales/AdvancedSettingsDialog.properties | 5 +- .../decompiler/flash/gui/tagtree/TagTree.java | 4 +- .../flash/gui/tagtree/TagTreeContextMenu.java | 18 +-- 139 files changed, 679 insertions(+), 459 deletions(-) diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/IdentifiersDeobfuscation.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/IdentifiersDeobfuscation.java index 0cc7a8691..08af9b616 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/IdentifiersDeobfuscation.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/IdentifiersDeobfuscation.java @@ -545,10 +545,17 @@ public class IdentifiersDeobfuscation { * words) * @return Printable identifier */ - public static String printIdentifier(boolean as3, String s, String... validExceptions) { + public static String printIdentifier(SWF swf, boolean as3, String s, String... validExceptions) { if (s == null || s.isEmpty()) { return ""; } + + if (Configuration.useSafeStr.get() && as3) { + Map map = swf.getAs3ObfuscatedIdentifiers(); + if (map.containsKey(s)) { + return map.get(s); + } + } if (s.startsWith("\u00A7") && s.endsWith("\u00A7")) { // Assuming already printed - TODO:detect better return s; diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/SWF.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/SWF.java index cd2e26b35..9867fee50 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/SWF.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/SWF.java @@ -190,12 +190,10 @@ import java.awt.geom.AffineTransform; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.File; -import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; -import java.nio.charset.Charset; import java.security.InvalidAlgorithmParameterException; import java.security.InvalidKeyException; import java.security.NoSuchAlgorithmException; @@ -670,6 +668,11 @@ public final class SWF implements SWFContainerItem, Timelined, Openable { * Event listeners */ private final HashSet listeners = new HashSet<>(); + + /** + * AS3 obfuscated identifiers map + */ + private transient Map as3ObfuscatedIdentifiersMap = null; /** * Lock for characters synchronization @@ -3364,7 +3367,7 @@ public final class SWF implements SWFContainerItem, Timelined, Openable { } return String.join(File.separator, parts); } - return DottedChain.parseNoSuffix(pkg.getName()).toPrintableString(false); + return DottedChain.parseNoSuffix(pkg.getName()).toPrintableString(this, false); } } @@ -3375,7 +3378,7 @@ public final class SWF implements SWFContainerItem, Timelined, Openable { String expName = tag.getSwf().getExportName(tag.getCharacterId()); if (expName != null && !expName.isEmpty()) { String[] pathParts = expName.contains(".") ? expName.split("\\.") : new String[]{expName}; - return IdentifiersDeobfuscation.printIdentifier(false, pathParts[pathParts.length - 1]); + return IdentifiersDeobfuscation.printIdentifier(this, false, pathParts[pathParts.length - 1]); } } @@ -3704,7 +3707,7 @@ public final class SWF implements SWFContainerItem, Timelined, Openable { * @param path Path * @throws InterruptedException On interrupt */ - private static void getVariables(ConstantPool constantPool, BaseLocalData localData, TranslateStack stack, List output, ActionGraphSource code, int ip, List> variables, List functions, HashMap strings, List visited, HashMap usageTypes, String path) throws InterruptedException { + private static void getVariables(SWF swf, ConstantPool constantPool, BaseLocalData localData, TranslateStack stack, List output, ActionGraphSource code, int ip, List> variables, List functions, HashMap strings, List visited, HashMap usageTypes, String path) throws InterruptedException { ActionLocalData aLocalData = (ActionLocalData) localData; boolean debugMode = false; while ((ip > -1) && ip < code.size()) { @@ -3714,7 +3717,7 @@ public final class SWF implements SWFContainerItem, Timelined, Openable { GraphSourceItem ins = code.get(ip); if (debugMode) { - System.err.println("Visit " + ip + ": ofs" + Helper.formatAddress(((Action) ins).getAddress()) + ":" + ((Action) ins).getASMSource(new ActionList(code.getCharset()), new HashSet<>(), ScriptExportMode.PCODE) + " stack:" + Helper.stackToString(stack, LocalData.create(new ConstantPool()))); + System.err.println("Visit " + ip + ": ofs" + Helper.formatAddress(((Action) ins).getAddress()) + ":" + ((Action) ins).getASMSource(new ActionList(code.getCharset()), new HashSet<>(), ScriptExportMode.PCODE) + " stack:" + Helper.stackToString(stack, LocalData.create(new ConstantPool(), swf))); } if (ins.isExit()) { break; @@ -3772,7 +3775,7 @@ public final class SWF implements SWFContainerItem, Timelined, Openable { ip = code.adr2pos(addr); addr += size; int nextip = code.adr2pos(addr); - getVariables(aLocalData.insideDoInitAction, variables, functions, strings, usageTypes, new ActionGraphSource(path, aLocalData.insideDoInitAction, code.getActions().subList(0, nextip), code.version, new HashMap<>(), new HashMap<>(), new HashMap<>(), code.getCharset(), ip), 0, path + (cntName == null ? "" : "/" + cntName)); + getVariables(swf, aLocalData.insideDoInitAction, variables, functions, strings, usageTypes, new ActionGraphSource(path, aLocalData.insideDoInitAction, code.getActions().subList(0, nextip), code.version, new HashMap<>(), new HashMap<>(), new HashMap<>(), code.getCharset(), ip), 0, path + (cntName == null ? "" : "/" + cntName)); ip = nextip; } List> r = new ArrayList<>(); @@ -3851,7 +3854,7 @@ public final class SWF implements SWFContainerItem, Timelined, Openable { for (int b : branches) { TranslateStack brStack = (TranslateStack) stack.clone(); if (b >= 0) { - getVariables(constantPool, localData, brStack, output, code, b, variables, functions, strings, visited, usageTypes, path); + getVariables(swf, constantPool, localData, brStack, output, code, b, variables, functions, strings, visited, usageTypes, path); } else if (debugMode) { System.out.println("Negative branch:" + b); } @@ -3866,6 +3869,7 @@ public final class SWF implements SWFContainerItem, Timelined, Openable { /** * Gets variables from AS1/2 code. * + * @param swf SWF * @param insideDoInitAction Is inside DoInitAction * @param variables Variables * @param functions Functions @@ -3876,9 +3880,9 @@ public final class SWF implements SWFContainerItem, Timelined, Openable { * @param path Path * @throws InterruptedException On interrupt */ - private static void getVariables(boolean insideDoInitAction, List> variables, List functions, HashMap strings, HashMap usageTypes, ActionGraphSource code, int addr, String path) throws InterruptedException { + private static void getVariables(SWF swf, boolean insideDoInitAction, List> variables, List functions, HashMap strings, HashMap usageTypes, ActionGraphSource code, int addr, String path) throws InterruptedException { ActionLocalData localData = new ActionLocalData(null, insideDoInitAction, new HashMap<>() /*??*/); - getVariables(null, localData, new TranslateStack(path), new ArrayList<>(), code, code.adr2pos(addr), variables, functions, strings, new ArrayList<>(), usageTypes, path); + getVariables(swf, null, localData, new TranslateStack(path), new ArrayList<>(), code, code.adr2pos(addr), variables, functions, strings, new ArrayList<>(), usageTypes, path); } /** @@ -3900,7 +3904,7 @@ public final class SWF implements SWFContainerItem, Timelined, Openable { ActionList actions = src.getActions(); actionsMap.put(src, actions); boolean insideDoInitAction = src instanceof DoInitActionTag; - getVariables(insideDoInitAction, variables, functions, strings, usageTypes, new ActionGraphSource(path, insideDoInitAction, actions, version, new HashMap<>(), new HashMap<>(), new HashMap<>(), src.getSwf().getCharset(), 0), 0, path); + getVariables(this, insideDoInitAction, variables, functions, strings, usageTypes, new ActionGraphSource(path, insideDoInitAction, actions, version, new HashMap<>(), new HashMap<>(), new HashMap<>(), src.getSwf().getCharset(), 0), 0, path); return ret; } @@ -3997,6 +4001,24 @@ public final class SWF implements SWFContainerItem, Timelined, Openable { } } + /** + * Gets all AS3 obfuscated identifiers in this SWF and their suggested SafeStr replacement + * @return Map source identifier to SafeStr replacement + */ + public synchronized Map getAs3ObfuscatedIdentifiers() { + if (as3ObfuscatedIdentifiersMap != null) { + return as3ObfuscatedIdentifiersMap; + } + Map ret = new LinkedHashMap<>(); + for (Tag tag : getTags()) { + if (tag instanceof ABCContainerTag) { + ABCContainerTag abcTag = (ABCContainerTag) tag; + abcTag.getABC().getObfuscatedIdentifiers(ret); + } + } + return as3ObfuscatedIdentifiersMap = ret; + } + /** * Deobfuscates AS3 identifiers. * @@ -4512,6 +4534,10 @@ public final class SWF implements SWFContainerItem, Timelined, Openable { asmsCache = null; asmsCacheExportFilenames = null; + synchronized (this) { + as3ObfuscatedIdentifiersMap = null; + } + IdentifiersDeobfuscation.clearCache(); } @@ -5956,10 +5982,10 @@ public final class SWF implements SWFContainerItem, Timelined, Openable { if (firstTrait instanceof TraitClass) { int cindex = ((TraitClass) firstTrait).class_info; Multiname superName = documentPack.abc.constants.getMultiname(documentPack.abc.instance_info.get(cindex).super_index); - String parentClass = superName.getNameWithNamespace(documentPack.abc.constants, true).toRawString(); + String parentClass = superName.getNameWithNamespace(documentPack.abc, documentPack.abc.constants, true).toRawString(); if ("mx.managers.SystemManager".equals(parentClass)) { for (Trait t : documentPack.abc.instance_info.get(cindex).instance_traits.traits) { - if ((t instanceof TraitMethodGetterSetter) && "info".equals(t.getName(documentPack.abc).getName(documentPack.abc.constants, new ArrayList<>(), true, true))) { + if ((t instanceof TraitMethodGetterSetter) && "info".equals(t.getName(documentPack.abc).getName(documentPack.abc, documentPack.abc.constants, new ArrayList<>(), true, true))) { int mi = ((TraitMethodGetterSetter) t).method_info; try { @@ -6053,7 +6079,7 @@ public final class SWF implements SWFContainerItem, Timelined, Openable { if (cit instanceof SetPropertyAVM2Item) { if (cit.value instanceof GetLexAVM2Item) { GetLexAVM2Item gl = (GetLexAVM2Item) cit.value; - ignoredClasses.add(gl.propertyName.getNameWithNamespace(p.abc.constants, true).toRawString()); + ignoredClasses.add(gl.propertyName.getNameWithNamespace(p.abc, p.abc.constants, true).toRawString()); } } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/ABC.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/ABC.java index b9deb7480..7d6d7f5ce 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/ABC.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/ABC.java @@ -639,6 +639,89 @@ public class ABC implements Openable { } } + + + + private void getObfuscatedIdentifier(int strIndex, Map ret) { + if (strIndex >= constants.getStringCount()) { + return; + } + if (strIndex <= 0) { + return; + } + String s = constants.getString(strIndex); + if (ret.containsKey(s)) { + return; + } + AVM2Deobfuscation deobfuscation = getDeobfuscation(); + if (deobfuscation.isValidName(strIndex)) { + return; + } + + ret.put(s, AVM2Deobfuscation.SAFE_STR_PREFIX + ret.size()); + } + + private void getObfuscatedPackageIdentifier(int strIndex, Map ret) { + if (strIndex >= constants.getStringCount()) { + return; + } + if (strIndex <= 0) { + return; + } + String s = constants.getString(strIndex); + if (ret.containsKey(s)) { + return; + } + AVM2Deobfuscation deobfuscation = getDeobfuscation(); + if (deobfuscation.isValidPackageName(strIndex)) { + return; + } + String[] parts = s.split("\\.", -1); + List deobfuscatedList = new ArrayList<>(); + for (String part : parts) { + if (!deobfuscation.isValidNSPart(part)) { + deobfuscatedList.add(AVM2Deobfuscation.SAFE_STR_PREFIX + ret.size()); + ret.put(part, AVM2Deobfuscation.SAFE_STR_PREFIX + ret.size()); + } else { + deobfuscatedList.add(part); + } + } + ret.put(s, String.join(".", deobfuscatedList)); + } + + public void getObfuscatedIdentifiers(Map ret) { + for (int i = 0; i < instance_info.size(); i++) { + InstanceInfo insti = instance_info.get(i); + if (insti.name_index != 0) { + getObfuscatedIdentifier(constants.getMultiname(insti.name_index).name_index, ret); + if (constants.getMultiname(insti.name_index).namespace_index != 0) { + getObfuscatedPackageIdentifier( constants.getNamespace(constants.getMultiname(insti.name_index).namespace_index).name_index, ret); + } + } + if (insti.super_index != 0) { + getObfuscatedIdentifier(constants.getMultiname(insti.super_index).name_index, ret); + } + for (int iface : insti.interfaces) { + getObfuscatedIdentifier(constants.getMultiname(iface).name_index, ret); + } + } + + for (int i = 1; i < constants.getMultinameCount(); i++) { + Multiname m = constants.getMultiname(i); + int strIndex = m.name_index; + if (m.kind == Multiname.MULTINAME && strIndex > 0 && "*".equals(constants.getString(strIndex))) { + continue; + } + getObfuscatedIdentifier(constants.getMultiname(i).name_index, ret); + } + for (int i = 1; i < constants.getNamespaceCount(); i++) { + if (constants.getNamespace(i).kind != Namespace.KIND_PACKAGE) { // only packages + continue; + } + getObfuscatedPackageIdentifier(constants.getNamespace(i).name_index, ret); + } + } + /** * Deobfuscates identifiers. * @@ -699,7 +782,7 @@ public class ABC implements Openable { int mIndex = body.getCode().code.get(ip).operands[0]; if (mIndex > 0 && mIndex < constants.getMultinameCount()) { Multiname m = constants.getMultiname(mIndex); - if (m.getNameWithNamespace(constants, true).toRawString().equals("flash.utils.getDefinitionByName")) { + if (m.getNameWithNamespace(this, constants, true).toRawString().equals("flash.utils.getDefinitionByName")) { if (ip > 0) { if (body.getCode().code.get(ip - 1).definition instanceof PushStringIns) { int strIndex = body.getCode().code.get(ip - 1).operands[0]; @@ -1269,7 +1352,7 @@ public class ABC implements Openable { */ public MethodBody findBodyClassInitializerByClass(String classNameWithSuffix) { for (int i = 0; i < instance_info.size(); i++) { - if (classNameWithSuffix.equals(constants.getMultiname(instance_info.get(i).name_index).getName(constants, null, true, true))) { + if (classNameWithSuffix.equals(constants.getMultiname(instance_info.get(i).name_index).getName(this, constants, null, true, true))) { MethodBody body = findBody(class_info.get(i).cinit_index); if (body != null) { return body; @@ -1288,7 +1371,7 @@ public class ABC implements Openable { */ public MethodBody findBodyInstanceInitializerByClass(String classNameWithSuffix) { for (int i = 0; i < instance_info.size(); i++) { - if (classNameWithSuffix.equals(constants.getMultiname(instance_info.get(i).name_index).getName(constants, null, true, true))) { + if (classNameWithSuffix.equals(constants.getMultiname(instance_info.get(i).name_index).getName(this, constants, null, true, true))) { MethodBody body = findBody(instance_info.get(i).iinit_index); if (body != null) { return body; @@ -1308,11 +1391,11 @@ public class ABC implements Openable { */ public MethodBody findBodyByClassAndName(String classNameWithSuffix, String methodNameWithSuffix) { for (int i = 0; i < instance_info.size(); i++) { - if (classNameWithSuffix.equals(constants.getMultiname(instance_info.get(i).name_index).getName(constants, null, true, true))) { + if (classNameWithSuffix.equals(constants.getMultiname(instance_info.get(i).name_index).getName(this, constants, null, true, true))) { for (Trait t : instance_info.get(i).instance_traits.traits) { if (t instanceof TraitMethodGetterSetter) { TraitMethodGetterSetter t2 = (TraitMethodGetterSetter) t; - if (methodNameWithSuffix.equals(t2.getName(this).getName(constants, null, true, true))) { + if (methodNameWithSuffix.equals(t2.getName(this).getName(this, constants, null, true, true))) { MethodBody body = findBody(t2.method_info); if (body != null) { return body; @@ -1324,7 +1407,7 @@ public class ABC implements Openable { for (Trait t : class_info.get(i).static_traits.traits) { if (t instanceof TraitMethodGetterSetter) { TraitMethodGetterSetter t2 = (TraitMethodGetterSetter) t; - if (methodNameWithSuffix.equals(t2.getName(this).getName(constants, null, true, true))) { + if (methodNameWithSuffix.equals(t2.getName(this).getName(this, constants, null, true, true))) { MethodBody body = findBody(t2.method_info); if (body != null) { return body; @@ -1437,7 +1520,7 @@ public class ABC implements Openable { TraitSlotConst s = ((TraitSlotConst) t); if (s.isNamespace()) { String key = constants.getNamespace(s.value_index).getName(constants).toRawString(); // assume not null - DottedChain val = constants.getMultiname(s.name_index).getNameWithNamespace(constants, true); + DottedChain val = constants.getMultiname(s.name_index).getNameWithNamespace(this, constants, true); map.put(key, val); } } @@ -1530,7 +1613,7 @@ public class ABC implements Openable { public void dump(OutputStream os) { Utf8PrintWriter output; output = new Utf8PrintWriter(os); - constants.dump(output); + constants.dump(this, output); for (int i = 0; i < method_info.size(); i++) { output.println("MethodInfo[" + i + "]:" + method_info.get(i).toString(this, new ArrayList<>())); } @@ -1618,7 +1701,7 @@ public class ABC implements Openable { for (int multinameIndex = 1; multinameIndex < constants.getMultinameCount(); multinameIndex++) { Multiname m = constants.getMultiname(multinameIndex); if (m.kind == Multiname.QNAME || m.kind == Multiname.QNAMEA) { - String name = m.getName(constants, new ArrayList<>(), true, false); + String name = m.getName(this, constants, new ArrayList<>(), true, false); List indices = nameToQNameIndices.get(name); if (indices == null) { indices = new ArrayList<>(); @@ -1689,7 +1772,7 @@ public class ABC implements Openable { if (classId > -1) { for (Trait t : instance_info.get(classId).instance_traits.traits) { if (t instanceof TraitMethodGetterSetter) { - if (t.getName(this).getName(constants, null, true, true).equals(methodNameWithSuffix)) { + if (t.getName(this).getName(this, constants, null, true, true).equals(methodNameWithSuffix)) { return ((TraitMethodGetterSetter) t).method_info; } } @@ -1709,7 +1792,7 @@ public class ABC implements Openable { if (classId > -1) { for (Trait t : instance_info.get(classId).instance_traits.traits) { if (t instanceof TraitMethodGetterSetter) { - if (t.getName(this).getName(constants, null, true, true).equals(methodNameWithSuffix)) { + if (t.getName(this).getName(this, constants, null, true, true).equals(methodNameWithSuffix)) { return findBodyIndex(((TraitMethodGetterSetter) t).method_info); } } @@ -1752,7 +1835,7 @@ public class ABC implements Openable { if (instance_info.get(c).deleted) { continue; } - DottedChain s = constants.getMultiname(instance_info.get(c).name_index).getNameWithNamespace(constants, true); + DottedChain s = constants.getMultiname(instance_info.get(c).name_index).getNameWithNamespace(this, constants, true); if (nameWithSuffix.equals(s.toRawString())) { return c; } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/ClassPath.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/ClassPath.java index 653227c5e..c9680e21d 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/ClassPath.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/ClassPath.java @@ -16,6 +16,7 @@ */ package com.jpexs.decompiler.flash.abc; +import com.jpexs.decompiler.flash.SWF; import com.jpexs.decompiler.graph.DottedChain; import java.io.Serializable; import java.util.Objects; @@ -41,6 +42,11 @@ public class ClassPath implements Serializable { * Namespace suffix */ public final String namespaceSuffix; + + /** + * SWF + */ + private final SWF swf; /** * Constructs a new class path @@ -48,11 +54,13 @@ public class ClassPath implements Serializable { * @param packageStr Package name * @param className Class name * @param namespaceSuffix Namespace suffix + * @param SWF swf */ - public ClassPath(DottedChain packageStr, String className, String namespaceSuffix) { + public ClassPath(DottedChain packageStr, String className, String namespaceSuffix, SWF swf) { this.packageStr = packageStr == null ? DottedChain.TOPLEVEL : packageStr; this.className = className; this.namespaceSuffix = namespaceSuffix; + this.swf = swf; } /** @@ -62,7 +70,7 @@ public class ClassPath implements Serializable { */ @Override public String toString() { - return packageStr.add(className, namespaceSuffix).toPrintableString(true); + return packageStr.add(className, namespaceSuffix).toPrintableString(swf, true); } /** diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/ScriptPack.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/ScriptPack.java index e23053e4f..e138525e6 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/ScriptPack.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/ScriptPack.java @@ -207,7 +207,7 @@ public class ScriptPack extends AS3ClassTreeItem { Multiname name = abc.script_info.get(scriptIndex).traits.traits.get(t).getName(abc); int nskind = name.getSimpleNamespaceKind(abc.constants); if ((nskind == Namespace.KIND_PACKAGE) || (nskind == Namespace.KIND_PACKAGE_INTERNAL)) { - scriptName = name.getName(abc.constants, null, false, true); + scriptName = name.getName(abc, abc.constants, null, false, true); } } return scriptName; @@ -224,7 +224,7 @@ public class ScriptPack extends AS3ClassTreeItem { String scriptName = getPathScriptName(); DottedChain packageName = getPathPackage(); - File outDir = new File(directory + File.separatorChar + packageName.toFilePath()); + File outDir = new File(directory + File.separatorChar + packageName.toFilePath(abc.getSwf())); String fileName = outDir.toString() + File.separator + Helper.makeFileName(scriptName) + extension; return new File(fileName); } @@ -325,7 +325,7 @@ public class ScriptPack extends AS3ClassTreeItem { continue; } - String fullName = t.getName(abc).getNameWithNamespace(abc.constants, false).toPrintableString(true); + String fullName = t.getName(abc).getNameWithNamespace(abc, abc.constants, false).toPrintableString(abc.getSwf(), true); writer.appendNoHilight("include \"" + fullName.replace(".", "/") + ".as\";").newLine(); } writer.newLine(); @@ -771,7 +771,7 @@ public class ScriptPack extends AS3ClassTreeItem { //String filepath = path.toString().replace('.', '/') + ".as"; String pkg = path.packageStr.toString(); String cls = path.className; - String filename = new File(directoryPath, path.packageStr.toFilePath()).getPath().replace(";", "{{semicolon}}") + String filename = new File(directoryPath, path.packageStr.toFilePath(abc.getSwf())).getPath().replace(";", "{{semicolon}}") + ";" + swfHash + ":" + pkg.replace(".", File.separator).replace(";", "{{semicolon}}") diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/AVM2Code.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/AVM2Code.java index 912c08a1d..2bbfcb4bb 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/AVM2Code.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/AVM2Code.java @@ -1998,7 +1998,7 @@ public class AVM2Code implements Cloneable { 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(abc.constants, fullyQualifiedNames, true, true); + functionName = abc.constants.getMultiname(code.get(ip + plus + 3).operands[0]).getName(abc, abc.constants, fullyQualifiedNames, true, true); localScopeStack.pop(); // with output.remove(output.size() - 1); // with ip = ip + plus + 4; // +1 below @@ -2070,18 +2070,19 @@ public class AVM2Code implements Cloneable { /** * Gets types of local registers. * + * @param abc ABC * @param constants Constant pool * @param fullyQualifiedNames Fully qualified names * @return Map from register id to type */ - public HashMap getLocalRegTypes(AVM2ConstantPool constants, List fullyQualifiedNames) { + public HashMap getLocalRegTypes(ABC abc, AVM2ConstantPool constants, List fullyQualifiedNames) { HashMap ret = new HashMap<>(); AVM2Instruction prev = null; for (AVM2Instruction ins : code) { if (ins.definition instanceof SetLocalTypeIns) { if (prev != null) { if (prev.definition instanceof CoerceOrConvertTypeIns) { - ret.put(((SetLocalTypeIns) ins.definition).getRegisterId(ins), ((CoerceOrConvertTypeIns) prev.definition).getTargetType(constants, prev)); + ret.put(((SetLocalTypeIns) ins.definition).getRegisterId(ins), ((CoerceOrConvertTypeIns) prev.definition).getTargetType(abc, constants, prev)); } } } @@ -2257,7 +2258,7 @@ public class AVM2Code implements Cloneable { if (t instanceof TraitSlotConst) { TraitSlotConst tsc = (TraitSlotConst) t; Multiname tratMultiname = abc.constants.getMultiname(tsc.name_index); - String bodyTraitName = tratMultiname.getName(abc.constants, new ArrayList<>(), true, true); + String bodyTraitName = tratMultiname.getName(abc, abc.constants, new ArrayList<>(), true, true); traits.put(bodyTraitName, tsc); } } @@ -2275,7 +2276,7 @@ public class AVM2Code implements Cloneable { if (ss.slotName == null) { break; } - propNameStr = ss.slotName.getName(abc.constants, new ArrayList<>(), true, true); + propNameStr = ss.slotName.getName(abc, abc.constants, new ArrayList<>(), true, true); value = ss.value; } else if (item instanceof SetPropertyAVM2Item) { SetPropertyAVM2Item sp = (SetPropertyAVM2Item) item; @@ -2323,7 +2324,7 @@ public class AVM2Code implements Cloneable { } else { return; } - propertyName = propertyMultiName.getName(abc.constants, new ArrayList<>(), true, true); + propertyName = propertyMultiName.getName(abc, abc.constants, new ArrayList<>(), true, true); if (traits.containsKey(propertyName)) { Slot sl = new Slot(new NewActivationAVM2Item(null, null), propertyMultiName); @@ -2348,8 +2349,8 @@ public class AVM2Code implements Cloneable { if (!beginDeclaredSlotsNames.contains(traitName)) { Slot sl = new Slot(new NewActivationAVM2Item(null, null), abc.constants.getMultiname(traits.get(traitName).name_index)); TraitSlotConst tsc = (TraitSlotConst) traits.get(traitName); - GraphTargetItem type = AbcIndexing.multinameToType(tsc.type_index, abc.constants); - DeclarationAVM2Item d = new DeclarationAVM2Item(new GetLexAVM2Item(null, null, sl.multiname, abc.constants, type, TypeItem.UNBOUNDED /*?*/, false), type); + GraphTargetItem type = AbcIndexing.multinameToType(tsc.type_index, abc, abc.constants); + DeclarationAVM2Item d = new DeclarationAVM2Item(new GetLexAVM2Item(null, null, sl.multiname, abc, abc.constants, type, TypeItem.UNBOUNDED /*?*/, false), type); declaredSlotsDec.add(d); declaredSlots.add(sl); @@ -2415,7 +2416,7 @@ public class AVM2Code implements Cloneable { if (!declaredProperties.contains(propName.resolvedMultinameName)) { if (traits.containsKey(propName.resolvedMultinameName)) { TraitSlotConst tsc = traits.get(propName.resolvedMultinameName); - GraphTargetItem type = AbcIndexing.multinameToType(tsc.type_index, abc.constants); + GraphTargetItem type = AbcIndexing.multinameToType(tsc.type_index, abc, abc.constants); DeclarationAVM2Item d = new DeclarationAVM2Item(subItem, type); sp.setDeclaration(d); declaredPropsDec.add(d); @@ -2445,14 +2446,14 @@ public class AVM2Code implements Cloneable { SetSlotAVM2Item ssti = (SetSlotAVM2Item) subItem; if (ssti.scope instanceof NewActivationAVM2Item) { Slot sl = new Slot(ssti.scope, ssti.slotName); - String slotPropertyName = sl.multiname.getName(abc.constants, new ArrayList<>(), true, false); + String slotPropertyName = sl.multiname.getName(abc, abc.constants, new ArrayList<>(), true, false); if (!paramNames.contains(slotPropertyName)) { int index = slotListIndexOf(declaredSlots, slotPropertyName, abc); if (index == -1) { GraphTargetItem type = TypeItem.UNBOUNDED; if (traits.containsKey(slotPropertyName)) { - type = AbcIndexing.multinameToType(traits.get(slotPropertyName).type_index, abc.constants); + type = AbcIndexing.multinameToType(traits.get(slotPropertyName).type_index, abc, abc.constants); } DeclarationAVM2Item d = new DeclarationAVM2Item(subItem, type); ssti.setDeclaration(d); @@ -2549,7 +2550,7 @@ public class AVM2Code implements Cloneable { } HashMap localRegTypes = new HashMap<>(); for (int i = 0; i < abc.method_info.get(methodIndex).param_types.length; i++) { - localRegTypes.put(i + 1, AbcIndexing.multinameToType(abc.method_info.get(methodIndex).param_types[i], abc.constants)); + localRegTypes.put(i + 1, AbcIndexing.multinameToType(abc.method_info.get(methodIndex).param_types[i], abc, abc.constants)); } try { @@ -2581,7 +2582,7 @@ public class AVM2Code implements Cloneable { if (value != null && !convertData.assignedValues.containsKey(tsc)) { if (value instanceof NewFunctionAVM2Item) { NewFunctionAVM2Item f = (NewFunctionAVM2Item) value; - f.functionName = tsc.getName(abc).getName(abc.constants, fullyQualifiedNames, true, true); + f.functionName = tsc.getName(abc).getName(abc, abc.constants, fullyQualifiedNames, true, true); } AssignedValue av = new AssignedValue(ti, value, initializerType, methodIndex); convertData.assignedValues.put(tsc, av); @@ -2670,7 +2671,7 @@ public class AVM2Code implements Cloneable { } if (value instanceof NewFunctionAVM2Item) { NewFunctionAVM2Item f = (NewFunctionAVM2Item) value; - f.functionName = tsc.getName(abc).getName(abc.constants, fullyQualifiedNames, true, true); + f.functionName = tsc.getName(abc).getName(abc, abc.constants, fullyQualifiedNames, true, true); } AssignedValue av = new AssignedValue(classMultiname == -1 ? ti : null, value, initializerType, methodIndex); convertData.assignedValues.put(tsc, av); @@ -2888,7 +2889,7 @@ public class AVM2Code implements Cloneable { if (param_types[i] == 0) { type = TypeItem.UNBOUNDED; } else { - type = new TypeItem(abc.constants.getMultiname(param_types[i]).getNameWithNamespace(abc.constants, true)); + type = new TypeItem(abc.constants.getMultiname(param_types[i]).getNameWithNamespace(abc, abc.constants, true)); } if (d.length > r) { d[r] = new DeclarationAVM2Item(new SetLocalAVM2Item(null, null, r, new NullAVM2Item(null, null), type), type); @@ -2913,7 +2914,7 @@ public class AVM2Code implements Cloneable { HashMap registerNames = body.getLocalRegNames(abc); List paramNamesList = new ArrayList<>(); for (int ir = 0; ir < r; ir++) { - paramNamesList.add(AVM2Item.localRegName(localRegNames, ir)); + paramNamesList.add(AVM2Item.localRegName(abc.getSwf(), localRegNames, ir)); } injectDeclarations(0, paramNamesList, list, 1, d, new ArrayList<>(), new ArrayList<>(), new ArrayList<>(), new ArrayList<>(), abc, body); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/AVM2ConstantPool.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/AVM2ConstantPool.java index 572595b25..eddd8e93f 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/AVM2ConstantPool.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/AVM2ConstantPool.java @@ -16,6 +16,7 @@ */ package com.jpexs.decompiler.flash.abc.avm2; +import com.jpexs.decompiler.flash.abc.ABC; import com.jpexs.decompiler.flash.abc.ABCVersionRequirements; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instructions; @@ -949,14 +950,16 @@ public class AVM2ConstantPool implements Cloneable { * Finds multiname index based on multiname in other constant pool. * * @param val Value + * @param thisAbc This ABC + * @param origAbc Original ABC * @param origConst Original constant pool * @return List of multiname indexes */ - public List getMultinameIds(Multiname val, AVM2ConstantPool origConst) { + public List getMultinameIds(Multiname val, ABC thisAbc, ABC origAbc, AVM2ConstantPool origConst) { List ret = new ArrayList<>(); for (int i = 1; i < getMultinameCount(); i++) { - if (getMultiname(i).qnameEquals(this, val, origConst)) { + if (getMultiname(i).qnameEquals(thisAbc, this, val, origAbc, origConst)) { ret.add(i); } } @@ -1196,9 +1199,10 @@ public class AVM2ConstantPool implements Cloneable { /** * Dumps the constant pool. * + * @param abc ABC * @param writer Writer */ - public void dump(Utf8PrintWriter writer) { + public void dump(ABC abc, Utf8PrintWriter writer) { for (int i = 1; i < constant_int.size(); i++) { writer.println("INT[" + i + "]=" + constant_int.get(i)); } @@ -1212,7 +1216,7 @@ public class AVM2ConstantPool implements Cloneable { writer.println("String[" + i + "]=" + constant_string.get(i)); } for (int i = 1; i < constant_namespace.size(); i++) { - writer.println("Namespace[" + i + "]=" + constant_namespace.get(i).toString(this)); + writer.println("Namespace[" + i + "]=" + constant_namespace.get(i).toString(abc, this)); } for (int i = 1; i < constant_namespace_set.size(); i++) { writer.println("NamespaceSet[" + i + "]=" + constant_namespace_set.get(i).toString(this)); @@ -1239,14 +1243,15 @@ public class AVM2ConstantPool implements Cloneable { /** * Converts namespace to string. * + * @param abc ABC * @param index Namespace index * @return String */ - public String namespaceToString(int index) { + public String namespaceToString(ABC abc, int index) { if (index == 0) { return "null"; } - return constant_namespace.get(index).toString(this); + return constant_namespace.get(index).toString(abc, this); } /** diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/AVM2Deobfuscation.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/AVM2Deobfuscation.java index 32bca14b8..9263b95f2 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/AVM2Deobfuscation.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/AVM2Deobfuscation.java @@ -35,6 +35,8 @@ import java.util.regex.Pattern; */ public class AVM2Deobfuscation { + public static final String SAFE_STR_PREFIX = "_SafeStr_"; + /** * Default size of random word. */ @@ -97,7 +99,7 @@ public class AVM2Deobfuscation { * @param s String * @return True if string is valid namespace part */ - private boolean isValidNSPart(String s) { + public boolean isValidNSPart(String s) { boolean isValid = true; if (IdentifiersDeobfuscation.isReservedWord2(s)) { isValid = false; @@ -179,6 +181,23 @@ public class AVM2Deobfuscation { return ret; } + + /** + * Checks whether string at given index is valid package name + * @param strIndex String index + * @return True if valid + */ + public boolean isValidPackageName(int strIndex) { + if (strIndex <= 0) { + return true; + } + String s = constants.getString(strIndex); + if (builtInNs(s) != null) { + return true; + } + return isValidNSPart(s); + } + /** * Deobfuscates package name. * @@ -189,16 +208,9 @@ public class AVM2Deobfuscation { * @param renameType Rename type * @return Deobfuscated package name */ - public int deobfuscatePackageName(Map stringUsageTypes, Set stringUsages, HashMap namesMap, int strIndex, RenameType renameType) { - if (strIndex <= 0) { - return strIndex; - } - String s = constants.getString(strIndex); - if (builtInNs(s) != null) { - return strIndex; - } - boolean isValid = isValidNSPart(s); - if (!isValid) { + public int deobfuscatePackageName(Map stringUsageTypes, Set stringUsages, HashMap namesMap, int strIndex, RenameType renameType) { + if (!isValidPackageName(strIndex)) { + String s = constants.getString(strIndex); DottedChain sChain = DottedChain.parseWithSuffix(s); DottedChain newName; if (namesMap.containsKey(sChain)) { @@ -228,20 +240,13 @@ public class AVM2Deobfuscation { } /** - * Deobfuscates name. - * - * @param stringUsageTypes String usage types - * @param stringUsages String usages - * @param namespaceUsages Namespace usages - * @param namesMap Names map + * Checks whether string at given index is valid name * @param strIndex String index - * @param firstUppercase First uppercase - * @param renameType Rename type - * @return Deobfuscated name string index + * @return True when valid */ - public int deobfuscateName(Map stringUsageTypes, Set stringUsages, Set namespaceUsages, HashMap namesMap, int strIndex, boolean firstUppercase, RenameType renameType) { + public boolean isValidName(int strIndex) { if (strIndex <= 0) { - return strIndex; + return true; } String s = constants.getString(strIndex); boolean isValid = true; @@ -264,8 +269,24 @@ public class AVM2Deobfuscation { isValid = false; } } - - if (!isValid) { + return isValid; + } + + /** + * Deobfuscates name. + * + * @param stringUsageTypes String usage types + * @param stringUsages String usages + * @param namespaceUsages Namespace usages + * @param namesMap Names map + * @param strIndex String index + * @param firstUppercase First uppercase + * @param renameType Rename type + * @return Deobfuscated name string index + */ + public int deobfuscateName(Map stringUsageTypes, Set stringUsages, Set namespaceUsages, HashMap namesMap, int strIndex, boolean firstUppercase, RenameType renameType) { + if (!isValidName(strIndex)) { + String s = constants.getString(strIndex); DottedChain newname; DottedChain sChain = DottedChain.parseNoSuffix(s); if (namesMap.containsKey(sChain)) { diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/graph/AVM2Graph.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/graph/AVM2Graph.java index 22e1295d1..b429d299b 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/graph/AVM2Graph.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/graph/AVM2Graph.java @@ -2190,7 +2190,7 @@ public class AVM2Graph extends Graph { } if (construct.object instanceof GetLexAVM2Item) { GetLexAVM2Item glt = (GetLexAVM2Item) construct.object; - isXMLList = glt.propertyName.getName(aLocalData.getConstants(), aLocalData.fullyQualifiedNames, true, true).equals("XMLList"); + isXMLList = glt.propertyName.getName(aLocalData.abc, aLocalData.getConstants(), aLocalData.fullyQualifiedNames, true, true).equals("XMLList"); } if (isXMLList) { @@ -2733,7 +2733,7 @@ public class AVM2Graph extends Graph { if (sp.value instanceof LocalRegAVM2Item) { LocalRegAVM2Item lr = (LocalRegAVM2Item) sp.value; AVM2FinalProcessLocalData aLocalData = (AVM2FinalProcessLocalData) localData; - if (Objects.equals(propName.resolvedMultinameName, AVM2Item.localRegName(aLocalData.localRegNames, lr.regIndex))) { + if (Objects.equals(propName.resolvedMultinameName, AVM2Item.localRegName(abc.getSwf(), aLocalData.localRegNames, lr.regIndex))) { list.remove(i); i--; continue loopi; @@ -2746,7 +2746,7 @@ public class AVM2Graph extends Graph { if (list.get(i) instanceof SetSlotAVM2Item) { SetSlotAVM2Item sslot = (SetSlotAVM2Item) list.get(i); if (sslot.slotObject instanceof NewActivationAVM2Item) { - String slotName = sslot.slotName.getName(abc.constants, new ArrayList<>(), true, true); + String slotName = sslot.slotName.getName(abc, abc.constants, new ArrayList<>(), true, true); if (sslot.value.getNotCoercedNoDup() instanceof LocalRegAVM2Item) { LocalRegAVM2Item locReg = (LocalRegAVM2Item) sslot.value.getNotCoercedNoDup(); if (localRegNames.containsValue(slotName)) { diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/InstructionDefinition.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/InstructionDefinition.java index 7c18542c4..b66e2bd9c 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/InstructionDefinition.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/InstructionDefinition.java @@ -388,7 +388,7 @@ public abstract class InstructionDefinition implements Serializable { } } - return new FullMultinameAVM2Item(property, ins, localData.lineStartInstruction, multinameIndex, localData.abc.constants.getMultiname(multinameIndex).getName(localData.getConstants(), new ArrayList<>(), true, true), name, ns); + return new FullMultinameAVM2Item(property, ins, localData.lineStartInstruction, multinameIndex, localData.abc.constants.getMultiname(multinameIndex).getName(localData.abc, localData.getConstants(), new ArrayList<>(), true, true), name, ns); } /** diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/construction/ConstructIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/construction/ConstructIns.java index 009bf93a9..902d76fee 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/construction/ConstructIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/construction/ConstructIns.java @@ -129,7 +129,7 @@ public class ConstructIns extends InstructionDefinition { } if (obj instanceof GetLexAVM2Item) { GetLexAVM2Item glt = (GetLexAVM2Item) obj; - isXML = glt.propertyName.getName(localData.getConstants(), localData.fullyQualifiedNames, true, true).equals("XML"); + isXML = glt.propertyName.getName(localData.abc, localData.getConstants(), localData.fullyQualifiedNames, true, true).equals("XML"); } if (isXML) { @@ -157,7 +157,7 @@ public class ConstructIns extends InstructionDefinition { } if (obj instanceof GetLexAVM2Item) { GetLexAVM2Item glt = (GetLexAVM2Item) obj; - isRegExp = glt.propertyName.getName(localData.getConstants(), localData.fullyQualifiedNames, true, true).equals("RegExp"); + isRegExp = glt.propertyName.getName(localData.abc, localData.getConstants(), localData.fullyQualifiedNames, true, true).equals("RegExp"); } if (isRegExp && (args.size() >= 1) && (args.get(0) instanceof StringAVM2Item) && (args.size() == 1 || (args.size() == 2 && args.get(1) instanceof StringAVM2Item))) { diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/construction/NewClassIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/construction/NewClassIns.java index e29785764..175c42a76 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/construction/NewClassIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/construction/NewClassIns.java @@ -53,7 +53,7 @@ public class NewClassIns extends InstructionDefinition { writer.finishHilights(); String baseType = writer.toString(); ABC abc = localData.abc; - stack.push(new UnparsedAVM2Item(ins, localData.lineStartInstruction, "§§newclass(" + abc.constants.getMultiname(abc.instance_info.get(clsIndex).name_index).getName(localData.getConstants(), localData.fullyQualifiedNames, false, true) + "," + baseType + ")")); + stack.push(new UnparsedAVM2Item(ins, localData.lineStartInstruction, "§§newclass(" + abc.constants.getMultiname(abc.instance_info.get(clsIndex).name_index).getName(localData.abc, localData.getConstants(), localData.fullyQualifiedNames, false, true) + "," + baseType + ")")); } @Override diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/GetLocalTypeIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/GetLocalTypeIns.java index a716d9d92..7bd53f23c 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/GetLocalTypeIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/GetLocalTypeIns.java @@ -93,7 +93,7 @@ public abstract class GetLocalTypeIns extends InstructionDefinition { List ts = localData.getInstanceInfo().get(localData.classIndex).instance_traits.traits; boolean isBasicObject = localData.thisHasDefaultToPrimitive; Multiname m = localData.getInstanceInfo().get(localData.classIndex).getName(localData.getConstants()); - stack.push(new ThisAVM2Item(ins, localData.lineStartInstruction, m.getNameWithNamespace(localData.getConstants(), true), isBasicObject, false)); + stack.push(new ThisAVM2Item(ins, localData.lineStartInstruction, m.getNameWithNamespace(localData.abc, localData.getConstants(), true), isBasicObject, false)); } return; } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/GetGlobalSlotIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/GetGlobalSlotIns.java index fc482b3fe..9f023e5ac 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/GetGlobalSlotIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/GetGlobalSlotIns.java @@ -60,7 +60,7 @@ public class GetGlobalSlotIns extends InstructionDefinition { if (t instanceof TraitSlotConst) { TraitSlotConst tsc = (TraitSlotConst) t; if (tsc.slot_id == slotIndex) { - slotType = AbcIndexing.multinameToType(tsc.type_index, localData.abc.constants); + slotType = AbcIndexing.multinameToType(tsc.type_index, localData.abc, localData.abc.constants); break; } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/GetLexIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/GetLexIns.java index 7e63e2b1b..5b8d80b35 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/GetLexIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/GetLexIns.java @@ -58,17 +58,17 @@ public class GetLexIns extends InstructionDefinition { Reference isStatic, Reference type, Reference callType) { type.setVal(TypeItem.UNKNOWN); callType.setVal(TypeItem.UNKNOWN); - String multinameStr = localData.abc.constants.getMultiname(multinameIndex).getName(localData.abc.constants, new ArrayList<>(), true, true); + String multinameStr = localData.abc.constants.getMultiname(multinameIndex).getName(localData.abc, localData.abc.constants, new ArrayList<>(), true, true); for (int b = localData.callStack.size() - 1; b >= 0; b--) { MethodBody body = localData.callStack.get(b); for (Trait t : body.traits.traits) { if (t instanceof TraitSlotConst) { TraitSlotConst tsc = (TraitSlotConst) t; if (Objects.equals( - tsc.getName(localData.abc).getName(localData.abc.constants, new ArrayList<>(), true, true), + tsc.getName(localData.abc).getName(localData.abc, localData.abc.constants, new ArrayList<>(), true, true), multinameStr )) { - GraphTargetItem ty = AbcIndexing.multinameToType(tsc.type_index, localData.abc.constants); + GraphTargetItem ty = AbcIndexing.multinameToType(tsc.type_index, localData.abc, localData.abc.constants); type.setVal(ty); callType.setVal(ty); return; @@ -78,7 +78,7 @@ public class GetLexIns extends InstructionDefinition { } if (localData.abcIndex != null) { - String currentClassName = localData.classIndex == -1 ? null : localData.abc.instance_info.get(localData.classIndex).getName(localData.abc.constants).getNameWithNamespace(localData.abc.constants, true).toRawString(); + String currentClassName = localData.classIndex == -1 ? null : localData.abc.instance_info.get(localData.classIndex).getName(localData.abc.constants).getNameWithNamespace(localData.abc, localData.abc.constants, true).toRawString(); if (currentClassName != null) { Reference foundStatic = new Reference<>(null); localData.abcIndex.findPropertyTypeOrCallType(localData.abc, new TypeItem(currentClassName), multinameStr, localData.abc.constants.getMultiname(multinameIndex).namespace_index, true, true, true, type, callType, foundStatic); @@ -86,7 +86,7 @@ public class GetLexIns extends InstructionDefinition { if (type.getVal().equals(TypeItem.UNKNOWN)) { //TypeItem ti = new TypeItem(localData.abc.constants.getMultiname(multinameIndex).getNameWithNamespace(localData.abc.constants, true)); - GraphTargetItem ti = AbcIndexing.multinameToType(multinameIndex, localData.abc.constants); + GraphTargetItem ti = AbcIndexing.multinameToType(multinameIndex, localData.abc, localData.abc.constants); if (localData.abcIndex.findClass(ti, localData.abc, localData.scriptIndex) != null) { type.setVal(ti); callType.setVal(TypeItem.UNBOUNDED); @@ -116,7 +116,7 @@ public class GetLexIns extends InstructionDefinition { Reference type = new Reference<>(null); Reference callType = new Reference<>(null); GetLexIns.resolveLexType(localData, null, multinameIndex, isStatic, type, callType); - stack.push(new GetLexAVM2Item(ins, localData.lineStartInstruction, multiname, localData.getConstants(), type.getVal(), callType.getVal(), isStatic.getVal())); + stack.push(new GetLexAVM2Item(ins, localData.lineStartInstruction, multiname, localData.abc, localData.getConstants(), type.getVal(), callType.getVal(), isStatic.getVal())); } @Override diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/GetPropertyIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/GetPropertyIns.java index f03e088b6..415858a79 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/GetPropertyIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/GetPropertyIns.java @@ -152,7 +152,7 @@ public class GetPropertyIns extends InstructionDefinition { Reference isStatic, Reference type, Reference callType) { type.setVal(TypeItem.UNKNOWN); callType.setVal(TypeItem.UNKNOWN); - String multinameStr = localData.abc.constants.getMultiname(multiname.multinameIndex).getName(localData.abc.constants, new ArrayList<>(), true, true); + String multinameStr = localData.abc.constants.getMultiname(multiname.multinameIndex).getName(localData.abc, localData.abc.constants, new ArrayList<>(), true, true); if (obj instanceof FindPropertyAVM2Item) { FindPropertyAVM2Item fprop = (FindPropertyAVM2Item) obj; if (fprop.propertyName.equals(multiname)) { @@ -162,10 +162,10 @@ public class GetPropertyIns extends InstructionDefinition { if (t instanceof TraitSlotConst) { TraitSlotConst tsc = (TraitSlotConst) t; if (Objects.equals( - tsc.getName(localData.abc).getName(localData.abc.constants, new ArrayList<>(), true, true), + tsc.getName(localData.abc).getName(localData.abc, localData.abc.constants, new ArrayList<>(), true, true), multinameStr )) { - GraphTargetItem ty = AbcIndexing.multinameToType(tsc.type_index, localData.abc.constants); + GraphTargetItem ty = AbcIndexing.multinameToType(tsc.type_index, localData.abc, localData.abc.constants); type.setVal(ty); callType.setVal(ty); return; @@ -176,13 +176,13 @@ public class GetPropertyIns extends InstructionDefinition { if (type.getVal().equals(TypeItem.UNKNOWN)) { if (localData.abcIndex != null) { - String currentClassName = localData.classIndex == -1 ? null : localData.abc.instance_info.get(localData.classIndex).getName(localData.abc.constants).getNameWithNamespace(localData.abc.constants, true).toRawString(); + String currentClassName = localData.classIndex == -1 ? null : localData.abc.instance_info.get(localData.classIndex).getName(localData.abc.constants).getNameWithNamespace(localData.abc, localData.abc.constants, true).toRawString(); if (currentClassName != null) { Reference foundStatic = new Reference<>(null); localData.abcIndex.findPropertyTypeOrCallType(localData.abc, new TypeItem(currentClassName), multinameStr, localData.abc.constants.getMultiname(multiname.multinameIndex).namespace_index, true, true, true, type, callType, foundStatic); } if (type.getVal().equals(TypeItem.UNKNOWN)) { - GraphTargetItem ti = AbcIndexing.multinameToType(multiname.multinameIndex, localData.abc.constants); + GraphTargetItem ti = AbcIndexing.multinameToType(multiname.multinameIndex, localData.abc, localData.abc.constants); if (localData.abcIndex.findClass(ti, localData.abc, localData.scriptIndex) != null) { type.setVal(ti); callType.setVal(ti); //coercion i = int(xx); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/GetSlotIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/GetSlotIns.java index 1e9fa52f8..be58f242e 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/GetSlotIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/GetSlotIns.java @@ -63,7 +63,7 @@ public class GetSlotIns extends InstructionDefinition { if (t instanceof TraitSlotConst) { TraitSlotConst tsc = (TraitSlotConst) t; if (tsc.slot_id == slotIndex) { - slotType = AbcIndexing.multinameToType(tsc.type_index, localData.abc.constants); + slotType = AbcIndexing.multinameToType(tsc.type_index, localData.abc, localData.abc.constants); break; } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/SetSlotIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/SetSlotIns.java index bd966d065..d9452451f 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/SetSlotIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/SetSlotIns.java @@ -85,7 +85,7 @@ public class SetSlotIns extends InstructionDefinition implements SetTypeIns { if (slotname != null) { if (value instanceof LocalRegAVM2Item) { LocalRegAVM2Item lr = (LocalRegAVM2Item) value; - String slotNameStr = slotname.getName(localData.getConstants(), localData.fullyQualifiedNames, true, true); + String slotNameStr = slotname.getName(localData.abc, localData.getConstants(), localData.fullyQualifiedNames, true, true); if (localData.localRegNames.containsKey(lr.regIndex)) { if (localData.localRegNames.get(lr.regIndex).equals(slotNameStr)) { return; //Register with same name to slot @@ -150,7 +150,7 @@ public class SetSlotIns extends InstructionDefinition implements SetTypeIns { if (t instanceof TraitSlotConst) { TraitSlotConst tsc = (TraitSlotConst) t; if (tsc.slot_id == slotIndex) { - slotType = AbcIndexing.multinameToType(tsc.type_index, localData.abc.constants); + slotType = AbcIndexing.multinameToType(tsc.type_index, localData.abc, localData.abc.constants); break; } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/decimalsupport/ConvertMIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/decimalsupport/ConvertMIns.java index 66d328926..7bd998826 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/decimalsupport/ConvertMIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/decimalsupport/ConvertMIns.java @@ -68,11 +68,11 @@ public class ConvertMIns extends InstructionDefinition implements CoerceOrConver @Override public void translate(AVM2LocalData localData, TranslateStack stack, AVM2Instruction ins, List output, String path) { - stack.push(new ConvertAVM2Item(ins, localData.lineStartInstruction, stack.pop(), getTargetType(localData.getConstants(), ins))); + stack.push(new ConvertAVM2Item(ins, localData.lineStartInstruction, stack.pop(), getTargetType(localData.abc, localData.getConstants(), ins))); } @Override - public GraphTargetItem getTargetType(AVM2ConstantPool constants, AVM2Instruction ins) { + public GraphTargetItem getTargetType(ABC abc, AVM2ConstantPool constants, AVM2Instruction ins) { return new TypeItem(DottedChain.DECIMAL); } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/decimalsupport/ConvertMPIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/decimalsupport/ConvertMPIns.java index bb5fa9a90..2e1961fe5 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/decimalsupport/ConvertMPIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/decimalsupport/ConvertMPIns.java @@ -69,11 +69,11 @@ public class ConvertMPIns extends InstructionDefinition implements CoerceOrConve @Override public void translate(AVM2LocalData localData, TranslateStack stack, AVM2Instruction ins, List output, String path) { - stack.push(new ConvertAVM2Item(ins, localData.lineStartInstruction, stack.pop(), getTargetType(localData.getConstants(), ins))); + stack.push(new ConvertAVM2Item(ins, localData.lineStartInstruction, stack.pop(), getTargetType(localData.abc, localData.getConstants(), ins))); } @Override - public GraphTargetItem getTargetType(AVM2ConstantPool constants, AVM2Instruction ins) { + public GraphTargetItem getTargetType(ABC abc, AVM2ConstantPool constants, AVM2Instruction ins) { return new TypeItem(DottedChain.DECIMAL); } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/deprecated/CoerceBIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/deprecated/CoerceBIns.java index 8f0f5a1d2..69c88c4dc 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/deprecated/CoerceBIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/deprecated/CoerceBIns.java @@ -60,7 +60,7 @@ public class CoerceBIns extends InstructionDefinition implements CoerceOrConvert } @Override - public GraphTargetItem getTargetType(AVM2ConstantPool constants, AVM2Instruction ins) { + public GraphTargetItem getTargetType(ABC abc, AVM2ConstantPool constants, AVM2Instruction ins) { return new TypeItem(DottedChain.BOOLEAN); } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/deprecated/CoerceDIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/deprecated/CoerceDIns.java index f62779a5a..03065995e 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/deprecated/CoerceDIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/deprecated/CoerceDIns.java @@ -60,7 +60,7 @@ public class CoerceDIns extends InstructionDefinition implements CoerceOrConvert } @Override - public GraphTargetItem getTargetType(AVM2ConstantPool constants, AVM2Instruction ins) { + public GraphTargetItem getTargetType(ABC abc, AVM2ConstantPool constants, AVM2Instruction ins) { return new TypeItem(DottedChain.NUMBER); } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/deprecated/CoerceIIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/deprecated/CoerceIIns.java index eb20d3871..a19156f04 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/deprecated/CoerceIIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/deprecated/CoerceIIns.java @@ -60,7 +60,7 @@ public class CoerceIIns extends InstructionDefinition implements CoerceOrConvert } @Override - public GraphTargetItem getTargetType(AVM2ConstantPool constants, AVM2Instruction ins) { + public GraphTargetItem getTargetType(ABC abc, AVM2ConstantPool constants, AVM2Instruction ins) { return new TypeItem(DottedChain.INT); } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/deprecated/CoerceUIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/deprecated/CoerceUIns.java index 4489713ad..de2bf4b30 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/deprecated/CoerceUIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/deprecated/CoerceUIns.java @@ -60,7 +60,7 @@ public class CoerceUIns extends InstructionDefinition implements CoerceOrConvert } @Override - public GraphTargetItem getTargetType(AVM2ConstantPool constants, AVM2Instruction ins) { + public GraphTargetItem getTargetType(ABC abc, AVM2ConstantPool constants, AVM2Instruction ins) { return new TypeItem(DottedChain.UINT); } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/floatsupport/ConvertF4Ins.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/floatsupport/ConvertF4Ins.java index 483f1ee8f..8f616cade 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/floatsupport/ConvertF4Ins.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/floatsupport/ConvertF4Ins.java @@ -78,11 +78,11 @@ public class ConvertF4Ins extends InstructionDefinition implements CoerceOrConve @Override public void translate(AVM2LocalData localData, TranslateStack stack, AVM2Instruction ins, List output, String path) { - stack.push(new ConvertAVM2Item(ins, localData.lineStartInstruction, stack.pop(), getTargetType(localData.getConstants(), ins))); + stack.push(new ConvertAVM2Item(ins, localData.lineStartInstruction, stack.pop(), getTargetType(localData.abc, localData.getConstants(), ins))); } @Override - public GraphTargetItem getTargetType(AVM2ConstantPool constants, AVM2Instruction ins) { + public GraphTargetItem getTargetType(ABC abc, AVM2ConstantPool constants, AVM2Instruction ins) { return new TypeItem("float4"); } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/floatsupport/ConvertFIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/floatsupport/ConvertFIns.java index 61d64df39..03dfbab80 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/floatsupport/ConvertFIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/floatsupport/ConvertFIns.java @@ -77,11 +77,11 @@ public class ConvertFIns extends InstructionDefinition implements CoerceOrConver @Override public void translate(AVM2LocalData localData, TranslateStack stack, AVM2Instruction ins, List output, String path) { - stack.push(new ConvertAVM2Item(ins, localData.lineStartInstruction, stack.pop(), getTargetType(localData.getConstants(), ins))); + stack.push(new ConvertAVM2Item(ins, localData.lineStartInstruction, stack.pop(), getTargetType(localData.abc, localData.getConstants(), ins))); } @Override - public GraphTargetItem getTargetType(AVM2ConstantPool constants, AVM2Instruction ins) { + public GraphTargetItem getTargetType(ABC abc, AVM2ConstantPool constants, AVM2Instruction ins) { return new TypeItem("float"); } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/AsTypeIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/AsTypeIns.java index 5e5c33495..53531d49a 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/AsTypeIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/AsTypeIns.java @@ -65,7 +65,7 @@ public class AsTypeIns extends InstructionDefinition { public void translate(AVM2LocalData localData, TranslateStack stack, AVM2Instruction ins, List output, String path) { GraphTargetItem val = stack.pop(); - stack.push(new AsTypeAVM2Item(ins, localData.lineStartInstruction, val, new FullMultinameAVM2Item(false, ins, localData.lineStartInstruction, ins.operands[0], localData.abc.constants.getMultiname(ins.operands[0]).getName(localData.getConstants(), new ArrayList<>(), true, true)))); + stack.push(new AsTypeAVM2Item(ins, localData.lineStartInstruction, val, new FullMultinameAVM2Item(false, ins, localData.lineStartInstruction, ins.operands[0], localData.abc.constants.getMultiname(ins.operands[0]).getName(localData.abc, localData.getConstants(), new ArrayList<>(), true, true)))); } @Override diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/CoerceAIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/CoerceAIns.java index 38fc13e39..6b1e395cd 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/CoerceAIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/CoerceAIns.java @@ -50,7 +50,7 @@ public class CoerceAIns extends InstructionDefinition implements CoerceOrConvert @Override public void translate(AVM2LocalData localData, TranslateStack stack, AVM2Instruction ins, List output, String path) { - stack.push(new CoerceAVM2Item(ins, localData.lineStartInstruction, stack.pop(), getTargetType(localData.getConstants(), ins))); + stack.push(new CoerceAVM2Item(ins, localData.lineStartInstruction, stack.pop(), getTargetType(localData.abc, localData.getConstants(), ins))); } @@ -73,7 +73,7 @@ public class CoerceAIns extends InstructionDefinition implements CoerceOrConvert } @Override - public GraphTargetItem getTargetType(AVM2ConstantPool constants, AVM2Instruction ins) { + public GraphTargetItem getTargetType(ABC abc, AVM2ConstantPool constants, AVM2Instruction ins) { return TypeItem.UNBOUNDED; } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/CoerceIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/CoerceIns.java index 9ec2d1b3c..f10ef3ac2 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/CoerceIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/CoerceIns.java @@ -84,7 +84,7 @@ public class CoerceIns extends InstructionDefinition implements CoerceOrConvertT @Override public void translate(AVM2LocalData localData, TranslateStack stack, AVM2Instruction ins, List output, String path) { int multinameIndex = ins.operands[0]; - stack.push(new CoerceAVM2Item(ins, localData.lineStartInstruction, stack.pop(), AbcIndexing.multinameToType(multinameIndex, localData.getConstants()))); + stack.push(new CoerceAVM2Item(ins, localData.lineStartInstruction, stack.pop(), AbcIndexing.multinameToType(multinameIndex, localData.abc, localData.getConstants()))); } @Override @@ -98,8 +98,8 @@ public class CoerceIns extends InstructionDefinition implements CoerceOrConvertT } @Override - public GraphTargetItem getTargetType(AVM2ConstantPool constants, AVM2Instruction ins) { + public GraphTargetItem getTargetType(ABC abc, AVM2ConstantPool constants, AVM2Instruction ins) { int multinameIndex = ins.operands[0]; - return AbcIndexing.multinameToType(multinameIndex, constants); + return AbcIndexing.multinameToType(multinameIndex, abc, constants); } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/CoerceOIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/CoerceOIns.java index eb7a76787..41fcdf1ec 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/CoerceOIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/CoerceOIns.java @@ -64,7 +64,7 @@ public class CoerceOIns extends InstructionDefinition implements CoerceOrConvert } @Override - public GraphTargetItem getTargetType(AVM2ConstantPool constants, AVM2Instruction ins) { + public GraphTargetItem getTargetType(ABC abc, AVM2ConstantPool constants, AVM2Instruction ins) { return new TypeItem(DottedChain.OBJECT); } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/CoerceOrConvertTypeIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/CoerceOrConvertTypeIns.java index a971cb18f..c887bbbfb 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/CoerceOrConvertTypeIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/CoerceOrConvertTypeIns.java @@ -16,6 +16,7 @@ */ package com.jpexs.decompiler.flash.abc.avm2.instructions.types; +import com.jpexs.decompiler.flash.abc.ABC; import com.jpexs.decompiler.flash.abc.avm2.AVM2ConstantPool; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; import com.jpexs.decompiler.graph.GraphTargetItem; @@ -30,9 +31,10 @@ public interface CoerceOrConvertTypeIns { /** * Get target type of coercing or converting. * + * @param abc ABC * @param constants Constants * @param ins Instruction * @return Target type */ - public GraphTargetItem getTargetType(AVM2ConstantPool constants, AVM2Instruction ins); + public GraphTargetItem getTargetType(ABC abc, AVM2ConstantPool constants, AVM2Instruction ins); } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/CoerceSIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/CoerceSIns.java index 8499a8313..c62afd93f 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/CoerceSIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/CoerceSIns.java @@ -64,7 +64,7 @@ public class CoerceSIns extends InstructionDefinition implements CoerceOrConvert @Override public void translate(AVM2LocalData localData, TranslateStack stack, AVM2Instruction ins, List output, String path) { - stack.push(new CoerceAVM2Item(ins, localData.lineStartInstruction, stack.pop(), getTargetType(localData.getConstants(), ins))); + stack.push(new CoerceAVM2Item(ins, localData.lineStartInstruction, stack.pop(), getTargetType(localData.abc, localData.getConstants(), ins))); } @Override @@ -78,7 +78,7 @@ public class CoerceSIns extends InstructionDefinition implements CoerceOrConvert } @Override - public GraphTargetItem getTargetType(AVM2ConstantPool constants, AVM2Instruction ins) { + public GraphTargetItem getTargetType(ABC abc, AVM2ConstantPool constants, AVM2Instruction ins) { return new TypeItem(DottedChain.STRING); } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/ConvertBIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/ConvertBIns.java index 8f730879f..00a195e49 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/ConvertBIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/ConvertBIns.java @@ -53,7 +53,7 @@ public class ConvertBIns extends InstructionDefinition implements CoerceOrConver @Override public void translate(AVM2LocalData localData, TranslateStack stack, AVM2Instruction ins, List output, String path) { - stack.push(new ConvertAVM2Item(ins, localData.lineStartInstruction, stack.pop(), getTargetType(localData.getConstants(), ins))); + stack.push(new ConvertAVM2Item(ins, localData.lineStartInstruction, stack.pop(), getTargetType(localData.abc, localData.getConstants(), ins))); } @Override @@ -67,7 +67,7 @@ public class ConvertBIns extends InstructionDefinition implements CoerceOrConver } @Override - public GraphTargetItem getTargetType(AVM2ConstantPool constants, AVM2Instruction ins) { + public GraphTargetItem getTargetType(ABC abc, AVM2ConstantPool constants, AVM2Instruction ins) { return new TypeItem(DottedChain.BOOLEAN); } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/ConvertDIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/ConvertDIns.java index 00e7382c6..7744283b5 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/ConvertDIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/ConvertDIns.java @@ -53,7 +53,7 @@ public class ConvertDIns extends InstructionDefinition implements CoerceOrConver @Override public void translate(AVM2LocalData localData, TranslateStack stack, AVM2Instruction ins, List output, String path) { - stack.push(new ConvertAVM2Item(ins, localData.lineStartInstruction, stack.pop(), getTargetType(localData.getConstants(), ins))); + stack.push(new ConvertAVM2Item(ins, localData.lineStartInstruction, stack.pop(), getTargetType(localData.abc, localData.getConstants(), ins))); } @Override @@ -67,7 +67,7 @@ public class ConvertDIns extends InstructionDefinition implements CoerceOrConver } @Override - public GraphTargetItem getTargetType(AVM2ConstantPool constants, AVM2Instruction ins) { + public GraphTargetItem getTargetType(ABC abc, AVM2ConstantPool constants, AVM2Instruction ins) { return new TypeItem(DottedChain.NUMBER); } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/ConvertIIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/ConvertIIns.java index 760a47a75..0457652f6 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/ConvertIIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/ConvertIIns.java @@ -53,7 +53,7 @@ public class ConvertIIns extends InstructionDefinition implements CoerceOrConver @Override public void translate(AVM2LocalData localData, TranslateStack stack, AVM2Instruction ins, List output, String path) { - stack.push(new ConvertAVM2Item(ins, localData.lineStartInstruction, stack.pop(), getTargetType(localData.getConstants(), ins))); + stack.push(new ConvertAVM2Item(ins, localData.lineStartInstruction, stack.pop(), getTargetType(localData.abc, localData.getConstants(), ins))); } @Override @@ -67,7 +67,7 @@ public class ConvertIIns extends InstructionDefinition implements CoerceOrConver } @Override - public GraphTargetItem getTargetType(AVM2ConstantPool constants, AVM2Instruction ins) { + public GraphTargetItem getTargetType(ABC abc, AVM2ConstantPool constants, AVM2Instruction ins) { return new TypeItem(DottedChain.INT); } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/ConvertOIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/ConvertOIns.java index 4e84115c7..da7b562a8 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/ConvertOIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/ConvertOIns.java @@ -63,7 +63,7 @@ public class ConvertOIns extends InstructionDefinition implements CoerceOrConver @Override public void translate(AVM2LocalData localData, TranslateStack stack, AVM2Instruction ins, List output, String path) { - stack.push(new ConvertAVM2Item(ins, localData.lineStartInstruction, stack.pop(), getTargetType(localData.getConstants(), ins))); + stack.push(new ConvertAVM2Item(ins, localData.lineStartInstruction, stack.pop(), getTargetType(localData.abc, localData.getConstants(), ins))); } @Override @@ -77,7 +77,7 @@ public class ConvertOIns extends InstructionDefinition implements CoerceOrConver } @Override - public GraphTargetItem getTargetType(AVM2ConstantPool constants, AVM2Instruction ins) { + public GraphTargetItem getTargetType(ABC abc, AVM2ConstantPool constants, AVM2Instruction ins) { return new TypeItem(DottedChain.OBJECT); } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/ConvertSIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/ConvertSIns.java index d9c62c5a0..ecb4a63e4 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/ConvertSIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/ConvertSIns.java @@ -53,7 +53,7 @@ public class ConvertSIns extends InstructionDefinition implements CoerceOrConver @Override public void translate(AVM2LocalData localData, TranslateStack stack, AVM2Instruction ins, List output, String path) { - stack.push(new ConvertAVM2Item(ins, localData.lineStartInstruction, stack.pop(), getTargetType(localData.getConstants(), ins))); + stack.push(new ConvertAVM2Item(ins, localData.lineStartInstruction, stack.pop(), getTargetType(localData.abc, localData.getConstants(), ins))); } @Override @@ -67,7 +67,7 @@ public class ConvertSIns extends InstructionDefinition implements CoerceOrConver } @Override - public GraphTargetItem getTargetType(AVM2ConstantPool constants, AVM2Instruction ins) { + public GraphTargetItem getTargetType(ABC abc, AVM2ConstantPool constants, AVM2Instruction ins) { return new TypeItem(DottedChain.STRING); } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/ConvertUIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/ConvertUIns.java index 8abe18c86..7b2576de1 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/ConvertUIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/ConvertUIns.java @@ -53,7 +53,7 @@ public class ConvertUIns extends InstructionDefinition implements CoerceOrConver @Override public void translate(AVM2LocalData localData, TranslateStack stack, AVM2Instruction ins, List output, String path) { - stack.push(new ConvertAVM2Item(ins, localData.lineStartInstruction, stack.pop(), getTargetType(localData.getConstants(), ins))); + stack.push(new ConvertAVM2Item(ins, localData.lineStartInstruction, stack.pop(), getTargetType(localData.abc, localData.getConstants(), ins))); } @Override @@ -67,7 +67,7 @@ public class ConvertUIns extends InstructionDefinition implements CoerceOrConver } @Override - public GraphTargetItem getTargetType(AVM2ConstantPool constants, AVM2Instruction ins) { + public GraphTargetItem getTargetType(ABC abc, AVM2ConstantPool constants, AVM2Instruction ins) { return new TypeItem(DottedChain.UINT); } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/IsTypeIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/IsTypeIns.java index 83fb9373e..ff280537c 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/IsTypeIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/IsTypeIns.java @@ -46,7 +46,7 @@ public class IsTypeIns extends InstructionDefinition { public void translate(AVM2LocalData localData, TranslateStack stack, AVM2Instruction ins, List output, String path) { int multinameIndex = ins.operands[0]; GraphTargetItem value = stack.pop(); - stack.push(new IsTypeAVM2Item(ins, localData.lineStartInstruction, value, new FullMultinameAVM2Item(false, ins, localData.lineStartInstruction, multinameIndex, localData.abc.constants.getMultiname(multinameIndex).getName(localData.getConstants(), new ArrayList<>(), true, true)))); + stack.push(new IsTypeAVM2Item(ins, localData.lineStartInstruction, value, new FullMultinameAVM2Item(false, ins, localData.lineStartInstruction, multinameIndex, localData.abc.constants.getMultiname(multinameIndex).getName(localData.abc, localData.getConstants(), new ArrayList<>(), true, true)))); } @Override diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/AVM2Item.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/AVM2Item.java index 026176916..716526d74 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/AVM2Item.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/AVM2Item.java @@ -17,6 +17,7 @@ package com.jpexs.decompiler.flash.abc.avm2.model; import com.jpexs.decompiler.flash.IdentifiersDeobfuscation; +import com.jpexs.decompiler.flash.SWF; import com.jpexs.decompiler.flash.SourceGeneratorLocalData; import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; import com.jpexs.decompiler.flash.abc.avm2.graph.AVM2GraphTargetDialect; @@ -193,13 +194,14 @@ public abstract class AVM2Item extends GraphTargetItem { /** * Gets local register name. + * @param swf SWF * @param localRegNames Local register names * @param reg Register * @return Local register name */ - public static String localRegName(HashMap localRegNames, int reg) { + public static String localRegName(SWF swf, HashMap localRegNames, int reg) { if (localRegNames.containsKey(reg)) { - return IdentifiersDeobfuscation.printIdentifier(true, localRegNames.get(reg)); + return IdentifiersDeobfuscation.printIdentifier(swf, true, localRegNames.get(reg)); } else { if (reg == 0) { return "this"; diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/ClassAVM2Item.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/ClassAVM2Item.java index 825756a14..73d5b03eb 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/ClassAVM2Item.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/ClassAVM2Item.java @@ -65,11 +65,11 @@ public class ClassAVM2Item extends AVM2Item { public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) { if (classNameAsStr != null) { if (localData.fullyQualifiedNames != null && localData.fullyQualifiedNames.contains(classNameAsStr)) { - return writer.append(classNameAsStr.toPrintableString(true)); + return writer.append(classNameAsStr.toPrintableString(localData.swf, true)); } - return writer.append(IdentifiersDeobfuscation.printIdentifier(true, classNameAsStr.getLast())); + return writer.append(IdentifiersDeobfuscation.printIdentifier(localData.abc.getSwf(), true, classNameAsStr.getLast())); } - return writer.append(className.getName(localData.constantsAvm2, localData.fullyQualifiedNames, false, true)); + return writer.append(className.getName(localData.abc, localData.constantsAvm2, localData.fullyQualifiedNames, false, true)); } @Override diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/DecLocalAVM2Item.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/DecLocalAVM2Item.java index 84ce0753e..74beafa3e 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/DecLocalAVM2Item.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/DecLocalAVM2Item.java @@ -47,7 +47,7 @@ public class DecLocalAVM2Item extends AVM2Item { @Override public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) { - writer.append(localRegName(localData.localRegNames, regIndex)); + writer.append(localRegName(localData.abc.getSwf(), localData.localRegNames, regIndex)); return writer.append("--"); } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/FindDefAVM2Item.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/FindDefAVM2Item.java index 1f82e8058..62132e902 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/FindDefAVM2Item.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/FindDefAVM2Item.java @@ -50,7 +50,7 @@ public class FindDefAVM2Item extends AVM2Item { @Override public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) { - return writer.append(propertyName.getNamespace(localData.constantsAvm2).getName(localData.constantsAvm2).toPrintableString(true)); //assume not null name + return writer.append(propertyName.getNamespace(localData.constantsAvm2).getName(localData.constantsAvm2).toPrintableString(localData.swf, true)); //assume not null name } @Override diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/FullMultinameAVM2Item.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/FullMultinameAVM2Item.java index 8facc70a9..8650747a7 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/FullMultinameAVM2Item.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/FullMultinameAVM2Item.java @@ -156,7 +156,7 @@ public class FullMultinameAVM2Item extends AVM2Item { if (name != null) { cname = name.toString(LocalData.create(new ArrayList<>(), null, abc, localRegNames, fullyQualifiedNames, seenMethods, ScriptExportMode.AS, -1)); } else { - cname = (abc.constants.getMultiname(multinameIndex).getName(abc.constants, fullyQualifiedNames, true, true)); + cname = (abc.constants.getMultiname(multinameIndex).getName(abc, abc.constants, fullyQualifiedNames, true, true)); } String cns = ""; if (namespace != null) { @@ -164,7 +164,7 @@ public class FullMultinameAVM2Item extends AVM2Item { } else { Namespace ns = abc.constants.getMultiname(multinameIndex).getNamespace(abc.constants); if ((ns != null) && (ns.name_index != 0)) { - cns = ns.getName(abc.constants).toPrintableString(true); + cns = ns.getName(abc.constants).toPrintableString(abc.getSwf(), true); } } return cname.equals(tname) && cns.isEmpty(); @@ -206,7 +206,7 @@ public class FullMultinameAVM2Item extends AVM2Item { AVM2ConstantPool constants = localData.constantsAvm2; List fullyQualifiedNames = property ? new ArrayList<>() : localData.fullyQualifiedNames; if (multinameIndex > 0 && multinameIndex < constants.getMultinameCount()) { - String simpleName = constants.getMultiname(multinameIndex).getName(constants, fullyQualifiedNames, true, false); + String simpleName = constants.getMultiname(multinameIndex).getName(localData.abc, constants, fullyQualifiedNames, true, false); if ("*".equals(simpleName)) { writer.append("*"); } else { @@ -215,7 +215,7 @@ public class FullMultinameAVM2Item extends AVM2Item { DottedChain customNs = customNsRef.getVal(); if (customNs != null) { String nsname = customNs.getLast(); - String identifier = IdentifiersDeobfuscation.printIdentifier(true, nsname); + String identifier = IdentifiersDeobfuscation.printIdentifier(localData.abc.getSwf(), true, nsname); writer.hilightSpecial(identifier, HighlightSpecialType.TYPE_NAME, customNs.toRawString()); writer.appendNoHilight("::"); } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/GetLexAVM2Item.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/GetLexAVM2Item.java index 4e9f0cfd5..992788bf2 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/GetLexAVM2Item.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/GetLexAVM2Item.java @@ -17,6 +17,7 @@ package com.jpexs.decompiler.flash.abc.avm2.model; import com.jpexs.decompiler.flash.IdentifiersDeobfuscation; +import com.jpexs.decompiler.flash.abc.ABC; import com.jpexs.decompiler.flash.abc.avm2.AVM2ConstantPool; import com.jpexs.decompiler.flash.abc.types.Multiname; import com.jpexs.decompiler.flash.helpers.GraphTextWriter; @@ -65,17 +66,18 @@ public class GetLexAVM2Item extends AVM2Item { * @param instruction Instruction * @param lineStartIns Line start instruction * @param propertyName Property name + * @param abc ABC * @param constants Constants * @param type Type * @param callType Call type * @param isStatic Is static */ - public GetLexAVM2Item(GraphSourceItem instruction, GraphSourceItem lineStartIns, Multiname propertyName, AVM2ConstantPool constants, GraphTargetItem type, GraphTargetItem callType, boolean isStatic) { + public GetLexAVM2Item(GraphSourceItem instruction, GraphSourceItem lineStartIns, Multiname propertyName, ABC abc, AVM2ConstantPool constants, GraphTargetItem type, GraphTargetItem callType, boolean isStatic) { super(instruction, lineStartIns, PRECEDENCE_PRIMARY); this.propertyName = propertyName; this.type = type; this.callType = callType; - this.fullPropertyName = propertyName.getNameWithNamespace(constants, true); + this.fullPropertyName = propertyName.getNameWithNamespace(abc, constants, true); this.isStatic = isStatic; } @@ -94,7 +96,7 @@ public class GetLexAVM2Item extends AVM2Item { DottedChain customNs = customNsRef.getVal(); if (customNs != null) { String nsname = customNs.getLast(); - String identifier = IdentifiersDeobfuscation.printIdentifier(true, nsname); + String identifier = IdentifiersDeobfuscation.printIdentifier(localData.abc.getSwf(), true, nsname); writer.hilightSpecial(identifier, HighlightSpecialType.TYPE_NAME, customNs.toRawString()); writer.appendNoHilight("::"); getSrcData().localName = nsname + "::" + localName; diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/GetSlotAVM2Item.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/GetSlotAVM2Item.java index c7c89d20f..2545306ee 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/GetSlotAVM2Item.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/GetSlotAVM2Item.java @@ -93,7 +93,7 @@ public class GetSlotAVM2Item extends AVM2Item { if (slotName == null) { return slotObject.toString(localData) + ".§§slot[" + slotIndex + "]"; } - return slotName.getName(localData.constantsAvm2, localData.fullyQualifiedNames, false, true); + return slotName.getName(localData.abc, localData.constantsAvm2, localData.fullyQualifiedNames, false, true); } public GraphTextWriter getName(GraphTextWriter writer, LocalData localData) throws InterruptedException { diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/IncLocalAVM2Item.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/IncLocalAVM2Item.java index a8187179b..608ca1922 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/IncLocalAVM2Item.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/IncLocalAVM2Item.java @@ -47,7 +47,7 @@ public class IncLocalAVM2Item extends AVM2Item { @Override public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) { - writer.append(localRegName(localData.localRegNames, regIndex)); + writer.append(localRegName(localData.abc.getSwf(), localData.localRegNames, regIndex)); return writer.append("++"); } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/LocalRegAVM2Item.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/LocalRegAVM2Item.java index c2b811e81..8030cb2d6 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/LocalRegAVM2Item.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/LocalRegAVM2Item.java @@ -91,7 +91,7 @@ public class LocalRegAVM2Item extends AVM2Item { return computedValue.toString(writer, localData); } - String localName = localRegName(localData.localRegNames, regIndex); + String localName = localRegName(localData.abc.getSwf(), localData.localRegNames, regIndex); getSrcData().localName = localName; return writer.append(localName); } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/NameSpaceAVM2Item.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/NameSpaceAVM2Item.java index 8c7ded150..c2f31f767 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/NameSpaceAVM2Item.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/NameSpaceAVM2Item.java @@ -60,7 +60,7 @@ public class NameSpaceAVM2Item extends AVM2Item { String nsname = dc != null ? dc.getLast() : null; if (nsname != null) { - String identifier = IdentifiersDeobfuscation.printIdentifier(true, nsname); + String identifier = IdentifiersDeobfuscation.printIdentifier(localData.abc.getSwf(), true, nsname); if (identifier != null && !identifier.isEmpty()) { writer.append(identifier); return writer; diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/NewFunctionAVM2Item.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/NewFunctionAVM2Item.java index 0b8e2c387..84d96c456 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/NewFunctionAVM2Item.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/NewFunctionAVM2Item.java @@ -125,7 +125,7 @@ public class NewFunctionAVM2Item extends AVM2Item { writer.appendNoHilight(methodIndex); writer.newLine(); } - abc.method_info.get(methodIndex).getReturnTypeStr(writer, abc.constants, localData.fullyQualifiedNames); + abc.method_info.get(methodIndex).getReturnTypeStr(writer, abc, abc.constants, localData.fullyQualifiedNames); writer.startBlock(); if (body != null) { List callStack = new ArrayList<>(localData.callStack); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/PackageAVM2Item.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/PackageAVM2Item.java index 8604a84de..18b5f4951 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/PackageAVM2Item.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/PackageAVM2Item.java @@ -51,7 +51,7 @@ public class PackageAVM2Item extends AVM2Item { public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) throws InterruptedException { writer.appendNoHilight("package"); if (!packageName.isEmpty()) { - writer.appendNoHilight(" " + DottedChain.parseWithSuffix(packageName).toPrintableString(true)); + writer.appendNoHilight(" " + DottedChain.parseWithSuffix(packageName).toPrintableString(localData.swf, true)); } writer.startBlock(); Graph.graphToString(items, writer, localData); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/SetLocalAVM2Item.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/SetLocalAVM2Item.java index c38e6af12..74ba34dd0 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/SetLocalAVM2Item.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/SetLocalAVM2Item.java @@ -104,7 +104,7 @@ public class SetLocalAVM2Item extends AVM2Item implements SetTypeAVM2Item, Assig @Override public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) throws InterruptedException { - String localName = localRegName(localData.localRegNames, regIndex); + String localName = localRegName(localData.abc.getSwf(), localData.localRegNames, regIndex); getSrcData().localName = localName; writer.append(localName); if (hideValue) { diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/SetSlotAVM2Item.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/SetSlotAVM2Item.java index 57059113a..a7c8a944f 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/SetSlotAVM2Item.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/SetSlotAVM2Item.java @@ -152,7 +152,7 @@ public class SetSlotAVM2Item extends AVM2Item implements SetTypeAVM2Item, Assign if (slotName == null) { return slotObject.toString(localData) + ".§§slot[" + slotIndex + "]"; } - return slotName.getName(localData.constantsAvm2, localData.fullyQualifiedNames, false, true); + return slotName.getName(localData.abc, localData.constantsAvm2, localData.fullyQualifiedNames, false, true); } /** diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/ThisAVM2Item.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/ThisAVM2Item.java index f078a5f08..d153079b1 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/ThisAVM2Item.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/ThisAVM2Item.java @@ -114,9 +114,9 @@ public class ThisAVM2Item extends AVM2Item { if (showClassName) { if (className != null) { if (localData.fullyQualifiedNames != null && localData.fullyQualifiedNames.contains(className)) { - return writer.append(className.toPrintableString(true)).append(".this"); + return writer.append(className.toPrintableString(localData.swf, true)).append(".this"); } - return writer.append(IdentifiersDeobfuscation.printIdentifier(true, className.getLast())).append(".this"); + return writer.append(IdentifiersDeobfuscation.printIdentifier(localData.abc.getSwf(), true, className.getLast())).append(".this"); } } return writer.append("this"); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/clauses/DeclarationAVM2Item.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/clauses/DeclarationAVM2Item.java index 391090a9e..35657e901 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/clauses/DeclarationAVM2Item.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/clauses/DeclarationAVM2Item.java @@ -92,7 +92,7 @@ public class DeclarationAVM2Item extends AVM2Item { if (assignment instanceof LocalRegAVM2Item) { //for..in LocalRegAVM2Item lti = (LocalRegAVM2Item) assignment; - String localName = localRegName(localData.localRegNames, lti.regIndex); + String localName = localRegName(localData.abc.getSwf(), localData.localRegNames, lti.regIndex); HighlightData srcData = getSrcData(); srcData.localName = localName; srcData.declaration = true; @@ -116,7 +116,7 @@ public class DeclarationAVM2Item extends AVM2Item { if (assignment instanceof SetLocalAVM2Item) { SetLocalAVM2Item lti = (SetLocalAVM2Item) assignment; - String localName = localRegName(localData.localRegNames, lti.regIndex); + String localName = localRegName(localData.abc.getSwf(), localData.localRegNames, lti.regIndex); HighlightData srcData = getSrcData(); srcData.localName = localName; srcData.declaration = true; @@ -163,7 +163,7 @@ public class DeclarationAVM2Item extends AVM2Item { GraphTargetItem val = spti.value; srcData.declaredType = (type instanceof TypeItem) ? ((TypeItem) type).fullTypeName : DottedChain.ALL; writer.append("var "); - writer.append(IdentifiersDeobfuscation.printIdentifier(true, ((FullMultinameAVM2Item) spti.propertyName).resolvedMultinameName)); + writer.append(IdentifiersDeobfuscation.printIdentifier(localData.abc.getSwf(), true, ((FullMultinameAVM2Item) spti.propertyName).resolvedMultinameName)); writer.append(":"); type.appendTry(writer, localData); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/clauses/ExceptionAVM2Item.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/clauses/ExceptionAVM2Item.java index 830481475..974dcddd9 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/clauses/ExceptionAVM2Item.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/clauses/ExceptionAVM2Item.java @@ -47,7 +47,7 @@ public class ExceptionAVM2Item extends AVM2Item { @Override public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) { - return writer.append(exception.getVarName(localData.constantsAvm2, localData.fullyQualifiedNames)); + return writer.append(exception.getVarName(localData.abc, localData.constantsAvm2, localData.fullyQualifiedNames)); } @Override diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/clauses/TryAVM2Item.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/clauses/TryAVM2Item.java index c6da6cda7..2219bc140 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/clauses/TryAVM2Item.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/clauses/TryAVM2Item.java @@ -142,7 +142,7 @@ public class TryAVM2Item extends AVM2Item implements Block { for (int e = 0; e < catchExceptions.size(); e++) { writer.newLine(); writer.append("catch("); - String localName = catchExceptions.get(e).getVarName(localData.constantsAvm2, localData.fullyQualifiedNames); + String localName = catchExceptions.get(e).getVarName(localData.abc, localData.constantsAvm2, localData.fullyQualifiedNames); if (localName.isEmpty()) { localName = finCatchName; } @@ -153,10 +153,10 @@ public class TryAVM2Item extends AVM2Item implements Block { int eti = catchExceptions.get(e).type_index; - data.declaredType = eti <= 0 ? DottedChain.ALL : localData.constantsAvm2.getMultiname(eti).getNameWithNamespace(localData.constantsAvm2, true); + data.declaredType = eti <= 0 ? DottedChain.ALL : localData.constantsAvm2.getMultiname(eti).getNameWithNamespace(localData.abc, localData.constantsAvm2, true); writer.hilightSpecial(localName, HighlightSpecialType.TRY_NAME, e, data); writer.append(":"); - writer.hilightSpecial(catchExceptions.get(e).getTypeName(localData.constantsAvm2, localData.fullyQualifiedNames), HighlightSpecialType.TRY_TYPE, e); + writer.hilightSpecial(catchExceptions.get(e).getTypeName(localData.abc, localData.constantsAvm2, localData.fullyQualifiedNames), HighlightSpecialType.TRY_TYPE, e); writer.append(")"); List commands = catchCommands.get(e); appendBlock(null, writer, localData, commands); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/AVM2SourceGenerator.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/AVM2SourceGenerator.java index 3c1684cb2..ad3bf737a 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/AVM2SourceGenerator.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/AVM2SourceGenerator.java @@ -231,7 +231,7 @@ public class AVM2SourceGenerator implements SourceGenerator { Multiname m = ci.abc.instance_info.get(ci.index).getName(ci.abc.constants); if (m != null) { Namespace ns = ci.abc.instance_info.get(ci.index).getName(ci.abc.constants).getNamespace(ci.abc.constants); - String n = m.getName(ci.abc.constants, new ArrayList<>(), true, true /*FIXME!!*/); + String n = m.getName(ci.abc, ci.abc.constants, new ArrayList<>(), true, true /*FIXME!!*/); String nsn = ns == null ? null : ns.getRawName(ci.abc.constants); name_index = constants.getQnameId( n, @@ -253,7 +253,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(constants, null, true, true /*FIXME!!*/).equals(name)) { + if (t.getName(abc).getName(abc, constants, null, true, true /*FIXME!!*/).equals(name)) { name_index = t.name_index; break; } @@ -727,7 +727,7 @@ public class AVM2SourceGenerator implements SourceGenerator { if (t instanceof TraitSlotConst) { TraitSlotConst tsc = (TraitSlotConst) t; if (tsc.kindType == Trait.TRAIT_SLOT) { - if ("_skinParts".equals(tsc.getName(ci.abc).getName(ci.abc.constants, new ArrayList<>(), true, true))) { + if ("_skinParts".equals(tsc.getName(ci.abc).getName(ci.abc, ci.abc.constants, new ArrayList<>(), true, true))) { if (d.assignedValues.containsKey(tsc)) { if (d.assignedValues.get(tsc).value instanceof NewObjectAVM2Item) { NewObjectAVM2Item no = (NewObjectAVM2Item) d.assignedValues.get(tsc).value; @@ -1812,7 +1812,7 @@ public class AVM2SourceGenerator implements SourceGenerator { instanceInfo.super_index = abcIndex.getSelectedAbc().constants.getMultinameId(Multiname.createQName(false, str("Object"), namespace(Namespace.KIND_PACKAGE, "")), true); } if (instanceInfo.super_index != 0) { - int foundClass = abc.findClassByName(abc.constants.getMultiname(instanceInfo.super_index).getNameWithNamespace(abc.constants, true)); + int foundClass = abc.findClassByName(abc.constants.getMultiname(instanceInfo.super_index).getNameWithNamespace(abc, abc.constants, true)); if (foundClass > -1) { if (foundClass > minClassIndex) { minClassIndex = foundClass; @@ -1822,7 +1822,7 @@ public class AVM2SourceGenerator implements SourceGenerator { instanceInfo.interfaces = new int[((ClassAVM2Item) item).implementsOp.size()]; for (int i = 0; i < ((ClassAVM2Item) item).implementsOp.size(); i++) { instanceInfo.interfaces[i] = superIntName(localData, ((ClassAVM2Item) item).implementsOp.get(i)); - int foundIface = abc.findClassByName(abc.constants.getMultiname(instanceInfo.interfaces[i]).getNameWithNamespace(abc.constants, true)); + int foundIface = abc.findClassByName(abc.constants.getMultiname(instanceInfo.interfaces[i]).getNameWithNamespace(abc, abc.constants, true)); if (foundIface > -1) { if (foundIface > minClassIndex) { minClassIndex = foundIface; @@ -1845,7 +1845,7 @@ public class AVM2SourceGenerator implements SourceGenerator { GraphTargetItem un = ((InterfaceAVM2Item) item).superInterfaces.get(i); instanceInfo.interfaces[i] = superIntName(localData, un); - int foundIface = abc.findClassByName(abc.constants.getMultiname(instanceInfo.interfaces[i]).getNameWithNamespace(abc.constants, true)); + int foundIface = abc.findClassByName(abc.constants.getMultiname(instanceInfo.interfaces[i]).getNameWithNamespace(abc, abc.constants, true)); if (foundIface > -1) { if (foundIface > minClassIndex) { minClassIndex = foundIface; @@ -2342,7 +2342,7 @@ public class AVM2SourceGenerator implements SourceGenerator { for (Trait t : scriptInfo.traits.traits) { if (t instanceof TraitClass) { TraitClass tc = (TraitClass) t; - DottedChain className = tc.getName(abc).getNameWithNamespace(abc.constants, true); + DottedChain className = tc.getName(abc).getNameWithNamespace(abc, abc.constants, true); List parents = new ArrayList<>(); if (documentClass != null && documentClass.equals(className)) { @@ -2356,7 +2356,7 @@ public class AVM2SourceGenerator implements SourceGenerator { sinitcode.add(ins(AVM2Instructions.PushNull)); } else { - AbcIndexing.ClassIndex ci = abcIndex.findClass(AbcIndexing.multinameToType(abc.instance_info.get(tc.class_info).name_index, constants), abc, scriptIndex); + AbcIndexing.ClassIndex ci = abcIndex.findClass(AbcIndexing.multinameToType(abc.instance_info.get(tc.class_info).name_index, abc, constants), abc, scriptIndex); while (ci != null && ci.parent != null) { ci = ci.parent; Multiname origM = ci.abc.constants.getMultiname(ci.abc.instance_info.get(ci.index).name_index); @@ -2430,7 +2430,7 @@ public class AVM2SourceGenerator implements SourceGenerator { indices.add( abc.getSelectedAbc().constants.getMultinameId( Multiname.createQName(false, - abc.getSelectedAbc().constants.getStringId(superName.getName(a.constants, null, true, true /*FIXME!!! ???*/), true), + abc.getSelectedAbc().constants.getStringId(superName.getName(a, a.constants, null, true, true /*FIXME!!! ???*/), true), abc.getSelectedAbc().constants.getNamespaceId(superName.getNamespace(a.constants).kind, superName.getNamespace(a.constants).getName(a.constants), 0, true)), true) ); } @@ -2449,16 +2449,16 @@ public class AVM2SourceGenerator implements SourceGenerator { if (tsc.type_index == 0) { return TypeItem.UNBOUNDED; } - return AbcIndexing.multinameToType(tsc.type_index, abc.getSelectedAbc().constants); + return AbcIndexing.multinameToType(tsc.type_index, abc.getSelectedAbc(), abc.getSelectedAbc().constants); } if (t instanceof TraitMethodGetterSetter) { TraitMethodGetterSetter tmgs = (TraitMethodGetterSetter) t; if (tmgs.kindType == Trait.TRAIT_GETTER) { - return AbcIndexing.multinameToType(abc.getSelectedAbc().method_info.get(tmgs.method_info).ret_type, abc.getSelectedAbc().constants); + return AbcIndexing.multinameToType(abc.getSelectedAbc().method_info.get(tmgs.method_info).ret_type, abc.getSelectedAbc(), abc.getSelectedAbc().constants); } if (tmgs.kindType == Trait.TRAIT_SETTER) { if (abc.getSelectedAbc().method_info.get(tmgs.method_info).param_types.length > 0) { - return AbcIndexing.multinameToType(abc.getSelectedAbc().method_info.get(tmgs.method_info).param_types[0], abc.getSelectedAbc().constants); + return AbcIndexing.multinameToType(abc.getSelectedAbc().method_info.get(tmgs.method_info).param_types[0], abc.getSelectedAbc(), abc.getSelectedAbc().constants); } else { return TypeItem.UNBOUNDED; } @@ -2557,12 +2557,12 @@ public class AVM2SourceGenerator implements SourceGenerator { * @param outABCs Out ABCs */ public static void parentNames(AbcIndexing abc, int scriptIndex, int name_index, List indices, List names, List namespaces, List outABCs) { - AbcIndexing.ClassIndex ci = abc.findClass(new TypeItem(abc.getSelectedAbc().constants.getMultiname(name_index).getNameWithNamespace(abc.getSelectedAbc().constants, true /*FIXME!!*/)), abc.getSelectedAbc(), scriptIndex); + AbcIndexing.ClassIndex ci = abc.findClass(new TypeItem(abc.getSelectedAbc().constants.getMultiname(name_index).getNameWithNamespace(abc.getSelectedAbc(), abc.getSelectedAbc().constants, true /*FIXME!!*/)), abc.getSelectedAbc(), scriptIndex); while (ci != null) { int ni = ci.abc.instance_info.get(ci.index).name_index; indices.add(ni); outABCs.add(ci.abc); - names.add(ci.abc.constants.getMultiname(ni).getName(ci.abc.constants, null, true, true/*FIXME!!*/)); + names.add(ci.abc.constants.getMultiname(ni).getName(ci.abc, ci.abc.constants, null, true, true/*FIXME!!*/)); namespaces.add(ci.abc.constants.getMultiname(ni).getNamespace(ci.abc.constants).getName(ci.abc.constants).toRawString()); ci = ci.parent; } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/AbcIndexing.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/AbcIndexing.java index 469ace5c9..b1f9f7f90 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/AbcIndexing.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/AbcIndexing.java @@ -512,7 +512,7 @@ public final class AbcIndexing { */ @Override public String toString() { - return abc.constants.getMultiname(abc.instance_info.get(index).name_index).getNameWithNamespace(abc.constants, true).toPrintableString(true); + return abc.constants.getMultiname(abc.instance_info.get(index).name_index).getNameWithNamespace(abc, abc.constants, true).toPrintableString(abc.getSwf(), true); } /** @@ -627,7 +627,7 @@ public final class AbcIndexing { } private void getClassIndexTraitNames(List ret, List staticRet, ClassIndex ci, boolean getStatic, boolean getInstance, boolean getInheritance, Set used) { - GraphTargetItem ciName = multinameToType(ci.abc.instance_info.get(ci.index).name_index, ci.abc.constants); + GraphTargetItem ciName = multinameToType(ci.abc.instance_info.get(ci.index).name_index, ci.abc, ci.abc.constants); boolean isObject = ciName.equals(new TypeItem("Object")); List ignoredObjectTraits = Arrays.asList("_init", "_dontEnumPrototype", "_setPropertyIsEnumerable"); @@ -890,7 +890,7 @@ public final class AbcIndexing { AbcIndexing.ClassIndex ci = findClass(prop.parent, prop.abc, null); if (ci != null && ci.parent != null && (prop.abc == null || prop.propNsIndex == 0)) { AbcIndexing.ClassIndex ciParent = ci.parent; - DottedChain parentClass = ciParent.abc.instance_info.get(ciParent.index).getName(ciParent.abc.constants).getNameWithNamespace(ciParent.abc.constants, true); + DottedChain parentClass = ciParent.abc.instance_info.get(ciParent.index).getName(ciParent.abc.constants).getNameWithNamespace(ciParent.abc, ciParent.abc.constants, true); TraitIndex pti = findProperty(new PropertyDef(prop.propName, new TypeItem(parentClass), prop.getPropNsString()), findStatic, findInstance, findProtected, foundStatic); if (pti != null) { return pti; @@ -920,10 +920,11 @@ public final class AbcIndexing { /** * Converts multiname to type * @param m_index Multiname index + * @param abc ABC * @param constants AVM2 constant pool * @return Type */ - public static GraphTargetItem multinameToType(int m_index, AVM2ConstantPool constants) { + public static GraphTargetItem multinameToType(int m_index, ABC abc, AVM2ConstantPool constants) { if (m_index == 0) { return TypeItem.UNBOUNDED; } @@ -932,13 +933,13 @@ public final class AbcIndexing { return null; } if (m.kind == Multiname.TYPENAME) { - GraphTargetItem obj = multinameToType(m.qname_index, constants); + GraphTargetItem obj = multinameToType(m.qname_index, abc, constants); if (obj == null) { return null; } List params = new ArrayList<>(); for (int pm : m.params) { - GraphTargetItem r = multinameToType(pm, constants); + GraphTargetItem r = multinameToType(pm, abc, constants); if (r == null) { return null; } @@ -950,9 +951,9 @@ public final class AbcIndexing { return new ApplyTypeAVM2Item(null, null, obj, params); } else { if (m.namespace_index != 0 && m.getNamespace(constants).kind == Namespace.KIND_PRIVATE) { - return new TypeItem(m.getName(constants, new ArrayList<>(), true, true), "ns:" + m.namespace_index); + return new TypeItem(m.getName(abc, constants, new ArrayList<>(), true, true), "ns:" + m.namespace_index); } - return new TypeItem(m.getNameWithNamespace(constants, true)); + return new TypeItem(m.getNameWithNamespace(abc, constants, true)); } } @@ -968,12 +969,12 @@ public final class AbcIndexing { if (tmgs.kindType == Trait.TRAIT_SETTER) { return TypeItem.UNBOUNDED; } - return multinameToType(abc.method_info.get(tmgs.method_info).ret_type, abc.constants); + return multinameToType(abc.method_info.get(tmgs.method_info).ret_type, abc, abc.constants); } if (t instanceof TraitFunction) { TraitFunction tf = (TraitFunction) t; - return multinameToType(abc.method_info.get(tf.method_info).ret_type, abc.constants); + return multinameToType(abc.method_info.get(tf.method_info).ret_type, abc, abc.constants); } return TypeItem.UNBOUNDED; @@ -985,16 +986,16 @@ public final class AbcIndexing { if (tsc.type_index == 0) { return TypeItem.UNBOUNDED; } - return multinameToType(tsc.type_index, abc.constants); + return multinameToType(tsc.type_index, abc, abc.constants); } if (t instanceof TraitMethodGetterSetter) { TraitMethodGetterSetter tmgs = (TraitMethodGetterSetter) t; if (tmgs.kindType == Trait.TRAIT_GETTER) { - return multinameToType(abc.method_info.get(tmgs.method_info).ret_type, abc.constants); + return multinameToType(abc.method_info.get(tmgs.method_info).ret_type, abc, abc.constants); } if (tmgs.kindType == Trait.TRAIT_SETTER) { if (abc.method_info.get(tmgs.method_info).param_types.length > 0) { - return multinameToType(abc.method_info.get(tmgs.method_info).param_types[0], abc.constants); + return multinameToType(abc.method_info.get(tmgs.method_info).param_types[0], abc, abc.constants); } else { return TypeItem.UNBOUNDED; } @@ -1025,13 +1026,13 @@ public final class AbcIndexing { propValue = new ValueKind(tsc.value_index, tsc.value_kind); } if (map != null) { - PropertyDef dp = new PropertyDef(t.getName(abc).getName(abc.constants, new ArrayList<>() /*?*/, true, false), multinameToType(name_index, abc.constants), abc, abc.constants.getMultiname(t.name_index).namespace_index); - map.put(dp, new TraitIndex(t, abc, getTraitReturnType(abc, t), getTraitCallReturnType(abc, t), propValue, multinameToType(name_index, abc.constants), scriptIndex)); + PropertyDef dp = new PropertyDef(t.getName(abc).getName(abc, abc.constants, new ArrayList<>() /*?*/, true, false), multinameToType(name_index, abc, abc.constants), abc, abc.constants.getMultiname(t.name_index).namespace_index); + map.put(dp, new TraitIndex(t, abc, getTraitReturnType(abc, t), getTraitCallReturnType(abc, t), propValue, multinameToType(name_index, abc, abc.constants), scriptIndex)); } if (mapNs != null) { Multiname m = abc.constants.getMultiname(t.name_index); - PropertyNsDef ndp = new PropertyNsDef(t.getName(abc).getName(abc.constants, new ArrayList<>() /*?*/, true, true/*FIXME ???*/), m == null || m.namespace_index == 0 ? DottedChain.EMPTY : m.getNamespace(abc.constants).getName(abc.constants), abc, m == null ? 0 : m.namespace_index); - TraitIndex ti = new TraitIndex(t, abc, getTraitReturnType(abc, t), getTraitCallReturnType(abc, t), propValue, multinameToType(name_index, abc.constants), scriptIndex); + PropertyNsDef ndp = new PropertyNsDef(t.getName(abc).getName(abc, abc.constants, new ArrayList<>() /*?*/, true, true/*FIXME ???*/), m == null || m.namespace_index == 0 ? DottedChain.EMPTY : m.getNamespace(abc.constants).getName(abc.constants), abc, m == null ? 0 : m.namespace_index); + TraitIndex ti = new TraitIndex(t, abc, getTraitReturnType(abc, t), getTraitCallReturnType(abc, t), propValue, multinameToType(name_index, abc, abc.constants), scriptIndex); if (!mapNs.containsKey(ndp)) { mapNs.put(ndp, ti); } @@ -1136,7 +1137,7 @@ public final class AbcIndexing { Integer classScriptIndex = nsKind == Namespace.KIND_PACKAGE ? null : i; ClassIndex cindex = new ClassIndex(tc.class_info, abc, null, classScriptIndex); addedClasses.add(cindex); - GraphTargetItem cname = multinameToType(ii.name_index, abc.constants); + GraphTargetItem cname = multinameToType(ii.name_index, abc, abc.constants); classes.put(new ClassDef(cname, abc, classScriptIndex), cindex); indexTraits(abc, ii.name_index, ii.instance_traits, instanceProperties, instanceNsProperties, i); @@ -1148,7 +1149,7 @@ public final class AbcIndexing { for (ClassIndex cindex : addedClasses) { int parentClassName = abc.instance_info.get(cindex.index).super_index; if (parentClassName > 0) { - TypeItem parentClass = new TypeItem(abc.constants.getMultiname(parentClassName).getNameWithNamespace(abc.constants, true)); + TypeItem parentClass = new TypeItem(abc.constants.getMultiname(parentClassName).getNameWithNamespace(abc, abc.constants, true)); ClassIndex parentClassIndex = findClass(parentClass, abc, null); if (parentClassIndex == null) { //Parent class can be deleted, do not check. TODO: handle this better @@ -1210,14 +1211,14 @@ public final class AbcIndexing { * @return True if class is instance of another class */ public boolean isInstanceOf(ABC abc, int classIndex, DottedChain searchClassName) { - DottedChain clsName = abc.instance_info.get(classIndex).getName(abc.constants).getNameWithNamespace(abc.constants, false); + DottedChain clsName = abc.instance_info.get(classIndex).getName(abc.constants).getNameWithNamespace(abc, abc.constants, false); if (searchClassName.equals(clsName)) { return true; } if (abc.instance_info.get(classIndex).super_index == 0) { return false; } - DottedChain parentClassName = abc.constants.getMultiname(abc.instance_info.get(classIndex).super_index).getNameWithNamespace(abc.constants, false); + DottedChain parentClassName = abc.constants.getMultiname(abc.instance_info.get(classIndex).super_index).getNameWithNamespace(abc, abc.constants, false); AbcIndexing.ClassIndex ci = findClass(new TypeItem(parentClassName), abc, null); if (ci == null) { diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/CallAVM2Item.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/CallAVM2Item.java index cac553749..0d75b6a74 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/CallAVM2Item.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/CallAVM2Item.java @@ -178,7 +178,7 @@ public class CallAVM2Item extends AVM2Item { if (mi.param_types[i] == 0) { type = TypeItem.UNBOUNDED; } else { - type = new TypeItem(abc.constants.getMultiname(mi.param_types[i]).getNameWithNamespace(abc.constants, true /*??*/)); + type = new TypeItem(abc.constants.getMultiname(mi.param_types[i]).getNameWithNamespace(abc, abc.constants, true /*??*/)); } arguments.set(i, AVM2SourceGenerator.handleAndOrCoerce(arguments.get(i), type)); } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/NameAVM2Item.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/NameAVM2Item.java index 6f82b6369..0a733c72f 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/NameAVM2Item.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/NameAVM2Item.java @@ -434,7 +434,7 @@ public class NameAVM2Item 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(abcV).getName(constants, null, true, true).equals(variableName)) { + if (t.getName(abcV).getName(abcV, constants, null, true, true).equals(variableName)) { if (t instanceof TraitSlotConst) { if (!localData.traitUsages.containsKey(b)) { localData.traitUsages.put(b, new ArrayList<>()); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/PropertyAVM2Item.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/PropertyAVM2Item.java index fc366c2b1..091aa8ab0 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/PropertyAVM2Item.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/PropertyAVM2Item.java @@ -217,11 +217,11 @@ 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(constants, null, true, true).equals(propertyName)) { + if (t.getName(abc).getName(abc, constants, null, true, true).equals(propertyName)) { if (t instanceof TraitSlotConst) { TraitSlotConst tsc = (TraitSlotConst) t; objType = new TypeItem(DottedChain.FUNCTION); - propType = AbcIndexing.multinameToType(tsc.type_index, constants); + propType = AbcIndexing.multinameToType(tsc.type_index, abc, constants); propIndex = tsc.name_index; if (!localData.traitUsages.containsKey(b)) { localData.traitUsages.put(b, new ArrayList<>()); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/UnresolvedAVM2Item.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/UnresolvedAVM2Item.java index f685cbf24..1f5a6976d 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/UnresolvedAVM2Item.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/UnresolvedAVM2Item.java @@ -625,7 +625,7 @@ public class UnresolvedAVM2Item extends AssignableAVM2Item { if (ci == null) { ntype = new TypeItem("Object"); } else { - ntype = new TypeItem(ci.abc.instance_info.get(ci.index).getName(ci.abc.constants).getNameWithNamespace(ci.abc.constants, true)); + ntype = new TypeItem(ci.abc.instance_info.get(ci.index).getName(ci.abc.constants).getNameWithNamespace(ci.abc, ci.abc.constants, true)); } } @@ -650,7 +650,7 @@ public class UnresolvedAVM2Item extends AssignableAVM2Item { } if (mustBeType) { - throw new CompilationException(name.toPrintableString(true) + " is not an existing type", line); + throw new CompilationException(name.toPrintableString(abcIndex.getSelectedAbc().getSwf(), true) + " is not an existing type", line); } resolved = null; GraphTargetItem ret = null; diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/ABCException.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/ABCException.java index b2bcb75c3..02c4e6460 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/ABCException.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/ABCException.java @@ -16,6 +16,7 @@ */ package com.jpexs.decompiler.flash.abc.types; +import com.jpexs.decompiler.flash.abc.ABC; import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; import com.jpexs.decompiler.flash.abc.avm2.AVM2ConstantPool; import com.jpexs.decompiler.flash.abc.avm2.ConvertException; @@ -78,24 +79,26 @@ public class ABCException implements Serializable, Cloneable { /** * To string. + * @param ABC abc * @param constants AVM2 constant pool * @param fullyQualifiedNames Fully qualified names * @return String */ - public String toString(AVM2ConstantPool constants, List fullyQualifiedNames) { - return "Exception: startServer=" + Helper.formatAddress(start) + " end=" + Helper.formatAddress(end) + " target=" + target + " type=\"" + getTypeName(constants, fullyQualifiedNames) + "\" name=\"" + getVarName(constants, fullyQualifiedNames) + "\""; + public String toString(ABC abc, AVM2ConstantPool constants, List fullyQualifiedNames) { + return "Exception: startServer=" + Helper.formatAddress(start) + " end=" + Helper.formatAddress(end) + " target=" + target + " type=\"" + getTypeName(abc, constants, fullyQualifiedNames) + "\" name=\"" + getVarName(abc, constants, fullyQualifiedNames) + "\""; } /** * To string. + * @param ABC abc * @param constants AVM2 constant pool * @param code AVM2 code * @param fullyQualifiedNames Fully qualified names * @return String */ - public String toString(AVM2ConstantPool constants, AVM2Code code, List fullyQualifiedNames) { + public String toString(ABC abc, AVM2ConstantPool constants, AVM2Code code, List fullyQualifiedNames) { try { - return "Exception: startServer=" + code.adr2pos(start) + ":" + code.code.get(code.adr2pos(start)).toStringNoAddress(constants, fullyQualifiedNames) + " end=" + code.adr2pos(end) + ":" + code.code.get(code.adr2pos(end)).toStringNoAddress(constants, fullyQualifiedNames) + " target=" + code.adr2pos(target) + ":" + code.code.get(code.adr2pos(target)).toStringNoAddress(constants, fullyQualifiedNames) + " type=\"" + getTypeName(constants, fullyQualifiedNames) + "\" name=\"" + getVarName(constants, fullyQualifiedNames) + "\""; + return "Exception: startServer=" + code.adr2pos(start) + ":" + code.code.get(code.adr2pos(start)).toStringNoAddress(constants, fullyQualifiedNames) + " end=" + code.adr2pos(end) + ":" + code.code.get(code.adr2pos(end)).toStringNoAddress(constants, fullyQualifiedNames) + " target=" + code.adr2pos(target) + ":" + code.code.get(code.adr2pos(target)).toStringNoAddress(constants, fullyQualifiedNames) + " type=\"" + getTypeName(abc, constants, fullyQualifiedNames) + "\" name=\"" + getVarName(abc, constants, fullyQualifiedNames) + "\""; } catch (ConvertException ex) { return ""; } @@ -111,28 +114,30 @@ public class ABCException implements Serializable, Cloneable { /** * Gets variable name. + * @param abc ABC * @param constants AVM2 constant pool * @param fullyQualifiedNames Fully qualified names * @return Variable name */ - public String getVarName(AVM2ConstantPool constants, List fullyQualifiedNames) { + public String getVarName(ABC abc, AVM2ConstantPool constants, List fullyQualifiedNames) { if (name_index == 0) { return DEFAULT_EXCEPTION_NAME; } - return constants.getMultiname(name_index).getName(constants, fullyQualifiedNames, false, true); + return constants.getMultiname(name_index).getName(abc, constants, fullyQualifiedNames, false, true); } /** * Gets type name. + * @param abc ABC * @param constants AVM2 constant pool * @param fullyQualifiedNames Fully qualified names * @return Type name */ - public String getTypeName(AVM2ConstantPool constants, List fullyQualifiedNames) { + public String getTypeName(ABC abc, AVM2ConstantPool constants, List fullyQualifiedNames) { if (type_index == 0) { return "*"; } - return constants.getMultiname(type_index).getName(constants, fullyQualifiedNames, false, true); + return constants.getMultiname(type_index).getName(abc, constants, fullyQualifiedNames, false, true); } /** diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/InstanceInfo.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/InstanceInfo.java index 1c7227acf..00218596e 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/InstanceInfo.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/InstanceInfo.java @@ -169,12 +169,12 @@ public class InstanceInfo { final String ASSETS_DIR = assetsDir; // "/_assets/"; if (allowEmbed) { if (abc.getSwf() != null) { - String className = getName(abc.constants).getNameWithNamespace(abc.constants, false).toRawString(); + String className = getName(abc.constants).getNameWithNamespace(abc, abc.constants, false).toRawString(); CharacterTag ct = abc.getSwf().getCharacterByClass(className); if (ct != null) { String fileName = ct.getCharacterExportFileName(); if (Configuration.as3ExportNamesUseClassNamesOnly.get()) { - fileName = getName(abc.constants).getNameWithNamespace(abc.constants, false).toRawString(); + fileName = getName(abc.constants).getNameWithNamespace(abc, abc.constants, false).toRawString(); } String ext = ""; @@ -313,17 +313,17 @@ public class InstanceInfo { } writer.appendNoHilight(modifiers + objType); - String classTypeName = abc.constants.getMultiname(name_index).getNameWithNamespace(abc.constants, true).toRawString(); + String classTypeName = abc.constants.getMultiname(name_index).getNameWithNamespace(abc, abc.constants, true).toRawString(); - writer.hilightSpecial(abc.constants.getMultiname(name_index).getName(abc.constants, null/* No full names here*/, false, true), HighlightSpecialType.CLASS_NAME, classTypeName); + writer.hilightSpecial(abc.constants.getMultiname(name_index).getName(abc, abc.constants, null/* No full names here*/, false, true), HighlightSpecialType.CLASS_NAME, classTypeName); if (!isNullable()) { writer.appendNoHilight("!"); } if (super_index > 0) { - String typeName = abc.constants.getMultiname(super_index).getNameWithNamespace(abc.constants, true).toRawString(); - String parentName = abc.constants.getMultiname(super_index).getName(abc.constants, fullyQualifiedNames, false, true); + String typeName = abc.constants.getMultiname(super_index).getNameWithNamespace(abc, abc.constants, true).toRawString(); + String parentName = abc.constants.getMultiname(super_index).getName(abc, abc.constants, fullyQualifiedNames, false, true); if (!parentName.equals("Object")) { writer.appendNoHilight(" extends "); writer.hilightSpecial(parentName, HighlightSpecialType.TYPE_NAME, typeName); @@ -339,8 +339,8 @@ public class InstanceInfo { if (i > 0) { writer.append(", "); } - String typeName = abc.constants.getMultiname(interfaces[i]).getNameWithNamespace(abc.constants, true).toRawString(); - writer.hilightSpecial(abc.constants.getMultiname(interfaces[i]).getName(abc.constants, fullyQualifiedNames, false, true), HighlightSpecialType.TYPE_NAME, typeName); + String typeName = abc.constants.getMultiname(interfaces[i]).getNameWithNamespace(abc, abc.constants, true).toRawString(); + writer.hilightSpecial(abc.constants.getMultiname(interfaces[i]).getName(abc, abc.constants, fullyQualifiedNames, false, true), HighlightSpecialType.TYPE_NAME, typeName); } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/MethodBody.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/MethodBody.java index 8257817fd..4fa3de38c 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/MethodBody.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/MethodBody.java @@ -565,7 +565,7 @@ public final class MethodBody implements Cloneable { } List fullyQualifiedNames2 = new ArrayList<>(fullyQualifiedNames); for (Trait t : traits.traits) { - DottedChain tname = DottedChain.parseWithSuffix(t.getName(abc).getName(abc.constants, new ArrayList<>(), false, true)); + DottedChain tname = DottedChain.parseWithSuffix(t.getName(abc).getName(abc, abc.constants, new ArrayList<>(), false, true)); fullyQualifiedNames2.remove(tname); } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/MethodInfo.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/MethodInfo.java index db52744c9..af8c37675 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/MethodInfo.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/MethodInfo.java @@ -344,7 +344,7 @@ public class MethodInfo { } DottedChain ptype = DottedChain.ALL; if (param_types[i] > 0) { - ptype = constants.getMultiname(param_types[i]).getNameWithNamespace(constants, true); + ptype = constants.getMultiname(param_types[i]).getNameWithNamespace(abc, constants, true); } HighlightData pdata = new HighlightData(); @@ -353,10 +353,10 @@ public class MethodInfo { pdata.regIndex = i + 1; if (!localRegNames.isEmpty()) { pdata.localName = localRegNames.get(i + 1); //assuming it is a slot - writer.hilightSpecial(IdentifiersDeobfuscation.printIdentifier(true, localRegNames.get(i + 1)), HighlightSpecialType.PARAM_NAME, i, pdata); + writer.hilightSpecial(IdentifiersDeobfuscation.printIdentifier(abc.getSwf(), true, localRegNames.get(i + 1)), HighlightSpecialType.PARAM_NAME, i, pdata); } else if ((paramNames.length > i) && (paramNames[i] != 0) && Configuration.paramNamesEnable.get()) { pdata.localName = constants.getString(paramNames[i]); - writer.hilightSpecial(IdentifiersDeobfuscation.printIdentifier(true, constants.getString(paramNames[i])), HighlightSpecialType.PARAM_NAME, i, pdata); + writer.hilightSpecial(IdentifiersDeobfuscation.printIdentifier(abc.getSwf(), true, constants.getString(paramNames[i])), HighlightSpecialType.PARAM_NAME, i, pdata); } else { pdata.localName = "param" + (i + 1); writer.hilightSpecial(pdata.localName, HighlightSpecialType.PARAM_NAME, i, pdata); @@ -365,7 +365,7 @@ public class MethodInfo { if (param_types[i] == 0) { writer.hilightSpecial("*", HighlightSpecialType.PARAM, i); } else { - writer.hilightSpecial(constants.getMultiname(param_types[i]).getName(constants, fullyQualifiedNames, false, true), HighlightSpecialType.PARAM, i); + writer.hilightSpecial(constants.getMultiname(param_types[i]).getName(abc, constants, fullyQualifiedNames, false, true), HighlightSpecialType.PARAM, i); } if (optional != null && flagHas_optional()) { if (i >= param_types.length - optional.length) { @@ -399,27 +399,27 @@ public class MethodInfo { return writer; } - public GraphTextWriter getReturnTypeStr(GraphTextWriter writer, AVM2ConstantPool constants, List fullyQualifiedNames) { + public GraphTextWriter getReturnTypeStr(GraphTextWriter writer, ABC abc, AVM2ConstantPool constants, List fullyQualifiedNames) { String rname = "*"; if (ret_type > 0) { Multiname multiname = constants.getMultiname(ret_type); if (multiname.kind != Multiname.TYPENAME && multiname.name_index > 0 && constants.getString(multiname.name_index).equals("void")) { rname = "void"; } else { - rname = multiname.getName(constants, fullyQualifiedNames, false, true); + rname = multiname.getName(abc, constants, fullyQualifiedNames, false, true); } } return writer.hilightSpecial(rname, HighlightSpecialType.RETURNS); } - public String getReturnTypeRaw(AVM2ConstantPool constants, List fullyQualifiedNames) { + public String getReturnTypeRaw(ABC abc, AVM2ConstantPool constants, List fullyQualifiedNames) { String rname = "*"; if (ret_type > 0) { Multiname multiname = constants.getMultiname(ret_type); if (multiname.kind != Multiname.TYPENAME && multiname.name_index > 0 && constants.getString(multiname.name_index).equals("void")) { rname = "void"; } else { - rname = multiname.getName(constants, fullyQualifiedNames, false, true); + rname = multiname.getName(abc, constants, fullyQualifiedNames, false, true); } } return rname; diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/Multiname.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/Multiname.java index 5b38cb60c..1d03f638a 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/Multiname.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/Multiname.java @@ -624,18 +624,19 @@ public class Multiname { /** * Converts the typename to string. * + * @param abc ABC * @param constants Constant pool * @param fullyQualifiedNames Fully qualified names * @param dontDeobfuscate Don't deobfuscate flag * @param withSuffix With suffix flag * @return Typename as string */ - private String typeNameToStr(AVM2ConstantPool constants, List fullyQualifiedNames, boolean dontDeobfuscate, boolean withSuffix) { + private String typeNameToStr(ABC abc, AVM2ConstantPool constants, List fullyQualifiedNames, boolean dontDeobfuscate, boolean withSuffix) { if (cyclic) { return "§§cyclic_typename()"; } StringBuilder typeNameStr = new StringBuilder(); - typeNameStr.append(constants.getMultiname(qname_index).getName(constants, fullyQualifiedNames, dontDeobfuscate, withSuffix)); + typeNameStr.append(constants.getMultiname(qname_index).getName(abc, constants, fullyQualifiedNames, dontDeobfuscate, withSuffix)); if (params != null && params.length > 0) { typeNameStr.append(".<"); for (int i = 0; i < params.length; i++) { @@ -646,7 +647,7 @@ public class Multiname { if (param == 0) { typeNameStr.append("*"); } else { - typeNameStr.append(constants.getMultiname(param).getName(constants, fullyQualifiedNames, dontDeobfuscate, withSuffix)); + typeNameStr.append(constants.getMultiname(param).getName(abc, constants, fullyQualifiedNames, dontDeobfuscate, withSuffix)); } } typeNameStr.append(">"); @@ -665,7 +666,7 @@ public class Multiname { */ public String getNameWithCustomNamespace(ABC abc, List fullyQualifiedNames, boolean dontDeobfuscate, boolean withSuffix) { if (kind == TYPENAME) { - return typeNameToStr(abc.constants, fullyQualifiedNames, dontDeobfuscate, withSuffix); + return typeNameToStr(abc, abc.constants, fullyQualifiedNames, dontDeobfuscate, withSuffix); } if (name_index == -1) { return ""; @@ -681,7 +682,7 @@ public class Multiname { String nsname = dc != null ? dc.getLast() : null; if (nsname != null && !"AS3".equals(nsname)) { - String identifier = dontDeobfuscate ? nsname : IdentifiersDeobfuscation.printIdentifier(true, nsname); + String identifier = dontDeobfuscate ? nsname : IdentifiersDeobfuscation.printIdentifier(abc.getSwf(), true, nsname); if (identifier != null && !identifier.isEmpty()) { return identifier + "::" + name; } @@ -689,10 +690,10 @@ public class Multiname { } if (nskind == Namespace.KIND_PACKAGE && fullyQualifiedNames != null && !fullyQualifiedNames.isEmpty() && fullyQualifiedNames.contains(DottedChain.parseWithSuffix(name))) { - DottedChain dc = getNameWithNamespace(abc.constants, withSuffix); - return dontDeobfuscate ? dc.toRawString() : dc.toPrintableString(true); + DottedChain dc = getNameWithNamespace(abc, abc.constants, withSuffix); + return dontDeobfuscate ? dc.toRawString() : dc.toPrintableString(abc.getSwf(), true); } - return (isAttribute() ? "@" : "") + (dontDeobfuscate ? name : IdentifiersDeobfuscation.printIdentifier(true, name)) + (withSuffix ? getNamespaceSuffix() : ""); + return (isAttribute() ? "@" : "") + (dontDeobfuscate ? name : IdentifiersDeobfuscation.printIdentifier(abc.getSwf(), true, name)) + (withSuffix ? getNamespaceSuffix() : ""); } } @@ -708,7 +709,7 @@ public class Multiname { */ public String getNameAndCustomNamespace(ABC abc, List fullyQualifiedNames, boolean dontDeobfuscate, boolean withSuffix, Reference customNamespaceRef) { if (kind == TYPENAME) { - return typeNameToStr(abc.constants, fullyQualifiedNames, dontDeobfuscate, withSuffix); + return typeNameToStr(abc, abc.constants, fullyQualifiedNames, dontDeobfuscate, withSuffix); } if (name_index == -1) { return ""; @@ -724,7 +725,7 @@ public class Multiname { String nsname = dc != null ? dc.getLast() : null; if (nsname != null && !"AS3".equals(nsname)) { - String identifier = dontDeobfuscate ? nsname : IdentifiersDeobfuscation.printIdentifier(true, nsname); + String identifier = dontDeobfuscate ? nsname : IdentifiersDeobfuscation.printIdentifier(abc.getSwf(), true, nsname); if (identifier != null && !identifier.isEmpty()) { customNamespaceRef.setVal(dc); return name; @@ -733,25 +734,26 @@ public class Multiname { } if (nskind == Namespace.KIND_PACKAGE && fullyQualifiedNames != null && !fullyQualifiedNames.isEmpty() && fullyQualifiedNames.contains(DottedChain.parseWithSuffix(name))) { - DottedChain dc = getNameWithNamespace(abc.constants, withSuffix); - return dontDeobfuscate ? dc.toRawString() : dc.toPrintableString(true); + DottedChain dc = getNameWithNamespace(abc, abc.constants, withSuffix); + return dontDeobfuscate ? dc.toRawString() : dc.toPrintableString(abc.getSwf(), true); } - return (isAttribute() ? "@" : "") + (dontDeobfuscate ? name : IdentifiersDeobfuscation.printIdentifier(true, name)) + (withSuffix ? getNamespaceSuffix() : ""); + return (isAttribute() ? "@" : "") + (dontDeobfuscate ? name : IdentifiersDeobfuscation.printIdentifier(abc.getSwf(), true, name)) + (withSuffix ? getNamespaceSuffix() : ""); } } /** * Gets the name. * + * @param abc ABC * @param constants Constant pool * @param fullyQualifiedNames Fully qualified names * @param dontDeobfuscate Don't deobfuscate flag * @param withSuffix With suffix flag * @return Name */ - public String getName(AVM2ConstantPool constants, List fullyQualifiedNames, boolean dontDeobfuscate, boolean withSuffix) { + public String getName(ABC abc, AVM2ConstantPool constants, List fullyQualifiedNames, boolean dontDeobfuscate, boolean withSuffix) { if (kind == TYPENAME) { - return typeNameToStr(constants, fullyQualifiedNames, dontDeobfuscate, withSuffix); + return typeNameToStr(abc, constants, fullyQualifiedNames, dontDeobfuscate, withSuffix); } if (name_index == -1) { return ""; @@ -774,21 +776,22 @@ public class Multiname { isPublic = true; } if (isPublic && fullyQualifiedNames != null && !fullyQualifiedNames.isEmpty() && fullyQualifiedNames.contains(DottedChain.parseWithSuffix(name))) { - DottedChain dc = getNameWithNamespace(constants, withSuffix); - return dontDeobfuscate ? dc.toRawString() : dc.toPrintableString(true); + DottedChain dc = getNameWithNamespace(abc, constants, withSuffix); + return dontDeobfuscate ? dc.toRawString() : dc.toPrintableString(abc.getSwf(), true); } - return (isAttribute() ? "@" : "") + (dontDeobfuscate ? name : IdentifiersDeobfuscation.printIdentifier(true, name)) + (withSuffix ? getNamespaceSuffix() : ""); + return (isAttribute() ? "@" : "") + (dontDeobfuscate ? name : IdentifiersDeobfuscation.printIdentifier(abc.getSwf(), true, name)) + (withSuffix ? getNamespaceSuffix() : ""); } } /** * Gets the name with namespace. * + * @param abc ABC * @param constants Constant pool * @param withSuffix With suffix flag * @return Name with namespace */ - public DottedChain getNameWithNamespace(AVM2ConstantPool constants, boolean withSuffix) { + public DottedChain getNameWithNamespace(ABC abc, AVM2ConstantPool constants, boolean withSuffix) { DottedChain cached = constants.getCachedMultinameWithNamespace(this); if (cached != null) { return cached; @@ -809,7 +812,7 @@ public class Multiname { nsName = ns.getName(constants); } } - String name = getName(constants, null, true, false); + String name = getName(abc, constants, null, true, false); DottedChain ret; if (nsName != null) { ret = nsName.add(name, withSuffix ? getNamespaceSuffix() : ""); @@ -1041,7 +1044,7 @@ public class Multiname { * @param otherCpool Other constant pool * @return True if this qname effectively equals to other qname */ - public boolean qnameEquals(AVM2ConstantPool thisCpool, Multiname other, AVM2ConstantPool otherCpool) { + public boolean qnameEquals(ABC thisAbc, AVM2ConstantPool thisCpool, Multiname other, ABC otherAbc, AVM2ConstantPool otherCpool) { if (!isEffectivelyQname(thisCpool) || !other.isEffectivelyQname(otherCpool)) { return false; } @@ -1063,7 +1066,7 @@ public class Multiname { return false; } - if (!Objects.equals(other.getName(otherCpool, new ArrayList<>(), true, true), getName(thisCpool, new ArrayList<>(), true, true))) { + if (!Objects.equals(other.getName(otherAbc, otherCpool, new ArrayList<>(), true, true), getName(thisAbc, thisCpool, new ArrayList<>(), true, true))) { return false; } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/Namespace.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/Namespace.java index 4d187e84f..36cc30b2d 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/Namespace.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/Namespace.java @@ -16,6 +16,7 @@ */ package com.jpexs.decompiler.flash.abc.types; +import com.jpexs.decompiler.flash.abc.ABC; import com.jpexs.decompiler.flash.abc.avm2.AVM2ConstantPool; import com.jpexs.decompiler.flash.types.annotations.Internal; import com.jpexs.decompiler.graph.DottedChain; @@ -179,12 +180,12 @@ public class Namespace { /** * To string. - * + * @param ABC abc * @param constants Constant pool * @return String representation */ - public String toString(AVM2ConstantPool constants) { - return getName(constants).toPrintableString(true); + public String toString(ABC abc, AVM2ConstantPool constants) { + return getName(constants).toPrintableString(abc.getSwf(), true); } /** diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/ScriptInfo.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/ScriptInfo.java index 2045bc375..38ba3e800 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/ScriptInfo.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/ScriptInfo.java @@ -128,7 +128,7 @@ public class ScriptInfo { if (packageTraits.isEmpty() || packageTraits.size() > 1) { return null; } - return traits.traits.get(packageTraits.get(0)).getName(abc).getNameWithNamespace(abc.constants, true); + return traits.traits.get(packageTraits.get(0)).getName(abc).getNameWithNamespace(abc, abc.constants, true); } /** @@ -180,7 +180,7 @@ public class ScriptInfo { if ((nskind == Namespace.KIND_PACKAGE_INTERNAL) || (nskind == Namespace.KIND_PACKAGE)) { DottedChain packageName = name.getSimpleNamespaceName(abc.constants); // assume not null package - String objectName = name.getName(abc.constants, null, true, false); + String objectName = name.getName(abc, abc.constants, null, true, false); String namespaceSuffix = name.getNamespaceSuffix(); List traitIndices = new ArrayList<>(); @@ -190,9 +190,9 @@ public class ScriptInfo { otherTraits.clear(); } - if (packagePrefix == null || packageName.toPrintableString(true).startsWith(packagePrefix)) { + if (packagePrefix == null || packageName.toPrintableString(abc.getSwf(), true).startsWith(packagePrefix)) { - ClassPath cp = new ClassPath(packageName, objectName, namespaceSuffix); + ClassPath cp = new ClassPath(packageName, objectName, namespaceSuffix, abc.getSwf()); ScriptPack pack = new ScriptPack(cp, abc, allAbcs, scriptIndex, traitIndices); pack.isSimple = isSimple; ret.add(pack); @@ -206,18 +206,18 @@ public class ScriptInfo { Multiname name = t.getName(abc); DottedChain packageName = name.getSimpleNamespaceName(abc.constants); - String objectName = name.getName(abc.constants, null, true, false); + String objectName = name.getName(abc, abc.constants, null, true, false); String namespaceSuffix = name.getNamespaceSuffix(); List traitIndices = new ArrayList<>(); traitIndices.add(traitIndex); - ClassPath cp = new ClassPath(packageName, objectName, namespaceSuffix); + ClassPath cp = new ClassPath(packageName, objectName, namespaceSuffix, abc.getSwf()); ret.add(new ScriptPack(cp, abc, allAbcs, scriptIndex, traitIndices)); } } if (!isSimple) { - ret.add(new ScriptPack(new ClassPath(DottedChain.EMPTY, "script_" + scriptIndex, ""), abc, allAbcs, scriptIndex, new ArrayList<>())); + ret.add(new ScriptPack(new ClassPath(DottedChain.EMPTY, "script_" + scriptIndex, "", abc.getSwf()), abc, allAbcs, scriptIndex, new ArrayList<>())); } if (packagePrefix == null) { cachedPacks = new ArrayList<>(ret); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/traits/Trait.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/traits/Trait.java index f5ea545fa..511837cae 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/traits/Trait.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/traits/Trait.java @@ -211,11 +211,11 @@ public abstract class Trait implements Cloneable, Serializable { public var attr2; */ if (parent instanceof TraitClass) { - String thisName = getName(abc).getName(abc.constants, new ArrayList<>(), true, true); + String thisName = getName(abc).getName(abc, abc.constants, new ArrayList<>(), true, true); List classTraits = abc.class_info.get(((TraitClass) parent).class_info).static_traits.traits; for (Trait t : classTraits) { if (t.kindType == Trait.TRAIT_SLOT) { - if ("_skinParts".equals(t.getName(abc).getName(abc.constants, new ArrayList<>(), true, true))) { + if ("_skinParts".equals(t.getName(abc).getName(abc, abc.constants, new ArrayList<>(), true, true))) { if (t.getName(abc).getNamespace(abc.constants).kind == Namespace.KIND_PRIVATE) { if (convertData.assignedValues.containsKey(t)) { if (convertData.assignedValues.get(t).value instanceof NewObjectAVM2Item) { @@ -332,7 +332,7 @@ public abstract class Trait implements Cloneable, Serializable { continue; } } - traitNamesInThisScript.add(it.getName(abc).getName(abc.constants, new ArrayList<>(), true, true)); + traitNamesInThisScript.add(it.getName(abc).getName(abc, abc.constants, new ArrayList<>(), true, true)); } for (Trait ct : abc.class_info.get(classIndex).static_traits.traits) { if (publicProtectedOnly) { @@ -341,12 +341,12 @@ public abstract class Trait implements Cloneable, Serializable { continue; } } - traitNamesInThisScript.add(ct.getName(abc).getName(abc.constants, new ArrayList<>(), true, true)); + traitNamesInThisScript.add(ct.getName(abc).getName(abc, abc.constants, new ArrayList<>(), true, true)); } if (abc.instance_info.get(classIndex).super_index == 0) { return; } - DottedChain fullClassName = abc.constants.getMultiname(abc.instance_info.get(classIndex).super_index).getNameWithNamespace(abc.constants, true); + DottedChain fullClassName = abc.constants.getMultiname(abc.instance_info.get(classIndex).super_index).getNameWithNamespace(abc, abc.constants, true); AbcIndexing.ClassIndex ci = abcIndex.findClass(new TypeItem(fullClassName), abc, scriptIndex); if (ci != null) { getAllClassTraitNames(traitNamesInThisScript, abcIndex, ci.abc, ci.index, ci.scriptIndex, true); @@ -388,7 +388,7 @@ public abstract class Trait implements Cloneable, Serializable { if (st instanceof TraitClass) { getAllClassTraitNames(traitNamesInThisScript, abcIndex, abc, ((TraitClass) st).class_info, scriptIndex, false); } else { - traitNamesInThisScript.add(st.getName(abc).getName(abc.constants, new ArrayList<>(), true, true)); + traitNamesInThisScript.add(st.getName(abc).getName(abc, abc.constants, new ArrayList<>(), true, true)); } } @@ -481,13 +481,13 @@ public abstract class Trait implements Cloneable, Serializable { writer.appendNoHilight("import "); if (imp.size() > 1) { - writer.appendNoHilight(imp.getWithoutLast().toPrintableString(true)); + writer.appendNoHilight(imp.getWithoutLast().toPrintableString(abc.getSwf(), true)); writer.appendNoHilight("."); } if ("*".equals(imp.getLast())) { writer.appendNoHilight("*"); } else { - writer.hilightSpecial(IdentifiersDeobfuscation.printIdentifier(true, imp.getLast()), HighlightSpecialType.TYPE_NAME, imp.toRawString()); + writer.hilightSpecial(IdentifiersDeobfuscation.printIdentifier(abc.getSwf(), true, imp.getLast()), HighlightSpecialType.TYPE_NAME, imp.toRawString()); } writer.appendNoHilight(";").newLine(); hasImport = true; @@ -545,7 +545,7 @@ public abstract class Trait implements Cloneable, Serializable { if (METADATA_DEFINITION.equals(name) || METADATA_CTOR_DEFINITION.equals(name)) { continue; } - writer.append("[").append(IdentifiersDeobfuscation.printIdentifier(true, name)); + writer.append("[").append(IdentifiersDeobfuscation.printIdentifier(abc.getSwf(), true, name)); if (!en.getValue().isEmpty()) { writer.append("("); boolean first = true; @@ -555,7 +555,7 @@ public abstract class Trait implements Cloneable, Serializable { } first = false; if (key != null && !key.isEmpty()) { - writer.append(IdentifiersDeobfuscation.printIdentifier(true, key)).append("="); + writer.append(IdentifiersDeobfuscation.printIdentifier(abc.getSwf(), true, key)).append("="); } writer.append("\""); String val = en.getValue().get(key); @@ -629,7 +629,7 @@ public abstract class Trait implements Cloneable, Serializable { writer.append(Helper.escapeActionScriptString(m.getSimpleNamespaceName(abc.constants).toRawString())); writer.append("\") "); } else if (dc != null && nsname != null) { - String identifier = IdentifiersDeobfuscation.printIdentifier(true, nsname); + String identifier = IdentifiersDeobfuscation.printIdentifier(abc.getSwf(), true, nsname); if (identifier != null && !identifier.isEmpty()) { writer.hilightSpecial(identifier, HighlightSpecialType.TYPE_NAME, dc.toRawString()).appendNoHilight(" "); } @@ -872,7 +872,7 @@ public abstract class Trait implements Cloneable, Serializable { Multiname name = abc.constants.getMultiname(name_index); int nskind = name.getSimpleNamespaceKind(abc.constants); if ((nskind == Namespace.KIND_PACKAGE) || (nskind == Namespace.KIND_PACKAGE_INTERNAL)) { - String nsname = name.getSimpleNamespaceName(abc.constants).toPrintableString(true); + String nsname = name.getSimpleNamespaceName(abc.constants).toPrintableString(abc.getSwf(), true); writer.appendNoHilight("package"); if (!nsname.isEmpty()) { writer.appendNoHilight(" " + nsname); //assume not null name @@ -881,7 +881,7 @@ public abstract class Trait implements Cloneable, Serializable { List traits = new ArrayList<>(); traits.add(this); writeImports(traits, -1, abcIndex, scriptIndex, classIndex, isStatic, abc, writer, getPackage(abc), fullyQualifiedNames); - toString(swfVersion, abcIndex, name.getNameWithNamespace(abc.constants, true).getWithoutLast(), parent, convertData, path, abc, isStatic, exportMode, scriptIndex, classIndex, writer, fullyQualifiedNames, parallel, insideInterface); + toString(swfVersion, abcIndex, name.getNameWithNamespace(abc, abc.constants, true).getWithoutLast(), parent, convertData, path, abc, isStatic, exportMode, scriptIndex, classIndex, writer, fullyQualifiedNames, parallel, insideInterface); writer.endBlock(); writer.newLine(); } @@ -911,7 +911,7 @@ public abstract class Trait implements Cloneable, Serializable { Multiname name = abc.constants.getMultiname(name_index); int nskind = name.getSimpleNamespaceKind(abc.constants); if ((nskind == Namespace.KIND_PACKAGE) || (nskind == Namespace.KIND_PACKAGE_INTERNAL)) { - String nsname = name.getSimpleNamespaceName(abc.constants).toPrintableString(true); + String nsname = name.getSimpleNamespaceName(abc.constants).toPrintableString(abc.getSwf(), true); convert(swfVersion, abcIndex, parent, convertData, path + nsname, abc, isStatic, exportMode, scriptIndex, classIndex, writer, fullyQualifiedNames, parallel, scopeStack); } } @@ -999,9 +999,9 @@ public abstract class Trait implements Cloneable, Serializable { Multiname name = getName(abc); Namespace ns = name.getNamespace(abc.constants); DottedChain packageName = ns == null ? DottedChain.EMPTY : ns.getName(abc.constants); - String objectName = name.getName(abc.constants, null, true, false); + String objectName = name.getName(abc, abc.constants, null, true, false); String namespaceSuffix = name.getNamespaceSuffix(); - return new ClassPath(packageName, objectName, namespaceSuffix); //assume not null name + return new ClassPath(packageName, objectName, namespaceSuffix, abc.getSwf()); //assume not null name } /** diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/traits/TraitClass.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/traits/TraitClass.java index d500663f6..e98120a6d 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/traits/TraitClass.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/traits/TraitClass.java @@ -201,7 +201,7 @@ public class TraitClass extends Trait implements TraitWithSlot { Reference first = new Reference<>(true); - String instanceInfoName = instanceInfoMultiname.getName(abc.constants, fullyQualifiedNames, false, true); + String instanceInfoName = instanceInfoMultiname.getName(abc, abc.constants, fullyQualifiedNames, false, true); getMetaData(this, convertData, abc, writer); @@ -210,7 +210,7 @@ public class TraitClass extends Trait implements TraitWithSlot { if (convertData.exportEmbedFlaMode) { allowEmbed = false; if (abc.getSwf() != null) { - CharacterTag ct = abc.getSwf().getCharacterByClass(instanceInfoMultiname.getNameWithNamespace(abc.constants, false).toRawString()); + CharacterTag ct = abc.getSwf().getCharacterByClass(instanceInfoMultiname.getNameWithNamespace(abc, abc.constants, false).toRawString()); if (ct == null) { allowEmbed = false; } else { @@ -318,7 +318,7 @@ public class TraitClass extends Trait implements TraitWithSlot { writer.startMethod(instanceInfo.iinit_index, "iinit"); writer.appendNoHilight(modifier); writer.appendNoHilight("function "); - writer.appendNoHilight(m.getName(abc.constants, null/*do not want full names here*/, false, true)); + writer.appendNoHilight(m.getName(abc, abc.constants, null/*do not want full names here*/, false, true)); writer.appendNoHilight("("); bodyIndex = abc.findBodyIndex(instanceInfo.iinit_index); MethodBody body = bodyIndex == -1 ? null : abc.bodies.get(bodyIndex); @@ -346,7 +346,7 @@ public class TraitClass extends Trait implements TraitWithSlot { } if (convertData.ignoreAccessibility) { for (Trait t : instanceInfo.instance_traits.traits) { - String traitName = t.getName(abc).getName(abc.constants, new ArrayList<>(), true, false);; + String traitName = t.getName(abc).getName(abc, abc.constants, new ArrayList<>(), true, false);; if (traitName.startsWith("__setAcc_") || traitName.startsWith("__setTab_")) { ignoredInstanceTraitNames.add(traitName); @@ -372,7 +372,7 @@ public class TraitClass extends Trait implements TraitWithSlot { fullyQualifiedNames = new ArrayList<>(); InstanceInfo instanceInfo = abc.instance_info.get(class_info); - String instanceInfoName = instanceInfo.getName(abc.constants).getName(abc.constants, fullyQualifiedNames, false, true); + String instanceInfoName = instanceInfo.getName(abc.constants).getName(abc, abc.constants, fullyQualifiedNames, false, true); ClassInfo classInfo = abc.class_info.get(class_info); AbcIndexing index = new AbcIndexing(abc.getSwf()); @@ -382,7 +382,7 @@ public class TraitClass extends Trait implements TraitWithSlot { int nsIndex = abc.constants.getNamespaceId(Namespace.KIND_PACKAGE, DottedChain.TOPLEVEL, sIndex, false); if (nsIndex > -1) { Reference foundStatic = new Reference<>(null); - convertData.thisHasDefaultToPrimitive = null == index.findProperty(new AbcIndexing.PropertyDef("toString", new TypeItem(instanceInfo.getName(abc.constants).getNameWithNamespace(abc.constants, true)), abc, nsIndex), false, true, false, foundStatic); + convertData.thisHasDefaultToPrimitive = null == index.findProperty(new AbcIndexing.PropertyDef("toString", new TypeItem(instanceInfo.getName(abc.constants).getNameWithNamespace(abc, abc.constants, true)), abc, nsIndex), false, true, false, foundStatic); } else { convertData.thisHasDefaultToPrimitive = true; } @@ -398,7 +398,7 @@ public class TraitClass extends Trait implements TraitWithSlot { callStack.add(abc.bodies.get(bodyIndex)); if (!abc.instance_info.get(class_info).isInterface()) { - AbcIndexing.ClassIndex cls = abcIndex.findClass(AbcIndexing.multinameToType(abc.instance_info.get(class_info).name_index, abc.constants), abc, scriptIndex); + AbcIndexing.ClassIndex cls = abcIndex.findClass(AbcIndexing.multinameToType(abc.instance_info.get(class_info).name_index, abc, abc.constants), abc, scriptIndex); List clsList = new ArrayList<>(); cls = cls.parent; while (cls != null) { @@ -406,7 +406,7 @@ public class TraitClass extends Trait implements TraitWithSlot { cls = cls.parent; } for (AbcIndexing.ClassIndex cls2 : clsList) { - newScopeStack.push(new ClassAVM2Item(cls2.abc.instance_info.get(cls2.index).getName(cls2.abc.constants).getNameWithNamespace(cls2.abc.constants, true))); + newScopeStack.push(new ClassAVM2Item(cls2.abc.instance_info.get(cls2.index).getName(cls2.abc.constants).getNameWithNamespace(cls2.abc, cls2.abc.constants, true))); } } @@ -453,14 +453,14 @@ public class TraitClass extends Trait implements TraitWithSlot { if (callProp.arguments.get(i) instanceof IntegerValueAVM2Item) { if (callProp.arguments.get(i + 1) instanceof GetLexAVM2Item) { GetLexAVM2Item lex = (GetLexAVM2Item) callProp.arguments.get(i + 1); - frameTraitNames.add(lex.propertyName.getName(abc.constants, new ArrayList<>(), false, true)); + frameTraitNames.add(lex.propertyName.getName(abc, abc.constants, new ArrayList<>(), false, true)); } else if (callProp.arguments.get(i + 1) instanceof GetPropertyAVM2Item) { GetPropertyAVM2Item getProp = (GetPropertyAVM2Item) callProp.arguments.get(i + 1); if (getProp.object instanceof ThisAVM2Item) { if (getProp.propertyName instanceof FullMultinameAVM2Item) { FullMultinameAVM2Item framePropName = (FullMultinameAVM2Item) getProp.propertyName; int multinameIndex = framePropName.multinameIndex; - frameTraitNames.add(abc.constants.getMultiname(multinameIndex).getName(abc.constants, new ArrayList<>(), false, true)); + frameTraitNames.add(abc.constants.getMultiname(multinameIndex).getName(abc, abc.constants, new ArrayList<>(), false, true)); } } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/traits/TraitFunction.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/traits/TraitFunction.java index 490103c36..128e4081c 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/traits/TraitFunction.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/traits/TraitFunction.java @@ -84,11 +84,11 @@ public class TraitFunction extends Trait implements TraitWithSlot { } getModifiers(abc, isStatic, insideInterface, writer, classIndex); writer.hilightSpecial("function ", HighlightSpecialType.TRAIT_TYPE); - writer.hilightSpecial(abc.constants.getMultiname(name_index).getName(abc.constants, fullyQualifiedNames, false, true), HighlightSpecialType.TRAIT_NAME); + writer.hilightSpecial(abc.constants.getMultiname(name_index).getName(abc, abc.constants, fullyQualifiedNames, false, true), HighlightSpecialType.TRAIT_NAME); writer.appendNoHilight("("); abc.method_info.get(method_info).getParamStr(writer, abc.constants, body, abc, fullyQualifiedNames); writer.appendNoHilight(") : "); - abc.method_info.get(method_info).getReturnTypeStr(writer, abc.constants, fullyQualifiedNames); + abc.method_info.get(method_info).getReturnTypeStr(writer, abc, abc.constants, fullyQualifiedNames); return writer; } @@ -111,7 +111,7 @@ public class TraitFunction extends Trait implements TraitWithSlot { @Override public GraphTextWriter toString(int swfVersion, AbcIndexing abcIndex, DottedChain packageName, Trait parent, ConvertData convertData, String path, ABC abc, boolean isStatic, ScriptExportMode exportMode, int scriptIndex, int classIndex, GraphTextWriter writer, List fullyQualifiedNames, boolean parallel, boolean insideInterface) throws InterruptedException { getMetaData(this, convertData, abc, writer); - writer.startMethod(method_info, getName(abc).getName(abc.constants, new ArrayList<>(), true, false)); + writer.startMethod(method_info, getName(abc).getName(abc, abc.constants, new ArrayList<>(), true, false)); toStringHeader(swfVersion, parent, packageName, convertData, path, abc, isStatic, exportMode, scriptIndex, classIndex, writer, fullyQualifiedNames, parallel, insideInterface); writer.startBlock(); @@ -120,7 +120,7 @@ public class TraitFunction extends Trait implements TraitWithSlot { //writeUses(scriptIndex, classIndex, isStatic, abc, writer); List callStack = new ArrayList<>(); callStack.add(abc.bodies.get(bodyIndex)); - abc.bodies.get(bodyIndex).toString(swfVersion, callStack, abcIndex, path + "." + abc.constants.getMultiname(name_index).getName(abc.constants, fullyQualifiedNames, false, true), exportMode, abc, this, writer, fullyQualifiedNames, new HashSet<>()); + abc.bodies.get(bodyIndex).toString(swfVersion, callStack, abcIndex, path + "." + abc.constants.getMultiname(name_index).getName(abc, abc.constants, fullyQualifiedNames, false, true), exportMode, abc, this, writer, fullyQualifiedNames, new HashSet<>()); } writer.endBlock(); @@ -133,13 +133,13 @@ public class TraitFunction extends Trait implements TraitWithSlot { @Override public void convert(int swfVersion, AbcIndexing abcIndex, Trait parent, ConvertData convertData, String path, ABC abc, boolean isStatic, ScriptExportMode exportMode, int scriptIndex, int classIndex, NulWriter writer, List fullyQualifiedNames, boolean parallel, ScopeStack scopeStack) throws InterruptedException { fullyQualifiedNames = new ArrayList<>(); - writer.startMethod(method_info, getName(abc).getName(abc.constants, new ArrayList<>(), true, false)); + writer.startMethod(method_info, getName(abc).getName(abc, abc.constants, new ArrayList<>(), true, false)); convertHeader(swfVersion, parent, convertData, path, abc, isStatic, exportMode, scriptIndex, classIndex, writer, fullyQualifiedNames, parallel); int bodyIndex = abc.findBodyIndex(method_info); if (bodyIndex != -1) { List callStack = new ArrayList<>(); callStack.add(abc.bodies.get(bodyIndex)); - abc.bodies.get(bodyIndex).convert(swfVersion, callStack, abcIndex, convertData, path + "." + abc.constants.getMultiname(name_index).getName(abc.constants, fullyQualifiedNames, false, true), exportMode, isStatic, method_info, scriptIndex, classIndex, abc, this, scopeStack, 0, writer, fullyQualifiedNames, null, true, new HashSet<>(), new ArrayList<>()); + abc.bodies.get(bodyIndex).convert(swfVersion, callStack, abcIndex, convertData, path + "." + abc.constants.getMultiname(name_index).getName(abc, abc.constants, fullyQualifiedNames, false, true), exportMode, isStatic, method_info, scriptIndex, classIndex, abc, this, scopeStack, 0, writer, fullyQualifiedNames, null, true, new HashSet<>(), new ArrayList<>()); } writer.endMethod(); } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/traits/TraitMethodGetterSetter.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/traits/TraitMethodGetterSetter.java index b44c9c9ed..1df73c1bb 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/traits/TraitMethodGetterSetter.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/traits/TraitMethodGetterSetter.java @@ -127,19 +127,19 @@ public class TraitMethodGetterSetter extends Trait { } writer.hilightSpecial("function " + addKind, HighlightSpecialType.TRAIT_TYPE); - writer.hilightSpecial(getName(abc).getName(abc.constants, new ArrayList<>(), false, true), HighlightSpecialType.TRAIT_NAME); + writer.hilightSpecial(getName(abc).getName(abc, abc.constants, new ArrayList<>(), false, true), HighlightSpecialType.TRAIT_NAME); writer.appendNoHilight("("); abc.method_info.get(method_info).getParamStr(writer, abc.constants, body, abc, fullyQualifiedNames); writer.appendNoHilight(") : "); - abc.method_info.get(method_info).getReturnTypeStr(writer, abc.constants, fullyQualifiedNames); + abc.method_info.get(method_info).getReturnTypeStr(writer, abc, abc.constants, fullyQualifiedNames); return writer; } @Override public void convert(int swfVersion, AbcIndexing abcIndex, Trait parent, ConvertData convertData, String path, ABC abc, boolean isStatic, ScriptExportMode exportMode, int scriptIndex, int classIndex, NulWriter writer, List fullyQualifiedNames, boolean parallel, ScopeStack scopeStack) throws InterruptedException { int nsKind = getName(abc).getSimpleNamespaceKind(abc.constants); - writer.startMethod(method_info, getName(abc).getName(abc.constants, new ArrayList<>(), true, false)); - path = path + "." + getName(abc).getName(abc.constants, fullyQualifiedNames, false, true); + writer.startMethod(method_info, getName(abc).getName(abc, abc.constants, new ArrayList<>(), true, false)); + path = path + "." + getName(abc).getName(abc, abc.constants, fullyQualifiedNames, false, true); convertHeader(swfVersion, parent, convertData, path, abc, isStatic, exportMode, scriptIndex, classIndex, writer, fullyQualifiedNames, parallel); int bodyIndex = abc.findBodyIndex(method_info); if (exportMode != ScriptExportMode.AS_METHOD_STUBS) { @@ -169,8 +169,8 @@ public class TraitMethodGetterSetter extends Trait { @Override public GraphTextWriter toString(int swfVersion, AbcIndexing abcIndex, DottedChain packageName, Trait parent, ConvertData convertData, String path, ABC abc, boolean isStatic, ScriptExportMode exportMode, int scriptIndex, int classIndex, GraphTextWriter writer, List fullyQualifiedNames, boolean parallel, boolean insideInterface) throws InterruptedException { getMetaData(this, convertData, abc, writer); - writer.startMethod(method_info, getName(abc).getName(abc.constants, new ArrayList<>(), true, false)); - path = path + "." + getName(abc).getName(abc.constants, fullyQualifiedNames, false, true); + writer.startMethod(method_info, getName(abc).getName(abc, abc.constants, new ArrayList<>(), true, false)); + path = path + "." + getName(abc).getName(abc, abc.constants, fullyQualifiedNames, false, true); toStringHeader(swfVersion, parent, packageName, convertData, path, abc, isStatic, exportMode, scriptIndex, classIndex, writer, fullyQualifiedNames, parallel, insideInterface); int bodyIndex = abc.findBodyIndex(method_info); if (classIndex != -1 && abc.instance_info.get(classIndex).isInterface() || bodyIndex == -1) { @@ -188,7 +188,7 @@ public class TraitMethodGetterSetter extends Trait { abc.bodies.get(bodyIndex).toString(swfVersion, callStack, abcIndex, path, exportMode, abc, this, writer, fullyQualifiedNames, new HashSet<>()); } } else { - String retTypeRaw = abc.method_info.get(method_info).getReturnTypeRaw(abc.constants, fullyQualifiedNames); + String retTypeRaw = abc.method_info.get(method_info).getReturnTypeRaw(abc, abc.constants, fullyQualifiedNames); switch (retTypeRaw) { case "void": break; @@ -256,10 +256,10 @@ public class TraitMethodGetterSetter extends Trait { @Override public boolean isVisible(boolean isStatic, ABC abc) { if (Configuration.handleSkinPartsAutomatically.get()) { - if ("skinParts".equals(getName(abc).getName(abc.constants, new ArrayList<>(), true, true))) { + if ("skinParts".equals(getName(abc).getName(abc, abc.constants, new ArrayList<>(), true, true))) { if (kindType == TRAIT_GETTER) { MethodInfo mi = abc.method_info.get(method_info); - if (mi.param_types.length == 0 && "Object".equals(abc.constants.getMultiname(mi.ret_type).getNameWithNamespace(abc.constants, true).toRawString())) { + if (mi.param_types.length == 0 && "Object".equals(abc.constants.getMultiname(mi.ret_type).getNameWithNamespace(abc, abc.constants, true).toRawString())) { if (abc.constants.getNamespace(abc.constants.getMultiname(name_index).namespace_index).kind == Namespace.KIND_PROTECTED) { return false; } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/traits/TraitSlotConst.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/traits/TraitSlotConst.java index 95a7a6785..a6b29f724 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/traits/TraitSlotConst.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/traits/TraitSlotConst.java @@ -99,14 +99,15 @@ public class TraitSlotConst extends Trait implements TraitWithSlot { /** * Gets type as string. * + * @param abc ABC * @param constants Constant pool * @param fullyQualifiedNames Fully qualified names * @return Type as string */ - public String getType(AVM2ConstantPool constants, List fullyQualifiedNames) { + public String getType(ABC abc, AVM2ConstantPool constants, List fullyQualifiedNames) { String typeStr = "*"; if (type_index > 0) { - typeStr = constants.getMultiname(type_index).getName(constants, fullyQualifiedNames, false, true); + typeStr = constants.getMultiname(type_index).getName(abc, constants, fullyQualifiedNames, false, true); } return typeStr; } @@ -120,7 +121,7 @@ public class TraitSlotConst extends Trait implements TraitWithSlot { * @return Writer */ public GraphTextWriter getNameStr(GraphTextWriter writer, ABC abc, List fullyQualifiedNames) { - String typeStr = getType(abc.constants, fullyQualifiedNames); + String typeStr = getType(abc, abc.constants, fullyQualifiedNames); ValueKind val = null; if (value_kind != 0) { val = new ValueKind(value_index, value_kind); @@ -137,7 +138,7 @@ public class TraitSlotConst extends Trait implements TraitWithSlot { typeStr = ""; } writer.hilightSpecial(slotconst + " ", HighlightSpecialType.TRAIT_TYPE); - writer.hilightSpecial(getName(abc).getName(abc.constants, new ArrayList<>(), false, true), HighlightSpecialType.TRAIT_NAME); + writer.hilightSpecial(getName(abc).getName(abc, abc.constants, new ArrayList<>(), false, true), HighlightSpecialType.TRAIT_NAME); writer.hilightSpecial(typeStr, HighlightSpecialType.TRAIT_TYPE_NAME); return writer; } @@ -356,9 +357,9 @@ public class TraitSlotConst extends Trait implements TraitWithSlot { Hide: private static var _skinParts (part of [SkinPart] compilations) */ - if (isStatic && "_skinParts".equals(getName(abc).getName(abc.constants, new ArrayList<>(), true, true))) { + if (isStatic && "_skinParts".equals(getName(abc).getName(abc, abc.constants, new ArrayList<>(), true, true))) { if (kindType == Trait.TRAIT_SLOT) { - if ("_skinParts".equals(getName(abc).getName(abc.constants, new ArrayList<>(), true, true))) { + if ("_skinParts".equals(getName(abc).getName(abc, abc.constants, new ArrayList<>(), true, true))) { if (getName(abc).getNamespace(abc.constants).kind == Namespace.KIND_PRIVATE) { return false; } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/traits/Traits.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/traits/Traits.java index 13ce72d93..8b24eb6e9 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/traits/Traits.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/traits/Traits.java @@ -333,7 +333,7 @@ public class Traits implements Cloneable, Serializable { if (!trait.isVisible(isStatic, abc)) { continue; } - if (ignoredTraitNames.contains(trait.getName(abc).getName(abc.constants, new ArrayList<>(), false, false))) { + if (ignoredTraitNames.contains(trait.getName(abc).getName(abc, abc.constants, new ArrayList<>(), false, false))) { continue; } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/usages/multinames/ClassNameMultinameUsage.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/usages/multinames/ClassNameMultinameUsage.java index 607af08ab..165880933 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/usages/multinames/ClassNameMultinameUsage.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/usages/multinames/ClassNameMultinameUsage.java @@ -49,7 +49,7 @@ public class ClassNameMultinameUsage extends MultinameUsage implements Definitio public String toString() { InstanceInfo ii = abc.instance_info.get(classIndex); String kind = ii.isInterface() ? "interface" : "class"; - return kind + " " + ii.getName(abc.constants).getNameWithNamespace(abc.constants, true).toPrintableString(true) + " name"; + return kind + " " + ii.getName(abc.constants).getNameWithNamespace(abc, abc.constants, true).toPrintableString(abc.getSwf(), true) + " name"; } @Override diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/usages/multinames/MultinameUsage.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/usages/multinames/MultinameUsage.java index 7e71708d2..de42e862f 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/usages/multinames/MultinameUsage.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/usages/multinames/MultinameUsage.java @@ -86,8 +86,8 @@ public abstract class MultinameUsage implements Usage { return false; } if ((thisM.kind == Multiname.QNAME || thisM.kind == Multiname.QNAMEA) && otherM.kind == thisM.kind) { - String thisName = thisM.getName(abc.constants, new ArrayList<>(), true, true); - String otherName = otherM.getName(other.abc.constants, new ArrayList<>(), true, true); + String thisName = thisM.getName(abc, abc.constants, new ArrayList<>(), true, true); + String otherName = otherM.getName(other.abc, other.abc.constants, new ArrayList<>(), true, true); Namespace thisNs = thisM.getNamespace(abc.constants); Namespace otherNs = otherM.getNamespace(other.abc.constants); if (!Objects.equals(thisName, otherName)) { diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/usages/multinames/SuperClassMultinameUsage.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/usages/multinames/SuperClassMultinameUsage.java index 8d04707f6..84b357a01 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/usages/multinames/SuperClassMultinameUsage.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/usages/multinames/SuperClassMultinameUsage.java @@ -52,7 +52,7 @@ public class SuperClassMultinameUsage extends MultinameUsage implements InsideCl public String toString() { InstanceInfo ii = abc.instance_info.get(classIndex); String kind = ii.isInterface() ? "interface" : "class"; - return kind + " " + ii.getName(abc.constants).getNameWithNamespace(abc.constants, true) + " extends"; + return kind + " " + ii.getName(abc.constants).getNameWithNamespace(abc, abc.constants, true) + " extends"; } @Override diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/usages/multinames/SuperInterfaceMultinameUsage.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/usages/multinames/SuperInterfaceMultinameUsage.java index c42e534cd..d62c4447f 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/usages/multinames/SuperInterfaceMultinameUsage.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/usages/multinames/SuperInterfaceMultinameUsage.java @@ -52,7 +52,7 @@ public class SuperInterfaceMultinameUsage extends MultinameUsage implements Insi public String toString() { InstanceInfo ii = abc.instance_info.get(classIndex); String kind = ii.isInterface() ? "interface" : "class"; - return kind + " " + ii.getName(abc.constants).getNameWithNamespace(abc.constants, true) + " " + (ii.isInterface() ? "extends" : "implements"); + return kind + " " + ii.getName(abc.constants).getNameWithNamespace(abc, abc.constants, true) + " " + (ii.isInterface() ? "extends" : "implements"); } @Override diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/usages/multinames/TraitMultinameUsage.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/usages/multinames/TraitMultinameUsage.java index 6bdcb203b..92c746ad4 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/usages/multinames/TraitMultinameUsage.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/usages/multinames/TraitMultinameUsage.java @@ -100,10 +100,10 @@ public abstract class TraitMultinameUsage extends MultinameUsage implements Insi if (classIndex != -1) { InstanceInfo ii = abc.instance_info.get(classIndex); String kind = ii.isInterface() ? "interface" : "class"; - return kind + " " + ii.getName(abc.constants).getNameWithNamespace(abc.constants, true).toPrintableString(true); + return kind + " " + ii.getName(abc.constants).getNameWithNamespace(abc, abc.constants, true).toPrintableString(abc.getSwf(), true); } DottedChain scriptSimpleName = abc.script_info.get(scriptIndex).getSimplePackName(abc); - return "script " + (scriptSimpleName == null ? "" + scriptIndex : scriptSimpleName.toPrintableString(true)); + return "script " + (scriptSimpleName == null ? "" + scriptIndex : scriptSimpleName.toPrintableString(abc.getSwf(), true)); } @Override diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/StoreTypeAction.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/StoreTypeAction.java index cd3a4a411..08128ebf7 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/StoreTypeAction.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/StoreTypeAction.java @@ -16,6 +16,7 @@ */ package com.jpexs.decompiler.flash.action; +import com.jpexs.decompiler.flash.SWF; import com.jpexs.decompiler.flash.action.model.ConstantPool; import com.jpexs.decompiler.graph.TranslateStack; @@ -31,7 +32,8 @@ public interface StoreTypeAction { * * @param stack Stack * @param cpool Constant pool + * @param swf SWF * @return Variable name */ - public String getVariableName(TranslateStack stack, ConstantPool cpool); + public String getVariableName(TranslateStack stack, ConstantPool cpool, SWF swf); } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/as2/UninitializedClassFieldsDetector.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/as2/UninitializedClassFieldsDetector.java index f84c88688..47bf051b2 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/as2/UninitializedClassFieldsDetector.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/as2/UninitializedClassFieldsDetector.java @@ -71,7 +71,7 @@ public class UninitializedClassFieldsDetector { DoInitActionTag doi = (DoInitActionTag) asm; String exportName = doi.getSwf().getExportName(doi.spriteId); if (exportName != null) { - asmPath = DottedChain.parseNoSuffix(exportName).toPrintableString(false); + asmPath = DottedChain.parseNoSuffix(exportName).toPrintableString(doi.getSwf(), false); } } for (ProgressListener listener : progressListeners) { diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/model/DirectValueActionItem.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/model/DirectValueActionItem.java index 3b077e574..e2fb0ab06 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/model/DirectValueActionItem.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/model/DirectValueActionItem.java @@ -142,7 +142,7 @@ public class DirectValueActionItem extends ActionItem implements SimpleValue { } if (value instanceof RegisterNumber) { - return IdentifiersDeobfuscation.printIdentifier(false, ((RegisterNumber) value).translate()); + return IdentifiersDeobfuscation.printIdentifier(localData.swf, false, ((RegisterNumber) value).translate()); } return value.toString(); @@ -164,7 +164,7 @@ public class DirectValueActionItem extends ActionItem implements SimpleValue { } if (value instanceof RegisterNumber) { - return writer.append(IdentifiersDeobfuscation.printIdentifier(false, ((RegisterNumber) value).translate())); + return writer.append(IdentifiersDeobfuscation.printIdentifier(localData.swf, false, ((RegisterNumber) value).translate())); } return writer.append(value.toString()); @@ -197,7 +197,7 @@ public class DirectValueActionItem extends ActionItem implements SimpleValue { srcData.localName = ((RegisterNumber) value).translate(); srcData.regIndex = ((RegisterNumber) value).number; - return writer.appendWithData(IdentifiersDeobfuscation.printIdentifier(false, ((RegisterNumber) value).translate()), srcData); + return writer.appendWithData(IdentifiersDeobfuscation.printIdentifier(localData.swf, false, ((RegisterNumber) value).translate()), srcData); } return writer.append(EcmaScript.toString(value)); } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/model/GetMemberActionItem.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/model/GetMemberActionItem.java index cc4b26c91..2b9172c80 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/model/GetMemberActionItem.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/model/GetMemberActionItem.java @@ -82,7 +82,7 @@ public class GetMemberActionItem extends ActionItem { StringBuilder sb = new StringBuilder(); StringBuilderTextWriter sbw = new StringBuilderTextWriter(new CodeFormatting(), sb); stripQuotes(memberName, localData, sbw); - writer.append(IdentifiersDeobfuscation.printIdentifier(false, sb.toString())); + writer.append(IdentifiersDeobfuscation.printIdentifier(localData.swf, false, sb.toString())); return writer; } if (((!(memberName instanceof DirectValueActionItem)) || (!((DirectValueActionItem) memberName).isString()) || (!printObfuscatedMemberName && !IdentifiersDeobfuscation.isValidName(false, ((DirectValueActionItem) memberName).toStringNoQuotes(localData))))) { diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/model/GetVariableActionItem.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/model/GetVariableActionItem.java index 9ccb1718a..a54b981f7 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/model/GetVariableActionItem.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/model/GetVariableActionItem.java @@ -102,7 +102,7 @@ public class GetVariableActionItem extends ActionItem { StringBuilder sb = new StringBuilder(); StringBuilderTextWriter sbw = new StringBuilderTextWriter(new CodeFormatting(), sb); stripQuotes(name, localData, sbw); - writer.append(IdentifiersDeobfuscation.printIdentifier(false, sb.toString())); + writer.append(IdentifiersDeobfuscation.printIdentifier(localData.swf, false, sb.toString())); return writer; } if ((name instanceof DirectValueActionItem) && (((DirectValueActionItem) name).isString()) && (printObfuscatedName || IdentifiersDeobfuscation.isValidNameWithDot(false, ((DirectValueActionItem) name).toStringNoQuotes(localData), "this", "super"))) { diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/model/InitObjectActionItem.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/model/InitObjectActionItem.java index 75a2e4259..b63f05c64 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/model/InitObjectActionItem.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/model/InitObjectActionItem.java @@ -81,7 +81,7 @@ public class InitObjectActionItem extends ActionItem { //AS1/2 does not allow quotes in name here if ((names.get(i) instanceof DirectValueActionItem) && (((DirectValueActionItem) names.get(i)).isSimpleValue())) { - writer.append(IdentifiersDeobfuscation.printIdentifier(false, names.get(i).toStringNoQuotes(localData))); + writer.append(IdentifiersDeobfuscation.printIdentifier(localData.swf, false, names.get(i).toStringNoQuotes(localData))); } else { writer.append("("); names.get(i).appendTo(writer, localData); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/model/NewObjectActionItem.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/model/NewObjectActionItem.java index 60ac32a5c..f7b4453d3 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/model/NewObjectActionItem.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/model/NewObjectActionItem.java @@ -70,7 +70,7 @@ public class NewObjectActionItem extends ActionItem { @Override public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) throws InterruptedException { writer.append("new "); - writer.append(IdentifiersDeobfuscation.printIdentifier(false, objectName.toStringNoQuotes(localData))); + writer.append(IdentifiersDeobfuscation.printIdentifier(localData.swf, false, objectName.toStringNoQuotes(localData))); writer.spaceBeforeCallParenthesis(arguments.size()); writer.append("("); for (int t = 0; t < arguments.size(); t++) { diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/model/SetVariableActionItem.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/model/SetVariableActionItem.java index 5d77b16dc..62e64ccef 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/model/SetVariableActionItem.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/model/SetVariableActionItem.java @@ -130,7 +130,7 @@ public class SetVariableActionItem extends ActionItem implements SetTypeActionIt //TODO: handle result needed better, without identifierdeobfuscation HighlightData srcData = getSrcData(); srcData.localName = name.toStringNoQuotes(localData); - writer.append(IdentifiersDeobfuscation.printIdentifier(false, name.toStringNoQuotes(localData))); + writer.append(IdentifiersDeobfuscation.printIdentifier(localData.swf, false, name.toStringNoQuotes(localData))); if (compoundOperator != null) { writer.append(" "); writer.append(compoundOperator); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/model/StoreRegisterActionItem.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/model/StoreRegisterActionItem.java index 2215c3e58..05a0e7201 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/model/StoreRegisterActionItem.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/model/StoreRegisterActionItem.java @@ -126,7 +126,7 @@ public class StoreRegisterActionItem extends ActionItem implements SetTypeAction srcData.declaredType = DottedChain.ALL; writer.append("var "); } - writer.append(IdentifiersDeobfuscation.printIdentifier(false, register.translate())); + writer.append(IdentifiersDeobfuscation.printIdentifier(localData.swf, false, register.translate())); if (compoundOperator != null) { writer.append(" "); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/model/clauses/ClassActionItem.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/model/clauses/ClassActionItem.java index 091d02053..0eec9c66f 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/model/clauses/ClassActionItem.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/model/clauses/ClassActionItem.java @@ -250,7 +250,7 @@ public class ClassActionItem extends ActionItem implements Block { item.getValue().toString(writer, localData).newLine(); } else { writer.append("var "); - writer.append(IdentifiersDeobfuscation.printIdentifier(false, item.getKey().toStringNoQuotes(localData))); + writer.append(IdentifiersDeobfuscation.printIdentifier(localData.swf, false, item.getKey().toStringNoQuotes(localData))); if (item.getValue() != null) { writer.append(" = "); item.getValue().toString(writer, localData); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/parser/script/ActionScript2Parser.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/parser/script/ActionScript2Parser.java index a199ef0c2..23f5d811e 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/parser/script/ActionScript2Parser.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/parser/script/ActionScript2Parser.java @@ -253,6 +253,11 @@ public class ActionScript2Parser { * Charset */ private String charset; + + /** + * SWF + */ + private SWF swf; /** * Constructor @@ -2056,7 +2061,7 @@ public class ActionScript2Parser { } private boolean isCastOp(GraphTargetItem item) { - LocalData localData = LocalData.create(new ConstantPool(constantPool)); + LocalData localData = LocalData.create(new ConstantPool(constantPool), this.swf); List items = new ArrayList<>(); while (item instanceof GetMemberActionItem) { GetMemberActionItem mem = (GetMemberActionItem) item; diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionSetVariable.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionSetVariable.java index 6206db2fd..cf0a87a35 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionSetVariable.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionSetVariable.java @@ -17,6 +17,7 @@ package com.jpexs.decompiler.flash.action.swf4; import com.jpexs.decompiler.flash.BaseLocalData; +import com.jpexs.decompiler.flash.SWF; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.LocalDataArea; import com.jpexs.decompiler.flash.action.StoreTypeAction; @@ -196,10 +197,10 @@ public class ActionSetVariable extends Action implements StoreTypeAction { } @Override - public String getVariableName(TranslateStack stack, ConstantPool cpool) { + public String getVariableName(TranslateStack stack, ConstantPool cpool, SWF swf) { if (stack.size() < 2) { return null; } - return stack.get(stack.size() - 2).toStringNoQuotes(LocalData.create(cpool)); + return stack.get(stack.size() - 2).toStringNoQuotes(LocalData.create(cpool, swf)); } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf5/ActionStoreRegister.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf5/ActionStoreRegister.java index 9043fb22b..53191082b 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf5/ActionStoreRegister.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf5/ActionStoreRegister.java @@ -17,6 +17,7 @@ package com.jpexs.decompiler.flash.action.swf5; import com.jpexs.decompiler.flash.BaseLocalData; +import com.jpexs.decompiler.flash.SWF; import com.jpexs.decompiler.flash.SWFInputStream; import com.jpexs.decompiler.flash.SWFOutputStream; import com.jpexs.decompiler.flash.action.Action; @@ -218,7 +219,7 @@ public class ActionStoreRegister extends Action implements StoreTypeAction { } @Override - public String getVariableName(TranslateStack stack, ConstantPool cpool) { + public String getVariableName(TranslateStack stack, ConstantPool cpool, SWF swf) { return "__register" + registerNumber; } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/configuration/Configuration.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/configuration/Configuration.java index d87c9b291..478a38719 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/configuration/Configuration.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/configuration/Configuration.java @@ -1158,6 +1158,10 @@ public final class Configuration { @ConfigurationDefaultBoolean(false) @ConfigurationInternal public static ConfigurationItem showHeapStatusWidget = null; + + @ConfigurationDefaultBoolean(false) + @ConfigurationCategory("script") + public static ConfigurationItem useSafeStr = null; private static Map configurationDescriptions = new LinkedHashMap<>(); private static Map configurationTitles = new LinkedHashMap<>(); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/script/AS3ScriptExporter.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/script/AS3ScriptExporter.java index 525b18701..b75faf9e3 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/script/AS3ScriptExporter.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/script/AS3ScriptExporter.java @@ -163,7 +163,7 @@ public class AS3ScriptExporter { if (((SetLocalAVM2Item) asg).regIndex == ((LocalRegAVM2Item) sp.object).regIndex) { GraphTargetItem val = sp.value; if (sp.propertyName instanceof FullMultinameAVM2Item) { - String propName = pack.abc.constants.getMultiname(((FullMultinameAVM2Item) sp.propertyName).multinameIndex).getName(pack.abc.constants, new ArrayList<>(), true, true); + String propName = pack.abc.constants.getMultiname(((FullMultinameAVM2Item) sp.propertyName).multinameIndex).getName(pack.abc, pack.abc.constants, new ArrayList<>(), true, true); if (val instanceof CallPropertyAVM2Item) { CallPropertyAVM2Item cap = (CallPropertyAVM2Item) val; if (cp.propertyName instanceof FullMultinameAVM2Item) { @@ -253,7 +253,7 @@ public class AS3ScriptExporter { private String getTagName(ScriptPack pack, int classMIndex, int nameMindex, Map namespaces) { Multiname m = pack.abc.constants.getMultiname(classMIndex); Multiname mn = pack.abc.constants.getMultiname(nameMindex); - String parentName = mn.getName(pack.abc.constants, new ArrayList<>(), true, true); + String parentName = mn.getName(pack.abc, pack.abc.constants, new ArrayList<>(), true, true); String pkg = m.getNamespace(pack.abc.constants).getName(pack.abc.constants).toRawString(); pkg += ".*"; String ns = null; @@ -315,7 +315,7 @@ public class AS3ScriptExporter { if (it instanceof InitPropertyAVM2Item) { InitPropertyAVM2Item ip = (InitPropertyAVM2Item) it; if (ip.object instanceof ThisAVM2Item) { - String propName = pack.abc.constants.getMultiname(ip.propertyName.multinameIndex).getName(pack.abc.constants, new ArrayList<>(), true, true); + String propName = pack.abc.constants.getMultiname(ip.propertyName.multinameIndex).getName(pack.abc, pack.abc.constants, new ArrayList<>(), true, true); GraphTargetItem val = ((InitPropertyAVM2Item) it).value; if (val instanceof CallPropertyAVM2Item) { CallPropertyAVM2Item cp = (CallPropertyAVM2Item) val; @@ -335,7 +335,7 @@ public class AS3ScriptExporter { ConstructPropAVM2Item cp = (ConstructPropAVM2Item) val; if (cp.propertyName instanceof FullMultinameAVM2Item) { Multiname m = pack.abc.constants.getMultiname(((FullMultinameAVM2Item) cp.propertyName).multinameIndex); - if ("mx.core.DeferredInstanceFromFunction".equals("" + m.getNameWithNamespace(pack.abc.constants, true))) { + if ("mx.core.DeferredInstanceFromFunction".equals("" + m.getNameWithNamespace(pack.abc, pack.abc.constants, true))) { if (!cp.args.isEmpty()) { if (cp.args.get(0) instanceof GetPropertyAVM2Item) { GetPropertyAVM2Item gp = (GetPropertyAVM2Item) cp.args.get(0); @@ -411,7 +411,7 @@ public class AS3ScriptExporter { Set files = new HashSet<>(); String documentClass = swf.getDocumentClass(); StringBuffer includeClassesBuilder = new StringBuffer(); - String documentPkg = documentClass != null ? DottedChain.parseNoSuffix(documentClass).getWithoutLast().toPrintableString(true) : null; + String documentPkg = documentClass != null ? DottedChain.parseNoSuffix(documentClass).getWithoutLast().toPrintableString(swf, true) : null; StringBuilder importsBuilder = new StringBuilder(); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/script/DependencyParser.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/script/DependencyParser.java index f9678b4fc..19a735741 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/script/DependencyParser.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/script/DependencyParser.java @@ -135,7 +135,7 @@ public class DependencyParser { return; } Namespace ns = m.getNamespace(abc.constants); - String name = m.getName(abc.constants, fullyQualifiedNames, true, true); + String name = m.getName(abc, abc.constants, fullyQualifiedNames, true, true); NamespaceSet nss = m.getNamespaceSet(abc.constants); if (ns != null) { parseDependenciesFromNS(abcIndex, ignoredCustom, abc, dependencies, m.namespace_index, ignorePackage, name, dependencyType, uses); @@ -271,7 +271,7 @@ public class DependencyParser { } if (classIndex > -1 && ins.definition instanceof GetOuterScopeIns) { if (ins.operands[0] > 0) { //first is global - DottedChain type = abc.instance_info.get(classIndex).getName(abc.constants).getNameWithNamespace(abc.constants, true); + DottedChain type = abc.instance_info.get(classIndex).getName(abc.constants).getNameWithNamespace(abc, abc.constants, true); AbcIndexing.ClassIndex cls = abcIndex.findClass(new TypeItem(type), abc, scriptIndex); List clsList = new ArrayList<>(); cls = cls.parent; @@ -281,7 +281,7 @@ public class DependencyParser { } if (ins.operands[0] < 1 + clsList.size()) { AbcIndexing.ClassIndex cls2 = clsList.get(ins.operands[0] - 1); - DottedChain nimport = cls2.abc.instance_info.get(cls2.index).getName(cls2.abc.constants).getNameWithNamespace(cls2.abc.constants, true); + DottedChain nimport = cls2.abc.instance_info.get(cls2.index).getName(cls2.abc.constants).getNameWithNamespace(cls2.abc, cls2.abc.constants, true); Dependency depExp = new Dependency(nimport, DependencyType.EXPRESSION); if (!dependencies.contains(depExp)) { dependencies.add(depExp); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/script/LinkReportExporter.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/script/LinkReportExporter.java index 518690d3f..c3ba94c11 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/script/LinkReportExporter.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/script/LinkReportExporter.java @@ -128,7 +128,7 @@ public class LinkReportExporter { ns = abc.constants.getNamespace(nss.namespaces[0]); } String pkgName = ns == null ? "" : ns.getName(abc.constants).toRawString(); - String clsName = multiName.getName(abc.constants, new ArrayList<>(), true, true); + String clsName = multiName.getName(abc, abc.constants, new ArrayList<>(), true, true); return pkgName.isEmpty() ? clsName : pkgName + ":" + clsName; } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/flexsdk/MxmlcAs3ScriptReplacer.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/flexsdk/MxmlcAs3ScriptReplacer.java index 2e1ed9efc..f4a1ec1ef 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/flexsdk/MxmlcAs3ScriptReplacer.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/flexsdk/MxmlcAs3ScriptReplacer.java @@ -112,11 +112,11 @@ public class MxmlcAs3ScriptReplacer extends MxmlcRunner implements As3ScriptRepl if (ii.deleted) { return true; } - if (ii.super_index != 0 && isParentDeleted(abc, allAbcs, abc.constants.getMultiname(ii.super_index).getNameWithNamespace(abc.constants, false))) { + if (ii.super_index != 0 && isParentDeleted(abc, allAbcs, abc.constants.getMultiname(ii.super_index).getNameWithNamespace(abc, abc.constants, false))) { return true; } for (int iface : ii.interfaces) { - if (isParentDeleted(abc, allAbcs, abc.constants.getMultiname(iface).getNameWithNamespace(abc.constants, false))) { + if (isParentDeleted(abc, allAbcs, abc.constants.getMultiname(iface).getNameWithNamespace(abc, abc.constants, false))) { return true; } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/search/ABCSearchResult.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/search/ABCSearchResult.java index 41378058b..218408117 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/search/ABCSearchResult.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/search/ABCSearchResult.java @@ -240,10 +240,10 @@ public class ABCSearchResult implements Serializable, ScriptSearchResult { boolean isStatic = traitId < staticTraitCount; if (isStatic) { - return abc.class_info.get(classIndex).static_traits.traits.get(traitId).getName(abc).getName(abc.constants, null, false, true); + return abc.class_info.get(classIndex).static_traits.traits.get(traitId).getName(abc).getName(abc, abc.constants, null, false, true); } else { int index = traitId - staticTraitCount; - return abc.instance_info.get(classIndex).instance_traits.traits.get(index).getName(abc).getName(abc.constants, null, false, true); + return abc.instance_info.get(classIndex).instance_traits.traits.get(index).getName(abc).getName(abc, abc.constants, null, false, true); } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineEditTextTag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineEditTextTag.java index 5a60fbb19..db2bdd2b2 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineEditTextTag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineEditTextTag.java @@ -897,7 +897,7 @@ public class DefineEditTextTag extends TextTag { writer.append("leading ").append(leading).newLine(); } if (!variableName.isEmpty()) { - writer.append("variablename ").append(DottedChain.parseNoSuffix(variableName).toPrintableString(false)).newLine(); + writer.append("variablename ").append(DottedChain.parseNoSuffix(variableName).toPrintableString(getSwf(), false)).newLine(); } writer.append("]"); if (hasText) { @@ -1610,7 +1610,7 @@ public class DefineEditTextTag extends TextTag { public Map getNameProperties() { Map ret = super.getNameProperties(); if (variableName != null && !variableName.isEmpty()) { - ret.put("vn", DottedChain.parseNoSuffix(variableName).toPrintableString(false)); + ret.put("vn", DottedChain.parseNoSuffix(variableName).toPrintableString(getSwf(), false)); } return ret; } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DoInitActionTag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DoInitActionTag.java index 6925e8914..1ce950fbb 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DoInitActionTag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DoInitActionTag.java @@ -253,7 +253,7 @@ public class DoInitActionTag extends Tag implements CharacterIdTag, ASMSource { if (exportName == null || exportName.isEmpty()) { return ret; } - ret.put("exp", Helper.escapeExportname(exportName, true)); + ret.put("exp", Helper.escapeExportname(getSwf(), exportName, true)); return ret; } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/ExportAssetsTag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/ExportAssetsTag.java index cb0de5895..021a9ad9c 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/ExportAssetsTag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/ExportAssetsTag.java @@ -166,7 +166,7 @@ public class ExportAssetsTag extends SymbolClassTypeTag { if (names.size() == 1) { ret.put("chid", "" + tags.get(0)); String exportName = names.get(0); - ret.put("exp", Helper.escapeExportname(exportName, true)); + ret.put("exp", Helper.escapeExportname(getSwf(), exportName, true)); } return ret; } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/ImportAssets2Tag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/ImportAssets2Tag.java index 1110247bd..254af1781 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/ImportAssets2Tag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/ImportAssets2Tag.java @@ -164,7 +164,7 @@ public class ImportAssets2Tag extends Tag implements ImportTag { ret.put("chid", "" + tags.get(0)); String importName = names.get(0); if (importName.startsWith("__Packages.")) { - ret.put("imp", DottedChain.parseNoSuffix(importName).toPrintableString(false)); + ret.put("imp", DottedChain.parseNoSuffix(importName).toPrintableString(getSwf(), false)); } else { ret.put("imp", "\"" + Helper.escapePCodeString(importName) + "\""); } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/ImportAssetsTag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/ImportAssetsTag.java index b1d156ffb..cf786817e 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/ImportAssetsTag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/ImportAssetsTag.java @@ -142,7 +142,7 @@ public class ImportAssetsTag extends Tag implements ImportTag { String importName = names.get(0); if (importName.startsWith("__Packages.")) { - ret.put("imp", DottedChain.parseNoSuffix(importName).toPrintableString(false)); + ret.put("imp", DottedChain.parseNoSuffix(importName).toPrintableString(getSwf(), false)); } else { ret.put("imp", "\"" + Helper.escapePCodeString(importName) + "\""); } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/PlaceObject2Tag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/PlaceObject2Tag.java index c934b95bb..bacd3f7a1 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/PlaceObject2Tag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/PlaceObject2Tag.java @@ -458,7 +458,7 @@ public class PlaceObject2Tag extends PlaceObjectTypeTag implements ASMSourceCont public Map getNameProperties() { Map ret = super.getNameProperties(); if (placeFlagHasName) { - ret.put("nm", DottedChain.parseNoSuffix(name).toPrintableString(false)); + ret.put("nm", DottedChain.parseNoSuffix(name).toPrintableString(getSwf(), false)); } return ret; } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/PlaceObject3Tag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/PlaceObject3Tag.java index 162b3c6df..595b60fc8 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/PlaceObject3Tag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/PlaceObject3Tag.java @@ -698,7 +698,7 @@ public class PlaceObject3Tag extends PlaceObjectTypeTag implements ASMSourceCont public Map getNameProperties() { Map ret = super.getNameProperties(); if (placeFlagHasName) { - ret.put("nm", DottedChain.parseNoSuffix(name).toPrintableString(false)); + ret.put("nm", DottedChain.parseNoSuffix(name).toPrintableString(getSwf(), false)); } return ret; } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/PlaceObject4Tag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/PlaceObject4Tag.java index 031eae7a5..ec65896ca 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/PlaceObject4Tag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/PlaceObject4Tag.java @@ -711,7 +711,7 @@ public class PlaceObject4Tag extends PlaceObjectTypeTag implements ASMSourceCont public Map getNameProperties() { Map ret = super.getNameProperties(); if (placeFlagHasName) { - ret.put("nm", DottedChain.parseNoSuffix(name).toPrintableString(false)); + ret.put("nm", DottedChain.parseNoSuffix(name).toPrintableString(getSwf(), false)); } return ret; } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/base/CharacterTag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/base/CharacterTag.java index 0ca67b187..3c4867e17 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/base/CharacterTag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/base/CharacterTag.java @@ -99,12 +99,12 @@ public abstract class CharacterTag extends Tag implements CharacterIdTag { ret.put("chid", "" + chid); } if (exportName != null) { - ret.put("exp", Helper.escapeExportname(exportName, true)); + ret.put("exp", Helper.escapeExportname(getSwf(), exportName, true)); } if (!classNames.isEmpty()) { List escapedList = new ArrayList<>(); for (String className : classNames) { - escapedList.add(DottedChain.parseNoSuffix(className).toPrintableString(true)); + escapedList.add(DottedChain.parseNoSuffix(className).toPrintableString(getSwf(), true)); } ret.put("cls", String.join(", ", escapedList)); } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/base/PlaceObjectTypeTag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/base/PlaceObjectTypeTag.java index 264217511..227185a37 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/base/PlaceObjectTypeTag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/base/PlaceObjectTypeTag.java @@ -338,7 +338,7 @@ public abstract class PlaceObjectTypeTag extends Tag implements CharacterIdTag, ret.put("chid", "" + charId); } if (exportName != null) { - ret.put("exp", Helper.escapeExportname(exportName, true)); + ret.put("exp", Helper.escapeExportname(getSwf(), exportName, true)); } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/base/RemoveTag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/base/RemoveTag.java index 32562b205..a50c6c16d 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/base/RemoveTag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/base/RemoveTag.java @@ -50,7 +50,7 @@ public abstract class RemoveTag extends Tag implements DepthTag { ret.put("chid", "" + getCharacterId()); } if (exportName != null) { - ret.put("exp", Helper.escapeExportname(exportName, true)); + ret.put("exp", Helper.escapeExportname(getSwf(), exportName, true)); } ret.put("dpt", "" + getDepth()); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/timeline/AS2Package.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/timeline/AS2Package.java index 100fde754..0915af148 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/timeline/AS2Package.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/timeline/AS2Package.java @@ -192,7 +192,7 @@ public class AS2Package implements TreeItem { if (defaultPackage) { return name; } - return DottedChain.parseNoSuffix(name).toPrintableString(false); + return DottedChain.parseNoSuffix(name).toPrintableString(swf, false); } /** diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/timeline/AS3Package.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/timeline/AS3Package.java index 621da38f4..173023403 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/timeline/AS3Package.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/timeline/AS3Package.java @@ -355,7 +355,7 @@ public class AS3Package extends AS3ClassTreeItem { if (flat) { return packageName; } - return IdentifiersDeobfuscation.printIdentifier(true, packageName); + return IdentifiersDeobfuscation.printIdentifier(abc.getSwf(), true, packageName); } /** diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/treeitems/AS3ClassTreeItem.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/treeitems/AS3ClassTreeItem.java index ce1e90044..33e75fdba 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/treeitems/AS3ClassTreeItem.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/treeitems/AS3ClassTreeItem.java @@ -17,6 +17,8 @@ package com.jpexs.decompiler.flash.treeitems; import com.jpexs.decompiler.flash.IdentifiersDeobfuscation; +import com.jpexs.decompiler.flash.SWF; +import com.jpexs.decompiler.flash.abc.ABC; import com.jpexs.decompiler.flash.abc.ClassPath; /** @@ -73,7 +75,17 @@ public abstract class AS3ClassTreeItem implements TreeItem { * @return Name with namespace suffix but printable */ public String getPrintableNameWithNamespaceSuffix() { - String ret = IdentifiersDeobfuscation.printIdentifier(true, name); + + Openable o = getOpenable(); + SWF swf = null; + if (o instanceof SWF) { + swf = (SWF) o; + } + if (o instanceof ABC) { + swf = ((ABC) o).getSwf(); + } + + String ret = IdentifiersDeobfuscation.printIdentifier(swf, true, name); if (namespaceSuffix != null) { ret += namespaceSuffix; } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/xfl/XFLConverter.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/xfl/XFLConverter.java index ee4caa62e..65b70ba15 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/xfl/XFLConverter.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/xfl/XFLConverter.java @@ -3060,14 +3060,14 @@ public class XFLConverter { if (callProp.arguments.get(i) instanceof IntegerValueAVM2Item) { if (callProp.arguments.get(i + 1) instanceof GetLexAVM2Item) { GetLexAVM2Item lex = (GetLexAVM2Item) callProp.arguments.get(i + 1); - frameTraitNames.add(lex.propertyName.getName(abc.constants, new ArrayList<>(), false, true)); + frameTraitNames.add(lex.propertyName.getName(abc, abc.constants, new ArrayList<>(), false, true)); } else if (callProp.arguments.get(i + 1) instanceof GetPropertyAVM2Item) { GetPropertyAVM2Item getProp = (GetPropertyAVM2Item) callProp.arguments.get(i + 1); if (getProp.object instanceof ThisAVM2Item) { if (getProp.propertyName instanceof FullMultinameAVM2Item) { FullMultinameAVM2Item framePropName = (FullMultinameAVM2Item) getProp.propertyName; int multinameIndex = framePropName.multinameIndex; - frameTraitNames.add(abc.constants.getMultiname(multinameIndex).getName(abc.constants, new ArrayList<>(), false, true)); + frameTraitNames.add(abc.constants.getMultiname(multinameIndex).getName(abc, abc.constants, new ArrayList<>(), false, true)); } } } @@ -3083,7 +3083,7 @@ public class XFLConverter { List frameRangeAccessibilityTraitNames = new ArrayList<>(); for (Trait t : instanceInfo.instance_traits.traits) { if (t instanceof TraitMethodGetterSetter) { - String traitName = t.getName(abc).getName(abc.constants, new ArrayList<>(), true, false); + String traitName = t.getName(abc).getName(abc, abc.constants, new ArrayList<>(), true, false); if ("__setTab_handler".equals(traitName) || "__setAcc_handler".equals(traitName)) { TraitMethodGetterSetter tm = (TraitMethodGetterSetter) t; @@ -3144,7 +3144,7 @@ public class XFLConverter { for (Trait t : instanceInfo.instance_traits.traits) { if (t instanceof TraitMethodGetterSetter) { - String traitName = t.getName(abc).getName(abc.constants, new ArrayList<>(), true, false); + String traitName = t.getName(abc).getName(abc, abc.constants, new ArrayList<>(), true, false); if (frameAccessibilityTraitNames.contains(traitName)) { TraitMethodGetterSetter tm = (TraitMethodGetterSetter) t; MethodBody traitBody = abc.findBody(tm.method_info); @@ -3367,7 +3367,7 @@ public class XFLConverter { } for (Trait t : instanceInfo.instance_traits.traits) { - if (allFramesAccessibilityTraitNames.contains(t.getName(abc).getName(abc.constants, new ArrayList<>(), true, false))) { + if (allFramesAccessibilityTraitNames.contains(t.getName(abc).getName(abc, abc.constants, new ArrayList<>(), true, false))) { if (t instanceof TraitMethodGetterSetter) { TraitMethodGetterSetter tm = (TraitMethodGetterSetter) t; MethodBody traitBody = abc.findBody(tm.method_info); @@ -3511,14 +3511,14 @@ public class XFLConverter { int frame = frameItem.intValue(); if (callProp.arguments.get(i + 1) instanceof GetLexAVM2Item) { GetLexAVM2Item lex = (GetLexAVM2Item) callProp.arguments.get(i + 1); - frameToTraitName.put(frame, lex.propertyName.getName(abc.constants, new ArrayList<>(), true, false)); + frameToTraitName.put(frame, lex.propertyName.getName(abc, abc.constants, new ArrayList<>(), true, false)); } else if (callProp.arguments.get(i + 1) instanceof GetPropertyAVM2Item) { GetPropertyAVM2Item getProp = (GetPropertyAVM2Item) callProp.arguments.get(i + 1); if (getProp.object instanceof ThisAVM2Item) { if (getProp.propertyName instanceof FullMultinameAVM2Item) { FullMultinameAVM2Item framePropName = (FullMultinameAVM2Item) getProp.propertyName; int multinameIndex = framePropName.multinameIndex; - frameToTraitName.put(frame, abc.constants.getMultiname(multinameIndex).getName(abc.constants, new ArrayList<>(), true, false)); + frameToTraitName.put(frame, abc.constants.getMultiname(multinameIndex).getName(abc, abc.constants, new ArrayList<>(), true, false)); } } } @@ -3532,7 +3532,7 @@ public class XFLConverter { Map multinameToMethodTrait = new HashMap<>(); for (Trait trait : instanceInfo.instance_traits.traits) { if (trait instanceof TraitMethodGetterSetter) { - multinameToMethodTrait.put(abc.constants.getMultiname(trait.name_index).getName(abc.constants, new ArrayList<>(), true, false), (TraitMethodGetterSetter) trait); + multinameToMethodTrait.put(abc.constants.getMultiname(trait.name_index).getName(abc, abc.constants, new ArrayList<>(), true, false), (TraitMethodGetterSetter) trait); } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/graph/DottedChain.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/graph/DottedChain.java index 1f256adff..f7d940974 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/graph/DottedChain.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/graph/DottedChain.java @@ -17,6 +17,7 @@ package com.jpexs.decompiler.graph; import com.jpexs.decompiler.flash.IdentifiersDeobfuscation; +import com.jpexs.decompiler.flash.SWF; import com.jpexs.helpers.Helper; import java.io.File; import java.io.Serializable; @@ -449,12 +450,13 @@ public class DottedChain implements Serializable, Comparable { /** * To string. * + * @param swf SWF * @param as3 Whether to print as AS3 * @param raw Whether to print raw (without deobfuscation) * @param withSuffix Whether to print with suffix * @return String */ - protected String toString(boolean as3, boolean raw, boolean withSuffix) { + protected String toString(SWF swf, boolean as3, boolean raw, boolean withSuffix) { if (parts.isEmpty()) { return ""; } @@ -469,7 +471,7 @@ public class DottedChain implements Serializable, Comparable { } String part = parts.get(i).name; boolean lastStar = i == parts.size() - 1 && "*".equals(part); - ret.append((raw || lastStar) ? part : IdentifiersDeobfuscation.printIdentifier(as3, part)); + ret.append((raw || lastStar) ? part : IdentifiersDeobfuscation.printIdentifier(swf, as3, part)); if (withSuffix) { ret.append(parts.get(i).namespaceSuffix); } @@ -481,9 +483,10 @@ public class DottedChain implements Serializable, Comparable { /** * To file path. * + * @param swf SWF * @return File path */ - public String toFilePath() { + public String toFilePath(SWF swf) { if (parts.isEmpty()) { return ""; } @@ -494,7 +497,7 @@ public class DottedChain implements Serializable, Comparable { ret.append(File.separator); } - ret.append(Helper.makeFileName(IdentifiersDeobfuscation.printIdentifier(true, parts.get(i).name))); + ret.append(Helper.makeFileName(IdentifiersDeobfuscation.printIdentifier(swf, true, parts.get(i).name))); } return ret.toString(); } @@ -515,20 +518,22 @@ public class DottedChain implements Serializable, Comparable { /** * To printable string. * + * @param swf SWF * @param as3 Whether to print as AS3 * @return Printable string */ - public String toPrintableString(boolean as3) { - return toString(as3, false, true); + public String toPrintableString(SWF swf, boolean as3) { + return toString(swf, as3, false, true); } /** * To raw string. (without deobfuscation) * + * @param swf SWF * @return Raw string */ public String toRawString() { //Is SUFFIX correctly handled? - return toString(false/*ignored*/, true, true); + return toString(null, false/*ignored*/, true, true); } /** diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/graph/TypeItem.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/graph/TypeItem.java index 9fb1d9ac5..24818570e 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/graph/TypeItem.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/graph/TypeItem.java @@ -163,9 +163,9 @@ public class TypeItem extends GraphTargetItem { boolean as3 = localData.constantsAvm2 != null; if (localData.fullyQualifiedNames.contains(DottedChain.parseWithSuffix(fullTypeName.getLast()))) { - writer.hilightSpecial(fullTypeName.toPrintableString(as3), HighlightSpecialType.TYPE_NAME, fullTypeName.toRawString()); + writer.hilightSpecial(fullTypeName.toPrintableString(localData.swf, as3), HighlightSpecialType.TYPE_NAME, fullTypeName.toRawString()); } else { - writer.hilightSpecial(IdentifiersDeobfuscation.printIdentifier(as3, fullTypeName.getLast()), HighlightSpecialType.TYPE_NAME, fullTypeName.toRawString()); + writer.hilightSpecial(IdentifiersDeobfuscation.printIdentifier(localData.swf, as3, fullTypeName.getLast()), HighlightSpecialType.TYPE_NAME, fullTypeName.toRawString()); } return writer; diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/graph/model/LocalData.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/graph/model/LocalData.java index 049cac156..b9afdb5f2 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/graph/model/LocalData.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/graph/model/LocalData.java @@ -16,6 +16,7 @@ */ package com.jpexs.decompiler.graph.model; +import com.jpexs.decompiler.flash.SWF; import com.jpexs.decompiler.flash.abc.ABC; import com.jpexs.decompiler.flash.abc.avm2.AVM2ConstantPool; import com.jpexs.decompiler.flash.abc.avm2.parser.script.AbcIndexing; @@ -39,7 +40,12 @@ public class LocalData { * Empty local data */ public static LocalData empty = new LocalData(); - + + /** + * SWF + */ + public SWF swf; + /** * Constant pool */ @@ -96,9 +102,10 @@ public class LocalData { * @param constants Constant pool * @return Local data */ - public static LocalData create(ConstantPool constants) { + public static LocalData create(ConstantPool constants, SWF swf) { LocalData localData = new LocalData(); localData.constants = constants; + localData.swf = swf; return localData; } @@ -125,6 +132,7 @@ public class LocalData { localData.callStack = callStack; localData.exportMode = exportMode; localData.swfVersion = swfVersion; + localData.swf = abc.getSwf(); return localData; } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/helpers/Helper.java b/libsrc/ffdec_lib/src/com/jpexs/helpers/Helper.java index b1b2f37ca..1129ba7e1 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/helpers/Helper.java +++ b/libsrc/ffdec_lib/src/com/jpexs/helpers/Helper.java @@ -18,6 +18,7 @@ package com.jpexs.helpers; import com.jpexs.decompiler.flash.AppResources; import com.jpexs.decompiler.flash.ApplicationInfo; +import com.jpexs.decompiler.flash.SWF; import com.jpexs.decompiler.flash.configuration.Configuration; import com.jpexs.decompiler.flash.helpers.Freed; import com.jpexs.decompiler.flash.helpers.GraphTextWriter; @@ -240,13 +241,14 @@ public class Helper { /** * Escapes export name + * @param swf SWF * @param s Input string * @param quote Add quotes when not starts __Packages. * @return Escaped string */ - public static String escapeExportname(String s, boolean quote) { + public static String escapeExportname(SWF swf, String s, boolean quote) { if (s.startsWith("__Packages.")) { - return DottedChain.parseNoSuffix(s).toPrintableString(false); + return DottedChain.parseNoSuffix(s).toPrintableString(swf, false); } return (quote ? "\"" : "") + escapePCodeString(s) + (quote ? "\"" : ""); } diff --git a/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/generators/AS3Generator.java b/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/generators/AS3Generator.java index 9bf6b806c..712761046 100644 --- a/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/generators/AS3Generator.java +++ b/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/generators/AS3Generator.java @@ -127,7 +127,7 @@ public class AS3Generator { for (Trait t : abc.instance_info.get(classId).instance_traits.traits) { if (t instanceof TraitMethodGetterSetter) { - String name = t.getName(abc).getName(abc.constants, null, true, true); + String name = t.getName(abc).getName(abc, abc.constants, null, true, true); String clsName = pack.getClassPath().className; String lower = clsName.substring(0, 1).toLowerCase() + clsName.substring(1); String identifier = swfAndIdentifierList[0][1]; diff --git a/src/com/jpexs/decompiler/flash/console/CommandLineArgumentParser.java b/src/com/jpexs/decompiler/flash/console/CommandLineArgumentParser.java index dc0421a59..bfd67b1c5 100644 --- a/src/com/jpexs/decompiler/flash/console/CommandLineArgumentParser.java +++ b/src/com/jpexs/decompiler/flash/console/CommandLineArgumentParser.java @@ -4354,9 +4354,9 @@ public class CommandLineArgumentParser { if (dcs != null) { if (dcs.contains(".")) { DottedChain dc = DottedChain.parseWithSuffix(dcs); - pw.println("documentClass=" + dc.toPrintableString(true)); + pw.println("documentClass=" + dc.toPrintableString(swf, true)); } else { - pw.println("documentClass=" + IdentifiersDeobfuscation.printIdentifier(true, dcs)); + pw.println("documentClass=" + IdentifiersDeobfuscation.printIdentifier(swf, true, dcs)); } } else { pw.println("documentClass="); diff --git a/src/com/jpexs/decompiler/flash/easygui/LibraryTreeTable.java b/src/com/jpexs/decompiler/flash/easygui/LibraryTreeTable.java index 6bac609e0..0a8871008 100644 --- a/src/com/jpexs/decompiler/flash/easygui/LibraryTreeTable.java +++ b/src/com/jpexs/decompiler/flash/easygui/LibraryTreeTable.java @@ -391,13 +391,13 @@ public class LibraryTreeTable extends JTreeTable { CharacterTag ct = (CharacterTag) o; String exportName = ct.getExportName(); if (exportName != null) { - return Helper.escapeExportname(exportName, false); + return Helper.escapeExportname(ct.getSwf(), exportName, false); } Set classNames = ct.getClassNames(); if (!classNames.isEmpty()) { List escapedList = new ArrayList<>(); for (String className : classNames) { - escapedList.add(DottedChain.parseNoSuffix(className).toPrintableString(true)); + escapedList.add(DottedChain.parseNoSuffix(className).toPrintableString(ct.getSwf(), true)); } return String.join(", ", escapedList); } diff --git a/src/com/jpexs/decompiler/flash/gui/DebuggerHandler.java b/src/com/jpexs/decompiler/flash/gui/DebuggerHandler.java index 1a075bf84..c2a9ab962 100644 --- a/src/com/jpexs/decompiler/flash/gui/DebuggerHandler.java +++ b/src/com/jpexs/decompiler/flash/gui/DebuggerHandler.java @@ -755,7 +755,7 @@ public class DebuggerHandler implements DebugConnectionListener { pkg = pkg.substring(pkg.indexOf(":") + 1); } - name = swfHash + ":" + DottedChain.parseWithSuffix(pkg).addWithSuffix(clsNameWithSuffix).toPrintableString(con.isAS3); + name = swfHash + ":" + DottedChain.parseWithSuffix(pkg).addWithSuffix(clsNameWithSuffix).toPrintableString(Main.getRunningSWF()/*???*/, con.isAS3); } } else { if (name.contains(":")) { diff --git a/src/com/jpexs/decompiler/flash/gui/FolderListPanel.java b/src/com/jpexs/decompiler/flash/gui/FolderListPanel.java index 5c7b57f42..adabd6724 100644 --- a/src/com/jpexs/decompiler/flash/gui/FolderListPanel.java +++ b/src/com/jpexs/decompiler/flash/gui/FolderListPanel.java @@ -258,9 +258,9 @@ public class FolderListPanel extends JPanel { if (expName != null && !expName.isEmpty()) { String[] pathParts = expName.contains(".") ? expName.split("\\.") : new String[]{expName}; if (expName.startsWith("__Packages.")) { - s = IdentifiersDeobfuscation.printIdentifier(false, pathParts[pathParts.length - 1]); + s = IdentifiersDeobfuscation.printIdentifier(tag.getSwf(), false, pathParts[pathParts.length - 1]); } else { - s = Helper.escapeExportname(expName, false); + s = Helper.escapeExportname(tag.getSwf(), expName, false); } } } diff --git a/src/com/jpexs/decompiler/flash/gui/GenericTagTreePanel.java b/src/com/jpexs/decompiler/flash/gui/GenericTagTreePanel.java index 7f9d2e198..1d6ff87fb 100644 --- a/src/com/jpexs/decompiler/flash/gui/GenericTagTreePanel.java +++ b/src/com/jpexs/decompiler/flash/gui/GenericTagTreePanel.java @@ -161,8 +161,7 @@ public class GenericTagTreePanel extends GenericTagPanel { super.paint(g, c); } }); - setCellRenderer(new MyTreeCellRenderer()); - setCellEditor(new MyTreeCellEditor(this)); + setCellRenderer(new MyTreeCellRenderer()); setInvokesStopCellEditing(true); } @@ -293,9 +292,11 @@ public class GenericTagTreePanel extends GenericTagPanel { private final JTree tree; private FieldNode fnode; + private final SWF swf; - public MyTreeCellEditor(JTree tree) { + public MyTreeCellEditor(JTree tree, SWF swf) { this.tree = tree; + this.swf = swf; } @Override @@ -361,7 +362,7 @@ public class GenericTagTreePanel extends GenericTagPanel { } else if (type.equals(boolean.class) || type.equals(Boolean.class)) { editor = new BooleanEditor(field.getName(), obj, field, index, type); } else if (type.equals(String.class)) { - editor = new StringEditor(field.getName(), obj, field, index, type, multiline != null); + editor = new StringEditor(field.getName(), obj, field, index, type, multiline != null, swf); } else if (type.equals(RGB.class) || type.equals(RGBA.class) || type.equals(ARGB.class)) { editor = new ColorEditor(field.getName(), obj, field, index, type); } else if (type.equals(byte[].class) || type.equals(ByteArrayRange.class)) { @@ -794,12 +795,13 @@ public class GenericTagTreePanel extends GenericTagPanel { private MyTreeModel model; private Object parentObject; + private final SWF swf; public Object getParentObject() { return parentObject; } - public FieldNode(Object parent, MyTreeModel model, Tag tag, Object obj, FieldSet fieldSet, int index) { + public FieldNode(Object parent, MyTreeModel model, Tag tag, Object obj, FieldSet fieldSet, int index, SWF swf) { this.tag = tag; this.obj = obj; this.fieldSet = fieldSet; @@ -820,6 +822,7 @@ public class GenericTagTreePanel extends GenericTagPanel { } } } + this.swf = swf; } @Override @@ -911,9 +914,9 @@ public class GenericTagTreePanel extends GenericTagPanel { DottedIdentifier di = field.getAnnotation(DottedIdentifier.class); if (val instanceof String && di != null) { if (di.exportName()) { - valStr += " = " + escapeHtml(Helper.escapeExportname(val.toString(), true)); + valStr += " = " + escapeHtml(Helper.escapeExportname(swf, val.toString(), true)); } else { - valStr += " = " + escapeHtml(DottedChain.parseNoSuffix(val.toString()).toPrintableString(di.as3())); + valStr += " = " + escapeHtml(DottedChain.parseNoSuffix(val.toString()).toPrintableString(swf, di.as3())); } } else if (val instanceof byte[]) { valStr += " = " + ((byte[]) val).length + " byte"; @@ -1216,15 +1219,15 @@ public class GenericTagTreePanel extends GenericTagPanel { private Object getChild(Object parent, int index, boolean limited) { if (parent == mtroot) { - return new FieldNode(null, this, mtroot, mtroot, filterFields(mtroot.getSwf(), this, mtroot.getClass().getSimpleName(), mtroot.getClass(), limited, mtroot.getId()).get(index), -1); + return new FieldNode(null, this, mtroot, mtroot, filterFields(mtroot.getSwf(), this, mtroot.getClass().getSimpleName(), mtroot.getClass(), limited, mtroot.getId()).get(index), -1, mtroot.getSwf()); } FieldNode fnode = (FieldNode) parent; Field field = fnode.fieldSet.get(FIELD_INDEX); if (ReflectionTools.needsIndex(field) && (fnode.index == -1)) { //Arrays ot Lists - return new FieldNode(parent, this, mtroot, fnode.obj, fnode.fieldSet, index); + return new FieldNode(parent, this, mtroot, fnode.obj, fnode.fieldSet, index, mtroot.getSwf()); } parent = fnode.getValue(FIELD_INDEX); - return new FieldNode(parent, this, mtroot, parent, filterFields(mtroot.getSwf(), this, getNodePathName(fnode), parent.getClass(), limited, mtroot.getId()).get(index), -1); + return new FieldNode(parent, this, mtroot, parent, filterFields(mtroot.getSwf(), this, getNodePathName(fnode), parent.getClass(), limited, mtroot.getId()).get(index), -1, mtroot.getSwf()); } @Override @@ -1314,6 +1317,9 @@ public class GenericTagTreePanel extends GenericTagPanel { tree.stopEditing(); } tree.setEditable(edit); + if (editedTag != null) { + tree.setCellEditor(new MyTreeCellEditor(tree, editedTag.getSwf())); + } refreshTree(); } diff --git a/src/com/jpexs/decompiler/flash/gui/MainPanel.java b/src/com/jpexs/decompiler/flash/gui/MainPanel.java index 563c3c833..27b8be3a3 100644 --- a/src/com/jpexs/decompiler/flash/gui/MainPanel.java +++ b/src/com/jpexs/decompiler/flash/gui/MainPanel.java @@ -2010,7 +2010,7 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se if (!oldName.equals(newName)) { if (oldName.equals(abcPanel.decompiledTextArea.getScriptLeaf().getClassPath().className)) { - scriptName = abcPanel.decompiledTextArea.getScriptLeaf().getClassPath().packageStr.add(newName, "").toPrintableString(true); + scriptName = abcPanel.decompiledTextArea.getScriptLeaf().getClassPath().packageStr.add(newName, "").toPrintableString(swf, true); } final String fScriptName = scriptName; @@ -2849,7 +2849,7 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se String documentClass = swf.getDocumentClass(); if (documentClass != null && currentView != VIEW_DUMP) { - String documentClassPrintable = DottedChain.parseNoSuffix(documentClass).toPrintableString(true); + String documentClassPrintable = DottedChain.parseNoSuffix(documentClass).toPrintableString(swf, true); List abcList = swf.getAbcList(); if (!abcList.isEmpty()) { ABCPanel abcPanel = getABCPanel(); diff --git a/src/com/jpexs/decompiler/flash/gui/abc/ABCExplorerDialog.java b/src/com/jpexs/decompiler/flash/gui/abc/ABCExplorerDialog.java index ea19bd116..54134d834 100644 --- a/src/com/jpexs/decompiler/flash/gui/abc/ABCExplorerDialog.java +++ b/src/com/jpexs/decompiler/flash/gui/abc/ABCExplorerDialog.java @@ -967,9 +967,9 @@ public class ABCExplorerDialog extends AppDialog { if (found) { DottedChain scriptNameDc = abc.script_info.get(scriptIndex).getSimplePackName(abc); if (scriptNameDc == null && scriptTraitIndex > -1) { - scriptNameDc = abc.script_info.get(scriptIndex).traits.traits.get(scriptTraitIndex).getName(abc).getNameWithNamespace(abc.constants, false); + scriptNameDc = abc.script_info.get(scriptIndex).traits.traits.get(scriptTraitIndex).getName(abc).getNameWithNamespace(abc, abc.constants, false); } - String scriptName = (scriptNameDc == null ? "script_" + scriptIndex : scriptNameDc.toPrintableString(true)); + String scriptName = (scriptNameDc == null ? "script_" + scriptIndex : scriptNameDc.toPrintableString(abc.getSwf(), true)); //mainPanel.gotoScriptTrait(abc.getSwf(), scriptName, classIndex, globalTraitIndex); mainPanel.gotoScriptMethod(abc.getSwf(), scriptName, searchMethodInfo); } @@ -1000,7 +1000,7 @@ public class ABCExplorerDialog extends AppDialog { case SCRIPT_INFO: scriptIndex = vwi.getIndex(); DottedChain scriptNameDc = abc.script_info.get(scriptIndex).getSimplePackName(abc); - String scriptName = (scriptNameDc == null ? "script_" + scriptIndex : scriptNameDc.toPrintableString(true)); + String scriptName = (scriptNameDc == null ? "script_" + scriptIndex : scriptNameDc.toPrintableString(abc.getSwf(), true)); mainPanel.gotoScriptName(abc.getSwf(), scriptName); break; case METHOD_BODY: @@ -1033,9 +1033,9 @@ public class ABCExplorerDialog extends AppDialog { if (scriptIndex != -1) { DottedChain scriptNameDc2 = abc.script_info.get(scriptIndex).getSimplePackName(abc); if (scriptNameDc2 == null && scriptTraitIndex != -1) { - scriptNameDc2 = abc.script_info.get(scriptIndex).traits.traits.get(scriptTraitIndex).getName(abc).getNameWithNamespace(abc.constants, false); + scriptNameDc2 = abc.script_info.get(scriptIndex).traits.traits.get(scriptTraitIndex).getName(abc).getNameWithNamespace(abc, abc.constants, false); } - String scriptName2 = (scriptNameDc2 == null ? "script_" + scriptIndex : scriptNameDc2.toPrintableString(true)); + String scriptName2 = (scriptNameDc2 == null ? "script_" + scriptIndex : scriptNameDc2.toPrintableString(abc.getSwf(), true)); mainPanel.gotoScriptTrait(abc.getSwf(), scriptName2, classIndex, GraphTextWriter.TRAIT_CLASS_INITIALIZER); } break; @@ -1086,10 +1086,10 @@ public class ABCExplorerDialog extends AppDialog { if (scriptIndex != -1) { DottedChain scriptNameDc = abc.script_info.get(scriptIndex).getSimplePackName(abc); if (scriptNameDc == null && scriptTraitIndex != -1) { - scriptNameDc = abc.script_info.get(scriptIndex).traits.traits.get(scriptTraitIndex).getName(abc).getNameWithNamespace(abc.constants, false); + scriptNameDc = abc.script_info.get(scriptIndex).traits.traits.get(scriptTraitIndex).getName(abc).getNameWithNamespace(abc, abc.constants, false); } - String scriptName = (scriptNameDc == null ? "script_" + scriptIndex : scriptNameDc.toPrintableString(true)); + String scriptName = (scriptNameDc == null ? "script_" + scriptIndex : scriptNameDc.toPrintableString(abc.getSwf(), true)); mainPanel.gotoScriptTrait(abc.getSwf(), scriptName, classIndex, globalTraitIndex); } @@ -1656,7 +1656,7 @@ public class ABCExplorerDialog extends AppDialog { StringBuilderTextWriter miParamStrSbW = new StringBuilderTextWriter(new CodeFormatting(), miStrSb); mi.getParamStr(miParamStrSbW, abc.constants, null, abc, new ArrayList<>()); miStrSb.append("): "); - String miReturnType = mi.getReturnTypeRaw(abc.constants, new ArrayList<>()); + String miReturnType = mi.getReturnTypeRaw(abc, abc.constants, new ArrayList<>()); miStrSb.append(miReturnType); return new ValueWithIndex(parent, currentLevelIndex, index, valueType, mi, miStrSb.toString(), title); case METHOD_BODY: @@ -1678,7 +1678,7 @@ public class ABCExplorerDialog extends AppDialog { if (ii.name_index >= abc.constants.getMultinameCount() || ii.getName(abc.constants).namespace_index >= abc.constants.getNamespaceCount()) { iiName = ""; } else { - iiName = "\"" + Helper.escapePCodeString(ii.getName(abc.constants).getNameWithNamespace(abc.constants, false).toRawString()) + "\""; + iiName = "\"" + Helper.escapePCodeString(ii.getName(abc.constants).getNameWithNamespace(abc, abc.constants, false).toRawString()) + "\""; } return new ValueWithIndex(parent, currentLevelIndex, index, TreeType.INSTANCE_INFO, ii, iiName + (ii.instance_traits.traits.isEmpty() ? "" : ", " + ii.instance_traits.traits.size() + " traits"), title); case CLASS_INFO: diff --git a/src/com/jpexs/decompiler/flash/gui/abc/ABCPanel.java b/src/com/jpexs/decompiler/flash/gui/abc/ABCPanel.java index e62a4cc94..37db64d99 100644 --- a/src/com/jpexs/decompiler/flash/gui/abc/ABCPanel.java +++ b/src/com/jpexs/decompiler/flash/gui/abc/ABCPanel.java @@ -936,9 +936,9 @@ public class ABCPanel extends JPanel implements ItemListener, SearchListener -1) { - scriptName = newAbc.instance_info.get(classIndex).getName(newAbc.constants).getNameWithNamespace(newAbc.constants, true).toPrintableString(true); + scriptName = newAbc.instance_info.get(classIndex).getName(newAbc.constants).getNameWithNamespace(newAbc, newAbc.constants, true).toPrintableString(newAbc.getSwf(), true); } else if (scriptIndex > -1) { - scriptName = newAbc.script_info.get(classIndex).getSimplePackName(newAbc).toPrintableString(true); + scriptName = newAbc.script_info.get(classIndex).getSimplePackName(newAbc).toPrintableString(newAbc.getSwf(), true); } else { scriptName = ""; } @@ -1011,7 +1011,7 @@ public class ABCPanel extends JPanel implements ItemListener, SearchListener mids = a.constants.getMultinameIds(m, usedAbc.constants); + List mids = a.constants.getMultinameIds(m, a, usedAbc, usedAbc.constants); for (int mid : mids) { usages.addAll(a.findMultinameDefinition(mid)); } @@ -1601,7 +1601,7 @@ public class ABCPanel extends JPanel implements ItemListener, SearchListener mids = a.constants.getMultinameIds(m, usedAbc.constants); + List mids = a.constants.getMultinameIds(m, a, usedAbc, usedAbc.constants); for (int mid : mids) { usages.addAll(a.findMultinameDefinition(mid)); } diff --git a/src/com/jpexs/decompiler/flash/gui/abc/ClassesListTreeModel.java b/src/com/jpexs/decompiler/flash/gui/abc/ClassesListTreeModel.java index a5a05fdc9..b77452a49 100644 --- a/src/com/jpexs/decompiler/flash/gui/abc/ClassesListTreeModel.java +++ b/src/com/jpexs/decompiler/flash/gui/abc/ClassesListTreeModel.java @@ -156,7 +156,7 @@ public class ClassesListTreeModel extends AS3ClassTreeItem implements TreeModel } if (flat) { - String fullName = packageStr.toPrintableString(true); + String fullName = packageStr.toPrintableString(abc.getSwf(), true); boolean defaultPackage = false; if (fullName.length() == 0) { fullName = AppResources.translate("package.default"); diff --git a/src/com/jpexs/decompiler/flash/gui/abc/DecompiledEditorPane.java b/src/com/jpexs/decompiler/flash/gui/abc/DecompiledEditorPane.java index 03b7cb18f..98b18ad3e 100644 --- a/src/com/jpexs/decompiler/flash/gui/abc/DecompiledEditorPane.java +++ b/src/com/jpexs/decompiler/flash/gui/abc/DecompiledEditorPane.java @@ -314,7 +314,7 @@ public class DecompiledEditorPane extends DebuggableEditorPane implements CaretL Highlighting ch = Highlighting.searchPos(highlightedText.getClassHighlights(), pos); int cindex = (int) ch.getProperties().index; ABC abc = getABC(); - type.setVal(abc.instance_info.get(cindex).getName(abc.constants).getNameWithNamespace(abc.constants, true)); + type.setVal(abc.instance_info.get(cindex).getName(abc.constants).getNameWithNamespace(abc, abc.constants, true)); linkTypeRef.setVal(LinkType.LINK_THIS_SCRIPT); return ch.startPos; } @@ -599,7 +599,7 @@ public class DecompiledEditorPane extends DebuggableEditorPane implements CaretL for (int i = 1; i < abc.constants.getMultinameCount(); i++) { Multiname m = abc.constants.getMultiname(i); if (m != null) { - if (typeName.equals(m.getNameWithNamespace(abc.constants, true).toRawString())) { + if (typeName.equals(m.getNameWithNamespace(abc, abc.constants, true).toRawString())) { return i; } } @@ -660,7 +660,7 @@ public class DecompiledEditorPane extends DebuggableEditorPane implements CaretL if (tm != null) { String name = ""; if (classIndex > -1) { - name = abc.instance_info.get(classIndex).getName(abc.constants).getNameWithNamespace(abc.constants, true).toPrintableString(true); + name = abc.instance_info.get(classIndex).getName(abc.constants).getNameWithNamespace(abc, abc.constants, true).toPrintableString(abc.getSwf(), true); } Trait currentTrait = null; @@ -671,7 +671,7 @@ public class DecompiledEditorPane extends DebuggableEditorPane implements CaretL currentTrait = getCurrentTrait(); isStatic = abc.isStaticTraitId(classIndex, lastTraitIndex); if (currentTrait != null) { - name += ":" + currentTrait.getName(abc).getName(abc.constants, null, false, true); + name += ":" + currentTrait.getName(abc).getName(abc, abc.constants, null, false, true); } if (currentTrait instanceof TraitSlotConst) { @@ -729,14 +729,14 @@ public class DecompiledEditorPane extends DebuggableEditorPane implements CaretL } currentMethodHighlight = null; //currentTrait = null; - String name = classIndex == -1 ? "" : abc.instance_info.get(classIndex).getName(abc.constants).getNameWithNamespace(abc.constants, true).toPrintableString(true); + String name = classIndex == -1 ? "" : abc.instance_info.get(classIndex).getName(abc.constants).getNameWithNamespace(abc, abc.constants, true).toPrintableString(abc.getSwf(), true); currentTrait = getCurrentTrait(); isStatic = abc.isStaticTraitId(classIndex, lastTraitIndex); if (currentTrait != null) { if (!name.isEmpty()) { name += ":"; } - name += currentTrait.getName(abc).getName(abc.constants, null, false, true); + name += currentTrait.getName(abc).getName(abc, abc.constants, null, false, true); } int methodId; diff --git a/src/com/jpexs/decompiler/flash/gui/abc/DetailPanel.java b/src/com/jpexs/decompiler/flash/gui/abc/DetailPanel.java index 52385f8f3..244121652 100644 --- a/src/com/jpexs/decompiler/flash/gui/abc/DetailPanel.java +++ b/src/com/jpexs/decompiler/flash/gui/abc/DetailPanel.java @@ -303,7 +303,7 @@ public class DetailPanel extends JPanel implements TagEditorPanel { traitNameLabel.setText("-"); } else if (abcPanel != null) { Multiname traitName = trait.getName(abc); - String traitNameStr = traitName == null ? "" : traitName.getName(abc.constants, null, false, true); + String traitNameStr = traitName == null ? "" : traitName.getName(abc, abc.constants, null, false, true); traitNameLabel.setText(traitNameStr); } }); diff --git a/src/com/jpexs/decompiler/flash/gui/abc/TraitsListItem.java b/src/com/jpexs/decompiler/flash/gui/abc/TraitsListItem.java index b858b27e8..9657d49f1 100644 --- a/src/com/jpexs/decompiler/flash/gui/abc/TraitsListItem.java +++ b/src/com/jpexs/decompiler/flash/gui/abc/TraitsListItem.java @@ -80,9 +80,9 @@ public class TraitsListItem { return "__" + STR_SCRIPT_INITIALIZER; } if (isStatic) { - return abc.class_info.get(classIndex).static_traits.traits.get(index).getName(abc).getName(abc.constants, null, false, true); + return abc.class_info.get(classIndex).static_traits.traits.get(index).getName(abc).getName(abc, abc.constants, null, false, true); } else { - return abc.instance_info.get(classIndex).instance_traits.traits.get(index).getName(abc).getName(abc.constants, null, false, true); + return abc.instance_info.get(classIndex).instance_traits.traits.get(index).getName(abc).getName(abc, abc.constants, null, false, true); } } diff --git a/src/com/jpexs/decompiler/flash/gui/abc/UsageFrame.java b/src/com/jpexs/decompiler/flash/gui/abc/UsageFrame.java index beadb6e28..f3c58ee4c 100644 --- a/src/com/jpexs/decompiler/flash/gui/abc/UsageFrame.java +++ b/src/com/jpexs/decompiler/flash/gui/abc/UsageFrame.java @@ -78,7 +78,7 @@ public class UsageFrame extends AppDialog implements MouseListener { if (a == abc) { continue; } - List mids = a.constants.getMultinameIds(m, abc.constants); + List mids = a.constants.getMultinameIds(m, a, abc, abc.constants); for (int mid : mids) { usages.addAll(definitions ? a.findMultinameDefinition(mid) : a.findMultinameUsage(mid, exactMatch)); } @@ -106,7 +106,7 @@ public class UsageFrame extends AppDialog implements MouseListener { cont.add(new FasterScrollPane(usageList), BorderLayout.CENTER); cont.add(buttonsPanel, BorderLayout.SOUTH); setSize(400, 300); - setTitle((definitions ? translate("dialog.title.declaration") : translate("dialog.title")) + abc.constants.getMultiname(multinameIndex).getNameWithNamespace(abc.constants, true).toPrintableString(true)); + setTitle((definitions ? translate("dialog.title.declaration") : translate("dialog.title")) + abc.constants.getMultiname(multinameIndex).getNameWithNamespace(abc, abc.constants, true).toPrintableString(abc.getSwf(), true)); View.centerScreen(this); View.setWindowIcon(this); } @@ -164,9 +164,9 @@ public class UsageFrame extends AppDialog implements MouseListener { decompiledTextArea.addScriptListener(setTrait); String scriptName; if (icu.getClassIndex() > -1) { - scriptName = icu.getAbc().instance_info.get(icu.getClassIndex()).getName(icu.getAbc().constants).getNameWithNamespace(icu.getAbc().constants, true).toPrintableString(true); + scriptName = icu.getAbc().instance_info.get(icu.getClassIndex()).getName(icu.getAbc().constants).getNameWithNamespace(icu.getAbc(), icu.getAbc().constants, true).toPrintableString(icu.getAbc().getSwf(), true); } else if (icu.getScriptIndex() > -1) { - scriptName = icu.getAbc().script_info.get(icu.getScriptIndex()).getSimplePackName(icu.getAbc()).toPrintableString(true); + scriptName = icu.getAbc().script_info.get(icu.getScriptIndex()).getSimplePackName(icu.getAbc()).toPrintableString(icu.getAbc().getSwf(), true); } else { scriptName = ""; } diff --git a/src/com/jpexs/decompiler/flash/gui/abc/tablemodels/MultinameTableModel.java b/src/com/jpexs/decompiler/flash/gui/abc/tablemodels/MultinameTableModel.java index 3ac800f0d..5acc7cc4f 100644 --- a/src/com/jpexs/decompiler/flash/gui/abc/tablemodels/MultinameTableModel.java +++ b/src/com/jpexs/decompiler/flash/gui/abc/tablemodels/MultinameTableModel.java @@ -130,7 +130,7 @@ public class MultinameTableModel implements TableModel { if (abc.constants.getMultiname(rowIndex).name_index == -1) { return ""; } - return abc.constants.getMultiname(rowIndex).getName(abc.constants, null, true, true); + return abc.constants.getMultiname(rowIndex).getName(abc, abc.constants, null, true, true); case 3: if (rowIndex == 0) { return ""; diff --git a/src/com/jpexs/decompiler/flash/gui/debugger/DebuggerTools.java b/src/com/jpexs/decompiler/flash/gui/debugger/DebuggerTools.java index 68a0490f5..96b5a6400 100644 --- a/src/com/jpexs/decompiler/flash/gui/debugger/DebuggerTools.java +++ b/src/com/jpexs/decompiler/flash/gui/debugger/DebuggerTools.java @@ -106,9 +106,9 @@ public class DebuggerTools { int debuggerNs = a.constants.getNamespaceId(Namespace.KIND_PACKAGE, debuggerPkg, 0, true); for (int i = 1; i < a.constants.getMultinameCount(); i++) { Multiname m = a.constants.getMultiname(i); - String rawNsName = m.getNameWithNamespace(a.constants, true).toRawString(); + String rawNsName = m.getNameWithNamespace(a, a.constants, true).toRawString(); if (m.kind == Multiname.MULTINAME) { - String simpleName = m.getName(a.constants, new ArrayList<>(), true, false); + String simpleName = m.getName(a, a.constants, new ArrayList<>(), true, false); String nsToSearch; if (displayTypes.contains(simpleName)) { nsToSearch = "flash.display"; @@ -120,7 +120,7 @@ public class DebuggerTools { int nsFoundId = -1; for (int ns : a.constants.getNamespaceSet(m.namespace_set_index).namespaces) { - String nsString = a.constants.namespaceToString(ns); + String nsString = a.constants.namespaceToString(a, ns); if (nsString != null) { if (nsString.equals(nsToSearch)) { nsFoundId = ns; @@ -132,7 +132,7 @@ public class DebuggerTools { m.kind = Multiname.QNAME; m.namespace_index = nsFoundId; m.namespace_set_index = 0; - rawNsName = m.getNameWithNamespace(a.constants, true).toRawString(); + rawNsName = m.getNameWithNamespace(a, a.constants, true).toRawString(); } } if (null != rawNsName) { @@ -177,7 +177,7 @@ public class DebuggerTools { ABC a = ct.getABC(); for (int i = 1; i < a.constants.getMultinameCount(); i++) { Multiname m = a.constants.getMultiname(i); - if ("trace".equals(m.getNameWithNamespace(a.constants, true).toRawString())) { + if ("trace".equals(m.getNameWithNamespace(a, a.constants, true).toRawString())) { m.namespace_index = a.constants.getNamespaceId(Namespace.KIND_PACKAGE, debuggerPkg, 0, true); m.name_index = a.constants.getStringId(fname, true); ((Tag) ct).setModified(true); @@ -200,7 +200,7 @@ public class DebuggerTools { ABC a = ct.getABC(); for (int i = 1; i < a.constants.getMultinameCount(); i++) { Multiname m = a.constants.getMultiname(i); - String packageStr = m.getNameWithNamespace(a.constants, true).toString(); + String packageStr = m.getNameWithNamespace(a, a.constants, true).toString(); if (isDebuggerClass(packageStr, "debugTrace") || isDebuggerClass(packageStr, "debugAlert") || isDebuggerClass(packageStr, "debugSocket") diff --git a/src/com/jpexs/decompiler/flash/gui/generictageditors/StringEditor.java b/src/com/jpexs/decompiler/flash/gui/generictageditors/StringEditor.java index 28cc46b0e..d97fff762 100644 --- a/src/com/jpexs/decompiler/flash/gui/generictageditors/StringEditor.java +++ b/src/com/jpexs/decompiler/flash/gui/generictageditors/StringEditor.java @@ -16,6 +16,7 @@ */ package com.jpexs.decompiler.flash.gui.generictageditors; +import com.jpexs.decompiler.flash.SWF; import com.jpexs.decompiler.flash.types.annotations.DottedIdentifier; import com.jpexs.decompiler.graph.DottedChain; import com.jpexs.helpers.Helper; @@ -44,6 +45,7 @@ public class StringEditor extends JTextArea implements GenericTagEditor { private String fieldName; private boolean multiline; + private final SWF swf; @Override public boolean getScrollableTracksViewportWidth() { @@ -67,7 +69,7 @@ public class StringEditor extends JTextArea implements GenericTagEditor { return 0; } - public StringEditor(String fieldName, Object obj, Field field, int index, Class type, boolean multiline) { + public StringEditor(String fieldName, Object obj, Field field, int index, Class type, boolean multiline, SWF swf) { setLineWrap(true); this.obj = obj; this.field = field; @@ -75,13 +77,14 @@ public class StringEditor extends JTextArea implements GenericTagEditor { this.type = type; this.fieldName = fieldName; this.multiline = multiline; + this.swf = swf; if (multiline) { Dimension d = new Dimension(500, 200); setPreferredSize(d); setSize(d); } reset(); - } + } @Override public void reset() { @@ -90,9 +93,9 @@ public class StringEditor extends JTextArea implements GenericTagEditor { DottedIdentifier di = field.getAnnotation(DottedIdentifier.class); if (di != null) { if (di.exportName()) { - newValue = Helper.escapeExportname(newValue, false); + newValue = Helper.escapeExportname(swf, newValue, false); } else { - newValue = DottedChain.parseNoSuffix(newValue).toPrintableString(di.as3()); + newValue = DottedChain.parseNoSuffix(newValue).toPrintableString(swf, di.as3()); } } setText(newValue); diff --git a/src/com/jpexs/decompiler/flash/gui/locales/AdvancedSettingsDialog.properties b/src/com/jpexs/decompiler/flash/gui/locales/AdvancedSettingsDialog.properties index 62231b4fe..1951804fd 100644 --- a/src/com/jpexs/decompiler/flash/gui/locales/AdvancedSettingsDialog.properties +++ b/src/com/jpexs/decompiler/flash/gui/locales/AdvancedSettingsDialog.properties @@ -632,4 +632,7 @@ config.name.skipDetectionOfUnitializedClassFields = AS2: Skip detection of unini config.description.skipDetectionOfUnitializedClassFields = Skips detection of uninitialized attributes in AS2 classes which includes decompilation of all scripts in current SWF before accessing any class. Set this to true if you have large obfuscated file and you want to see at least something (= incomplete class). config.name.showHeapStatusWidget = Show heap status widget -config.description.showHeapStatusWidget = Displays used memory widget in the titlebar. \ No newline at end of file +config.description.showHeapStatusWidget = Displays used memory widget in the titlebar. + +config.name.useSafeStr = Use SafeStr notation +config.description.useSafeStr = Obfuscated names that are not valid identifiers will be printed as _SafeStr_XX. \ No newline at end of file diff --git a/src/com/jpexs/decompiler/flash/gui/tagtree/TagTree.java b/src/com/jpexs/decompiler/flash/gui/tagtree/TagTree.java index 167afd850..546efee4f 100644 --- a/src/com/jpexs/decompiler/flash/gui/tagtree/TagTree.java +++ b/src/com/jpexs/decompiler/flash/gui/tagtree/TagTree.java @@ -352,9 +352,9 @@ public class TagTree extends AbstractTagTree { if (expName != null && !expName.isEmpty()) { String[] pathParts = expName.contains(".") ? expName.split("\\.") : new String[]{expName}; if (expName.startsWith("__Packages.")) { - return IdentifiersDeobfuscation.printIdentifier(false, pathParts[pathParts.length - 1]); + return IdentifiersDeobfuscation.printIdentifier(tag.getSwf(), false, pathParts[pathParts.length - 1]); } else { - return Helper.escapeExportname(expName, false); + return Helper.escapeExportname(tag.getSwf(), expName, false); } } } diff --git a/src/com/jpexs/decompiler/flash/gui/tagtree/TagTreeContextMenu.java b/src/com/jpexs/decompiler/flash/gui/tagtree/TagTreeContextMenu.java index 9962d8329..ed2306379 100644 --- a/src/com/jpexs/decompiler/flash/gui/tagtree/TagTreeContextMenu.java +++ b/src/com/jpexs/decompiler/flash/gui/tagtree/TagTreeContextMenu.java @@ -3071,7 +3071,7 @@ public class TagTreeContextMenu extends JPopupMenu { DottedChain classDottedChain = new DottedChain(parts); try { - List regActions = regParser.actionsFromString("Object.registerClass(\"" + Helper.escapePCodeString(identifier) + "\"," + classDottedChain.toPrintableString(false) + ");", swf.getCharset()); + List regActions = regParser.actionsFromString("Object.registerClass(\"" + Helper.escapePCodeString(identifier) + "\"," + classDottedChain.toPrintableString(swf, false) + ");", swf.getCharset()); regDoInit.setActions(regActions); } catch (ActionParseException | IOException | CompilationException | InterruptedException ex) { //ignore @@ -3116,7 +3116,7 @@ public class TagTreeContextMenu extends JPopupMenu { DottedChain dcParent = new DottedChain(partsParent); try { - List actions = parser.actionsFromString("class " + classDottedChain.toPrintableString(false) + (classParent.isEmpty() ? "" : " extends " + dcParent.toPrintableString(false)) + "{}", swf.getCharset()); + List actions = parser.actionsFromString("class " + classDottedChain.toPrintableString(swf, false) + (classParent.isEmpty() ? "" : " extends " + dcParent.toPrintableString(swf, false)) + "{}", swf.getCharset()); classDoInit.setActions(actions); } catch (ActionParseException | IOException | CompilationException | InterruptedException ex) { //ignore @@ -3259,9 +3259,9 @@ public class TagTreeContextMenu extends JPopupMenu { ActionScript3Parser parser = new ActionScript3Parser(abcIndex); DottedChain dc = new DottedChain(pkgParts); - String script = "package " + dc.toPrintableString(true) + " {" + String script = "package " + dc.toPrintableString(swf, true) + " {" + (parentClassName.isEmpty() ? "" : "import " + parentClassName + ";") - + "public class " + IdentifiersDeobfuscation.printIdentifier(true, classSimpleName) + (parentClassName.isEmpty() ? "" : " extends " + parentClassName) + " {" + + "public class " + IdentifiersDeobfuscation.printIdentifier(swf, true, classSimpleName) + (parentClassName.isEmpty() ? "" : " extends " + parentClassName) + " {" + " }" + "}"; parser.addScript(script, fileName, 0, 0, swf.getDocumentClass(), selectedAbcContainer.getABC()); @@ -3357,16 +3357,16 @@ public class TagTreeContextMenu extends JPopupMenu { AbstractTagTreeModel model = mainPanel.getCurrentTree().getFullModel(); TreeItem it = pkg; List pkgParts = new ArrayList<>(); + SWF swf = (SWF) pkg.getOpenable(); while (it instanceof AS2Package) { pkg = (AS2Package) it; if (!pkg.isDefaultPackage()) { - pkgParts.add(0, DottedChain.parseNoSuffix(pkg.getName()).toPrintableString(false)); + pkgParts.add(0, DottedChain.parseNoSuffix(pkg.getName()).toPrintableString(swf, false)); } it = model.getParent(it); } pkgParts.remove(0); String fullPkgName = String.join(".", pkgParts); - SWF swf = (SWF) pkg.getOpenable(); AddScriptDialog addScriptDialog = new AddScriptDialog(Main.getDefaultDialogsOwner(), swf); String prefix = fullPkgName; if (!prefix.isEmpty()) { @@ -3489,8 +3489,8 @@ public class TagTreeContextMenu extends JPopupMenu { ActionScript3Parser parser = new ActionScript3Parser(abcIndex); DottedChain dc = new DottedChain(pkgParts); - String script = "package " + dc.toPrintableString(true) + " {" - + "public class " + IdentifiersDeobfuscation.printIdentifier(true, classSimpleName) + " {" + String script = "package " + dc.toPrintableString(doAbc.getSwf(), true) + " {" + + "public class " + IdentifiersDeobfuscation.printIdentifier(swf, true, classSimpleName) + " {" + " }" + "}"; parser.addScript(script, fileName, 0, 0, swf.getDocumentClass(), doAbc.getABC()); @@ -3946,7 +3946,7 @@ public class TagTreeContextMenu extends JPopupMenu { DottedChain dc = new DottedChain(parts); try { - List actions = parser.actionsFromString("class " + dc.toPrintableString(false) + "{}", swf.getCharset()); + List actions = parser.actionsFromString("class " + dc.toPrintableString(swf, false) + "{}", swf.getCharset()); doInit.setActions(actions); } catch (ActionParseException | IOException | CompilationException | InterruptedException ex) {