Skip to content

Latest commit

 

History

History
98 lines (76 loc) · 4.25 KB

nf-processthreadsapi-getcurrentprocess.md

File metadata and controls

98 lines (76 loc) · 4.25 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.GetCurrentProcess
GetCurrentProcess function (processthreadsapi.h)
Retrieves a pseudo handle for the current process.
GetCurrentProcess
GetCurrentProcess function
_win32_getcurrentprocess
base.getcurrentprocess
processthreadsapi/GetCurrentProcess
winbase/GetCurrentProcess
base\getcurrentprocess.htm
processthreadsapi
0471790c-3bb9-4180-8676-941e655b1812
02/02/2024
GetCurrentProcess, GetCurrentProcess function, _win32_getcurrentprocess, base.getcurrentprocess, processthreadsapi/GetCurrentProcess, winbase/GetCurrentProcess
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
GetCurrentProcess
processthreadsapi/GetCurrentProcess
c++
APIRef
kbSyntax
DllExport
Kernel32.dll
API-MS-Win-Core-ProcessThreads-l1-1-0.dll
KernelBase.dll
MinKernelBase.dll
API-MS-Win-Core-ProcessThreads-l1-1-1.dll
API-MS-Win-Core-ProcessThreads-l1-1-2.dll
api-ms-win-downlevel-kernel32-l1-1-0.dll
API-MS-Win-Core-ProcessThreads-L1-1-3.dll
Vertdll.dll
GetCurrentProcess

GetCurrentProcess function

-description

Retrieves a pseudo handle for the current process.

-returns

The return value is a pseudo handle to the current process.

-remarks

A pseudo handle is a special constant, currently (HANDLE)-1, that is interpreted as the current process handle. For compatibility with future operating systems, it is best to call GetCurrentProcess instead of hard-coding this constant value. The calling process can use a pseudo handle to specify its own process whenever a process handle is required. Pseudo handles are not inherited by child processes.

This handle has the PROCESS_ALL_ACCESS access right to the process object. For more information, see Process Security and Access Rights.

Windows Server 2003 and Windows XP: This handle has the maximum access allowed by the security descriptor of the process to the primary token of the process.

A process can create a "real" handle to itself that is valid in the context of other processes, or that can be inherited by other processes, by specifying the pseudo handle as the source handle in a call to the DuplicateHandle function. A process can also use the OpenProcess function to open a real handle to itself.

The pseudo handle need not be closed when it is no longer needed. Calling the CloseHandle function with a pseudo handle has no effect. If the pseudo handle is duplicated by DuplicateHandle, the duplicate handle must be closed.

Examples

For an example, see Creating a Child Process with Redirected Input and Output.

-see-also

CloseHandle

DuplicateHandle

GetCurrentProcessId

GetCurrentThread

OpenProcess

Process and Thread Functions

Processes

Vertdll APIs available in VBS enclaves