From 51c7dde8d1c3d6c663a3aaf35c096535f999ab09 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jindra=20Pet=C5=99=C3=ADk?= Date: Sun, 15 Feb 2026 10:28:15 +0100 Subject: [PATCH] Do not create subswf if the file with same hash is already opened. --- .../decompiler/flash/gui/DebuggerSession.java | 34 ++----------------- src/com/jpexs/decompiler/flash/gui/Main.java | 22 +++--------- 2 files changed, 7 insertions(+), 49 deletions(-) diff --git a/src/com/jpexs/decompiler/flash/gui/DebuggerSession.java b/src/com/jpexs/decompiler/flash/gui/DebuggerSession.java index 9f9fa44b2..1c2f03118 100644 --- a/src/com/jpexs/decompiler/flash/gui/DebuggerSession.java +++ b/src/com/jpexs/decompiler/flash/gui/DebuggerSession.java @@ -52,7 +52,6 @@ import com.jpexs.decompiler.flash.SWF; import com.jpexs.decompiler.flash.configuration.Configuration; import com.jpexs.decompiler.graph.DottedChain; import com.jpexs.helpers.Helper; -import java.io.FileOutputStream; import java.io.IOException; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; @@ -84,7 +83,6 @@ public class DebuggerSession { private DebuggerCommands commands = null; - //private List swfs = new ArrayList<>(); private boolean paused = true; private Map modulePaths = new HashMap<>(); @@ -260,22 +258,6 @@ public class DebuggerSession { modulePaths.put(file, name); scriptToModule.put(name, file); 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); } con.dropMessage(sc); @@ -344,16 +326,6 @@ public class DebuggerSession { try { for (InSwfInfo.SwfInfo s : t.swfInfos) { 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); Logger.getLogger(DebuggerSession.class.getName()).fine("Received SWF"); Logger.getLogger(DebuggerSession.class.getName()).log(Level.FINE, "Received SWF.URL = {0}", s.url); @@ -499,14 +471,14 @@ public class DebuggerSession { if (moduleToSwfIndex.containsKey(message.file)) { SWF swf = debuggedSwfs.get(moduleToSwfIndex.get(message.file)); userSwfName = swf.toString(); - } else if(!debuggedSwfs.isEmpty()) { + } else if (!debuggedSwfs.isEmpty()) { userSwfName = debuggedSwfs.get(debuggedSwfs.size() - 1).toString(); } - + if (modulePaths.containsKey(message.file)) { newBreakScriptName = modulePaths.get(message.file); userBreakScriptName = newBreakScriptName; - if (newBreakScriptName.contains(":")) { + if (newBreakScriptName.contains(":")) { userBreakScriptName = userSwfName + ": " + newBreakScriptName.substring(newBreakScriptName.indexOf(":") + 1); } } else if (reasonInt != InBreakReason.REASON_SCRIPT_LOADED) { diff --git a/src/com/jpexs/decompiler/flash/gui/Main.java b/src/com/jpexs/decompiler/flash/gui/Main.java index d520f30d1..1da5c3ad4 100644 --- a/src/com/jpexs/decompiler/flash/gui/Main.java +++ b/src/com/jpexs/decompiler/flash/gui/Main.java @@ -270,14 +270,7 @@ public class Main { hashSha256 = origKey; break; } - } - - if (hashSha256.startsWith("loaded_")) { - hashSha256 = hashSha256.substring("loaded_".length()); - } - if (hashSha256.startsWith("imported_")) { - hashSha256 = hashSha256.substring("loaded_".length()); - } + } 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()}); @@ -681,7 +674,7 @@ public class Main { SWF.decompress(new ByteArrayInputStream(impData), baos); Helper.writeFile(newTempFile.getAbsolutePath(), impData); 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); } 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()); tempFile.delete(); Logger.getLogger(Main.class.getName()).log(Level.FINE, "calling datamodified"); @@ -3991,7 +3984,7 @@ public class Main { }*/ String tit = swf.getTitleOrShortFileName(); if (tit != null && tit.contains(":")) { - return "loaded_" + tit.substring(tit.lastIndexOf(":") + 1); + return tit.substring(tit.lastIndexOf(":") + 1); } 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 (int s = 0; s < sl.size(); s++) { Openable op = sl.get(s);