- 40
- 2
код че:
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<uintptr_t*>(HookAddress + 1) + HookAddress + 5;
DWORD oldProt;
VirtualProtect(reinterpret_cast<void*>(HookAddress + 1), sizeof(uintptr_t), PAGE_READWRITE, &oldProt);
*reinterpret_cast<uintptr_t*>(HookAddress + 1) = reinterpret_cast<uintptr_t>(DetourFunction) - HookAddress - 5;
VirtualProtect(reinterpret_cast<void*>(HookAddress + 1), sizeof(uintptr_t), oldProt, &oldProt);
return reinterpret_cast<void*>(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<uintptr_t>(GetModuleHandleA("samp.dll")); dwSAMP != 0) {
pOriginalFunction = reinterpret_cast<CChat__AddEntry>(SetCallHook(dwSAMP + 0x67460, &HOOK_AddEntry));
}
пытаюсь хукнуть CChat__AddEntry, чтоб сменить текст samp started бла бла бла, но игра после запуска просто крашится