Compare commits
13 Commits
fix/data-s
...
main
Author | SHA1 | Date |
---|---|---|
paring | 81ad517e67 | |
paring | 81d08b4e2d | |
paring | ada7cae22f | |
paring | 8453fe0ab2 | |
paring | 39c6b23a24 | |
paring | 90b18e8792 | |
paring | 8b697f382a | |
paring | 4e0d4007fe | |
paring | cb2df46a79 | |
paring | d93311a4fb | |
CrackThrough | 663da66138 | |
CrackThrough | b068616d44 | |
paring | c13b65c3ba |
|
@ -4,8 +4,9 @@ version = "0.1.0"
|
|||
edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
chrono = "0.4.23"
|
||||
skyhook = { path = "./vendor/skyhook/skyhook" }
|
||||
|
||||
[lib]
|
||||
name = "skyhook"
|
||||
crate-type = ["dylib"]
|
||||
crate-type = ["cdylib"]
|
||||
|
|
24
src/lib.rs
24
src/lib.rs
|
@ -1,9 +1,11 @@
|
|||
use std::{
|
||||
ffi::{c_char, CString},
|
||||
ptr::null,
|
||||
time::{SystemTime, UNIX_EPOCH},
|
||||
};
|
||||
|
||||
use chrono::NaiveDateTime;
|
||||
|
||||
extern crate chrono;
|
||||
extern crate skyhook;
|
||||
|
||||
#[repr(C)]
|
||||
|
@ -14,7 +16,8 @@ pub enum NativeEventType {
|
|||
|
||||
#[repr(C)]
|
||||
pub struct NativeEvent {
|
||||
pub time: usize,
|
||||
pub time_sec: i64,
|
||||
pub time_nsec: u32,
|
||||
pub event_type: NativeEventType,
|
||||
pub vkey: u16,
|
||||
pub keycode: u16,
|
||||
|
@ -30,8 +33,8 @@ fn send_callback(ev: NativeEvent) {
|
|||
}
|
||||
}
|
||||
|
||||
fn get_time(time: SystemTime) -> usize {
|
||||
time.duration_since(UNIX_EPOCH).unwrap().as_nanos() as usize
|
||||
fn get_time(time: NaiveDateTime) -> (i64, u32) {
|
||||
(time.timestamp(), time.timestamp_subsec_nanos())
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
|
@ -41,18 +44,22 @@ pub extern "C" fn start_hook(callback: extern "C" fn(NativeEvent)) -> *const c_c
|
|||
}
|
||||
|
||||
if let Err(e) = skyhook::run(move |event| {
|
||||
let (sec, nsec) = get_time(event.time);
|
||||
|
||||
let event = match event.data {
|
||||
skyhook::types::EventData::KeyPress(label, key) => NativeEvent {
|
||||
time: get_time(event.time),
|
||||
event_type: NativeEventType::KeyPressed,
|
||||
vkey: label as u16,
|
||||
keycode: key,
|
||||
time_sec: sec,
|
||||
time_nsec: nsec,
|
||||
},
|
||||
skyhook::types::EventData::KeyRelease(label, key) => NativeEvent {
|
||||
time: get_time(event.time),
|
||||
event_type: NativeEventType::KeyReleased,
|
||||
vkey: label as u16,
|
||||
keycode: key,
|
||||
time_sec: sec,
|
||||
time_nsec: nsec,
|
||||
},
|
||||
};
|
||||
send_callback(event);
|
||||
|
@ -73,3 +80,8 @@ pub extern "C" fn stop_hook() -> *const c_char {
|
|||
|
||||
null()
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn hook_is_running() -> bool {
|
||||
skyhook::is_running()
|
||||
}
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 530166d47103698a2613e42b47f8c89a91c2363b
|
||||
Subproject commit ebf908ad35cfcb9b2af3b027fcff6c859e3c1d6f
|
Reference in New Issue