diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/SWF.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/SWF.java index e56dda397..435a5fdb0 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/SWF.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/SWF.java @@ -1533,6 +1533,9 @@ public final class SWF implements SWFContainerItem, Timelined, Openable { } assignExportNamesToSymbols(); assignClassesToSymbols(); + if (Configuration.autoLoadEmbeddedSwfs.get()) { + loadAllEmbeddedSwfs(); + } SWFDecompilerPlugin.fireSwfParsed(this); } else { boolean hasNonUnknownTag = false; @@ -1560,6 +1563,16 @@ public final class SWF implements SWFContainerItem, Timelined, Openable { getASMs(true); // Add scriptNames to ASMs } + private void loadAllEmbeddedSwfs() + { + for (Tag t : getTags()) { + if (t instanceof DefineBinaryDataTag) { + DefineBinaryDataTag binaryData = (DefineBinaryDataTag) t; + binaryData.loadEmbeddedSwf(); + } + } + } + private void resolveImported(UrlResolver resolver) { for (int p = 0; p < tags.size(); p++) { Tag t = tags.get(p); @@ -2472,7 +2485,7 @@ public final class SWF implements SWFContainerItem, Timelined, Openable { val >>= 8; } } - + public static void createWavFromPcmData(OutputStream fos, int soundRateHz, boolean soundSize, boolean soundType, byte[] data) throws IOException { ByteArrayOutputStream subChunk1Data = new ByteArrayOutputStream(); int audioFormat = 1; // PCM diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineBinaryDataTag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineBinaryDataTag.java index f26c2a0da..2104ef885 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineBinaryDataTag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineBinaryDataTag.java @@ -88,30 +88,31 @@ public class DefineBinaryDataTag extends CharacterTag { public final void readData(SWFInputStream sis, ByteArrayRange data, int level, boolean parallel, boolean skipUnusualTags, boolean lazy) throws IOException { tag = sis.readUI16("tag"); reserved = sis.readUI32("reserved"); - binaryData = sis.readByteRangeEx(sis.available(), "binaryData"); + binaryData = sis.readByteRangeEx(sis.available(), "binaryData"); + } + + public void loadEmbeddedSwf() + { + String path = getSwf().getShortPathTitle() + "/DefineBinaryData (" + getCharacterId() + ")"; + SwfSpecificCustomConfiguration conf = Configuration.getSwfSpecificCustomConfiguration(path); + String charset = conf == null ? Charset.defaultCharset().name() : conf.getCustomData(CustomConfigurationKeys.KEY_CHARSET, Charset.defaultCharset().name()); - if (Configuration.autoLoadEmbeddedSwfs.get()) { - String path = getSwf().getShortPathTitle() + "/DefineBinaryData (" + getCharacterId() + ")"; - SwfSpecificCustomConfiguration conf = Configuration.getSwfSpecificCustomConfiguration(path); - String charset = conf == null ? Charset.defaultCharset().name() : conf.getCustomData(CustomConfigurationKeys.KEY_CHARSET, Charset.defaultCharset().name()); - - try { - InputStream is = new ByteArrayInputStream(binaryData.getArray(), binaryData.getPos(), binaryData.getLength()); - detectPacker(); - String packerAdd = ""; - if (usedPacker != null) { - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - usedPacker.decrypt(is, baos); - is = new ByteArrayInputStream(baos.toByteArray()); - packerAdd = " - " + usedPacker.getName(); - } - - SWF bswf = new SWF(is, null, "(SWF Data" + packerAdd + ")", Configuration.parallelSpeedUp.get(), charset); - innerSwf = bswf; - bswf.binaryData = this; - } catch (IOException | InterruptedException ex) { - // ignore + try { + InputStream is = new ByteArrayInputStream(binaryData.getArray(), binaryData.getPos(), binaryData.getLength()); + detectPacker(); + String packerAdd = ""; + if (usedPacker != null) { + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + usedPacker.decrypt(is, baos); + is = new ByteArrayInputStream(baos.toByteArray()); + packerAdd = " - " + usedPacker.getName(); } + + SWF bswf = new SWF(is, null, "(SWF Data" + packerAdd + ")", Configuration.parallelSpeedUp.get(), charset); + innerSwf = bswf; + bswf.binaryData = this; + } catch (IOException | InterruptedException ex) { + // ignore } }