So I appear to be stuck while trying to get this detour to work. Here is my game data:
PHP Code:
"Games"
{
"csgo"
{
"Signatures"
{
"FireBullet"
{
"library" "server"
"windows" "\x53\x8B\xDC\x83\xEC\x08\x83\xE4\xF0\x83\xC4\x04\x55\x8B\x6B\x04\x89\x6C\x24\x04\x8B\xEC\x81\xEC\x2A\x05\x00\x00\x66\x0F\x6E\x43\x24"
"linux" "@_ZN9CCSPlayer10FireBulletE6"
}
"FX_FireBullets"
{
"library" "server"
"windows" "\x55\x8B\xEC\x83\xE4\xF8\x81\xEC\xC0\x01\x00\x00\x89\x54\x24\x08"
"linux" "@_Z14FX_FireBulletsitRK6"
}
}
}
}
I was able to construct the FX_FireBullets() signature on my own, but someone had to help me create the signature for CCSPlayer::FireBullet() because I could not seem to get it. Here are the detours that I'm working with:
PHP Code:
DETOUR_DECL_MEMBER12(DetourFireBullet, void, Vector, a1, QAngle const &, a2, float, a3, float, a4, int, a5, int, a6, int, a7, float, a8, CBaseEntity *, a9, bool, a10, float, a11, float, a12)
{
//int client = gamehelpers->EntityToBCompatRef(reinterpret_cast<CBaseEntity *>(this));
//cell_t result = Pl_Continue;
//g_pFireBullet->PushCell(client);
//g_pFireBullet->Execute(&result);
//DETOUR_MEMBER_CALL(DetourFireBullet)(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12);
return;
}
DETOUR_DECL_STATIC12(DetourFXFireBullets, void, int, a1, unsigned short, a2, Vector const&, a3, QAngle const&, a4, CSWeaponID, a5, int, a6, int, a7, float, a8, float, a9, float, a10, float, a11, WeaponSound_t, a12)
{
cell_t result = Pl_Continue;
g_pFireBullet->PushCell(0);
g_pFireBullet->Execute(&result);
//DETOUR_STATIC_CALL(DetourFXFireBullets)(a1, a2, Vector(0, 0, 0), QAngle(0, 0, 0), a5, a6, a7, a8, a9, a10, a11, a12);
return;
}
Even with everything commented out, the detour for CCSPlayer::FireBullet() crashes when called. I get the following error:
Run-Time Check Failure #0 - The value of ESP was not properly saved across a function call. This is usually a result of calling a function declared with one calling convention with a function pointer declared with a different calling convention.
The detour for FX_FireBullets(), which is the only function that references CCSPlayer::FireBullet(), works fine, except if I uncomment the static call. It crashes the server as well, but doesn't give me any error information. Also, with the static call commented out, it still appears that the original FX_FireBullets() is being called, which was not the behavior I was expecting.
Any help moving forward on this is greatly appreciated. Thanks.