Compare commits

..

18 Commits

Author SHA1 Message Date
paxcut
375145e759 include/std: std::ptr::relative_to_base_section not working anymore (#349)
Fixes #348 

In issue #348 it is stated that the pattern fails to find the variable baseAddress in the parent of the parent of the attribute function. One parent is required to access the variables on the pattern that is using the attribute.

That pattern is used in the pattern that contains baseAddress as a pointer to an array of the children pattern and that seems to require an extra parent level to be added in order to access baseAddress without errors. The fix was tested on an xbe file extracted from an xbox cd rom and while it failed without the fix as stated in issue 348 with the fix it ran to completion without issues.
2025-02-16 12:52:01 +01:00
paxcut
71eeed981d patterns/protobuf: Remove global variables
In issue #346 it is noted that the format functions return the same value repeatidly and erroneously. This is due to the use of global variables which result on only their last value being used in format functions due to their delayed evaluation. Fixed by using local variables instead. Also remove tabs from the file and an unused tags variable.
2025-01-30 20:24:11 +01:00
Fabian Neundorf
e779b88a58 patterns/iso: Fix incorrect condition (#344) 2025-01-23 21:44:44 +01:00
Fabian Neundorf
aef3d3451f patterns/iso: Add some improvements to the ISO pattern matching (#343)
* patterns: Load all ISO volume descriptors

* patterns: Parse supplementary volume descriptors

* patterns: Add system use in directory records for iso
2025-01-23 19:23:11 +01:00
Nik
c5fa53dcea includes/type: Make type::Formatted actually work as documented 2025-01-19 18:13:48 +01:00
The Wandering Trader
9a6cbdfe28 patterns: Add CAB pattern (#342)
* Add files via upload

* Add files via upload

* Update README.md
2025-01-19 00:13:04 +01:00
Nik
083042632d includes/hex: Hide implementation data of json types 2025-01-16 19:15:10 +01:00
Nik
4d172cebc3 patterns: Removed invalid zip test file 2025-01-14 20:07:03 +01:00
Nik
53ff0a5d62 patterns/afe2: Fixed misspelled of pragma 2025-01-14 20:06:39 +01:00
WerWolv
b3b730c6e9 patterns: Fixed various test binaries 2025-01-14 20:01:51 +01:00
Nik
8db011b6e5 patterns: Added MIME types and magic numbers to all patterns that have them 2025-01-14 20:01:36 +01:00
Nik
b936c04d21 patterns/gguf: Added #pragma magic to allow auto-loading the pattern 2025-01-14 18:21:16 +01:00
bake
bf56d4ff49 patterns: Add veado pattern (#339)
* Add veado pattern

* Add veado to README

* Add veado example file
2025-01-13 21:21:05 +01:00
Known Rabbit
fdc4a87389 patterns: Add bcss (BeyondCompare SnapShot) file (#338)
* patterns: add bcss (BeyondCompare SnapShot) file

* Add entry to readme

* Change table entries in alphabetical order

* Support both bcss file and uncompressed content

* Remove misleading cases, add warning message

* Add test cases to bcss.hexpat

* ifdef out ImHex-only functionality

---------

Co-authored-by: Nik <werwolv98@gmail.com>
2025-01-13 21:20:36 +01:00
Mia
1f6c701348 patterns: Added sup pattern file (#337)
* Add sup pattern file

* Add files via upload

* Update README.md
2025-01-09 20:01:14 +01:00
JTurtle
4092dad428 includes/type: Fix error in float16 format function (#336) 2025-01-05 09:46:09 +01:00
Nik
559faebec3 patterns: Added simple SQLite3 database pattern 2024-12-28 19:57:48 +01:00
Nik
cde46e1f15 patterns/bgcode: Improve bgcode pattern 2024-12-28 18:51:34 +01:00
73 changed files with 940 additions and 149 deletions

View File

@@ -25,7 +25,7 @@ Everything will immediately show up in ImHex's Content Store and gets bundled wi
|------|------|------|-------------|
| 3DS | | [`patterns/3ds.hexpat`](patterns/3ds.hexpat) | Autodesk 3DS Max Model file |
| 7Z | | [`patterns/7z.hexpat`](patterns/7z.hexpat) | 7z File Format |
| ADTS | | [`patterns/adts.hexpat`](patterns/adts.hexpat) | ADTS/AAC audio files |
| ADTS | `audio/x-hx-aac-adts` | [`patterns/adts.hexpat`](patterns/adts.hexpat) | ADTS/AAC audio files |
| AFE2 | | [`patterns/afe2.hexpat`](patterns/afe2.hexpat) | Nintendo Switch Atmosphère CFW Fatal Error log |
| ANI | `application/x-navi-animation` | [`patterns/ani.hexpat`](patterns/ani.hexpat) | Windows Animated Cursor file |
| AR | `application/x-archive` | [`patterns/ar.hexpat`](patterns/ar.hexpat) | Static library archive files |
@@ -33,6 +33,7 @@ Everything will immediately show up in ImHex's Content Store and gets bundled wi
| ARIA2 | | [`patterns/aria2.hexpat`](patterns/aria2.hexpat) | ARIA2 Download Manager Control files |
| ARM VTOR | | [`patterns/arm_cm_vtor.hexpat`](patterns/arm_cm_vtor.hexpat) | ARM Cortex M Vector Table Layout |
| Bastion | | [`patterns/bastion/*`](https://gitlab.com/EvelynTSMG/imhex-bastion-pats) | Various [Bastion](https://en.wikipedia.org/wiki/Bastion_(video_game)) files |
| BeyondCompare BCSS | | [`patterns/bcss.hexpat`](patterns/bcss.hexpat) | BeyondCompare Snapshot (BCSS) file |
| Bencode | `application/x-bittorrent` | [`patterns/bencode.hexpat`](patterns/bencode.hexpat) | Bencode encoding, used by Torrent files |
| Prusa BGCODE | | [`patterns/bgcode.hexpat`](patterns/bgcode.hexpat) | PrusaSlicer Binary G-Code files |
| BLEND | | [`patterns/blend.hexpat`](patterns/blend.hexpat) | Blender Project file |
@@ -40,14 +41,15 @@ Everything will immediately show up in ImHex's Content Store and gets bundled wi
| BIN | | [`patterns/selinux.hexpat`](patterns/selinux.pat) | SE Linux modules |
| BINKA | | [`patterns/binka.hexpat`](patterns/binka.pat) | RAD Game Tools Bink Audio (BINKA) files |
| BSON | `application/bson` | [`patterns/bson.hexpat`](patterns/bson.hexpat) | BSON (Binary JSON) format |
| bplist | | [`patterns/bplist.hexpat`](patterns/bplist.hexpat) | Apple's binary property list format (bplist) |
| bplist | `application/x-bplist` | [`patterns/bplist.hexpat`](patterns/bplist.hexpat) | Apple's binary property list format (bplist) |
| BSP | | [`patterns/bsp_goldsrc.hexpat`](patterns/bsp_goldsrc.hexpat) | GoldSrc engine maps format (used in Half-Life 1) |
| BZIP3 | | [`patterns/bzip3.hexpat`](patterns/bzip3.hexpat) | GoldSrc engine maps format (used in Half-Life 1) |
| CAB | | [`patterns/cab.hexpat`](patterns/cab.hexpat) | Microsoft Cabinet (CAB) Files |
| CCHVA | | [`patterns/cchva.hexpat`](patterns/cchva.hexpat) | Command and Conquer Voxel Animation |
| CCVXL | | [`patterns/ccvxl.hexpat`](patterns/ccvxl.hexpat) | Command and Conquer Voxel Model |
| CCPAL | | [`patterns/ccpal.hexpat`](patterns/ccpal.hexpat) | Command and Conquer Voxel Palette |
| CDA | | [`patterns/cda.hexpat`](patterns/cda.hexpat) | Compact Disc Audio track |
| CHM | | [`patterns/chm.hexpat`](patterns/chm.hexpat) | Windows HtmlHelp Data (ITSF / CHM) |
| CHM | `application/vnd.ms-htmlhelp` | [`patterns/chm.hexpat`](patterns/chm.hexpat) | Windows HtmlHelp Data (ITSF / CHM) |
| COFF | `application/x-coff` | [`patterns/coff.hexpat`](patterns/coff.hexpat) | Common Object File Format (COFF) executable |
| CPIO | `application/x-cpio` | [`patterns/cpio.hexpat`](patterns/cpio.hexpat) | Old Binary CPIO Format |
| CrashLvl | | [`patterns/Crashlvl.hexpat`](patterns/Crashlvl.hexpat) | Crash Bandicoot - Back in Time (fan game) User created level format |
@@ -63,13 +65,13 @@ Everything will immediately show up in ImHex's Content Store and gets bundled wi
| DTA | | [`patterns/max_v104.hexpat`](patterns/max_v104.hexpat) | Mechanized Assault and Exploration v1.04 (strategy game) save file format |
| DTED | | [`patterns/dted.hexpat`](patterns/dted.hexpat) | Digital Terrain Elevation Data (DTED) |
| ELF | `application/x-executable` | [`patterns/elf.hexpat`](patterns/elf.hexpat) | ELF header in elf binaries |
| EVTX | | [`patterns/evtx.hexpat`](patterns/evtx.hexpat) | MS Windows Vista Event Log |
| EVTX | `application/x-ms-evtx` | [`patterns/evtx.hexpat`](patterns/evtx.hexpat) | MS Windows Vista Event Log |
| EXT4 | | [`patterns/ext4.hexpat`](patterns/ext4.hexpat) | Ext4 filesystem |
| FAS | | [`patterns/fas_oskasoftware.hexpat`](patterns/fas_oskasoftware.hexpat) [`patterns/fas_oskasoftware_old.hexpat`](patterns/fas_oskasoftware_old.hexpat) (Old versions of Oska DeskMate) | Oska Software DeskMates FAS (Frames and Sequences) file |
| FBX | | [`patterns/fbx.hexpat`](patterns/fbx.hexpat) | Kaydara FBX Binary |
| FDT | | [`patterns/fdt.hexpat`](patterns/fdt.hexpat) | Flat Linux Device Tree blob |
| FFX | | [`patterns/ffx/*`](https://gitlab.com/EvelynTSMG/imhex-ffx-pats) | Various Final Fantasy X files |
| File System | | [`patterns/fs.hexpat`](patterns/fs.hexpat) | Drive File System |
| File System | `application/x-ima` | [`patterns/fs.hexpat`](patterns/fs.hexpat) | Drive File System |
| FLAC | `audio/flac` | [`patterns/flac.hexpat`](patterns/flac.hexpat) | Free Lossless Audio Codec, FLAC Audio Format |
| Flipper Zero Settings | | [`patterns/flipper_settings.hexpat`](patterns/flipper_settings.hexpat) | Flipper Zero Settings Files |
| GB | `application/x-gameboy-rom` | [`patterns/gb.hexpat`](patterns/gb.hexpat) | Game Boy ROM |
@@ -87,7 +89,7 @@ Everything will immediately show up in ImHex's Content Store and gets bundled wi
| Intel HEX | | [`patterns/intel_hex.hexpat`](patterns/intel_hex.hexpat) | [Intel hexadecimal object file format definition]("https://en.wikipedia.org/wiki/Intel_HEX") |
| IP | | [`patterns/ip.hexpat`](patterns/ip.hexpat) | Ethernet II Frames (IP Packets) |
| IPS | | [`patterns/ips.hexpat`](patterns/ips.hexpat) | IPS (International Patching System) files |
| ISO | | [`patterns/iso.hexpat`](patterns/iso.hexpat) | ISO 9660 file system |
| ISO | `application/x-iso9660-image` | [`patterns/iso.hexpat`](patterns/iso.hexpat) | ISO 9660 file system |
| Java Class | `application/x-java-applet` | [`patterns/java_class.hexpat`](patterns/java_class.hexpat) | Java Class files |
| JPEG | `image/jpeg` | [`patterns/jpeg.hexpat`](patterns/jpeg.hexpat) | JPEG Image Format |
| LOC | | [`patterns/loc.hexpat`](patterns/loc.hexpat) | Minecraft Legacy Console Edition Language file |
@@ -105,8 +107,8 @@ Everything will immediately show up in ImHex's Content Store and gets bundled wi
| MSSCMP | | [`patterns/msscmp.hexpat`](patterns/msscmp.hexpat) | Miles Sound System Compressed Archive |
| NACP | | [`patterns/nacp.hexpat`](patterns/nacp.hexpat) | Nintendo Switch NACP files |
| NBT | | [`patterns/nbt.hexpat`](patterns/nbt.hexpat) | Minecraft NBT format |
| NE | | [`patterns/ne.hexpat`](patterns/ne.hexpat) | NE header and Standard NE fields |
| nes | | [`patterns/nes.hexpat`](patterns/nes.hexpat) | .nes file format |
| NE | `application/x-ms-ne-executable` | [`patterns/ne.hexpat`](patterns/ne.hexpat) | NE header and Standard NE fields |
| nes | | [`patterns/nes.hexpat`](patterns/nes.hexpat) | .nes file format |
| NotepadCache | | [`patterns/notepad-cache.hexpat`](patterns/notepad-cache.hexpat) | Windows Notepad Cache |
| NotepadWindowState | | [`patterns/notepadwindowstate.hexpat`](patterns/notepadwindowstate.hexpat) | Windows 11 Notepad - Window State .bin file |
| NRO | | [`patterns/nro.hexpat`](patterns/nro.hexpat) | Nintendo Switch NRO files |
@@ -116,8 +118,8 @@ Everything will immediately show up in ImHex's Content Store and gets bundled wi
| PCAP | `application/vnd.tcpdump.pcap` | [`patterns/pcap.hexpat`](patterns/pcap.hexpat) | pcap header and packets |
| PCK | | [`patterns/pck.hexpat`](patterns/pck.hexpat) | Minecraft Legacy Console Edition .pck file |
| PCX | `application/x-pcx` | [`patterns/pcx.hexpat`](patterns/pcx.hexpat) | PCX Image format |
| PE | `application/x-dosexec` `application/x-msdownload` | [`patterns/pe.hexpat`](patterns/pe.hexpat) | PE header, COFF header, Standard COFF fields and Windows Specific fields |
| PP | | [`patterns/selinuxpp.hexpat`](patterns/selinuxpp.pat) | SE Linux package |
| PE | `application/x-dosexec` `application/x-msdownload` | [`patterns/pe.hexpat`](patterns/pe.hexpat) | PE header, COFF header, Standard COFF fields and Windows Specific fields |
| PP | | [`patterns/selinuxpp.hexpat`](patterns/selinuxpp.pat) | SE Linux package |
| PFS0 | | [`patterns/pfs0.hexpat`](patterns/pfs0.hexpat) | Nintendo Switch PFS0 archive (NSP files) |
| PIF | `image/pif` | [`patterns/pif.hexpat`](patterns/pif.hexpat) | PIF Image Format |
| PKM | | [`patterns/pkm.hexpat`](patterns/pkm.hexpat) | PKM texture format |
@@ -126,21 +128,23 @@ Everything will immediately show up in ImHex's Content Store and gets bundled wi
| Protobuf | | [`patterns/protobuf.hexpat`](patterns/protobuf.hexpat) | Google Protobuf encoding |
| psafe3 | | [`patterns/psafe3.hexpat`](patterns/psafe3.hexpat`) | Password Safe V3 |
| PyInstaller | | [`patterns/pyinstaller.hexpat`](patterns/pyinstaller.hexpat) | PyInstaller binray files |
| PYC | | [`patterns/pyc.hexpat`](patterns/pyc.hexpat) | Python bytecode files |
| PYC | `application/x-bytecode.python` | [`patterns/pyc.hexpat`](patterns/pyc.hexpat) | Python bytecode files |
| QBCL | | [`patterns/qbcl.hexpat`](patterns/qbcl.hexpat) | Qubicle voxel scene project file |
| QOI | `image/qoi` | [`patterns/qoi.hexpat`](patterns/qoi.hexpat) | QOI image files |
| QOI | `image/qoi` | [`patterns/qoi.hexpat`](patterns/qoi.hexpat) | QOI image files |
| quantized-mesh | | [`patterns/quantized-mesh.hexpat`](patterns/quantized-mesh.hexpat) | Cesium quantized-mesh terrain |
| RAR | `application/x-rar` | [`patterns/rar.hexpat`](patterns/rar.hexpat) | RAR archive file format |
| RAS | `image/x-sun-raster` | [`patterns/ras.hexpat`](patterns/ras.hexpat) | RAS image files |
| RAS | `image/x-sun-raster` | [`patterns/ras.hexpat`](patterns/ras.hexpat) | RAS image files |
| ReFS | | [`patterns/refs.hexpat`](patterns/refs.hexpat) | Microsoft Resilient File System |
| RGBDS | | [`patterns/rgbds.hexpat`](patterns/rgbds.hexpat) | [RGBDS](https://rgbds.gbdev.io) object file format |
| Shell Link | `application/x-ms-shortcut` | [`patterns/lnk.hexpat`](patterns/lnk.hexpat) | Windows Shell Link file format |
| shp | | [`patterns/shp.hexpat`](patterns/shp.hexpat) | ESRI shape file |
| shx | | [`patterns/shx.hexpat`](patterns/shx.hexpat) | ESRI index file |
| sup | | [`patterns/sup.hexpat`](patterns/sup.hexpat) | PGS Subtitle |
| 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 |
| SQLite3 | `application/vnd.sqlite3` | [`patterns/sqlite3.hexpat`](patterns/sqlite3.hexpat) | SQLite3 Database |
| SWF | `application/x-shockwave-flash` |[`patterns/swf.hexpat`](patterns/swf.hexpat) | Shockwave Flash file format |
| TAR | `application/x-tar` | [`patterns/tar.hexpat`](patterns/tar.hexpat) | Tar file format |
| TES | | [`patterns/wintec_tes.hexpat`](patterns/wintec_tes.hexpat) | Wintec TES GPS log |
| TIFF | `image/tiff` | [`patterns/tiff.hexpat`](patterns/tiff.hexpat) | Tag Image File Format |
@@ -152,6 +156,7 @@ Everything will immediately show up in ImHex's Content Store and gets bundled wi
| UF2 | | [`patterns/uf2.hexpat`](patterns/uf2.hexpat) | [USB Flashing Format](https://github.com/microsoft/uf2) |
| VBMeta | | [`patterns/vbmeta.hexpat`](patterns/vbmeta.hexpat) | Android VBMeta image |
| VDF | | [`patterns/vdf.hexpat`](patterns/vdf.hexpat) | Binary Value Data Format (.vdf) files |
| VEADO | | [`patterns/veado.hexpat`](patterns/veado.hexpat) | veadotube mini avatar file |
| VGM | | [`patterns/vgm.hexpat`](patterns/vgm.hexpat) | VGM (Video Game Music) sound log |
| VHDX | | [`patterns/vhdx.hexpat`](patterns/vhdx.hexpat) | Microsoft Hyper-V Virtual Hard Disk format |
| WAV | `audio/x-wav` | [`patterns/wav.hexpat`](patterns/wav.hexpat) | RIFF header, WAVE header, PCM header |
@@ -162,7 +167,7 @@ Everything will immediately show up in ImHex's Content Store and gets bundled wi
| XCI | | [`patterns/xci.hexpat`](patterns/xci.hexpat) | Nintendo Switch XCI cartridge ROM |
| XGT | | [`patterns/xgt.hexpat`](patterns/xgstexture.hexpat) | Exient XGS Engine Texture |
| Xilinx BIT | | [`patterns/xilinx_bit.hexpat`](patterns/xilinx_bit.hexpat) | Xilinx FPGA Bitstreams |
| Xilinx Bootgen | | [`patterns/xilinx_bootgen.hexpat`](patterns/xilinx_bootgen.hexpat) | Xilinx ZynqMP Boot Images |
| Xilinx Bootgen | `application/x-xilinx-boot-zynqmp` | [`patterns/xilinx_bootgen.hexpat`](patterns/xilinx_bootgen.hexpat) | Xilinx ZynqMP Boot Images |
| ZIP | `application/zip` | [`patterns/zip.hexpat`](patterns/zip.hexpat) | End of Central Directory Header, Central Directory File Headers |
| ZLIB | `application/zlib` | [`patterns/zlib.hexpat`](patterns/zlib.hexpat) | ZLIB compressed data format |
| ZSTD | `application/zstd` | [`patterns/zstd.hexpat`](patterns/zstd.hexpat) | Zstandard compressed data format |
@@ -266,4 +271,4 @@ Everything will immediately show up in ImHex's Content Store and gets bundled wi
| Name | Path | Description |
|------|------|-------------|
| 8051 | [`disassemblers/8051.json`](disassemblers/8051.json) | Intel 8051 Architecture |
| 8051 | [`disassemblers/8051.json`](disassemblers/8051.json) | Intel 8051 Architecture |

View File

@@ -13,7 +13,7 @@ namespace auto hex::type {
@tparam Size size of the string
*/
struct Json<auto Size> {
char __data[Size];
char __data[Size] [[hidden]];
builtin::hex::dec::Json<__data> json [[merge]];
};
@@ -22,7 +22,7 @@ namespace auto hex::type {
@tparam Size size of the data
*/
struct Bson<auto Size> {
u8 __data[Size];
u8 __data[Size] [[hidden]];
builtin::hex::dec::Bson<__data> bson [[merge]];
};
@@ -31,7 +31,7 @@ namespace auto hex::type {
@tparam Size size of the data
*/
struct Cbor<auto Size> {
u8 __data[Size];
u8 __data[Size] [[hidden]];
builtin::hex::dec::Cbor<__data> cbor [[merge]];
};
@@ -40,7 +40,7 @@ namespace auto hex::type {
@tparam Size size of the data
*/
struct Bjdata<auto Size> {
u8 __data[Size];
u8 __data[Size] [[hidden]];
builtin::hex::dec::Bjdata<__data> bjdata [[merge]];
};
@@ -49,7 +49,7 @@ namespace auto hex::type {
@tparam Size size of the data
*/
struct Msgpack<auto Size> {
u8 __data[Size];
u8 __data[Size] [[hidden]];
builtin::hex::dec::Msgpack<__data> msgpack [[merge]];
};
@@ -58,7 +58,7 @@ namespace auto hex::type {
@tparam Size size of the data
*/
struct Ubjson<auto Size> {
u8 __data[Size];
u8 __data[Size] [[hidden]];
builtin::hex::dec::Ubjson<__data> ubjson [[merge]];
};

View File

@@ -52,7 +52,7 @@ namespace auto type {
std::mem::Reinterpreter<u32, float> converter;
converter.from_value = result;
return std::format("{}", converter.to);
return std::format("{}", converter.to_value);
};
}

View File

@@ -30,7 +30,7 @@ namespace auto type {
namespace impl {
fn format_formatted(ref auto formatted) {
return std::format(std::format("{{0:{}}}", formatted.FormatString), formatted.value);
return std::format(formatted.FormatString, formatted.value);
};
fn transform_formatted(ref auto formatted) {
@@ -39,4 +39,4 @@ namespace auto type {
}
}
}

View File

@@ -1,5 +1,6 @@
#pragma author AdventureT
#pragma description Crash Bandicoot - Back in Time (fan game) User created level
#pragma magic [ 43 52 41 53 48 4C 56 4C ] @ 0x00
#pragma history
#pragma 0.3 2024-05-15 Added support for version 0.95
#pragma 0.2 2023-10-29 Added support for version 0.94c

View File

@@ -1,6 +1,6 @@
#pragma author zhoubo
#pragma description AAC ADTSn (Audio Data Transport Stream) Audio
#pragma magic [ FF F? ] @ 0x00
#pragma MIME audio/x-hx-aac-adts
#pragma pattern_limit 0xFFFFFF
// History

View File

@@ -1,6 +1,10 @@
#pragma author WerWolv
#pragma description Nintendo Switch Atmosphère CFW Fatal Error log
#pragma magic [ 41 46 45 30 ] @ 0x00
#pragma magic [ 41 46 45 31 ] @ 0x00
#pragma magic [ 41 46 45 32 ] @ 0x00
#pragma endian little
import std.io;

168
patterns/bcss.hexpat Normal file
View File

@@ -0,0 +1,168 @@
#pragma author ttimasdf
#pragma description BeyondCompare Snapshot (BCSS) file
#pragma magic [42 43 53 53] @ 0x00
#pragma array_limit 4294967295
#pragma pattern_limit 4294967295
import std.io;
import std.mem;
import std.array;
import std.string;
import type.magic;
#ifdef __IMHEX__
import hex.dec;
import hex.core;
#endif
const u8 max_path_size = 1000;
str current_path[max_path_size];
u8 current_path_level = 0;
enum EntryType : u8 {
DIRECTORY = 0x01,
FILE = 0x02,
SYMLINK = 0x03,
// NULL = 0x00,
DIR_END = 0xFF,
};
struct BCSSEntry {
EntryType type;
match (type) {
(EntryType::DIRECTORY) : {
// FileName name;
std::string::SizedString<u8> name;
if (name.size != 0) {
u8 unknown[12];
on_dir_enter(name.data); // std::string::to_string(name)
} else {
// some buggy edge cases
u8 unknown[6];
std::warning(std::format("invalid empty entry current_lvl={} current_pos=0x{:02x}", current_path_level, $));
}
}
(EntryType::FILE) : {
std::string::SizedString<u8> name;
if (name.size != 0) {
u8 unknown[20];
#ifdef __IMHEX__
hex::core::add_virtual_file(get_vfs_path(name), this); // std::string::to_string(name)
#endif
} else {
// some buggy edge cases
u8 unknown[6];
std::warning(std::format("invalid empty entry current_lvl={} current_pos=0x{:02x}", current_path_level, $));
}
//try {
// u8 unknown[20];
//} catch {
// u8 unknown[0];
//}
}
(EntryType::SYMLINK) : {
std::string::SizedString<u8> name;
u8 unknown[23];
std::string::SizedString<u8> target;
#ifdef __IMHEX__
hex::core::add_virtual_file(get_vfs_path(name + " [s]"), this); // std::string::to_string(name)
#endif
}
(EntryType::DIR_END) : {
on_dir_exit();
}
// (EntryType::NULL) : {
// // some buggy edge cases
// u8 unknown[7];
// std::warning(std::format("invalid empty entry current_lvl={} current_pos=0x{:02x}", current_path_level, $));
// }
(_): {
std::error(std::format("unknown EntryType idx={} current_pos=0x{:02x}", std::core::array_index(), $));
}
}
}[[format_read("fmt_BCSSEntry")]];
fn on_dir_enter(str folder_name) {
// std::print("on_dir_enter folder={} current_lvl={}", folder_name, current_path_level);
if (std::string::length(folder_name) > 0) {
current_path[current_path_level] = folder_name;
current_path_level += 1;
} else {
std::warning(std::format("invalid folder name {} current_lvl={} current_pos=0x{:02x}", folder_name, current_path_level, $));
}
};
fn on_dir_exit() {
if (current_path_level > 0) {
current_path_level -= 1;
} else if (!std::mem::eof()) {
std::warning(std::format("on_dir_exit current_lvl already == 0 current_pos=0x{:02x}", $));
}
// std::print("on_dir_exit current_lvl={}", current_path_level);
};
fn get_vfs_path(str file_name) {
str vfs_path = "";
if (current_path_level > 0) {
vfs_path = current_path[0];
for(u8 i = 1, i < current_path_level, i += 1) {
//hash_hex = hash_hex + std::format("{:02X}",bytes[i]);
vfs_path = vfs_path + "/" + current_path[i];
}
return vfs_path + "/" + file_name;
} else {
return file_name;
}
};
fn fmt_BCSSEntry(BCSSEntry e) {
try {
match (e.type) {
(EntryType::DIRECTORY | EntryType::FILE) : {
return std::format("{}: {}", (e.type == EntryType::DIRECTORY ? "Dir" : "File"), e.name.data);
}
(EntryType::SYMLINK) : {
return std::format("Symlink: {} -> {}", e.name.data, e.target.data);
}
(EntryType::DIR_END) : {
return "Directory End";
}
}
} catch {
return "[FmtErr]";
}
};
struct BCSSFile {
if (std::mem::read_unsigned(0, 4) == 0x53534342) {
type::Magic<"BCSS"> magic;
u8 unknown[14];
std::string::SizedString<u16> root_path;
u8 zlib_content[std::mem::size()-$];
// manually add zlib header which is essential for hex::dec::zlib_decompress
const str zlib_header = "\x78\x9c";
std::mem::Section zlib_compressed = std::mem::create_section("zlib_compressed");
std::mem::copy_value_to_section(zlib_header, zlib_compressed, 0);
std::mem::copy_value_to_section(zlib_content, zlib_compressed, 2);
u8 zlib[std::mem::get_section_size(zlib_compressed)] @ 0x00 in zlib_compressed;
#ifdef __IMHEX__
std::mem::Section zlib_decompressed = std::mem::create_section("zlib_decompressed");
hex::dec::zlib_decompress(zlib, zlib_decompressed, 15);
u8 decompressed_content[std::mem::get_section_size(zlib_decompressed)] @ 0x00 in zlib_decompressed;
hex::core::add_virtual_file("bcss_content", decompressed_content);
std::warning("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n! BCSS file content is compressed !\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\nopen `bcss_content` file from the Virtual Filesystem tab and run this pattern on it.");
#endif
} else {
BCSSEntry entries[while(!std::mem::eof())];
}
};
BCSSFile bcss_file @ 0x00;

View File

@@ -1,80 +1,101 @@
#pragma author Shadlock0133 (aka Aurora)
#pragma author Shadlock0133 (aka Aurora) / WerWolv
#pragma description Prusa Binary G-Code
#pragma magic [ 47 43 44 45 ] @ 0x00
import type.magic;
import std.mem;
enum ChecksumType : u16 {
None,
CRC32,
None = 0,
CRC32 = 1
};
enum BlockType : u16 {
FileMetadata,
GCode,
SlicerMetadata,
PrinterMetadata,
PrintMetadata,
Thumbnail,
FileMetadata = 0,
GCode = 1,
SlicerMetadata = 2,
PrinterMetadata = 3,
PrintMetadata = 4,
Thumbnail = 5
};
enum Compression : u16 {
None,
Deflate,
Heatshrink11_4,
Heatshrink12_4,
enum CompressionType : u16 {
NoCompression = 0,
Deflate = 1,
HeatshrinkWindowSize11 = 2,
HeatshrinkWindowSize12 = 3
};
struct BlockHeader {
BlockType type;
CompressionType compressionType;
u32 uncompressedSize;
if (compressionType != CompressionType::NoCompression) {
u32 compressedSize;
}
u32 dataSize = compressionType == CompressionType::NoCompression ? uncompressedSize : compressedSize;
};
enum Encoding : u16 {
Ini,
INI = 0
};
struct Metadata {
Encoding encoding;
char data[parent.header.dataSize];
};
enum ImageFormat : u16 {
Png,
Jpg,
Qoi,
PNG = 0,
JPG = 1,
QOI = 2
};
struct Header {
type::Magic<"GCDE"> magic;
u32 version;
ChecksumType checksum_type;
struct Thumbnail {
ImageFormat format;
u16 width, height;
std::mem::Bytes<parent.header.dataSize> imageData;
} [[hex::visualize("image", imageData)]];
enum GCodeEncoding : u16 {
NoEncoding = 0,
MeatPack = 1,
MeatPackWithComments = 2
};
Header header @ 0;
std::assert(header.version == 1, "only version 1 supported");
struct GCode {
GCodeEncoding encoding;
std::mem::Bytes<parent.header.dataSize> gcode;
};
struct Block {
BlockType type;
Compression compression;
u32 uncompressed_size;
auto size = uncompressed_size;
if (compression != Compression::None) {
u32 compressed_size;
size = compressed_size;
}
match (type) {
(BlockType::FileMetadata
| BlockType::PrinterMetadata
| BlockType::PrintMetadata
| BlockType::SlicerMetadata): {
Encoding encoding;
}
(BlockType::Thumbnail): {
ImageFormat image_format;
u16 width;
u16 height;
}
(BlockType::GCode): {
u16;
}
(_): { std::assert(false, "unknown type"); }
}
u8 data[size];
match (header.checksum_type) {
(ChecksumType::None): {}
(ChecksumType::CRC32): { u32 checksum; }
BlockHeader header;
match (header.type) {
(BlockType::FileMetadata): Metadata fileMetadata;
(BlockType::PrinterMetadata): Metadata printerMetadata;
(BlockType::Thumbnail): Thumbnail thumbnail;
(BlockType::PrintMetadata): Metadata printMetadata;
(BlockType::SlicerMetadata): Metadata slicerMetadata;
(BlockType::GCode): GCode gcode;
(_): std::error("Invalid Block type!");
}
if (parent.checksumType != ChecksumType::None)
u32 checksum;
};
Block blocks[while(!std::mem::eof())] @ $;
struct BGCode {
type::Magic<"GCDE"> magic;
u32 version;
std::assert(version == 1, "Only Version 1 is supported");
ChecksumType checksumType;
Block blocks[while(!std::mem::eof())];
};
BGCode bgcode @ 0x00;

View File

@@ -1,4 +1,5 @@
#pragma description Apple binary property list
#pragma MIME application/x-bplist
import std.math;
import std.core;

110
patterns/cab.hexpat Normal file
View File

@@ -0,0 +1,110 @@
#pragma author The Wandering Trader
#pragma description Microsoft Cabinet (CAB) Files
#pragma magic [4D 53 43 46] @ 0x00
import type.time;
import type.magic;
import type.size;
fn format_string(auto string) {
return std::format("{}",string);
};
bitfield flags {
bool cfhdrPREV_CABINET : 1;
bool cfhdrNEXT_CABINET : 1;
bool cfhdrRESERVE_PRESENT : 1;
padding : 13;
};
struct CFHEADER {
type::Magic<"MSCF"> signature;
u32 reserved1;
type::Size32 cbCabinet;
u32 reserved2;
u32 coffFiles;
u32 reserved3;
u8 versionMajor;
u8 versionMinor;
u16 cFolders;
u16 cFiles;
flags flags;
u16 setID;
u16 iCabinet;
if (flags.cfhdrRESERVE_PRESENT) {
type::Size16 cbCFHeader;
type::Size8 cbCFFolder;
type::Size8 cbCFData;
u8 abReserve[cbCFHeader];
}
if (flags.cfhdrPREV_CABINET) {
char szCabinetPrev[] [[format("format_string")]];
char szDiskPrev[] [[format("format_string")]];
}
if (flags.cfhdrNEXT_CABINET) {
char szCabinetNext[] [[format("format_string")]];
char szDiskNext[] [[format("format_string")]];
}
};
enum typeCompress : u8{
tcompMASK_TYPE = 0x000F,
tcompTYPE_NONE = 0x0000,
tcompTYPE_MSZIP = 0x0001,
tcompTYPE_QUANTUM = 0x0002,
tcompTYPE_LZX = 0x0003,
};
using CFDATA;
struct CFFOLDER {
u32 coffCabStart;
u16 cCfData;
typeCompress typeCompress;
u8 compressionLevel;
if (CFHEADER.flags.cfhdrRESERVE_PRESENT) {
u8 abReserve[CFHEADER.cbCFFolder];
}
CFDATA CFDATA[cCfData] @ coffCabStart;
};
bitfield attribs {
bool _A_RDONLY : 1;
bool _A_HIDDEN : 1;
bool _A_SYSTEM : 1;
padding : 2;
bool _A_ARCH : 1;
bool _A_EXEC : 1;
bool _A_NAME_IS_UTF : 1;
padding : 8;
};
struct CFFILE {
type::Size32 cbFile;
u32 uoffFolderStart;
u16 iFolder;
type::DOSDate date;
type::DOSTime time;
attribs attribs;
if (attribs._A_NAME_IS_UTF) {
char16 szName[];
} else {
char szName[] [[format("format_string")]];
}
};
struct CFDATA {
u32 csum;
type::Size16 cbData;
type::Size16 cbUncomp;
if (CFHEADER.flags.cfhdrRESERVE_PRESENT) {
u8 abReserve[CFHEADER.cbCFData];
}
u8 ab[cbData];
};
CFHEADER CFHEADER @ 0;
CFFOLDER CFFOLDER[CFHEADER.cFolders] @ $;
CFFILE CFFILE[CFHEADER.cFiles] @ $;

View File

@@ -1,29 +1,29 @@
#pragma description Compact Disc Audio track
#pragma magic [ 52 49 46 46 ] @ 0x00
struct Header {
u32 RIFF;
s32 size;
u32 CDDA;
u32 fmt;
u32 lenghtofthechunck;
u16 versionofcdformat;
u16 numberofrange;
u32 identifier;
u32 RIFF;
s32 size;
u32 CDDA;
u32 fmt;
u32 lenghtofthechunck;
u16 versionofcdformat;
u16 numberofrange;
u32 identifier;
};
struct DataInfo {
u32 range;
u32 duration;
u8 rangepositionframes;
u8 rangepositionseconds;
u8 rangepositionminutes;
u8 nullbyte;
u8 durationtrackframes;
u8 durationtrackseconds;
u8 durationtrackminutes;
u8 nullbytee;
u32 range;
u32 duration;
u8 rangepositionframes;
u8 rangepositionseconds;
u8 rangepositionminutes;
u8 nullbyte;
u8 durationtrackframes;
u8 durationtrackseconds;
u8 durationtrackminutes;
u8 nullbytee;
};

View File

@@ -1,5 +1,6 @@
#pragma author WerWolv
#pragma description Windows HtmlHelp Data (ITSF / CHM)
#pragma MIME application/vnd.ms-htmlhelp
import type.magic;
import type.size;

View File

@@ -1,4 +1,5 @@
#pragma description Dalvik EXecutable
#pragma magic [ 64 65 78 0A ?? ?? ?? 00 ]
import type.leb128;

View File

@@ -1,4 +1,5 @@
#pragma description Apple Disk Image Trailer (DMG)
#pragma magic [ 6B 6F 6C 79 ] @ -512
#pragma endian big

View File

@@ -1,4 +1,4 @@
#pragma magic [50 41 47 45] // PAGE
#pragma magic [ 50 41 47 45 ] @ 0x00 // PAGE
#pragma author "5h4rrK"
#pragma description "KERNEL DUMP"
@@ -99,4 +99,4 @@ struct DUMP_HEADER64 {
};
DUMP_HEADER64 dmp @0x00 [[name("DumpHeader")]];
DUMP_HEADER64 dmp @ 0x00 [[name("DumpHeader")]];

View File

@@ -1,4 +1,5 @@
#pragma description macOS .DS_Store
#pragma magic [ 42 75 64 31 ] @ 0x04
// Apple macOS .DS_Store format
#pragma endian big

View File

@@ -1,6 +1,8 @@
#pragma description Digital Terrain Elevation Data
#pragma endian big
#pragma magic [ 4C 48 55 ] @ 0x00
import std.core;
import std.io;
import std.mem;

View File

@@ -1,5 +1,5 @@
#pragma description MS Windows Vista Event Log
#pragma MIME application/x-ms-evtx
#pragma endian little
struct Header {

View File

@@ -1,5 +1,6 @@
#pragma author WerWolv
#pragma description Flat Linux Device Tree blob
#pragma magic [ D0 0D FE ED ] @ 0x00
#pragma endian big

View File

@@ -1,5 +1,6 @@
#pragma author WerWolv
#pragma description Free Lossless Audio Codec, FLAC Audio Format
#pragma MIME audio/flac
import std.sys;
import std.core;

View File

@@ -1,5 +1,6 @@
#pragma author WerWolv
#pragma description Drive File System
#pragma MIME application/x-ima
import std.io;
import std.core;

View File

@@ -3,6 +3,7 @@
#pragma description ggml GGUF v3
#pragma authors @leonjza, jessie @ imhex discord
#pragma magic [ 47 47 55 46 ] @ 0x00
#pragma pattern_limit 300000

View File

@@ -1,5 +1,6 @@
#pragma author Surasia
#pragma description Halo Infinite HavokScript 5.1 "luas"
#pragma magic [ 75 63 73 68 ] @ 0x00
import std.io;
import std.mem;

View File

@@ -1,7 +1,8 @@
#pragma author Surasia
#pragma description Halo Infinite Module
#pragma array_limit 4294967295
#pragma pattern_limit 4294967295
#pragma array_limit 0
#pragma pattern_limit 0
#pragma magic [ 6D 6F 68 64 ] @ 0x00
import std.string;

View File

@@ -1,5 +1,6 @@
#pragma author Surasia
#pragma description Halo Infinite Tag
#pragma magic [ 75 63 73 68 ] @ 0x00
import std.string;
import type.guid;

View File

@@ -2,9 +2,11 @@
#pragma author xtex
#pragma description HiSilicon HSDT device-tree table
#pragma endian little
#pragma magic [ 48 53 44 54 ] @ 0x00
import std.sys;
import std.mem;
#pragma endian little
u32 dt_hdr_offset;
if (std::mem::read_unsigned(4096, 4, std::mem::Endian::Little) == 0x54445348) {

View File

@@ -7,6 +7,7 @@
* values
*/
#pragma endian big
#pragma MIME text/x-hex
import std.mem;

View File

@@ -1,5 +1,6 @@
#pragma author gmestanley
#pragma description IPS (International Patching System)
#pragma magic [ 50 41 54 43 48 ] @ 0x00
#pragma endian big

View File

@@ -1,8 +1,10 @@
#pragma description ISO 9660 file system
#pragma MIME application/x-iso9660-image
#pragma endian little
import std.io;
import std.mem;
enum VolumeDescriptorTypes : u8 {
BootRecord,
@@ -95,6 +97,19 @@ struct DirectoryRecord {
u8 fileNameLen;
char fileName[fileNameLen];
padding[$ % 2];
u8 remainingSize = $ - addressof(this);
if (recordSize > remainingSize) {
u8 systemUse[recordSize - remainingSize];
}
};
fn GetSupplementaryEncoding() {
const u128 escapeSequencesOffset = 89 - 8;
str encoding = std::mem::read_string($ + escapeSequencesOffset, 0x20);
return encoding == "%/@\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
|| encoding == "%/C\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
|| encoding == "%/E\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0";
};
struct VolumeDescriptor {
@@ -127,8 +142,37 @@ struct VolumeDescriptor {
StrDateFormat expirationTime[[format("FormatStrDate")]];
StrDateFormat effectiveTime[[format("FormatStrDate")]];
u8 fileStructVersion;
padding[0x200 + 0x28E];
} else if (type == VolumeDescriptorTypes::SupplementaryVolume && GetSupplementaryEncoding()) {
u8 flags;
be char16 systemId[0x10];
be char16 volumeId[0x10];
padding[8];
di32 spaceSize;
u8 escapeSequences[0x20];
di16 setSize;
di16 sequenceNumber;
di16 logicalBlockSize;
di32 pathTableSize;
PathTablePtr pathTableOffset;
DirectoryRecord rootDir;
be char16 setId[0x40];
be char16 publisherId[0x40];
be char16 preparerId[0x40];
be char16 applicationId[0x40];
be char16 copyrightFileId[0x12];
padding[1];
be char16 abstractFileId[0x12];
padding[1];
be char16 bibliographicFileId[0x12];
padding[1];
StrDateFormat creationTime[[format("FormatStrDate")]];
StrDateFormat modificationTime[[format("FormatStrDate")]];
StrDateFormat expirationTime[[format("FormatStrDate")]];
StrDateFormat effectiveTime[[format("FormatStrDate")]];
u8 fileStructVersion;
}
padding[0x800 - $ % 0x800];
};
VolumeDescriptor data @ 0x8000;
VolumeDescriptor descriptors[while(std::mem::read_unsigned($, 1) != 0xFF)] @ 0x8000;
VolumeDescriptor terminator @ $;

View File

@@ -2,8 +2,8 @@
#pragma description Minecraft LCE LOC file
#pragma endian big
#pragma array_limit 739845729834
#pragma pattern_limit 34893726894
#pragma array_limit 0
#pragma pattern_limit 0
import std.string;

View File

@@ -1,4 +1,5 @@
#pragma description Lua 5.1 bytecode
#pragma magic [ 1B 4C 75 61 51 ] @ 0x00
import std.io;

View File

@@ -1,4 +1,5 @@
#pragma description Lua 5.2 bytecode
#pragma magic [ 1B 4C 75 61 52 ] @ 0x00
import std.io;
import std.mem;

View File

@@ -1,4 +1,5 @@
#pragma description Lua 5.3 bytecode
#pragma magic [ 1B 4C 75 61 53 ] @ 0x00
import std.io;
import type.base;

View File

@@ -1,4 +1,5 @@
#pragma description Lua 5.4 bytecode
#pragma magic [ 1B 4C 75 61 54 ] @ 0x00
import std.io;
import std.mem;

View File

@@ -3,8 +3,8 @@
import std.sys;
import std.mem;
#pragma array_limit 12544
#pragma pattern_limit 2000000
#pragma array_limit 0
#pragma pattern_limit 0
#pragma eval_depth 32
enum FileType : u8

View File

@@ -2,8 +2,8 @@
#pragma description MSSCMP (Miles Sound System Compressed Archive)
#pragma magic [ 42 41 4E 4B ] @ 0x00
#pragma magic [ 4B 4E 41 42 ] @ 0x00
#pragma array_limit 4294967295
#pragma pattern_limit 4294967295
#pragma array_limit 0
#pragma pattern_limit 0
import type.magic;
import std.core;

View File

@@ -1,4 +1,5 @@
#pragma description Microsoft DOS NE executable
#pragma MIME application/x-ms-ne-executable
import std.mem;

View File

@@ -1,5 +1,6 @@
#pragma author gmestanley
#pragma description Nintendo Entertainment System ROM (.nes)
#pragma MIME application/x-nes-rom
import std.mem;
import std.string;

View File

@@ -1,5 +1,6 @@
#pragma author sethhall
#pragma description Windows Notepad Cache Files
#pragma magic [ 4E 50 00 ] @ 0x00
// This was written based on the following blog post:
// https://u0041.co/posts/articals/exploring-windows-artifacts-notepad-files/

View File

@@ -1,5 +1,6 @@
#pragma author ogmini https://github.com/ogmini
#pragma description Windows 11 Notepad Window State file
#pragma magic [ 4E 50 ] @ 0x00
// File found at %localappdata%/Packages/Microsoft.WindowsNotepad_8wekyb3d8bbwe/LocalState/WindowState
#include <std/string.pat>

View File

@@ -1,5 +1,6 @@
#pragma author WerWolv
#pragma description Nintendo Switch NRO
#pragma magic [ 4E 52 4F 30 ] @ 0x10
import std.io;
import std.sys;

View File

@@ -8,6 +8,7 @@
#pragma author Nicolás Alvarez
#pragma description Apple pbz
#pragma magic [ 70 62 7A ] @ 0x00
import std.mem;
import type.magic;

View File

@@ -1,5 +1,6 @@
#pragma author WerWolv
#pragma description Nintendo Switch PFS0 archive (.nsp)
#pragma magic [ 50 46 53 30 ] @ 0x00
import type.magic;
import type.size;

View File

@@ -1,6 +1,7 @@
#pragma author applecuckoo
#pragma description PKM (PacKMan) files containing ETC (Ericsson Texture Compression)
#pragma endian big
#pragma magic [ 50 4B 4D 20 ] @ 0x00
enum PKMFormat : u16 {
ETC1_RGB_NO_MIPMAPS,

View File

@@ -1,5 +1,6 @@
#pragma author WerWolv
#pragma description Nintendo Switch PRODINFO
#pragma magic [ 43 41 4C 30 ] @ 0x00
enum Model : u16 {
NX = 1

View File

@@ -8,73 +8,70 @@ import std.mem;
import type.leb128;
struct ZigZag32 {
u32 value;
u32 value;
} [[sealed, format("format_zigzag32")]];
fn format_zigzag32(ZigZag32 zigzag) {
return s32((s32(zigzag.value) << 1) ^ (s32(zigzag.value) >> 31));
return s32((s32(zigzag.value) << 1) ^ (s32(zigzag.value) >> 31));
};
struct ZigZag64 {
u64 value;
u64 value;
} [[sealed, format("format_zigzag64")]];
fn format_zigzag64(ZigZag64 zigzag) {
return s64((s64(zigzag.value) << 1) ^ (s64(zigzag.value) >> 63));
return s64((s64(zigzag.value) << 1) ^ (s64(zigzag.value) >> 63));
};
enum WireType : u8 {
Varint = 0,
_64Bit = 1,
LengthDelimited = 2,
StartGroup = 3,
EndGroup = 4,
_32Bit = 5
Varint = 0,
_64Bit = 1,
LengthDelimited = 2,
StartGroup = 3,
EndGroup = 4,
_32Bit = 5
};
WireType wire_type;
u32 tag;
u32 field_number;
struct Key {
type::uLEB128 keyDec;
field_number = u32(keyDec) >> 3;
wire_type = u32(keyDec) & 7;
u32 field_number = u32(keyDec) >> 3;
WireType wire_type = u32(keyDec) & 7;
}[[sealed, format("format_key")]];
fn format_key(Key keyObject) {
return std::format("{} with field number {}", wire_type, field_number);
return std::format("{} with field number {}", keyObject.wire_type, keyObject.field_number);
};
union _64Bit {
u64 fixed64;
ZigZag64 sfixed64;
double dbl;
u64 fixed64;
ZigZag64 sfixed64;
double dbl;
};
union _32Bit {
u32 fixed32;
ZigZag32 sfixed32;
float flt;
u32 fixed32;
ZigZag32 sfixed32;
float flt;
};
struct LengthDelimited {
type::uLEB128 length;
char data[length];
type::uLEB128 length;
char data[length];
};
struct Entry {
Key key;
if (wire_type == WireType::Varint)
type::uLEB128 value;
else if (wire_type == WireType::_64Bit)
_64Bit value;
else if (wire_type == WireType::LengthDelimited)
LengthDelimited value;
else if (wire_type == WireType::_32Bit)
_32Bit value;
if (key.wire_type == WireType::Varint)
type::uLEB128 value;
else if (key.wire_type == WireType::_64Bit)
_64Bit value;
else if (key.wire_type == WireType::LengthDelimited)
LengthDelimited value;
else if (key.wire_type == WireType::_32Bit)
_32Bit value;
};
Entry entries[while(!std::mem::eof())] @ 0x00;

View File

@@ -3,6 +3,7 @@
#pragma endian little
#pragma description Password Safe V3
#pragma magic [ 50 57 53 33 ] @ 0x00
import std.mem;
import std.sys;

View File

@@ -1,4 +1,5 @@
#pragma description Python bytecode
#pragma MIME application/x-bytecode.python
import type.time;
import std.mem;

View File

@@ -2,9 +2,11 @@
#pragma author Ange Albertini
import std.sys;
#pragma pattern_limit 13107200
#pragma array_limit 13107200
#pragma pattern_limit 0
#pragma array_limit 0
#pragma endian little
#pragma magic [ 8C FF 7C F9 ] @ 0x00
#pragma magic [ 8D FF 7C F9 ] @ 0x00
u32 version;
u32 symbols_count;

View File

@@ -4,6 +4,7 @@
// Extension: PP
// https://github.com/SELinuxProject/selinux/blob/master/libsepol/src/module.c
#pragma magic [ 8F FF 7C F9 ] @ 0x00
#pragma endian little
import std.sys;

View File

@@ -1,5 +1,6 @@
#pragma author Calcoph
#pragma description ESRI shapefile
#pragma magic [ 00 00 27 0A ] @ 0x00
// Spec:
// https://www.esri.com/content/dam/esrisites/sitecore-archive/Files/Pdfs/library/whitepapers/pdfs/shapefile.pdf

View File

@@ -1,5 +1,6 @@
#pragma author Calcoph
#pragma description ESRI shapefile indices
#pragma magic [ 00 00 27 0A ] @ 0x00
// Spec:
// https://www.esri.com/content/dam/esrisites/sitecore-archive/Files/Pdfs/library/whitepapers/pdfs/shapefile.pdf

95
patterns/sqlite3.hexpat Normal file
View File

@@ -0,0 +1,95 @@
#pragma description SQLite 3 database
#pragma author WerWolv
#pragma MIME application/vnd.sqlite3
import type.magic;
enum FileFormatVersion : u8 {
Legacy = 1,
WAL = 2
};
enum TextEncoding : u32 {
UTF8 = 1,
UTF16LE = 2,
UTF16BE = 3
};
struct SQLiteVersion {
u32 rawValue;
u8 major = (rawValue / 1000000) % 1000 [[export]];
u8 minor = (rawValue / 1000) % 1000 [[export]];
u8 patch = (rawValue / 1) % 1000 [[export]];
} [[sealed, format("format_sqlite_version")]];
fn format_sqlite_version(ref auto version) {
return std::format("v{}.{}.{} [{}]", version.major, version.minor, version.patch, version.rawValue);
};
u16 globalPageSize = 0;
enum PageType : u8 {
InteriorIndexBTreePage = 0x02,
InteriorTableBTreePage = 0x05,
LeafIndexBTreePage = 0x0A,
LeafTableBTreePage = 0x0D
};
struct Page {
PageType pageType;
u16 freeBlockStart;
u16 numCells;
u16 cellContentAreaStart;
u8 fragmentedFreeBytesCount;
if (pageType == PageType::InteriorIndexBTreePage || pageType == PageType::InteriorTableBTreePage)
u32 rightMostPointer;
} [[fixed_size(le u16(globalPageSize))]];
struct DatabaseHeader {
type::Magic<"SQLite format 3\x00"> magic;
u16 pageSizeValue;
u16 pageSize = pageSizeValue == 1 ? 65536 : le u16(pageSizeValue) [[export]];
globalPageSize = pageSize;
FileFormatVersion readVersion, writeVersion;
padding[1];
u8 maxEmbeddedPayloadFraction;
if (maxEmbeddedPayloadFraction != 64)
std::warning("Unexpected Max Embedded Payload Fraction");
u8 minEmbeddedPayloadFraction;
if (minEmbeddedPayloadFraction != 32)
std::warning("Unexpected Min Embedded Payload Fraction");
u8 leafPayloadFraction;
if (leafPayloadFraction != 32)
std::warning("Unexpected Leaf Payload Fraction");
u32 fileChangeCounter;
u32 totalPageCount;
u32 freelistTrunkPageNumber;
u32 totalFreeListPageCount;
u32 schemaCookie;
u32 schemaFormatNumber;
u32 defaultPageCacheSize;
u32 largestRootBTreePage;
TextEncoding textEncoding;
u32 userVersion;
u32 incrementalVacuumMode;
u32 applicationId;
padding[20];
u32 versionValidForNumber;
SQLiteVersion sqliteVersionNumber;
};
struct SQLite3 {
be DatabaseHeader header;
be Page pages[le u16(header.totalPageCount) - 1] @ le u16(header.pageSize);
};
SQLite3 sqlite3 @ 0x00;

119
patterns/sup.hexpat Normal file
View File

@@ -0,0 +1,119 @@
#pragma description SUP Bluray Subtitle
#pragma magic [ 50 47 ] @ 0x00
#pragma endian big
import std.mem;
enum SegmentType : u8{
PaletteDefinitionSegment=0x14,
ObjectDefinitionSegment=0x15,
PresentationCompositionSegment=0x16,
WindowDefinitionSegment=0x17,
END=0x80
};
enum CompositionState : u8 {
Normal=0x00,
AcquisitionPoint=0x40,
EpochStart=0x80
};
enum PaletteUpdateFlag : u8 {
False=0x00,
True=0x80
};
enum ObjectCroppedFlag : u8{
True=0x40,
False=0x00
};
struct CompositionObject{
u16 objectID;
u8 windowID;
ObjectCroppedFlag objectCroppedFlag;
u16 objectHorizontalPosition;
u16 objectVerticalPosition;
if (objectCroppedFlag == ObjectCroppedFlag::True){
u16 objectCroppingHorizontalPosition;
u16 objectCroppingVerticalPosition;
u16 objectCroppingWidth;
u16 objectCroppingHeight;
}
};
struct PresentationCompositionSegment{
u16 width;
u16 height;
u8 framerate;
u16 compositionNumber;
CompositionState compositionState;
PaletteUpdateFlag paletteUpdateFlag;
u8 paletteID;
u8 numberOfCompositionObjects;
CompositionObject compositionObject[numberOfCompositionObjects];
};
struct WindowDefinitionSegment{
u8 numberOfWindows;
u8 windowID;
u16 windowHorizontalPosition;
u16 windowVerticalPosition;
u16 windowWidth;
u16 windowHeight;
};
fn paletteCount(){
u64 len = (parent.parent.header.segmentSize-7)/5+1;
return len;
};
struct PaletteEntry{
u8 paletteEntryID;
u8 luminance;
u8 colorDifferenceRed [[color("FF0000")]];
u8 colorDifferenceBlue [[color("0000FF")]];
u8 Transparency;
};
struct PaletteDefinitionSegment{
u8 paletteID;
u8 paletteVersionNumber;
PaletteEntry paletteEntry[paletteCount()];
};
enum LastInSequenceFlag : u8{
LastInSequence=0x40,
FirstInSequence=0x80,
FirstAndLastsInSequence=0xC0
};
struct ObjectDefinitionSegment{
u16 objectID;
u8 objectVersionNumber;
LastInSequenceFlag lastInSequenceFlag;
u24 objectDataLength;
//u16 width;
//u16 height;
u8 objectData[objectDataLength];
};
struct PGSHeader{
char magicNumber[2];
u32 presentationTimeStamp;
u32 decodingTimeStamp;
SegmentType segmentType;
u16 segmentSize;
};
struct PGSSegment{
PGSHeader header;
match(header.segmentType){
(0x14): PaletteDefinitionSegment paletteDefinitionSegment;
(0x15): ObjectDefinitionSegment objectDefinitionSegment;
(0x16): PresentationCompositionSegment presentationCompositionSegment;
(0x17): WindowDefinitionSegment windowDefinitionSegment;
}
};
PGSSegment pgsSegment[while(!std::mem::eof())] @ 0;

View File

@@ -1,8 +1,9 @@
#pragma author saturnaliam
#pragma description Shockwave Flash Movie (SWF)
#pragma endian little
import type.magic;
#pragma MIME application/x-shockwave-flash
import type.magic;
// RECTs are more complicated, but for the header,
// this works fine.

View File

@@ -1,6 +1,7 @@
#pragma description Ubiquiti Firmware (update) image
#pragma endian big
#pragma magic [ 55 42 4E 54 ] @ 0x00
import std.mem;
import std.sys;

View File

@@ -1,4 +1,5 @@
#pragma description Android VBMeta image
#pragma magic [ 41 56 42 30 ] @ 0x00
#pragma endian big
import std.core;

183
patterns/veado.hexpat Normal file
View File

@@ -0,0 +1,183 @@
#pragma author bake
#pragma description Veadotube Mini Avatar File
#pragma magic [ 56 45 41 44 4F 54 55 42 45 ] @ 0x00
import std.mem;
import std.io;
struct varint {
u8 value;
};
struct String {
varint length;
char string[length.value];
};
struct Header {
char magic[9];
};
struct Meta {
String software;
String credits;
String description;
};
enum EffectFlag : u8 {
Active = 0x1,
UsePreset = 0x2,
UsePresetChunk = 0x4,
};
struct Effect {
String effect_id;
EffectFlag flag;
if (u8(flag) & EffectFlag::UsePresetChunk) {
u32 chunk_id;
}
if (u8(flag) & EffectFlag::UsePreset) {
String preset_id;
}
varint num_values;
double values[num_values.value];
};
struct Effects {
varint num_effects;
Effect effects[num_effects.value];
};
enum StateFlag : u32 {
Pixelated = 0x1,
Blink = 0x2,
Start = 0x4,
};
struct Signal {
String source;
String name;
};
enum ShortcutMode : char {
Press = "PRES",
Release = "RLSE",
WhilePressed = "PRED",
};
struct Msta {
String name;
StateFlag state;
u32 thumbnail_closed_mouth;
u32 thumbnail_open_mouth;
u32 thumbnail_blinking_closed_mouth;
u32 thumbnail_blinking_open_mouth;
u32 closed_mouth;
u32 open_mouth;
u32 blinking_closed_mouth;
u32 blinking_open_mouth;
double blink_duration;
double min_blink_interval;
double max_blink_interval;
Effects closed_mouth_effects;
Effects open_mouth_effects;
Effects on_open_mouth_effects;
Effects on_close_mouth_effects;
varint num_signals;
Signal signals[num_signals.value];
char shortcut_mode[4];
};
struct AsfdMetadata {
char type[4];
varint num_metadata;
u8 metadata[num_metadata.value];
};
struct AsfdEntry {
String entry_name;
u32 chunk_id;
varint num_metadata;
AsfdMetadata metadata[num_metadata.value];
};
struct Asfd {
char root_code[4];
AsfdEntry entries[];
};
struct Thmb {};
struct AimgFrame {
u32 chunk_id;
s32 offset_x;
s32 offset_y;
double duration;
};
struct Aimg {
u32 width;
u32 height;
varint num_frames;
if (num_frames.value > 1) {
varint num_loops;
}
AimgFrame frames[num_frames.value];
};
struct Abmp {
u32 width;
u32 height;
char format[4];
u32 num_as;
u32 num_rs;
u32 num_gs;
u32 num_bs;
if (format == "VDD." && num_as < 0xffffff00) {
u32 _as[num_as];
}
if (format == "VDD." && num_rs < 0xffffff00) {
u32 _rs[num_rs];
}
if (format == "VDD." && num_gs < 0xffffff00) {
u32 _gs[num_gs];
}
if (format == "VDD." && num_bs < 0xffffff00) {
u32 _bs[num_bs];
}
if (format == "RAW.") {
u32 data[];
}
};
struct Chunk {
u32 id;
char type[4];
u32 length;
if (type == "META") {
Meta meta;
} else if (type == "MLST") {
u32 chunk_ids[length / 4];
} else if (type == "MSTA") {
Msta msta;
} else if (type == "ASFD") {
u64 startAddress = $;
Asfd asfd;
AsfdEntry entries[while ($ - startAddress < length)];
} else if (type == "THMB") {
Thmb thmb;
padding[length];
} else if (type == "AIMG") {
Aimg aimg;
} else if (type == "ABMP") {
Abmp abmp;
padding[length - sizeof(abmp)];
} else {
std::print("unknown type {}", type);
padding[length];
break;
}
};
Header header @0x00;
Chunk data[while (!std::mem::eof())] @$;

View File

@@ -1,5 +1,6 @@
#pragma author WerWolv
#pragma description DOOM WAD Archive
#pragma magic [ 50 57 41 44 ] @ 0x00
import type.magic;
import type.size;

View File

@@ -329,7 +329,7 @@ fn relative_to_base(auto pointer) {
};
fn relative_to_base_section(auto pointer) {
return -parent.parent.baseAddress;
return -parent.parent.parent.baseAddress;
};
bitfield LibraryFlags {

View File

@@ -1,5 +1,6 @@
#pragma author WerWolv
#pragma description Nintendo Switch XCI cartridge ROM
#pragma magic [ 48 46 53 30 ] @ 0x00
import std.core;

View File

@@ -1,5 +1,6 @@
#pragma endian little
#pragma description Xilinx Zynq UltraScale+ Boot Image
#pragma MIME application/x-xilinx-boot-zynqmp
#pragma magic [ 58 4E 4C 58 ] @ 0x24
// Spec: Xilinx UG1283 https://docs.xilinx.com/r/en-US/ug1283-bootgen-user-guide/Zynq-UltraScale-MPSoC-Boot-and-Configuration

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.