@isopodlabs/binary_libs 1.2.0 → 1.3.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/dist/clr.js CHANGED
@@ -24,7 +24,8 @@ var __importStar = (this && this.__importStar) || function (mod) {
24
24
  };
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
26
  exports.CLR = void 0;
27
- const binary = __importStar(require("@isopodlabs/binary"));
27
+ exports.ReadCLR = ReadCLR;
28
+ const bin = __importStar(require("@isopodlabs/binary"));
28
29
  const pe = __importStar(require("./pe"));
29
30
  //-----------------------------------------------------------------------------
30
31
  // CLR
@@ -44,12 +45,12 @@ const CLR_FLAGS = {
44
45
  FLAGS_TRACKDEBUGDATA: 0x00010000,
45
46
  };
46
47
  const CLR_HEADER = {
47
- cb: binary.UINT32_LE,
48
- MajorRuntimeVersion: binary.UINT16_LE,
49
- MinorRuntimeVersion: binary.UINT16_LE,
48
+ cb: bin.UINT32_LE,
49
+ MajorRuntimeVersion: bin.UINT16_LE,
50
+ MinorRuntimeVersion: bin.UINT16_LE,
50
51
  MetaData: pe.DATA_DIRECTORY,
51
- Flags: binary.asFlags(binary.UINT32_LE, CLR_FLAGS),
52
- EntryPoint: binary.UINT32_LE,
52
+ Flags: bin.asFlags(bin.UINT32_LE, CLR_FLAGS),
53
+ EntryPoint: bin.UINT32_LE,
53
54
  Resources: pe.DATA_DIRECTORY,
54
55
  StrongNameSignature: pe.DATA_DIRECTORY,
55
56
  CodeManagerTable: pe.DATA_DIRECTORY,
@@ -58,28 +59,28 @@ const CLR_HEADER = {
58
59
  //ManagedNativeHeader: pe.DATA_DIRECTORY,
59
60
  };
60
61
  const STREAM_HDR = {
61
- Offset: binary.UINT32_LE, // Memory offset to start of this stream from start of the metadata root (§II.24.2.1)
62
- Size: binary.UINT32_LE, // Size of this stream in bytes, shall be a multiple of 4.
63
- Name: binary.NullTerminatedStringType(), // Name of the stream as null-terminated variable length array of ASCII characters, padded to the next 4-byte boundary with \0 characters. The name is limited to 32 characters.
64
- unused: binary.AlignType(4),
62
+ Offset: bin.UINT32_LE, // Memory offset to start of this stream from start of the metadata root (§II.24.2.1)
63
+ Size: bin.UINT32_LE, // Size of this stream in bytes, shall be a multiple of 4.
64
+ Name: bin.NullTerminatedStringType(), // Name of the stream as null-terminated variable length array of ASCII characters, padded to the next 4-byte boundary with \0 characters. The name is limited to 32 characters.
65
+ unused: bin.AlignType(4),
65
66
  };
66
67
  const METADATA_ROOT = {
67
- Signature: binary.UINT32_LE, //'BSJB'
68
- MajorVersion: binary.UINT16_LE,
69
- MinorVersion: binary.UINT16_LE,
70
- Reserved: binary.UINT32_LE, // always 0
71
- Version: binary.StringType(binary.UINT32_LE, 'utf8', true),
72
- unknown: binary.UINT16_LE,
73
- Streams: binary.ArrayType(binary.UINT16_LE, STREAM_HDR)
68
+ Signature: bin.UINT32_LE, //'BSJB'
69
+ MajorVersion: bin.UINT16_LE,
70
+ MinorVersion: bin.UINT16_LE,
71
+ Reserved: bin.UINT32_LE, // always 0
72
+ Version: bin.StringType(bin.UINT32_LE, 'utf8', true),
73
+ unknown: bin.UINT16_LE,
74
+ Streams: bin.ArrayType(bin.UINT16_LE, STREAM_HDR)
74
75
  };
75
76
  const CLR_TABLES = {
76
- Reserved: binary.UINT32_LE, // Reserved, always 0 (§II.24.1).
77
- MajorVersion: binary.UINT8, // Major version of table schemata; shall be 2 (§II.24.1).
78
- MinorVersion: binary.UINT8, // Minor version of table schemata; shall be 0 (§II.24.1).
79
- HeapSizes: binary.UINT8, // Bit vector for heap sizes.
80
- Reserved2: binary.UINT8, // Reserved, always 1 (§II.24.1).
81
- Valid: binary.UINT64_LE, // Bit vector of present tables, let n be the number of bits that are 1.
82
- Sorted: binary.UINT64_LE, // Bit vector of sorted tables.
77
+ Reserved: bin.UINT32_LE, // Reserved, always 0 (§II.24.1).
78
+ MajorVersion: bin.UINT8, // Major version of table schemata; shall be 2 (§II.24.1).
79
+ MinorVersion: bin.UINT8, // Minor version of table schemata; shall be 0 (§II.24.1).
80
+ HeapSizes: bin.UINT8, // Bit vector for heap sizes.
81
+ Reserved2: bin.UINT8, // Reserved, always 1 (§II.24.1).
82
+ Valid: bin.UINT64_LE, // Bit vector of present tables, let n be the number of bits that are 1.
83
+ Sorted: bin.UINT64_LE, // Bit vector of sorted tables.
83
84
  };
84
85
  var TABLE;
85
86
  (function (TABLE) {
@@ -139,7 +140,7 @@ function bytesToGuid(bytes) {
139
140
  hexArray.slice(8, 10).join('') + '-' +
140
141
  hexArray.slice(10, 16).join('');
141
142
  }
142
- class clr_stream extends binary.stream {
143
+ class clr_stream extends bin.stream {
143
144
  heaps;
144
145
  heap_sizes;
145
146
  table_counts;
@@ -150,7 +151,7 @@ class clr_stream extends binary.stream {
150
151
  this.table_counts = table_counts;
151
152
  }
152
153
  getOffset(big) {
153
- return (big ? binary.UINT32_LE : binary.UINT16_LE).get(this);
154
+ return (big ? bin.UINT32_LE : bin.UINT16_LE).get(this);
154
155
  }
155
156
  getHeap(heap) {
156
157
  return this.heaps[heap].subarray(this.getOffset(!!(this.heap_sizes & (1 << heap))));
@@ -162,9 +163,9 @@ class clr_stream extends binary.stream {
162
163
  const thresh = 0xffff >> B;
163
164
  for (const i of trans) {
164
165
  if (this.table_counts[i] > thresh)
165
- return binary.UINT32_LE.get(this);
166
+ return bin.UINT32_LE.get(this);
166
167
  }
167
- return binary.UINT16_LE.get(this);
168
+ return bin.UINT16_LE.get(this);
168
169
  }
169
170
  getString() {
170
171
  const mem = this.getHeap(HEAP.String);
@@ -178,7 +179,7 @@ class clr_stream extends binary.stream {
178
179
  return this.getHeap(HEAP.Blob);
179
180
  }
180
181
  }
181
- class clr_dummy extends binary.dummy {
182
+ class clr_dummy extends bin.dummy {
182
183
  heap_sizes;
183
184
  table_counts;
184
185
  constructor(heap_sizes, table_counts) {
@@ -187,7 +188,7 @@ class clr_dummy extends binary.dummy {
187
188
  this.table_counts = table_counts;
188
189
  }
189
190
  getOffset(big) {
190
- return (big ? binary.UINT32_LE : binary.UINT16_LE).get(this);
191
+ return (big ? bin.UINT32_LE : bin.UINT16_LE).get(this);
191
192
  }
192
193
  getHeap(heap) {
193
194
  return this.getOffset(!!(this.heap_sizes & (1 << heap)));
@@ -199,9 +200,9 @@ class clr_dummy extends binary.dummy {
199
200
  const thresh = 0xffff >> B;
200
201
  for (const i of trans) {
201
202
  if (this.table_counts[i] > thresh)
202
- return binary.UINT32_LE.get(this);
203
+ return bin.UINT32_LE.get(this);
203
204
  }
204
- return binary.UINT16_LE.get(this);
205
+ return bin.UINT16_LE.get(this);
205
206
  }
206
207
  getString() { return this.getHeap(HEAP.String); }
207
208
  getGUID() { return this.getHeap(HEAP.GUID); }
@@ -221,7 +222,7 @@ const clr_Blob = {
221
222
  };
222
223
  const Signature = clr_Blob;
223
224
  const CustomAttributeValue = clr_Blob;
224
- const clr_Code = binary.UINT32_LE;
225
+ const clr_Code = bin.UINT32_LE;
225
226
  function Indexed(table) {
226
227
  return {
227
228
  get(s) { return s.getIndex(table); }
@@ -255,7 +256,7 @@ const TypeOrMethodDef = CodedIndex([TABLE.TypeDef, TABLE.MethodDef], 1);
255
256
  const ResolutionScope = CodedIndex([TABLE.Module, TABLE.ModuleRef, TABLE.AssemblyRef, TABLE.TypeRef], 2);
256
257
  const TableReaders = {
257
258
  [TABLE.Module]: {
258
- generation: binary.UINT16_LE,
259
+ generation: bin.UINT16_LE,
259
260
  name: clr_String,
260
261
  mvid: clr_GUID,
261
262
  encid: clr_GUID,
@@ -267,7 +268,7 @@ const TableReaders = {
267
268
  namespce: clr_String,
268
269
  },
269
270
  [TABLE.TypeDef]: {
270
- flags: binary.UINT32_LE,
271
+ flags: bin.UINT32_LE,
271
272
  name: clr_String,
272
273
  namespce: clr_String,
273
274
  extends: TypeDefOrRef,
@@ -275,21 +276,21 @@ const TableReaders = {
275
276
  methods: IndexedList(TABLE.MethodDef),
276
277
  },
277
278
  [TABLE.Field]: {
278
- flags: binary.UINT16_LE,
279
+ flags: bin.UINT16_LE,
279
280
  name: clr_String,
280
281
  signature: Signature,
281
282
  },
282
283
  [TABLE.MethodDef]: {
283
284
  code: clr_Code,
284
- implflags: binary.UINT16_LE,
285
- flags: binary.UINT16_LE,
285
+ implflags: bin.UINT16_LE,
286
+ flags: bin.UINT16_LE,
286
287
  name: clr_String,
287
288
  signature: Signature,
288
289
  paramlist: IndexedList(TABLE.Param),
289
290
  },
290
291
  [TABLE.Param]: {
291
- flags: binary.UINT16_LE,
292
- sequence: binary.UINT16_LE,
292
+ flags: bin.UINT16_LE,
293
+ sequence: bin.UINT16_LE,
293
294
  name: clr_String,
294
295
  },
295
296
  [TABLE.InterfaceImpl]: {
@@ -302,7 +303,7 @@ const TableReaders = {
302
303
  signature: Signature,
303
304
  },
304
305
  [TABLE.Constant]: {
305
- type: binary.UINT16_LE,
306
+ type: bin.UINT16_LE,
306
307
  parent: HasConstant,
307
308
  value: clr_Blob,
308
309
  },
@@ -316,17 +317,17 @@ const TableReaders = {
316
317
  native_type: clr_Blob,
317
318
  },
318
319
  [TABLE.DeclSecurity]: {
319
- action: binary.UINT16_LE,
320
+ action: bin.UINT16_LE,
320
321
  parent: HasDeclSecurity,
321
322
  permission_set: clr_Blob,
322
323
  },
323
324
  [TABLE.ClassLayout]: {
324
- packing_size: binary.UINT16_LE,
325
- class_size: binary.UINT32_LE,
325
+ packing_size: bin.UINT16_LE,
326
+ class_size: bin.UINT32_LE,
326
327
  parent: Indexed(TABLE.TypeDef),
327
328
  },
328
329
  [TABLE.FieldLayout]: {
329
- offset: binary.UINT32_LE,
330
+ offset: bin.UINT32_LE,
330
331
  field: Indexed(TABLE.Field),
331
332
  },
332
333
  [TABLE.StandAloneSig]: {
@@ -337,7 +338,7 @@ const TableReaders = {
337
338
  event_list: IndexedList(TABLE.Event),
338
339
  },
339
340
  [TABLE.Event]: {
340
- flags: binary.UINT16_LE,
341
+ flags: bin.UINT16_LE,
341
342
  name: clr_String,
342
343
  event_type: TypeDefOrRef,
343
344
  },
@@ -346,12 +347,12 @@ const TableReaders = {
346
347
  property_list: IndexedList(TABLE.Property),
347
348
  },
348
349
  [TABLE.Property]: {
349
- flags: binary.UINT16_LE,
350
+ flags: bin.UINT16_LE,
350
351
  name: clr_String,
351
352
  type: Signature,
352
353
  },
353
354
  [TABLE.MethodSemantics]: {
354
- flags: binary.UINT16_LE,
355
+ flags: bin.UINT16_LE,
355
356
  method: Indexed(TABLE.MethodDef),
356
357
  association: HasSemantics,
357
358
  },
@@ -367,70 +368,70 @@ const TableReaders = {
367
368
  signature: clr_Blob,
368
369
  },
369
370
  [TABLE.ImplMap]: {
370
- flags: binary.UINT16_LE,
371
+ flags: bin.UINT16_LE,
371
372
  member_forwarded: MemberForwarded,
372
373
  name: clr_String,
373
374
  scope: Indexed(TABLE.ModuleRef),
374
375
  },
375
376
  [TABLE.FieldRVA]: {
376
- rva: binary.UINT32_LE,
377
+ rva: bin.UINT32_LE,
377
378
  field: Indexed(TABLE.Field),
378
379
  },
379
380
  [TABLE.Assembly]: {
380
- hashalg: binary.UINT32_LE,
381
- major: binary.UINT16_LE,
382
- minor: binary.UINT16_LE,
383
- build: binary.UINT16_LE,
384
- rev: binary.UINT16_LE,
385
- flags: binary.UINT32_LE,
381
+ hashalg: bin.UINT32_LE,
382
+ major: bin.UINT16_LE,
383
+ minor: bin.UINT16_LE,
384
+ build: bin.UINT16_LE,
385
+ rev: bin.UINT16_LE,
386
+ flags: bin.UINT32_LE,
386
387
  publickey: clr_Blob,
387
388
  name: clr_String,
388
389
  culture: clr_String,
389
390
  },
390
391
  [TABLE.AssemblyProcessor]: {
391
- processor: binary.UINT32_LE,
392
+ processor: bin.UINT32_LE,
392
393
  },
393
394
  [TABLE.AssemblyOS]: {
394
- platform: binary.UINT32_LE,
395
- minor: binary.UINT32_LE,
396
- major: binary.UINT32_LE,
395
+ platform: bin.UINT32_LE,
396
+ minor: bin.UINT32_LE,
397
+ major: bin.UINT32_LE,
397
398
  },
398
399
  [TABLE.AssemblyRef]: {
399
- major: binary.UINT16_LE,
400
- minor: binary.UINT16_LE,
401
- build: binary.UINT16_LE,
402
- rev: binary.UINT16_LE,
403
- flags: binary.UINT32_LE,
400
+ major: bin.UINT16_LE,
401
+ minor: bin.UINT16_LE,
402
+ build: bin.UINT16_LE,
403
+ rev: bin.UINT16_LE,
404
+ flags: bin.UINT32_LE,
404
405
  publickey: clr_Blob,
405
406
  name: clr_String,
406
407
  culture: clr_String,
407
408
  hashvalue: clr_Blob,
408
409
  },
409
410
  [TABLE.AssemblyRefProcessor]: {
410
- processor: binary.UINT32_LE,
411
+ processor: bin.UINT32_LE,
411
412
  assembly: Indexed(TABLE.AssemblyRef),
412
413
  },
413
414
  [TABLE.AssemblyRefOS]: {
414
- platform: binary.UINT32_LE,
415
- major: binary.UINT32_LE,
416
- minor: binary.UINT32_LE,
415
+ platform: bin.UINT32_LE,
416
+ major: bin.UINT32_LE,
417
+ minor: bin.UINT32_LE,
417
418
  assembly: Indexed(TABLE.AssemblyRef),
418
419
  },
419
420
  [TABLE.File]: {
420
- flags: binary.UINT32_LE,
421
+ flags: bin.UINT32_LE,
421
422
  name: clr_String,
422
423
  hash: clr_Blob,
423
424
  },
424
425
  [TABLE.ExportedType]: {
425
- flags: binary.UINT32_LE,
426
- typedef_id: binary.UINT32_LE, //(a 4-byte index into a TypeDef table of another module in this Assembly).
426
+ flags: bin.UINT32_LE,
427
+ typedef_id: bin.UINT32_LE, //(a 4-byte index into a TypeDef table of another module in this Assembly).
427
428
  name: clr_String,
428
429
  namespce: clr_String,
429
430
  implementation: Implementation,
430
431
  },
431
432
  [TABLE.ManifestResource]: {
432
- data: binary.UINT32_LE,
433
- flags: binary.UINT32_LE,
433
+ data: bin.UINT32_LE,
434
+ flags: bin.UINT32_LE,
434
435
  name: clr_String,
435
436
  implementation: Implementation,
436
437
  },
@@ -439,8 +440,8 @@ const TableReaders = {
439
440
  enclosing_class: Indexed(TABLE.TypeDef),
440
441
  },
441
442
  [TABLE.GenericParam]: {
442
- number: binary.UINT16_LE,
443
- flags: binary.UINT16_LE,
443
+ number: bin.UINT16_LE,
444
+ flags: bin.UINT16_LE,
444
445
  owner: TypeOrMethodDef,
445
446
  name: clr_String,
446
447
  },
@@ -454,20 +455,20 @@ const TableReaders = {
454
455
  },
455
456
  };
456
457
  const ResourceManagerHeader = {
457
- magic: binary.UINT32_LE,
458
- version: binary.UINT32_LE,
459
- skip: binary.UINT32_LE,
458
+ magic: bin.UINT32_LE,
459
+ version: bin.UINT32_LE,
460
+ skip: bin.UINT32_LE,
460
461
  };
461
462
  const ResourceManager = {
462
- reader: binary.StringType(binary.UINT8), // Class name of IResourceReader to parse this file
463
- set: binary.StringType(binary.UINT8), // Class name of ResourceSet to parse this file
464
- version: binary.UINT32_LE,
465
- num_resources: binary.UINT32_LE,
466
- types: binary.ArrayType(binary.UINT32_LE, binary.StringType(binary.UINT8)),
463
+ reader: bin.StringType(bin.UINT8), // Class name of IResourceReader to parse this file
464
+ set: bin.StringType(bin.UINT8), // Class name of ResourceSet to parse this file
465
+ version: bin.UINT32_LE,
466
+ num_resources: bin.UINT32_LE,
467
+ types: bin.ArrayType(bin.UINT32_LE, bin.StringType(bin.UINT8)),
467
468
  };
468
469
  const ResourceEntry = {
469
- name: binary.StringType(binary.UINT8, 'utf16le', false, 1),
470
- offset: binary.UINT32_LE,
470
+ name: bin.StringType(bin.UINT8, 'utf16le', false, 1),
471
+ offset: bin.UINT32_LE,
471
472
  };
472
473
  class CLR {
473
474
  raw;
@@ -477,10 +478,10 @@ class CLR {
477
478
  tables;
478
479
  Resources;
479
480
  constructor(pe, clr_data) {
480
- this.header = binary.read(new binary.stream(clr_data), CLR_HEADER);
481
+ this.header = bin.read(new bin.stream(clr_data), CLR_HEADER);
481
482
  const meta_data = pe.GetDataDir(this.header.MetaData);
482
- const meta_root = meta_data && binary.read(new binary.stream(meta_data.data), METADATA_ROOT);
483
- if (meta_root?.Signature != binary.utils.stringCode('BSJB'))
483
+ const meta_root = meta_data && bin.read(new bin.stream(meta_data.data), METADATA_ROOT);
484
+ if (meta_root?.Signature != bin.utils.stringCode('BSJB'))
484
485
  throw new Error("Invalid CLR");
485
486
  let table_data;
486
487
  for (const h of meta_root.Streams) {
@@ -504,21 +505,21 @@ class CLR {
504
505
  }
505
506
  }
506
507
  if (table_data) {
507
- const stream = new binary.stream(table_data);
508
- this.table_info = binary.read(stream, CLR_TABLES);
508
+ const stream = new bin.stream(table_data);
509
+ this.table_info = bin.read(stream, CLR_TABLES);
509
510
  const table_counts = [];
510
511
  //read counts
511
- for (let b = this.table_info.Valid; b; b = binary.utils.clearLowest(b)) {
512
- const i = binary.utils.lowestSetIndex(b);
513
- table_counts[i] = binary.UINT32_LE.get(stream);
512
+ for (let b = this.table_info.Valid; b; b = bin.utils.clearLowest(b)) {
513
+ const i = bin.utils.lowestSetIndex(b);
514
+ table_counts[i] = bin.UINT32_LE.get(stream);
514
515
  }
515
516
  this.raw = stream.remainder();
516
517
  const stream1 = new clr_dummy(this.table_info.HeapSizes, table_counts);
517
518
  let offset = 0;
518
- for (let b = this.table_info.Valid; b; b = binary.utils.clearLowest(b)) {
519
- const i = binary.utils.lowestSetIndex(b);
519
+ for (let b = this.table_info.Valid; b; b = bin.utils.clearLowest(b)) {
520
+ const i = bin.utils.lowestSetIndex(b);
520
521
  stream1.seek(0);
521
- binary.read(stream1, TableReaders[i]);
522
+ bin.read(stream1, TableReaders[i]);
522
523
  this.tables[i] = { offset, count: table_counts[i], size: stream1.tell() };
523
524
  offset += this.tables[i].size * this.tables[i].count;
524
525
  }
@@ -530,7 +531,7 @@ class CLR {
530
531
  if (table) {
531
532
  const stream2 = new clr_stream(this.raw, this.heaps, this.table_info.HeapSizes, Object.values(this.tables).map(i => i.count));
532
533
  stream2.seek(table.offset + i * table.size);
533
- return binary.read(stream2, TableReaders[t]);
534
+ return bin.read(stream2, TableReaders[t]);
534
535
  }
535
536
  }
536
537
  getTable(t) {
@@ -540,7 +541,7 @@ class CLR {
540
541
  stream2.seek(table.offset);
541
542
  const result = [];
542
543
  for (let i = 0; i < table.count; i++)
543
- result.push(binary.read(stream2, TableReaders[t]));
544
+ result.push(bin.read(stream2, TableReaders[t]));
544
545
  return result;
545
546
  }
546
547
  }
@@ -548,8 +549,8 @@ class CLR {
548
549
  if (this.Resources) {
549
550
  for (const i of this.getTable(TABLE.ManifestResource)) {
550
551
  if (i.name == block) {
551
- const data0 = new binary.stream(this.Resources.subarray(i.data));
552
- const size = binary.UINT32_LE.get(data0);
552
+ const data0 = new bin.stream(this.Resources.subarray(i.data));
553
+ const size = bin.UINT32_LE.get(data0);
553
554
  return getResources(data0.read_buffer(size));
554
555
  }
555
556
  }
@@ -562,8 +563,8 @@ class CLR {
562
563
  if (this.Resources) {
563
564
  const result = {};
564
565
  for (const i of this.getTable(TABLE.ManifestResource)) {
565
- const data0 = new binary.stream(this.Resources.subarray(i.data));
566
- const size = binary.UINT32_LE.get(data0);
566
+ const data0 = new bin.stream(this.Resources.subarray(i.data));
567
+ const size = bin.UINT32_LE.get(data0);
567
568
  const resources = getResources(data0.read_buffer(size));
568
569
  if (resources)
569
570
  Object.assign(result, resources);
@@ -574,15 +575,15 @@ class CLR {
574
575
  }
575
576
  exports.CLR = CLR;
576
577
  function getResources(data) {
577
- const stream = new binary.stream(data);
578
- const manager0 = binary.read(stream, ResourceManagerHeader);
578
+ const stream = new bin.stream(data);
579
+ const manager0 = bin.read(stream, ResourceManagerHeader);
579
580
  if (manager0.magic == 0xBEEFCACE) {
580
- const manager = binary.read_more(stream, ResourceManager, manager0);
581
- stream.align(8);
582
- const hashes = binary.readn(stream, binary.UINT32_LE, manager.num_resources);
583
- const offsets = binary.readn(stream, binary.UINT32_LE, manager.num_resources);
584
- const start = binary.UINT32_LE.get(stream);
585
- const entries = binary.readn(stream, ResourceEntry, manager.num_resources);
581
+ const manager = bin.read_more(stream, ResourceManager, manager0);
582
+ bin.AlignType(8).get(stream);
583
+ const _hashes = bin.readn(stream, bin.UINT32_LE, manager.num_resources);
584
+ const _offsets = bin.readn(stream, bin.UINT32_LE, manager.num_resources);
585
+ const start = bin.UINT32_LE.get(stream);
586
+ const entries = bin.readn(stream, ResourceEntry, manager.num_resources);
586
587
  const resources = {};
587
588
  const decoder = new TextDecoder('utf-8');
588
589
  for (let j = 0; j < manager.num_resources; j++) {
@@ -595,13 +596,24 @@ function getResources(data) {
595
596
  }
596
597
  }
597
598
  // hook into PE reader
598
- pe.DIRECTORIES.CLR_DESCRIPTOR.read = (pe, data) => {
599
- function fix_names(table) {
599
+ /*
600
+ pe.DIRECTORIES.CLR_DESCRIPTOR.read = (pe: pe.PE, data: binary.MappedMemory) => {
601
+ function fix_names(table: any[]) {
600
602
  if ('name' in table[0])
601
603
  return Object.fromEntries(table.map(i => [i.name, i]));
602
604
  return table;
603
605
  }
604
606
  const clr = new CLR(pe, data.data);
605
- return Object.fromEntries(Object.entries(clr.tables).map(([k, v]) => [TABLE[+k], fix_names(clr.getTable(+k))]));
607
+ return Object.fromEntries(Object.entries(clr.tables).map(([k, v]) => [TABLE[+k], fix_names(clr.getTable(+k)!)]));
606
608
  };
609
+ */
610
+ function ReadCLR(pe, data) {
611
+ function fix_names(table) {
612
+ if ('name' in table[0])
613
+ return Object.fromEntries(table.map(i => [i.name, i]));
614
+ return table;
615
+ }
616
+ const clr = new CLR(pe, data.data);
617
+ return Object.fromEntries(Object.entries(clr.tables).map(([k, _]) => [TABLE[+k], fix_names(clr.getTable(+k))]));
618
+ }
607
619
  //# sourceMappingURL=clr.js.map
@@ -0,0 +1,26 @@
1
+ import * as binary from '@isopodlabs/binary';
2
+ declare const Decimal_base: (new (s: binary._stream) => {
3
+ reserved: number;
4
+ scale: number;
5
+ sign: number;
6
+ mhi: number;
7
+ mlo: bigint;
8
+ } & {
9
+ write(w: binary._stream): void;
10
+ }) & {
11
+ get: <X extends abstract new (...args: any) => any>(this: X, s: binary._stream) => InstanceType<X>;
12
+ put: (s: binary._stream, v: any) => void;
13
+ };
14
+ export declare class Decimal extends Decimal_base {
15
+ toNumber(): number;
16
+ }
17
+ export declare const CV_MMASK = 1792;
18
+ export declare const CV_TMASK = 240;
19
+ export declare const CV_SMASK = 15;
20
+ export declare const CV_MSHIFT = 8;
21
+ export declare const CV_TSHIFT = 4;
22
+ export declare const CV_SSHIFT = 0;
23
+ export declare function CV_MODE(typ: number): number;
24
+ export declare function CV_TYPE(typ: number): number;
25
+ export declare function CV_SUBT(typ: number): number;
26
+ export {};