After a process is created using CreateProcess, The PROCESS_INFORMATION structure will contain the handle of the process and a unique process ID. Then, when you use openprocess to open the process, according to the first parameter (dwDesiredAccess: PROCESS_ALL_ACCESS all the permissions that can be obtained by this process
After a process is created using CreateProcess, The PROCESS_INFORMATION structure will contain the handle of the process and a unique process ID. Then, when you use openprocess to open the process, according to the first parameter (dwDesiredAccess: you want to have the process access permission PROCESS_ALL_ACCESS // all the obtained permissions PROCES
Use CreateProcess to createProcessThe PROCESS_INFORMATION structure containsProcessHandle, and uniqueProcessID
Use openprocess to openProcessAccording to the first parameter
(DwDesiredAccess:ProcessAccess permission
PROCESS_ALL_ACCESS // all permissions that can be obtained
PROCESS_CREATE_PROCESS // you need to createProcess
PROCESS_CREATE_THREAD // you need to create a thread.
PROCESS_DUP_HANDLE // reuse DuplicateHandle handle
PROCESS_QUERY_INFORMATION // obtainProcessInformation permissions, such as its exit code and priority
PROCESS_QUERY_LIMITED_INFORMATION/* obtain certain information. If PROCESS_QUERY_INFORMATION is obtained, PROCESS_QUERY_LIMITED_INFORMATION is also granted */
PROCESS_SET_INFORMATION // set the permission for certain information, suchProcessPriority
PROCESS_SET_QUOTA // set the memory limit permission and use SetProcessWorkingSetSize
PROCESS_SUSPEND_RESUME // pause or resumeProcessPermissions
PROCESS_TERMINATE // terminateProcessUse TerminateProcess
PROCESS_VM_OPERATION // operationProcessMemory space permission (VirtualProtectEx and WriteProcessMemory are available)
PROCESS_VM_READ // readProcessThe permission for memory space. You can use ReadProcessMemory.
PROCESS_VM_WRITE // readProcessMemory space permission. WriteProcessMemory can be used.
SYNCHRONIZE // waitProcessTermination
)
Different, the returned handle value is different, and is definitely not equal to the handle value in PROCESS_INFORMATION
OpenProcess is used when the program is not closed.ObtainSameProcess, Each time you get a different handle Value
The handle returned by OpenProcess is the temporary operation handle assigned by the system. When CloseHandle (hand) is not used to close the handle, call OpenProcess againObtainA new handle is assigned to you. It is equivalent to the sameProcess
Essentially,ProcessHandle "is not actually trueProcessHandle,ProcessThe index (offset) of the handle in the "handle table ".ProcessThe handle is stored inProcessHandle table
If CloseHandle is disabled after each handle is used, OpenProcessObtainSameProcessYou can get the same handle value.
EachProcessAll have handle tables. The first entry of the table isProcessYour own handle, which is why calling GetCurrentProcess () always returns 0x7FFFFFFF.