PE cleanup after review elsewhere

This commit is contained in:
Folkert 2022-09-06 13:36:14 +02:00
parent 8a2aa076ee
commit 6fff224c77
No known key found for this signature in database
GPG key ID: 1F17F6FFD112B97C
2 changed files with 5 additions and 4 deletions

View file

@ -6,7 +6,7 @@ pub fn create_dylib_elf64(custom_names: &[String]) -> object::read::Result<Vec<u
let mut out_data = Vec::new();
let mut writer = object::write::elf::Writer::new(endian, true, &mut out_data);
const DYNAMIC_SECTION: usize = 2;
const DYNAMIC_SECTION_INDEX: usize = 2;
let out_sections_index = [
writer.reserve_dynsym_section_index(),
@ -66,7 +66,7 @@ pub fn create_dylib_elf64(custom_names: &[String]) -> object::read::Result<Vec<u
for (_index, name) in out_dynsyms {
writer.write_dynamic_symbol(&object::write::elf::Sym {
name: Some(name),
section: Some(out_sections_index[DYNAMIC_SECTION]),
section: Some(out_sections_index[DYNAMIC_SECTION_INDEX]),
st_info: (elf::STB_GLOBAL << 4) | elf::STT_FUNC,
st_other: 0,
st_shndx: 0,

View file

@ -109,9 +109,10 @@ pub fn synthetic_dll(custom_names: &[String]) -> Vec<u8> {
// we store the export directory in a .rdata section
let rdata_section: (_, Vec<u8>) = {
let characteristics = 0x40000040;
let range = writer.reserve_section(
*b".rdata\0\0",
1073741888,
characteristics,
// virtual size
exports.len() as u32,
// size_of_raw_data
@ -127,7 +128,7 @@ pub fn synthetic_dll(custom_names: &[String]) -> Vec<u8> {
// the header on my machine
let headers = object::write::pe::NtHeaders {
machine: 34404,
time_date_stamp: 1661696130,
time_date_stamp: 0,
characteristics: 8226,
major_linker_version: 14,
minor_linker_version: 0,