Raised This Month: $ Target: $400
 0% 

Issue with packPlayerItem hooking (dealing with registers EAX-EDX-ECX)


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Asmodai
New Member
Join Date: May 2011
Old 02-08-2017 , 13:22   Re: Issue with packPlayerItem hooking (dealing with registers EAX-EDX-ECX)
Reply With Quote #1

Quote:
Originally Posted by Arkshine View Post
I don't know much the assembly language, but is it really needed the following: " : "%eax", "%edx", "%ecx" "?
Yes, we must list all used registers because gcc didn't parsing asm insertions.

And your code from link
Code:
DETOUR_DECL_MEMBER1(SetAnimation, void, int, playerAnim)
{
	const void *pvPlayer = reinterpret_cast<const void*>(this);

#if defined(LINUX)

	asm volatile
	(
		"movl %%edx, %0;"
		"movl %%eax, %1;"
		: "=d" (playerAnim), "=a" (pvPlayer) : :
	);

#endif

	if (MF_ExecuteForward(OnSetAnimationForward, Utils::PrivateToIndex(pvPlayer), playerAnim) > 0)
	{
		return;
	}

#if defined(WIN32) || defined(APPLE)

	DETOUR_MEMBER_CALL(SetAnimation)(playerAnim);

#elif defined(LINUX)

	SetAnimationDetour->DisableDetour();
	SetAnimationOrig(pvPlayer, playerAnim);
	SetAnimationDetour->EnableDetour();

#endif
}
will not work, because eax and edx is a scratch registers that can be changed by any function call. You should change this registers only immediately before jmp to SetAnimation.

Last edited by Asmodai; 02-08-2017 at 13:35.
Asmodai is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 01:13.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode