From e7d19739577ed6fce552fbe3444c8956a6bd4081 Mon Sep 17 00:00:00 2001 From: lucia c Date: Sat, 27 Jan 2024 14:53:16 +0000 Subject: [PATCH] patterns: Added SWF header pattern (#219) * patterns: Added pattern for SWF files. * Added test file for SWF header. * Update README with SWF file type. --- README.md | 1 + patterns/swf.hexpat | 29 ++++++++++++++++++++++++ tests/patterns/test_data/swf.hexpat.swf | Bin 0 -> 21 bytes 3 files changed, 30 insertions(+) create mode 100644 patterns/swf.hexpat create mode 100644 tests/patterns/test_data/swf.hexpat.swf diff --git a/README.md b/README.md index 2e0f3fc..aa4ce90 100644 --- a/README.md +++ b/README.md @@ -101,6 +101,7 @@ Everything will immediately show up in ImHex's Content Store and gets bundled wi | SPIRV | | [`patterns/spirv.hexpat`](patterns/spirv.hexpat) | SPIR-V header and instructions | | STL | `model/stl` | [`patterns/stl.hexpat`](patterns/stl.hexpat) | STL 3D Model format | | StuffItV5 | `application/x-stuffit` | [`patterns/sit5.hexpat`](patterns/sit5.hexpat) | StuffIt V5 archive | +| SWF | |[`patterns/swf.hexpat`](patterns/swf.hexpat) | Shockwave Flash file format | | TAR | `application/x-tar` | [`patterns/tar.hexpat`](patterns/tar.hexpat) | Tar file format | | TIFF | `image/tiff` | [`patterns/tiff.hexpat`](patterns/tiff.hexpat) | Tag Image File Format | | TGA | `image/tga` | [`patterns/tga.hexpat`](patterns/tga.hexpat) | Truevision TGA/TARGA image | diff --git a/patterns/swf.hexpat b/patterns/swf.hexpat new file mode 100644 index 0000000..83ef30f --- /dev/null +++ b/patterns/swf.hexpat @@ -0,0 +1,29 @@ +#pragma author saturnaliam +#pragma description SWF file header +#pragma endian little +#include + + +// RECTs are more complicated, but for the header, +// this works fine. +bitfield Rect { + nSize : 5 [[name("N Size")]]; + signed xMin : 15 [[name("X Min")]]; + signed xMax : 15 [[name("X Max")]]; + signed yMin : 15 [[name("Y Min")]]; + signed yMax : 15 [[name("Y Max")]]; +}; + + +struct Header { + char compressionSignature [[name("Compression"), comment("F - Uncompressed\nC - zlib Compressed\nZ - LZMA compressed")]]; + type::Magic<"WS"> signature [[name("Signature")]]; + u8 swfVersion [[name("SWF Version")]]; + u32 bytesSize [[name("Uncompressed Size")]]; + be Rect rect [[name("Frame Size"), comment("Needs to be uncompressed to have the correct value.")]]; + padding[1]; + u8 frameRate [[name("Framerate"), comment("Needs to be uncompressed to have the correct value.")]]; + u16 frameCount [[name("Frame Count"), comment("Needs to be uncompressed to have the correct value.")]]; +}; + +Header header @ 0x00; \ No newline at end of file diff --git a/tests/patterns/test_data/swf.hexpat.swf b/tests/patterns/test_data/swf.hexpat.swf new file mode 100644 index 0000000000000000000000000000000000000000..10e3a4c3df6225dd02cea7894b4c27f85d3c1bc2 GIT binary patch literal 21 ccmZ<@59W%f<6)>^V0B|);J?JcAjil605GHjpa1{> literal 0 HcmV?d00001