| Crates.io | libload_reflective |
| lib.rs | libload_reflective |
| version | 0.1.14 |
| created_at | 2024-11-04 15:19:27.792141+00 |
| updated_at | 2025-02-14 13:36:38.949624+00 |
| description | A package to reflectively load libraries from memory |
| homepage | |
| repository | https://github.com/mrLochness350/Libload-Reflective |
| max_upload_size | |
| id | 1435121 |
| size | 44,666 |
This crate allows loading dynamic libraries into memory from bytes, rather than from disk.
A lot of this code was taken from the libloading crate, because I thought their implementation of Symbol<T> was already done and it didn't need a lot of modifications for it to work with in-memory libraries.
For Windows it uses Reflective DLL loading, and for Linux it uses anonymous file-descriptors to load the library into memory.
I am by no means expecting people to use this, since it's still messy, and I want to clean and reformat the code to be prettier.
Feel free to open issues or PRs to make it better.
I only tested this on Windows 11 and Ubuntu 22.04, so be advised.
I wanted to implement a custom "plugin" system for the C2 framework (payload and server) that I'm working on, and I couldn't find something that fit my needs, so I decided to implement my own system for this.
type AddFn = fn(usize, usize) -> usize;
fn main() -> Result<(), ReflectError> {
let data = vec![/*Library bytes*/]
let lib = ReflectedLibrary::new(data)?;
let add: Symbol<AddFn> = lib.get(b"add")?;
let result = add(1,2);
println!("Result: {res}");
lib.close()?;
}