@isopodlabs/binary_libs 0.1.5 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +49 -85
- package/dist/CompoundDocument.d copy.ts +95 -0
- package/dist/CompoundDocument.d.ts +2 -36
- package/dist/arch.d copy.ts +18 -0
- package/dist/arch.d.ts +1 -1
- package/dist/arch.js +1 -1
- package/dist/clr.d copy.ts +409 -0
- package/dist/clr.d.ts +223 -18
- package/dist/clr.js +224 -276
- package/dist/elf.d copy.ts +152 -0
- package/dist/elf.d.ts +1 -1
- package/dist/elf.js +4 -4
- package/dist/mach.d copy.ts +505 -0
- package/dist/mach.d.ts +11 -7
- package/dist/mach.js +9 -10
- package/dist/pe.d copy.ts +144 -0
- package/dist/pe.d.ts +4 -19
- package/dist/pe.js +4 -6
- package/package.json +3 -2
package/dist/elf.js
CHANGED
|
@@ -47,7 +47,7 @@ const Ident = {
|
|
|
47
47
|
file_class: binary.asEnum(binary.UINT8, CLASS),
|
|
48
48
|
encoding: binary.asEnum(binary.UINT8, DATA),
|
|
49
49
|
version: binary.UINT8,
|
|
50
|
-
_: binary.If(
|
|
50
|
+
_: binary.If(s => s.obj.file_class === 'CLASS64', {
|
|
51
51
|
//64 bit only
|
|
52
52
|
osabi: binary.asEnum(binary.UINT8, OSABI),
|
|
53
53
|
abiversion: binary.UINT8,
|
|
@@ -616,12 +616,12 @@ function readDataAs(data, type) {
|
|
|
616
616
|
return binary.RemainingArrayType(type).get(new binary.stream(data.data));
|
|
617
617
|
}
|
|
618
618
|
class ELFFile {
|
|
619
|
-
segments;
|
|
620
|
-
sections;
|
|
621
|
-
header;
|
|
622
619
|
static check(data) {
|
|
623
620
|
return binary.utils.decodeText(data.subarray(0, 4), 'utf8') === '\x7fELF';
|
|
624
621
|
}
|
|
622
|
+
segments;
|
|
623
|
+
sections;
|
|
624
|
+
header;
|
|
625
625
|
getDynamic;
|
|
626
626
|
getRel;
|
|
627
627
|
getRelA;
|
|
@@ -0,0 +1,505 @@
|
|
|
1
|
+
import * as binary from '@isopodlabs/binary';
|
|
2
|
+
declare class mach_stream extends binary.endianStream {
|
|
3
|
+
base: Uint8Array;
|
|
4
|
+
mem?: binary.memory | undefined;
|
|
5
|
+
constructor(base: Uint8Array, data: Uint8Array, be: boolean, mem?: binary.memory | undefined);
|
|
6
|
+
subdata(offset: number, size?: number): Uint8Array;
|
|
7
|
+
substream(offset: number, size?: number): mach_stream;
|
|
8
|
+
getmem(address: bigint, size: number): Uint8Array | Promise<Uint8Array> | undefined;
|
|
9
|
+
}
|
|
10
|
+
declare const fat_arch: {
|
|
11
|
+
cputype: binary.TypeT<string>;
|
|
12
|
+
cpusubtype: binary.TypeT<string | number>;
|
|
13
|
+
offset: binary.TypeT<number>;
|
|
14
|
+
size: binary.TypeT<number>;
|
|
15
|
+
align: binary.TypeT<number>;
|
|
16
|
+
contents: binary.TypeT<MachFile | undefined>;
|
|
17
|
+
};
|
|
18
|
+
export declare enum CMD {
|
|
19
|
+
SEGMENT = 1,// segment of this file to be mapped
|
|
20
|
+
SYMTAB = 2,// link-edit stab symbol table info
|
|
21
|
+
SYMSEG = 3,// link-edit gdb symbol table info (obsolete)
|
|
22
|
+
THREAD = 4,// thread
|
|
23
|
+
UNIXTHREAD = 5,// unix thread (includes a stack)
|
|
24
|
+
LOADFVMLIB = 6,// load a specified fixed VM shared library
|
|
25
|
+
IDFVMLIB = 7,// fixed VM shared library identification
|
|
26
|
+
FVMFILE = 9,// fixed VM file inclusion (internal use)
|
|
27
|
+
DYSYMTAB = 11,// dynamic link-edit symbol table info
|
|
28
|
+
LOAD_DYLIB = 12,// load a dynamically linked shared library
|
|
29
|
+
ID_DYLIB = 13,// dynamically linked shared lib ident
|
|
30
|
+
LOAD_DYLINKER = 14,// load a dynamic linker
|
|
31
|
+
ID_DYLINKER = 15,// dynamic linker identification
|
|
32
|
+
PREBOUND_DYLIB = 16,// modules prebound for a dynamically linked shared library
|
|
33
|
+
ROUTINES = 17,// image routines
|
|
34
|
+
SUB_FRAMEWORK = 18,// sub framework
|
|
35
|
+
SUB_UMBRELLA = 19,// sub umbrella
|
|
36
|
+
SUB_CLIENT = 20,// sub client
|
|
37
|
+
SUB_LIBRARY = 21,// sub library
|
|
38
|
+
TWOLEVEL_HINTS = 22,// two-level namespace lookup hints
|
|
39
|
+
PREBIND_CKSUM = 23,// prebind checksum
|
|
40
|
+
LOAD_WEAK_DYLIB = 2147483672,// load a dynamically linked shared library that is allowed to be missing (all symbols are weak imported).
|
|
41
|
+
SEGMENT_64 = 25,// 64-bit segment of this file to be mapped
|
|
42
|
+
ROUTINES_64 = 26,// 64-bit image routines
|
|
43
|
+
UUID = 27,// the uuid
|
|
44
|
+
RPATH = 2147483676,// runpath additions
|
|
45
|
+
CODE_SIGNATURE = 29,// local of code signature
|
|
46
|
+
SEGMENT_SPLIT_INFO = 30,// local of info to split segments
|
|
47
|
+
REEXPORT_DYLIB = 2147483679,// load and re-export dylib
|
|
48
|
+
LAZY_LOAD_DYLIB = 32,// delay load of dylib until first use
|
|
49
|
+
ENCRYPTION_INFO = 33,// encrypted segment information
|
|
50
|
+
DYLD_INFO = 34,// compressed dyld information
|
|
51
|
+
DYLD_INFO_ONLY = 2147483682,// compressed dyld information only
|
|
52
|
+
LOAD_UPWARD_DYLIB = 2147483683,// load upward dylib
|
|
53
|
+
VERSION_MIN_MACOSX = 36,// build for MacOSX min OS version
|
|
54
|
+
VERSION_MIN_IPHONEOS = 37,// build for iPhoneOS min OS version
|
|
55
|
+
FUNCTION_STARTS = 38,// compressed table of function start addresses
|
|
56
|
+
DYLD_ENVIRONMENT = 39,// string for dyld to treat like environment variable
|
|
57
|
+
MAIN = 2147483688,// replacement for LC_UNIXTHREAD
|
|
58
|
+
DATA_IN_CODE = 41,// table of non-instructions in __text
|
|
59
|
+
SOURCE_VERSION = 42,// source version used to build binary
|
|
60
|
+
DYLIB_CODE_SIGN_DRS = 43,// Code signing DRs copied from linked dylibs
|
|
61
|
+
ENCRYPTION_INFO_64 = 44,// 64-bit encrypted segment information
|
|
62
|
+
LINKER_OPTION = 45,// linker options in MH_OBJECT files
|
|
63
|
+
LINKER_OPTIMIZATION_HINT = 46,// optimization hints in MH_OBJECT files
|
|
64
|
+
VERSION_MIN_TVOS = 47,// build for AppleTV min OS version
|
|
65
|
+
VERSION_MIN_WATCHOS = 48,// build for Watch min OS version
|
|
66
|
+
NOTE = 49,// arbitrary data included within a Mach-O file
|
|
67
|
+
BUILD_VERSION = 50,// build for platform min OS version
|
|
68
|
+
DYLD_EXPORTS_TRIE = 2147483699,// used with linkedit_data_command, payload is trie
|
|
69
|
+
DYLD_CHAINED_FIXUPS = 2147483700
|
|
70
|
+
}
|
|
71
|
+
declare const cmd_table: {
|
|
72
|
+
1: {
|
|
73
|
+
get(s: mach_stream): {
|
|
74
|
+
data: binary.MappedMemory | undefined;
|
|
75
|
+
segname: string;
|
|
76
|
+
vmaddr: number;
|
|
77
|
+
vmsize: number;
|
|
78
|
+
fileoff: number;
|
|
79
|
+
filesize: number;
|
|
80
|
+
maxprot: number;
|
|
81
|
+
initprot: number;
|
|
82
|
+
nsects: number;
|
|
83
|
+
flags: Record<string, bigint | boolean> | Record<string, number | boolean>;
|
|
84
|
+
sections: Record<string, any> | undefined;
|
|
85
|
+
};
|
|
86
|
+
};
|
|
87
|
+
25: {
|
|
88
|
+
get(s: mach_stream): {
|
|
89
|
+
data: binary.MappedMemory | undefined;
|
|
90
|
+
segname: string;
|
|
91
|
+
vmaddr: bigint;
|
|
92
|
+
vmsize: bigint;
|
|
93
|
+
fileoff: bigint;
|
|
94
|
+
filesize: bigint;
|
|
95
|
+
maxprot: number;
|
|
96
|
+
initprot: number;
|
|
97
|
+
nsects: number;
|
|
98
|
+
flags: Record<string, bigint | boolean> | Record<string, number | boolean>;
|
|
99
|
+
sections: Record<string, any> | undefined;
|
|
100
|
+
};
|
|
101
|
+
};
|
|
102
|
+
6: {
|
|
103
|
+
name: {
|
|
104
|
+
get(s: binary.stream): string;
|
|
105
|
+
};
|
|
106
|
+
minor_version: binary.TypeT<binary.hex<number | bigint>>;
|
|
107
|
+
header_addr: binary.TypeT<binary.hex<number | bigint>>;
|
|
108
|
+
};
|
|
109
|
+
7: {
|
|
110
|
+
name: {
|
|
111
|
+
get(s: binary.stream): string;
|
|
112
|
+
};
|
|
113
|
+
minor_version: binary.TypeT<binary.hex<number | bigint>>;
|
|
114
|
+
header_addr: binary.TypeT<binary.hex<number | bigint>>;
|
|
115
|
+
};
|
|
116
|
+
12: {
|
|
117
|
+
name: {
|
|
118
|
+
get(s: binary.stream): string;
|
|
119
|
+
};
|
|
120
|
+
timestamp: binary.TypeT<number>;
|
|
121
|
+
current_version: binary.TypeT<Record<string, bigint | boolean> | Record<string, number | boolean>>;
|
|
122
|
+
compatibility_version: binary.TypeT<Record<string, bigint | boolean> | Record<string, number | boolean>>;
|
|
123
|
+
};
|
|
124
|
+
13: {
|
|
125
|
+
name: {
|
|
126
|
+
get(s: binary.stream): string;
|
|
127
|
+
};
|
|
128
|
+
timestamp: binary.TypeT<number>;
|
|
129
|
+
current_version: binary.TypeT<Record<string, bigint | boolean> | Record<string, number | boolean>>;
|
|
130
|
+
compatibility_version: binary.TypeT<Record<string, bigint | boolean> | Record<string, number | boolean>>;
|
|
131
|
+
};
|
|
132
|
+
2147483672: {
|
|
133
|
+
name: {
|
|
134
|
+
get(s: binary.stream): string;
|
|
135
|
+
};
|
|
136
|
+
timestamp: binary.TypeT<number>;
|
|
137
|
+
current_version: binary.TypeT<Record<string, bigint | boolean> | Record<string, number | boolean>>;
|
|
138
|
+
compatibility_version: binary.TypeT<Record<string, bigint | boolean> | Record<string, number | boolean>>;
|
|
139
|
+
};
|
|
140
|
+
2147483679: {
|
|
141
|
+
name: {
|
|
142
|
+
get(s: binary.stream): string;
|
|
143
|
+
};
|
|
144
|
+
timestamp: binary.TypeT<number>;
|
|
145
|
+
current_version: binary.TypeT<Record<string, bigint | boolean> | Record<string, number | boolean>>;
|
|
146
|
+
compatibility_version: binary.TypeT<Record<string, bigint | boolean> | Record<string, number | boolean>>;
|
|
147
|
+
};
|
|
148
|
+
32: {
|
|
149
|
+
name: {
|
|
150
|
+
get(s: binary.stream): string;
|
|
151
|
+
};
|
|
152
|
+
timestamp: binary.TypeT<number>;
|
|
153
|
+
current_version: binary.TypeT<Record<string, bigint | boolean> | Record<string, number | boolean>>;
|
|
154
|
+
compatibility_version: binary.TypeT<Record<string, bigint | boolean> | Record<string, number | boolean>>;
|
|
155
|
+
};
|
|
156
|
+
2147483683: {
|
|
157
|
+
name: {
|
|
158
|
+
get(s: binary.stream): string;
|
|
159
|
+
};
|
|
160
|
+
timestamp: binary.TypeT<number>;
|
|
161
|
+
current_version: binary.TypeT<Record<string, bigint | boolean> | Record<string, number | boolean>>;
|
|
162
|
+
compatibility_version: binary.TypeT<Record<string, bigint | boolean> | Record<string, number | boolean>>;
|
|
163
|
+
};
|
|
164
|
+
18: {
|
|
165
|
+
get(s: binary.stream): string;
|
|
166
|
+
};
|
|
167
|
+
19: {
|
|
168
|
+
get(s: binary.stream): string;
|
|
169
|
+
};
|
|
170
|
+
20: {
|
|
171
|
+
get(s: binary.stream): string;
|
|
172
|
+
};
|
|
173
|
+
21: {
|
|
174
|
+
get(s: binary.stream): string;
|
|
175
|
+
};
|
|
176
|
+
14: {
|
|
177
|
+
get(s: binary.stream): string;
|
|
178
|
+
};
|
|
179
|
+
15: {
|
|
180
|
+
get(s: binary.stream): string;
|
|
181
|
+
};
|
|
182
|
+
39: {
|
|
183
|
+
get(s: binary.stream): string;
|
|
184
|
+
};
|
|
185
|
+
2147483676: {
|
|
186
|
+
get(s: binary.stream): string;
|
|
187
|
+
};
|
|
188
|
+
16: {
|
|
189
|
+
name: {
|
|
190
|
+
get(s: binary.stream): string;
|
|
191
|
+
};
|
|
192
|
+
nmodules: binary.TypeT<number>;
|
|
193
|
+
linked_modules: {
|
|
194
|
+
get(s: binary.stream): string;
|
|
195
|
+
};
|
|
196
|
+
};
|
|
197
|
+
4: {
|
|
198
|
+
flavor: binary.TypeT<number>;
|
|
199
|
+
count: binary.TypeT<number>;
|
|
200
|
+
};
|
|
201
|
+
5: {
|
|
202
|
+
flavor: binary.TypeT<number>;
|
|
203
|
+
count: binary.TypeT<number>;
|
|
204
|
+
};
|
|
205
|
+
17: {
|
|
206
|
+
init_address: binary.TypeT<bigint> | binary.TypeT<number>;
|
|
207
|
+
init_module: binary.TypeT<bigint> | binary.TypeT<number>;
|
|
208
|
+
reserved1: binary.TypeT<bigint> | binary.TypeT<number>;
|
|
209
|
+
reserved2: binary.TypeT<bigint> | binary.TypeT<number>;
|
|
210
|
+
reserved3: binary.TypeT<bigint> | binary.TypeT<number>;
|
|
211
|
+
reserved4: binary.TypeT<bigint> | binary.TypeT<number>;
|
|
212
|
+
reserved5: binary.TypeT<bigint> | binary.TypeT<number>;
|
|
213
|
+
reserved6: binary.TypeT<bigint> | binary.TypeT<number>;
|
|
214
|
+
};
|
|
215
|
+
26: {
|
|
216
|
+
init_address: binary.TypeT<bigint> | binary.TypeT<number>;
|
|
217
|
+
init_module: binary.TypeT<bigint> | binary.TypeT<number>;
|
|
218
|
+
reserved1: binary.TypeT<bigint> | binary.TypeT<number>;
|
|
219
|
+
reserved2: binary.TypeT<bigint> | binary.TypeT<number>;
|
|
220
|
+
reserved3: binary.TypeT<bigint> | binary.TypeT<number>;
|
|
221
|
+
reserved4: binary.TypeT<bigint> | binary.TypeT<number>;
|
|
222
|
+
reserved5: binary.TypeT<bigint> | binary.TypeT<number>;
|
|
223
|
+
reserved6: binary.TypeT<bigint> | binary.TypeT<number>;
|
|
224
|
+
};
|
|
225
|
+
2: {
|
|
226
|
+
get(s: binary._stream): (string | {
|
|
227
|
+
strx: number;
|
|
228
|
+
flags: {
|
|
229
|
+
ext: number | bigint;
|
|
230
|
+
type: string;
|
|
231
|
+
pext: number | bigint;
|
|
232
|
+
stab: string;
|
|
233
|
+
};
|
|
234
|
+
sect: number;
|
|
235
|
+
desc: {
|
|
236
|
+
ref: string;
|
|
237
|
+
flags: Record<string, bigint | boolean> | Record<string, number | boolean>;
|
|
238
|
+
align: number | bigint;
|
|
239
|
+
};
|
|
240
|
+
value: number | bigint;
|
|
241
|
+
})[][] | undefined;
|
|
242
|
+
};
|
|
243
|
+
22: {
|
|
244
|
+
get(s: mach_stream): {
|
|
245
|
+
sub_image: number | bigint;
|
|
246
|
+
toc: number | bigint;
|
|
247
|
+
}[] | undefined;
|
|
248
|
+
};
|
|
249
|
+
23: {
|
|
250
|
+
cksum: binary.TypeT<number>;
|
|
251
|
+
};
|
|
252
|
+
27: {
|
|
253
|
+
uuid: binary.TypeT<Uint8Array>;
|
|
254
|
+
};
|
|
255
|
+
29: {
|
|
256
|
+
get(s: mach_stream): Uint8Array | undefined;
|
|
257
|
+
};
|
|
258
|
+
30: {
|
|
259
|
+
get(s: mach_stream): Uint8Array | undefined;
|
|
260
|
+
};
|
|
261
|
+
38: {
|
|
262
|
+
get(s: mach_stream): {
|
|
263
|
+
data: Uint8Array;
|
|
264
|
+
contents: (number | bigint)[];
|
|
265
|
+
};
|
|
266
|
+
};
|
|
267
|
+
41: {
|
|
268
|
+
get(s: mach_stream): {
|
|
269
|
+
data: Uint8Array;
|
|
270
|
+
contents: {
|
|
271
|
+
offset: binary.hex<number | bigint>;
|
|
272
|
+
length: number;
|
|
273
|
+
kind: string;
|
|
274
|
+
}[];
|
|
275
|
+
};
|
|
276
|
+
};
|
|
277
|
+
43: {
|
|
278
|
+
get(s: mach_stream): Uint8Array | undefined;
|
|
279
|
+
};
|
|
280
|
+
46: {
|
|
281
|
+
get(s: mach_stream): Uint8Array | undefined;
|
|
282
|
+
};
|
|
283
|
+
2147483699: {
|
|
284
|
+
get(s: mach_stream): Uint8Array | undefined;
|
|
285
|
+
};
|
|
286
|
+
2147483700: {
|
|
287
|
+
get(s: mach_stream): Uint8Array | undefined;
|
|
288
|
+
};
|
|
289
|
+
33: {
|
|
290
|
+
cryptoff: binary.TypeT<number>;
|
|
291
|
+
cryptsize: binary.TypeT<number>;
|
|
292
|
+
cryptid: binary.TypeT<number>;
|
|
293
|
+
};
|
|
294
|
+
44: {
|
|
295
|
+
cryptoff: binary.TypeT<number>;
|
|
296
|
+
cryptsize: binary.TypeT<number>;
|
|
297
|
+
cryptid: binary.TypeT<number>;
|
|
298
|
+
pad: binary.TypeT<number>;
|
|
299
|
+
};
|
|
300
|
+
36: {
|
|
301
|
+
version: binary.TypeT<Record<string, bigint | boolean> | Record<string, number | boolean>>;
|
|
302
|
+
reserved: binary.TypeT<number>;
|
|
303
|
+
};
|
|
304
|
+
37: {
|
|
305
|
+
version: binary.TypeT<Record<string, bigint | boolean> | Record<string, number | boolean>>;
|
|
306
|
+
reserved: binary.TypeT<number>;
|
|
307
|
+
};
|
|
308
|
+
47: {
|
|
309
|
+
version: binary.TypeT<Record<string, bigint | boolean> | Record<string, number | boolean>>;
|
|
310
|
+
reserved: binary.TypeT<number>;
|
|
311
|
+
};
|
|
312
|
+
48: {
|
|
313
|
+
version: binary.TypeT<Record<string, bigint | boolean> | Record<string, number | boolean>>;
|
|
314
|
+
reserved: binary.TypeT<number>;
|
|
315
|
+
};
|
|
316
|
+
34: {
|
|
317
|
+
rebase: {
|
|
318
|
+
get(s: mach_stream): Uint8Array | undefined;
|
|
319
|
+
};
|
|
320
|
+
bind: {
|
|
321
|
+
get(s: mach_stream): Uint8Array | undefined;
|
|
322
|
+
};
|
|
323
|
+
weak_bind: {
|
|
324
|
+
get(s: mach_stream): Uint8Array | undefined;
|
|
325
|
+
};
|
|
326
|
+
lazy_bind: {
|
|
327
|
+
get(s: mach_stream): Uint8Array | undefined;
|
|
328
|
+
};
|
|
329
|
+
exprt: {
|
|
330
|
+
get(s: mach_stream): Uint8Array | undefined;
|
|
331
|
+
};
|
|
332
|
+
};
|
|
333
|
+
2147483682: {
|
|
334
|
+
rebase: {
|
|
335
|
+
get(s: mach_stream): Uint8Array | undefined;
|
|
336
|
+
};
|
|
337
|
+
bind: {
|
|
338
|
+
get(s: mach_stream): Uint8Array | undefined;
|
|
339
|
+
};
|
|
340
|
+
weak_bind: {
|
|
341
|
+
get(s: mach_stream): Uint8Array | undefined;
|
|
342
|
+
};
|
|
343
|
+
lazy_bind: {
|
|
344
|
+
get(s: mach_stream): Uint8Array | undefined;
|
|
345
|
+
};
|
|
346
|
+
exprt: {
|
|
347
|
+
get(s: mach_stream): Uint8Array | undefined;
|
|
348
|
+
};
|
|
349
|
+
};
|
|
350
|
+
3: {
|
|
351
|
+
get(s: mach_stream): Uint8Array | undefined;
|
|
352
|
+
};
|
|
353
|
+
9: {
|
|
354
|
+
name: {
|
|
355
|
+
get(s: binary.stream): string;
|
|
356
|
+
};
|
|
357
|
+
header_addr: binary.TypeT<number>;
|
|
358
|
+
};
|
|
359
|
+
2147483688: {
|
|
360
|
+
entryoff: binary.TypeT<number>;
|
|
361
|
+
stacksize: binary.TypeT<number>;
|
|
362
|
+
};
|
|
363
|
+
42: {
|
|
364
|
+
version: binary.TypeT<{
|
|
365
|
+
a: number | bigint;
|
|
366
|
+
b: number | bigint;
|
|
367
|
+
c: number | bigint;
|
|
368
|
+
d: number | bigint;
|
|
369
|
+
e: number | bigint;
|
|
370
|
+
}>;
|
|
371
|
+
};
|
|
372
|
+
50: {
|
|
373
|
+
platform: binary.TypeT<string>;
|
|
374
|
+
minos: binary.TypeT<Record<string, bigint | boolean> | Record<string, number | boolean>>;
|
|
375
|
+
sdk: binary.TypeT<Record<string, bigint | boolean> | Record<string, number | boolean>>;
|
|
376
|
+
tools: binary.TypeT<Record<string, {
|
|
377
|
+
tool: string;
|
|
378
|
+
version: Record<string, bigint | boolean> | Record<string, number | boolean>;
|
|
379
|
+
}>>;
|
|
380
|
+
};
|
|
381
|
+
45: {
|
|
382
|
+
count: binary.TypeT<number>;
|
|
383
|
+
};
|
|
384
|
+
49: {
|
|
385
|
+
data_owner: binary.TypeT<string>;
|
|
386
|
+
data: {
|
|
387
|
+
get(s: mach_stream): Uint8Array | undefined;
|
|
388
|
+
};
|
|
389
|
+
};
|
|
390
|
+
11: {
|
|
391
|
+
localsym: {
|
|
392
|
+
first: binary.TypeT<number>;
|
|
393
|
+
count: binary.TypeT<number>;
|
|
394
|
+
};
|
|
395
|
+
extdefsym: {
|
|
396
|
+
first: binary.TypeT<number>;
|
|
397
|
+
count: binary.TypeT<number>;
|
|
398
|
+
};
|
|
399
|
+
undefsym: {
|
|
400
|
+
first: binary.TypeT<number>;
|
|
401
|
+
count: binary.TypeT<number>;
|
|
402
|
+
};
|
|
403
|
+
toc: {
|
|
404
|
+
get(s: mach_stream): {
|
|
405
|
+
symbol_index: number;
|
|
406
|
+
module_index: number;
|
|
407
|
+
}[] | undefined;
|
|
408
|
+
};
|
|
409
|
+
modtab: {
|
|
410
|
+
get(s: mach_stream): ({
|
|
411
|
+
objc_module_info_addr: number;
|
|
412
|
+
objc_module_info_size: number;
|
|
413
|
+
module_name: number;
|
|
414
|
+
extdefsym: never;
|
|
415
|
+
refsym: never;
|
|
416
|
+
localsym: never;
|
|
417
|
+
extrel: never;
|
|
418
|
+
init_iterm: never;
|
|
419
|
+
} | {
|
|
420
|
+
objc_module_info_size: number;
|
|
421
|
+
objc_module_info_addr: bigint;
|
|
422
|
+
module_name: number;
|
|
423
|
+
extdefsym: never;
|
|
424
|
+
refsym: never;
|
|
425
|
+
localsym: never;
|
|
426
|
+
extrel: never;
|
|
427
|
+
init_iterm: never;
|
|
428
|
+
})[] | undefined;
|
|
429
|
+
};
|
|
430
|
+
extrefsym: {
|
|
431
|
+
get(s: mach_stream): {
|
|
432
|
+
symbol_index: number | bigint;
|
|
433
|
+
flags: number | bigint;
|
|
434
|
+
}[] | undefined;
|
|
435
|
+
};
|
|
436
|
+
indirectsym: {
|
|
437
|
+
get(s: mach_stream): {
|
|
438
|
+
symbol_index: number | bigint;
|
|
439
|
+
flags: number | bigint;
|
|
440
|
+
}[] | undefined;
|
|
441
|
+
};
|
|
442
|
+
extrel: {
|
|
443
|
+
get(s: mach_stream): {
|
|
444
|
+
address: number;
|
|
445
|
+
symbol_ref: {
|
|
446
|
+
symbol_index: number | bigint;
|
|
447
|
+
flags: number | bigint;
|
|
448
|
+
};
|
|
449
|
+
}[] | undefined;
|
|
450
|
+
};
|
|
451
|
+
locrel: {
|
|
452
|
+
get(s: mach_stream): {
|
|
453
|
+
address: number;
|
|
454
|
+
symbol_ref: {
|
|
455
|
+
symbol_index: number | bigint;
|
|
456
|
+
flags: number | bigint;
|
|
457
|
+
};
|
|
458
|
+
}[] | undefined;
|
|
459
|
+
};
|
|
460
|
+
};
|
|
461
|
+
};
|
|
462
|
+
export declare class MachFile {
|
|
463
|
+
header: any;
|
|
464
|
+
commands: {
|
|
465
|
+
cmd: CMD;
|
|
466
|
+
data: any;
|
|
467
|
+
}[];
|
|
468
|
+
ready: Promise<void>;
|
|
469
|
+
static check(data: Uint8Array): boolean;
|
|
470
|
+
constructor(data: Uint8Array, mem?: binary.memory);
|
|
471
|
+
load(data: Uint8Array, be: boolean, bits: 32 | 64, mem?: binary.memory): Promise<void>;
|
|
472
|
+
getCommand<T extends CMD>(cmd: T): binary.ReadType<typeof cmd_table[T]>;
|
|
473
|
+
getSegment(name: string): {
|
|
474
|
+
data: binary.MappedMemory | undefined;
|
|
475
|
+
segname: string;
|
|
476
|
+
vmaddr: number;
|
|
477
|
+
vmsize: number;
|
|
478
|
+
fileoff: number;
|
|
479
|
+
filesize: number;
|
|
480
|
+
maxprot: number;
|
|
481
|
+
initprot: number;
|
|
482
|
+
nsects: number;
|
|
483
|
+
flags: Record<string, bigint | boolean> | Record<string, number | boolean>;
|
|
484
|
+
sections: Record<string, any> | undefined;
|
|
485
|
+
} | {
|
|
486
|
+
data: binary.MappedMemory | undefined;
|
|
487
|
+
segname: string;
|
|
488
|
+
vmaddr: bigint;
|
|
489
|
+
vmsize: bigint;
|
|
490
|
+
fileoff: bigint;
|
|
491
|
+
filesize: bigint;
|
|
492
|
+
maxprot: number;
|
|
493
|
+
initprot: number;
|
|
494
|
+
nsects: number;
|
|
495
|
+
flags: Record<string, bigint | boolean> | Record<string, number | boolean>;
|
|
496
|
+
sections: Record<string, any> | undefined;
|
|
497
|
+
} | undefined;
|
|
498
|
+
}
|
|
499
|
+
export declare class FATMachFile {
|
|
500
|
+
archs: binary.ReadType<typeof fat_arch>[];
|
|
501
|
+
static check(data: Uint8Array): boolean;
|
|
502
|
+
constructor(data: Uint8Array, mem?: binary.memory);
|
|
503
|
+
load(file: binary.endianStream, mem?: binary.memory): void;
|
|
504
|
+
}
|
|
505
|
+
export {};
|
package/dist/mach.d.ts
CHANGED
|
@@ -61,15 +61,19 @@ export declare enum CMD {
|
|
|
61
61
|
DYLD_CHAINED_FIXUPS = 2147483700
|
|
62
62
|
}
|
|
63
63
|
export declare class MachFile {
|
|
64
|
-
header: any;
|
|
65
|
-
commands: {
|
|
66
|
-
cmd: CMD;
|
|
67
|
-
data: any;
|
|
68
|
-
}[];
|
|
69
|
-
ready: Promise<void>;
|
|
70
64
|
static check(data: Uint8Array): boolean;
|
|
65
|
+
header: {
|
|
66
|
+
magic: number;
|
|
67
|
+
cputype: string;
|
|
68
|
+
cpusubtype: string | number;
|
|
69
|
+
filetype: string;
|
|
70
|
+
ncmds: number;
|
|
71
|
+
sizeofcmds: number;
|
|
72
|
+
flags: Record<string, bigint | boolean> | Record<string, number | boolean>;
|
|
73
|
+
};
|
|
74
|
+
private commands;
|
|
71
75
|
constructor(data: Uint8Array, mem?: binary.memory);
|
|
72
|
-
load(data: Uint8Array, be: boolean, bits:
|
|
76
|
+
load(data: Uint8Array, be: boolean, bits: 64 | 32, mem?: binary.memory): void;
|
|
73
77
|
getCommand(cmd: CMD.SEGMENT): {
|
|
74
78
|
data: binary.MappedMemory | undefined;
|
|
75
79
|
segname: string;
|
package/dist/mach.js
CHANGED
|
@@ -966,9 +966,6 @@ const cmd_table = {
|
|
|
966
966
|
},
|
|
967
967
|
};
|
|
968
968
|
class MachFile {
|
|
969
|
-
header;
|
|
970
|
-
commands = [];
|
|
971
|
-
ready;
|
|
972
969
|
static check(data) {
|
|
973
970
|
switch (binary.UINT32_BE.get(new binary.stream(data))) {
|
|
974
971
|
case 0xfeedface:
|
|
@@ -980,25 +977,27 @@ class MachFile {
|
|
|
980
977
|
return false;
|
|
981
978
|
}
|
|
982
979
|
}
|
|
980
|
+
header;
|
|
981
|
+
commands = [];
|
|
983
982
|
constructor(data, mem) {
|
|
984
983
|
const magic = binary.UINT32_LE.get(new binary.stream(data));
|
|
985
984
|
switch (magic) {
|
|
986
985
|
case 0xfeedface:
|
|
987
|
-
this.
|
|
986
|
+
this.load(data, false, 32, mem);
|
|
988
987
|
break;
|
|
989
988
|
case 0xcefaedfe:
|
|
990
|
-
this.
|
|
989
|
+
this.load(data, true, 32, mem);
|
|
991
990
|
break;
|
|
992
991
|
case 0xfeedfacf:
|
|
993
|
-
this.
|
|
992
|
+
this.load(data, false, 64, mem);
|
|
994
993
|
break;
|
|
995
994
|
case 0xcffaedfe:
|
|
996
|
-
this.
|
|
995
|
+
this.load(data, true, 64, mem);
|
|
997
996
|
break;
|
|
998
997
|
default: throw new Error('not a mach file');
|
|
999
998
|
}
|
|
1000
999
|
}
|
|
1001
|
-
|
|
1000
|
+
load(data, be, bits, mem) {
|
|
1002
1001
|
const file = new binary.endianStream(data, be);
|
|
1003
1002
|
const h = binary.read(file, header);
|
|
1004
1003
|
const cpu = CPU_TYPE[h.cputype];
|
|
@@ -1008,14 +1007,14 @@ class MachFile {
|
|
|
1008
1007
|
for (let i = 0; i < h.ncmds; ++i) {
|
|
1009
1008
|
const cmd = binary.read(file, command);
|
|
1010
1009
|
const file2 = new mach_stream(data, file.read_buffer(cmd.cmdsize - 8), file.be, mem);
|
|
1011
|
-
const result =
|
|
1010
|
+
const result = binary.read(file2, cmd_table[cmd.cmd] ?? {});
|
|
1012
1011
|
this.commands.push({ cmd: cmd.cmd, data: result });
|
|
1013
1012
|
}
|
|
1014
1013
|
this.header = h;
|
|
1015
1014
|
const funcs = this.getCommand(CMD.FUNCTION_STARTS);
|
|
1016
1015
|
if (funcs) {
|
|
1017
1016
|
const array = funcs.contents;
|
|
1018
|
-
const text =
|
|
1017
|
+
const text = this.getSegment('__TEXT');
|
|
1019
1018
|
let acc = BigInt(text?.vmaddr ?? 0);
|
|
1020
1019
|
for (const i in array)
|
|
1021
1020
|
array[i] = (acc += BigInt(array[i]));
|