[DllImport("kernel32.dll")]
static extern IntPtr OpenProcess(ProcessAccessFlags dwDesiredAccess, bool bInheritHandle,
uint dwProcessId);
Declare Auto Function OpenProcess Lib "kernel32.dll" (ByVal dwDesiredAccess As PROCESS_ACCESS, ByVal bInheritHandle As Boolean, ByVal dwProcessId As Long) As IntPtr
End Function
<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
public enum ProcessAccessFlags : uint
{
All = 0x001F0FFF,
Terminate = 0x00000001,
CreateThread = 0x00000002,
VMOperation = 0x00000008,
VMRead = 0x00000010,
VMWrite = 0x00000020,
DupHandle = 0x00000040,
SetInformation = 0x00000200,
QueryInformation = 0x00000400,
Synchronize = 0x00100000
}
None.
Please add some!
' Get the handle of a running process
Dim curProcess As Process = Process.GetCurrentProcess()
hProcess = OpenProcess(PROCESS_ACCESS.PROCESS_QUERY_INFORMATION, True, curProcess.Id)
Do you know one? Please contribute it!