Skip to content

Commit 15f8053

Browse files
committed
WIP fix U16/U16Bytes split.
1 parent 984ed7e commit 15f8053

File tree

1 file changed

+33
-25
lines changed

1 file changed

+33
-25
lines changed

src/archive.rs

Lines changed: 33 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,18 @@ mod windows_import_lib {
6666
use object::{LittleEndian as LE, U16Bytes, U32Bytes, U16, U32};
6767

6868
fn u16(value: u16) -> U16<LE> {
69-
U16Bytes::new(LE, value)
69+
U16::new(LE, value)
7070
}
7171

7272
fn u32(value: u32) -> U32<LE> {
73+
U32::new(LE, value)
74+
}
75+
76+
fn u16b(value: u16) -> U16Bytes<LE> {
77+
U16Bytes::new(LE, value)
78+
}
79+
80+
fn u32b(value: u32) -> U32Bytes<LE> {
7381
U32Bytes::new(LE, value)
7482
}
7583

@@ -387,21 +395,21 @@ mod windows_import_lib {
387395
);
388396
// relocation 0: [3] import lookup table rva => points to UNDEF symbol .idata$4
389397
import_descriptor.write_pod(&ImageRelocation {
390-
virtual_address: u32(0),
391-
symbol_table_index: u32(3),
392-
typ: u16(IMAGE_REL_AMD64_ADDR32NB),
398+
virtual_address: u32b(0),
399+
symbol_table_index: u32b(3),
400+
typ: u16b(IMAGE_REL_AMD64_ADDR32NB),
393401
});
394402
// relocation 1: [2] name rva => points to DLL name section .idata$6
395403
import_descriptor.write_pod(&ImageRelocation {
396-
virtual_address: u32(12),
397-
symbol_table_index: u32(2),
398-
typ: u16(IMAGE_REL_AMD64_ADDR32NB),
404+
virtual_address: u32b(12),
405+
symbol_table_index: u32b(2),
406+
typ: u16b(IMAGE_REL_AMD64_ADDR32NB),
399407
});
400408
// relocation 2: [4] import address table rva => points to UNDEF symbol .idata$5
401409
import_descriptor.write_pod(&ImageRelocation {
402-
virtual_address: u32(16),
403-
symbol_table_index: u32(4),
404-
typ: u16(IMAGE_REL_AMD64_ADDR32NB),
410+
virtual_address: u32b(16),
411+
symbol_table_index: u32b(4),
412+
typ: u16b(IMAGE_REL_AMD64_ADDR32NB),
405413
});
406414

407415
// [1] section .idata$6 data
@@ -455,45 +463,45 @@ mod windows_import_lib {
455463
// [0] external __IMPORT_DESCRIPTOR_{dll_basename} => section 1
456464
import_descriptor.write_pod(&ImageSymbol {
457465
name: coff_string_table.get_symbol_raw_name(&import_descriptor_symbol),
458-
value: u32(0),
459-
section_number: u16(1),
460-
typ: u16(null_type),
466+
value: u32b(0),
467+
section_number: u16b(1),
468+
typ: u16b(null_type),
461469
storage_class: IMAGE_SYM_CLASS_EXTERNAL,
462470
number_of_aux_symbols: 0,
463471
});
464472
// [1] section .idata$2 => section 1
465473
import_descriptor.write_pod(&ImageSymbol {
466474
name: coff_string_table.get_symbol_raw_name(".idata$2"),
467-
value: u32(0),
468-
section_number: u16(1),
469-
typ: u16(null_type),
475+
value: u32b(0),
476+
section_number: u16b(1),
477+
typ: u16b(null_type),
470478
storage_class: IMAGE_SYM_CLASS_SECTION,
471479
number_of_aux_symbols: 0,
472480
});
473481
// [2] static .idata$6 => section 2
474482
import_descriptor.write_pod(&ImageSymbol {
475483
name: coff_string_table.get_symbol_raw_name(".idata$6"),
476-
value: u32(0),
477-
section_number: u16(2),
478-
typ: u16(null_type),
484+
value: u32b(0),
485+
section_number: u16b(2),
486+
typ: u16b(null_type),
479487
storage_class: IMAGE_SYM_CLASS_STATIC,
480488
number_of_aux_symbols: 0,
481489
});
482490
// [3] section .idata$4 => undef
483491
import_descriptor.write_pod(&ImageSymbol {
484492
name: coff_string_table.get_symbol_raw_name(".idata$4"),
485-
value: u32(0),
486-
section_number: u16(IMAGE_SYM_UNDEFINED as u16),
487-
typ: u16(null_type),
493+
value: u32b(0),
494+
section_number: u16b(IMAGE_SYM_UNDEFINED as u16),
495+
typ: u16b(null_type),
488496
storage_class: IMAGE_SYM_CLASS_SECTION,
489497
number_of_aux_symbols: 0,
490498
});
491499
// [4] section .idata$5 => undef
492500
import_descriptor.write_pod(&ImageSymbol {
493501
name: coff_string_table.get_symbol_raw_name(".idata$5"),
494-
value: u32(0),
495-
section_number: u16(IMAGE_SYM_UNDEFINED as u16),
496-
typ: u16(null_type),
502+
value: u32b(0),
503+
section_number: u16b(IMAGE_SYM_UNDEFINED as u16),
504+
typ: u16b(null_type),
497505
storage_class: IMAGE_SYM_CLASS_SECTION,
498506
number_of_aux_symbols: 0,
499507
});

0 commit comments

Comments
 (0)