NotExecutable error


#1

Hey guys, I’ve been attempting to create a dll game function hooker, in rust. And I’ve ran into a problem. I’m using the library minhook-rs to hook my functions, and I keep getting this error in my match statement, “Error NotExecutable”

    let test = match test {
        Ok(test) => {
            println!("OKAY! {:?}", test);
        },

        Err(test) => println!("Error {:?}", test)
    };

where test is:

let test = unsafe { minhook::Hook::<createmove_fn>::create::<createmove_fn>(hook_createmove, fn_ptrs.addy) };

where

    ::create::

returns a std::result::Result

Its building the DLL fine, I’m building the target as cargo build --target=i686-pc-windows-msvc

createmove_fn is my type for my function pointer:
type createmove_fn = fn(f32, *mut UserCmd) -> bool;
and fn_ptrs.addy is:

lazy_static! {
    static ref fn_ptrs: FunctionPtrAddress = FunctionPtrAddress {
        addy: unsafe {
            std::mem::transmute::<usize, createmove_fn>(0x104E1D68)
        }
    };
}

Thanks guys, all helps appreciated. I’d like to know why, and how to fix this error 2 :heart:


#2

Fixed on github. https://github.com/rust-lang/rust/issues/42914