forked from trickster0/OffensiveRust
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.rs
32 lines (29 loc) · 849 Bytes
/
main.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
use std::ffi::CString;
use winapi::{
um::{
winuser::MessageBoxA,
},
shared::{
windef::HWND,
minwindef::{
UINT
},
ntdef::LPCSTR
}
};
use detour::static_detour;
static_detour! {
static MsgBox: unsafe extern "system" fn(HWND, LPCSTR, LPCSTR, UINT) -> i32;
}
fn main() {
unsafe {
MsgBox.initialize(MessageBoxA, |hwnd, lp_text, lp_caption, u_type| {
println!("Hooked MessageBoxA");
MsgBox.call(hwnd, lp_text, lp_caption, u_type)
});
MessageBoxA(0 as HWND, CString::new("Before").unwrap().as_ptr(), CString::new("Before").unwrap().as_ptr(), 0);
MsgBox.enable();
MessageBoxA(0 as HWND, CString::new("After").unwrap().as_ptr(), CString::new("After").unwrap().as_ptr(), 0);
MsgBox.disable();
}
}