MCPcopy Index your code
hub / github.com/Thoxy67/rust-pe

github.com/Thoxy67/rust-pe @v0.1.2

Chat with this repo
repository ↗ · DeepWiki ↗ · release v0.1.2 ↗ · + Follow
36 symbols 82 edges 6 files 17 documented · 47%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

rspe

Simple Native Rust Reflective PE loader library

Features

This project can execute RunPE into memory using the following methods:

  • Native RunPE (C/C++/RUST...)
    • [x] 64-bit
    • [x] 32-bit
  • .NET RunPE (C#/VB/CLR...)
    • [ ] 64-bit .NET RunPE into Memory (maybe view clroxide lib)
    • [ ] 32-bit .NET RunPE into Memory (maybe view clroxide lib)

Use

use rspe::{reflective_loader, utils::check_dotnet};

// Main function
fn main() -> Result<(), String> {
    // Read the file to load into a buffer
    #[cfg(target_arch = "x86_64")]
    let data = include_bytes!(r#".\putty_x64.exe"#).to_vec();
    #[cfg(target_arch = "x86")]
    let data = include_bytes!(r#".\putty_x86.exe"#).to_vec();

    // Load the file based on the target architecture
    // Check if the file is a .NET assembly
    if !check_dotnet(data.clone()) {
        // If it is not, use the reflective loader to load the file
        unsafe {
            reflective_loader(data.clone());

            // Using Threads (useful to bind 2nd exe to execute at the same time):
            // Currently not in use, but can be used to load the pe file in a separate thread
            // let handle = std::thread::spawn(move || {
            //     pe::loader::reflective_loader(data.clone());
            // });
            // let _ = handle.join();
        };
    } else {
        panic!("This is a .NET PE file. Only native PE image are supported! Please provide a native PE image.")
    }

    Ok(())
}

Credits / References

Special thanks to the following individuals and projects for their contributions to this project:

  • memN0ps for providing useful winapi rust code for learning
  • trickster0 for providing many OffensiveRust code for learning

License

This project is licensed under the MIT License - see the LICENSE file for details.

Core symbols most depended-on inside this repo

get_headers_size
called by 4
src/pelib.rs
get_image_size
called by 4
src/pelib.rs
get_dos_header
called by 4
src/pelib.rs
get_nt_header
called by 4
src/pelib.rs
read_string_from_memory
called by 2
src/utils.rs
write_sections
called by 2
src/pelib.rs
fix_base_relocations
called by 2
src/pelib.rs
write_import_table
called by 2
src/pelib.rs

Shape

Function 24
Class 12

Languages

Rust100%

Modules by API surface

src/windows.rs12 symbols
src/pelib.rs10 symbols
src/utils.rs5 symbols
src/test.rs5 symbols
src/lib.rs3 symbols
examples/putty.rs1 symbols

For agents

$ claude mcp add rust-pe \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact