1 /* 2 * PROJECT: ReactOS API tests 3 * LICENSE: GPL-2.0-or-later (https://spdx.org/licenses/GPL-2.0-or-later) 4 * PURPOSE: Test for RtlGetUnloadEventTrace 5 * COPYRIGHT: Copyright 2020 Mark Jansen (mark.jansen@reactos.org) 6 */ 7 8 #include "precomp.h" 9 10 PRTL_UNLOAD_EVENT_TRACE 11 NTAPI 12 RtlGetUnloadEventTrace(VOID); 13 14 #ifndef _WIN64 15 C_ASSERT(sizeof(RTL_UNLOAD_EVENT_TRACE) == 84); 16 C_ASSERT(sizeof(RTL_UNLOAD_EVENT_TRACE) * RTL_UNLOAD_EVENT_TRACE_NUMBER == 0x540); 17 #endif 18 19 static void Test_Dump() 20 { 21 PRTL_UNLOAD_EVENT_TRACE TraceHead, Trace; 22 UINT n; 23 24 TraceHead = RtlGetUnloadEventTrace(); 25 for (n = 0; n < RTL_UNLOAD_EVENT_TRACE_NUMBER; ++n) 26 { 27 ULONG ExpectSequence = n ? n : RTL_UNLOAD_EVENT_TRACE_NUMBER; 28 29 Trace = TraceHead + n; 30 31 ok(Trace->BaseAddress != NULL, "Got no BaseAddress for %u\n", n); 32 ok(Trace->SizeOfImage != 0, "Got no SizeOfImage for %u\n", n); 33 ok(Trace->Sequence == ExpectSequence, 34 "Wrong Sequence: %lu instead of %lu for %u\n", Trace->Sequence, ExpectSequence, n); 35 ok(Trace->TimeDateStamp != 0, "Got no TimeDateStamp for %u\n", n); 36 ok(Trace->CheckSum != 0, "Got no CheckSum for %u\n", n); 37 ok(!wcscmp(Trace->ImageName, L"GetUName.dLl"), "Wrong ImageName for %u: %S\n", n, Trace->ImageName); 38 } 39 } 40 41 #define TESTDLL "GetUName.dLl" 42 static void Test_LoadUnload() 43 { 44 HMODULE mod; 45 static char Buffer[MAX_PATH] = {0}; 46 47 mod = GetModuleHandleA(TESTDLL); 48 ok(mod == NULL, "ERROR, %s already loaded\n", TESTDLL); 49 50 mod = LoadLibraryA(Buffer[0] ? Buffer :TESTDLL); 51 ok(mod != NULL, "ERROR, %s not loaded\n", TESTDLL); 52 53 if (!Buffer[0]) 54 { 55 GetModuleFileNameA(mod, Buffer, _countof(Buffer)); 56 } 57 else 58 { 59 Buffer[0] = '\0'; 60 } 61 62 FreeLibrary(mod); 63 64 mod = GetModuleHandleA(TESTDLL); 65 ok(mod == NULL, "ERROR, %s still loaded\n", TESTDLL); 66 } 67 68 START_TEST(RtlGetUnloadEventTrace) 69 { 70 int n; 71 HMODULE Ignore; 72 73 Ignore = LoadLibrary("user32.dll"); 74 75 for (n = 0; n <= RTL_UNLOAD_EVENT_TRACE_NUMBER; ++n) 76 { 77 trace("Num: %u\n", n); 78 Test_LoadUnload(); 79 } 80 Test_Dump(); 81 82 FreeLibrary(Ignore); 83 } 84