Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
The PsGetCurrentProcessId routine identifies the current thread's process.
Syntax
HANDLE PsGetCurrentProcessId();
Return value
PsGetCurrentProcessId returns the process ID of the process that created the current thread.
Remarks
PsGetCurrentProcessId returns the process ID of the process that originally created the current thread, which is not necessarily the process that the thread is currently attached to. In scenarios where a thread may be attached to a different process context (via APC state), this can differ from PsGetProcessId(PsGetCurrentProcess()).
- PsGetCurrentProcessId() - Returns the process ID of the process that created the thread
- PsGetProcessId(PsGetCurrentProcess()) - Returns the process ID of the process that the thread is currently attached to
Use PsGetCurrentProcessId when you need the ID of the process that owns the thread. Use PsGetProcessId(PsGetCurrentProcess()) when you need the ID of the process context the thread is currently operating in.
Requirements
| Requirement | Value |
|---|---|
| Minimum supported client | Windows 2000 |
| Target Platform | Universal |
| Header | ntddk.h (include Ntddk.h) |
| Library | NtosKrnl.lib |
| DLL | NtosKrnl.exe |
| IRQL | Any level |
See also
PsSetCreateProcessNotifyRoutine