From 1a0aa9c7794bead06946a005a99321dfe49ef53f Mon Sep 17 00:00:00 2001 From: "honfika@gmail.com" Date: Sat, 27 Feb 2016 16:29:58 +0100 Subject: [PATCH 1/3] show warning on 32bit jre --- .../flash/abc/types/MethodBody.java | 1 + .../jpexs/decompiler/flash/action/Action.java | 12 +++++---- .../src/com/jpexs/helpers/Helper.java | 22 +++++++++++++++ src/com/jpexs/decompiler/flash/gui/Main.java | 5 ++++ .../decompiler/flash/gui/MainFrameMenu.java | 27 ++++++++++--------- .../flash/gui/locales/MainFrame.properties | 1 + 6 files changed, 50 insertions(+), 18 deletions(-) diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/MethodBody.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/MethodBody.java index 21df89e4a..7c28f17ca 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/MethodBody.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/MethodBody.java @@ -334,6 +334,7 @@ public final class MethodBody implements Cloneable { } else { logger.log(Level.SEVERE, "Decompilation error in: " + path, ex); } + convertException = ex; Throwable cause = ex.getCause(); if (ex instanceof ExecutionException && cause instanceof Exception) { diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/Action.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/Action.java index ca67b478c..58e21b37d 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/Action.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/Action.java @@ -863,6 +863,7 @@ public abstract class Action implements GraphSourceItem { } else { logger.log(Level.SEVERE, "Decompilation error in: " + path, ex); } + convertException = ex; Throwable cause = ex.getCause(); if (ex instanceof ExecutionException && cause instanceof Exception) { @@ -1023,11 +1024,12 @@ public abstract class Action implements GraphSourceItem { } } out = ActionGraph.translateViaGraph(regNames, variables2, functions, actions.subList(adr2ip(actions, endAddr), adr2ip(actions, endAddr + size)), version, staticOperation, path + (cntName == null ? "" : "/" + cntName)); - } catch (OutOfMemoryError | TranslateException | StackOverflowError ex2) { - logger.log(Level.SEVERE, "Decompilation error in: " + path, ex2); - if (ex2 instanceof OutOfMemoryError) { + } catch (OutOfMemoryError | TranslateException | StackOverflowError ex) { + logger.log(Level.SEVERE, "Decompilation error in: " + path, ex); + if (ex instanceof OutOfMemoryError) { Helper.freeMem(); } + out = new ArrayList<>(); out.add(new CommentItem(new String[]{ "", @@ -1035,7 +1037,7 @@ public abstract class Action implements GraphSourceItem { " * " + AppResources.translate("decompilationError.obfuscated"), Helper.decompilationErrorAdd == null ? null : " * " + Helper.decompilationErrorAdd, " * " + AppResources.translate("decompilationError.errorType") + ": " - + ex2.getClass().getSimpleName(), + + ex.getClass().getSimpleName(), ""})); } outs.add(out); @@ -1065,7 +1067,7 @@ public abstract class Action implements GraphSourceItem { } /*ActionJump && ActionIf removed*/ - /*if ((action instanceof ActionEnumerate2) || (action instanceof ActionEnumerate)) { + /*if ((action instanceof ActionEnumerate2) || (action instanceof ActionEnumerate)) { loopStart = ip + 1; isForIn = true; ip += 4; diff --git a/libsrc/ffdec_lib/src/com/jpexs/helpers/Helper.java b/libsrc/ffdec_lib/src/com/jpexs/helpers/Helper.java index 9264dec10..30de0fc0d 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/helpers/Helper.java +++ b/libsrc/ffdec_lib/src/com/jpexs/helpers/Helper.java @@ -1406,4 +1406,26 @@ public class Helper { lastIds.put(str, a); return str + "_" + a; } + + public static boolean is64BitJre() { + String prop = System.getProperty("sun.arch.data.model"); + return prop != null && prop.contains("64"); + + } + + public static boolean is64BitOs() { + String arch = System.getenv("PROCESSOR_ARCHITECTURE"); + String wow64Arch = System.getenv("PROCESSOR_ARCHITEW6432"); + + if (arch == null) { + return false; + } + + return arch.endsWith("64") + || wow64Arch != null && wow64Arch.endsWith("64"); + } + + public static void showOutOfMemoryWarning() { + + } } diff --git a/src/com/jpexs/decompiler/flash/gui/Main.java b/src/com/jpexs/decompiler/flash/gui/Main.java index 7d4ca0dfa..053dd27cf 100644 --- a/src/com/jpexs/decompiler/flash/gui/Main.java +++ b/src/com/jpexs/decompiler/flash/gui/Main.java @@ -1006,6 +1006,8 @@ public class Main { } else { throw new IOException("Output is empty"); } + } else { + throw new IOException("Output not found"); } } @@ -2250,6 +2252,9 @@ public class Main { @Override public void uncaughtException(Thread t, Throwable e) { logger.log(Level.SEVERE, "Uncaught exception in thread: " + t.getName(), e); + if (e instanceof OutOfMemoryError || !Helper.is64BitJre() && Helper.is64BitOs()) { + View.showMessageDialog(null, AppStrings.translate("message.warning.outOfMemeory32BitJre"), AppStrings.translate("message.warning"), JOptionPane.WARNING_MESSAGE); + } } }); diff --git a/src/com/jpexs/decompiler/flash/gui/MainFrameMenu.java b/src/com/jpexs/decompiler/flash/gui/MainFrameMenu.java index 84cf7206f..11291e169 100644 --- a/src/com/jpexs/decompiler/flash/gui/MainFrameMenu.java +++ b/src/com/jpexs/decompiler/flash/gui/MainFrameMenu.java @@ -28,7 +28,6 @@ import com.jpexs.decompiler.flash.gui.debugger.DebuggerTools; import com.jpexs.decompiler.flash.gui.helpers.CheckResources; import com.jpexs.decompiler.flash.tags.ABCContainerTag; import com.jpexs.helpers.ByteArrayRange; -import com.jpexs.helpers.Cache; import com.jpexs.helpers.Helper; import com.jpexs.helpers.utf8.Utf8Helper; import com.sun.jna.Platform; @@ -559,16 +558,16 @@ public abstract class MainFrameMenu implements MenuBuilder { } /*protected void cacheOnDiskActionPerformed(ActionEvent evt) { - AbstractButton button = (AbstractButton) evt.getSource(); - boolean selected = button.isSelected(); + AbstractButton button = (AbstractButton) evt.getSource(); + boolean selected = button.isSelected(); - Configuration.cacheOnDisk.set(selected); - if (selected) { - Cache.setStorageType(Cache.STORAGE_FILES); - } else { - Cache.setStorageType(Cache.STORAGE_MEMORY); - } - }*/ + Configuration.cacheOnDisk.set(selected); + if (selected) { + Cache.setStorageType(Cache.STORAGE_FILES); + } else { + Cache.setStorageType(Cache.STORAGE_MEMORY); + } + }*/ protected void setLanguageActionPerformed(ActionEvent evt) { new SelectLanguageDialog().display(); } @@ -949,9 +948,9 @@ public abstract class MainFrameMenu implements MenuBuilder { }); /*setMenuChecked("/settings/cacheOnDisk", Configuration.cacheOnDisk.get()); - Configuration.cacheOnDisk.addListener(configListenerCacheOnDisk = (Boolean newValue) -> { - setMenuChecked("/settings/cacheOnDisk", newValue); - });*/ + Configuration.cacheOnDisk.addListener(configListenerCacheOnDisk = (Boolean newValue) -> { + setMenuChecked("/settings/cacheOnDisk", newValue); + });*/ setMenuChecked("/settings/gotoMainClassOnStartup", Configuration.gotoMainClassOnStartup.get()); Configuration.gotoMainClassOnStartup.addListener(configListenerGotoMainClassOnStartup = (Boolean newValue) -> { setMenuChecked("/settings/gotoMainClassOnStartup", newValue); @@ -1012,6 +1011,8 @@ public abstract class MainFrameMenu implements MenuBuilder { String architecture = System.getProperty("sun.arch.data.model"); Runtime runtime = Runtime.getRuntime(); String info = "Architecture: " + architecture + Helper.newLine + + "Jre 64bit: " + Helper.is64BitJre() + Helper.newLine + + "Os 64bit: " + Helper.is64BitOs() + Helper.newLine + "Max: " + (runtime.maxMemory() / 1024 / 1024) + "MB" + Helper.newLine + "Used: " + (runtime.totalMemory() / 1024 / 1024) + "MB" + Helper.newLine + "Free: " + (runtime.freeMemory() / 1024 / 1024) + "MB"; diff --git a/src/com/jpexs/decompiler/flash/gui/locales/MainFrame.properties b/src/com/jpexs/decompiler/flash/gui/locales/MainFrame.properties index 1e407b88d..ffd9c5797 100644 --- a/src/com/jpexs/decompiler/flash/gui/locales/MainFrame.properties +++ b/src/com/jpexs/decompiler/flash/gui/locales/MainFrame.properties @@ -712,3 +712,4 @@ menu.settings.simplifyExpressions = Simplify expressions #after 8.0.1 menu.recentFiles.empty = Recent file list is empty +message.warning.outOfMemeory32BitJre = OutOfMemory error occured. You are running 32bit Java on 64bit system. Please use 64bit Java. From d73d46b2a2e82fbecede207888562aa34d1f9adf Mon Sep 17 00:00:00 2001 From: "honfika@gmail.com" Date: Sun, 28 Feb 2016 08:01:43 +0100 Subject: [PATCH 2/3] refresh tree after raw edit (for example to show the new script tags when a buttonconditionaction is added to a DefineButton tag) --- .../src/com/jpexs/decompiler/flash/types/BUTTONCONDACTION.java | 3 ++- src/com/jpexs/decompiler/flash/gui/PreviewPanel.java | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/BUTTONCONDACTION.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/BUTTONCONDACTION.java index 7f890411a..a4cddf8b3 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/BUTTONCONDACTION.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/BUTTONCONDACTION.java @@ -27,6 +27,7 @@ import com.jpexs.decompiler.flash.helpers.GraphTextWriter; import com.jpexs.decompiler.flash.tags.Tag; import com.jpexs.decompiler.flash.tags.base.ASMSource; import com.jpexs.decompiler.flash.types.annotations.Conditional; +import com.jpexs.decompiler.flash.types.annotations.HideInRawEdit; import com.jpexs.decompiler.flash.types.annotations.Internal; import com.jpexs.decompiler.flash.types.annotations.SWFType; import com.jpexs.helpers.ByteArrayRange; @@ -154,7 +155,7 @@ public class BUTTONCONDACTION implements ASMSource, Serializable { /** * Actions to perform in byte array */ - @Internal + @HideInRawEdit public ByteArrayRange actionBytes; /** diff --git a/src/com/jpexs/decompiler/flash/gui/PreviewPanel.java b/src/com/jpexs/decompiler/flash/gui/PreviewPanel.java index 60171d41b..642b1c874 100644 --- a/src/com/jpexs/decompiler/flash/gui/PreviewPanel.java +++ b/src/com/jpexs/decompiler/flash/gui/PreviewPanel.java @@ -1211,7 +1211,7 @@ public class PreviewPanel extends JPersistentSplitPane implements TagEditorPanel tag.getTimelined().resetTimeline(); swf.assignClassesToSymbols(); swf.assignExportNamesToSymbols(); - mainPanel.repaintTree(); + mainPanel.refreshTree(swf); mainPanel.setTagTreeSelectedNode(tag); genericEditButton.setVisible(true); genericSaveButton.setVisible(false); From 859e394c55ee6b340eba91226a48a9e5586f377a Mon Sep 17 00:00:00 2001 From: "honfika@gmail.com" Date: Sun, 28 Feb 2016 09:41:26 +0100 Subject: [PATCH 3/3] action bytes: HideInRawEdit everywhere --- .../src/com/jpexs/decompiler/flash/tags/DefineButtonTag.java | 1 - .../src/com/jpexs/decompiler/flash/tags/DoActionTag.java | 1 - .../src/com/jpexs/decompiler/flash/tags/DoInitActionTag.java | 1 - .../com/jpexs/decompiler/flash/types/BUTTONCONDACTION.java | 4 ---- .../com/jpexs/decompiler/flash/types/CLIPACTIONRECORD.java | 4 ++-- 5 files changed, 2 insertions(+), 9 deletions(-) diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineButtonTag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineButtonTag.java index b5ebbd2a3..ea3776639 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineButtonTag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineButtonTag.java @@ -74,7 +74,6 @@ public class DefineButtonTag extends ButtonTag implements ASMSource { /** * Actions to perform */ - //public List actions; @HideInRawEdit public ByteArrayRange actionBytes; diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DoActionTag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DoActionTag.java index 149073150..ea53f2642 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DoActionTag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DoActionTag.java @@ -51,7 +51,6 @@ public class DoActionTag extends Tag implements ASMSource { /** * List of actions to perform */ - //public List actions = new ArrayList(); @HideInRawEdit public ByteArrayRange actionBytes; diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DoInitActionTag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DoInitActionTag.java index 4a5505f1d..6c9900227 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DoInitActionTag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DoInitActionTag.java @@ -58,7 +58,6 @@ public class DoInitActionTag extends Tag implements CharacterIdTag, ASMSource { /** * List of actions to perform */ - //public List actions = new ArrayList(); @HideInRawEdit public ByteArrayRange actionBytes; diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/BUTTONCONDACTION.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/BUTTONCONDACTION.java index a4cddf8b3..e29c628f9 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/BUTTONCONDACTION.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/BUTTONCONDACTION.java @@ -148,10 +148,6 @@ public class BUTTONCONDACTION implements ASMSource, Serializable { */ public boolean condOverDownToIdle; - /** - * Actions to perform - */ - //public List actions; /** * Actions to perform in byte array */ diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/CLIPACTIONRECORD.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/CLIPACTIONRECORD.java index 3b117b067..f7c518f01 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/CLIPACTIONRECORD.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/CLIPACTIONRECORD.java @@ -27,6 +27,7 @@ import com.jpexs.decompiler.flash.helpers.GraphTextWriter; import com.jpexs.decompiler.flash.tags.Tag; import com.jpexs.decompiler.flash.tags.base.ASMSource; import com.jpexs.decompiler.flash.types.annotations.Conditional; +import com.jpexs.decompiler.flash.types.annotations.HideInRawEdit; import com.jpexs.decompiler.flash.types.annotations.Internal; import com.jpexs.helpers.ByteArrayRange; import com.jpexs.helpers.Helper; @@ -146,8 +147,7 @@ public class CLIPACTIONRECORD implements ASMSource, Serializable { /** * Actions to perform */ - //public List actions; - @Internal + @HideInRawEdit public ByteArrayRange actionBytes; /**