Issue with packPlayerItem hooking (dealing with registers EAX-EDX-ECX)
Time ago I've had troubles with hooking this function with Orpheu.
Now I tried to make a module to deal with this, by knowing it was some kind of weird optimization. It has the same behavior that SetAnimation function has. Reference: https://forums.alliedmods.net/showpo...postcount=1462 First, what I tried to do is to read Arkshine's way to deal with SetAnimation module: https://forums.alliedmods.net/showpo...51&postcount=7 Then I looked through the gamedll with IDA Pro and discover what does register store. Inside CBasePlayer::PackDeadPlayerItems: http://puu.sh/tTwl4/f0b324bdbe.png and..: http://puu.sh/tTwnh/ee60503a7b.png What I guessed first was "ECX contains packAmmo parameter", which makes sense reading a decompiled version of PackDeadPlayerItems (it's always 1) Then, reading this code, I tried to understand decompiled version of it. PHP Code:
Code:
Just read it and you'll understand. v20 is packAmmo, v20 equals to v5 and v5 contains the value of CL register, lower part of ECX register, set as 1 in the pictures below. (also see this one) v4 is pItem, and it points to EDX register. Inside CBaseEntity::Create you can see references with v6 to the player pev->origin entvar. then you guess that v6 = result, and results references to the EAX register. Now it makes sense this picture http://puu.sh/tTwl4/f0b324bdbe.png I managed to create this code, by reading a few guides of Inline Assembly in cpp and also Arkshine's SetAnimation hooker: PHP Code:
PHP Code:
PHP Code:
If I comment SERVER_PRINT call, server crashes with a seg fault. Why? I dont know. So, my first guess is the inline assembler code that I wrote has a mistake, and I believe it's that. Am I doing right with it? Or am I forgetting something? Thanks for reading. |
Re: Issue with packPlayerItem hooking (dealing with registers EAX-EDX-ECX)
I don't know much the assembly language, but is it really needed the following: " : "%eax", "%edx", "%ecx" "?
|
Re: Issue with packPlayerItem hooking (dealing with registers EAX-EDX-ECX)
Try to declare OrigFunc_packPlayerItem with __attribute__((regparm(3))) before *.
|
Re: Issue with packPlayerItem hooking (dealing with registers EAX-EDX-ECX)
Quote:
And your code from link Code:
DETOUR_DECL_MEMBER1(SetAnimation, void, int, playerAnim) |
Re: Issue with packPlayerItem hooking (dealing with registers EAX-EDX-ECX)
The code above works, I don't post module which has not been tested. But it's possible I did not test in a way he would not work, I don't know. Also, I'm confused, I don't change the registers, I get the values from them and set them in variables.
|
Re: Issue with packPlayerItem hooking (dealing with registers EAX-EDX-ECX)
Ah, right. I'm forgot about reverse operands order. Yes, in this way it's correct. I thought that you are calling original SetAnimation.
|
Re: Issue with packPlayerItem hooking (dealing with registers EAX-EDX-ECX)
Quote:
PHP Code:
Quote:
Also thanks for answering. The way I wrote the clubbed list is right then? Quote:
|
Re: Issue with packPlayerItem hooking (dealing with registers EAX-EDX-ECX)
Quote:
|
Re: Issue with packPlayerItem hooking (dealing with registers EAX-EDX-ECX)
Didn't read all but the original function is cdecl so your function must be of cdecl type, remember that
|
Re: Issue with packPlayerItem hooking (dealing with registers EAX-EDX-ECX)
Quote:
My final doubt is, does the "m" constraints are ok? |
All times are GMT -4. The time now is 14:10. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.