@isopodlabs/binary_libs 0.1.1 → 0.1.3

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/dist/mach.d.ts ADDED
@@ -0,0 +1,394 @@
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 enum CMD {
11
+ SEGMENT = 1,// segment of this file to be mapped
12
+ SYMTAB = 2,// link-edit stab symbol table info
13
+ SYMSEG = 3,// link-edit gdb symbol table info (obsolete)
14
+ THREAD = 4,// thread
15
+ UNIXTHREAD = 5,// unix thread (includes a stack)
16
+ LOADFVMLIB = 6,// load a specified fixed VM shared library
17
+ IDFVMLIB = 7,// fixed VM shared library identification
18
+ FVMFILE = 9,// fixed VM file inclusion (internal use)
19
+ DYSYMTAB = 11,// dynamic link-edit symbol table info
20
+ LOAD_DYLIB = 12,// load a dynamically linked shared library
21
+ ID_DYLIB = 13,// dynamically linked shared lib ident
22
+ LOAD_DYLINKER = 14,// load a dynamic linker
23
+ ID_DYLINKER = 15,// dynamic linker identification
24
+ PREBOUND_DYLIB = 16,// modules prebound for a dynamically linked shared library
25
+ ROUTINES = 17,// image routines
26
+ SUB_FRAMEWORK = 18,// sub framework
27
+ SUB_UMBRELLA = 19,// sub umbrella
28
+ SUB_CLIENT = 20,// sub client
29
+ SUB_LIBRARY = 21,// sub library
30
+ TWOLEVEL_HINTS = 22,// two-level namespace lookup hints
31
+ PREBIND_CKSUM = 23,// prebind checksum
32
+ LOAD_WEAK_DYLIB = 2147483672,// load a dynamically linked shared library that is allowed to be missing (all symbols are weak imported).
33
+ SEGMENT_64 = 25,// 64-bit segment of this file to be mapped
34
+ ROUTINES_64 = 26,// 64-bit image routines
35
+ UUID = 27,// the uuid
36
+ RPATH = 2147483676,// runpath additions
37
+ CODE_SIGNATURE = 29,// local of code signature
38
+ SEGMENT_SPLIT_INFO = 30,// local of info to split segments
39
+ REEXPORT_DYLIB = 2147483679,// load and re-export dylib
40
+ LAZY_LOAD_DYLIB = 32,// delay load of dylib until first use
41
+ ENCRYPTION_INFO = 33,// encrypted segment information
42
+ DYLD_INFO = 34,// compressed dyld information
43
+ DYLD_INFO_ONLY = 2147483682,// compressed dyld information only
44
+ LOAD_UPWARD_DYLIB = 2147483683,// load upward dylib
45
+ VERSION_MIN_MACOSX = 36,// build for MacOSX min OS version
46
+ VERSION_MIN_IPHONEOS = 37,// build for iPhoneOS min OS version
47
+ FUNCTION_STARTS = 38,// compressed table of function start addresses
48
+ DYLD_ENVIRONMENT = 39,// string for dyld to treat like environment variable
49
+ MAIN = 2147483688,// replacement for LC_UNIXTHREAD
50
+ DATA_IN_CODE = 41,// table of non-instructions in __text
51
+ SOURCE_VERSION = 42,// source version used to build binary
52
+ DYLIB_CODE_SIGN_DRS = 43,// Code signing DRs copied from linked dylibs
53
+ ENCRYPTION_INFO_64 = 44,// 64-bit encrypted segment information
54
+ LINKER_OPTION = 45,// linker options in MH_OBJECT files
55
+ LINKER_OPTIMIZATION_HINT = 46,// optimization hints in MH_OBJECT files
56
+ VERSION_MIN_TVOS = 47,// build for AppleTV min OS version
57
+ VERSION_MIN_WATCHOS = 48,// build for Watch min OS version
58
+ NOTE = 49,// arbitrary data included within a Mach-O file
59
+ BUILD_VERSION = 50,// build for platform min OS version
60
+ DYLD_EXPORTS_TRIE = 2147483699,// used with linkedit_data_command, payload is trie
61
+ DYLD_CHAINED_FIXUPS = 2147483700
62
+ }
63
+ export declare class MachFile {
64
+ header: any;
65
+ commands: {
66
+ cmd: CMD;
67
+ data: any;
68
+ }[];
69
+ ready: Promise<void>;
70
+ static check(data: Uint8Array): boolean;
71
+ constructor(data: Uint8Array, mem?: binary.memory);
72
+ load(data: Uint8Array, be: boolean, bits: 32 | 64, mem?: binary.memory): Promise<void>;
73
+ getCommand(cmd: CMD.SEGMENT): {
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
+ getCommand(cmd: CMD.SYMTAB): (string | {
87
+ strx: number;
88
+ flags: {
89
+ ext: number | bigint;
90
+ type: string;
91
+ pext: number | bigint;
92
+ stab: string;
93
+ };
94
+ sect: number;
95
+ desc: {
96
+ ref: string;
97
+ flags: Record<string, bigint | boolean> | Record<string, number | boolean>;
98
+ align: number | bigint;
99
+ };
100
+ value: number | bigint;
101
+ })[][] | undefined;
102
+ getCommand(cmd: CMD.SYMSEG): Uint8Array | undefined;
103
+ getCommand(cmd: CMD.THREAD): {
104
+ flavor: number;
105
+ count: number;
106
+ };
107
+ getCommand(cmd: CMD.UNIXTHREAD): {
108
+ flavor: number;
109
+ count: number;
110
+ };
111
+ getCommand(cmd: CMD.LOADFVMLIB): {
112
+ name: string;
113
+ minor_version: binary.hex<number | bigint>;
114
+ header_addr: binary.hex<number | bigint>;
115
+ };
116
+ getCommand(cmd: CMD.IDFVMLIB): {
117
+ name: string;
118
+ minor_version: binary.hex<number | bigint>;
119
+ header_addr: binary.hex<number | bigint>;
120
+ };
121
+ getCommand(cmd: CMD.FVMFILE): {
122
+ name: string;
123
+ header_addr: number;
124
+ };
125
+ getCommand(cmd: CMD.DYSYMTAB): {
126
+ localsym: never;
127
+ extdefsym: never;
128
+ undefsym: never;
129
+ toc: {
130
+ symbol_index: number;
131
+ module_index: number;
132
+ }[] | undefined;
133
+ modtab: ({
134
+ objc_module_info_addr: number;
135
+ objc_module_info_size: number;
136
+ module_name: number;
137
+ extdefsym: never;
138
+ refsym: never;
139
+ localsym: never;
140
+ extrel: never;
141
+ init_iterm: never;
142
+ } | {
143
+ objc_module_info_size: number;
144
+ objc_module_info_addr: bigint;
145
+ module_name: number;
146
+ extdefsym: never;
147
+ refsym: never;
148
+ localsym: never;
149
+ extrel: never;
150
+ init_iterm: never;
151
+ })[] | undefined;
152
+ extrefsym: {
153
+ symbol_index: number | bigint;
154
+ flags: number | bigint;
155
+ }[] | undefined;
156
+ indirectsym: {
157
+ symbol_index: number | bigint;
158
+ flags: number | bigint;
159
+ }[] | undefined;
160
+ extrel: {
161
+ address: number;
162
+ symbol_ref: {
163
+ symbol_index: number | bigint;
164
+ flags: number | bigint;
165
+ };
166
+ }[] | undefined;
167
+ locrel: {
168
+ address: number;
169
+ symbol_ref: {
170
+ symbol_index: number | bigint;
171
+ flags: number | bigint;
172
+ };
173
+ }[] | undefined;
174
+ };
175
+ getCommand(cmd: CMD.LOAD_DYLIB): {
176
+ name: string;
177
+ timestamp: number;
178
+ current_version: Record<string, bigint | boolean> | Record<string, number | boolean>;
179
+ compatibility_version: Record<string, bigint | boolean> | Record<string, number | boolean>;
180
+ };
181
+ getCommand(cmd: CMD.ID_DYLIB): {
182
+ name: string;
183
+ timestamp: number;
184
+ current_version: Record<string, bigint | boolean> | Record<string, number | boolean>;
185
+ compatibility_version: Record<string, bigint | boolean> | Record<string, number | boolean>;
186
+ };
187
+ getCommand(cmd: CMD.LOAD_DYLINKER): string;
188
+ getCommand(cmd: CMD.ID_DYLINKER): string;
189
+ getCommand(cmd: CMD.PREBOUND_DYLIB): {
190
+ name: string;
191
+ nmodules: number;
192
+ linked_modules: string;
193
+ };
194
+ getCommand(cmd: CMD.ROUTINES): {
195
+ init_address: number | bigint;
196
+ init_module: number | bigint;
197
+ reserved1: number | bigint;
198
+ reserved2: number | bigint;
199
+ reserved3: number | bigint;
200
+ reserved4: number | bigint;
201
+ reserved5: number | bigint;
202
+ reserved6: number | bigint;
203
+ };
204
+ getCommand(cmd: CMD.SUB_FRAMEWORK): string;
205
+ getCommand(cmd: CMD.SUB_UMBRELLA): string;
206
+ getCommand(cmd: CMD.SUB_CLIENT): string;
207
+ getCommand(cmd: CMD.SUB_LIBRARY): string;
208
+ getCommand(cmd: CMD.TWOLEVEL_HINTS): {
209
+ sub_image: number | bigint;
210
+ toc: number | bigint;
211
+ }[] | undefined;
212
+ getCommand(cmd: CMD.PREBIND_CKSUM): {
213
+ cksum: number;
214
+ };
215
+ getCommand(cmd: CMD.LOAD_WEAK_DYLIB): {
216
+ name: string;
217
+ timestamp: number;
218
+ current_version: Record<string, bigint | boolean> | Record<string, number | boolean>;
219
+ compatibility_version: Record<string, bigint | boolean> | Record<string, number | boolean>;
220
+ };
221
+ getCommand(cmd: CMD.SEGMENT_64): {
222
+ data: binary.MappedMemory | undefined;
223
+ segname: string;
224
+ vmaddr: bigint;
225
+ vmsize: bigint;
226
+ fileoff: bigint;
227
+ filesize: bigint;
228
+ maxprot: number;
229
+ initprot: number;
230
+ nsects: number;
231
+ flags: Record<string, bigint | boolean> | Record<string, number | boolean>;
232
+ sections: Record<string, any> | undefined;
233
+ };
234
+ getCommand(cmd: CMD.ROUTINES_64): {
235
+ init_address: number | bigint;
236
+ init_module: number | bigint;
237
+ reserved1: number | bigint;
238
+ reserved2: number | bigint;
239
+ reserved3: number | bigint;
240
+ reserved4: number | bigint;
241
+ reserved5: number | bigint;
242
+ reserved6: number | bigint;
243
+ };
244
+ getCommand(cmd: CMD.UUID): {
245
+ uuid: Uint8Array;
246
+ };
247
+ getCommand(cmd: CMD.RPATH): string;
248
+ getCommand(cmd: CMD.CODE_SIGNATURE): Uint8Array | undefined;
249
+ getCommand(cmd: CMD.SEGMENT_SPLIT_INFO): Uint8Array | undefined;
250
+ getCommand(cmd: CMD.REEXPORT_DYLIB): {
251
+ name: string;
252
+ timestamp: number;
253
+ current_version: Record<string, bigint | boolean> | Record<string, number | boolean>;
254
+ compatibility_version: Record<string, bigint | boolean> | Record<string, number | boolean>;
255
+ };
256
+ getCommand(cmd: CMD.LAZY_LOAD_DYLIB): {
257
+ name: string;
258
+ timestamp: number;
259
+ current_version: Record<string, bigint | boolean> | Record<string, number | boolean>;
260
+ compatibility_version: Record<string, bigint | boolean> | Record<string, number | boolean>;
261
+ };
262
+ getCommand(cmd: CMD.ENCRYPTION_INFO): {
263
+ cryptoff: number;
264
+ cryptsize: number;
265
+ cryptid: number;
266
+ };
267
+ getCommand(cmd: CMD.DYLD_INFO): {
268
+ rebase: Uint8Array | undefined;
269
+ bind: Uint8Array | undefined;
270
+ weak_bind: Uint8Array | undefined;
271
+ lazy_bind: Uint8Array | undefined;
272
+ exprt: Uint8Array | undefined;
273
+ };
274
+ getCommand(cmd: CMD.DYLD_INFO_ONLY): {
275
+ rebase: Uint8Array | undefined;
276
+ bind: Uint8Array | undefined;
277
+ weak_bind: Uint8Array | undefined;
278
+ lazy_bind: Uint8Array | undefined;
279
+ exprt: Uint8Array | undefined;
280
+ };
281
+ getCommand(cmd: CMD.LOAD_UPWARD_DYLIB): {
282
+ name: string;
283
+ timestamp: number;
284
+ current_version: Record<string, bigint | boolean> | Record<string, number | boolean>;
285
+ compatibility_version: Record<string, bigint | boolean> | Record<string, number | boolean>;
286
+ };
287
+ getCommand(cmd: CMD.VERSION_MIN_MACOSX): {
288
+ version: Record<string, bigint | boolean> | Record<string, number | boolean>;
289
+ reserved: number;
290
+ };
291
+ getCommand(cmd: CMD.VERSION_MIN_IPHONEOS): {
292
+ version: Record<string, bigint | boolean> | Record<string, number | boolean>;
293
+ reserved: number;
294
+ };
295
+ getCommand(cmd: CMD.FUNCTION_STARTS): {
296
+ data: Uint8Array;
297
+ contents: (number | bigint)[];
298
+ };
299
+ getCommand(cmd: CMD.DYLD_ENVIRONMENT): string;
300
+ getCommand(cmd: CMD.MAIN): {
301
+ entryoff: number;
302
+ stacksize: number;
303
+ };
304
+ getCommand(cmd: CMD.DATA_IN_CODE): {
305
+ data: Uint8Array;
306
+ contents: {
307
+ offset: binary.hex<number | bigint>;
308
+ length: number;
309
+ kind: string;
310
+ }[];
311
+ };
312
+ getCommand(cmd: CMD.SOURCE_VERSION): {
313
+ version: {
314
+ a: number | bigint;
315
+ b: number | bigint;
316
+ c: number | bigint;
317
+ d: number | bigint;
318
+ e: number | bigint;
319
+ };
320
+ };
321
+ getCommand(cmd: CMD.DYLIB_CODE_SIGN_DRS): Uint8Array | undefined;
322
+ getCommand(cmd: CMD.ENCRYPTION_INFO_64): {
323
+ cryptoff: number;
324
+ cryptsize: number;
325
+ cryptid: number;
326
+ pad: number;
327
+ };
328
+ getCommand(cmd: CMD.LINKER_OPTION): {
329
+ count: number;
330
+ };
331
+ getCommand(cmd: CMD.LINKER_OPTIMIZATION_HINT): Uint8Array | undefined;
332
+ getCommand(cmd: CMD.VERSION_MIN_TVOS): {
333
+ version: Record<string, bigint | boolean> | Record<string, number | boolean>;
334
+ reserved: number;
335
+ };
336
+ getCommand(cmd: CMD.VERSION_MIN_WATCHOS): {
337
+ version: Record<string, bigint | boolean> | Record<string, number | boolean>;
338
+ reserved: number;
339
+ };
340
+ getCommand(cmd: CMD.NOTE): {
341
+ data_owner: string;
342
+ data: Uint8Array | undefined;
343
+ };
344
+ getCommand(cmd: CMD.BUILD_VERSION): {
345
+ platform: string;
346
+ minos: Record<string, bigint | boolean> | Record<string, number | boolean>;
347
+ sdk: Record<string, bigint | boolean> | Record<string, number | boolean>;
348
+ tools: Record<string, {
349
+ tool: string;
350
+ version: Record<string, bigint | boolean> | Record<string, number | boolean>;
351
+ }>;
352
+ };
353
+ getCommand(cmd: CMD.DYLD_EXPORTS_TRIE): Uint8Array | undefined;
354
+ getCommand(cmd: CMD.DYLD_CHAINED_FIXUPS): Uint8Array | undefined;
355
+ getSegment(name: string): {
356
+ data: binary.MappedMemory | undefined;
357
+ segname: string;
358
+ vmaddr: number;
359
+ vmsize: number;
360
+ fileoff: number;
361
+ filesize: number;
362
+ maxprot: number;
363
+ initprot: number;
364
+ nsects: number;
365
+ flags: Record<string, bigint | boolean> | Record<string, number | boolean>;
366
+ sections: Record<string, any> | undefined;
367
+ } | {
368
+ data: binary.MappedMemory | undefined;
369
+ segname: string;
370
+ vmaddr: bigint;
371
+ vmsize: bigint;
372
+ fileoff: bigint;
373
+ filesize: bigint;
374
+ maxprot: number;
375
+ initprot: number;
376
+ nsects: number;
377
+ flags: Record<string, bigint | boolean> | Record<string, number | boolean>;
378
+ sections: Record<string, any> | undefined;
379
+ } | undefined;
380
+ }
381
+ export declare class FATMachFile {
382
+ archs: {
383
+ cputype: string;
384
+ cpusubtype: string | number;
385
+ offset: number;
386
+ size: number;
387
+ align: number;
388
+ contents: MachFile | undefined;
389
+ }[];
390
+ static check(data: Uint8Array): boolean;
391
+ constructor(data: Uint8Array, mem?: binary.memory);
392
+ load(file: binary.endianStream, mem?: binary.memory): void;
393
+ }
394
+ export {};