1 /* 2 * PROJECT: ReactOS EventLog Service 3 * LICENSE: GPL - See COPYING in the top level directory 4 * FILE: base/services/eventlog/eventlog.h 5 * PURPOSE: Precompiled Header for the Event logging service 6 * COPYRIGHT: Copyright 2005 Saveliy Tretiakov 7 */ 8 9 #ifndef __EVENTLOG_H__ 10 #define __EVENTLOG_H__ 11 12 #include <stdarg.h> 13 14 /* PSDK/NDK Headers */ 15 #define WIN32_NO_STATUS 16 #include <windef.h> 17 #include <winbase.h> 18 19 #define NTOS_MODE_USER 20 #include <ndk/rtlfuncs.h> 21 #include <ndk/obfuncs.h> 22 23 #define ROUND_DOWN(n, align) (((ULONG)n) & ~((align) - 1l)) 24 #define ROUND_UP(n, align) ROUND_DOWN(((ULONG)n) + (align) - 1, (align)) 25 26 #include <evtlib.h> 27 28 #include <eventlogrpc_s.h> 29 #include <strsafe.h> 30 31 /* Defined in evtlib.h */ 32 // #define LOGFILE_SIGNATURE 0x654c664c // "LfLe" 33 34 typedef struct _LOGFILE 35 { 36 EVTLOGFILE LogFile; 37 HANDLE FileHandle; 38 WCHAR *LogName; 39 RTL_RESOURCE Lock; 40 BOOL Permanent; 41 LIST_ENTRY ListEntry; 42 } LOGFILE, *PLOGFILE; 43 44 typedef struct _EVENTSOURCE 45 { 46 LIST_ENTRY EventSourceListEntry; 47 PLOGFILE LogFile; 48 WCHAR szName[1]; 49 } EVENTSOURCE, *PEVENTSOURCE; 50 51 52 /* Log Handle Flags */ 53 #define LOG_HANDLE_BACKUP_FILE 1 54 55 typedef struct _LOGHANDLE 56 { 57 LIST_ENTRY LogHandleListEntry; 58 PEVENTSOURCE EventSource; 59 PLOGFILE LogFile; 60 ULONG CurrentRecord; 61 ULONG Flags; 62 WCHAR szName[1]; 63 } LOGHANDLE, *PLOGHANDLE; 64 65 66 /* eventlog.c */ 67 extern PEVENTSOURCE EventLogSource; 68 69 VOID PRINT_RECORD(PEVENTLOGRECORD pRec); 70 71 72 /* eventsource.c */ 73 VOID InitEventSourceList(VOID); 74 75 BOOL 76 LoadEventSources(HKEY hKey, 77 PLOGFILE pLogFile); 78 79 PEVENTSOURCE 80 GetEventSourceByName(LPCWSTR Name); 81 82 83 /* file.c */ 84 VOID LogfListInitialize(VOID); 85 DWORD LogfListItemCount(VOID); 86 PLOGFILE LogfListItemByIndex(DWORD Index); 87 PLOGFILE LogfListItemByName(LPCWSTR Name); 88 // DWORD LogfListItemIndexByName(WCHAR * Name); 89 90 NTSTATUS 91 LogfCreate(PLOGFILE* LogFile, 92 PCWSTR LogName, 93 PUNICODE_STRING FileName, 94 ULONG MaxSize, 95 ULONG Retention, 96 BOOLEAN Permanent, 97 BOOLEAN Backup); 98 99 VOID 100 LogfClose(PLOGFILE LogFile, 101 BOOLEAN ForceClose); 102 103 VOID LogfCloseAll(VOID); 104 105 NTSTATUS 106 LogfClearFile(PLOGFILE LogFile, 107 PUNICODE_STRING BackupFileName); 108 109 NTSTATUS 110 LogfBackupFile(PLOGFILE LogFile, 111 PUNICODE_STRING BackupFileName); 112 113 NTSTATUS 114 LogfReadEvents(PLOGFILE LogFile, 115 ULONG Flags, 116 PULONG RecordNumber, 117 ULONG BufSize, 118 PBYTE Buffer, 119 PULONG BytesRead, 120 PULONG BytesNeeded, 121 BOOLEAN Ansi); 122 123 NTSTATUS 124 LogfWriteRecord(PLOGFILE LogFile, 125 PEVENTLOGRECORD Record, 126 SIZE_T BufSize); 127 128 PEVENTLOGRECORD 129 LogfAllocAndBuildNewRecord(PSIZE_T pRecSize, 130 ULONG Time, 131 USHORT wType, 132 USHORT wCategory, 133 ULONG dwEventId, 134 PUNICODE_STRING SourceName, 135 PUNICODE_STRING ComputerName, 136 ULONG dwSidLength, 137 PSID pUserSid, 138 USHORT wNumStrings, 139 PWSTR pStrings, 140 ULONG dwDataSize, 141 PVOID pRawData); 142 143 static __inline void LogfFreeRecord(PEVENTLOGRECORD Record) 144 { 145 RtlFreeHeap(GetProcessHeap(), 0, Record); 146 } 147 148 VOID 149 LogfReportEvent(USHORT wType, 150 USHORT wCategory, 151 ULONG dwEventId, 152 USHORT wNumStrings, 153 PWSTR pStrings, 154 ULONG dwDataSize, 155 PVOID pRawData); 156 157 158 /* logport.c */ 159 NTSTATUS WINAPI PortThreadRoutine(PVOID Param); 160 161 NTSTATUS InitLogPort(VOID); 162 163 NTSTATUS ProcessPortMessage(VOID); 164 165 /* rpc.c */ 166 DWORD WINAPI RpcThreadRoutine(LPVOID lpParameter); 167 168 #endif /* __EVENTLOG_H__ */ 169