Compare commits

...

20 Commits

Author SHA1 Message Date
Justus Garbe
3786f7e265 patterns/gif: Improved gif format using more explicit formating styles (#84)
* Improved gif format using more explicit formating styles

* Set mime type

* Move content type formatting to struct value
2023-02-15 09:40:09 +01:00
Kuruyia
ea4dda001a includes/type: Fix the IPv6 type (#83)
includes/type: fix the IPv6 type
2023-02-13 08:49:29 +01:00
Nik
324b0894d3 git: Fixed typos 2023-02-10 11:47:36 +01:00
Nik
e89e85e10c nodes: Added Caecar and XOR cipher nodes 2023-02-10 11:25:56 +01:00
Nik
b93e957e46 patterns/jpeg: Removed hex::visualize attribute until it's supported by ImHex 2023-02-09 11:49:43 +01:00
Camas
e7eba44ae0 git: Fix broken ID3 link in README.md (#81)
Fix broken ID3 link
2023-02-06 07:12:30 +01:00
Lenni0451
41d801a114 patterns/nbt: Added missing int array and long array tag (#79) 2023-02-03 21:55:52 +01:00
Nik
25f73ca721 patterns/afe2: Fixed missing include 2023-01-30 16:37:55 +01:00
Nik
facbe59163 patterns/jpeg: Added JPEG pattern 2023-01-29 00:15:56 +01:00
Nik
55023ce4ea patterns/tga: Make pattern compatible with new version 2023-01-22 12:24:14 +01:00
Hank Donnay
32158edb3a patterns/tar: Support PAX archives (#77)
There are two common magic values for archives: the [GNU one](https://git.savannah.gnu.org/cgit/tar.git/tree/src/tar.h#n160) (8 bytes) and the [ustar one](https://pubs.opengroup.org/onlinepubs/9699919799/utilities/pax.html#tag_20_92_13_06) (6 bytes).

This change has the pattern support both.
2023-01-17 22:51:11 +01:00
WerWolv
862d4d1c28 includes/std: Added missing std::file::seek function 2023-01-16 14:23:29 +01:00
Pascal
d4045b76c3 patterns/pif: Add PIF image pattern (#76)
* Added PIF pattern

* tests/patterns: Added test file for pif pattern

* Added pif pattern to list

* Delete pif.hexpat.pif

* patterns: Added pif image format pattern
2023-01-16 12:07:11 +01:00
Martin Gerhardy
8ab2ff4ab1 patterns: Added a few voxel model patterns (#74)
* patterns: added a few voxel model patterns

* patterns: updated qbcl

according to https://gist.github.com/tostc/7f049207a2e5a7ccb714499702b5e2fd

* readme: added new voxel format petterns to the readme

* tests: added vxl test file

* ccvxl: updated two fields
2023-01-13 20:19:06 +01:00
Nik
5ea7141cb7 patterns: Added Xbox executable (XBEH) pattern 2023-01-12 11:35:47 +01:00
Berylskid
9b13113682 encodings: Update shiftjis.tbl and create ms932.tbl (#73)
* Duplicate current shiftjis.tbl as ms932.tbl

* Correct some wrong characters in shiftjis.tbl

* Remove bunch of non-shift-jis characters from shiftjis.tbl

* Add a missing character (819F=◆)
2023-01-12 11:33:34 +01:00
Max1Truc
0748fa135e patterns/qoi: Fixed bitfields order being wrong (#72) 2023-01-10 09:15:08 +01:00
Max1Truc
a4a14309be patterns/qoi: Added QOI pattern (#71)
For more information on QOI: https://qoiformat.org/
2023-01-09 07:29:33 +01:00
Nik
7c179b3b41 git: Added note for application/octet-stream MIME type to PR template 2023-01-08 16:19:38 +01:00
Daniel Stinson-Diess
c204696209 patterns/dmg: Added DMG pattern (#70) 2023-01-08 16:11:57 +01:00
25 changed files with 8710 additions and 239 deletions

View File

@@ -6,5 +6,6 @@
- [ ] A pattern for this format doesn't exist yet (or this PR improves the existing one)
- [ ] The new pattern has been added to the relevant table in the Readme
- [ ] The pattern was associated with all relevant MIME types (using `#pragma MIME mime-type` in the source code)
- Make sure to never use `application/octet-stream` here as that means "Unidentifiable binary data"
- [ ] A test file for this pattern has been added to [/tests/patterns/test_data](/tests/patterns/test_data)
- Try to keep this file below ~ 1 MB

View File

@@ -27,6 +27,7 @@ Hex patterns, include patterns and magic files for the use with the ImHex Hex Ed
| ARM VTOR | | [`patterns/arm_cm_vtor.hexpat`](patterns/arm_cm_vtor.hexpat) | ARM Cortex M Vector Table Layout |
| ICO | | [`patterns/ico.hexpat`](patterns/ico.hexpat) | Icon (.ico) or Cursor (.cur) files |
| PNG | `image/png` | [`patterns/png.hexpat`](patterns/png.hexpat) | PNG image files |
| QOI | `image/qoi` | [`patterns/qoi.hexpat`](patterns/qoi.hexpat) | QOI image files |
| DDS | `image/vnd-ms.dds` | [`patterns/dds.hexpat`](patterns/dds.hexpat) | DirectDraw Surface |
| TGA | `image/tga` | [`patterns/tga.hexpat`](patterns/tga.hexpat) | Truevision TGA/TARGA image |
| ISO | | [`patterns/iso.hexpat`](patterns/iso.hexpat) | ISO 9660 file system |
@@ -46,7 +47,7 @@ Hex patterns, include patterns and magic files for the use with the ImHex Hex Ed
| BSON | `application/bson` | [`patterns/bson.hexpat`](patterns/bson.hexpat) | BSON (Binary JSON) format |
| msgpack | `application/x-msgpack` | [`patterns/msgpack.hexpat`](patterns/msgpack.hexpat) | MessagePack binary serialization format |
| MiniDump | `application/x-dmp` | [`patterns/minidump.hexpat`](patterns/minidump.hexpat) | Windows MiniDump files |
| ID3 | `audio/mpeg` | [`patterns/id3tag.hexpat`](patterns/id3tag.hexpat) | ID3 tags in MP3 files |
| ID3 | `audio/mpeg` | [`patterns/id3.hexpat`](patterns/id3.hexpat) | ID3 tags in MP3 files |
| TAR | `application/x-tar` | [`patterns/tar.hexpat`](patterns/tar.hexpat) | Tar file format |
| CPIO | `application/x-cpio` | [`patterns/cpio.hexpat`](patterns/cpio.hexpat) | Old Binary CPIO Format |
| FDT | | [`patterns/fdt.hexpat`](patterns/fdt.hexpat) | Flat Linux Device Tree blob |
@@ -62,6 +63,14 @@ Hex patterns, include patterns and magic files for the use with the ImHex Hex Ed
| COFF | `application/x-coff` | [`patterns/coff.hexpat`](patterns/coff.hexpat) | Common Object File Format (COFF) executable |
| Mach-O | `application/x-mach-binary` | [`patterns/macho.hexpat`](patterns/macho.hexpat) | Mach-O executable |
| CHM | | [`patterns/chm.hexpat`](patterns/chm.hexpat) | Windows HtmlHelp Data (ITSF / CHM) |
| DMG | | [`patterns/dmg.hexpat`](patterns/dmg.hexpat) | Apple Disk Image Trailer (DMG) |
| XBEH | `audio/x-xbox-executable` | [`patterns/xbeh.hexpat`](patterns/xbeh.hexpat) | Xbox executable |
| QBCL | | [`patterns/qbcl.hexpat`](patterns/qbcl.hexpat) | Qubicle voxel scene project file |
| 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 |
| PIF | `image/pif` | [`patterns/pif.hexpat`](patterns/pif.hexpat) | PIF Image Format |
| JPEG | `image/jpeg` | [`patterns/jpeg.hexpat`](patterns/jpeg.hexpat) | JPEG Image Format |
### Scripts
@@ -138,6 +147,12 @@ Hex patterns, include patterns and magic files for the use with the ImHex Hex Ed
| UTF-8 | [`encodings/utf8.tbl`](encodings/utf8.tbl) | UTF-8 encoding |
| Vietnamese | [`encodings/vietnamese.tbl`](encodings/vietnamese.tbl) | Vietnamese character encoding |
### Data Processor Nodes
| Name | Path | Description |
|------|------|-------------|
| Caesar Cipher | [`nodes/caesar.hexnode`](nodes/caesar.hexnode) | Simple adjustable per-byte Caecar Cipher (ROT) |
| XOR Cipher | [`nodes/xor.hexnode`](nodes/xor.hexnode) | XORs a input with a repeating XOR pad |
## Contributing
If you want to contribute a file to the database, please make a PR which adds it to the right folder and adds a new entry to the table in this readme.

7120
encodings/ms932.tbl Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -1,9 +1,3 @@
08=␈
09=␉
0A=␊
0B=␋
0C=␌
0D=␍
20=
21=!
22="
@@ -127,12 +121,12 @@
8159=〆
815A=
815B=ー
815C=
815C=
815D=
815E=
815F=
8160=
8161=
8160=
8161=
8162=
8163=…
8164=‥
@@ -159,7 +153,7 @@
8179=【
817A=】
817B=
817C=
817C=
817D=±
817E=×
8180=÷
@@ -179,8 +173,8 @@
818E=℃
818F=¥
8190=
8191=
8192=
8191=¢
8192=£
8193=
8194=
8195=
@@ -193,6 +187,7 @@
819C=●
819D=◎
819E=◇
819F=◆
81A0=□
81A1=■
81A2=△
@@ -216,7 +211,7 @@
81BF=∩
81C8=∧
81C9=
81CA=
81CA=¬
81CB=⇒
81CC=⇔
81CD=∀
@@ -622,89 +617,6 @@
84BC=┥
84BD=┸
84BE=╂
8740=①
8741=②
8742=③
8743=④
8744=⑤
8745=⑥
8746=⑦
8747=⑧
8748=⑨
8749=⑩
874A=⑪
874B=⑫
874C=⑬
874D=⑭
874E=⑮
874F=⑯
8750=⑰
8751=⑱
8752=⑲
8753=⑳
8754=
8755=Ⅱ
8756=Ⅲ
8757=Ⅳ
8758=
8759=Ⅵ
875A=Ⅶ
875B=Ⅷ
875C=Ⅸ
875D=
875F=㍉
8760=㌔
8761=㌢
8762=㍍
8763=㌘
8764=㌧
8765=㌃
8766=㌶
8767=㍑
8768=㍗
8769=㌍
876A=㌦
876B=㌣
876C=㌫
876D=㍊
876E=㌻
876F=㎜
8770=㎝
8771=㎞
8772=㎎
8773=㎏
8774=㏄
8775=㎡
877E=㍻
8780=〝
8781=〟
8782=№
8783=㏍
8784=℡
8785=㊤
8786=㊥
8787=㊦
8788=㊧
8789=㊨
878A=㈱
878B=㈲
878C=㈹
878D=㍾
878E=㍽
878F=㍼
8790=≒
8791=≡
8792=∫
8793=∮
8794=∑
8795=√
8796=⊥
8797=∠
8798=∟
8799=⊿
879A=∵
879B=∩
879C=
889F=亜
88A0=唖
88A1=娃
@@ -7123,4 +7035,3 @@ EAA1=遙
EAA2=瑤
EAA3=凜
EAA4=熙
FA5B=∵

View File

@@ -28,6 +28,10 @@ namespace std::file {
return builtin::std::file::write(handle, data);
};
fn seek(Handle handle, u64 offset) {
builtin::std::file::seek(handle, offset);
};
fn size(Handle handle) {
return builtin::std::file::size(handle);

View File

@@ -1,6 +1,7 @@
#pragma once
#include <std/io.pat>
#include <std/string.pat>
namespace type {
@@ -9,11 +10,11 @@ namespace type {
} [[sealed, format("type::impl::format_ipv4_address")]];
struct IPv6Address {
u16 words[8];
be u16 words[8];
} [[sealed, format("type::impl::format_ipv6_address")]];
namespace impl {
fn format_ipv4_address(IPv4Address address) {
return std::format("{}.{}.{}.{}",
address.bytes[0],
@@ -24,33 +25,33 @@ namespace type {
fn format_ipv6_address(IPv6Address address) {
str result;
bool hadZeros = false;
s8 startIndex = -1;
for (u8 i = 0, i < 8, i += 1) {
if (address.words[i] == 0x00 && !hadZeros) {
hadZeros = true;
startIndex = i;
while (i < 7) {
if (address.words[i + 1] != 0x00)
break;
i += 1;
}
if (startIndex == 0 || i == 7)
result += ":";
} else {
result += std::format("{:04X}", address.words[i]);
result += std::format("{:X}", address.words[i]);
}
result += ":";
}
return std::string::substr(result, 0, std::string::length(result) - 1);
};
}
}

219
nodes/caesar.hexnode Normal file
View File

@@ -0,0 +1,219 @@
{
"attrs": [
76,
77,
78
],
"data": {
"nodes": {
"links": {
"31": {
"from": 54,
"id": 31,
"to": 55
},
"33": {
"from": 59,
"id": 33,
"to": 56
},
"34": {
"from": 60,
"id": 34,
"to": 57
},
"40": {
"from": 68,
"id": 40,
"to": 53
},
"41": {
"from": 66,
"id": 41,
"to": 69
},
"42": {
"from": 66,
"id": 42,
"to": 63
},
"43": {
"from": 58,
"id": 43,
"to": 71
},
"44": {
"from": 70,
"id": 44,
"to": 72
},
"45": {
"from": 73,
"id": 45,
"to": 64
},
"46": {
"from": 65,
"id": 46,
"to": 75
}
},
"nodes": {
"19": {
"attrs": [
66
],
"data": {
"name": "Input",
"type": 2
},
"id": 19,
"name": "Input",
"pos": {
"x": 48.0,
"y": 151.0
},
"type": "hex.builtin.nodes.custom.input"
},
"20": {
"attrs": [
68
],
"data": {
"name": "Count",
"type": 0
},
"id": 20,
"name": "Count",
"pos": {
"x": 50.0,
"y": 264.0
},
"type": "hex.builtin.nodes.custom.input"
},
"21": {
"attrs": [
53,
54
],
"data": null,
"id": 21,
"name": "hex.builtin.nodes.casting.int_to_buffer.header",
"pos": {
"x": 212.0,
"y": 315.0
},
"type": "hex.builtin.nodes.casting.int_to_buffer"
},
"22": {
"attrs": [
55,
56,
57,
58
],
"data": null,
"id": 22,
"name": "hex.builtin.nodes.buffer.slice.header",
"pos": {
"x": 384.0,
"y": 375.0
},
"type": "hex.builtin.nodes.buffer.slice"
},
"23": {
"attrs": [
59
],
"data": {
"data": 0
},
"id": 23,
"name": "hex.builtin.nodes.constants.int.header",
"pos": {
"x": 122.0,
"y": 423.0
},
"type": "hex.builtin.nodes.constants.int"
},
"24": {
"attrs": [
60
],
"data": {
"data": 1
},
"id": 24,
"name": "hex.builtin.nodes.constants.int.header",
"pos": {
"x": 120.0,
"y": 510.0
},
"type": "hex.builtin.nodes.constants.int"
},
"25": {
"attrs": [
63,
64,
65
],
"data": null,
"id": 25,
"name": "hex.builtin.nodes.bitwise.add.header",
"pos": {
"x": 720.0,
"y": 183.0
},
"type": "hex.builtin.nodes.bitwise.add"
},
"26": {
"attrs": [
69,
70
],
"data": null,
"id": 26,
"name": "hex.builtin.nodes.buffer.size.header",
"pos": {
"x": 383.0,
"y": 274.0
},
"type": "hex.builtin.nodes.buffer.size"
},
"27": {
"attrs": [
71,
72,
73
],
"data": null,
"id": 27,
"name": "hex.builtin.nodes.buffer.repeat.header",
"pos": {
"x": 595.0,
"y": 445.0
},
"type": "hex.builtin.nodes.buffer.repeat"
},
"28": {
"attrs": [
75
],
"data": {
"name": "Output",
"type": 2
},
"id": 28,
"name": "Output",
"pos": {
"x": 864.0,
"y": 330.0
},
"type": "hex.builtin.nodes.custom.output"
}
}
}
},
"name": "Caesar Cipher",
"type": "hex.builtin.nodes.custom.custom"
}

223
nodes/xor.hexnode Normal file
View File

@@ -0,0 +1,223 @@
{
"attrs": [
36,
37,
38
],
"data": {
"nodes": {
"links": {
"11": {
"from": 20,
"id": 11,
"to": 22
},
"13": {
"from": 23,
"id": 13,
"to": 32
},
"14": {
"from": 17,
"id": 14,
"to": 19
},
"15": {
"from": 14,
"id": 15,
"to": 15
},
"16": {
"from": 12,
"id": 16,
"to": 16
},
"17": {
"from": 9,
"id": 17,
"to": 11
},
"18": {
"from": 7,
"id": 18,
"to": 10
},
"19": {
"from": 31,
"id": 19,
"to": 8
},
"20": {
"from": 30,
"id": 20,
"to": 6
},
"22": {
"from": 31,
"id": 22,
"to": 18
},
"23": {
"from": 30,
"id": 23,
"to": 21
}
},
"nodes": {
"10": {
"attrs": [
14
],
"data": {
"data": 1
},
"id": 10,
"name": "hex.builtin.nodes.constants.int.header",
"pos": {
"x": 430.0,
"y": 364.0
},
"type": "hex.builtin.nodes.constants.int"
},
"11": {
"attrs": [
15,
16,
17
],
"data": null,
"id": 11,
"name": "hex.builtin.nodes.arithmetic.add.header",
"pos": {
"x": 579.0,
"y": 421.0
},
"type": "hex.builtin.nodes.arithmetic.add"
},
"12": {
"attrs": [
18,
19,
20
],
"data": null,
"id": 12,
"name": "hex.builtin.nodes.buffer.repeat.header",
"pos": {
"x": 661.0,
"y": 241.0
},
"type": "hex.builtin.nodes.buffer.repeat"
},
"13": {
"attrs": [
21,
22,
23
],
"data": null,
"id": 13,
"name": "hex.builtin.nodes.bitwise.xor.header",
"pos": {
"x": 818.0,
"y": 163.0
},
"type": "hex.builtin.nodes.bitwise.xor"
},
"14": {
"attrs": [
32
],
"data": {
"name": "Output",
"type": 2
},
"id": 14,
"name": "Output",
"pos": {
"x": 1000.0,
"y": 432.0
},
"type": "hex.builtin.nodes.custom.output"
},
"4": {
"attrs": [
30
],
"data": {
"name": "Input",
"type": 2
},
"id": 4,
"name": "Input",
"pos": {
"x": 82.0,
"y": 139.0
},
"type": "hex.builtin.nodes.custom.input"
},
"5": {
"attrs": [
31
],
"data": {
"name": "XOR Pad",
"type": 2
},
"id": 5,
"name": "XOR Pad",
"pos": {
"x": 89.0,
"y": 328.0
},
"type": "hex.builtin.nodes.custom.input"
},
"6": {
"attrs": [
6,
7
],
"data": null,
"id": 6,
"name": "hex.builtin.nodes.buffer.size.header",
"pos": {
"x": 269.0,
"y": 403.0
},
"type": "hex.builtin.nodes.buffer.size"
},
"7": {
"attrs": [
8,
9
],
"data": null,
"id": 7,
"name": "hex.builtin.nodes.buffer.size.header",
"pos": {
"x": 267.0,
"y": 486.0
},
"type": "hex.builtin.nodes.buffer.size"
},
"8": {
"attrs": [
10,
11,
12
],
"data": null,
"id": 8,
"name": "hex.builtin.nodes.arithmetic.div.header",
"pos": {
"x": 409.0,
"y": 465.0
},
"type": "hex.builtin.nodes.arithmetic.div"
}
}
}
},
"name": "XOR Pad",
"type": "hex.builtin.nodes.custom.custom"
}

View File

@@ -1,6 +1,7 @@
#pragma endian little
#include <std/io.pat>
#include <std/sys.pat>
#define ATMOSPHERE_REBOOT_TO_FATAL_MAGIC "AFE2"
#define ATMOSPHERE_REBOOT_TO_FATAL_MAGIC_1 "AFE1"
@@ -54,4 +55,4 @@ std::assert_warn(ctx.magic == ATMOSPHERE_REBOOT_TO_FATAL_MAGIC,
std::print("Error Description: 0x{:04X}", ctx.error_desc);
std::print("Program ID: {:016X}", ctx.program_id);
std::print("Program ID: {:016X}", ctx.program_id);

30
patterns/cchva.hexpat Normal file
View File

@@ -0,0 +1,30 @@
// Command and conquer voxel animation format
struct vec4_s {
float x [[color("FF0000")]];
float y [[color("00FF00")]];
float z [[color("0000FF")]];
float w [[color("FFFF00")]];
};
struct mat3x4_s {
vec4_s row[3];
};
struct name_s {
char buffer[16] [[color("EECCCC")]];
};
struct hva_s {
name_s name;
u32 numFrames;
u32 numNodes;
name_s nodeNames[numNodes];
};
struct frame_s {
mat3x4_s mat[hva.numNodes];
};
hva_s hva @0x00;
frame_s frames[hva.numFrames] @sizeof(hva);

13
patterns/ccpal.hexpat Normal file
View File

@@ -0,0 +1,13 @@
// Command and conquer palette format
struct Color {
u8 r;
u8 g;
u8 b;
};
struct Palette {
Color colors[256];
};
Palette pal @0x00;

69
patterns/ccvxl.hexpat Normal file
View File

@@ -0,0 +1,69 @@
// Command and Conquer voxel model format
struct vec4_s {
float x [[color("FF0000")]];
float y [[color("00FF00")]];
float z [[color("0000FF")]];
float w [[color("FFFF00")]];
};
struct vec3_s {
float x [[color("FF0000")]];
float y [[color("00FF00")]];
float z [[color("0000FF")]];
};
struct mat3x4_s {
vec4_s row[3];
};
struct name_s {
char buffer[16] [[color("EECCCC")]];
};
struct color_s {
u8 r;
u8 g;
u8 b;
};
struct vxl_limb_header_s {
name_s name;
s32 limb_number;
u32 _reserved1;
u32 _reserved2;
};
struct vxl_limb_tailer_s {
u32 span_start_offset;
u32 span_end_offset;
u32 span_data_offset;
float scale;
mat3x4_s matrix;
vec3_s min_bounds;
vec3_s max_bounds;
u8 xsize;
u8 ysize;
u8 zsize;
u8 normal_type;
};
struct vxl_s {
name_s name;
u32 palette_count;
u32 limb_count;
u32 tailer_count;
u32 body_size;
u8 remap_start_index;
u8 remap_end_index;
color_s internal_palette[256];
vxl_limb_header_s _headers[limb_count];
u8 body[body_size];
vxl_limb_tailer_s _tailers[limb_count];
};
struct frame_s {
mat3x4_s mat[hva.numNodes];
};
vxl_s vxl @0x00;

49
patterns/dmg.hexpat Normal file
View File

@@ -0,0 +1,49 @@
#pragma endian big
#include <type/magic.pat>
#include <type/size.pat>
#include <type/guid.pat>
#include <std/mem.pat>
// Parse DMG Structure per http://newosxbook.com/DMG.html
//
// UDIFResourceFile starts at size(file) - 512
struct UDIFResourceFile {
type::Magic<"koly"> Signature; // Magic ('koly')
u32 Version; // Current version is 4
type::Size<u32> HeaderSize; // sizeof(this), always 512
u32 Flags;
u64 RunningDataForkOffset; //
u64 DataForkOffset; // Data fork offset (usually 0, beginning of file)
type::Size<u64> DataForkLength; // Size of data fork (usually up to the XMLOffset, below)
u64 RsrcForkOffset; // Resource fork offset, if any
type::Size<u64> RsrcForkLength; // Resource fork length, if any
u32 SegmentNumber; // Usually 1, may be 0
u32 SegmentCount; // Usually 1, may be 0
type::GUID SegmentID; // 128-bit GUID identifier of segment (if SegmentNumber !=0)
u32 DataChecksumType; // Data fork
type::Size<u32> DataChecksumSize; // Checksum Information
u32 DataChecksum[DataChecksumSize]; // Up to 128-bytes (32 x 4) of checksum
u64 XMLOffset; // Offset of property list in DMG, from beginning
type::Size<u64> XMLLength; // Length of property list
u8 Reserved1[120]; // 120 reserved bytes - zeroed
u32 ChecksumType; // Master
type::Size<u32> ChecksumSize; // Checksum information
u32 Checksum[ChecksumSize]; // Up to 128-bytes (32 x 4) of checksum
u32 ImageVariant; // Commonly 1
u64 SectorCount; // Size of DMG when expanded, in sectors
u32 reserved2; // 0
u32 reserved3; // 0
u32 reserved4; // 0
};
UDIFResourceFile trailer @ std::mem::size() - 512;
char metadata_plist[trailer.XMLLength] @ trailer.XMLOffset;

View File

@@ -1,153 +1,181 @@
#define LABEL_GC 0xF9
#define LABEL_COMMENT 0xFE
#define LABEL_APPLICATION 0xFF
#define LABEL_PLAINTEXT 0x01
#define LABEL_APPLICATION_NETSCAPE "NETSCAPE"
#define CODE_FRAME 0x2C
#define CODE_EXTENSION 0x21
#define CODE_TRAILER 0x3B
#define MAX_BLOCKS 4096
#define GCT_ACCESS parent.parent.parent.parent.header.gct
#include <std/io.pat>
#include <std/core.pat>
#include <std/mem.pat>
#include <std/string.pat>
#pragma MIME image/gif
#pragma bitfield_order left_to_right
// gif89a
struct data_subblock_t {
u8 block_size;
u8 data_values[block_size];
bitfield GCT_Flags {
size : 3 [[comment("physical size = 2^(flags.size + 1)")]];
sort : 1 [[comment("Indicates if the table is sorted by importance")]];
colorRes : 3 [[comment("Indicates the richness of the original pallet")]];
enabled : 1;
};
bitfield LCT_Flags {
size : 3 [[comment("physical size = 2^(flags.size + 1)")]];
padding : 2;
sort : 1 [[comment("Indicates if the table is sorted by importance")]];
interlace : 1;
enable : 1;
};
bitfield GC_Flags {
transparent : 1;
userInput : 1;
disposalMode : 3 [[format("format::dispose_enum")]];
reserved : 3;
};
struct data_subblocks_t {
data_subblock_t data[while (std::mem::read_unsigned($, 1) != 0x00)];
u8 block_terminator; // 0x00
} [[inline]];
struct color {
u8 r, g, b;
} [[color(std::format("{:02X}{:02X}{:02X}", r, g, b))]];
struct header_t {
char header[3];
struct subblock {
u8 size;
if(size == 0) break;
u8 data[size];
};
struct block {
subblock blocks[MAX_BLOCKS];
};
fn exp2(auto n) {
return 1 << n;
};
struct Header {
char magic[3];
char version[3];
};
bitfield lsd_fields_t {
global_color_table_flag : 1;
color_resolution : 3;
sort_flag : 1;
size_of_global_color_table : 3;
} [[inline]];
struct logical_screen_descriptor_t {
u16 width;
u16 height;
lsd_fields_t fields;
u8 background_color_index;
u8 pixel_aspect_ratio;
GCT_Flags gctFlags;
u8 bgColorIndex;
u8 pixelAscpet;
if (gctFlags.enabled) {
color gct[(exp2(gctFlags.size + 1))];
color bgColor = gct[bgColorIndex];
}
};
struct frame {
u16 x;
u16 y;
u16 width;
u16 height;
LCT_Flags lctFlags;
if(lctFlags.enable) {
color lct[(exp2(lctFlags.size + 1))];
}
u8 lzwMinCode [[comment("This byte determines the initial number of bits used for LZW codes in the image data")]];
block lzwCompressedData [[comment("Data is pallet indecies either into current LDC or GCT and is compressed using LZW")]];
};
struct color_table_entry_t {
u8 red;
u8 green;
u8 blue;
struct comment {
block data [[hidden]];
char comment[] @ addressof(data.blocks) + 1; // TODO : need to find a better way of doing this
};
bitfield gce_fields_t {
padding : 3;
disposal_method : 3;
user_input_flag : 1;
transparent_color_flag : 1;
} [[inline]];
struct graphic_coltrol_extension_t {
u8 extension_introducer; // 0x21
u8 graphic_control_label; // 0xf9
u8 block_size;
gce_fields_t fields;
u16 delay_time;
u8 transparent_color_index;
u8 block_terminator;
struct application {
u8 blockSize [[hidden]];
char identifier[8] [[comment("Only known are: NETSCAPE")]];
char version[3] [[comment("Only known for NETSCAPE: '2.0'")]];
block b [[hidden]];
if(identifier == LABEL_APPLICATION_NETSCAPE) {
u16 loopcount @ addressof(b.blocks[0].data) + 1 [[comment("0, = Forever")]];
}
};
struct comment_extension_t {
u8 extension_introducer; // 0x21
u8 comment_label; // 0xfe
data_subblocks_t comment_data;
struct plaintext {
u8 blockSize [[hidden]];
u16 gridLeftPos;
u16 gridTopPos;
u16 gridWidth;
u16 gridHeight;
u8 cellWidth;
u8 cellHeight;
u8 textForegroundColorIndex [[hidden]];
u8 textBackgroundColorIndex [[hidden]];
color textForegroundColor @ addressof(GCT_ACCESS[textForegroundColorIndex]);
color textBackgroundColor @ addressof(GCT_ACCESS[textBackgroundColorIndex]);
block data [[hidden]];
char text[] @ addressof(data.blocks) + 1;
//char text[data.blocks[std::core::array_index()].size] @ addressof(data.blocks[std::core::array_index()].data);
};
struct plaintext_extension_t {
u8 extension_introducer; // 0x21
u8 plain_text_label; // 0x01
u8 block_size; // 12
u16 text_grid_left_position;
u16 text_grid_top_position;
u16 text_grid_width;
u16 text_grid_height;
u8 character_cell_width;
u8 character_cell_height;
u8 text_foreground_color_index;
u8 text_background_color_index;
data_subblocks_t plain_text_data;
struct graphical_control {
u8 blockSize [[hidden]];
GC_Flags flags;
u16 delay [[format("format::delay")]];
u8 transparentColorIndex;
block b [[hidden]];
};
struct application_extension_t {
u8 extension_introducer; // 0x21
u8 extension_label; // 0xff
u8 block_size; // 11
u8 application_identifier[8];
u8 application_authentication_code[3];
namespace format {
fn dispose_enum(u8 value) {
if(value == 0x00) return "Do nothing";
if(value == 0x01) return "Do not remove pixels";
if(value == 0x02) return "Restore background pixels";
if(value == 0x03) return "Restore previous pixels";
};
data_subblocks_t data;
fn extension_name(u8 label) {
if(label == LABEL_GC) return "Graphical Control Extension";
if(label == LABEL_COMMENT) return "Comment Extension";
if(label == LABEL_APPLICATION) return "Application Extension";
if(label == LABEL_PLAINTEXT) return "Plaintext Extension";
return "Unknown Extension";
};
fn content_name(ref frame f) {
if(f.code == CODE_FRAME) return "Frame";
if(f.code == CODE_EXTENSION) return "Extension";
if(f.code == CODE_TRAILER) return "End";
return "Unknown Content";
};
fn delay(u16 delay) {
if(delay == -1) return "forever";
else if(delay < 2) return "100ms";
else return std::string::to_string(delay * 10) + "ms";
return "notime";
};
}
struct extension {
u8 label [[format("format::extension_name")]];
if(label == LABEL_GC) graphical_control gc [[inline]];
if(label == LABEL_COMMENT) comment c [[inline]];
if(label == LABEL_APPLICATION) application a [[inline]];
if(label == LABEL_PLAINTEXT) plaintext [[inline]];
};
bitfield id_fields_t {
local_color_table : 1;
interlace_flag : 1;
sort_fla : 1;
padding : 2;
size_of_local_color_table : 3;
} [[inline]];
struct content {
u8 code [[hidden]];
if(code == CODE_FRAME) frame f [[inline]];
if(code == CODE_EXTENSION) extension e [[inline]];
if(code == CODE_TRAILER) break;
} [[format("format::content_name")]];
struct image_descriptor_t {
u8 image_separator; // 0x2c
u16 image_left_position;
u16 image_top_position;
u16 image_width;
u16 image_height;
id_fields_t fields;
struct Data {
content contents[while(!std::mem::eof())] [[inline]];
};
struct table_based_image_t {
u8 lzw_minimum_code_size;
data_subblocks_t data;
struct Gif {
Header header;
Data data;
};
struct gif_block_t {
if (std::mem::read_unsigned($, 1) == 0x21) {
if (std::mem::read_unsigned($+1, 1) == 0x01) {
plaintext_extension_t plaintext_extension;
}
else if (std::mem::read_unsigned($+1, 1) == 0xf9) {
graphic_coltrol_extension_t graphic_coltrol_extension;
}
else if (std::mem::read_unsigned($+1, 1) == 0xfe) {
comment_extension_t comment;
} else {
application_extension_t application_extension;
}
}
else if (std::mem::read_unsigned($, 1) == 0x2c) {
image_descriptor_t image_descriptor;
if (image_descriptor.fields.local_color_table) {
color_table_entry_t local_color_table[1<<(image_descriptor.fields.size_of_local_color_table + 1)];
}
table_based_image_t image;
}
} [[inline]];
struct gif_t {
header_t header;
logical_screen_descriptor_t logical_screen_descriptor;
if (logical_screen_descriptor.fields.global_color_table_flag) {
color_table_entry_t global_color_table[1<<(logical_screen_descriptor.fields.size_of_global_color_table + 1)];
}
gif_block_t blocks[while (std::mem::read_unsigned($, 1) != 0x3b)];
u8 trailer; // 0x3b
};
gif_t gif @ 0x00;
Gif gif @ 0x00;

122
patterns/jpeg.hexpat Normal file
View File

@@ -0,0 +1,122 @@
#include <std/mem.pat>
#pragma endian big
#pragma MIME image/jpeg
enum Marker : u8 {
TEM = 0x01,
SOF0 = 0xC0,
SOF1 = 0xC1,
SOF2 = 0xC2,
SOF3 = 0xC3,
DHT = 0xC4,
SOF5 = 0xC5,
SOF6 = 0xC6,
SOF7 = 0xC7,
SOI = 0xD8,
EOI = 0xD9,
SOS = 0xDA,
DQT = 0xDB,
DNL = 0xDC,
DRI = 0xDD,
DHP = 0xDE,
APP0 = 0xE0,
APP1 = 0xE1,
APP2 = 0xE2,
APP3 = 0xE3,
APP4 = 0xE4,
APP5 = 0xE5,
APP6 = 0xE6,
APP7 = 0xE7,
APP8 = 0xE8,
APP9 = 0xE9,
APP10 = 0xEA,
APP11 = 0xEB,
APP12 = 0xEC,
APP13 = 0xED,
APP14 = 0xEE,
APP15 = 0xEF,
COM = 0xFE
};
enum DensityUnit : u8 {
NoUnit = 0x00,
PixelsPerInch = 0x01,
PixelsPerCm = 0x02
};
struct Pixel {
u8 r, g, b;
} [[sealed, transform("transform_pixel")]];
fn transform_pixel(Pixel pixel) {
return (0xFF << 24) | (pixel.b << 16) | (pixel.g << 8) | (pixel.r << 0);
};
struct APP0 {
char magic[5];
u8 versionMajor, versionMinor;
DensityUnit densityUnit;
u16 densityX, densityY;
u8 thumbnailX, thumbnailY;
Pixel thumbnail[thumbnailX * thumbnailY] [[sealed]];
};
enum ComponentId : u8 {
Y = 1,
CB = 2,
CR = 3,
I = 4,
Q = 5
};
struct SOF0Component {
ComponentId componentId;
u8 samplingFactors;
u8 quantizationTableId;
};
struct SOF0 {
u8 bitsPerSample;
u16 imageHeight, imageWidth;
u8 numComponents;
SOF0Component components[numComponents];
};
struct SOSComponent {
ComponentId componentId;
u8 huffmanTable;
};
struct SOS {
u8 numComponents;
SOSComponent components[numComponents];
u8 startSpectralSelection;
u8 endSpectral;
u8 apprBitPos;
u8 image_data[while(!std::mem::eof())] [[sealed]];
};
struct Segment {
u8 magic;
Marker marker;
if (marker == Marker::SOI || marker == Marker::EOI) {
} else {
u16 length;
if (marker == Marker::APP0) {
APP0 data;
} else if (marker == Marker::SOF0) {
SOF0 data;
} else if (marker == Marker::SOS) {
SOS data;
} else {
u8 data[length - sizeof(length)] [[sealed]];
}
}
};
Segment segments[while(!std::mem::eof())] @ 0x00;

View File

@@ -45,6 +45,12 @@ struct Value {
Value values[listLength] [[static]];
} else if (parent.tag == Tag::Compound) {
Element values[while(true)];
} else if (parent.tag == Tag::IntArray){
s32 arrayLength;
s32 value[arrayLength] [[sealed]];
} else if (parent.tag == Tag::LongArray) {
s32 arrayLength;
s64 value[arrayLength] [[sealed]];
} else {
std::error(std::format("Invalid tag {:02X}", TypeTag));
}
@@ -67,4 +73,4 @@ struct NBT {
Element element[while(true)] [[inline]];
};
NBT nbt @ 0x00;
NBT nbt @ 0x00;

76
patterns/pif.hexpat Normal file
View File

@@ -0,0 +1,76 @@
/* PIF - Portable Image Format
*
* Basic decoder for the PIF file structure
* https://github.com/gfcwfzkm/PIF-Image-Format
*/
#pragma MIME image/pif
#pragma endian little
enum imageType_t : u16 {
RGB888 = 0x433C,
RGB565 = 0xE5C5,
RGB332 = 0x1E53,
RGB16C = 0xB895,
BLWH = 0x7DAA,
IND24 = 0x4952,
IND16 = 0x4947,
IND8 = 0x4942
};
enum compression_t : u16 {
NO_COMPRESSION = 0,
RLE_COMPRESSION = 0x7DDE
};
struct PIFFileHeader {
char Signature[4];
u32 FileSize;
u32 ImageOffset;
};
struct PIFInfoHeader {
imageType_t ImageType;
u16 BitsPerPixel;
u16 ImageWidth;
u16 ImageHeight;
u32 ImageSize;
u16 ColorTableSize;
compression_t Compression;
};
struct PIF {
PIFFileHeader PIF_FileHeader;
PIFInfoHeader PIF_ImageHeader;
if (PIF_ImageHeader.ImageType == imageType_t::IND24)
{
u24 ColorTable[PIF_ImageHeader.ColorTableSize/3];
}
else if (PIF_ImageHeader.ImageType == imageType_t::IND16)
{
u16 ColorTable[PIF_ImageHeader.ColorTableSize/2];
}
else if (PIF_ImageHeader.ImageType == imageType_t::IND8)
{
u8 ColorTable[PIF_ImageHeader.ColorTableSize];
}
if ((PIF_ImageHeader.ImageType == imageType_t::RGB888) ||
(PIF_ImageHeader.ImageType == imageType_t::IND24))
{
u24 ImageData[(PIF_FileHeader.FileSize - PIF_FileHeader.ImageOffset)/3];
}
else if ((PIF_ImageHeader.ImageType == imageType_t::RGB565) ||
(PIF_ImageHeader.ImageType == imageType_t::IND16))
{
u16 ImageData[(PIF_FileHeader.FileSize - PIF_FileHeader.ImageOffset)/2];
}
else if ((PIF_ImageHeader.ImageType == imageType_t::RGB332) ||
(PIF_ImageHeader.ImageType == imageType_t::IND8))
{
u8 ImageData[(PIF_FileHeader.FileSize - PIF_FileHeader.ImageOffset)/1];
}
};
PIF pif @ 0x00;

80
patterns/qbcl.hexpat Normal file
View File

@@ -0,0 +1,80 @@
// Qubicle QBCL format
struct String {
u32 len;
char string[len];
};
struct Matrix {
u32 sizex;
u32 sizey;
u32 sizez;
s32 tx;
s32 ty;
s32 tz;
float pivotx;
float pivoty;
float pivotz;
u32 compressedDataSize;
u8 zip[compressedDataSize];
};
// Rotation matrix according to wikipedia
// https://en.wikipedia.org/wiki/Rotation_matrix#Basic_rotations
struct Matrices {
float row1[3];
float row2[3];
float row3[3];
};
using Node;
struct Model {
Matrices rotation;
u32 childCount;
Node nodes[childCount];
};
struct Compound {
Matrix matrix;
u32 childCount;
Node nodes[childCount];
};
struct Node {
u32 type;
u32 unknown;
String name;
u8 visible;
u8 unknown2;
u8 locked;
if (type == 0) {
Matrix matrix;
} else if (type == 1) {
Model model;
} else if (type == 2) {
Compound compound;
}
};
struct Header {
u32 magic;
u32 version;
u32 fileversion;
u32 thumbwidth;
u32 thumbheight;
char bgra[thumbwidth * thumbheight * 4];
String title;
String desc;
String metadata;
String author;
String company;
String website;
String copyright;
// Maybe change and creation time?
double time1;
double time2;
Node node;
};
Header hdr @0x00;

99
patterns/qoi.hexpat Normal file
View File

@@ -0,0 +1,99 @@
#pragma MIME image/qoi
#pragma endian big
#pragma bitfield_order left_to_right
#include <std/mem.pat>
namespace qoi {
enum channels_t : u8 {
RGB = 3,
RGBA = 4
};
enum color_space_t : u8 {
sRGB = 0,
linear = 1
};
struct header_t {
char magic[4];
u32 width;
u32 height;
channels_t channels;
color_space_t color_space;
};
enum tags_t : u8 {
index = 0b00000000 ... 0b00111111,
diff = 0b01000000 ... 0b01111111,
luma = 0b10000000 ... 0b10111111,
run = 0b11000000 ... 0b11111101,
rgb = 0b11111110,
rgba = 0b11111111,
};
bitfield op_index {
tag: 2;
index: 6;
} [[color("0000FF")]];
bitfield op_diff {
tag: 2;
dr: 2;
dg: 2;
db: 2;
} [[color("FFFFFF")]];
bitfield op_luma {
tag: 2;
diff_green: 6;
dr_dg: 4;
db_dg: 4;
} [[color("FFFF00")]];
bitfield op_run {
tag: 2;
run_length: 6;
} [[color("00FF00")]];
struct op_rgb {
u8 tag;
u8 red;
u8 green;
u8 blue;
} [[color("FF7700")]];
struct op_rgba {
u8 tag;
u8 red;
u8 green;
u8 blue;
u8 alpha;
} [[color("FF0000")]];
u8 op_type;
fn get_op_type() {
op_type = std::mem::read_unsigned($, 1);
if (op_type < tags_t::rgb)
op_type &= 0b11000000;
};
struct op_t {
qoi::get_op_type();
if (op_type == tags_t::index) op_index;
else if (op_type == tags_t::diff) op_diff;
else if (op_type == tags_t::luma) op_luma;
else if (op_type == tags_t::run) op_run;
else if (op_type == tags_t::rgb) op_rgb;
else if (op_type == tags_t::rgba) op_rgba;
};
struct file_t {
header_t header;
op_t data[while(!std::mem::eof())];
};
} // namespace qoi
qoi::file_t qoi_picture @ 0x0;

View File

@@ -9,7 +9,8 @@
#include <std/sys.pat>
#define HEADER "ustar "
#define GNU_HEADER "ustar "
#define PAX_HEADER "ustar\x00"
#define NULL "\x00"
fn octal_to_decimal(str value) {
@@ -83,6 +84,6 @@ struct tar {
};
char magic[6] @ 0x00000101 [[hidden]];
std::assert(magic == HEADER, "Magic bytes are not correct! Perhaps wrong file?");
std::assert(magic == PAX_HEADER || magic == GNU_HEADER, "Magic bytes are not correct! Perhaps wrong file?");
tar tar[while(!std::mem::eof())] @ 0x000;

View File

@@ -72,7 +72,7 @@ struct Footer {
u32 developerDirectoryOffset;
char signature[0x10];
char dot;
char null;
char zero;
};
Header header @ 0x0;

403
patterns/xbeh.hexpat Normal file
View File

@@ -0,0 +1,403 @@
#pragma MIME audio/x-xbox-executable
#include <type/magic.pat>
#include <type/size.pat>
#include <type/time.pat>
#include <std/io.pat>
#include <std/mem.pat>
bitfield AllowedMedia {
HardDisk : 1;
DVD_X2 : 1;
DVD_CD : 1;
CD : 1;
DVD_5_RO : 1;
DVD_9_RO : 1;
DVD_5_RW : 1;
DVD_9_RW : 1;
Dongle : 1;
MediaBoard : 1;
padding : 20;
NonSecureHardDisk : 1;
NonSecureMode : 1;
} [[right_to_left]];
bitfield GameRegion {
NorthAmerica : 1;
Japan : 1;
RestOfTheWorld : 1;
padding : 28;
Manufacturing : 1;
} [[right_to_left]];
struct Certificate {
type::Size<u32> certificateSize;
type::time32_t timeDate;
u32 titleId;
char16 titleName[0x50 / 2];
u32 alternateTitleIds[16];
AllowedMedia allowedMedia;
GameRegion gameRegion;
u32 gameRatings;
u128 lanKey;
u128 signatureKey;
u128 alternateSignatureKeys[16];
};
bitfield InitializationFlags {
MountUtilityDrive : 1;
FormatUtilityDrive : 1;
Limit64Megabytes : 1;
DontSetuptHarddisk : 1;
padding : 28;
} [[right_to_left]];
union EntryPoint {
u32 betaAddress [[format("format_beta_entrypoint")]];
u32 debugAddress [[format("format_debug_entrypoint")]];
u32 retailAddress [[format("format_retail_entrypoint")]];
if ((betaAddress ^ 0xE682F45B) - parent.baseAddress < std::mem::size())
u8 beta @ (betaAddress ^ 0xE682F45B) - parent.baseAddress;;
if ((debugAddress ^ 0x94859D4B) - parent.baseAddress < std::mem::size())
u8 debug @ (debugAddress ^ 0x94859D4B) - parent.baseAddress;;
if ((retailAddress ^ 0xA8FC57AB) - parent.baseAddress < std::mem::size())
u8 retail @ (retailAddress ^ 0xA8FC57AB) - parent.baseAddress;
};
fn format_beta_entrypoint(u32 value) {
return std::format("0x{:08X}", value ^ 0xE682F45B);
};
fn format_debug_entrypoint(u32 value) {
return std::format("0x{:08X}", value ^ 0x94859D4B);
};
fn format_retail_entrypoint(u32 value) {
return std::format("0x{:08X}", value ^ 0xA8FC57AB);
};
#define KERNEL_BASE 0x8000'0000
enum KernelImageFunction : u32 {
AvGetSavedDataAddress = 1 + KERNEL_BASE,
AvSendTVEncoderOption = 2 + KERNEL_BASE,
AvSetDisplayMode = 3 + KERNEL_BASE,
AvSetSavedDataAddress = 4 + KERNEL_BASE,
DbgBreakPoint = 5 + KERNEL_BASE,
DbgBreakPointWithStatus = 6 + KERNEL_BASE,
DbgLoadImageSymbols = 7 + KERNEL_BASE,
DbgPrint = 8 + KERNEL_BASE,
HalReadSMCTrayState = 9 + KERNEL_BASE,
DbgPrompt = 10 + KERNEL_BASE,
DbgUnLoadImageSymbols = 11 + KERNEL_BASE,
ExAcquireReadWriteLockExclusive = 12 + KERNEL_BASE,
ExAcquireReadWriteLockShared = 13 + KERNEL_BASE,
ExAllocatePool = 14 + KERNEL_BASE,
ExAllocatePoolWithTag = 15 + KERNEL_BASE,
ExEventObjectType = 16 + KERNEL_BASE,
ExFreePool = 17 + KERNEL_BASE,
ExInitializeReadWriteLock = 18 + KERNEL_BASE,
ExInterlockedAddLargeInteger = 19 + KERNEL_BASE,
ExInterlockedAddLargeStatistic = 20 + KERNEL_BASE,
ExInterlockedCompareExchange64 = 21 + KERNEL_BASE,
ExMutantObjectType = 22 + KERNEL_BASE,
ExQueryPoolBlockSize = 23 + KERNEL_BASE,
ExQueryNonVolatileSetting = 24 + KERNEL_BASE,
ExReadWriteRefurbInfo = 25 + KERNEL_BASE,
ExRaiseException = 26 + KERNEL_BASE,
ExRaiseStatus = 27 + KERNEL_BASE,
ExReleaseReadWriteLock = 28 + KERNEL_BASE,
ExSaveNonVolatileSetting = 29 + KERNEL_BASE,
ExSemaphoreObjectType = 30 + KERNEL_BASE,
ExTimerObjectType = 31 + KERNEL_BASE,
ExfInterlockedInsertHeadList = 32 + KERNEL_BASE,
ExfInterlockedInsertTailList = 33 + KERNEL_BASE,
ExfInterlockedRemoveHeadList = 34 + KERNEL_BASE,
FscGetCacheSize = 35 + KERNEL_BASE,
FscInvalidateIdleBlocks = 36 + KERNEL_BASE,
FscSetCacheSize = 37 + KERNEL_BASE,
HalClearSoftwareInterrupt = 38 + KERNEL_BASE,
HalDisableSystemInterrupt = 39 + KERNEL_BASE,
HalDiskCachePartitionCount = 40 + KERNEL_BASE,
HalDiskModelNumber = 41 + KERNEL_BASE,
HalDiskSerialNumber = 42 + KERNEL_BASE,
HalEnableSystemInterrupt = 43 + KERNEL_BASE,
HalGetInterruptVector = 44 + KERNEL_BASE,
HalReadSMBusValue = 45 + KERNEL_BASE,
HalReadWritePCISpace = 46 + KERNEL_BASE,
HalRegisterShutdownNotification = 47 + KERNEL_BASE,
HalRequestSoftwareInterrupt = 48 + KERNEL_BASE,
HalReturnToFirmware = 49 + KERNEL_BASE,
HalWriteSMBusValue = 50 + KERNEL_BASE,
InterlockedCompareExchange = 51 + KERNEL_BASE,
InterlockedDecrement = 52 + KERNEL_BASE,
InterlockedIncrement = 53 + KERNEL_BASE,
InterlockedExchange = 54 + KERNEL_BASE,
InterlockedExchangeAdd = 55 + KERNEL_BASE,
InterlockedFlushSList = 56 + KERNEL_BASE,
InterlockedPopEntrySList = 57 + KERNEL_BASE,
InterlockedPushEntrySList = 58 + KERNEL_BASE,
IoAllocateIrp = 59 + KERNEL_BASE,
IoBuildAsynchronousFsdRequest = 60 + KERNEL_BASE,
IoBuildDeviceIoControlRequest = 61 + KERNEL_BASE,
IoBuildSynchronousFsdRequest = 62 + KERNEL_BASE,
IoCheckShareAccess = 63 + KERNEL_BASE,
IoCompletionObjectType = 64 + KERNEL_BASE,
IoCreateDevice = 65 + KERNEL_BASE,
IoCreateFile = 66 + KERNEL_BASE,
IoCreateSymbolicLink = 67 + KERNEL_BASE,
IoDeleteDevice = 68 + KERNEL_BASE,
IoDeleteSymbolicLink = 69 + KERNEL_BASE,
IoDeviceObjectType = 70 + KERNEL_BASE,
IoFileObjectType = 71 + KERNEL_BASE,
IoFreeIrp = 72 + KERNEL_BASE,
IoInitializeIrp = 73 + KERNEL_BASE,
IoInvalidDeviceRequest = 74 + KERNEL_BASE,
IoQueryFileInformation = 75 + KERNEL_BASE,
IoQueryVolumeInformation = 76 + KERNEL_BASE,
IoQueueThreadIrp = 77 + KERNEL_BASE,
IoRemoveShareAccess = 78 + KERNEL_BASE,
IoSetIoCompletion = 79 + KERNEL_BASE,
IoSetShareAccess = 80 + KERNEL_BASE,
IoStartNextPacket = 81 + KERNEL_BASE,
IoStartNextPacketByKey = 82 + KERNEL_BASE,
IoStartPacket = 83 + KERNEL_BASE,
IoSynchronousDeviceIoControlRequest = 84 + KERNEL_BASE,
IoSynchronousFsdRequest = 85 + KERNEL_BASE,
IofCallDriver = 86 + KERNEL_BASE,
IofCompleteRequest = 87 + KERNEL_BASE,
KdDebuggerEnabled = 88 + KERNEL_BASE,
KdDebuggerNotPresent = 89 + KERNEL_BASE,
IoDismountVolume = 90 + KERNEL_BASE,
IoDismountVolumeByName = 91 + KERNEL_BASE,
KeAlertResumeThread = 92 + KERNEL_BASE,
KeAlertThread = 93 + KERNEL_BASE,
KeBoostPriorityThread = 94 + KERNEL_BASE,
KeBugCheck = 95 + KERNEL_BASE,
KeBugCheckEx = 96 + KERNEL_BASE,
KeCancelTimer = 97 + KERNEL_BASE,
KeConnectInterrupt = 98 + KERNEL_BASE,
KeDelayExecutionThread = 99 + KERNEL_BASE,
KeDisconnectInterrupt = 100 + KERNEL_BASE,
KeEnterCriticalRegion = 101 + KERNEL_BASE,
MmGlobalData = 102 + KERNEL_BASE,
KeGetCurrentIrql = 103 + KERNEL_BASE,
KeGetCurrentThread = 104 + KERNEL_BASE,
KeInitializeApc = 105 + KERNEL_BASE,
KeInitializeDeviceQueue = 106 + KERNEL_BASE,
KeInitializeDpc = 107 + KERNEL_BASE,
KeInitializeEvent = 108 + KERNEL_BASE,
KeInitializeInterrupt = 109 + KERNEL_BASE,
KeInitializeMutant = 110 + KERNEL_BASE,
KeInitializeQueue = 111 + KERNEL_BASE,
KeInitializeSemaphore = 112 + KERNEL_BASE,
KeInitializeTimerEx = 113 + KERNEL_BASE,
KeInsertByKeyDeviceQueue = 114 + KERNEL_BASE,
KeInsertDeviceQueue = 115 + KERNEL_BASE,
KeInsertHeadQueue = 116 + KERNEL_BASE,
KeInsertQueue = 117 + KERNEL_BASE,
KeInsertQueueApc = 118 + KERNEL_BASE,
KeInsertQueueDpc = 119 + KERNEL_BASE,
KeInterruptTime = 120 + KERNEL_BASE,
KeIsExecutingDpc = 121 + KERNEL_BASE,
KeLeaveCriticalRegion = 122 + KERNEL_BASE,
KePulseEvent = 123 + KERNEL_BASE,
KeQueryBasePriorityThread = 124 + KERNEL_BASE,
KeQueryInterruptTime = 125 + KERNEL_BASE,
KeQueryPerformanceCounter = 126 + KERNEL_BASE,
KeQueryPerformanceFrequency = 127 + KERNEL_BASE,
KeQuerySystemTime = 128 + KERNEL_BASE,
KeRaiseIrqlToDpcLevel = 129 + KERNEL_BASE,
KeRaiseIrqlToSynchLevel = 130 + KERNEL_BASE,
KeReleaseMutant = 131 + KERNEL_BASE,
KeReleaseSemaphore = 132 + KERNEL_BASE,
KeRemoveByKeyDeviceQueue = 133 + KERNEL_BASE,
KeRemoveDeviceQueue = 134 + KERNEL_BASE,
KeRemoveEntryDeviceQueue = 135 + KERNEL_BASE,
KeRemoveQueue = 136 + KERNEL_BASE,
KeRemoveQueueDpc = 137 + KERNEL_BASE,
KeResetEvent = 138 + KERNEL_BASE,
KeRestoreFloatingPointState = 139 + KERNEL_BASE,
KeResumeThread = 140 + KERNEL_BASE,
KeRundownQueue = 141 + KERNEL_BASE,
KeSaveFloatingPointState = 142 + KERNEL_BASE,
KeSetBasePriorityThread = 143 + KERNEL_BASE,
KeSetDisableBoostThread = 144 + KERNEL_BASE,
KeSetEvent = 145 + KERNEL_BASE,
KeSetEventBoostPriority = 146 + KERNEL_BASE,
KeSetPriorityProcess = 147 + KERNEL_BASE,
KeSetPriorityThread = 148 + KERNEL_BASE,
KeSetTimer = 149 + KERNEL_BASE,
KeSetTimerEx = 150 + KERNEL_BASE,
KeStallExecutionProcessor = 151 + KERNEL_BASE,
KeSuspendThread = 152 + KERNEL_BASE,
KeSynchronizeExecution = 153 + KERNEL_BASE,
KeSystemTime = 154 + KERNEL_BASE,
KeTestAlertThread = 155 + KERNEL_BASE,
KeTickCount = 156 + KERNEL_BASE,
KeTimeIncrement = 157 + KERNEL_BASE,
KeWaitForMultipleObjects = 158 + KERNEL_BASE,
KeWaitForSingleObject = 159 + KERNEL_BASE,
KfRaiseIrql = 160 + KERNEL_BASE,
KfLowerIrql = 161 + KERNEL_BASE,
KiBugCheckData = 162 + KERNEL_BASE,
KiUnlockDispatcherDatabase = 163 + KERNEL_BASE,
LaunchDataPage = 164 + KERNEL_BASE,
MmAllocateContiguousMemory = 165 + KERNEL_BASE,
MmAllocateContiguousMemoryEx = 166 + KERNEL_BASE,
MmAllocateSystemMemory = 167 + KERNEL_BASE,
MmClaimGpuInstanceMemory = 168 + KERNEL_BASE,
MmCreateKernelStack = 169 + KERNEL_BASE,
MmDeleteKernelStack = 170 + KERNEL_BASE,
MmFreeContiguousMemory = 171 + KERNEL_BASE,
MmFreeSystemMemory = 172 + KERNEL_BASE,
MmGetPhysicalAddress = 173 + KERNEL_BASE,
MmIsAddressValid = 174 + KERNEL_BASE,
MmLockUnlockBufferPages = 175 + KERNEL_BASE,
MmLockUnlockPhysicalPage = 176 + KERNEL_BASE,
MmMapIoSpace = 177 + KERNEL_BASE,
MmPersistContiguousMemory = 178 + KERNEL_BASE,
MmQueryAddressProtect = 179 + KERNEL_BASE,
MmQueryAllocationSize = 180 + KERNEL_BASE,
MmQueryStatistics = 181 + KERNEL_BASE,
MmSetAddressProtect = 182 + KERNEL_BASE,
MmUnmapIoSpace = 183 + KERNEL_BASE,
NtAllocateVirtualMemory = 184 + KERNEL_BASE,
NtCancelTimer = 185 + KERNEL_BASE,
NtClearEvent = 186 + KERNEL_BASE,
NtClose = 187 + KERNEL_BASE,
NtCreateDirectoryObject = 188 + KERNEL_BASE,
NtCreateEvent = 189 + KERNEL_BASE,
NtCreateFile = 190 + KERNEL_BASE,
NtCreateIoCompletion = 191 + KERNEL_BASE,
NtCreateMutant = 192 + KERNEL_BASE,
NtCreateSemaphore = 193 + KERNEL_BASE,
NtCreateTimer = 194 + KERNEL_BASE,
NtDeleteFile = 195 + KERNEL_BASE,
NtDeviceIoControlFile = 196 + KERNEL_BASE,
NtDuplicateObject = 197 + KERNEL_BASE,
NtFlushBuffersFile = 198 + KERNEL_BASE,
NtFreeVirtualMemory = 199 + KERNEL_BASE,
NtFsControlFile = 200 + KERNEL_BASE,
NtOpenDirectoryObject = 201 + KERNEL_BASE,
NtOpenFile = 202 + KERNEL_BASE,
NtOpenSymbolicLinkObject = 203 + KERNEL_BASE,
NtProtectVirtualMemory = 204 + KERNEL_BASE,
NtPulseEvent = 205 + KERNEL_BASE,
NtQueueApcThread = 206 + KERNEL_BASE,
NtQueryDirectoryFile = 207 + KERNEL_BASE
};
struct KernelImageThunk {
KernelImageFunction addresses[while(std::mem::read_unsigned($, 4) != 0x00)];
padding[4];
};
union KernelImageThunkAddress {
u32 debugAddress [[format("format_debug_kernel_image_thunk_address")]];
u32 retailAddress [[format("format_retail_kernel_image_thunk_address")]];
if ((debugAddress ^ 0xEFB1F152) - parent.baseAddress < std::mem::size())
KernelImageThunk debug @ (debugAddress ^ 0xEFB1F152) - parent.baseAddress;;
if ((retailAddress ^ 0x5B6D40B6) - parent.baseAddress < std::mem::size())
KernelImageThunk retail @ (retailAddress ^ 0x5B6D40B6) - parent.baseAddress;
};
fn format_debug_kernel_image_thunk_address(u32 value) {
return std::format("0x{:08X}", value ^ 0xEFB1F152);
};
fn format_retail_kernel_image_thunk_address(u32 value) {
return std::format("0x{:08X}", value ^ 0x5B6D40B6);
};
struct TLS {
u32 rawDataStart, rawDataEnd;
u32 indexAddress;
u32 callbacksAddress;
type::Size<u32> zeroFillSize;
u32 characteristics;
};
fn relative_to_base(auto pointer) {
return -parent.baseAddress;
};
fn relative_to_base_section(auto pointer) {
return -parent.parent.baseAddress;
};
bitfield LibraryFlags {
QFEVersion : 13;
Approved : 2;
DebugBuild : 1;
} [[right_to_left]];
struct LibraryVersion {
char libraryName[8];
u16 major, minor, build;
LibraryFlags flags;
};
bitfield SectionFlags {
Writable : 1;
Preload : 1;
Executable : 1;
InsertedFile : 1;
HeadPageReadOnly : 1;
TailPageReadOnly : 1;
padding : 26;
} [[right_to_left]];
struct SectionHeader {
SectionFlags sectionFlags;
u32 virtualAddress;
type::Size<u32> virtualSize;
u32 rawAddress;
type::Size<u32> rawSize;
char *sectionName[] : u32 [[pointer_base("relative_to_base_section")]];
u32 *sectionNameRefrenceCount : u32 [[pointer_base("relative_to_base_section")]];
u16 *headSharedPageReferenceCount : u32 [[pointer_base("relative_to_base_section")]];
u16 *tailSharedPageReferenceCount : u32 [[pointer_base("relative_to_base_section")]];
u8 sectionDigest[20];
u8 data[rawSize] @ rawAddress [[sealed]];
};
struct XBEH {
type::Magic<"XBEH"> magic;
u8 signature[0x100] [[sealed]];
u32 baseAddress;
type::Size<u32> headerSize, imageSize, imageHeaderSize;
type::time32_t timeDate;
Certificate *certificate : u32 [[pointer_base("relative_to_base")]];
u32 numSections;
SectionHeader *sectionHeader[numSections] : u32 [[pointer_base("relative_to_base")]];
InitializationFlags initializationFlags;
EntryPoint entrypoint;
TLS *tls : u32 [[pointer_base("relative_to_base")]];
type::Size<u32> stackSize;
u32 peHeapReserve, peHeapCommit, peBaseAddress;
type::Size<u32> peImageSize;
u32 peChecksum;
type::time32_t peTimeDate;
char *debugPathNameAddress[] : u32 [[pointer_base("relative_to_base")]];
char *debugFileNameAddress[] : u32 [[pointer_base("relative_to_base")]];
char16 *utf16DebugFileNameAddress[] : u32 [[pointer_base("relative_to_base")]];
KernelImageThunkAddress kernelImageThunkAddress;
u32 nonKernelImportDirectoryAddress;
u32 numLibraryVersions;
LibraryVersion *libraryVersonTable[numLibraryVersions] : u32 [[pointer_base("relative_to_base")]];
LibraryVersion *kernelLibraryVersion : u32 [[pointer_base("relative_to_base")]];
LibraryVersion *xapiLibraryVersion : u32 [[pointer_base("relative_to_base")]];
u32 logoBitMapAddress, logoBitmapSize;
u64 unknown1;
u32 unknown2;
u8 logoBitmap[logoBitmapSize] @ logoBitMapAddress - baseAddress;
};
XBEH xbeh @ 0x00;

Binary file not shown.

Binary file not shown.

Binary file not shown.