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
#![feature(proc_macro_hygiene)]

use skyline::{hook, install_hook};

extern "C" fn test() -> u32 {
    2
}

#[hook(replace = test)]
fn test_replacement() -> u32 {

    let original_test = original!();

    let val = original_test();

    println!("[override] original value: {}", val); // 2

    val + 1
}

#[skyline::main(name = "skyline_rs_template")]
pub fn main() {
    println!("Hello from Skyline Rust Plugin!");

    install_hook!(test_replacement);

    let x = test();

    println!("[main] test returned: {}", x); // 3
}