ReactOS  0.4.15-dev-3299-gbe8e5fc
RtlGetUnloadEventTrace.c
Go to the documentation of this file.
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 
11 NTAPI
13 
14 #ifndef _WIN64
15 C_ASSERT(sizeof(RTL_UNLOAD_EVENT_TRACE) == 84);
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 
48  ok(mod == NULL, "ERROR, %s already loaded\n", TESTDLL);
49 
51  ok(mod != NULL, "ERROR, %s not loaded\n", TESTDLL);
52 
53  if (!Buffer[0])
54  {
56  }
57  else
58  {
59  Buffer[0] = '\0';
60  }
61 
63 
65  ok(mod == NULL, "ERROR, %s still loaded\n", TESTDLL);
66 }
67 
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);
79  }
80  Test_Dump();
81 
82  FreeLibrary(Ignore);
83 }
#define LoadLibrary
Definition: winbase.h:3718
GLdouble n
Definition: glext.h:7729
PRTL_UNLOAD_EVENT_TRACE NTAPI RtlGetUnloadEventTrace(VOID)
Definition: trace.c:20
DWORD WINAPI GetModuleFileNameA(HINSTANCE hModule, LPSTR lpFilename, DWORD nSize)
Definition: loader.c:539
static void Test_Dump()
NTSTATUS(* NTAPI)(IN PFILE_FULL_EA_INFORMATION EaBuffer, IN ULONG EaLength, OUT PULONG ErrorOffset)
Definition: IoEaTest.cpp:117
HINSTANCE WINAPI DECLSPEC_HOTPATCH LoadLibraryA(LPCSTR lpLibFileName)
Definition: loader.c:111
Definition: bufpool.h:45
static void Test_LoadUnload()
#define FreeLibrary(x)
Definition: compat.h:607
#define trace
Definition: atltest.h:70
#define _countof(array)
Definition: sndvol32.h:68
#define MAX_PATH
Definition: compat.h:34
#define TESTDLL
C_ASSERT(sizeof(RTL_UNLOAD_EVENT_TRACE)==84)
static const WCHAR L[]
Definition: oid.c:1250
HMODULE WINAPI DECLSPEC_HOTPATCH GetModuleHandleA(LPCSTR lpModuleName)
Definition: loader.c:812
#define Trace(x)
Definition: inflate.c:42
_Check_return_ _CRTIMP int __cdecl wcscmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
#define RTL_UNLOAD_EVENT_TRACE_NUMBER
Definition: rtltypes.h:1229
#define ok(value,...)
Definition: atltest.h:57
unsigned int UINT
Definition: ndis.h:50
#define NULL
Definition: types.h:112
unsigned int ULONG
Definition: retypes.h:1
static int mod
Definition: i386-dis.c:1281
START_TEST(RtlGetUnloadEventTrace)