Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hook process event #8

Merged
merged 16 commits into from
Jun 28, 2020
Prev Previous commit
Next Next commit
Print unique events
  • Loading branch information
rkr35 committed Jun 27, 2020
commit a4a2f5efadd783a4ec30918478a10c644744b99b
17 changes: 15 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use std::mem;
use std::ptr;

use detours_sys::{DetourTransactionBegin, DetourUpdateThread, DetourAttach, DetourDetach, DetourTransactionCommit};
use log::{error, info};
use log::{error, info, warn};
use simplelog::{Config, LevelFilter, TermLogger, TerminalMode};
use thiserror::Error;
use winapi::{
Expand Down Expand Up @@ -169,7 +169,20 @@ unsafe fn unhook_process_event() {
unsafe extern "fastcall" fn my_process_event(this: &game::Object, edx: usize, function: &game::Function, parameters: *mut c_void, return_value: *mut c_void) {
type ProcessEvent = unsafe extern "fastcall" fn (this: &game::Object, _edx: usize, function: &game::Function, parameters: *mut c_void, return_value: *mut c_void);

info!("my_process_event");
if let Some(full_name) = function.full_name() {
use std::collections::HashSet;
static mut UNIQUE_EVENTS: Option<HashSet<String>> = None;

if let Some(set) = UNIQUE_EVENTS.as_mut() {
if set.insert(full_name.clone()) {
info!("{}", full_name);
}
} else {
UNIQUE_EVENTS = Some(HashSet::new());
}
} else {
warn!("couldn't get full name");
}

let original = mem::transmute::<*mut c_void, ProcessEvent>(PROCESS_EVENT);
original(this, edx, function, parameters, return_value);
Expand Down