1c2c66affSColin Finck /*
2c2c66affSColin Finck  * PROJECT:     ReactOS Event Log Viewer
389bdca61SHermès Bélusca-Maïto  * LICENSE:     GPL-2.0-or-later (https://spdx.org/licenses/GPL-2.0-or-later)
489bdca61SHermès Bélusca-Maïto  * PURPOSE:     Event Log Viewer header.
589bdca61SHermès Bélusca-Maïto  * COPYRIGHT:   Copyright 2007 Marc Piulachs <marc.piulachs@codexchange.net>
689bdca61SHermès Bélusca-Maïto  *              Copyright 2008-2016 Eric Kohl <eric.kohl@reactos.org>
789bdca61SHermès Bélusca-Maïto  *              Copyright 2016-2022 Hermès Bélusca-Maïto <hermes.belusca-maito@reactos.org>
8c2c66affSColin Finck  */
9c2c66affSColin Finck 
10c2c66affSColin Finck #ifndef _EVENTVWR_PCH_
11c2c66affSColin Finck #define _EVENTVWR_PCH_
12c2c66affSColin Finck 
13*069b08daSHermès Bélusca-Maïto #pragma once
14c2c66affSColin Finck 
15*069b08daSHermès Bélusca-Maïto /* C Headers */
16c2c66affSColin Finck #include <stdio.h>
17c2c66affSColin Finck #include <stdlib.h>
18c2c66affSColin Finck 
19*069b08daSHermès Bélusca-Maïto #include <assert.h>
20*069b08daSHermès Bélusca-Maïto #define ASSERT(x) assert(x)
21c2c66affSColin Finck 
22*069b08daSHermès Bélusca-Maïto /* PSDK Headers */
23*069b08daSHermès Bélusca-Maïto #define WIN32_NO_STATUS
24c2c66affSColin Finck #include <windef.h>
25c2c66affSColin Finck #include <winbase.h>
26c2c66affSColin Finck #include <wingdi.h>
27c2c66affSColin Finck #include <winuser.h>
28c2c66affSColin Finck #include <winnls.h>
29c2c66affSColin Finck #include <winreg.h>
30c2c66affSColin Finck 
31*069b08daSHermès Bélusca-Maïto #include <ndk/rtlfuncs.h> // For linked-lists.
32c2c66affSColin Finck 
33c2c66affSColin Finck #define ROUND_DOWN(n, align) (((ULONG)n) & ~((align) - 1l))
34c2c66affSColin Finck #define ROUND_UP(n, align) ROUND_DOWN(((ULONG)n) + (align) - 1, (align))
35c2c66affSColin Finck 
36c2c66affSColin Finck #include <strsafe.h>
37c2c66affSColin Finck 
38c2c66affSColin Finck #include <commctrl.h>
39c2c66affSColin Finck #include <commdlg.h>
40c2c66affSColin Finck 
41c2c66affSColin Finck #include <richedit.h>
42c2c66affSColin Finck 
43c2c66affSColin Finck /* Missing RichEdit flags in our richedit.h */
44c2c66affSColin Finck #define AURL_ENABLEURL          1
45c2c66affSColin Finck #define AURL_ENABLEEMAILADDR    2
46c2c66affSColin Finck #define AURL_ENABLETELNO        4
47c2c66affSColin Finck #define AURL_ENABLEEAURLS       8
48c2c66affSColin Finck #define AURL_ENABLEDRIVELETTERS 16
49c2c66affSColin Finck 
50c2c66affSColin Finck #include <windowsx.h>
51c2c66affSColin Finck 
52c2c66affSColin Finck /*
53c2c66affSColin Finck  * windowsx.h extensions
54c2c66affSColin Finck  */
55c2c66affSColin Finck #define EnableDlgItem(hDlg, nID, bEnable)   \
56c2c66affSColin Finck     EnableWindow(GetDlgItem((hDlg), (nID)), (bEnable))
57c2c66affSColin Finck 
58c2c66affSColin Finck #define ProgressBar_SetPos(hwndCtl,pos)    \
59c2c66affSColin Finck     ((int)SNDMSG((hwndCtl),PBM_SETPOS,(WPARAM)(int)(pos),(LPARAM)0))
60c2c66affSColin Finck #define ProgressBar_SetRange(hwndCtl,range)    \
61c2c66affSColin Finck     ((int)SNDMSG((hwndCtl),PBM_SETRANGE,(WPARAM)0,(LPARAM)(range)))
62c2c66affSColin Finck #define ProgressBar_SetStep(hwndCtl,inc)    \
63c2c66affSColin Finck     ((int)SNDMSG((hwndCtl),PBM_SETSTEP,(WPARAM)(int)(inc),(LPARAM)0))
64c2c66affSColin Finck #define ProgressBar_StepIt(hwndCtl)         \
65c2c66affSColin Finck     ((int)SNDMSG((hwndCtl),PBM_STEPIT,(WPARAM)0,(LPARAM)0))
66c2c66affSColin Finck 
67c2c66affSColin Finck #define StatusBar_GetItemRect(hwndCtl,index,lprc)   \
68c2c66affSColin Finck     ((BOOL)SNDMSG((hwndCtl),SB_GETRECT,(WPARAM)(int)(index),(LPARAM)(RECT*)(lprc)))
69c2c66affSColin Finck #define StatusBar_SetText(hwndCtl,index,data)   \
70c2c66affSColin Finck     ((BOOL)SNDMSG((hwndCtl),SB_SETTEXT,(WPARAM)(index),(LPARAM)(data)))
71c2c66affSColin Finck 
72c2c66affSColin Finck #ifndef WM_APP
73c2c66affSColin Finck     #define WM_APP 0x8000
74c2c66affSColin Finck #endif
75c2c66affSColin Finck 
76c2c66affSColin Finck #include "resource.h"
77c2c66affSColin Finck 
78c2c66affSColin Finck extern HINSTANCE hInst;
79c2c66affSColin Finck 
80c2c66affSColin Finck 
81c2c66affSColin Finck /*
82c2c66affSColin Finck  * Structure that caches information about an opened event log.
83c2c66affSColin Finck  */
84c2c66affSColin Finck typedef struct _EVENTLOG
85c2c66affSColin Finck {
86c2c66affSColin Finck     LIST_ENTRY ListEntry;
87c2c66affSColin Finck 
88c2c66affSColin Finck     // HANDLE hEventLog;       // At least for user logs, a handle is kept opened (by eventlog service) as long as the event viewer has the focus on this log.
89c2c66affSColin Finck 
90c2c66affSColin Finck     PWSTR ComputerName;     // Computer where the log resides
91c2c66affSColin Finck 
92c2c66affSColin Finck /** Cached information **/
93c2c66affSColin Finck     PWSTR LogName;          // Internal name (from registry, or file path for user logs)
94c2c66affSColin Finck     PWSTR FileName;         // Cached, for user logs; retrieved once (at startup) from registry for system logs (i.e. may be different from the one opened by the eventlog service)
95c2c66affSColin Finck     // PWSTR DisplayName;     // The default value is the one computed; can be modified by the user for this local session only.
96c2c66affSColin Finck     // We can use the TreeView' item name for the DisplayName...
97c2c66affSColin Finck     BOOL Permanent;         // TRUE: system log; FALSE: user log
98c2c66affSColin Finck 
99c2c66affSColin Finck /** Volatile information **/
100c2c66affSColin Finck     // ULONG Flags;
101c2c66affSColin Finck     // ULONG MaxSize;          // Always retrieved from registry (only valid for system logs)
102c2c66affSColin Finck     // ULONG Retention;        // Always retrieved from registry (only valid for system logs)
103c2c66affSColin Finck } EVENTLOG, *PEVENTLOG;
104c2c66affSColin Finck 
105c2c66affSColin Finck typedef struct _EVENTLOGFILTER
106c2c66affSColin Finck {
107c2c66affSColin Finck     LIST_ENTRY ListEntry;
108c2c66affSColin Finck 
109c2c66affSColin Finck     LONG ReferenceCount;
110c2c66affSColin Finck 
111c2c66affSColin Finck     // HANDLE hEnumEventsThread;
112c2c66affSColin Finck     // HANDLE hStopEnumEvent;
113c2c66affSColin Finck 
114c2c66affSColin Finck     // PWSTR DisplayName;     // The default value is the one computed; can be modified by the user for this local session only.
115c2c66affSColin Finck     // We can use the TreeView' item name for the DisplayName...
116c2c66affSColin Finck 
117c2c66affSColin Finck     BOOL Information;
118c2c66affSColin Finck     BOOL Warning;
119c2c66affSColin Finck     BOOL Error;
120c2c66affSColin Finck     BOOL AuditSuccess;
121c2c66affSColin Finck     BOOL AuditFailure;
122c2c66affSColin Finck 
123c2c66affSColin Finck     // ULONG Category;
124c2c66affSColin Finck     ULONG EventID;
125c2c66affSColin Finck 
126c2c66affSColin Finck     /*
127c2c66affSColin Finck      * The following three string filters are multi-strings that enumerate
128c2c66affSColin Finck      * the list of sources/users/computers to be shown. If a string points
129c2c66affSColin Finck      * to an empty string: "\0", it filters for an empty source/user/computer.
130c2c66affSColin Finck      * If a string points to NULL, it filters for all sources/users/computers.
131c2c66affSColin Finck      */
132c2c66affSColin Finck     PWSTR Sources;
133c2c66affSColin Finck     PWSTR Users;
134c2c66affSColin Finck     PWSTR ComputerNames;
135c2c66affSColin Finck 
136c2c66affSColin Finck     /* List of event logs maintained by this filter */
137c2c66affSColin Finck     ULONG NumOfEventLogs;
138c2c66affSColin Finck     PEVENTLOG EventLogs[ANYSIZE_ARRAY];
139c2c66affSColin Finck } EVENTLOGFILTER, *PEVENTLOGFILTER;
140c2c66affSColin Finck 
141c2c66affSColin Finck #endif /* _EVENTVWR_PCH_ */
142