Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rust API missing Binary Modification Documentation #1123

Open
a1rb0rn3 opened this issue Nov 4, 2024 · 1 comment
Open

Rust API missing Binary Modification Documentation #1123

a1rb0rn3 opened this issue Nov 4, 2024 · 1 comment
Assignees

Comments

@a1rb0rn3
Copy link

a1rb0rn3 commented Nov 4, 2024

Describe the bug
The rust API lacks documentation on how it can be utilized to modify or write PE files: e.g. lief::pe::Section to modify a binary by adding custom sections. I am not sure whether this is simply not documented or not implemented yet.

To Reproduce
I didn't get it to work on rust but for C++ the implementation would be (as described in the docs https://lief.re/doc/latest/formats/pe/index.html):

std::unique_ptr<LIEF::PE::Binary> pe;

LIEF::PE::Section section(".hello");
section.content = std::vector<uint8_t>(0x100, 0xCC);
pe->add_section(section);

pe->write("new.exe");

Expected behavior
A simple way to construct a new lief::pe:Section or a clear and concise description on how to utilize the Rust API (including the lief_ffi package???) to modify and write PE files by adding new sections.

I would expect something similar to this:

let mut pe: lief::pe::Binary;

let mut section = lief::pe::Section::new(".hello");
section.content = vec![0xCC; 0x100];
pe.add_section(section);

pe.write("new.exe");

Environment (please complete the following information):

  • System and Version : Ubuntu 22.04
  • Target format: PE
  • LIEF version: 0.15.1

Additional context
The Problem could still be layer 8 as I'm relatively new to rust :D

NOTICE

If the issue does not contain enough information to be reproduced,
it will be flagged as incomplete
and closed.

/NOTICE

@romainthomas
Copy link
Member

Hi @a1rb0rn3

Thank you for raising this issue and for providing an example of the API you would like to see in Rust to modify binaries.

Right now the Rust API is read only on the LIEF binaries (on purpose) but I'm starting to consider to introduce mutable API as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants