diff --git a/CHANGELOG.md b/CHANGELOG.md index 57a232c1f..1c558f55b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,6 +24,8 @@ All notable changes to this project will be documented in this file. - [#2550] FLV video import - incorrect frame position caused by wrong FLV tag sort - Mac package problems related to BOM file (updated jbomutils library) - [#2561] Cannot set filter strength to 128 or above +- [#2562] ABC explorer not working in some obfuscated code +- [#2562] P-code not showing in some obfuscated code (NumberContext related) ### Changed - Simple editor uses percent as units for filter strength @@ -4046,6 +4048,7 @@ Major version of SWF to XML export changed to 2. [#2551]: https://www.free-decompiler.com/flash/issues/2551 [#2550]: https://www.free-decompiler.com/flash/issues/2550 [#2561]: https://www.free-decompiler.com/flash/issues/2561 +[#2562]: https://www.free-decompiler.com/flash/issues/2562 [#2477]: https://www.free-decompiler.com/flash/issues/2477 [#2478]: https://www.free-decompiler.com/flash/issues/2478 [#2485]: https://www.free-decompiler.com/flash/issues/2485 diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/NumberContext.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/NumberContext.java index 38af20efa..f750b002e 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/NumberContext.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/NumberContext.java @@ -87,8 +87,9 @@ public class NumberContext { * @param usage Usage */ public void setUsage(int usage) { - if (usage > usageNames.length || usage < 0) { - throw new IllegalArgumentException("Invalid usage value :" + usage); + if (usage >= usageNames.length || usage < 0) { + this.usage = USE_NUMBER; + return; } this.usage = usage; } @@ -118,7 +119,7 @@ public class NumberContext { */ public void setPrecision(int precision) { if (precision > 34) { - throw new IllegalArgumentException("Maximum value of precision is 34"); + precision = 34; } this.precision = precision; } @@ -129,8 +130,9 @@ public class NumberContext { * @param rounding Rounding */ public void setRounding(int rounding) { - if (rounding > roundingNames.length || rounding < 0) { - throw new IllegalArgumentException("Invalid rounding value :" + rounding); + if (rounding >= roundingNames.length || rounding < 0) { + this.rounding = ROUND_HALF_EVEN; + return; } this.rounding = rounding; } @@ -165,8 +167,8 @@ public class NumberContext { * @return Name */ public static String usageToName(int usage) { - if (usage > usageNames.length || usage < 0) { - throw new IllegalArgumentException("Invalid usage value :" + usage); + if (usage >= usageNames.length || usage < 0) { + return "Number"; } return usageNames[usage]; } @@ -177,8 +179,8 @@ public class NumberContext { * @return Name */ public static String roundingToName(int rounding) { - if (rounding > roundingNames.length || rounding < 0) { - throw new IllegalArgumentException("Invalid rounding value :" + rounding); + if (rounding >= roundingNames.length || rounding < 0) { + return "HALF_EVEN"; } return roundingNames[rounding]; } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/graph/AVM2Graph.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/graph/AVM2Graph.java index b5f71f0c1..cc4992437 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/graph/AVM2Graph.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/graph/AVM2Graph.java @@ -712,6 +712,9 @@ public class AVM2Graph extends Graph { continue; } for (int ip = p.start; ip <= p.end; ip++) { + if (ip >= avm2code.code.size()) { + continue; + } AVM2Instruction ins = avm2code.code.get(ip); if (ins.definition instanceof SetLocalTypeIns) { int regId = ((SetLocalTypeIns) ins.definition).getRegisterId(ins); @@ -3306,6 +3309,9 @@ public class AVM2Graph extends Graph { if (part.end < 0) { return false; } + if (part.end >= avm2code.code.size()) { + return false; + } return avm2code.code.get(part.end).definition instanceof LookupSwitchIns; } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/usages/simple/ABCCleaner.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/usages/simple/ABCCleaner.java index fea96864a..7215dd1ad 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/usages/simple/ABCCleaner.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/usages/simple/ABCCleaner.java @@ -351,7 +351,7 @@ public class ABCCleaner { } private int handleReplace(ABCSimpleUsageDetector.ItemKind kind, int index, Map> replaceMap) { - if (!replaceMap.get(kind).containsKey(index)) { + if (!replaceMap.containsKey(kind) || !replaceMap.get(kind).containsKey(index)) { return index; } return replaceMap.get(kind).get(index); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/usages/simple/ABCSimpleUsageDetector.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/usages/simple/ABCSimpleUsageDetector.java index 6e3e41b81..e30ebe767 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/usages/simple/ABCSimpleUsageDetector.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/usages/simple/ABCSimpleUsageDetector.java @@ -540,7 +540,7 @@ public class ABCSimpleUsageDetector { * @return True if it is new */ private boolean handleUsage(ItemKind kind, int index, String usageDescription) { - if (index < 0 || index > usages.get(kind).size() - 1) { + if (!usages.containsKey(kind) || index < 0 || index > usages.get(kind).size() - 1) { Logger.getLogger(ABCSimpleUsageDetector.class.getName()).log(Level.WARNING, "{0} with index {1} not found for usage {2}", new Object[]{kind, index, usageDescription}); return false; }