mirror of
https://github.com/WerWolv/ImHex-Patterns.git
synced 2026-03-27 23:37:04 -05:00
patterns: Add SDB pattern (#424)
Co-authored-by: Nik <werwolv98@gmail.com>
This commit is contained in:
@@ -154,6 +154,7 @@ Everything will immediately show up in ImHex's Content Store and gets bundled wi
|
|||||||
| ReFS | | [`patterns/refs.hexpat`](patterns/fs/refs.hexpat) | Microsoft Resilient File System |
|
| ReFS | | [`patterns/refs.hexpat`](patterns/fs/refs.hexpat) | Microsoft Resilient File System |
|
||||||
| RGBDS | | [`patterns/rgbds.hexpat`](patterns/rgbds.hexpat) | [RGBDS](https://rgbds.gbdev.io) object file format |
|
| RGBDS | | [`patterns/rgbds.hexpat`](patterns/rgbds.hexpat) | [RGBDS](https://rgbds.gbdev.io) object file format |
|
||||||
| RPM | | [`patterns/rpm.hexpat`](patterns/rpm.hexpat) | [RPM](http://ftp.rpm.org/max-rpm/s1-rpm-file-format-rpm-file-format.html) package file format |
|
| RPM | | [`patterns/rpm.hexpat`](patterns/rpm.hexpat) | [RPM](http://ftp.rpm.org/max-rpm/s1-rpm-file-format-rpm-file-format.html) package file format |
|
||||||
|
| SDB | | [`patterns/sdb.hexpat`](patterns/sdb.hexpat) | [Shim DataBase](https://learn.microsoft.com/en-us/windows/win32/devnotes/application-compatibility-database) file format |
|
||||||
| Shell Link | `application/x-ms-shortcut` | [`patterns/lnk.hexpat`](patterns/lnk.hexpat) | Windows Shell Link 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 |
|
| shp | | [`patterns/shp.hexpat`](patterns/shp.hexpat) | ESRI shape file |
|
||||||
| shx | | [`patterns/shx.hexpat`](patterns/shx.hexpat) | ESRI index file |
|
| shx | | [`patterns/shx.hexpat`](patterns/shx.hexpat) | ESRI index file |
|
||||||
|
|||||||
87
patterns/sdb.hexpat
Normal file
87
patterns/sdb.hexpat
Normal file
@@ -0,0 +1,87 @@
|
|||||||
|
#pragma description SDB File (Shim DataBase file)
|
||||||
|
#pragma author learn_more
|
||||||
|
#pragma magic [ 73 64 62 66 ] @ 0x08
|
||||||
|
#pragma endian little
|
||||||
|
|
||||||
|
import std.mem;
|
||||||
|
import std.io;
|
||||||
|
import std.string;
|
||||||
|
import type.base;
|
||||||
|
|
||||||
|
enum TagType : u8 {
|
||||||
|
Null = 0x1,
|
||||||
|
Byte = 0x2,
|
||||||
|
Word = 0x3,
|
||||||
|
DWord = 0x4,
|
||||||
|
QWord = 0x5,
|
||||||
|
StringRef = 0x6,
|
||||||
|
List = 0x7,
|
||||||
|
String = 0x8,
|
||||||
|
Binary = 0x9,
|
||||||
|
};
|
||||||
|
|
||||||
|
bitfield TypeId {
|
||||||
|
id : 12;
|
||||||
|
type : 4;
|
||||||
|
};
|
||||||
|
|
||||||
|
fn get_tag(TypeId tag) {
|
||||||
|
return std::format("{:x}{:03x}", tag.type, tag.id);
|
||||||
|
};
|
||||||
|
|
||||||
|
fn get_type(TypeId tag) {
|
||||||
|
TagType tmp = tag.type;
|
||||||
|
str name = std::format("{}", tmp);
|
||||||
|
u32 len = std::string::length(name);
|
||||||
|
return std::string::substr(name, 9, len-9);
|
||||||
|
};
|
||||||
|
|
||||||
|
struct Tag {
|
||||||
|
TypeId tag[[format_read("get_tag")]];
|
||||||
|
match (tag.type) {
|
||||||
|
(TagType::Null) : {
|
||||||
|
// All set
|
||||||
|
}
|
||||||
|
(TagType::Byte) : {
|
||||||
|
u8 value;
|
||||||
|
u8 pad[[hidden]];
|
||||||
|
}
|
||||||
|
(TagType::Word) : {
|
||||||
|
u16 value;
|
||||||
|
}
|
||||||
|
(TagType::DWord) : {
|
||||||
|
u32 value;
|
||||||
|
}
|
||||||
|
(TagType::QWord) : {
|
||||||
|
u64 value;
|
||||||
|
}
|
||||||
|
(TagType::StringRef) : {
|
||||||
|
u32 str_offset;
|
||||||
|
char value @ str_offset;
|
||||||
|
}
|
||||||
|
(TagType::List) : {
|
||||||
|
u32 size ;
|
||||||
|
Tag tags[while($ < ((addressof(size) + size + 4) ))];
|
||||||
|
}
|
||||||
|
(TagType::String) : {
|
||||||
|
u32 size;
|
||||||
|
char16 value[size/2];
|
||||||
|
}
|
||||||
|
(TagType::Binary) : {
|
||||||
|
u32 size;
|
||||||
|
u8 value[size];
|
||||||
|
if (size & 1 ) {
|
||||||
|
u8 pad[[hidden]];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}[[name(get_tag(tag)), comment(get_type(tag))]];
|
||||||
|
|
||||||
|
struct Header {
|
||||||
|
u32 Major;
|
||||||
|
u32 Minor;
|
||||||
|
char Magic[4];
|
||||||
|
Tag tags[while(!std::mem::eof())];
|
||||||
|
};
|
||||||
|
|
||||||
|
Header file @ 0x0;
|
||||||
BIN
tests/patterns/test_data/sdb.hexpat.sdb
Normal file
BIN
tests/patterns/test_data/sdb.hexpat.sdb
Normal file
Binary file not shown.
Reference in New Issue
Block a user