Private Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long
Private Declare Function GetWindowThreadProcessId Lib "user32" (ByVal hwnd As Long, lpdwProcessId As Long) As Long
Private Declare Function ReadProcessMemory Lib "kernel32" (ByVal hProcess As Long, ByVal lpBaseAddress As Any, ByVal lpBuffer As Any, ByVal nSize As Long, lpNumberOfBytesWritten As Long) As LongPrivate Declare Function WriteProcessMemory Lib "kernel32" (ByVal hProcess As Long, lpBaseAddress As Any, lpBuffer As Any, ByVal nSize As Long, lpNumberOfBytesWritten As Long) As LongPrivate Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
'提升权限
Private Declare Function GetLastError Lib "kernel32" () As Long
Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
Private Const PROCESS_ALL_ACCESS = &H1F0FFF
Private ipd As Long
Private hwdn As Long
Private pen As Long
Private xia As Long
Private h As Long
Private Sub Command1_Click()
hwdn = FindWindow(vbNullString, "计算器")
Call GetWindowThreadProcessId(hwdn, ipd)
pen = OpenProcess(PROCESS_ALL_ACCESS, False, ipd)
ReadProcessMemory pen, ByVal &H77F344A4, ByVal xia, 4, 0&
h = GetLastError()
Print xia
CloseHandle pen
End Sub
问题在哪啊?
Private Declare Function GetWindowThreadProcessId Lib "user32" (ByVal hwnd As Long, lpdwProcessId As Long) As Long
Private Declare Function ReadProcessMemory Lib "kernel32" (ByVal hProcess As Long, ByVal lpBaseAddress As Any, ByVal lpBuffer As Any, ByVal nSize As Long, lpNumberOfBytesWritten As Long) As LongPrivate Declare Function WriteProcessMemory Lib "kernel32" (ByVal hProcess As Long, lpBaseAddress As Any, lpBuffer As Any, ByVal nSize As Long, lpNumberOfBytesWritten As Long) As LongPrivate Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
'提升权限
Private Declare Function GetLastError Lib "kernel32" () As Long
Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
Private Const PROCESS_ALL_ACCESS = &H1F0FFF
Private ipd As Long
Private hwdn As Long
Private pen As Long
Private xia As Long
Private h As Long
Private Sub Command1_Click()
hwdn = FindWindow(vbNullString, "计算器")
Call GetWindowThreadProcessId(hwdn, ipd)
pen = OpenProcess(PROCESS_ALL_ACCESS, False, ipd)
ReadProcessMemory pen, ByVal &H77F344A4, ByVal xia, 4, 0&
h = GetLastError()
Print xia
CloseHandle pen
End Sub
问题在哪啊?
这样才可以读取PROCESS_VM_READ=&H10&
这句有问题的说
Private 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, 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 CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
Private Declare Function ReadProcessMemory Lib "kernel32" (ByVal hprocess As Long, ByVal lpBaseAddress As Long, ByVal lpBuffer As Byte, ByVal nSize As Long, ByRef lpNumberOfBytesWritten As Long) As Long
Private Const PROCESS_ALL_ACCESS = &H1F0FFF
Private Sub Command1_Click()
Dim hwnd As Long
hwnd = FindWindow(vbNullString, "计算器")
Dim pid As Long
Call GetWindowThreadProcessId(hwnd, pid)
Dim hprocess As Long
hprocess = OpenProcess(PROCESS_ALL_ACCESS, False, pid)
Dim lon As Byte
ReadProcessMemory pid, &H77F344A4, lon, 4, 0&
Print lon
CloseHandle hprocess
End Sub