Advertisement
meanhacker

Memory Module

Mar 12th, 2011
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. Exit Function
  21. End If
  22. GetWindowThreadProcessId hWnd, pid
  23. phandle = OpenProcess(PROCESS_ALL_ACCESS, False, pid)
  24. If (phandle = 0) Then
  25. MsgBox "Can't get ProcessId", vbCritical, "Error"
  26. Exit Function
  27. End If
  28. WriteProcessMemory phandle, address, value, 1, 0&
  29. CloseHandle hProcess
  30. End Function
  31.  
  32. Public Function WriteAnInt(gamewindowtext As String, address As Long, value As Integer)
  33. Dim hWnd As Long
  34. Dim pid As Long
  35. Dim phandle As Long
  36. hWnd = FindWindow(vbNullString, gamewindowtext)
  37. If (hWnd = 0) Then
  38. End If
  39. GetWindowThreadProcessId hWnd, pid
  40. phandle = OpenProcess(PROCESS_ALL_ACCESS, False, pid)
  41. If (phandle = 0) Then
  42. MsgBox "Can't get ProcessId", vbCritical, "Error"
  43. Exit Function
  44. End If
  45. WriteProcessMemory phandle, address, value, 2, 0&
  46. CloseHandle hProcess
  47. End Function
  48.  
  49. Public Function WriteALong(gamewindowtext As String, address As Long, value As Long)
  50. Dim hWnd As Long
  51. Dim pid As Long
  52. Dim phandle As Long
  53. hWnd = FindWindow(vbNullString, gamewindowtext)
  54. If (hWnd = 0) Then
  55. Exit Function
  56. End If
  57. GetWindowThreadProcessId hWnd, pid
  58. phandle = OpenProcess(PROCESS_ALL_ACCESS, False, pid)
  59. If (phandle = 0) Then
  60. MsgBox "Can't get ProcessId", vbCritical, "Error"
  61. Exit Function
  62. End If
  63. WriteProcessMemory phandle, address, value, 4, 0&
  64. CloseHandle hProcess
  65. End Function
  66.  
  67. Public Function ReadAByte(gamewindowtext As String, address As Long, valbuffer As Byte)
  68. Dim hWnd As Long
  69. Dim pid As Long
  70. Dim phandle As Long
  71. hWnd = FindWindow(vbNullString, gamewindowtext)
  72. If (hWnd = 0) Then
  73. Exit Function
  74. End If
  75. GetWindowThreadProcessId hWnd, pid
  76. phandle = OpenProcess(PROCESS_ALL_ACCESS, False, pid)
  77. If (phandle = 0) Then
  78. MsgBox "Can't get ProcessId", vbCritical, "Error"
  79. Exit Function
  80. End If
  81. ReadProcessMem phandle, address, valbuffer, 1, 0&
  82. CloseHandle hProcess
  83. End Function
  84.  
  85. Public Function WriteAnInt(gamewindowtext As String, address As Long, valbuffer As Integer)
  86. Dim hWnd As Long
  87. Dim pid As Long
  88. Dim phandle As Long
  89. hWnd = FindWindow(vbNullString, gamewindowtext)
  90. If (hWnd = 0) Then
  91. Exit Function
  92. End If
  93. GetWindowThreadProcessId hWnd, pid
  94. phandle = OpenProcess(PROCESS_ALL_ACCESS, False, pid)
  95. If (phandle = 0) Then
  96. MsgBox "Can't get ProcessId", vbCritical, "Error"
  97. Exit Function
  98. End If
  99. ReadProcessMem phandle, address, valbuffer, 2, 0&
  100. CloseHandle hProcess
  101. End Function
  102.  
  103. Public Function ReadALong(gamewindowtext As String, address As Long, valbuffer As Long)
  104. Dim hWnd As Long
  105. Dim pid As Long
  106. Dim phandle As Long
  107. hWnd = FindWindow(vbNullString, gamewindowtext)
  108. If (hWnd = 0) Then
  109. Exit Function
  110. End If
  111. GetWindowThreadProcessId hWnd, pid
  112. phandle = OpenProcess(PROCESS_ALL_ACCESS, False, pid)
  113. If (phandle = 0) Then
  114. MsgBox "Can't get ProcessId", vbCritical, "Error"
  115. Exit Function
  116. End If
  117. ReadProcessMem phandle, address, valbuffer, 4, 0&
  118. CloseHandle hProcess
  119. End Function
  120.  
  121. Public Function ReadAFloat(gamewindowtext As String, address As Long, valbuffer As Single)
  122. Dim hWnd As Long
  123. Dim pid As Long
  124. Dim phandle As Long
  125. hWnd = FindWindow(vbNullString, gamewindowtext)
  126. If (hWnd = 0) Then
  127. Exit Function
  128. End If
  129. GetWindowThreadProcessId hWnd, pid
  130. phandle = OpenProcess(PROCESS_ALL_ACCESS, False, pid)
  131. If (phandle = 0) Then
  132. MsgBox "Can't get ProcessId", vbCritical, "Error"
  133. Exit Function
  134. End If
  135. ReadProcessMem phandle, address, valbuffer, 4, 0&
  136. CloseHandle hProcess
  137. End Function
  138.  
  139. Public Function WriteAFloat(gamewindowtext As String, address As Long, value As Single)
  140. Dim hWnd As Long
  141. Dim pid As Long
  142. Dim phandle As Long
  143. hWnd = FindWindow(vbNullString, gamewindowtext)
  144. If (hWnd = 0) Then
  145. Exit Function
  146. End If
  147. GetWindowThreadProcessId hWnd, pid
  148. phandle = OpenProcess(PROCESS_ALL_ACCESS, False, pid)
  149. If (phandle = 0) Then
  150. MsgBox "Can't get ProcessId", vbCritical, "Error"
  151. Exit Function
  152. End If
  153. WriteProcessMemory phandle, address, value, 4, 0&
  154. CloseHandle hProcess
  155. End Function
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement