ryanm2711 0 Posted January 19 Posted January 19 Hey guys I was just wondering how I would hook into the game's native functions and alter it's behaviour globally? I want to hook into the TASK_KNOCKED_OUT native and make it so the third parameter dictating whether or not the knockout is permanent to always be false - resulting in infinite knockouts on the same pedestrian, in theory. I have written the code to hook into the native, and I have got MinHook - but I couldn't find anywhere that has got information on the address for the native table which points to said function. This is my first time doing this sort of thing, so I am not particularly confident in finding it myself through disassembling, but if needed - some pointers on where to start would be appreciated 🙂 Code: #include "script.h" typedef void(*Original_TASK_KNOCKED_OUT)(Ped ped, float duration, BOOL isPermanent); Original_TASK_KNOCKED_OUT Original_TASK_KNOCKED_OUT_Func = nullptr; void Hooked_TASK_KNOCKED_OUT(Ped ped, float duration, BOOL isPermanent) { isPermanent = false; // Always wake up // Call the original function invoke<void>(0xF90427F00A495A28, ped, duration, isPermanent); } void* GetNativeFunctionAddress() { return reinterpret_cast<void*>(invoke<void*>(0x7F8C3BE3E7A910C7)); } void ReplaceNativeFunction() { // Hook the function } void main() { while (true) { WAIT(0); } } void ScriptMain() { srand(GetTickCount()); main(); } Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.