1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
|
/*
** Zabbix
** Copyright (C) 2001-2014 Zabbix SIA
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation; either version 2 of the License, or
** (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**/
#ifndef ZABBIX_EVENTLOG_H
#define ZABBIX_EVENTLOG_H
#ifndef _WINDOWS
# error "This module is only available for Windows OS"
#endif
/* Structures from winevt.h file */
typedef HANDLE EVT_HANDLE, *PEVT_HANDLE;
typedef struct _EVT_VARIANT
{
union
{
BOOL BooleanVal;
INT8 SByteVal;
INT16 Int16Val;
INT32 Int32Val;
INT64 Int64Val;
UINT8 ByteVal;
UINT16 UInt16Val;
UINT32 UInt32Val;
UINT64 UInt64Val;
float SingleVal;
double DoubleVal;
ULONGLONG FileTimeVal;
SYSTEMTIME *SysTimeVal;
GUID *GuidVal;
const wchar_t *StringVal;
const char *AnsiStringVal;
PBYTE BinaryVal;
PSID SidVal;
size_t SizeTVal;
/* array fields */
BOOL *BooleanArr;
INT8 *SByteArr;
INT16 *Int16Arr;
INT32 *Int32Arr;
INT64 *Int64Arr;
UINT8 *ByteArr;
UINT16 *UInt16Arr;
UINT32 *UInt32Arr;
UINT64 *UInt64Arr;
float *SingleArr;
double *DoubleArr;
FILETIME *FileTimeArr;
SYSTEMTIME *SysTimeArr;
GUID *GuidArr;
wchar_t **StringArr;
char **AnsiStringArr;
PSID *SidArr;
size_t *SizeTArr;
/* internal fields */
EVT_HANDLE EvtHandleVal;
const wchar_t *XmlVal;
const wchar_t **XmlValArr;
};
DWORD Count; /* number of elements (not length) in bytes */
DWORD Type;
}
EVT_VARIANT, *PEVT_VARIANT;
typedef enum _EVT_LOG_PROPERTY_ID
{
EvtLogCreationTime = 0, /* EvtVarTypeFileTime */
EvtLogLastAccessTime, /* EvtVarTypeFileTime */
EvtLogLastWriteTime, /* EvtVarTypeFileTime */
EvtLogFileSize, /* EvtVarTypeUInt64 */
EvtLogAttributes, /* EvtVarTypeUInt32 */
EvtLogNumberOfLogRecords, /* EvtVarTypeUInt64 */
EvtLogOldestRecordNumber, /* EvtVarTypeUInt64 */
EvtLogFull, /* EvtVarTypeBoolean */
}
EVT_LOG_PROPERTY_ID;
typedef enum _EVT_RENDER_CONTEXT_FLAGS
{
EvtRenderContextValues = 0, /* render specific properties */
EvtRenderContextSystem, /* render all system properties (System) */
EvtRenderContextUser /* render all user properties (User/EventData) */
}
EVT_RENDER_CONTEXT_FLAGS;
typedef enum _EVT_QUERY_FLAGS
{
EvtQueryChannelPath = 0x1,
EvtQueryFilePath = 0x2,
EvtQueryForwardDirection = 0x100,
EvtQueryReverseDirection = 0x200,
EvtQueryTolerateQueryErrors = 0x1000
}
EVT_QUERY_FLAGS;
typedef enum _EVT_RENDER_FLAGS
{
EvtRenderEventValues = 0, /* variants */
EvtRenderEventXml, /* XML */
EvtRenderBookmark /* bookmark */
}
EVT_RENDER_FLAGS;
typedef enum _EVT_FORMAT_MESSAGE_FLAGS
{
EvtFormatMessageEvent = 1,
EvtFormatMessageLevel,
EvtFormatMessageTask,
EvtFormatMessageOpcode,
EvtFormatMessageKeyword,
EvtFormatMessageChannel,
EvtFormatMessageProvider,
EvtFormatMessageId,
EvtFormatMessageXml,
}
EVT_FORMAT_MESSAGE_FLAGS;
typedef enum _EVT_OPEN_LOG_FLAGS
{
EvtOpenChannelPath = 0x1,
EvtOpenFilePath = 0x2
}
EVT_OPEN_LOG_FLAGS;
typedef enum _EVT_VARIANT_TYPE
{
EvtVarTypeNull = 0,
EvtVarTypeString = 1,
EvtVarTypeAnsiString = 2,
EvtVarTypeSByte = 3,
EvtVarTypeByte = 4,
EvtVarTypeInt16 = 5,
EvtVarTypeUInt16 = 6,
EvtVarTypeInt32 = 7,
EvtVarTypeUInt32 = 8,
EvtVarTypeInt64 = 9,
EvtVarTypeUInt64 = 10,
EvtVarTypeSingle = 11,
EvtVarTypeDouble = 12,
EvtVarTypeBoolean = 13,
EvtVarTypeBinary = 14,
EvtVarTypeGuid = 15,
EvtVarTypeSizeT = 16,
EvtVarTypeFileTime = 17,
EvtVarTypeSysTime = 18,
EvtVarTypeSid = 19,
EvtVarTypeHexInt32 = 20,
EvtVarTypeHexInt64 = 21,
/* these types used internally */
EvtVarTypeEvtHandle = 32,
EvtVarTypeEvtXml = 35
}
EVT_VARIANT_TYPE;
int process_eventlog(const char *source, zbx_uint64_t *lastlogsize, unsigned long *out_timestamp,
char **out_source, unsigned short *out_severity, char **out_message, unsigned long *out_eventid,
unsigned char skip_old_data);
int process_eventlog6(const char *source, zbx_uint64_t *lastlogsize, unsigned long *out_timestamp,
char **out_provider, char **out_source, unsigned short *out_severity, char **out_message,
unsigned long *out_eventid, zbx_uint64_t *FirstID, zbx_uint64_t *LastID,
EVT_HANDLE *render_context, EVT_HANDLE *query, zbx_uint64_t *keywords,
unsigned char skip_old_data);
int initialize_eventlog6(const char *source, zbx_uint64_t *lastlogsize, zbx_uint64_t *FirstID,
zbx_uint64_t *LastID, EVT_HANDLE *render_context, EVT_HANDLE *query);
int finalize_eventlog6(EVT_HANDLE *render_context, EVT_HANDLE *query);
EVT_HANDLE WINAPI EvtOpenLog(EVT_HANDLE Session, const wchar_t *Path, DWORD Flags);
EVT_HANDLE WINAPI EvtCreateRenderContext(DWORD ValuePathsCount, const wchar_t **ValuePaths, DWORD Flags);
EVT_HANDLE WINAPI EvtQuery(EVT_HANDLE Session, const wchar_t *Path, const wchar_t *Query, DWORD Flags);
EVT_HANDLE WINAPI EvtOpenPublisherMetadata(EVT_HANDLE Session, const wchar_t *PublisherId, const wchar_t *LogFilePath,
LCID Locale, DWORD Flags);
BOOL WINAPI EvtGetLogInfo( EVT_HANDLE Log, EVT_LOG_PROPERTY_ID PropertyId, DWORD PropertyValueBufferSize,
PEVT_VARIANT PropertyValueBuffer, __out PDWORD PropertyValueBufferUsed);
BOOL WINAPI EvtRender(EVT_HANDLE Context, EVT_HANDLE Fragment, DWORD Flags, DWORD BufferSize,
__out_bcount_part_opt(BufferSize, *BufferUsed) PVOID Buffer, __out PDWORD BufferUsed,
__out PDWORD PropertyCount);
BOOL WINAPI EvtNext(EVT_HANDLE ResultSet, DWORD EventsSize, PEVT_HANDLE Events, DWORD Timeout, DWORD Flags,
__out PDWORD Returned);
BOOL WINAPI EvtClose(EVT_HANDLE Object);
BOOL WINAPI EvtFormatMessage(EVT_HANDLE PublisherMetadata, EVT_HANDLE Event, DWORD MessageId,
DWORD ValueCount, PEVT_VARIANT Values, DWORD Flags, DWORD BufferSize,
__out_ecount_part_opt(BufferSize, *BufferUsed) wchar_t *Buffer, __out PDWORD BufferUsed);
#endif /* ZABBIX_EVENTLOG_H */
|