Code:
Imports System.Text
Imports System.Runtime.InteropServices
Public Class Form1
Public Declare Function ReadProcessMemory Lib "kernel32" (ByVal hProcess As IntPtr, ByVal lpBaseAddress As IntPtr, <[In](), Out()> ByVal buffer As Byte(), ByVal size As UInt32, ByRef lpNumberOfBytesRead As IntPtr) As Int32
Public Declare Function WriteProcessMemory Lib "kernel32" (ByVal hProcess As IntPtr, ByVal lpBaseAddress As IntPtr, ByVal lpBuffer As Byte(), ByVal nSize As System.UInt32, <Out()> ByRef lpNumberOfBytesWritten As IntPtr) As Boolean
Private Function ReadBytes(ByVal ProcessHandle As IntPtr, ByVal memAdr As Long, ByVal bytesToRead As UInteger) As Byte()
Dim BytesRead As IntPtr
Dim Buffer As Byte() = New Byte(bytesToRead - 1) {}
ReadProcessMemory(ProcessHandle, New IntPtr(memAdr), Buffer, bytesToRead, BytesRead)
Return Buffer
End Function
Public Function WriteBytes(ByVal ProcessHandle As IntPtr, ByVal memAdr As Long, ByVal bytes As Byte(), ByVal length As UInteger) As Boolean
Dim BytesWritten As IntPtr
Dim Result As Integer = WriteProcessMemory(ProcessHandle, New IntPtr(memAdr), bytes, length, BytesWritten)
Return Result <> 0
End Function
Public Function ReadInt32(ByVal ProcessHandle As IntPtr, ByVal memAdr As Int32) As Integer
Return BitConverter.ToInt32(ReadBytes(ProcessHandle, memAdr, 4), 0)
End Function
Public Function AVA(ByVal ProcessHandle As IntPtr, ByVal Address As Integer, ByVal Offsets As Integer(), ByVal Value As Byte()) As Boolean
Try
Dim Current As Integer = Address
For i As Integer = 1 To Offsets.Length
Current = ReadInt32(ProcessHandle, Current) + Offsets(i - 1)
Next
WriteBytes(ProcessHandle, Current, Value, Value.Length)
Return True
Catch ex As Exception
Return False
End Try
End Function
Public Shared Function StrToByteArray(str As String) As Byte()
Dim UE As UnicodeEncoding = New UnicodeEncoding()
Return UE.GetBytes(str)
End Function
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Try
Dim AVAProcesses As Process() = Process.GetProcessesByName("AVA")
If AVAProcesses.Length > 0 Then
Dim Mem As Boolean = AVA(AVAProcesses(0).Handle, AVAProcesses(0).MainModule.BaseAddress + &H2406774, {&H90, &H0}, StrToByteArray(TextBox1.Text + vbNullChar))
If Mem = True Then
MsgBox("Success", 64, "Try")
Else
MsgBox("Failed", 64, "Try")
End If
Else
MsgBox("Process not found", 64, "Try")
End If
Catch ex As Exception
MsgBox("Error", 64, "Catch")
End Try
End Sub
End Class