Do not create subswf if the file with same hash is already opened.

This commit is contained in:
Jindra Petřík
2026-02-15 10:28:15 +01:00
parent 8645679ce9
commit 51c7dde8d1
2 changed files with 7 additions and 49 deletions
@@ -52,7 +52,6 @@ import com.jpexs.decompiler.flash.SWF;
import com.jpexs.decompiler.flash.configuration.Configuration; import com.jpexs.decompiler.flash.configuration.Configuration;
import com.jpexs.decompiler.graph.DottedChain; import com.jpexs.decompiler.graph.DottedChain;
import com.jpexs.helpers.Helper; import com.jpexs.helpers.Helper;
import java.io.FileOutputStream;
import java.io.IOException; import java.io.IOException;
import java.security.MessageDigest; import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException; import java.security.NoSuchAlgorithmException;
@@ -84,7 +83,6 @@ public class DebuggerSession {
private DebuggerCommands commands = null; private DebuggerCommands commands = null;
//private List<InSwfInfo.SwfInfo> swfs = new ArrayList<>();
private boolean paused = true; private boolean paused = true;
private Map<Integer, String> modulePaths = new HashMap<>(); private Map<Integer, String> modulePaths = new HashMap<>();
@@ -260,22 +258,6 @@ public class DebuggerSession {
modulePaths.put(file, name); modulePaths.put(file, name);
scriptToModule.put(name, file); scriptToModule.put(name, file);
moduleToSwfIndex.put(file, swfIndex); moduleToSwfIndex.put(file, swfIndex);
/*if (!"main".equals(swfHash)) {
SWF swf = Main.getSwfByHash(swfHash);
debuggedSwfs.put(swfIndex, swf);
}*/
/*if (swfIndex > debuggedSwfs.size() - 1) {
SWF swf = Main.getSwfByHash(swfHash);
if (swf == null) {
Logger.getLogger(DebuggerSession.class.getName()).log(Level.WARNING, "SWF with hash {0} not found", swfHash);
} else {
Logger.getLogger(DebuggerSession.class.getName()).log(Level.FINE, "adding {0} to debugSwfs", swfIndex);
swfIndicesCommitted.add(swfIndex);
debuggedSwfs.add(swf);
}
} else {
Logger.getLogger(DebuggerSession.class.getName()).log(Level.FINE, "Swf index already committed");
}*/
swfIndicesCommitted.add(swfIndex); swfIndicesCommitted.add(swfIndex);
} }
con.dropMessage(sc); con.dropMessage(sc);
@@ -344,16 +326,6 @@ public class DebuggerSession {
try { try {
for (InSwfInfo.SwfInfo s : t.swfInfos) { for (InSwfInfo.SwfInfo s : t.swfInfos) {
try { try {
/*try {
con.sendMessageWithTimeout(new OutGetSwf(con, (int) s.index), InGetSwf.class);
con.sendMessageWithTimeout(new OutGetSwd(con, (int) s.index), InGetSwd.class);
} catch (IOException ex) {
//ignore
}*/
/*if (s.scriptCount == 0) {
continue;
}*/
InGetSwf inGetSwf = con.sendMessage(new OutGetSwf(con, (int) s.index), InGetSwf.class); InGetSwf inGetSwf = con.sendMessage(new OutGetSwf(con, (int) s.index), InGetSwf.class);
Logger.getLogger(DebuggerSession.class.getName()).fine("Received SWF"); Logger.getLogger(DebuggerSession.class.getName()).fine("Received SWF");
Logger.getLogger(DebuggerSession.class.getName()).log(Level.FINE, "Received SWF.URL = {0}", s.url); Logger.getLogger(DebuggerSession.class.getName()).log(Level.FINE, "Received SWF.URL = {0}", s.url);
+3 -17
View File
@@ -272,13 +272,6 @@ public class Main {
} }
} }
if (hashSha256.startsWith("loaded_")) {
hashSha256 = hashSha256.substring("loaded_".length());
}
if (hashSha256.startsWith("imported_")) {
hashSha256 = hashSha256.substring("loaded_".length());
}
for (SWF swf : mainFrame.getPanel().getAllSwfs()) { for (SWF swf : mainFrame.getPanel().getAllSwfs()) {
Logger.getLogger(Main.class.getName()).log(Level.FINE, "Checking {0} with hash {1}", new Object[]{swf.toString(), swf.getHashSha256()}); Logger.getLogger(Main.class.getName()).log(Level.FINE, "Checking {0} with hash {1}", new Object[]{swf.toString(), swf.getHashSha256()});
if (Objects.equals(hashSha256, swf.getHashSha256())) { if (Objects.equals(hashSha256, swf.getHashSha256())) {
@@ -681,7 +674,7 @@ public class Main {
SWF.decompress(new ByteArrayInputStream(impData), baos); SWF.decompress(new ByteArrayInputStream(impData), baos);
Helper.writeFile(newTempFile.getAbsolutePath(), impData); Helper.writeFile(newTempFile.getAbsolutePath(), impData);
tempFiles.add(newTempFile); tempFiles.add(newTempFile);
prepareSwf("imported_" + sha256(baos.toByteArray()), prep, newTempFile, importedFile, tempFilesDir, tempFiles); prepareSwf(sha256(baos.toByteArray()), prep, newTempFile, importedFile, tempFilesDir, tempFiles);
} }
} }
} }
@@ -3047,7 +3040,7 @@ public class Main {
fos.write(inputData); fos.write(inputData);
} }
Logger.getLogger(Main.class.getName()).log(Level.FINE, "preparing for load: {0}", hash); Logger.getLogger(Main.class.getName()).log(Level.FINE, "preparing for load: {0}", hash);
prepareSwf("loaded_" + hash, runningPreparation, tempFile, mainSWF.getFile() == null ? null : new File(mainSWF.getFile()), tempRunDir, runTempFiles); prepareSwf(hash, runningPreparation, tempFile, mainSWF.getFile() == null ? null : new File(mainSWF.getFile()), tempRunDir, runTempFiles);
byte[] outputData = Helper.readFileEx(tempFile.getAbsolutePath()); byte[] outputData = Helper.readFileEx(tempFile.getAbsolutePath());
tempFile.delete(); tempFile.delete();
Logger.getLogger(Main.class.getName()).log(Level.FINE, "calling datamodified"); Logger.getLogger(Main.class.getName()).log(Level.FINE, "calling datamodified");
@@ -3991,7 +3984,7 @@ public class Main {
}*/ }*/
String tit = swf.getTitleOrShortFileName(); String tit = swf.getTitleOrShortFileName();
if (tit != null && tit.contains(":")) { if (tit != null && tit.contains(":")) {
return "loaded_" + tit.substring(tit.lastIndexOf(":") + 1); return tit.substring(tit.lastIndexOf(":") + 1);
} }
return swf.getHashSha256(); return swf.getHashSha256();
} }
@@ -4013,13 +4006,6 @@ public class Main {
} }
} }
if (hashSha256.startsWith("loaded_")) {
hashSha256 = hashSha256.substring("loaded_".length());
}
if (hashSha256.startsWith("imported_")) {
hashSha256 = hashSha256.substring("imported_".length());
}
for (OpenableList sl : Main.getMainFrame().getPanel().getSwfs()) { for (OpenableList sl : Main.getMainFrame().getPanel().getSwfs()) {
for (int s = 0; s < sl.size(); s++) { for (int s = 0; s < sl.size(); s++) {
Openable op = sl.get(s); Openable op = sl.get(s);