loserland_exec

Crates.ioloserland_exec
lib.rsloserland_exec
version0.1.0
sourcesrc
created_at2022-01-09 15:39:41.768167
updated_at2022-01-09 15:39:41.768167
descriptionA short description of my package
homepage
repository
max_upload_size
id510892
size22,420
Eugenio Delfa (EugenioDelfa)

documentation

README

loserland_exec

Load a DLL from memory

A neat example of translating unsafe C code to Rust.

To quote fancycode:

The default windows API functions to load external libraries into a program
(LoadLibrary, LoadLibraryEx) only work with files on the filesystem. 

This makes it difficult to execute code given a stream of bytes who don't reside on the Windows Filesystem.

extern crate loserland_exec;

use std::fs::File;

// helloworld.dll exports a function named callme
let mut dll_file = File::open("helloworld.dll").unwrap();
let mut dll_data = Vec::new();

// Read the dll file into a vector of bytes so we can pretend we got them from anywhere
dll_file.read_to_end(&mut dll_data).unwrap();

// Find the function exported by our dll in memory
let callme = loserland_exec::get_proc("callme", &dll_data) as *const ();

// Execute the code
(callme)(); // Hello from plugin!

Status

Looking for help writing up in-depth documentation showing how the memory is laid out and code is executed. Would also like to add linux and darwin compatability.

Contributing

Please feel free to open an issue or reach out on twitter

Questions, comments, concerns, and contributions will be met with compassion.

References

Commit count: 0

cargo fmt