#772: closing loading dialog now cancels the loading of the swf

#762:export pcode with diffren extension
This commit is contained in:
2015-04-26 12:09:59 +02:00
parent e497b58f81
commit 62be884e42
14 changed files with 201 additions and 150 deletions
@@ -290,7 +290,7 @@ public final class SWF implements SWFContainerItem, Timelined {
private final IdentifiersDeobfuscation deobfuscation = new IdentifiersDeobfuscation();
@Internal
private static Cache<String, SerializableImage> frameCache = Cache.getInstance(false, false, "frame");
private Cache<String, SerializableImage> frameCache = Cache.getInstance(false, false, "frame");
@Internal
private final Cache<ASMSource, CachedScript> as2Cache = Cache.getInstance(true, false, "as2");
@@ -337,6 +337,7 @@ public final class SWF implements SWFContainerItem, Timelined {
as2Cache.clear();
as3Cache.clear();
frameCache.clear();
timeline = null;
clearDumpInfo(dumpInfo);
@@ -2176,14 +2177,14 @@ public final class SWF implements SWFContainerItem, Timelined {
mat.translateX, mat.translateY);
}
public static SerializableImage getFromCache(String key) {
public SerializableImage getFromCache(String key) {
if (frameCache.contains(key)) {
return SWF.frameCache.get(key);
return frameCache.get(key);
}
return null;
}
public static void putToCache(String key, SerializableImage img) {
public void putToCache(String key, SerializableImage img) {
if (Configuration.useFrameCache.get()) {
frameCache.put(key, img);
}
@@ -2405,10 +2406,11 @@ public final class SWF implements SWFContainerItem, Timelined {
}
public static SerializableImage frameToImageGet(Timeline timeline, int frame, int time, DepthState stateUnderCursor, int mouseButton, RECT displayRect, Matrix transformation, ColorTransform colorTransform, Color backGroundColor, boolean useCache, double zoom) {
String key = "frame_" + frame + "_" + timeline.id + "_" + timeline.swf.hashCode() + "_" + zoom;
SWF swf = timeline.swf;
String key = "frame_" + frame + "_" + timeline.id + "_" + swf.hashCode() + "_" + zoom;
SerializableImage image;
if (useCache) {
image = getFromCache(key);
image = swf.getFromCache(key);
if (image != null) {
return image;
}
@@ -2429,6 +2431,7 @@ public final class SWF implements SWFContainerItem, Timelined {
g.setColor(backGroundColor);
g.fill(new Rectangle(image.getWidth(), image.getHeight()));
}
Matrix m = transformation.clone();
m.translate(-rect.Xmin * zoom, -rect.Ymin * zoom);
m.scale(zoom);
@@ -2437,8 +2440,9 @@ public final class SWF implements SWFContainerItem, Timelined {
renderContext.mouseButton = mouseButton;
frameToImage(timeline, frame, time, renderContext, image, m, colorTransform);
if (useCache) {
putToCache(key, image);
swf.putToCache(key, image);
}
return image;
}
@@ -1060,6 +1060,10 @@ public class SWFInputStream implements AutoCloseable {
* @throws java.lang.InterruptedException
*/
public List<Tag> readTagList(Timelined timelined, int level, boolean parallel, boolean skipUnusualTags, boolean parseTags, boolean lazy) throws IOException, InterruptedException {
if (Thread.currentThread().interrupted()) {
throw new InterruptedException();
}
boolean parallel1 = level == 0 && parallel;
ExecutorService executor = null;
List<Future<Tag>> futureResults = new ArrayList<>();
@@ -196,7 +196,7 @@ public class ScriptPack extends AS3ClassTreeItem {
String packageName = getPathPackage();
File outDir = new File(directory + File.separatorChar + makeDirPath(packageName));
Path.createDirectorySafe(outDir);
String fileName = outDir.toString() + File.separator + Helper.makeFileName(scriptName) + ".as";
String fileName = outDir.toString() + File.separator + Helper.makeFileName(scriptName) + exportSettings.getFileExtension();
file = new File(fileName);
}
@@ -297,7 +297,6 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.TreeMap;
import java.util.TreeSet;
import java.util.logging.Level;
import java.util.logging.Logger;
@@ -745,7 +744,6 @@ public class AVM2Code implements Cloneable {
public AVM2Code(ABCInputStream ais) throws IOException {
Map<Long, AVM2Instruction> codeMap = new TreeMap<>();
Map<Long, Long> endOffsets = new HashMap<>();
DumpInfo diParent = ais.dumpInfo;
List<Long> addresses = new ArrayList<>();
long startPos = ais.getPosition();
@@ -810,8 +808,6 @@ public class AVM2Code implements Cloneable {
}
codeMap.put(startOffset, new AVM2Instruction(startOffset, instr, actualOperands));
ais.endDumpLevel(instr.instructionCode);
long endOffset = ais.getPosition();
endOffsets.put(startOffset, endOffset);
if (instr.isExitInstruction()) { //do not process jumps if there is return/throw instruction
afterExit = true;
}
@@ -117,7 +117,7 @@ public class AS2ScriptExporter {
Path.createDirectorySafe(new File(outdir));
}
String f = outdir + name + ".as";
String f = outdir + name + exportSettings.getFileExtension();
if (evl != null) {
evl.handleExportingEvent("script", currentIndex, count, f);
}
@@ -153,7 +153,7 @@ public class AS2ScriptExporter {
return file;
} catch (InterruptedException ex) {
} catch (IOException | OutOfMemoryError | TranslateException | StackOverflowError ex) {
Logger.getLogger(AS2ScriptExporter.class.getName()).log(Level.SEVERE, "Decompilation error in file: " + name + ".as", ex);
Logger.getLogger(AS2ScriptExporter.class.getName()).log(Level.SEVERE, "Decompilation error in script: " + name, ex);
if (handler != null) {
int action = handler.getNewInstance().handle(ex);
switch (action) {
@@ -35,4 +35,18 @@ public class ScriptExportSettings {
this.mode = mode;
this.singleFile = singleFile;
}
public String getFileExtension() {
switch (mode) {
case AS:
return ".as";
case PCODE:
case PCODE_HEX:
return ".pcode";
case HEX:
return ".hex";
default:
throw new Error("Unsupported script export mode: " + mode);
}
}
}
@@ -830,6 +830,10 @@ public class Helper {
}
public static boolean contains(int[] array, int value) {
if (array == null) {
return false;
}
for (int i : array) {
if (i == value) {
return true;