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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
use libil2cpp::{Parameters, Return, ThisParameter};
pub trait Hook {
type This: ThisParameter;
type Parameters: Parameters;
type Return: Return;
const NAMESPACE: &'static str;
const CLASS_NAME: &'static str;
const METHOD_NAME: &'static str;
fn install(&self) -> Result<(), HookInstallError>;
fn hook(&self) -> *const ();
fn original(&self) -> Option<*const ()>;
}
#[derive(Debug, thiserror::Error, Clone, Copy, PartialEq, Eq, Hash)]
pub enum HookInstallError {
#[error("hook already installed")]
AlreadyInstalled,
#[error("class not found")]
ClassNotFound,
#[error("method not found")]
MethodNotFound,
#[error("error installing hook")]
InstallError,
}