
Tengo un problema estoy haciendo un programa que extrae información de la memoria de un proceso con el Api de Windows (ReadProcessMemory) pero me dice que no tengo permisos para escribir en la memoria aqui está el codigo:
Las funciones API que use:
Código:
Está es la funcion que hice para leer la informaciónPrivate Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long Private Declare Function GetWindowThreadProcessId Lib "user32" (ByVal hwnd As Long, ByVal 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 Object, ByVal lpBuffer As Object, ByVal nSize As Long, ByVal lpNumberOfBytesWritten As Long) As Long Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long Private Declare Function WriteProcessMemory Lib "kernel32" (ByVal hProcess As Long, ByVal lpBaseAddress As Object, ByVal lpBuffer As Object, ByVal nSize As Long, ByVal lpNumberOfBytesWritten As Long) As Long
Código:
Y está la utilización de dicha funciónPrivate Function Memory(ByVal hwnd As Long, ByVal Address As Long, ByVal Value As Byte, ByVal Process As Integer) Dim pid As Long Dim phandle As Long GetWindowThreadProcessId(hwnd, pid) phandle = OpenProcess(&H1F0FFF, False, pid) If Process = 1 Then ReadProcessMemory(phandle, Address, Value, 1, 0&) If Process = 2 Then WriteProcessMemory(phandle, Address, Value, 1, 0&) MsgBox(Err.LastDllError) CloseHandle(phandle) Memory = Value End Function
Código:
Gracias de antemano Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim hwnd As Long Dim lngExp As Long hwnd = FindWindow(vbNullString, "Tibia ") If (hwnd = 0) Then MsgBox("No se encuentra la ventana!") Exit Sub End If lngExp = Memory(hwnd, &H4903D0, 4, 1) MyMsgBox(lngExp) End Sub
