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