From 4dbdc09278f675f583b62d5d4ef7cdfcce50e3f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jindra=20Pet=C5=99=C3=ADk?= Date: Thu, 14 Aug 2025 09:23:58 +0200 Subject: [PATCH] Fixed: #2511 Allowing to jump from search window while editation causing problems Changed: Serial form of AS3 search results changed so the decompiler is unable to read saved AS3 search result from older versions and vice-versa --- CHANGELOG.md | 4 ++++ .../flash/search/ABCSearchResult.java | 20 ++++++++++++++++--- .../flash/gui/SearchResultsDialog.java | 3 +++ .../flash/gui/SearchResultsStorage.java | 5 ++--- 4 files changed, 26 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4b7fd688e..c94e7dcb0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -66,6 +66,7 @@ All notable changes to this project will be documented in this file. - [#2507] FLA export - Place characters over multiple button frames - [#2508] AS1/2 direct editation - first command in for loop header not compiled - [#2510] AS direct editation - popped value +- [#2511] Allowing to jump from search window while editation causing problems ### Changed - Icon of "Deobfuscation options" menu from pile of pills to medkit @@ -78,6 +79,8 @@ All notable changes to this project will be documented in this file. - The label of option "automatic deobfuscation" changed to "deobfuscate code" - SetTabIndex tag moved from others to frames folder - SWF3 actions split into SWF1, SWF2 and SWF3 actions (in FFDec source code, docs, etc.) +- Serial form of AS3 search results changed so the decompiler is unable to read + saved AS3 search result from older versions and vice-versa ### Removed - Resample wav to 44kHz feature from GUI @@ -3973,6 +3976,7 @@ Major version of SWF to XML export changed to 2. [#2507]: https://www.free-decompiler.com/flash/issues/2507 [#2508]: https://www.free-decompiler.com/flash/issues/2508 [#2510]: https://www.free-decompiler.com/flash/issues/2510 +[#2511]: https://www.free-decompiler.com/flash/issues/2511 [#2476]: https://www.free-decompiler.com/flash/issues/2476 [#2404]: https://www.free-decompiler.com/flash/issues/2404 [#1418]: https://www.free-decompiler.com/flash/issues/1418 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 831ed7751..05569c66b 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 @@ -23,6 +23,7 @@ import com.jpexs.decompiler.flash.abc.ClassPath; import com.jpexs.decompiler.flash.abc.ScriptPack; import com.jpexs.decompiler.flash.helpers.GraphTextWriter; import com.jpexs.decompiler.flash.treeitems.Openable; +import com.jpexs.decompiler.graph.DottedChain; import java.io.IOException; import java.io.InputStream; import java.io.ObjectInputStream; @@ -80,7 +81,7 @@ public class ABCSearchResult implements Serializable, ScriptSearchResult { /** * Serial version major */ - private static final int SERIAL_VERSION_MAJOR = 1; + private static final int SERIAL_VERSION_MAJOR = 2; /** * Serial version minor */ @@ -98,14 +99,27 @@ public class ABCSearchResult implements Serializable, ScriptSearchResult { ObjectInputStream ois = new ObjectInputStream(is); int versionMajor = ois.read(); ois.read(); //minor + if (versionMajor == 1) { + throw new IOException("Cannot read older version results"); + } if (versionMajor != SERIAL_VERSION_MAJOR) { throw new IOException("Unknown search result version: " + versionMajor); } + SWF swf = null; + if (openable instanceof SWF) { + swf = (SWF) openable; + } + if (openable instanceof ABC) { + swf = ((ABC) openable).getSwf(); + } + ClassPath cp; List traitIndices; try { - cp = (ClassPath) ois.readObject(); + String classPathDC = ois.readUTF(); + DottedChain dc = DottedChain.parseWithSuffix(classPathDC); + cp = new ClassPath(dc.getWithoutLast(), dc.getLast(), dc.getLastNamespaceSuffix(), swf); traitIndices = (List) ois.readObject(); } catch (ClassNotFoundException ex) { Logger.getLogger(ABCSearchResult.class.getName()).log(Level.SEVERE, null, ex); @@ -149,7 +163,7 @@ public class ABCSearchResult implements Serializable, ScriptSearchResult { ObjectOutputStream oos = new ObjectOutputStream(os); oos.write(SERIAL_VERSION_MAJOR); oos.write(SERIAL_VERSION_MINOR); - oos.writeObject(scriptPack.getClassPath()); + oos.writeUTF(scriptPack.getClassPath().toRawString()); oos.writeObject(scriptPack.traitIndices); oos.writeBoolean(pcode); oos.writeInt(classIndex); diff --git a/src/com/jpexs/decompiler/flash/gui/SearchResultsDialog.java b/src/com/jpexs/decompiler/flash/gui/SearchResultsDialog.java index b5f926a8f..a1e4c2b85 100644 --- a/src/com/jpexs/decompiler/flash/gui/SearchResultsDialog.java +++ b/src/com/jpexs/decompiler/flash/gui/SearchResultsDialog.java @@ -460,6 +460,9 @@ public class SearchResultsDialog extends AppDialog { @SuppressWarnings("unchecked") private void gotoElement() { + if (Main.getMainFrame().getPanel().checkEdited()) { + return; + } if (openableToResults.size() > 1) { BasicTreeNode selection = (BasicTreeNode) resultsTree.getLastSelectedPathComponent(); if (selection.getData() instanceof SearchResult) { diff --git a/src/com/jpexs/decompiler/flash/gui/SearchResultsStorage.java b/src/com/jpexs/decompiler/flash/gui/SearchResultsStorage.java index d3d2f57e8..ed4f4afd3 100644 --- a/src/com/jpexs/decompiler/flash/gui/SearchResultsStorage.java +++ b/src/com/jpexs/decompiler/flash/gui/SearchResultsStorage.java @@ -176,13 +176,12 @@ public class SearchResultsStorage { if (kind == DATA_ACTION) { currentResults.add(new ActionSearchResult((SWF) openable, bais)); } - } catch (ScriptNotFoundException | IOException ex) { - ex.printStackTrace(); + } catch (ScriptNotFoundException ex) { //ignore } } } catch (IOException ex) { - Logger.getLogger(SearchResultsStorage.class.getName()).log(Level.SEVERE, null, ex); + //ignore } unpackedData.set(j, currentResults); result.addAll(currentResults);