RtlEnumerateGenericTableLikeADirectory 函式 (ntddk.h)
RtlEnumerateGenericTableLikeADirectory 例程會依定序順序傳回泛型數據表的專案。
語法
NTSYSAPI PVOID RtlEnumerateGenericTableLikeADirectory(
[in] PRTL_AVL_TABLE Table,
[in, optional] PRTL_AVL_MATCH_FUNCTION MatchFunction,
[in, optional] PVOID MatchData,
[in] ULONG NextFlag,
[in, out] PVOID *RestartKey,
[in, out] PULONG DeleteCount,
[in] PVOID Buffer
);
參數
[in] Table
將列舉的 Adelson-Velsky/Landis (AVL) 數據表 (RTL_AVL_TABLE) 指標。
[in, optional] MatchFunction
比對函式,決定要傳回的專案。 如果未指定,則會傳回所有節點。
[in, optional] MatchData
要傳遞至比對函式的數據。
[in] NextFlag
如果 *RestartKey 未 NULL,則 true 的值表示列舉將會略過元素。 如果 FALSE 列舉會在上一次呼叫 RtlEnumerateGenericTableLikeADirectory時繼續關閉。 如果 *RestartKeyNULL,則 TRUE 的值會指示RtlEnumerateGenericTableLikeADirectory 傳回符合 Buffer中數據的專案之後,樹狀結構中的下一個專案。 FALSE 的值會指示 RtlEnumerateGenericTableLikeADirectory 傳回樹狀結構中符合 Buffer中的數據的專案。
[in, out] RestartKey
值,決定要從何處開始或繼續列舉泛型數據表專案。 如果 *RestartKeyNULL,則列舉會從 Buffer中所述的位置開始或繼續。 如果未 NULL,則列舉會從 RestartKey 指出的點繼續執行。 傳回時,RestartKey 會保留值,指出列舉離開的樹狀結構中的位置。 在下一次呼叫 RtlEnumerateGenericTableLikeADirectory 呼叫端應傳回相同的值,以通知 RtlEnumerateGenericTableLikeADirectory 繼續列舉的位置。 下列程式代碼範例說明如何執行這項作:
NextFlag = FALSE;
RestartKey = NULL;
DeleteCount = 0;
// Initialize Buffer for start/resume point
Buffer = ...
for (ptr = NULL; ptr != NULL; ) {
// Value returned in RestartKey will be passed back in
// on following call (iteration):
ptr = RtlEnumerateGenericTableLikeADirectory(
&MyTable, NULL, NULL, TRUE, &RestartKey,
&DeleteCount, &Buffer, sizeof(LONG) );
...
// The value output in RestartKey will still be in
// RestartKey when the
// RtlEnumerationGenericTableLikeADirectory routine
// is called in the next iteration of this loop.
// This ensures that the enumeration will pick up
// where it left off.
}
如果在呼叫 RtlEnumerateGenericTableLikeADirectory之間從樹狀結構中刪除節點,則列舉會從 Buffer中所述的樹狀結構位置繼續執行,無論 *RestartKey的值為何。
[in, out] DeleteCount
在輸出中,值,表示從數據表中刪除之專案的目前計數。 呼叫者必須在下一次呼叫中將此值傳回給 RtlEnumerateGenericTableLikeADirectory。 此值可協助 RtlEnumerateGenericTableLikeADirectory 例程判斷從數據表刪除是否發生在呼叫 RtlEnumerateGenericTableLikeADirectory之間。 如果發生刪除,則列舉會繼續使用符合 Buffer中數據的數據表專案,而不是 RestartKey所指示的數據表專案。 如果 *RestartKeyNULL,此參數對 列舉沒有任何作用。
[in] Buffer
當 *RestartKey NULL時,決定要從何處開始列舉的索引鍵表達式。 呼叫端可以傳入符合數據表中特定專案的已儲存索引鍵,而且列舉會從儲存的索引鍵所指定的項目開始,前提是 *RestartKey 是 NULL,而且 NextFlagFALSE。 若要傳回緊接在儲存金鑰之後的金鑰,請在此處傳入金鑰,請將 *RestartKey 設定為 NULL,並將 NextFlag TRUE。 如果已刪除儲存的金鑰,列舉將會以下一個相符的索引鍵開頭。
傳回值
RtlEnumerateGenericTableLikeADirectory 例程會傳回與列舉中下一個數據表元素相關聯的使用者定義結構的指標。 如果沒有其他新元素可傳回傳回值,則會 NULL。
言論
RtlEnumerateGenericTableLikeADirectory 例程提供安全的方法,可在混合插入和刪除作業之間列舉泛型數據表。 從第一個相符的索引鍵名稱開始,RtlEnumerateGenericTableLikeADirectory 會傳回數據表中的每個名稱,除非在列舉期間插入或刪除名稱。 在列舉期間插入或刪除索引鍵名稱時(也就是在呼叫 RtlEnumerateGenericTableLikeADirectory之間),它可能會或可能不會包含在列舉中。 當 RtlEnumerateGenericTableLikeADirectory 處理名稱所在的目錄範圍時,是否包含這類名稱取決於名稱的狀態。
有四個例程可用來列舉泛型數據表:
根據預設,作系統會使用 splay 樹來實作泛型數據表,但 RtlEnumerateGenericTableLikeADirectory 例程只適用於 Adelson-Velsky/Landis (AVL) 樹狀結構。 若要將泛型數據表例程設定為使用AVL樹狀結構,而不是驅動程式中的splay樹狀結構,請在包含Ntddk.h之前,在通用頭檔中插入下列define語句:
#define RTL_USE_AVL_TABLES 0
如果未定義RTL_USE_AVL_TABLES,您必須使用泛型數據表例程的AVL形式。
如果下列任一條件保留,RtlEnumerateGenericTableLikeADirectory 的呼叫者必須在 IRQL <= APC_LEVEL 執行:
呼叫端在 數據表 或 緩衝區 的呼叫端配置記憶體是可分頁的。
呼叫端提供的 MatchFunction 包含可分頁的程序代碼。
要求
要求 | 價值 |
---|---|
目標平臺 | 普遍 |
標頭 | ntddk.h (include Ntddk.h, Ntifs.h, FltKernel.h) |
連結庫 | NtosKrnl.lib |
DLL | NtosKrnl.exe |
IRQL | <= APC_LEVEL (請參閱一節) |