mirror of
https://github.com/WerWolv/ImHex-Patterns.git
synced 2026-03-31 05:15:54 -05:00
Compare commits
544 Commits
ImHex-v1.2
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a534e2a23b | ||
|
|
525f3ad4d6 | ||
|
|
27480b1da9 | ||
|
|
6a2a963a5a | ||
|
|
cee3a5de77 | ||
|
|
fb84bbb5d1 | ||
|
|
097ab49cae | ||
|
|
5a04a4256b | ||
|
|
8a9bd577ad | ||
|
|
190f9d891b | ||
|
|
2d92bfca13 | ||
|
|
0e4040fae1 | ||
|
|
57c3dd44b8 | ||
|
|
4646e4b965 | ||
|
|
9143996589 | ||
|
|
7c3dcc1fcc | ||
|
|
ea8b381ac5 | ||
|
|
998655f74a | ||
|
|
681b208aab | ||
|
|
64d86cbdd1 | ||
|
|
285a2fc7d1 | ||
|
|
2a9676238f | ||
|
|
ee340409db | ||
|
|
84dff0c886 | ||
|
|
28a297582b | ||
|
|
681b1a1ded | ||
|
|
0a09efdd20 | ||
|
|
0d8bd76c2c | ||
|
|
a525160243 | ||
|
|
c3946d33a7 | ||
|
|
cc7eb7d764 | ||
|
|
53384a4a54 | ||
|
|
da005f0172 | ||
|
|
b2f126d22f | ||
|
|
7ea863269e | ||
|
|
faff9e0364 | ||
|
|
a35004665f | ||
|
|
4fc11f1b91 | ||
|
|
7a9a5097a2 | ||
|
|
0e67ee102b | ||
|
|
69077b919d | ||
|
|
297f611fed | ||
|
|
b24ae36638 | ||
|
|
50d776f497 | ||
|
|
7dfacc4139 | ||
|
|
5359e385ea | ||
|
|
75bcb487ee | ||
|
|
fb214600ec | ||
|
|
d95390ea42 | ||
|
|
284ca8d325 | ||
|
|
6630180276 | ||
|
|
ff68d1e23d | ||
|
|
70dd55aa6b | ||
|
|
76f850c543 | ||
|
|
74c06b74f7 | ||
|
|
f13d9d3894 | ||
|
|
c4c75a9ab2 | ||
|
|
7278a22eb2 | ||
|
|
91fd36097c | ||
|
|
afffd7eced | ||
|
|
7fd79ec9fd | ||
|
|
6b9f39cc21 | ||
|
|
9207282bcf | ||
|
|
5ed64f9f08 | ||
|
|
a75a7a5b98 | ||
|
|
60c8d93449 | ||
|
|
d3b05fd753 | ||
|
|
3b2f098b09 | ||
|
|
f4f004f0eb | ||
|
|
5c6cb9dccc | ||
|
|
44717e9b19 | ||
|
|
bc35349e0f | ||
|
|
fed5db4109 | ||
|
|
1d41392215 | ||
|
|
0b75336638 | ||
|
|
e3edbd5a6f | ||
|
|
b10a37af67 | ||
|
|
103d434cc5 | ||
|
|
7716b9d6e7 | ||
|
|
ad1e300674 | ||
|
|
e918ce52b9 | ||
|
|
db4d62aa20 | ||
|
|
d96bfbb942 | ||
|
|
2070c95f58 | ||
|
|
877895741d | ||
|
|
6b279b8375 | ||
|
|
a692b22ecc | ||
|
|
2ae0499293 | ||
|
|
bd06987e8e | ||
|
|
74e08623f1 | ||
|
|
a860c396fa | ||
|
|
da934e2045 | ||
|
|
394ef80611 | ||
|
|
2ce182b1b3 | ||
|
|
6cadad3d1f | ||
|
|
7ad9cd4f41 | ||
|
|
bcaeef31d7 | ||
|
|
ee8d2f50b7 | ||
|
|
5b8dde19a9 | ||
|
|
0b0eff0cb6 | ||
|
|
3185503be1 | ||
|
|
3a64207e58 | ||
|
|
c94d42d5c0 | ||
|
|
45c4c1d35b | ||
|
|
f93be1ea06 | ||
|
|
5ed9c0fd4d | ||
|
|
11d373319f | ||
|
|
e7d366571d | ||
|
|
b6df1742b6 | ||
|
|
0b9e83ff8a | ||
|
|
c0fc748de6 | ||
|
|
89307ba8a5 | ||
|
|
a12b5ba406 | ||
|
|
537ce67895 | ||
|
|
1771c1f077 | ||
|
|
cef20e24a7 | ||
|
|
8e7cfd9442 | ||
|
|
d0ba754dc2 | ||
|
|
9f92c38ecf | ||
|
|
0844e07056 | ||
|
|
66fc006b08 | ||
|
|
5bc66df14f | ||
|
|
7310a10214 | ||
|
|
34ee3107e2 | ||
|
|
c4378ffb14 | ||
|
|
5ad7f0c1e7 | ||
|
|
df97fc7257 | ||
|
|
3ad263783d | ||
|
|
5ccd431320 | ||
|
|
fb8e5e3f77 | ||
|
|
375145e759 | ||
|
|
71eeed981d | ||
|
|
e779b88a58 | ||
|
|
aef3d3451f | ||
|
|
c5fa53dcea | ||
|
|
9a6cbdfe28 | ||
|
|
083042632d | ||
|
|
4d172cebc3 | ||
|
|
53ff0a5d62 | ||
|
|
b3b730c6e9 | ||
|
|
8db011b6e5 | ||
|
|
b936c04d21 | ||
|
|
bf56d4ff49 | ||
|
|
fdc4a87389 | ||
|
|
1f6c701348 | ||
|
|
4092dad428 | ||
|
|
559faebec3 | ||
|
|
cde46e1f15 | ||
|
|
17c200a92e | ||
|
|
384d4c7794 | ||
|
|
37a7e59c06 | ||
|
|
e8cea09477 | ||
|
|
883433b260 | ||
|
|
2db9993cb1 | ||
|
|
01ce565c9e | ||
|
|
b7b949ea27 | ||
|
|
e026ff187e | ||
|
|
63504f59a1 | ||
|
|
6113df643d | ||
|
|
3f42dddd19 | ||
|
|
2cc8868727 | ||
|
|
7f02510762 | ||
|
|
13c4168af0 | ||
|
|
1e69cd7fb2 | ||
|
|
16a87df2ac | ||
|
|
b7598405b5 | ||
|
|
d14f8de459 | ||
|
|
4c96bfbeb3 | ||
|
|
500a3fe26e | ||
|
|
5ffc583640 | ||
|
|
b9f5f1668b | ||
|
|
4c22f28a67 | ||
|
|
6f9b05b853 | ||
|
|
c533017d0b | ||
|
|
221fa70a67 | ||
|
|
661e5b7081 | ||
|
|
7d0bbd1e24 | ||
|
|
55aca93a18 | ||
|
|
255116a587 | ||
|
|
79e25fdb73 | ||
|
|
c8d9a8deb7 | ||
|
|
1d680fbf5e | ||
|
|
bc5a55affe | ||
|
|
85f5541350 | ||
|
|
61d3e110fb | ||
|
|
af957389c2 | ||
|
|
e85645897e | ||
|
|
abc78d1644 | ||
|
|
46e41db0a8 | ||
|
|
c67dc84911 | ||
|
|
323898d083 | ||
|
|
abbd25e7f6 | ||
|
|
c8ebb3eb8a | ||
|
|
bf94cb7243 | ||
|
|
6697fc23a4 | ||
|
|
8a6bb6612b | ||
|
|
1d66949375 | ||
|
|
7c65d51986 | ||
|
|
d961271c5d | ||
|
|
26d48df7dd | ||
|
|
8f1f4911a0 | ||
|
|
1d7cc537ed | ||
|
|
62ceaae09b | ||
|
|
4a8a6cba1b | ||
|
|
c3eb9e4126 | ||
|
|
a263347414 | ||
|
|
204599a70b | ||
|
|
bf6ee6d02f | ||
|
|
0125ec2c57 | ||
|
|
c5aaac25dd | ||
|
|
196011ead9 | ||
|
|
5b15136ea4 | ||
|
|
59c954ae28 | ||
|
|
8a5cb1061b | ||
|
|
120bc84548 | ||
|
|
0e17355db0 | ||
|
|
6aee524d1a | ||
|
|
b42c571d4d | ||
|
|
71e1ad8df7 | ||
|
|
5c7d77b50f | ||
|
|
a746ecb164 | ||
|
|
569e5c4c1a | ||
|
|
0316f2b667 | ||
|
|
196695e37b | ||
|
|
bced518508 | ||
|
|
2f795fc23c | ||
|
|
5ff783d571 | ||
|
|
4299243e95 | ||
|
|
23b3c2b5d0 | ||
|
|
da1c2687e8 | ||
|
|
18f968df5b | ||
|
|
f797c711ca | ||
|
|
5380877da4 | ||
|
|
bb46276bde | ||
|
|
4242869ac1 | ||
|
|
8bdcd814a9 | ||
|
|
d7811ff5e9 | ||
|
|
4d0b3e21bc | ||
|
|
acd6903b21 | ||
|
|
8d2a39f7d4 | ||
|
|
65ef3a7783 | ||
|
|
21a0b99eac | ||
|
|
a33b68921d | ||
|
|
a0bb71be58 | ||
|
|
c7fc39ac19 | ||
|
|
b540ead0ae | ||
|
|
26878548f0 | ||
|
|
e4c9d86755 | ||
|
|
2a3de1b705 | ||
|
|
e02280f9ee | ||
|
|
bbba68cef7 | ||
|
|
28b281b403 | ||
|
|
c807959d75 | ||
|
|
3416d30f2b | ||
|
|
10bf1c76cf | ||
|
|
5b7c212029 | ||
|
|
1c2e948940 | ||
|
|
7ea34e410a | ||
|
|
56950e44d8 | ||
|
|
ed42452fc1 | ||
|
|
a68ecb8888 | ||
|
|
8d4cf59497 | ||
|
|
3c2fed22e4 | ||
|
|
ff550bd105 | ||
|
|
0ad6e3abde | ||
|
|
891968db53 | ||
|
|
5799d1d7ea | ||
|
|
9c6bfeb50f | ||
|
|
9f7cdded6a | ||
|
|
03298b0b0c | ||
|
|
5f2738872e | ||
|
|
63585e6de7 | ||
|
|
cb6caafa64 | ||
|
|
236fadee47 | ||
|
|
0549e62a14 | ||
|
|
b4bf2b946f | ||
|
|
5e82bfadac | ||
|
|
a5c9f3b18a | ||
|
|
38262e6bb9 | ||
|
|
0a37b60d70 | ||
|
|
345e264ff8 | ||
|
|
ba2c396534 | ||
|
|
439f04e19b | ||
|
|
eaeea8d093 | ||
|
|
9af8d7e693 | ||
|
|
dac2e0f786 | ||
|
|
f70b7066b9 | ||
|
|
3f44a743e8 | ||
|
|
834e5261b3 | ||
|
|
0e2966f10d | ||
|
|
b2bc248447 | ||
|
|
e6589ecba1 | ||
|
|
f75ba4b6ee | ||
|
|
cf18580960 | ||
|
|
e7d1973957 | ||
|
|
35cc68544b | ||
|
|
41d8967deb | ||
|
|
658ec20b37 | ||
|
|
fb5fcbafc1 | ||
|
|
6f7988e96e | ||
|
|
0a631f0c1f | ||
|
|
5942897c29 | ||
|
|
a7e6209791 | ||
|
|
294f69fa36 | ||
|
|
1ea12cd4bd | ||
|
|
8129504dcb | ||
|
|
22e30cfef9 | ||
|
|
9b819cf392 | ||
|
|
3277821153 | ||
|
|
f23dbbb565 | ||
|
|
52f7d9e77a | ||
|
|
99df77baf2 | ||
|
|
d7b0819ff0 | ||
|
|
70f491d2fa | ||
|
|
08680a6544 | ||
|
|
23bc36c4bd | ||
|
|
8ae778944d | ||
|
|
7e6a5d3bfa | ||
|
|
27e55d2e6d | ||
|
|
e0a602c10a | ||
|
|
8748646016 | ||
|
|
4a52ee4cf8 | ||
|
|
e517e3534b | ||
|
|
edd0aa9a2f | ||
|
|
a992d1ba92 | ||
|
|
6fbdcac556 | ||
|
|
47fce1628f | ||
|
|
9b152ae560 | ||
|
|
6b136b7fc6 | ||
|
|
93494a19a4 | ||
|
|
4fd710e23e | ||
|
|
44842dc44b | ||
|
|
056035c540 | ||
|
|
5ad8e15afc | ||
|
|
39c4d11404 | ||
|
|
815bd5f7f3 | ||
|
|
917b05a9f2 | ||
|
|
46a2cef993 | ||
|
|
bca25b1a78 | ||
|
|
7ecd6d87dd | ||
|
|
bf0d96db5f | ||
|
|
705900d38b | ||
|
|
734afdf500 | ||
|
|
c0c117ac19 | ||
|
|
7fba66a444 | ||
|
|
8eed75d783 | ||
|
|
81f4978656 | ||
|
|
b6e0557a1d | ||
|
|
ba14dd0cb2 | ||
|
|
86f93dfdaf | ||
|
|
001900e3c2 | ||
|
|
6baae92553 | ||
|
|
520f9bcb22 | ||
|
|
44b0392b78 | ||
|
|
df2bd4e3f9 | ||
|
|
7723cf55c6 | ||
|
|
caa2b6aaa6 | ||
|
|
7344df7ff6 | ||
|
|
df649d2e62 | ||
|
|
8710b9e66f | ||
|
|
665c942329 | ||
|
|
50f93d14ff | ||
|
|
ab43516517 | ||
|
|
4587b465d4 | ||
|
|
75b2c7be7e | ||
|
|
19dd39e7c0 | ||
|
|
ecd34d35b2 | ||
|
|
06366839aa | ||
|
|
e3c387d0cf | ||
|
|
5a7077412c | ||
|
|
d8a37b0579 | ||
|
|
1f1b2b9c5b | ||
|
|
d1645d2dc2 | ||
|
|
61ef68b12a | ||
|
|
c52e5b959b | ||
|
|
4a62892411 | ||
|
|
fc9b4cdbc2 | ||
|
|
daa556db31 | ||
|
|
e01a832fab | ||
|
|
759708d446 | ||
|
|
82560e6d9d | ||
|
|
1a2d785093 | ||
|
|
addec74d91 | ||
|
|
ce83eedf02 | ||
|
|
463ddcc62e | ||
|
|
13b97fc976 | ||
|
|
55e4283432 | ||
|
|
ea225edf12 | ||
|
|
bb19cb43ee | ||
|
|
8f8ad0e2d5 | ||
|
|
3ad1f3969f | ||
|
|
5451d45158 | ||
|
|
e6a731fa1d | ||
|
|
8a62001705 | ||
|
|
1f8710b586 | ||
|
|
acd2d4abb8 | ||
|
|
032f3c7c01 | ||
|
|
3841ff51ef | ||
|
|
622721403f | ||
|
|
11291d1ebb | ||
|
|
92e61ccf5d | ||
|
|
062edfe527 | ||
|
|
5b32941801 | ||
|
|
e99ab5b59b | ||
|
|
775c836766 | ||
|
|
43058b4c45 | ||
|
|
0128ea87db | ||
|
|
fe231436d9 | ||
|
|
7a9ac44577 | ||
|
|
74e9d8f2e7 | ||
|
|
2f39a62d85 | ||
|
|
e21063d58b | ||
|
|
8f1a6bdd75 | ||
|
|
b9af43e08b | ||
|
|
2ffa4e0161 | ||
|
|
1cd7f92a5d | ||
|
|
d42b87d9e6 | ||
|
|
035de359d7 | ||
|
|
fe59788783 | ||
|
|
ef198cf24f | ||
|
|
b73b69a8cc | ||
|
|
5d72494019 | ||
|
|
afbce642fb | ||
|
|
a72058eb65 | ||
|
|
ab2ed98dab | ||
|
|
3edc6ea172 | ||
|
|
a9a7f0b186 | ||
|
|
5f352e26d1 | ||
|
|
3e2a6aabaa | ||
|
|
56d6f0187f | ||
|
|
adf7256c39 | ||
|
|
a25a8a3615 | ||
|
|
6ae8b30488 | ||
|
|
125ba38d72 | ||
|
|
ba55feb200 | ||
|
|
a301a4bfeb | ||
|
|
531be04739 | ||
|
|
87e05bec48 | ||
|
|
a31d290005 | ||
|
|
f3de35a320 | ||
|
|
d9de2f7058 | ||
|
|
790f837e4f | ||
|
|
d8a291977a | ||
|
|
62a83b53aa | ||
|
|
53ea45ffa6 | ||
|
|
c0a1bbd218 | ||
|
|
27f4e20638 | ||
|
|
bbb2107d5f | ||
|
|
8601a6665e | ||
|
|
c6f2b57384 | ||
|
|
dd190f7c8a | ||
|
|
55e3fec3bc | ||
|
|
8e78f371f5 | ||
|
|
2758ec8d36 | ||
|
|
82ca79c166 | ||
|
|
146273b1b3 | ||
|
|
ab4bff9f42 | ||
|
|
000f0eb730 | ||
|
|
2d45d5d086 | ||
|
|
2d4b4add82 | ||
|
|
e635c3a5bf | ||
|
|
15234a284d | ||
|
|
0673673b99 | ||
|
|
3786f7e265 | ||
|
|
ea4dda001a | ||
|
|
324b0894d3 | ||
|
|
e89e85e10c | ||
|
|
b93e957e46 | ||
|
|
e7eba44ae0 | ||
|
|
41d801a114 | ||
|
|
25f73ca721 | ||
|
|
facbe59163 | ||
|
|
55023ce4ea | ||
|
|
32158edb3a | ||
|
|
862d4d1c28 | ||
|
|
d4045b76c3 | ||
|
|
8ab2ff4ab1 | ||
|
|
5ea7141cb7 | ||
|
|
9b13113682 | ||
|
|
0748fa135e | ||
|
|
a4a14309be | ||
|
|
7c179b3b41 | ||
|
|
c204696209 | ||
|
|
f53be98204 | ||
|
|
ee95990225 | ||
|
|
ac28d9d029 | ||
|
|
372a0e5bba | ||
|
|
544cadbcca | ||
|
|
1471b02abd | ||
|
|
73cde21254 | ||
|
|
f730d8b0cc | ||
|
|
13183769f8 | ||
|
|
5eda5a15bf | ||
|
|
8e6248aa2d | ||
|
|
75fd40442b | ||
|
|
5a3036149c | ||
|
|
b160e99b63 | ||
|
|
f32db1745f | ||
|
|
7842c974df | ||
|
|
e2c191b7c9 | ||
|
|
71ee41fe2c | ||
|
|
69feadfc09 | ||
|
|
e79d512b2b | ||
|
|
e876270a08 | ||
|
|
8f39ecd879 | ||
|
|
ba36826e2d | ||
|
|
ac0b77540d | ||
|
|
683e78d9c3 | ||
|
|
110b498d7b | ||
|
|
9887da7af5 | ||
|
|
01a1bd0d9f | ||
|
|
fbb6a84323 | ||
|
|
4cdf3c11cf | ||
|
|
a9ada89bd0 | ||
|
|
de0e089165 | ||
|
|
e7ea6fd77f | ||
|
|
ff3c796de8 | ||
|
|
0c83764f24 | ||
|
|
d87f95dbfa | ||
|
|
51dad63779 | ||
|
|
764b86acc9 | ||
|
|
10fdf94899 | ||
|
|
9ba998e618 | ||
|
|
aceeb2b7b3 | ||
|
|
3b1b7cc379 | ||
|
|
49be43e0e1 | ||
|
|
8e70a5524d | ||
|
|
9c0bf1433c | ||
|
|
43afbfa120 | ||
|
|
f75703fd2b | ||
|
|
16eebea2fb | ||
|
|
6cb208d975 | ||
|
|
665c50b914 | ||
|
|
04ef9d6085 | ||
|
|
dc5b219d24 | ||
|
|
e6c800b71c | ||
|
|
5c9a7b1ac0 | ||
|
|
22390d0adf | ||
|
|
dfc9b17067 | ||
|
|
d33fdfafb8 | ||
|
|
58d63d1d4a | ||
|
|
86f38ca545 | ||
|
|
27d98d4552 | ||
|
|
dba93afe06 |
2
.gitattributes
vendored
2
.gitattributes
vendored
@@ -1,2 +1,4 @@
|
||||
*.pat linguist-language=Rust
|
||||
*.hexpat linguist-language=Rust
|
||||
|
||||
tests/patterns/test_data/** binary
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
## Checklist
|
||||
- [ ] 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 new pattern has a description pragma (`#pragma description My pattern Description here`)
|
||||
- [ ] 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
|
||||
- Try to keep this file below ~ 1 MB
|
||||
|
||||
56
.github/workflows/dispatch.yml
vendored
Normal file
56
.github/workflows/dispatch.yml
vendored
Normal file
@@ -0,0 +1,56 @@
|
||||
name: "Dispatch"
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ '*' ]
|
||||
pull_request:
|
||||
branches: [ '*' ]
|
||||
repository_dispatch:
|
||||
types: [run_tests]
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
generate_docs:
|
||||
description: "Regenerate docs"
|
||||
required: false
|
||||
type: boolean
|
||||
|
||||
jobs:
|
||||
tests:
|
||||
name: 🎯 Dispatch changes
|
||||
runs-on: ubuntu-24.04
|
||||
env:
|
||||
DISPATCH_TOKEN: ${{ secrets.DISPATCH_TOKEN }}
|
||||
permissions:
|
||||
actions: read
|
||||
contents: read
|
||||
security-events: write
|
||||
|
||||
steps:
|
||||
- name: 🧰 Checkout
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
submodules: recursive
|
||||
|
||||
- name: 📄 Check changed include files
|
||||
id: changed-includes
|
||||
uses: tj-actions/changed-files@v45
|
||||
with:
|
||||
files: includes/**/*.pat
|
||||
|
||||
- name: ✉️ Run Documentation generator
|
||||
if: ${{ env.DISPATCH_TOKEN != '' && (steps.changed-includes.outputs.any_changed == 'true' || inputs.generate_docs || github.event_name == 'repository_dispatch' ) }}
|
||||
uses: mvasigh/dispatch-action@main
|
||||
with:
|
||||
token: ${{ secrets.DISPATCH_TOKEN }}
|
||||
repo: Documentation
|
||||
owner: WerWolv
|
||||
event_type: update_pl_docs
|
||||
|
||||
- name: ✉️ Update PatternLanguage Website
|
||||
if: ${{ env.DISPATCH_TOKEN != '' }}
|
||||
uses: mvasigh/dispatch-action@main
|
||||
with:
|
||||
token: ${{ secrets.DISPATCH_TOKEN }}
|
||||
repo: PatternLanguageWeb
|
||||
owner: WerWolv
|
||||
event_type: rebuild_wasm
|
||||
60
.github/workflows/tests.yml
vendored
60
.github/workflows/tests.yml
vendored
@@ -7,11 +7,17 @@ on:
|
||||
branches: [ '*' ]
|
||||
repository_dispatch:
|
||||
types: [run_tests]
|
||||
workflow_call:
|
||||
inputs:
|
||||
pattern_language_git_repo:
|
||||
type: string
|
||||
pattern_language_git_hash:
|
||||
type: string
|
||||
|
||||
jobs:
|
||||
tests:
|
||||
name: 🧪 Unit Tests
|
||||
runs-on: ubuntu-22.04
|
||||
runs-on: ubuntu-24.04
|
||||
permissions:
|
||||
actions: read
|
||||
contents: read
|
||||
@@ -19,8 +25,9 @@ jobs:
|
||||
|
||||
steps:
|
||||
- name: 🧰 Checkout
|
||||
uses: actions/checkout@v2
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
repository: ${{ github.repository_owner }}/ImHex-Patterns
|
||||
submodules: recursive
|
||||
|
||||
- name: ⬇️ Install dependencies
|
||||
@@ -28,53 +35,56 @@ jobs:
|
||||
sudo apt update
|
||||
sudo apt install -y \
|
||||
build-essential \
|
||||
gcc-12 \
|
||||
g++-12 \
|
||||
ccache \
|
||||
gcc-14 \
|
||||
g++-14 \
|
||||
lld \
|
||||
${PKGCONF:-} \
|
||||
cmake \
|
||||
make \
|
||||
ninja-build \
|
||||
python3 \
|
||||
python3-pip \
|
||||
libmagic-dev \
|
||||
lcov
|
||||
|
||||
|
||||
sudo pip install jsonschema
|
||||
|
||||
- name: 📜 Setup ccache
|
||||
uses: hendrikmuhs/ccache-action@v1
|
||||
with:
|
||||
key: ${{ runner.os }}-ccache-${{ github.run_id }}
|
||||
restore-keys: ${{ runner.os }}-ccache
|
||||
max-size: 1G
|
||||
|
||||
- name: 🛠️ Build
|
||||
run: |
|
||||
cd tests
|
||||
mkdir -p build
|
||||
cd build
|
||||
CC=gcc-12 CXX=g++-12 cmake \
|
||||
CC=gcc-14 CXX=g++-14 cmake \
|
||||
-DCMAKE_C_COMPILER_LAUNCHER=ccache \
|
||||
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
|
||||
-DCMAKE_C_FLAGS="-fuse-ld=lld --coverage" \
|
||||
-DCMAKE_CXX_FLAGS="-fuse-ld=lld --coverage" \
|
||||
-DIMHEX_PATTERNS_ENABLE_UNIT_TESTS=ON \
|
||||
-DLIBPL_ENABLE_TESTS=OFF \
|
||||
-DLIBPL_ENABLE_CLI=OFF \
|
||||
-DIMHEX_PATTERNS_LIBPL_GIT_REPO="${{ inputs.pattern_language_git_repo }}" \
|
||||
-DIMHEX_PATTERNS_LIBPL_GIT_HASH="${{ inputs.pattern_language_git_hash }}" \
|
||||
-G Ninja \
|
||||
..
|
||||
make -j4
|
||||
ninja unit_tests
|
||||
|
||||
- name: 🧪 Perform Unit Tests
|
||||
run: |
|
||||
cd tests/build
|
||||
ctest --output-on-failure
|
||||
|
||||
- name: ⚗️ Generate Coverage Report
|
||||
run: |
|
||||
cd tests/build
|
||||
lcov -d ./_deps/pattern_language-build/lib --gcov-tool /usr/bin/gcov-12 -c -o coverage.info
|
||||
|
||||
- name: ⬆️ Upload Coverage Report
|
||||
uses: coverallsapp/github-action@master
|
||||
with:
|
||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
path-to-lcov: tests/build/coverage.info
|
||||
cd build
|
||||
ctest --output-on-failure -j 4
|
||||
|
||||
- name: 📎 Validate JSON Files
|
||||
run: |
|
||||
cd constants
|
||||
for file in ./[!_schema.json]*; do jsonschema -i $file _schema.json; done
|
||||
for file in ./[!_]*; do jsonschema -i $file _schema.json; done
|
||||
cd ..
|
||||
|
||||
|
||||
cd tips
|
||||
for file in ./[!_schema.json]*; do jsonschema -i $file _schema.json; done
|
||||
for file in ./[!_]*; do jsonschema -i $file _schema.json; done
|
||||
cd ..
|
||||
|
||||
11
.gitignore
vendored
11
.gitignore
vendored
@@ -1,4 +1,13 @@
|
||||
|
||||
tests/cmake-build-debug/
|
||||
tests/cmake*/
|
||||
tests/build*/
|
||||
build/
|
||||
cmake-build-*/
|
||||
|
||||
.vscode/
|
||||
.devcontainer/
|
||||
.cache/
|
||||
.idea/
|
||||
.DS_Store
|
||||
|
||||
compile_commands.json
|
||||
8
.gitmodules
vendored
8
.gitmodules
vendored
@@ -1,4 +1,10 @@
|
||||
[submodule "rules"]
|
||||
path = yara/official_rules
|
||||
url = https://github.com/Yara-Rules/rules
|
||||
branch = master
|
||||
branch = master
|
||||
[submodule "patterns/ffx"]
|
||||
path = patterns/ffx
|
||||
url = https://gitlab.com/EvelynTSMG/imhex-ffx-pats.git
|
||||
[submodule "patterns/bastion"]
|
||||
path = patterns/bastion
|
||||
url = https://gitlab.com/EvelynTSMG/imhex-bastion-pats.git
|
||||
|
||||
42
CMakeLists.txt
Normal file
42
CMakeLists.txt
Normal file
@@ -0,0 +1,42 @@
|
||||
cmake_minimum_required(VERSION 3.16)
|
||||
|
||||
project(ImHex-Patterns)
|
||||
|
||||
option(IMHEX_PATTERNS_ENABLE_UNIT_TESTS "Enable building unit tests for ImHex-Patterns" OFF)
|
||||
|
||||
# if enabled, add a unit_test custom target for all the unit tests to be registered against
|
||||
if(IMHEX_PATTERNS_ENABLE_UNIT_TESTS)
|
||||
if(NOT TARGET unit_tests)
|
||||
enable_testing()
|
||||
add_custom_target(unit_tests)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# If this has been manually cloned into another project, libpl may already have been set up
|
||||
if(NOT TARGET libpl)
|
||||
include(FetchContent)
|
||||
|
||||
if (NOT DEFINED IMHEX_PATTERNS_LIBPL_GIT_REPO OR IMHEX_PATTERNS_LIBPL_GIT_REPO STREQUAL "")
|
||||
set(LIBPL_GIT_REPO "https://github.com/WerWolv/PatternLanguage")
|
||||
else()
|
||||
set(LIBPL_GIT_REPO ${IMHEX_PATTERNS_LIBPL_GIT_REPO})
|
||||
endif()
|
||||
|
||||
if (NOT DEFINED IMHEX_PATTERNS_LIBPL_GIT_HASH OR IMHEX_PATTERNS_LIBPL_GIT_HASH STREQUAL "")
|
||||
set(LIBPL_GIT_TAG "master")
|
||||
else()
|
||||
set(LIBPL_GIT_TAG ${IMHEX_PATTERNS_LIBPL_GIT_HASH})
|
||||
endif()
|
||||
|
||||
FetchContent_Declare(
|
||||
pattern_language
|
||||
GIT_REPOSITORY ${LIBPL_GIT_REPO}
|
||||
GIT_TAG ${LIBPL_GIT_TAG}
|
||||
)
|
||||
|
||||
FetchContent_MakeAvailable(pattern_language)
|
||||
endif()
|
||||
|
||||
if(IMHEX_PATTERNS_ENABLE_UNIT_TESTS)
|
||||
add_subdirectory(tests)
|
||||
endif()
|
||||
12
CONTRIBUTING.md
Normal file
12
CONTRIBUTING.md
Normal file
@@ -0,0 +1,12 @@
|
||||
# Contributing
|
||||
|
||||
Contributing to the Database is very simple. Fork this repository, add your new files (or changes to existing files) to the right folders and create a PR.
|
||||
When adding new files, please make sure to also add a link to them to the Table of Contents in the README.md file. That way the files can be discovered by others more easily.
|
||||
|
||||
Thanks a lot for any additions or improvements :)
|
||||
|
||||
## Adding new Patterns
|
||||
|
||||
When adding new patterns, if possible, please also add a test file named `<pattern_name>.hexpat.<extension>` to the `/tests/patterns/test_data` directory. This allows our Unit Tests to be run against your code so we can make sure it stays up-to-date and doesn't break when changes are made to the PatternLanguage.
|
||||
Please try to keep these files as small as possible (~100kiB at most) so cloning stays fast.
|
||||
Please also make sure to not submit any test files that are under copyright such as game files, ROMs or files extracted from other programs. We don't want a DMCA takedown on this repo.
|
||||
399
README.md
399
README.md
@@ -1,6 +1,21 @@
|
||||
# ImHex-Patterns
|
||||
# ImHex Database
|
||||
|
||||
Hex patterns, include patterns and magic files for the use with the ImHex Hex Editor
|
||||
This repository serves as a database for files to use with the [ImHex Hex Editor](https://github.com/WerWolv/ImHex). It currently contains
|
||||
|
||||
- [Patterns](/patterns) - Binary Format definitions for the Pattern Language
|
||||
- [Pattern Libraries](/includes) - Libraries that make using the Pattern Language easier
|
||||
- [Magic Files](/magic) - Custom magic file definitions for the use with libmagic
|
||||
- [Encodings](/encodings) - Custom encodings in the .tbl format
|
||||
- [Data Processor Nodes](/nodes) - Custom nodes made for ImHex's Data Processor
|
||||
- [Themes](/themes) - Custom themes for ImHex
|
||||
- [Constants](/constants) - Constants definition files
|
||||
- [Scripts](/scripts) - Various scripts to generate code or automate some tasks
|
||||
- [Yara](/yara) - Custom Yara rules
|
||||
|
||||
## Submissions
|
||||
|
||||
Most files in this repository have been submitted by the community. Please feel free to open a PR on your own and add files to it!
|
||||
Everything will immediately show up in ImHex's Content Store and gets bundled with the next release of ImHex.
|
||||
|
||||
## Table of Contents
|
||||
|
||||
@@ -8,122 +23,330 @@ Hex patterns, include patterns and magic files for the use with the ImHex Hex Ed
|
||||
|
||||
| Name | MIME | Path | Description |
|
||||
|------|------|------|-------------|
|
||||
| BMP | `image/bmp` | `patterns/bmp.hexpat` | OS2/Windows Bitmap files |
|
||||
| ELF | `application/x-executable` | `patterns/elf.hexpat` | ELF header in elf binaries |
|
||||
| PE | `application/x-dosexec` | `patterns/pe.hexpat` | PE header, COFF header, Standard COFF fields and Windows Specific fields |
|
||||
| Intel HEX | | `patterns/intel_hex.hexpat` | [Intel hexadecimal object file format definition]("https://en.wikipedia.org/wiki/Intel_HEX") |
|
||||
| MIDI | `audio/midi` | `patterns/midi.hexpat` | MIDI header, event fields provided |
|
||||
| WAV | `audio/wav` | `patterns/wav.hexpat` | RIFF header, WAVE header, PCM header |
|
||||
| ZIP | `application/zip` | `patterns/zip.hexpat` | End of Central Directory Header, Central Directory File Headers |
|
||||
| PCAP | `application/vnd.tcpdump.pcap` | `patterns/pcap.hexpat` | pcap header and packets |
|
||||
| SPIRV | | `patterns/spirv.hexpat` | SPIR-V header and instructions |
|
||||
| AFE2 | | `patterns/afe2.hexpat` | Nintendo Switch Atmosphère CFW Fatal Error log |
|
||||
| AR | `application/x-archive` | `patterns/ar.hexpat` | Static library archive files |
|
||||
| NACP | | `patterns/nacp.hexpat` | Nintendo Switch NACP files |
|
||||
| NRO | | `patterns/nro.hexpat` | Nintendo Switch NRO files |
|
||||
| PRODINFO | | `patterns/prodinfo.hexpat` | Nintendo Switch PRODINFO |
|
||||
| Java Class | `application/x-java-applet` | `patterns/java_class.hexpat` | Java Class files |
|
||||
| ARM VTOR | | `patterns/arm_cm_vtor.hexpat` | ARM Cortex M Vector Table Layout |
|
||||
| ICO | | `patterns/ico.hexpat` | Icon (.ico) or Cursor (.cur) files |
|
||||
| PNG | `image/png` | `patterns/png.hexpat` | PNG image files |
|
||||
| DDS | `image/vnd-ms.dds` | `patterns/dds.hexpat` | DirectDraw Surface |
|
||||
| TGA | `image/tga` | `patterns/tga.hexpat` | Truevision TGA/TARGA image |
|
||||
| ISO | | `patterns/iso.hexpat` | ISO 9660 file system |
|
||||
| VDF | | `patterns/vdf.hexpat` | Binary Value Data Format (.vdf) files |
|
||||
| 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 |
|
||||
| Xilinx BIT | | `patterns/xilinx_bit.hexpat` | Xilinx FPGA Bitstreams |
|
||||
| FLAC | `audio/flac` | `patterns/flac.hexpat` | Free Lossless Audio Codec, FLAC Audio Format |
|
||||
| BSON | `application/bson` | `patterns/bson.hexpat` | BSON (Binary JSON) format |
|
||||
| msgpack | `application/x-msgpack` | `patterns/msgpack.hexpat` | MessagePack binary serialization format |
|
||||
| MiniDump | `application/x-dmp` | `patterns/minidump.hexpat` | Windows MiniDump files |
|
||||
| 3DS | | [`patterns/3ds.hexpat`](patterns/3ds.hexpat) | Autodesk 3DS Max Model file |
|
||||
| 7Z | | [`patterns/7z.hexpat`](patterns/7z.hexpat) | 7z File Format |
|
||||
| ADTFDAT | | [`patterns/adtfdat.hexpat`](patterns/adtfdat.hexpat) | [ADTFDAT files](https://digitalwerk.gitlab.io/solutions/adtf_content/adtf_base/adtf_file_library) |
|
||||
| ADTS | `audio/x-hx-aac-adts` | [`patterns/adts.hexpat`](patterns/adts.hexpat) | ADTS/AAC audio files |
|
||||
| AFE2 | | [`patterns/afe2.hexpat`](patterns/afe2.hexpat) | Nintendo Switch Atmosphère CFW Fatal Error log |
|
||||
| ANI | `application/x-navi-animation` | [`patterns/ani.hexpat`](patterns/ani.hexpat) | Windows Animated Cursor file |
|
||||
| APFS | | [`patterns/fs/apfs.hexpat`](patterns/fs/apfs.hexpat) | Apple File Ssytem (APFS) |
|
||||
| AppleSingle | `application/applefile` | [`patterns/apple_single_double.hexpat`](patterns/apple_single_double.hexpat) | AppleSingle Dual Fork file |
|
||||
| AppleDouble | `multipart/appledouble` | [`patterns/apple_single_double.hexpat`](patterns/apple_single_double.hexpat) | AppleDouble Resource Fork/Finder Metadata file |
|
||||
| AR | `application/x-archive` | [`patterns/ar.hexpat`](patterns/ar.hexpat) | Static library archive files |
|
||||
| ARC | | [`patterns/arc.hexpat`](patterns/arc.hexpat) | Minecraft Legacy Console Edition ARC files |
|
||||
| ARIA2 | | [`patterns/aria2.hexpat`](patterns/aria2.hexpat) | ARIA2 Download Manager Control files |
|
||||
| ARM VTOR | | [`patterns/arm_cm_vtor.hexpat`](patterns/arm_cm_vtor.hexpat) | ARM Cortex M Vector Table Layout |
|
||||
| Arma 3 config | `application/x.a3-rap` | [`patterns/a3/a3_rap.hexpat`](patterns/a3/a3_rap.hexpat) | Arma 3 binary/rapified config |
|
||||
| Arma 3 P3D (MLOD) | `model/x.a3-p3d-mlod` | [`patterns/a3/a3_p3d_mlod.hexpat`](patterns/a3/a3_p3d_mlod.hexpat) | Arma 3 P3D model file (MLOD) |
|
||||
| Arma 3 PAA | `image/x.a3-paa` | [`patterns/a3/a3_paa.hexpat`](patterns/a3/a3_paa.hexpat) | Arma 3 PAA texture file |
|
||||
| Arma 3 RTM | `application/x.a3-rtm` | [`patterns/a3/a3_rtm.hexpat`](patterns/a3/a3_rtm.hexpat) | Arma 3 RTM animation file (plain) |
|
||||
| Arma 3 RTM (binarized) | `application/x.a3-bmtr` | [`patterns/a3/a3_bmtr.hexpat`](patterns/a3/a3_bmtr.hexpat) | Arma 3 RTM animation file (binarized) |
|
||||
| Arma 3 texHeaders.bin | `application/x.a3-texheaders` | [`patterns/a3/a3_texheaders.hexpat`](patterns/a3/a3_texheaders.hexpat) | Arma 3 texture index file |
|
||||
| Assassin's Creed: Unity | | [`patterns/AC Unity`](patterns/Assassin's Creed: Unity) | Assassin's Creed: Unity archive files -- .forge & .data (compressed and decompressed) -- |
|
||||
| Bastion | | [`patterns/bastion/*`](https://gitlab.com/EvelynTSMG/imhex-bastion-pats) | Various [Bastion](https://en.wikipedia.org/wiki/Bastion_(video_game)) files |
|
||||
| BeyondCompare BCSS | | [`patterns/bcss.hexpat`](patterns/bcss.hexpat) | BeyondCompare Snapshot (BCSS) file |
|
||||
| Bencode | `application/x-bittorrent` | [`patterns/bencode.hexpat`](patterns/bencode.hexpat) | Bencode encoding, used by Torrent files |
|
||||
| Prusa BGCODE | | [`patterns/bgcode.hexpat`](patterns/bgcode.hexpat) | PrusaSlicer Binary G-Code files |
|
||||
| BLEND | | [`patterns/blend.hexpat`](patterns/blend.hexpat) | Blender Project file |
|
||||
| BLF | | [`patterns/blf.hexpat`](patterns/blf.hexpat) | Vector BLF Frame Logging Files |
|
||||
| BMP | `image/bmp` | [`patterns/bmp.hexpat`](patterns/bmp.hexpat) | OS2/Windows Bitmap files |
|
||||
| BIN | | [`patterns/selinux.hexpat`](patterns/selinux.pat) | SE Linux modules |
|
||||
| BINKA | | [`patterns/binka.hexpat`](patterns/binka.pat) | RAD Game Tools Bink Audio (BINKA) files |
|
||||
| BSON | `application/bson` | [`patterns/bson.hexpat`](patterns/bson.hexpat) | BSON (Binary JSON) format |
|
||||
| bplist | `application/x-bplist` | [`patterns/bplist.hexpat`](patterns/bplist.hexpat) | Apple's binary property list format (bplist) |
|
||||
| BSP | | [`patterns/bsp_goldsrc.hexpat`](patterns/bsp_goldsrc.hexpat) | GoldSrc engine maps format (used in Half-Life 1) |
|
||||
| BZIP3 | | [`patterns/bzip3.hexpat`](patterns/bzip3.hexpat) | Parses BZip3 compression (file format) by Kamila Szewczyk |
|
||||
| CAB | | [`patterns/cab.hexpat`](patterns/cab.hexpat) | Microsoft Cabinet (CAB) Files |
|
||||
| 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 |
|
||||
| CDA | | [`patterns/cda.hexpat`](patterns/cda.hexpat) | Compact Disc Audio track |
|
||||
| CHD | | [`patterns/chd.hexpat`](patterns/chd.hexpat) | MAME Compressed Hunks of Data file |
|
||||
| CHM | `application/vnd.ms-htmlhelp` | [`patterns/chm.hexpat`](patterns/chm.hexpat) | Windows HtmlHelp Data (ITSF / CHM) |
|
||||
| Chromium Pak | | [`patterns/chromium_pak.hexpat`](patterns/chromium_pak.hexpat) | Chromium pak file |
|
||||
| COFF | `application/x-coff` | [`patterns/coff.hexpat`](patterns/coff.hexpat) | Common Object File Format (COFF) executable |
|
||||
| CPIO | `application/x-cpio` | [`patterns/cpio.hexpat`](patterns/cpio.hexpat) | Old Binary CPIO Format |
|
||||
| CPIO | | [`patterns/cpio_portable_ascii.hexpat`](patterns/cpio_portable_ascii.hexpat) | Portable ASCII CPIO Format |
|
||||
| CPIO | | [`patterns/cpio_new_ascii.hexpat`](patterns/cpio_new_ascii.hexpat) | "New" ASCII CPIO Format |
|
||||
| CrashLvl | | [`patterns/Crashlvl.hexpat`](patterns/Crashlvl.hexpat) | Crash Bandicoot - Back in Time (fan game) User created level format |
|
||||
| CREDHIST | | [`patterns/credhist.hexpat`](patterns/credhist.hexpat) | CREDHIST Format |
|
||||
| DDS | `image/vnd-ms.dds` | [`patterns/dds.hexpat`](patterns/dds.hexpat) | DirectDraw Surface |
|
||||
| DEX | | [`patterns/dex.hexpat`](patterns/dex.hexpat) | Dalvik EXecutable Format |
|
||||
| Devil May Cry HD Collection | | [`patterns/Devil May Cry HD Collection`](patterns/Devil May Cry HD Collection) | 3D Model files used in Devil May Cry 3 HD Collection |
|
||||
| DICOM | `application/dicom` | [`patterns/dicom.hexpat`](patterns/dicom.hexpat) | DICOM image format |
|
||||
| DISK_PARSER (DFIR) | `application/x-ima` | [`patterns/DFIR/DISK_PARSER.hexpat`](patterns/DFIR/DISK_PARSER.hexpat) | Recursive Disk/Volume/Filesystem parsing |
|
||||
| DMG | | [`patterns/dmg.hexpat`](patterns/dmg.hexpat) | Apple Disk Image Trailer (DMG) |
|
||||
| DMP | | [`patterns/dmp64.hexpat`](patterns/dmp64.hexpat) | Windows Kernel Dump(DMP64) |
|
||||
| DOS | `application/x-dosexec` | [`patterns/dos.hexpat`](patterns/dos.hexpat) | 16-bit real mode DOS EXE files |
|
||||
| DOTNET_BinaryFormatter | | [`patterns/dotnet_binaryformatter.hexpat`](patterns/dotnet_binaryformatter.hexpat) | .NET BinaryFormatter |
|
||||
| DPAPI_Blob | | [`patterns/dpapblob.hexpat`](patterns/dpapiblob.hexpat) | Data protection API Blob File Format |
|
||||
| DPAPI_MasterKey | | [`patterns/dpapimasterkey.hexpat`](patterns/dpapimasterkey.hexpat) | Data protection API MasterKey |
|
||||
| DS_Store | | [`patterns/dsstore.hexpat`](patterns/dsstore.hexpat) | .DS_Store file format |
|
||||
| DTA | | [`patterns/max_v104.hexpat`](patterns/max_v104.hexpat) | Mechanized Assault and Exploration v1.04 (strategy game) save file format |
|
||||
| DTED | | [`patterns/dted.hexpat`](patterns/dted.hexpat) | Digital Terrain Elevation Data (DTED) |
|
||||
| ELF | `application/x-executable` | [`patterns/elf.hexpat`](patterns/elf.hexpat) | ELF header in elf binaries |
|
||||
| ESP32 Image | | [`patterns/esp32_image.hexpat`](patterns/esp32_image.hexpat) | Firmware image format for the ESP32 chip family |
|
||||
| EVTX | `application/x-ms-evtx` | [`patterns/evtx.hexpat`](patterns/evtx.hexpat) | MS Windows Vista Event Log |
|
||||
| EXFAT | | [`patterns/fs/exfat.hexpat`](patterns/fs/exfat.hexpat) | Extensible File Allocation Table (exFAT) |
|
||||
| EXFAT (DFIR) | | [`patterns/DFIR/exFAT.hexpat`](patterns/DFIR/exFAT.hexpat) | Imported by DISK_PARSER.hexpat |
|
||||
| EXT4 | | [`patterns/fs/ext4.hexpat`](patterns/fs/ext4.hexpat) | Ext4 File System |
|
||||
| FAS | | [`patterns/fas_oskasoftware.hexpat`](patterns/fas_oskasoftware.hexpat) [`patterns/fas_oskasoftware_old.hexpat`](patterns/fas_oskasoftware_old.hexpat) (Old versions of Oska DeskMate) | Oska Software DeskMates FAS (Frames and Sequences) file |
|
||||
| FAT32 | | [`patterns/fs/fat32.hexpat`](patterns/fs/fat32.hexpat) | FAT32 File System |
|
||||
| FAT32 (DFIR) | | [`patterns/DFIR/FAT32.hexpat`](patterns/DFIR/FAT32.hexpat) | Imported by DISK_PARSER.hexpat |
|
||||
| FBX | | [`patterns/fbx.hexpat`](patterns/fbx.hexpat) | Kaydara FBX Binary |
|
||||
| FDT | | [`patterns/fdt.hexpat`](patterns/fdt.hexpat) | Flat Linux Device Tree blob |
|
||||
| FFX | | [`patterns/ffx/*`](https://gitlab.com/EvelynTSMG/imhex-ffx-pats) | Various Final Fantasy X files |
|
||||
| File System | `application/x-ima` | [`patterns/fs/pattern.hexpat`](patterns/fs/pattern.hexpat) | Drive File System |
|
||||
| FLAC | `audio/flac` | [`patterns/flac.hexpat`](patterns/flac.hexpat) | Free Lossless Audio Codec, FLAC Audio Format |
|
||||
| FLC/FLIC | | [`patterns/flc.hexpat`](patterns/flc.hexpat) | FLC/FLIC animation file |
|
||||
| FLV | | [`patterns/flv.hexpat`](patterns/flv.hexpat) | FLv animation file |
|
||||
| Flipper Zero Settings | | [`patterns/flipper_settings.hexpat`](patterns/flipper_settings.hexpat) | Flipper Zero Settings Files |
|
||||
| GB | `application/x-gameboy-rom` | [`patterns/gb.hexpat`](patterns/gb.hexpat) | Game Boy ROM |
|
||||
| GBA | `application/x-gameboy-advance-rom` | [`patterns/gba.hexpat`](patterns/gba.hexpat) | Game Boy Advance ROM header |
|
||||
| GBX | | [`patterns/gbx.hexpat`](patterns/gbx.hexpat) | GameBoy ROM file GBX footer |
|
||||
| Gen | | [`patterns/gen.hexpat`](patterns/gen.hexpat) | Sega Genesis/MegaDrive ROM |
|
||||
| GGUF | | [`patterns/gguf.hexpat`](patterns/gguf.hexpat) | GGML Inference Models |
|
||||
| GIF | `image/gif` | [`patterns/gif.hexpat`](patterns/gif.hexpat) | GIF image files |
|
||||
| GLTF | `model/gltf-binary` | [`patterns/gltf.hexpat`](patterns/gltf.hexpat) | GL Transmission Format binary 3D model file |
|
||||
| GZIP | `application/gzip` | [`patterns/gzip.hexpat`](patterns/gzip.hexpat) | GZip compressed data format |
|
||||
| Halo Tag || [`patterns/hinf_tag.hexpat`](patterns/hinf_tag.hexpat) | Halo Infinite Tag Files |
|
||||
| Halo Module || [`patterns/hinf_module.hexpat`](patterns/hinf_module.hexpat) | Halo Infinite Module Archive Files |
|
||||
| Halo HavokScript || [`patterns/hinf_luas.hexpat`](patterns/hinf_luas.hexpat) | Halo Infinite HavokScript 5.1 Bytecode |
|
||||
| HPROF || [`patterns/hprof.hexpat`](patterns/hprof.hexpat) | Java HPROF Profiler Data Format |
|
||||
| HSDT || [`patterns/hsdt.hexpat`](patterns/hsdt.hexpat) | HiSilicon device-tree table images |
|
||||
| ICO | | [`patterns/ico.hexpat`](patterns/ico.hexpat) | Icon (.ico) or Cursor (.cur) files |
|
||||
| ID3 | `audio/mpeg` | [`patterns/id3.hexpat`](patterns/id3.hexpat) | ID3 tags in MP3 files |
|
||||
| IM*H || [`patterns/imah.hexpat`](patterns/imah.hexpat) | DJI Signed Firmware (IM*H) |
|
||||
| Intel HEX | | [`patterns/intel_hex.hexpat`](patterns/intel_hex.hexpat) | [Intel hexadecimal object file format definition]("https://en.wikipedia.org/wiki/Intel_HEX") |
|
||||
| IP | | [`patterns/ip.hexpat`](patterns/ip.hexpat) | Ethernet II Frames (IP Packets) |
|
||||
| IPS | | [`patterns/ips.hexpat`](patterns/ips.hexpat) | IPS (International Patching System) files |
|
||||
| ISO | `application/x-iso9660-image` | [`patterns/iso.hexpat`](patterns/iso.hexpat) | ISO 9660 file system |
|
||||
| Java Class | `application/x-java-applet` | [`patterns/java_class.hexpat`](patterns/java_class.hexpat) | Java Class files |
|
||||
| JPEG | `image/jpeg` | [`patterns/jpeg.hexpat`](patterns/jpeg.hexpat) | JPEG Image Format |
|
||||
| Kindle Update | | [`patterns/kindle_update.hexpat`](patterns/kindle_update.hexpat) | Kindle Update Package |
|
||||
| KTX | `image/ktx` | [`patterns/ktx.hexpat`](patterns/ktx.hexpat) | Khronos TeXture 1.0 |
|
||||
| LOC | | [`patterns/loc.hexpat`](patterns/loc.hexpat) | Minecraft Legacy Console Edition Language file |
|
||||
| Lua 4.0 | | [`patterns/lua40.hexpat`](patterns/lua40.hexpat) | Lua 4.0 bytecode |
|
||||
| LUC | | [`patterns/popcap_luc.hexpat`](patterns/popcap_luc.hexpat) | PopCap's proprietary Lua bytecode |
|
||||
| Lua 5.0 | | [`patterns/lua50.hexpat`](patterns/lua50.hexpat) | Lua 5.0 bytecode |
|
||||
| Lua 5.1 | | [`patterns/lua51.hexpat`](patterns/lua51.hexpat) | Lua 5.1 bytecode |
|
||||
| Lua 5.2 | | [`patterns/lua52.hexpat`](patterns/lua52.hexpat) | Lua 5.2 bytecode |
|
||||
| Lua 5.3 | | [`patterns/lua53.hexpat`](patterns/lua53.hexpat) | Lua 5.3 bytecode |
|
||||
| Lua 5.4 | | [`patterns/lua54.hexpat`](patterns/lua54.hexpat) | Lua 5.4 bytecode |
|
||||
| LCE Savefile | | [`patterns/lcesave.hexpat`](patterns/lcesave.hexpat) | Minecraft Legacy Console Edition save file |
|
||||
| LZNT1 | | [`patterns/lznt1.hexpat`](patterns/lznt1.hexpat) | LZNT1 compressed data format |
|
||||
| Mach-O | `application/x-mach-binary` | [`patterns/macho.hexpat`](patterns/macho.hexpat) | Mach-O executable |
|
||||
| MIDI | `audio/midi` | [`patterns/midi.hexpat`](patterns/midi.hexpat) | MIDI header, event fields provided |
|
||||
| MiniDump | `application/x-dmp` | [`patterns/minidump.hexpat`](patterns/minidump.hexpat) | Windows MiniDump files |
|
||||
| MO | | [`patterns/mo.hexpat`](patterns/mo.hexpat) | GNU Machine Object (MO) files containing translations for gettext |
|
||||
| mp4 | `video/mp4` | [`patterns/mp4.hexpat`](patterns/mp4.hexpat) | MPEG-4 Part 14 digital multimedia container format |
|
||||
| msgpack | `application/x-msgpack` | [`patterns/msgpack.hexpat`](patterns/msgpack.hexpat) | MessagePack binary serialization format |
|
||||
| MSSCMP | | [`patterns/msscmp.hexpat`](patterns/msscmp.hexpat) | Miles Sound System Compressed Archive |
|
||||
| NACP | | [`patterns/nacp.hexpat`](patterns/nacp.hexpat) | Nintendo Switch NACP files |
|
||||
| NBT | | [`patterns/nbt.hexpat`](patterns/nbt.hexpat) | Minecraft NBT format |
|
||||
| N64 | | [`patterns/n64.hexpat`](patterns/n64.hexpat) | Nintendo 64 ROM header |
|
||||
| NDS | `application/x-nintendo-ds-rom` | [`patterns/nds.hexpat`](patterns/nds.hexpat) | DS Cartridge Header |
|
||||
| NE | `application/x-ms-ne-executable` | [`patterns/ne.hexpat`](patterns/ne.hexpat) | NE header and Standard NE fields |
|
||||
| nes | | [`patterns/nes.hexpat`](patterns/nes.hexpat) | Nintendo Entertainment System ROM |
|
||||
| NSF | | [`patterns/nsf.hexpat`](patterns/nsf.hexpat) | NES Sound Format |
|
||||
| NSFe | | [`patterns/nsfe.hexpat`](patterns/nsfe.hexpat) | NES Sound Format extended |
|
||||
| NotepadCache | | [`patterns/notepad-cache.hexpat`](patterns/notepad-cache.hexpat) | Windows Notepad Cache |
|
||||
| NotepadStateFile | | [`patterns/notepad-state.hexpat`](patterns/notepad-state.hexpat) | Windows Notepad .bin State files |
|
||||
| NotepadWindowState | | [`patterns/notepadwindowstate.hexpat`](patterns/notepadwindowstate.hexpat) | Windows 11 Notepad - Window State .bin file |
|
||||
| NRO | | [`patterns/nro.hexpat`](patterns/nro.hexpat) | Nintendo Switch NRO files |
|
||||
| NTAG | | [`patterns/ntag.hexpat`](patterns/ntag.hexpat) | NTAG213/NTAG215/NTAG216, NFC Forum Type 2 Tag compliant IC |
|
||||
| NTFS | | [`patterns/fs/ntfs.hexpat`](patterns/fs/ntfs.hexpat) | NTFS (NT File System) |
|
||||
| NTFS (DFIR) | | [`patterns/DFIR/NTFS.hexpat`](patterns/DFIR/NTFS.hexpat) | Imported by DISK_PARSER.hexpat |
|
||||
| OGG | `audio/ogg` | [`patterns/ogg.hexpat`](patterns/ogg.hexpat) | OGG Audio format |
|
||||
| ORP / ORS | | [`patterns/orp.hexpat`](patterns/orp.hexpat) | OpenRGB profile format |
|
||||
| PACK | | [`patterns/roblox_pack.hexpat`](patterns/roblox_pack.hexpat) | Roblox shader archive format |
|
||||
| PAK | | [`patterns/xgspak.hexpat`](patterns/xgspak.hexpat) | Exient XGS Engine Pak files |
|
||||
| PCAP | `application/vnd.tcpdump.pcap` | [`patterns/pcap.hexpat`](patterns/pcap.hexpat) | pcap header and packets |
|
||||
| PcapNG | `application/vnd.tcpdump.pcap` | [`patterns/pcapng.hexpat`](patterns/pcapng.hexpat) | pcapng header and packets |
|
||||
| PCK | | [`patterns/pck.hexpat`](patterns/pck.hexpat) | Minecraft Legacy Console Edition .pck file |
|
||||
| PCX | `application/x-pcx` | [`patterns/pcx.hexpat`](patterns/pcx.hexpat) | PCX Image format |
|
||||
| PE | `application/x-dosexec` `application/x-msdownload` | [`patterns/pe.hexpat`](patterns/pe.hexpat) | PE header, COFF header, Standard COFF fields and Windows Specific fields |
|
||||
| PEF | | [`patterns/pef.hexpat`](patterns/pef.hexpat) | Preffered Executable Format executable (for Mac OS 7.1.2 - Mac OS 10.4 / BeOS) |
|
||||
| PEX | | [`patterns/pex.hexpat`](patterns/pex.hexpat) | Bethesda Papyrus executable compiled script file |
|
||||
| PP | | [`patterns/selinuxpp.hexpat`](patterns/selinuxpp.pat) | SE Linux package |
|
||||
| PFS0 | | [`patterns/pfs0.hexpat`](patterns/pfs0.hexpat) | Nintendo Switch PFS0 archive (NSP files) |
|
||||
| PF | | [`patterns/pf.hexpat`](patterns/pf.hexpat) | Microsoft uncompressed prefetch files (.pf) |
|
||||
| Pickle | | [`patterns/pickle.hexpat`](patterns/pickle.hexpat) | Python Pickle Protocol |
|
||||
| PIF | `image/pif` | [`patterns/pif.hexpat`](patterns/pif.hexpat) | PIF Image Format |
|
||||
| PKM | | [`patterns/pkm.hexpat`](patterns/pkm.hexpat) | PKM texture format |
|
||||
| PNG | `image/png` | [`patterns/png.hexpat`](patterns/png.hexpat) | PNG image files |
|
||||
| PRODINFO | | [`patterns/prodinfo.hexpat`](patterns/prodinfo.hexpat) | Nintendo Switch PRODINFO |
|
||||
| Protobuf | | [`patterns/protobuf.hexpat`](patterns/protobuf.hexpat) | Google Protobuf encoding |
|
||||
| psafe3 | | [`patterns/psafe3.hexpat`](patterns/psafe3.hexpat`) | Password Safe V3 |
|
||||
| PyInstaller | | [`patterns/pyinstaller.hexpat`](patterns/pyinstaller.hexpat) | PyInstaller binray files |
|
||||
| PYC | `application/x-bytecode.python` | [`patterns/pyc.hexpat`](patterns/pyc.hexpat) | Python bytecode files |
|
||||
| QBCL | | [`patterns/qbcl.hexpat`](patterns/qbcl.hexpat) | Qubicle voxel scene project file |
|
||||
| QOI | `image/qoi` | [`patterns/qoi.hexpat`](patterns/qoi.hexpat) | QOI image files |
|
||||
| Quake 3 engine demo | | [`patterns/q3demo.hexpat`](patterns/q3demo.hexpat) | Demos/replays of most Quake 3 engine games |
|
||||
| quantized-mesh | | [`patterns/quantized-mesh.hexpat`](patterns/quantized-mesh.hexpat) | Cesium quantized-mesh terrain |
|
||||
| RAR | `application/x-rar` | [`patterns/rar.hexpat`](patterns/rar.hexpat) | RAR archive file format |
|
||||
| RAS | `image/x-sun-raster` | [`patterns/ras.hexpat`](patterns/ras.hexpat) | RAS image files |
|
||||
| RCF 1.2 | | [`patterns/rcf_v1_2.hexpat`](patterns/rcf_v1_2.hexpat) | Radcore Cement Library 1.2 file header |
|
||||
| ReFS | | [`patterns/refs.hexpat`](patterns/fs/refs.hexpat) | Microsoft Resilient File System |
|
||||
| RGBDS | | [`patterns/rgbds.hexpat`](patterns/rgbds.hexpat) | [RGBDS](https://rgbds.gbdev.io) object file format |
|
||||
| RPM | | [`patterns/rpm.hexpat`](patterns/rpm.hexpat) | [RPM](http://ftp.rpm.org/max-rpm/s1-rpm-file-format-rpm-file-format.html) package file format |
|
||||
| SDB | | [`patterns/sdb.hexpat`](patterns/sdb.hexpat) | [Shim DataBase](https://learn.microsoft.com/en-us/windows/win32/devnotes/application-compatibility-database) file format |
|
||||
| Shell Link | `application/x-ms-shortcut` | [`patterns/lnk.hexpat`](patterns/lnk.hexpat) | Windows Shell Link file format |
|
||||
| shp | | [`patterns/shp.hexpat`](patterns/shp.hexpat) | ESRI shape file |
|
||||
| SHR | | [`patterns/SHR.hexpat`](patterns/SHR.hexpat) | Apple IIgs Super Hi-Res (SHR) + PaintWorks Animation (ANI) |
|
||||
| shx | | [`patterns/shx.hexpat`](patterns/shx.hexpat) | ESRI index file |
|
||||
| smk | | [`patterns/smk.hexpat`](patterns/smk.hexpat) | Smacker video file |
|
||||
| SNES | | [`patterns/snes.hexpat`](patterns/snes.hexpat) | Super Nintendo Entertainment System ROM header |
|
||||
| sup | | [`patterns/sup.hexpat`](patterns/sup.hexpat) | PGS Subtitle |
|
||||
| SPC | | [`patterns/spc.hexpat`](patterns/spc.hexpat) | Super Nintendo Entertainment System SPC-700 dump file |
|
||||
| SPIRV | | [`patterns/spirv.hexpat`](patterns/spirv.hexpat) | SPIR-V header and instructions |
|
||||
| STDF | | [`patterns/stdfv4.hexpat`](patterns/stdfv4.hexpat) | Standard test data format for IC testers |
|
||||
| STL | `model/stl` | [`patterns/stl.hexpat`](patterns/stl.hexpat) | STL 3D Model format |
|
||||
| StuffItV5 | `application/x-stuffit` | [`patterns/sit5.hexpat`](patterns/sit5.hexpat) | StuffIt V5 archive |
|
||||
| SQLite3 | `application/vnd.sqlite3` | [`patterns/sqlite3.hexpat`](patterns/sqlite3.hexpat) | SQLite3 Database |
|
||||
| SWF | `application/x-shockwave-flash` |[`patterns/swf.hexpat`](patterns/swf.hexpat) | Shockwave Flash file format |
|
||||
| TA | | [`patterns/optee_ta.hexpat`](patterns/optee_ta.hexpat) | OPTEE Trusted Application Executable |
|
||||
| TAR | `application/x-tar` | [`patterns/tar.hexpat`](patterns/tar.hexpat) | Tar file format |
|
||||
| TARC | | [`patterns/tarc.hexpat`](patterns/tarc.hexpat) | KEX Engine TARC file format |
|
||||
| TES | | [`patterns/wintec_tes.hexpat`](patterns/wintec_tes.hexpat) | Wintec TES GPS log |
|
||||
| Thumbcache | | [`patterns/thumbcache.hexpat`](patterns/thumbcache.hexpat) | Windows thumbcache_*.db |
|
||||
| TIFF | `image/tiff` | [`patterns/tiff.hexpat`](patterns/tiff.hexpat) | Tag Image File Format |
|
||||
| TGA | `image/tga` | [`patterns/tga.hexpat`](patterns/tga.hexpat) | Truevision TGA/TARGA image |
|
||||
| TTF | `font/ttf`, `font/otf` | [`patterns/ttf.hexpat`](patterns/ttf.hexpat) | TrueType and OpenType font format |
|
||||
| Ubiquiti | | [`patterns/ubiquiti.hexpat`](patterns/ubiquiti.hexpat) | Ubiquiti Firmware (update) image |
|
||||
| UPK | | [`patterns/upk-ue3.hexpat`](patterns/upk-ue3.hexpat) | Unreal Engine 3 UPK file |
|
||||
| UEFI | | [`patterns/uefi.hexpat`](patterns/uefi.hexpat)` | UEFI structs for parsing efivars |
|
||||
| UEFI Boot Entry | | [`patterns/uefi_boot_entry.hexpat`](patterns/uefi_boot_entry.hexpat) | UEFI Boot Entry (Load option) |
|
||||
| UEFI Variable Store | | [`patterns/uefi_fv_varstore.hexpat`](patterns/uefi_fv_varstore.hexpat) | UEFI Firmware Volume Variable Store |
|
||||
| UF2 | | [`patterns/uf2.hexpat`](patterns/uf2.hexpat) | [USB Flashing Format](https://github.com/microsoft/uf2) |
|
||||
| Unity Asset Bundle | | [`patterns/unity-asset-bundle.hexpat`](patterns/unity-asset-bundle.hexpat) | Unity Asset Bundle |
|
||||
| Valve VPK | | [`patterns/valve_vpk.hexpat`](valve_vpk.hexpat) | Valve Package File |
|
||||
| VBMeta | | [`patterns/vbmeta.hexpat`](patterns/vbmeta.hexpat) | Android VBMeta image |
|
||||
| VDF | | [`patterns/vdf.hexpat`](patterns/vdf.hexpat) | Binary Value Data Format (.vdf) files |
|
||||
| VEADO | | [`patterns/veado.hexpat`](patterns/veado.hexpat) | veadotube mini avatar file |
|
||||
| VGM | | [`patterns/vgm.hexpat`](patterns/vgm.hexpat) | VGM (Video Game Music) sound log |
|
||||
| VHDX | | [`patterns/vhdx.hexpat`](patterns/vhdx.hexpat) | Microsoft Hyper-V Virtual Hard Disk format |
|
||||
| VOX | | [`patterns/vox.hexpat`](patterns/vox.hexpat) | MagicaVoxel scene description format |
|
||||
| WAV | `audio/x-wav` | [`patterns/wav.hexpat`](patterns/wav.hexpat) | RIFF header, WAVE header, PCM header |
|
||||
| WAS | | [`patterns/was_oskasoftware.hexpat`](patterns/was_oskasoftware.hexpat) | Oska Software DeskMates WAS/WA3 (WAVE/MP3 Set) file
|
||||
| WAD | | [`patterns/wad.hexpat`](patterns/wad.hexpat) | DOOM WAD Archive |
|
||||
| WebP | `image/webp` | [`patterns/webp.hexpat`](patterns/webp.hexpat) | Google WebP image |
|
||||
| XBEH | `audio/x-xbox-executable` | [`patterns/xbeh.hexpat`](patterns/xbeh.hexpat) | Xbox executable |
|
||||
| XCI | | [`patterns/xci.hexpat`](patterns/xci.hexpat) | Nintendo Switch XCI cartridge ROM |
|
||||
| XGT | | [`patterns/xgt.hexpat`](patterns/xgstexture.hexpat) | Exient XGS Engine Texture |
|
||||
| Xilinx BIT | | [`patterns/xilinx_bit.hexpat`](patterns/xilinx_bit.hexpat) | Xilinx FPGA Bitstreams |
|
||||
| Xilinx Bootgen | `application/x-xilinx-boot-zynqmp` | [`patterns/xilinx_bootgen.hexpat`](patterns/xilinx_bootgen.hexpat) | Xilinx ZynqMP Boot Images |
|
||||
| ZIM | | [`patterns/zim.hexpat`](patterns/zim.hexpat) | [ZIM](https://openzim.org) file format |
|
||||
| ZIP | `application/zip` | [`patterns/zip.hexpat`](patterns/zip.hexpat) | End of Central Directory Header, Central Directory File Headers |
|
||||
| ZLIB | `application/zlib` | [`patterns/zlib.hexpat`](patterns/zlib.hexpat) | ZLIB compressed data format |
|
||||
| ZSTD | `application/zstd` | [`patterns/zstd.hexpat`](patterns/zstd.hexpat) | Zstandard compressed data format |
|
||||
| MOD | `3d-model/mod` | [`patterns/DMC3HD-Mod.hexpat`](patterns/dmc3_hd_mod.hexpat) | 3D Model files used in Devil May Cry 3 HD Collection |
|
||||
| CBM BASIC | | [`commodore_basic.hexpat`](patterns/commodore_basic.hexpat) | Commodore BASIC |
|
||||
| Atari XEX | | [`xex.hexpat`](patterns/xex.hexpat) | Atari 8-bit binary format |
|
||||
| Terminfo | `application/x-terminfo` and `application/x-terminfo2` | [`patterns/terminfo.hexpat`](patterns/terminfo.hexpat) | Compiled *(legacy and extended)* term info entry |
|
||||
|
||||
|
||||
|
||||
### Scripts
|
||||
|
||||
| Name | Path | Description |
|
||||
|------|------|-------------|
|
||||
| svd2pat | `scripts/svd2pat.py` | Converts a ARM .svd register MMIO definition file into a pattern |
|
||||
| csv2tbl | `scripts/csv2tbl.py` | Converts a 010 editor CSV encoding file into a table file |
|
||||
| svd2pat | [`scripts/svd2pat.py`](scripts/svd2pat.py) | Converts a ARM .svd register MMIO definition file into a pattern |
|
||||
| csv2tbl | [`scripts/csv2tbl.py`](scripts/csv2tbl.py) | Converts a 010 editor CSV encoding file into a table file |
|
||||
|
||||
### Pattern Libraries
|
||||
|
||||
| Name | Path | Description |
|
||||
|------|------|-------------|
|
||||
| libstd | `includes/std/*` | Pattern Language Standard Libaray |
|
||||
| libtype | `includes/type/*` | Various custom types with special formatters |
|
||||
| libhex | `includes/hex/*` | Functions to interact with ImHex |
|
||||
| libhex | [`includes/hex/*`](includes/hex) | Functions to interact with ImHex |
|
||||
| libstd | [`includes/std/*`](includes/std) | Pattern Language Standard Library |
|
||||
| libtype | [`includes/type/*`](includes/type) | Various custom types with special formatters |
|
||||
|
||||
### Yara rules
|
||||
|
||||
| Name | Path | Description |
|
||||
|------|------|-------------|
|
||||
| Official Rules | `yara/official_rules/*` | Official Yara rules repository |
|
||||
| Official Rules | [`yara/official_rules/*`](yara/official_rules) | Official Yara rules repository |
|
||||
|
||||
### Magic files
|
||||
|
||||
| Name | Path | Description |
|
||||
|------|------|-------------|
|
||||
| Nintendo Switch | `magic/nintendo_switch_magic` | Identifies common file types used on the Nintendo Switch |
|
||||
| Portable Executable | `magic/portable_executable_magic` | Identifies PE files used on Windows
|
||||
| Arma 3 | [`magic/arma3_magic`](magic/arma3_magic) | Identifies Arma 3 binary formats |
|
||||
| Nintendo Switch | [`magic/nintendo_switch_magic`](magic/nintendo_switch_magic) | Identifies common file types used on the Nintendo Switch |
|
||||
| Portable Executable | [`magic/portable_executable_magic`](magic/portable_executable_magic) | Identifies PE files used on Windows
|
||||
|
||||
### Constants files
|
||||
|
||||
| Name | Path | Description |
|
||||
|------|------|-------------|
|
||||
| CRC-16 | `constants/crc16.json` | Constants associated with CRC-16 operations |
|
||||
| CRC-32 | `constants/crc32.json` | Constants associated with CRC-32 operations |
|
||||
| HTTP-Codes | `constants/http_status.json` | HTTP Status code values |
|
||||
| Linux Error Codes | `constants/linux_errors.json` | Values of Linux error results |
|
||||
| CRC-16 | [`constants/crc16.json`](constants/crc16.json) | Constants associated with CRC-16 operations |
|
||||
| CRC-32 | [`constants/crc32.json`](constants/crc32.json) | Constants associated with CRC-32 operations |
|
||||
| HTTP-Codes | [`constants/http_status.json`](constants/http_status.json) | HTTP Status code values |
|
||||
| Linux Error Codes | [`constants/linux_errors.json`](constants/linux_errors.json) | Values of Linux error results |
|
||||
|
||||
### Encoding files
|
||||
|
||||
| Name | Path | Description |
|
||||
|------|------|-------------|
|
||||
| Arabic ISO | `encodings/arabic_iso.tbl` | Arabic ISO encoding |
|
||||
| Arabic Windows | `encodings/arabic_windows.tbl` | Arabic Windows encoding |
|
||||
| ASCII | `encodings/ascii.tbl` | Regular ASCII encoding |
|
||||
| ASCII+ANSI | `encodings/ascii_ansi.tbl` | Extended ASCII encoding |
|
||||
| ASCII+OEM | `encodings/ascii_oem.tbl` | ASCII encoding with Windows OEM characters |
|
||||
| Baltic ISO | `encodings/baltic_iso.tbl` | Baltic ISO encoding |
|
||||
| Baltic Windows | `encodings/baltic_windows.tbl` | Baltic Windows encoding |
|
||||
| Cyrillic ISO | `encodings/cyrillic_iso.tbl` | Cyrillic ISO encoding |
|
||||
| Cyrillic Windows | `encodings/cyrillic_windows.tbl` | Cyrillic Windows encoding |
|
||||
| Cyrillic KOI8-R | `encodings/cyrillic_koi8_r.tbl` | Cyrillic KOI8-R encoding (Russian Characters) |
|
||||
| Cyrillic KOI8-U | `encodings/cyrillic_koi8_u.tbl` | Cyrillic KOI8-U encoding (Ukranian Characters) |
|
||||
| Eastern Europe ISO | `encodings/eastern_europe_iso.tbl` | Eastern Europe ISO encoding |
|
||||
| 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 |
|
||||
| Hebrew Windows | `encodings/hebrew_windows.tbl` | Hebrew Windows encoding |
|
||||
| ISO/IEC 646 | `encodings/iso_646.tbl` | ISO/IEC 646 encoding, an older version of ASCII |
|
||||
| ISO/IEC 6937 | `encodings/iso_6937.tbl` | ISO/IEC 6937 encoding, an extension of ASCII containing additional character |
|
||||
| JIS 0201 | `encodings/jis_x_0201.tbl` | JIS X 0201 encoding in UTF-8 |
|
||||
| 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 |
|
||||
| Turkish Windows | `encodings/turkish_windows.tbl` | Turkish Windows encoding |
|
||||
| UTF-8 | `encodings/utf8.tbl` | UTF-8 encoding |
|
||||
| Vietnamese | `encodings/vietnamese.tbl` | Vietnamese character encoding |
|
||||
| Arabic ISO | [`encodings/arabic_iso.tbl`](encodings/arabic_iso.tbl) | Arabic ISO encoding |
|
||||
| Arabic Windows | [`encodings/arabic_windows.tbl`](encodings/arabic_windows.tbl) | Arabic Windows encoding |
|
||||
| ASCII | [`encodings/ascii.tbl`](encodings/ascii.tbl) | Regular ASCII encoding |
|
||||
| ASCII+ANSI | [`encodings/ascii_ansi.tbl`](encodings/ascii_ansi.tbl) | Extended ASCII encoding |
|
||||
| ASCII+OEM | [`encodings/ascii_oem.tbl`](encodings/ascii_oem.tbl) | ASCII encoding with Windows OEM characters |
|
||||
| Baltic ISO | [`encodings/baltic_iso.tbl`](encodings/baltic_iso.tbl) | Baltic ISO encoding |
|
||||
| Baltic Windows | [`encodings/baltic_windows.tbl`](encodings/baltic_windows.tbl) | Baltic Windows encoding |
|
||||
| Big5 (Traditional Chinese) | [`encodings/big5.tbl`](encodings/big5.tbl) | Big5 encoding for Traditional Chinese |
|
||||
| Cyrillic ISO | [`encodings/cyrillic_iso.tbl`](encodings/cyrillic_iso.tbl) | Cyrillic ISO encoding |
|
||||
| Cyrillic Windows | [`encodings/cyrillic_windows.tbl`](encodings/cyrillic_windows.tbl) | Cyrillic Windows encoding |
|
||||
| Cyrillic KOI8-R | [`encodings/cyrillic_koi8_r.tbl`](encodings/cyrillic_koi8_r.tbl) | Cyrillic KOI8-R encoding (Russian Characters) |
|
||||
| Cyrillic KOI8-U | [`encodings/cyrillic_koi8_u.tbl`](encodings/cyrillic_koi8_u.tbl) | Cyrillic KOI8-U encoding (Ukranian Characters) |
|
||||
| Eastern Europe ISO | [`encodings/eastern_europe_iso.tbl`](encodings/eastern_europe_iso.tbl) | Eastern Europe ISO encoding |
|
||||
| Eastern Europe Windows | [`encodings/eastern_europe_windows.tbl`](encodings/eastern_europe_windows.tbl) | Eastern Europe Windows encoding |
|
||||
| EBCDIC | [`encodings/ebcdic.tbl`](encodings/ebcdic.tbl) | Extended Binary Coded Decimal Interchange Code, developed by IBM for their Main Frames |
|
||||
| EUC-JP | [`encodings/euc_jp.tbl`](encodings/euc_jp.tbl) | EUC-JP encoding with NEC special and IBM extended characters |
|
||||
| EUC-KR | [`encodings/euc_kr.tbl`](encodings/euc_kr.tbl) | EUC-KR encoding |
|
||||
| Greek ISO | [`encodings/greek_iso.tbl`](encodings/greek_iso.tbl) | Greek ISO encoding |
|
||||
| Greek Windows | [`encodings/greek_windows.tbl`](encodings/greek_windows.tbl) | Greek Windows encoding |
|
||||
| Hebrew ISO | [`encodings/hebrew_iso.tbl`](encodings/hebrew_iso.tbl) | Hebrew ISO encoding |
|
||||
| Hebrew Windows | [`encodings/hebrew_windows.tbl`](encodings/hebrew_windows.tbl) | Hebrew Windows encoding |
|
||||
| ISO/IEC 646 | [`encodings/iso_646.tbl`](encodings/iso_646.tbl) | ISO/IEC 646 encoding, an older version of ASCII |
|
||||
| ISO/IEC 6937 | [`encodings/iso_6937.tbl`](encodings/iso_6937.tbl) | ISO/IEC 6937 encoding, an extension of ASCII containing additional character |
|
||||
| JIS 0201 | [`encodings/jis_x_0201.tbl`](encodings/jis_x_0201.tbl) | JIS X 0201 encoding in UTF-8 |
|
||||
| JIS X 0211 | [`encodings/jis_x_0211.tbl`](encodings/jis_x_0211.tbl) | JIS X 0211 encoding in UTF-8 |
|
||||
| JIS 0213 | [`encodings/jis_x_0213.tbl`](encodings/jis_x_0213.tbl) | JIS X 0213 encoding in UTF-8 |
|
||||
| Macintosh | [`encodings/macintosh.tbl`](encodings/macintosh.tbl) | Macintosh character encoding used by the Kermit protocol |
|
||||
| Pokémon (English, Generation 1) | [`encodings/pokegen1_en.tbl`](encodings/pokegen1_en.tbl) | Character encoding used by the English generation 1 Pokémon games |
|
||||
| Pokémon (English, Generation 3) | [`encodings/pokegen3_en.tbl`](encodings/pokegen3_en.tbl) | Character encoding used by the English generation 3 Pokémon games |
|
||||
| Shift-JIS UTF-8 | [`encodings/shiftjis.tbl`](encodings/shiftjis.tbl) | Shift-JIS encoding in UTF-8 |
|
||||
| Thai | [`encodings/thai.tbl`](encodings/thai.tbl) | Thai character encoding |
|
||||
| Turkish ISO | [`encodings/turkish_iso.tbl`](encodings/turkish_iso.tbl) | Turkish ISO encoding |
|
||||
| Turkish Windows | [`encodings/turkish_windows.tbl`](encodings/turkish_windows.tbl) | Turkish Windows encoding |
|
||||
| UTF-8 | [`encodings/utf8.tbl`](encodings/utf8.tbl) | UTF-8 encoding |
|
||||
| Vietnamese | [`encodings/vietnamese.tbl`](encodings/vietnamese.tbl) | Vietnamese character encoding |
|
||||
|
||||
## Contributing
|
||||
### Data Processor Nodes
|
||||
|
||||
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.
|
||||
To take advantage of the automatic pattern testing, please consider adding a test file named `<pattern_name>.hexpat.<extension>` to the `/tests/patterns/test_data` directory. Try to keep this file as small as possible so the repository doesn't become excessively large
|
||||
| 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 |
|
||||
|
||||
Thanks a lot :)
|
||||
### Themes
|
||||
|
||||
| Name | Path | Description |
|
||||
|------|------|-------------|
|
||||
| Visual Studio Dark | [`themes/vs_dark.json`](themes/vs_dark.json) | Theme similar to Visual Studio's Dark theme |
|
||||
| Solarized Dark | [`themes/solarized_dark.json`](themes/solarized_dark.json) | Solarized Dark Theme |
|
||||
| Catppuccin Latte | [`themes/catppuccin-latte.json`](themes/catppuccin-latte.json) | Catppuccin Latte Flavor (Light Theme) |
|
||||
| Catppuccin Frappe | [`themes/catppuccin-frappe.json`](themes/catppuccin-frappe.json) | Catppuccin Frappe Flavor (Dark Theme) |
|
||||
| Catppuccin Macchiato | [`themes/catppuccin-macchiato.json`](themes/catppuccin-macchiato.json) | Catppuccin Macchiato Flavor (Dark Theme) |
|
||||
| Catppuccin Mocha | [`themes/catppuccin-mocha.json`](themes/catppuccin-mocha.json) | Catppuccin Mocha Flavor (Dark Theme) |
|
||||
| Theme Lion | [`themes/theme_lion.json`](themes/theme_lion.json) | Semantic CLion inspired theme (Dark Theme) |
|
||||
| Retina Dark | [`themes/retina_dark.json`](themes/retina_dark.json) | Semantic theme based on Dark Theme |
|
||||
|
||||
### Disassemblers
|
||||
|
||||
| Name | Path | Description |
|
||||
|------|------|-------------|
|
||||
| 8051 | [`disassemblers/8051.json`](disassemblers/8051.json) | Intel 8051 Architecture |
|
||||
|
||||
@@ -29,23 +29,10 @@
|
||||
"title": "Items",
|
||||
"type": "object",
|
||||
"required": [
|
||||
"type",
|
||||
"value",
|
||||
"name"
|
||||
],
|
||||
"properties": {
|
||||
"type": {
|
||||
"$id": "#root/values/items/type",
|
||||
"title": "Type",
|
||||
"type": "string",
|
||||
"default": "",
|
||||
"examples": [
|
||||
"int16be",
|
||||
"int16le",
|
||||
"int10"
|
||||
],
|
||||
"pattern": "^(int10|int16le|int16be)$"
|
||||
},
|
||||
"value": {
|
||||
"$id": "#root/values/items/value",
|
||||
"title": "Value",
|
||||
@@ -54,7 +41,7 @@
|
||||
"examples": [
|
||||
"ACDC"
|
||||
],
|
||||
"pattern": "^([0-9a-fA-F]+)$"
|
||||
"pattern": "^.*$"
|
||||
},
|
||||
"name": {
|
||||
"$id": "#root/values/items/name",
|
||||
|
||||
@@ -2,118 +2,95 @@
|
||||
"name": "CRC16 Constants",
|
||||
"values": [
|
||||
{
|
||||
"type": "int16be",
|
||||
"value": "1021",
|
||||
"value": "10 21",
|
||||
"name": "CRC-16/CCITT-FALSE Polynomial"
|
||||
},
|
||||
{
|
||||
"type": "int16be",
|
||||
"value": "8005",
|
||||
"value": "80 05",
|
||||
"name": "CRC-16/ARC Polynomial"
|
||||
},
|
||||
{
|
||||
"type": "int16be",
|
||||
"value": "1021",
|
||||
"value": "10 21",
|
||||
"name": "CRC-16/AUG-CCITT Polynomial"
|
||||
},
|
||||
{
|
||||
"type": "int16be",
|
||||
"value": "8005",
|
||||
"value": "80 05",
|
||||
"name": "CRC-16/BUYPASS Polynomial"
|
||||
},
|
||||
{
|
||||
"type": "int16be",
|
||||
"value": "C867",
|
||||
"value": "C8 67",
|
||||
"name": "CRC-16/CDMA2000 Polynomial"
|
||||
},
|
||||
{
|
||||
"type": "int16be",
|
||||
"value": "8005",
|
||||
"value": "80 05",
|
||||
"name": "CRC-16/DDS-110 Polynomial"
|
||||
},
|
||||
{
|
||||
"type": "int16be",
|
||||
"value": "0589",
|
||||
"value": "05 89",
|
||||
"name": "CRC-16/DECT-R Polynomial"
|
||||
},
|
||||
{
|
||||
"type": "int16be",
|
||||
"value": "0589",
|
||||
"value": "05 89",
|
||||
"name": "CRC-16/DECT-X Polynomial"
|
||||
},
|
||||
{
|
||||
"type": "int16be",
|
||||
"value": "3D65",
|
||||
"value": "3D 65",
|
||||
"name": "CRC-16/DNP Polynomial"
|
||||
},
|
||||
{
|
||||
"type": "int16be",
|
||||
"value": "3D65",
|
||||
"value": "3D 65",
|
||||
"name": "CRC-16/EN-13757 Polynomial"
|
||||
},
|
||||
{
|
||||
"type": "int16be",
|
||||
"value": "1021",
|
||||
"value": "10 21",
|
||||
"name": "CRC-16/GENIBUS Polynomial"
|
||||
},
|
||||
{
|
||||
"type": "int16be",
|
||||
"value": "8005",
|
||||
"value": "80 05",
|
||||
"name": "CRC-16/MAXIM Polynomial"
|
||||
},
|
||||
{
|
||||
"type": "int16be",
|
||||
"value": "1021",
|
||||
"value": "10 21",
|
||||
"name": "CRC-16/MCRF4XX Polynomial"
|
||||
},
|
||||
{
|
||||
"type": "int16be",
|
||||
"value": "1021",
|
||||
"value": "10 21",
|
||||
"name": "CRC-16/RIELLO Polynomial"
|
||||
},
|
||||
{
|
||||
"type": "int16be",
|
||||
"value": "8BB7",
|
||||
"value": "8B B7",
|
||||
"name": "CRC-16/T10-DIF Polynomial"
|
||||
},
|
||||
{
|
||||
"type": "int16be",
|
||||
"value": "A097",
|
||||
"value": "A0 97",
|
||||
"name": "CRC-16/TELEDISK Polynomial"
|
||||
},
|
||||
{
|
||||
"type": "int16be",
|
||||
"value": "1021",
|
||||
"value": "10 21",
|
||||
"name": "CRC-16/TMS37157 Polynomial"
|
||||
},
|
||||
{
|
||||
"type": "int16be",
|
||||
"value": "8005",
|
||||
"value": "80 05",
|
||||
"name": "CRC-16/USB Polynomial"
|
||||
},
|
||||
{
|
||||
"type": "int16be",
|
||||
"value": "1021",
|
||||
"value": "10 21",
|
||||
"name": "CRC-A Polynomial"
|
||||
},
|
||||
{
|
||||
"type": "int16be",
|
||||
"value": "1021",
|
||||
"value": "10 21",
|
||||
"name": "CRC-16/KERMIT Polynomial"
|
||||
},
|
||||
{
|
||||
"type": "int16be",
|
||||
"value": "8005",
|
||||
"value": "80 05",
|
||||
"name": "CRC-16/MODBUS Polynomial"
|
||||
},
|
||||
{
|
||||
"type": "int16be",
|
||||
"value": "1021",
|
||||
"value": "10 21",
|
||||
"name": "CRC-16/X-25 Polynomial"
|
||||
},
|
||||
{
|
||||
"type": "int16be",
|
||||
"value": "1021",
|
||||
"value": "10 21",
|
||||
"name": "CRC-16/XMODEM Polynomial"
|
||||
}
|
||||
]
|
||||
|
||||
@@ -2,48 +2,39 @@
|
||||
"name": "CRC32 Constants",
|
||||
"values": [
|
||||
{
|
||||
"type": "int16be",
|
||||
"value": "04C11DB7",
|
||||
"value": "04 C1 1D B7",
|
||||
"name": "CRC-32 Polynomial"
|
||||
},
|
||||
{
|
||||
"type": "int16be",
|
||||
"value": "04C11DB7",
|
||||
"value": "04 C1 1D B7",
|
||||
"name": "CRC-32/BZIP2 Polynomial"
|
||||
},
|
||||
{
|
||||
"type": "int16be",
|
||||
"value": "1EDC6F41",
|
||||
"value": "1E DC 6F 41",
|
||||
"name": "CRC-32C Polynomial"
|
||||
},
|
||||
{
|
||||
"type": "int16be",
|
||||
"value": "A833982B",
|
||||
"value": "A8 33 98 2B",
|
||||
"name": "CRC-32D Polynomial"
|
||||
},
|
||||
{
|
||||
"type": "int16be",
|
||||
"value": "04C11DB7",
|
||||
"value": "04 C1 1D B7",
|
||||
"name": "CRC-32/MPEG-2 Polynomial"
|
||||
},
|
||||
{
|
||||
"type": "int16be",
|
||||
"value": "04C11DB7",
|
||||
"value": "04 C1 1D B7",
|
||||
"name": "CRC-32/POSIX Polynomial"
|
||||
},
|
||||
{
|
||||
"type": "int16be",
|
||||
"value": "814141AB",
|
||||
"value": "81 41 41 AB",
|
||||
"name": "CRC-32Q Polynomial"
|
||||
},
|
||||
{
|
||||
"type": "int16be",
|
||||
"value": "04C11DB7",
|
||||
"value": "04 C1 1D B7",
|
||||
"name": "CRC-32/JAMCRC Polynomial"
|
||||
},
|
||||
{
|
||||
"type": "int16be",
|
||||
"value": "000000AF",
|
||||
"value": "00 00 00 AF",
|
||||
"name": "CRC-32/XFER Polynomial"
|
||||
}
|
||||
]
|
||||
|
||||
@@ -1,315 +0,0 @@
|
||||
{
|
||||
"name": "HTTP Status Codes",
|
||||
"values": [
|
||||
{
|
||||
"type": "int10",
|
||||
"value": "100",
|
||||
"name": "Continue"
|
||||
},
|
||||
{
|
||||
"type": "int10",
|
||||
"value": "101",
|
||||
"name": "Switching Protocols"
|
||||
},
|
||||
{
|
||||
"type": "int10",
|
||||
"value": "102",
|
||||
"name": "Processing (WebDAV; RFC 2518)"
|
||||
},
|
||||
{
|
||||
"type": "int10",
|
||||
"value": "103",
|
||||
"name": "Early Hints (RFC 8297)"
|
||||
},
|
||||
{
|
||||
"type": "int10",
|
||||
"value": "200",
|
||||
"name": "OK"
|
||||
},
|
||||
{
|
||||
"type": "int10",
|
||||
"value": "201",
|
||||
"name": "Created"
|
||||
},
|
||||
{
|
||||
"type": "int10",
|
||||
"value": "202",
|
||||
"name": "Accepted"
|
||||
},
|
||||
{
|
||||
"type": "int10",
|
||||
"value": "203",
|
||||
"name": "Non-Authoritative Information (since HTTP/1.1)"
|
||||
},
|
||||
{
|
||||
"type": "int10",
|
||||
"value": "204",
|
||||
"name": "No Content"
|
||||
},
|
||||
{
|
||||
"type": "int10",
|
||||
"value": "205",
|
||||
"name": "Reset Content"
|
||||
},
|
||||
{
|
||||
"type": "int10",
|
||||
"value": "206",
|
||||
"name": "Partial Content (RFC 7233)"
|
||||
},
|
||||
{
|
||||
"type": "int10",
|
||||
"value": "207",
|
||||
"name": "Multi-Status (WebDAV; RFC 4918)"
|
||||
},
|
||||
{
|
||||
"type": "int10",
|
||||
"value": "208",
|
||||
"name": "Already Reported (WebDAV; RFC 5842)"
|
||||
},
|
||||
{
|
||||
"type": "int10",
|
||||
"value": "226",
|
||||
"name": "IM Used (RFC 3229)"
|
||||
},
|
||||
{
|
||||
"type": "int10",
|
||||
"value": "300",
|
||||
"name": "Multiple Choices"
|
||||
},
|
||||
{
|
||||
"type": "int10",
|
||||
"value": "301",
|
||||
"name": "Moved Permanently"
|
||||
},
|
||||
{
|
||||
"type": "int10",
|
||||
"value": "302",
|
||||
"name": "Found (Previously \"Moved temporarily\")"
|
||||
},
|
||||
{
|
||||
"type": "int10",
|
||||
"value": "303",
|
||||
"name": "See Other (since HTTP/1.1)"
|
||||
},
|
||||
{
|
||||
"type": "int10",
|
||||
"value": "304",
|
||||
"name": "Not Modified (RFC 7232)"
|
||||
},
|
||||
{
|
||||
"type": "int10",
|
||||
"value": "305",
|
||||
"name": "Use Proxy (since HTTP/1.1)"
|
||||
},
|
||||
{
|
||||
"type": "int10",
|
||||
"value": "306",
|
||||
"name": "Switch Proxy"
|
||||
},
|
||||
{
|
||||
"type": "int10",
|
||||
"value": "307",
|
||||
"name": "Temporary Redirect (since HTTP/1.1)"
|
||||
},
|
||||
{
|
||||
"type": "int10",
|
||||
"value": "308",
|
||||
"name": "Permanent Redirect (RFC 7538)"
|
||||
},
|
||||
{
|
||||
"type": "int10",
|
||||
"value": "400",
|
||||
"name": "Bad Request"
|
||||
},
|
||||
{
|
||||
"type": "int10",
|
||||
"value": "401",
|
||||
"name": "Unauthorized (RFC 7235)"
|
||||
},
|
||||
{
|
||||
"type": "int10",
|
||||
"value": "402",
|
||||
"name": "Payment Required"
|
||||
},
|
||||
{
|
||||
"type": "int10",
|
||||
"value": "403",
|
||||
"name": "Forbidden"
|
||||
},
|
||||
{
|
||||
"type": "int10",
|
||||
"value": "404",
|
||||
"name": "Not Found"
|
||||
},
|
||||
{
|
||||
"type": "int10",
|
||||
"value": "405",
|
||||
"name": "Method Not Allowed"
|
||||
},
|
||||
{
|
||||
"type": "int10",
|
||||
"value": "406",
|
||||
"name": "Not Acceptable"
|
||||
},
|
||||
{
|
||||
"type": "int10",
|
||||
"value": "407",
|
||||
"name": "Proxy Authentication Required (RFC 7235)"
|
||||
},
|
||||
{
|
||||
"type": "int10",
|
||||
"value": "408",
|
||||
"name": "Request Timeout"
|
||||
},
|
||||
{
|
||||
"type": "int10",
|
||||
"value": "409",
|
||||
"name": "Conflict"
|
||||
},
|
||||
{
|
||||
"type": "int10",
|
||||
"value": "410",
|
||||
"name": "Gone"
|
||||
},
|
||||
{
|
||||
"type": "int10",
|
||||
"value": "411",
|
||||
"name": "Length Required"
|
||||
},
|
||||
{
|
||||
"type": "int10",
|
||||
"value": "412",
|
||||
"name": "Precondition Failed (RFC 7232)"
|
||||
},
|
||||
{
|
||||
"type": "int10",
|
||||
"value": "413",
|
||||
"name": "Payload Too Large (RFC 7231)"
|
||||
},
|
||||
{
|
||||
"type": "int10",
|
||||
"value": "414",
|
||||
"name": "URI Too Long (RFC 7231)"
|
||||
},
|
||||
{
|
||||
"type": "int10",
|
||||
"value": "415",
|
||||
"name": "Unsupported Media Type (RFC 7231)"
|
||||
},
|
||||
{
|
||||
"type": "int10",
|
||||
"value": "416",
|
||||
"name": "Range Not Satisfiable (RFC 7233)"
|
||||
},
|
||||
{
|
||||
"type": "int10",
|
||||
"value": "417",
|
||||
"name": "Expectation Failed"
|
||||
},
|
||||
{
|
||||
"type": "int10",
|
||||
"value": "418",
|
||||
"name": "I'm a teapot (RFC 2324, RFC 7168)"
|
||||
},
|
||||
{
|
||||
"type": "int10",
|
||||
"value": "421",
|
||||
"name": "Misdirected Request (RFC 7540)"
|
||||
},
|
||||
{
|
||||
"type": "int10",
|
||||
"value": "422",
|
||||
"name": "Unprocessable Entity (WebDAV; RFC 4918)"
|
||||
},
|
||||
{
|
||||
"type": "int10",
|
||||
"value": "424",
|
||||
"name": "Failed Dependency (WebDAV; RFC 4918)"
|
||||
},
|
||||
{
|
||||
"type": "int10",
|
||||
"value": "425",
|
||||
"name": "Too Early (RFC 8470)"
|
||||
},
|
||||
{
|
||||
"type": "int10",
|
||||
"value": "426",
|
||||
"name": "Upgrade Required"
|
||||
},
|
||||
{
|
||||
"type": "int10",
|
||||
"value": "428",
|
||||
"name": "Precondition Required (RFC 6585)"
|
||||
},
|
||||
{
|
||||
"type": "int10",
|
||||
"value": "429",
|
||||
"name": "Too Many Requests (RFC 6585)"
|
||||
},
|
||||
{
|
||||
"type": "int10",
|
||||
"value": "431",
|
||||
"name": "Request Header Fields Too Large (RFC 6585)"
|
||||
},
|
||||
{
|
||||
"type": "int10",
|
||||
"value": "451",
|
||||
"name": "Unavailable For Legal Reasons (RFC 7725)"
|
||||
},
|
||||
{
|
||||
"type": "int10",
|
||||
"value": "500",
|
||||
"name": "Internal Server Error"
|
||||
},
|
||||
{
|
||||
"type": "int10",
|
||||
"value": "501",
|
||||
"name": "Not Implemented"
|
||||
},
|
||||
{
|
||||
"type": "int10",
|
||||
"value": "502",
|
||||
"name": "Bad Gateway"
|
||||
},
|
||||
{
|
||||
"type": "int10",
|
||||
"value": "503",
|
||||
"name": "Service Unavailable"
|
||||
},
|
||||
{
|
||||
"type": "int10",
|
||||
"value": "504",
|
||||
"name": "Gateway Timeout"
|
||||
},
|
||||
{
|
||||
"type": "int10",
|
||||
"value": "505",
|
||||
"name": "HTTP Version Not Supported"
|
||||
},
|
||||
{
|
||||
"type": "int10",
|
||||
"value": "506",
|
||||
"name": "Variant Also Negotiates (RFC 2295)"
|
||||
},
|
||||
{
|
||||
"type": "int10",
|
||||
"value": "507",
|
||||
"name": "Insufficient Storage (WebDAV; RFC 4918)"
|
||||
},
|
||||
{
|
||||
"type": "int10",
|
||||
"value": "508",
|
||||
"name": "Loop Detected (WebDAV; RFC 5842)"
|
||||
},
|
||||
{
|
||||
"type": "int10",
|
||||
"value": "510",
|
||||
"name": "Not Extended (RFC 2774)"
|
||||
},
|
||||
{
|
||||
"type": "int10",
|
||||
"value": "511",
|
||||
"name": "Network Authentication Required (RFC 6585)"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -1,780 +0,0 @@
|
||||
{
|
||||
"name": "Linux Error Codes",
|
||||
"values": [
|
||||
{
|
||||
"type": "int10",
|
||||
"value": "1",
|
||||
"name": "EPERM",
|
||||
"desc": "Operation not permitted"
|
||||
},
|
||||
{
|
||||
"type": "int10",
|
||||
"value": "2",
|
||||
"name": "ENOENT",
|
||||
"desc": "No such file or directory"
|
||||
},
|
||||
{
|
||||
"type": "int10",
|
||||
"value": "3",
|
||||
"name": "ESRCH",
|
||||
"desc": "No such process"
|
||||
},
|
||||
{
|
||||
"type": "int10",
|
||||
"value": "4",
|
||||
"name": "EINTR",
|
||||
"desc": "Interrupted system call"
|
||||
},
|
||||
{
|
||||
"type": "int10",
|
||||
"value": "5",
|
||||
"name": "EIO",
|
||||
"desc": "I/O error"
|
||||
},
|
||||
{
|
||||
"type": "int10",
|
||||
"value": "6",
|
||||
"name": "ENXIO",
|
||||
"desc": "No such device or address"
|
||||
},
|
||||
{
|
||||
"type": "int10",
|
||||
"value": "7",
|
||||
"name": "E2BIG",
|
||||
"desc": "Argument list too long"
|
||||
},
|
||||
{
|
||||
"type": "int10",
|
||||
"value": "8",
|
||||
"name": "ENOEXEC",
|
||||
"desc": "Exec format error"
|
||||
},
|
||||
{
|
||||
"type": "int10",
|
||||
"value": "9",
|
||||
"name": "EBADF",
|
||||
"desc": "Bad file value"
|
||||
},
|
||||
{
|
||||
"type": "int10",
|
||||
"value": "10",
|
||||
"name": "ECHILD",
|
||||
"desc": "No child processes"
|
||||
},
|
||||
{
|
||||
"type": "int10",
|
||||
"value": "11",
|
||||
"name": "EAGAIN",
|
||||
"desc": "Try again"
|
||||
},
|
||||
{
|
||||
"type": "int10",
|
||||
"value": "12",
|
||||
"name": "ENOMEM",
|
||||
"desc": "Out of memory"
|
||||
},
|
||||
{
|
||||
"type": "int10",
|
||||
"value": "13",
|
||||
"name": "EACCES",
|
||||
"desc": "Permission denied"
|
||||
},
|
||||
{
|
||||
"type": "int10",
|
||||
"value": "14",
|
||||
"name": "EFAULT",
|
||||
"desc": "Bad address"
|
||||
},
|
||||
{
|
||||
"type": "int10",
|
||||
"value": "15",
|
||||
"name": "ENOTBLK",
|
||||
"desc": "Block device required"
|
||||
},
|
||||
{
|
||||
"type": "int10",
|
||||
"value": "16",
|
||||
"name": "EBUSY",
|
||||
"desc": "Device or resource busy"
|
||||
},
|
||||
{
|
||||
"type": "int10",
|
||||
"value": "17",
|
||||
"name": "EEXIST",
|
||||
"desc": "File exists"
|
||||
},
|
||||
{
|
||||
"type": "int10",
|
||||
"value": "18",
|
||||
"name": "EXDEV",
|
||||
"desc": "Cross-device link"
|
||||
},
|
||||
{
|
||||
"type": "int10",
|
||||
"value": "19",
|
||||
"name": "ENODEV",
|
||||
"desc": "No such device"
|
||||
},
|
||||
{
|
||||
"type": "int10",
|
||||
"value": "20",
|
||||
"name": "ENOTDIR",
|
||||
"desc": "Not a directory"
|
||||
},
|
||||
{
|
||||
"type": "int10",
|
||||
"value": "21",
|
||||
"name": "EISDIR",
|
||||
"desc": "Is a directory"
|
||||
},
|
||||
{
|
||||
"type": "int10",
|
||||
"value": "22",
|
||||
"name": "EINVAL",
|
||||
"desc": "Invalid argument"
|
||||
},
|
||||
{
|
||||
"type": "int10",
|
||||
"value": "23",
|
||||
"name": "ENFILE",
|
||||
"desc": "File table overflow"
|
||||
},
|
||||
{
|
||||
"type": "int10",
|
||||
"value": "24",
|
||||
"name": "EMFILE",
|
||||
"desc": "Too many open files"
|
||||
},
|
||||
{
|
||||
"type": "int10",
|
||||
"value": "25",
|
||||
"name": "ENOTTY",
|
||||
"desc": "Not a typewriter"
|
||||
},
|
||||
{
|
||||
"type": "int10",
|
||||
"value": "26",
|
||||
"name": "ETXTBSY",
|
||||
"desc": "Text file busy"
|
||||
},
|
||||
{
|
||||
"type": "int10",
|
||||
"value": "27",
|
||||
"name": "EFBIG",
|
||||
"desc": "File too large"
|
||||
},
|
||||
{
|
||||
"type": "int10",
|
||||
"value": "28",
|
||||
"name": "ENOSPC",
|
||||
"desc": "No space left on device"
|
||||
},
|
||||
{
|
||||
"type": "int10",
|
||||
"value": "29",
|
||||
"name": "ESPIPE",
|
||||
"desc": "Illegal seek"
|
||||
},
|
||||
{
|
||||
"type": "int10",
|
||||
"value": "30",
|
||||
"name": "EROFS",
|
||||
"desc": "Read-only file system"
|
||||
},
|
||||
{
|
||||
"type": "int10",
|
||||
"value": "31",
|
||||
"name": "EMLINK",
|
||||
"desc": "Too many links"
|
||||
},
|
||||
{
|
||||
"type": "int10",
|
||||
"value": "32",
|
||||
"name": "EPIPE",
|
||||
"desc": "Broken pipe"
|
||||
},
|
||||
{
|
||||
"type": "int10",
|
||||
"value": "33",
|
||||
"name": "EDOM",
|
||||
"desc": "Math argument out of domain of func"
|
||||
},
|
||||
{
|
||||
"type": "int10",
|
||||
"value": "34",
|
||||
"name": "ERANGE",
|
||||
"desc": "Math result not representable"
|
||||
},
|
||||
{
|
||||
"type": "int10",
|
||||
"value": "35",
|
||||
"name": "EDEADLK",
|
||||
"desc": "Resource deadlock would occur"
|
||||
},
|
||||
{
|
||||
"type": "int10",
|
||||
"value": "36",
|
||||
"name": "ENAMETOOLONG",
|
||||
"desc": "File name too long"
|
||||
},
|
||||
{
|
||||
"type": "int10",
|
||||
"value": "37",
|
||||
"name": "ENOLCK",
|
||||
"desc": "No record locks available"
|
||||
},
|
||||
{
|
||||
"type": "int10",
|
||||
"value": "38",
|
||||
"name": "ENOSYS",
|
||||
"desc": "Function not implemented"
|
||||
},
|
||||
{
|
||||
"type": "int10",
|
||||
"value": "39",
|
||||
"name": "ENOTEMPTY",
|
||||
"desc": "Directory not empty"
|
||||
},
|
||||
{
|
||||
"type": "int10",
|
||||
"value": "40",
|
||||
"name": "ELOOP",
|
||||
"desc": "Too many symbolic links encountered"
|
||||
},
|
||||
{
|
||||
"type": "int10",
|
||||
"value": "42",
|
||||
"name": "ENOMSG",
|
||||
"desc": "No message of desired type"
|
||||
},
|
||||
{
|
||||
"type": "int10",
|
||||
"value": "43",
|
||||
"name": "EIDRM",
|
||||
"desc": "Identifier removed"
|
||||
},
|
||||
{
|
||||
"type": "int10",
|
||||
"value": "44",
|
||||
"name": "ECHRNG",
|
||||
"desc": "Channel value out of range"
|
||||
},
|
||||
{
|
||||
"type": "int10",
|
||||
"value": "45",
|
||||
"name": "EL2NSYNC",
|
||||
"desc": "Level 2 not synchronized"
|
||||
},
|
||||
{
|
||||
"type": "int10",
|
||||
"value": "46",
|
||||
"name": "EL3HLT",
|
||||
"desc": "Level 3 halted"
|
||||
},
|
||||
{
|
||||
"type": "int10",
|
||||
"value": "47",
|
||||
"name": "EL3RST",
|
||||
"desc": "Level 3 reset"
|
||||
},
|
||||
{
|
||||
"type": "int10",
|
||||
"value": "48",
|
||||
"name": "ELNRNG",
|
||||
"desc": "Link value out of range"
|
||||
},
|
||||
{
|
||||
"type": "int10",
|
||||
"value": "49",
|
||||
"name": "EUNATCH",
|
||||
"desc": "Protocol driver not attached"
|
||||
},
|
||||
{
|
||||
"type": "int10",
|
||||
"value": "50",
|
||||
"name": "ENOCSI",
|
||||
"desc": "No CSI structure available"
|
||||
},
|
||||
{
|
||||
"type": "int10",
|
||||
"value": "51",
|
||||
"name": "EL2HLT",
|
||||
"desc": "Level 2 halted"
|
||||
},
|
||||
{
|
||||
"type": "int10",
|
||||
"value": "52",
|
||||
"name": "EBADE",
|
||||
"desc": "Invalid exchange"
|
||||
},
|
||||
{
|
||||
"type": "int10",
|
||||
"value": "53",
|
||||
"name": "EBADR",
|
||||
"desc": "Invalid request descriptor"
|
||||
},
|
||||
{
|
||||
"type": "int10",
|
||||
"value": "54",
|
||||
"name": "EXFULL",
|
||||
"desc": "Exchange full"
|
||||
},
|
||||
{
|
||||
"type": "int10",
|
||||
"value": "55",
|
||||
"name": "ENOANO",
|
||||
"desc": "No anode"
|
||||
},
|
||||
{
|
||||
"type": "int10",
|
||||
"value": "56",
|
||||
"name": "EBADRQC",
|
||||
"desc": "Invalid request code"
|
||||
},
|
||||
{
|
||||
"type": "int10",
|
||||
"value": "57",
|
||||
"name": "EBADSLT",
|
||||
"desc": "Invalid slot"
|
||||
},
|
||||
{
|
||||
"type": "int10",
|
||||
"value": "59",
|
||||
"name": "EBFONT",
|
||||
"desc": "Bad font file format"
|
||||
},
|
||||
{
|
||||
"type": "int10",
|
||||
"value": "60",
|
||||
"name": "ENOSTR",
|
||||
"desc": "Device not a stream"
|
||||
},
|
||||
{
|
||||
"type": "int10",
|
||||
"value": "61",
|
||||
"name": "ENODATA",
|
||||
"desc": "No data available"
|
||||
},
|
||||
{
|
||||
"type": "int10",
|
||||
"value": "62",
|
||||
"name": "ETIME",
|
||||
"desc": "Timer expired"
|
||||
},
|
||||
{
|
||||
"type": "int10",
|
||||
"value": "63",
|
||||
"name": "ENOSR",
|
||||
"desc": "Out of streams resources"
|
||||
},
|
||||
{
|
||||
"type": "int10",
|
||||
"value": "64",
|
||||
"name": "ENONET",
|
||||
"desc": "Machine is not on the network"
|
||||
},
|
||||
{
|
||||
"type": "int10",
|
||||
"value": "65",
|
||||
"name": "ENOPKG",
|
||||
"desc": "Package not installed"
|
||||
},
|
||||
{
|
||||
"type": "int10",
|
||||
"value": "66",
|
||||
"name": "EREMOTE",
|
||||
"desc": "Object is remote"
|
||||
},
|
||||
{
|
||||
"type": "int10",
|
||||
"value": "67",
|
||||
"name": "ENOLINK",
|
||||
"desc": "Link has been severed"
|
||||
},
|
||||
{
|
||||
"type": "int10",
|
||||
"value": "68",
|
||||
"name": "EADV",
|
||||
"desc": "Advertise error"
|
||||
},
|
||||
{
|
||||
"type": "int10",
|
||||
"value": "69",
|
||||
"name": "ESRMNT",
|
||||
"desc": "Srmount error"
|
||||
},
|
||||
{
|
||||
"type": "int10",
|
||||
"value": "70",
|
||||
"name": "ECOMM",
|
||||
"desc": "Communication error on send"
|
||||
},
|
||||
{
|
||||
"type": "int10",
|
||||
"value": "71",
|
||||
"name": "EPROTO",
|
||||
"desc": "Protocol error"
|
||||
},
|
||||
{
|
||||
"type": "int10",
|
||||
"value": "72",
|
||||
"name": "EMULTIHOP",
|
||||
"desc": "Multihop attempted"
|
||||
},
|
||||
{
|
||||
"type": "int10",
|
||||
"value": "73",
|
||||
"name": "EDOTDOT",
|
||||
"desc": "RFS specific error"
|
||||
},
|
||||
{
|
||||
"type": "int10",
|
||||
"value": "74",
|
||||
"name": "EBADMSG",
|
||||
"desc": "Not a data message"
|
||||
},
|
||||
{
|
||||
"type": "int10",
|
||||
"value": "75",
|
||||
"name": "EOVERFLOW",
|
||||
"desc": "Value too large for defined data type"
|
||||
},
|
||||
{
|
||||
"type": "int10",
|
||||
"value": "76",
|
||||
"name": "ENOTUNIQ",
|
||||
"desc": "Name not unique on network"
|
||||
},
|
||||
{
|
||||
"type": "int10",
|
||||
"value": "77",
|
||||
"name": "EBADFD",
|
||||
"desc": "File descriptor in bad state"
|
||||
},
|
||||
{
|
||||
"type": "int10",
|
||||
"value": "78",
|
||||
"name": "EREMCHG",
|
||||
"desc": "Remote address changed"
|
||||
},
|
||||
{
|
||||
"type": "int10",
|
||||
"value": "79",
|
||||
"name": "ELIBACC",
|
||||
"desc": "Can not access a needed shared library"
|
||||
},
|
||||
{
|
||||
"type": "int10",
|
||||
"value": "80",
|
||||
"name": "ELIBBAD",
|
||||
"desc": "Accessing a corrupted shared library"
|
||||
},
|
||||
{
|
||||
"type": "int10",
|
||||
"value": "81",
|
||||
"name": "ELIBSCN",
|
||||
"desc": ".lib section in a.out corrupted"
|
||||
},
|
||||
{
|
||||
"type": "int10",
|
||||
"value": "82",
|
||||
"name": "ELIBMAX",
|
||||
"desc": "Attempting to link in too many shared libraries"
|
||||
},
|
||||
{
|
||||
"type": "int10",
|
||||
"value": "83",
|
||||
"name": "ELIBEXEC",
|
||||
"desc": "Cannot exec a shared library directly"
|
||||
},
|
||||
{
|
||||
"type": "int10",
|
||||
"value": "84",
|
||||
"name": "EILSEQ",
|
||||
"desc": "Illegal byte sequence"
|
||||
},
|
||||
{
|
||||
"type": "int10",
|
||||
"value": "85",
|
||||
"name": "ERESTART",
|
||||
"desc": "Interrupted system call should be restarted"
|
||||
},
|
||||
{
|
||||
"type": "int10",
|
||||
"value": "86",
|
||||
"name": "ESTRPIPE",
|
||||
"desc": "Streams pipe error"
|
||||
},
|
||||
{
|
||||
"type": "int10",
|
||||
"value": "87",
|
||||
"name": "EUSERS",
|
||||
"desc": "Too many users"
|
||||
},
|
||||
{
|
||||
"type": "int10",
|
||||
"value": "88",
|
||||
"name": "ENOTSOCK",
|
||||
"desc": "Socket operation on non-socket"
|
||||
},
|
||||
{
|
||||
"type": "int10",
|
||||
"value": "89",
|
||||
"name": "EDESTADDRREQ",
|
||||
"desc": "Destination address required"
|
||||
},
|
||||
{
|
||||
"type": "int10",
|
||||
"value": "90",
|
||||
"name": "EMSGSIZE",
|
||||
"desc": "Message too long"
|
||||
},
|
||||
{
|
||||
"type": "int10",
|
||||
"value": "91",
|
||||
"name": "EPROTOTYPE",
|
||||
"desc": "Protocol wrong type for socket"
|
||||
},
|
||||
{
|
||||
"type": "int10",
|
||||
"value": "92",
|
||||
"name": "ENOPROTOOPT",
|
||||
"desc": "Protocol not available"
|
||||
},
|
||||
{
|
||||
"type": "int10",
|
||||
"value": "93",
|
||||
"name": "EPROTONOSUPPORT",
|
||||
"desc": "Protocol not supported"
|
||||
},
|
||||
{
|
||||
"type": "int10",
|
||||
"value": "94",
|
||||
"name": "ESOCKTNOSUPPORT",
|
||||
"desc": "Socket type not supported"
|
||||
},
|
||||
{
|
||||
"type": "int10",
|
||||
"value": "95",
|
||||
"name": "EOPNOTSUPP",
|
||||
"desc": "Operation not supported on transport endpoint"
|
||||
},
|
||||
{
|
||||
"type": "int10",
|
||||
"value": "96",
|
||||
"name": "EPFNOSUPPORT",
|
||||
"desc": "Protocol family not supported"
|
||||
},
|
||||
{
|
||||
"type": "int10",
|
||||
"value": "97",
|
||||
"name": "EAFNOSUPPORT",
|
||||
"desc": "Address family not supported by protocol"
|
||||
},
|
||||
{
|
||||
"type": "int10",
|
||||
"value": "98",
|
||||
"name": "EADDRINUSE",
|
||||
"desc": "Address already in use"
|
||||
},
|
||||
{
|
||||
"type": "int10",
|
||||
"value": "99",
|
||||
"name": "EADDRNOTAVAIL",
|
||||
"desc": "Cannot assign requested address"
|
||||
},
|
||||
{
|
||||
"type": "int10",
|
||||
"value": "100",
|
||||
"name": "ENETDOWN",
|
||||
"desc": "Network is down"
|
||||
},
|
||||
{
|
||||
"type": "int10",
|
||||
"value": "101",
|
||||
"name": "ENETUNREACH",
|
||||
"desc": "Network is unreachable"
|
||||
},
|
||||
{
|
||||
"type": "int10",
|
||||
"value": "102",
|
||||
"name": "ENETRESET",
|
||||
"desc": "Network dropped connection because of reset"
|
||||
},
|
||||
{
|
||||
"type": "int10",
|
||||
"value": "103",
|
||||
"name": "ECONNABORTED",
|
||||
"desc": "Software caused connection abort"
|
||||
},
|
||||
{
|
||||
"type": "int10",
|
||||
"value": "104",
|
||||
"name": "ECONNRESET",
|
||||
"desc": "Connection reset by peer"
|
||||
},
|
||||
{
|
||||
"type": "int10",
|
||||
"value": "105",
|
||||
"name": "ENOBUFS",
|
||||
"desc": "No buffer space available"
|
||||
},
|
||||
{
|
||||
"type": "int10",
|
||||
"value": "106",
|
||||
"name": "EISCONN",
|
||||
"desc": "Transport endpoint is already connected"
|
||||
},
|
||||
{
|
||||
"type": "int10",
|
||||
"value": "107",
|
||||
"name": "ENOTCONN",
|
||||
"desc": "Transport endpoint is not connected"
|
||||
},
|
||||
{
|
||||
"type": "int10",
|
||||
"value": "108",
|
||||
"name": "ESHUTDOWN",
|
||||
"desc": "Cannot send after transport endpoint shutdown"
|
||||
},
|
||||
{
|
||||
"type": "int10",
|
||||
"value": "109",
|
||||
"name": "ETOOMANYREFS",
|
||||
"desc": "Too many references: cannot splice"
|
||||
},
|
||||
{
|
||||
"type": "int10",
|
||||
"value": "110",
|
||||
"name": "ETIMEDOUT",
|
||||
"desc": "Connection timed out"
|
||||
},
|
||||
{
|
||||
"type": "int10",
|
||||
"value": "111",
|
||||
"name": "ECONNREFUSED",
|
||||
"desc": "Connection refused"
|
||||
},
|
||||
{
|
||||
"type": "int10",
|
||||
"value": "112",
|
||||
"name": "EHOSTDOWN",
|
||||
"desc": "Host is down"
|
||||
},
|
||||
{
|
||||
"type": "int10",
|
||||
"value": "113",
|
||||
"name": "EHOSTUNREACH",
|
||||
"desc": "No route to host"
|
||||
},
|
||||
{
|
||||
"type": "int10",
|
||||
"value": "114",
|
||||
"name": "EALREADY",
|
||||
"desc": "Operation already in progress"
|
||||
},
|
||||
{
|
||||
"type": "int10",
|
||||
"value": "115",
|
||||
"name": "EINPROGRESS",
|
||||
"desc": "Operation now in progress"
|
||||
},
|
||||
{
|
||||
"type": "int10",
|
||||
"value": "116",
|
||||
"name": "ESTALE",
|
||||
"desc": "Stale NFS file handle"
|
||||
},
|
||||
{
|
||||
"type": "int10",
|
||||
"value": "117",
|
||||
"name": "EUCLEAN",
|
||||
"desc": "Structure needs cleaning"
|
||||
},
|
||||
{
|
||||
"type": "int10",
|
||||
"value": "118",
|
||||
"name": "ENOTNAM",
|
||||
"desc": "Not a XENIX named type file"
|
||||
},
|
||||
{
|
||||
"type": "int10",
|
||||
"value": "119",
|
||||
"name": "ENAVAIL",
|
||||
"desc": "No XENIX semaphores available"
|
||||
},
|
||||
{
|
||||
"type": "int10",
|
||||
"value": "120",
|
||||
"name": "EISNAM",
|
||||
"desc": "Is a named type file"
|
||||
},
|
||||
{
|
||||
"type": "int10",
|
||||
"value": "121",
|
||||
"name": "EREMOTEIO",
|
||||
"desc": "Remote I/O error"
|
||||
},
|
||||
{
|
||||
"type": "int10",
|
||||
"value": "122",
|
||||
"name": "EDQUOT",
|
||||
"desc": "Quota exceeded"
|
||||
},
|
||||
{
|
||||
"type": "int10",
|
||||
"value": "123",
|
||||
"name": "ENOMEDIUM",
|
||||
"desc": "No medium found"
|
||||
},
|
||||
{
|
||||
"type": "int10",
|
||||
"value": "124",
|
||||
"name": "EMEDIUMTYPE",
|
||||
"desc": "Wrong medium type"
|
||||
},
|
||||
{
|
||||
"type": "int10",
|
||||
"value": "125",
|
||||
"name": "ECANCELED",
|
||||
"desc": "Operation Canceled"
|
||||
},
|
||||
{
|
||||
"type": "int10",
|
||||
"value": "126",
|
||||
"name": "ENOKEY",
|
||||
"desc": "Required key not available"
|
||||
},
|
||||
{
|
||||
"type": "int10",
|
||||
"value": "127",
|
||||
"name": "EKEYEXPIRED",
|
||||
"desc": "Key has expired"
|
||||
},
|
||||
{
|
||||
"type": "int10",
|
||||
"value": "128",
|
||||
"name": "EKEYREVOKED",
|
||||
"desc": "Key has been revoked"
|
||||
},
|
||||
{
|
||||
"type": "int10",
|
||||
"value": "129",
|
||||
"name": "EKEYREJECTED",
|
||||
"desc": "Key was rejected by service"
|
||||
},
|
||||
{
|
||||
"type": "int10",
|
||||
"value": "130",
|
||||
"name": "EOWNERDEAD",
|
||||
"desc": "Owner died"
|
||||
},
|
||||
{
|
||||
"type": "int10",
|
||||
"value": "131",
|
||||
"name": "ENOTRECOVERABLE",
|
||||
"desc": "State not recoverable"
|
||||
}
|
||||
|
||||
]
|
||||
}
|
||||
730
disassemblers/8051.json
Normal file
730
disassemblers/8051.json
Normal file
@@ -0,0 +1,730 @@
|
||||
{
|
||||
"name": "Intel 8051",
|
||||
"includes": [],
|
||||
"options": [],
|
||||
"opcodes": [
|
||||
{
|
||||
"mask": "0000'0000",
|
||||
"mnemonic": "NOP",
|
||||
"format": ""
|
||||
},
|
||||
{
|
||||
"mask": "0000'0010 AAAA'AAAA AAAA'AAAA",
|
||||
"mnemonic": "LJMP",
|
||||
"format": "#0x{A:04X}",
|
||||
"metadata": [
|
||||
{
|
||||
"type": "jump",
|
||||
"data": {
|
||||
"destination": "A"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"mask": "1000'0000 AAAA'AAAA",
|
||||
"mnemonic": "SJMP",
|
||||
"format": "#0x{A:02X}",
|
||||
"metadata": [
|
||||
{
|
||||
"type": "jump",
|
||||
"data": {
|
||||
"destination": "A"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"mask": "0111'0011",
|
||||
"mnemonic": "JMP",
|
||||
"format": "@A+DPTR"
|
||||
},
|
||||
{
|
||||
"mask": "0100'0000 AAAA'AAAA",
|
||||
"mnemonic": "JC",
|
||||
"format": "PC + 0x{A:02X}",
|
||||
"metadata": [
|
||||
{
|
||||
"type": "jump",
|
||||
"data": {
|
||||
"destination": "offset + 2 + A"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"mask": "0011'0000 BBBB'BBBB AAAA'AAAA",
|
||||
"mnemonic": "JNB",
|
||||
"format": "BIT[0x{B:02X}], PC + 0x{A:02X}",
|
||||
"metadata": [
|
||||
{
|
||||
"type": "jump",
|
||||
"data": {
|
||||
"destination": "offset + 3 + A"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"mask": "0001'0000 BBBB'BBBB AAAA'AAAA",
|
||||
"mnemonic": "JBC",
|
||||
"format": "BIT[0x{B:02X}], PC + 0x{A:02X}",
|
||||
"metadata": [
|
||||
{
|
||||
"type": "jump",
|
||||
"data": {
|
||||
"destination": "offset + 3 + A"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"mask": "0010'0000 AAAA'AAAA RRRR'RRRR",
|
||||
"mnemonic": "JB",
|
||||
"format": "BIT[0x{A:02X}], PC + 0x{R:02X}",
|
||||
"metadata": [
|
||||
{
|
||||
"type": "jump",
|
||||
"data": {
|
||||
"destination": "offset + 3 + A"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"mask": "0001'0010 AAAA'AAAA AAAA'AAAA",
|
||||
"mnemonic": "LCALL",
|
||||
"format": "#0x{A:04X}",
|
||||
"metadata": [
|
||||
{
|
||||
"type": "jump",
|
||||
"data": {
|
||||
"destination": "A"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"mask": "PPP1'0001 AAAA'AAAA",
|
||||
"mnemonic": "ACALL",
|
||||
"format": "page{P} #0x{A:04X}",
|
||||
"metadata": [
|
||||
{
|
||||
"type": "jump",
|
||||
"data": {
|
||||
"destination": "P * 256 + A"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"mask": "PPP0'0001 AAAA'AAAA",
|
||||
"mnemonic": "AJMP",
|
||||
"format": "page{P} #0x{A:04X}",
|
||||
"metadata": [
|
||||
{
|
||||
"type": "jump",
|
||||
"data": {
|
||||
"destination": "P * 256 + A"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"mask": "0000'0011",
|
||||
"mnemonic": "RR",
|
||||
"format": "A"
|
||||
},
|
||||
{
|
||||
"mask": "0001'0011",
|
||||
"mnemonic": "RRC",
|
||||
"format": "A"
|
||||
},
|
||||
{
|
||||
"mask": "0010'0011",
|
||||
"mnemonic": "RL",
|
||||
"format": "A"
|
||||
},
|
||||
{
|
||||
"mask": "0011'0011",
|
||||
"mnemonic": "RLC",
|
||||
"format": "A"
|
||||
},
|
||||
{
|
||||
"mask": "0000'0100",
|
||||
"mnemonic": "INC",
|
||||
"format": "A"
|
||||
},
|
||||
{
|
||||
"mask": "0000'0101 AAAA'AAAA",
|
||||
"mnemonic": "INC",
|
||||
"format": "IRAM[0x{A:02X}]"
|
||||
},
|
||||
{
|
||||
"mask": "0000'011R",
|
||||
"mnemonic": "INC",
|
||||
"format": "@R{R}"
|
||||
},
|
||||
{
|
||||
"mask": "0000'1RRR",
|
||||
"mnemonic": "INC",
|
||||
"format": "R{R}"
|
||||
},
|
||||
{
|
||||
"mask": "1010'0011",
|
||||
"mnemonic": "INC",
|
||||
"format": "DPTR"
|
||||
},
|
||||
{
|
||||
"mask": "0001'0100",
|
||||
"mnemonic": "DEC",
|
||||
"format": "A"
|
||||
},
|
||||
{
|
||||
"mask": "0001'0101 AAAA'AAAA",
|
||||
"mnemonic": "DEC",
|
||||
"format": "IRAM[0x{A:02X}]"
|
||||
},
|
||||
{
|
||||
"mask": "0001'0110",
|
||||
"mnemonic": "DEC",
|
||||
"format": "@R0"
|
||||
},
|
||||
{
|
||||
"mask": "0001'0111",
|
||||
"mnemonic": "DEC",
|
||||
"format": "@R1"
|
||||
},
|
||||
{
|
||||
"mask": "0001'1RRR",
|
||||
"mnemonic": "DEC",
|
||||
"format": "R{R}"
|
||||
},
|
||||
{
|
||||
"mask": "1110'0100",
|
||||
"mnemonic": "CLR",
|
||||
"format": "A"
|
||||
},
|
||||
{
|
||||
"mask": "1100'0010 AAAA'AAAA",
|
||||
"mnemonic": "CLR",
|
||||
"format": "BIT[0x{A:02X}]"
|
||||
},
|
||||
{
|
||||
"mask": "1100'0011",
|
||||
"mnemonic": "CLR",
|
||||
"format": "C"
|
||||
},
|
||||
{
|
||||
"mask": "1111'0000",
|
||||
"mnemonic": "MOVX",
|
||||
"format": "@DPTR, A"
|
||||
},
|
||||
{
|
||||
"mask": "1110'0000",
|
||||
"mnemonic": "MOVX",
|
||||
"format": "A, @DPTR"
|
||||
},
|
||||
{
|
||||
"mask": "1111'001R",
|
||||
"mnemonic": "MOVX",
|
||||
"format": "@R{R}, A"
|
||||
},
|
||||
{
|
||||
"mask": "1110'001R",
|
||||
"mnemonic": "MOVX",
|
||||
"format": "A, @R{R}"
|
||||
},
|
||||
{
|
||||
"mask": "0111'011R AAAA'AAAA",
|
||||
"mnemonic": "MOV",
|
||||
"format": "@R{R}, #0x{A:02X}"
|
||||
},
|
||||
{
|
||||
"mask": "0111'1RRR AAAA'AAAA",
|
||||
"mnemonic": "MOV",
|
||||
"format": "R{R}, #0x{A:02X}"
|
||||
},
|
||||
{
|
||||
"mask": "1111'1RRR",
|
||||
"mnemonic": "MOV",
|
||||
"format": "R{R}, A"
|
||||
},
|
||||
{
|
||||
"mask": "1110'011R",
|
||||
"mnemonic": "MOV",
|
||||
"format": "A, @R{R}"
|
||||
},
|
||||
{
|
||||
"mask": "1111'011R",
|
||||
"mnemonic": "MOV",
|
||||
"format": "@R{R}, A"
|
||||
},
|
||||
{
|
||||
"mask": "1110'1RRR",
|
||||
"mnemonic": "MOV",
|
||||
"format": "A, R{R}"
|
||||
},
|
||||
{
|
||||
"mask": "1001'0010 AAAA'AAAA",
|
||||
"mnemonic": "MOV",
|
||||
"format": "BIT[0x{A:02X}], C"
|
||||
},
|
||||
{
|
||||
"mask": "1010'0010 AAAA'AAAA",
|
||||
"mnemonic": "MOV",
|
||||
"format": "C, BIT[0x{A:02X}]"
|
||||
},
|
||||
{
|
||||
"mask": "1001'0000 DDDD'DDDD DDDD'DDDD",
|
||||
"mnemonic": "MOV",
|
||||
"format": "DPTR, #0x{D:04X}"
|
||||
},
|
||||
{
|
||||
"mask": "1110'0101 AAAA'AAAA",
|
||||
"mnemonic": "MOV",
|
||||
"format": "A, IRAM[0x{A:02X}]"
|
||||
},
|
||||
{
|
||||
"mask": "1111'0101 AAAA'AAAA",
|
||||
"mnemonic": "MOV",
|
||||
"format": "IRAM[#0x{A:02X}], A"
|
||||
},
|
||||
{
|
||||
"mask": "0111'0101 AAAA'AAAA DDDD'DDDD",
|
||||
"mnemonic": "MOV",
|
||||
"format": "IRAM[0x{A:02X}], #0x{D:02X}"
|
||||
},
|
||||
{
|
||||
"mask": "1000'0101 AAAA'AAAA BBBB'BBBB",
|
||||
"mnemonic": "MOV",
|
||||
"format": "IRAM[0x{A:02X}], IRAM[0x{B:02X}]"
|
||||
},
|
||||
{
|
||||
"mask": "0111'0100 DDDD'DDDD",
|
||||
"mnemonic": "MOV",
|
||||
"format": "A, #0x{D:02X}"
|
||||
},
|
||||
{
|
||||
"mask": "1000'011R AAAA'AAAA",
|
||||
"mnemonic": "MOV",
|
||||
"format": "IRAM[0x{A:02X}], @R{R}"
|
||||
},
|
||||
{
|
||||
"mask": "1000'1RRR AAAA'AAAA",
|
||||
"mnemonic": "MOV",
|
||||
"format": "IRAM[0x{A:02X}], R{R}"
|
||||
},
|
||||
{
|
||||
"mask": "1010'011R AAAA'AAAA",
|
||||
"mnemonic": "MOV",
|
||||
"format": "@R{R}, IRAM[0x{A:02X}]"
|
||||
},
|
||||
{
|
||||
"mask": "1010'1RRR AAAA'AAAA",
|
||||
"mnemonic": "MOV",
|
||||
"format": "R{R}, IRAM[0x{A:02X}]"
|
||||
},
|
||||
{
|
||||
"mask": "0110'0000 AAAA'AAAA",
|
||||
"mnemonic": "JZ",
|
||||
"format": "PC + 0x{A:02X}",
|
||||
"metadata": [
|
||||
{
|
||||
"type": "jump",
|
||||
"data": {
|
||||
"destination": "offset + 2 + A"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"mask": "0111'0000 AAAA'AAAA",
|
||||
"mnemonic": "JNZ",
|
||||
"format": "PC + 0x{A:02X}",
|
||||
"metadata": [
|
||||
{
|
||||
"type": "jump",
|
||||
"data": {
|
||||
"destination": "offset + 2 + A"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"mask": "1001'0011",
|
||||
"mnemonic": "MOVC",
|
||||
"format": "A, @A+DPTR"
|
||||
},
|
||||
{
|
||||
"mask": "1000'0011",
|
||||
"mnemonic": "MOVC",
|
||||
"format": "A, @A+PC"
|
||||
},
|
||||
{
|
||||
"mask": "1101'011R",
|
||||
"mnemonic": "XCHD",
|
||||
"format": "A, @R{R}"
|
||||
},
|
||||
{
|
||||
"mask": "1100'011R",
|
||||
"mnemonic": "XCH",
|
||||
"format": "A, @R{R}"
|
||||
},
|
||||
{
|
||||
"mask": "1100'1RRR",
|
||||
"mnemonic": "XCH",
|
||||
"format": "A, R{R}"
|
||||
},
|
||||
{
|
||||
"mask": "1100'0101 AAAA'AAAA",
|
||||
"mnemonic": "XCH",
|
||||
"format": "A, IRAM[0x{A:02X}]"
|
||||
},
|
||||
{
|
||||
"mask": "0010'0010",
|
||||
"mnemonic": "RET",
|
||||
"format": ""
|
||||
},
|
||||
{
|
||||
"mask": "0011'0010",
|
||||
"mnemonic": "RETI",
|
||||
"format": ""
|
||||
},
|
||||
{
|
||||
"mask": "1101'0010 AAAA'AAAA",
|
||||
"mnemonic": "SETB",
|
||||
"format": "BIT[0x{A:02X}]"
|
||||
},
|
||||
{
|
||||
"mask": "1101'0011",
|
||||
"mnemonic": "SETB",
|
||||
"format": "C"
|
||||
},
|
||||
{
|
||||
"mask": "0101'0010 AAAA'AAAA",
|
||||
"mnemonic": "ANL",
|
||||
"format": "IRAM[0x{A:02X}], A"
|
||||
},
|
||||
{
|
||||
"mask": "0101'0101 AAAA'AAAA",
|
||||
"mnemonic": "ANL",
|
||||
"format": "A, IRAM[0x{A:02X}]"
|
||||
},
|
||||
{
|
||||
"mask": "0101'0011 AAAA'AAAA DDDD'DDDD",
|
||||
"mnemonic": "ANL",
|
||||
"format": "A, IRAM[0x{A:02X}], #0x{D:02X}"
|
||||
},
|
||||
{
|
||||
"mask": "0101'0100 AAAA'AAAA",
|
||||
"mnemonic": "ANL",
|
||||
"format": "A, #0x{A:02X}"
|
||||
},
|
||||
{
|
||||
"mask": "0101'011R",
|
||||
"mnemonic": "ANL",
|
||||
"format": "A, @R{R}"
|
||||
},
|
||||
{
|
||||
"mask": "0101'1RRR",
|
||||
"mnemonic": "ANL",
|
||||
"format": "A, R{R}"
|
||||
},
|
||||
{
|
||||
"mask": "1000'0010 AAAA'AAAA",
|
||||
"mnemonic": "ANL",
|
||||
"format": "C, BIT[0x{A:02X}]"
|
||||
},
|
||||
{
|
||||
"mask": "1011'0000 AAAA'AAAA",
|
||||
"mnemonic": "ANL",
|
||||
"format": "C, /BIT[0x{A:02X}]"
|
||||
},
|
||||
{
|
||||
"mask": "0100'0010 AAAA'AAAA",
|
||||
"mnemonic": "ORL",
|
||||
"format": "IRAM[0x{A:02X}], A"
|
||||
},
|
||||
{
|
||||
"mask": "0100'0011 AAAA'AAAA DDDD'DDDD",
|
||||
"mnemonic": "ORL",
|
||||
"format": "IRAM[0x{A:02X}], #0x{D:02X}"
|
||||
},
|
||||
{
|
||||
"mask": "0100'0100 DDDD'DDDD",
|
||||
"mnemonic": "ORL",
|
||||
"format": "A, #0x{D:02X}"
|
||||
},
|
||||
{
|
||||
"mask": "0100'011R",
|
||||
"mnemonic": "ORL",
|
||||
"format": "A, @R{R}"
|
||||
},
|
||||
{
|
||||
"mask": "0100'1RRR",
|
||||
"mnemonic": "ORL",
|
||||
"format": "A, R{R}"
|
||||
},
|
||||
{
|
||||
"mask": "0100'0101 AAAA'AAAA",
|
||||
"mnemonic": "ORL",
|
||||
"format": "A, IRAM[0x{A:02X}]"
|
||||
},
|
||||
{
|
||||
"mask": "0111'0010 AAAA'AAAA",
|
||||
"mnemonic": "ORL",
|
||||
"format": "C, BIT[0x{A:02X}]"
|
||||
},
|
||||
{
|
||||
"mask": "1010'0000 AAAA'AAAA",
|
||||
"mnemonic": "ORL",
|
||||
"format": "C, /BIT[0x{A:02X}]"
|
||||
},
|
||||
{
|
||||
"mask": "0110'0010 AAAA'AAAA",
|
||||
"mnemonic": "XRL",
|
||||
"format": "IRAM[0x{A:02X}], A"
|
||||
},
|
||||
{
|
||||
"mask": "0110'0011 AAAA'AAAA DDDD'DDDD",
|
||||
"mnemonic": "XRL",
|
||||
"format": "IRAM[0x{A:02X}], #0x{D:02X}"
|
||||
},
|
||||
{
|
||||
"mask": "0110'0100 DDDD'DDDD",
|
||||
"mnemonic": "XRL",
|
||||
"format": "A, #0x{D:02X}"
|
||||
},
|
||||
{
|
||||
"mask": "0110'011R",
|
||||
"mnemonic": "XRL",
|
||||
"format": "A, @R{R}"
|
||||
},
|
||||
{
|
||||
"mask": "0110'1RRR",
|
||||
"mnemonic": "XRL",
|
||||
"format": "A, R{R}"
|
||||
},
|
||||
{
|
||||
"mask": "0110'0101 AAAA'AAAA",
|
||||
"mnemonic": "XRL",
|
||||
"format": "A, IRAM[0x{A:02X}]"
|
||||
},
|
||||
{
|
||||
"mask": "0010'0100 DDDD'DDDD",
|
||||
"mnemonic": "ADD",
|
||||
"format": "A, #0x{D:02X}"
|
||||
},
|
||||
{
|
||||
"mask": "0010'011R",
|
||||
"mnemonic": "ADD",
|
||||
"format": "A, @R{R}"
|
||||
},
|
||||
{
|
||||
"mask": "0010'0101 AAAA'AAAA",
|
||||
"mnemonic": "ADD",
|
||||
"format": "A, IRAM[0x{A:02X}]"
|
||||
},
|
||||
{
|
||||
"mask": "0011'0100 DDDD'DDDD",
|
||||
"mnemonic": "ADDC",
|
||||
"format": "A, #0x{D:02X}"
|
||||
},
|
||||
{
|
||||
"mask": "0011'011R",
|
||||
"mnemonic": "ADDC",
|
||||
"format": "A, @R{R}"
|
||||
},
|
||||
{
|
||||
"mask": "0011'0101 AAAA'AAAA",
|
||||
"mnemonic": "ADDC",
|
||||
"format": "A, IRAM[0x{A:02X}]"
|
||||
},
|
||||
{
|
||||
"mask": "0011'1RRR",
|
||||
"mnemonic": "ADDC",
|
||||
"format": "A, R{R}"
|
||||
},
|
||||
{
|
||||
"mask": "1001'0100 DDDD'DDDD",
|
||||
"mnemonic": "SUBB",
|
||||
"format": "A, #0x{D:02X}"
|
||||
},
|
||||
{
|
||||
"mask": "1001'0101 IIII'IIII",
|
||||
"mnemonic": "SUBB",
|
||||
"format": "A, IRAM[0x{I:02X}]"
|
||||
},
|
||||
{
|
||||
"mask": "1001'011R",
|
||||
"mnemonic": "SUBB",
|
||||
"format": "A, @R{R}"
|
||||
},
|
||||
{
|
||||
"mask": "1001'1RRR",
|
||||
"mnemonic": "SUBB",
|
||||
"format": "A, R{R}"
|
||||
},
|
||||
{
|
||||
"mask": "1010'0100",
|
||||
"mnemonic": "MUL",
|
||||
"format": "AB"
|
||||
},
|
||||
{
|
||||
"mask": "1000'0100",
|
||||
"mnemonic": "DIV",
|
||||
"format": "AB"
|
||||
},
|
||||
{
|
||||
"mask": "0010'1RRR",
|
||||
"mnemonic": "ORL",
|
||||
"format": "A, R{R}"
|
||||
},
|
||||
{
|
||||
"mask": "1011'0101 IIII'IIII AAAA'AAAA",
|
||||
"mnemonic": "CJNE",
|
||||
"format": "A, IRAM[0x{I:02X}], PC + 0x{A:02X}",
|
||||
"metadata": [
|
||||
{
|
||||
"type": "jump",
|
||||
"data": {
|
||||
"destination": "offset + 3 + A"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"mask": "1011'0100 DDDD'DDDD AAAA'AAAA",
|
||||
"mnemonic": "CJNE",
|
||||
"format": "A, #0x{D:02X}, PC + 0x{A:02X}",
|
||||
"metadata": [
|
||||
{
|
||||
"type": "jump",
|
||||
"data": {
|
||||
"destination": "offset + 3 + A"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"mask": "1011'011R DDDD'DDDD AAAA'AAAA",
|
||||
"mnemonic": "CJNE",
|
||||
"format": "@R{R}, #0x{D:02X}, PC + 0x{A:02X}",
|
||||
"metadata": [
|
||||
{
|
||||
"type": "jump",
|
||||
"data": {
|
||||
"destination": "offset + 3 + A"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"mask": "1011'1RRR DDDD'DDDD AAAA'AAAA",
|
||||
"mnemonic": "CJNE",
|
||||
"format": "R{R}, #0x{D:02X}, PC + 0x{A:02X}",
|
||||
"metadata": [
|
||||
{
|
||||
"type": "jump",
|
||||
"data": {
|
||||
"destination": "offset + 3 + A"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"mask": "1101'0101 IIII'IIII AAAA'AAAA",
|
||||
"mnemonic": "DJNZ",
|
||||
"format": "IRAM[0x{I:02X}], PC + 0x{A:02X}",
|
||||
"metadata": [
|
||||
{
|
||||
"type": "jump",
|
||||
"data": {
|
||||
"destination": "offset + 3 + A"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"mask": "1101'1RRR AAAA'AAAA",
|
||||
"mnemonic": "DJNZ",
|
||||
"format": "R{R}, PC + 0x{R:02X}",
|
||||
"metadata": [
|
||||
{
|
||||
"type": "jump",
|
||||
"data": {
|
||||
"destination": "offset + 2 + A"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"mask": "0101'0000 AAAA'AAAA",
|
||||
"mnemonic": "JNC",
|
||||
"format": "PC + 0x{A:02X}",
|
||||
"metadata": [
|
||||
{
|
||||
"type": "jump",
|
||||
"data": {
|
||||
"destination": "offset + 2 + A"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"mask": "1101'0000 AAAA'AAAA",
|
||||
"mnemonic": "POP",
|
||||
"format": "IRAM[0x{A:02X}]"
|
||||
},
|
||||
{
|
||||
"mask": "1100'0000 AAAA'AAAA",
|
||||
"mnemonic": "PUSH",
|
||||
"format": "IRAM[0x{A:02X}]"
|
||||
},
|
||||
{
|
||||
"mask": "1101'0100",
|
||||
"mnemonic": "DA",
|
||||
"format": ""
|
||||
},
|
||||
{
|
||||
"mask": "1100'0100",
|
||||
"mnemonic": "SWAP",
|
||||
"format": "A"
|
||||
},
|
||||
{
|
||||
"mask": "1111'0100",
|
||||
"mnemonic": "CPL",
|
||||
"format": "A"
|
||||
},
|
||||
{
|
||||
"mask": "1011'0011",
|
||||
"mnemonic": "CPL",
|
||||
"format": "C"
|
||||
},
|
||||
{
|
||||
"mask": "1011'0010 BBBB'BBBB",
|
||||
"mnemonic": "CPL",
|
||||
"format": "BIT[0x{B:02X}]"
|
||||
},
|
||||
{
|
||||
"mask": "1010'0101",
|
||||
"mnemonic": "INVALID",
|
||||
"format": ""
|
||||
},
|
||||
{
|
||||
"mask": "XXXX'XXXX",
|
||||
"mnemonic": "DB",
|
||||
"format": "#0x{X:02X}",
|
||||
"metadata": [
|
||||
{
|
||||
"type": "data",
|
||||
"data": {
|
||||
"value": "X"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
]
|
||||
}
|
||||
1045
disassemblers/jvm.json
Normal file
1045
disassemblers/jvm.json
Normal file
File diff suppressed because it is too large
Load Diff
18594
encodings/big5.tbl
Normal file
18594
encodings/big5.tbl
Normal file
File diff suppressed because it is too large
Load Diff
Binary file not shown.
21887
encodings/gbk.tbl
Normal file
21887
encodings/gbk.tbl
Normal file
File diff suppressed because it is too large
Load Diff
Binary file not shown.
7120
encodings/ms932.tbl
Normal file
7120
encodings/ms932.tbl
Normal file
File diff suppressed because it is too large
Load Diff
256
encodings/pokegen3_en.tbl
Normal file
256
encodings/pokegen3_en.tbl
Normal file
@@ -0,0 +1,256 @@
|
||||
00
|
||||
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
|
||||
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
|
||||
4a
|
||||
4b
|
||||
4c
|
||||
4d
|
||||
4e
|
||||
4f
|
||||
50
|
||||
51=¿
|
||||
52=¡
|
||||
53=Pk
|
||||
54=Mn
|
||||
55=Po
|
||||
56=Ké
|
||||
57
|
||||
58
|
||||
59
|
||||
5a=Í
|
||||
5b=%
|
||||
5c=(
|
||||
5d=)
|
||||
5e
|
||||
5f
|
||||
60
|
||||
61
|
||||
62
|
||||
63
|
||||
64
|
||||
65
|
||||
66
|
||||
67
|
||||
68=â
|
||||
69
|
||||
6a
|
||||
6b
|
||||
6c
|
||||
6d
|
||||
6e
|
||||
6f=í
|
||||
70
|
||||
71
|
||||
72
|
||||
73
|
||||
74
|
||||
75
|
||||
76
|
||||
77
|
||||
78
|
||||
79=⬆
|
||||
7a=⬇
|
||||
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=0
|
||||
a2=1
|
||||
a3=2
|
||||
a4=3
|
||||
a5=4
|
||||
a6=5
|
||||
a7=6
|
||||
a8=7
|
||||
a9=8
|
||||
aa=9
|
||||
ab=!
|
||||
ac=?
|
||||
ad=.
|
||||
ae=-
|
||||
af=・
|
||||
b0
|
||||
b1=“
|
||||
b2=”
|
||||
b3=‘
|
||||
b4=’
|
||||
b5=♂
|
||||
b6=♀
|
||||
b7
|
||||
b8=,
|
||||
b9=×
|
||||
ba=/
|
||||
bb=A
|
||||
bc=B
|
||||
bd=C
|
||||
be=D
|
||||
bf=E
|
||||
c0=F
|
||||
c1=G
|
||||
c2=H
|
||||
c3=I
|
||||
c4=J
|
||||
c5=K
|
||||
c6=L
|
||||
c7=M
|
||||
c8=N
|
||||
c9=O
|
||||
ca=P
|
||||
cb=Q
|
||||
cc=R
|
||||
cd=S
|
||||
ce=T
|
||||
cf=U
|
||||
d0=V
|
||||
d1=W
|
||||
d2=X
|
||||
d3=Y
|
||||
d4=Z
|
||||
d5=a
|
||||
d6=b
|
||||
d7=c
|
||||
d8=d
|
||||
d9=e
|
||||
da=f
|
||||
db=g
|
||||
dc=h
|
||||
dd=i
|
||||
de=j
|
||||
df=k
|
||||
e0=l
|
||||
e1=m
|
||||
e2=n
|
||||
e3=o
|
||||
e4=p
|
||||
e5=q
|
||||
e6=r
|
||||
e7=s
|
||||
e8=t
|
||||
e9=u
|
||||
ea=v
|
||||
eb=w
|
||||
ec=x
|
||||
ed=y
|
||||
ee=z
|
||||
ef=▶
|
||||
f0=:
|
||||
f1=Ä
|
||||
f2=Ö
|
||||
f3=Ü
|
||||
f4=ä
|
||||
f5=ö
|
||||
f6=ü
|
||||
f7
|
||||
f8
|
||||
f9
|
||||
fa
|
||||
fb
|
||||
fc
|
||||
fd
|
||||
fe
|
||||
ff
|
||||
@@ -1,10 +1,3 @@
|
||||
00=
|
||||
08=\b
|
||||
09=\t
|
||||
0A=\n
|
||||
0B=\v
|
||||
0C=\f
|
||||
0D=\r
|
||||
20=
|
||||
21=!
|
||||
22="
|
||||
@@ -128,12 +121,12 @@
|
||||
8159=〆
|
||||
815A=〇
|
||||
815B=ー
|
||||
815C=―
|
||||
815C=—
|
||||
815D=‐
|
||||
815E=/
|
||||
815F=\
|
||||
8160=~
|
||||
8161=∥
|
||||
8160=〜
|
||||
8161=‖
|
||||
8162=|
|
||||
8163=…
|
||||
8164=‥
|
||||
@@ -160,7 +153,7 @@
|
||||
8179=【
|
||||
817A=】
|
||||
817B=+
|
||||
817C=-
|
||||
817C=−
|
||||
817D=±
|
||||
817E=×
|
||||
8180=÷
|
||||
@@ -180,8 +173,8 @@
|
||||
818E=℃
|
||||
818F=¥
|
||||
8190=$
|
||||
8191=¢
|
||||
8192=£
|
||||
8191=¢
|
||||
8192=£
|
||||
8193=%
|
||||
8194=#
|
||||
8195=&
|
||||
@@ -194,6 +187,7 @@
|
||||
819C=●
|
||||
819D=◎
|
||||
819E=◇
|
||||
819F=◆
|
||||
81A0=□
|
||||
81A1=■
|
||||
81A2=△
|
||||
@@ -217,7 +211,7 @@
|
||||
81BF=∩
|
||||
81C8=∧
|
||||
81C9=∨
|
||||
81CA=¬
|
||||
81CA=¬
|
||||
81CB=⇒
|
||||
81CC=⇔
|
||||
81CD=∀
|
||||
@@ -623,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=娃
|
||||
@@ -7124,4 +7035,3 @@ EAA1=遙
|
||||
EAA2=瑤
|
||||
EAA3=凜
|
||||
EAA4=熙
|
||||
FA5B=∵
|
||||
|
||||
1257568
encodings/utf8.tbl
1257568
encodings/utf8.tbl
File diff suppressed because it is too large
Load Diff
@@ -1,29 +1,50 @@
|
||||
#pragma once
|
||||
|
||||
#include <hex/impl/imhex_check.pat>
|
||||
import hex.impl.imhex_check;
|
||||
|
||||
namespace hex::core {
|
||||
/*!
|
||||
Core intrinsic functions to interact with the ImHex Hex Editor
|
||||
*/
|
||||
|
||||
namespace auto hex::core {
|
||||
|
||||
/**
|
||||
A type representing a selection in the hex editor
|
||||
*/
|
||||
struct Selection {
|
||||
bool valid;
|
||||
u64 address, size;
|
||||
};
|
||||
|
||||
/**
|
||||
Returns the current selection in the hex editor
|
||||
@return The current selection
|
||||
*/
|
||||
fn get_selection() {
|
||||
u128 result = builtin::hex::core::get_selection();
|
||||
u128 selection = builtin::hex::core::get_selection();
|
||||
|
||||
Selection result;
|
||||
if (result == u128(-1)) {
|
||||
if (selection == u128(-1)) {
|
||||
result.valid = false;
|
||||
result.address = 0x00;
|
||||
result.size = 0x00;
|
||||
} else {
|
||||
result.valid = true;
|
||||
result.address = result >> 64;
|
||||
result.size = result & u64(-1);
|
||||
result.address = selection >> 64;
|
||||
result.size = selection & u64(-1);
|
||||
}
|
||||
|
||||
return result;
|
||||
};
|
||||
|
||||
}
|
||||
/**
|
||||
Add a file to the Virtual Filesystem
|
||||
@param path The name of the file
|
||||
@param pattern The pattern associated with the file
|
||||
*/
|
||||
fn add_virtual_file(str path, auto pattern)
|
||||
{
|
||||
builtin::hex::core::add_virtual_file(path, pattern);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
75
includes/hex/dec.pat
Normal file
75
includes/hex/dec.pat
Normal file
@@ -0,0 +1,75 @@
|
||||
#pragma once
|
||||
|
||||
import hex.impl.imhex_check;
|
||||
|
||||
import std.mem;
|
||||
|
||||
/*!
|
||||
Library to allow decoding of more complex values
|
||||
*/
|
||||
|
||||
namespace auto hex::dec {
|
||||
|
||||
/**
|
||||
Demangles a mangled name into a human readable name
|
||||
@param mangled_name The mangled name
|
||||
@return The demangled name
|
||||
*/
|
||||
fn demangle(str mangled_name) {
|
||||
return builtin::hex::dec::demangle(mangled_name);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
Decompresses the bytes of a pattern into a section using the zlib algorithm
|
||||
@param pattern The pattern whose bytes should be decompressed
|
||||
@param section The section to decompress the data into
|
||||
@param window_size The window size passed to zlib
|
||||
@return A value representing either the number of bytes decompressed or an error code from zlib
|
||||
*/
|
||||
fn zlib_decompress(ref auto pattern, std::mem::Section section, u64 window_size = 0) {
|
||||
return builtin::hex::dec::zlib_decompress(pattern, section, window_size);
|
||||
};
|
||||
|
||||
/**
|
||||
Decompresses the bytes of a pattern into a section using the bzip algorithm
|
||||
@param pattern The pattern whose bytes should be decompressed
|
||||
@param section The section to decompress the data into
|
||||
@return true if successful, false otherwise
|
||||
*/
|
||||
fn bzip_decompress(ref auto pattern, std::mem::Section section) {
|
||||
return builtin::hex::dec::bzip_decompress(pattern, section);
|
||||
};
|
||||
|
||||
/**
|
||||
Decompresses the bytes of a pattern into a section using the LZMA algorithm
|
||||
@param pattern The pattern whose bytes should be decompressed
|
||||
@param section The section to decompress the data into
|
||||
@return true if successful, false otherwise
|
||||
*/
|
||||
fn lzma_decompress(ref auto pattern, std::mem::Section section) {
|
||||
return builtin::hex::dec::lzma_decompress(pattern, section);
|
||||
};
|
||||
|
||||
/**
|
||||
Decompresses the bytes of a pattern into a section using the zstd algorithm
|
||||
@param pattern The pattern whose bytes should be decompressed
|
||||
@param section The section to decompress the data into
|
||||
@return true if successful, false otherwise
|
||||
*/
|
||||
fn zstd_decompress(ref auto pattern, std::mem::Section section) {
|
||||
return builtin::hex::dec::zstd_decompress(pattern, section);
|
||||
};
|
||||
|
||||
/**
|
||||
Decompresses the bytes of a pattern into a section using the lz4 algorithm
|
||||
@param pattern The pattern whose bytes should be decompressed
|
||||
@param section The section to decompress the data into
|
||||
@param frame Whether the data is framed or not
|
||||
@return true if successful, false otherwise
|
||||
*/
|
||||
fn lz4_decompress(ref auto pattern, std::mem::Section section, bool frame = true) {
|
||||
return builtin::hex::dec::lz4_decompress(pattern, section, frame);
|
||||
};
|
||||
|
||||
}
|
||||
@@ -1,9 +1,18 @@
|
||||
#pragma once
|
||||
|
||||
#include <hex/impl/imhex_check.pat>
|
||||
import hex.impl.imhex_check;
|
||||
|
||||
namespace hex::http {
|
||||
/*!
|
||||
Library to do HTTP requests
|
||||
*/
|
||||
|
||||
namespace auto hex::http {
|
||||
|
||||
/**
|
||||
Performs a HTTP GET request to the given URL and returns the response body
|
||||
@param url URL to perform the request to
|
||||
@return Response body
|
||||
*/
|
||||
fn get(str url) {
|
||||
return builtin::hex::http::get(url);
|
||||
};
|
||||
|
||||
43
includes/hex/provider.pat
Normal file
43
includes/hex/provider.pat
Normal file
@@ -0,0 +1,43 @@
|
||||
#pragma once
|
||||
|
||||
import hex.impl.imhex_check;
|
||||
|
||||
/*!
|
||||
Library to interact with the currently loaded provider.
|
||||
*/
|
||||
|
||||
namespace auto hex::prv {
|
||||
|
||||
|
||||
/**
|
||||
Queries information from the currently loaded provider. The kind of information that's available depends on the provider that's loaded
|
||||
|
||||
> **Available information**
|
||||
> - File Provider
|
||||
> - `file_path() -> str`
|
||||
> - `file_name() -> str`
|
||||
> - `file_extension() -> str`
|
||||
> - `creation_time() -> time_t`
|
||||
> - `access_time() -> time_t`
|
||||
> - `modification_time() -> time_t`
|
||||
> - `permissions() -> u16`
|
||||
> - Disk Provider
|
||||
> - `file_path() -> str`
|
||||
> - `sector_size() -> u128`
|
||||
> - GDB Provider
|
||||
> - `ip() -> str`
|
||||
> - `port() -> u16`
|
||||
> - Process Memory Provider
|
||||
> - `region_address(regionName) -> u64`
|
||||
> - `region_size(regionName) -> u64`
|
||||
> - `process_id() -> u32`
|
||||
> - `process_name() -> str`
|
||||
|
||||
@param category Information category
|
||||
@param argument Extra argument to pass along
|
||||
*/
|
||||
fn get_information(str category, str argument = "") {
|
||||
return builtin::hex::prv::get_information(category, argument);
|
||||
};
|
||||
|
||||
}
|
||||
28
includes/hex/type/encstr.pat
Normal file
28
includes/hex/type/encstr.pat
Normal file
@@ -0,0 +1,28 @@
|
||||
#pragma once
|
||||
|
||||
import hex.impl.imhex_check;
|
||||
|
||||
/*!
|
||||
Types to work with custom encoded strings using Thiny encoding definitions
|
||||
*/
|
||||
|
||||
namespace auto hex::type {
|
||||
|
||||
/**
|
||||
A string that was encoded using a custom encoding
|
||||
@tparam Data Pattern whose bytes are used in the decoding process
|
||||
@tparam EncodingDefinition A string containing a Thingy encoding definition as used by ImHex's custom encoding feature
|
||||
*/
|
||||
struct EncodedString<auto Data, auto EncodingDefinition> {
|
||||
builtin::hex::dec::EncodedString<Data, EncodingDefinition> string;
|
||||
} [[sealed, format("hex::type::impl::format_encoded_string")]];
|
||||
|
||||
namespace impl {
|
||||
|
||||
fn format_encoded_string(ref auto string) {
|
||||
return string.string;
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
143
includes/hex/type/instruction.pat
Normal file
143
includes/hex/type/instruction.pat
Normal file
@@ -0,0 +1,143 @@
|
||||
#pragma once
|
||||
|
||||
import hex.impl.imhex_check;
|
||||
|
||||
/*!
|
||||
Types to work with machine code
|
||||
*/
|
||||
|
||||
namespace auto hex::type {
|
||||
|
||||
/**
|
||||
A machine code instruction which will get disassembled
|
||||
@tparam DisassemblerSetting A string containing the config for the disassembler in the form of "architecture; setting1, setting2, no-setting3"
|
||||
@tparam SyntaxType Syntax used in the disassembly. Possible values are "intel", "at&t", "masm" and "motorola"
|
||||
@tparam ImageBaseAddress Start address of the instruction region in the data
|
||||
@tparam ImageLoadAddress Address where the instructions will be loaded into memory
|
||||
|
||||
Possible Values for DisassemblerSetting:
|
||||
- Architecture, all may be suffixed with le or be to specify endianess (e.g armbe or mipsle)
|
||||
- arm
|
||||
- thumb
|
||||
- aarch64
|
||||
- arm64
|
||||
- mips
|
||||
- x86
|
||||
- x86_64
|
||||
- x64
|
||||
- ppc
|
||||
- powerpc
|
||||
- sparc
|
||||
- sysz
|
||||
- xcore
|
||||
- m68k
|
||||
- m680x
|
||||
- tms320c64x
|
||||
- evm
|
||||
- wasm
|
||||
- riscv
|
||||
- mos65xx
|
||||
- bpf
|
||||
- sh
|
||||
- tricore
|
||||
|
||||
- Settings, not all settings make sense for each architecture. Prefixing settings with no- will remove them instead
|
||||
- 16bit
|
||||
- 32bit
|
||||
- 64bit
|
||||
- cortex-m
|
||||
- armv8
|
||||
- micromips
|
||||
- mips2
|
||||
- mips3
|
||||
- mips32r6
|
||||
- sparcv9
|
||||
- qpx
|
||||
- spe
|
||||
- ps
|
||||
- 68000
|
||||
- 68010
|
||||
- 68020
|
||||
- 68030
|
||||
- 68040
|
||||
- 68060
|
||||
- 6301
|
||||
- 6309
|
||||
- 6800
|
||||
- 6801
|
||||
- 6805
|
||||
- 6808
|
||||
- 6809
|
||||
- 6811
|
||||
- cpu12
|
||||
- hcs08
|
||||
- bpfe
|
||||
- rv32g
|
||||
- rv64g
|
||||
- riscvc
|
||||
- 6502
|
||||
- 65c02
|
||||
- w65c02
|
||||
- 65816
|
||||
- long-m
|
||||
- long-x
|
||||
- sh2
|
||||
- sh2a
|
||||
- sh3
|
||||
- sh4
|
||||
- sh4a
|
||||
- shfpu
|
||||
- shdsp
|
||||
- 1.1
|
||||
- 1.2
|
||||
- 1.3
|
||||
- 1.3.1
|
||||
- 1.6
|
||||
- 1.6.1
|
||||
- 1.6.2
|
||||
*/
|
||||
struct Instruction<auto DisassemblerSetting, auto SyntaxType, auto ImageBaseAddress, auto ImageLoadAddress> {
|
||||
builtin::hex::dec::Instruction<DisassemblerSetting, SyntaxType, ImageBaseAddress, ImageLoadAddress> instruction;
|
||||
} [[sealed, format("hex::type::impl::format_instruction")]];
|
||||
|
||||
/**
|
||||
A machine code instruction which will get disassembled using Intel syntax
|
||||
@tparam DisassemblerSetting A string containing the config for the disassembler in the form of "architecture; setting1, setting2, no-setting3"
|
||||
@tparam ImageBaseAddress Start address of the instruction region in the data
|
||||
@tparam ImageLoadAddress Address where the instructions will be loaded into memory
|
||||
*/
|
||||
using InstructionIntel<auto DisassemblerSetting, auto ImageBaseAddress, auto ImageLoadAddress> = Instruction<DisassemblerSetting, "intel", ImageBaseAddress, ImageLoadAddress>;
|
||||
|
||||
/**
|
||||
A machine code instruction which will get disassembled using AT&T syntax
|
||||
@tparam DisassemblerSetting A string containing the config for the disassembler in the form of "architecture; setting1, setting2, no-setting3"
|
||||
@tparam ImageBaseAddress Start address of the instruction region in the data
|
||||
@tparam ImageLoadAddress Address where the instructions will be loaded into memory
|
||||
*/
|
||||
using InstructionATNT<auto DisassemblerSetting, auto ImageBaseAddress, auto ImageLoadAddress> = Instruction<DisassemblerSetting, "at&t", ImageBaseAddress, ImageLoadAddress>;
|
||||
|
||||
/**
|
||||
A machine code instruction which will get disassembled using MASM syntax
|
||||
@tparam DisassemblerSetting A string containing the config for the disassembler in the form of "architecture; setting1, setting2, no-setting3"
|
||||
@tparam ImageBaseAddress Start address of the instruction region in the data
|
||||
@tparam ImageLoadAddress Address where the instructions will be loaded into memory
|
||||
*/
|
||||
using InstructionMASM<auto DisassemblerSetting, auto ImageBaseAddress, auto ImageLoadAddress> = Instruction<DisassemblerSetting, "masm", ImageBaseAddress, ImageLoadAddress>;
|
||||
|
||||
/**
|
||||
A machine code instruction which will get disassembled using Motorola syntax
|
||||
@tparam DisassemblerSetting A string containing the config for the disassembler in the form of "architecture; setting1, setting2, no-setting3"
|
||||
@tparam ImageBaseAddress Start address of the instruction region in the data
|
||||
@tparam ImageLoadAddress Address where the instructions will be loaded into memory
|
||||
*/
|
||||
using InstructionMotorola<auto DisassemblerSetting, auto ImageBaseAddress, auto ImageLoadAddress> = Instruction<DisassemblerSetting, "motorola", ImageBaseAddress, ImageLoadAddress>;
|
||||
|
||||
namespace impl {
|
||||
|
||||
fn format_instruction(ref auto instruction) {
|
||||
return instruction.instruction;
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
66
includes/hex/type/json.pat
Normal file
66
includes/hex/type/json.pat
Normal file
@@ -0,0 +1,66 @@
|
||||
#pragma once
|
||||
|
||||
import hex.impl.imhex_check;
|
||||
|
||||
/*!
|
||||
Types to decode JSON and JSON-like file formats into a pattern tree
|
||||
*/
|
||||
|
||||
namespace auto hex::type {
|
||||
|
||||
/**
|
||||
Type representing a JSON string
|
||||
@tparam Size size of the string
|
||||
*/
|
||||
struct Json<auto Size> {
|
||||
char __data[Size] [[hidden, no_unique_address]];
|
||||
builtin::hex::dec::Json<__data> json [[merge]];
|
||||
};
|
||||
|
||||
/**
|
||||
Type representing Bson data
|
||||
@tparam Size size of the data
|
||||
*/
|
||||
struct Bson<auto Size> {
|
||||
u8 __data[Size] [[hidden, no_unique_address]];
|
||||
builtin::hex::dec::Bson<__data> bson [[merge]];
|
||||
};
|
||||
|
||||
/**
|
||||
Type representing Cbor data
|
||||
@tparam Size size of the data
|
||||
*/
|
||||
struct Cbor<auto Size> {
|
||||
u8 __data[Size] [[hidden, no_unique_address]];
|
||||
builtin::hex::dec::Cbor<__data> cbor [[merge]];
|
||||
};
|
||||
|
||||
/**
|
||||
Type representing Bjdata data
|
||||
@tparam Size size of the data
|
||||
*/
|
||||
struct Bjdata<auto Size> {
|
||||
u8 __data[Size] [[hidden, no_unique_address]];
|
||||
builtin::hex::dec::Bjdata<__data> bjdata [[merge]];
|
||||
};
|
||||
|
||||
/**
|
||||
Type representing Msgpack data
|
||||
@tparam Size size of the data
|
||||
*/
|
||||
struct Msgpack<auto Size> {
|
||||
u8 __data[Size] [[hidden, no_unique_address]];
|
||||
builtin::hex::dec::Msgpack<__data> msgpack [[merge]];
|
||||
};
|
||||
|
||||
/**
|
||||
Type representing Ubjson data
|
||||
@tparam Size size of the data
|
||||
*/
|
||||
struct Ubjson<auto Size> {
|
||||
u8 __data[Size] [[hidden, no_unique_address]];
|
||||
builtin::hex::dec::Ubjson<__data> ubjson [[merge]];
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
30
includes/hex/type/mangled.pat
Normal file
30
includes/hex/type/mangled.pat
Normal file
@@ -0,0 +1,30 @@
|
||||
#pragma once
|
||||
|
||||
import std.io;
|
||||
import std.mem;
|
||||
|
||||
import hex.impl.imhex_check;
|
||||
import hex.dec;
|
||||
|
||||
/*!
|
||||
Types to automatically decode mangled names
|
||||
*/
|
||||
|
||||
namespace auto hex::type {
|
||||
|
||||
/**
|
||||
A mangled name string that gets demangled when displayed
|
||||
*/
|
||||
struct MangledName {
|
||||
char value[];
|
||||
} [[sealed, format("hex::type::impl::format_mangled_name")]];
|
||||
|
||||
namespace impl {
|
||||
|
||||
fn format_mangled_name(ref MangledName name) {
|
||||
return hex::dec::demangle(name.value);
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
68
includes/std/array.pat
Normal file
68
includes/std/array.pat
Normal file
@@ -0,0 +1,68 @@
|
||||
#pragma once
|
||||
|
||||
import std.sys;
|
||||
import std.core;
|
||||
|
||||
/*!
|
||||
The array library contains a helper type to make it easier to create multi-dimensional arrays
|
||||
and pass arrays to functions as parameters.
|
||||
|
||||
## Multi-dimensional arrays
|
||||
|
||||
The following example shows how to use multi-dimensional arrays with structs.
|
||||
|
||||
```rust
|
||||
import std.array;
|
||||
|
||||
struct File {
|
||||
u8 width, height;
|
||||
std::Array<std::Array<u8, parent.width>, height> cells;
|
||||
};
|
||||
|
||||
File file @ 0x00;
|
||||
```
|
||||
|
||||
*/
|
||||
|
||||
namespace auto std {
|
||||
|
||||
/**
|
||||
Simple one dimensional array wrapper
|
||||
@tparam T The array types
|
||||
@tparam Size Number of entries in the array
|
||||
*/
|
||||
struct Array<T, auto Size> {
|
||||
T data[Size] [[inline]];
|
||||
} [[format("std::impl::format_array")]];
|
||||
|
||||
/**
|
||||
Simple array wrapper for an array with a size in bytes
|
||||
@tparam T The array types
|
||||
@tparam NumBytes Number of bytes the array contains
|
||||
*/
|
||||
struct ByteSizedArray<T, auto NumBytes> {
|
||||
u64 startAddress = $;
|
||||
T array[while($ - startAddress < NumBytes)] [[inline]];
|
||||
|
||||
std::assert($ - startAddress == NumBytes, "Not enough bytes available to fit a whole number of types");
|
||||
} [[format("std::impl::format_array")]];
|
||||
|
||||
|
||||
/**
|
||||
An interface type for getting the index of the currently processed element in an array. This is a nice wrapper around `std::core::array_index()`
|
||||
|
||||
To use it, inherit from it and use the `this.index` field to get the index of the current element
|
||||
*/
|
||||
struct IIndexed {
|
||||
const u64 index = std::core::array_index();
|
||||
};
|
||||
|
||||
namespace impl {
|
||||
|
||||
fn format_array(ref auto array) {
|
||||
return "[ ... ]";
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
72
includes/std/attrs.pat
Normal file
72
includes/std/attrs.pat
Normal file
@@ -0,0 +1,72 @@
|
||||
#pragma once
|
||||
|
||||
import std.io;
|
||||
import std.core;
|
||||
|
||||
/*!
|
||||
The attributes library contains a set of attributes that can be used to annotate types with certain properties.
|
||||
To use an attribute, simply make your custom type inherit from the attribute type you want to use.
|
||||
|
||||
For example, to make a type hidden, you can use the `Hidden` attribute like this:
|
||||
|
||||
```rust
|
||||
struct MyType : std::attr::Hidden {
|
||||
// ...
|
||||
};
|
||||
```
|
||||
*/
|
||||
|
||||
namespace auto std::attr {
|
||||
|
||||
/**
|
||||
Attribute that marks a type as a literal type.
|
||||
This means the type behaves like a built-in type in the sense that it doesn't show its internal state and its display value is determined by a format function.
|
||||
It can also be transformed into a different built-in literal when used in an expression.
|
||||
@tparam FormatFunction The format function to use. The return value of this function is used to display the value of the literal and also determines the value returned when the literal is used in an expression.
|
||||
*/
|
||||
struct Literal<auto FormatFunction> { }
|
||||
[[sealed, format_read(FormatFunction), transform(FormatFunction)]];
|
||||
|
||||
/**
|
||||
Attribute that changes the name of the variable created from a type.
|
||||
@tparam Name The name of the variable created
|
||||
*/
|
||||
struct Named<auto Name> { }
|
||||
[[name(Name)]];
|
||||
|
||||
/**
|
||||
Attribute that adds a comment to the variable created from a type.
|
||||
@tparam Comment The comment to add
|
||||
*/
|
||||
struct Commented<auto Comment> {}
|
||||
[[comment(Comment)]];
|
||||
|
||||
/**
|
||||
Attribute that marks a type as hidden.
|
||||
This means variables of this type are not displayed in the UI.
|
||||
*/
|
||||
struct Hidden {}
|
||||
[[hidden]];
|
||||
|
||||
/**
|
||||
Attribute that marks a type as hidden and also hides it from the highlighter.
|
||||
This means variables of this type are don't display any highlighting in the UI but are still visible.
|
||||
*/
|
||||
struct HighlightHidden {}
|
||||
[[highlight_hidden]];
|
||||
|
||||
/**
|
||||
Attribute that marks a type as inline.
|
||||
Creating a variable of this type will not create a new layer but instead dump the contents of the type directly into the current layer.
|
||||
*/
|
||||
struct Inlined {}
|
||||
[[inline]];
|
||||
|
||||
/**
|
||||
Attribute that marks a type as sealed.
|
||||
Sealed types don't display their internal state in the UI.
|
||||
*/
|
||||
struct Sealed {}
|
||||
[[sealed]];
|
||||
|
||||
}
|
||||
@@ -1,39 +1,67 @@
|
||||
#pragma once
|
||||
|
||||
#include <std/limits.pat>
|
||||
import std.limits;
|
||||
|
||||
namespace std::bit {
|
||||
/*!
|
||||
This library contains various helper functions for common bit operations.
|
||||
*/
|
||||
|
||||
fn popcount(u128 x) {
|
||||
x = (x & (std::limits::u128_max() / 3)) + ((x >> 1) & (std::limits::u128_max() / 3));
|
||||
x = (x & (std::limits::u128_max() / 5)) + ((x >> 2) & (std::limits::u128_max() / 5));
|
||||
x = (x & (std::limits::u128_max() / 17)) + ((x >> 4) & (std::limits::u128_max() / 17));
|
||||
|
||||
return x % 0xFF;
|
||||
};
|
||||
namespace auto std::bit {
|
||||
|
||||
fn has_single_bit(u128 x) {
|
||||
return x != 0 && (x & (x - 1)) == 0;
|
||||
};
|
||||
|
||||
fn bit_ceil(u128 x) {
|
||||
if (x == 0) return 0;
|
||||
|
||||
u8 i;
|
||||
while ((1 << i) < x)
|
||||
i = i + 1;
|
||||
|
||||
return 1 << i;
|
||||
};
|
||||
|
||||
fn bit_floor(u128 x) {
|
||||
if (x == 0) return 0;
|
||||
|
||||
u8 i;
|
||||
while ((x >> i) > 0)
|
||||
i = i + 1;
|
||||
|
||||
return 1 << (i - 1);
|
||||
};
|
||||
/**
|
||||
Calculates the number of 1 bits in a given number
|
||||
@param x The number
|
||||
@return The number of bits set to 1 in `x`
|
||||
*/
|
||||
fn popcount(u128 x) {
|
||||
const u128 a = 0x55555555555555555555555555555555;
|
||||
const u128 b = 0x33333333333333333333333333333333;
|
||||
const u128 c = 0x0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F;
|
||||
|
||||
x = (x & a) + ((x >> 1) & a);
|
||||
x = (x & b) + ((x >> 2) & b);
|
||||
x = (x & c) + ((x >> 4) & c);
|
||||
|
||||
return x % 0xFF;
|
||||
};
|
||||
|
||||
/**
|
||||
Checks if only a single bit is set to 1 in a given number
|
||||
@param x The number
|
||||
@return True if there's a single bit set to 1 in `x`, false otherwise
|
||||
*/
|
||||
fn has_single_bit(u128 x) {
|
||||
return x != 0 && (x & (x - 1)) == 0;
|
||||
};
|
||||
|
||||
/**
|
||||
Rounds the given number up to the next bigger power of two
|
||||
@param x The number
|
||||
@return Next bigger power of two that can fit `x`
|
||||
*/
|
||||
fn bit_ceil(u128 x) {
|
||||
if (x == 0) return 0;
|
||||
|
||||
u8 i;
|
||||
while ((1 << i) < x)
|
||||
i = i + 1;
|
||||
|
||||
return 1 << i;
|
||||
};
|
||||
|
||||
/**
|
||||
Rounds the given number down to the next bigger power of two
|
||||
@param x The number
|
||||
@return Next smaller power of two
|
||||
*/
|
||||
fn bit_floor(u128 x) {
|
||||
if (x == 0) return 0;
|
||||
|
||||
u8 i;
|
||||
while ((x >> i) > 0)
|
||||
i = i + 1;
|
||||
|
||||
return 1 << (i - 1);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -1,57 +1,192 @@
|
||||
#pragma once
|
||||
|
||||
#include <std/mem.pat>
|
||||
import std.mem;
|
||||
|
||||
namespace std::core {
|
||||
/*!
|
||||
The core library contains intrinsics and "compiler magic" functions that
|
||||
get extra help from the runtime to fulfill their purpose.
|
||||
*/
|
||||
|
||||
namespace auto std::core {
|
||||
|
||||
/**
|
||||
The layout order of each field after byte-endianness has been handled.
|
||||
|
||||
`LeftToRight` and `RightToLeft` are deprecated in favor of the clearer `MostToLeastSignificant` and `LeastToMostSignificant` names.
|
||||
*/
|
||||
enum BitfieldOrder : u8 {
|
||||
/**
|
||||
@warning deprecated
|
||||
*/
|
||||
LeftToRight = 0,
|
||||
RightToLeft = 1
|
||||
/**
|
||||
@warning deprecated
|
||||
*/
|
||||
RightToLeft = 1,
|
||||
MostToLeastSignificant = 0,
|
||||
LeastToMostSignificant = 1
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
Checks if a pattern has a specific attribute assigned to it
|
||||
@param pattern The pattern to check
|
||||
@param attribute The attribute's name to check for
|
||||
*/
|
||||
fn has_attribute(ref auto pattern, str attribute) {
|
||||
return builtin::std::core::has_attribute(pattern, attribute);
|
||||
};
|
||||
|
||||
/**
|
||||
Returns the nth parameter of the attribute of a pattern if it has one
|
||||
@param pattern The pattern to check
|
||||
@param attribute The attribute's name to query
|
||||
@param [index] The parameter index of the attribute to return. Defaults to 0
|
||||
*/
|
||||
fn get_attribute_argument(ref auto pattern, str attribute, u32 index = 0) {
|
||||
return builtin::std::core::get_attribute_argument(pattern, attribute, index);
|
||||
};
|
||||
|
||||
/**
|
||||
@warning Removed in 1.27.0
|
||||
*/
|
||||
fn get_attribute_value(ref auto pattern, str attribute) {
|
||||
return builtin::std::core::get_attribute_value(pattern, attribute);
|
||||
builtin::std::error("`std::core::get_attribute_value(pattern, attribute)` has been removed.\nUse `std::core::get_attribute_argument(pattern, attribute, [index])` instead.");
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
Sets the current default endianness.
|
||||
Any patterns created following this attribute will be created using the set endianness.
|
||||
@param endian The new default endianness
|
||||
*/
|
||||
fn set_endian(std::mem::Endian endian) {
|
||||
builtin::std::core::set_endian(u32(endian));
|
||||
};
|
||||
|
||||
/**
|
||||
Gets the current default endianness.
|
||||
@return The currently set default endianness
|
||||
*/
|
||||
fn get_endian() {
|
||||
return builtin::std::core::get_endian();
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
@warning Removed in 1.28.0
|
||||
*/
|
||||
fn set_bitfield_order(BitfieldOrder order) {
|
||||
builtin::std::core::set_bitfield_order(order);
|
||||
builtin::std::error("Runtime default bitfield order is no longer supported.\nConsider using `be` or `le` on your bitfield variables,\nor attach attribute `bitfield_order` to the bitfield.");
|
||||
};
|
||||
|
||||
/**
|
||||
@warning Removed in 1.28.0
|
||||
*/
|
||||
fn get_bitfield_order() {
|
||||
return builtin::std::core::get_bitfield_order();
|
||||
builtin::std::error("Runtime default bitfield order is no longer supported.\nConsider using `be` or `le` on your bitfield variables,\nor attach attribute `bitfield_order` to the bitfield.");
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
When used inside of a pattern that's being created using a pattern,
|
||||
returns the current array index that's being processed.
|
||||
If used outside of an array, always yields 0.
|
||||
@return The current array index
|
||||
*/
|
||||
fn array_index() {
|
||||
return builtin::std::core::array_index();
|
||||
};
|
||||
|
||||
/**
|
||||
Queries the number of members of a struct, union or bitfield or the number of entries in an array
|
||||
@param pattern The pattern to check
|
||||
@return The number of members in `pattern`
|
||||
*/
|
||||
fn member_count(ref auto pattern) {
|
||||
return builtin::std::core::member_count(pattern);
|
||||
};
|
||||
|
||||
/**
|
||||
Checks whether or not a given pattern has a member with a given name
|
||||
@param pattern The pattern to check
|
||||
@param name The name of the member to look for
|
||||
@return True if a member called `name` exists, false otherwise
|
||||
*/
|
||||
fn has_member(ref auto pattern, str name) {
|
||||
return builtin::std::core::has_member(pattern, name);
|
||||
};
|
||||
|
||||
/**
|
||||
Formats a pattern using it's default formatter or its custom formatter function set through
|
||||
the `[[format]]` or `[[format_read]]` attribute
|
||||
@param pattern The pattern to format
|
||||
@return Formatted string representation of `pattern`
|
||||
*/
|
||||
fn formatted_value(ref auto pattern) {
|
||||
return builtin::std::core::formatted_value(pattern);
|
||||
};
|
||||
|
||||
/**
|
||||
Checks if the given enum value corresponds has a corresponding constant
|
||||
@param pattern The enum value to check
|
||||
@return True if pattern has a valid enum representation, false if not
|
||||
*/
|
||||
fn is_valid_enum(ref auto pattern) {
|
||||
return builtin::std::core::is_valid_enum(pattern);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
Changes the color of the given pattern to a new color
|
||||
@param pattern The pattern to modify
|
||||
@param color The RGBA8 color
|
||||
*/
|
||||
fn set_pattern_color(ref auto pattern, u32 color) {
|
||||
builtin::std::core::set_pattern_color(pattern, color);
|
||||
};
|
||||
|
||||
/**
|
||||
Changes the display name of a given pattern
|
||||
@param pattern The pattern to modify
|
||||
@param name The new display name of the pattern
|
||||
*/
|
||||
fn set_display_name(ref auto pattern, str name) {
|
||||
builtin::std::core::set_display_name(pattern, name);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
Changes the comment attached to a pattern
|
||||
@param pattern The pattern to modify
|
||||
@param comment The new comment of the pattern
|
||||
*/
|
||||
fn set_pattern_comment(ref auto pattern, str comment) {
|
||||
builtin::std::core::set_pattern_comment(pattern, comment);
|
||||
};
|
||||
|
||||
/**
|
||||
Executes the function with the given name, passing in all given arguments
|
||||
@param function_name The namespace-prefixed name of the function
|
||||
@param args Arguments to pass to the function
|
||||
*/
|
||||
fn execute_function(str function_name, auto ... args) {
|
||||
builtin::std::core::execute_function(function_name, args);
|
||||
};
|
||||
|
||||
/**
|
||||
Sets the pattern color palette for all future created patterns
|
||||
@param args RGBA8 colors as 32 bit integers (0xAABBGGRR)
|
||||
*/
|
||||
fn set_pattern_palette_colors(auto ... colors) {
|
||||
builtin::std::core::set_pattern_palette_colors(colors);
|
||||
};
|
||||
|
||||
/**
|
||||
Resets the current pattern palette progress back to zero.
|
||||
This can be useful to force all instances of a type to have the same coloring for its members
|
||||
*/
|
||||
fn reset_pattern_palette() {
|
||||
builtin::std::core::reset_pattern_palette();
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,51 +1,116 @@
|
||||
#pragma once
|
||||
|
||||
namespace std::ctype {
|
||||
/*!
|
||||
The ctype library has functions to check if a character is part of a specific category
|
||||
of ASCII characters.
|
||||
*/
|
||||
|
||||
namespace auto std::ctype {
|
||||
|
||||
/**
|
||||
Checks if the given character `c` is a digit between '0' and '9'
|
||||
@param c The character to check
|
||||
@return True if `c` is part of this range, false otherwise
|
||||
*/
|
||||
fn isdigit(char c) {
|
||||
return c >= '0' && c <= '9';
|
||||
};
|
||||
|
||||
/**
|
||||
Checks if the given character `c` is a hexadecimal digit between '0' and '9', `A` and `F` or `a` and `f`
|
||||
@param c The character to check
|
||||
@return True if `c` is part of this range, false otherwise
|
||||
*/
|
||||
fn isxdigit(char c) {
|
||||
return std::ctype::isdigit(c) || (c >= 'A' && c <= 'F') || (c >= 'a' && c <= 'f');
|
||||
};
|
||||
|
||||
/**
|
||||
Checks if the given character `c` is a upper case letter between 'A' and 'Z'
|
||||
@param c The character to check
|
||||
@return True if `c` is part of this range, false otherwise
|
||||
*/
|
||||
fn isupper(char c) {
|
||||
return c >= 'A' && c <= 'Z';
|
||||
};
|
||||
|
||||
/**
|
||||
Checks if the given character `c` is a lower case letter between 'a' and 'z'
|
||||
@param c The character to check
|
||||
@return True if `c` is part of this range, false otherwise
|
||||
*/
|
||||
fn islower(char c) {
|
||||
return c >= 'a' && c <= 'z';
|
||||
};
|
||||
|
||||
/**
|
||||
Checks if the given character `c` is either a upper or lower case letter between 'A' and 'Z' or 'a' and 'z'
|
||||
@param c The character to check
|
||||
@return True if `c` is part of this range, false otherwise
|
||||
*/
|
||||
fn isalpha(char c) {
|
||||
return std::ctype::isupper(c) || std::ctype::islower(c);
|
||||
};
|
||||
|
||||
/**
|
||||
Checks if the given character `c` is a upper or lower case letter or a number
|
||||
@param c The character to check
|
||||
@return True if `c` is part of this range, false otherwise
|
||||
*/
|
||||
fn isalnum(char c) {
|
||||
return std::ctype::isalpha(c) || std::ctype::isdigit(c);
|
||||
};
|
||||
|
||||
/**
|
||||
Checks if the given character `c` is a space character
|
||||
@param c The character to check
|
||||
@return True if `c` is part of this range, false otherwise
|
||||
*/
|
||||
fn isspace(char c) {
|
||||
return (c >= 0x09 && c <= 0x0D) || c == 0x20;
|
||||
};
|
||||
|
||||
/**
|
||||
Checks if the given character `c` is a invisible character
|
||||
@param c The character to check
|
||||
@return True if `c` is part of this range, false otherwise
|
||||
*/
|
||||
fn isblank(char c) {
|
||||
return c == 0x09 || c == ' ';
|
||||
};
|
||||
|
||||
/**
|
||||
Checks if the given character `c` has a printable glyph
|
||||
@param c The character to check
|
||||
@return True if `c` is part of this range, false otherwise
|
||||
*/
|
||||
fn isprint(char c) {
|
||||
return c >= '0' && c <= '~';
|
||||
return c >= ' ' && c <= '~';
|
||||
};
|
||||
|
||||
/**
|
||||
Checks if the given character `c` is a control code
|
||||
@param c The character to check
|
||||
@return True if `c` is part of this range, false otherwise
|
||||
*/
|
||||
fn iscntrl(char c) {
|
||||
return !std::ctype::isprint(c);
|
||||
};
|
||||
|
||||
/**
|
||||
Checks if the given character `c` has a visible glyph
|
||||
@param c The character to check
|
||||
@return True if `c` is part of this range, false otherwise
|
||||
*/
|
||||
fn isgraph(char c) {
|
||||
return std::ctype::isprint(c) && !std::ctype::isspace(c);
|
||||
};
|
||||
|
||||
/**
|
||||
Checks if the given character `c` is a punctuation character
|
||||
@param c The character to check
|
||||
@return True if `c` is part of this range, false otherwise
|
||||
*/
|
||||
fn ispunct(char c) {
|
||||
return std::ctype::isgraph(c) && !std::ctype::isalnum(c);
|
||||
};
|
||||
|
||||
@@ -1,49 +1,120 @@
|
||||
#pragma once
|
||||
|
||||
namespace std::file {
|
||||
/*!
|
||||
The File library allows reading and writing from/to external files using
|
||||
a C-like File IO API.
|
||||
|
||||
using Handle = s32;
|
||||
|
||||
enum Mode : u8 {
|
||||
Read = 1,
|
||||
Write = 2,
|
||||
Create = 3
|
||||
};
|
||||
**These functions are considered dangerous and require the user to manually permit them**
|
||||
*/
|
||||
|
||||
namespace auto std::file {
|
||||
|
||||
/**
|
||||
A handle representing a file that has been opened
|
||||
*/
|
||||
using Handle = s32;
|
||||
|
||||
/**
|
||||
The mode to open a file in.
|
||||
Read opens the file in read-only mode
|
||||
Write opens the file in read and write mode
|
||||
Create creates a new file if it doesn't exist and overwrites an existing file
|
||||
*/
|
||||
enum Mode : u8 {
|
||||
Read = 1,
|
||||
Write = 2,
|
||||
Create = 3
|
||||
};
|
||||
|
||||
|
||||
fn open(str path, Mode mode) {
|
||||
return builtin::std::file::open(path, u32(mode));
|
||||
};
|
||||
/**
|
||||
Opens a file
|
||||
@param path The path to the file to open
|
||||
@param mode File open mode
|
||||
@return Handle to the newly opened file
|
||||
*/
|
||||
fn open(str path, Mode mode) {
|
||||
return builtin::std::file::open(path, u32(mode));
|
||||
};
|
||||
|
||||
fn close(Handle handle) {
|
||||
builtin::std::file::close(handle);
|
||||
};
|
||||
|
||||
|
||||
fn read(Handle handle, u64 size) {
|
||||
return builtin::std::file::read(handle, size);
|
||||
};
|
||||
|
||||
fn write(Handle handle, str data) {
|
||||
return builtin::std::file::write(handle, data);
|
||||
};
|
||||
/**
|
||||
Closes a file handle that has been opened previously
|
||||
@param handle The handle to close
|
||||
*/
|
||||
fn close(Handle handle) {
|
||||
builtin::std::file::close(handle);
|
||||
};
|
||||
|
||||
|
||||
fn size(Handle handle) {
|
||||
return builtin::std::file::size(handle);
|
||||
};
|
||||
/**
|
||||
Reads the content of a file into a string
|
||||
@param handle The file handle to read from
|
||||
@param size Number of bytes to read
|
||||
@return String containing the read data
|
||||
*/
|
||||
fn read(Handle handle, u64 size) {
|
||||
return builtin::std::file::read(handle, size);
|
||||
};
|
||||
|
||||
fn resize(Handle handle, u64 size) {
|
||||
builtin::std::file::resize(handle, size);
|
||||
};
|
||||
/**
|
||||
Writes the content of a string into a file
|
||||
@param handle The file handle to write to
|
||||
@param data String or Pattern to write to the file
|
||||
*/
|
||||
fn write(Handle handle, auto data) {
|
||||
builtin::std::file::write(handle, data);
|
||||
};
|
||||
|
||||
fn flush(Handle handle) {
|
||||
builtin::std::file::remove(handle);
|
||||
};
|
||||
/**
|
||||
Sets the current cursor position in the given file handle
|
||||
@param handle The file handle to set the cursor position in
|
||||
@param offset The offset to move the cursor to
|
||||
*/
|
||||
fn seek(Handle handle, u64 offset) {
|
||||
builtin::std::file::seek(handle, offset);
|
||||
};
|
||||
|
||||
|
||||
fn remove(Handle handle) {
|
||||
builtin::std::file::remove(handle);
|
||||
};
|
||||
/**
|
||||
Queries the size of a file
|
||||
@param handle The handle of the file to get the size of
|
||||
@return The file's size
|
||||
*/
|
||||
fn size(Handle handle) {
|
||||
return builtin::std::file::size(handle);
|
||||
};
|
||||
|
||||
/**
|
||||
Resizes a file
|
||||
@param handle The handle of the file to resize
|
||||
*/
|
||||
fn resize(Handle handle, u64 size) {
|
||||
builtin::std::file::resize(handle, size);
|
||||
};
|
||||
|
||||
/**
|
||||
Flushes changes made to a file to disk
|
||||
@param handle The handle of the file to flush
|
||||
*/
|
||||
fn flush(Handle handle) {
|
||||
builtin::std::file::flush(handle);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
Deletes a file from disk. This will also automatically close this file
|
||||
@param handle The handle of the file to delete
|
||||
*/
|
||||
fn remove(Handle handle) {
|
||||
builtin::std::file::remove(handle);
|
||||
};
|
||||
|
||||
/**
|
||||
Create all directories for the provided path
|
||||
@param path The path for which all directories should be created
|
||||
*/
|
||||
fn create_directories(str path) {
|
||||
builtin::std::file::create_directories(path);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -1,35 +1,89 @@
|
||||
#pragma once
|
||||
|
||||
namespace std::fxpt {
|
||||
/*!
|
||||
Library for doing arithmetic with fixed point numbers and converting them from/to floating point numbers.
|
||||
*/
|
||||
|
||||
using fixed = s128;
|
||||
namespace auto std::fxpt {
|
||||
|
||||
fn to_float(fixed fxt, u32 precision) {
|
||||
return double(fxt) / double((1 << precision));
|
||||
};
|
||||
|
||||
fn to_fixed(double flt, u32 precision) {
|
||||
return fixed((flt * (1 << precision)));
|
||||
};
|
||||
/**
|
||||
A fixed point value
|
||||
*/
|
||||
using fixed = s128;
|
||||
|
||||
fn change_precision(fixed value, u32 start_precision, u32 end_precision) {
|
||||
return std::fxpt::to_fixed(std::fxpt::to_float(value, start_precision), end_precision);
|
||||
};
|
||||
|
||||
fn add(fixed a, fixed b, u32 precision) {
|
||||
return a + b;
|
||||
};
|
||||
|
||||
fn subtract(fixed a, fixed b, u32 precision) {
|
||||
return a - b;
|
||||
};
|
||||
|
||||
fn multiply(fixed a, fixed b, u32 precision) {
|
||||
return (a * b) / (1 << precision);
|
||||
};
|
||||
|
||||
fn divide(fixed a, fixed b, u32 precision) {
|
||||
return (a << precision) / b;
|
||||
};
|
||||
/**
|
||||
Converts a fixed point value into a floating point value
|
||||
@param fxt The fixed point value to convert
|
||||
@param precision The bits of precision the new value should have
|
||||
@return The floating point representation of fxt
|
||||
*/
|
||||
fn to_float(fixed fxt, u32 precision) {
|
||||
return double(fxt) / double((1 << precision));
|
||||
};
|
||||
|
||||
/**
|
||||
Converts a floating point value into a fixed point value
|
||||
@param flt The floating point value to convert
|
||||
@param precision The bits of precision the new value should have
|
||||
@return The fixed point representation of flt
|
||||
*/
|
||||
fn to_fixed(double flt, u32 precision) {
|
||||
return s128((flt * (1 << precision)));
|
||||
};
|
||||
|
||||
/**
|
||||
Changes the number of bits used to represent the decimal part of the given fixed point number
|
||||
@param value The fixed point value to convert
|
||||
@param start_precision The current number of bits used
|
||||
@param end_precision The new number of bits used
|
||||
@return `value` as a new fixed point number with `end_precision` bits of precision
|
||||
*/
|
||||
fn change_precision(fixed value, u32 start_precision, u32 end_precision) {
|
||||
return std::fxpt::to_fixed(std::fxpt::to_float(value, start_precision), end_precision);
|
||||
};
|
||||
|
||||
/**
|
||||
Adds two fixed point numbers with a given precision together
|
||||
@param a First fixed point number
|
||||
@param b Second fixed point number
|
||||
@param precision The precision of `a` and `b`
|
||||
@return Result of the addition of `a` and `b`
|
||||
*/
|
||||
fn add(fixed a, fixed b, u32 precision) {
|
||||
return a + b;
|
||||
};
|
||||
|
||||
/**
|
||||
Subtracts two fixed point numbers with a given precision together
|
||||
@param a First fixed point number
|
||||
@param b Second fixed point number
|
||||
@param precision The precision of `a` and `b`
|
||||
@return Result of the subtraction of `a` and `b`
|
||||
*/
|
||||
fn subtract(fixed a, fixed b, u32 precision) {
|
||||
return a - b;
|
||||
};
|
||||
|
||||
/**
|
||||
Multiplies two fixed point numbers with a given precision together
|
||||
@param a First fixed point number
|
||||
@param b Second fixed point number
|
||||
@param precision The precision of `a` and `b`
|
||||
@return Result of the multiplication of `a` and `b`
|
||||
*/
|
||||
fn multiply(fixed a, fixed b, u32 precision) {
|
||||
return (a * b) / (1 << precision);
|
||||
};
|
||||
|
||||
/**
|
||||
Divides two fixed point numbers with a given precision together
|
||||
@param a First fixed point number
|
||||
@param b Second fixed point number
|
||||
@param precision The precision of `a` and `b`
|
||||
@return Result of the division of `a` and `b`
|
||||
*/
|
||||
fn divide(fixed a, fixed b, u32 precision) {
|
||||
return (a << precision) / b;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -1,29 +1,65 @@
|
||||
#pragma once
|
||||
|
||||
namespace std::hash {
|
||||
/*!
|
||||
The hash library contains various data hash functions
|
||||
*/
|
||||
|
||||
fn crc32(u128 address, u64 size, u32 init, u32 poly) {
|
||||
u8 byte;
|
||||
u32 crc, mask;
|
||||
|
||||
crc = init;
|
||||
|
||||
u64 i;
|
||||
while (i < size) {
|
||||
byte = std::mem::read_unsigned(address + i, 1);
|
||||
crc = crc ^ byte;
|
||||
|
||||
u8 j;
|
||||
while (j < 8) {
|
||||
mask = u32(-(crc & 1));
|
||||
crc = (crc >> 1) ^ (poly & mask);
|
||||
j = j + 1;
|
||||
}
|
||||
|
||||
i = i + 1;
|
||||
}
|
||||
|
||||
return u32(~crc);
|
||||
namespace auto std::hash {
|
||||
|
||||
/**
|
||||
Calculates the CRC8 hash of the bytes inside of a given pattern
|
||||
@param pattern The pattern to calculate the CRC8 hash of
|
||||
@param init The CRC8 init value
|
||||
@param poly The CRC8 polynomial
|
||||
@param xorout The CRC8 XOR-Out value
|
||||
@param reflect_in Whether or not the input bytes should be reflected
|
||||
@param reflect_out Whether or not the output should be reflected
|
||||
@return Calculated CRC8 hash
|
||||
*/
|
||||
fn crc8(ref auto pattern, u8 init, u8 poly, u8 xorout, bool reflect_in, bool reflect_out) {
|
||||
return builtin::std::hash::crc8(pattern, init, poly, xorout, reflect_in, reflect_out);
|
||||
};
|
||||
|
||||
/**
|
||||
Calculates the CRC16 hash of the bytes inside of a given pattern
|
||||
@param pattern The pattern to calculate the CRC16 hash of
|
||||
@param init The CRC16 init value
|
||||
@param poly The CRC16 polynomial
|
||||
@param xorout The CRC16 XOR-Out value
|
||||
@param reflect_in Whether or not the input bytes should be reflected
|
||||
@param reflect_out Whether or not the output should be reflected
|
||||
@return Calculated CRC16 hash
|
||||
*/
|
||||
fn crc16(ref auto pattern, u16 init, u16 poly, u16 xorout, bool reflect_in, bool reflect_out) {
|
||||
return builtin::std::hash::crc16(pattern, init, poly, xorout, reflect_in, reflect_out);
|
||||
};
|
||||
|
||||
/**
|
||||
Calculates the CRC32 hash of the bytes inside of a given pattern
|
||||
@param pattern The pattern to calculate the CRC32 hash of
|
||||
@param init The CRC32 init value
|
||||
@param poly The CRC32 polynomial
|
||||
@param xorout The CRC32 XOR-Out value
|
||||
@param reflect_in Whether or not the input bytes should be reflected
|
||||
@param reflect_out Whether or not the output should be reflected
|
||||
@return Calculated CRC32 hash
|
||||
*/
|
||||
fn crc32(ref auto pattern, u32 init, u32 poly, u32 xorout, bool reflect_in, bool reflect_out) {
|
||||
return builtin::std::hash::crc32(pattern, init, poly, xorout, reflect_in, reflect_out);
|
||||
};
|
||||
|
||||
/**
|
||||
Calculates the CRC64 hash of the bytes inside of a given pattern
|
||||
@param pattern The pattern to calculate the CRC64 hash of
|
||||
@param init The CRC64 init value
|
||||
@param poly The CRC64 polynomial
|
||||
@param xorout The CRC64 XOR-Out value
|
||||
@param reflect_in Whether or not the input bytes should be reflected
|
||||
@param reflect_out Whether or not the output should be reflected
|
||||
@return Calculated CRC64 hash
|
||||
*/
|
||||
fn crc64(ref auto pattern, u64 init, u64 poly, u64 xorout, bool reflect_in, bool reflect_out) {
|
||||
return builtin::std::hash::crc64(pattern, init, poly, xorout, reflect_in, reflect_out);
|
||||
};
|
||||
|
||||
}
|
||||
@@ -1,20 +1,45 @@
|
||||
#pragma once
|
||||
|
||||
namespace std {
|
||||
/*!
|
||||
The IO library allows formatting strings and outputting text to the console
|
||||
*/
|
||||
|
||||
fn print(str fmt, auto ... args) {
|
||||
namespace auto std {
|
||||
|
||||
/**
|
||||
Formats the given arguments using the format string and prints the result to the console
|
||||
This function uses the C++20 `std::format` or libfmt's `fmt::format` syntax.
|
||||
@param fmt Format string or any other value that can be converted to a string
|
||||
@param args Values to use in the formatting
|
||||
*/
|
||||
fn print(auto fmt, auto ... args) {
|
||||
builtin::std::print(fmt, args);
|
||||
};
|
||||
|
||||
fn format(str fmt, auto ... args) {
|
||||
/**
|
||||
Formats the given arguments using the format string and returns the result as a string
|
||||
This function uses the C++20 `std::format` or libfmt's `fmt::format` syntax.
|
||||
@param fmt Format string or any other value that can be converted to a string
|
||||
@param args Values to use in the formatting
|
||||
@return The formatted string
|
||||
*/
|
||||
fn format(auto fmt, auto ... args) {
|
||||
return builtin::std::format(fmt, args);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
Aborts evaluation of the code immediately and prints a error message to the console
|
||||
@param message The message to print
|
||||
*/
|
||||
fn error(str message) {
|
||||
builtin::std::error(message);
|
||||
};
|
||||
|
||||
/**
|
||||
Prints a warning message to the console
|
||||
@param message The message to print
|
||||
*/
|
||||
fn warning(str message) {
|
||||
builtin::std::warning(message);
|
||||
};
|
||||
|
||||
@@ -1,85 +1,169 @@
|
||||
#pragma once
|
||||
|
||||
namespace std::limits {
|
||||
|
||||
fn u8_min() {
|
||||
return u8(0);
|
||||
};
|
||||
|
||||
fn u8_max() {
|
||||
return u8(-1);
|
||||
};
|
||||
/*!
|
||||
Library to calculate the minimum and maximum values that fit into a given data type
|
||||
*/
|
||||
|
||||
namespace auto std::limits {
|
||||
|
||||
/**
|
||||
Returns the minimum value that can be stored in a `u8`.
|
||||
@return Minimum value
|
||||
*/
|
||||
fn u8_min() {
|
||||
return u8(0);
|
||||
};
|
||||
|
||||
/**
|
||||
Returns the maximum value that can be stored in a `u8`.
|
||||
@return Maximum value
|
||||
*/
|
||||
fn u8_max() {
|
||||
return u8(-1);
|
||||
};
|
||||
|
||||
/**
|
||||
Returns the minimum value that can be stored in a `s8`.
|
||||
@return Minimum value
|
||||
*/
|
||||
fn s8_min() {
|
||||
return -s8((std::limits::u8_max() / 2)) - 1;
|
||||
};
|
||||
|
||||
fn s8_max() {
|
||||
return s8((u8_max() / 2));
|
||||
};
|
||||
return -s8((std::limits::u8_max() / 2)) - 1;
|
||||
};
|
||||
|
||||
fn u16_min() {
|
||||
return u16(0);
|
||||
};
|
||||
|
||||
fn u16_max() {
|
||||
return u16(-1);
|
||||
};
|
||||
|
||||
fn s16_min() {
|
||||
return -s16((std::limits::u16_max() / 2)) - 1;
|
||||
};
|
||||
|
||||
fn s16_max() {
|
||||
return s16((u16_max() / 2));
|
||||
};
|
||||
|
||||
fn u32_min() {
|
||||
return u32(0);
|
||||
};
|
||||
|
||||
fn u32_max() {
|
||||
return u32(-1);
|
||||
};
|
||||
|
||||
fn s32_min() {
|
||||
return -s32((std::limits::u32_max() / 2)) - 1;
|
||||
};
|
||||
|
||||
fn s32_max() {
|
||||
return s32((u32_max() / 2));
|
||||
};
|
||||
|
||||
fn u64_min() {
|
||||
return u64(0);
|
||||
};
|
||||
|
||||
fn u64_max() {
|
||||
return u64(-1);
|
||||
};
|
||||
|
||||
fn s64_min() {
|
||||
return -s64((std::limits::u64_max() / 2)) - 1;
|
||||
};
|
||||
|
||||
fn s64_max() {
|
||||
return s64((u64_max() / 2));
|
||||
};
|
||||
|
||||
fn u128_min() {
|
||||
return u128(0);
|
||||
};
|
||||
|
||||
fn u128_max() {
|
||||
return u128(-1);
|
||||
};
|
||||
|
||||
fn s128_min() {
|
||||
return -s128((std::limits::u128_max() / 2)) - 1;
|
||||
};
|
||||
|
||||
fn s128_max() {
|
||||
return s128((u128_max() / 2));
|
||||
};
|
||||
|
||||
}
|
||||
/**
|
||||
Returns the maximum value that can be stored in a `s8`.
|
||||
@return Maximum value
|
||||
*/
|
||||
fn s8_max() {
|
||||
return s8((std::limits::u8_max() / 2));
|
||||
};
|
||||
|
||||
/**
|
||||
Returns the minimum value that can be stored in a `u16`.
|
||||
@return Minimum value
|
||||
*/
|
||||
fn u16_min() {
|
||||
return u16(0);
|
||||
};
|
||||
|
||||
/**
|
||||
Returns the maximum value that can be stored in a `u16`.
|
||||
@return Maximum value
|
||||
*/
|
||||
fn u16_max() {
|
||||
return u16(-1);
|
||||
};
|
||||
|
||||
/**
|
||||
Returns the minimum value that can be stored in a `s16`.
|
||||
@return Minimum value
|
||||
*/
|
||||
fn s16_min() {
|
||||
return -s16((std::limits::u16_max() / 2)) - 1;
|
||||
};
|
||||
|
||||
/**
|
||||
Returns the maximum value that can be stored in a `s16`.
|
||||
@return Maximum value
|
||||
*/
|
||||
fn s16_max() {
|
||||
return s16((std::limits::u16_max() / 2));
|
||||
};
|
||||
|
||||
/**
|
||||
Returns the minimum value that can be stored in a `u32`.
|
||||
@return Minimum value
|
||||
*/
|
||||
fn u32_min() {
|
||||
return u32(0);
|
||||
};
|
||||
|
||||
/**
|
||||
Returns the maximum value that can be stored in a `u32`.
|
||||
@return Maximum value
|
||||
*/
|
||||
fn u32_max() {
|
||||
return u32(-1);
|
||||
};
|
||||
|
||||
/**
|
||||
Returns the minimum value that can be stored in a `s32`.
|
||||
@return Minimum value
|
||||
*/
|
||||
fn s32_min() {
|
||||
return -s32((std::limits::u32_max() / 2)) - 1;
|
||||
};
|
||||
|
||||
/**
|
||||
Returns the maximum value that can be stored in a `s32`.
|
||||
@return Maximum value
|
||||
*/
|
||||
fn s32_max() {
|
||||
return s32((std::limits::u32_max() / 2));
|
||||
};
|
||||
|
||||
/**
|
||||
Returns the minimum value that can be stored in a `u64`.
|
||||
@return Minimum value
|
||||
*/
|
||||
fn u64_min() {
|
||||
return u64(0);
|
||||
};
|
||||
|
||||
/**
|
||||
Returns the maximum value that can be stored in a `u64`.
|
||||
@return Maximum value
|
||||
*/
|
||||
fn u64_max() {
|
||||
return u64(-1);
|
||||
};
|
||||
|
||||
/**
|
||||
Returns the minimum value that can be stored in a `s64`.
|
||||
@return Minimum value
|
||||
*/
|
||||
fn s64_min() {
|
||||
return -s64((std::limits::u64_max() / 2)) - 1;
|
||||
};
|
||||
|
||||
/**
|
||||
Returns the maximum value that can be stored in a `s64`.
|
||||
@return Maximum value
|
||||
*/
|
||||
fn s64_max() {
|
||||
return s64((std::limits::u64_max() / 2));
|
||||
};
|
||||
|
||||
/**
|
||||
Returns the minimum value that can be stored in a `u128`.
|
||||
@return Minimum value
|
||||
*/
|
||||
fn u128_min() {
|
||||
return u128(0);
|
||||
};
|
||||
|
||||
/**
|
||||
Returns the maximum value that can be stored in a `u128`.
|
||||
@return Maximum value
|
||||
*/
|
||||
fn u128_max() {
|
||||
return u128(-1);
|
||||
};
|
||||
|
||||
/**
|
||||
Returns the minimum value that can be stored in a `s128`.
|
||||
@return Minimum value
|
||||
*/
|
||||
fn s128_min() {
|
||||
return -s128((std::limits::u128_max() / 2)) - 1;
|
||||
};
|
||||
|
||||
/**
|
||||
Returns the maximum value that can be stored in a `s128`.
|
||||
@return Maximum value
|
||||
*/
|
||||
fn s128_max() {
|
||||
return s128((std::limits::u128_max() / 2));
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -1,109 +1,340 @@
|
||||
#pragma once
|
||||
|
||||
namespace std::math {
|
||||
import std.mem;
|
||||
|
||||
fn min(auto a, auto b) {
|
||||
if (a < b)
|
||||
return a;
|
||||
else
|
||||
return b;
|
||||
};
|
||||
|
||||
fn max(auto a, auto b) {
|
||||
if (a > b)
|
||||
return a;
|
||||
else
|
||||
return b;
|
||||
};
|
||||
/*!
|
||||
Library containing more advanced mathematical operations.
|
||||
*/
|
||||
|
||||
fn clamp(auto x, auto min, auto max) {
|
||||
if (x < min)
|
||||
return min;
|
||||
else if (x > max)
|
||||
return max;
|
||||
else
|
||||
return x;
|
||||
};
|
||||
namespace auto std::math {
|
||||
|
||||
fn abs(auto x) {
|
||||
if (x < 0)
|
||||
return -x;
|
||||
else
|
||||
return x;
|
||||
};
|
||||
/**
|
||||
Compares the values `a` and `b` with each other and returns the smaller of the two
|
||||
@param a First value
|
||||
@param b Second value
|
||||
@return `a` if `a` is smaller than `b`, otherwise `b`
|
||||
*/
|
||||
fn min(auto a, auto b) {
|
||||
if (a < b)
|
||||
return a;
|
||||
else
|
||||
return b;
|
||||
};
|
||||
|
||||
fn sign(auto x) {
|
||||
if (x > 0)
|
||||
return 1;
|
||||
else if (x < 0)
|
||||
return -1;
|
||||
else
|
||||
return 0;
|
||||
};
|
||||
/**
|
||||
Compares the values `a` and `b` with each other and returns the bigger of the two
|
||||
@param a First value
|
||||
@param b Second value
|
||||
@return `a` if `a` is bigger than `b`, otherwise `b`
|
||||
*/
|
||||
fn max(auto a, auto b) {
|
||||
if (a > b)
|
||||
return a;
|
||||
else
|
||||
return b;
|
||||
};
|
||||
|
||||
fn copy_sign(auto x, auto y) {
|
||||
if (y >= 0)
|
||||
return std::math::abs(x);
|
||||
else
|
||||
return -std::math::abs(x);
|
||||
};
|
||||
/**
|
||||
Clamps the value of `x` between `min` and `max`.
|
||||
@param x Value
|
||||
@param min Minimum value
|
||||
@param max Maximum value
|
||||
@return `min` if `x` is smaller than `min`, `max` if `x` is bigger than `max`, `x` otherwise
|
||||
*/
|
||||
fn clamp(auto x, auto min, auto max) {
|
||||
if (x < min)
|
||||
return min;
|
||||
else if (x > max)
|
||||
return max;
|
||||
else
|
||||
return x;
|
||||
};
|
||||
|
||||
fn factorial(u128 x) {
|
||||
u128 result;
|
||||
|
||||
result = x;
|
||||
while (x > 1) {
|
||||
x = x - 1;
|
||||
result = result * x;
|
||||
}
|
||||
|
||||
return result;
|
||||
};
|
||||
/**
|
||||
Returns the absolute value of `x`.
|
||||
@param x Value
|
||||
@return `x` if `x` is positive, `-x` otherwise
|
||||
*/
|
||||
fn abs(auto x) {
|
||||
if (x < 0)
|
||||
return -x;
|
||||
else
|
||||
return x;
|
||||
};
|
||||
|
||||
fn comb(u128 n, u128 k) {
|
||||
if (k > n)
|
||||
return 0;
|
||||
else
|
||||
return std::math::factorial(n) / (std::math::factorial(k) * std::math::factorial(n - k));
|
||||
};
|
||||
/**
|
||||
Returns the sign of `x`.
|
||||
@param x Value
|
||||
@return `1` if `x` is positive, `-1` if `x` is negative, `0` if `x` is zero
|
||||
*/
|
||||
fn sign(auto x) {
|
||||
if (x > 0)
|
||||
return 1;
|
||||
else if (x < 0)
|
||||
return -1;
|
||||
else
|
||||
return 0;
|
||||
};
|
||||
|
||||
fn perm(u128 n, u128 k) {
|
||||
if (k > n)
|
||||
return 0;
|
||||
else
|
||||
return std::math::factorial(n) / std::math::factorial(n - k);
|
||||
};
|
||||
/**
|
||||
Copies the sign of `y` to `x`.
|
||||
@param x Value
|
||||
@param y Value
|
||||
@return `x` if `y` is positive, `-x` if `y` is negative
|
||||
*/
|
||||
fn copy_sign(auto x, auto y) {
|
||||
if (y >= 0)
|
||||
return std::math::abs(x);
|
||||
else
|
||||
return -std::math::abs(x);
|
||||
};
|
||||
|
||||
/**
|
||||
Calculates the factorial of `x`.
|
||||
@param x Value
|
||||
@return Factorial of `x`
|
||||
*/
|
||||
fn factorial(u128 x) {
|
||||
u128 result;
|
||||
|
||||
result = x;
|
||||
while (x > 1) {
|
||||
x = x - 1;
|
||||
result = result * x;
|
||||
}
|
||||
|
||||
return result;
|
||||
};
|
||||
|
||||
/**
|
||||
Calculates the binomial coefficient of `n` and `k`.
|
||||
@param n Value
|
||||
@param k Value
|
||||
@return Binomial coefficient of `n` and `k`
|
||||
*/
|
||||
fn comb(u128 n, u128 k) {
|
||||
if (k > n)
|
||||
return 0;
|
||||
else
|
||||
return std::math::factorial(n) / (std::math::factorial(k) * std::math::factorial(n - k));
|
||||
};
|
||||
|
||||
/**
|
||||
Calculates the permutation of `n` and `k`.
|
||||
@param n Value
|
||||
@param k Value
|
||||
@return Permutation of `n` and `k`
|
||||
*/
|
||||
fn perm(u128 n, u128 k) {
|
||||
if (k > n)
|
||||
return 0;
|
||||
else
|
||||
return std::math::factorial(n) / std::math::factorial(n - k);
|
||||
};
|
||||
|
||||
/**
|
||||
Floors the value of `value`.
|
||||
@param value Value
|
||||
@return `value` floored
|
||||
*/
|
||||
fn floor(auto value) { return builtin::std::math::floor(value); };
|
||||
|
||||
/**
|
||||
Ceils the value of `value`.
|
||||
@param value Value
|
||||
@return `value` ceiled
|
||||
*/
|
||||
fn ceil(auto value) { return builtin::std::math::ceil(value); };
|
||||
|
||||
/**
|
||||
Rounds the value of `value`.
|
||||
@param value Value
|
||||
@return `value` rounded
|
||||
*/
|
||||
fn round(auto value) { return builtin::std::math::round(value); };
|
||||
|
||||
/**
|
||||
Truncates the value of `value`.
|
||||
@param value Value
|
||||
@return `value` truncated
|
||||
*/
|
||||
fn trunc(auto value) { return builtin::std::math::trunc(value); };
|
||||
|
||||
|
||||
fn floor(auto value) { return builtin::std::math::floor(value); };
|
||||
fn ceil(auto value) { return builtin::std::math::ceil(value); };
|
||||
fn round(auto value) { return builtin::std::math::round(value); };
|
||||
fn trunc(auto value) { return builtin::std::math::trunc(value); };
|
||||
/**
|
||||
Calculates the logarithm of `value` with base 10.
|
||||
@param value Value
|
||||
@return Logarithm of `value` with base 10
|
||||
*/
|
||||
fn log10(auto value) { return builtin::std::math::log10(value); };
|
||||
|
||||
fn log10(auto value) { return builtin::std::math::log10(value); };
|
||||
fn log2(auto value) { return builtin::std::math::log2(value); };
|
||||
fn ln(auto value) { return builtin::std::math::ln(value); };
|
||||
/**
|
||||
Calculates the logarithm of `value` with base 2.
|
||||
@param value Value
|
||||
@return Logarithm of `value` with base 2
|
||||
*/
|
||||
fn log2(auto value) { return builtin::std::math::log2(value); };
|
||||
|
||||
fn fmod(auto value) { return builtin::std::math::fmod(value); };
|
||||
fn pow(auto base, auto exp) { return builtin::std::math::pow(base, exp); };
|
||||
fn sqrt(auto value) { return builtin::std::math::sqrt(value); };
|
||||
fn cbrt(auto value) { return builtin::std::math::cbrt(value); };
|
||||
/**
|
||||
Calculates the natural logarithm of `value`.
|
||||
@param value Value
|
||||
@return Logarithm of `value` with base `e`
|
||||
*/
|
||||
fn ln(auto value) { return builtin::std::math::ln(value); };
|
||||
|
||||
fn sin(auto value) { return builtin::std::math::sin(value); };
|
||||
fn cos(auto value) { return builtin::std::math::cos(value); };
|
||||
fn tan(auto value) { return builtin::std::math::tan(value); };
|
||||
/**
|
||||
Calculates the floating point modulus of `value`.
|
||||
@param value Value
|
||||
@return Floating point modulus of `value`
|
||||
*/
|
||||
fn fmod(auto value) { return builtin::std::math::fmod(value); };
|
||||
|
||||
fn asin(auto value) { return builtin::std::math::asin(value); };
|
||||
fn acos(auto value) { return builtin::std::math::acos(value); };
|
||||
fn atan(auto value) { return builtin::std::math::atan(value); };
|
||||
fn atan2(auto value) { return builtin::std::math::atan2(value); };
|
||||
/**
|
||||
Calculates the value of `base` raised to the power of `exp`.
|
||||
@param base Base
|
||||
@param exp Exponent
|
||||
@return `base` raised to the power of `exp`
|
||||
*/
|
||||
fn pow(auto base, auto exp) { return builtin::std::math::pow(base, exp); };
|
||||
|
||||
fn sinh(auto value) { return builtin::std::math::sinh(value); };
|
||||
fn cosh(auto value) { return builtin::std::math::cosh(value); };
|
||||
fn tanh(auto value) { return builtin::std::math::tanh(value); };
|
||||
/**
|
||||
Calculates the value of the natural number `e` raised to the power of `value`.
|
||||
@param value Exponent
|
||||
@return `e` raised to the power of `value`
|
||||
*/
|
||||
fn exp(auto value) { return builtin::std::math::exp(value); };
|
||||
|
||||
/**
|
||||
Calculates the square root of `value`.
|
||||
@param value Value
|
||||
@return Square root of `value`
|
||||
*/
|
||||
fn sqrt(auto value) { return builtin::std::math::sqrt(value); };
|
||||
|
||||
/**
|
||||
Calculates the cubic root of `value`.
|
||||
@param value Value
|
||||
@return Cubic root of `value`
|
||||
*/
|
||||
fn cbrt(auto value) { return builtin::std::math::cbrt(value); };
|
||||
|
||||
/**
|
||||
Calculates the sine of `value`.
|
||||
@param value Angle value in radians
|
||||
@return Sine of `value`
|
||||
*/
|
||||
fn sin(auto value) { return builtin::std::math::sin(value); };
|
||||
|
||||
/**
|
||||
Calculates the cosine of `value`.
|
||||
@param value Angle value in radians
|
||||
@return Cosine of `value`
|
||||
*/
|
||||
fn cos(auto value) { return builtin::std::math::cos(value); };
|
||||
|
||||
/**
|
||||
Calculates the tangent of `value`.
|
||||
@param value Angle value in radians
|
||||
@return Tangent of `value`
|
||||
*/
|
||||
fn tan(auto value) { return builtin::std::math::tan(value); };
|
||||
|
||||
/**
|
||||
Calculates the arc sine of `value`.
|
||||
@param value Angle value in radians
|
||||
@return Arc sine of `value`
|
||||
*/
|
||||
fn asin(auto value) { return builtin::std::math::asin(value); };
|
||||
|
||||
/**
|
||||
Calculates the arc cosine of `value`.
|
||||
@param value Value
|
||||
@return Arc cosine of `value` in radians
|
||||
*/
|
||||
fn acos(auto value) { return builtin::std::math::acos(value); };
|
||||
|
||||
/**
|
||||
Calculates the arc tangent of `value`.
|
||||
@param value Value
|
||||
@return Arc tangent of `value` in radians between `-pi/2` and `pi/2`
|
||||
*/
|
||||
fn atan(auto value) { return builtin::std::math::atan(value); };
|
||||
|
||||
/**
|
||||
Calculates the arc tangent of `value`.
|
||||
@param y Value representing the proportion of the y-coordinate
|
||||
@param x Value representing the proportion of the x-coordinate.
|
||||
@return Arc tangent of `value` in radians between `-pi` and `pi`
|
||||
*/
|
||||
fn atan2(auto y, auto x) { return builtin::std::math::atan2(y, x); };
|
||||
|
||||
/**
|
||||
Calculates the hyperbolic sine of `value`.
|
||||
@param value Angle value in radians
|
||||
@return Hyperbolic sine of `value`
|
||||
*/
|
||||
fn sinh(auto value) { return builtin::std::math::sinh(value); };
|
||||
|
||||
/**
|
||||
Calculates the hyperbolic cosine of `value`.
|
||||
@param value Angle value in radians
|
||||
@return Hyperbolic cosine of `value`
|
||||
*/
|
||||
fn cosh(auto value) { return builtin::std::math::cosh(value); };
|
||||
|
||||
/**
|
||||
Calculates the hyperbolic tangent of `value`.
|
||||
@param value Angle value in radians
|
||||
@return Hyperbolic tangent of `value`
|
||||
*/
|
||||
fn tanh(auto value) { return builtin::std::math::tanh(value); };
|
||||
|
||||
|
||||
/**
|
||||
Calculates the arc hyperbolic sine of `value`.
|
||||
@param value Value
|
||||
@return Arc hyperbolic sine of `value`
|
||||
*/
|
||||
fn asinh(auto value) { return builtin::std::math::asinh(value); };
|
||||
|
||||
/**
|
||||
Calculates the arc hyperbolic cosine of `value`.
|
||||
@param value Value
|
||||
@return Arc hyperbolic cosine of `value`
|
||||
*/
|
||||
fn acosh(auto value) { return builtin::std::math::acosh(value); };
|
||||
|
||||
/**
|
||||
Calculates the arc hyperbolic tangent of `value`.
|
||||
@param value Value
|
||||
@return Arc hyperbolic tangent of `value`
|
||||
*/
|
||||
fn atanh(auto value) { return builtin::std::math::atanh(value); };
|
||||
|
||||
|
||||
/**
|
||||
Options to use with the `std::math::accumulate` function.
|
||||
*/
|
||||
enum AccumulateOperation : u8 {
|
||||
Add = 0,
|
||||
Multiply = 1,
|
||||
Modulo = 2,
|
||||
Min = 3,
|
||||
Max = 4
|
||||
};
|
||||
|
||||
/**
|
||||
Calculates the sum of all values in the specified memory range.
|
||||
@param start Start address
|
||||
@param end End address
|
||||
@param valueSize Size of each value in bytes
|
||||
@param [section] Section to use
|
||||
@param [operation] Operation to use. Defaults to addition
|
||||
@param [endian] Endianness to use. Defaults to native
|
||||
@return Sum of all values in the specified memory range
|
||||
*/
|
||||
fn accumulate(u128 start, u128 end, u128 valueSize, std::mem::Section section = 0, AccumulateOperation operation = AccumulateOperation::Add, std::mem::Endian endian = std::mem::Endian::Native) {
|
||||
return builtin::std::math::accumulate(start, end, valueSize, section, u128(operation), u128(endian));
|
||||
};
|
||||
|
||||
fn asinh(auto value) { return builtin::std::math::asinh(value); };
|
||||
fn acosh(auto value) { return builtin::std::math::acosh(value); };
|
||||
fn atanh(auto value) { return builtin::std::math::atanh(value); };
|
||||
|
||||
}
|
||||
|
||||
@@ -1,50 +1,285 @@
|
||||
#pragma once
|
||||
|
||||
namespace std::mem {
|
||||
|
||||
/*!
|
||||
Library for doing raw memory accesses and other low-level operations.
|
||||
*/
|
||||
|
||||
namespace auto std::mem {
|
||||
|
||||
/**
|
||||
A Handle for a custom Section
|
||||
*/
|
||||
using Section = u128;
|
||||
|
||||
/**
|
||||
The endianness of a value
|
||||
*/
|
||||
enum Endian : u8 {
|
||||
Native = 0,
|
||||
Big = 1,
|
||||
Little = 2
|
||||
};
|
||||
|
||||
/**
|
||||
Function that returns true if the cursor position is at the end of the memory
|
||||
This is usually used in while-sized arrays in the form of `u8 array[while(!std::mem::eof())]`
|
||||
@return True if the cursor is at the end of the memory
|
||||
*/
|
||||
fn eof() {
|
||||
return $ >= std::mem::size();
|
||||
return $ >= (std::mem::base_address() + std::mem::size());
|
||||
};
|
||||
|
||||
/**
|
||||
Function that returns true if the cursor position is at or beyond the given address
|
||||
@param address The address to compare against
|
||||
@return True if the cursor is at or beyond the given address
|
||||
*/
|
||||
fn reached(u128 address) {
|
||||
return $ >= address;
|
||||
};
|
||||
|
||||
/**
|
||||
Aligns the given value to the given alignment
|
||||
@param alignment The alignment to align to
|
||||
@param value The value to align
|
||||
@return The aligned value
|
||||
*/
|
||||
fn align_to(u128 alignment, u128 value) {
|
||||
u128 remainder = value % alignment;
|
||||
|
||||
return remainder != 0 ? value + (alignment - remainder) : value;
|
||||
};
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Gets the base address of the data
|
||||
@return The base address of the memory
|
||||
*/
|
||||
fn base_address() {
|
||||
return builtin::std::mem::base_address();
|
||||
};
|
||||
|
||||
/**
|
||||
Gets the size of the data
|
||||
@return The size of the memory
|
||||
*/
|
||||
fn size() {
|
||||
return builtin::std::mem::size();
|
||||
};
|
||||
|
||||
/**
|
||||
Finds a sequence of bytes in the data
|
||||
@param occurrence_index The index of the occurrence to find
|
||||
@param bytes The bytes to find
|
||||
@return The address of the sequence
|
||||
*/
|
||||
fn find_sequence(u128 occurrence_index, auto ... bytes) {
|
||||
return builtin::std::mem::find_sequence_in_range(occurrence_index, builtin::std::mem::base_address(), builtin::std::mem::size(), bytes);
|
||||
const u128 address = std::mem::base_address();
|
||||
return builtin::std::mem::find_sequence_in_range(occurrence_index, address, address + std::mem::size(), bytes);
|
||||
};
|
||||
|
||||
/**
|
||||
Finds a sequence of bytes in a specific region of the data
|
||||
@param occurrence_index The index of the occurrence to find
|
||||
@param offsetFrom The offset from which to start searching
|
||||
@param offsetTo The offset to which to search
|
||||
@param bytes The bytes to find
|
||||
@return The address of the sequence
|
||||
*/
|
||||
fn find_sequence_in_range(u128 occurrence_index, u128 offsetFrom, u128 offsetTo, auto ... bytes) {
|
||||
return builtin::std::mem::find_sequence_in_range(occurrence_index, offsetFrom, offsetTo, bytes);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
Finds a string in the data
|
||||
@param occurrence_index The index of the occurrence to find
|
||||
@param string The string to find
|
||||
@return The address of the sequence
|
||||
*/
|
||||
fn find_string(u128 occurrence_index, str string) {
|
||||
const u128 address = std::mem::base_address();
|
||||
return builtin::std::mem::find_string_in_range(occurrence_index, address, address + std::mem::size(), string);
|
||||
};
|
||||
|
||||
/**
|
||||
Finds a string in a specific region of the data
|
||||
@param occurrence_index The index of the occurrence to find
|
||||
@param offsetFrom The offset from which to start searching
|
||||
@param offsetTo The offset to which to search
|
||||
@param string The string to find
|
||||
@return The address of the sequence
|
||||
*/
|
||||
fn find_string_in_range(u128 occurrence_index, u128 offsetFrom, u128 offsetTo, str string) {
|
||||
return builtin::std::mem::find_string_in_range(occurrence_index, offsetFrom, offsetTo, string);
|
||||
};
|
||||
|
||||
/**
|
||||
Reads a unsigned value from the memory
|
||||
@param address The address to read from
|
||||
@param size The size of the value to read
|
||||
@param [endian] The endianness of the value to read. Defaults to native
|
||||
@return The value read
|
||||
*/
|
||||
fn read_unsigned(u128 address, u8 size, Endian endian = Endian::Native) {
|
||||
return builtin::std::mem::read_unsigned(address, size, u32(endian));
|
||||
};
|
||||
|
||||
/**
|
||||
Reads a signed value from the memory
|
||||
@param address The address to read from
|
||||
@param size The size of the value to read
|
||||
@param [endian] The endianness of the value to read. Defaults to native
|
||||
@return The value read
|
||||
*/
|
||||
fn read_signed(u128 address, u8 size, Endian endian = Endian::Native) {
|
||||
return builtin::std::mem::read_signed(address, size, u32(endian));
|
||||
};
|
||||
|
||||
fn read_string(u128 address, u8 size) {
|
||||
/**
|
||||
Reads a string value from the memory
|
||||
@param address The address to read from
|
||||
@param size The size of the value to read
|
||||
@return The value read
|
||||
*/
|
||||
fn read_string(u128 address, u128 size) {
|
||||
return builtin::std::mem::read_string(address, size);
|
||||
};
|
||||
|
||||
/**
|
||||
Reads a number of bits from the specified bit offset within the specified byte
|
||||
@param byteOffset The byte offset within the data
|
||||
@param bitOffset The bit offset to start the read at within the current byte
|
||||
@param bitSize The total number of bits to read
|
||||
@return A u128 containing the value read
|
||||
*/
|
||||
fn read_bits(u128 byteOffset, u128 bitOffset, u64 bitSize) {
|
||||
byteOffset += bitOffset >> 3;
|
||||
bitOffset = bitOffset & 0x7;
|
||||
return builtin::std::mem::read_bits(byteOffset, bitOffset, bitSize);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
Creates a new custom section with the given name
|
||||
@param name The name of the section
|
||||
@return The handle to the section
|
||||
*/
|
||||
fn create_section(str name) {
|
||||
return builtin::std::mem::create_section(name);
|
||||
};
|
||||
|
||||
/**
|
||||
Deletes a custom section
|
||||
@param section The handle to the section
|
||||
*/
|
||||
fn delete_section(Section section) {
|
||||
builtin::std::mem::delete_section(section);
|
||||
};
|
||||
|
||||
/**
|
||||
Gets the size of a custom section
|
||||
@param section The handle to the section
|
||||
@return The size of the section
|
||||
*/
|
||||
fn get_section_size(Section section) {
|
||||
return builtin::std::mem::get_section_size(section);
|
||||
};
|
||||
|
||||
/**
|
||||
Changes the size of a custom section
|
||||
@param section The handle to the section
|
||||
@param size The new size of the section
|
||||
*/
|
||||
fn set_section_size(Section section, u128 size) {
|
||||
builtin::std::mem::set_section_size(section, size);
|
||||
};
|
||||
|
||||
/**
|
||||
Copies a range of bytes from one section into another
|
||||
@param from_section The section to copy from
|
||||
@param from_address The address to copy from
|
||||
@param to_section The section to copy to
|
||||
@param to_address The address to copy to
|
||||
@param size The size of the range to copy
|
||||
*/
|
||||
fn copy_section_to_section(Section from_section, u64 from_address, Section to_section, u64 to_address, u64 size) {
|
||||
builtin::std::mem::copy_to_section(from_section, from_address, to_section, to_address, size);
|
||||
};
|
||||
|
||||
/**
|
||||
Copies a range of bytes from the main section into a custom section
|
||||
@param value The pattern whose bytes should be copied
|
||||
@param to_section The section to copy to
|
||||
@param to_address The address to copy to
|
||||
*/
|
||||
fn copy_value_to_section(ref auto value, Section to_section, u64 to_address) {
|
||||
builtin::std::mem::copy_value_to_section(value, to_section, to_address);
|
||||
};
|
||||
|
||||
/**
|
||||
Returns the current bit offset when inside of a bitfield.
|
||||
@return The current bit offset between 0 and 7
|
||||
*/
|
||||
fn current_bit_offset() {
|
||||
return builtin::std::mem::current_bit_offset();
|
||||
};
|
||||
|
||||
/**
|
||||
Reinterprets a value as a different one
|
||||
@tparam From The type to reinterpret from
|
||||
@tparam To The type to reinterpret to
|
||||
*/
|
||||
union Reinterpreter<From, To> {
|
||||
From from_value;
|
||||
To to_value;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
Aligns the cursor to the given alignment
|
||||
@tparam alignment The alignment to align to
|
||||
*/
|
||||
struct AlignTo<auto Alignment> {
|
||||
padding[Alignment - ((($ - 1) % Alignment) + 1)];
|
||||
} [[hidden, sealed]];
|
||||
|
||||
/**
|
||||
A type representing a sequence of bytes without any specific meaning
|
||||
@tparam Size The size of the sequence
|
||||
*/
|
||||
struct Bytes<auto Size> {
|
||||
u8 bytes[Size];
|
||||
} [[sealed, format("std::mem::impl::format_bytes")]];
|
||||
|
||||
namespace impl {
|
||||
|
||||
fn format_bytes(auto bytes) {
|
||||
return "";
|
||||
};
|
||||
|
||||
struct MagicSearchImpl<auto Magic, T> {
|
||||
s128 address = builtin::std::mem::find_string_in_range(0, $, std::mem::size(), Magic);
|
||||
if (address < 0)
|
||||
break;
|
||||
|
||||
$ = address;
|
||||
try {
|
||||
T data [[inline]];
|
||||
} catch {
|
||||
T data;
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
Searches for a sequence of bytes and places the given type at that address
|
||||
@tparam Magic The magic sequence to search for
|
||||
@tparam T The type to place at the address
|
||||
*/
|
||||
struct MagicSearch<auto Magic, T> {
|
||||
std::mem::impl::MagicSearchImpl<Magic, T> impl[while(!std::mem::eof())] [[inline]];
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -1,17 +1,69 @@
|
||||
#pragma once
|
||||
|
||||
namespace std::ptr {
|
||||
import std.mem;
|
||||
|
||||
/*!
|
||||
The Pointer library contains helper functions to deal with pointer types.
|
||||
The `relative_to` functions are meant to be used with the `[[pointer_base]]` attribute
|
||||
*/
|
||||
|
||||
namespace auto std::ptr {
|
||||
|
||||
/**
|
||||
Use the offset of the current pointer as start address
|
||||
@param offset The pointer's value
|
||||
@return The new pointer base
|
||||
*/
|
||||
fn relative_to_pointer(u128 offset) {
|
||||
return $;
|
||||
};
|
||||
|
||||
/**
|
||||
Use the offset of the pointer's parent as start address
|
||||
@param offset The pointer's value
|
||||
@return The new pointer base
|
||||
*/
|
||||
fn relative_to_parent(u128 offset) {
|
||||
return addressof(parent);
|
||||
};
|
||||
|
||||
/**
|
||||
Use the end of the file as pointer base address and use its value as offset backwards from there
|
||||
@param offset The pointer's value
|
||||
@return The new pointer base
|
||||
*/
|
||||
fn relative_to_end(u128 offset) {
|
||||
return std::mem::size() - offset * 2;
|
||||
};
|
||||
|
||||
}
|
||||
/**
|
||||
A nullable pointer, generic over both the pointee type and pointer type.
|
||||
|
||||
By nullable, we mean that if the pointer's value is zero (`0x0`), then the
|
||||
value will appear as padding rather than a pointer to something, but
|
||||
if the pointer's value is non-zero, that non-zero value will be treated as
|
||||
a pointer of type `PointerTy` which points to an element of type `PointeeTy`.
|
||||
|
||||
Example:
|
||||
A struct field called `p_myInfo` which is a nullable 64-bit pointer to an
|
||||
element of type `MyInfoTy` would be written as:
|
||||
```rust
|
||||
struct MyStruct {
|
||||
std::ptr::NullablePtr<MyInfoTy, u64> p_myInfo;
|
||||
}
|
||||
```
|
||||
*/
|
||||
struct NullablePtr<PointeeTy, PointerTy> {
|
||||
// `pointerValue` is `no_unique_address` because we don't want to advance
|
||||
// the current memory location after reading the value of the pointer itself;
|
||||
// we want to examine the value at this address to determine what should be
|
||||
// displayed. It's also `hidden` so the editor only displays either thee
|
||||
// padding or the populated pointer/pointee field.
|
||||
PointerTy pointerValue [[no_unique_address, hidden]];
|
||||
if (pointerValue == 0x0) {
|
||||
padding[sizeof(PointerTy)];
|
||||
} else {
|
||||
PointeeTy *data : PointerTy;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
81
includes/std/random.pat
Normal file
81
includes/std/random.pat
Normal file
@@ -0,0 +1,81 @@
|
||||
#pragma once
|
||||
|
||||
import std.limits;
|
||||
|
||||
/*!
|
||||
Library to generate random numbers. Supports various different distribution types.
|
||||
*/
|
||||
|
||||
namespace auto std::random {
|
||||
|
||||
/**
|
||||
Represents the type of distribution to use to generate a random number
|
||||
*/
|
||||
enum Distribution : u8 {
|
||||
Uniform = 0,
|
||||
Normal = 1,
|
||||
Exponential = 2,
|
||||
Gamma = 3,
|
||||
Weibull = 4,
|
||||
ExtremeValue = 5,
|
||||
ChiSquared = 6,
|
||||
Cauchy = 7,
|
||||
FisherF = 8,
|
||||
StudentT = 9,
|
||||
LogNormal = 10,
|
||||
Bernoulli = 11,
|
||||
Binomial = 12,
|
||||
NegativeBinomial = 13,
|
||||
Geometric = 14,
|
||||
Poisson = 15
|
||||
};
|
||||
|
||||
/**
|
||||
Sets the seed of the random number generator
|
||||
@param seed Seed to use
|
||||
*/
|
||||
fn set_seed(u64 seed) {
|
||||
builtin::std::random::set_seed(seed);
|
||||
};
|
||||
|
||||
/**
|
||||
Generates a random number using the given distribution with the given parameters.
|
||||
The random number generator used internally is C++'s std::mt19937_64 Mersenne Twister implementation.
|
||||
|
||||
> **Distributions**
|
||||
> - `Uniform(min, max) -> i128`
|
||||
> - `Normal(mean, stddev) -> double`
|
||||
> - `Exponential(lambda) -> double`
|
||||
> - `Gamma(alpha, beta) -> double`
|
||||
> - `Weibull(a, b) -> double`
|
||||
> - `ExtremeValue(a, b) -> double`
|
||||
> - `ChiSquared(n) -> double`
|
||||
> - `Cauchy(a, b) -> double`
|
||||
> - `FisherF(m, n) -> double`
|
||||
> - `StudentT(n) -> double`
|
||||
> - `LogNormal(m, s) -> double`
|
||||
> - `Bernoulli(p) -> bool`
|
||||
> - `Binomial(t, p) -> i128`
|
||||
> - `NegativeBinomial(k, p) -> i128`
|
||||
> - `Geometric(p) -> i128`
|
||||
> - `Poisson(mean) -> i128`
|
||||
|
||||
@param distribution Distribution to use
|
||||
@param [param1] This parameter depends on the type of distribution used. Defaults to 0
|
||||
@param [param2] This parameter depends on the type of distribution used. Defaults to 0
|
||||
*/
|
||||
fn generate_using(Distribution distribution, auto param1 = 0, auto param2 = 0) {
|
||||
return builtin::std::random::generate(u32(distribution), param1, param2);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
Generates a uniformly distributed random number between `min` and `max`
|
||||
@param [min] Minimum number. Defaults to 0
|
||||
@param [max] Maximum number. Defaults to `u64_max`
|
||||
*/
|
||||
fn generate(u64 min = std::limits::u64_min(), u64 max = std::limits::u64_max()) {
|
||||
return std::random::generate_using(Distribution::Uniform, min, max);
|
||||
};
|
||||
|
||||
}
|
||||
@@ -1,130 +1,259 @@
|
||||
#pragma once
|
||||
|
||||
#include <std/io.pat>
|
||||
import std.io;
|
||||
import std.mem;
|
||||
|
||||
namespace std::string {
|
||||
/*!
|
||||
Library to interact with strings.
|
||||
*/
|
||||
|
||||
fn length(str string) {
|
||||
return builtin::std::string::length(string);
|
||||
};
|
||||
namespace auto std::string {
|
||||
|
||||
fn at(str string, u32 index) {
|
||||
return builtin::std::string::at(string, index);
|
||||
};
|
||||
/**
|
||||
Base type for sized strings. Represents a string with its size preceding it.
|
||||
@tparam SizeType The type of the size field.
|
||||
@tparam DataType The type of the characters.
|
||||
*/
|
||||
struct SizedStringBase<SizeType, DataType> {
|
||||
SizeType size;
|
||||
DataType data[size];
|
||||
} [[sealed, format("std::string::impl::format_string"), transform("std::string::impl::format_string")]];
|
||||
|
||||
fn substr(str string, u32 pos, u32 count) {
|
||||
return builtin::std::string::substr(string, pos, count);
|
||||
};
|
||||
/**
|
||||
A ASCII string with a prefixed size.
|
||||
@tparam SizeType The type of the size field.
|
||||
*/
|
||||
using SizedString<SizeType> = SizedStringBase<SizeType, char>;
|
||||
|
||||
/**
|
||||
A UTF-16 string with a prefixed size.
|
||||
@tparam SizeType The type of the size field.
|
||||
*/
|
||||
using SizedString16<SizeType> = SizedStringBase<SizeType, char16>;
|
||||
|
||||
/**
|
||||
Base type for null-terminated strings. Represents a string with its size determined by the first 0x00 byte found.
|
||||
@tparam DataType The type of the characters.
|
||||
*/
|
||||
struct NullStringBase<DataType> {
|
||||
DataType data[while(std::mem::read_unsigned($, sizeof(DataType)) != 0x00)];
|
||||
DataType null_terminator;
|
||||
} [[sealed, format("std::string::impl::format_string"), transform("std::string::impl::format_string")]];
|
||||
|
||||
/**
|
||||
A null-terminated ASCII string.
|
||||
*/
|
||||
using NullString = NullStringBase<char>;
|
||||
|
||||
/**
|
||||
A null-terminated UTF-16 string.
|
||||
*/
|
||||
using NullString16 = NullStringBase<char16>;
|
||||
|
||||
namespace impl {
|
||||
|
||||
fn format_string(ref auto string) {
|
||||
return string.data;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
Gets the length of a string.
|
||||
@param string The string to get the length of.
|
||||
@return The length of the string.
|
||||
*/
|
||||
fn length(str string) {
|
||||
return builtin::std::string::length(string);
|
||||
};
|
||||
|
||||
/**
|
||||
Gets the character at a given index.
|
||||
@param string The string to get the character from.
|
||||
@param index The index of the character to get.
|
||||
@return The character at the given index.
|
||||
*/
|
||||
fn at(str string, u32 index) {
|
||||
return builtin::std::string::at(string, index);
|
||||
};
|
||||
|
||||
/**
|
||||
Gets a substring of a string.
|
||||
@param string The string to get the substring from.
|
||||
@param pos The position of the first character of the substring.
|
||||
@param count The number of characters to get.
|
||||
@return The substring.
|
||||
*/
|
||||
fn substr(str string, u32 pos, u32 count) {
|
||||
return builtin::std::string::substr(string, pos, count);
|
||||
};
|
||||
|
||||
|
||||
fn parse_int(str string, u8 base) {
|
||||
return builtin::std::string::parse_int(string, base);
|
||||
};
|
||||
/**
|
||||
Converts a string to an integer.
|
||||
@param string The string to convert.
|
||||
@param base The base of the number.
|
||||
@return The integer.
|
||||
*/
|
||||
fn parse_int(str string, u8 base) {
|
||||
return builtin::std::string::parse_int(string, base);
|
||||
};
|
||||
|
||||
fn parse_float(str string) {
|
||||
return builtin::std::string::parse_float(string);
|
||||
};
|
||||
/**
|
||||
Converts a string to a float.
|
||||
@param string The string to convert.
|
||||
@return The float.
|
||||
*/
|
||||
fn parse_float(str string) {
|
||||
return builtin::std::string::parse_float(string);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
Converts any type to a string.
|
||||
@param x The value to convert.
|
||||
@return The string.
|
||||
*/
|
||||
fn to_string(auto x) {
|
||||
return std::format("{}", x);
|
||||
};
|
||||
|
||||
/**
|
||||
Checks if a string starts with a given substring.
|
||||
@param string The string to check.
|
||||
@param part The substring to check for.
|
||||
@return True if the string starts with the substring, false otherwise.
|
||||
*/
|
||||
fn starts_with(str string, str part) {
|
||||
if (std::string::length(string) < std::string::length(part))
|
||||
return false;
|
||||
return std::string::substr(string, 0, std::string::length(part)) == part;
|
||||
};
|
||||
|
||||
/**
|
||||
Checks if a string ends with a given substring.
|
||||
@param string The string to check.
|
||||
@param part The substring to check for.
|
||||
@return True if the string ends with the substring, false otherwise.
|
||||
*/
|
||||
fn ends_with(str string, str part) {
|
||||
if (std::string::length(string) < std::string::length(part))
|
||||
return false;
|
||||
return std::string::substr(string, std::string::length(string) - std::string::length(part), std::string::length(part)) == part;
|
||||
};
|
||||
|
||||
fn contains(str a, str b) {
|
||||
s32 a_len = std::string::length(a);
|
||||
s32 b_len = std::string::length(b);
|
||||
/**
|
||||
Checks if a string contains a given substring.
|
||||
@param string The string to check.
|
||||
@param part The substring to check for.
|
||||
@return True if the string contains the substring, false otherwise.
|
||||
*/
|
||||
fn contains(str string, str part) {
|
||||
s32 string_len = std::string::length(string);
|
||||
s32 part_len = std::string::length(part);
|
||||
|
||||
for (s32 i = 0, i <= (a_len - b_len), i += 1) {
|
||||
if (std::string::substr(a, i, b_len) == b)
|
||||
for (s32 i = 0, i <= (string_len - part_len), i += 1) {
|
||||
if (std::string::substr(string, i, part_len) == part)
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
};
|
||||
|
||||
fn reverse(str string) {
|
||||
/**
|
||||
Reverses a string.
|
||||
@param string The string to reverse.
|
||||
@return The reversed string.
|
||||
*/
|
||||
fn reverse(str string) {
|
||||
str result;
|
||||
|
||||
|
||||
s32 i;
|
||||
i = std::string::length(string);
|
||||
while (i > 0) {
|
||||
i = i - 1;
|
||||
result = result + std::string::at(string, i);
|
||||
}
|
||||
|
||||
|
||||
return result;
|
||||
};
|
||||
|
||||
/**
|
||||
Converts a string to upper case.
|
||||
@param string The string to convert.
|
||||
@return The converted string.
|
||||
*/
|
||||
fn to_upper(str string) {
|
||||
str result;
|
||||
|
||||
u32 i;
|
||||
char c;
|
||||
while (i < std::string::length(string)) {
|
||||
c = std::string::at(string, i);
|
||||
|
||||
if (c >= 'a' && c <= 'z')
|
||||
result = result + char(c - 0x20);
|
||||
else
|
||||
result = result + c;
|
||||
|
||||
i = i + 1;
|
||||
}
|
||||
|
||||
return result;
|
||||
};
|
||||
|
||||
fn to_lower(str string) {
|
||||
str result;
|
||||
|
||||
u32 i;
|
||||
char c;
|
||||
while (i < std::string::length(string)) {
|
||||
c = std::string::at(string, i);
|
||||
|
||||
if (c >= 'A' && c <= 'Z')
|
||||
result = result + char(c + 0x20);
|
||||
else
|
||||
result = result + c;
|
||||
|
||||
i = i + 1;
|
||||
}
|
||||
|
||||
return result;
|
||||
};
|
||||
str result;
|
||||
|
||||
u32 i;
|
||||
char c;
|
||||
while (i < std::string::length(string)) {
|
||||
c = std::string::at(string, i);
|
||||
|
||||
if (c >= 'a' && c <= 'z')
|
||||
result = result + char(c - 0x20);
|
||||
else
|
||||
result = result + c;
|
||||
|
||||
i = i + 1;
|
||||
}
|
||||
|
||||
return result;
|
||||
};
|
||||
|
||||
/**
|
||||
Converts a string to lower case.
|
||||
@param string The string to convert.
|
||||
@return The converted string.
|
||||
*/
|
||||
fn to_lower(str string) {
|
||||
str result;
|
||||
|
||||
u32 i;
|
||||
char c;
|
||||
while (i < std::string::length(string)) {
|
||||
c = std::string::at(string, i);
|
||||
|
||||
if (c >= 'A' && c <= 'Z')
|
||||
result = result + char(c + 0x20);
|
||||
else
|
||||
result = result + c;
|
||||
|
||||
i = i + 1;
|
||||
}
|
||||
|
||||
return result;
|
||||
};
|
||||
|
||||
/**
|
||||
Replaces all occurrences of a substring with another substring.
|
||||
@param string The string to replace in.
|
||||
@param pattern The substring to replace.
|
||||
@param replace The substring to replace with.
|
||||
@return The string with the replacements.
|
||||
*/
|
||||
fn replace(str string, str pattern, str replace) {
|
||||
u32 string_len, pattern_len, replace_len;
|
||||
string_len = std::string::length(string);
|
||||
pattern_len = std::string::length(pattern);
|
||||
replace_len = std::string::length(replace);
|
||||
|
||||
if (pattern_len > string_len)
|
||||
return string;
|
||||
|
||||
str result;
|
||||
u32 i;
|
||||
while (i <= (string_len - pattern_len)) {
|
||||
|
||||
if (std::string::substr(string, i, pattern_len) == pattern) {
|
||||
result = result + replace;
|
||||
i = i + pattern_len;
|
||||
} else {
|
||||
result = result + std::string::at(string, i);
|
||||
i = i + 1;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
};
|
||||
s32 string_len = std::string::length(string);
|
||||
s32 pattern_len = std::string::length(pattern);
|
||||
|
||||
if (pattern_len > string_len || pattern_len * string_len == 0 )
|
||||
return string;
|
||||
|
||||
str result;
|
||||
s32 string_index;
|
||||
s32 remaining_len = string_len;
|
||||
while (pattern_len <= remaining_len) {
|
||||
if (std::string::substr(string, string_index, pattern_len) == pattern) {
|
||||
result += replace;
|
||||
string_index += pattern_len;
|
||||
} else {
|
||||
result += std::string::at(string, string_index);
|
||||
string_index += 1;
|
||||
}
|
||||
remaining_len = string_len - string_index;
|
||||
}
|
||||
result += std::string::substr(string, string_index, remaining_len );
|
||||
return result;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,15 +1,29 @@
|
||||
#pragma once
|
||||
|
||||
#include <std/io.pat>
|
||||
import std.io;
|
||||
|
||||
namespace std {
|
||||
/*!
|
||||
Basic helper functions
|
||||
*/
|
||||
|
||||
namespace auto std {
|
||||
|
||||
/**
|
||||
Asserts that a given value is true. If it's not, abort evaluation and print the given message to the console
|
||||
@param condition The condition that is required to be true
|
||||
@param message The message to print in case the assertion doesn't hold
|
||||
*/
|
||||
fn assert(bool condition, str message) {
|
||||
if (!condition) {
|
||||
std::error(std::format("assertion failed '{0}'", message));
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
Asserts that a given value is true. If it's not, print the given message to the console as a warning
|
||||
@param condition The condition that is required to be true
|
||||
@param message The message to print in case the assertion doesn't hold
|
||||
*/
|
||||
fn assert_warn(bool condition, str message) {
|
||||
if (!condition) {
|
||||
std::warning(std::format("assertion failed '{0}'", message));
|
||||
@@ -17,12 +31,29 @@ namespace std {
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
Queries the value of a set environment variable given it's name
|
||||
@param name The name of the env variable
|
||||
@return The value of that variable
|
||||
*/
|
||||
fn env(str name) {
|
||||
return builtin::std::env(name);
|
||||
};
|
||||
|
||||
/**
|
||||
Returns the number of parameters in a parameter pack.
|
||||
@param pack The pack to check
|
||||
@return Number of parameters in `pack`
|
||||
*/
|
||||
fn sizeof_pack(auto ... pack) {
|
||||
return builtin::std::sizeof_pack(pack);
|
||||
};
|
||||
|
||||
/**
|
||||
Throws an error notifying the developer that the current code path is not implemented currently.
|
||||
*/
|
||||
fn unimplemented() {
|
||||
std::error("Unimplemented code path reached!");
|
||||
};
|
||||
|
||||
}
|
||||
@@ -1,71 +1,200 @@
|
||||
#pragma once
|
||||
|
||||
#include <std/io.pat>
|
||||
import std.io;
|
||||
|
||||
namespace std::time {
|
||||
/*!
|
||||
Library to handle time and date related operations.
|
||||
*/
|
||||
|
||||
struct Time {
|
||||
u8 sec;
|
||||
u8 min;
|
||||
u8 hour;
|
||||
u8 mday;
|
||||
u8 mon;
|
||||
u16 year;
|
||||
u8 wday;
|
||||
u16 yday;
|
||||
bool isdst;
|
||||
} [[sealed]];
|
||||
|
||||
union TimeConverter {
|
||||
Time time;
|
||||
u128 value;
|
||||
};
|
||||
|
||||
using EpochTime = u128;
|
||||
namespace auto std::time {
|
||||
|
||||
enum TimeZone : u8 {
|
||||
Local,
|
||||
UTC
|
||||
};
|
||||
/**
|
||||
A structured representation of a time and date.
|
||||
*/
|
||||
struct Time {
|
||||
u8 sec;
|
||||
u8 min;
|
||||
u8 hour;
|
||||
u8 mday;
|
||||
u8 mon;
|
||||
u16 year;
|
||||
u8 wday;
|
||||
u16 yday;
|
||||
bool isdst;
|
||||
} [[sealed]];
|
||||
|
||||
fn epoch() {
|
||||
return builtin::std::time::epoch();
|
||||
};
|
||||
|
||||
fn to_local(EpochTime epoch_time) {
|
||||
TimeConverter converter;
|
||||
|
||||
converter.value = builtin::std::time::to_local(epoch_time);
|
||||
|
||||
return converter.time;
|
||||
};
|
||||
|
||||
fn to_utc(EpochTime epoch_time) {
|
||||
TimeConverter converter;
|
||||
|
||||
converter.value = builtin::std::time::to_utc(epoch_time);
|
||||
|
||||
return converter.time;
|
||||
};
|
||||
/**
|
||||
A helper type to convert between Time and u128.
|
||||
*/
|
||||
union TimeConverter {
|
||||
Time time;
|
||||
u128 value;
|
||||
};
|
||||
|
||||
/**
|
||||
A type to represent a time in seconds since the epoch.
|
||||
*/
|
||||
using EpochTime = u32;
|
||||
|
||||
/**
|
||||
A type to represent a time zone.
|
||||
*/
|
||||
enum TimeZone : u8 {
|
||||
Local,
|
||||
UTC
|
||||
};
|
||||
|
||||
/**
|
||||
A type to represent a DOS date.
|
||||
*/
|
||||
bitfield DOSDate {
|
||||
day: 5;
|
||||
month: 4;
|
||||
year: 7;
|
||||
} [[sealed]];
|
||||
|
||||
/**
|
||||
A type to represent a DOS time.
|
||||
*/
|
||||
bitfield DOSTime {
|
||||
seconds: 5;
|
||||
minutes: 6;
|
||||
hours: 5;
|
||||
} [[sealed]];
|
||||
|
||||
namespace impl {
|
||||
|
||||
union DOSDateConverter {
|
||||
DOSDate date;
|
||||
u16 value;
|
||||
};
|
||||
|
||||
union DOSTimeConverter {
|
||||
DOSTime time;
|
||||
u16 value;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
|
||||
fn now(TimeZone time_zone = TimeZone::Local) {
|
||||
TimeConverter converter;
|
||||
|
||||
if (time_zone == TimeZone::Local)
|
||||
converter.value = builtin::std::time::to_local(std::time::epoch());
|
||||
else if (time_zone == TimeZone::UTC)
|
||||
converter.value = builtin::std::time::to_utc(std::time::epoch());
|
||||
else
|
||||
converter.value = 0x00;
|
||||
|
||||
return converter.time;
|
||||
};
|
||||
|
||||
fn format(Time time, str format_string = "%c") {
|
||||
TimeConverter converter;
|
||||
converter.time = time;
|
||||
|
||||
return builtin::std::time::format(format_string, converter.value);
|
||||
};
|
||||
}
|
||||
/**
|
||||
Returns the current time in seconds since the epoch.
|
||||
@return The current time in seconds since the epoch.
|
||||
*/
|
||||
fn epoch() {
|
||||
return builtin::std::time::epoch();
|
||||
};
|
||||
|
||||
/**
|
||||
Converts a time in seconds since the epoch to a local time.
|
||||
@param epoch_time The time in seconds since the epoch.
|
||||
@return The local time.
|
||||
*/
|
||||
fn to_local(EpochTime epoch_time) {
|
||||
le TimeConverter converter;
|
||||
|
||||
converter.value = builtin::std::time::to_local(epoch_time);
|
||||
|
||||
return converter.time;
|
||||
};
|
||||
|
||||
/**
|
||||
Converts a time in seconds since the epoch to a UTC time.
|
||||
@param epoch_time The time in seconds since the epoch.
|
||||
@return The UTC time.
|
||||
*/
|
||||
fn to_utc(EpochTime epoch_time) {
|
||||
le TimeConverter converter;
|
||||
|
||||
converter.value = builtin::std::time::to_utc(epoch_time);
|
||||
|
||||
return converter.time;
|
||||
};
|
||||
|
||||
/**
|
||||
Queries the current time in the specified time zone.
|
||||
@param [time_zone] The time zone to query. Defaults to local.
|
||||
@return The current time in the specified time zone.
|
||||
*/
|
||||
fn now(TimeZone time_zone = TimeZone::Local) {
|
||||
le TimeConverter converter;
|
||||
|
||||
if (time_zone == TimeZone::Local)
|
||||
converter.value = builtin::std::time::to_local(std::time::epoch());
|
||||
else if (time_zone == TimeZone::UTC)
|
||||
converter.value = builtin::std::time::to_utc(std::time::epoch());
|
||||
else
|
||||
converter.value = 0x00;
|
||||
|
||||
return converter.time;
|
||||
};
|
||||
|
||||
/**
|
||||
Converts a value to a DOS date.
|
||||
@param value The value to convert.
|
||||
@return The DOS date.
|
||||
*/
|
||||
fn to_dos_date(u16 value) {
|
||||
le impl::DOSDateConverter converter;
|
||||
|
||||
converter.value = value;
|
||||
|
||||
return converter.date;
|
||||
};
|
||||
|
||||
/**
|
||||
Converts a value to a DOS time.
|
||||
@param value The value to convert.
|
||||
@return The DOS time.
|
||||
*/
|
||||
fn to_dos_time(u16 value) {
|
||||
le impl::DOSTimeConverter converter;
|
||||
|
||||
converter.value = value;
|
||||
|
||||
return converter.time;
|
||||
};
|
||||
|
||||
/**
|
||||
Converts a FILETIME to unix time.
|
||||
@param value The value to convert.
|
||||
@return Timestamp formatted as unix time.
|
||||
*/
|
||||
fn filetime_to_unix(u64 value) {
|
||||
return value / 10000000 - 11644473600;
|
||||
};
|
||||
|
||||
/**
|
||||
Formats a time according to the specified format string.
|
||||
@param time The time to format.
|
||||
@param [format_string] The format string to use. Defaults to "%c".
|
||||
@return The formatted time.
|
||||
*/
|
||||
fn format(Time time, str format_string = "%c") {
|
||||
le TimeConverter converter;
|
||||
converter.time = time;
|
||||
|
||||
return builtin::std::time::format(format_string, converter.value);
|
||||
};
|
||||
|
||||
/**
|
||||
Formats a DOS date according to the specified format string.
|
||||
@param date The DOS date to format.
|
||||
@param [format_string] The format string to use. Defaults to "{}/{}/{}".
|
||||
@return The formatted DOS date.
|
||||
*/
|
||||
fn format_dos_date(DOSDate date, str format_string = "{}/{}/{}") {
|
||||
return std::format(format_string, date.day, date.month, date.year + 1980);
|
||||
};
|
||||
|
||||
/**
|
||||
Formats a DOS time according to the specified format string.
|
||||
@param time The DOS time to format.
|
||||
@param [format_string] The format string to use. Defaults to "{:02}:{:02}:{:02}".
|
||||
@return The formatted DOS time.
|
||||
*/
|
||||
fn format_dos_time(DOSTime time, str format_string = "{:02}:{:02}:{:02}") {
|
||||
return std::format(format_string, time.hours, time.minutes, time.seconds * 2);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
55
includes/type/base.pat
Normal file
55
includes/type/base.pat
Normal file
@@ -0,0 +1,55 @@
|
||||
#pragma once
|
||||
|
||||
import std.io;
|
||||
import std.math;
|
||||
|
||||
/*!
|
||||
Types used to change the base of the displayed integer value.
|
||||
Used like `type::Hex<u32> hexNumber;`, `type::Oct<u16> octalNumber;`
|
||||
*/
|
||||
|
||||
namespace auto type {
|
||||
|
||||
/**
|
||||
Integer type representing a Hexadecimal value. Displays its value in hexadecimal format.
|
||||
@tparam T Integer type to use
|
||||
*/
|
||||
using Hex<T> = T [[format("type::impl::format_hex")]];
|
||||
|
||||
/**
|
||||
Integer type representing a Octal value. Displays its value in octal format.
|
||||
@tparam T Integer type to use
|
||||
*/
|
||||
using Oct<T> = T [[format("type::impl::format_oct")]];
|
||||
|
||||
/**
|
||||
Integer type representing a Decimal value. Displays its value in decimal format.
|
||||
@tparam T Integer type to use
|
||||
*/
|
||||
using Dec<T> = T [[format("type::impl::format_dec")]];
|
||||
|
||||
/**
|
||||
Integer type representing a Binary value. Displays its value in binary format.
|
||||
@tparam T Integer type to use
|
||||
*/
|
||||
using Bin<T> = T [[format("type::impl::format_bin")]];
|
||||
|
||||
namespace impl {
|
||||
|
||||
fn format_number(auto value, str fmt) {
|
||||
bool negative = value < 0;
|
||||
|
||||
if (negative)
|
||||
return std::format("-" + fmt, std::math::abs(value));
|
||||
else
|
||||
return std::format(fmt, value);
|
||||
};
|
||||
|
||||
fn format_hex(auto value) { return type::impl::format_number(value, "0x{:02X}"); };
|
||||
fn format_oct(auto value) { return type::impl::format_number(value, "0o{:03o}"); };
|
||||
fn format_dec(auto value) { return type::impl::format_number(value, "{}"); };
|
||||
fn format_bin(auto value) { return type::impl::format_number(value, "0b{:08b}"); };
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
64
includes/type/base64.pat
Normal file
64
includes/type/base64.pat
Normal file
@@ -0,0 +1,64 @@
|
||||
#pragma once
|
||||
import std.io;
|
||||
import std.string;
|
||||
import std.mem;
|
||||
|
||||
/*!
|
||||
Type representing a Base64 encoded string
|
||||
*/
|
||||
|
||||
namespace auto type {
|
||||
|
||||
/**
|
||||
Type representing a Base64 encoded string
|
||||
@tparam T String type
|
||||
*/
|
||||
struct Base64<T> {
|
||||
T string;
|
||||
} [[sealed, format("type::impl::transform_base64")]];
|
||||
|
||||
namespace impl {
|
||||
|
||||
fn get_decoded_value(char c) {
|
||||
if (c >= 'A' && c <= 'Z') return c - 'A';
|
||||
if (c >= 'a' && c <= 'z') return c - 'a' + 26;
|
||||
if (c >= '0' && c <= '9') return c - '0' + 52;
|
||||
if (c == '+') return 62;
|
||||
if (c == '/') return 63;
|
||||
return -1; // Invalid character
|
||||
};
|
||||
|
||||
fn decode_base64(str input) {
|
||||
u64 inputLength = std::string::length(input);
|
||||
str result;
|
||||
|
||||
s32 val = 0;
|
||||
s32 bits = -8;
|
||||
for (u32 i = 0, i < inputLength, i += 1) {
|
||||
char c = input[i];
|
||||
if (c == '=')
|
||||
break;
|
||||
|
||||
s32 index = type::impl::get_decoded_value(c);
|
||||
if (index == -1)
|
||||
continue;
|
||||
|
||||
val = (val << 6) + index;
|
||||
bits += 6;
|
||||
|
||||
if (bits >= 0) {
|
||||
result += char((val >> bits) & 0xFF);
|
||||
bits -= 8;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
};
|
||||
|
||||
fn transform_base64(ref auto base64) {
|
||||
return type::impl::decode_base64(base64.string);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
37
includes/type/bcd.pat
Normal file
37
includes/type/bcd.pat
Normal file
@@ -0,0 +1,37 @@
|
||||
#pragma once
|
||||
|
||||
import std.io;
|
||||
|
||||
/*!
|
||||
Type to decode a BCD (Binary Coded Decimal) number
|
||||
*/
|
||||
|
||||
namespace auto type {
|
||||
|
||||
/**
|
||||
Decodes a BCD value where one byte represents a single digit
|
||||
@tparam Digits Number of digits
|
||||
*/
|
||||
struct BCD<auto Digits> {
|
||||
u8 bytes[Digits];
|
||||
} [[sealed, format_read("type::impl::format_bcd")]];
|
||||
|
||||
namespace impl {
|
||||
|
||||
fn format_bcd(ref auto bcd) {
|
||||
str result;
|
||||
|
||||
for (u32 i = 0, i < sizeof(bcd.bytes), i += 1) {
|
||||
u8 byte = bcd.bytes[i];
|
||||
if (byte >= 10)
|
||||
return "Invalid";
|
||||
|
||||
result += std::format("{}", byte);
|
||||
}
|
||||
|
||||
return result;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,9 +1,17 @@
|
||||
#pragma once
|
||||
|
||||
#include <std/io.pat>
|
||||
import std.io;
|
||||
import std.core;
|
||||
|
||||
namespace type {
|
||||
|
||||
/*!
|
||||
Types to display single bytes using various different representations
|
||||
*/
|
||||
|
||||
namespace auto type {
|
||||
|
||||
/**
|
||||
Type visualizing the value of each individual bit
|
||||
*/
|
||||
bitfield Bits {
|
||||
bit0 : 1;
|
||||
bit1 : 1;
|
||||
@@ -13,13 +21,19 @@ namespace type {
|
||||
bit5 : 1;
|
||||
bit6 : 1;
|
||||
bit7 : 1;
|
||||
} [[format("type::impl::format_bits"), right_to_left]];
|
||||
|
||||
} [[format("type::impl::format_bits"), bitfield_order(std::core::BitfieldOrder::LeastToMostSignificant, 8)]];
|
||||
|
||||
/**
|
||||
Type visualizing the value of the two nibbles
|
||||
*/
|
||||
bitfield Nibbles {
|
||||
low : 4;
|
||||
high : 4;
|
||||
} [[format("type::impl::format_nibbles")]];
|
||||
|
||||
|
||||
/**
|
||||
Type representing a single Byte. Decodes the byte as it's hexadecimal value, individual bits and nibbles
|
||||
*/
|
||||
union Byte {
|
||||
u8 value;
|
||||
Bits bits;
|
||||
@@ -27,7 +41,7 @@ namespace type {
|
||||
} [[format("type::impl::format_byte"), single_color]];
|
||||
|
||||
|
||||
namespace impl {
|
||||
namespace impl {
|
||||
|
||||
fn format_byte(Byte byte) {
|
||||
return std::format("0x{0:02X} (0b{1:08b}) LSB:{2}, MSB:{3}",
|
||||
@@ -36,9 +50,9 @@ namespace type {
|
||||
byte.bits.bit0,
|
||||
byte.bits.bit7);
|
||||
};
|
||||
|
||||
|
||||
fn format_bits(Bits bits) {
|
||||
return std::format("0b{}{}{}{}{}{}{}{}",
|
||||
return std::format("0b{}{}{}{}{}{}{}{}",
|
||||
bits.bit7,
|
||||
bits.bit6,
|
||||
bits.bit5,
|
||||
@@ -48,11 +62,11 @@ namespace type {
|
||||
bits.bit1,
|
||||
bits.bit0);
|
||||
};
|
||||
|
||||
|
||||
fn format_nibbles(Nibbles nibbles) {
|
||||
return std::format("{{ {0:0X}, {1:0X} }}", nibbles.high, nibbles.low);
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
80
includes/type/color.pat
Normal file
80
includes/type/color.pat
Normal file
@@ -0,0 +1,80 @@
|
||||
#pragma once
|
||||
|
||||
import std.io;
|
||||
import std.core;
|
||||
|
||||
/*!
|
||||
Types representing RGB or RGBA colors. The decoded color will be displayed in their color field
|
||||
*/
|
||||
|
||||
namespace auto type {
|
||||
|
||||
/**
|
||||
Type representing a generic RGBA color with a variable number of bits for each color
|
||||
@tparam R Number of bits used for the red component
|
||||
@tparam G Number of bits used for the green component
|
||||
@tparam B Number of bits used for the blue component
|
||||
@tparam A Number of bits used for the alpha component
|
||||
*/
|
||||
bitfield RGBA<auto R, auto G, auto B, auto A> {
|
||||
r : R;
|
||||
g : G;
|
||||
b : B;
|
||||
if (A > 0) a : A;
|
||||
} [[sealed, format("type::impl::format_color"), color(std::format("{0:02X}{1:02X}{2:02X}", r, g, b))]];
|
||||
|
||||
/**
|
||||
Type representing a generic RGB color with a variable number of bits for each color
|
||||
@tparam R Number of bits used for the red component
|
||||
@tparam G Number of bits used for the green component
|
||||
@tparam B Number of bits used for the blue component
|
||||
*/
|
||||
using RGB<auto R, auto G, auto B> = RGBA<R,G,B,0>;
|
||||
|
||||
|
||||
/**
|
||||
Type representing a RGBA color with 8 bits for the red component, 8 bits for green, 8 bits for blue and 8 bits for alpha
|
||||
*/
|
||||
using RGBA8 = RGBA<8,8,8,8>;
|
||||
|
||||
/**
|
||||
Type representing a RGB color with 8 bits for the red component, 8 bits for green and 8 bits for blue
|
||||
*/
|
||||
using RGB8 = RGB<8,8,8>;
|
||||
|
||||
/**
|
||||
Type representing a RGB color with 5 bits for the red component, 6 bits for green and 5 bits for blue
|
||||
*/
|
||||
using RGB565 = RGB<5,6,5>;
|
||||
|
||||
/**
|
||||
Type representing a RGBA color with 4 bits for the red component, 4 bits for green, 4 bits for blue and 4 bits for alpha
|
||||
*/
|
||||
using RGB4444 = RGBA<4,4,4,4>;
|
||||
|
||||
/**
|
||||
Type representing a RGBA color with 5 bits for the red component, 5 bits for green, 5 bits for blue and 1 bits for alpha
|
||||
*/
|
||||
using RGBA5551 = RGBA<5,5,5,1>;
|
||||
|
||||
|
||||
namespace impl {
|
||||
|
||||
fn format_color(ref auto color) {
|
||||
if (!std::core::has_member(color, "a")) {
|
||||
return std::format("#{0:02X}{1:02X}{2:02X} | rgb({0}, {1}, {2})",
|
||||
color.r,
|
||||
color.g,
|
||||
color.b);
|
||||
} else {
|
||||
return std::format("#{0:02X}{1:02X}{2:02X}{3:02X} | rgba({0}, {1}, {2}, {3})",
|
||||
color.r,
|
||||
color.g,
|
||||
color.b,
|
||||
color.a);
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,29 +1,60 @@
|
||||
#pragma once
|
||||
|
||||
#include <std/io.pat>
|
||||
#include <std/math.pat>
|
||||
import std.io;
|
||||
import std.math;
|
||||
import std.mem;
|
||||
|
||||
namespace type {
|
||||
|
||||
/*!
|
||||
Type representing a 16 bit half precision floating point number
|
||||
*/
|
||||
|
||||
namespace auto type {
|
||||
|
||||
/**
|
||||
Type representing a 16 bit half precision floating point number
|
||||
*/
|
||||
using float16 = u16 [[format("type::impl::format_float16")]];
|
||||
|
||||
namespace impl {
|
||||
namespace impl {
|
||||
|
||||
fn format_float16(float16 value) {
|
||||
float sign = (value >> 15) == 0b01 ? -1.0 : 1.0;
|
||||
float exponent = std::math::pow(2.0, float((value >> 10) & 0x1F) - 14);
|
||||
u16 mantissa = value & 0x3FF;
|
||||
|
||||
float fraction = 0;
|
||||
for (s8 i = 9, i >= 0, i -= 1) {
|
||||
if ((mantissa & (1 << i)) != 0) {
|
||||
fraction += 1.0 / std::math::pow(2.0, (10.0 - i));
|
||||
}
|
||||
}
|
||||
|
||||
return std::format("{:f}", sign * exponent * fraction);
|
||||
union U32ToFloatConverter {
|
||||
u32 intValue;
|
||||
float floatValue;
|
||||
};
|
||||
|
||||
}
|
||||
fn format_float16(float16 value) {
|
||||
u32 sign = value >> 15;
|
||||
u32 exponent = (value >> 10) & 0x1F;
|
||||
u32 mantissa = value & 0x3FF;
|
||||
|
||||
}
|
||||
u32 result = 0x00;
|
||||
|
||||
if (exponent == 0) {
|
||||
if (mantissa == 0) {
|
||||
result = sign << 31;
|
||||
} else {
|
||||
exponent = 0x7F - 14;
|
||||
|
||||
while ((mantissa & (1 << 10)) == 0) {
|
||||
exponent -= 1;
|
||||
mantissa <<= 1;
|
||||
}
|
||||
|
||||
mantissa &= 0x3FF;
|
||||
result = (sign << 31) | (exponent << 23) | (mantissa << 13);
|
||||
}
|
||||
} else if (exponent == 0x1F) {
|
||||
result = (sign << 31) | (0xFF << 23) | (mantissa << 13);
|
||||
} else {
|
||||
result = (sign << 31) | ((exponent + (0x7F - 15)) << 23) | (mantissa << 13);
|
||||
}
|
||||
|
||||
std::mem::Reinterpreter<u32, float> converter;
|
||||
converter.from_value = result;
|
||||
|
||||
return std::format("{}", converter.to_value);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
42
includes/type/fmt.pat
Normal file
42
includes/type/fmt.pat
Normal file
@@ -0,0 +1,42 @@
|
||||
#pragma once
|
||||
|
||||
import std.io;
|
||||
|
||||
/*!
|
||||
Type that allows specifying its format value using a format string.
|
||||
## Usage
|
||||
|
||||
The following code reads a u32 from the data and formats it as an upper case hexadecimal value with
|
||||
a minimum of 8 digits which is prefixed by 0x.
|
||||
|
||||
The format string is the same as passed to `std::format()` and follows the libfmt specification.
|
||||
|
||||
```rust
|
||||
type::Formatted<u32, "0x{:08X}"> hex_formatted_integer @ 0x00;
|
||||
```
|
||||
*/
|
||||
|
||||
namespace auto type {
|
||||
|
||||
/**
|
||||
Arbitrarily formatted type
|
||||
@tparam T Type to format
|
||||
@tparam FormatString libfmt format string to format the value
|
||||
*/
|
||||
struct Formatted<T, auto FormatString> {
|
||||
T value;
|
||||
} [[sealed, format("type::impl::format_formatted"), transform("type::impl::transform_formatted")]];
|
||||
|
||||
namespace impl {
|
||||
|
||||
fn format_formatted(ref auto formatted) {
|
||||
return std::format(formatted.FormatString, formatted.value);
|
||||
};
|
||||
|
||||
fn transform_formatted(ref auto formatted) {
|
||||
return formatted.value;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,10 +1,17 @@
|
||||
#pragma once
|
||||
|
||||
#include <std/io.pat>
|
||||
import std.io;
|
||||
|
||||
namespace type {
|
||||
/*!
|
||||
Types to deal with UUIDs (Universally Unique Identifiers) / GUIDs (Globally Unique Identifiers) as described in RFC 4122
|
||||
*/
|
||||
|
||||
struct GUID {
|
||||
namespace auto type {
|
||||
|
||||
/**
|
||||
Type representing a GUID value
|
||||
*/
|
||||
struct GUID {
|
||||
u32 time_low;
|
||||
u16 time_mid;
|
||||
u16 time_high_and_version;
|
||||
@@ -13,26 +20,31 @@ namespace type {
|
||||
u8 node[6];
|
||||
} [[sealed, format("type::impl::format_guid")]];
|
||||
|
||||
namespace impl {
|
||||
/**
|
||||
Alias name for GUID
|
||||
*/
|
||||
using UUID = GUID;
|
||||
|
||||
fn format_guid(GUID guid) {
|
||||
bool valid = ((le u16(guid.time_high_and_version) >> 12) <= 5) && (((guid.clock_seq_and_reserved >> 4) >= 8) || ((guid.clock_seq_and_reserved >> 4) == 0));
|
||||
|
||||
return std::format("{}{{{:08X}-{:04X}-{:04X}-{:02X}{:02X}-{:02X}{:02X}{:02X}{:02X}{:02X}{:02X}}}",
|
||||
valid ? "" : "Invalid ",
|
||||
le u32(guid.time_low),
|
||||
le u16(guid.time_mid),
|
||||
le u16(guid.time_high_and_version),
|
||||
guid.clock_seq_and_reserved,
|
||||
guid.clock_seq_low,
|
||||
guid.node[0],
|
||||
guid.node[1],
|
||||
guid.node[2],
|
||||
guid.node[3],
|
||||
guid.node[4],
|
||||
guid.node[5]);
|
||||
};
|
||||
namespace impl {
|
||||
|
||||
}
|
||||
fn format_guid(GUID guid) {
|
||||
bool valid = ((le u16(guid.time_high_and_version) >> 12) <= 5) && (((guid.clock_seq_and_reserved >> 4) >= 8) || ((guid.clock_seq_and_reserved >> 4) == 0));
|
||||
|
||||
return std::format("{}{{{:08X}-{:04X}-{:04X}-{:02X}{:02X}-{:02X}{:02X}{:02X}{:02X}{:02X}{:02X}}}",
|
||||
valid ? "" : "Invalid ",
|
||||
le u32(guid.time_low),
|
||||
le u16(guid.time_mid),
|
||||
le u16(guid.time_high_and_version),
|
||||
guid.clock_seq_and_reserved,
|
||||
guid.clock_seq_low,
|
||||
guid.node[0],
|
||||
guid.node[1],
|
||||
guid.node[2],
|
||||
guid.node[3],
|
||||
guid.node[4],
|
||||
guid.node[5]);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,39 +1,67 @@
|
||||
#pragma once
|
||||
|
||||
#include <std/io.pat>
|
||||
import std.io;
|
||||
import std.string;
|
||||
|
||||
namespace type {
|
||||
/*!
|
||||
Types used to decode IP addresses
|
||||
*/
|
||||
|
||||
struct IPv4Address {
|
||||
u8 bytes[4];
|
||||
} [[sealed, format("type::impl::format_ipv4_address")]];
|
||||
namespace auto type {
|
||||
|
||||
/**
|
||||
A 4 byte IPv4 Address as described in RFC 791
|
||||
*/
|
||||
struct IPv4Address {
|
||||
u8 bytes[4];
|
||||
} [[sealed, format("type::impl::format_ipv4_address")]];
|
||||
|
||||
/**
|
||||
A 16 byte IPv6 Address as described in RFC 8200
|
||||
*/
|
||||
struct IPv6Address {
|
||||
u16 words[8];
|
||||
} [[sealed, format("type::impl::format_ipv6_address")]];
|
||||
|
||||
namespace impl {
|
||||
|
||||
fn format_ipv4_address(IPv4Address address) {
|
||||
return std::format("{}.{}.{}.{}",
|
||||
address.bytes[0],
|
||||
address.bytes[1],
|
||||
address.bytes[2],
|
||||
address.bytes[3]);
|
||||
};
|
||||
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],
|
||||
address.bytes[1],
|
||||
address.bytes[2],
|
||||
address.bytes[3]);
|
||||
};
|
||||
|
||||
fn format_ipv6_address(IPv6Address address) {
|
||||
return std::format("{:04X}:{:04X}:{:04X}:{:04X}:{:04X}:{:04X}:{:04X}:{:04X}",
|
||||
address.words[0],
|
||||
address.words[1],
|
||||
address.words[2],
|
||||
address.words[3],
|
||||
address.words[4],
|
||||
address.words[5],
|
||||
address.words[6],
|
||||
address.words[7]);
|
||||
};
|
||||
|
||||
}
|
||||
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("{:X}", address.words[i]);
|
||||
}
|
||||
|
||||
result += ":";
|
||||
}
|
||||
|
||||
return std::string::substr(result, 0, std::string::length(result) - 1);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,33 +1,72 @@
|
||||
#pragma once
|
||||
|
||||
#include <std/io.pat>
|
||||
#include <std/mem.pat>
|
||||
import std.io;
|
||||
import std.mem;
|
||||
|
||||
/*!
|
||||
Types used to decode Little Endian Base 128 numbers used to store large numbers as space efficiently as possible
|
||||
*/
|
||||
|
||||
namespace auto type {
|
||||
|
||||
/**
|
||||
Base LEB128 type. Use `uLEB128` and `sLEB128` instead.
|
||||
*/
|
||||
struct LEB128Base {
|
||||
u8 array[while($ == addressof(this) || std::mem::read_unsigned($-1, 1) & 0x80 != 0)] [[hidden]];
|
||||
} [[sealed]];
|
||||
|
||||
/**
|
||||
A unsigned variant of a LEB128 number
|
||||
*/
|
||||
using uLEB128 = LEB128Base [[format("type::impl::format_uleb128"), transform("type::impl::transform_uleb128")]];
|
||||
|
||||
/**
|
||||
A signed variant of a LEB128 number
|
||||
*/
|
||||
using sLEB128 = LEB128Base [[format("type::impl::format_sleb128"), transform("type::impl::transform_sleb128")]];
|
||||
|
||||
/**
|
||||
Legacy alias for uLEB128
|
||||
*/
|
||||
using LEB128 = uLEB128;
|
||||
|
||||
namespace impl {
|
||||
|
||||
fn transform_uleb128_array(ref auto array) {
|
||||
u128 res = array[0] & 0x7f;
|
||||
for(u8 i = 1, array[i-1] & 0x80 != 0, i+=1) {
|
||||
res |= u128(array[i] & 0x7f) << 7 * i;
|
||||
}
|
||||
return res;
|
||||
};
|
||||
|
||||
fn transform_sleb128_array(ref auto array) {
|
||||
s128 res = type::impl::transform_uleb128_array(array);
|
||||
if (res & 1 << ((sizeof(array) / sizeof(u8)) * 7 - 1) != 0) {
|
||||
res |= ~0 << (sizeof(array) / sizeof(u8)) * 7;
|
||||
}
|
||||
return res;
|
||||
};
|
||||
|
||||
fn format_uleb128(ref auto leb128) {
|
||||
u128 res = type::impl::transform_uleb128_array(leb128.array);
|
||||
return std::format("{} ({:#x})", res, res);
|
||||
};
|
||||
|
||||
fn transform_uleb128(ref auto leb128) {
|
||||
return type::impl::transform_uleb128_array(leb128.array);
|
||||
};
|
||||
|
||||
fn format_sleb128(ref auto leb128) {
|
||||
s128 res = type::impl::transform_sleb128_array(leb128.array);
|
||||
return std::format("{} ({:#x})", res, res);
|
||||
};
|
||||
|
||||
fn transform_sleb128(ref auto leb128) {
|
||||
return type::impl::transform_sleb128_array(leb128.array);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
namespace type {
|
||||
|
||||
struct LEB128 {
|
||||
u8 array[while($ == addressof(this) || std::mem::read_unsigned($-1, 1) & 0x80 != 0)] [[hidden]];
|
||||
} [[sealed, format("type::impl::format_leb128"), transform("type::impl::transform_leb128")]];
|
||||
|
||||
namespace impl {
|
||||
|
||||
fn transform_leb128_array(auto array) {
|
||||
u128 res = array[0] & 0x7f;
|
||||
for(u8 i = 1, array[i-1] & 0x80 != 0, i+=1) {
|
||||
res |= u64(array[i] & 0x7f) << 7 * i;
|
||||
}
|
||||
return res;
|
||||
};
|
||||
|
||||
fn format_leb128(auto leb128) {
|
||||
u128 res = type::impl::transform_leb128_array(leb128.array);
|
||||
return std::format("{} ({:#x})", res, res);
|
||||
};
|
||||
|
||||
fn transform_leb128(auto leb128) {
|
||||
return type::impl::transform_leb128_array(leb128.array);
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -1,25 +1,32 @@
|
||||
#pragma once
|
||||
|
||||
#include <std/io.pat>
|
||||
import std.io;
|
||||
|
||||
namespace type {
|
||||
/*!
|
||||
Types used to decode MAC Addresses
|
||||
*/
|
||||
|
||||
struct MACAddress {
|
||||
u8 bytes[6];
|
||||
} [[sealed, format("type::impl::format_mac_address")]];
|
||||
namespace auto type {
|
||||
|
||||
namespace impl {
|
||||
/**
|
||||
A MAC Address as used in the Internet Protocol
|
||||
*/
|
||||
struct MACAddress {
|
||||
u8 bytes[6];
|
||||
} [[sealed, format("type::impl::format_mac_address")]];
|
||||
|
||||
namespace impl {
|
||||
|
||||
fn format_mac_address(MACAddress address) {
|
||||
return std::format("{:02X}:{:02X}:{:02X}:{:02X}:{:02X}:{:02X}",
|
||||
address.bytes[0],
|
||||
address.bytes[1],
|
||||
address.bytes[2],
|
||||
address.bytes[3],
|
||||
address.bytes[4],
|
||||
address.bytes[5]);
|
||||
};
|
||||
return std::format("{:02X}:{:02X}:{:02X}:{:02X}:{:02X}:{:02X}",
|
||||
address.bytes[0],
|
||||
address.bytes[1],
|
||||
address.bytes[2],
|
||||
address.bytes[3],
|
||||
address.bytes[4],
|
||||
address.bytes[5]);
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
47
includes/type/magic.pat
Normal file
47
includes/type/magic.pat
Normal file
@@ -0,0 +1,47 @@
|
||||
#pragma once
|
||||
|
||||
import std.string;
|
||||
import std.sys;
|
||||
import std.io;
|
||||
import std.ctype;
|
||||
|
||||
/*!
|
||||
Types used to parse and enforce specific magic numbers
|
||||
*/
|
||||
|
||||
namespace auto type
|
||||
{
|
||||
|
||||
/**
|
||||
Escapes all bytes in a string to only contain printable characters. All non-printable bytes will be transformed to sequences in the \xFF form
|
||||
@param value Byte array to escape
|
||||
@return Escaped string
|
||||
*/
|
||||
fn escape_bytes(ref auto value) {
|
||||
str result;
|
||||
for (u32 i = 0, i < sizeof(value), i += 1)
|
||||
{
|
||||
char c = value[i];
|
||||
|
||||
if (std::ctype::isprint(c))
|
||||
result += c;
|
||||
else
|
||||
result += std::format("\\x{:02X}", u8(c));
|
||||
}
|
||||
return result;
|
||||
};
|
||||
|
||||
/**
|
||||
A Magic number. Throws an error if the magic number does not match the expected value
|
||||
@tparam ExpectedValue A string representing the expected value
|
||||
*/
|
||||
struct Magic<auto ExpectedValue> {
|
||||
char value[std::string::length(ExpectedValue)];
|
||||
std::assert(value == ExpectedValue, std::format("Invalid magic value! Expected \"{}\", got \"{}\" at position 0x{:X}", type::escape_bytes(ExpectedValue), type::escape_bytes(value), $ - std::string::length(ExpectedValue)));
|
||||
} [[sealed, format("type::impl::format_magic")]];
|
||||
namespace impl {
|
||||
fn format_magic(ref auto magic) {
|
||||
return std::format("\"{}\"", type::escape_bytes(magic.value));
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -1,32 +1,55 @@
|
||||
#include <std/mem.pat>
|
||||
#pragma once
|
||||
|
||||
namespace type {
|
||||
import std.mem;
|
||||
|
||||
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));
|
||||
};
|
||||
|
||||
}
|
||||
/*!
|
||||
Types dealing with various kinds of resource paths
|
||||
*/
|
||||
|
||||
}
|
||||
namespace auto type {
|
||||
|
||||
/**
|
||||
Type representing a single path segment. Use the `Path` type instead of using this on its own
|
||||
@tparam Delimiter The delimiter sequence used to separate two path segments
|
||||
*/
|
||||
struct PathSegment<auto Delimiter> {
|
||||
char string[while(std::mem::read_string($, std::string::length(Delimiter)) != Delimiter && std::mem::read_unsigned($, 1) != 0x00)];
|
||||
char separator [[hidden]];
|
||||
|
||||
if (separator == 0x00) {
|
||||
$ -= 1;
|
||||
break;
|
||||
}
|
||||
} [[sealed, format("type::impl::format_path_segment")]];
|
||||
|
||||
/**
|
||||
A generic type representing a path with an arbitrary delimiter
|
||||
@tparam Delimiter The delimiter sequence used to separate two path segments
|
||||
*/
|
||||
struct Path<auto Delimiter> {
|
||||
PathSegment<Delimiter> segments[while(true)];
|
||||
} [[format("type::impl::format_path")]];
|
||||
|
||||
/**
|
||||
A type representing a Unix path using a '/' forward slash as delimiter
|
||||
*/
|
||||
using UnixPath = Path<"/">;
|
||||
|
||||
/**
|
||||
A type representing a DOS path using a '\\' backslash as delimiter
|
||||
*/
|
||||
using DOSPath = Path<"\\">;
|
||||
|
||||
namespace impl {
|
||||
|
||||
fn format_path_segment(ref auto segment) {
|
||||
return segment.string;
|
||||
};
|
||||
|
||||
fn format_path(ref auto path) {
|
||||
return std::mem::read_string($, sizeof(path));
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,10 +1,39 @@
|
||||
namespace type {
|
||||
#pragma once
|
||||
|
||||
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")]];
|
||||
import std.io;
|
||||
|
||||
/*!
|
||||
Types used to pretty print size values
|
||||
*/
|
||||
|
||||
namespace auto type {
|
||||
|
||||
/**
|
||||
A generic size type which displays its value in Bytes (or kiB, MiB, GiB, TiB, PiB, EiB if larger)
|
||||
@tparam T Underlying type
|
||||
*/
|
||||
using Size<T> = T [[format("type::impl::size_formatter")]];
|
||||
|
||||
/**
|
||||
A 8 bit size type
|
||||
*/
|
||||
using Size8 = Size<u8>;
|
||||
/**
|
||||
A 16 bit size type
|
||||
*/
|
||||
using Size16 = Size<u16>;
|
||||
/**
|
||||
A 32 bit size type
|
||||
*/
|
||||
using Size32 = Size<u32>;
|
||||
/**
|
||||
A 64 bit size type
|
||||
*/
|
||||
using Size64 = Size<u64>;
|
||||
/**
|
||||
A 128 bit size type
|
||||
*/
|
||||
using Size128 = Size<u128>;
|
||||
|
||||
namespace impl {
|
||||
|
||||
|
||||
@@ -1,19 +1,62 @@
|
||||
#pragma once
|
||||
|
||||
#include <std/io.pat>
|
||||
#include <std/time.pat>
|
||||
import std.io;
|
||||
import std.time;
|
||||
|
||||
namespace type {
|
||||
|
||||
/*!
|
||||
Types used to decode various different time formats
|
||||
*/
|
||||
|
||||
namespace auto type {
|
||||
|
||||
/**
|
||||
A 32 bit Unix time value
|
||||
*/
|
||||
using time32_t = u32 [[format("type::impl::format_time_t")]];
|
||||
|
||||
/**
|
||||
Alias name for `time32_t`
|
||||
*/
|
||||
using time_t = time32_t;
|
||||
|
||||
/**
|
||||
A 64 bit Unix time value
|
||||
*/
|
||||
using time64_t = u64 [[format("type::impl::format_time_t")]];
|
||||
|
||||
/**
|
||||
A DOS Date value
|
||||
*/
|
||||
using DOSDate = u16 [[format("type::impl::format_dosdate")]];
|
||||
|
||||
/**
|
||||
A DOS Time value
|
||||
*/
|
||||
using DOSTime = u16 [[format("type::impl::format_dostime")]];
|
||||
|
||||
/**
|
||||
A 64bit FILETIME value
|
||||
*/
|
||||
using FILETIME = u64 [[format("type::impl::format_filetime_as_unix")]];
|
||||
|
||||
namespace impl {
|
||||
|
||||
fn format_time_t(u128 value) {
|
||||
fn format_time_t(u128 value) {
|
||||
return std::time::format(std::time::to_utc(value));
|
||||
};
|
||||
|
||||
fn format_dosdate(u16 value) {
|
||||
return std::time::format_dos_date(std::time::to_dos_date(value));
|
||||
};
|
||||
|
||||
fn format_dostime(u16 value) {
|
||||
return std::time::format_dos_time(std::time::to_dos_time(value));
|
||||
};
|
||||
|
||||
fn format_filetime_as_unix(u64 value) {
|
||||
return std::time::filetime_to_unix(value);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,7 +1,11 @@
|
||||
#pragma once
|
||||
|
||||
/*!
|
||||
Alias types to make it easier to move template definitions over from 010 Editor to ImHex
|
||||
*/
|
||||
|
||||
// Explicitly don't add these types to the `type` namespace for usability
|
||||
// namespace type {
|
||||
// namespace auto type {
|
||||
|
||||
// using char = s8;
|
||||
using byte = s8;
|
||||
@@ -11,7 +15,7 @@
|
||||
using uchar = u8;
|
||||
using ubyte = u8;
|
||||
using UCHAR = u8;
|
||||
using ubyte = u8;
|
||||
using UBYTE = u8;
|
||||
|
||||
|
||||
using short = s16;
|
||||
@@ -59,4 +63,4 @@
|
||||
// using double = double;
|
||||
using DOUBLE = double;
|
||||
|
||||
// }
|
||||
// }
|
||||
|
||||
@@ -1,7 +1,11 @@
|
||||
#pragma once
|
||||
|
||||
/*!
|
||||
Alias definitions for all C stdint and regular data types
|
||||
*/
|
||||
|
||||
// Explicitly don't add these types to the `type` namespace for usability
|
||||
// namespace type {
|
||||
// namespace auto type {
|
||||
|
||||
using uint8_t = u8;
|
||||
using uint16_t = u16;
|
||||
|
||||
@@ -1,7 +1,11 @@
|
||||
#pragma once
|
||||
|
||||
/*!
|
||||
Various data types used in the Linux Kernel
|
||||
*/
|
||||
|
||||
// Explicitly don't add these types to the `type` namespace for usability
|
||||
// namespace type {
|
||||
// namespace auto type {
|
||||
|
||||
using le16 = le u16;
|
||||
using be16 = be u16;
|
||||
|
||||
@@ -1,7 +1,11 @@
|
||||
#pragma once
|
||||
|
||||
/*!
|
||||
Alias definitions for Rust's data types
|
||||
*/
|
||||
|
||||
// Explicitly don't add these types to the `type` namespace for usability
|
||||
// namespace type {
|
||||
// namespace auto type {
|
||||
|
||||
// using u8 = u8;
|
||||
// using u16 = u16;
|
||||
|
||||
@@ -1,7 +1,11 @@
|
||||
#pragma once
|
||||
|
||||
/*!
|
||||
Alias definitions for various type names used in Windows applications
|
||||
*/
|
||||
|
||||
// Explicitly don't add these types to the `type` namespace for usability
|
||||
// namespace type {
|
||||
// namespace auto type {
|
||||
|
||||
using BYTE = u8;
|
||||
using WORD = u16;
|
||||
|
||||
41
magic/arma3_magic
Normal file
41
magic/arma3_magic
Normal file
@@ -0,0 +1,41 @@
|
||||
# A libmagic database containing definitions for files used by the Arma 3 game by Bohemia Interactive
|
||||
|
||||
# Arma 3 PAA image
|
||||
0x02 string GGAT Arma 3 PAA image file
|
||||
!:mime image/x.a3-paa
|
||||
!:ext paa
|
||||
>0 leshort 0xff01 DXT1 compression
|
||||
>0 leshort 0xff02 DXT2 compression
|
||||
>0 leshort 0xff03 DXT3 compression
|
||||
>0 leshort 0xff04 DXT4 compression
|
||||
>0 leshort 0xff05 DXT5 compression
|
||||
>0 leshort 0x4444 RGBA4 format
|
||||
>0 leshort 0x1555 RGBA5 format
|
||||
>0 leshort 0x8888 RGBA8 format
|
||||
>0 leshort 0x8080 Grayscale format
|
||||
|
||||
# Arma 3 RTM animation
|
||||
0 string RTM_ Arma 3 RTM animation file (plain)
|
||||
!:mime application/x.a3-rtm
|
||||
!:ext rtm
|
||||
|
||||
# Arma 3 binarized RTM animation
|
||||
0 string BMTR Arma 3 RTM animation file (binarized)
|
||||
!:mime application/x.a3-bmtr
|
||||
!:ext rtm
|
||||
|
||||
# Arma 3 texture index
|
||||
0 string 0DHT Arma 3 texture index file
|
||||
!:mime application/x.a3-texheaders
|
||||
!:ext bin
|
||||
|
||||
# Arma 3 MLOD P3D model
|
||||
0 string MLOD Arma 3 P3D model file (MLOD)
|
||||
!:mime model/x.a3-p3d-mlod
|
||||
!:ext p3d
|
||||
>0x0c string P3DM P3DM LOD type
|
||||
|
||||
# Arma 3 binarized config
|
||||
0x01 string raP Arma 3 binary configuration file
|
||||
!:mime application/x.a3-rap
|
||||
!:ext bin
|
||||
@@ -1,4 +1,4 @@
|
||||
# A libmagic database containing definition for PE files used by MS-DOS based systems
|
||||
# A libmagic database containing definition for PE files used by MS-DOS/Windows based systems
|
||||
|
||||
# MS-DOS Portable Executable
|
||||
0x0 string/b MZ MS-DOS Binary
|
||||
|
||||
219
nodes/caesar.hexnode
Normal file
219
nodes/caesar.hexnode
Normal 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
223
nodes/xor.hexnode
Normal 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"
|
||||
}
|
||||
1141
patterns/3ds.hexpat
Normal file
1141
patterns/3ds.hexpat
Normal file
File diff suppressed because it is too large
Load Diff
93
patterns/7z.hexpat
Normal file
93
patterns/7z.hexpat
Normal file
@@ -0,0 +1,93 @@
|
||||
#pragma description 7z Archive
|
||||
#pragma MIME application/x-7z-compressed
|
||||
#pragma magic [ 37 7A BC AF 27 1C ] @ 0x00
|
||||
|
||||
import std.io;
|
||||
import std.mem;
|
||||
import std.math;
|
||||
import type.magic;
|
||||
|
||||
|
||||
enum Type:u8{
|
||||
startPosition = 0x00, // Start position
|
||||
sizeStartHeader = 0x20, // Size of start Header
|
||||
};
|
||||
|
||||
struct StartHeader {
|
||||
// File signature
|
||||
type::Magic<"7z\xBC\xAF\x27\x1C"> signature [[color("FF0000")] ];
|
||||
// Version format
|
||||
u16 formatVersion [[color("00FF00")]];
|
||||
// CRC start header
|
||||
u32 crcOfTheFollowing20Bytes [[color("0000FF")]];
|
||||
// Relative offset of End Header
|
||||
u64 relativeOffsetEndHeader [[color("FFFF00")]];
|
||||
// Length of End Header
|
||||
u64 theLengthOfEndHeader [[color("00FFFF")]];
|
||||
// CRC of End Ender
|
||||
u32 crcOftheEndHeader [[color("FF00FF")]];
|
||||
// File size calculation
|
||||
u64 fileSize = relativeOffsetEndHeader + theLengthOfEndHeader + Type::sizeStartHeader;
|
||||
// Absolute offset calculation End Header
|
||||
u64 startEndHeader = relativeOffsetEndHeader + Type::sizeStartHeader;
|
||||
};
|
||||
|
||||
StartHeader startheader @ Type::startPosition;
|
||||
|
||||
struct CompressedData {
|
||||
// Start of compressed data
|
||||
u8 startOfCompressedData[4] [[color("C0C0C0")]];
|
||||
};
|
||||
|
||||
CompressedData compresseddata @ Type::sizeStartHeader;
|
||||
|
||||
|
||||
struct EndHeader {
|
||||
// Set padding to place End Header in right position
|
||||
padding[startheader.relativeOffsetEndHeader];
|
||||
// Mark link to meta block
|
||||
u8 linkToMetaBlock [[color("FF0000")]];
|
||||
// Mark all End Header
|
||||
char fullEndHeader[startheader.theLengthOfEndHeader] [[color("63954A")]];
|
||||
// Detect LZMA signature
|
||||
u64 lzmaSignaturePosition = std::mem::find_sequence_in_range(0, addressof(fullEndHeader), addressof(fullEndHeader) + sizeof(fullEndHeader), 0x23, 0x03, 0x01, 0x01, 0x05, 0x5D);
|
||||
|
||||
// Mark positions if LZMA signature was detected
|
||||
if(lzmaSignaturePosition != 0xFFFFFFFFFFFFFFFF){
|
||||
u48 lzmaSignature @ lzmaSignaturePosition [[color("0000FF")]];
|
||||
}
|
||||
};
|
||||
|
||||
EndHeader endheader @ Type::sizeStartHeader;
|
||||
|
||||
std::print("Format Version {} ",startheader.formatVersion);
|
||||
|
||||
// Version verification
|
||||
if(startheader.formatVersion == 0x0400){
|
||||
std::print("Major Version 0x00 || 0 - Minor Version 0x04 || 4");
|
||||
}
|
||||
|
||||
// Verification of the compressed method is LZMA, Bzip2 or LZMA2
|
||||
if(compresseddata.startOfCompressedData[0] == Type::startPosition){
|
||||
std::print("Compressed Method LZMA");
|
||||
}else if(compresseddata.startOfCompressedData[0] == 0x42){
|
||||
std::print("Compressed Method Bzip2");
|
||||
}else{
|
||||
std::print("Compressed Method LZMA2");
|
||||
}
|
||||
|
||||
|
||||
|
||||
std::print("CRC Start Header 0x{:X}",startheader.crcOfTheFollowing20Bytes);
|
||||
|
||||
std::print("CRC End Header 0x{:X} ", startheader.crcOftheEndHeader);
|
||||
|
||||
std::print("CompressedData length 0x{:X} || {} bytes ",startheader.relativeOffsetEndHeader, startheader.relativeOffsetEndHeader);
|
||||
|
||||
std::print("Relative Offset of End Header 0x{:X} || {} bytes",startheader.relativeOffsetEndHeader, startheader.relativeOffsetEndHeader);
|
||||
|
||||
std::print("Offset to start End Header 0x{:X} || {} bytes",startheader.startEndHeader,startheader.startEndHeader);
|
||||
|
||||
std::print("End Header length 0x{:X} || {} bytes",startheader.theLengthOfEndHeader,startheader.theLengthOfEndHeader);
|
||||
|
||||
std::print("File size 0x{:X} || {} bytes",startheader.fileSize, startheader.fileSize);
|
||||
47
patterns/AC Unity/acu_data_compressed.hexpat
Normal file
47
patterns/AC Unity/acu_data_compressed.hexpat
Normal file
@@ -0,0 +1,47 @@
|
||||
#pragma description Assassin's Creed: Unity's Compressed .data file
|
||||
#pragma author haru233
|
||||
|
||||
// many thanks to AxCut
|
||||
// ImHex Hex Pattern File for Assassin's Creed: Unity's Compressed .data files
|
||||
|
||||
|
||||
import std.core;
|
||||
import std.mem;
|
||||
|
||||
enum CompressionType : u8 {
|
||||
LZO1X_ = 0x00, // Both 0x00 and 0x01 mean LZO1X
|
||||
LZO1X = 0x01,
|
||||
LZO2A = 0x02,
|
||||
xmemdecompress = 0x03,
|
||||
LZO1C = 0x05
|
||||
};
|
||||
|
||||
struct CHUNK {
|
||||
u16 Uncompressed_Size;
|
||||
u16 Compressed_Size;
|
||||
};
|
||||
|
||||
struct CHUNK_Data {
|
||||
u32 Hash;
|
||||
|
||||
u64 i = std::core::array_index();
|
||||
u8 data[parent.chunk[i].Compressed_Size];
|
||||
};
|
||||
|
||||
struct PACK {
|
||||
u64 ID;
|
||||
padding[2];
|
||||
CompressionType Compression_Type;
|
||||
padding[3];
|
||||
u8 Version;
|
||||
u16 CHUNK_Count;
|
||||
|
||||
CHUNK chunk[CHUNK_Count];
|
||||
CHUNK_Data data[CHUNK_Count];
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
PACK pack[while(!std::mem::eof())] @0x00;
|
||||
93
patterns/AC Unity/acu_data_decompressed.hexpat
Normal file
93
patterns/AC Unity/acu_data_decompressed.hexpat
Normal file
@@ -0,0 +1,93 @@
|
||||
#pragma description Assassin's Creed: Unity's Decompressed .data file
|
||||
#pragma author haru233
|
||||
|
||||
// Thanks to yretenai on GitHub for helping with the Block Allocator part
|
||||
|
||||
import std.core;
|
||||
import std.mem;
|
||||
|
||||
struct Block_Allocator_Type0 {
|
||||
padding[4];
|
||||
u32 Class_ID;
|
||||
u32 Size;
|
||||
};
|
||||
|
||||
struct Block_Allocator_Type1 {
|
||||
padding[4];
|
||||
u32 Type_ID;
|
||||
u32 Size;
|
||||
};
|
||||
|
||||
struct Block_Allocator {
|
||||
u16 Version;
|
||||
|
||||
if (Version == 0) {
|
||||
u32 Block_Allocator_Number;
|
||||
Block_Allocator_Type0 block_allocator_type0[Block_Allocator_Number];
|
||||
}
|
||||
|
||||
else if (Version == 1) {
|
||||
u32 Block_Allocator_Number;
|
||||
Block_Allocator_Type1 block_allocator_type1_[Block_Allocator_Number];
|
||||
}
|
||||
|
||||
else if (Version == 2) {
|
||||
bool Has_Secondary_Block_Allocator;
|
||||
u32 Main_Block_Allocator_Number;
|
||||
|
||||
Block_Allocator_Type1 block_allocator_type1__[Main_Block_Allocator_Number];
|
||||
|
||||
if (Has_Secondary_Block_Allocator) {
|
||||
u32 Secondary_Block_Allocator_Number;
|
||||
Block_Allocator_Type1 block_allocator_type1___[Secondary_Block_Allocator_Number+1];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
struct File {
|
||||
u32 Object_Hash;
|
||||
u32 File_Size;
|
||||
u32 Filename_Length;
|
||||
|
||||
if (File_Size > 0) {
|
||||
if (Filename_Length == 0) {
|
||||
bool HasBlockAllocator;
|
||||
|
||||
if (HasBlockAllocator) {
|
||||
Block_Allocator block_allocator;
|
||||
u8 File_Data[File_Size];
|
||||
}
|
||||
|
||||
else
|
||||
u8 File_Data[File_Size];
|
||||
}
|
||||
|
||||
else {
|
||||
char Filename[Filename_Length];
|
||||
|
||||
bool HasBlockAllocator;
|
||||
|
||||
if (HasBlockAllocator) {
|
||||
Block_Allocator block_allocator;
|
||||
u8 File_Data[File_Size];
|
||||
}
|
||||
|
||||
else
|
||||
u8 File_Data[File_Size];
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
else
|
||||
continue;
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
File file[while(!std::mem::eof())] @0x00;
|
||||
64
patterns/AC Unity/acu_forge.hexpat
Normal file
64
patterns/AC Unity/acu_forge.hexpat
Normal file
@@ -0,0 +1,64 @@
|
||||
#pragma description Assassin's Creed: Unity's .forge archive file
|
||||
#pragma author haru233
|
||||
|
||||
// many thanks to AxCut
|
||||
// ImHex Hex Pattern File for Assassin's Creed: Unity's .forge files
|
||||
|
||||
import std.core;
|
||||
|
||||
struct Forge_Header {
|
||||
char MAGIC[8];
|
||||
padding[1];
|
||||
u32 Version;
|
||||
u32 File_Data_Header_Offset;
|
||||
};
|
||||
|
||||
struct File_Data_Header {
|
||||
u32 File_Count;
|
||||
padding[32];
|
||||
u64 File_Data_Header2_Offset;
|
||||
};
|
||||
|
||||
struct File_Data_Header2 {
|
||||
u32 File_Count2;
|
||||
padding[4];
|
||||
u64 File_Table_Offset;
|
||||
padding[12];
|
||||
u32 File_Count3;
|
||||
u64 File_Name_Table_Offset;
|
||||
padding[8];
|
||||
};
|
||||
|
||||
|
||||
struct File_Table {
|
||||
u64 Raw_Data_Offset;
|
||||
u64 File_ID;
|
||||
u32 Raw_Data_Size;
|
||||
};
|
||||
|
||||
struct File_Name_Table {
|
||||
u32 Raw_Data_Size;
|
||||
padding[40];
|
||||
char Filename[128];
|
||||
padding[20];
|
||||
};
|
||||
|
||||
|
||||
Forge_Header forge_header @0x00;
|
||||
|
||||
File_Data_Header file_data_header @(forge_header.File_Data_Header_Offset);
|
||||
|
||||
File_Data_Header2 file_data_header2 @(file_data_header.File_Data_Header2_Offset);
|
||||
|
||||
File_Table file_table[file_data_header.File_Count] @(file_data_header2.File_Table_Offset);
|
||||
|
||||
File_Name_Table file_name_table[file_data_header.File_Count] @(file_data_header2.File_Name_Table_Offset);
|
||||
|
||||
|
||||
struct Raw_Data_Table {
|
||||
u64 i = std::core::array_index();
|
||||
u8 Raw_Data[file_table[i].Raw_Data_Size] @ file_table[i].Raw_Data_Offset;
|
||||
};
|
||||
|
||||
|
||||
Raw_Data_Table raw_data_table[file_data_header.File_Count] @0x00;
|
||||
371
patterns/Crashlvl.hexpat
Normal file
371
patterns/Crashlvl.hexpat
Normal file
@@ -0,0 +1,371 @@
|
||||
#pragma author AdventureT
|
||||
#pragma description Crash Bandicoot - Back in Time (fan game) User created level
|
||||
#pragma magic [ 43 52 41 53 48 4C 56 4C ] @ 0x00
|
||||
#pragma history
|
||||
#pragma 0.3 2024-05-15 Added support for version 0.95
|
||||
#pragma 0.2 2023-10-29 Added support for version 0.94c
|
||||
#pragma 0.1 2023-04-25 Initial support
|
||||
// Supports all versions till 0.95, newer versions might be compatible!
|
||||
|
||||
import type.magic;
|
||||
import std.string;
|
||||
import std.array;
|
||||
|
||||
struct Header {
|
||||
type::Magic<"CRASHLVL"> magic;
|
||||
u8 version;
|
||||
if (version >= 4) {
|
||||
std::string::SizedString<u8> gameVersion;
|
||||
}
|
||||
std::string::SizedString<u8> levelName;
|
||||
std::string::SizedString<u8> author;
|
||||
};
|
||||
|
||||
// Background Music
|
||||
enum BGM : u32 {
|
||||
None,
|
||||
BonusBGM,
|
||||
CrashCreatorBGM,
|
||||
MainMenuBGM,
|
||||
WarpRoomBGM,
|
||||
Level01BGM,
|
||||
Level02BGM,
|
||||
Level03BGM,
|
||||
Level04BGM,
|
||||
Level05BGM,
|
||||
SewerBGM,
|
||||
EgyptBGM,
|
||||
NBrioBGM
|
||||
};
|
||||
|
||||
enum BGMV2 : u32 {
|
||||
None,
|
||||
N_TropyBGM,
|
||||
CrashCreatorBGM,
|
||||
MainMenuBGM,
|
||||
WarpRoomBGM,
|
||||
Jungle01BGM,
|
||||
SnowBGM,
|
||||
RiverBGM,
|
||||
FutureBGM,
|
||||
LabBGM,
|
||||
SewerBGM,
|
||||
EgyptBGM,
|
||||
NBrioBGM,
|
||||
AdventureBGM,
|
||||
SpyBGM,
|
||||
ChaseBGM,
|
||||
TrialsBGM,
|
||||
SpaceBGM,
|
||||
Jungle02BGM,
|
||||
RipperBGM,
|
||||
TheGreatWallBGM,
|
||||
RoadToSomewhereBGM,
|
||||
LavaKoalaBGM,
|
||||
CortexBGM,
|
||||
CyberCortexBGM,
|
||||
ArabicBGM,
|
||||
N_Tropy2BGM,
|
||||
JazzBGM,
|
||||
Space2BGM,
|
||||
TawnaBonusBGM,
|
||||
CortexPowerBGM,
|
||||
ArabicBonusBGM,
|
||||
EgyptBonusBGM,
|
||||
FutureBonusBGM,
|
||||
LostCityBGM,
|
||||
PolarBGM,
|
||||
RiverBonusBGM,
|
||||
RuinsBonusBGM,
|
||||
SewerBonusBGM,
|
||||
SnowBonusBGM,
|
||||
RoadToRuinBGM,
|
||||
NGinBGM,
|
||||
Arabia01BGM,
|
||||
Arabia02BGM,
|
||||
BashBGM,
|
||||
Cortex02BGM
|
||||
};
|
||||
|
||||
// v0.95
|
||||
enum BGMV3 : BGMV2 {
|
||||
None,
|
||||
N_TropyBGM,
|
||||
CrashCreatorBGM,
|
||||
MainMenuBGM,
|
||||
WarpRoomBGM,
|
||||
Jungle01BGM,
|
||||
SnowBGM,
|
||||
RiverBGM,
|
||||
FutureBGM,
|
||||
LabBGM,
|
||||
SewerBGM,
|
||||
EgyptBGM,
|
||||
NBrioBGM,
|
||||
AdventureBGM,
|
||||
SpyBGM,
|
||||
ChaseBGM,
|
||||
TrialsBGM,
|
||||
SpaceBGM,
|
||||
Jungle02BGM,
|
||||
RipperBGM,
|
||||
TheGreatWallBGM,
|
||||
RoadToSomewhereBGM,
|
||||
LavaKoalaBGM,
|
||||
CortexBGM,
|
||||
CyberCortexBGM,
|
||||
ArabicBGM,
|
||||
N_Tropy2BGM,
|
||||
JazzBGM,
|
||||
Space2BGM,
|
||||
TawnaBonusBGM,
|
||||
CortexPowerBGM,
|
||||
ArabicBonusBGM,
|
||||
EgyptBonusBGM,
|
||||
FutureBonusBGM,
|
||||
LostCityBGM,
|
||||
PolarBGM,
|
||||
RiverBonusBGM,
|
||||
RuinsBonusBGM,
|
||||
SewerBonusBGM,
|
||||
SnowBonusBGM,
|
||||
RoadToRuinBGM,
|
||||
NGinBGM,
|
||||
Arabia01BGM,
|
||||
Arabia02BGM,
|
||||
BashBGM,
|
||||
Cortex02BGM,
|
||||
MedievalBGM,
|
||||
PreHistoricBGM,
|
||||
UnderWaterBGM,
|
||||
BrioRevisitedBGM,
|
||||
EgyptChaseBGM,
|
||||
RuinsLoopBGM,
|
||||
DingoSynthBGM
|
||||
};
|
||||
|
||||
enum Type : u32 {
|
||||
Unset,
|
||||
Flashback,
|
||||
Trial
|
||||
};
|
||||
|
||||
enum TypeV2 : u32 {
|
||||
Practice,
|
||||
Flashback,
|
||||
Trial,
|
||||
Adventure
|
||||
};
|
||||
|
||||
enum Skybox : u32 {
|
||||
Night,
|
||||
Day,
|
||||
Storm,
|
||||
Dawn
|
||||
};
|
||||
|
||||
enum SkyboxV2 : u32 {
|
||||
Default = 1,
|
||||
Briolab,
|
||||
Fort,
|
||||
Moon,
|
||||
Toxic,
|
||||
AboutRight,
|
||||
Crash1Island,
|
||||
Arabia,
|
||||
RoadToRuin,
|
||||
Black
|
||||
};
|
||||
|
||||
// 0.95
|
||||
enum SkyboxV3 : u32 {
|
||||
Default = 1,
|
||||
Briolab,
|
||||
Fort,
|
||||
Moon,
|
||||
Toxic,
|
||||
AboutRight,
|
||||
Crash1Island,
|
||||
Arabia,
|
||||
RoadToRuin,
|
||||
MotorcycleDay,
|
||||
MotorcycleNoon,
|
||||
MotorcycleMoon,
|
||||
MotorcycleNight,
|
||||
Black
|
||||
};
|
||||
|
||||
enum Scenery : u32 {
|
||||
None,
|
||||
FutureTense,
|
||||
Forest,
|
||||
Waterfall,
|
||||
Snow,
|
||||
Fortress
|
||||
};
|
||||
|
||||
enum SceneryV2 : u32 {
|
||||
None,
|
||||
FutureTense,
|
||||
Forest,
|
||||
Waterfall,
|
||||
None2,
|
||||
Fortress,
|
||||
None3,
|
||||
Lava,
|
||||
TheGreatGate,
|
||||
Mountain,
|
||||
KoalaKong,
|
||||
SunsetVista,
|
||||
HangemHigh,
|
||||
Sphynxinator,
|
||||
Tunnel,
|
||||
Pipes
|
||||
};
|
||||
|
||||
enum SceneryV4 : u32 {
|
||||
None,
|
||||
FutureTense,
|
||||
Forest,
|
||||
Waterfall,
|
||||
Snow,
|
||||
Fortress,
|
||||
None2,
|
||||
Lava,
|
||||
TheGreatGate,
|
||||
Mountain,
|
||||
KoalaKong,
|
||||
SunsetVista,
|
||||
HangemHigh,
|
||||
Sphynxinator,
|
||||
Tunnel,
|
||||
Pipes
|
||||
};
|
||||
|
||||
// 0.95
|
||||
enum SceneryV5 : u32 {
|
||||
None,
|
||||
FutureTense,
|
||||
Forest,
|
||||
Waterfall,
|
||||
Snow,
|
||||
Fortress,
|
||||
None2,
|
||||
Lava,
|
||||
TheGreatGate,
|
||||
Mountain,
|
||||
KoalaKong,
|
||||
SunsetVista,
|
||||
HangemHigh,
|
||||
Sphynxinator,
|
||||
Tunnel,
|
||||
Pipes,
|
||||
Medieval,
|
||||
FutureCity,
|
||||
TinyArena,
|
||||
HeavyMachinery,
|
||||
CrystalCave,
|
||||
MedievalWithHouses,
|
||||
CortexBonusChamber
|
||||
};
|
||||
|
||||
enum Weather : u32 {
|
||||
Default,
|
||||
Snow,
|
||||
Rain
|
||||
};
|
||||
|
||||
// 0.95
|
||||
enum WeatherV2 : u32 {
|
||||
Default,
|
||||
Snow,
|
||||
Rain,
|
||||
Night,
|
||||
UnderWater
|
||||
};
|
||||
|
||||
|
||||
struct Options {
|
||||
// Type
|
||||
if (header.version > 1) {
|
||||
TypeV2 type;
|
||||
}
|
||||
else {
|
||||
Type type;
|
||||
}
|
||||
// Skybox
|
||||
if (header.version > 1) {
|
||||
if (header.gameVersion == "0.95") {
|
||||
SkyboxV3 skybox;
|
||||
}
|
||||
else {
|
||||
SkyboxV2 skybox;
|
||||
}
|
||||
}
|
||||
else {
|
||||
Skybox skybox;
|
||||
}
|
||||
// Scenery
|
||||
if (header.version == 1) {
|
||||
Scenery scenery;
|
||||
}
|
||||
else if (header.version > 1 && header.version < 4) {
|
||||
SceneryV2 scenery;
|
||||
}
|
||||
else {
|
||||
if (header.gameVersion == "0.95") {
|
||||
SceneryV5 skybox;
|
||||
}
|
||||
else {
|
||||
SceneryV4 skybox;
|
||||
}
|
||||
}
|
||||
// Weather
|
||||
if (header.version > 2) {
|
||||
if (header.gameVersion == "0.95") {
|
||||
WeatherV2 weather;
|
||||
}
|
||||
else {
|
||||
Weather weather;
|
||||
}
|
||||
}
|
||||
// Background music
|
||||
if (header.version > 1) {
|
||||
BGMV2 bgm;
|
||||
}
|
||||
else {
|
||||
BGM bgm;
|
||||
}
|
||||
// Time Trial
|
||||
if (type == Type::Trial) {
|
||||
u32 timeTrialTicksBronze;
|
||||
u32 timeTrialTicksSilver;
|
||||
u32 timeTrialTicksGold;
|
||||
}
|
||||
};
|
||||
|
||||
struct Object {
|
||||
std::string::SizedString<u8> objName;
|
||||
if (header.version > 1) {
|
||||
u16 x;
|
||||
u16 y;
|
||||
bool hasMetafields;
|
||||
if (hasMetafields) {
|
||||
u16 numOfMetafields;
|
||||
u8 metafields[numOfMetafields];
|
||||
}
|
||||
}
|
||||
else {
|
||||
u32 x;
|
||||
u32 y;
|
||||
}
|
||||
};
|
||||
|
||||
struct Objects{
|
||||
u32 objCount;
|
||||
std::Array<Object, objCount> objArray;
|
||||
};
|
||||
|
||||
Header header @ $;
|
||||
Options options @ $;
|
||||
Objects objects @ $;
|
||||
81
patterns/DFIR/DFIR_README.md
Normal file
81
patterns/DFIR/DFIR_README.md
Normal file
@@ -0,0 +1,81 @@
|
||||
ImHex Pattern Files - Digital Forensics:
|
||||
|
||||
- [ImHex-DFIR-Patterns](https://github.com/Xtreme-Liberty/ImHex-DFIR-Patterns)
|
||||
|
||||
Enhanced features of the stock Disk/Filesystem pattern files for forensic review of disk content.
|
||||
- [ImHex](https://github.com/WerWolv/ImHex)
|
||||
- [ImHex Patterns](https://github.com/WerWolv/ImHex-Patterns)
|
||||
|
||||
Use:
|
||||
- Open a physical disk via Raw Provider (read-only)
|
||||
- EXAMPLE: /dev/disk6
|
||||
- Import Pattern File
|
||||
- EXAMPLE: DISK_PARSER.hexpat
|
||||
- [Pattern_Selection (screenshot)](https://github.com/Xtreme-Liberty/ImHex-DFIR-Patterns/blob/main/screenshots/2-DISK_PARSER-Pattern.png)
|
||||
|
||||
- DISK_PARSER.hexpat
|
||||
- Recognize MBR/GPT Disks and parse MPT/GPT
|
||||
- Including Logical Volumes in an Extended Partition (container)
|
||||
- Auto load file system patterns for FAT32, exFAT, NTFS formatted volumes
|
||||
- Optional Disk Report
|
||||
|
||||
- [DISK > MBR/GPT (screenshot)](https://github.com/Xtreme-Liberty/ImHex-DFIR-Patterns/blob/main/screenshots/3-DISK-HYBRID.png)
|
||||
- [DISK > MBR > MPT > 3 Primaries | 2 Logicals in an Extended (screenshot)](https://github.com/Xtreme-Liberty/ImHex-DFIR-Patterns/blob/main/screenshots/3a-DISK-MBR.png)
|
||||
|
||||
- FAT32.hexpat
|
||||
- Auto loaded by DISK_PARSER.hexpat
|
||||
- Parse VBR, FAT1, FAT2, Root Dir, and 1 level of SubDirs
|
||||
- FAT1/FAT2 Cluster chaining with SFN resolution
|
||||
- LFN/SFN Alias grouping in Root Dir
|
||||
- Recognize deleted entries (xE5)
|
||||
- File Content pointer
|
||||
- D/T Conversions
|
||||
- Optional FAT32 Volume Report
|
||||
|
||||
- [VOLUME > FAT32 > FAT1 (screenshot)](https://github.com/Xtreme-Liberty/ImHex-DFIR-Patterns/blob/main/screenshots/4-FAT32-1_SMALL_TXT.png)
|
||||
- [VOLUME > FAT32 > Root Dir (screenshot)](https://github.com/Xtreme-Liberty/ImHex-DFIR-Patterns/blob/main/screenshots/5-FAT32_ROOT_DIR.png)
|
||||
- [VOLUME > FAT32 > Data Pointer (screenshot)](https://github.com/Xtreme-Liberty/ImHex-DFIR-Patterns/blob/main/screenshots/6-FAT32_SFN_POINTER.png)
|
||||
|
||||
- exFAT.hexpat
|
||||
- Auto loaded by DISK_PARSER.hexpat
|
||||
- Parse VBR/Boot Sector/Extended Sectors, FAT1, Root Dir
|
||||
- Recognize active directory entries (x85, xC0, xC1)
|
||||
- Recognize inactive directory entries (x05, x40, x41)
|
||||
- xC0/x40 File Content pointer
|
||||
- D/T Conversions
|
||||
- Optional exFAT Volume Report
|
||||
|
||||
- [VOLUME > exFAT (screenshot)](https://github.com/Xtreme-Liberty/ImHex-DFIR-Patterns/blob/main/screenshots/7-exFAT-1.png)
|
||||
- [VOLUME > exFAT > Root Dir > xC0 (screenshot)](https://github.com/Xtreme-Liberty/ImHex-DFIR-Patterns/blob/main/screenshots/8-exFAT_xC0.png)
|
||||
- [VOLUME > exFAT > Data Pointer (screenshot)](https://github.com/Xtreme-Liberty/ImHex-DFIR-Patterns/blob/main/screenshots/9-exFAT-Data_Pointer.png)
|
||||
|
||||
- NTFS.hexpat
|
||||
- Auto loaded by DISK_PARSER.hexpat
|
||||
- Parse VBR (Boot Sector), $MFT, Root Dir, and Indexes
|
||||
- Recursively parse the $Metadata files, $Attributes, and user files/dirs
|
||||
- Added file record | parent [MFT#] [SEQ#] indicators
|
||||
- Parse x80/xB0 Data Runs
|
||||
- File Content pointer
|
||||
- D/T Conversions
|
||||
- Optional NTFS Volume Report
|
||||
|
||||
- [VOLUME > NTFS > $MFT > D/T Conversion (screenshot)](https://github.com/Xtreme-Liberty/ImHex-DFIR-Patterns/blob/main/screenshots/10-NTFS-DT.png)
|
||||
- [VOLUME > NTFS > $MFT > x80 Run List (screenshot)](https://github.com/Xtreme-Liberty/ImHex-DFIR-Patterns/blob/main/screenshots/11-NTFS-DATA_RUN.png)
|
||||
- [VOLUME > NTFS > Data Pointer (screenshot)](https://github.com/Xtreme-Liberty/ImHex-DFIR-Patterns/blob/main/screenshots/12-NTFS-DATA_POINTER.png)
|
||||
|
||||
- Optional Reports
|
||||
- Simply copy the console output to a file...
|
||||
|
||||
- To enable/disable the reports:
|
||||
- Open each DFIR related .hexpat
|
||||
- Find the report constant (near the top)
|
||||
- "true" = enabled
|
||||
- "false" = disabled
|
||||
|
||||
Example Report: GPT > FAT32|exFAT
|
||||
- [exFAT_Report](https://github.com/Xtreme-Liberty/ImHex-DFIR-Patterns/blob/main/reports/exFAT_Report.txt)
|
||||
|
||||
Example Report: MBR > 5 Logical Volumes (2 in an Extended) > All FAT32 Volumes
|
||||
- [MBR_5_VOLs](https://github.com/Xtreme-Liberty/ImHex-DFIR-Patterns/blob/main/reports/MBR_5_VOLs.txt)
|
||||
|
||||
|
||||
677
patterns/DFIR/DISK_PARSER.hexpat
Normal file
677
patterns/DFIR/DISK_PARSER.hexpat
Normal file
@@ -0,0 +1,677 @@
|
||||
#pragma author Formula Zero One Technologies
|
||||
#pragma description DFIR_DISK_PARSER_v2.0
|
||||
#pragma MIME application/x-ima
|
||||
#pragma endian little
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// CREDIT
|
||||
// -----------------------------------------------------------------------------
|
||||
// Based on /fs/pattern.hexpat by WerWolv
|
||||
// -----------------------------------------------------------------------------
|
||||
// TODO
|
||||
// -----------------------------------------------------------------------------
|
||||
// Refine File System Detection/Match
|
||||
// -----------------------------------------------------------------------------
|
||||
// IMPORTS
|
||||
// -----------------------------------------------------------------------------
|
||||
import std.core;
|
||||
import std.io;
|
||||
import std.time;
|
||||
import type.guid;
|
||||
import type.magic;
|
||||
import type.time;
|
||||
import type.base;
|
||||
import hex.provider;
|
||||
|
||||
// WORKING IMPORTS
|
||||
import * from DFIR.FAT32 as FAT32Pat;
|
||||
import * from DFIR.exFAT as EXFATPat;
|
||||
import * from DFIR.NTFS as NTFSPat;
|
||||
|
||||
// ------------------------------------
|
||||
// DISABLED IMPORTS
|
||||
// REFS - UNTESTED
|
||||
// EXT4 - GROUP DESC ERRORS
|
||||
// APFS - PARTIALLY WORKS
|
||||
// Comment out "using uuid_t = type::GUID"
|
||||
// Replace all instances of "uuid_t" with "type::GUID"
|
||||
// Comment out line 1456-EOF
|
||||
// JPEG/PNG - OFFSET ERRORS
|
||||
// ------------------------------------
|
||||
//import * from fs.apfs as APFSPat;
|
||||
//import * from fs.ext4 as EXT4Pat;
|
||||
//import * from fs.refs as REFSPat;
|
||||
//import * from jpeg as JPEGPat;
|
||||
//import * from png as PNGPat;
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// FWD DECs - GLOBAL
|
||||
// -----------------------------------------------------------------------------
|
||||
bool has_ext = false;
|
||||
bool has_gpt = false;
|
||||
u64 partitionOffset = 0;
|
||||
u64 containerStartOffset = 0;
|
||||
|
||||
u32 mptIndex = 0;
|
||||
u32 extIndex = 0;
|
||||
str entryName = "";
|
||||
|
||||
u32 MPT_Count = 0;
|
||||
u32 EXT_VolCount = 0;
|
||||
u32 GPT_Count = 0;
|
||||
|
||||
u32 memory_size = std::mem::size();
|
||||
str disk_path = hex::prv::get_information("file_path","");
|
||||
u128 sector_size = hex::prv::get_information("sector_size","");
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// REPORT HEADER ** ATTENTION **
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
// ---******---*******---vvvv--- |
|
||||
const bool DISK_REPORT = true;
|
||||
// ---******---*******---^^^^--- |
|
||||
|
||||
if (DISK_REPORT) {
|
||||
std::print(" # # # # # # ");
|
||||
std::print(" # # # ");
|
||||
std::print(" # # # ");
|
||||
std::print(" # # # # # # # ");
|
||||
std::print(" I m H e x ");
|
||||
std::print(" ");
|
||||
std::print("-----------------------------------------");
|
||||
std::print(" ");
|
||||
std::print(" ENTITY: _____________________");
|
||||
std::print(" ");
|
||||
std::print("EXAMINER: _____________________");
|
||||
std::print(" ");
|
||||
u128 timestamp = std::time::epoch();
|
||||
std::time::Time local_ts = std::time::to_local(timestamp);
|
||||
std::time::Time utc_ts = std::time::to_utc(timestamp);
|
||||
std::print("-----------------------------------------");
|
||||
std::print(" LOCAL: {}",
|
||||
std::format("{:02}/{:02}/{:04} @ {:02}:{:02}:{:02}",
|
||||
local_ts.mon + 1,
|
||||
local_ts.mday,
|
||||
local_ts.year + 1900,
|
||||
local_ts.hour,
|
||||
local_ts.min,
|
||||
local_ts.sec
|
||||
));
|
||||
std::print(" UTC: {}",
|
||||
std::format("{:02}/{:02}/{:04} @ {:02}:{:02}:{:02}",
|
||||
utc_ts.mon + 1,
|
||||
utc_ts.mday,
|
||||
utc_ts.year + 1900,
|
||||
utc_ts.hour,
|
||||
utc_ts.min,
|
||||
utc_ts.sec
|
||||
));
|
||||
std::print("-----------------------------------------");
|
||||
std::print(" ");
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// SIGNATURE HELPER
|
||||
// -----------------------------------------------------------------------------
|
||||
enum MBRSignature : u16 {
|
||||
MBR_SIG = 0xAA55 // 0x55AA -> Read LE
|
||||
};
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// CHS HELPER
|
||||
// -----------------------------------------------------------------------------
|
||||
bitfield CHS_Decoder {
|
||||
head : 8;
|
||||
sector : 6;
|
||||
cylinder : 10;
|
||||
} [[format("chs_formatter")]];
|
||||
|
||||
fn chs_formatter(CHS_Decoder CHS) {
|
||||
return std::format("({:X}, {:X}, {:X}) | 0x{:X}", CHS.cylinder, CHS.head, CHS.sector, (CHS.cylinder * 16 + CHS.head) * 63 + (CHS.sector - 1));
|
||||
};
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// TIMESTAMP HELPER
|
||||
// -----------------------------------------------------------------------------
|
||||
struct DiskTimeStamp {
|
||||
u8 seconds, minutes, hours;
|
||||
};
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// DISK PROTECTION HELPER
|
||||
// -----------------------------------------------------------------------------
|
||||
enum DiskProtection : u16 {
|
||||
NotProtected = 0x0000,
|
||||
CopyProtected = 0x5A5A
|
||||
};
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// PARTITION STATUS HELPER
|
||||
// -----------------------------------------------------------------------------
|
||||
enum PartitionStatus : u8 {
|
||||
Not_Active = 0x00, // not_bootable
|
||||
Active = 0x80 // bootable
|
||||
};
|
||||
|
||||
enum MPTPartLabel : u8 {
|
||||
UNUSED_OR_HIDDEN_ENTRY = 0x00,
|
||||
PRIMARY = 0x07,
|
||||
PRIMARY_F32_SMALL = 0x0B,
|
||||
PRIMARY_0C_BIG = 0x0C,
|
||||
EXTENDED_CONT_SMALL = 0x05,
|
||||
EXTENDED_CONT_BIG = 0x0F,
|
||||
LEGACY_MBR = 0xEE
|
||||
};
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// PARTITION TYPE HELPER
|
||||
// -----------------------------------------------------------------------------
|
||||
enum PartitionTypeCode : u8 {
|
||||
UNUSED_ENTRY = 0x00,
|
||||
FAT12_HDD = 0x01,
|
||||
FAT12_HIDDEN = 0x11,
|
||||
FAT16_SMALL = 0x04,
|
||||
FAT16_SMALL_HIDDEN = 0x14,
|
||||
FAT16_BIG = 0x06,
|
||||
FAT16_BIG_HIDDEN = 0x16,
|
||||
FAT32_SMALL = 0x0B,
|
||||
FAT32_SMALL_HIDDEN = 0x1B,
|
||||
FAT32_BIG = 0x0C,
|
||||
FAT32_BIG_HIDDEN = 0x1C,
|
||||
EXT_PART_SMALL = 0x05,
|
||||
EXT_PART_SMALL_HIDDEN = 0x15,
|
||||
EXT_PART_BIG = 0x0F,
|
||||
EXT_PART_BIG_HIDDEN = 0x1F,
|
||||
NTFS_EXFAT = 0x07,
|
||||
NTFS_EXFAT_HIDDEN = 0x17,
|
||||
WINDOWS_RECOVERY = 0x27,
|
||||
NTFS_VOL_SET_1 = 0x86,
|
||||
NTFS_VOL_SET_2 = 0x87,
|
||||
macOSX = 0xA8,
|
||||
OS2_HIDDEN_CDRIVE = 0x84,
|
||||
LINUX_EXT = 0x83,
|
||||
LINUX_EXT2 = 0x85,
|
||||
LINUX_LVM = 0x8E,
|
||||
LINUX_PA_RISC = 0xF0,
|
||||
LINUX_RAID = 0xFD,
|
||||
FREE_BSD = 0xA5,
|
||||
OPEN_BSD = 0xA6,
|
||||
QNX_1 = 0x4D,
|
||||
QNX_2 = 0x4E,
|
||||
QNX_3 = 0x4F,
|
||||
GPT_DISK_STD = 0xEE,
|
||||
GPT_DISK_SYS = 0xEF,
|
||||
UNKNOWN = 0xFF,
|
||||
};
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// GUID PARTITION TABLE (GPT) PARTIONING SCHEME RELATED
|
||||
// -----------------------------------------------------------------------------
|
||||
// V V V V V V V V V V
|
||||
// -----------------------------------------------------------------------------
|
||||
// GPT PARTITION LABEL HELPER
|
||||
// -----------------------------------------------------------------------------
|
||||
enum GUIDPartLabel : u128 {
|
||||
// ---------------- COMMON ----------------
|
||||
UNUSED_ENTRY = 0x00000000000000000000000000000000,
|
||||
EFI_SYSTEM_PART = 0x3BC93EC9A0004BBA11D2F81FC12A7328,
|
||||
APPLE_APFS_CONT = 0xACEC4365300011AA11AA00007C3457EF,
|
||||
APPLE_HFS_PLUS_PART = 0xACEC4365300011AA11AA000048465300,
|
||||
MICROSOFT_RESERVED_PART = 0xAE1502F92DF97D81B84D5C0BE3E3C9E3,
|
||||
WINDOWS_REC_ENVIRONMENT = 0xACD67901D5BF6AA1404DD106A4BB94DE,
|
||||
BASIC_DATA_PART = 0xC79926B7B668C0874433B9E5EBD0A0A2,
|
||||
|
||||
// ---------------- LINUX ----------------
|
||||
LINUX_FILE_SYSTEM = 0xE47D47D8693D798E477284830FC63DAF,
|
||||
RAID_PART = 0x1E91840F3F7406A04D3B05FCA19D880F,
|
||||
ROOT_PART_X86 = 0x8A45F0D531D1F79A41B2F29744479540,
|
||||
ROOT_PART_X86_64 = 0x09B784F9CAFBE7964DB1E8CD4F68BCE3,
|
||||
ROOT_PART_ARM = 0xD3BE9AD4A1216CB14E3C2CE469DAD710,
|
||||
ROOT_PART_ARM_64 = 0xAE3F0D286F4C44AF41C31DF0B921B045,
|
||||
BOOT_PART = 0x72716FFD75B252A3426259E6BC13C2FF,
|
||||
SWAP_PART = 0x4F4F4BC83309E58443C4A4AB0657FD6D,
|
||||
LOGICAL_VOLUME_MGR_PART = 0x28F93D2A8F233CA244C2F507E6D6D379,
|
||||
HOME_PART = 0x15F9AEE2140E44B84F132EB4933AC7E1,
|
||||
SRV_SERVER_DATA_PART = 0xE8986FA7251A7F904F3B20E03B8F8425,
|
||||
PLAIN_DMCRYPT_PART = 0xB786550AA13E418949B72D007FFEC5C9,
|
||||
LUKS_PART = 0xCC59605342171C864C5363EDCA7D7CCB,
|
||||
|
||||
// ---------------- APPLE ----------------
|
||||
APPLE_UFS_CONT = 0xACEC4365300011AA11AA000055465300,
|
||||
APPLE_ZFS = 0x316673200008A69911B21DD26A898CC3,
|
||||
APPLE_RAID_PART = 0xACEC4365300011AA11AA000052414944,
|
||||
APPLE_RAID_PART_OFFLINE = 0xACEC4365300011AA11AA5F4F52414944,
|
||||
APPLE_BOOT_PART_REC_HD = 0xACEC4365300011AA11AA0000426F6F74,
|
||||
APPLE_LABEL = 0xACEC4365300011AA11AA6C004C616265,
|
||||
APPLE_TV_RECOVERY_PART = 0xACEC4365300011AA11AA76655265636F,
|
||||
APPLE_CORE_STORAGE_CONT = 0xACEC4365300011AA11AA616753746F72,
|
||||
HFS_FILEVAULT_VOLUME_CONT = 0xACEC4365300011AA11AA616753746F72,
|
||||
APPLE_APFS_PREBOOT_PART = 0xACEC4365300011AA11AA006769646961,
|
||||
APPLE_APFS_RECOVERY_PART = 0xACEC4365300011AA11AA007972637652,
|
||||
|
||||
// ---------------- WINDOWS ----------------
|
||||
LOGICAL_DISK_MGR_META_PART = 0xB3CF34E104E1D28542E08F7EAAC80858,
|
||||
LOGICAL_DISK_MGR_DATA_PART = 0xAD694A71113368BC4F621431A0609BAF,
|
||||
IBM_GENERAL_PARALLEL_FILE_SYS_PART = 0x74B155E07A2DC3914E4EEF7D90FFAA37,
|
||||
STORAGE_SPACES_PART = 0x2DECF6E501B0A3AFEE4CF6808FAF5CE7,
|
||||
STORAGE_REPLICA_PART = 0xD123292BD147C8AAC043A1ACC58D4355,
|
||||
};
|
||||
// -----------------------------------------------------------------------------
|
||||
// BASIC DATA PARTITION ATTRIBUTES
|
||||
// -----------------------------------------------------------------------------
|
||||
bitfield GPT_BDP_Attributes {
|
||||
bool platform_required : 1 [[comment("Bit 0: RequiredPartition - Volume must be preserved")]];
|
||||
bool io_ignore : 1 [[comment("Bit 1: NoBlockIOProtocol - EFI ignores this Volume, no FS Mapping")]];
|
||||
bool legacy_flag : 1 [[comment("Bit 2: LegacyBIOSBootable - Active/Bootable under BIOS")]];
|
||||
reserved_UEFI : 45 [[comment("Bits 3–47: Reserved for UEFI")]];
|
||||
reserved_MS : 12 [[comment("Bits 48–59: Reserved for Microsoft")]];
|
||||
bool read_only : 1 [[comment("Bit 60: BasicDataPart - Read-Only Volume")]];
|
||||
bool shadow_copy : 1 [[comment("Bit 61: BasicDataPart - Shadow Copy Volume")]];
|
||||
bool hidden : 1 [[comment("Bit 62: BasicDataPart - Hidden Volume")]];
|
||||
bool no_drive_letter : 1 [[comment("Bit 63: BasicDataPart - Do not Auto-Assign Drive Letter")]];
|
||||
} [[bitfield_order(
|
||||
std::core::BitfieldOrder::LeastToMostSignificant, 64)]];
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// GPT ENTRIES PARSER
|
||||
// LBA2-LBA33
|
||||
// EACH ENTRY IS 128 BYTES (DESCRIBES A VOLUME)
|
||||
// -----------------------------------------------------------------------------
|
||||
union PartitionUnion {
|
||||
le type::GUID PartTypeGUID; // HUMAN READABLE GUID
|
||||
GUIDPartLabel PartTypeLabel [[name(std::format("PartTypeLabel (DERIVED)"))]]; // OBJECT LABEL
|
||||
};
|
||||
|
||||
struct GPT_PartitionEntry {
|
||||
PartitionUnion Type [[comment("Known Partition Type GUID: Global Identifier")]];
|
||||
le type::GUID Unique_GUID [[comment("Unique Partition GUID: Every Volume has its own Unique GUID")]];
|
||||
u64 Start_LBA [[comment("The first Sector of the Volume (Offset by 1)")]];
|
||||
u64 End_LBA [[comment("The last Sector of the Volume (Offset by 1)")]];
|
||||
GPT_BDP_Attributes ATTR [[comment("ATTRs for a Basic Data Partition may not be the same as a Microsoft Reserved Partition")]];
|
||||
char16 PartName[36] [[comment("Partition Name: Based on Known Partition Type GUID, except for Disk Images")]];
|
||||
|
||||
if (Type.PartTypeLabel != GUIDPartLabel::UNUSED_ENTRY) {
|
||||
GPT_Count += 1;
|
||||
}
|
||||
|
||||
u64 GPTpartitionOffset = Start_LBA * sector_size
|
||||
[[name(std::format("VOL_OFFSET {} | 0x{:02X} (DERIVED)", Start_LBA * sector_size, Start_LBA * sector_size)),
|
||||
export]];
|
||||
|
||||
match (Type.PartTypeLabel) {
|
||||
(GUIDPartLabel::UNUSED_ENTRY):
|
||||
continue;
|
||||
|
||||
(GUIDPartLabel::EFI_SYSTEM_PART):
|
||||
FAT32Pat EFI_SYS_VOL @ GPTpartitionOffset;
|
||||
|
||||
(GUIDPartLabel::BASIC_DATA_PART |
|
||||
GUIDPartLabel::WINDOWS_REC_ENVIRONMENT): {
|
||||
char gpt_fat32_magic[8] @ GPTpartitionOffset + 82 [[hidden]];
|
||||
char gpt_ntfs_magic[8] @ GPTpartitionOffset + 3 [[hidden]];
|
||||
char gpt_exfat_magic[8] @ GPTpartitionOffset + 3 [[hidden]];
|
||||
|
||||
if (gpt_fat32_magic == "FAT32 ")
|
||||
FAT32Pat FAT32_VOL @ GPTpartitionOffset;
|
||||
if (gpt_ntfs_magic == "NTFS ")
|
||||
NTFSPat NTFS_VOL @ GPTpartitionOffset;
|
||||
else if (gpt_exfat_magic == "EXFAT ")
|
||||
EXFATPat EXFAT_VOL @ GPTpartitionOffset;
|
||||
}
|
||||
// --------- DISABLED -----------------
|
||||
// EXT4 PATTERN WAS INOP WHEN TESTED
|
||||
//(GUIDPartLabel::LINUX_FILE_SYSTEM):
|
||||
//EXT4Pat EXT4_VOL @ GPTpartitionOffset;
|
||||
//(GUIDPartLabel::APPLE_APFS_CONT):
|
||||
// APFSPat APFS_VOL @ GPTpartitionOffset;
|
||||
}
|
||||
} [[name(std::format("GPT_ENTRY [{}]", std::core::array_index()))]];
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// GPT HEADER PARSER
|
||||
// LBA1 OFFSETS 0-91 (92 bytes of 512 bytes used)
|
||||
// -----------------------------------------------------------------------------
|
||||
struct GPT_Header {
|
||||
type::Magic<"EFI PART"> signature [[comment("Signature (EFI PART)")]];
|
||||
u32 revision [[comment("Header Revision Value")]];
|
||||
u32 header_size [[comment("Size of Header - 92 Bytes")]];
|
||||
type::Hex<u32> header_crc32 [[comment("GPT Header Checksum")]];
|
||||
u32 reserved [[comment("Zeros")]];
|
||||
u64 current_lba [[comment("Current LBA - GPT Header Location")]];
|
||||
u64 backup_lba [[comment("Location of Backup - Header & GPT")]];
|
||||
u64 first_usable_lba [[comment("1st Sector Available for Logical VOL")]];
|
||||
u64 last_usable_lba [[comment("Last Sector Available for Logical VOL")]];
|
||||
type::GUID disk_guid [[comment("Unique Disk GUID")]];
|
||||
u64 partition_entries_lba [[comment("1st Sector of GPT")]];
|
||||
u32 num_partition_entries [[comment("Total Number of Partition Entries Available - 128 on Windows")]];
|
||||
u32 size_of_partition_entry [[comment("Size in Bytes of each GPT Entry")]];
|
||||
type::Hex<u32> partition_entries_crc32 [[comment("GPT Array Checksum")]];
|
||||
};
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// MASTER BOOT RECORD (MBR) PARTIONING SCHEME RELATED
|
||||
// -----------------------------------------------------------------------------
|
||||
// V V V V V V V V V V
|
||||
// -----------------------------------------------------------------------------
|
||||
// MASTER PARTITION TABLE (MPT)
|
||||
// LBA0 > 0FFSETS 446-509
|
||||
// Each Entry Describes a Logical Volume (type/start_loc/size)
|
||||
// -----------------------------------------------------------------------------
|
||||
union MBRPartitionUnion {
|
||||
PartitionTypeCode Part_Type;
|
||||
MPTPartLabel PartTypeLabel; // overlay for 0x00
|
||||
};
|
||||
|
||||
struct PartitionTableEntry {
|
||||
// partition table fields
|
||||
PartitionStatus ActiveFlag;
|
||||
CHS_Decoder Starting_CHS;
|
||||
MBRPartitionUnion Type;
|
||||
CHS_Decoder Ending_CHS;
|
||||
u32 Start_LBA;
|
||||
u32 Total_Sectors;
|
||||
|
||||
if (Type.PartTypeLabel != MPTPartLabel::UNUSED_OR_HIDDEN_ENTRY) {
|
||||
// Track Count of Logical Volumes in the Extended Container
|
||||
//MPT_Count += 1;
|
||||
if (containerStartOffset == 0) {
|
||||
// top-level MBR entry
|
||||
MPT_Count = MPT_Count + 1;
|
||||
} else {
|
||||
// a logical inside an extended container
|
||||
EXT_VolCount = EXT_VolCount + 1;
|
||||
}
|
||||
}
|
||||
|
||||
partitionOffset = containerStartOffset + (Start_LBA * sector_size);
|
||||
|
||||
match (Type.PartTypeLabel) {
|
||||
(PartitionTypeCode::UNUSED_ENTRY): continue;
|
||||
(PartitionTypeCode::FAT32_SMALL | PartitionTypeCode::FAT32_BIG): {
|
||||
FAT32Pat FAT32_VOL @ partitionOffset;
|
||||
}
|
||||
(PartitionTypeCode::NTFS_EXFAT): {
|
||||
char magic[8] @ partitionOffset + 3;
|
||||
if (magic == "NTFS ")
|
||||
NTFSPat NTFS_VOL @ partitionOffset;
|
||||
else
|
||||
EXFATPat EXFAT_VOL @ partitionOffset;
|
||||
}
|
||||
(PartitionTypeCode::EXT_PART_SMALL | PartitionTypeCode::EXT_PART_BIG): {
|
||||
// Save parent state
|
||||
bool parent_has_ext = has_ext;
|
||||
has_ext = true;
|
||||
|
||||
containerStartOffset = partitionOffset;
|
||||
|
||||
// Parse first two entries of the extended partition
|
||||
PartitionTableEntry EXTENDED_PARTITION[2] @ partitionOffset + 446;
|
||||
|
||||
has_ext = parent_has_ext;
|
||||
}
|
||||
(PartitionTypeCode::GPT_DISK_STD | PartitionTypeCode::GPT_DISK_SYS):
|
||||
// Set global flag
|
||||
has_gpt = true;
|
||||
}
|
||||
if (!has_ext) {
|
||||
entryName = std::format("MPT_ENTRY [{}]", mptIndex);
|
||||
mptIndex += 1;
|
||||
} else {
|
||||
if (std::core::array_index() <= 0) {
|
||||
entryName = std::format("LOGICAL_VOL (EXT) [{}]", extIndex);
|
||||
} else if (std::core::array_index() == 1) {
|
||||
entryName = "NEXT VOL POINTER (EXT)";
|
||||
} else {
|
||||
entryName = std::format("LOGICAL_VOL (EXT) [{}]", extIndex);
|
||||
}
|
||||
extIndex += 1;
|
||||
}
|
||||
} [[name(entryName)]];
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// MBR PARSER
|
||||
// LBA0 > OFFSETS 0-511 (512 bytes)
|
||||
// -----------------------------------------------------------------------------
|
||||
struct MasterBootRecord {
|
||||
u8 bootstrapCodeArea1[218] [[comment("Boot Strapping Code")]];
|
||||
padding[2] [[comment("Zeros")]];
|
||||
u8 originalPhysicalDrive [[comment("???")]];
|
||||
DiskTimeStamp diskTimeStamp [[comment("Timestamp of Disk OG Partitioning")]];
|
||||
u8 bootstrapCodeArea2[216] [[comment("Boot Strapping Code")]];
|
||||
u32 diskSignature [[comment("Disk Signature")]];
|
||||
DiskProtection diskProtection [[comment("Disk Protection - 0x0000=Not | 0x5A5A=Prot")]];
|
||||
PartitionTableEntry PT[4] [[comment("Master Partition Table (MPT) Offset 446-509")]];
|
||||
MBRSignature MBR_SIG [[comment("End of MBR - 0x55AA")]];
|
||||
};
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// DISK PARSER
|
||||
// -----------------------------------------------------------------------------
|
||||
struct DiskRoot {
|
||||
// Master Boot Record at LBA 0 (1st physical sector)
|
||||
MasterBootRecord MBR @ 0x00;
|
||||
|
||||
if (has_gpt) {
|
||||
// GPT Header at LBA 1 (2nd physical sector)
|
||||
GPT_Header GPT_HEADER @ 0x200;
|
||||
// The GPT (table) at LBA 2 (3rd physical sector) to LBA 33 (34th physical sector)
|
||||
// 32 sectors total (Windows) that can define up to 128 - (primary) logical volumes
|
||||
GPT_PartitionEntry GPT_ENTRIES[GPT_HEADER.num_partition_entries] @ (GPT_HEADER.partition_entries_lba * 512);
|
||||
}
|
||||
};
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// ROOT OBJECT
|
||||
// -----------------------------------------------------------------------------
|
||||
// ---
|
||||
DiskRoot DISK @ 0x0;
|
||||
// ---
|
||||
|
||||
|
||||
// ------------------------------
|
||||
// DISK REPORT
|
||||
// ------------------------------
|
||||
|
||||
if (DISK_REPORT) {
|
||||
std::print("-----------------------------------------");
|
||||
std::print("-------------- DISK_REPORT --------------");
|
||||
std::print("-----------------------------------------");
|
||||
|
||||
// Disk Basics
|
||||
std::print("DISK_PATH = {}", disk_path);
|
||||
std::print("SECTOR_SIZE = {} BYTES", sector_size);
|
||||
std::print("DISK_SIZE = {} SECTORS", memory_size / sector_size);
|
||||
std::print("DISK_SIZE = {:.4f} GB @ 1000", memory_size / 1000.0 / 1000.0 / 1000.0);
|
||||
std::print("DISK_SIZE = {:.4f} GiB @ 1024", memory_size / 1024.0 / 1024.0 / 1024.0);
|
||||
|
||||
// Disk Protection
|
||||
str diskProtectionStr;
|
||||
if (DISK.MBR.diskProtection == DiskProtection::NotProtected) {
|
||||
diskProtectionStr = "NOT_COPY_PROTECTED";
|
||||
} else if (DISK.MBR.diskProtection == DiskProtection::CopyProtected) {
|
||||
diskProtectionStr = "COPY_PROTECTED";
|
||||
} else {
|
||||
diskProtectionStr = "UNKNOWN";
|
||||
}
|
||||
std::print("DISK_PROTECT = {}", diskProtectionStr);
|
||||
|
||||
// Partition Scheme
|
||||
if (MPT_Count >= 1 && GPT_Count == 0) {
|
||||
std::print("PART_SCHEME = MBR");
|
||||
} else if (GPT_Count >= 1 && MPT_Count == 0) {
|
||||
std::print("PART_SCHEME = GPT");
|
||||
} else if (GPT_Count >= 1 && MPT_Count >= 1) {
|
||||
std::print("PART_SCHEME = HYBRID (MBR + GPT)");
|
||||
} else {
|
||||
std::print("PART_SCHEME = UNKNOWN");
|
||||
}
|
||||
|
||||
// MBR MPT Partitions
|
||||
for (u32 i = 0, i < MPT_Count, i = i + 1) {
|
||||
std::print("-----------------------------------------");
|
||||
std::print("-------------- MBR_MPT [{}] --------------", i);
|
||||
std::print("-----------------------------------------");
|
||||
|
||||
// STATUS
|
||||
str statusStr;
|
||||
if (DISK.MBR.PT[i].ActiveFlag == PartitionStatus::Active) {
|
||||
statusStr = "ACTIVE/BOOTABLE";
|
||||
} else if (DISK.MBR.PT[i].ActiveFlag == PartitionStatus::Not_Active) {
|
||||
statusStr = "INACTIVE/NOT_BOOTABLE";
|
||||
} else {
|
||||
statusStr = "UNKNOWN";
|
||||
}
|
||||
std::print(" STATUS = {}", statusStr);
|
||||
|
||||
// TYPE_CODE
|
||||
str typeStr;
|
||||
if (DISK.MBR.PT[i].Type.Part_Type == PartitionTypeCode::FAT32_SMALL) {
|
||||
typeStr = "FAT32 (CHS) (0x0B)";
|
||||
} else if (DISK.MBR.PT[i].Type.Part_Type == PartitionTypeCode::FAT32_BIG) {
|
||||
typeStr = "FAT32 (LBA) (0x0C)";
|
||||
} else if (DISK.MBR.PT[i].Type.Part_Type == PartitionTypeCode::NTFS_EXFAT) {
|
||||
typeStr = "NTFS/EXFAT (0x07)";
|
||||
} else if (DISK.MBR.PT[i].Type.Part_Type == PartitionTypeCode::GPT_DISK_STD) {
|
||||
typeStr = "GPT_PROTECTIVE (0xEE)";
|
||||
} else if (DISK.MBR.PT[i].Type.Part_Type == PartitionTypeCode::EXT_PART_BIG) {
|
||||
typeStr = "EXTENDED (0x0F)";
|
||||
} else {
|
||||
typeStr = "OTHER/UNKNOWN";
|
||||
}
|
||||
std::print(" TYPE_CODE = {}", typeStr);
|
||||
|
||||
// LBA and size
|
||||
std::print(" FIRST_LBA = {:02}", DISK.MBR.PT[i].Start_LBA);
|
||||
std::print(" LAST_LBA = {:02}", DISK.MBR.PT[i].Start_LBA + DISK.MBR.PT[i].Total_Sectors - 1);
|
||||
std::print(" VOL_SIZE = {:02} SECTORS", DISK.MBR.PT[i].Total_Sectors);
|
||||
std::print(" VOL_SIZE = {:.4f} GB", (DISK.MBR.PT[i].Total_Sectors * sector_size) / 1000.0 / 1000.0 / 1000.0);
|
||||
std::print(" VOL_SIZE = {:.4f} GiB", (DISK.MBR.PT[i].Total_Sectors * sector_size) / 1024.0 / 1024.0 / 1024.0);
|
||||
|
||||
if (DISK.MBR.PT[i].Type.PartTypeLabel == MPTPartLabel::EXTENDED_CONT_SMALL ||
|
||||
DISK.MBR.PT[i].Type.PartTypeLabel == MPTPartLabel::EXTENDED_CONT_BIG) {
|
||||
|
||||
u32 logicalCount = std::core::member_count(DISK.MBR.PT[i].EXTENDED_PARTITION);
|
||||
//u32 logicalCount = std::mem::size(DISK.MBR.PT[i].EXTENDED_PARTITION);
|
||||
|
||||
for (u32 e = 0, e < logicalCount, e = e + 1) {
|
||||
if (DISK.MBR.PT[i].EXTENDED_PARTITION[e].Type.PartTypeLabel == MPTPartLabel::UNUSED_OR_HIDDEN_ENTRY)
|
||||
continue;
|
||||
|
||||
std::print("-----------------------------------------");
|
||||
std::print("---------- LOGICAL (EXT) [{}] ------------", e);
|
||||
std::print("-----------------------------------------");
|
||||
|
||||
// STATUS
|
||||
str EXTstatusStr;
|
||||
if (DISK.MBR.PT[i].EXTENDED_PARTITION[e].ActiveFlag == PartitionStatus::Active) {
|
||||
EXTstatusStr = "ACTIVE/BOOTABLE";
|
||||
} else if (DISK.MBR.PT[i].EXTENDED_PARTITION[e].ActiveFlag == PartitionStatus::Not_Active) {
|
||||
EXTstatusStr = "INACTIVE/NOT_BOOTABLE";
|
||||
} else {
|
||||
EXTstatusStr = "UNKNOWN";
|
||||
}
|
||||
std::print(" STATUS = {}", EXTstatusStr);
|
||||
|
||||
// TYPE_CODE
|
||||
str EXTtypeStr;
|
||||
if (DISK.MBR.PT[i].EXTENDED_PARTITION[e].Type.Part_Type == PartitionTypeCode::FAT32_SMALL) {
|
||||
EXTtypeStr = "FAT32 (CHS) (0x0B)";
|
||||
} else if (DISK.MBR.PT[i].EXTENDED_PARTITION[e].Type.Part_Type == PartitionTypeCode::FAT32_BIG) {
|
||||
EXTtypeStr = "FAT32 (LBA) (0x0C)";
|
||||
} else if (DISK.MBR.PT[i].EXTENDED_PARTITION[e].Type.Part_Type == PartitionTypeCode::NTFS_EXFAT) {
|
||||
EXTtypeStr = "NTFS/EXFAT (0x07)";
|
||||
} else if (DISK.MBR.PT[i].EXTENDED_PARTITION[e].Type.Part_Type == PartitionTypeCode::GPT_DISK_STD) {
|
||||
EXTtypeStr = "GPT_PROTECTIVE (0xEE)";
|
||||
} else if (DISK.MBR.PT[i].EXTENDED_PARTITION[e].Type.Part_Type == PartitionTypeCode::EXT_PART_BIG) {
|
||||
EXTtypeStr = "EXTENDED (0x0F)";
|
||||
} else {
|
||||
EXTtypeStr = "OTHER/UNKNOWN";
|
||||
}
|
||||
std::print(" TYPE_CODE = {}", EXTtypeStr);
|
||||
|
||||
std::print(" FIRST_LBA = {}", DISK.MBR.PT[i].EXTENDED_PARTITION[e].Start_LBA);
|
||||
std::print(" LAST_LBA = {}", DISK.MBR.PT[i].EXTENDED_PARTITION[e].Start_LBA +
|
||||
DISK.MBR.PT[i].EXTENDED_PARTITION[e].Total_Sectors - 1);
|
||||
std::print(" VOL_SIZE = {} SECTORS", DISK.MBR.PT[i].EXTENDED_PARTITION[e].Total_Sectors);
|
||||
std::print(" VOL_SIZE = {:.4f} GB",
|
||||
(DISK.MBR.PT[i].EXTENDED_PARTITION[e].Total_Sectors * sector_size) / 1000.0 / 1000.0 / 1000.0);
|
||||
std::print(" VOL_SIZE = {:.4f} GiB",
|
||||
(DISK.MBR.PT[i].EXTENDED_PARTITION[e].Total_Sectors * sector_size) / 1024.0 / 1024.0 / 1024.0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// GPT Header
|
||||
if (GPT_Count >= 1) {
|
||||
std::print("-----------------------------------------");
|
||||
std::print("-------------- GPT_HEADER ---------------");
|
||||
std::print("-----------------------------------------");
|
||||
std::print("SIGNATURE = {}", DISK.GPT_HEADER.signature);
|
||||
std::print("REVISION = 0x{:02X}", DISK.GPT_HEADER.revision);
|
||||
std::print("GPT_HDR_CRC = 0x{:02X}", DISK.GPT_HEADER.header_crc32);
|
||||
std::print("GPT_HDR_BACKUP_LBA = {}", DISK.GPT_HEADER.backup_lba);
|
||||
std::print("DISK_GUID = {}", DISK.GPT_HEADER.disk_guid);
|
||||
std::print("FIRST_USABLE_LBA = {}", DISK.GPT_HEADER.first_usable_lba);
|
||||
std::print("LAST_USABLE_LBA = {}", DISK.GPT_HEADER.last_usable_lba);
|
||||
std::print("MAX_GPT_ENTRIES = {:02}", DISK.GPT_HEADER.num_partition_entries);
|
||||
std::print("GPT_ENTRY_SIZE = {:02} BYTES", DISK.GPT_HEADER.size_of_partition_entry);
|
||||
std::print("GPT_ARRAY_CRC = 0x{:02X}", DISK.GPT_HEADER.partition_entries_crc32);
|
||||
|
||||
// GPT Partitions
|
||||
for (u32 j = 0, j < GPT_Count, j = j + 1) {
|
||||
std::print("-----------------------------------------");
|
||||
std::print("------------- GPT_PART [{}] --------------", j);
|
||||
std::print("-----------------------------------------");
|
||||
std::print(" PART_TYPE_LABEL = {}", DISK.GPT_ENTRIES[j].Type.PartTypeLabel);
|
||||
std::print(" PART_TYPE_GUID = {}", DISK.GPT_ENTRIES[j].Type.PartTypeGUID);
|
||||
std::print(" UNIQUE_PART_GUID = {}", DISK.GPT_ENTRIES[j].Unique_GUID);
|
||||
std::print(" FIRST_LBA = {:02}", DISK.GPT_ENTRIES[j].Start_LBA);
|
||||
std::print(" LAST_LBA = {:02}", DISK.GPT_ENTRIES[j].End_LBA);
|
||||
|
||||
bool _any = false;
|
||||
std::print(" ATTR_FLAGS |");
|
||||
if(DISK.GPT_ENTRIES[j].ATTR.platform_required) {
|
||||
std::print(" |- - - - > PlatformRequired");
|
||||
_any = true;
|
||||
}
|
||||
if(DISK.GPT_ENTRIES[j].ATTR.io_ignore) {
|
||||
std::print(" |- - - - > NO_FS_MAP");
|
||||
_any = true;
|
||||
}
|
||||
if(DISK.GPT_ENTRIES[j].ATTR.legacy_flag) {
|
||||
std::print(" |- - - - > LEGACY_BOOT");
|
||||
_any = true;
|
||||
}
|
||||
if(DISK.GPT_ENTRIES[j].Type.PartTypeLabel == GUIDPartLabel::BASIC_DATA_PART) {
|
||||
if(DISK.GPT_ENTRIES[j].ATTR.read_only) {
|
||||
std::print(" |- - - - > READ_ONLY");
|
||||
_any = true;
|
||||
}
|
||||
if(DISK.GPT_ENTRIES[j].ATTR.shadow_copy) {
|
||||
std::print(" |- - - - > SHADOW_COPY");
|
||||
_any = true;
|
||||
}
|
||||
if(DISK.GPT_ENTRIES[j].ATTR.hidden) {
|
||||
std::print(" |- - - - > HIDDEN");
|
||||
_any = true;
|
||||
}
|
||||
if(DISK.GPT_ENTRIES[j].ATTR.no_drive_letter) {
|
||||
std::print(" |- - - - > NO_AUTO_MOUNT");
|
||||
_any = true;
|
||||
}
|
||||
}
|
||||
// if nothing was printed, say "NONE"
|
||||
if (!_any) {
|
||||
//std::print(" |> NONE");
|
||||
std::print(" |- - - - > NONE");
|
||||
}
|
||||
std::print(" PART_TYPE_NAME = {}", DISK.GPT_ENTRIES[j].PartName);
|
||||
}
|
||||
}
|
||||
std::print("-----------------------------------------");
|
||||
std::print("------------------ END ------------------");
|
||||
std::print("-----------------------------------------");
|
||||
std::print(" ");
|
||||
}
|
||||
789
patterns/DFIR/FAT32.hexpat
Normal file
789
patterns/DFIR/FAT32.hexpat
Normal file
@@ -0,0 +1,789 @@
|
||||
#pragma author Formula Zero One Technologies
|
||||
#pragma description FAT32 File System (FAT32_v2.0)
|
||||
#pragma MIME application/x-ima
|
||||
#pragma endian little
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// CREDIT
|
||||
// -----------------------------------------------------------------------------
|
||||
// OG AUTHOR: WerWolv
|
||||
// OG DESC: fs/fat32.hexpat_v1.0
|
||||
// -----------------------------------------------------------------------------
|
||||
// NOTES FOR v2.0 ** GLOBALS NEED YOUR INPUT **
|
||||
// -----------------------------------------------------------------------------
|
||||
// Imported by DISK_PARSER.hexpat
|
||||
// Added section separators for organization
|
||||
// Added recursive parsing for Root Dir and a next level
|
||||
// Added D/T conversions
|
||||
// Show filenames on hover
|
||||
// Added comments to DFIR fields of interest
|
||||
// Changed pattern output naming/structure.
|
||||
// Parse FAT1/FAT2
|
||||
// Show SFN <-> Starting Cluster Relation Overlay
|
||||
// -----------------------------------------------------------------------------
|
||||
// TODO
|
||||
// -----------------------------------------------------------------------------
|
||||
// Parse all SFN/LFN entries, not just Root + 1
|
||||
// -----------------------------------------------------------------------------
|
||||
// IMPORTS
|
||||
// -----------------------------------------------------------------------------
|
||||
import std.core;
|
||||
import std.io;
|
||||
import std.mem;
|
||||
import std.time;
|
||||
import std.string;
|
||||
import type.time;
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// FORWARD DECS/GLOBALS
|
||||
// -----------------------------------------------------------------------------
|
||||
// *** ATTENTION ***
|
||||
// SET MAXIMUM NUMBER OF 4 BYTE CHUNKS TO PARSE FROM FAT1
|
||||
// DEFAULT IS 4096
|
||||
// Choose a value greater than 1 and less than 65536 OR increase the Array size limit with "#define... "
|
||||
|
||||
// -------**************---vvvv--- |
|
||||
const u64 MAX_FAT_CHUNKS = 4096;
|
||||
// -------**************---^^^^--- |
|
||||
|
||||
// *** ATTENTION ***
|
||||
// SET MAXIMUM NUMBER OF SFN = STARTING CLUSTER TO PROCESS
|
||||
// DEFAULT IS 100 (2 LEVELS DEEP | ROOT DIR + 1)
|
||||
// Choose a value greater than 1 and less than 65536 OR increase the Array size limit with "#define... "
|
||||
|
||||
// ---**************---************---vvv--- |
|
||||
const u64 MAX_SFN_CLUSTER_RELATIONS = 100;
|
||||
// ---**************---************---^^^--- |
|
||||
|
||||
// ---*******---*******----vvvv--- |
|
||||
const bool VOLUME_REPORT = true;
|
||||
// ---*******---*******----^^^^--- |
|
||||
|
||||
u64 bytesPerCluster = 0;
|
||||
u64 rootDirSectors = 0;
|
||||
u64 firstDataSector = 0;
|
||||
u64 dataRegionStart = 0;
|
||||
u64 sfn_count = 0;
|
||||
u64 sfn_del_count = 0;
|
||||
u64 lfn_count = 0;
|
||||
u64 lfn_del_count = 0;
|
||||
u64 start_index = 0;
|
||||
u64 root_dir_start = 0;
|
||||
u64 allocated_file_count = 0;
|
||||
|
||||
u64 VBR_OFFSET = 0;
|
||||
u64 FAT1_start_offset = 0;
|
||||
u64 FAT2_start_offset = 0;
|
||||
u64 FAT_ClusterHeap_Count = 0;
|
||||
|
||||
u64 abs_FAT1_start_offset = 0;
|
||||
u64 abs_FAT2_start_offset = 0;
|
||||
u64 abs_rootDirStart_offset = 0;
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// FILE ALLOCATION TABLE RELATED
|
||||
// -----------------------------------------------------------------------------
|
||||
// V V V V V V V V V V
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
// ------------------------------
|
||||
// SFN <-> CLUSTER OVERLAY
|
||||
// ------------------------------
|
||||
struct INFO_Overlay {
|
||||
u64 index = std::core::array_index();
|
||||
u64 start_location = FAT1_start_offset + 8 + (index * 4);
|
||||
u32 current_cluster = 2 + index;
|
||||
str filename = overlay_func_name(current_cluster);
|
||||
|
||||
if (filename != "") {
|
||||
char hover_label[4] @ start_location [[
|
||||
name(std::format(
|
||||
"SFN: {} | CLUSTER {}",
|
||||
filename,
|
||||
current_cluster
|
||||
))]];
|
||||
}
|
||||
} [[inline]];
|
||||
|
||||
fn overlay_func_name(u32 cluster_num) {
|
||||
str fname = "";
|
||||
str ext = "";
|
||||
str combo = "";
|
||||
|
||||
// Loop through all ROOT_DIR_ENTRIES
|
||||
for (u32 i = 0, i < std::core::member_count(ROOT_DIR_ENTRIES), i = i + 1) {
|
||||
|
||||
// Check SFN_ALIAS and SFN_ENTRY in root entries
|
||||
if (std::core::has_member(ROOT_DIR_ENTRIES[i], "SFN_ALIAS")) {
|
||||
if (ROOT_DIR_ENTRIES[i].SFN_ALIAS.first_cluster == cluster_num) {
|
||||
combo = std::format("{}.{}",
|
||||
ROOT_DIR_ENTRIES[i].SFN_ALIAS.fileName,
|
||||
ROOT_DIR_ENTRIES[i].SFN_ALIAS.extension);
|
||||
return combo;
|
||||
}
|
||||
} else if (std::core::has_member(ROOT_DIR_ENTRIES[i], "SFN_ENTRY")) {
|
||||
if (ROOT_DIR_ENTRIES[i].SFN_ENTRY.first_cluster == cluster_num) {
|
||||
combo = std::format("{}.{}",
|
||||
ROOT_DIR_ENTRIES[i].SFN_ENTRY.fileName,
|
||||
ROOT_DIR_ENTRIES[i].SFN_ENTRY.extension);
|
||||
return combo;
|
||||
}
|
||||
}
|
||||
|
||||
// Loop through all SUB_DIR_INDEX arrays for this root entry
|
||||
if (std::core::has_member(ROOT_DIR_ENTRIES[i], "SUB_DIR_INDEX")) {
|
||||
for (u32 j = 0, j < std::core::member_count(ROOT_DIR_ENTRIES[i].SUB_DIR_INDEX), j = j + 1) {
|
||||
|
||||
if (std::core::has_member(ROOT_DIR_ENTRIES[i].SUB_DIR_INDEX[j], "SFN_ALIAS")) {
|
||||
if (ROOT_DIR_ENTRIES[i].SUB_DIR_INDEX[j].SFN_ALIAS.first_cluster == cluster_num) {
|
||||
combo = std::format("{}.{}",
|
||||
ROOT_DIR_ENTRIES[i].SUB_DIR_INDEX[j].SFN_ALIAS.fileName,
|
||||
ROOT_DIR_ENTRIES[i].SUB_DIR_INDEX[j].SFN_ALIAS.extension);
|
||||
return combo;
|
||||
}
|
||||
|
||||
} else if (std::core::has_member(ROOT_DIR_ENTRIES[i].SUB_DIR_INDEX[j], "SFN_ENTRY")) {
|
||||
if (ROOT_DIR_ENTRIES[i].SUB_DIR_INDEX[j].SFN_ENTRY.first_cluster == cluster_num) {
|
||||
combo = std::format("{}.{}",
|
||||
ROOT_DIR_ENTRIES[i].SUB_DIR_INDEX[j].SFN_ENTRY.fileName,
|
||||
ROOT_DIR_ENTRIES[i].SUB_DIR_INDEX[j].SFN_ENTRY.extension);
|
||||
return combo;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return ""; // no match found
|
||||
};
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// FAT32 FILE ALLOCATION TABLE (FAT) PARSER
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
const u32 CLUSTER_SIZE_BYTES = 4; // Each FAT32 entry = 4 bytes
|
||||
const u32 FAT32_EOF = 0x0FFFFFFF; // End-of-file marker
|
||||
const u32 FAT32_BAD = 0x0FFFFFF7; // Bad cluster marker
|
||||
const u32 FIRST_ALLOC_CLUSTER = 2; // First usable cluster after reserved
|
||||
|
||||
enum FAT_Flags : u32 {
|
||||
UNALLOCATED = 0x00000000,
|
||||
END_OF_FILE = 0x0FFFFFFF, // L.END
|
||||
BAD_CLUSTER = 0xFFFFFFF7, // L.END
|
||||
//POINTER = Num >= 1 // INFO
|
||||
};
|
||||
|
||||
union FAT_Union {
|
||||
u32 DECIMAL [[hidden]];
|
||||
FAT_Flags FAT_FLAG;
|
||||
};
|
||||
|
||||
// ------------------------------
|
||||
// Helper function for pointer label
|
||||
// ------------------------------
|
||||
fn cluster_label(u32 val) {
|
||||
if (val == FAT_Flags::UNALLOCATED)
|
||||
return "UNALLOCATED";
|
||||
if (val == FAT_Flags::BAD_CLUSTER)
|
||||
return "BAD";
|
||||
if (val >= 0x0FFFFFF8)
|
||||
return "EOF";
|
||||
return std::format("{}", val);
|
||||
};
|
||||
|
||||
// ------------------------------
|
||||
// FAT1/FAT2 HEAPS/CHAINS
|
||||
// ------------------------------
|
||||
struct FAT_Entry {
|
||||
FAT_Union FAT [[inline]];
|
||||
|
||||
u32 cluster_num = (FIRST_ALLOC_CLUSTER) + (std::core::array_index());
|
||||
|
||||
u32 next_cluster = FAT.DECIMAL & 0x0FFFFFFF;
|
||||
|
||||
char hover_label[4] @ $ - 4 [[
|
||||
name(std::format(
|
||||
"Cluster: {} → {}",
|
||||
cluster_num,
|
||||
cluster_label(next_cluster)
|
||||
))
|
||||
]];
|
||||
|
||||
bool is_eof = next_cluster >= 0x0FFFFFF8;
|
||||
bool is_bad = next_cluster == FAT32_BAD;
|
||||
bool is_free = next_cluster == 0;
|
||||
|
||||
if (is_eof) {
|
||||
allocated_file_count += 1;
|
||||
}
|
||||
} [[name(format_fat_entry(FAT.DECIMAL, std::core::array_index(), FIRST_ALLOC_CLUSTER))]];
|
||||
|
||||
// ------------------------------
|
||||
// FAT FORMATTER FUNC
|
||||
// ------------------------------
|
||||
fn format_fat_entry(u32 raw_value, u32 cluster_index, u32 first_alloc_cluster) {
|
||||
u32 next_cluster = raw_value & 0x0FFFFFFF;
|
||||
|
||||
str next_label;
|
||||
|
||||
if (next_cluster == 0)
|
||||
next_label = "UNALLOCATED";
|
||||
|
||||
else if (next_cluster == FAT32_BAD)
|
||||
next_label = "BAD";
|
||||
|
||||
else if (next_cluster == 0x0FFFFFFF)
|
||||
next_label = "EOF";
|
||||
|
||||
else
|
||||
next_label = std::format("{}", next_cluster);
|
||||
|
||||
u32 logical_cluster = first_alloc_cluster + cluster_index;
|
||||
|
||||
if (next_label == "UNALLOCATED" || next_label == "BAD" || next_label == "EOF")
|
||||
return std::format("Cluster {}: {}", logical_cluster, next_label);
|
||||
else
|
||||
return std::format("Cluster {} → {}", logical_cluster, next_label);
|
||||
};
|
||||
|
||||
// ------------------------------
|
||||
// MEDIA DESCRIPTOR HELPER
|
||||
// ------------------------------
|
||||
enum Media_Descriptor : u8 {
|
||||
SINGLE_SIDE_FLOPPY = 0xF0,
|
||||
DOUBLE_SIDE_FLOPPY = 0xF9,
|
||||
HARD_DISK_DRIVE = 0xF8,
|
||||
};
|
||||
|
||||
// ------------------------------
|
||||
// FAT1/FAT2 HEADER PARSER
|
||||
// ------------------------------
|
||||
struct FAT_Header {
|
||||
Media_Descriptor mediaDescriptor [[comment("0xF8=FIXED DISK | 0xF0=REMOVABLE")]];;
|
||||
u8 FAT32_FAT_HEADER[7] [[comment("8 BYTES TOTAL: 4 BYTES REPRESENT PSUEDO CLUSTER 0 (SYSTEM) | 4 BYTES REPRESENT PSUEDO CLUSTER 1 (SYSTEM)(EOF)")]];
|
||||
char root_dir_label[4] @ $ [[
|
||||
name(std::format(
|
||||
"ROOT_DIRECTORY"
|
||||
))
|
||||
]];
|
||||
// WHICH IS WHY THE ROOT DIRECTORY (FIRST DATA AREA ITEM) STARTS IN CLUSTER 2
|
||||
};
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// ROOT DIRECTORY RELATED
|
||||
// -----------------------------------------------------------------------------
|
||||
// V V V V V V V V V V
|
||||
// -----------------------------------------------------------------------------
|
||||
// ------------------------------
|
||||
// ACTIVE LFN SEQUENCE NUMBER BITFIELD
|
||||
// * EXCEPT DELETED ENTRIES - 0xE5 *
|
||||
// ------------------------------
|
||||
bitfield LFN_Sequence {
|
||||
padding : 1;
|
||||
IS_LAST_ENTRY : 1 [[name("IS_LAST_ENTRY: [0=NO | 1=YES] ==")]];
|
||||
padding : 1;
|
||||
LFN_SEQ_NUM : 5;
|
||||
} [[bitfield_order(
|
||||
std::core::BitfieldOrder::MostToLeastSignificant, 8)]];
|
||||
|
||||
// ------------------------------
|
||||
// DIRECTORY ENTRY STATUS/SEQUENCE HELPERS
|
||||
// ------------------------------
|
||||
enum Entry_Status : u8 {
|
||||
EMPTY_ENTRY = 0x00,
|
||||
DOT_ENTRY = 0x2E,
|
||||
DELETED_ENTRY = 0xE5,
|
||||
|
||||
ACTIVE_1ST_ENTRY = 0x01,
|
||||
ACTIVE_2ND_ENTRY = 0x02,
|
||||
ACTIVE_3RD_ENTRY = 0x03,
|
||||
ACTIVE_4TH_ENTRY = 0x04,
|
||||
ACTIVE_5TH_ENTRY = 0x05,
|
||||
ACTIVE_6TH_ENTRY = 0x06,
|
||||
ACTIVE_7TH_ENTRY = 0x07,
|
||||
ACTIVE_8TH_ENTRY = 0x08,
|
||||
ACTIVE_9TH_ENTRY = 0x09,
|
||||
ACTIVE_10TH_ENTRY = 0x0A,
|
||||
ACTIVE_11TH_ENTRY = 0x0B,
|
||||
ACTIVE_12TH_ENTRY = 0x0C,
|
||||
ACTIVE_13TH_ENTRY = 0x0D,
|
||||
ACTIVE_14TH_ENTRY = 0x0E,
|
||||
ACTIVE_15TH_ENTRY = 0x0F,
|
||||
ACTIVE_16TH_ENTRY = 0x10,
|
||||
ACTIVE_17TH_ENTRY = 0x11,
|
||||
ACTIVE_18TH_ENTRY = 0x12,
|
||||
ACTIVE_19TH_ENTRY = 0x13,
|
||||
ACTIVE_20TH_ENTRY = 0x14,
|
||||
ACTIVE_1ST_ENTRY_LAST = 0x41,
|
||||
ACTIVE_2ND_ENTRY_LAST = 0x42,
|
||||
ACTIVE_3RD_ENTRY_LAST = 0x43,
|
||||
ACTIVE_4TH_ENTRY_LAST = 0x44,
|
||||
ACTIVE_5TH_ENTRY_LAST = 0x45,
|
||||
ACTIVE_6TH_ENTRY_LAST = 0x46,
|
||||
ACTIVE_7TH_ENTRY_LAST = 0x47,
|
||||
ACTIVE_8TH_ENTRY_LAST = 0x48,
|
||||
ACTIVE_9TH_ENTRY_LAST = 0x49,
|
||||
ACTIVE_10TH_ENTRY_LAST = 0x4A,
|
||||
ACTIVE_11TH_ENTRY_LAST = 0x4B,
|
||||
ACTIVE_12TH_ENTRY_LAST = 0x4C,
|
||||
ACTIVE_13TH_ENTRY_LAST = 0x4D,
|
||||
ACTIVE_14TH_ENTRY_LAST = 0x4E,
|
||||
ACTIVE_15TH_ENTRY_LAST = 0x4F,
|
||||
ACTIVE_16TH_ENTRY_LAST = 0x50,
|
||||
ACTIVE_17TH_ENTRY_LAST = 0x51,
|
||||
ACTIVE_18TH_ENTRY_LAST = 0x52,
|
||||
ACTIVE_19TH_ENTRY_LAST = 0x53,
|
||||
ACTIVE_20TH_ENTRY_LAST = 0x54,
|
||||
};
|
||||
|
||||
// ------------------------------
|
||||
// HELPER FOR LFN FIRST BYTE
|
||||
// ------------------------------
|
||||
union LFNEntry_FirstByte {
|
||||
Entry_Status status;
|
||||
LFN_Sequence seq_num;
|
||||
};
|
||||
|
||||
// ------------------------------
|
||||
// SFN ATTRIBUTE HELPER
|
||||
// ------------------------------
|
||||
bitfield Attributes {
|
||||
readOnly : 1;
|
||||
hidden : 1;
|
||||
systemFile : 1;
|
||||
volumeLabel : 1;
|
||||
subDirectory : 1;
|
||||
archive : 1;
|
||||
padding : 2;
|
||||
} [[bitfield_order(
|
||||
std::core::BitfieldOrder::LeastToMostSignificant, 8)]];
|
||||
|
||||
// ------------------------------
|
||||
// ROOT DIRECTORY ENTRY FUNC
|
||||
// ------------------------------
|
||||
fn dir_entry_marker(u64 abs_off) {
|
||||
u8 first @ abs_off;
|
||||
return first;
|
||||
};
|
||||
|
||||
// ------------------------------
|
||||
// ROOT DIRECTORY ENTRY FUNC
|
||||
// ------------------------------
|
||||
fn dir_entry_attr(u64 abs_off) {
|
||||
u8 attr @ abs_off + 0x0B;
|
||||
return attr;
|
||||
};
|
||||
|
||||
// ------------------------------
|
||||
// DATES AND TIMES FUNC
|
||||
// ------------------------------
|
||||
fn format_dos_time_field(std::time::DOSTime t) {
|
||||
return std::time::format_dos_time(t, "{:02}:{:02}:{:02}");
|
||||
};
|
||||
|
||||
fn format_dos_date_field(std::time::DOSDate d) {
|
||||
return std::time::format_dos_date(d, "{1:02}-{0:02}-{2:04}");
|
||||
};
|
||||
|
||||
// ------------------------------
|
||||
// SHORT FILE NAME ALIAS PARSER
|
||||
// ------------------------------
|
||||
struct SFN_Entry_Alias {
|
||||
char fileName[8] [[name("SFN"), comment("Short File Name (8dot3)")]];
|
||||
char extension[3] [[name("EXT"), comment("File Extension (8dot3)")]];
|
||||
Attributes attributes [[name("RASH ATTR"), comment("Read-Only | Archive | System | Hidden | SubDir...")]];
|
||||
u8 reserved [[comment("Zeros")]];
|
||||
u8 milliseconds [[comment("Add to Times for Refinement")]];
|
||||
std::time::DOSTime Created_Time [[format("format_dos_time_field")]];
|
||||
std::time::DOSDate Created_Date [[format("format_dos_date_field")]];
|
||||
std::time::DOSDate Accessed_Date [[format("format_dos_date_field")]];
|
||||
u16 Cluster_Hi [[comment("High Cluster if Needed")]];
|
||||
std::time::DOSTime Modified_Time [[format("format_dos_time_field")]];
|
||||
std::time::DOSDate Modified_Date [[format("format_dos_date_field")]];
|
||||
u16 Cluster_Lo [[comment("Starting Cluster or Combine with Cluster_Hi")]];
|
||||
u32 fileSize [[name("FILE_SIZE"), comment("File Size in Bytes")]];
|
||||
|
||||
u32 first_cluster = (Cluster_Hi << 16) | Cluster_Lo;
|
||||
|
||||
u8 FILE_DATA[fileSize] @ dataRegionStart + (first_cluster -2) * bytesPerCluster [[comment("Pointer to the Files Content")]];
|
||||
|
||||
sfn_count += 1;
|
||||
|
||||
if (fileName[0] == 0xE5) {
|
||||
sfn_del_count += 1;
|
||||
}
|
||||
};
|
||||
|
||||
// ------------------------------
|
||||
// LOOOONG FILE NAME PARSER
|
||||
// ------------------------------
|
||||
struct LFN_Entry {
|
||||
u64 curr_first_byte = $;
|
||||
u8 curr_attr = dir_entry_attr(curr_first_byte);
|
||||
|
||||
LFNEntry_FirstByte SeqByte [[name("SEQUENCE_NUM"), comment("0x01-0x20 | Add 0x40 to Last LFN Entry")]];
|
||||
char16 NAME_1[5] [[comment("First 5 Characters of LFN")]];
|
||||
Attributes attributes [[name("LFN_ATTR"), comment("0x0F = LFN")]];
|
||||
padding[1] [[comment("Zeros")]];
|
||||
u8 nameChecksum [[name("Checksum"), comment("Checksum Calculated on SFN_ALIAS")]];
|
||||
char16 NAME_2[6] [[comment("Next 6 Characters of LFN")]];
|
||||
padding[2] [[comment("Zeros")]];
|
||||
char16 NAME_3[2] [[comment("Next 2 Characters of LFN")]];
|
||||
|
||||
// ATTEMPT TO CLEANUP UNICODE LFN... DOES NOT ACCOUNT FOR MULTI LFN ENTRIES
|
||||
if (curr_attr == 0x0F) {
|
||||
char display_name[32] @ $ - 32 [[
|
||||
name(
|
||||
(NAME_1[0] >= 0x20 && NAME_1[0] <= 0x7E ? std::string::to_string(NAME_1[0]) : "") +
|
||||
(NAME_1[1] >= 0x20 && NAME_1[1] <= 0x7E ? std::string::to_string(NAME_1[1]) : "") +
|
||||
(NAME_1[2] >= 0x20 && NAME_1[2] <= 0x7E ? std::string::to_string(NAME_1[2]) : "") +
|
||||
(NAME_1[3] >= 0x20 && NAME_1[3] <= 0x7E ? std::string::to_string(NAME_1[3]) : "") +
|
||||
(NAME_1[4] >= 0x20 && NAME_1[4] <= 0x7E ? std::string::to_string(NAME_1[4]) : "") +
|
||||
|
||||
(NAME_2[0] >= 0x20 && NAME_2[0] <= 0x7E ? std::string::to_string(NAME_2[0]) : "") +
|
||||
(NAME_2[1] >= 0x20 && NAME_2[1] <= 0x7E ? std::string::to_string(NAME_2[1]) : "") +
|
||||
(NAME_2[2] >= 0x20 && NAME_2[2] <= 0x7E ? std::string::to_string(NAME_2[2]) : "") +
|
||||
(NAME_2[3] >= 0x20 && NAME_2[3] <= 0x7E ? std::string::to_string(NAME_2[3]) : "") +
|
||||
(NAME_2[4] >= 0x20 && NAME_2[4] <= 0x7E ? std::string::to_string(NAME_2[4]) : "") +
|
||||
(NAME_2[5] >= 0x20 && NAME_2[5] <= 0x7E ? std::string::to_string(NAME_2[5]) : "") +
|
||||
|
||||
(NAME_3[0] >= 0x20 && NAME_3[0] <= 0x7E ? std::string::to_string(NAME_3[0]) : "") +
|
||||
(NAME_3[1] >= 0x20 && NAME_3[1] <= 0x7E ? std::string::to_string(NAME_3[1]) : "")
|
||||
)
|
||||
]];
|
||||
}
|
||||
lfn_count += 1;
|
||||
|
||||
if (SeqByte.status == Entry_Status::DELETED_ENTRY) {
|
||||
lfn_del_count += 1;
|
||||
}
|
||||
};
|
||||
|
||||
// ------------------------------
|
||||
// SHORT FILE NAME PARSER
|
||||
// ------------------------------
|
||||
struct SFN_Entry {
|
||||
char fileName[8] [[name("SFN"), comment("Short File Name (8dot3)")]];
|
||||
char extension[3] [[name("EXT"), comment("File Extension (8dot3)")]];
|
||||
Attributes attributes [[name("RASH ATTR"), comment("Read-Only | Archive | System | Hidden | SubDir...")]];
|
||||
u8 reserved [[comment("Zeros")]];
|
||||
u8 milliseconds [[comment("Add to Times for Refinement")]];
|
||||
std::time::DOSTime Created_Time [[format("format_dos_time_field")]];
|
||||
std::time::DOSDate Created_Date [[format("format_dos_date_field")]];
|
||||
std::time::DOSDate Accessed_Date [[format("format_dos_date_field")]];
|
||||
u16 Cluster_Hi [[comment("High Cluster if Needed")]];
|
||||
std::time::DOSTime Modified_Time [[format("format_dos_time_field")]];
|
||||
std::time::DOSDate Modified_Date [[format("format_dos_date_field")]];
|
||||
u16 Cluster_Lo [[comment("Starting Cluster or Combine with Cluster_Hi")]];
|
||||
u32 fileSize [[name("FILE_SIZE"), comment("File Size in Bytes")]];
|
||||
|
||||
u32 first_cluster = (Cluster_Hi << 16) | Cluster_Lo;
|
||||
|
||||
u8 FILE_DATA[fileSize] @ dataRegionStart + (first_cluster -2) * bytesPerCluster [[comment("Pointer to the File Content")]];
|
||||
|
||||
sfn_count += 1;
|
||||
|
||||
if (fileName[0] == 0xE5) {
|
||||
sfn_del_count += 1;
|
||||
}
|
||||
};
|
||||
|
||||
// ------------------------------
|
||||
// SUBDIRECTORY PARSER | LEVEL 2
|
||||
// ------------------------------
|
||||
struct SubDirParser {
|
||||
u8 first = dir_entry_marker($);
|
||||
u8 attr = dir_entry_attr($);
|
||||
|
||||
u64 next_first_byte = $ + 32;
|
||||
u8 next_attr = dir_entry_attr(next_first_byte); // current offset plus 12 bytes (offset 0x0B of entry)
|
||||
|
||||
if (first != 0x00 && attr == 0x0F) {
|
||||
LFN_Entry LFN_ENTRY;
|
||||
|
||||
if (next_first_byte != 0x00 && next_first_byte != 0xE5 && next_attr == 0x0F) {
|
||||
LFN_Entry next_LFN_ENTRY;
|
||||
SFN_Entry_Alias SFN_ALIAS;
|
||||
}
|
||||
|
||||
} else if (first != 0x00 && attr != 0x0F) {
|
||||
SFN_Entry SFN_ENTRY;
|
||||
}
|
||||
};
|
||||
|
||||
// ------------------------------
|
||||
// ROOT DIRECTORY ENTRY PARSER
|
||||
// ROUGH METHOD OF PARSING SFN/LFN/SFN_ALIAS/SUBDIR TWO LEVELS DEEP
|
||||
// IF THE PATTERN CRASHES - THIS IS LIKELY WHY
|
||||
// ------------------------------
|
||||
struct RootDirParser {
|
||||
u64 curr_first_byte = $;
|
||||
u8 curr_attr = dir_entry_attr(curr_first_byte); // current offset plus 12 bytes (offset 0x0B of entry)
|
||||
|
||||
u64 next_first_byte = $ + 32;
|
||||
u8 next_attr = dir_entry_attr(next_first_byte); // current offset plus 12 bytes (offset 0x0B of entry)
|
||||
|
||||
bool is_subdir = false;
|
||||
|
||||
if (curr_first_byte != 0x00 && curr_first_byte != 0xE5 && curr_attr == 0x0F) {
|
||||
LFN_Entry LFN_ENTRY;
|
||||
|
||||
if (next_first_byte != 0x00 && next_first_byte != 0xE5 && next_attr == 0x0F) {
|
||||
LFN_Entry next_LFN_ENTRY;
|
||||
SFN_Entry_Alias SFN_ALIAS;
|
||||
|
||||
is_subdir = SFN_ALIAS.attributes.subDirectory;
|
||||
|
||||
if (SFN_ALIAS.attributes.subDirectory && next_first_byte != 0x00 && next_attr != 0xE5) {
|
||||
is_subdir = SFN_ALIAS.attributes.subDirectory;
|
||||
|
||||
u64 dir_start_addr = dataRegionStart + (SFN_ALIAS.first_cluster - 2) * bytesPerCluster;
|
||||
SubDirParser SUB_DIR_INDEX[while(std::mem::read_unsigned($, 1) != 0x00)] @ dir_start_addr;
|
||||
}
|
||||
}
|
||||
|
||||
if (next_first_byte != 0x00 && next_first_byte != 0xE5 && next_attr != 0x0F) {
|
||||
SFN_Entry_Alias SFN_ALIAS;
|
||||
|
||||
is_subdir = SFN_ALIAS.attributes.subDirectory;
|
||||
|
||||
if (SFN_ALIAS.attributes.subDirectory && next_first_byte != 0x00 && next_attr != 0xE5) {
|
||||
is_subdir = SFN_ALIAS.attributes.subDirectory;
|
||||
|
||||
u64 dir_start_addr = dataRegionStart + (SFN_ALIAS.first_cluster - 2) * bytesPerCluster;
|
||||
SubDirParser SUB_DIR_INDEX[while(std::mem::read_unsigned($, 1) != 0x00)] @ dir_start_addr;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
} else if (curr_first_byte != 0x00 && curr_first_byte != 0xE5 && curr_attr != 0x0F) {
|
||||
SFN_Entry SFN_ENTRY;
|
||||
is_subdir = SFN_ENTRY.attributes.subDirectory;
|
||||
|
||||
if (SFN_ENTRY.attributes.subDirectory && next_first_byte != 0x00 && next_attr != 0xE5) {
|
||||
is_subdir = SFN_ENTRY.attributes.subDirectory;
|
||||
|
||||
u64 dir_start_addr = dataRegionStart + (SFN_ENTRY.first_cluster - 2) * bytesPerCluster;
|
||||
SubDirParser SUB_DIR_INDEX[while(std::mem::read_unsigned($, 1) != 0x00)] @ dir_start_addr;
|
||||
}
|
||||
|
||||
} else if (curr_first_byte != 0x00 && current_first_byte == 0xE5) {
|
||||
|
||||
if (next_first_byte != 0x00 && next_attr == 0x0F) {
|
||||
LFN_Entry LFN_ENTRY;
|
||||
|
||||
if (next_first_byte != 0x00 && next_first_byte != 0xE5) {
|
||||
|
||||
if (next_attr != 0x0F) {
|
||||
SFN_Entry_Alias SFN_ALIAS;
|
||||
|
||||
is_subdir = SFN_ALIAS.attributes.subDirectory;
|
||||
|
||||
if (next_first_byte != 0x00 && next_first_byte != 0xE5 && next_attr != 0x0F) {
|
||||
SFN_Entry_Alias SFN_ALIAS2; // otherwise switch to SFN
|
||||
|
||||
is_subdir = SFN_ALIAS.attributes.subDirectory;
|
||||
|
||||
if (SFN_ALIAS.attributes.subDirectory && next_first_byte != 0x00 && next_attr != 0xE5) {
|
||||
is_subdir = SFN_ALIAS.attributes.subDirectory;
|
||||
|
||||
u64 dir_start_addr = dataRegionStart + (SFN_ALIAS.first_cluster - 2) * bytesPerCluster;
|
||||
SubDirParser SUB_DIR_INDEX[while(std::mem::read_unsigned($, 1) != 0x00)] @ dir_start_addr;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
SFN_Entry SFN_ENTRY;
|
||||
is_subdir = SFN_ENTRY.attributes.subDirectory;
|
||||
}
|
||||
}
|
||||
} [[name(format_element($, start_index, is_subdir)), comment("FILE/DIR [INDX #]")]];
|
||||
|
||||
// ------------------------------
|
||||
// NAME FORMATTER
|
||||
// ------------------------------
|
||||
fn format_element(auto v, u64 offset, bool subdir) {
|
||||
if (subdir) {
|
||||
return std::format("SUB_DIR [{:02}]", std::core::array_index() + offset);
|
||||
} else {
|
||||
return std::format("FILE [{:02}]", std::core::array_index() + offset);
|
||||
}
|
||||
};
|
||||
|
||||
// ------------------------------
|
||||
// ROOT DIRECTORY HEADER PARSER
|
||||
// ------------------------------
|
||||
struct RootDirHeader {
|
||||
char VolumeName[11] [[comment("User Defined Name of the VOL")]];
|
||||
u8 VolumeLabelFlag [[comment("Indicates the Preceding VOL LABEL")]];
|
||||
padding[10] [[comment("Zeros")]];
|
||||
std::time::DOSTime Created_Time [[format("format_dos_time_field"), comment("Last Write Time - Typically when Created/Formatted, but NOT ALWAYS...(DISK IMAGE/FAT DRIVERS)")]];
|
||||
std::time::DOSDate Created_Date [[format("format_dos_date_field"), comment("Last Write Date - Typically when Created/Formatted, but NOT ALWAYS...(DISK IMAGE/FAT DRIVERS)")]];
|
||||
padding[6] [[comment("Zeros")]];
|
||||
};
|
||||
|
||||
// ------------------------------
|
||||
// VBR SIGNATURE HELPER
|
||||
// ------------------------------
|
||||
enum VBRSignature : u16 {
|
||||
VBR_SIG = 0xAA55
|
||||
};
|
||||
|
||||
// ------------------------------
|
||||
// FILE SYSTEM INFO BLOCK
|
||||
// ------------------------------
|
||||
struct FSInfo {
|
||||
u32 leadSignature [[comment("RRaA")]];
|
||||
padding[480] [[comment("Zeros")]];
|
||||
u32 structSignature [[comment("FSINFO Signature")]];
|
||||
u32 freeClusterCount [[comment("Approximate Free Cluster Count")]];
|
||||
u32 nextFreeCluster [[comment("FAT1: Suggested Starting Point")]];
|
||||
padding[14] [[comment("Zeros")]];
|
||||
VBRSignature VBR_SIG [[comment("0x55AA")]];
|
||||
};
|
||||
|
||||
// ------------------------------
|
||||
// FAT12/16/32 BIOS PARAMETER BLOCK (BPB)
|
||||
// ------------------------------
|
||||
struct BPB_Common {
|
||||
u8 jmp_boot[3] [[comment("Assembly Instructions to Jump to Boot Code")]];
|
||||
char oem_name[8] [[comment("MSDOS/BSD")]];
|
||||
u16 bytes_per_sector [[comment("512,1024,2048,4096")]];
|
||||
u8 sectors_per_cluster [[comment("Under 32K - Must be a power of 2")]];
|
||||
u16 reserved_sectors [[comment("Size of Reserved Area in Sectors")]];
|
||||
u8 num_fats [[comment("Typically 2, but can be 1 for Small Volumes")]];
|
||||
u16 root_entry_count [[comment("Max Num of Entries -- 0 for FAT32| 512 for FAT16")]];
|
||||
u16 total_sectors16 [[comment("if 0, use total_sectors32")]];
|
||||
u8 media_type [[comment("0xF8=FIXED DISK | 0xF0=REMOVABLE")]];
|
||||
u16 fat_size16 [[comment("Size of each FAT in Sectors for FAT12/16; 0 for FAT32")]];
|
||||
u16 sectors_per_track [[comment("Legacy")]];
|
||||
u16 num_heads [[comment("Legacy")]];
|
||||
u32 hidden_sectors [[comment("Num of Sectors before the Volume")]];
|
||||
u32 total_sectors32 [[comment("32bit Value of Total Num of Sectors in Volume")]];
|
||||
// ----------------------vvv-----
|
||||
// FAT32 EXTENDED
|
||||
// ----------------------vvv-----
|
||||
u32 FAT_Sector_Count [[comment("Total Sectors per FAT")]];
|
||||
u16 ext_flags [[comment("16bit Value: BIT_7 = 1 == 1 FAT USED | Otherwise both FATs USED")]];
|
||||
u16 fs_version [[comment("Major and Minor | None")]];
|
||||
u32 root_cluster [[comment("Cluster Num of Root Dir")]];
|
||||
u16 fs_info_sector [[comment("FS_INFO Location")]];
|
||||
u16 backup_boot_sector [[comment("VBR Backup Location")]];
|
||||
u8 reserved[12] [[comment("Zeros")]];
|
||||
u8 drive_number [[comment("BIOS INT13h Drive Num")]];
|
||||
u8 reserved1 [[comment("Zeros")]];
|
||||
u8 boot_signature [[comment("Extended Boot Sig = 0x29")]];
|
||||
u32 volume_id [[comment("Volume Serial Number - Based on Created Date/Time")]];
|
||||
char volume_label[11] [[comment("No Name | User Defined Name | Check Root Dir")]];
|
||||
char fs_type[8] [[comment("FAT32 ")]];
|
||||
u8 bootstrap[420] [[comment("Until Signature")]];
|
||||
VBRSignature VBR_SIG [[comment("0x55AA")]];
|
||||
// ----------------------vvv-----
|
||||
// UPDATE CONSTANTS/GLOBALS
|
||||
// ----------------------vvv-----
|
||||
bytesPerCluster = sectors_per_cluster * bytes_per_sector;
|
||||
rootDirSectors = ((root_entry_count * 32) + (bytes_per_sector - 1)) / bytes_per_sector;
|
||||
firstDataSector = reserved_sectors + (num_fats * FAT_Sector_Count) + rootDirSectors;
|
||||
dataRegionStart = firstDataSector * bytes_per_sector;
|
||||
};
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// FAT32 MAIN RELATED
|
||||
// -----------------------------------------------------------------------------
|
||||
// V V V V V V V V V V
|
||||
// -----------------------------------------------------------------------------
|
||||
// ------------------------------
|
||||
// FAT32 VOLUME BOOT RECORD
|
||||
// ------------------------------
|
||||
BPB_Common F32_VBR @ $;
|
||||
VBR_OFFSET = F32_VBR.hidden_sectors * F32_VBR.bytes_per_sector;
|
||||
|
||||
/// ------------------------------
|
||||
// FILE SYSTEM INFO BLOCK
|
||||
// ------------------------------
|
||||
FSInfo FS_INFO @ F32_VBR.fs_info_sector * F32_VBR.bytes_per_sector;
|
||||
root_dir_start = dataRegionStart + ((F32_VBR.root_cluster - 2) * bytesPerCluster) + 32;
|
||||
|
||||
// ------------------------------
|
||||
// FILE ALLOCATION TABLE
|
||||
// *** HAS GLOBAL AT TOP ***
|
||||
// ------------------------------
|
||||
FAT1_start_offset = F32_VBR.reserved_sectors * F32_VBR.bytes_per_sector;
|
||||
FAT2_start_offset = FAT1_start_offset + (F32_VBR.FAT_Sector_Count * F32_VBR.bytes_per_sector);
|
||||
FAT_ClusterHeap_Count = F32_VBR.FAT_Sector_Count * F32_VBR.bytes_per_sector / CLUSTER_SIZE_BYTES;
|
||||
|
||||
FAT_Header FAT1_HEADER @ FAT1_start_offset;
|
||||
FAT_Entry FAT1[MAX_FAT_CHUNKS] @ FAT1_start_offset + 8;
|
||||
|
||||
FAT_Header FAT2_HEADER @ FAT2_start_offset;
|
||||
FAT_Entry FAT2[MAX_FAT_CHUNKS] @ FAT2_start_offset + 8;
|
||||
|
||||
// ------------------------------
|
||||
// ROOT DIRECTORY HEADER
|
||||
// ------------------------------
|
||||
RootDirHeader ROOT_DIR_HEADER @ dataRegionStart + ((F32_VBR.root_cluster - 2) * bytesPerCluster);
|
||||
|
||||
// ----*-----*------*------*-----
|
||||
// * * ROOT DIRECTORY PARSER * *
|
||||
// ----*-----*------*------*-----
|
||||
RootDirParser ROOT_DIR_ENTRIES[while(std::mem::read_unsigned($, 1) != 0x00)] @ root_dir_start;
|
||||
|
||||
// ------------------------------
|
||||
// SFN <-> CLUSTER RELATION OVERLAY
|
||||
// *** HAS GLOBAL AT TOP ***
|
||||
// ------------------------------
|
||||
INFO_Overlay SFN_CLUSTER_LIST[MAX_SFN_CLUSTER_RELATIONS] @ FAT1_start_offset [[name("SFN <-> CLUSTER (DERIVED)")]];
|
||||
|
||||
// ------------------------------
|
||||
// FAT32 VOLUME REPORT
|
||||
// *** HAS GLOBAL AT TOP ***
|
||||
// ------------------------------
|
||||
abs_FAT1_start_offset = VBR_OFFSET + (F32_VBR.reserved_sectors * F32_VBR.bytes_per_sector);
|
||||
abs_FAT2_start_offset = abs_FAT1_start_offset + (F32_VBR.FAT_Sector_Count * F32_VBR.bytes_per_sector);
|
||||
abs_rootDirStart_offset = VBR_OFFSET + dataRegionStart;
|
||||
|
||||
if (VOLUME_REPORT) {
|
||||
std::print(" ");
|
||||
std::print("-----------------------------------------");
|
||||
std::print("---------- FAT32 VOLUME_REPORT ----------");
|
||||
std::print("-----------------------------------------");
|
||||
std::print("VOL_LABEL = {}", F32_VBR.volume_label);
|
||||
std::print("FILE_SYSTEM = {}", F32_VBR.fs_type);
|
||||
std::print("SERIAL_NUMBER = 0x{:X}", F32_VBR.volume_id);
|
||||
|
||||
std::print("-----------------------------------------");
|
||||
std::print("BYTES/SECTOR = {:02}", F32_VBR.bytes_per_sector);
|
||||
std::print("SECTORS/CLUSTER = {:02}", F32_VBR.sectors_per_cluster);
|
||||
std::print("BYTES/CLUSTER = {:02}", bytesPerCluster);
|
||||
std::print("ROOT_ENTRIES = {:02}", F32_VBR.root_entry_count);
|
||||
std::print("CLUSTER_COUNT = {:02}", (F32_VBR.total_sectors32 - firstDataSector) / F32_VBR.sectors_per_cluster);
|
||||
|
||||
std::print("-----------------------------------------");
|
||||
std::print("VOLUME_SIZE = {:02} SECTORS", F32_VBR.total_sectors32);
|
||||
std::print("VOLUME_SIZE = {:.4f} GB @ 1000", (F32_VBR.total_sectors32 * F32_VBR.bytes_per_sector) / 1000.0 / 1000.0 / 1000.0);
|
||||
std::print("VOLUME_SIZE = {:.4f} GiB @ 1024", (F32_VBR.total_sectors32 * F32_VBR.bytes_per_sector) / 1024.0 / 1024.0 / 1024.0);
|
||||
|
||||
std::print("-----------------------------------------");
|
||||
std::print("RESERVED_SECTORS = {:02}", F32_VBR.reserved_sectors);
|
||||
std::print("FAT_COUNT = {:02}", F32_VBR.num_fats);
|
||||
std::print("FAT_SIZE = {:02} SECTORS", F32_VBR.FAT_Sector_Count);
|
||||
std::print("FAT1_START_OFF = {} | 0x{:02X}", abs_FAT1_start_offset, abs_FAT1_start_offset);
|
||||
std::print("FAT2_START_OFF = {} | 0x{:02X}", abs_FAT2_start_offset, abs_FAT2_start_offset);
|
||||
std::print("ROOT_DIR_CLUSTER = {:02}", F32_VBR.root_cluster);
|
||||
std::print("ROOT_DIR_OFFSET = {} | 0x{:02X}", abs_rootDirStart_offset, abs_rootDirStart_offset);
|
||||
|
||||
std::print("-----------------------------------------");
|
||||
if (sfn_del_count >= 1) {
|
||||
std::print("SFN_DEL(xE5) = DETECTED");
|
||||
}
|
||||
if (lfn_del_count >= 1) {
|
||||
std::print("LFN_DEL(xE5) = DETECTED");
|
||||
}
|
||||
std::print("FAT1_EOF_COUNT = {:02}", allocated_file_count / 2); // divided by 2 (FAT1/FAT2)
|
||||
|
||||
std::print("-----------------------------------------");
|
||||
std::print("------------------ END ------------------");
|
||||
std::print("-----------------------------------------");
|
||||
std::print(" ");
|
||||
}
|
||||
1571
patterns/DFIR/NTFS.hexpat
Normal file
1571
patterns/DFIR/NTFS.hexpat
Normal file
File diff suppressed because it is too large
Load Diff
616
patterns/DFIR/exFAT.hexpat
Normal file
616
patterns/DFIR/exFAT.hexpat
Normal file
@@ -0,0 +1,616 @@
|
||||
#pragma author Formula Zero One Technologies
|
||||
#pragma description exFAT Filesystem (exFAT_v2.0)
|
||||
#pragma MIME application/x-ima
|
||||
#pragma endian little
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// CREDIT
|
||||
// -----------------------------------------------------------------------------
|
||||
// Based on /fs/exfat.hexpat by WerWolv
|
||||
// -----------------------------------------------------------------------------
|
||||
// -----------------------------------------------------------------------------
|
||||
// NOTES
|
||||
// -----------------------------------------------------------------------------
|
||||
// Imported by DISK_PARSER.hexpat
|
||||
// -----------------------------------------------------------------------------
|
||||
// -----------------------------------------------------------------------------
|
||||
// TODO
|
||||
// -----------------------------------------------------------------------------
|
||||
// Recursive parsing of Root Directory / SubDirs
|
||||
// -----------------------------------------------------------------------------
|
||||
// -----------------------------------------------------------------------------
|
||||
// IMPORTS
|
||||
// -----------------------------------------------------------------------------
|
||||
import std.core;
|
||||
import std.io;
|
||||
import std.time;
|
||||
import std.mem;
|
||||
import type.guid;
|
||||
import type.magic;
|
||||
import type.base;
|
||||
|
||||
// ------------------------------
|
||||
// FORWARD DECS/GLOBALS
|
||||
// ------------------------------
|
||||
|
||||
// *** ATTENTION ***
|
||||
// SET MAXIMUM NUMBER OF 4 BYTE CHUNKS TO PARSE FROM FAT1
|
||||
// SET MAXIMUM NUMBER OF DIRECTORY ENTRIES TO PARSE FROM ROOT DIRECTORY
|
||||
// DEFAULTS ARE 4096 | 2500
|
||||
// Choose a value greater than 1 and less than 65536 OR increase the Array size limit with "#define... "
|
||||
|
||||
// -------**************---vvvv--- |
|
||||
const u64 MAX_FAT_CHUNKS = 4096;
|
||||
// -------**************---^^^^--- |
|
||||
|
||||
// -------**************---vvvv--- |
|
||||
const u64 MAX_DIR_ENTRIES = 2500;
|
||||
// -------**************---^^^^--- |
|
||||
|
||||
// *** ATTENTION ***
|
||||
// ---*******---*******----vvvv--- |
|
||||
const bool VOLUME_REPORT = true;
|
||||
// ---*******---*******----^^^^--- |
|
||||
|
||||
u64 allocated_file_count;
|
||||
u64 rdc;
|
||||
|
||||
// --------------------------
|
||||
// exFAT DIRECTORY ENTRY HELPER
|
||||
// --------------------------
|
||||
enum EntryType : u8 {
|
||||
UNUSED_ENTRY = 0x00,
|
||||
ACTIVE_VOLUME_GUID_ENTRY = 0xA0,
|
||||
INACTIVE_VOLUME_GUID_ENTRY = 0x20,
|
||||
ACTIVE_TEXFAT_ENTRY = 0xA1,
|
||||
INACTIVE_TEXFAT_ENTRY = 0x21,
|
||||
ACTIVE_ACCESS_CONTROL_ENTRY = 0xA2,
|
||||
INACTIVE_ACCESS_CONTROL_ENTRY = 0x22,
|
||||
ACTIVE_VOLUME_LABEL_ENTRY = 0x83,
|
||||
INACTIVE_VOLUME_LABEL_ENTRY = 0x03,
|
||||
ACTIVE_ALLOCATION_BITMAP_ENTRY = 0x81,
|
||||
INACTIVE_ALLOCATION_BITMAP_ENTRY = 0x01,
|
||||
ACTIVE_UPCASE_TABLE_ENTRY = 0x82,
|
||||
INACTIVE_UPCASE_TABLE_ENTRY = 0x02,
|
||||
ACTIVE_FILE_INFO_ENTRY = 0x85,
|
||||
INACTIVE_FILE_INFO_ENTRY = 0x05,
|
||||
ACTIVE_STREAM_ENTRY = 0xC0,
|
||||
INACTIVE_STREAM_ENTRY = 0x40,
|
||||
ACTIVE_FILENAME_ENTRY = 0xC1,
|
||||
INACTIVE_FILENAME_ENTRY = 0x41,
|
||||
};
|
||||
|
||||
// ------------------------------
|
||||
// DATES AND TIMES FUNC
|
||||
// ------------------------------
|
||||
fn format_dos_time_field(std::time::DOSTime t) {
|
||||
return std::time::format_dos_time(t, "{:02}:{:02}:{:02}");
|
||||
};
|
||||
|
||||
fn format_dos_date_field(std::time::DOSDate d) {
|
||||
return std::time::format_dos_date(d, "{1:02}-{0:02}-{2:04}");
|
||||
};
|
||||
|
||||
// ------------------------------
|
||||
// BITFIELD HELPERS
|
||||
// ------------------------------
|
||||
bitfield Entry_Flags {
|
||||
unsigned TypeCode : 5;
|
||||
unsigned Importance : 1;
|
||||
unsigned Category : 1;
|
||||
unsigned InUse : 1;
|
||||
} [[bitfield_order(std::core::BitfieldOrder::LeastToMostSignificant, 8)]];
|
||||
|
||||
bitfield Bitmap_Flags {
|
||||
unsigned Bitmap_1 : 1;
|
||||
unsigned Bitmap_2 : 1;
|
||||
} [[bitfield_order(std::core::BitfieldOrder::LeastToMostSignificant, 8)]];
|
||||
|
||||
bitfield General_Primary_Flags {
|
||||
unsigned Allocation_Possible : 1;
|
||||
unsigned No_FAT_Chain : 1;
|
||||
unsigned Reserved : 6;
|
||||
} [[bitfield_order(std::core::BitfieldOrder::LeastToMostSignificant, 8)]];
|
||||
|
||||
bitfield General_Secondary_Flags {
|
||||
unsigned Allocation_Possible : 1;
|
||||
unsigned No_FAT_Chain : 1;
|
||||
unsigned Reserved : 6;
|
||||
} [[bitfield_order(std::core::BitfieldOrder::LeastToMostSignificant, 8)]];
|
||||
|
||||
bitfield File_Attr_Flags {
|
||||
unsigned Read_Only : 1;
|
||||
unsigned Hidden : 1;
|
||||
unsigned System : 1;
|
||||
unsigned Directory : 1;
|
||||
unsigned Archive : 1;
|
||||
Reserved : 11;
|
||||
} [[bitfield_order(std::core::BitfieldOrder::LeastToMostSignificant, 16)]];
|
||||
|
||||
// --------------------------
|
||||
// exFAT DIRECTORY ENTRY STRUCTURES
|
||||
// --------------------------
|
||||
// xA0 / x20 = Volume GUID Entry
|
||||
struct VolumeGUID_Entry {
|
||||
Entry_Flags EntryFlags [[comment("ENTRY TYPE IDENTIFIER")]];
|
||||
u8 SecondaryCount[3] [[comment("COUNT OF SUBSEQUENT ENTRIES")]];
|
||||
type::Hex<u16> SetChecksum [[comment("16bit CHECKSUM")]];
|
||||
General_Primary_Flags PrimaryFlags;
|
||||
type::GUID GUID;
|
||||
u8 Reserved_1[9];
|
||||
};
|
||||
|
||||
// xA1 / x21 = TexFAT / Padding Entry
|
||||
struct TexFATPadding_Entry {
|
||||
Entry_Flags Flags [[comment("ENTRY TYPE IDENTIFIER")]];
|
||||
u8 Reserved_1[31];
|
||||
};
|
||||
|
||||
// xA2 / x22 = Access Control Entry
|
||||
struct AccessControl_Entry {
|
||||
Entry_Flags Flags [[comment("ENTRY TYPE IDENTIFIER")]];
|
||||
u8 Reserved[31];
|
||||
};
|
||||
|
||||
// x83 / x03 = Volume Label Entry
|
||||
struct VolumeLabel_Entry {
|
||||
Entry_Flags Flags [[comment("ENTRY TYPE IDENTIFIER")]];
|
||||
u8 LabelLength [[comment("NUMBER OF UTF-16 CHARACTERS")]];
|
||||
char16 Label[LabelLength] [[comment("VOLUME LABEL: UTF-16")]];
|
||||
u8 Reserved[32-2-(LabelLength * 2)];
|
||||
};
|
||||
|
||||
// x81 / x01 = Allocation Bitmap Entry
|
||||
struct AllocationBitmap_Entry {
|
||||
Entry_Flags Flags [[comment("ENTRY TYPE IDENTIFIER")]];
|
||||
Bitmap_Flags BitmapFlags;
|
||||
u8 Reserved_1[18];
|
||||
u32 FirstCluster [[comment("FIRST LOGICAL CLUSTER NUMBER")]];
|
||||
u64 DataLength [[comment("DATA SIZE")]];
|
||||
u8 FILE_DATA[DataLength] @ temp_root_location + (FirstCluster - exFAT_VBR.root_dir_cluster) * bytesPerCluster [[comment("POINTER TO THE CLUSTER CONTENT")]];
|
||||
};
|
||||
|
||||
// x82 / x02 = UpCase Table Entry
|
||||
struct UpCaseTable_Entry {
|
||||
Entry_Flags Flags [[comment("ENTRY TYPE IDENTIFIER")]];
|
||||
u8 Reserved_1[3];
|
||||
type::Hex<u32> TableChecksum [[comment("16bit CHECKSUM")]];
|
||||
u8 Reserved_2[12];
|
||||
u32 FirstCluster [[comment("FIRST LOGICAL CLUSTER NUMBER")]];
|
||||
u64 DataLength [[comment("DATA SIZE")]];
|
||||
u8 FILE_DATA[DataLength] @ temp_root_location + (FirstCluster - exFAT_VBR.root_dir_cluster) * bytesPerCluster [[comment("POINTER TO THE CLUSTER CONTENT")]];
|
||||
};
|
||||
|
||||
// x85 / x05 = File Info Entry
|
||||
struct FileInfo_Entry {
|
||||
Entry_Flags EntryFlags [[comment("ENTRY TYPE IDENTIFIER")]];
|
||||
u8 SecondaryCount [[comment("COUNT OF SUBSEQUENT ENTRIES")]];
|
||||
type::Hex<u16> SetChecksum [[comment("16bit CHECKSUM")]];
|
||||
File_Attr_Flags AttrFlags [[comment("FILE ATTRS: RASH")]];
|
||||
u16 Reserved_1;
|
||||
std::time::DOSTime Created_Time [[format("format_dos_time_field")]];
|
||||
std::time::DOSDate Created_Date [[format("format_dos_date_field")]];
|
||||
std::time::DOSTime Accessed_Time [[format("format_dos_time_field")]];
|
||||
std::time::DOSDate Accessed_Date [[format("format_dos_date_field")]];
|
||||
std::time::DOSTime Modified_Time [[format("format_dos_time_field")]];
|
||||
std::time::DOSDate Modified_Date [[format("format_dos_date_field")]];
|
||||
u8 Created_10ms_Increments [[comment("Add to Times for Refinement")]];
|
||||
u8 Modified_10ms_Increments [[comment("Add to Times for Refinement")]];
|
||||
s8 Created_UTC_Diff [[comment("Add to Times for Refinement")]];
|
||||
s8 Modified_UTC_Diff [[comment("Add to Times for Refinement")]];
|
||||
s8 Accessed_UTC_Diff [[comment("Add to Times for Refinement")]];
|
||||
u8 Reserved[7];
|
||||
};
|
||||
|
||||
// xC1 / x41 = File Name Entry
|
||||
struct FileName_Entry {
|
||||
Entry_Flags EntryFlags [[comment("ENTRY TYPE IDENTIFIER")]];
|
||||
General_Secondary_Flags SecondaryFlags [[comment("COUNT OF SUBSEQUENT ENTRIES")]];
|
||||
char16 FileName[15] [[comment("FILE NAME: UTF-16")]];
|
||||
};
|
||||
|
||||
// xC0 / x40 = Stream Extension Entry
|
||||
struct Stream_Entry {
|
||||
Entry_Flags EntryFlags [[comment("ENTRY TYPE IDENTIFIER")]];;
|
||||
General_Secondary_Flags SecondaryFlags [[comment("COUNT OF SUBSEQUENT ENTRIES")]];
|
||||
u8 Reserved_1;
|
||||
u8 NameLength [[comment("STREAM LENGTH")]];
|
||||
type::Hex<u16> NameHash [[comment("16bit QUICK HASH: USED FOR FILE SEARCHING")]];
|
||||
u16 Reserved_2;
|
||||
u64 InitSize [[comment("INITIALIZED SIZE")]];
|
||||
u32 Reserved_3;
|
||||
u32 FirstCluster [[comment("FIRST LOGICAL CLUSTER NUMBER")]];
|
||||
u64 ActualSize [[comment("PHYSICAL DATA SIZE")]];;
|
||||
u8 FILE_DATA[InitSize] @ temp_root_location + (FirstCluster - exFAT_VBR.root_dir_cluster) * bytesPerCluster [[comment("POINTER TO THE CLUSTER CONTENT")]];
|
||||
};
|
||||
|
||||
// --------------------------
|
||||
// exFAT ROOT DIRECTORY
|
||||
// --------------------------
|
||||
struct RootDir {
|
||||
EntryType Type;
|
||||
padding[31];
|
||||
|
||||
match (Type) {
|
||||
(EntryType::UNUSED_ENTRY): {
|
||||
continue;
|
||||
}
|
||||
(EntryType::ACTIVE_VOLUME_GUID_ENTRY | EntryType::INACTIVE_VOLUME_GUID_ENTRY):{
|
||||
VolumeGUID_Entry VOLUME_GUID_ENTRY @ $ - 32;
|
||||
}
|
||||
(EntryType::ACTIVE_TEXFAT_ENTRY | EntryType::INACTIVE_TEXFAT_ENTRY):{
|
||||
TexFATPadding_Entry TEXFAT_PADDING_ENTRY @ $ - 32;
|
||||
}
|
||||
(EntryType::ACTIVE_ACCESS_CONTROL_ENTRY | EntryType::INACTIVE_ACCESS_CONTROL_ENTRY):{
|
||||
AccessControl_Entry ACCESS_CONTROL_ENTRY @ $ - 32;
|
||||
}
|
||||
(EntryType::ACTIVE_VOLUME_LABEL_ENTRY | EntryType::INACTIVE_VOLUME_LABEL_ENTRY):{
|
||||
VolumeLabel_Entry VOLUME_LABEL_ENTRY @ $ - 32;
|
||||
}
|
||||
(EntryType::ACTIVE_ALLOCATION_BITMAP_ENTRY | EntryType::INACTIVE_ALLOCATION_BITMAP_ENTRY):{
|
||||
AllocationBitmap_Entry ALLOCATION_BITMAP_ENTRY @ $ - 32;
|
||||
u64 bitmap_cluster = ALLOCATION_BITMAP_ENTRY.FirstCluster;
|
||||
char dolla_BITMAP_label[4] @ FAT1_start_offset + (bitmap_cluster * 4) [[name(std::format("$Bitmap"))]];
|
||||
}
|
||||
(EntryType::ACTIVE_UPCASE_TABLE_ENTRY | EntryType::INACTIVE_UPCASE_TABLE_ENTRY):{
|
||||
UpCaseTable_Entry UPCASE_TABLE_ENTRY @ $ - 32;
|
||||
u64 upcase_cluster = UPCASE_TABLE_ENTRY.FirstCluster;
|
||||
char dolla_UPCASE_label[4] @ FAT1_start_offset + (upcase_cluster * 4) [[name(std::format("$UpCase"))]];
|
||||
}
|
||||
(EntryType::ACTIVE_FILE_INFO_ENTRY | EntryType::INACTIVE_FILE_INFO_ENTRY):{
|
||||
FileInfo_Entry FILE_INFO_ENTRY @ $ - 32;
|
||||
}
|
||||
(EntryType::ACTIVE_STREAM_ENTRY | EntryType::INACTIVE_STREAM_ENTRY):{
|
||||
Stream_Entry STREAM_EXT_ENTRY @ $ - 32;
|
||||
}
|
||||
(EntryType::ACTIVE_FILENAME_ENTRY | EntryType::INACTIVE_FILENAME_ENTRY):{
|
||||
FileName_Entry FILE_NAME_ENTRY @ $ - 32;
|
||||
}
|
||||
}
|
||||
} [[name(format_entry_name(std::mem::read_unsigned($-32, 1), std::core::array_index()))]];
|
||||
|
||||
fn format_entry_name(auto entry_type, u64 idx) {
|
||||
return std::format("{}[{}]", type_name(entry_type), idx);
|
||||
};
|
||||
|
||||
// ------------------------------
|
||||
// TYPE RE-NAMER
|
||||
// ------------------------------
|
||||
fn type_name(u32 type) {
|
||||
if (type == EntryType::UNUSED_ENTRY) return "UNUSED_ENTRY";
|
||||
if (type == EntryType::ACTIVE_VOLUME_GUID_ENTRY) return "ACTIVE_VOLUME_GUID_ENTRY";
|
||||
if (type == EntryType::INACTIVE_VOLUME_GUID_ENTRY) return "INACTIVE_VOLUME_GUID_ENTRY";
|
||||
if (type == EntryType::ACTIVE_TEXFAT_ENTRY) return "ACTIVE_TEXFAT_ENTRY";
|
||||
if (type == EntryType::INACTIVE_TEXFAT_ENTRY) return "INACTIVE_TEXFAT_ENTRY";
|
||||
if (type == EntryType::ACTIVE_ACCESS_CONTROL_ENTRY) return "ACTIVE_ACCESS_CONTROL_ENTRY";
|
||||
if (type == EntryType::INACTIVE_ACCESS_CONTROL_ENTRY) return "INACTIVE_ACCESS_CONTROL_ENTRY";
|
||||
if (type == EntryType::ACTIVE_VOLUME_LABEL_ENTRY) return "ACTIVE_VOLUME_LABEL_ENTRY";
|
||||
if (type == EntryType::INACTIVE_VOLUME_LABEL_ENTRY) return "INACTIVE_VOLUME_LABEL_ENTRY";
|
||||
if (type == EntryType::ACTIVE_ALLOCATION_BITMAP_ENTRY) return "ACTIVE_ALLOCATION_BITMAP_ENTRY";
|
||||
if (type == EntryType::INACTIVE_ALLOCATION_BITMAP_ENTRY) return "INACTIVE_ALLOCATION_BITMAP_ENTRY";
|
||||
if (type == EntryType::ACTIVE_UPCASE_TABLE_ENTRY) return "ACTIVE_UPCASE_TABLE_ENTRY";
|
||||
if (type == EntryType::INACTIVE_UPCASE_TABLE_ENTRY) return "INACTIVE_UPCASE_TABLE_ENTRY";
|
||||
if (type == EntryType::ACTIVE_FILE_INFO_ENTRY) return "ACTIVE_FILE_INFO_ENTRY";
|
||||
if (type == EntryType::INACTIVE_FILE_INFO_ENTRY) return "INACTIVE_FILE_INFO_ENTRY";
|
||||
if (type == EntryType::ACTIVE_STREAM_ENTRY) return "ACTIVE_STREAM_ENTRY";
|
||||
if (type == EntryType::INACTIVE_STREAM_ENTRY) return "INACTIVE_STREAM_ENTRY";
|
||||
if (type == EntryType::ACTIVE_FILENAME_ENTRY) return "ACTIVE_FILENAME_ENTRY";
|
||||
if (type == EntryType::INACTIVE_FILENAME_ENTRY) return "INACTIVE_FILENAME_ENTRY";
|
||||
return "UNKNOWN";
|
||||
};
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// exFAT FILE ALLOCATION TABLE (FAT1) PARSER
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
const u32 CLUSTER_SIZE_BYTES = 4; // Each FAT32 entry = 4 bytes
|
||||
const u32 FAT_EOF = 0x0FFFFFFF; // End-of-file marker
|
||||
const u32 FAT_BAD = 0x0FFFFFF7; // Bad cluster marker
|
||||
const u32 FIRST_ALLOC_CLUSTER = 2; // First usable cluster after reserved
|
||||
|
||||
enum FAT_Flags : u32 {
|
||||
UNALLOCATED = 0x00000000,
|
||||
END_OF_FILE = 0xFFFFFFFF, // L.END
|
||||
BAD_CLUSTER = 0xFFFFFFF7, // L.END
|
||||
};
|
||||
|
||||
union FAT_Union {
|
||||
u32 DECIMAL [[hidden]];
|
||||
FAT_Flags FAT_FLAG;
|
||||
};
|
||||
|
||||
// ------------------------------
|
||||
// Helper function for pointer label
|
||||
// ------------------------------
|
||||
fn cluster_label(u32 val) {
|
||||
if (val == FAT_Flags::UNALLOCATED)
|
||||
return "UNALLOCATED";
|
||||
if (val == FAT_Flags::BAD_CLUSTER)
|
||||
return "BAD";
|
||||
if (val >= 0x0FFFFFF8)
|
||||
return "EOF";
|
||||
return std::format("{}", val);
|
||||
};
|
||||
|
||||
// ------------------------------
|
||||
// FAT1 HEAPS/CHAINS
|
||||
// ------------------------------
|
||||
struct FAT_Entry {
|
||||
FAT_Union FAT [[inline]];
|
||||
|
||||
u32 cluster_num = (FIRST_ALLOC_CLUSTER) + (std::core::array_index());
|
||||
|
||||
u32 next_cluster = FAT.DECIMAL & 0x0FFFFFFF;
|
||||
|
||||
char hover_label[4] @ $ - 4 [[
|
||||
name(std::format(
|
||||
"Cluster: {} → {}",
|
||||
cluster_num,
|
||||
cluster_label(next_cluster)
|
||||
))
|
||||
]];
|
||||
|
||||
bool is_eof = next_cluster >= 0x0FFFFFF8;
|
||||
bool is_bad = next_cluster == FAT_BAD;
|
||||
bool is_free = next_cluster == 0;
|
||||
|
||||
if (is_eof) {
|
||||
allocated_file_count += 1;
|
||||
}
|
||||
} [[name(format_fat_entry(FAT.DECIMAL, std::core::array_index(), FIRST_ALLOC_CLUSTER))]];
|
||||
|
||||
// ------------------------------
|
||||
// FAT FORMATTER FUNC
|
||||
// ------------------------------
|
||||
fn format_fat_entry(u32 raw_value, u32 cluster_index, u32 first_alloc_cluster) {
|
||||
u32 next_cluster = raw_value & 0x0FFFFFFF;
|
||||
|
||||
str next_label;
|
||||
|
||||
if (next_cluster == 0)
|
||||
next_label = "UNALLOCATED";
|
||||
|
||||
else if (next_cluster == FAT_BAD)
|
||||
next_label = "BAD";
|
||||
|
||||
else if (next_cluster == 0x0FFFFFFF)
|
||||
next_label = "EOF";
|
||||
|
||||
else
|
||||
next_label = std::format("{}", next_cluster);
|
||||
|
||||
u32 logical_cluster = first_alloc_cluster + cluster_index;
|
||||
|
||||
if (next_label == "UNALLOCATED" || next_label == "BAD" || next_label == "EOF")
|
||||
return std::format("Cluster {}: {}", logical_cluster, next_label);
|
||||
else
|
||||
return std::format("Cluster {} → {}", logical_cluster, next_label);
|
||||
};
|
||||
|
||||
// ------------------------------
|
||||
// MEDIA DESCRIPTOR HELPER
|
||||
// ------------------------------
|
||||
enum Media_Descriptor : u8 {
|
||||
SINGLE_SIDE_FLOPPY = 0xF0,
|
||||
DOUBLE_SIDE_FLOPPY = 0xF9,
|
||||
HARD_DISK_DRIVE = 0xF8,
|
||||
};
|
||||
|
||||
// ------------------------------
|
||||
// FAT HEADER PARSER
|
||||
// ------------------------------
|
||||
struct FAT_Header {
|
||||
Media_Descriptor mediaDescriptor [[comment("0xF8=FIXED DISK | 0xF0=REMOVABLE")]];;
|
||||
u8 exFAT_FAT_HEADER[7] [[comment("8 BYTES TOTAL: 4 BYTES REPRESENT PSUEDO CLUSTER 0 (SYSTEM) | 4 BYTES REPRESENT PSUEDO CLUSTER 1 (SYSTEM)(EOF)")]];
|
||||
|
||||
//Bitmap and UpCase overlays handled in RootDir parser
|
||||
|
||||
char root_dir_label[4] @ $ + ((rdc - 2) * 4) [[
|
||||
name(std::format(
|
||||
"ROOT_DIRECTORY"
|
||||
))
|
||||
]];
|
||||
};
|
||||
|
||||
// ------------------------------
|
||||
//SIGNATURE HELPER
|
||||
// ------------------------------
|
||||
enum VBRSignature : u16 {
|
||||
VBR_SIG = 0xAA55
|
||||
};
|
||||
|
||||
// ------------------------------
|
||||
// EXTENDED BOOT REGION
|
||||
// ------------------------------
|
||||
struct ExtendedBoot {
|
||||
u8 Extended_Boot_Sector[1 * bytesPerSector];
|
||||
VBRSignature VBR_SIG @ $ - 2;
|
||||
};
|
||||
|
||||
// ------------------------------
|
||||
// BOOT SECTOR BITFIELD FLAGS
|
||||
// ------------------------------
|
||||
bitfield VolumeFlags {
|
||||
unsigned Active : 1;
|
||||
unsigned VolumeDirty : 1;
|
||||
unsigned Media_Failure : 1;
|
||||
unsigned Clear_to_Zero : 1;
|
||||
Rserved : 12;
|
||||
} [[bitfield_order(std::core::BitfieldOrder::LeastToMostSignificant, 16)]];
|
||||
|
||||
// ------------------------------
|
||||
// EXFAT VOLUME BOOT RECORD
|
||||
// ------------------------------
|
||||
struct exFAT_BootSector {
|
||||
u8 jmp_boot[3];
|
||||
char fs_name[8]; // "EXFAT "
|
||||
u8 must_be_zero[53];
|
||||
u64 partition_offset; // in sectors
|
||||
u64 volume_length; // in sectors
|
||||
u32 fat_offset; // in sectors
|
||||
u32 fat_length; // in sectors
|
||||
u32 cluster_heap_offset; // in sectors
|
||||
u32 cluster_count;
|
||||
u32 root_dir_cluster;
|
||||
u32 volume_serial;
|
||||
u16 fs_revision;
|
||||
VolumeFlags volume_flags;
|
||||
u8 bytes_per_sector_shift; // 2^n
|
||||
u8 sectors_per_cluster_shift; // 2^n
|
||||
u8 number_of_fats;
|
||||
u8 drive_select;
|
||||
u8 percent_in_use;
|
||||
u8 reserved[7];
|
||||
u8 bootstrap[390];
|
||||
VBRSignature VBR_SIG; // 0x55AA
|
||||
|
||||
rdc = root_dir_cluster;
|
||||
};
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// MAIN
|
||||
// -------------------------------------------------------------------------
|
||||
// V V V V V V V V V
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
exFAT_BootSector exFAT_VBR @ 0x0;
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// DERIVED CONSTANTS
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
// ============= SIZES ===================================================================
|
||||
u32 bytesPerSector = 1 << exFAT_VBR.bytes_per_sector_shift;
|
||||
u32 bytesPerCluster = bytesPerSector << exFAT_VBR.sectors_per_cluster_shift;
|
||||
|
||||
// ============= OFFSETS =================================================================
|
||||
u64 volumeStartSector = exFAT_VBR.partition_offset;
|
||||
u64 volumeStartOffset = volumeStartSector * bytesPerSector;
|
||||
u64 volumeSize = exFAT_VBR.volume_length * bytesPerSector;
|
||||
|
||||
u64 FAT1_start_offset = exFAT_VBR.fat_offset * bytesPerSector;
|
||||
|
||||
//For printing absolute offset
|
||||
u64 RootDir_Offset = (exFAT_VBR.cluster_heap_offset +
|
||||
((exFAT_VBR.root_dir_cluster - 2) << exFAT_VBR.sectors_per_cluster_shift))
|
||||
* bytesPerSector + volumeStartOffset;
|
||||
|
||||
// ============= CLUSTERS ================================================================
|
||||
u32 clusterSize = bytesPerCluster;
|
||||
u32 clusterCount = exFAT_VBR.cluster_count;
|
||||
u64 clusterHeapOffset = exFAT_VBR.cluster_heap_offset * bytesPerSector;
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// SECONDARY
|
||||
// -------------------------------------------------------------------------
|
||||
// V V V V V V V V V
|
||||
// -------------------------------------------------------------------------
|
||||
// ============= USAGE ===================================================================
|
||||
u8 percentInUse = exFAT_VBR.percent_in_use;
|
||||
|
||||
// ============= EBS =====================================================================
|
||||
ExtendedBoot Extended_Boot_Sectors[8] @ $;
|
||||
|
||||
// ============= OEM =====================================================================
|
||||
u8 OEM_Parameters[1 * bytesPerSector] @ $;
|
||||
|
||||
// ============= ER ======================================================================
|
||||
u8 Extended_Reserved[1 * bytesPerSector] @ $;
|
||||
|
||||
// ============= BCS =====================================================================
|
||||
u8 Boot_Checksum[1 * bytesPerSector] @ $;
|
||||
|
||||
// ============= BBS =====================================================================
|
||||
exFAT_BootSector Backup_Boot_Sector @ $;
|
||||
|
||||
// ============= BEBS ====================================================================
|
||||
ExtendedBoot Backup_Extended_Boot_Sectors[8] @ $;
|
||||
|
||||
// ============= BOEM ====================================================================
|
||||
u8 Backup_OEM_Parameters[1 * bytesPerSector] @ $;
|
||||
|
||||
// ============= BER =====================================================================
|
||||
u8 Backup_Extended_Reserved[1 * bytesPerSector] @ $;
|
||||
|
||||
// ============= BBCS ====================================================================
|
||||
u8 Backup_Boot_Checksum[1 * bytesPerSector] @ $;
|
||||
|
||||
// ============= FAT =====================================================================
|
||||
// *** HAS GLOBAL AT TOP ***
|
||||
|
||||
FAT_Header FAT1_HEADER @ FAT1_start_offset;
|
||||
FAT_Entry FAT1[MAX_FAT_CHUNKS] @ FAT1_start_offset + 8;
|
||||
|
||||
// ============= ROOT ====================================================================
|
||||
// ROOT DIRECTORY
|
||||
// *** HAS GLOBAL AT TOP ***
|
||||
|
||||
// for locating root directory within memory
|
||||
u64 temp_root_location = (exFAT_VBR.root_dir_cluster - 2) * clusterSize + clusterHeapOffset;
|
||||
RootDir ROOT_DIRECTORY[MAX_DIR_ENTRIES] @ temp_root_location;
|
||||
|
||||
|
||||
// ============= REPORT ==================================================================
|
||||
// VOLUME REPORT
|
||||
// *** HAS GLOBAL AT TOP ***
|
||||
|
||||
if (VOLUME_REPORT) {
|
||||
std::print(" ");
|
||||
std::print("-----------------------------------------");
|
||||
std::print("---------- EXFAT VOLUME_REPORT ----------");
|
||||
std::print("-----------------------------------------");
|
||||
std::print("FILE_SYSTEM = {}", exFAT_VBR.fs_name);
|
||||
std::print("SERIAL_NUMBER = 0x{:X}", exFAT_VBR.volume_serial);
|
||||
std::print("FS_REVISION = {}.{}", (exFAT_VBR.fs_revision >> 8) & 0xFF, exFAT_VBR.fs_revision & 0xFF);
|
||||
|
||||
bool _any = false;
|
||||
if(exFAT_VBR.volume_flags.Active) {
|
||||
std::print("FAT_FLAG = 0b{:X}", exFAT_VBR.volume_flags.Active);
|
||||
_any = true;
|
||||
}
|
||||
if(exFAT_VBR.volume_flags.VolumeDirty) {
|
||||
std::print("DIRTY_FLAG = 0b{:X}", exFAT_VBR.volume_flags.Volume_Dirty);
|
||||
_any = true;
|
||||
}
|
||||
if(exFAT_VBR.volume_flags.Media_Failure) {
|
||||
std::print("FAILURE_FLAG = 0b{:X}", exFAT_VBR.volume_flags.Media_Failure);
|
||||
_any = true;
|
||||
}
|
||||
if(exFAT_VBR.volume_flags.Clear_to_Zero) {
|
||||
std::print("CLEAR_TO_ZERO_FLAG = 0b{:X}", exFAT_VBR.volume_flags.Clear_to_Zero);
|
||||
_any = true;
|
||||
}
|
||||
if (!_any){
|
||||
std::print("VOL_FLAGS = NONE");
|
||||
}
|
||||
|
||||
std::print("-----------------------------------------");
|
||||
std::print("BYTES/SECTOR = {}", bytesPerSector);
|
||||
std::print("SECTORS/CLUSTER = {}", 1 << exFAT_VBR.sectors_per_cluster_shift);
|
||||
std::print("BYTES/CLUSTER = {}", bytesPerCluster);
|
||||
std::print("CLUSTER_COUNT = {}", clusterCount);
|
||||
|
||||
std::print("-----------------------------------------");
|
||||
std::print("VOLUME_SIZE = {} SECTORS", exFAT_VBR.volume_length);
|
||||
std::print("VOLUME_SIZE = {:.4f} GB @ 1000", volumeSize / 1000.0 / 1000.0 / 1000.0);
|
||||
std::print("VOLUME_SIZE = {:.4f} GiB @ 1024", volumeSize / 1024.0 / 1024.0 / 1024.0);
|
||||
|
||||
std::print("-----------------------------------------");
|
||||
std::print("VOLUME_START_SEC = {}", volumeStartSector);
|
||||
std::print("VOLUME_START_OFF = 0x{:X}", volumeStartOffset);
|
||||
|
||||
std::print("FAT1_START_OFF = 0x{:02X}", FAT1_start_offset);
|
||||
std::print("CLUSTER_HEAP_OFF = 0x{:02X}", clusterHeapOffset);
|
||||
std::print("ROOT_DIR_CLUSTER = {:02}", exFAT_VBR.root_dir_cluster);
|
||||
std::print("ROOT_DIR_OFFSET = 0x{:02X}", RootDir_Offset);
|
||||
|
||||
std::print("-----------------------------------------");
|
||||
std::print("PERCENT_IN_USE = {:02} %", percentInUse);
|
||||
std::print("NUMBER_OF_FATS = {:02}", exFAT_VBR.number_of_fats);
|
||||
std::print("DRIVE_SELECT = 0x{:02X}", exFAT_VBR.drive_select);
|
||||
|
||||
std::print("-----------------------------------------");
|
||||
std::print("------------------ END ------------------");
|
||||
std::print("-----------------------------------------");
|
||||
std::print(" ");
|
||||
}
|
||||
165
patterns/Devil May Cry HD Collection/dmc3_hd_mod.hexpat
Normal file
165
patterns/Devil May Cry HD Collection/dmc3_hd_mod.hexpat
Normal file
@@ -0,0 +1,165 @@
|
||||
#pragma description Devil May Cry 3 HD .mod 3D model file
|
||||
#pragma author haru233
|
||||
|
||||
// many thanks to AxCut
|
||||
// ImHex Hex Pattern File for Capcom's Devil May Cry 3 HD .mod files
|
||||
|
||||
|
||||
import std.core;
|
||||
|
||||
|
||||
struct ModelHeader {
|
||||
char ID[4];
|
||||
float Version;
|
||||
padding[8];
|
||||
u8 objectCount;
|
||||
u8 boneCount;
|
||||
u8 numberTextures;
|
||||
u8;
|
||||
u32;
|
||||
u64;
|
||||
u64 skeletonOffset;
|
||||
padding[24];
|
||||
};
|
||||
|
||||
struct ObjectInfo {
|
||||
u8 meshCount;
|
||||
u8;
|
||||
u16 numberVertices;
|
||||
padding[4];
|
||||
u64 meshOffset;
|
||||
u32 flags;
|
||||
padding[28];
|
||||
float X, Y, Z;
|
||||
float radius;
|
||||
};
|
||||
|
||||
struct Positions {
|
||||
float positions[3];
|
||||
};
|
||||
|
||||
|
||||
struct Normals {
|
||||
float normal[3];
|
||||
};
|
||||
|
||||
|
||||
struct UVs {
|
||||
s16 uv[2];
|
||||
};
|
||||
|
||||
struct BoneIndices {
|
||||
u8 boneindex[4];
|
||||
};
|
||||
|
||||
struct Weights {
|
||||
u16 weight[1];
|
||||
};
|
||||
|
||||
struct MeshSCM {
|
||||
u16 numberVertices;
|
||||
u16 textureIndex;
|
||||
padding[12];
|
||||
u64 VerticesPositionsOffset;
|
||||
u64 NormalsPositionsOffset;
|
||||
u64 UVsPositionsOffset;
|
||||
|
||||
padding[16];
|
||||
u64 unknownOffset;
|
||||
|
||||
u64;
|
||||
padding[8];
|
||||
|
||||
Positions positions[numberVertices] @VerticesPositionsOffset;
|
||||
Normals normals[numberVertices] @NormalsPositionsOffset;
|
||||
UVs uvs[numberVertices] @UVsPositionsOffset;
|
||||
|
||||
|
||||
};
|
||||
|
||||
struct Mesh {
|
||||
u16 numberVertices;
|
||||
u16 textureIndex;
|
||||
padding[12];
|
||||
u64 VerticesPositionsOffset;
|
||||
u64 NormalsPositionsOffset;
|
||||
u64 UVsPositionsOffset;
|
||||
|
||||
u64 BoneIndicesOffset;
|
||||
u64 WeightsOffset;
|
||||
padding[8];
|
||||
|
||||
u64;
|
||||
padding[8];
|
||||
|
||||
Positions positions[numberVertices] @VerticesPositionsOffset;
|
||||
Normals normals[numberVertices] @NormalsPositionsOffset;
|
||||
UVs uvs[numberVertices] @UVsPositionsOffset;
|
||||
|
||||
BoneIndices b_index[numberVertices] @BoneIndicesOffset;
|
||||
Weights weights[numberVertices] @WeightsOffset;
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
struct Hierarchy {
|
||||
u8 hierarchy;
|
||||
};
|
||||
|
||||
struct HierarchyOrder {
|
||||
u8 hierarchyorder;
|
||||
};
|
||||
|
||||
struct Unknown {
|
||||
u8;
|
||||
};
|
||||
|
||||
struct Transform {
|
||||
float x;
|
||||
float y;
|
||||
float z;
|
||||
float length; // sqrt(x*x + y*y + z*z)
|
||||
padding[16];
|
||||
};
|
||||
|
||||
struct Skeleton{
|
||||
u32 hierarchyOffset;
|
||||
u32 hierarchyOrderOffset;
|
||||
u32 unknownOffset;
|
||||
u32 transformsOffset;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
ModelHeader modelheader @ 0x00;
|
||||
ObjectInfo objects_info[modelheader.objectCount] @ 0x40;
|
||||
|
||||
u32 objectOffset;
|
||||
|
||||
struct Object {
|
||||
u64 i = std::core::array_index();
|
||||
if (modelheader.ID == "SCM ") {
|
||||
objectOffset = objects_info[0].meshOffset;
|
||||
MeshSCM meshscm[objects_info[i].meshCount] @ objects_info[i].meshOffset;
|
||||
|
||||
|
||||
} else {
|
||||
objectOffset = objects_info[0].meshOffset;
|
||||
Mesh mesh[objects_info[i].meshCount] @ objects_info[i].meshOffset;
|
||||
}
|
||||
};
|
||||
|
||||
Object objects[modelheader.objectCount] @objectOffset;
|
||||
|
||||
Skeleton skeleton @modelheader.skeletonOffset;
|
||||
|
||||
Hierarchy hierarchy[modelheader.boneCount] @(modelheader.skeletonOffset + skeleton.hierarchyOffset);
|
||||
|
||||
HierarchyOrder hierarchyorder[modelheader.boneCount] @(modelheader.skeletonOffset + skeleton.hierarchyOrderOffset);
|
||||
|
||||
Unknown unknown[modelheader.boneCount] @(modelheader.skeletonOffset + skeleton.unknownOffset);
|
||||
|
||||
Transform transform[modelheader.boneCount] @(modelheader.skeletonOffset + skeleton.transformsOffset);
|
||||
189
patterns/SHR.hexpat
Normal file
189
patterns/SHR.hexpat
Normal file
@@ -0,0 +1,189 @@
|
||||
/*!
|
||||
Apple IIgs Super Hi-Res (SHR) + PaintWorks Animation (ANI) — ImHex pattern
|
||||
|
||||
Supports:
|
||||
• PIC $C1/$0000 — 32 KB uncompressed SHR screen image
|
||||
• PIC $C1/$0002 — 3200-color (“Brooks”) per-scanline palettes
|
||||
• ANI $C2/$0000 — PaintWorks animation:
|
||||
0x0000..0x7FFF : base SHR $C1/$0000 image
|
||||
0x8000.. : animation header + chunks
|
||||
|
||||
PaintWorks animation structure (per reversed docs):
|
||||
- Base image: uncompressed SHR ($C1/$0000)
|
||||
- +0x8000 u32: total animation data length after header (file_len - 0x8008)
|
||||
- +0x8004 u16: global frame delay in VBLs
|
||||
- +0x8006 u16: flag/? (commonly 0x00C0 or 0x00C1)
|
||||
- +0x8008 ...: one or more animation chunks:
|
||||
chunk:
|
||||
u32 chunk_len (includes this length field)
|
||||
repeated { u16 offset; u16 value; } pairs
|
||||
offset==0x0000 marks End-of-Frame (value is ignored)
|
||||
- Offsets may target any byte in the 32 KB SHR space (pixels, SCBs, palettes).
|
||||
This enables palette-cycling and SCB effects.
|
||||
|
||||
References:
|
||||
- CiderPress2 PaintWorks Animation notes (file structure, fields, semantics).
|
||||
*/
|
||||
|
||||
import std.core;
|
||||
import std.sys;
|
||||
import std.math;
|
||||
|
||||
#pragma endian little
|
||||
#include <std/mem.pat>
|
||||
|
||||
#pragma description Apple IIgs Super Hi-Res (SHR) + PaintWorks Animation (ANI)
|
||||
#pragma author hasseily
|
||||
|
||||
|
||||
// ------------------------------ Constants ------------------------------
|
||||
|
||||
const u32 SHR_ROWS = 200;
|
||||
const u32 SHR_BYTES_PER_ROW = 160;
|
||||
const u32 SHR_PIXEL_DATA_SIZE = SHR_ROWS * SHR_BYTES_PER_ROW; // 32000 (0x7D00)
|
||||
|
||||
const u32 PIC0000_FILE_SIZE = 0x8000; // 32768
|
||||
const u32 PIC0002_FILE_SIZE = 0x9600; // 38400 (32000 + 200*32)
|
||||
|
||||
const u32 PIC0000_OFF_PIXELS = 0x0000;
|
||||
const u32 PIC0000_OFF_SCB = 0x7D00;
|
||||
const u32 PIC0000_OFF_RESERVED = 0x7DC8;
|
||||
const u32 PIC0000_OFF_PALETTES = 0x7E00;
|
||||
|
||||
const u32 PALETTE_COUNT = 16;
|
||||
const u32 PALETTE_COLORS = 16;
|
||||
|
||||
const u32 ANI_BASE_SHR_SIZE = 0x8000; // First 32 KB is a $C1/$0000 image
|
||||
const u32 ANI_HDR_OFF = 0x8000; // Animation header starts here
|
||||
const u32 ANI_MIN_TOTAL_SIZE = 0x8008; // base + header (no chunks)
|
||||
|
||||
// ------------------------------ Types: SHR core ------------------------------
|
||||
|
||||
struct Row160 { u8 data[SHR_BYTES_PER_ROW]; };
|
||||
|
||||
// Scanline Control Byte
|
||||
bitfield ShrSCB {
|
||||
palette : 4; // 0..15
|
||||
reserved : 1;
|
||||
color_fill : 1;
|
||||
interrupt : 1;
|
||||
mode_640 : 1; // 0=320, 1=640
|
||||
};
|
||||
|
||||
// helper: expand a 4-bit channel to 8-bit (0x0..0xF -> 0x00..0xFF)
|
||||
fn expand4(u8 v) { return (v << 4) | v; };
|
||||
|
||||
bitfield Colors_gb {
|
||||
blue : 4; // Blue (B3..B0)
|
||||
green : 4; // Green (G3..G0)
|
||||
};
|
||||
|
||||
bitfield Colors_r0 {
|
||||
red : 4; // Red (R3..R0)
|
||||
unused : 4; // Unused / reserved
|
||||
};
|
||||
|
||||
// RGB444 stored as 0RGB
|
||||
struct Rgb444_0RGB {
|
||||
Colors_gb gb;
|
||||
Colors_r0 r0;
|
||||
} [[color(std::format("{:02X}{:02X}{:02X}", expand4(r0.red), expand4(gb.green), expand4(gb.blue)))]];
|
||||
|
||||
struct Palette16 { Rgb444_0RGB color[PALETTE_COLORS]; };
|
||||
|
||||
// $C1/$0000 raw 32 KB screen dump
|
||||
struct SHR_PIC0000 {
|
||||
Row160 pixels[SHR_ROWS] @ PIC0000_OFF_PIXELS;
|
||||
ShrSCB scb[SHR_ROWS] @ PIC0000_OFF_SCB;
|
||||
u8 reserved[56] @ PIC0000_OFF_RESERVED;
|
||||
Palette16 palettes[PALETTE_COUNT] @ PIC0000_OFF_PALETTES;
|
||||
};
|
||||
|
||||
// “Brooks” 3200-color: pixels + 200 per-line palettes (no SCBs)
|
||||
struct BrooksLinePalette { Rgb444_0RGB color[PALETTE_COLORS]; };
|
||||
|
||||
struct SHR_PIC0002 {
|
||||
Row160 pixels[SHR_ROWS] @ 0x0000;
|
||||
BrooksLinePalette line_palettes[SHR_ROWS] @ SHR_PIXEL_DATA_SIZE; // 0x7D00
|
||||
};
|
||||
|
||||
// ------------------------------ Types: PaintWorks ANI ($C2/$0000) ------------------------------
|
||||
|
||||
/* Each operation modifies 1 word at an absolute offset in the 32 KB SHR area.
|
||||
End-of-frame marker: offset == 0x0000 (value is ignored). */
|
||||
struct AniOp {
|
||||
u16 offset [[color("0000AA")]]; // 0x0000..0x7FFE valid; 0x0000 = End-of-Frame
|
||||
u16 value [[color("00AAAA")]]; // word to store at [offset]
|
||||
// For convenience in the sidebar:
|
||||
bool is_eof = (offset == 0x0000);
|
||||
};
|
||||
|
||||
// A contiguous animation chunk: length + packed AniOp pairs.
|
||||
// Most files have exactly one chunk that spans all frames.
|
||||
struct AniChunk {
|
||||
u32 chunk_len; // includes this field
|
||||
|
||||
// ops_count = (chunk_len - 4)/4, unless chunk_len == 4
|
||||
// in which case: (__file_size - 0x8000 - 12)/4
|
||||
u64 ops_count64 =
|
||||
(chunk_len == 4)
|
||||
? ( (__file_size > (0x8000 + 12)) ? ((__file_size - 0x8000 - 12) / 4) : 0 )
|
||||
: ( (chunk_len >= 4) ? (u64(chunk_len - 4) / 4) : 0 );
|
||||
|
||||
u32 ops_count = u32(ops_count64);
|
||||
|
||||
// ops start immediately after chunk_len (offset +4)
|
||||
AniOp ops[ops_count];
|
||||
};
|
||||
|
||||
// Header located at 0x8000 after the base 32 KB image
|
||||
struct AniHeader {
|
||||
u32 anim_data_len [[color("660000")]]; // total bytes of animation data after header
|
||||
u16 frame_delay_vbl [[color("CC0000")]]; // global per-frame delay in VBLs (NTSC/PAL differ)
|
||||
u16 flag_unknown; // usually 0x00C0 or 0x00C1
|
||||
};
|
||||
|
||||
// Full PaintWorks animation container
|
||||
struct ANI_PaintWorks {
|
||||
// Base frame: a normal uncompressed SHR image
|
||||
SHR_PIC0000 base @ 0x0000;
|
||||
|
||||
// Global animation header
|
||||
AniHeader hdr @ ANI_HDR_OFF;
|
||||
|
||||
// One or more chunks, typically exactly one:
|
||||
AniChunk chunks[ std::math::min(
|
||||
u32(16), // cap to keep ImHex happy in pathological cases
|
||||
u32((__file_size - (ANI_HDR_OFF + sizeof(AniHeader))) > 3 ?
|
||||
1 + u32((__file_size - (ANI_HDR_OFF + sizeof(AniHeader))) / 0x10000000) :
|
||||
1)
|
||||
) ] @ (ANI_HDR_OFF + sizeof(AniHeader));
|
||||
|
||||
// Helpful computed values for inspection:
|
||||
u64 file_len = __file_size;
|
||||
u64 expected_anim_end = ANI_HDR_OFF + sizeof(AniHeader) + u64(hdr.anim_data_len);
|
||||
};
|
||||
|
||||
// ------------------------------ Dispatcher ------------------------------
|
||||
|
||||
u64 __file_size = std::mem::size();
|
||||
|
||||
if (__file_size == PIC0000_FILE_SIZE) {
|
||||
// Plain SHR dump
|
||||
SHR_PIC0000 pic0000 @ 0x0000;
|
||||
|
||||
} else if (__file_size == PIC0002_FILE_SIZE) {
|
||||
// Brooks 3200-color
|
||||
SHR_PIC0002 pic0002 @ 0x0000;
|
||||
|
||||
} else if (__file_size >= ANI_MIN_TOTAL_SIZE) {
|
||||
// Heuristic: treat as PaintWorks ANI if there’s room for base+header.
|
||||
// (Many PW ANI files use ProDOS type $C2/$0000.)
|
||||
ANI_PaintWorks ani @ 0x0000;
|
||||
|
||||
} else if (__file_size >= SHR_PIXEL_DATA_SIZE) {
|
||||
// Fallback: show pixels only for odd dumps
|
||||
Row160 pixels_only[SHR_ROWS] @ 0x0000;
|
||||
}
|
||||
|
||||
ANI_PaintWorks ani_paintworks_at_0 @ 0;
|
||||
129
patterns/a3/a3_bmtr.hexpat
Normal file
129
patterns/a3/a3_bmtr.hexpat
Normal file
@@ -0,0 +1,129 @@
|
||||
#pragma author MrClock
|
||||
#pragma description Arma 3 RTM animation format (binarized)
|
||||
|
||||
#pragma endian little
|
||||
|
||||
#pragma MIME application/x.a3-bmtr
|
||||
|
||||
fn get_data_description() {
|
||||
return "Binarized RTM (BMTR) animation files are the PBO packed versions of plain RTMs.\n Binarized files are optimized for use by the game engine, and they are not editable.\nBone transformations are stored as relative quaternion-vector pairs.\nData blocks are conditionally LZO1X compressed (these are not supported by this pattern).";
|
||||
};
|
||||
|
||||
import std.string;
|
||||
import std.sys;
|
||||
import type.float16;
|
||||
|
||||
using asciiz = std::string::NullString [[format("formatAsciiz")]];
|
||||
using half = type::float16 ;
|
||||
struct s16float {
|
||||
s16 data;
|
||||
} [[sealed,static,transform("transforms16float"), format("transforms16float")]];
|
||||
|
||||
struct Property {
|
||||
padding[4];
|
||||
asciiz name;
|
||||
float phase;
|
||||
asciiz value;
|
||||
} [[format("formatProperty")]];
|
||||
|
||||
struct Vector<DataType> {
|
||||
DataType x [[comment("+Left/-Right")]];
|
||||
DataType y [[comment("+Up/-Down (UNUSED)")]];
|
||||
DataType z [[comment("+Forward/-Backward")]];
|
||||
} [[static]];
|
||||
|
||||
struct Quaternion {
|
||||
s16float x;
|
||||
s16float y;
|
||||
s16float z;
|
||||
s16float w;
|
||||
} [[static,format("formatQuaternion")]];
|
||||
|
||||
struct Transform {
|
||||
Quaternion orientation;
|
||||
Vector<half> position [[format("formatVectorHalf")]];
|
||||
} [[static]];
|
||||
|
||||
struct Frame {
|
||||
u32 count_bones;
|
||||
bool compressed = count_bones * sizeof(Transform) >= 1024;
|
||||
if (parent.version > 4) {
|
||||
u8 lzo_flag;
|
||||
compressed = lzo_flag > 0;
|
||||
}
|
||||
|
||||
if (compressed) {
|
||||
std::error("Transformations are LZO compressed and compressed length is unknown");
|
||||
} else {
|
||||
Transform transforms[count_bones];
|
||||
}
|
||||
};
|
||||
|
||||
struct BMTR {
|
||||
char signature[4];
|
||||
u32 version;
|
||||
padding[1];
|
||||
Vector<float> motion [[format("formatVectorFloat")]];
|
||||
u32 count_frames;
|
||||
padding[4];
|
||||
u32 count_bones;
|
||||
u32 count_bones_again;
|
||||
|
||||
std::assert_warn(count_bones == count_bones_again, "Mismatch between bone counts");
|
||||
|
||||
asciiz bones[count_bones];
|
||||
|
||||
if (version >= 4) {
|
||||
padding[4];
|
||||
u32 count_properties;
|
||||
Property properties[count_properties];
|
||||
}
|
||||
|
||||
u32 count_phases;
|
||||
std::assert_warn(count_frames == count_phases, "Frame and phase counts do not match");
|
||||
|
||||
bool compressed = count_phases * sizeof(float) >= 1024;
|
||||
if (version > 4) {
|
||||
u8 lzo_flag;
|
||||
compressed = lzo_flag > 0;
|
||||
}
|
||||
|
||||
if (compressed) {
|
||||
std::error("Phases are LZO compressed and compressed length is unknown");
|
||||
} else {
|
||||
float phases[count_phases];
|
||||
}
|
||||
|
||||
Frame frames[count_frames];
|
||||
};
|
||||
|
||||
fn transforms16float(ref s16float value) {
|
||||
return float(value.data) / 16384;
|
||||
};
|
||||
|
||||
fn formatAsciiz(ref asciiz value) {
|
||||
return std::format("\"{:s}\"", value);
|
||||
};
|
||||
|
||||
fn formatProperty(ref Property prop) {
|
||||
return std::format("\"{0:s}\" = \"{1:s}\" @ {2:.4f}", prop.name, prop.value, prop.phase);
|
||||
};
|
||||
|
||||
fn formatVectorHalf(ref Vector<half> vec) {
|
||||
return std::format(
|
||||
"[{0}, {1}, {2}]",
|
||||
type::impl::format_float16(vec.x),
|
||||
type::impl::format_float16(vec.y),
|
||||
type::impl::format_float16(vec.z)
|
||||
);
|
||||
};
|
||||
|
||||
fn formatVectorFloat(ref Vector<float> vec) {
|
||||
return std::format("[{0:.2f}, {1:.2f}, {2:.2f}]", vec.x, vec.y, vec.z);
|
||||
};
|
||||
|
||||
fn formatQuaternion(ref Quaternion q) {
|
||||
return std::format("[{0:.2f}, {1:.2f}, {2:.2f}, {3:.2f}]", q.x, q.y, q.z, q.w);
|
||||
};
|
||||
|
||||
BMTR file @ 0x0000;
|
||||
222
patterns/a3/a3_p3d_mlod.hexpat
Normal file
222
patterns/a3/a3_p3d_mlod.hexpat
Normal file
@@ -0,0 +1,222 @@
|
||||
#pragma author MrClock
|
||||
#pragma description Arma 3 P3D model format (MLOD)
|
||||
|
||||
#pragma endian little
|
||||
|
||||
#pragma MIME model/x.a3-p3d-mlod
|
||||
|
||||
fn get_data_description() {
|
||||
return "MLOD type P3D files are used for authoring 3D models for Arma 3.\nThese files can be carated in and edited in the Object Builder application.\nAll data is stored uncompressed for ease of editing.\nDuring the PBO packing process they are further \"binarized\" into ODOL type P3D files, that are optimized for use by the game engine. (These are no longer editable, the conversion is irreversible.)\n\nP3D model files can by quite large, so by default only the 1st LOD is processed by this pattern. Processing of all LODs can be enabled in the pattern settings.";
|
||||
};
|
||||
|
||||
import std.string;
|
||||
import std.core;
|
||||
|
||||
bool process_all_lods in;
|
||||
|
||||
using asciiz = std::string::NullString;
|
||||
|
||||
enum FaceType: u32 {
|
||||
TRIANGLE = 3,
|
||||
QUAD = 4
|
||||
};
|
||||
|
||||
struct Vector {
|
||||
float x;
|
||||
float y;
|
||||
float z;
|
||||
} [[static,format("formatVector")]];
|
||||
|
||||
struct UV {
|
||||
float u;
|
||||
float v;
|
||||
} [[static,format("formatUV")]];
|
||||
|
||||
enum SurfaceFitting: u8 {
|
||||
NORMAL = 0,
|
||||
ON_SURFACE = 1,
|
||||
ABOVE_SURFACE = 2,
|
||||
UNDER_SURFACE = 4,
|
||||
KEEP_HEIGHT = 8
|
||||
};
|
||||
|
||||
enum Lighting: u8 {
|
||||
NORMAL = 0,
|
||||
SHINING = 1,
|
||||
SHADOWED = 2,
|
||||
FULL_LIT = 4,
|
||||
HALF_LIT = 8
|
||||
};
|
||||
|
||||
enum DecalMode: u8 {
|
||||
NORMAL = 0,
|
||||
DECAL = 1,
|
||||
RADIO12 = 2
|
||||
};
|
||||
|
||||
enum Fog: u8 {
|
||||
NORMAL = 0,
|
||||
NONE = 1,
|
||||
SKY = 2
|
||||
};
|
||||
|
||||
enum NormalCalculation: u8 {
|
||||
FACE_AREA = 0,
|
||||
HIDDE_VERTEX = 1,
|
||||
FIXED = 2,
|
||||
FACE_ANLGE = 4
|
||||
};
|
||||
|
||||
bitfield VertexFlags {
|
||||
padding : 5;
|
||||
NormalCalculation normals : 3;
|
||||
u8 user;
|
||||
padding : 2;
|
||||
Fog fog : 2;
|
||||
padding : 2;
|
||||
DecalMode decal : 2;
|
||||
Lighting lighting : 4;
|
||||
SurfaceFitting surface : 4;
|
||||
} [[bitfield_order(std::core::BitfieldOrder::MostToLeastSignificant, 32)]];
|
||||
|
||||
struct Vertex {
|
||||
Vector position;
|
||||
VertexFlags flags;
|
||||
}[[static,format("formatVertex")]];
|
||||
|
||||
struct FacePoint {
|
||||
u32 vertex_index;
|
||||
u32 normal_index;
|
||||
UV uv;
|
||||
} [[static]];
|
||||
|
||||
enum ZBiasFlag: u8 {
|
||||
NONE = 0,
|
||||
LOW = 1,
|
||||
MIDDLE = 2,
|
||||
HIGH = 3
|
||||
};
|
||||
|
||||
bitfield FaceFlags {
|
||||
user : 7;
|
||||
disable_texture_merging : 1;
|
||||
padding : 2;
|
||||
flat_lighting : 1;
|
||||
reversed_face : 1;
|
||||
padding : 10;
|
||||
ZBiasFlag zbias : 2;
|
||||
position : 1;
|
||||
padding : 1;
|
||||
double_sided_face : 1;
|
||||
disable_shadow : 1;
|
||||
padding : 4;
|
||||
} [[bitfield_order(std::core::BitfieldOrder::MostToLeastSignificant, 32)]];
|
||||
|
||||
struct Face {
|
||||
FaceType type;
|
||||
FacePoint points[4];
|
||||
FaceFlags flags;
|
||||
asciiz texture;
|
||||
asciiz material;
|
||||
} [[format("formatFace")]];
|
||||
|
||||
struct Edge {
|
||||
u32 vertex_1;
|
||||
u32 vertex_2;
|
||||
} [[sealed,static,format("formatEdge")]];
|
||||
|
||||
struct Property {
|
||||
char name[64] [[transform("std::string::to_string")]];
|
||||
char value[64] [[transform("std::string::to_string")]];
|
||||
} [[static,sealed,format("formatProperty")]];
|
||||
|
||||
struct Tagg {
|
||||
bool active;
|
||||
asciiz name;
|
||||
u32 length;
|
||||
|
||||
if (name == "#EndOfFile#") {
|
||||
break;
|
||||
}
|
||||
|
||||
match (name) {
|
||||
("#SharpEdges#"): Edge edges[length/8];
|
||||
("#Property#"): Property property;
|
||||
("#Mass#"): float masses[parent.count_verticies];
|
||||
("#UVSet#"): {
|
||||
u32 channel;
|
||||
UV coordinates[(length - 4) / 8];
|
||||
}
|
||||
(_): if (std::string::starts_with(name, "#") && std::string::ends_with(name, "#")) {
|
||||
u8 unknown_data[length];
|
||||
} else {
|
||||
u8 vertex_weights[parent.count_verticies];
|
||||
u8 face_weights[parent.count_faces];
|
||||
}
|
||||
}
|
||||
} [[format("formatTagg")]];
|
||||
|
||||
struct P3dmLod {
|
||||
char signature[4];
|
||||
u32 version_major;
|
||||
u32 version_minor;
|
||||
u32 count_verticies;
|
||||
u32 count_normals;
|
||||
u32 count_faces;
|
||||
u32; // Unknown data (might be unused model flags)
|
||||
Vertex verticies[count_verticies];
|
||||
Vector normals[count_normals];
|
||||
Face faces[count_faces];
|
||||
char tagg_signature[4];
|
||||
Tagg taggs[while(true)];
|
||||
float resolution;
|
||||
} [[format("formatP3dmLod")]];
|
||||
|
||||
struct P3D {
|
||||
char signature[4];
|
||||
u32 version;
|
||||
u32 count_lods;
|
||||
if (!process_all_lods) {
|
||||
P3dmLod lod_0;
|
||||
} else {
|
||||
P3dmLod lods[count_lods];
|
||||
}
|
||||
};
|
||||
|
||||
fn formatVector(ref Vector pos) {
|
||||
return std::format("[{0:.3f}, {1:.3f}, {1:.3f}]", pos.x, pos.y, pos.z);
|
||||
};
|
||||
|
||||
fn formatUV(ref UV pos) {
|
||||
return std::format("[{0:.3f}, {1:.3f}]", pos.u, pos.v);
|
||||
};
|
||||
|
||||
fn formatVertex(ref Vertex vert) {
|
||||
return formatVector(vert.position);
|
||||
};
|
||||
|
||||
fn formatFace(ref Face face) {
|
||||
return face.type == FaceType::TRIANGLE ? "triangle" : "quad";
|
||||
};
|
||||
|
||||
fn formatEdge(ref Edge edge) {
|
||||
return std::format("{0:d} <-> {1:d}", edge.vertex_1, edge.vertex_2);
|
||||
};
|
||||
|
||||
fn formatProperty(ref Property prop) {
|
||||
return std::format("\"{0:s}\" = \"{1:s}\"", prop.name, prop.value);
|
||||
};
|
||||
|
||||
fn formatTagg(ref Tagg tagg) {
|
||||
if (std::core::has_member(tagg, "vertex_weights")) {
|
||||
return std::format("\"{0:s}\" selection", tagg.name);
|
||||
} else {
|
||||
return std::format("\"{0:s}\"", tagg.name);
|
||||
}
|
||||
};
|
||||
|
||||
fn formatP3dmLod(ref P3dmLod lod) {
|
||||
return std::format("Resolution: {0}", lod.resolution);
|
||||
};
|
||||
|
||||
P3D file @ 0x0000;
|
||||
141
patterns/a3/a3_paa.hexpat
Normal file
141
patterns/a3/a3_paa.hexpat
Normal file
@@ -0,0 +1,141 @@
|
||||
#pragma author MrClock
|
||||
#pragma description Arma 3 PAA image format
|
||||
|
||||
#pragma endian little
|
||||
|
||||
#pragma MIME image/x.a3-paa
|
||||
|
||||
fn get_data_description() {
|
||||
return "PAA texture files are the proprietary image format used for textures in Arma 3.\nSimilar to most other formats used in game engines, the PAA stores not only a single resolution, but a series of precomputed mipmaps.\nPAA supports multiple pixel encoding formats, such as DXT1, DXT5, RGBA5551, grayscale, and others. Mipmap data in DXT encoded files is optionally compressed with the LZO1X algorithm. All other types are unconditionally LZSS compressed.";
|
||||
};
|
||||
|
||||
import type.color;
|
||||
import std.mem;
|
||||
import std.sys;
|
||||
|
||||
struct Color<auto alpha> {
|
||||
u8 b;
|
||||
u8 g;
|
||||
u8 r;
|
||||
if (alpha) u8 a;
|
||||
} [[sealed, format("type::impl::format_color"), color(std::format("{0:02X}{1:02X}{2:02X}", r, g, b))]];
|
||||
|
||||
using BGR8 = Color<false>;
|
||||
using BGRA8 = Color<true>;
|
||||
|
||||
enum PixelFormat: u16 {
|
||||
DXT1 = 0xFF01,
|
||||
DXT2 = 0xFF02,
|
||||
DXT3 = 0xFF03,
|
||||
DXT4 = 0xFF04,
|
||||
DXT5 = 0xFF05,
|
||||
RGBA4 = 0x4444,
|
||||
RGBA5 = 0x1555,
|
||||
RGBA8 = 0x8888,
|
||||
GRAY = 0x8080
|
||||
};
|
||||
|
||||
enum AlphaMode: u32 {
|
||||
NONE = 0,
|
||||
INTERPOLATED = 1,
|
||||
BINARY = 2
|
||||
};
|
||||
|
||||
enum Swizzle: u8 {
|
||||
ALPHA = 0,
|
||||
RED = 1,
|
||||
GREEN = 2,
|
||||
BLUE = 3,
|
||||
INVERTED_ALPHA = 4,
|
||||
INVERTED_RED = 5,
|
||||
INVERTED_GREEN = 6,
|
||||
INVERTED_BLUE = 7,
|
||||
BLANK_WHITE = 8,
|
||||
BLANK_BLACK = 9
|
||||
};
|
||||
|
||||
enum Compression: u8 {
|
||||
NONE = 0,
|
||||
LZO1X = 1,
|
||||
LZSS = 2
|
||||
};
|
||||
|
||||
struct Tagg {
|
||||
char signature[8];
|
||||
u32 length;
|
||||
|
||||
match (signature) {
|
||||
("GGATCGVA"): BGRA8 color;
|
||||
("GGATCXAM"): BGRA8 color;
|
||||
("GGATGALF"): AlphaMode alpha;
|
||||
("GGATSFFO"): u32 offsets[16];
|
||||
("GGATZIWS"): Swizzle copies[4];
|
||||
(_): u8 data[length];
|
||||
}
|
||||
} [[format("format_tagg_name")]];
|
||||
|
||||
struct Palette {
|
||||
u16 length;
|
||||
BGR8 colors[length];
|
||||
};
|
||||
|
||||
struct Mipmap {
|
||||
u16 width_and_lzo [[format("format_width_lzo")]];
|
||||
u16 height;
|
||||
|
||||
u16 width = width_and_lzo;
|
||||
Compression compression = Compression::NONE;
|
||||
if ((u32(parent.format) & 0xFF00) == 0xFF00) {
|
||||
width = width_and_lzo & 0x7FFF;
|
||||
compression = width_and_lzo & 0x8000 ? Compression::LZO1X : Compression::NONE;
|
||||
} else {
|
||||
compression = Compression::LZSS;
|
||||
}
|
||||
|
||||
if (width == 0 && height == 0) {
|
||||
break;
|
||||
}
|
||||
|
||||
u24 size;
|
||||
match (compression) {
|
||||
(Compression::NONE): u8 encoded_data[size];
|
||||
(Compression::LZO1X): u8 lzo_compressed_data[size];
|
||||
(Compression::LZSS): u8 lzss_compressed_data[size];
|
||||
}
|
||||
} [[format("format_resolution")]];
|
||||
|
||||
struct PAA {
|
||||
PixelFormat format;
|
||||
Tagg taggs[while(std::mem::read_string($, 4) == "GGAT")];
|
||||
Palette palette;
|
||||
Mipmap mipmaps[while(true)];
|
||||
u16 EOF;
|
||||
|
||||
std::assert_warn(EOF == 0, "Invalid EOF sentinel");
|
||||
};
|
||||
|
||||
fn format_resolution(ref auto mip) {
|
||||
return std::format("{0:d} x {1:d}", mip.width, mip.height);
|
||||
};
|
||||
|
||||
fn format_width_lzo(u16 value) {
|
||||
u16 width = value & 0x7FFF;
|
||||
if (value & 0x8000) {
|
||||
return std::format("{0:d} (+LZO flag)", width);
|
||||
} else {
|
||||
return std::format("{0:d}", width);
|
||||
}
|
||||
};
|
||||
|
||||
fn format_tagg_name(Tagg data) {
|
||||
match (data.signature) {
|
||||
("GGATCGVA"): return "Average color";
|
||||
("GGATCXAM"): return "Max color";
|
||||
("GGATGALF"): return "Alpha flag";
|
||||
("GGATZIWS"): return "Swizzle";
|
||||
("GGATSFFO"): return "Mipmap offsets";
|
||||
(_): return "Unknown";
|
||||
}
|
||||
};
|
||||
|
||||
PAA file @ 0x0000;
|
||||
165
patterns/a3/a3_rap.hexpat
Normal file
165
patterns/a3/a3_rap.hexpat
Normal file
@@ -0,0 +1,165 @@
|
||||
#pragma author MrClock
|
||||
#pragma description Arma 3 binary configuration format
|
||||
|
||||
#pragma endian little
|
||||
|
||||
#pragma MIME application/x.a3-rap
|
||||
|
||||
fn get_data_description() {
|
||||
return "The RAP format is the binarized/\"rapified\" version of configuration files for Arma 3. Plain text configuration, material definition, scenario description and other files using the configuration syntax are rapified during the PBO packing process. The game can work with the plain text versions (they are actually rapified during boot), but properly converting them into the binary format ahead of time makes the booting easier.";
|
||||
};
|
||||
|
||||
import std.mem;
|
||||
import std.string;
|
||||
import std.core;
|
||||
import std.io;
|
||||
|
||||
using asciiz = std::string::NullString [[format("formatAsciiz")]];
|
||||
|
||||
/*
|
||||
Item counts are stored in 7-bit encoded integers. In each byte the top bit signals
|
||||
if the next byte belongs to the number as well.
|
||||
*/
|
||||
struct CompressedUint {
|
||||
u8 extras[while(std::mem::read_unsigned($, 1) & 0x80)];
|
||||
u8 last;
|
||||
} [[sealed,transform("transformCompressedUint"),format("formatCompressedUint")]];
|
||||
|
||||
enum MemberType: u8 {
|
||||
CLASS = 0,
|
||||
LITERAL = 1,
|
||||
ARRAY = 2,
|
||||
EXTERNAL = 3,
|
||||
DELETE = 4,
|
||||
ARRAY_EXTENSION = 5
|
||||
};
|
||||
|
||||
enum ValueType: u8 {
|
||||
STRING = 0,
|
||||
FLOAT = 1,
|
||||
INTEGER = 2,
|
||||
ARRAY = 3,
|
||||
VARIABLE = 4
|
||||
};
|
||||
|
||||
using Array;
|
||||
|
||||
struct ArrayItem {
|
||||
ValueType type;
|
||||
match (type) {
|
||||
(ValueType::STRING): asciiz value;
|
||||
(ValueType::FLOAT): float value;
|
||||
(ValueType::INTEGER): s32 value;
|
||||
(ValueType::ARRAY): Array value;
|
||||
(ValueType::VARIABLE): asciiz value;
|
||||
}
|
||||
} [[format("formatArrayItem")]];
|
||||
|
||||
struct Array {
|
||||
CompressedUint count_items;
|
||||
ArrayItem items[count_items];
|
||||
} [[format("formatArray")]];
|
||||
|
||||
using ClassBody;
|
||||
|
||||
struct Member {
|
||||
MemberType type;
|
||||
|
||||
match(type) {
|
||||
(MemberType::CLASS): {
|
||||
asciiz name;
|
||||
ClassBody *body : u32;
|
||||
}
|
||||
(MemberType::LITERAL): {
|
||||
ValueType subtype;
|
||||
asciiz name;
|
||||
match (subtype) {
|
||||
(ValueType::STRING): asciiz value;
|
||||
(ValueType::FLOAT): float value;
|
||||
(ValueType::INTEGER): s32 value;
|
||||
(_): std::error(std::format("Unexpected subtype for literal: {}", subtype));
|
||||
}
|
||||
}
|
||||
(MemberType::ARRAY | MemberType::ARRAY_EXTENSION): {
|
||||
asciiz name;
|
||||
Array value;
|
||||
}
|
||||
(MemberType::EXTERNAL): {
|
||||
asciiz name;
|
||||
}
|
||||
(MemberType::DELETE): {
|
||||
asciiz name;
|
||||
}
|
||||
}
|
||||
} [[format("formatMember")]];
|
||||
|
||||
using Enums;
|
||||
|
||||
struct ClassBody {
|
||||
asciiz parent_name;
|
||||
CompressedUint count_members;
|
||||
|
||||
Member members[count_members];
|
||||
u8 *pointer : u32 [[comment("In the root body this points to the enum list.\nIn all others it points to the next body on the same level.")]];
|
||||
};
|
||||
|
||||
struct EnumItem {
|
||||
asciiz name;
|
||||
s32 value;
|
||||
} [[format("formatEnumItem")]];
|
||||
|
||||
struct Enums {
|
||||
u32 count_items;
|
||||
EnumItem items[count_items];
|
||||
};
|
||||
|
||||
struct RAP {
|
||||
char signature[4];
|
||||
u32;
|
||||
u32;
|
||||
Enums *enums : u32;
|
||||
ClassBody root;
|
||||
};
|
||||
|
||||
fn formatAsciiz(ref asciiz value) {
|
||||
return std::format("\"{0:s}\"", value);
|
||||
};
|
||||
|
||||
fn transformCompressedUint(ref CompressedUint value) {
|
||||
u64 result = 0;
|
||||
for (u8 i = 0, i < sizeof(value.extras), i += 1) {
|
||||
result += (value.extras[i] & 0x7F) << (7*i);
|
||||
}
|
||||
|
||||
result += value.last << (sizeof(value.extras) * 7);
|
||||
|
||||
return result;
|
||||
};
|
||||
|
||||
fn formatCompressedUint(ref CompressedUint value) {
|
||||
return value;
|
||||
};
|
||||
|
||||
fn formatArrayItem(ref ArrayItem value) {
|
||||
return value.value;
|
||||
};
|
||||
|
||||
fn formatArray(ref Array value) {
|
||||
return "{...}";
|
||||
};
|
||||
|
||||
fn formatMember(ref Member item) {
|
||||
match (item.type) {
|
||||
(MemberType::CLASS): return std::format("class {0:s} {{...}};", item.name);
|
||||
(MemberType::LITERAL): return std::format("{0:s} = {1};", item.name, item.value);
|
||||
(MemberType::ARRAY): return std::format("{0:s}[] = {{...}};", item.name);
|
||||
(MemberType::EXTERNAL): return std::format("class {0:s};", item.name);
|
||||
(MemberType::DELETE): return std::format("del {0:s};", item.name);
|
||||
}
|
||||
};
|
||||
|
||||
fn formatEnumItem(ref EnumItem value) {
|
||||
return std::format("{0:s} = {1}", item.name, item.value);
|
||||
};
|
||||
|
||||
RAP file @ 0x0000;
|
||||
93
patterns/a3/a3_rtm.hexpat
Normal file
93
patterns/a3/a3_rtm.hexpat
Normal file
@@ -0,0 +1,93 @@
|
||||
#pragma author MrClock
|
||||
#pragma description Arma 3 RTM animation format (plain)
|
||||
|
||||
#pragma endian little
|
||||
|
||||
#pragma MIME application/x.a3-rtm
|
||||
|
||||
fn get_data_description() {
|
||||
return "Plain RTM animation files are used in animation authoring for Arma 3.\nThey can be created and edited in Object Builder.\nBone transformations are stored as absolute transformation matrices.\nPlain RTMs must be converted to their \"binarized\" versions by an appropriate PBO packing tool for use in game.";
|
||||
};
|
||||
|
||||
import std.mem;
|
||||
import std.sys;
|
||||
import std.string;
|
||||
import std.io;
|
||||
|
||||
using lascii = std::string::SizedString<u8> [[format("formatLascii")]];
|
||||
|
||||
struct Property {
|
||||
float phase;
|
||||
lascii name;
|
||||
lascii value;
|
||||
} [[format("formatProperty")]];
|
||||
|
||||
struct Bone {
|
||||
char name[32];
|
||||
} [[sealed,static,transform("transformBone"),format("formatBone")]];
|
||||
|
||||
struct Transform {
|
||||
Bone bone;
|
||||
float matrix[12] [[comment("4x4 transformation matrix (with last row omitted)")]];
|
||||
} [[static,format("formatTransform")]];
|
||||
|
||||
struct Frame {
|
||||
float phase;
|
||||
Transform transforms[parent.count_bones];
|
||||
} [[static,format("formatFrame")]];
|
||||
|
||||
struct Vector {
|
||||
float x [[comment("+Left/-Right")]];
|
||||
float y [[comment("+Up/-Down (UNUSED)")]];
|
||||
float z [[comment("+Forward/-Backward")]];
|
||||
} [[static,format("formatVector")]];
|
||||
|
||||
struct RTM {
|
||||
if (std::mem::read_string($, 8) == "RTM_MDAT") {
|
||||
char properties_signature[8];
|
||||
padding[4];
|
||||
u32 count_properties;
|
||||
Property properties[count_properties];
|
||||
}
|
||||
|
||||
std::assert(std::mem::read_string($, 8) == "RTM_0101", "Missing animation data");
|
||||
|
||||
char animation_signature[8];
|
||||
Vector motion;
|
||||
u32 count_frames;
|
||||
u32 count_bones;
|
||||
Bone bones[count_bones];
|
||||
Frame frames[count_frames];
|
||||
|
||||
std::assert_warn(std::mem::eof(), "Data ended before EOF");
|
||||
};
|
||||
|
||||
fn formatLascii(ref lascii value) {
|
||||
return std::format("\"{:s}\"", value);
|
||||
};
|
||||
|
||||
fn formatProperty(ref Property prop) {
|
||||
return std::format("\"{0:s}\" = \"{1:s}\" @ {2:.4f}", prop.name, prop.value, prop.phase);
|
||||
};
|
||||
|
||||
fn transformBone(ref Bone value) {
|
||||
return std::string::to_string(value.name);
|
||||
};
|
||||
|
||||
fn formatBone(ref Bone value) {
|
||||
return std::format("\"{0:s}\"", value);
|
||||
};
|
||||
|
||||
fn formatTransform(ref Transform transform) {
|
||||
return std::format("\"{0:s}\" transform", transform.bone);
|
||||
};
|
||||
|
||||
fn formatFrame(ref Frame frame) {
|
||||
return std::format("frame @ {0:.4f}", frame.phase);
|
||||
};
|
||||
|
||||
fn formatVector(ref Vector vec) {
|
||||
return std::format("[{0:.2f}, {1:.2f}, {2:.2f}]", vec.x, vec.y, vec.z);
|
||||
};
|
||||
|
||||
RTM file @ 0x0000;
|
||||
131
patterns/a3/a3_texheaders.hexpat
Normal file
131
patterns/a3/a3_texheaders.hexpat
Normal file
@@ -0,0 +1,131 @@
|
||||
#pragma author MrClock
|
||||
#pragma description Arma 3 texture index file format
|
||||
|
||||
#pragma endian little
|
||||
|
||||
#pragma MIME application/x.a3-texheaders
|
||||
|
||||
fn get_data_description() {
|
||||
return "TexHeaders.bin files are texture index files used in Arma 3 PBO archives.\nThe files are generated during the PBO packing process, and contain basic information about all the PAA texture files in the PBO.\nThe index for each texture includes the file paths relative to the PBO root, pixel format, suffix, number of mipmaps and their resolutions among other things.";
|
||||
};
|
||||
|
||||
import std.string;
|
||||
import std.math;
|
||||
import type.color;
|
||||
|
||||
using asciiz = std::string::NullString;
|
||||
|
||||
struct BGRA8 {
|
||||
u8 b;
|
||||
u8 g;
|
||||
u8 r;
|
||||
u8 a;
|
||||
} [[
|
||||
static,
|
||||
sealed,
|
||||
format("type::impl::format_color"),
|
||||
color(std::format("{0:02X}{1:02X}{2:02X}", r, g, b))
|
||||
]];
|
||||
|
||||
struct RGBAfloat {
|
||||
float r [[transform("float2u8")]];
|
||||
float g [[transform("float2u8")]];
|
||||
float b [[transform("float2u8")]];
|
||||
float a [[transform("float2u8")]];
|
||||
} [[
|
||||
static,
|
||||
sealed,
|
||||
format("type::impl::format_color"),
|
||||
color(std::format("{0:02X}{1:02X}{2:02X}", r, g, b))
|
||||
]];
|
||||
|
||||
enum PixelFormat: u8 {
|
||||
INDEXED = 0,
|
||||
GRAY = 1,
|
||||
RGB565 = 2,
|
||||
RGBA5551 = 3,
|
||||
RGBA4444 = 4,
|
||||
RGBA8888 = 5,
|
||||
DXT1 = 6,
|
||||
DXT2 = 7,
|
||||
DXT3 = 8,
|
||||
DXT4 = 9,
|
||||
DXT5 = 10
|
||||
};
|
||||
|
||||
enum Suffix: u32 {
|
||||
DIFFUSE = 0,
|
||||
DIFFUSE_LINEAR = 1,
|
||||
DETAIL = 2,
|
||||
NORMAL = 3,
|
||||
IRRADIANCE = 4,
|
||||
RANDOM = 5,
|
||||
TREECROWN = 6,
|
||||
MACRO = 7,
|
||||
SHADOW = 8,
|
||||
SPECULAR = 9,
|
||||
DITHERING = 10,
|
||||
DETAIL_SPECULAR = 11,
|
||||
MASK = 12,
|
||||
THERMAL = 13
|
||||
};
|
||||
|
||||
struct Mipmap {
|
||||
u16 width;
|
||||
u16 height;
|
||||
padding[2];
|
||||
PixelFormat format;
|
||||
padding[1];
|
||||
u32 offset [[comment("Byte offset in file")]];
|
||||
} [[static,format("formatMipmap")]];
|
||||
|
||||
struct Texture {
|
||||
u32 count_color_pallets [[comment("Always 1")]];
|
||||
u32 pallet_pointer [[comment("Always 0")]];
|
||||
RGBAfloat average_color_float;
|
||||
BGRA8 average_color;
|
||||
BGRA8 max_color;
|
||||
u32 clamp_flags [[comment("Always 0")]];
|
||||
u32 transparency [[comment("Always 0xffffffff")]];
|
||||
bool maxcolor_defined [[comment("GGATCXAM was found in PAA")]];
|
||||
bool alpha_interpolated;
|
||||
bool alpha_binary;
|
||||
bool non_opaque [[comment("Interpolated alpha and average alpha < 127")]];
|
||||
u32 count_mipmaps;
|
||||
/*
|
||||
Technically the format is listed as u32 on the community wiki, but
|
||||
for the sake of reusability in the Mipmap struct, it is broken up into
|
||||
a u8 + 3 padding bytes here. (The enum values are in the u8 range
|
||||
anyway.)
|
||||
*/
|
||||
PixelFormat format;
|
||||
padding[3];
|
||||
bool little_endian [[comment("Always true")]];
|
||||
bool is_paa [[comment("File is PAA not PAC")]];
|
||||
asciiz path [[comment("Path relative to texHeaders.bin file")]];
|
||||
Suffix suffix;
|
||||
u32 count_mipmaps_again;
|
||||
Mipmap mipmaps[count_mipmaps];
|
||||
u32 filesize;
|
||||
}[[format("formatTexture")]];
|
||||
|
||||
struct TexHeaders {
|
||||
char signature[4];
|
||||
u32 version [[comment("Always 1")]];
|
||||
u32 count_textures;
|
||||
Texture textures[count_textures];
|
||||
};
|
||||
|
||||
fn float2u8(float value) {
|
||||
return u8(std::math::round(value * 255));
|
||||
};
|
||||
|
||||
fn formatMipmap(ref Mipmap mip) {
|
||||
return std::format("{0:d} x {1:d}", mip.width, mip.height);
|
||||
};
|
||||
|
||||
fn formatTexture(ref Texture tex) {
|
||||
return std::format("{0:d} x {1:d} @ {2:s}", tex.mipmaps[0].width, tex.mipmaps[0].height, tex.path);
|
||||
};
|
||||
|
||||
TexHeaders file @ 0x0000;
|
||||
176
patterns/adtfdat.hexpat
Normal file
176
patterns/adtfdat.hexpat
Normal file
@@ -0,0 +1,176 @@
|
||||
#pragma description ADTFDAT File
|
||||
|
||||
#pragma magic [ 49 46 48 44 ] @ 0x00
|
||||
#pragma endian little
|
||||
|
||||
import std.io;
|
||||
import std.mem;
|
||||
import type.time;
|
||||
|
||||
enum FileVersion : u32 {
|
||||
with_history_end_offset = 0x00000301,
|
||||
v500 = 0x00000500
|
||||
};
|
||||
|
||||
bitfield ChunkFlags {
|
||||
key : 1;
|
||||
info : 1;
|
||||
marker : 1;
|
||||
type : 1;
|
||||
trigger : 1;
|
||||
reserved: 11;
|
||||
};
|
||||
|
||||
struct Extension
|
||||
{
|
||||
char identifier[384];
|
||||
u16 stream_id;
|
||||
u8 reserved1[2];
|
||||
u32 user_id;
|
||||
u32 type_id;
|
||||
u32 version_id;
|
||||
u64 data_pos;
|
||||
u64 data_size;
|
||||
u8 reserved[96];
|
||||
u8 payload[data_size] @ data_pos;
|
||||
};
|
||||
|
||||
struct ChunkHeader {
|
||||
u64 time_stamp [[format("format_timestamp_with_offset")]];;
|
||||
u32 ref_master_table_index;
|
||||
u32 offset_to_last;
|
||||
u32 size;
|
||||
u16 stream_id;
|
||||
ChunkFlags flags;
|
||||
u64 stream_index;
|
||||
};
|
||||
|
||||
struct SampleInfo {
|
||||
u8 memory_layout_version;
|
||||
u32 size;
|
||||
u8 payload[size];
|
||||
};
|
||||
|
||||
struct Sample {
|
||||
s64 timestamp [[format("format_timestamp")]];;
|
||||
s32 flags;
|
||||
u64 buffer_size;
|
||||
u8 payload[buffer_size];
|
||||
if (flags & 0x100) {
|
||||
SampleInfo sample_info;
|
||||
}
|
||||
if (flags & 0x200) {
|
||||
u32 substream_id;
|
||||
} else {
|
||||
u32 substream_id = 0 [[export]];
|
||||
}
|
||||
};
|
||||
|
||||
struct Chunk {
|
||||
auto start_address = $;
|
||||
|
||||
ChunkHeader header;
|
||||
|
||||
if (header.size < 32 || start_address + header.size > std::mem::size()) {
|
||||
std::warning(std::format("Invalid header size {} in chunk {} at offset 0x{:X}, last valid chunk at 0x{:X}.", header.size, chunk_index, start_address, last_valid_chunk_offset));
|
||||
break;
|
||||
}
|
||||
|
||||
last_valid_chunk_offset = start_address;
|
||||
|
||||
u8 payload[header.size - 32];
|
||||
|
||||
if (!skip_valid_chunks) {
|
||||
if (!header.flags.info && !header.flags.marker && !header.flags.type && !header.flags.trigger) {
|
||||
try {
|
||||
Sample sample @ addressof(payload);
|
||||
} catch {
|
||||
std::warning(std::format("Invalid sample payload at chunk {} at 0x{:X}", chunk_index, start_address));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
chunk_index += 1;
|
||||
|
||||
// Padding with 0xEE to the next chunk header
|
||||
std::mem::AlignTo<16>;
|
||||
|
||||
if (skip_valid_chunks) {
|
||||
continue;
|
||||
}
|
||||
};
|
||||
|
||||
struct Header {
|
||||
u32 file_id;
|
||||
u32 version_id;
|
||||
u32 flags;
|
||||
u32 extension_count;
|
||||
u64 extension_offset;
|
||||
u64 data_offset;
|
||||
u64 data_size;
|
||||
u64 chunk_count;
|
||||
u64 max_chunk_size;
|
||||
u64 duration;
|
||||
type::time64_t filetime;
|
||||
u8 header_byte_order;
|
||||
u64 time_offset [[format("format_timestamp")]];
|
||||
u8 patch_number;
|
||||
u64 first_chunk_offset;
|
||||
u64 continuous_offset;
|
||||
u64 ring_buffer_end_offset;
|
||||
u8 reserved[30];
|
||||
char description[1912];
|
||||
};
|
||||
|
||||
struct IndexedFile {
|
||||
Header header;
|
||||
Extension extensions[header.extension_count] @ header.extension_offset;
|
||||
|
||||
if (header.version_id >= FileVersion::with_history_end_offset &&
|
||||
header.continuous_offset != header.data_offset) {
|
||||
try {
|
||||
Chunk ring_front[while($ < header.continuous_offset)] @ header.first_chunk_offset;
|
||||
Chunk ring_back[while($ < header.ring_buffer_end_offset)] @ header.data_offset;
|
||||
Chunk continueous[header.chunk_count - chunk_index] @ header.continuous_offset;
|
||||
} catch {
|
||||
std::warning("Too many chunks. Performing check only.");
|
||||
skip_valid_chunks = true;
|
||||
chunk_index = 0;
|
||||
Chunk ring_front[while($ < header.continuous_offset)] @ header.first_chunk_offset;
|
||||
Chunk ring_back[while($ < header.ring_buffer_end_offset)] @ header.data_offset;
|
||||
Chunk continueous[while(chunk_index < header.chunk_count)] @ header.continuous_offset;
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
Chunk chunks[header.chunk_count] @ header.data_offset;
|
||||
} catch {
|
||||
std::warning("Too many chunks. Performing check only.");
|
||||
skip_valid_chunks = true;
|
||||
chunk_index = 0;
|
||||
Chunk chunks[while(chunk_index < header.chunk_count)] @ header.data_offset;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
fn format_timestamp(u64 data) {
|
||||
double seconds = 0;
|
||||
if (file.header.version_id < FileVersion::v500) {
|
||||
// microseconds
|
||||
seconds = data / double(1000000);
|
||||
} else {
|
||||
// nanoseconds
|
||||
seconds = data / double(1000000000);
|
||||
}
|
||||
|
||||
std::time::Time time64 = std::time::to_utc(seconds);
|
||||
return std::time::format(time64);
|
||||
};
|
||||
|
||||
fn format_timestamp_with_offset(u64 data) {
|
||||
return format_timestamp(data + file.header.time_offset);
|
||||
};
|
||||
|
||||
bool skip_valid_chunks = false;
|
||||
u64 last_valid_chunk_offset = 0;
|
||||
u64 chunk_index = 0;
|
||||
IndexedFile file @ 0x00;
|
||||
197
patterns/adts.hexpat
Normal file
197
patterns/adts.hexpat
Normal file
@@ -0,0 +1,197 @@
|
||||
#pragma author zhoubo
|
||||
#pragma description AAC ADTSn (Audio Data Transport Stream) Audio
|
||||
#pragma MIME audio/x-hx-aac-adts
|
||||
#pragma pattern_limit 0xFFFFFF
|
||||
|
||||
// History
|
||||
// 0.4 2024-02-12 zhoubo: Porting from 010 Editor Templates.
|
||||
// 0.3 2024-02-09 zhoubo: use BitfieldDisablePadding(Unpadded Bitfields) for odd header bytes(7,9 bytes) color, and remove FSeek.
|
||||
// 0.2 2024-02-05 zhoubo: fix some comment & color.
|
||||
// 0.1 2022-06-13 zhoubo: Init release. only ADTS, not support ADIF,LATM.
|
||||
|
||||
// More information available at:
|
||||
// 1. https://wiki.multimedia.cx/index.php?title=ADTS
|
||||
// 2. https://en.wikipedia.org/wiki/Advanced_Audio_Coding
|
||||
// 3. https://en.wikipedia.org/wiki/AAC
|
||||
// 4. https://juejin.cn/post/7032170229732442148
|
||||
|
||||
#pragma endian big
|
||||
|
||||
#include <std/sys.pat>
|
||||
#include <std/core.pat>
|
||||
|
||||
fn GetMPEGVersionComment(auto MPEG_Version)
|
||||
{
|
||||
str comment = "";
|
||||
match (MPEG_Version)
|
||||
{
|
||||
(0): comment = "MPEG-4";
|
||||
(1): comment = "MPEG-2";
|
||||
}
|
||||
return comment;
|
||||
};
|
||||
|
||||
fn GetProtectionAbsentComment(auto Protection_absence)
|
||||
{
|
||||
str comment = "";
|
||||
match (Protection_absence)
|
||||
{
|
||||
(0): comment = "ADTS has 9 bytes with CRC";
|
||||
(1): comment = "ADTS has 7 bytes without CRC";
|
||||
}
|
||||
return comment;
|
||||
};
|
||||
|
||||
fn GetProfileComment(auto Profile)
|
||||
{
|
||||
str comment = "";
|
||||
match (Profile)
|
||||
{
|
||||
(0x00): comment = "AAC Main";
|
||||
(0x01): comment = "AAC LC (Low Complexity)";
|
||||
(0x10): comment = "AAC SSR (Scalable Sample Rate)";
|
||||
(0x11): comment = "AAC LTP (Long Term Prediction)";
|
||||
}
|
||||
return comment;
|
||||
};
|
||||
|
||||
fn GetSamplingFrequencyIndexComment(auto Sampling_frequency_index)
|
||||
{
|
||||
str comment = "";
|
||||
match (Sampling_frequency_index)
|
||||
{
|
||||
(0x0): comment = "96000Hz";
|
||||
(0x1): comment = "88200Hz";
|
||||
(0x2): comment = "64000Hz";
|
||||
(0x3): comment = "48000Hz";
|
||||
(0x4): comment = "44100Hz";
|
||||
(0x5): comment = "32000Hz";
|
||||
(0x6): comment = "24000Hz";
|
||||
(0x7): comment = "22050Hz";
|
||||
(0x8): comment = "16000Hz";
|
||||
(0x9): comment = "12000Hz";
|
||||
(0xa): comment = "11025Hz";
|
||||
(0xb): comment = "8000Hz";
|
||||
(0xc): comment = "7350Hz";
|
||||
(0xd): comment = "Reserved";
|
||||
(0xe): comment = "Reserved";
|
||||
(0xf): comment = "FORBIDDEN (malformed)";
|
||||
}
|
||||
return comment;
|
||||
};
|
||||
|
||||
fn GetChannelConfigurationComment(auto Channel_configuration)
|
||||
{
|
||||
str comment = "";
|
||||
match (Channel_configuration)
|
||||
{
|
||||
(0): comment = "Defined in AOT Specifc Config";
|
||||
(1): comment = "1 channel: front-center";
|
||||
(2): comment = "2 channels: front-left, front-right";
|
||||
(3): comment = "3 channels: front-center, front-left, front-right";
|
||||
(4): comment = "4 channels: front-center, front-left, front-right, back-center";
|
||||
(5): comment = "5 channels: front-center, front-left, front-right, back-left, back-right";
|
||||
(6): comment = "6 channels: front-center, front-left, front-right, back-left, back-right, LFE-channel";
|
||||
(7): comment = "8 channels: front-center, front-left, front-right, side-left, side-right, back-left, back-right, LFE-channel";
|
||||
}
|
||||
return comment;
|
||||
};
|
||||
|
||||
fn GetBufferFullnessComment(auto ADTS_buffer_fullness)
|
||||
{
|
||||
str comment = "";
|
||||
match (ADTS_buffer_fullness)
|
||||
{
|
||||
(0x7FF): comment = "VBR (most software ignore this field)";
|
||||
(_): comment = "rate..?? (most software ignore this field)";
|
||||
}
|
||||
return comment;
|
||||
};
|
||||
|
||||
fn GetRawDataBlockComment(auto Number_of_AAC_frames_minus_1)
|
||||
{
|
||||
str comment = "";
|
||||
match (Number_of_AAC_frames_minus_1)
|
||||
{
|
||||
(0x0): comment = "has 1 AAC data block";
|
||||
(_): comment = "data block number + 1";
|
||||
}
|
||||
return comment;
|
||||
};
|
||||
|
||||
|
||||
//-----------------------------------
|
||||
// Define structures used in AAC files
|
||||
//
|
||||
// [1.adts_fixed_header information]
|
||||
// Syncword: 12bits, sync header, always 0xFFF。
|
||||
// MPEG_Version: 1bit, 0 means MPGE-4, 1 means MPGE-2
|
||||
// Layer: 2bits, alwayas ”00”
|
||||
// Protection_absence: 1bit, 0 means ADTS Header 9 bytes; 1 means ADTS Header 7 bytes
|
||||
// Profile: 2bit, AAC level : Main,LC,SSR,LTP
|
||||
// Sampling_frequency_index: 4bits, Sampling Frequencies
|
||||
// Private_bit: 1bit
|
||||
// Channel_configuration: 3bits, channel number...
|
||||
// Originality: 1bit
|
||||
// Home: 1bit
|
||||
//
|
||||
// [2.adts_variable_header information]
|
||||
// Copyright_id_bit: 1bit
|
||||
// Copyright_id_start: 1bit
|
||||
// AAC_frame_length: 13bits, AAC frame length : ADTS Header(7 or 9 bytes) + sizeof(AAC Frame)
|
||||
// ADTS_buffer_fullness: 11bits, 0x7FF means VBR
|
||||
// Number_of_AAC_frames_minus_1: 2bits, ADTS Frame numbers : Number_of_AAC_frames_minus_1 + 1
|
||||
//
|
||||
// [3.CRC information]
|
||||
// CRC16: 16bits, when Protection_absence=0
|
||||
|
||||
bitfield ADTS_HEADER
|
||||
{
|
||||
// ADTS_FIXED_HEADER
|
||||
Syncword : 12 [[color("00FF00"), comment("always 0xFFF")]];
|
||||
MPEG_Version : 1 [[color("00FF00"), comment(GetMPEGVersionComment(this))]];
|
||||
Layer : 2 [[color("00FF00"), comment("always 0")]];
|
||||
Protection_absence : 1 [[color("00FF00"), comment(GetProtectionAbsentComment(this))]];
|
||||
|
||||
Profile : 2 [[color("0000FF"), comment(GetProfileComment(this))]];
|
||||
Sampling_frequency_index : 4 [[color("0000FF"), comment(GetSamplingFrequencyIndexComment(this))]];
|
||||
Private_bit : 1 [[color("0000FF")]];
|
||||
Channel_configuration : 3 [[color("0000FF"), comment(GetChannelConfigurationComment(this))]];
|
||||
Originality : 1 [[color("0000FF")]];
|
||||
Home : 1 [[color("0000FF")]];
|
||||
|
||||
// ADTS_VARIABLE_HEADER
|
||||
Copyright_id_bit : 1 [[color("0000FF")]];
|
||||
Copyright_id_start : 1 [[color("0000FF")]];
|
||||
AAC_frame_length : 13 [[color("0000FF")]];
|
||||
ADTS_buffer_fullness : 11 [[color("0000FF"), comment(GetBufferFullnessComment(this))]];
|
||||
Number_of_AAC_frames_minus_1 : 2 [[color("0000FF"), comment(GetRawDataBlockComment(this))]];
|
||||
|
||||
// ADTS_CRC_HEADER
|
||||
if (0 == Protection_absence) // Header with CRC
|
||||
{
|
||||
u16 CRC16 [[color("FFFF00")]];
|
||||
}
|
||||
else // Header without CRC
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
struct ADTS_FRAME
|
||||
{
|
||||
ADTS_HEADER Header;
|
||||
|
||||
if (0 == Header.Protection_absence) // Header with CRC 2 bytes
|
||||
{
|
||||
u8 Data[Header.AAC_frame_length - 9] [[color("000000")]];
|
||||
}
|
||||
else // Header without CRC
|
||||
{
|
||||
u8 Data[Header.AAC_frame_length - 7] [[color("000000")]];
|
||||
}
|
||||
};
|
||||
|
||||
//---------------------------------------------
|
||||
|
||||
ADTS_FRAME adtsFrame[while(!std::mem::eof())] @ 0x00;
|
||||
@@ -1,6 +1,14 @@
|
||||
#pragma author WerWolv
|
||||
#pragma description Nintendo Switch Atmosphère CFW Fatal Error log
|
||||
|
||||
#pragma magic [ 41 46 45 30 ] @ 0x00
|
||||
#pragma magic [ 41 46 45 31 ] @ 0x00
|
||||
#pragma magic [ 41 46 45 32 ] @ 0x00
|
||||
|
||||
#pragma endian little
|
||||
|
||||
#include <std/io.pat>
|
||||
import std.io;
|
||||
import std.sys;
|
||||
|
||||
#define ATMOSPHERE_REBOOT_TO_FATAL_MAGIC "AFE2"
|
||||
#define ATMOSPHERE_REBOOT_TO_FATAL_MAGIC_1 "AFE1"
|
||||
@@ -48,10 +56,10 @@ std::assert(ctx.magic == ATMOSPHERE_REBOOT_TO_FATAL_MAGIC ||
|
||||
ctx.magic == ATMOSPHERE_REBOOT_TO_FATAL_MAGIC_1 ||
|
||||
ctx.magic == ATMOSPHERE_REBOOT_TO_FATAL_MAGIC_0,
|
||||
"File is not a valid Atmosphere fatal error binary!");
|
||||
|
||||
std::assert_warn(ctx.magic == ATMOSPHERE_REBOOT_TO_FATAL_MAGIC,
|
||||
|
||||
std::assert_warn(ctx.magic == ATMOSPHERE_REBOOT_TO_FATAL_MAGIC,
|
||||
"Atmosphere fatal error binary is for an older version!");
|
||||
|
||||
|
||||
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);
|
||||
|
||||
71
patterns/ani.hexpat
Normal file
71
patterns/ani.hexpat
Normal file
@@ -0,0 +1,71 @@
|
||||
#pragma description Windows animated cursor
|
||||
#pragma MIME application/x-navi-animation
|
||||
#pragma endian little
|
||||
|
||||
import std.io;
|
||||
import std.mem;
|
||||
|
||||
bitfield HeaderFlags {
|
||||
icon : 1;
|
||||
sequence : 1;
|
||||
padding: 30;
|
||||
};
|
||||
|
||||
struct anih {
|
||||
u32 struct_size;
|
||||
u32 stored_frames;
|
||||
u32 animation_steps;
|
||||
u32 w;
|
||||
u32 h;
|
||||
u32 bits;
|
||||
u32 planes;
|
||||
u32 default_jiffies;
|
||||
HeaderFlags flags;
|
||||
};
|
||||
|
||||
struct rate {
|
||||
u32 jiffies[parent.size / 4];
|
||||
};
|
||||
|
||||
struct seq {
|
||||
u32 index[parent.size / 4];
|
||||
};
|
||||
|
||||
struct RiffChunk {
|
||||
char signature[4];
|
||||
u32 size;
|
||||
if (signature == "RIFF" || signature == "LIST") {
|
||||
char type[4];
|
||||
|
||||
// Compatible with error size defined in ani files
|
||||
u32 remain = sizeof($) - addressof(type);
|
||||
u32 marked = size > remain ? remain : size;
|
||||
|
||||
RiffChunk chunks[while($ - addressof(type) < marked)];
|
||||
} else if (signature[0] == 'I' && parent.type == "INFO") {
|
||||
char info[size];
|
||||
} else if (signature == "anih") {
|
||||
anih anih [[inline]];
|
||||
} else if (signature == "rate") {
|
||||
rate rate [[inline]];
|
||||
} else if (signature == "seq ") {
|
||||
seq seq [[inline]];
|
||||
} else {
|
||||
std::mem::Bytes<size> data;
|
||||
}
|
||||
padding[size % 2];
|
||||
} [[format_read("read_chunk")]];
|
||||
|
||||
fn read_chunk(RiffChunk chunk) {
|
||||
if (chunk.signature == "RIFF" || chunk.signature == "LIST") {
|
||||
return std::format("{}<{}> ({})", chunk.signature, chunk.type, chunk.size);
|
||||
} else {
|
||||
str ret = std::format("{} ({})", chunk.signature, chunk.size);
|
||||
try {
|
||||
ret += std::format(" \"{}\"", chunk.info);
|
||||
} catch {}
|
||||
return ret;
|
||||
}
|
||||
};
|
||||
|
||||
RiffChunk riff @ 0;
|
||||
50
patterns/apple_single_double.hexpat
Normal file
50
patterns/apple_single_double.hexpat
Normal file
@@ -0,0 +1,50 @@
|
||||
#pragma author Lexi Mayfield
|
||||
#pragma description AppleSingle/AppleDouble file format
|
||||
#pragma endian big
|
||||
#pragma magic [00 05 16 0?] @ 0x00
|
||||
|
||||
import type.magic;
|
||||
|
||||
enum EntryID : u32 {
|
||||
DataFork = 1,
|
||||
ResourceFork = 2,
|
||||
RealName = 3,
|
||||
Comment = 4,
|
||||
IconBW = 5,
|
||||
IconColor = 6,
|
||||
FileDatesInfo = 8,
|
||||
FinderInfo = 9,
|
||||
MacFileInfo = 10,
|
||||
ProDOSFileInfo = 11,
|
||||
MSDOSFileInfo = 12,
|
||||
ShortName = 13,
|
||||
AFPFileInfo = 14,
|
||||
DirectoryID = 15,
|
||||
};
|
||||
|
||||
struct Entry {
|
||||
EntryID entryID;
|
||||
u32 offset;
|
||||
u32 length;
|
||||
u8 data[length] @ offset [[sealed]];
|
||||
};
|
||||
|
||||
enum FileType : u32 {
|
||||
AppleSingle = 0x00051600,
|
||||
AppleDouble = 0x00051607,
|
||||
};
|
||||
|
||||
enum Version : u32 {
|
||||
V1 = 0x00010000,
|
||||
V2 = 0x00020000,
|
||||
};
|
||||
|
||||
struct AppleSingleDouble {
|
||||
FileType fileType;
|
||||
Version version;
|
||||
char homeFileSystem[16];
|
||||
u16 numEntries;
|
||||
Entry entryDescs[numEntries];
|
||||
};
|
||||
|
||||
AppleSingleDouble appleSingleDouble @ 0x00;
|
||||
@@ -1,8 +1,11 @@
|
||||
#pragma author WerWolv
|
||||
#pragma description GNU Static library archive
|
||||
|
||||
#pragma MIME application/x-archive
|
||||
|
||||
#include <std/string.pat>
|
||||
#include <std/mem.pat>
|
||||
#include <std/sys.pat>
|
||||
import std.string;
|
||||
import std.mem;
|
||||
import std.sys;
|
||||
|
||||
struct ARFile {
|
||||
char file_name[16];
|
||||
@@ -12,7 +15,7 @@ struct ARFile {
|
||||
char file_mode[8];
|
||||
char file_size[10];
|
||||
u16 end_marker;
|
||||
|
||||
|
||||
if (end_marker == 0x0A60) {
|
||||
u8 data[std::string::parse_int(this.file_size, 10)];
|
||||
padding[sizeof(data) & 1];
|
||||
@@ -20,6 +23,9 @@ struct ARFile {
|
||||
};
|
||||
|
||||
char signature[8] @ 0x00;
|
||||
if (signature == "!<arch>\r") {
|
||||
std::error("Archive file got corrupted due to CRLF line ending conversion!");
|
||||
}
|
||||
std::assert(signature == "!<arch>\n", "File is not a valid archive!");
|
||||
|
||||
ARFile files[while($ < std::mem::size())] @ $;
|
||||
|
||||
26
patterns/arc.hexpat
Normal file
26
patterns/arc.hexpat
Normal file
@@ -0,0 +1,26 @@
|
||||
#pragma author DexrnZacAttack
|
||||
#pragma description Minecraft LCE ARC File
|
||||
#pragma endian big
|
||||
|
||||
import std.string;
|
||||
#ifdef __IMHEX__
|
||||
import hex.core;
|
||||
#endif
|
||||
|
||||
struct Table {
|
||||
u16 nameSize;
|
||||
char fileName[nameSize];
|
||||
u32 offset;
|
||||
u32 size;
|
||||
u8 file[size] @ offset;
|
||||
#ifdef __IMHEX__
|
||||
hex::core::add_virtual_file(fileName, file);
|
||||
#endif
|
||||
} [[name(std::string::to_string(fileName))]];
|
||||
|
||||
struct ARC {
|
||||
u32 count;
|
||||
Table table[count];
|
||||
};
|
||||
|
||||
ARC arc @ 0x00;
|
||||
36
patterns/aria2.hexpat
Normal file
36
patterns/aria2.hexpat
Normal file
@@ -0,0 +1,36 @@
|
||||
#pragma author itsmeow
|
||||
#pragma description aria2 Control File
|
||||
|
||||
#pragma endian big
|
||||
|
||||
/*
|
||||
Format sourced from:
|
||||
https://aria2.github.io/manual/en/html/technical-notes.html#control-file-aria2-format
|
||||
|
||||
Version 0 files are not supported by default
|
||||
However parsing one is as simple as changing to #pragma endian ittle
|
||||
and resolving any errors resulting from that by adding be prefixes to struct fields.
|
||||
*/
|
||||
|
||||
struct AriaInFlight {
|
||||
u32 index;
|
||||
u32 length;
|
||||
u32 bitfield_piece_length;
|
||||
u8 bitfield_p[bitfield_piece_length];
|
||||
};
|
||||
|
||||
struct AriaHeader {
|
||||
u16 version;
|
||||
u32 extension;
|
||||
u32 infohash_length;
|
||||
u8 infohash[infohash_length];
|
||||
u32 piece_length;
|
||||
u64 total_length;
|
||||
u64 upload_length;
|
||||
u32 bitfield_length;
|
||||
u8 bitfield_d[bitfield_length];
|
||||
u32 inflight_count;
|
||||
AriaInFlight inflights[inflight_count];
|
||||
};
|
||||
|
||||
AriaHeader aria_header @ 0x00;
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user