Forum > Coding >

Executor API Rust Language Usage

New Reply

Posts: 1

Threads: 1

Joined: Jan, 2026

Reputation: 0

Posted

Hello, the example code on the executor api page (Rust) is false. Instead of using this you can use this:

// executor.rs
use libloading::{Library, Symbol};
use once_cell::sync::OnceCell;
use std::ffi::{CString, c_char};

static DLL: OnceCell<Library> = OnceCell::new();

fn load_dll() -> &'static Library {
    DLL.get_or_init(|| unsafe {
        Library::new("src/wearedevs_exploit_api.dll").expect("Failed to load dll")
    })
}

type InitializeFn = extern "C" fn() -> bool;
type IsAttachedFn = extern "C" fn() -> u8;
type ExecuteFn = extern "C" fn(*const c_char);

pub fn initialize() -> bool {
    unsafe {
        let func: Symbol<InitializeFn> = load_dll().get(b"initialize").unwrap();
        func()
    }
}

pub fn is_attached() -> u8 {
    unsafe {
        let func: Symbol<IsAttachedFn> = load_dll().get(b"isAttached").unwrap();
        func()
    }
}
 
This will help you develope from stratch easier now. Have a great day!

pub fn execute(script: &str) {
    let c_string = CString::new(script).expect("Failed to create C string");
    unsafe {
        let func: Symbol<ExecuteFn> = load_dll().get(b"execute").unwrap();
        func(c_string.as_ptr());
    }
}

fn main() {
    initialize();
    // execute(script)
}
  • 0

  • Comment

I'm a Turkish developer who uses and studies Rust.

Login to unlock the reply editor

Add your reply

Users viewing this thread:

( Members: 0, Guests: 1, Total: 1 )