-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
bom.h
149 lines (116 loc) · 3.48 KB
/
bom.h
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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
// bom.h
#ifndef OSX_BOM_H
#define OSX_BOM_H 1
//
// These structure define part of the NextSTEP/OSX BOM file format
//
// Initial code
// Author: Joseph Coffland
// Date: October, 2011
//
// Additional work on BOMPath & BOMTree
// Author: Julian Devlin
// Date: October, 2012
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
// This program is in the public domain.
//
#include <stdint.h>
#ifndef FLEXIBLE_ARRAY_MEMBER
# define FLEXIBLE_ARRAY_MEMBER 0
#endif /* !FLEXIBLE_ARRAY_MEMBER */
struct BOMHeader {
char magic[8]; // = BOMStore
uint32_t unknown0; // = 1?
uint32_t unknown1; // = 73 = 0x49?
uint32_t indexOffset; // Length of first part
uint32_t indexLength; // Length of second part
uint32_t varsOffset;
uint32_t trailerLen; // FIXME: What does this data at the end mean?
} __attribute__((packed));
struct BOMIndex {
uint32_t address;
uint32_t length;
} __attribute__((packed));
struct BOMIndexHeader {
uint32_t unknown0; // FIXME: What is this? It is not the length of the array...
BOMIndex index[FLEXIBLE_ARRAY_MEMBER];
} __attribute__((packed));
struct BOMTree { // 21 bytes
char tree[4]; // = "tree"
uint32_t unknown0;
uint32_t child; // FIXME: Not sure about this one...
uint32_t nodeSize; // byte count of each entry in the tree (BOMPaths)
uint32_t pathCount; // total number of paths in all leaves combined
uint8_t unknown3;
} __attribute__((packed));
struct BOMVar {
uint32_t index;
uint8_t length;
char name[FLEXIBLE_ARRAY_MEMBER]; // length
} __attribute__((packed));
struct BOMVars {
uint32_t count; // Number of entries that follow
BOMVar first[FLEXIBLE_ARRAY_MEMBER];
} __attribute__((packed));
struct BOMPathIndices {
uint32_t index0;
uint32_t index1;
} __attribute__((packed));
struct BOMPaths {
uint16_t isLeaf; // if 0 then this entry refers to other BOMPaths entries
uint16_t count; // for leaf, count of paths. for top level, (# of leafs - 1)
uint32_t forward; // next leaf, when there are multiple leafs
uint32_t backward; // previous leaf, when there are multiple leafs
BOMPathIndices indices[FLEXIBLE_ARRAY_MEMBER];
} __attribute__((packed));
enum {
TYPE_FILE = 1, // BOMPathInfo2 is exe=88 regular=35 bytes
TYPE_DIR = 2, // BOMPathInfo2 is 31 bytes
TYPE_LINK = 3, // BOMPathInfo2 is 44? bytes
TYPE_DEV = 4 // BOMPathInfo2 is 35 bytes
};
// Not sure of all the corect values here:
enum {
ARCH_PPC = 0,
ARCH_I386 = 1 << 12,
ARCH_HPPA = 0,
ARCH_SPARC = 0
};
struct BOMPathInfo2 {
uint8_t type; // See types above
uint8_t unknown0; // = 1?
uint16_t architecture; // Not sure exactly what this means...
uint16_t mode;
uint32_t user;
uint32_t group;
uint32_t modtime;
uint32_t size;
uint8_t unknown1; // = 1?
union {
uint32_t checksum;
uint32_t devType;
};
uint32_t linkNameLength;
char linkName[FLEXIBLE_ARRAY_MEMBER];
// FIXME: executable files have a buch of other crap here:
} __attribute__((packed));
struct BOMPathInfo1 {
uint32_t id;
uint32_t index; // Pointer to BOMPathInfo2
} __attribute__((packed));
struct BOMFile {
uint32_t parent; // Parent BOMPathInfo1->id
char name[FLEXIBLE_ARRAY_MEMBER];
} __attribute__((packed));
// prototypes:
char *lookup(int i, uint32_t *length);
void short_usage(void);
void usage_error(const char *msg);
void usage(void);
void error(const char *msg);
void version(void);
#endif // OSX_BOM_H
// EOF