diff --git a/src/com/jpexs/decompiler/flash/gui/MainFrameMenu.java b/src/com/jpexs/decompiler/flash/gui/MainFrameMenu.java index 0b687bf5b..aa1e70d28 100644 --- a/src/com/jpexs/decompiler/flash/gui/MainFrameMenu.java +++ b/src/com/jpexs/decompiler/flash/gui/MainFrameMenu.java @@ -357,6 +357,14 @@ public abstract class MainFrameMenu implements MenuBuilder { mainFrame.getPanel().renameOneIdentifier(swf); } + protected void renameColliding(ActionEvent evt) { + if (Main.isWorking()) { + return; + } + + mainFrame.getPanel().renameColliding(swf); + } + protected void renameInvalidIdentifiers(ActionEvent evt) { if (Main.isWorking()) { return; @@ -718,6 +726,7 @@ public abstract class MainFrameMenu implements MenuBuilder { setMenuEnabled("/tools/deobfuscation", swfSelected); setMenuEnabled("/tools/deobfuscation/renameOneIdentifier", swfSelected && !isWorking); setMenuEnabled("/tools/deobfuscation/renameInvalidIdentifiers", swfSelected && !isWorking); + setMenuEnabled("/tools/deobfuscation/renameColliding", swfSelected && !isWorking); setMenuEnabled("/tools/deobfuscation/deobfuscation", hasAbc); setMenuEnabled("/tools/search", swfSelected); @@ -889,6 +898,7 @@ public abstract class MainFrameMenu implements MenuBuilder { addMenuItem("/tools/deobfuscation", translate("menu.tools.deobfuscation"), "deobfuscate16", null, 0, null, false, null, false); addMenuItem("/tools/deobfuscation/renameOneIdentifier", translate("menu.tools.deobfuscation.globalrename"), "rename16", this::renameOneIdentifier, PRIORITY_MEDIUM, null, true, null, false); addMenuItem("/tools/deobfuscation/renameInvalidIdentifiers", translate("menu.tools.deobfuscation.renameinvalid"), "renameall16", this::renameInvalidIdentifiers, PRIORITY_MEDIUM, null, true, null, false); + addMenuItem("/tools/deobfuscation/renameColliding", translate("menu.tools.deobfuscation.renameColliding"), "renameall16", this::renameColliding, PRIORITY_MEDIUM, null, true, null, false); addMenuItem("/tools/deobfuscation/deobfuscation", translate("menu.tools.deobfuscation.pcode"), "deobfuscate32", this::deobfuscationActionPerformed, PRIORITY_TOP, null, true, null, false); finishMenu("/tools/deobfuscation"); diff --git a/src/com/jpexs/decompiler/flash/gui/MainPanel.java b/src/com/jpexs/decompiler/flash/gui/MainPanel.java index 137a504fd..c45bc048b 100644 --- a/src/com/jpexs/decompiler/flash/gui/MainPanel.java +++ b/src/com/jpexs/decompiler/flash/gui/MainPanel.java @@ -27,6 +27,7 @@ import com.jpexs.decompiler.flash.abc.ABC; import com.jpexs.decompiler.flash.abc.RenameType; import com.jpexs.decompiler.flash.abc.ScriptPack; import com.jpexs.decompiler.flash.abc.avm2.AVM2ConstantPool; +import com.jpexs.decompiler.flash.abc.avm2.deobfuscation.AbcMultiNameCollisionFixer; import com.jpexs.decompiler.flash.abc.avm2.deobfuscation.DeobfuscationLevel; import com.jpexs.decompiler.flash.abc.types.traits.Trait; import com.jpexs.decompiler.flash.configuration.Configuration; @@ -1913,6 +1914,48 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se updateClassesList(); } + public void renameColliding(final SWF swf) { + if (swf == null) { + return; + } + if (confirmExperimental()) { + new CancellableWorker() { + @Override + protected Integer doInBackground() throws Exception { + AbcMultiNameCollisionFixer fixer = new AbcMultiNameCollisionFixer(); + return fixer.fixCollisions(swf); + } + + @Override + protected void onStart() { + Main.startWork(translate("work.renaming.identifiers") + "...", this); + } + + @Override + protected void done() { + View.execInEventDispatch(() -> { + try { + int cnt = get(); + Main.stopWork(); + View.showMessageDialog(null, translate("message.rename.renamed").replace("%count%", Integer.toString(cnt))); + swf.assignClassesToSymbols(); + swf.clearScriptCache(); + if (abcPanel != null) { + abcPanel.reload(); + } + updateClassesList(); + reload(true); + } catch (Exception ex) { + logger.log(Level.SEVERE, "Error during renaming identifiers", ex); + Main.stopWork(); + View.showMessageDialog(null, translate("error.occured").replace("%error%", ex.getClass().getSimpleName())); + } + }); + } + }.execute(); + } + } + public void renameOneIdentifier(final SWF swf) { if (swf == null) { return; diff --git a/src/com/jpexs/decompiler/flash/gui/locales/MainFrame.properties b/src/com/jpexs/decompiler/flash/gui/locales/MainFrame.properties index 65c5f29d9..5d716e46c 100644 --- a/src/com/jpexs/decompiler/flash/gui/locales/MainFrame.properties +++ b/src/com/jpexs/decompiler/flash/gui/locales/MainFrame.properties @@ -769,4 +769,6 @@ error.debug.watch.add = Cannot add watch to this variable. variables.column.scope = Scope variables.column.flags = Flags -variables.column.trait = Trait \ No newline at end of file +variables.column.trait = Trait + +menu.tools.deobfuscation.renameColliding = Rename colliding traits/classes