From b762bebe70c13cc3d663888eda7b63ca915d3237 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jindra=20Pet=C5=99=C3=ADk?= Date: Sun, 5 Mar 2023 17:16:58 +0100 Subject: [PATCH] Added FileAttributes tag - SWF relative Urls flag --- CHANGELOG.md | 1 + .../flash/importers/SwfXmlImporter.java | 14 ++++++++++ .../flash/tags/FileAttributesTag.java | 27 +++++++++---------- 3 files changed, 28 insertions(+), 14 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1328009b7..1ee278cab 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ All notable changes to this project will be documented in this file. - AS3 support for logical AND/OR compound operator - AS3 Display missing namespaces along traits as §§namespace("url") - [#1888], [#1892] AS3 option to select SWF dependencies to properly resolve namespaces, types, etc. (currently in GUI only) +- FileAttributes tag - SWF relative Urls flag ### Fixed - [#1981] AS3 fully qualified (colliding) types in submethods diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/importers/SwfXmlImporter.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/importers/SwfXmlImporter.java index 9ad31d800..d619ae079 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/importers/SwfXmlImporter.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/importers/SwfXmlImporter.java @@ -39,6 +39,7 @@ import com.jpexs.decompiler.flash.abc.types.traits.TraitSlotConst; import com.jpexs.decompiler.flash.abc.types.traits.Traits; import com.jpexs.decompiler.flash.amf.amf3.Amf3Value; import com.jpexs.decompiler.flash.tags.DefineSpriteTag; +import com.jpexs.decompiler.flash.tags.FileAttributesTag; import com.jpexs.decompiler.flash.tags.Tag; import com.jpexs.decompiler.flash.tags.TagTypeInfo; import com.jpexs.decompiler.flash.tags.UnknownTag; @@ -313,6 +314,19 @@ public class SwfXmlImporter { ((SWF) obj).setCharset(val); continue; } + + //backwards compatibility + if (name.equals("reserved1") && "FileAttributesTag".equals(attributes.get("type"))) { + name = "reservedA"; + } + if (name.equals("reserved2") && "FileAttributesTag".equals(attributes.get("type"))) { + name = "swfRelativeUrls"; + } + if (name.equals("reserved3") && "FileAttributesTag".equals(attributes.get("type"))) { + name = "reservedB"; + } + + if (!name.equals("type")) { try { Field field = getField(cls, name); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/FileAttributesTag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/FileAttributesTag.java index 9eacc5670..5c13da755 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/FileAttributesTag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/FileAttributesTag.java @@ -37,6 +37,9 @@ public class FileAttributesTag extends Tag { public static final String NAME = "FileAttributes"; + @Reserved + public boolean reservedA; + public boolean useDirectBlit; public boolean useGPU; @@ -48,16 +51,12 @@ public class FileAttributesTag extends Tag { public boolean useNetwork; public boolean noCrossDomainCache; - - @Reserved - public boolean reserved1; - - @Reserved - public boolean reserved2; - + + public boolean swfRelativeUrls; + @SWFType(value = BasicType.UB, count = 24) @Reserved - public int reserved3; + public int reservedB; /** * Constructor @@ -75,14 +74,14 @@ public class FileAttributesTag extends Tag { @Override public final void readData(SWFInputStream sis, ByteArrayRange data, int level, boolean parallel, boolean skipUnusualTags, boolean lazy) throws IOException { - reserved1 = sis.readUB(1, "reserved1") == 1; // reserved + reservedA = sis.readUB(1, "reservedA") == 1; // reserved // UB[1] == 0 (reserved) useDirectBlit = sis.readUB(1, "useDirectBlit") != 0; useGPU = sis.readUB(1, "useGPU") != 0; hasMetadata = sis.readUB(1, "hasMetadata") != 0; actionScript3 = sis.readUB(1, "actionScript3") != 0; noCrossDomainCache = sis.readUB(1, "noCrossDomainCache") != 0; - reserved2 = sis.readUB(1, "reserved2") == 1; // reserved + swfRelativeUrls = sis.readUB(1, "swfRelativeUrls") == 1; useNetwork = sis.readUB(1, "useNetwork") != 0; // UB[24] == 0 (reserved) int bitCount = 24; @@ -90,7 +89,7 @@ public class FileAttributesTag extends Tag { bitCount = sis.available() * 8; } - reserved3 = (int) sis.readUB(bitCount, "reserved3"); //reserved + reservedB = (int) sis.readUB(bitCount, "reservedB"); //reserved } /** @@ -101,14 +100,14 @@ public class FileAttributesTag extends Tag { */ @Override public void getData(SWFOutputStream sos) throws IOException { - sos.writeUB(1, reserved1 ? 1 : 0); //reserved + sos.writeUB(1, reservedA ? 1 : 0); //reserved sos.writeUB(1, useDirectBlit ? 1 : 0); sos.writeUB(1, useGPU ? 1 : 0); sos.writeUB(1, hasMetadata ? 1 : 0); sos.writeUB(1, actionScript3 ? 1 : 0); sos.writeUB(1, noCrossDomainCache ? 1 : 0); - sos.writeUB(1, reserved2 ? 1 : 0); //reserved + sos.writeUB(1, swfRelativeUrls ? 1 : 0); sos.writeUB(1, useNetwork ? 1 : 0); - sos.writeUB(24, reserved3); //reserved + sos.writeUB(24, reservedB); //reserved } }