patterns: Added vdf pattern

This commit is contained in:
WerWolv
2022-03-17 00:11:54 +01:00
parent 448a81a06d
commit 08ace38914
2 changed files with 37 additions and 4 deletions

View File

@@ -25,10 +25,7 @@ Hex patterns, include patterns and magic files for the use with the ImHex Hex Ed
| Java Class | `application/x-java-applet` | `patterns/java_class.hexpat` | Java Class files |
| ARM VTOR | | `patterns/arm_cm_vtor.hexpat` | ARM Cortex M Vector Table Layout |
| ICO | | `patterns/ico.hexpat` | Icon (.ico) or Cursor (.cur) files |
| PNG | `image/png` | `patterns/png.hexpat` | PNG image files |
| DDS | `image/vnd-ms.dds` | `patterns/dds.hexpat` | DirectDraw Surface |
| TGA | `image/tga` | `patterns/tga.hexpat` | Truevision TGA/TARGA image |
| ISO | | `patterns/iso.hexpat` | ISO 9660 file system |
| VDF | | `patterns/vdf.hexpat` | Binary Value Data Format (.vdf) files |
### Scripts

36
patterns/vdf.hexpat Normal file
View File

@@ -0,0 +1,36 @@
#pragma eval_depth 0x10000
#include <std/mem.pat>
#include <std/sys.pat>
enum Type : u8 {
Set = 0x00,
String = 0x01,
Integer = 0x02,
EndSet = 0x08
};
struct Entry {
Type type;
char name[];
if (type == Type::Set) {
Entry entries[while (std::mem::read_unsigned($, 1) != Type::EndSet)];
Type endSet [[hidden]];
std::assert(endSet == Type::EndSet, "Invalid end of set byte!");
}
else if (type == Type::Integer)
u32 value;
else if (type == Type::String) {
char value[];
}
};
struct Set {
Entry entry [[inline]];
Type endSet [[hidden]];
std::assert(endSet == Type::EndSet, "Invalid end of set byte!");
};
Set set[while (std::mem::read_unsigned($ - 1, 1) != Type::EndSet)] @ 0x00;