minhook_sys/
lib.rs

1//! Raw bindings to [MinHook](http://www.codeproject.com/KB/winsdk/LibMinHook.aspx), the
2//! minimalistic x86/x64 API hooking library for Windows.
3//!
4//! MinHook is bundled and built with `cc`. Cross-compiling from Linux works fine.
5
6#![doc(html_root_url = "https://docs.rs/minhook-sys/0.1.1")]
7
8use std::os::raw::*;
9
10#[allow(non_camel_case_types)]
11pub type MH_STATUS = i32;
12
13pub const MH_UNKNOWN: MH_STATUS = -1;
14pub const MH_OK: MH_STATUS = 0;
15pub const MH_ERROR_ALREADY_INITIALIZED: MH_STATUS = 1;
16pub const MH_ERROR_NOT_INITIALIZED: MH_STATUS = 2;
17pub const MH_ERROR_ALREADY_CREATED: MH_STATUS = 3;
18pub const MH_ERROR_NOT_CREATED: MH_STATUS = 4;
19pub const MH_ERROR_ENABLED: MH_STATUS = 5;
20pub const MH_ERROR_DISABLED: MH_STATUS = 6;
21pub const MH_ERROR_NOT_EXECUTABLE: MH_STATUS = 7;
22pub const MH_ERROR_UNSUPPORTED_FUNCTION: MH_STATUS = 8;
23pub const MH_ERROR_MEMORY_ALLOC: MH_STATUS = 9;
24pub const MH_ERROR_MEMORY_PROTECT: MH_STATUS = 10;
25pub const MH_ERROR_MODULE_NOT_FOUND: MH_STATUS = 11;
26pub const MH_ERROR_FUNCTION_NOT_FOUND: MH_STATUS = 12;
27
28#[link(name = "MinHook")]
29extern "system" {
30    pub fn MH_Initialize() -> MH_STATUS;
31    pub fn MH_Uninitialize() -> MH_STATUS;
32    pub fn MH_CreateHook(
33        pTarget: *mut c_void,
34        pDetour: *mut c_void,
35        ppOriginal: *mut *mut c_void,
36    ) -> MH_STATUS;
37    pub fn MH_CreateHookApi(
38        pszModule: *const u16,
39        pszProcName: *const c_char,
40        pDetour: *mut c_void,
41        ppOriginal: *mut *mut c_void,
42    ) -> MH_STATUS;
43    pub fn MH_CreateHookApiEx(
44        pszModule: *const u16,
45        pszProcName: *const c_char,
46        pDetour: *mut c_void,
47        ppOriginal: *mut *mut c_void,
48        ppTarget: *mut *mut c_void,
49    ) -> MH_STATUS;
50    pub fn MH_RemoveHook(pTarget: *mut c_void) -> MH_STATUS;
51    pub fn MH_EnableHook(pTarget: *mut c_void) -> MH_STATUS;
52    pub fn MH_DisableHook(pTarget: *mut c_void) -> MH_STATUS;
53    pub fn MH_QueueEnableHook(pTarget: *mut c_void) -> MH_STATUS;
54    pub fn MH_QueueDisableHook(pTarget: *mut c_void) -> MH_STATUS;
55    pub fn MH_ApplyQueued() -> MH_STATUS;
56    pub fn MH_StatusToString(status: MH_STATUS) -> *const c_char;
57}