Advertisement
Guest User

Untitled

a guest
May 29th, 2017
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 1.71 KB | None | 0 0
  1. Private Declare Function WriteProcessMemory Lib "kernel32" (ByVal hProcess As Integer, ByVal lpBaseAddress As Integer, ByRef lpBuffer As Long, ByVal nSize As Integer, ByRef lpNumberOfBytesWritten As Integer) As Long
  2.     Private Declare Auto Function ReadProcessMemory Lib "kernel32" (ByVal hProcess As Integer, ByVal lpBaseAddress As Integer, ByRef lpBuffer As Long, ByVal nSize As Integer, ByRef lpNumberOfBytesWritten As Integer) As Long
  3.     Private Declare Function VirtualProtectEx Lib "kernel32" (ByVal hProcess As Long, ByRef lpAddress As Object, ByVal dwSize As Long, ByVal flNewProtect As Long, ByRef lpflOldProtect As Long) As Long
  4.  
  5.     Public Function GetValue(ByVal ProcessHandle As IntPtr, ByVal Address As Integer)
  6.         Dim Buffer As Long
  7.         Dim convert As Long
  8.         Dim byte_array0 As Byte()
  9.  
  10.         Try
  11.             ReadProcessMemory(ProcessHandle, Address, Buffer, 4, 0)
  12.         Catch ex As Exception
  13.             MsgBox(ex.Message, MsgBoxStyle.Critical, "Error!")
  14.             Return False
  15.         End Try
  16.  
  17.         byte_array0 = BitConverter.GetBytes(Buffer)
  18.         convert = BitConverter.ToInt64(byte_array0, 0)
  19.  
  20.         Return convert
  21.     End Function
  22.  
  23.     Public Function WriteValue(ByVal ProcessHandle As IntPtr, ByVal Address As Integer, ByVal Value As Long)
  24.         Try
  25.             VirtualProtectEx(ProcessHandle, Address, 4, &H4&, 0)
  26.             WriteProcessMemory(ProcessHandle, Address, Value, 4, 0)
  27.         Catch ex As Exception
  28.             MsgBox(ex.Message, MsgBoxStyle.Critical, "Error!")
  29.             Return False
  30.         End Try
  31.  
  32.         Return True
  33.     End Function
  34.  
  35.  
  36.  
  37. Dim Buffer As object '''<<<correction
  38.         Dim convert As Long
  39.         Dim byte_array0 As Byte()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement