-
Notifications
You must be signed in to change notification settings - Fork 101
x64 linux sourcehook hookmangen #212
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
base: master
Are you sure you want to change the base?
Conversation
May I recommend that you mark this PR as a draft until it is ready ? Anyways, thanks for seeing this through I've a few remarks that aren't noted in your todo. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lots of stack alignment for Linux are missing. Specifically in
-
x64GenContext::GeneratePubFunc
-
x64GenContext::CallEndContext
-
x64GenContext::DoReturn
-
x64GenContext::PrepareReturn
-
x64GenContext::GenerateCallHooks
-
retInfo.pAssignOperator
-
retInfo.pDtor
-
x64GenContext::CallSetupHookLoop
(You also need to handle parameter 7, 8, 9 & 10)
const x86_64_Reg params_reg[] = { rdi, rsi, rdx, rcx, r8, r9 }; | ||
|
||
int reg_index = 0; | ||
|
||
m_HookFunc.mov(rbp(v_this), rdi); | ||
reg_index++; | ||
|
||
8000 | if ((retInfo.flags & PassInfo::PassFlag_RetMem) == PassInfo::PassFlag_RetMem) { | |
m_HookFunc.mov(rbp(v_memret_ptr), params_reg[reg_index]); | ||
reg_index++; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given that System V callconv is very annoying because sourcehook doesn't provide nearly enough information to tell whether an object goes in memory or registers. I'm fine with the idea of just saving all the registers and restoring them when its time to call the original. Only the return value will therefore need special attention.
It's very important all the registers are saved, because in the rest of the stub generator I make the promise that all general purpose registers are available for usage. Which I did make use of (see when r8
or r9
get used) and they're not restored, this will create issues.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given that System V callconv is very annoying because sourcehook doesn't provide nearly enough information to tell whether an object goes in memory or registers
This is nice in a way though because it means all the type classification logic from the ABI can be excluded.
Which does mean Linux64 Sourcepawn DHooks users will have to manually fill out registers, where on Windows64 you can just HookParamType_Object
/HookParamType_ObjectPtr
and call it a day...
Alignment for these were added with the latest commit:
TODO still because they're a bit more than just copy & pasting.
|
…copy a ton of notes from System V docs
Following up on @Kenzzer's epic work on the x64 Windows hookmangen #175 stuff: WIP x64 Linux hookmangen stuff!
TODO: