https://git.reactos.org/?p=reactos.git;a=commitdiff;h=7cce7b9c08aad08c87884…
commit 7cce7b9c08aad08c87884ecec59bb07ef4fada16
Author: Mark Jansen <mark.jansen(a)reactos.org>
AuthorDate: Sat Apr 18 13:51:37 2020 +0200
Commit: Mark Jansen <mark.jansen(a)reactos.org>
CommitDate: Sun Apr 26 14:35:51 2020 +0200
[NTDLL_APITEST] Add a test for RtlGetUnloadEventTrace
---
modules/rostests/apitests/ntdll/CMakeLists.txt | 1 +
.../apitests/ntdll/RtlGetUnloadEventTrace.c | 83 ++++++++++++++++++++++
modules/rostests/apitests/ntdll/testlist.c | 2 +
3 files changed, 86 insertions(+)
diff --git a/modules/rostests/apitests/ntdll/CMakeLists.txt
b/modules/rostests/apitests/ntdll/CMakeLists.txt
index 63ea01f677d..fc46b1db676 100644
--- a/modules/rostests/apitests/ntdll/CMakeLists.txt
+++ b/modules/rostests/apitests/ntdll/CMakeLists.txt
@@ -58,6 +58,7 @@ list(APPEND SOURCE
RtlGetLengthWithoutTrailingPathSeperators.c
RtlGetLongestNtPathLength.c
RtlGetNtProductType.c
+ RtlGetUnloadEventTrace.c
RtlHandle.c
RtlImageRvaToVa.c
RtlIsNameLegalDOS8Dot3.c
diff --git a/modules/rostests/apitests/ntdll/RtlGetUnloadEventTrace.c
b/modules/rostests/apitests/ntdll/RtlGetUnloadEventTrace.c
new file mode 100644
index 00000000000..ba0044d1fa0
--- /dev/null
+++ b/modules/rostests/apitests/ntdll/RtlGetUnloadEventTrace.c
@@ -0,0 +1,83 @@
+/*
+ * PROJECT: ReactOS API tests
+ * LICENSE: GPL-2.0-or-later (
https://spdx.org/licenses/GPL-2.0-or-later)
+ * PURPOSE: Test for RtlGetUnloadEventTrace
+ * COPYRIGHT: Copyright 2020 Mark Jansen (mark.jansen(a)reactos.org)
+ */
+
+#include "precomp.h"
+
+PRTL_UNLOAD_EVENT_TRACE
+NTAPI
+RtlGetUnloadEventTrace(VOID);
+
+#ifndef _WIN64
+C_ASSERT(sizeof(RTL_UNLOAD_EVENT_TRACE) == 84);
+C_ASSERT(sizeof(RTL_UNLOAD_EVENT_TRACE) * RTL_UNLOAD_EVENT_TRACE_NUMBER == 0x540);
+#endif
+
+static void Test_Dump()
+{
+ PRTL_UNLOAD_EVENT_TRACE TraceHead, Trace;
+ UINT n;
+
+ TraceHead = RtlGetUnloadEventTrace();
+ for (n = 0; n < RTL_UNLOAD_EVENT_TRACE_NUMBER; ++n)
+ {
+ ULONG ExpectSequence = n ? n : RTL_UNLOAD_EVENT_TRACE_NUMBER;
+
+ Trace = TraceHead + n;
+
+ ok(Trace->BaseAddress != NULL, "Got no BaseAddress for %u\n", n);
+ ok(Trace->SizeOfImage != 0, "Got no SizeOfImage for %u\n", n);
+ ok(Trace->Sequence == ExpectSequence,
+ "Wrong Sequence: %lu instead of %lu for %u\n", Trace->Sequence,
ExpectSequence, n);
+ ok(Trace->TimeDateStamp != 0, "Got no TimeDateStamp for %u\n", n);
+ ok(Trace->CheckSum != 0, "Got no CheckSum for %u\n", n);
+ ok(!wcscmp(Trace->ImageName, L"GetUName.dLl"), "Wrong ImageName
for %u: %S\n", n, Trace->ImageName);
+ }
+}
+
+#define TESTDLL "GetUName.dLl"
+static void Test_LoadUnload()
+{
+ HMODULE mod;
+ static char Buffer[MAX_PATH] = {0};
+
+ mod = GetModuleHandleA(TESTDLL);
+ ok(mod == NULL, "ERROR, %s already loaded\n", TESTDLL);
+
+ mod = LoadLibraryA(Buffer[0] ? Buffer :TESTDLL);
+ ok(mod != NULL, "ERROR, %s not loaded\n", TESTDLL);
+
+ if (!Buffer[0])
+ {
+ GetModuleFileNameA(mod, Buffer, _countof(Buffer));
+ }
+ else
+ {
+ Buffer[0] = '\0';
+ }
+
+ FreeLibrary(mod);
+
+ mod = GetModuleHandleA(TESTDLL);
+ ok(mod == NULL, "ERROR, %s still loaded\n", TESTDLL);
+}
+
+START_TEST(RtlGetUnloadEventTrace)
+{
+ int n;
+ HMODULE Ignore;
+
+ Ignore = LoadLibrary("user32.dll");
+
+ for (n = 0; n <= RTL_UNLOAD_EVENT_TRACE_NUMBER; ++n)
+ {
+ trace("Num: %u\n", n);
+ Test_LoadUnload();
+ }
+ Test_Dump();
+
+ FreeLibrary(Ignore);
+}
diff --git a/modules/rostests/apitests/ntdll/testlist.c
b/modules/rostests/apitests/ntdll/testlist.c
index ac2d0cd529d..b2131a07b81 100644
--- a/modules/rostests/apitests/ntdll/testlist.c
+++ b/modules/rostests/apitests/ntdll/testlist.c
@@ -57,6 +57,7 @@ extern void func_RtlGetFullPathName_UstrEx(void);
extern void func_RtlGetLengthWithoutTrailingPathSeperators(void);
extern void func_RtlGetLongestNtPathLength(void);
extern void func_RtlGetNtProductType(void);
+extern void func_RtlGetUnloadEventTrace(void);
extern void func_RtlHandle(void);
extern void func_RtlImageRvaToVa(void);
extern void func_RtlIsNameLegalDOS8Dot3(void);
@@ -128,6 +129,7 @@ const struct test winetest_testlist[] =
{ "RtlGetLengthWithoutTrailingPathSeperators",
func_RtlGetLengthWithoutTrailingPathSeperators },
{ "RtlGetLongestNtPathLength", func_RtlGetLongestNtPathLength },
{ "RtlGetNtProductType", func_RtlGetNtProductType },
+ { "RtlGetUnloadEventTrace", func_RtlGetUnloadEventTrace },
{ "RtlHandle", func_RtlHandle },
{ "RtlImageRvaToVa", func_RtlImageRvaToVa },
{ "RtlIsNameLegalDOS8Dot3", func_RtlIsNameLegalDOS8Dot3 },