From: Zhiyi Zhang zzhang@codeweavers.com
--- dlls/ntdll/tests/rtl.c | 49 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+)
diff --git a/dlls/ntdll/tests/rtl.c b/dlls/ntdll/tests/rtl.c index 69af20619e6..eaee2768c6a 100644 --- a/dlls/ntdll/tests/rtl.c +++ b/dlls/ntdll/tests/rtl.c @@ -115,6 +115,7 @@ static void (WINAPI *pRtlInitializeGenericTable)(RTL_GENERIC_TABLE *, PRTL_ PRTL_GENERIC_ALLOCATE_ROUTINE, PRTL_GENERIC_FREE_ROUTINE, void *); static void * (WINAPI *pRtlFindExportedRoutineByName)(HMODULE,const char *); +static void * (WINAPI *pRtlLookupElementGenericTable)(PRTL_GENERIC_TABLE, void *); static ULONG (WINAPI *pRtlNumberGenericTableElements)(PRTL_GENERIC_TABLE); static NTSTATUS (WINAPI *pLdrEnumerateLoadedModules)(void *, void *, void *); static NTSTATUS (WINAPI *pLdrRegisterDllNotification)(ULONG, PLDR_DLL_NOTIFICATION_FUNCTION, void *, void **); @@ -181,6 +182,7 @@ static void InitFunctionPtrs(void) pRtlInitializeCriticalSectionEx = (void *)GetProcAddress(hntdll, "RtlInitializeCriticalSectionEx"); pRtlInitializeGenericTable = (void *)GetProcAddress(hntdll, "RtlInitializeGenericTable"); pRtlFindExportedRoutineByName = (void *)GetProcAddress(hntdll, "RtlFindExportedRoutineByName"); + pRtlLookupElementGenericTable = (void *)GetProcAddress(hntdll, "RtlLookupElementGenericTable"); pRtlNumberGenericTableElements = (void *)GetProcAddress(hntdll, "RtlNumberGenericTableElements"); pLdrEnumerateLoadedModules = (void *)GetProcAddress(hntdll, "LdrEnumerateLoadedModules"); pLdrRegisterDllNotification = (void *)GetProcAddress(hntdll, "LdrRegisterDllNotification"); @@ -5102,6 +5104,52 @@ static void test_RtlDeleteElementGenericTable(void) ok(!success, "RtlDeleteElementGenericTable succeeded.\n"); }
+static void test_RtlLookupElementGenericTable(void) +{ + static const int elements[] = {1, 9, 5, 4, 7, 2, 3, 8, 6}; + BOOLEAN new_element, success; + RTL_GENERIC_TABLE table; + int i, value, *ret; + + if (!pRtlLookupElementGenericTable) + { + win_skip("RtlLookupElementGenericTable is unavailable.\n"); + return; + } + + pRtlInitializeGenericTable(&table, generic_compare_proc, generic_allocate_proc, generic_free_proc, NULL); + + ret = pRtlLookupElementGenericTable(&table, NULL); + ok(!ret, "Got unexpected pointer.\n"); + + value = 1; + ret = pRtlLookupElementGenericTable(&table, &value); + ok(!ret, "Got unexpected pointer.\n"); + + for (i = 0; i < ARRAY_SIZE(elements); i++) + { + value = elements[i]; + ret = pRtlInsertElementGenericTable(&table, &value, sizeof(value), &new_element); + ok(ret && *ret == value, "Got unexpected pointer.\n"); + ok(new_element, "Expected new element.\n"); + } + + for (i = 0; i < ARRAY_SIZE(elements); i++) + { + value = elements[i]; + ret = pRtlLookupElementGenericTable(&table, &value); + ok(ret && *ret == value, "Got unexpected pointer.\n"); + ok(table.TableRoot == get_splay_links_from_data(ret), "Got unexpected TableRoot.\n"); + } + + for (i = 0; i < ARRAY_SIZE(elements); i++) + { + value = elements[i]; + success = pRtlDeleteElementGenericTable(&table, &value); + ok(success, "RtlDeleteElementGenericTable failed.\n"); + } +} + START_TEST(rtl) { InitFunctionPtrs(); @@ -5166,4 +5214,5 @@ START_TEST(rtl) test_RtlIsGenericTableEmpty(); test_RtlInsertElementGenericTable(); test_RtlDeleteElementGenericTable(); + test_RtlLookupElementGenericTable(); }