共用方式為


PsLookupProcessByProcessId 函式 (ntifs.h)

PsLookupProcessByProcessId 例程會接受進程的進程標識碼,並傳回進程的 EPROCESS 結構的參考指標。

語法

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

參數

[in] ProcessId

指定進程的進程識別碼。

[out] Process

傳回 ProcessId所指定之進程的 EPROCESS 結構的參考指標。

傳回值

PsLookupProcessByProcessId 會傳回成功或適當 NTSTATUS 值的STATUS_SUCCESS,例如:

傳回碼 描述
STATUS_INVALID_PARAMETER
在 Windows XP 和舊版 Windows 中指定找不到進程識別碼。
STATUS_INVALID_CID

在 Windows Vista 和更新版本的 Windows 中指定指定的用戶端識別碼無效。

言論

此例程適用於 Windows 2000 和更新版本。

如果呼叫 PsLookupProcessByProcessId 成功,PsLookupProcessByProcessID 會增加 Process 參數中所傳回對象的參考計數。 因此,當驅動程式使用 Process 參數完成時,驅動程式必須呼叫 ObDereferenceObject 來取值從 PsLookupProcessByProcessID 例程收到的 Process 參數。

EPROCESS 結構是作系統內部使用的不透明數據結構。 此結構可以傳遞至其他例程,以存取此結構中的特定資訊。

文件系統篩選驅動程式可以列舉使用中的進程,然後呼叫 PsLookupProcessByProcessId,將進程標識符轉換成 EPROCESS 結構。 進程標識碼可在進程建立例程中使用。 文件系統篩選驅動程式可以使用 PsSetCreateProcessNotifyRoutine來設定行程通知回呼例程。 在通知回呼例程中,文件系統篩選驅動程式可以使用傳入的 ProcessId 參數,並呼叫 PsLookupProcessByProcessID 來尋找 EPROCESS 結構。 PsSetCreateThreadNotifyRoutine 也可以用來設定通知例程,以在建立線程標識符時傳回進程標識碼。

PsLookupProcessByProcessId 例程包含可分頁的程式碼。

要求

要求 價值
目標平臺 普遍
標頭 ntifs.h (include Ntifs.h)
連結庫 NtosKrnl.lib
DLL NtosKrnl.exe
IRQL <= APC_LEVEL

另請參閱

ObDereferenceObject

PsGetCurrentProcess

PsGetCurrentProcessId

PsGetCurrentThread

PsGetCurrentThreadId

PsLookupThreadByThreadId

PsRemoveCreateThreadNotifyRoutine

PsRemoveLoadImageNotifyRoutine

PsSetCreateProcessNotifyRoutine

PsSetLoadImageNotifyRoutine