forked from WerWolv/ImHex-Patterns
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dsstore.hexpat
115 lines (93 loc) · 2.25 KB
/
dsstore.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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
#pragma description .DS_Store file format
// Apple macOS .DS_Store format
#pragma endian big
#include <std/io.pat>
struct RecordEntry {
u32 length;
char16 filename[length];
char id[4];
// either blob or length
char type[4];
if (type == "blob") {
u32 blobCount;
u8 blobData[blobCount];
}
else if (type == "long") {
u32 value;
}
else if (type == "shor") {
u32 value;
}
else if (type == "bool") {
u8 value;
}
};
struct TreeBlock {
u32 mode;
u32 count;
RecordEntry entries[count];
};
struct BuddyRootBlockOffsets {
u32 count;
u8 reserved[4];
u32 addresses[count];
padding[(1024 - (count * 4))];
};
struct BuddyTableOfContentEntry {
u8 count;
char name[count];
u32 value;
};
struct BuddyTableOfContents {
u32 count;
BuddyTableOfContentEntry toc[count];
};
struct BuddyFreeList {
u32 count;
u32 offsets[count];
};
struct BuddyRootBlock {
BuddyRootBlockOffsets offsets;
BuddyTableOfContents toc;
BuddyFreeList freelists[32];
};
struct BuddyBlock {
u32 blockCount;
u8 reserved[4];
// padding for next multiple of 256 entries (1024 bytes)
u32 addresses[blockCount];
// u8 padding[paddingCount];
u32 directoryCount;
// directory entries
u8 count;
u8 name[count];
u32 blockNumber;
// free lists
// 32 free lists
BuddyRootBlockOffsets off[32];
};
struct BlocksList {
u32 blockId [[color("E57373")]];
u32 internalBlocks [[color("80CBC4")]];
u32 countRecords [[color("ffeb3b")]];
u32 countBlocks [[color("64b5f6")]];
u32 reserved [[color("a1887f")]];
};
struct BuddyAllocator {
char header[4];
u32 offsetBookkeeping;
u32 sizeBookkeeping;
u32 offsetBookkeeping2;
u32 offsetData;
u8 reserved[12];
BuddyRootBlock root @ offsetBookkeeping + 4;
std::print("TOC {} address 0x{:08x}",
root.toc.toc[0].value,
root.offsets.addresses[root.toc.toc[0].value] >> 0x5 << 0x5);
BlocksList blocks @ (root.offsets.addresses[root.toc.toc[0].value] >> 0x5 << 0x5) + 4;
std::print("Blocks start at address 0x{:08x}, size 0x{:04x}",
root.offsets.addresses[blocks.blockId] >> 0x5 << 0x5,
1 << (root.offsets.addresses[blocks.blockId] & 0x1f));
TreeBlock entries @ (root.offsets.addresses[blocks.blockId] >> 0x5 << 0x5) + 4;
};
BuddyAllocator buddy @0x04;