m_zi
دوشنبه 03 تیر 1387, 11:53 صبح
با سلام
  من آدرس يك خانه از حافظه را دارم چه جوري مي توانم محتويات آن خانه حافظه را بدست آورم .ممنون مي شوم راهنماييم كنيد .
ممنون
r0ot$harp
دوشنبه 03 تیر 1387, 12:49 عصر
دوست عزیز این فانکشن هایی که نوشتم بدرت می خوره :
WriteLong - ReadMemory - ReadText
Private Const PROCESS_ALL_ACCESS = &H1F0FFF
Dim f1holder As Integer
Dim AddressM As Long
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 WriteProcessMemory _
                Lib "kernel32" (ByVal hProcess As Long, _
                                ByVal lpBaseAddress As Any, _
                                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 Classname As String, _
                                     ByVal WindowName As String) As Long
Private Declare Function ReadProcessMem _
                Lib "kernel32" _
                Alias "ReadProcessMemory" (ByVal hProcess As Long, _
                                           ByVal lpBaseAddress As Any, _
                                           ByRef lpBuffer As Any, _
                                           ByVal nSize As Long, _
                                           lpNumberOfBytesWritten As Long) As Long
 
Private Function ReadText(lngAddress As Long) As String
    Dim hwnd, process_handle, process_id As Long
    Dim data         As Byte
    Dim current_byte As Integer
 
    data = 0
    current_byte = 0
    hwnd = FindWindow(vbNullString, "Form1")
    If (hwnd <> 0) Then
        GetWindowThreadProcessId hwnd, process_id
        process_handle = OpenProcess(PROCESS_ALL_ACCESS, False, process_id)
        Do
            ReadProcessMem process_handle, (lngAddress + current_byte), data, 1, 0&
            ReadText = ReadText & Chr(data)
            current_byte = current_byte + 1
        Loop While ((ReadMemory(lngAddress + current_byte, 1)) <> 0)
        CloseHandle process_handle
    End If
End Function
Private Function ReadMemory(lngAddress As Long, ByRef intSize As Integer) As Long
    Dim hwnd, process_handle, process_id As Long
    hwnd = FindWindow(vbNullString, "Form1")
    If (hwnd <> 0) Then
        GetWindowThreadProcessId hwnd, process_id
        process_handle = OpenProcess(PROCESS_ALL_ACCESS, False, process_id)
        If (intSize > 4) Or (intSize < 1) Then
            intSize = 4
        End If
        ReadProcessMem process_handle, lngAddress, ReadMemory, intSize, 0&
        CloseHandle process_handle
    End If
End Function
Private Sub Form_Load()
    Text1.Text = ReadText(&HE00710)
End Sub
Private Function WriteLong(GameText As String, Adress As Long, Value As Long)
    'WriteLong "Spider", &H1012F60, 1800
    Dim hwnd    As Long
    Dim pid     As Long
    Dim phandle As Long
    hwnd = FindWindow(vbNullString, GameText)
    If (hwnd = 0) Then
        MsgBox "Run the game first", vbCritical, "Error"
        Exit Function
    End If
    GetWindowThreadProcessId hwnd, pid
    phandle = OpenProcess(PROCESS_ALL_ACCESS, False, pid)
    If (phandle = 0) Then
        MsgBox "Can't get ProcessId", vbCritical, "Error"
        Exit Function
    End If
    WriteProcessMemory phandle, Adress, Value, 4, 0&
    CloseHandle hProcess
    Timer1.Enabled = True
End Function
vBulletin® v4.2.5, Copyright ©2000-1404, Jelsoft Enterprises Ltd.