Hello!
I would appreciate if someone could convert this code from VB6 to VB.net.
Option Explicit
Private Declare Function GetWindowThreadProcessId Lib "user32" (ByVal hWnd As Long, lpdwProcessId As Long) As Long
Private Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long
Private Declare Function ReadProcessMemory Lib "kernel32" (ByVal hProcess As Long, ByVal lpBaseAddress As Any, ByRef lpBuffer As Any, ByVal nSize As Long, lpNumberOfBytesWritten As Long) As Long
Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Public Function Tibia_Hwnd() As Long
Dim tibiaclient As Long
tibiaclient = FindWindow("tibiaclient", vbNullString)
Tibia_Hwnd = tibiaclient
End Function
Public Function ReadMemory(Address As Long) As Long
Dim PID As Long, PHandle As Long
If Tibia_Hwnd = 0 Then Exit Function
GetWindowThreadProcessId Tibia_Hwnd, PID
PHandle = OpenProcess(&H10, False, PID)
If PHandle = 0 Then Exit Function
ReadProcessMemory PHandle, Address, ReadMemory, 4, 0&
CloseHandle PHandle
End Function
I get errors on
Private Declare Function ReadProcessMemory Lib "kernel32" (ByVal hProcess As Long, ByVal lpBaseAddress As Any, ByRef lpBuffer As Any, ByVal nSize As Long, ByVal lpNumberOfBytesWritten As Long) As Long
Thank you!