patterns: Add SDB pattern (#424)

Co-authored-by: Nik <werwolv98@gmail.com>
This commit is contained in:
Mark Jansen
2025-08-15 17:16:50 +02:00
committed by GitHub
parent 9207282bcf
commit 6b9f39cc21
3 changed files with 88 additions and 0 deletions

View File

@@ -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
View 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;

Binary file not shown.