1 /*
2 * PROJECT: ReactOS Run-Time Library
3 * LICENSE: BSD - See COPYING.ARM in the top level directory
4 * PURPOSE: Rtl Trace Routines
5 */
6
7 /* INCLUDES *******************************************************************/
8
9 #include <rtl.h>
10 #define NDEBUG
11 #include <debug.h>
12
13 static RTL_UNLOAD_EVENT_TRACE RtlpUnloadEventTrace[RTL_UNLOAD_EVENT_TRACE_NUMBER];
14 static UINT RtlpUnloadEventTraceIndex = 0;
15
16 /* FUNCTIONS ******************************************************************/
17
18 PRTL_UNLOAD_EVENT_TRACE
19 NTAPI
RtlGetUnloadEventTrace(VOID)20 RtlGetUnloadEventTrace(VOID)
21 {
22 /* Just return a pointer to an array, according to MSDN */
23 return RtlpUnloadEventTrace;
24 }
25
26 VOID
27 NTAPI
LdrpRecordUnloadEvent(_In_ PLDR_DATA_TABLE_ENTRY LdrEntry)28 LdrpRecordUnloadEvent(_In_ PLDR_DATA_TABLE_ENTRY LdrEntry)
29 {
30 PIMAGE_NT_HEADERS NtHeaders;
31 UINT Sequence = RtlpUnloadEventTraceIndex++;
32 UINT Index = Sequence % RTL_UNLOAD_EVENT_TRACE_NUMBER;
33 USHORT StringLen;
34
35 DPRINT("LdrpRecordUnloadEvent(%wZ, %p - %p)\n", &LdrEntry->BaseDllName, LdrEntry->DllBase,
36 (ULONG_PTR)LdrEntry->DllBase + LdrEntry->SizeOfImage);
37
38 RtlpUnloadEventTrace[Index].BaseAddress = LdrEntry->DllBase;
39 RtlpUnloadEventTrace[Index].SizeOfImage = LdrEntry->SizeOfImage;
40 RtlpUnloadEventTrace[Index].Sequence = Sequence;
41
42 NtHeaders = RtlImageNtHeader(LdrEntry->DllBase);
43
44 if (NtHeaders)
45 {
46 RtlpUnloadEventTrace[Index].TimeDateStamp = NtHeaders->FileHeader.TimeDateStamp;
47 RtlpUnloadEventTrace[Index].CheckSum = NtHeaders->OptionalHeader.CheckSum;
48 }
49 else
50 {
51 RtlpUnloadEventTrace[Index].TimeDateStamp = 0;
52 RtlpUnloadEventTrace[Index].CheckSum = 0;
53 }
54
55 StringLen = min(LdrEntry->BaseDllName.Length / sizeof(WCHAR), RTL_NUMBER_OF(RtlpUnloadEventTrace[Index].ImageName));
56 RtlCopyMemory(RtlpUnloadEventTrace[Index].ImageName, LdrEntry->BaseDllName.Buffer, StringLen * sizeof(WCHAR));
57 if (StringLen < RTL_NUMBER_OF(RtlpUnloadEventTrace[Index].ImageName))
58 RtlpUnloadEventTrace[Index].ImageName[StringLen] = 0;
59 }
60
61 BOOLEAN
62 NTAPI
RtlTraceDatabaseAdd(IN PRTL_TRACE_DATABASE Database,IN ULONG Count,IN PVOID * Trace,OUT OPTIONAL PRTL_TRACE_BLOCK * TraceBlock)63 RtlTraceDatabaseAdd(IN PRTL_TRACE_DATABASE Database,
64 IN ULONG Count,
65 IN PVOID *Trace,
66 OUT OPTIONAL PRTL_TRACE_BLOCK *TraceBlock)
67 {
68 UNIMPLEMENTED;
69 return FALSE;
70 }
71
72 PRTL_TRACE_DATABASE
73 NTAPI
RtlTraceDatabaseCreate(IN ULONG Buckets,IN OPTIONAL SIZE_T MaximumSize,IN ULONG Flags,IN ULONG Tag,IN OPTIONAL RTL_TRACE_HASH_FUNCTION HashFunction)74 RtlTraceDatabaseCreate(IN ULONG Buckets,
75 IN OPTIONAL SIZE_T MaximumSize,
76 IN ULONG Flags,
77 IN ULONG Tag,
78 IN OPTIONAL RTL_TRACE_HASH_FUNCTION HashFunction)
79 {
80 UNIMPLEMENTED;
81 return NULL;
82 }
83
84 BOOLEAN
85 NTAPI
RtlTraceDatabaseDestroy(IN PRTL_TRACE_DATABASE Database)86 RtlTraceDatabaseDestroy(IN PRTL_TRACE_DATABASE Database)
87 {
88 UNIMPLEMENTED;
89 return FALSE;
90 }
91
92 BOOLEAN
93 NTAPI
RtlTraceDatabaseEnumerate(IN PRTL_TRACE_DATABASE Database,IN PRTL_TRACE_ENUMERATE TraceEnumerate,IN OUT PRTL_TRACE_BLOCK * TraceBlock)94 RtlTraceDatabaseEnumerate(IN PRTL_TRACE_DATABASE Database,
95 IN PRTL_TRACE_ENUMERATE TraceEnumerate,
96 IN OUT PRTL_TRACE_BLOCK *TraceBlock)
97 {
98 UNIMPLEMENTED;
99 return FALSE;
100 }
101
102
103 BOOLEAN
104 NTAPI
RtlTraceDatabaseFind(IN PRTL_TRACE_DATABASE Database,IN ULONG Count,IN PVOID * Trace,OUT OPTIONAL PRTL_TRACE_BLOCK * TraceBlock)105 RtlTraceDatabaseFind(IN PRTL_TRACE_DATABASE Database,
106 IN ULONG Count,
107 IN PVOID *Trace,
108 OUT OPTIONAL PRTL_TRACE_BLOCK *TraceBlock)
109 {
110 UNIMPLEMENTED;
111 return FALSE;
112 }
113
114 BOOLEAN
115 NTAPI
RtlTraceDatabaseLock(IN PRTL_TRACE_DATABASE Database)116 RtlTraceDatabaseLock(IN PRTL_TRACE_DATABASE Database)
117 {
118 UNIMPLEMENTED;
119 return FALSE;
120 }
121
122 BOOLEAN
123 NTAPI
RtlTraceDatabaseUnlock(IN PRTL_TRACE_DATABASE Database)124 RtlTraceDatabaseUnlock(IN PRTL_TRACE_DATABASE Database)
125 {
126 UNIMPLEMENTED;
127 return FALSE;
128 }
129
130 BOOLEAN
131 NTAPI
RtlTraceDatabaseValidate(IN PRTL_TRACE_DATABASE Database)132 RtlTraceDatabaseValidate(IN PRTL_TRACE_DATABASE Database)
133 {
134 UNIMPLEMENTED;
135 return FALSE;
136 }
137