Перейти к содержанию

Что не так? VB.net Cheat Engine Tutorial Step 8


Рекомендуемые сообщения

image.png


Imports System.Text
Imports System.Runtime.InteropServices

Public Class Form1
<DllImport("kernel32.dll")> _
Public Shared Function WriteProcessMemory( _
ByVal hProcess As IntPtr, _
ByVal IpBaseAdress As IntPtr, _
ByVal IpBuffer As Byte(), _
ByVal nSize As UInt32, _
ByRef IpNumberOfBytesWritten As UInt32) As Boolean
End Function

<DllImport("kernel32.dll", SetLastError:=True)> _
Public Shared Function ReadProcessMemory( _
ByVal hProcess As IntPtr, _
ByVal lpBaseAddress As IntPtr, _
<Out()> ByVal lpBuffer() As Byte, _
ByVal dwSize As Integer, _
ByRef lpNumberOfBytesRead As Integer) As Boolean
End Function

Private Function FindAddress(ByVal pHandle As IntPtr, ByVal BaseAddress As IntPtr, ByVal StaticPointer As IntPtr, ByVal Offsets() As IntPtr) As IntPtr
Dim tmp(IntPtr.Size - 1) As Byte
Dim Address As IntPtr = BaseAddress
If IntPtr.Size = 4 Then
Address = New IntPtr(Address.ToInt32 + StaticPointer.ToInt32)
Else
Address = New IntPtr(Address.ToInt64 + StaticPointer.ToInt64)
End If
For i As Integer = 0 To Offsets.Length - 1
ReadProcessMemory(pHandle, Address, tmp, IntPtr.Size, 0)
If IntPtr.Size = 4 Then
Address = BitConverter.ToInt32(tmp, 0) + Offsets(i).ToInt32()
Else
Address = BitConverter.ToInt64(tmp, 0) + Offsets(i).ToInt64()
End If
Next
Return Address
End Function


Public Shared Function StrToByteArray(ByVal str As String) As Byte()
Dim encoding As New System.Text.ASCIIEncoding()
Return encoding.GetBytes(str)
End Function

Dim hProcess As Process() = Process.GetProcessesByName("Tutorial-i386")

Dim Written As Boolean = False

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim pID As IntPtr = hProcess(0).Handle
Dim base As IntPtr = hProcess(0).MainModule.BaseAddress
' Our static pointer...
Dim sptr As IntPtr = &H2903B0
' And our offsets...
Dim offsets() As IntPtr = {&HC, &H14, &H0, &H18}
Dim addr As IntPtr = FindAddress(pID, base, sptr, offsets)
Try
WriteProcessMemory(hProcess(0).Handle, addr, New Byte() {0}, 99, 0)
WriteProcessMemory(hProcess(0).Handle, addr, не доделано (5 тыщ), 99, 0)
MsgBox("SUCCESS")
Catch ex As Exception
MsgBox("ERROR")
End Try
End Sub

End Class

Ссылка на комментарий
Поделиться на другие сайты

×
×
  • Создать...

Важная информация

Находясь на нашем сайте, Вы автоматически соглашаетесь соблюдать наши Условия использования.