Skip to content

Commit 3185503

Browse files
authored
patterns: Added valve vpk pattern (#384)
1 parent 3a64207 commit 3185503

File tree

3 files changed

+63
-0
lines changed

3 files changed

+63
-0
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@ Everything will immediately show up in ImHex's Content Store and gets bundled wi
166166
| UEFI | | [`patterns/uefi.hexpat`](patterns/uefi.hexpat)` | UEFI structs for parsing efivars |
167167
| UEFI Boot Entry | | [`patterns/uefi_boot_entry.hexpat`](patterns/uefi_boot_entry.hexpat) | UEFI Boot Entry (Load option) |
168168
| UF2 | | [`patterns/uf2.hexpat`](patterns/uf2.hexpat) | [USB Flashing Format](https://github.com/microsoft/uf2) |
169+
| Valve VPK | | [`patterns/valve_vpk.hexpat`](valve_vpk.hexpat) | Valve Package File |
169170
| VBMeta | | [`patterns/vbmeta.hexpat`](patterns/vbmeta.hexpat) | Android VBMeta image |
170171
| VDF | | [`patterns/vdf.hexpat`](patterns/vdf.hexpat) | Binary Value Data Format (.vdf) files |
171172
| VEADO | | [`patterns/veado.hexpat`](patterns/veado.hexpat) | veadotube mini avatar file |

patterns/valve_vpk.hexpat

+62
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
#pragma author Enaium
2+
#pragma description Valve VPK
3+
4+
import std.io;
5+
import std.mem;
6+
import std.string;
7+
8+
struct string {
9+
char text[while(std::mem::read_unsigned($, 1) != 0x0)];
10+
u8 end [[hidden]];
11+
if (text == "") {
12+
break;
13+
}
14+
};
15+
16+
struct entry {
17+
string name;
18+
u32 crc;
19+
u16 preload_bytes;
20+
u16 archive_index;
21+
u32 entry_offset;
22+
u32 entry_length;
23+
u16 terminator;
24+
25+
if (preload_bytes > 0x0) {
26+
u8 preload[preload_bytes];
27+
}
28+
29+
if (archive_index == 0x7fff) {
30+
u8 data[entry_length] @ entry_offset;
31+
}
32+
};
33+
34+
struct path {
35+
string name;
36+
entry entry[while(true)];
37+
};
38+
39+
struct extension {
40+
string name;
41+
path path[while(true)];
42+
};
43+
44+
struct header {
45+
u32 signature;
46+
u32 version;
47+
u32 tree_size;
48+
49+
if (version == 0x2) {
50+
u32 file_data_section_size;
51+
u32 archive_md5_section_size;
52+
u32 ohter_md5_section_size;
53+
u32 signature_section_size;
54+
}
55+
};
56+
57+
struct vpk {
58+
header header;
59+
extension extension[while(true)];
60+
};
61+
62+
vpk vpk @ 0x0;
6.83 KB
Binary file not shown.

0 commit comments

Comments
 (0)