PsGetCurrentProcessId - NtDoc

Native API online documentation, based on the System Informer (formerly Process Hacker) phnt headers
// ntddk.h

HANDLE PsGetCurrentProcessId();

View the official Windows Driver Kit DDI reference

NtDoc

No description available.

Windows Driver Kit DDI reference (nf-ntddk-psgetcurrentprocessid)

PsGetCurrentProcessId function

Description

The PsGetCurrentProcessId routine identifies the current thread's process.

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()).

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.

See also

IoGetCurrentProcess

PsGetCurrentProcess

PsGetCurrentThread

PsGetCurrentThreadId

PsGetProcessId

PsSetCreateProcessNotifyRoutine

PsSetCreateThreadNotifyRoutine

PsSetLoadImageNotifyRoutine