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

kernel32 hook example without needing static_detour or nightly #16

Merged
merged 9 commits into from
May 29, 2023

Conversation

brandonros
Copy link

A little verbose, I couldn't figure out how to get it all as a macro... A little rushed as well, I'm sure it could be better. Up to you if you want to accept, just thought it'd be cool to demo not needing static_detour! + nightly.

@Hpmason
Copy link
Owner

Hpmason commented May 23, 2023

I like the idea of having a non-nightly example with GenericDetour, but it looks like your example is using crates that aren't included in retour. For instance, your example is using minidl, once_cell, and log aren't included in this crate. I want to replace lazy_static with once_cell anyways so that one isn't a huge problem, but I'm not sure about using minidl or log. You're also using crate::libc, which isn't part of retour.

If you could update the example to work with retour, I can add your example to the repo. You can add once_cell and minidl to the dev-dependencies since they make the example clearer, but would you be able to replace uses of log with print statements?

@brandonros
Copy link
Author

brandonros commented May 23, 2023

@Hpmason appreciate everything you've done for the community immensely by dedicating your time to maintain this and takeover detour. give me one minute on the Cargo.toml changes

Copy link
Owner

@Hpmason Hpmason left a comment

Choose a reason for hiding this comment

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

Mostly looks good, just a few minor changes, so that is works with CI. I left a few suggestions.

One thing not in the suggestions is to add the example to the Cargo.toml as a cdylib, like messageboxw_detour and cat-detour. Otherwise Rust expects there to be a main fn in the example.

[[example]]
name = "kernel32"
crate-type = ["cdylib"]

examples/kernel32.rs Outdated Show resolved Hide resolved
examples/kernel32.rs Outdated Show resolved Hide resolved
@brandonros
Copy link
Author

now it's in a weird state that it's designed to be the "injected DLL" part of a "hook process + inject DLL" steps. do you still want an fn main()? do we want an injector on the side? can we leave that up for the viewer to figure out and call it "out of scope" of this library/example?

@Hpmason
Copy link
Owner

Hpmason commented May 29, 2023

Each example has kind of acted as an "injected DLL", so they don't need an fn main(). The injection process is a little out of scope for at least this example.

I'm not sure what the best way to show off the injection process is. It's so varied, with LD_PRELOAD on Linux, injecting using debuggers, and the various injector libraries out there. It would be beneficial to mention/link some of the methods in the README.md and docs, just to point viewers in the right direction. Though it should probably be in another PR.

All the code looks good! Just let me know if you need to make any more changes before I merge it.

@brandonros
Copy link
Author

good enough for now please, thanks for your time on this.

@Hpmason Hpmason merged commit 7d6ab8a into Hpmason:master May 29, 2023
@Hpmason Hpmason mentioned this pull request Jun 6, 2023
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