-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgtasa_functionhooks.go
executable file
·58 lines (45 loc) · 1.59 KB
/
gtasa_functionhooks.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
package main
/*
// Shared definitions
#include <windows.h>
// Hooked Functions
typedef void (*fpRenderScene)(void);
extern fpRenderScene ogrenderscene;
void RenderScene(void);
void RenderSceneFirst(void);
typedef int (*fpRsEventHandler)(int, void*);
extern fpRsEventHandler ogrseventhandler;
int RsEventHandler(int event, void* param);
typedef LRESULT CALLBACK(*fpMainWndProc)(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
extern fpMainWndProc ogmainwndproc;
LRESULT CALLBACK myMainWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
*/
import "C"
import (
. "gtasamod/subhook"
)
const renderaddress = uintptr(0x53DF40)
var hookrender = SubhookTypeonly()
func SetRenderFuncFirstTime() {
hookrender = SubhookNew(renderaddress, C.RenderSceneFirst)
SubhookInstall(hookrender)
C.ogrenderscene = (C.fpRenderScene)(SubhookGetTrampoline(hookrender))
}
func SetRenderFuncLooping() {
SubhookRemove(hookrender)
SubhookFree(hookrender)
hookrender = SubhookNew(renderaddress, C.RenderScene)
SubhookInstall(hookrender)
C.ogrenderscene = (C.fpRenderScene)(SubhookGetTrampoline(hookrender))
}
func SetupFunctionsHooks() {
SetRenderFuncFirstTime()
const menurenderaddress = uintptr(0x619B60)
hookeventhandler := SubhookNew(menurenderaddress, C.RsEventHandler)
SubhookInstall(hookeventhandler)
C.ogrseventhandler = (C.fpRsEventHandler)(SubhookGetTrampoline(hookeventhandler))
const mainwndprocaddress = uintptr(0x747EB0)
hookmainwndproc := SubhookNew(mainwndprocaddress, C.myMainWndProc)
SubhookInstall(hookmainwndproc)
C.ogmainwndproc = (C.fpMainWndProc)(SubhookGetTrampoline(hookmainwndproc))
}