Skip to content

Latest commit

 

History

History
178 lines (100 loc) · 6.08 KB

nf-processthreadsapi-openprocess.md

File metadata and controls

178 lines (100 loc) · 6.08 KB
UID title description helpviewer_keywords old-location tech.root ms.assetid ms.date ms.keywords req.header req.include-header req.target-type req.target-min-winverclnt req.target-min-winversvr req.kmdf-ver req.umdf-ver req.ddi-compliance req.unicode-ansi req.idl req.max-support req.namespace req.assembly req.type-library req.lib req.dll req.irql targetos req.typenames req.redist ms.custom f1_keywords dev_langs topic_type api_type api_location api_name
NF:processthreadsapi.OpenProcess
OpenProcess function (processthreadsapi.h)
Opens an existing local process object.
OpenProcess
OpenProcess function
_win32_openprocess
base.openprocess
processthreadsapi/OpenProcess
winbase/OpenProcess
base\openprocess.htm
processthreadsapi
8f695c38-19c4-49e4-97de-8b64ea536cb1
12/05/2018
OpenProcess, OpenProcess function, _win32_openprocess, base.openprocess, processthreadsapi/OpenProcess, winbase/OpenProcess
processthreadsapi.h
Windows.h on Windows Server 2003, Windows Vista, Windows 7, Windows Server 2008 Windows Server 2008 R2
Windows
Windows XP [desktop apps \| UWP apps]
Windows Server 2003 [desktop apps \| UWP apps]
Kernel32.lib
Kernel32.dll
Windows
19H1
OpenProcess
processthreadsapi/OpenProcess
c++
APIRef
kbSyntax
DllExport
Kernel32.dll
API-MS-Win-Core-ProcessThreads-l1-1-1.dll
KernelBase.dll
MinKernelBase.dll
API-MS-Win-Core-ProcessThreads-l1-1-2.dll
api-ms-win-core-synch-l1-1-0.dll
api-ms-win-downlevel-kernel32-l1-1-0.dll
API-MS-Win-Core-ProcessThreads-L1-1-3.dll
OpenProcess

OpenProcess function

-description

Opens an existing local process object.

-parameters

-param dwDesiredAccess [in]

The access to the process object. This access right is checked against the security descriptor for the process. This parameter can be one or more of the process access rights.

If the caller has enabled the SeDebugPrivilege privilege, the requested access is granted regardless of the contents of the security descriptor.

-param bInheritHandle [in]

If this value is TRUE, processes created by this process will inherit the handle. Otherwise, the processes do not inherit this handle.

-param dwProcessId [in]

The identifier of the local process to be opened.

If the specified process is the System Idle Process (0x00000000), the function fails and the last error code is ERROR_INVALID_PARAMETER. If the specified process is the System process or one of the Client Server Run-Time Subsystem (CSRSS) processes, this function fails and the last error code is ERROR_ACCESS_DENIED because their access restrictions prevent user-level code from opening them.

If you are using GetCurrentProcessId as an argument to this function, consider using GetCurrentProcess instead of OpenProcess, for improved performance.

-returns

If the function succeeds, the return value is an open handle to the specified process.

If the function fails, the return value is NULL. To get extended error information, call GetLastError.

-remarks

To open a handle to another local process and obtain full access rights, you must enable the SeDebugPrivilege privilege. For more information, see Changing Privileges in a Token.

The handle returned by the OpenProcess function can be used in any function that requires a handle to a process, such as the wait functions, provided the appropriate access rights were requested.

When you are finished with the handle, be sure to close it using the CloseHandle function.

Examples

For an example, see Taking a Snapshot and Viewing Processes.

-see-also

AssignProcessToJobObject

CloseHandle

CreateProcess

CreateRemoteThread

DuplicateHandle

GetCurrentProcess

GetCurrentProcessId

GetExitCodeProcess

GetModuleFileNameEx

GetPriorityClass

Process and Thread Functions

Processes

ReadProcessMemory

SetPriorityClass

SetProcessWorkingSetSize

TerminateProcess

VirtualProtectEx

WriteProcessMemory