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:
@@ -165,13 +165,11 @@ bool CriticalHitManager::CreateCriticalMeleeDetour()
|
||||
|
||||
//If TempDetour returns non-zero we want to load something into eax and return this value
|
||||
|
||||
//IA32_Test_Rm_Reg(jit, eax, eax, something);
|
||||
jit->write_ubyte(0x85);
|
||||
jit->write_ubyte(0xC0);
|
||||
//test eax, eax
|
||||
IA32_Test_Rm_Reg(jit, REG_EAX, REG_EAX, MOD_REG);
|
||||
|
||||
//JNZ critical_callback+50
|
||||
jit->write_ubyte(0x75);
|
||||
jit->write_ubyte(50-((jit->outptr+1)-jit->outbase));
|
||||
//jnz _skip
|
||||
jitoffs_t jmp = IA32_Jump_Cond_Imm8(jit, CC_NZ, 0);
|
||||
|
||||
int callbyte = -1;
|
||||
/* 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;
|
||||
}
|
||||
|
||||
|
||||
/* Return to the original function */
|
||||
call = IA32_Jump_Imm32(jit, 0);
|
||||
IA32_Write_Jump32_Abs(jit, call, (unsigned char *)melee_address + melee_restore.bytes);
|
||||
|
||||
wr.outbase = (jitcode_t)melee_callback+50;
|
||||
wr.outptr = wr.outbase;
|
||||
|
||||
//copy g_returnvalue into eax
|
||||
jit->write_ubyte(0xA1);
|
||||
jit->write_uint32((jit_uint32_t)&g_returnvalue);
|
||||
|
||||
//_skip:
|
||||
//mov eax, [g_returnvalue]
|
||||
//ret
|
||||
IA32_Send_Jump8_Here(jit, jmp);
|
||||
IA32_Mov_Eax_Mem(jit, (jit_int32_t)&g_returnvalue);
|
||||
IA32_Return(jit);
|
||||
|
||||
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
|
||||
|
||||
//IA32_Test_Rm_Reg(jit, eax, eax, something);
|
||||
jit->write_ubyte(0x85);
|
||||
jit->write_ubyte(0xC0);
|
||||
//test eax, eax
|
||||
IA32_Test_Rm_Reg(jit, REG_EAX, REG_EAX, MOD_REG);
|
||||
|
||||
//JNZ critical_callback+50
|
||||
jit->write_ubyte(0x75);
|
||||
jit->write_ubyte(50-((jit->outptr+1)-jit->outbase));
|
||||
//jnz _skip
|
||||
jitoffs_t jmp = IA32_Jump_Cond_Imm8(jit, CC_NZ, 0);
|
||||
|
||||
/* Patch old bytes in */
|
||||
for (size_t i=0; i<knife_restore.bytes; i++)
|
||||
@@ -298,13 +291,11 @@ bool CriticalHitManager::CreateCriticalKnifeDetour()
|
||||
call = IA32_Jump_Imm32(jit, 0);
|
||||
IA32_Write_Jump32_Abs(jit, call, (unsigned char *)knife_address + knife_restore.bytes);
|
||||
|
||||
wr.outbase = (jitcode_t)knife_callback+50;
|
||||
wr.outptr = wr.outbase;
|
||||
|
||||
//copy g_returnvalue into eax
|
||||
jit->write_ubyte(0xA1);
|
||||
jit->write_uint32((jit_uint32_t)&g_returnvalue);
|
||||
|
||||
//_skip:
|
||||
//mov eax, [g_returnvalue]
|
||||
//ret
|
||||
IA32_Send_Jump8_Here(jit, jmp);
|
||||
IA32_Mov_Eax_Mem(jit, (jit_int32_t)&g_returnvalue);
|
||||
IA32_Return(jit);
|
||||
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user