leer memoria

Iniciado por mariana_87, 29 Octubre 2009, 04:47 AM

0 Miembros y 1 Visitante están viendo este tema.

mariana_87

hola yo tengo un codigo que lo hice en vb 6, me gustaria pasarlo a visual .net estuve intentando pero no me funciona

este es el codigo

en un modulo
Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long
Declare Function WriteProcessMemory Lib "kernel32" (ByVal hProcess As Long, ByVal lpBaseAddress As Any, lpBuffer As Any, ByVal nSize As Long, lpNumberOfBytesWritten As Long) As Long
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
Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Declare Function GetWindowThreadProcessId Lib "user32" (ByVal hWnd As Long, lpdwProcessId As Long) As Long
Declare Function GetCurrentProcess Lib "kernel32" () As Long

Global Const SYNCHRONIZE As Long = &H100000
Global Const STANDARD_RIGHTS_REQUIRED As Long = &HF0000
Global Const PROCESS_ALL_ACCESS As Long = (STANDARD_RIGHTS_REQUIRED Or SYNCHRONIZE Or &HFFF)


Declare Function GetAsyncKeyState Lib "user32.dll" (ByVal nVirtKey As Long) As Integer


Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)

Public WindowHandle As Long
Public ProcessID As Long
Public ProcessHandle As Long

Public Function GetGTAProcess(fProcessName As String) As Boolean

WindowHandle = FindWindow(vbNullString, fProcessName)
If (WindowHandle = 0) Then
  GetGTAProcess = False
  Exit Function
  End If

GetWindowThreadProcessId WindowHandle, ProcessID
ProcessHandle = OpenProcess(PROCESS_ALL_ACCESS, False, ProcessID)
If (ProcessHandle = 0) Then
  GetGTAProcess = False
  Exit Function
  End If

GetGTAProcess = True

End Function

Public Function SAptrPlayer() As Long
SAptrPlayer = ReadLong(&HB6F5F0)
End Function

Public Function ReadDMASingle(Address As Long, Offset As Long) As Single
ReadProcessMemory ProcessHandle, Address + Offset, ReadDMASingle, 4&, 0&
End Function

Public Function ReadLong(Address As Long) As Long
ReadProcessMemory ProcessHandle, Address, ReadLong, 4&, 0&
End Function



y despues en el formulario

Private Sub Timer1_Timer()
Text1.Text = ReadDMASingle(SAptrPlayer, &H540&)
End Sub

Private Sub Timer3_Timer()
GetGTAProcess ("GTA:SA:MP")
End Sub


gracias desde ya


MANULOMM

que es lo que quieres hacer exactamente?

En vb 6.0 implementabas API's para hacer tareas de este tipo, con el framework lo mas seguro es que ya haya una clase que te libre de esa complejidad y te de la abstracccion necesaria para ocuparte de lo que realmente importa.

Atentamente,

Juan Manuel Lombana
Medellín - Colombia


mariana_87

Cita de: MANULOMM en 29 Octubre 2009, 05:37 AM
que es lo que quieres hacer exactamente?

En vb 6.0 implementabas API's para hacer tareas de este tipo, con el framework lo mas seguro es que ya haya una clase que te libre de esa complejidad y te de la abstracccion necesaria para ocuparte de lo que realmente importa.

Atentamente,

Juan Manuel Lombana
Medellín - Colombia

hola yo quiero obtener la vida del player que la muestre en el textbox1