-- lua code local callback = ffi . cast ( 'void(__thiscall *)(void *_this, char *killer, char *killed, uint32_t clKiller, uint32_t clKilled, uint8_t reason)' , hook ) local detour_addr = tonumber ( ffi . cast ( 'uintptr_t' , callback ) ) local hook_addr = getModuleHandle ( 'samp.dll' ) + 0x2B2A3B memory . setint8 ( hook_addr , 0xE8 , true ) memory . setuint32 ( hook_addr + 1 , detour_addr - hook_addr - 5 , true )
// c++ code void ( __thiscall * callback ) ( void * , char * , char * , uint32_t , uint32_t , uint8_t ) = ( void ( __thiscall * ) ( void * _this , char * killer , char * killed , uint32_t clKiller , uint32_t clKilled , uint8_t reason ) ) ( hook ) ; uintptr_t detour_addr = ( uintptr_t ) callback ; uintptr_t hook_addr = ( uintptr_t ) GetModuleHandleA ( "samp.dll" ) + 0x2B2A3B ; * reinterpret_cast ( hook_addr ) = ( INT8 ) 0xE8 ; * reinterpret_cast ( hook_addr + 1 ) = detour_addr - hook_addr - 5 ;
* reinterpret_cast ( hook_addr ) = ( INT8 ) 0xE8 ;