Fixed Crit hits sigs for Windows and cleaned up the code somewhat

--HG--
extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%402154
This commit is contained in:
Matt Woodrow 2008-05-18 00:51:51 +00:00
parent b90386276f
commit f7613f80f1
2 changed files with 22 additions and 31 deletions

View File

@ -165,13 +165,11 @@ bool CriticalHitManager::CreateCriticalMeleeDetour()
//If TempDetour returns non-zero we want to load something into eax and return this value //If TempDetour returns non-zero we want to load something into eax and return this value
//IA32_Test_Rm_Reg(jit, eax, eax, something); //test eax, eax
jit->write_ubyte(0x85); IA32_Test_Rm_Reg(jit, REG_EAX, REG_EAX, MOD_REG);
jit->write_ubyte(0xC0);
//JNZ critical_callback+50 //jnz _skip
jit->write_ubyte(0x75); jitoffs_t jmp = IA32_Jump_Cond_Imm8(jit, CC_NZ, 0);
jit->write_ubyte(50-((jit->outptr+1)-jit->outbase));
int callbyte = -1; int callbyte = -1;
/* The callbyte should return the nth byte (starting from 1) in the backup bytes - Should be an 0xE8 (call) */ /* The callbyte should return the nth byte (starting from 1) in the backup bytes - Should be an 0xE8 (call) */
@ -212,18 +210,15 @@ bool CriticalHitManager::CreateCriticalMeleeDetour()
i += 4; i += 4;
} }
/* Return to the original function */ /* Return to the original function */
call = IA32_Jump_Imm32(jit, 0); call = IA32_Jump_Imm32(jit, 0);
IA32_Write_Jump32_Abs(jit, call, (unsigned char *)melee_address + melee_restore.bytes); IA32_Write_Jump32_Abs(jit, call, (unsigned char *)melee_address + melee_restore.bytes);
wr.outbase = (jitcode_t)melee_callback+50; //_skip:
wr.outptr = wr.outbase; //mov eax, [g_returnvalue]
//ret
//copy g_returnvalue into eax IA32_Send_Jump8_Here(jit, jmp);
jit->write_ubyte(0xA1); IA32_Mov_Eax_Mem(jit, (jit_int32_t)&g_returnvalue);
jit->write_uint32((jit_uint32_t)&g_returnvalue);
IA32_Return(jit); IA32_Return(jit);
return true; return true;
@ -280,13 +275,11 @@ bool CriticalHitManager::CreateCriticalKnifeDetour()
//If TempDetour returns non-zero we want to load something into eax and return this value //If TempDetour returns non-zero we want to load something into eax and return this value
//IA32_Test_Rm_Reg(jit, eax, eax, something); //test eax, eax
jit->write_ubyte(0x85); IA32_Test_Rm_Reg(jit, REG_EAX, REG_EAX, MOD_REG);
jit->write_ubyte(0xC0);
//JNZ critical_callback+50 //jnz _skip
jit->write_ubyte(0x75); jitoffs_t jmp = IA32_Jump_Cond_Imm8(jit, CC_NZ, 0);
jit->write_ubyte(50-((jit->outptr+1)-jit->outbase));
/* Patch old bytes in */ /* Patch old bytes in */
for (size_t i=0; i<knife_restore.bytes; i++) for (size_t i=0; i<knife_restore.bytes; i++)
@ -298,13 +291,11 @@ bool CriticalHitManager::CreateCriticalKnifeDetour()
call = IA32_Jump_Imm32(jit, 0); call = IA32_Jump_Imm32(jit, 0);
IA32_Write_Jump32_Abs(jit, call, (unsigned char *)knife_address + knife_restore.bytes); IA32_Write_Jump32_Abs(jit, call, (unsigned char *)knife_address + knife_restore.bytes);
wr.outbase = (jitcode_t)knife_callback+50; //_skip:
wr.outptr = wr.outbase; //mov eax, [g_returnvalue]
//ret
//copy g_returnvalue into eax IA32_Send_Jump8_Here(jit, jmp);
jit->write_ubyte(0xA1); IA32_Mov_Eax_Mem(jit, (jit_int32_t)&g_returnvalue);
jit->write_uint32((jit_uint32_t)&g_returnvalue);
IA32_Return(jit); IA32_Return(jit);
return true; return true;

View File

@ -32,13 +32,13 @@
{ {
"library" "server" "library" "server"
"linux" "@_ZN18CTFWeaponBaseMelee26CalcIsAttackCriticalHelperEv" "linux" "@_ZN18CTFWeaponBaseMelee26CalcIsAttackCriticalHelperEv"
"windows" "\x83\xEC\x08\x56\xE8\x2A\x2A\x2A\x2A\x8B\xF0\x85\xF6" "windows" "\x83\xEC\x08\x56\x57\x8B\xF1\xE8\x2A\x2A\x2A\x2A\x8B\xF8"
} }
"CalcCriticalKnife" "CalcCriticalKnife"
{ {
"library" "server" "library" "server"
"linux" "@_ZN8CTFKnife26CalcIsAttackCriticalHelperEv" "linux" "@_ZN8CTFKnife26CalcIsAttackCriticalHelperEv"
"windows" "\x33\xC0\x83\xB9\x74\x12\x00\x00\x01\x0F\x94\xC0\xC3" "windows" "\x33\xC0\x83\xB9\xF4\x12\x00\x00\x01\x0F\x94\xC0\xC3"
} }
} }
@ -57,13 +57,13 @@
"CalcCriticalMeleeBackup" "CalcCriticalMeleeBackup"
{ {
"linux" "7" "linux" "7"
"windows" "9" "windows" "7"
} }
/* The byte number (starting from 1) of the call (0xE8) byte or -1 if none */ /* The byte number (starting from 1) of the call (0xE8) byte or -1 if none */
"CalcCriticalMeleeCallByte" "CalcCriticalMeleeCallByte"
{ {
"linux" "-1" "linux" "-1"
"windows" "5" "windows" "-1"
} }
"CalcCriticalKnifeBackup" "CalcCriticalKnifeBackup"
{ {