-
-
Notifications
You must be signed in to change notification settings - Fork 196
/
Copy pathpbz.hexpat
44 lines (36 loc) · 867 Bytes
/
pbz.hexpat
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
// Apple pbz compressed file
// Used by Apple on .xip files and OTA updates,
// and can be created with macOS compression_tool.
//
// Copyright (c) 2023 Nicolás Alvarez <[email protected]>
//
// SPDX-License-Identifier: GPL-2.0-or-later
#pragma author Nicolás Alvarez
#pragma description Apple pbz
#pragma magic [ 70 62 7A ] @ 0x00
import std.mem;
import type.magic;
#pragma endian big
#define SHOW_DATA 0
enum CompressionType: char {
ZLIB = 'z',
LZMA = 'x',
LZ4 = '4',
LZFSE = 'e'
};
struct Chunk {
u64 uncompressed_size;
u64 compressed_size;
if (SHOW_DATA) {
u8 data[compressed_size] [[sealed]];
} else {
padding[compressed_size];
}
};
struct PBZ {
type::Magic<"pbz"> magic;
CompressionType compression;
u64 chunk_size;
Chunk chunks[while(!std::mem::eof())];
};
PBZ pbz @ 0;