Compare commits

...

4 Commits

6 changed files with 45 additions and 10 deletions

4
.gitignore vendored
View File

@ -1 +1,5 @@
/target
# Ignore environment directories
/.idea
/.vscode

7
Cargo.lock generated
View File

@ -13,6 +13,7 @@ name = "skyhook"
version = "0.1.0"
dependencies = [
"cancellation",
"winsafe",
]
[[package]]
@ -21,3 +22,9 @@ version = "0.1.0"
dependencies = [
"skyhook",
]
[[package]]
name = "winsafe"
version = "0.0.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1fd38859e955532136a544e7e6a6a1239a3f4fe48ecf67c63500ec9f527f8381"

View File

@ -1,3 +1,3 @@
# native
# Skyhook-Native
Very simple Keyboard & Mouse hook, meant for rhythm games.

View File

@ -11,3 +11,4 @@ edition = "2021"
[dependencies]
cancellation = "0.1.0"
winsafe = "0.0.5"

View File

@ -1,10 +1,10 @@
// unsafe stuff
extern crate user32;
extern crate winapi;
// safe stuff
use winsafe::co::WH;
extern crate winsafe;
/*
//#region Constants
const KEY_PRESSED: i32 = 0x8000;
const WM_KEYDOWN: i32 = 0x0100;
@ -14,11 +14,26 @@ const WM_SYSKEYUP: i32 = 0x0105;
const WH_KEYBOARD_LL: i32 = 13;
const WH_MOUSE_LL: i32 = 14;
//#endregion
*/
//#region Commons
static mut hook_id: winsafe::HHOOK = 0;
static mut hook_id: Option<winsafe::HHOOK> = None;
pub fn start() -> () {
/*
unsafe {
hook_id = Some(winsafe::HHOOK::SetWindowsHookEx(
WH::KEYBOARD_LL,
hook_callback,
winsafe::HINSTANCE::NULL,
Some(0)));
match hook_id {
Some(x) => (),
None => panic!(),
}
}*/
/*
unsafe {
let hook_id =
user32::SetWindowsHookExA(WH_KEYBOARD_LL, Some(hook_callback), std::ptr::null_mut(), 0);
@ -27,14 +42,14 @@ pub fn start() -> () {
// Release hook
user32::UnhookWindowsHookEx(hook_id);
}
}*/
}
pub fn stop() -> () {}
//#endregion
extern "system" fn hook_callback(code: i32, wParam: u64, lParam: i64) -> i64 {
unsafe {
extern "system" fn hook_callback(code: i32, wParam: usize, lParam: isize) -> isize {
/*unsafe {
assert!(
hook_id != 0,
format!(
@ -42,7 +57,7 @@ extern "system" fn hook_callback(code: i32, wParam: u64, lParam: i64) -> i64 {
winapi::um::errhandlingapi::GetLastError()
)
); // GetLastError is an unsafe method
}
}*/
return 0;
}

View File

@ -1 +1,9 @@
mod hook;
pub fn start() {
hook::start()
}
pub fn stop() {
hook::stop()
}