forked from WerWolv/ImHex-Patterns
-
Notifications
You must be signed in to change notification settings - Fork 0
/
pfs0.hexpat
41 lines (31 loc) · 894 Bytes
/
pfs0.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
#pragma author WerWolv
#pragma description Nintendo Switch PFS0 archive (NSP files)
#include <type/magic.pat>
#include <type/size.pat>
#include <std/core.pat>
struct FileEntry {
u64 dataOffset;
type::Size<u64> dataSize;
u32 nameOffset;
padding[4];
};
struct String {
char value[];
};
struct Header {
type::Magic<"PFS0"> magic;
u32 numFiles;
type::Size<u32> stringTableSize;
padding[4];
FileEntry fileEntryTable[numFiles];
String strings[numFiles];
};
struct File {
char name[] @ addressof(parent.header.strings) + parent.header.fileEntryTable[std::core::array_index()].nameOffset;
u8 data[parent.header.fileEntryTable[std::core::array_index()].dataSize] @ parent.header.fileEntryTable[std::core::array_index()].dataOffset [[sealed]];
};
struct PFS0 {
Header header;
File files[header.numFiles];
};
PFS0 pfs0 @ 0x00;