5 releases
Uses new Rust 2024
| 0.1.4 | Nov 2, 2025 |
|---|---|
| 0.1.3 | Sep 8, 2024 |
| 0.1.2 | Sep 8, 2024 |
| 0.1.1 | Dec 25, 2022 |
| 0.1.0 | Dec 21, 2022 |
#849 in Memory management
Used in shellexec
7KB
103 lines
virtual-memory
Library for allocating RWX memory on Unix and Windows.
Also see https://github.com/StackOverflowExcept1on/shellexec for more details
Example
use virtual_memory::*;
let buf = &[
//mov eax, 1337
0xb8, 0x39, 0x05, 0x00, 0x00,
//ret
0xc3,
];
let mut memory = VirtualMemory::new(buf.len()).expect("failed to allocate rwx memory");
memory.copy_from_slice(buf);
let f: extern "C" fn() -> u32 = unsafe { std::mem::transmute(memory.as_ptr()) };
assert_eq!(f(), 1337);
Dependencies
~0–3.5MB
~61K SLoC