using CChat__AddEntry = void ( __thiscall * ) ( void * , void * , int , const char * , const char * , unsigned long , unsigned long ) ; CChat__AddEntry pOriginalFunction = nullptr ; void * SetCallHook ( uintptr_t HookAddress , void * DetourFunction ) { uintptr_t OriginalFunction = * reinterpret_cast ( HookAddress + 1 ) + HookAddress + 5 ; DWORD oldProt ; VirtualProtect ( reinterpret_cast ( HookAddress + 1 ) , sizeof ( uintptr_t ) , PAGE_READWRITE , & oldProt ) ; * reinterpret_cast ( HookAddress + 1 ) = reinterpret_cast ( DetourFunction ) - HookAddress - 5 ; VirtualProtect ( reinterpret_cast ( HookAddress + 1 ) , sizeof ( uintptr_t ) , oldProt , & oldProt ) ; return reinterpret_cast ( OriginalFunction ) ; } void __fastcall HOOK_AddEntry ( void * pChat , void * EDX , int nType , const char * szText , const char * szPrefix , unsigned long textColor , unsigned long prefixColor ) { pOriginalFunction ( pChat , EDX , nType , szText , szPrefix , textColor , prefixColor ) ; } if ( uintptr_t dwSAMP = reinterpret_cast ( GetModuleHandleA ( "samp.dll" ) ) ; dwSAMP != 0 ) { pOriginalFunction = reinterpret_cast ( SetCallHook ( dwSAMP + 0x67460 , & HOOK_AddEntry ) ) ; }