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

CDetour crash on x64 due to copying relative address to trampoline #2147

Closed
bottiger1 opened this issue May 2, 2024 · 3 comments
Closed

Comments

@bottiger1
Copy link
Contributor

bottiger1 commented May 2, 2024

While porting TF2 extensions to x64, I noticed a hook that was working on x32 started crashing.

I noticed CDetour copied this instruction to the trampoline.

lea rax, [rip + 0xbecbb1]

Since the offset is based on the current program position, the destination obviously becomes invalid if it is moved.

I am not sure if anyone wants to fix this as it seems like a daunting task to detect relative addressing in every possible instruction.

But on the other hand due to x64, more functions like this may lose the normal function prologue that is guaranteed to be free of relative addressing, so it may become a frequent problem. Maybe there's another library besides udis that handles this problem?

@Mooshua
Copy link

Mooshua commented May 2, 2024

How x64 detours will be tackled is still to be determined. The backend will probably be migrated to a library with better platform/disassembly support.

@bottiger1
Copy link
Contributor Author

bottiger1 commented May 3, 2024

May I ask who is determining it?

There are many extensions that use CDetour so it might not be a good idea to port a bunch of extensions with a broken version of CDetour.

I also did a google search and it seems like some other hooking libraries can handle this but are all windows only.

stevemk14ebr/PolyHook_2_0#119

@Mooshua
Copy link

Mooshua commented May 3, 2024

May I ask who is determining it?

Sure as heck not me, but some folks in the AMcord were looking into SafetyHook if I recall correctly.

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

No branches or pull requests

2 participants