1 | Public Const PROCESS_ALL_ACCESS = &H1F0FFF
|
2 | Dim f1holder As Integer
|
3 | Dim timer_pos As Long
|
4 |
|
5 | 'API Declaration
|
6 | Public Declare Function GetWindowThreadProcessId Lib "user32" (ByVal hwnd As Long, lpdwProcessId As Long) As Long
|
7 | Public Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long
|
8 | Public Declare Function WriteProcessMemory Lib "kernel32" (ByVal hProcess As Long, ByVal lpBaseAddress As Any, lpBuffer As Any, ByVal nSize As Long, lpNumberOfBytesWritten As Long) As Long
|
9 | Public Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
|
10 | Public Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal Classname As String, ByVal WindowName As String) As Long
|
11 | Public Declare Function GetKeyPress Lib "user32" Alias "GetAsyncKeyState" (ByVal key As Long) As Integer
|
12 | Public Declare Function ReadProcessMem Lib "kernel32" Alias "ReadProcessMemory" (ByVal hProcess As Long, ByVal lpBaseAddress As Any, ByRef lpBuffer As Any, ByVal nSize As Long, lpNumberOfBytesWritten As Long) As Long
|
13 |
|
14 | Public Function WriteAByte(gamewindowtext As String, address As Long, value As Byte)
|
15 | Dim hwnd As Long
|
16 | Dim pid As Long
|
17 | Dim phandle As Long
|
18 | hwnd = FindWindow(vbNullString, gamewindowtext)
|
19 | If (hwnd = 0) Then
|
20 | MsgBox "The Game Is Not Working", vbCritical, "Error"
|
21 | End
|
22 | Exit Function
|
23 | End If
|
24 | GetWindowThreadProcessId hwnd, pid
|
25 | phandle = OpenProcess(PROCESS_ALL_ACCESS, False, pid)
|
26 | If (phandle = 0) Then
|
27 | MsgBox "Can't get ProcessId", vbCritical, "Error"
|
28 | Exit Function
|
29 | End If
|
30 | WriteProcessMemory phandle, address, value, 1, 0&
|
31 | CloseHandle hProcess
|
32 | End Function
|
33 |
|
34 | Public Function WriteAnInt(gamewindowtext As String, address As Long, value As Integer)
|
35 | Dim hwnd As Long
|
36 | Dim pid As Long
|
37 | Dim phandle As Long
|
38 | hwnd = FindWindow(vbNullString, gamewindowtext)
|
39 | If (hwnd = 0) Then
|
40 | MsgBox "The Game Is Not Working", vbCritical, "Error"
|
41 | End
|
42 | End If
|
43 | GetWindowThreadProcessId hwnd, pid
|
44 | phandle = OpenProcess(PROCESS_ALL_ACCESS, False, pid)
|
45 | If (phandle = 0) Then
|
46 | MsgBox "Can't get ProcessId", vbCritical, "Error"
|
47 | Exit Function
|
48 | End If
|
49 | WriteProcessMemory phandle, address, value, 2, 0&
|
50 | CloseHandle hProcess
|
51 | End Function
|
52 |
|
53 | Public Function WriteALong(gamewindowtext As String, address As Long, value As Long)
|
54 | Dim hwnd As Long
|
55 | Dim pid As Long
|
56 | Dim phandle As Long
|
57 | hwnd = FindWindow(vbNullString, gamewindowtext)
|
58 | If (hwnd = 0) Then
|
59 | MsgBox "The Game Is Not Working", vbCritical, "Error"
|
60 | End
|
61 | Exit Function
|
62 | End If
|
63 | GetWindowThreadProcessId hwnd, pid
|
64 | phandle = OpenProcess(PROCESS_ALL_ACCESS, False, pid)
|
65 | If (phandle = 0) Then
|
66 | MsgBox "Can't get ProcessId", vbCritical, "Error"
|
67 | Exit Function
|
68 | End If
|
69 | WriteProcessMemory phandle, address, value, 4, 0&
|
70 | CloseHandle hProcess
|
71 | End Function
|
72 |
|
73 | Public Function ReadAByte(gamewindowtext As String, address As Long, valbuffer As Byte)
|
74 | Dim hwnd As Long
|
75 | Dim pid As Long
|
76 | Dim phandle As Long
|
77 | hwnd = FindWindow(vbNullString, gamewindowtext)
|
78 | If (hwnd = 0) Then
|
79 | MsgBox "The Game Is Not Working", vbCritical, "Error"
|
80 | End
|
81 | Exit Function
|
82 | End If
|
83 | GetWindowThreadProcessId hwnd, pid
|
84 | phandle = OpenProcess(PROCESS_ALL_ACCESS, False, pid)
|
85 | If (phandle = 0) Then
|
86 | MsgBox "Can't get ProcessId", vbCritical, "Error"
|
87 | Exit Function
|
88 | End If
|
89 | ReadProcessMem phandle, address, valbuffer, 1, 0&
|
90 | CloseHandle hProcess
|
91 | End Function
|
92 |
|
93 | Public Function ReadAnInt(gamewindowtext As String, address As Long, valbuffer As Integer)
|
94 | Dim hwnd As Long
|
95 | Dim pid As Long
|
96 | Dim phandle As Long
|
97 | hwnd = FindWindow(vbNullString, gamewindowtext)
|
98 | If (hwnd = 0) Then
|
99 | MsgBox "The Game Is Not Working", vbCritical, "Error"
|
100 | End
|
101 | Exit Function
|
102 | End If
|
103 | GetWindowThreadProcessId hwnd, pid
|
104 | phandle = OpenProcess(PROCESS_ALL_ACCESS, False, pid)
|
105 | If (phandle = 0) Then
|
106 | MsgBox "Can't get ProcessId", vbCritical, "Error"
|
107 | Exit Function
|
108 | End If
|
109 | ReadProcessMem phandle, address, valbuffer, 2, 0&
|
110 | CloseHandle hProcess
|
111 | End Function
|
112 |
|
113 | Public Function ReadALong(gamewindowtext As String, address As Long, valbuffer As Long)
|
114 | Dim hwnd As Long
|
115 | Dim pid As Long
|
116 | Dim phandle As Long
|
117 | hwnd = FindWindow(vbNullString, gamewindowtext)
|
118 | If (hwnd = 0) Then
|
119 | MsgBox "The Game Is Not Working", vbCritical, "Error"
|
120 | End
|
121 | Exit Function
|
122 | End If
|
123 | GetWindowThreadProcessId hwnd, pid
|
124 | phandle = OpenProcess(PROCESS_ALL_ACCESS, False, pid)
|
125 | If (phandle = 0) Then
|
126 | MsgBox "Can't get ProcessId", vbCritical, "Error"
|
127 | Exit Function
|
128 | End If
|
129 | ReadProcessMem phandle, address, valbuffer, 4, 0&
|
130 | CloseHandle hProcess
|
131 | End Function
|