Getting the process Id
In order to open the other process to read it's memory you need to know the process id. You can get this if you have the window handle of the window that sent you the message thus:-
VB Code:
Private Declare Function GetWindowThreadProcessId Lib "user32" (ByVal hwnd As Long, lpProcId As Long) As Long Public Function ProcessIdFromHwnd(ByVal hwnd As Long) As Long Dim lProc As Long If GetWindowThreadProcessId(hwnd, lProc) Then ProcessIdFromHwnd = lProc End If End Function
And you pass this in to OpenProcess in order to get the hProc parameter to pass to LongFromOutOfprocessPointer and StringFromOutOfprocessPointer...
VB Code:
Public Enum ProcessAccessPriviledges PROCESS_TERMINATE = &H1 PROCESS_CREATE_THREAD = &H2 PROCESS_SET_SESSIONID = &H4 PROCESS_VM_OPERATION = &H8 PROCESS_VM_READ = &H10 PROCESS_VM_WRITE = &H20 PROCESS_DUP_HANDLE = &H40 PROCESS_CREATE_PROCESS = &H80 PROCESS_SET_QUOTA = &H100 PROCESS_SET_INFORMATION = &H200 PROCESS_QUERY_INFORMATION = &H400 PROCESS_SYNCHRONISE = &H100000 PROCESS_ALL_ACCESS = &H100FFF End Enum Private Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As ProcessAccessPriviledges, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long




Reply With Quote