Quote:
Originally Posted by Arkshine
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.