Да сказать легко а на практике не получается ...
Как найти начальный и конечный адрес процесса ???
- Код: Выделить всё
Option Explicit
Private Type MEMORY_BASIC_INFORMATION ' 28 bytes
BaseAddress As Long
AllocationBase As Long
AllocationProtect As Long
RegionSize As Long
State As Long
Protect As Long
lType As Long
End Type
Private Type SYSTEM_INFO ' 36 Bytes
dwOemID As Long
dwPageSize As Long
lpMinimumApplicationAddress As Long
lpMaximumApplicationAddress As Long
dwActiveProcessorMask As Long
dwNumberOrfProcessors As Long
dwProcessorType As Long
dwAllocationGranularity As Long
wProcessorLevel As Integer
wProcessorRevision As Integer
End Type
Private Declare Function GetVersionEx Lib "kernel32" Alias "GetVersionExA" (LpVersionInformation As OSVERSIONINFO) As Long
Private Declare Function VirtualQueryEx& Lib "kernel32" (ByVal hProcess As Long, lpAddress As Any, lpBuffer As MEMORY_BASIC_INFORMATION, ByVal dwLength As Long)
Private Declare Sub GetSystemInfo Lib "kernel32" (lpSystemInfo As SYSTEM_INFO)
Private Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long, ByVal blnheritHandle As Long, ByVal dwAppProcessId As Long) As Long
Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
Private Declare Function ReadProcessMemory Lib "kernel32" (ByVal hProcess As Long, lpBaseAddress As Any, lpBuffer As Any, ByVal nSize As Long, lpNumberOfBytesWritten As Long) As Long
Private Declare Function WriteProcessMemory Lib "kernel32" (ByVal hProcess As Long, lpBaseAddress As Any, lpBuffer As Any, ByVal nSize As Long, lpNumberOfBytesWritten As Long) As Long
Private Declare Function GetWindowThreadProcessId Lib "user32" (ByVal hWnd As Long, lpdwProcessId As Long) As Long
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function GetParent Lib "user32" (ByVal hWnd As Long) As Long
Private Declare Function GetWindow Lib "user32" (ByVal hWnd As Long, ByVal wCmd As Long) As Long
Private Declare Function InvalidateRect Lib "user32" (ByVal hWnd As Long, ByVal lpRect As Long, ByVal bErase As Long) As Long
Private Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hWnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
Private Declare Function GetWindowTextLength Lib "user32" Alias "GetWindowTextLengthA" (ByVal hWnd As Long) As Long
Const PROCESS_VM_READ = (&H10)
Const PROCESS_VM_WRITE = (&H20)
Const PROCESS_VM_OPERATION = (&H8)
Const PROCESS_QUERY_INFORMATION = (&H400)
Const PROCESS_READ_WRITE_QUERY = PROCESS_VM_READ + PROCESS_VM_WRITE + PROCESS_VM_OPERATION + PROCESS_QUERY_INFORMATION
Const MEM_PRIVATE& = &H20000
Const MEM_COMMIT& = &H1000
Const GW_HWNDFIRST = 0
Const GW_HWNDNEXT = 2
Dim CurrWnd As String
Dim ListItem As String
Dim Length As String
Dim hwind As Long
Dim pid As Long, hProcess As Long
Dim lpMem As Long, ret As Long, lLenMBI As Long
Dim lWritten As Long, CalcAddress As Long, lPos As Long
Dim si As SYSTEM_INFO
Dim mbi As MEMORY_BASIC_INFORMATION
Sub GetTaskList()
CurrWnd = GetWindow(Me.hWnd, GW_HWNDFIRST)
Do While CurrWnd <> 0
Length = GetWindowTextLength(CurrWnd)
ListItem = Space(Length + 1)
Length = GetWindowText(CurrWnd, ListItem, Length + 1)
If Length > 0 Then
Combo1.AddItem ListItem
End If
CurrWnd = GetWindow(CurrWnd, GW_HWNDNEXT)
DoEvents
Loop
End Sub
Private Sub Combo1_Change()
hwind = FindWindow(vbNullString, Combo1.Text)
Label1.Caption = "hWnd : " & hwind
Address
End Sub
Private Sub Combo1_Click()
hwind = FindWindow(vbNullString, Combo1.Text)
Label1.Caption = "hWnd : " & hwind
Address
End Sub
Private Sub Form_Load()
Label1.Caption = "hWnd : "
Label2.Caption = "ProcessMemoryStartAddress : "
Label3.Caption = "ProcessMemoryEndAddress : "
GetTaskList
End Sub
Private Sub Address()
GetWindowThreadProcessId hwind, pid
hProcess = OpenProcess(PROCESS_READ_WRITE_QUERY, False, pid)
lLenMBI = Len(mbi)
Call GetSystemInfo(si)
lpMem = si.lpMinimumApplicationAddress
Label2.Caption = "ProcessMemoryStartAddress : " & CStr(lpMem) ' <------ Что нужно вписать сюда ???
Label3.Caption = "ProcessMemoryEndAddress : " & CStr(si.lpMaximumApplicationAddress) ' <-------------- Что нужно вписать сюда ???
CloseHandle hProcess
End Sub
Неужели всё до такой степени сложно ???
Помогите пожалуйста !!!
Ведь чтобы понять код нужно хотябы иметь представление или описание
как это работает а одной смекалки не хватит .
Люди Добрые , помогите кто действительно знает .
Три дня по 12-14 часов я пытаюсь разобраться в этом , помочь некому ...
А высказывания "это функция такая" помогает лишь когда человек знаком с ней или есть достаточно материалов по описанию ...
А иногда в примерах допускают серьёзные ошибки
Искав через поисковики "ReadProcessMemory" я почти во всех примерах
не нашел такой маленькой вещи :
Const PROCESS_ALL_ACCESS = &HF0000 Or &H100000 Or &HFFF
это типа сами догадайтесь....
А зачастую , как бывает - есть люди которые могут помочь но по каким-то причинам не хотят помогать , а это неправельно...
И тогда человек который неможет найти ответ , не закончив работу делает : 'On Error ExitSub '