Git Product home page Git Product logo

werwolv / imhex-patterns Goto Github PK

View Code? Open in Web Editor NEW
625.0 14.0 165.0 17.5 MB

Hex patterns, include patterns and magic files for the use with the ImHex Hex Editor

Home Page: https://github.com/WerWolv/ImHex

License: GNU General Public License v2.0

Python 0.97% Rust 97.81% CMake 0.35% C++ 0.60% YARA 0.28%
hacktoberfest constants data-structures encoding formats imhex magic pattern-language patterns yara

imhex-patterns's Introduction

ImHex Database

This repository serves as a database for files to use with the ImHex Hex Editor. It currently contains

  • Patterns - Binary Format definitions for the Pattern Language
  • Pattern Libraries - Libraries that make using the Pattern Language easier
  • Magic Files - Custom magic file definitions for the use with libmagic
  • Encodings - Custom encodings in the .tbl format
  • Data Processor Nodes - Custom nodes made for ImHex's Data Processor
  • Themes - Custom themes for ImHex
  • Constants - Constants definition files
  • Scripts - Various scripts to generate code or automate some tasks
  • Yara - Custom Yara rules

Submissions

Most files in this repository have been submitted by the community. Please feel free to open a PR on your own and add files to it! Everything will immediately show up in ImHex's Content Store and gets bundled with the next release of ImHex.

Table of Contents

Hex Patterns

Name MIME Path Description
3DS patterns/3ds.hexpat Autodesk 3DS Max Model file
7Z patterns/7z.hexpat 7z File Format
ADTS [patterns/adts.hexpat(patterns/adts.hexpat) ADTS/AAC audio files
AFE2 patterns/afe2.hexpat Nintendo Switch Atmosphère CFW Fatal Error log
ANI application/x-navi-animation patterns/ani.hexpat Windows Animated Cursor file
AR application/x-archive patterns/ar.hexpat Static library archive files
ARIA2 patterns/aria2.hexpat ARIA2 Download Manager Control files
ARM VTOR patterns/arm_cm_vtor.hexpat ARM Cortex M Vector Table Layout
Bastion patterns/bastion/* Various Bastion files
Bencode application/x-bittorrent patterns/bencode.hexpat Bencode encoding, used by Torrent files
Prusa BGCODE patterns/bgcode.hexpat PrusaSlicer Binary G-Code files
BMP image/bmp patterns/bmp.hexpat OS2/Windows Bitmap files
BIN patterns/selinux.hexpat SE Linux modules
BSON application/bson patterns/bson.hexpat BSON (Binary JSON) format
bplist patterns/bplist.hexpat Apple's binary property list format (bplist)
BSP patterns/bsp_goldsrc.hexpat GoldSrc engine maps format (used in Half-Life 1)
CCHVA patterns/cchva.hexpat Command and Conquer Voxel Animation
CCVXL patterns/ccvxl.hexpat Command and Conquer Voxel Model
CCPAL patterns/ccpal.hexpat Command and Conquer Voxel Palette
CDA patterns/cda.hexpat Compact Disc Audio track
CHM patterns/chm.hexpat Windows HtmlHelp Data (ITSF / CHM)
COFF application/x-coff patterns/coff.hexpat Common Object File Format (COFF) executable
CPIO application/x-cpio patterns/cpio.hexpat Old Binary CPIO Format
CrashLvl patterns/Crashlvl.hexpat Crash Bandicoot - Back in Time (fan game) User created level format
DDS image/vnd-ms.dds patterns/dds.hexpat DirectDraw Surface
DEX patterns/dex.hexpat Dalvik EXecutable Format
DICOM application/dicom patterns/dicom.hexpat DICOM image format
DMG patterns/dmg.hexpat Apple Disk Image Trailer (DMG)
DS_Store patterns/dsstore.hexpat .DS_Store file format
DTA patterns/max_v104.hexpat Mechanized Assault and Exploration v1.04 (strategy game) save file format
DTED patterns/dted.hexpat Digital Terrain Elevation Data (DTED)
ELF application/x-executable patterns/elf.hexpat ELF header in elf binaries
EVTX patterns/evtx.hexpat MS Windows Vista Event Log
FAS patterns/fas_oskasoftware.hexpat patterns/fas_oskasoftware_old.hexpat (Old versions of Oska DeskMate) Oska Software DeskMates FAS (Frames and Sequences) file
FBX patterns/fbx.hexpat Kaydara FBX Binary
FDT patterns/fdt.hexpat Flat Linux Device Tree blob
FFX patterns/ffx/* Various Final Fantasy X files
File System patterns/fs.hexpat Drive File System
FLAC audio/flac patterns/flac.hexpat Free Lossless Audio Codec, FLAC Audio Format
Flipper Zero Settings patterns/flipper_settings.hexpat Flipper Zero Settings Files
GB application/x-gameboy-rom patterns/gb.hexpat Gameboy ROM
GGUF patterns/gguf.hexpat GGML Inference Models
GIF image/gif patterns/gif.hexpat GIF image files
GLTF model/gltf-binary patterns/gltf.hexpat GL Transmission Format binary 3D model file
GZIP application/gzip patterns/gzip.hexpat GZip compressed data format
Halo Tag patterns/hinf_tag.hexpat Halo Infinite Tag Files
Halo Module patterns/hinf_module.hexpat Halo Infinite Module Archive Files
Halo HavokScript patterns/hinf_luas.hexpat Halo Infinite HavokScript 5.1 Bytecode
HSDT patterns/hsdt.hexpat HiSilicon device-tree table images
ICO patterns/ico.hexpat Icon (.ico) or Cursor (.cur) files
ID3 audio/mpeg patterns/id3.hexpat ID3 tags in MP3 files
Intel HEX patterns/intel_hex.hexpat Intel hexadecimal object file format definition
IP patterns/ip.hexpat Ethernet II Frames (IP Packets)
IPS patterns/ips.hexpat IPS (International Patching System) files
ISO patterns/iso.hexpat ISO 9660 file system
Java Class application/x-java-applet patterns/java_class.hexpat Java Class files
JPEG image/jpeg patterns/jpeg.hexpat JPEG Image Format
Lua 5.1 patterns/lua51.hexpat Lua 5.1 bytecode
Lua 5.2 patterns/lua52.hexpat Lua 5.2 bytecode
Lua 5.3 patterns/lua53.hexpat Lua 5.3 bytecode
Lua 5.4 patterns/lua54.hexpat Lua 5.4 bytecode
LCE Savefile patterns/lcesave.hexpat Minecraft Legacy Console Edition save file
Mach-O application/x-mach-binary patterns/macho.hexpat Mach-O executable
MIDI audio/midi patterns/midi.hexpat MIDI header, event fields provided
MiniDump application/x-dmp patterns/minidump.hexpat Windows MiniDump files
mp4 video/mp4 patterns/mp4.hexpat MPEG-4 Part 14 digital multimedia container format
msgpack application/x-msgpack patterns/msgpack.hexpat MessagePack binary serialization format
NACP patterns/nacp.hexpat Nintendo Switch NACP files
NBT patterns/nbt.hexpat Minecraft NBT format
NE patterns/ne.hexpat NE header and Standard NE fields
nes patterns/nes.hexpat .nes file format
NotepadWindowState patterns/notepad-windowstate.hexpat Windows 11 Notepad - Window State .bin file
NRO patterns/nro.hexpat Nintendo Switch NRO files
NTAG patterns/ntag.hexpat NTAG213/NTAG215/NTAG216, NFC Forum Type 2 Tag compliant IC
OGG audio/ogg patterns/ogg.hexpat OGG Audio format
PAK patterns/xgspak.hexpat Exient XGS Engine Pak files
PCAP application/vnd.tcpdump.pcap patterns/pcap.hexpat pcap header and packets
PCX application/x-pcx patterns/pcx.hexpat PCX Image format
PE application/x-dosexec application/x-msdownload patterns/pe.hexpat PE header, COFF header, Standard COFF fields and Windows Specific fields
PP patterns/selinuxpp.hexpat SE Linux package
PFS0 patterns/pfs0.hexpat Nintendo Switch PFS0 archive (NSP files)
PIF image/pif patterns/pif.hexpat PIF Image Format
PKM patterns/pkm.hexpat PKM texture format
PNG image/png patterns/png.hexpat PNG image files
PRODINFO patterns/prodinfo.hexpat Nintendo Switch PRODINFO
Protobuf patterns/protobuf.hexpat Google Protobuf encoding
psafe3 patterns/psafe3.hexpat Password Safe V3
PyInstaller patterns/pyinstaller.hexpat PyInstaller binray files
PYC patterns/pyc.hexpat Python bytecode files
QBCL patterns/qbcl.hexpat Qubicle voxel scene project file
QOI image/qoi patterns/qoi.hexpat QOI image files
RAS image/x-sun-raster patterns/ras.hexpat RAS image files
ReFS patterns/refs.hexpat Microsoft Resilient File System
RGBDS patterns/rgbds.hexpat RGBDS object file format
Shell Link application/x-ms-shortcut patterns/lnk.hexpat Windows Shell Link file format
shp patterns/shp.hexpat ESRI shape file
shx patterns/shx.hexpat ESRI index file
SPIRV patterns/spirv.hexpat SPIR-V header and instructions
STL model/stl patterns/stl.hexpat STL 3D Model format
StuffItV5 application/x-stuffit patterns/sit5.hexpat StuffIt V5 archive
SWF patterns/swf.hexpat Shockwave Flash file format
TAR application/x-tar patterns/tar.hexpat Tar file format
TES patterns/wintec_tes.hexpat Wintec TES GPS log
TIFF image/tiff patterns/tiff.hexpat Tag Image File Format
TGA image/tga patterns/tga.hexpat Truevision TGA/TARGA image
TTF font/ttf, font/otf patterns/ttf.hexpat TrueType and OpenType font format
Ubiquiti patterns/ubiquiti.hexpat Ubiquiti Firmware (update) image
UEFI patterns/uefi.hexpat` UEFI structs for parsing efivars
UEFI Boot Entry patterns/uefi_boot_entry.hexpat UEFI Boot Entry (Load option)
UF2 patterns/uf2.hexpat USB Flashing Format
VBMeta patterns/vbmeta.hexpat Android VBMeta image
VDF patterns/vdf.hexpat Binary Value Data Format (.vdf) files
VHDX patterns/vhdx.hexpat Microsoft Hyper-V Virtual Hard Disk format
WAV audio/x-wav patterns/wav.hexpat RIFF header, WAVE header, PCM header
WAS patterns\was_oskasoftware.hexpat Oska Software DeskMates WAS/WA3 (WAVE/MP3 Set) file
WAD patterns/wad.hexpat DOOM WAD Archive
XBEH audio/x-xbox-executable patterns/xbeh.hexpat Xbox executable
XCI patterns/xci.hexpat Nintendo Switch XCI cartridge ROM
XGT patterns/xgt.hexpat Exient XGS Engine Texture
Xilinx BIT patterns/xilinx_bit.hexpat Xilinx FPGA Bitstreams
Xilinx Bootgen patterns/xilinx_bootgen.hexpat Xilinx ZynqMP Boot Images
ZIP application/zip patterns/zip.hexpat End of Central Directory Header, Central Directory File Headers
ZLIB application/zlib patterns/zlib.hexpat ZLIB compressed data format
ZSTD application/zstd patterns/zstd.hexpat Zstandard compressed data format

Scripts

Name Path Description
svd2pat scripts/svd2pat.py Converts a ARM .svd register MMIO definition file into a pattern
csv2tbl scripts/csv2tbl.py Converts a 010 editor CSV encoding file into a table file

Pattern Libraries

Name Path Description
libhex includes/hex/* Functions to interact with ImHex
libstd includes/std/* Pattern Language Standard Library
libtype includes/type/* Various custom types with special formatters

Yara rules

Name Path Description
Official Rules yara/official_rules/* Official Yara rules repository

Magic files

Name Path Description
Nintendo Switch magic/nintendo_switch_magic Identifies common file types used on the Nintendo Switch
Portable Executable magic/portable_executable_magic Identifies PE files used on Windows

Constants files

Name Path Description
CRC-16 constants/crc16.json Constants associated with CRC-16 operations
CRC-32 constants/crc32.json Constants associated with CRC-32 operations
HTTP-Codes constants/http_status.json HTTP Status code values
Linux Error Codes constants/linux_errors.json Values of Linux error results

Encoding files

Name Path Description
Arabic ISO encodings/arabic_iso.tbl Arabic ISO encoding
Arabic Windows encodings/arabic_windows.tbl Arabic Windows encoding
ASCII encodings/ascii.tbl Regular ASCII encoding
ASCII+ANSI encodings/ascii_ansi.tbl Extended ASCII encoding
ASCII+OEM encodings/ascii_oem.tbl ASCII encoding with Windows OEM characters
Baltic ISO encodings/baltic_iso.tbl Baltic ISO encoding
Baltic Windows encodings/baltic_windows.tbl Baltic Windows encoding
Big5 (Traditional Chinese) encodings/big5.tbl Big5 encoding for Traditional Chinese
Cyrillic ISO encodings/cyrillic_iso.tbl Cyrillic ISO encoding
Cyrillic Windows encodings/cyrillic_windows.tbl Cyrillic Windows encoding
Cyrillic KOI8-R encodings/cyrillic_koi8_r.tbl Cyrillic KOI8-R encoding (Russian Characters)
Cyrillic KOI8-U encodings/cyrillic_koi8_u.tbl Cyrillic KOI8-U encoding (Ukranian Characters)
Eastern Europe ISO encodings/eastern_europe_iso.tbl Eastern Europe ISO encoding
Eastern Europe Windows encodings/eastern_europe_windows.tbl Eastern Europe Windows encoding
EBCDIC encodings/ebcdic.tbl Extended Binary Coded Decimal Interchange Code, developed by IBM for their Main Frames
EUC-JP encodings/euc_jp.tbl EUC-JP encoding with NEC special and IBM extended characters
EUC-KR encodings/euc_kr.tbl EUC-KR encoding
Greek ISO encodings/greek_iso.tbl Greek ISO encoding
Greek Windows encodings/greek_windows.tbl Greek Windows encoding
Hebrew ISO encodings/hebrew_iso.tbl Hebrew ISO encoding
Hebrew Windows encodings/hebrew_windows.tbl Hebrew Windows encoding
ISO/IEC 646 encodings/iso_646.tbl ISO/IEC 646 encoding, an older version of ASCII
ISO/IEC 6937 encodings/iso_6937.tbl ISO/IEC 6937 encoding, an extension of ASCII containing additional character
JIS 0201 encodings/jis_x_0201.tbl JIS X 0201 encoding in UTF-8
JIS X 0211 encodings/jis_x_0211.tbl JIS X 0211 encoding in UTF-8
JIS 0213 encodings/jis_x_0213.tbl JIS X 0213 encoding in UTF-8
Macintosh encodings/macintosh.tbl Macintosh character encoding used by the Kermit protocol
Pokémon (English, Generation 1) encodings/pokegen1_en.tbl Character encoding used by the English generation 1 Pokémon games
Pokémon (English, Generation 3) encodings/pokegen3_en.tbl Character encoding used by the English generation 3 Pokémon games
Shift-JIS UTF-8 encodings/shiftjis.tbl Shift-JIS encoding in UTF-8
Thai encodings/thai.tbl Thai character encoding
Turkish ISO encodings/turkish_iso.tbl Turkish ISO encoding
Turkish Windows encodings/turkish_windows.tbl Turkish Windows encoding
UTF-8 encodings/utf8.tbl UTF-8 encoding
Vietnamese encodings/vietnamese.tbl Vietnamese character encoding

Data Processor Nodes

Name Path Description
Caesar Cipher nodes/caesar.hexnode Simple adjustable per-byte Caecar Cipher (ROT)
XOR Cipher nodes/xor.hexnode XORs a input with a repeating XOR pad

Themes

Name Path Description
Visual Studio Dark themes/vs_dark.json Theme similar to Visual Studio's Dark theme
Solarized Dark themes/solarized_dark.json Solarized Dark Theme
Catppuccin Latte themes/catppuccin-latte.json Catppuccin Latte Flavor (Light Theme)
Catppuccin Frappe themes/catppuccin-frappe.json Catppuccin Frappe Flavor (Dark Theme)
Catppuccin Macchiato themes/catppuccin-macchiato.json Catppuccin Macchiato Flavor (Dark Theme)
Catppuccin Mocha themes/catppuccin-mocha.json Catppuccin Mocha Flavor (Dark Theme)

imhex-patterns's People

Contributors

123456abcdef avatar 5h4rrk avatar adventuret avatar angea avatar applecuckoo avatar berylskid avatar bgilbert avatar blondecake433 avatar brliron avatar cryptax avatar ctrlcctrlv avatar dondish avatar evelyntsmg avatar flawwan avatar gmestanley avatar hexadecimaldinosaur avatar itrooz avatar jfsbrito avatar jumanji144 avatar klirktag avatar mandar1jn avatar nicolas17 avatar paxcut avatar predatorcz avatar qux-bbb avatar shimogawa avatar surasia avatar thisalv avatar vikke1234 avatar werwolv avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

imhex-patterns's Issues

Wasm Pattern

Hi i was wondering if there was any pattern made for webassembly?

[Feature] SHIFT+hovering a byte should show the full variable path

If you have defined a bunch of patterns that covers a large portion of the file, hovering the byte in the Hex Editor doesn't really give you a lot of useful information. It will say something like u8 unknown[4], but if unknown4 happens the be part of a struct that's in an array, there is no telling which index I have to look for.

Would be great if SHIFT-hovering shows the full path to the variable.

Using existing pattern for embedded files

Hello, I have a list of offsets with JPEG files. Since we already have a JPEG file pattern is it possible to use it as a type with an include, or am I forced to have to recreate a JPEG type.

It'd be nice if I could do something along the lines of:

#include <jpeg.hexpat>
JPEG myjpeg @ 0x112233;

Some raw types for your elf pattern.

Here's that raw data for your elf pattern that I promised.

First of all, some apologies for not making this into a proper PR as since I don't actually use ImHex I don't have it forked or anything (ui allergies, but I'm still an admirer). Plus, I didn't want to smash up the original elf pattern since I haven't tested this data with your parser. Hence it still being raw.

Also an apology for not doing the conditionals that glue the fields together, or that switch between types based on the values in the headers. As you can imagine that requires parsing logic out of my definitions, and rigging things with Python's ast library would definitely be more time consuming than just a simple type conversion.

In my definitions, I have the header split out, and then based on the header I use either the Elf32 or the Elf64 types.

Some of the bitfields might be wrong because they're in "microsoft-order" which is high-bit first, and it's a little bit clumsy because the byteorder can change based on E_DATA. So those bitfields should be little-endian.

for-werwolv.txt

If there's something you think I can fix, or that would make it easier for you to fit within your syntax, let me know as I can generate these again.

Question about intended repository contents & contribution guidelines

Is this repository for common filetypes only, or are very specific, rarely-used formats also welcome?
I have quite a few of these specific formats, most of them archive, texture and model filetypes. Ones which aren’t (publicly) documented elsewhere.

Aside from that, what are the contribution guidelines? Are incomplete patterns allowed? For formats which aren’t fully understood yet.

Protobuf pattern does not support field numbers > 15

As per Protobuf Documentation, "Tags" (Keys) of Records/Keys are encoded as VarInts / LEB128.

However the current Protobuf pattern assumes Keys are always 1 byte:

} [[bitfield_order(std::core::BitfieldOrder::MostToLeastSignificant, 8)]];

This assumption will not work anymore for larger (>15) field numbers, where the varint will be 2 bytes long:

CodedOutputStream stream = ...;
stream.writeUInt(16, 0);

The output binary will be:

80 01 00

The value byte here is expected to be 0. The current pattern will incorrectly interpret the second byte as the value 1.

typo in flac.hexpat

u32 mimeTypeLength;
char mimeType[mineTypeLength];

typo at "mineTypeLength", should be "mimeTypeLength" instead.

error message when exvaluate flac.hexpat:

error[E0003]: Variable error.
--> :141:19
141 | char mimeType[mineTypeLength];
^
No variable named 'mineTypeLength' found.

Fail on #include [Unknown type]

Freshly downloaded ImHex -> opened an something.so -> File-> Load Pattern -> Open "elf.hexpath". Executed pattern and got an Unknown type on line 7, #include <std/core.pat>.

Googled as "ImHex #include unknown type error" couldn't find anything

image

id3.hexpat error for MP3 files: Array expanded past end of the data

Opening an MP3 file proposes the id3.hexpat to be used which would be indeed really helpful.
Unfortunately, the pattern seems to fail due to some out of bound access. I've tried several random MP3 files on my device, all of them failed with one of the two following errors:

error[E0004]: Type error.
  --> <Source Code>:108:38
108 |             char data[parent.size - 1];
                                           ^
                                           Array expanded past end of the data.
error[E0004]: Type error.
  --> <Source Code>:104:46
104 |             char16 data[(parent.size - 3) / 2];
                                                   ^
                                                   Array expanded past end of the data.

Are there any prequisites or details I am missing? Or can this be identified as a bug in the pattern file?

@flimberger : It looks like the pattern was brought in by you. Is the pattern still working like expected for you? Any ideas about the issue?

Edge thinks the Windows Installer might be unsafe

Hi!

I just downloaded the Windows Installer with MS Edge, and the file triggered MS's SmartScreen protection.

The file can be reported as safe, but there's an option to certify as the author of the file that it is safe indeed. Maybe you would like to check that. Click on report as safe and follow the instructions in the form

image

Downloading with other browsers doesn't trigger the issue (e.g. Chrome)

How to search pattern from start to end?

struct FrameWithGPS {
    be u32 head;  // 0x01234567
    be u32 flag;
    be u32 week;
    be double second;
    be double latitude;
    be double longitude;
    be u16 reserve;
    be u16 pin_value;
};

How do I find all the data in the file that matches the pattern?
I only can do FrameWithGPS frane @addr;.

Photoshop ASE palette pattern

struct Block {
    be u16 Type;
    be u32 BlockLength;
    be u16 NameLength;
    be char16 Name[NameLength];
    if (Type == 1) {
        char ColorSpace[4];
        if (ColorSpace == "RGB " || ColorSpace == "LAB ") {
            be float rgb[3];
        } else if(ColorSpace == "CMYK") {
            be float cymk[4];
        } else if (ColorSpace == "Gray") {
            be float gray;
        }
        be u16 colorType;
    } else if (Type == 49153) {
        u8 unknown[BlockLength - 4];
    } else if (Type == 49154) {
        u8 unknown[BlockLength - 4];
    } else {
        u8 unknown[BlockLength];
    }
};

struct Header {
    u8 magic[4];
    be u16 versionMajor;
    be u16 versionMinor;
    be u32 blocks;
    Block b[blocks];
};

Header hdr @0x00;

files on lospec:

https://lospec.com/palette-list/periwinkle-is-a-weird-word.ase

[Feature] Obvious patterns for overridden JPEGs.

Hello!

Feature description

I'd like a feature if JPEG Pattern Parser will show correctly shows overridden JPEGs.

Example

Example of such image:
orig_schematic_fixed_53c1dec
This is how it processed now:
Screenshot 2024-04-15 at 00 56 31

Expected behavior

And this is how it expected to be processed (screenshot from 010 Editor):
image

[documentation] std::core::set_endian only applies to current and higher contexts

The current documentation states:

Any patterns created following this attribute will be created using the set endianness.

I interpreted this as meaning that the function sets the endianness for the global scope. However, when entering a lower scope then where the function was called, the endianness will return to what it was previously.

[Feature] CTRL+Click a byte should jump to the associated variable

Another way to look at #150, but a very nice addition on its own: it would be great to have CTRL+Click to jump to the variable in the Pattern Data (potentially can also be added as right-click menu).

This will make navigating around your file so much better and I would prefer this over #150 (it kind of solves the same problem, just with less manual work :P)!

Java class pattern error[E0004]: Type error, Array expanded past end of data.

attribute_name_index value show error[E0004]: Type error, Array expanded past end of data.

image

Reappear

Java source code:

class Test {
  private String a = "a";
  private String b = "b";
  private String c = "c";
  private String d = "d";
  private String e = "e";
  private String f = "f";
  private String g = "g";
  private String h = "h";
  private String i = "i";
  private String j = "j";
  private String k = "k";
  private String l = "l";
  private String m = "m";
  private String n = "n";
  private String o = "o";
  private String p = "p";
  private String q = "q";
  private String r = "r";
  private String s = "s";
  private String t = "t";
  private String u = "u";
  private String v = "v";
  private String w = "w";
  private String x = "x";
  private String y = "y";
  private String z = "z";
  private String aa = "aa";
  private String ab = "ab";
  private String ac = "ac";
  private String ad = "ad";
  private String ae = "ae";
  private String af = "af";
  private String ag = "ag";
  private String ah = "ah";
  private String ai = "ai";
  private String aj = "aj";
  private String ak = "ak";
  private String al = "al";
  private String am = "am";
  private String an = "an";
  private String ao = "ao";
  private String ap = "ap";
  private String aq = "aq";
  private String ar = "ar";
  private String as = "as";
  private String at = "at";
  private String au = "au";
  private String av = "av";
  private String aw = "aw";
  private String ax = "ax";
  private String ay = "ay";
  private String az = "az";
  private String ba = "ba";
  private String bb = "bb";
  private String bc = "bc";
  private String bd = "bd";
  private String be = "be";
  private String bf = "bf";
  private String bg = "bg";

  public static void main(String[] args) throws Exception {
    System.out.println("Hello World!");
    System.out.println("Hello World");
  }
  
}

error occurred in file.methods[n].attributes[n].attribute_name_index and file.methods[n].attributes[n].atrributes[n].attribute_name_index :

image

if delete a field, error occurred in file.methods[n].attributes[n].atrributes[n].attribute_name_index:

image

if delete two field, no orror:

image

I don't know if this error is related to the number of fields or the constant pool size, I also got this error with another class that has multiple methods but only one field.

Compile error [E0003] when using hex::core::get_selection()

Given this minimal test case in the pattern editor:

#include <hex/core.pat>

hex::core::get_selection();

The pattern compiler outputs the following error:

E:   --> <Source Code>:1:417
E: 1 | #include <hex/core.pat>
E:  [421 whitespaces] ^
E:  [421 whitespaces] Variable with name 'result' already exists in this scope.
E:
E:  

(I removed a lot of whitespaces from the error message; at first I could not see the actual error because it was so far off to the right)

I can see that hex/core.pat uses an u128 called 'result' in the get_selection function but I don't know how to fix this :)

std includes not found

I have a standard installation of 1.28.0-1.fc36 (through Fedora's repository)

When I try to write patterns, or copy/paste patterns from this github, it will inevitably give an error on the first #include <std/... include, saying "error[M0004]: No such file or directory".

Is that because it's not supported by this old version? Do I have the files but am I missing a setting? Where can I find a newer version that I don't have to compile myself (and isn't an AppImage or whatever)?

Saving a new file wipes the pattern editor

I have been using ImHex pretty intensly past few days. Really liking the tool and especially the pattern editor (coming from 010 Editor myself)! However, I have been running into a lot of crashes and nuisances as I was/am reversing a file. I will make a bunch of issues to cover those, this being the first.

If you make a new file, add some stuff in the pattern editor, and then save the file. All the contents of the pattern editor will be lost.

  1. File > New File...
  2. Type something in Pattern editor
  3. File > Save

After saving, the Pattern editor is now empty.

pe.hexpat does not parse correctly the reloc section

I am using the amazing ImHex program to learn reversing and I realize that the PE pattern is not parsing the .reloc table correctly. I have no idea about "Pattern language" but if you simply load the pattern in the classic calc.exe from windows you can realize that there are not 5 blocks of .reloc, there are only 2 blocks.

image

As you can see in the editor, the pattern does not show the different RVA addresses (2 bytes) where to change the delta:

image

This pattern should be something like this:

image

I guess that there is something wrong with this code:

struct BaseRelocationTable {
	BaseRelocationBlock baseRelocationBlocks[while($ < addressof(this) + coffHeader.optionalHeader.directories[5].size)];
};

Sorry about my English, I hope you can see what I mean.

Regards and thanks!

request: crc16 calculation in pattern editor

I like to get the crc16 calculation available in the pattern editor. Only crc32 is available at the moment. Adding the follwing code to hash.pat is not working:
fn crc16(ref auto pattern, u16 init, u16 poly, u16 xorout, bool reflect_in, bool reflect_out) {
return builtin::std::hash::crc16(pattern, init, poly, xorout, reflect_in, reflect_out);
};

Unexpected expression in type/color.pat

I am getting errors trying to #include <type/colors.pat>. So I tried to copy it's content directly into my pattern editor and got this error:

error[P0002]: Unexpected expression
  --> <Source Code>:19:14
19 |     bitfield RGBA<auto R, auto G, auto B, auto A> {
                  ^
                  Expected '{' after bitfield declaration, got Operator (<).

I've read #102 and I suppose it should solve it. I just wanted to write the issue so nobody else have to dig through the code to figure it out like I did.

Bug: png.hexpat "No variable named 'chunk' found"

Problem:

E: error[E0003]: Variable error.
E:   --> <Source Code>:176:18
E: 176 |     return chunk.name;
E:                        ^
E:                        No variable named 'chunk' found.
E: 
E: 
I: Evaluation took 0.0021474s

Source (line 173):

} [[name(chunkValueName(this))]];

fn chunkValueName(ref chunk_t chunk) {
    return chunk.name;
};

Proposed fix (line 173):

} [[name(this.name)]];

crash after changing theme and some other settings

Hello, I was looking for a new hex editor to replace HeX Workshop. I installed ImHex, changed theme from dark to light, changed some other settings (i don't remember which ones) and after application restart it's not working anymore. It show loading image, then, nothing.

These are the crash info:
image

Tried reinstall, uninstall, reboot.. nothing seems to be able to fix the issue. I'm pretty sure the problem has been caused by some files that has been changed with the settings change, but not removed with an uninstall.

The logs folder in the application folder is empty.

[Feature] Being able to save the project from the pattern editor

Because ImHex can crash if you are playing with the Pattern editor, I've made it a habit to constantly save. Currently, I have to switch to the file tab I'm working on, hit ALT+S. then switch back to the pattern editor.

Would be great if ALT+S (or CTRL+S could probably also be used there) also works from the pattern editor (or whichever tab you have focussed).

how to add additional information to structs

I'm writing pattern for dex file and here is my pattern

#pragma pattern_limit 0x20000
namespace dex {

	struct Header {
		char magic[4];
		char version[4];
		u32 checksum;
		char signature[20];
		u32 fileSize;
		u32 headerSize;
		u32 endianTag;
		u32 linkSize;
		u32 linkOff;
		u32 mapOff;
		u32 stringIdsSize;
		u32 stringIdsOffset;
		u32 typeIdsSize;
		u32 typeIdsOffset;
		u32 protoIdsSize;
		u32 protoIdsOffset;	
		u32 fieldIdsSize;
		u32 fieldIdsOffset;
		u32 methodIdsSize;
		u32 methodIdsOffset;
		u32 classDefSize;
		u32 classDefOffset;
		u32 dataSize;
		u32 dataOffset;
	};

	struct StringDataItem {
		u8 size;
		char string[size];
	
	};

	struct StringIdItem {
		u32 stringDataOffset;
	};
	
	struct MethodIdItem {
		u16 classIdx;
		u16 protoIdx;
		u32 nameIdx;
	
	};
	struct ClassDefItem {
		u32 classIdx;
		u32 accessFlags;
		u32 superClassIdx;
		u32 interfacesOffset;
		u32 sourceFileIdx;
		u32 annotationsOffset;
		u32 classDataOffset;
		u32 staticValuesOffset;
	
	};
	
	struct TypeIdItem {
		u32 descriptorIdx;
		
	};
	struct ProtoIdItem {
		u32 shortyIdx;
		u32 returnTypeIdx;
		u32 parametersOffset;
		
	};
	
	struct FieldIdItem {
		u16 classIdx;
		u16 typeIdx;
		u16 nameIdx;
		
	};
	
	struct MapList {
		u32 size;
	};
	

}

dex::Header header @0x0;
dex::StringIdItem stringIds[header.stringIdsSize] @ header.stringIdsOffset;
dex::MethodIdItem methodIds[header.methodIdsSize] @ header.methodIdsOffset;
dex::ClassDefItem classDefs[header.classDefSize] @ header.classDefOffset;
dex::MapList mapList @ header.mapOff;
dex::TypeIdItem typeIds[header.typeIdsSize] @ header.typeIdsOffset;
dex::ProtoIdItem protoIds[header.protoIdsSize] @ header.protoIdsOffset;
dex::FieldIdItem fieldIds[header.fieldIdsSize] @ header.fieldIdsOffset;

If you look at StringIdItem struct in dex namespace, normally it will point to StringDataItem. StringDataItem is not in StringIdItem struct. Instead its in where StringIdItem.stringDataOffset points to. So I would like to find each StringDataItem and get string from there and write this information to pattern data or somewhere so user can see.

In kaitai there can be two field in definition seq and instances my question is there a way to show information like instances in imhex patterns.

Integration with Kaitai Struct

Hi!

I love your project (ImHex) but I believe it can be more powerful if it uses something like Kaitai Struct (https://kaitai.io/) for describing the binary data structures. Using .ksy files for importation/exportation can be a huge improvement because those files can be turned inmediatly to parsers in any language supported by Kaitai (C, python, JavaScript, Go, etc..). Also there is a big community describing file formats in this declarative language, so you can take advantage of it.

Best regards!

How to represent nested structures that the child may span multiple parent?

Hi!
I'm trying to reverse engineer a file format and encountered the following problem. There is a nested structure, the length of the parent structure is fixed, the length of the child structure is variable, the parent structure may contain multiple child structures, and it is also possible that the child structure spans multiple parent structures, like this:

struct Parent
{
    u8 header[16];           /* This field should be skipped when child structure span multiple parent structures */
    u8 child_payload[496];
};

struct Child
{
    u16 length;
    u8 secret[length];       /* Here is what I actually want to parse */
};

I drew a simple diagram to use as an example:

|          |          |          |          |          |
|* |    |   *          *          *  |       *         |
  • the space between the vertical bars(|) represents a structure.
  • the first line indicates that there is a file containing 5 parent structures.
  • the second line indicates that these 5 payloads contain 4 child structures, and asterisks(*) indicates that it is the header of the parent structure and needs to be skipped.

How to write a list of pointers (instead of a pointer to a list)

I'm trying to write a pattern for doom's image format.
The header has a list of pointers. The length of this list is equal to the width of the image, which is defined in the header.
If I write:

Post *post[width]: u32;

I one pointer to a width amount of posts, instead of width amount of pointers to post.
The documentation doesn't mention how to do this and trial and error got me nowhere.

The complete pattern:

struct Post {
    le s8 topDelta;
    le u8 length;
    padding[1];
    le u8 data[length];
    padding[1];
    le u8 end;
};

struct Lmp {
    le s16 width;
    le s16 height;
    le s16 leftOffset;
    le s16 topOffset;
    Post *post[width]: u32; // this is incorrect
};

Lmp lmp @ 0;

This does work for now, as most doom images have their posts in a continuous array.

no parent avaliable

when open an elf file, and load elf.pat, there is an error:
Error at line 167:
there no parent avaliable
image

Issue with endianness in type::GUID

While writing a new pattern for keepass kdbx files I wanted to display a specific value of the keepass db file as UUID. KeePass uses specific CipherIDs for the used encryption algorithm. The known value for AES256-CBC is 31c1f2e6-bf71-4350-be58-05216afc5aff.

I was a bit irritated to find another value in the header:

base64: McHy5r9xQ1C+WAUhavxa/w==
hex: 0x31, 0xC1, 0xF2, 0xE6, 0xBF, 0x71, 0x43, 0x50, 0xBE, 0x58, 0x05, 0x21, 0x6A, 0xFC, 0x5A, 0xFF

wanted: 31c1f2e6-bf71-4350-be58-05216afc5aff
got:    e6f2c131-71bf-5043-be58-05216afc5aff
diff:	________ ____ ____

I checked back with two different sources and the uuid generated by imhex is definitely wrong. It seems like the endianness is not considered here:

return std::format("{}{{{:08X}-{:04X}-{:04X}-{:02X}{:02X}-{:02X}{:02X}{:02X}{:02X}{:02X}{:02X}}}",
valid ? "" : "Invalid ",
le u32(guid.time_low),
le u16(guid.time_mid),
le u16(guid.time_high_and_version),

Changing the endianness from le to be fixes the issue:

35,37c35,37
< 	            le u32(guid.time_low),
< 	            le u16(guid.time_mid),
< 	            le u16(guid.time_high_and_version),
---
> 	            be u32(guid.time_low),
> 	            be u16(guid.time_mid),
> 	            be u16(guid.time_high_and_version),

Cannot cast from aliased type to type for user defined types

This issue was edited after finding out that it has a wider scope than initially assumed. When you create an alias for a type with using the alias and the type both represent the same pl type and casting between them should be possible. This works for builtin types

s32 test @ 0;

using int = s32;

int test2 = test; // works ok

However a similar check using user defined types give a casting operation error. A simplest case example is

struct A {
    u8 byte;
};

A a @ 0;

using B=A;

B b1=a; //error cannot cast from A to B

I initially found this issue by trying to parse a uuid like so:

type::UUID uuid;

When doing so, I recieve the error [E0004]: Type error. Cannot cast from type 'type::UUID' to type 'type::GUID' when displaying the UUID in the Pattern Data or when printing the variable with std::print. This is probably because the format_guid function expects a struct of type GUID and doesn't know anything about UUID.

The issue can be reproduced with this pattern.

#include <std/io.pat>
#include <type/guid.pat>

type::UUID test @0x00;
std::print("Test: {}", test);

If my assumption is correct, the issue does not only affect UUIDs but all types with function attributes.

obscure pattern welcome?

I own a device that's pretty old and no longer manufactured. It has a pretty simple file format that I created a pattern for to learn the pattern language. Should I contribute it? I doubt that it has practical use, but it is a very simple format and might serve as an example. The whole file is an array of the same struct and it also has a few bitfields.

hex::visualize isn't documented

Hello,

I've discovered the hex::visualize feature that allow to render images and 3D meshes.

Unfortunately, I can't find any documentation about this feature, and therefore struggle to use it.

An addition in the official documentation would be very welcome.

Best regards.

harden wav.hexpat: WAV pattern fails on parsing IEEE float file produced by Audacity

I created a mono 48khz file with 32bit floating point encoding in Audacity and tried to inspect it with ImHex and the wav.hexpat pattern.
Since the WaveFormatType of 0x03 is not known this leads to an error of

error[E0004]: Type error.
  --> <Source Code>:207:62
207 |       padding[paddedChunkSize - sizeof(fmt) - sizeof(unknown)];
                                                                   ^
                                                                   Array size cannot be negative.

Looking at some format information on https://wavefilegem.com/how_wave_files_work.html it seems that the only added fmt field should be the bitsPerSample and a 2 byte extension size field which always should have the value 0.

However Audacity seems to incorrectly NOT add an "extension size" field with value 0 - so this leads to the error above.
By treating the IEEE floating point format similar to WaveFormatPCM format and handle the "extension size" as padding I can successfully use the pattern file.

image

I would create a PR but need to get sign off from my employer - so in the meantime here is the fix in comment form

#pragma MIME audio/wav

#include <std/mem.pat>

struct RiffHeader {
  char ckID[4] [[comment("Container Signature"), name("RIFF Header Signature")]];
  u32  ckSize [[comment("Size of RIFF Header"), name("RIFF Chunk Size")]];
  char format[4] [[comment("RIFF format"), name("WAVE Header Signature")]];
};

struct WaveChunk {
  char chunkId[4];
  u32  chunkSize;
};

enum WaveFormatType : u16 {
  Unknown,
  PCM,
  MS_ADPCM,
  IEEEFloatingPoint,
  ALAW = 6,
  MULAW,
  IMA_ADPCM  = 0x11,
  GSM610     = 0x31,
  MPEG       = 0x50,
  MPEGLAYER3 = 0x55,
};

struct WaveFormat {
  WaveFormatType formatTag;
  u16            channels;
  u32            samplesPerSec [[comment("Sample Frequency")]];
  u32            avgBytesPerSec [[comment("BPS - Used to estimate buffer size")]];
  u16            blockAlign;
};

struct WaveFormatEx {
  u16 bitsPerSample;
  u16 extendedDataSize;
};

struct WaveFormatExDummy {
  u16 bitsPerSample;
  u16 extendedDataSize;
  u8  extendedData[extendedDataSize];
};

struct WaveFormatPCM {
  u16 bitsPerSample;
};

struct WaveMSADPCMCoefSet {
  s16 coef1;    
  s16 coef2;
};

struct WaveFormatMSADPCM : WaveFormatEx {
  u16                samplesPerBlock;
  u16                numCoef;
  WaveMSADPCMCoefSet coef[numCoef];
};

bitfield WaveMPEGLayer {
  Layer1  : 1;
  Layer2  : 1;
  Layer3  : 1;
  padding : 13;
};

bitfield WaveMPEGMode {
  Stereo : 1;
  JointStereo : 1;
  DualChannel : 1;
  SingleChannel : 1;
  padding : 12;
};

bitfield WaveMPEGFlags {
  PrivateBit : 1;
  Copyright : 1;
  OriginalHome : 1;
  ProtectionBit : 1;
  IdMPEG1 : 1;
  padding : 11;
};

struct WaveFormatIEEEFloatingPoint : WaveFormatPCM
{

};

struct WaveFormatMPEG : WaveFormatEx {
  WaveMPEGLayer    headLayersUsed;
  u32              headBitrate;
  WaveMPEGMode     headMode;
  u16              headModeExt;
  u16              headEmphasis;
  WaveMPEGFlags    headFlags;
  u32              PTSLow;
  u32              PTSHigh;
};

enum WaveFormatMPEGLayer3Flags : u32 {
  MPEGLAYER3_FLAG_PADDING_ISO,
  MPEGLAYER3_FLAG_PADDING_ON,
  MPEGLAYER3_FLAG_PADDING_OFF
};

struct WaveFormatMPEGLayer3 : WaveFormatEx {
  u16                       id;
  WaveFormatMPEGLayer3Flags flags;
  u16                       blockSize;
  u16                       framesPerBlock;
  u16                       codecDelay;
};

struct WaveFact {
  u32 uncompressedSize;
};

enum SampleLookupType : u32 {
  TYPE_LOOP_FORWARD,
  TYPE_LOOP_ALTERNATE,
  TYPE_LOOP_BACKWARD,
};

struct SampleLookup {
  u32              id;
  SampleLookupType type;
  u32              start;
  u32              end;
  u32              fraction;
  u32              playCount;
};

struct WaveSample {
  u32 manufacturer;
  u32 product;
  u32 samplePeriod;
  u32 MIDIUnityNote;
  u32 MIDIPitchFraction;
  u32 SMPTEFormat;
  u32 SMPTEOffset;
  u32 numSampleLoops;
  u32 sampleLoopsSize;

  SampleLookup lookups[numSampleLoops];
};

struct WaveCuePoint {
  u32  indentifier;
  u32  position;
  char chunkID[4];
  u32  chunkStart;
  u32  blockStart;
  u32  sampleOffset;
};

struct WaveCue {
  u32          numCuePoints;
  WaveCuePoint cuePoints[numCuePoints];
};

struct WaveLabel {
  u32  id;
  char text[];
  padding[sizeof(text) % 2];
};

using WaveNote = WaveLabel;

struct WaveListItem : WaveChunk {
  if (chunkId == "labl") {
    WaveLabel label;
  } else if (chunkId == "note") {
    WaveNote note;
  } else {
    padding[(chunkSize + 1) >> 1 << 1];
  }
};

u64 listEnd;

struct WaveList {
  char type[4];

  WaveListItem item[while ($ < listEnd)];
};

u32 paddedChunkSize;

struct WavData {
  WaveChunk chunk;
  paddedChunkSize = (chunk.chunkSize + 1) >> 1 << 1;

  if (chunk.chunkId == "fmt ") {
    WaveFormat fmt;

    if (fmt.formatTag == WaveFormatType::PCM) {
      WaveFormatPCM pcmExtraData;
      padding[paddedChunkSize - sizeof(fmt) - sizeof(pcmExtraData)];
    } else if (fmt.formatTag == WaveFormatType::MS_ADPCM) {
      WaveFormatMSADPCM msAdpcmExtraData;
      padding[paddedChunkSize - sizeof(fmt) - sizeof(msAdpcmExtraData)];
    } else if (fmt.formatTag == WaveFormatType::MPEG) {
      WaveFormatMPEG mpegExtraData;
      padding[paddedChunkSize - sizeof(fmt) - sizeof(mpegExtraData)];
    } else if (fmt.formatTag == WaveFormatType::MPEGLAYER3) {
      WaveFormatMPEGLayer3 mpegLayer3ExtraData;
      padding[paddedChunkSize - sizeof(fmt) - sizeof(mpegLayer3ExtraData)];
    } else if (fmt.formatTag == WaveFormatType::IEEEFloatingPoint)
    {
        WaveFormatIEEEFloatingPoint ieeFloatingPointExtraData;
        padding[paddedChunkSize - sizeof(fmt) - sizeof(ieeFloatingPointExtraData)];
    } else {
      WaveFormatExDummy unknown;
      padding[paddedChunkSize - sizeof(fmt) - sizeof(unknown)];
    }
  } else if (chunk.chunkId == "data") {
    padding[paddedChunkSize];
  } else if (chunk.chunkId == "fact") {
    WaveFact fact;
    padding[paddedChunkSize - sizeof(fact)];
  } else if (chunk.chunkId == "smpl") {
    WaveSample smpl;
    padding[paddedChunkSize - sizeof(smpl)];
  } else if (chunk.chunkId == "cue ") {
    WaveCue cue;
    padding[paddedChunkSize - sizeof(cue)];
  } else if (chunk.chunkId == "LIST") {
    listEnd = $ + chunk.chunkSize;
    WaveList list;
    padding[paddedChunkSize % 1];
  } else {
    padding[paddedChunkSize];
  }
};

RiffHeader header @0x00;
WavData    data[while (!std::mem::eof())] @$;

PNG patterns are broken

・some code in the pattern are duplicates
image

enum BlendOp: u8 {
Source = 0x0,
Over
};
enum DisposeOp: u8 {
None = 0x0,
Background,
Previous
};
struct fctl_t {
u32 sequence_no [[comment("Sequence №")]];
u32 width [[comment("Frame width")]];
u32 height;
u32 xoff;
u32 yoff;
u16 delay_num;
u16 delay_den;
DisposeOp dispose_op;
BlendOp blend_op;
};
struct fdat_t {
u32 sequence_no;
};

enum BlendOp: u8 {
Source = 0x0,
Over
};
enum DisposeOp: u8 {
None = 0x0,
Background,
Previous
};
struct fctl_t {
u32 sequence_no [[comment("Sequence №")]];
u32 width [[comment("Frame width")]];
u32 height [[comment("Frame height")]];
u32 xoff;
u32 yoff;
u16 delay_num [[comment("Frame delay fraction numerator")]];
u16 delay_den [[comment("Frame delay fraction denominator")]];
DisposeOp dispose_op;
BlendOp blend_op;
};
struct fdat_t {
u32 sequence_no;
};

・some comparisons are wrong
image

std::mem::read_string is limited in size to u8::MAX

Attempting to use a larger integer for a longer length string will silently limit the read string. To me this seems unintentional as this would mean there's no way to read strings longer than u8::MAX and the builtin function this calls has the capability of reading much more as its instead limited to size_t.

java pattern error[V0002]: Statement redefinition

ImHex: v1.29.0

error[V0002]: Statement redefinition
  --> <Source Code>:609:49
609 |         cp_ref name_index @ addressof(name_index);
                                                      ^
                                                      Redefinition of identifier 'name_index'


image

If delete line 609, 624, 653, pattern can be evaluated
image

jpeg pattern error with embedded thumbnail

Hi,
It seems there is an error when using jpeg pattern (jpeg.hexpat) regarding embedded thumbnail (with MacOs 1.26.2 version):

error[P0002]: Unexpected expression --> <Source Code>:63:71 63 | Pixel thumbnail[thumbnailX * thumbnailY] [[sealed, hex::visualize("bitmap", thumbnailX, thumbnailY)]]; ^ Expected ')', got Separator (,)

Removing this part
[[sealed, hex::visualize("bitmap", thumbnailX, thumbnailY)]]
sure solves the problem but obviously also prevents intended thumbnail visualisation feature.

May be, I'm wrong but it seems hex::visualize function is not 'seen' by jpeg.hexpat.

Consider supporting multiple test cases per pattern

Some patterns have to make decisions based on file headers, such as selecting a particular byte order or field width. In such cases it's impossible to create a single test case that fully exercises the pattern. Is there any reason the test suite shouldn't allow multiple test cases per pattern?

Build engine patterns

KV6 Voxel model format

#include <std/array.pat>

struct color {
  u8 b;
  u8 g;
  u8 r;
};

bitfield VisMask {
  left : 1;
  right : 1;
  front : 1;
  back : 1;
  up : 1;
  down : 1;  
  upadding : 2;
};

struct kv6 {
	color col;
	u8 always128;
	u8 z;
	u8 always0;
	VisMask visMask;
	u8 direction;
};

struct Header {
	u32 magic;
	u32 width;
	u32 depth;
	u32 height;
	float pivot_x;
	float pivot_y;
	float pivot_z;
	u32 voxels;
	kv6 data[voxels];
	u32 xoffsets[width];
	std::Array<u16, depth * width> xyoffsets;
   // u32 palMagic; // optional if there is still space left in the file
   // color colors[256];
};

Header hdr @0x00;

KFA File (KV6 Animation) kfa.hexpat

struct point3d {
	float x;
	float y;
	float z;
};

struct hingetype {
	s32 parenthinge;
	point3d childPoint;
	point3d parentPoint;
	point3d childAxisRotationVector;
	point3d parentAxisRotationVector;
	s16 vmin;
	s16 vmax;
	s8 htype;
	s8 filler[7];
};

struct seqtyp {
	s32 timeMillis;
	s32 frm;
};

struct Header {
	u32 magic;
	u32 stringlen;
	u8 filename[stringlen];
	u32 numhinge;
	hingetype hinge[numhinge];
	u32 numfrm;
	// These are the hinge angles. 0 is 0 degrees, 16384 is 90 degrees, -16384 is -90 degrees
	s16 frmval[numfrm * numhinge]; //[numfrm][numhinge]
	u32 seqnum;
	seqtyp seq[seqnum];
};

Header hdr @0x00;

example files: https://github.com/Ericson2314/Voxlap/blob/no-asm/share/voxdata.zip

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.