df0ab151c41465951af8f11eb56a3f804fab1240
[reactos.git] / reactos / base / services / eventlog / eventlog.h
1 /*
2 * PROJECT: ReactOS kernel
3 * LICENSE: GPL - See COPYING in the top level directory
4 * FILE: services/eventlog/eventlog.h
5 * PURPOSE: Event logging service
6 * COPYRIGHT: Copyright 2005 Saveliy Tretiakov
7 */
8
9 #ifndef __EVENTLOG_H__
10 #define __EVENTLOG_H__
11
12 #define NDEBUG
13 #define WIN32_NO_STATUS
14
15 #include <windows.h>
16 #include <lpctypes.h>
17 #include <lpcfuncs.h>
18 #include <rtlfuncs.h>
19 #include <obfuncs.h>
20 #include <iotypes.h>
21 #include <debug.h>
22 #include "eventlogrpc_s.h"
23
24 typedef struct _IO_ERROR_LPC
25 {
26 PORT_MESSAGE Header;
27 IO_ERROR_LOG_MESSAGE Message;
28 } IO_ERROR_LPC, *PIO_ERROR_LPC;
29
30 #define MAJORVER 1
31 #define MINORVER 1
32
33 /*
34 * Our file format will be compatible with NT's
35 */
36 #define LOGFILE_SIGNATURE 0x654c664c
37
38 /*
39 * Flags used in logfile header
40 */
41 #define ELF_LOGFILE_HEADER_DIRTY 1
42 #define ELF_LOGFILE_HEADER_WRAP 2
43 #define ELF_LOGGFILE_LOGFULL_WRITTEN 4
44 #define ELF_LOGFILE_ARCHIVE_SET 8
45
46 /* FIXME: MSDN reads that the following two structs are in winnt.h. Are they? */
47 typedef struct _EVENTLOGHEADER
48 {
49 ULONG HeaderSize;
50 ULONG Signature;
51 ULONG MajorVersion;
52 ULONG MinorVersion;
53 ULONG StartOffset;
54 ULONG EndOffset;
55 ULONG CurrentRecordNumber;
56 ULONG OldestRecordNumber;
57 ULONG MaxSize;
58 ULONG Flags;
59 ULONG Retention;
60 ULONG EndHeaderSize;
61 } EVENTLOGHEADER, *PEVENTLOGHEADER;
62
63 typedef struct _EVENTLOGEOF
64 {
65 ULONG RecordSizeBeginning;
66 ULONG Ones;
67 ULONG Twos;
68 ULONG Threes;
69 ULONG Fours;
70 ULONG BeginRecord;
71 ULONG EndRecord;
72 ULONG CurrentRecordNumber;
73 ULONG OldestRecordNumber;
74 ULONG RecordSizeEnd;
75 } EVENTLOGEOF, *PEVENTLOGEOF;
76
77 typedef struct _EVENT_OFFSET_INFO
78 {
79 ULONG EventNumber;
80 ULONG EventOffset;
81 } EVENT_OFFSET_INFO, *PEVENT_OFFSET_INFO;
82
83 typedef struct _LOGFILE
84 {
85 HANDLE hFile;
86 EVENTLOGHEADER Header;
87 WCHAR *LogName;
88 WCHAR *FileName;
89 CRITICAL_SECTION cs;
90 PEVENT_OFFSET_INFO OffsetInfo;
91 ULONG OffsetInfoSize;
92 ULONG OffsetInfoNext;
93 LIST_ENTRY ListEntry;
94 } LOGFILE, *PLOGFILE;
95
96 typedef struct _EVENTSOURCE
97 {
98 LIST_ENTRY EventSourceListEntry;
99 PLOGFILE LogFile;
100 ULONG CurrentRecord;
101 WCHAR szName[1];
102 } EVENTSOURCE, *PEVENTSOURCE;
103
104 /* file.c */
105 VOID LogfListInitialize(VOID);
106
107 PLOGFILE LogfListHead(VOID);
108
109 INT LogfListItemCount(VOID);
110
111 PLOGFILE LogfListItemByIndex(INT Index);
112
113 PLOGFILE LogfListItemByName(WCHAR * Name);
114
115 INT LogfListItemIndexByName(WCHAR * Name);
116
117 VOID LogfListAddItem(PLOGFILE Item);
118
119 VOID LogfListRemoveItem(PLOGFILE Item);
120
121 DWORD LogfReadEvent(PLOGFILE LogFile,
122 DWORD Flags,
123 DWORD * RecordNumber,
124 DWORD BufSize,
125 PBYTE Buffer,
126 DWORD * BytesRead,
127 DWORD * BytesNeeded);
128
129 BOOL LogfWriteData(PLOGFILE LogFile,
130 DWORD BufSize,
131 PBYTE Buffer);
132
133 PLOGFILE LogfCreate(WCHAR * LogName,
134 WCHAR * FileName);
135
136 VOID LogfClose(PLOGFILE LogFile);
137
138 VOID LogfCloseAll(VOID);
139
140 BOOL LogfInitializeNew(PLOGFILE LogFile);
141
142 BOOL LogfInitializeExisting(PLOGFILE LogFile);
143
144 DWORD LogfGetOldestRecord(PLOGFILE LogFile);
145
146 DWORD LogfGetCurrentRecord(PLOGFILE LogFile);
147
148 ULONG LogfOffsetByNumber(PLOGFILE LogFile,
149 DWORD RecordNumber);
150
151 BOOL LogfAddOffsetInformation(PLOGFILE LogFile,
152 ULONG ulNumber,
153 ULONG ulOffset);
154
155 BOOL LogfDeleteOffsetInformation(PLOGFILE LogFile,
156 ULONG ulNumber);
157
158 PBYTE LogfAllocAndBuildNewRecord(LPDWORD lpRecSize,
159 DWORD dwRecordNumber,
160 WORD wType,
161 WORD wCategory,
162 DWORD dwEventId,
163 LPCWSTR SourceName,
164 LPCWSTR ComputerName,
165 DWORD dwSidLength,
166 PSID lpUserSid,
167 WORD wNumStrings,
168 WCHAR * lpStrings,
169 DWORD dwDataSize,
170 LPVOID lpRawData);
171
172 /* eventlog.c */
173 extern HANDLE MyHeap;
174
175 VOID PRINT_HEADER(PEVENTLOGHEADER header);
176
177 VOID PRINT_RECORD(PEVENTLOGRECORD pRec);
178
179 VOID EventTimeToSystemTime(DWORD EventTime,
180 SYSTEMTIME * SystemTime);
181
182 VOID SystemTimeToEventTime(SYSTEMTIME * pSystemTime,
183 DWORD * pEventTime);
184
185 /* logport.c */
186 NTSTATUS WINAPI PortThreadRoutine(PVOID Param);
187
188 NTSTATUS InitLogPort(VOID);
189
190 NTSTATUS ProcessPortMessage(VOID);
191
192 /* rpc.c */
193 DWORD WINAPI RpcThreadRoutine(LPVOID lpParameter);
194
195 static __inline void LogfFreeRecord(LPVOID Rec)
196 {
197 HeapFree(MyHeap, 0, Rec);
198 }
199
200 #endif /* __EVENTLOG_H__ */