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

Switch to using retour for better cross-platform support #5

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

ccptr
Copy link

@ccptr ccptr commented Sep 1, 2024

I'm planning on adding Linux support if you're open to it. I tested it on Windows and the behavior hasn't changed. Using retour also has the advantage of being written in Rust, so it's one less system dependency :)

};

let mut hk =
Self { target: target.cast_mut(), detour: detour.cast_mut(), original: null_mut() };
let hook = unsafe { retour::RawDetour::new(target as _, detour as _)? };
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can also be wrapped in ManuallyDrop instead of storing it in the struct below

@ccptr
Copy link
Author

ccptr commented Sep 14, 2024

Any input on this? I'm actually planning to turn this into a CS2 base as a library. I'm hoping to make something where you can pretty much just cargo init && cargo add cs2lib, and then do something along the lines of:

use cs2lib::{Hooks, make_entry_point};

unsafe extern "system" fn create_move(a1: *mut f32, a2: u64, a3: i8, a4: u64, a5: u64, a6: u64) -> u64 {
    println!("create move called");
    originals::create_move(a1, a2, a3, a4, a5, a6)
}

fn startup() {
    let hooks = Hooks {
        create_move: Some(create_move),
        // add the rest of the functions you want to hook here
        ..Default::default()
    };

    let originals = cs2lib::initialize(&hooks);
}

make_entry_point!(startup);

The cheat developer would get type checking for hook functions, signatures for hooks, and would make it easier to contribute due to the library not being coupled with the cheat, making it easier for everyone when CS2 updates break things.

I completely understand if you're not interested in doing this, but if you're willing to just add Linux support please let me know, as I have a PR in the works that I'll just squash if you're not interested.

@Jumaron
Copy link

Jumaron commented Sep 16, 2024

Any input on this? I'm actually planning to turn this into a CS2 base as a library. I'm hoping to make something where you can pretty much just cargo init && cargo add cs2lib, and then do something along the lines of:

use cs2lib::{Hooks, make_entry_point};

unsafe extern "system" fn create_move(a1: *mut f32, a2: u64, a3: i8, a4: u64, a5: u64, a6: u64) -> u64 {
    println!("create move called");
    originals::create_move(a1, a2, a3, a4, a5, a6)
}

fn startup() {
    let hooks = Hooks {
        create_move: Some(create_move),
        // add the rest of the functions you want to hook here
        ..Default::default()
    };

    let originals = cs2lib::initialize(&hooks);
}

make_entry_point!(startup);

The cheat developer would get type checking for hook functions, signatures for hooks, and would make it easier to contribute due to the library not being coupled with the cheat, making it easier for everyone when CS2 updates break things.

I completely understand if you're not interested in doing this, but if you're willing to just add Linux support please let me know, as I have a PR in the works that I'll just squash if you're not interested.

+1 for Retour also a +1 If you would add a Offset Manager.
Maybe also some Interfaces. The pointer on the create_move (a1) seems to be a bit buggy when used with the default CInput interface.
But in all would love to see this being more developed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants