mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-09-28 18:00:47 +00:00
WIP Safe strings handling
This commit is contained in:
@@ -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<DottedChain> {
|
||||
/**
|
||||
* 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<DottedChain> {
|
||||
}
|
||||
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<DottedChain> {
|
||||
/**
|
||||
* 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<DottedChain> {
|
||||
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<DottedChain> {
|
||||
/**
|
||||
* 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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user