Type a page name and press Enter. You'll jump to the page if it exists, or you can create it if it doesn't.
To create a page in a module other than kernel32, prefix the name with the module name and a period.
Declare Auto Function OpenProcess Lib "kernel32.dll" (ByVal dwDesiredAccess As PROCESS_ACCESS, ByVal bInheritHandle As Boolean, ByVal dwProcessId As Long) As IntPtr
End Function
User-Defined Types (VB.NET):
<Flags()> _
Public Enum PROCESS_ACCESS As Long
' Specifies all possible access flags for the process object.
PROCESS_ALL_ACCESS = &H1F0FFF
' Enables using the process handle in the CreateRemoteThread function
' to create a thread in the process.
PROCESS_CREATE_THREAD = &H2
' Enables using the process handle as either the source or
' target process in the DuplicateHandle function to duplicate a handle.
PROCESS_DUP_HANDLE = &H40
' Enables using the process handle in the GetExitCodeProcess and
' GetPriorityClass functions to read information from the process object.
PROCESS_QUERY_INFORMATION = &H400
' Enables using the process handle in the SetPriorityClass function to
' set the priority class of the process.
PROCESS_SET_INFORMATION = &H200
' Enables using the process handle in the TerminateProcess function to
' terminate the process.
PROCESS_TERMINATE = &H1
' Enables using the process handle in the VirtualProtectEx and
' WriteProcessMemory functions to modify the virtual memory of the process.
PROCESS_VM_OPERATION = &H8
' Enables using the process handle in the ReadProcessMemory function to
' read from the virtual memory of the process.
PROCESS_VM_READ = &H10
' Enables using the process handle in the WriteProcessMemory function to
' write to the virtual memory of the process.
PROCESS_VM_WRITE = &H20
' Enables using the process handle in any of the wait functions to wait
' for the process to terminate.
SYNCHRONIZE = &H100000
End Enum
' Get the handle of a running process
Dim curProcess As Process = Process.GetCurrentProcess()
hProcess = OpenProcess(PROCESS_ACCESS.PROCESS_QUERY_INFORMATION, True, curProcess.Id)
C#
//a Variable to hold the process id
uint ProccessID;
//Gets the Handle To the Window (Using an Open Notepad Window For Example)
// Gets The Windows Process ID To Use later
GetWindowThreadProcessId(hWnd, out ProccessID);
//Opens the Process
IntPtr ProcessHandle = OpenProcess(ProcessAccessFlags.VMRead, false, ProccessID);
Alternative Managed API:
Do you know one? Please contribute it!
Please edit this page!
Do you have...
helpful tips or sample code to share for using this API in managed code?
corrections to the existing content?
variations of the signature you want to share?
additional languages you want to include?
Select "Edit This Page" on the right hand toolbar and edit it! Or add new pages containing supporting types needed for this API (structures, delegates, and more).