virtual-memory

Crates.iovirtual-memory
lib.rsvirtual-memory
version0.1.3
sourcesrc
created_at2022-12-21 10:57:01.073035
updated_at2024-09-08 21:31:22.471597
descriptionLibrary for allocating RWX memory on Unix and Windows
homepage
repositoryhttps://github.com/StackOverflowExcept1on/shellexec
max_upload_size
id743057
size6,395
(StackOverflowExcept1on)

documentation

README

virtual-memory

Build Status Latest Version Documentation

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);
Commit count: 8

cargo fmt