psLookupProcessByProcessId 函数 (ntifs.h)

PsLookupProcessByProcessId 例程接受进程的进程 ID,并返回指向进程的 EPROCESS 结构的引用指针。

语法

NTSTATUS PsLookupProcessByProcessId(
  [in]  HANDLE    ProcessId,
  [out] PEPROCESS *Process
);

参数

[in] ProcessId

指定进程的进程 ID。

[out] Process

返回指向 ProcessId 指定的进程的 EPROCESS 结构的引用指针。

返回值

PsLookupProcessByProcessId 在成功时返回STATUS_SUCCESS或相应的 NTSTATUS 值,例如:

返回代码 说明
STATUS_INVALID_PARAMETER
指定在 Windows XP 和早期版本的 Windows 中找不到进程 ID。
STATUS_INVALID_CID

指定在 Windows Vista 和更高版本的 Windows 中,指定的客户端 ID 无效。

注解

此例程在 Windows 2000 及更高版本上可用。

如果对 PsLookupProcessByProcessId 的调用成功, 则 PsLookupProcessByProcessID 将增加 Process 参数中返回的对象的引用计数。 因此,当驱动程序使用 Process 参数完成时,驱动程序必须调用 ObDereferenceObject 才能取消引用从 PsLookupProcessByProcessID 例程收到的 Process 参数。

EPROCESS 结构是操作系统在内部使用的不透明数据结构。 此结构可以传递给其他例程,以访问此结构中的特定信息。

文件系统筛选器驱动程序可以枚举活动进程,然后调用 PsLookupProcessByProcessId 将进程 ID 转换为 EPROCESS 结构。 进程 ID 在进程创建例程中可用。 文件系统筛选器驱动程序可以使用 PsSetCreateProcessNotifyRoutine 设置进程通知回调例程。 在通知回调例程中,文件系统筛选器驱动程序可以使用传入的 ProcessId 参数并调用 PsLookupProcessByProcessID 来查找 EPROCESS 结构。 PsSetCreateThreadNotifyRoutine 还可用于设置通知例程,该例程在创建线程 ID 时返回进程 ID。

PsLookupProcessByProcessId 例程包含可分页代码。

要求

要求
目标平台 通用
标头 ntifs.h (包括 Ntifs.h)
Library NtosKrnl.lib
DLL NtosKrnl.exe
IRQL <= APC_LEVEL

另请参阅

ObDereferenceObject

PsGetCurrentProcess

PsGetCurrentProcessId

PsGetCurrentThread

PsGetCurrentThreadId

PsLookupThreadByThreadId

PsRemoveCreateThreadNotifyRoutine

PsRemoveLoadImageNotifyRoutine

PsSetCreateProcessNotifyRoutine

PsSetLoadImageNotifyRoutine