mirror of
https://github.com/WerWolv/ImHex-Patterns.git
synced 2026-03-31 05:15:54 -05:00
Compare commits
26 Commits
ImHex-v1.2
...
ImHex-v1.2
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
72acac1082 | ||
|
|
a9d6c882ac | ||
|
|
7ecfcd446d | ||
|
|
b094757b03 | ||
|
|
1d0b11372f | ||
|
|
f01ddec350 | ||
|
|
64136ba16c | ||
|
|
1e45938887 | ||
|
|
f32b162647 | ||
|
|
d2685aabf5 | ||
|
|
8027cda032 | ||
|
|
a178509b3c | ||
|
|
56411ae067 | ||
|
|
7ee489237d | ||
|
|
4d97e79097 | ||
|
|
9fec10000a | ||
|
|
b0d8b81861 | ||
|
|
c7fbb661ae | ||
|
|
7e19b4cb10 | ||
|
|
ff2726ce8a | ||
|
|
ed47fa65f1 | ||
|
|
f0963603bf | ||
|
|
15548b92e2 | ||
|
|
87efc6cf54 | ||
|
|
5e48adcb9d | ||
|
|
f548643933 |
@@ -33,6 +33,13 @@ Hex patterns, include patterns and magic files for the use with the ImHex Hex Ed
|
||||
| IP | | `patterns/ip.hexpat` | Ethernet II Frames (IP Packets) |
|
||||
| UF2 | | `patterns/uf2.hexpat` | [USB Flashing Format](https://github.com/microsoft/uf2) |
|
||||
| File System | | `patterns/fs.hexpat` | Drive File System |
|
||||
| Bencode | `application/x-bittorrent` | `patterns/bencode.hexpat` | Bencode encoding, used by Torrent files |
|
||||
| Protobuf | | `patterns/protobuf.hexpat` | Google Protobuf encoding |
|
||||
| OGG | `audio/ogg` | `patterns/ogg.hexpat` | OGG Audio format |
|
||||
| STL | `model/stl` | `patterns/stl.hexpat` | STL 3D Model format |
|
||||
| VHDX | | `patterns/vhdx.hexpat` | Microsoft Hyper-V Virtual Hard Disk format |
|
||||
| NTAG | | `patterns/ntag.hexpat` | NTAG213/NTAG215/NTAG216, NFC Forum Type 2 Tag compliant IC |
|
||||
| Shell Link | `application/x-ms-shortcut` | `patterns/lnk.hexpat` | Windows Shell Link file format |
|
||||
|
||||
### Scripts
|
||||
|
||||
@@ -89,6 +96,7 @@ Hex patterns, include patterns and magic files for the use with the ImHex Hex Ed
|
||||
| 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 |
|
||||
@@ -99,6 +107,7 @@ Hex patterns, include patterns and magic files for the use with the ImHex Hex Ed
|
||||
| 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 |
|
||||
| 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 |
|
||||
|
||||
256
encodings/cyrillic_cp866.tbl
Normal file
256
encodings/cyrillic_cp866.tbl
Normal file
@@ -0,0 +1,256 @@
|
||||
00=NUL
|
||||
01=☺
|
||||
02=☻
|
||||
03=♥
|
||||
04=♦
|
||||
05=♣
|
||||
06=♠
|
||||
07=•
|
||||
08=◘
|
||||
09=○
|
||||
0A=◙
|
||||
0B=♂
|
||||
0C=♀
|
||||
0D=♪
|
||||
0E=♫
|
||||
0F=☼
|
||||
10=►
|
||||
11=◄
|
||||
12=↕
|
||||
13=‼
|
||||
14=¶
|
||||
15=§
|
||||
16=▬
|
||||
17=↨
|
||||
18=↑
|
||||
19=↓
|
||||
1A=→
|
||||
1B=←
|
||||
1C=∟
|
||||
1D=↔
|
||||
1E=▲
|
||||
1F=▼
|
||||
20=
|
||||
21=!
|
||||
22="
|
||||
23=#
|
||||
24=$
|
||||
25=%
|
||||
26=&
|
||||
27='
|
||||
28=(
|
||||
29=)
|
||||
2A=*
|
||||
2B=+
|
||||
2C=,
|
||||
2D=-
|
||||
2E=.
|
||||
2F=/
|
||||
30=0
|
||||
31=1
|
||||
32=2
|
||||
33=3
|
||||
34=4
|
||||
35=5
|
||||
36=6
|
||||
37=7
|
||||
38=8
|
||||
39=9
|
||||
3A=:
|
||||
3B=;
|
||||
3C=<
|
||||
3D==
|
||||
3E=>
|
||||
3F=?
|
||||
40=@
|
||||
41=A
|
||||
42=B
|
||||
43=C
|
||||
44=D
|
||||
45=E
|
||||
46=F
|
||||
47=G
|
||||
48=H
|
||||
49=I
|
||||
4A=J
|
||||
4B=K
|
||||
4C=L
|
||||
4D=M
|
||||
4E=N
|
||||
4F=O
|
||||
50=P
|
||||
51=Q
|
||||
52=R
|
||||
53=S
|
||||
54=T
|
||||
55=U
|
||||
56=V
|
||||
57=W
|
||||
58=X
|
||||
59=Y
|
||||
5A=Z
|
||||
5B=[
|
||||
5C=\
|
||||
5D=]
|
||||
5E=^
|
||||
5F=_
|
||||
60=`
|
||||
61=a
|
||||
62=b
|
||||
63=c
|
||||
64=d
|
||||
65=e
|
||||
66=f
|
||||
67=g
|
||||
68=h
|
||||
69=i
|
||||
6A=j
|
||||
6B=k
|
||||
6C=l
|
||||
6D=m
|
||||
6E=n
|
||||
6F=o
|
||||
70=p
|
||||
71=q
|
||||
72=r
|
||||
73=s
|
||||
74=t
|
||||
75=u
|
||||
76=v
|
||||
77=w
|
||||
78=x
|
||||
79=y
|
||||
7A=z
|
||||
7B={
|
||||
7C=|
|
||||
7D=}
|
||||
7E=~
|
||||
7F=⌂
|
||||
80=А
|
||||
81=Б
|
||||
82=В
|
||||
83=Г
|
||||
84=Д
|
||||
85=Е
|
||||
86=Ж
|
||||
87=З
|
||||
88=И
|
||||
89=Й
|
||||
8A=К
|
||||
8B=Л
|
||||
8C=М
|
||||
8D=Н
|
||||
8E=О
|
||||
8F=П
|
||||
90=Р
|
||||
91=С
|
||||
92=Т
|
||||
93=У
|
||||
94=Ф
|
||||
95=Х
|
||||
96=Ц
|
||||
97=Ч
|
||||
98=Ш
|
||||
99=Щ
|
||||
9A=Ъ
|
||||
9B=Ы
|
||||
9C=Ь
|
||||
9D=Э
|
||||
9E=Ю
|
||||
9F=Я
|
||||
A0=а
|
||||
A1=б
|
||||
A2=в
|
||||
A3=г
|
||||
A4=д
|
||||
A5=е
|
||||
A6=ж
|
||||
A7=з
|
||||
A8=и
|
||||
A9=й
|
||||
AA=к
|
||||
AB=л
|
||||
AC=м
|
||||
AD=н
|
||||
AE=о
|
||||
AF=п
|
||||
B0=░
|
||||
B1=▒
|
||||
B2=▓
|
||||
B3=│
|
||||
B4=┤
|
||||
B5=╡
|
||||
B6=╢
|
||||
B7=╖
|
||||
B8=╕
|
||||
B9=╣
|
||||
BA=║
|
||||
BB=╗
|
||||
BC=╝
|
||||
BD=╜
|
||||
BE=╛
|
||||
BF=┐
|
||||
C0=└
|
||||
C1=┴
|
||||
C2=┬
|
||||
C3=├
|
||||
C4=─
|
||||
C5=┼
|
||||
C6=╞
|
||||
C7=╟
|
||||
C8=╚
|
||||
C9=╔
|
||||
CA=╩
|
||||
CB=╦
|
||||
CC=╠
|
||||
CD=═
|
||||
CE=╬
|
||||
CF=╧
|
||||
D0=╨
|
||||
D1=╤
|
||||
D2=╥
|
||||
D3=╙
|
||||
D4=╘
|
||||
D5=╒
|
||||
D6=╓
|
||||
D7=╫
|
||||
D8=╪
|
||||
D9=┘
|
||||
DA=┌
|
||||
DB=█
|
||||
DC=▄
|
||||
DD=▌
|
||||
DE=▐
|
||||
DF=▀
|
||||
E0=р
|
||||
E1=с
|
||||
E2=т
|
||||
E3=у
|
||||
E4=ф
|
||||
E5=х
|
||||
E6=ц
|
||||
E7=ч
|
||||
E8=ш
|
||||
E9=щ
|
||||
EA=ъ
|
||||
EB=ы
|
||||
EC=ь
|
||||
ED=э
|
||||
EE=ю
|
||||
EF=я
|
||||
F0=Ё
|
||||
F1=ё
|
||||
F2=Є
|
||||
F3=є
|
||||
F4=Ї
|
||||
F5=ї
|
||||
F6=Ў
|
||||
F7=ў
|
||||
F8=°
|
||||
F9=∙
|
||||
FA=·
|
||||
FB=√
|
||||
FC=№
|
||||
FD=¤
|
||||
FE=■
|
||||
FF=
|
||||
16674
encodings/euc_kr.tbl
Normal file
16674
encodings/euc_kr.tbl
Normal file
File diff suppressed because it is too large
Load Diff
255
encodings/pokegen1_en.tbl
Normal file
255
encodings/pokegen1_en.tbl
Normal file
@@ -0,0 +1,255 @@
|
||||
00=NUL
|
||||
01
|
||||
02
|
||||
03
|
||||
04
|
||||
05
|
||||
06
|
||||
07
|
||||
08
|
||||
09
|
||||
0A
|
||||
0B
|
||||
0C
|
||||
0D
|
||||
0E
|
||||
0F
|
||||
11
|
||||
12
|
||||
13
|
||||
14
|
||||
15
|
||||
16
|
||||
17
|
||||
18
|
||||
19
|
||||
1A
|
||||
1B
|
||||
1C
|
||||
1D
|
||||
1E
|
||||
1F
|
||||
20
|
||||
21
|
||||
22
|
||||
23
|
||||
24
|
||||
25
|
||||
26
|
||||
27
|
||||
28
|
||||
29
|
||||
2A
|
||||
2B
|
||||
2C
|
||||
2D
|
||||
2E
|
||||
2F
|
||||
30
|
||||
31
|
||||
32
|
||||
33
|
||||
34
|
||||
35
|
||||
36
|
||||
37
|
||||
38
|
||||
39
|
||||
3A
|
||||
3B
|
||||
3C
|
||||
3D
|
||||
3E
|
||||
3F
|
||||
40
|
||||
41
|
||||
42
|
||||
43
|
||||
44
|
||||
45
|
||||
46
|
||||
47
|
||||
48
|
||||
49=page
|
||||
4A=PkMn
|
||||
4B=_cont
|
||||
4C=autocont
|
||||
4D
|
||||
4E=next line
|
||||
4F=bottom line
|
||||
50=end
|
||||
51=paragraph
|
||||
52=player name
|
||||
53=rival name
|
||||
54=Poké
|
||||
55=cont
|
||||
56=......
|
||||
57=done
|
||||
58=prompt
|
||||
59=target
|
||||
5A=user
|
||||
5B=PC
|
||||
5C=TM
|
||||
5D=TRAINER
|
||||
5E=ROCKET
|
||||
5F=dex
|
||||
60=A
|
||||
61=B
|
||||
62=C
|
||||
63=D
|
||||
64=E
|
||||
65=F
|
||||
66=G
|
||||
67=H
|
||||
68=I
|
||||
69=V
|
||||
6A=S
|
||||
6B=L
|
||||
6C=M
|
||||
6D=:
|
||||
6E=ぃ
|
||||
6F=ぅ
|
||||
70=‘
|
||||
71=’
|
||||
72=“
|
||||
73=”
|
||||
74=・
|
||||
75=⋯
|
||||
76=ぁ
|
||||
77=ぇ
|
||||
78=ぉ
|
||||
79
|
||||
7A
|
||||
7B
|
||||
7C
|
||||
7D
|
||||
7E
|
||||
7F
|
||||
80=A
|
||||
81=B
|
||||
82=C
|
||||
83=D
|
||||
84=E
|
||||
85=F
|
||||
86=G
|
||||
87=H
|
||||
88=I
|
||||
89=J
|
||||
8A=K
|
||||
8B=L
|
||||
8C=M
|
||||
8D=N
|
||||
8E=O
|
||||
8F=P
|
||||
90=Q
|
||||
91=R
|
||||
92=S
|
||||
93=T
|
||||
94=U
|
||||
95=V
|
||||
96=W
|
||||
97=X
|
||||
98=Y
|
||||
99=Z
|
||||
9A=(
|
||||
9B=)
|
||||
9C=
|
||||
9D=;
|
||||
9E=[
|
||||
9F=]
|
||||
A0=a
|
||||
A1=b
|
||||
A2=c
|
||||
A3=d
|
||||
A4=e
|
||||
A5=f
|
||||
A6=g
|
||||
A7=h
|
||||
A8=i
|
||||
A9=j
|
||||
AA=k
|
||||
AB=l
|
||||
AC=m
|
||||
AD=n
|
||||
AE=o
|
||||
AF=p
|
||||
B0=q
|
||||
B1=r
|
||||
B2=s
|
||||
B3=t
|
||||
B4=u
|
||||
B5=v
|
||||
B6=w
|
||||
B7=x
|
||||
B8=y
|
||||
B9=z
|
||||
BA=é
|
||||
BB='d
|
||||
BC='l
|
||||
BD='s
|
||||
BE='t
|
||||
BF='v
|
||||
C0
|
||||
C1
|
||||
C2
|
||||
C3
|
||||
C4
|
||||
C5
|
||||
C6
|
||||
C7
|
||||
C8
|
||||
C9
|
||||
CA
|
||||
CB
|
||||
CC
|
||||
CD
|
||||
CE
|
||||
CF
|
||||
D0
|
||||
D1
|
||||
D2
|
||||
D3
|
||||
D4
|
||||
D5
|
||||
D6
|
||||
D7
|
||||
D8
|
||||
D9
|
||||
DA
|
||||
DB
|
||||
DC
|
||||
DD
|
||||
DE
|
||||
DF
|
||||
E0='
|
||||
E1=Pk
|
||||
E2=Mn
|
||||
E3=-
|
||||
E4='r
|
||||
E5='m
|
||||
E6=?
|
||||
E7=!
|
||||
E8=.
|
||||
E9=ァ
|
||||
EA=ゥ
|
||||
EB=ェ
|
||||
EC=▷
|
||||
ED=▶
|
||||
EE=▼
|
||||
EF=♂
|
||||
F0=$
|
||||
F1=×
|
||||
F2=.
|
||||
F3=/
|
||||
F4=,
|
||||
F5=♀
|
||||
F6=0
|
||||
F7=1
|
||||
F8=2
|
||||
F9=3
|
||||
FA=4
|
||||
FB=5
|
||||
FC=6
|
||||
FD=7
|
||||
FE=8
|
||||
FF=9
|
||||
@@ -1,6 +1,10 @@
|
||||
00=
|
||||
090D=(R)
|
||||
0A=(BR)
|
||||
08=\b
|
||||
09=\t
|
||||
0A=\n
|
||||
0B=\v
|
||||
0C=\f
|
||||
0D=\r
|
||||
20=
|
||||
21=!
|
||||
22="
|
||||
|
||||
61
includes/std/core.pat
Normal file
61
includes/std/core.pat
Normal file
@@ -0,0 +1,61 @@
|
||||
#pragma once
|
||||
|
||||
namespace std::core {
|
||||
|
||||
enum Endian : u8 {
|
||||
Native = 0,
|
||||
Big = 1,
|
||||
Little = 2
|
||||
};
|
||||
|
||||
enum BitfieldOrder : u8 {
|
||||
LeftToRight = 0,
|
||||
RightToLeft = 1
|
||||
};
|
||||
|
||||
|
||||
fn has_attribute(auto pattern, str attribute) {
|
||||
return builtin::std::core::has_attribute(pattern, attribute);
|
||||
};
|
||||
|
||||
|
||||
fn get_attribute_value(auto pattern, str attribute) {
|
||||
return builtin::std::core::get_attribute_value(pattern, attribute);
|
||||
};
|
||||
|
||||
|
||||
fn set_endian(Endian endian) {
|
||||
builtin::std::core::set_endian(endian);
|
||||
};
|
||||
|
||||
fn get_endian() {
|
||||
return builtin::std::core::get_endian();
|
||||
};
|
||||
|
||||
|
||||
fn set_bitfield_order(BitfieldOrder order) {
|
||||
builtin::std::core::set_bitfield_order(order);
|
||||
};
|
||||
|
||||
fn get_bitfield_order() {
|
||||
return builtin::std::core::get_bitfield_order();
|
||||
};
|
||||
|
||||
|
||||
fn array_index() {
|
||||
return builtin::std::core::array_index();
|
||||
};
|
||||
|
||||
fn member_count(auto pattern) {
|
||||
return builtin::std::core::member_count(pattern);
|
||||
};
|
||||
|
||||
fn has_member(auto pattern, str name) {
|
||||
return builtin::std::core::has_member(pattern, name);
|
||||
};
|
||||
|
||||
fn formatted_value(auto pattern) {
|
||||
return builtin::std::core::formatted_value(pattern);
|
||||
};
|
||||
|
||||
}
|
||||
@@ -39,15 +39,12 @@ namespace std::string {
|
||||
};
|
||||
|
||||
fn contains(str a, str b) {
|
||||
s32 a_len, b_len;
|
||||
a_len = std::string::length(a);
|
||||
b_len = std::string::length(b);
|
||||
s32 a_len = std::string::length(a);
|
||||
s32 b_len = std::string::length(b);
|
||||
|
||||
s32 i;
|
||||
while (i < a_len - b_len) {
|
||||
for (s32 i = 0, i <= (a_len - b_len), i += 1) {
|
||||
if (std::string::substr(a, i, b_len) == b)
|
||||
return true;
|
||||
i = i + 1;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
32
includes/type/path.pat
Normal file
32
includes/type/path.pat
Normal file
@@ -0,0 +1,32 @@
|
||||
#include <std/mem.pat>
|
||||
|
||||
namespace type {
|
||||
|
||||
struct UnixPathSegment {
|
||||
char string[while(std::mem::read_unsigned($, 1) != '/' && std::mem::read_unsigned($, 1) != 0x00)];
|
||||
char separator [[hidden]];
|
||||
|
||||
if (separator == 0x00) {
|
||||
$ -= 1;
|
||||
break;
|
||||
}
|
||||
} [[sealed, format("type::impl::format_unix_path_segment")]];
|
||||
|
||||
struct UnixPath {
|
||||
UnixPathSegment segments[while(true)];
|
||||
} [[format("type::impl::format_unix_path")]];
|
||||
|
||||
|
||||
namespace impl {
|
||||
|
||||
fn format_unix_path_segment(UnixPathSegment segment) {
|
||||
return segment.string;
|
||||
};
|
||||
|
||||
fn format_unix_path(UnixPath path) {
|
||||
return std::mem::read_string($, sizeof(path));
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
45
includes/type/size.pat
Normal file
45
includes/type/size.pat
Normal file
@@ -0,0 +1,45 @@
|
||||
namespace type {
|
||||
|
||||
using Size8 = u8 [[format("type::impl::size_formatter")]];
|
||||
using Size16 = u16 [[format("type::impl::size_formatter")]];
|
||||
using Size32 = u32 [[format("type::impl::size_formatter")]];
|
||||
using Size64 = u64 [[format("type::impl::size_formatter")]];
|
||||
using Size128 = u128 [[format("type::impl::size_formatter")]];
|
||||
|
||||
namespace impl {
|
||||
|
||||
fn size_formatter(u128 size) {
|
||||
double sizeFloat = size;
|
||||
|
||||
u32 i = 0;
|
||||
while (sizeFloat >= 1024 && i <= 6) {
|
||||
i += 1;
|
||||
sizeFloat /= 1024;
|
||||
}
|
||||
|
||||
if (i == 0) {
|
||||
if (size == 1)
|
||||
return std::format("{} Byte", size);
|
||||
else
|
||||
return std::format("{} Bytes", size);
|
||||
} else {
|
||||
str result = std::format("{:.3f} ", sizeFloat);
|
||||
|
||||
if (i == 1)
|
||||
return result + "kiB";
|
||||
else if (i == 2)
|
||||
return result + "MiB";
|
||||
else if (i == 3)
|
||||
return result + "GiB";
|
||||
else if (i == 4)
|
||||
return result + "TiB";
|
||||
else if (i == 5)
|
||||
return result + "PiB";
|
||||
else
|
||||
return result + "EiB";
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
73
patterns/bencode.hexpat
Normal file
73
patterns/bencode.hexpat
Normal file
@@ -0,0 +1,73 @@
|
||||
#pragma MIME application/x-bittorrent
|
||||
|
||||
#include <std/ctype.pat>
|
||||
#include <std/mem.pat>
|
||||
#include <std/string.pat>
|
||||
|
||||
namespace bencode {
|
||||
|
||||
struct ASCIIDecimal {
|
||||
char value[while(std::ctype::isdigit(std::mem::read_unsigned($, 1)))];
|
||||
} [[sealed, format("bencode::format_ascii_decimal"), transform("bencode::format_ascii_decimal")]];
|
||||
|
||||
fn format_ascii_decimal(ASCIIDecimal adsasd) {
|
||||
return std::string::parse_int(adsasd.value, 10);
|
||||
};
|
||||
|
||||
enum Type : u8 {
|
||||
Integer = 'i',
|
||||
Dictionary = 'd',
|
||||
List = 'l',
|
||||
|
||||
String0 = '0',
|
||||
String1 = '1',
|
||||
String2 = '2',
|
||||
String3 = '3',
|
||||
String4 = '4',
|
||||
String5 = '5',
|
||||
String6 = '6',
|
||||
String7 = '7',
|
||||
String8 = '8',
|
||||
String9 = '9'
|
||||
};
|
||||
|
||||
struct String {
|
||||
ASCIIDecimal length;
|
||||
char separator [[hidden]];
|
||||
char value[length];
|
||||
} [[sealed, format("bencode::format_string"), transform("bencode::format_string")]];
|
||||
|
||||
fn format_string(String string) {
|
||||
return string.value;
|
||||
};
|
||||
|
||||
using Bencode;
|
||||
using Value;
|
||||
|
||||
struct DictionaryEntry {
|
||||
String key;
|
||||
Value value;
|
||||
};
|
||||
|
||||
struct Value {
|
||||
Type type;
|
||||
|
||||
if (type == Type::Dictionary) {
|
||||
DictionaryEntry entry[while(std::mem::read_unsigned($, 1) != 'e')];
|
||||
} else if (type == Type::Integer) {
|
||||
ASCIIDecimal value;
|
||||
char end;
|
||||
} else {
|
||||
$ -= 1;
|
||||
String value;
|
||||
}
|
||||
};
|
||||
|
||||
struct Bencode {
|
||||
Value value[while(!std::mem::eof())] [[inline]];
|
||||
char end;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
bencode::Bencode bencode @ 0x00;
|
||||
@@ -158,7 +158,11 @@ namespace program {
|
||||
LOOS = 0x60000000,
|
||||
HIOS = 0x6FFFFFFF,
|
||||
LOPROC = 0x70000000,
|
||||
HIPROC = 0x7FFFFFFF
|
||||
HIPROC = 0x7FFFFFFF,
|
||||
GNU_EH_FRAME = program::Type::LOOS + 0x474E550,
|
||||
GNU_STACK = program::Type::LOOS + 0x474E551,
|
||||
GNU_RELRO = program::Type::LOOS + 0x474E552,
|
||||
GNU_PROPERTY = program::Type::LOOS + 0x474E553
|
||||
};
|
||||
|
||||
struct Header {
|
||||
|
||||
459
patterns/lnk.hexpat
Normal file
459
patterns/lnk.hexpat
Normal file
@@ -0,0 +1,459 @@
|
||||
#pragma MIME application/x-ms-shortcut
|
||||
|
||||
#include <type/guid.pat>
|
||||
#include <type/size.pat>
|
||||
|
||||
bitfield LinkFlags {
|
||||
HasLinkTargetIDList : 1;
|
||||
HasLinkInfo : 1;
|
||||
HasName : 1;
|
||||
HasRelativePath : 1;
|
||||
HasWorkingDir : 1;
|
||||
HasArguments : 1;
|
||||
HasIconLocation : 1;
|
||||
IsUnicode : 1;
|
||||
ForceNoLinkInfo : 1;
|
||||
HasExpString : 1;
|
||||
RunInSeparateProcess : 1;
|
||||
padding : 1;
|
||||
HasDarwinID : 1;
|
||||
RunAsUser : 1;
|
||||
HasExpIcon : 1;
|
||||
NoPidlAlias : 1;
|
||||
padding : 1;
|
||||
RunWithShimLayer : 1;
|
||||
ForceNoLinkTrack : 1;
|
||||
EnableTargetMetadata : 1;
|
||||
DisableLinkPathTracking : 1;
|
||||
DisableKnownFolderTracking : 1;
|
||||
DisableKnownFolderAlias : 1;
|
||||
AllowLinkToLink : 1;
|
||||
UnaliasOnSave : 1;
|
||||
PreferEnvironmentPath : 1;
|
||||
KeepLocalIDListForUNCTarget : 1;
|
||||
padding : 5;
|
||||
} [[right_to_left]];
|
||||
|
||||
bitfield FileAttributesFlags {
|
||||
FILE_ATTRIBUTE_READONLY : 1;
|
||||
FILE_ATTRIBUTE_HIDDEN : 1;
|
||||
FILE_ATTRIBUTE_SYSTEM : 1;
|
||||
padding : 1;
|
||||
FILE_ATTRIBUTE_DIRECTORY : 1;
|
||||
FILE_ATTRIBUTE_ARCHIVE : 1;
|
||||
padding : 1;
|
||||
FILE_ATTRIBUTE_NORMAL : 1;
|
||||
FILE_ATTRIBUTE_TEMPORARY : 1;
|
||||
FILE_ATTRIBUTE_SPARSE_FILE : 1;
|
||||
FILE_ATTRIBUTE_REPARSE_POINT : 1;
|
||||
FILE_ATTRIBUTE_COMPRESSED : 1;
|
||||
FILE_ATTRIBUTE_OFFLINE : 1;
|
||||
FILE_ATTRIBUTE_NOT_CONTENT_INDEXED : 1;
|
||||
FILE_ATTRIBUTE_ENCRYPTED : 1;
|
||||
padding : 17;
|
||||
} [[right_to_left]];
|
||||
|
||||
bitfield ModifierKeys {
|
||||
HOTKEYF_SHIFT : 1;
|
||||
HOTKEYF_CONTROL : 1;
|
||||
HOTKEYF_ALT : 1;
|
||||
padding : 5;
|
||||
} [[right_to_left]];
|
||||
|
||||
enum Keys : u8 {
|
||||
KEY_NONE = 0x00,
|
||||
KEY_0 = 0x30,
|
||||
KEY_1 = 0x31,
|
||||
KEY_2 = 0x32,
|
||||
KEY_3 = 0x33,
|
||||
KEY_4 = 0x34,
|
||||
KEY_5 = 0x35,
|
||||
KEY_6 = 0x36,
|
||||
KEY_7 = 0x37,
|
||||
KEY_8 = 0x38,
|
||||
KEY_9 = 0x39,
|
||||
KEY_A = 0x41,
|
||||
KEY_B = 0x42,
|
||||
KEY_C = 0x43,
|
||||
KEY_D = 0x44,
|
||||
KEY_E = 0x45,
|
||||
KEY_F = 0x46,
|
||||
KEY_G = 0x47,
|
||||
KEY_H = 0x48,
|
||||
KEY_I = 0x49,
|
||||
KEY_J = 0x4A,
|
||||
KEY_K = 0x4B,
|
||||
KEY_L = 0x4C,
|
||||
KEY_M = 0x4D,
|
||||
KEY_N = 0x4E,
|
||||
KEY_O = 0x4F,
|
||||
KEY_P = 0x50,
|
||||
KEY_Q = 0x51,
|
||||
KEY_R = 0x52,
|
||||
KEY_S = 0x53,
|
||||
KEY_T = 0x54,
|
||||
KEY_U = 0x55,
|
||||
KEY_V = 0x56,
|
||||
KEY_W = 0x57,
|
||||
KEY_X = 0x58,
|
||||
KEY_Y = 0x59,
|
||||
KEY_Z = 0x5A,
|
||||
|
||||
VK_F1 = 0x70,
|
||||
VK_F2 = 0x71,
|
||||
VK_F3 = 0x72,
|
||||
VK_F4 = 0x73,
|
||||
VK_F5 = 0x74,
|
||||
VK_F6 = 0x75,
|
||||
VK_F7 = 0x76,
|
||||
VK_F8 = 0x77,
|
||||
VK_F9 = 0x78,
|
||||
VK_F10 = 0x79,
|
||||
VK_F11 = 0x7A,
|
||||
VK_F12 = 0x7B,
|
||||
VK_F13 = 0x7C,
|
||||
VK_F14 = 0x7D,
|
||||
VK_F15 = 0x7E,
|
||||
VK_F16 = 0x7F,
|
||||
VK_F17 = 0x80,
|
||||
VK_F18 = 0x81,
|
||||
VK_F19 = 0x82,
|
||||
VK_F20 = 0x83,
|
||||
VK_F21 = 0x84,
|
||||
VK_F22 = 0x85,
|
||||
VK_F23 = 0x86,
|
||||
VK_F24 = 0x87,
|
||||
VK_NUMLOCK = 0x90,
|
||||
VK_SCROLL = 0x91,
|
||||
};
|
||||
|
||||
struct HotKeyFlags {
|
||||
Keys Key;
|
||||
ModifierKeys ModifierKeys;
|
||||
};
|
||||
|
||||
struct FILETIME {
|
||||
u32 dwLowDateTime;
|
||||
u32 dwHighDateTime;
|
||||
};
|
||||
|
||||
enum SHOWWINDOW_FLAGS : u32 {
|
||||
SW_SHOWNORMAL = 0x00000001,
|
||||
SW_SHOWMAXIMIZED = 0x00000003,
|
||||
SW_SHOWMINNOACTIVE = 0x00000007
|
||||
};
|
||||
|
||||
struct ShellLinkHeader {
|
||||
type::Size32 HeaderSize;
|
||||
type::GUID LinkCLSID;
|
||||
LinkFlags LinkFlags;
|
||||
FileAttributesFlags FileAttributes;
|
||||
FILETIME CreationTime, AccessTime, WriteTime;
|
||||
type::Size32 FileSize;
|
||||
u32 IconIndex;
|
||||
SHOWWINDOW_FLAGS ShowCommand;
|
||||
HotKeyFlags HotKey;
|
||||
padding[2];
|
||||
padding[4];
|
||||
padding[4];
|
||||
};
|
||||
|
||||
struct ItemID {
|
||||
type::Size16 ItemIDSize;
|
||||
|
||||
if (ItemIDSize == 0x00)
|
||||
break;
|
||||
else
|
||||
u8 Data[ItemIDSize - sizeof(ItemIDSize)];
|
||||
};
|
||||
|
||||
struct IDList {
|
||||
ItemID ItemIDList[while(true)];
|
||||
};
|
||||
|
||||
struct LinkTargetIDList {
|
||||
type::Size16 IDListSize;
|
||||
IDList IDList[while($ < (addressof(IDListSize) + IDListSize))];
|
||||
};
|
||||
|
||||
bitfield LinkInfoFlags {
|
||||
VolumeIDAndLocalBasePath : 1;
|
||||
CommonNetworkRelativeLinkAndPathSuffix : 1;
|
||||
padding : 30;
|
||||
};
|
||||
|
||||
enum DriveType : u32 {
|
||||
DRIVE_UNKNOWN = 0x00000000,
|
||||
DRIVE_NO_ROOT_DIR = 0x00000001,
|
||||
DRIVE_REMOVABLE = 0x00000002,
|
||||
DRIVE_FIXED = 0x00000003,
|
||||
DRIVE_REMOTE = 0x00000004,
|
||||
DRIVE_CDROM = 0x00000005,
|
||||
DRIVE_RAMDISK = 0x00000006
|
||||
};
|
||||
|
||||
struct VolumeID {
|
||||
type::Size32 VolumeIDSize;
|
||||
DriveType DriveType;
|
||||
u32 DriveSerialNumber;
|
||||
u32 VolumeLabelOffset;
|
||||
if (VolumeLabelOffset == 0x14)
|
||||
u32 VolumeLabelOffsetUnicode;
|
||||
char Data[VolumeIDSize - ($ - addressof(this))];
|
||||
};
|
||||
|
||||
bitfield CommonNetworkRelativeLinkFlags {
|
||||
ValidDevice : 1;
|
||||
ValidNetType : 1;
|
||||
padding : 30;
|
||||
} [[right_to_left]];
|
||||
|
||||
enum NetworkProviderType : u32 {
|
||||
WNNC_NET_AVID = 0x001A0000,
|
||||
WNNC_NET_DOCUSPACE = 0x001B0000,
|
||||
WNNC_NET_MANGOSOFT = 0x001C0000,
|
||||
WNNC_NET_SERNET = 0x001D0000,
|
||||
WNNC_NET_RIVERFRONT1 = 0x001E0000,
|
||||
WNNC_NET_RIVERFRONT2 = 0x001F0000,
|
||||
WNNC_NET_DECORB = 0x00200000,
|
||||
WNNC_NET_PROTSTOR = 0x00210000,
|
||||
WNNC_NET_FJ_REDIR = 0x00220000,
|
||||
WNNC_NET_DISTINCT = 0x00230000,
|
||||
WNNC_NET_TWINS = 0x00240000,
|
||||
WNNC_NET_RDR2SAMPLE = 0x00250000,
|
||||
WNNC_NET_CSC = 0x00260000,
|
||||
WNNC_NET_3IN1 = 0x00270000,
|
||||
WNNC_NET_EXTENDNET = 0x00290000,
|
||||
WNNC_NET_STAC = 0x002A0000,
|
||||
WNNC_NET_FOXBAT = 0x002B0000,
|
||||
WNNC_NET_YAHOO = 0x002C0000,
|
||||
WNNC_NET_EXIFS = 0x002D0000,
|
||||
WNNC_NET_DAV = 0x002E0000,
|
||||
WNNC_NET_KNOWARE = 0x002F0000,
|
||||
WNNC_NET_OBJECT_DIRE = 0x00300000,
|
||||
WNNC_NET_MASFAX = 0x00310000,
|
||||
WNNC_NET_HOB_NFS = 0x00320000,
|
||||
WNNC_NET_SHIVA = 0x00330000,
|
||||
WNNC_NET_IBMAL = 0x00340000,
|
||||
WNNC_NET_LOCK = 0x00350000,
|
||||
WNNC_NET_TERMSRV = 0x00360000,
|
||||
WNNC_NET_SRT = 0x00370000,
|
||||
WNNC_NET_QUINCY = 0x00380000,
|
||||
WNNC_NET_OPENAFS = 0x00390000,
|
||||
WNNC_NET_AVID1 = 0x003A0000,
|
||||
WNNC_NET_DFS = 0x003B0000,
|
||||
WNNC_NET_KWNP = 0x003C0000,
|
||||
WNNC_NET_ZENWORKS = 0x003D0000,
|
||||
WNNC_NET_DRIVEONWEB = 0x003E0000,
|
||||
WNNC_NET_VMWARE = 0x003F0000,
|
||||
WNNC_NET_RSFX = 0x00400000,
|
||||
WNNC_NET_MFILES = 0x00410000,
|
||||
WNNC_NET_MS_NFS = 0x00420000,
|
||||
WNNC_NET_GOOGLE = 0x00430000
|
||||
};
|
||||
|
||||
struct CommonNetworkRelativeLink {
|
||||
type::Size32 CommonNetworkRelativeLinkSize;
|
||||
CommonNetworkRelativeLinkFlags CommonNetworkRelativeLinkFlags;
|
||||
u32 NetNameOffset;
|
||||
u32 DeviceNameOffset;
|
||||
NetworkProviderType NetworkProviderType;
|
||||
|
||||
if (NetNameOffset > 0x14) {
|
||||
u32 NetNameOffsetUnicode;
|
||||
u32 DeviceNameOffsetUnicode;
|
||||
}
|
||||
|
||||
char NetName[];
|
||||
char DeviceName[];
|
||||
|
||||
if (NetNameOffset > 0x14) {
|
||||
char16 NetNameUnicode[];
|
||||
char16 DeviceNameUnicode[];
|
||||
}
|
||||
};
|
||||
|
||||
struct LinkInfo {
|
||||
type::Size32 LinkInfoSize;
|
||||
type::Size32 LinkInfoHeaderSize;
|
||||
LinkInfoFlags LinkInfoFlags;
|
||||
u32 VolumeIDOffset;
|
||||
u32 LocalBasePathOffset;
|
||||
u32 CommonNetworkRelativeLinkOffset;
|
||||
u32 CommonPathSuffixOffset;
|
||||
|
||||
if (LinkInfoHeaderSize >= 0x24) {
|
||||
u32 LocalBasePathOffsetUnicode;
|
||||
u32 CommonPathSuffixOffsetUnicode;
|
||||
}
|
||||
|
||||
if (LinkInfoFlags.VolumeIDAndLocalBasePath) {
|
||||
VolumeID VolumeID;
|
||||
char LocalBasePath[];
|
||||
}
|
||||
|
||||
if (LinkInfoFlags.CommonNetworkRelativeLinkAndPathSuffix)
|
||||
CommonNetworkRelativeLink CommonNetworkRelativeLink;
|
||||
|
||||
char CommonPathSuffix[];
|
||||
|
||||
if (LinkInfoHeaderSize >= 0x24) {
|
||||
if (LinkInfoFlags.VolumeIDAndLocalBasePath)
|
||||
char16 LocalBasePathUnicode[];
|
||||
char16 CommonPathSuffixUnicode[];
|
||||
}
|
||||
};
|
||||
|
||||
struct String {
|
||||
u16 CountCharacters;
|
||||
char16 String[CountCharacters];
|
||||
};
|
||||
|
||||
struct StringData {
|
||||
if (parent.ShellLinkHeader.LinkFlags.HasName)
|
||||
String NAME_STRING;
|
||||
if (parent.ShellLinkHeader.LinkFlags.HasRelativePath)
|
||||
String RELATIVE_PATH;
|
||||
if (parent.ShellLinkHeader.LinkFlags.HasWorkingDir)
|
||||
String WORKING_DIR;
|
||||
if (parent.ShellLinkHeader.LinkFlags.HasArguments)
|
||||
String COMMAND_LINE_ARGUMENTS;
|
||||
if (parent.ShellLinkHeader.LinkFlags.HasIconLocation)
|
||||
String ICON_LOCATION;
|
||||
};
|
||||
|
||||
bitfield FillAttributes {
|
||||
FOREGROUND_BLUE : 1;
|
||||
FOREGROUND_GREEN : 1;
|
||||
FOREGROUND_RED : 1;
|
||||
FOREGROUND_INTENSITY : 1;
|
||||
|
||||
BACKGROUND_BLUE : 1;
|
||||
BACKGROUND_GREEN : 1;
|
||||
BACKGROUND_RED : 1;
|
||||
BACKGROUND_INTENSITY : 1;
|
||||
|
||||
padding : 8;
|
||||
} [[right_to_left]];
|
||||
|
||||
struct ConsoleDataBlock {
|
||||
FillAttributes FillAttributes;
|
||||
FillAttributes PopupFillAttributes;
|
||||
u16 ScreenBufferSizeX, ScreenBufferSizeY;
|
||||
u16 WindowSizeX, WindowSizeY;
|
||||
u16 WindowOriginX, WindowOriginY;
|
||||
padding[4];
|
||||
padding[4];
|
||||
u32 FontSize;
|
||||
u32 FontFamily;
|
||||
u32 FontWeight;
|
||||
char16 FaceName[32];
|
||||
u32 CursorSize;
|
||||
u32 FullScreen;
|
||||
u32 QuickEdit;
|
||||
u32 InsertMode;
|
||||
u32 AutoPosition;
|
||||
u32 HistoryBufferSize;
|
||||
u32 NumberOfHistoryBuffers;
|
||||
u32 HistoryNoDup;
|
||||
u32 ColorTable[16];
|
||||
};
|
||||
|
||||
struct ConsoleFEDataBlock {
|
||||
u32 CodePage;
|
||||
};
|
||||
|
||||
struct DarwinDataBlock {
|
||||
char DarwinDataAnsi[260];
|
||||
char16 DarwinDataUnicode[260];
|
||||
};
|
||||
|
||||
struct EnvironmentVariableDataBlock {
|
||||
char TargetAnsi[260];
|
||||
char16 TargetUnicode[260];
|
||||
};
|
||||
|
||||
struct IconEnvironmentDataBlock {
|
||||
char TargetAnsi[260];
|
||||
char16 TargetUnicode[260];
|
||||
};
|
||||
|
||||
struct KnownFolderDataBlock {
|
||||
type::GUID KnownFolderID;
|
||||
u32 Offset;
|
||||
};
|
||||
|
||||
struct PropertyStoreDataBlock {
|
||||
u8 Bytes[parent.BlockSize - sizeof(parent.BlockSize) - sizeof(parent.BlockSignature)];
|
||||
std::warning("PropertyStoreDataBlock is not yet implemented!");
|
||||
};
|
||||
|
||||
struct ShimDataBlock {
|
||||
char16 LayerName[(parent.BlockSize - sizeof(parent.BlockSize) - sizeof(parent.BlockSignature)) / sizeof(char16)];
|
||||
};
|
||||
|
||||
struct SpecialFolderDataBlock {
|
||||
u32 SpecialFolderID;
|
||||
u32 Offset;
|
||||
};
|
||||
|
||||
struct TrackerDataBlock {
|
||||
type::Size32 Length;
|
||||
u32 Version;
|
||||
char MachineID[16];
|
||||
type::GUID Droid[2];
|
||||
type::GUID DroidBirth[2];
|
||||
};
|
||||
|
||||
struct VistaAndAboveIDListDataBlock {
|
||||
IDList IDList;
|
||||
};
|
||||
|
||||
struct ExtraDataBlock {
|
||||
type::Size32 BlockSize;
|
||||
|
||||
if (BlockSize < 0x04)
|
||||
break;
|
||||
else {
|
||||
u32 BlockSignature;
|
||||
|
||||
if (BlockSignature == 0xA000'0002)
|
||||
ConsoleDataBlock CONSOLE_PROPS;
|
||||
else if (BlockSignature == 0xA000'0004)
|
||||
ConsoleFEDataBlock CONSOLE_FE_PROPS;
|
||||
else if (BlockSignature == 0xA000'0006)
|
||||
DarwinDataBlock DARWIN_PROPS;
|
||||
else if (BlockSignature == 0xA000'0001)
|
||||
EnvironmentVariableDataBlock ENVIRONMENT_PROPS;
|
||||
else if (BlockSignature == 0xA000'0007)
|
||||
IconEnvironmentDataBlock ICON_ENVIRONMENT_PROPS;
|
||||
else if (BlockSignature == 0xA000'000B)
|
||||
KnownFolderDataBlock KNOWN_FOLDER_PROPS;
|
||||
else if (BlockSignature == 0xA000'0009)
|
||||
PropertyStoreDataBlock PROPERTY_STORE_PROPS;
|
||||
else if (BlockSignature == 0xA000'0008)
|
||||
ShimDataBlock SHIM_PROPS;
|
||||
else if (BlockSignature == 0xA000'0005)
|
||||
SpecialFolderDataBlock SPECIAL_FOLDER_PROPS;
|
||||
else if (BlockSignature == 0xA000'0003)
|
||||
TrackerDataBlock TRACKER_PROPS;
|
||||
else if (BlockSignature == 0xA000'000C)
|
||||
VistaAndAboveIDListDataBlock VISTA_AND_ABOVE_IDLIST_PROPS;
|
||||
}
|
||||
};
|
||||
|
||||
struct ExtraData {
|
||||
ExtraDataBlock ExtraDataBlock[while(true)];
|
||||
};
|
||||
|
||||
struct LNK {
|
||||
ShellLinkHeader ShellLinkHeader;
|
||||
if (ShellLinkHeader.LinkFlags.HasLinkTargetIDList)
|
||||
LinkTargetIDList LinkTargetIDList;
|
||||
if (ShellLinkHeader.LinkFlags.HasLinkInfo)
|
||||
LinkInfo LinkInfo;
|
||||
StringData StringData;
|
||||
ExtraData ExtraData;
|
||||
};
|
||||
|
||||
LNK lnk @ 0x00;
|
||||
161
patterns/ntag.hexpat
Normal file
161
patterns/ntag.hexpat
Normal file
@@ -0,0 +1,161 @@
|
||||
bitfield AccessCapability {
|
||||
Read : 4;
|
||||
Write : 4;
|
||||
} [[left_to_right]];
|
||||
|
||||
struct CapabilityContainer {
|
||||
u8 magic;
|
||||
u8 version;
|
||||
u8 memorySize;
|
||||
AccessCapability accessCapability;
|
||||
};
|
||||
|
||||
bitfield NDEFFlags {
|
||||
MB : 1;
|
||||
ME : 1;
|
||||
CF : 1;
|
||||
SR : 1;
|
||||
IL : 1;
|
||||
TNF : 3;
|
||||
} [[left_to_right]];
|
||||
|
||||
enum TNFType : u8 {
|
||||
Empty = 0x00,
|
||||
NFCForumWellKnownType = 0x01,
|
||||
MediaType = 0x02,
|
||||
AbsoluteURI = 0x03,
|
||||
NFCForumExternalType = 0x04,
|
||||
Unknown = 0x05,
|
||||
Unchanged = 0x06,
|
||||
Reserved = 0x07
|
||||
};
|
||||
|
||||
struct NDEF {
|
||||
NDEFFlags flags;
|
||||
u8 typeLength;
|
||||
|
||||
if (flags.SR)
|
||||
u8 payloadLength;
|
||||
else
|
||||
u32 payloadLength;
|
||||
|
||||
if (flags.IL)
|
||||
u8 idLength;
|
||||
|
||||
char type[typeLength];
|
||||
|
||||
if (flags.IL)
|
||||
u8 id[idLength];
|
||||
|
||||
u8 payload[payloadLength];
|
||||
|
||||
if (flags.ME)
|
||||
break;
|
||||
};
|
||||
|
||||
struct LockControl {
|
||||
u8 dynamicLockByteOffset;
|
||||
u8 numBits;
|
||||
u8 pageControlInfo;
|
||||
};
|
||||
|
||||
struct MemoryControl {
|
||||
u8 reservedBytesOffset;
|
||||
u8 numBytes;
|
||||
u8 pageSize;
|
||||
};
|
||||
|
||||
struct Length {
|
||||
u8 byte [[hidden, no_unique_address]];
|
||||
if (byte == 0xFF)
|
||||
u24 length;
|
||||
else
|
||||
u8 length;
|
||||
} [[sealed, transform("transform_length"), format("transform_length")]];
|
||||
|
||||
fn transform_length(Length length) {
|
||||
return length.length;
|
||||
};
|
||||
|
||||
enum Tag : u8 {
|
||||
NULL = 0x00,
|
||||
LockControl = 0x01,
|
||||
MemoryControl = 0x02,
|
||||
NDEFMessage = 0x03,
|
||||
Proprietary = 0xFD,
|
||||
TerminatorTLV = 0xFE
|
||||
};
|
||||
|
||||
struct TLV {
|
||||
Tag tag;
|
||||
if (tag == Tag::TerminatorTLV) {
|
||||
break;
|
||||
} else if (tag == Tag::NULL) {
|
||||
// Empty
|
||||
} else {
|
||||
Length length;
|
||||
|
||||
if (length > 0) {
|
||||
if (tag == Tag::LockControl) {
|
||||
LockControl lockControl;
|
||||
} else if (tag == Tag::MemoryControl) {
|
||||
LockControl lockControl;
|
||||
} else if (tag == Tag::NDEFMessage) {
|
||||
NDEF ndef[while(true)];
|
||||
} else {
|
||||
u8 value[length];
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
struct ManufacturerData {
|
||||
u8 serial1[3];
|
||||
u8 checkByte0;
|
||||
u8 serial2[4];
|
||||
u8 checkByte1;
|
||||
u8 internal;
|
||||
u16 lockBytes;
|
||||
};
|
||||
|
||||
struct DynamicLockBytes {
|
||||
u8 bytes[3];
|
||||
u8 RFUI;
|
||||
};
|
||||
|
||||
bitfield MIRROR {
|
||||
MIRROR_CONF : 2;
|
||||
MIRROR_BYTE : 2;
|
||||
RFUI : 1;
|
||||
STRG_MOD_EN : 1;
|
||||
RFUI : 2;
|
||||
} [[left_to_right]];
|
||||
|
||||
bitfield ACCESS {
|
||||
PROT : 1;
|
||||
CFGLCK : 1;
|
||||
RFUI : 1;
|
||||
NFC_CNT_EN : 1;
|
||||
NFC_CNT_PWD_PROT : 1;
|
||||
AUTHLIM : 3;
|
||||
};
|
||||
|
||||
struct Config {
|
||||
MIRROR MIRROR;
|
||||
u8 MIRROR_PAGE;
|
||||
u8 AUTH0;
|
||||
ACCESS ACCESS;
|
||||
u32 PWD;
|
||||
u16 PACK;
|
||||
};
|
||||
|
||||
struct NTAG {
|
||||
ManufacturerData manufacturerData;
|
||||
CapabilityContainer cc;
|
||||
TLV tlv[while(true)];
|
||||
padding[addressof(tlv) + cc.memorySize * 8 - sizeof(tlv)];
|
||||
DynamicLockBytes dynamicLockBytes;
|
||||
Config config;
|
||||
};
|
||||
|
||||
NTAG ntag @ 0x00;
|
||||
29
patterns/ogg.hexpat
Normal file
29
patterns/ogg.hexpat
Normal file
@@ -0,0 +1,29 @@
|
||||
#pragma MIME audio/ogg
|
||||
|
||||
#include <std/core.pat>
|
||||
#include <std/mem.pat>
|
||||
|
||||
bitfield HeaderType {
|
||||
Continuation : 1;
|
||||
BeginOfStream : 1;
|
||||
EndOfStream : 1;
|
||||
};
|
||||
|
||||
struct SegmentData {
|
||||
u8 data[parent.segmentTable[std::core::array_index()]];
|
||||
};
|
||||
|
||||
struct Ogg {
|
||||
char capturePattern[4];
|
||||
u8 version;
|
||||
HeaderType headerType;
|
||||
u64 granulePosition;
|
||||
u32 bitstreamSerialNumber;
|
||||
u32 pageSequenceNumber;
|
||||
u32 checksum;
|
||||
u8 pageSegments;
|
||||
u8 segmentTable[pageSegments];
|
||||
SegmentData data[pageSegments];
|
||||
};
|
||||
|
||||
Ogg ogg[while(!std::mem::eof())] @ 0x00;
|
||||
66
patterns/protobuf.hexpat
Normal file
66
patterns/protobuf.hexpat
Normal file
@@ -0,0 +1,66 @@
|
||||
#include <std/mem.pat>
|
||||
|
||||
#include <type/leb128.pat>
|
||||
|
||||
struct ZigZag32 {
|
||||
u32 value;
|
||||
} [[sealed, format("format_zigzag32")]];
|
||||
|
||||
fn format_zigzag32(ZigZag32 zigzag) {
|
||||
return s32((s32(zigzag.value) << 1) ^ (s32(zigzag.value) >> 31));
|
||||
};
|
||||
|
||||
struct ZigZag64 {
|
||||
u64 value;
|
||||
} [[sealed, format("format_zigzag64")]];
|
||||
|
||||
fn format_zigzag64(ZigZag64 zigzag) {
|
||||
return s64((s64(zigzag.value) << 1) ^ (s64(zigzag.value) >> 63));
|
||||
};
|
||||
|
||||
enum WireType : u8 {
|
||||
Varint = 0,
|
||||
_64Bit = 1,
|
||||
LengthDelimited = 2,
|
||||
StartGroup = 3,
|
||||
EndGroup = 4,
|
||||
_32Bit = 5
|
||||
};
|
||||
|
||||
bitfield Key {
|
||||
field_number : 5;
|
||||
wire_type : 3;
|
||||
} [[left_to_right]];
|
||||
|
||||
union _64Bit {
|
||||
u64 fixed64;
|
||||
ZigZag64 sfixed64;
|
||||
double dbl;
|
||||
};
|
||||
|
||||
union _32Bit {
|
||||
u32 fixed32;
|
||||
ZigZag32 sfixed32;
|
||||
float flt;
|
||||
};
|
||||
|
||||
struct LengthDelimited {
|
||||
type::LEB128 length;
|
||||
char data[length];
|
||||
};
|
||||
|
||||
|
||||
struct Entry {
|
||||
Key key;
|
||||
|
||||
if (key.wire_type == WireType::Varint)
|
||||
type::LEB128 value;
|
||||
else if (key.wire_type == WireType::_64Bit)
|
||||
_64Bit value;
|
||||
else if (key.wire_type == WireType::LengthDelimited)
|
||||
LengthDelimited value;
|
||||
else if (key.wire_type == WireType::_32Bit)
|
||||
_32Bit value;
|
||||
};
|
||||
|
||||
Entry entries[while(!std::mem::eof())] @ 0x00;
|
||||
38
patterns/stl.hexpat
Normal file
38
patterns/stl.hexpat
Normal file
@@ -0,0 +1,38 @@
|
||||
#pragma MIME model/stl
|
||||
#pragma MIME model/x.stl-binary
|
||||
#pragma MIME model/x.stl-ascii
|
||||
#pragma MIME application/sla
|
||||
|
||||
#include <std/sys.pat>
|
||||
#include <std/mem.pat>
|
||||
|
||||
struct Vector3f {
|
||||
float x, y, z;
|
||||
} [[static, format("format_vector3f")]];
|
||||
|
||||
fn format_vector3f(Vector3f vec) {
|
||||
return std::format("[ {}, {}, {} ]", vec.x, vec.y, vec.z);
|
||||
};
|
||||
|
||||
struct Triangle {
|
||||
Vector3f normal;
|
||||
Vector3f points[3];
|
||||
u16 flags;
|
||||
} [[static]];
|
||||
|
||||
struct BinarySTLHeader {
|
||||
char caption[];
|
||||
padding[80 - sizeof(caption)];
|
||||
u32 triangleCount;
|
||||
};
|
||||
|
||||
struct STL {
|
||||
if (std::mem::read_string(0, 6) == "solid ")
|
||||
std::warning("ASCII STL file!");
|
||||
else {
|
||||
BinarySTLHeader header;
|
||||
Triangle triangles[header.triangleCount];
|
||||
}
|
||||
};
|
||||
|
||||
STL stl @ 0x00;
|
||||
193
patterns/vhdx.hexpat
Normal file
193
patterns/vhdx.hexpat
Normal file
@@ -0,0 +1,193 @@
|
||||
#include <std/io.pat>
|
||||
#include <std/ptr.pat>
|
||||
#include <std/core.pat>
|
||||
|
||||
#include <type/guid.pat>
|
||||
#include <type/size.pat>
|
||||
|
||||
struct FileTypeIdentifier {
|
||||
char signature[8];
|
||||
char16 creator[256];
|
||||
padding[0x1'0000 - sizeof(signature) - sizeof(creator)];
|
||||
};
|
||||
|
||||
struct DataSector {
|
||||
u32 sequenceHigh;
|
||||
u8 data[4084];
|
||||
u32 sequenceLow;
|
||||
} [[static]];
|
||||
|
||||
struct ZeroDescriptor {
|
||||
padding[4];
|
||||
u64 zeroLength;
|
||||
DataSector *dataSector : u64;
|
||||
u64 sequenceNumber;
|
||||
} [[static]];
|
||||
|
||||
struct DataDescriptor {
|
||||
u32 trailingBytes;
|
||||
u64 leadingBytes;
|
||||
DataSector *dataSector : u64;
|
||||
u64 sequenceNumber;
|
||||
} [[static]];
|
||||
|
||||
struct LogDescriptor {
|
||||
char signature[4];
|
||||
|
||||
if (signature == "zero")
|
||||
ZeroDescriptor descriptor [[inline]];
|
||||
else if (signature == "desc")
|
||||
DataDescriptor descriptor [[inline]];
|
||||
};
|
||||
|
||||
struct LogEntry {
|
||||
char signature[4];
|
||||
u32 checksum;
|
||||
type::Size32 entryLength;
|
||||
u32 tail;
|
||||
u64 sequenceNumber;
|
||||
u32 descriptorCount;
|
||||
padding[4];
|
||||
type::GUID logGuid;
|
||||
u64 flushedFileOffset;
|
||||
u64 lastFileOffset;
|
||||
} [[static]];
|
||||
|
||||
bitfield BAT {
|
||||
State : 3;
|
||||
padding : 17;
|
||||
FileOffsetMB : 44;
|
||||
} [[right_to_left]];
|
||||
|
||||
bitfield MetadataEntryFlags {
|
||||
IsUser : 1;
|
||||
IsVirtualDisk : 1;
|
||||
IsRequired : 1;
|
||||
padding : 29;
|
||||
};
|
||||
|
||||
bitfield FileParameterFlags {
|
||||
LeaveBlockAllocated : 1;
|
||||
HasParent : 1;
|
||||
padding : 30;
|
||||
};
|
||||
|
||||
struct MetadataFileParameters {
|
||||
type::Size32 blockSize;
|
||||
FileParameterFlags flags;
|
||||
};
|
||||
|
||||
struct MetadataVirtualDiskSize {
|
||||
type::Size64 virtualDiskSize;
|
||||
};
|
||||
|
||||
struct MetadataVirtualDiskID {
|
||||
type::GUID virtualDiskID;
|
||||
};
|
||||
|
||||
struct MetadataLogicalSectorSize {
|
||||
type::Size32 logicalSectorSize;
|
||||
};
|
||||
|
||||
struct MetadataPhysicalSectorSize {
|
||||
type::Size32 physicalSectorSize;
|
||||
};
|
||||
|
||||
struct ParentLocatorEntry {
|
||||
u32 keyOffset;
|
||||
u32 valueOffset;
|
||||
u16 keyLength;
|
||||
u16 valueLength;
|
||||
|
||||
char key[keyLength] @ addressof(parent) + keyOffset;
|
||||
char value[valueLength] @ addressof(parent) + valueOffset;
|
||||
};
|
||||
|
||||
struct MetadataParentLocator {
|
||||
type::GUID locatorType;
|
||||
padding[2];
|
||||
u16 keyValueCount;
|
||||
ParentLocatorEntry entries[keyValueCount];
|
||||
};
|
||||
|
||||
fn metadata_relative(u128 offset) {
|
||||
return addressof(parent.parent);
|
||||
};
|
||||
|
||||
struct MetadataTableEntry {
|
||||
type::GUID itemID;
|
||||
|
||||
if (std::core::formatted_value(itemID) == "{CAA16737-FA36-4D43-B3B6-33F0AA44E76B}")
|
||||
MetadataFileParameters *data : u32 [[pointer_base("metadata_relative")]];
|
||||
else if (std::core::formatted_value(itemID) == "{2FA54224-CD1B-4876-B211-5DBED83BF4B8}")
|
||||
MetadataVirtualDiskSize *data : u32 [[pointer_base("metadata_relative")]];
|
||||
else if (std::core::formatted_value(itemID) == "{BECA12AB-B2E6-4523-93EF-C309E000C746}")
|
||||
MetadataVirtualDiskID *data : u32 [[pointer_base("metadata_relative")]];
|
||||
else if (std::core::formatted_value(itemID) == "{8141BF1D-A96F-4709-BA47-F233A8FAAB5F}")
|
||||
MetadataLogicalSectorSize *data : u32 [[pointer_base("metadata_relative")]];
|
||||
else if (std::core::formatted_value(itemID) == "{CDA348C7-445D-4471-9CC9-E9885251C556}")
|
||||
MetadataPhysicalSectorSize *data : u32 [[pointer_base("metadata_relative")]];
|
||||
else if (std::core::formatted_value(itemID) == "{A8D35F2D-B30B-454D-ABF7-D3D84834AB0C}")
|
||||
MetadataParentLocator *data : u32 [[pointer_base("metadata_relative")]];
|
||||
else
|
||||
u32 dataOffset;
|
||||
|
||||
type::Size32 length;
|
||||
MetadataEntryFlags flags;
|
||||
padding[4];
|
||||
};
|
||||
|
||||
struct MetadataRegion {
|
||||
char signature[8];
|
||||
padding[2];
|
||||
u16 entryCount;
|
||||
padding[20];
|
||||
MetadataTableEntry entries[entryCount];
|
||||
};
|
||||
|
||||
struct RegionTableEntry {
|
||||
type::GUID guid;
|
||||
|
||||
if (std::core::formatted_value(guid) == "{2DC27766-F623-4200-9D64-115E9BFD4A08}")
|
||||
BAT *bat : u64;
|
||||
else if (std::core::formatted_value(guid) == "{8B7CA206-4790-4B9A-B8FE-575F050F886E}")
|
||||
MetadataRegion *metadata : u64;
|
||||
else
|
||||
u64 fileOffset;
|
||||
|
||||
type::Size32 length;
|
||||
u32 required;
|
||||
};
|
||||
|
||||
struct RegionTable {
|
||||
char signature[4];
|
||||
u32 checksum;
|
||||
u32 entryCount;
|
||||
padding[4];
|
||||
|
||||
RegionTableEntry entries[entryCount];
|
||||
};
|
||||
|
||||
struct Header {
|
||||
char signature[4];
|
||||
u32 checksum;
|
||||
u64 sequenceNumber;
|
||||
type::GUID fileWriteGuid, dataWriteGuid, logGuid;
|
||||
u16 logVersion;
|
||||
u16 version;
|
||||
type::Size32 logLength;
|
||||
LogEntry *log : u64;
|
||||
padding[4016];
|
||||
};
|
||||
|
||||
struct VHDX {
|
||||
FileTypeIdentifier fileTypeIdentifier;
|
||||
|
||||
Header header @ 0x1'0000;
|
||||
Header headerBackup @ 0x2'0000;
|
||||
|
||||
RegionTable regionTable @ 0x3'0000;
|
||||
RegionTable regionTableBackup @ 0x4'0000;
|
||||
};
|
||||
|
||||
VHDX vhdx @ 0x00;
|
||||
@@ -169,7 +169,7 @@ struct WaveListItem : WaveChunk {
|
||||
} else if (chunkId == "note") {
|
||||
WaveNote note;
|
||||
} else {
|
||||
padding[chunkSize];
|
||||
padding[(chunkSize + 1) >> 1 << 1];
|
||||
}
|
||||
};
|
||||
|
||||
@@ -181,36 +181,48 @@ struct WaveList {
|
||||
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 {
|
||||
WaveFormatExDummy unknown;
|
||||
padding[paddedChunkSize - sizeof(fmt) - sizeof(unknown)];
|
||||
}
|
||||
} else if (chunk.chunkId == "data") {
|
||||
padding[chunk.chunkSize];
|
||||
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[chunk.chunkSize];
|
||||
padding[paddedChunkSize];
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ from pathlib import Path
|
||||
|
||||
def extractData(projectName, jsonData, objectName, extension):
|
||||
if objectName in jsonData:
|
||||
with open(f"./{projectName}.{extension}", "w") as output:
|
||||
with open(f"./{projectName}.{extension}", mode="w", encoding="utf-8") as output:
|
||||
output.write(jsonData[objectName])
|
||||
|
||||
def main():
|
||||
@@ -13,7 +13,7 @@ def main():
|
||||
exit(1)
|
||||
|
||||
projectPath = sys.argv[1]
|
||||
with open(projectPath, "r") as file:
|
||||
with open(projectPath, mode="r", encoding="utf-8") as file:
|
||||
jsonData = json.loads(file.read())
|
||||
|
||||
projectName = Path(projectPath).stem
|
||||
@@ -22,7 +22,7 @@ def main():
|
||||
extractData(projectName, jsonData, "pattern", "hexpat")
|
||||
|
||||
if "bookmarks" in jsonData:
|
||||
with open(f"./{projectName}.hexbm", "w") as output:
|
||||
with open(f"./{projectName}.hexbm", mode="w", encoding="utf-8") as output:
|
||||
jsonOutput = {}
|
||||
jsonOutput["bookmarks"] = jsonData["bookmarks"]
|
||||
|
||||
@@ -32,4 +32,4 @@ def main():
|
||||
print(f"Project file used file {jsonData['filePath']}")
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
main()
|
||||
|
||||
BIN
tests/patterns/test_data/lnk.hexpat.lnk
Normal file
BIN
tests/patterns/test_data/lnk.hexpat.lnk
Normal file
Binary file not shown.
BIN
tests/patterns/test_data/ntag.hexpat.bin
Normal file
BIN
tests/patterns/test_data/ntag.hexpat.bin
Normal file
Binary file not shown.
Reference in New Issue
Block a user