m4b / goblin

An impish, cross-platform binary parsing crate, written in Rust
MIT License
1.18k stars 158 forks source link

Little help with writing the modifications of an PE #394

Closed GanbaruTobi closed 7 months ago

GanbaruTobi commented 7 months ago

Hello, I just tried to use this crate. I parsed an PE from memory into an PE and that seems to work. But how do I write the modified result? Thanks for any help

    let poptions = ParseOptions{ resolve_rva : false, parse_attribute_certificates : false};
    let mut pe_mem = goblin::pe::PE::parse_with_opts(memory_data, &poptions)?; 

    for section in &mut pe_mem.sections {
        section.pointer_to_raw_data = section.virtual_address;
        section.size_of_raw_data = section.virtual_size;
   }
   //write the modifications here.
}
m4b commented 7 months ago

writing a PE (or binary file in general) is generally much more involved than reading. However, there is ongoing work to support writing pe in #389 as well as previously merged PRs. https://github.com/RaitoBezarius/ifrit is an example of this. if you need a specific feature that isn't covered, feel free to open another issue with that feature, thanks!