ReactOS 0.4.16-dev-974-g5022a45
eventvwr.c
Go to the documentation of this file.
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 main file.
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#include "eventvwr.h"
11#include "evtdetctl.h"
12
13#include <sddl.h> // For ConvertSidToStringSidW
14#include <shellapi.h>
15#include <shlwapi.h>
16
17#include <pseh/pseh2.h>
18
19// #include "resource.h"
20
21#define LVM_PROGRESS (WM_APP + 1) // Used by the subclassed ListView
22
23static const LPCWSTR EVENTVWR_WNDCLASS = L"EVENTVWR"; /* The main window class name */
24static const LPCWSTR EVENTLOG_BASE_KEY = L"SYSTEM\\CurrentControlSet\\Services\\EventLog\\";
25static const LPCWSTR EVNTVWR_PARAM_KEY = L"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Event Viewer";
26
27/* The 3 system logs that should always exist in the user's system */
28static const LPCWSTR SystemLogs[] =
29{
30 L"Application",
31 L"Security",
32 L"System"
33};
34
35/* MessageFile message buffer size */
36#define EVENT_MESSAGE_EVENTTEXT_BUFFER (1024*10) // NOTE: Used by evtdetctl.c
37#define EVENT_MESSAGE_FILE_BUFFER (1024*10)
38#define EVENT_DLL_SEPARATOR L";"
39#define EVENT_CATEGORY_MESSAGE_FILE L"CategoryMessageFile"
40#define EVENT_MESSAGE_FILE L"EventMessageFile"
41#define EVENT_PARAMETER_MESSAGE_FILE L"ParameterMessageFile"
42
43#define MAX_LOADSTRING 255
44
45#define SPLIT_WIDTH 4
46
47/* Globals */
48HINSTANCE hInst; /* Current instance */
49WCHAR szTitle[MAX_LOADSTRING]; /* The title bar text */
50WCHAR szTitleTemplate[MAX_LOADSTRING]; /* The logged-on title bar text */
51WCHAR szStatusBarTemplate[MAX_LOADSTRING]; /* The status bar text */
52WCHAR szLoadingWait[MAX_LOADSTRING]; /* The "Loading, please wait..." text */
53WCHAR szEmptyList[MAX_LOADSTRING]; /* The "There are no items to show in this view" text */
54WCHAR szSaveFilter[MAX_LOADSTRING]; /* Filter Mask for the save Dialog */
55
56INT nVSplitPos; /* Vertical splitter (1) position */
57INT nHSplitPos; /* Horizontal splitter (2) position */
58BYTE bSplit = 0; /* Splitter state:
59 * 0: No splitting;
60 * 1: Vertical splitting;
61 * 2: Horizontal splitting.
62 */
63
64HWND hwndMainWindow = NULL; /* Main window */
65HWND hwndTreeView; /* TreeView control */
66HWND hwndListView; /* ListView control */ // NOTE: Used by evtdetctl.c
67HWND hwndEventDetails; /* Event details pane */
68HWND hwndStatus; /* Status bar */
69HWND hwndStatusProgress; /* Progress bar in the status bar */
70HMENU hMainMenu; /* The application's main menu */
71
73
74LPWSTR lpComputerName = NULL; /* NULL: local user computer (default) */
75LPWSTR lpszzUserLogsToLoad = NULL; /* The list of user logs to load at startup (multi-string) */
77
78HKEY hkMachine = NULL; // Registry handle to the HKEY_LOCAL_MACHINE key of the remote computer registry.
79
80/* Global event records cache for the current active event log filter */
83
84/* Lists of event logs and event log filters */
88
91
92/*
93 * Setting EnumFilter to a valid pointer and raising the hStartEnumEvent event
94 * triggers the event-enumerator thread to perform a new enumeration.
95 */
97HANDLE hStartStopEnumEvent = NULL; // End-of-application event
98HANDLE hStartEnumEvent = NULL; // Command event
99
100/* Default Open/Save-As dialog box */
102
103
104/* Event Viewer Application Settings */
105typedef struct _SETTINGS
106{
107 BOOL bShowDetailsPane; /* Show (TRUE) or Hide (FALSE) the events details pane */
108 BOOL bShowGrid; /* Show (TRUE) or Hide (FALSE) the events view grid */
109 BOOL bSaveSettings; /* Save (TRUE) or do not save (FALSE) current settings on exit */
110 BOOL bNewestEventsFirst; /* Sort the displayed events the newest ones first (TRUE) or last (FALSE) */
111 INT nVSplitPos; /* Vertical splitter position */
112 INT nHSplitPos; /* Horizontal splitter position */
115
117
118
119/* Forward declarations of functions included in this code module */
120
121static DWORD WINAPI
123
124VOID OpenUserEventLogFile(IN LPCWSTR lpszFileName);
125
129
135
136
137/* MAIN FUNCTIONS *************************************************************/
138
139VOID
141{
142 LPWSTR lpMessageBuffer;
143
144 if (dwError == ERROR_SUCCESS)
145 return;
146
150 NULL,
151 dwError,
153 (LPWSTR)&lpMessageBuffer,
154 0, NULL))
155 {
156 return;
157 }
158
160 LocalFree(lpMessageBuffer);
161}
162
163VOID
165{
167 LPCWSTR lpUsage;
168 INT iUsageLen = LoadStringW(hInst, IDS_USAGE, (LPWSTR)&lpUsage, 0);
169
170 if (iUsageLen == 0)
171 return;
172
173 lpBuffer = HeapAlloc(GetProcessHeap(), 0, (iUsageLen + 1) * sizeof(WCHAR));
174 if (!lpBuffer)
175 return;
176
177 StringCchCopyNW(lpBuffer, iUsageLen + 1, lpUsage, iUsageLen);
179
181}
182
183BOOL
185{
187 INT i, argc;
188 LPWSTR* argv;
189
190 /* Skip any leading whitespace */
191 if (lpCmdLine)
192 {
193 while (iswspace(*lpCmdLine))
194 ++lpCmdLine;
195 }
196
197 /* No command line means no processing needed */
198 if (!lpCmdLine || !*lpCmdLine)
199 return TRUE;
200
201 /* Build the arguments vector */
202 argv = CommandLineToArgvW(lpCmdLine, &argc);
203 if (!argv)
204 return FALSE;
205
206 /* Parse the command line for options (skip the program name) */
207 for (i = 1; i < argc; ++i)
208 {
209 /* Check for new options */
210 if (argv[i][0] == L'-' || argv[i][0] == L'/')
211 {
212 if (argv[i][1] == L'?' && argv[i][2] == 0)
213 {
214 /* Display help */
215 DisplayUsage();
216 goto Quit;
217 }
218 else
219 if (argv[i][2] == L':')
220 {
221 switch (towupper(argv[i][1]))
222 {
223 case L'L':
224 {
225 LPWSTR lpNewBuffer;
226 LPWSTR lpFileName = argv[i] + 3;
227 SIZE_T cbFileName;
228
229 /* Check for a quoted file name */
230 if (*lpFileName == L'\"')
231 {
232 /* Skip this quote, and the last one too if any */
233 ++lpFileName;
234 cbFileName = wcslen(lpFileName);
235 if (cbFileName > 0 && lpFileName[cbFileName - 1] == L'\"')
236 lpFileName[cbFileName - 1] = UNICODE_NULL;
237 }
238
239 /* Skip this one if we do not actually have a file name */
240 if (!*lpFileName)
241 continue;
242
243 cbFileName = (wcslen(lpFileName) + 1) * sizeof(WCHAR);
244
245 /* Reallocate the list of user logs to load */
247 {
248 lpNewBuffer = HeapReAlloc(GetProcessHeap(),
251 /* Count the multi-string NULL-terminator */
252 cbUserLogsSize + cbFileName + sizeof(WCHAR));
253 }
254 else
255 {
256 cbUserLogsSize = 0;
257 lpNewBuffer = HeapAlloc(GetProcessHeap(),
259 /* Count the multi-string NULL-terminator */
260 cbUserLogsSize + cbFileName + sizeof(WCHAR));
261 }
262
263 if (!lpNewBuffer)
264 {
266 goto Quit;
267 }
268
269 lpszzUserLogsToLoad = lpNewBuffer;
270 lpNewBuffer = (LPWSTR)((ULONG_PTR)lpNewBuffer + cbUserLogsSize);
271 cbUserLogsSize += cbFileName;
272
273 /* Save the file name */
274 StringCbCopyW(lpNewBuffer, cbFileName, lpFileName);
275
276 continue;
277 }
278
279 default:
280 break;
281 }
282 }
283
284 /* Unknown argument: display help and bail out */
285 DisplayUsage();
286 goto Quit;
287 }
288 else
289 {
290 /*
291 * An argument that does not start with the switch character.
292 * If this is the first argument then this corresponds to the
293 * optional computer name. Otherwise this is a wrong argument.
294 */
295 if (i == 1)
296 {
297 /* Store the computer name */
298 LPWSTR lpTemp = argv[i];
299 SIZE_T cbLength;
300
301 /* Strip any leading backslashes */
302 while (*lpTemp == L'\\')
303 ++lpTemp;
304
305 cbLength = (wcslen(lpTemp) + 1) * sizeof(WCHAR);
307 if (lpComputerName)
308 {
309 StringCbCopyW(lpComputerName, cbLength, lpTemp);
310 }
311 /* else, fall back to local computer */
312 }
313 else
314 {
315 /* Invalid syntax: display help and bail out */
316 DisplayUsage();
317 goto Quit;
318 }
319 }
320 }
321
322 Success = TRUE;
323
324Quit:
325 /* In case of failure, free anything we have allocated */
326 if (!Success)
327 {
329 {
330 cbUserLogsSize = 0;
333 }
334 if (lpComputerName)
335 {
338 }
339 }
340
341 /* Free the arguments vector and exit */
343 return Success;
344}
345
346BOOL
347LoadSettings(int nDefCmdShow)
348{
349 LONG Result;
350 HKEY hKeyEventVwr;
351 DWORD dwType, cbData;
352 WCHAR buffer[100];
353
354 /* Load the default values */
355 Settings.bSaveSettings = TRUE;
356 Settings.bShowDetailsPane = TRUE;
357 Settings.bShowGrid = FALSE;
358 Settings.bNewestEventsFirst = TRUE;
359 Settings.nVSplitPos = 250; /* Splitter default positions */
360 Settings.nHSplitPos = 250;
361 ZeroMemory(&Settings.wpPos, sizeof(Settings.wpPos));
362 Settings.wpPos.length = sizeof(Settings.wpPos);
363 SetRect(&Settings.wpPos.rcNormalPosition,
365 Settings.wpPos.showCmd = nDefCmdShow; // SW_SHOWNORMAL;
366
367 /* Try to open the Event Viewer user key */
370 0,
372 &hKeyEventVwr) != ERROR_SUCCESS)
373 {
374 return FALSE;
375 }
376
377 // Result = RegQueryValueExW(hKeyEventVwr, L"Filter", NULL, &dwType, (LPBYTE)&szFilter, &cbData); // REG_SZ
378 // Result = RegQueryValueExW(hKeyEventVwr, L"Find", NULL, &dwType, (LPBYTE)&szFind, &cbData); // REG_SZ
379 // Result = RegQueryValueExW(hKeyEventVwr, L"Module", NULL, &dwType, (LPBYTE)&szModule, &cbData); // REG_SZ
380
381 cbData = sizeof(buffer);
382 Result = RegQueryValueExW(hKeyEventVwr, L"SaveSettings", NULL, &dwType, (LPBYTE)buffer, &cbData);
383 if (Result == ERROR_SUCCESS)
384 {
385 if (dwType == REG_SZ)
386 {
387 buffer[cbData / sizeof(WCHAR) - 1] = UNICODE_NULL;
388 Settings.bSaveSettings = !!(DWORD)_wtoi(buffer);
389 }
390 else if (dwType == REG_DWORD && cbData == sizeof(DWORD))
391 {
392 Settings.bSaveSettings = !!*(PDWORD)buffer;
393 }
394 }
395
396 cbData = sizeof(buffer);
397 Result = RegQueryValueExW(hKeyEventVwr, L"DetailsPane", NULL, &dwType, (LPBYTE)buffer, &cbData);
398 if (Result == ERROR_SUCCESS)
399 {
400 if (dwType == REG_SZ)
401 {
402 buffer[cbData / sizeof(WCHAR) - 1] = UNICODE_NULL;
403 Settings.bShowDetailsPane = !!(DWORD)_wtoi(buffer);
404 }
405 else if (dwType == REG_DWORD && cbData == sizeof(DWORD))
406 {
407 Settings.bShowDetailsPane = !!*(PDWORD)buffer;
408 }
409 }
410
411 cbData = sizeof(buffer);
412 Result = RegQueryValueExW(hKeyEventVwr, L"ShowGrid", NULL, &dwType, (LPBYTE)buffer, &cbData);
413 if (Result == ERROR_SUCCESS)
414 {
415 if (dwType == REG_SZ)
416 {
417 buffer[cbData / sizeof(WCHAR) - 1] = UNICODE_NULL;
418 Settings.bShowGrid = !!(DWORD)_wtoi(buffer);
419 }
420 else if (dwType == REG_DWORD && cbData == sizeof(DWORD))
421 {
422 Settings.bShowGrid = !!*(PDWORD)buffer;
423 }
424 }
425
426 cbData = sizeof(buffer);
427 Result = RegQueryValueExW(hKeyEventVwr, L"SortOrder", NULL, &dwType, (LPBYTE)buffer, &cbData);
428 if (Result == ERROR_SUCCESS)
429 {
430 if (dwType == REG_SZ)
431 {
432 buffer[cbData / sizeof(WCHAR) - 1] = UNICODE_NULL;
433 Settings.bNewestEventsFirst = !!(DWORD)_wtoi(buffer);
434 }
435 else if (dwType == REG_DWORD && cbData == sizeof(DWORD))
436 {
437 Settings.bNewestEventsFirst = !!*(PDWORD)buffer;
438 }
439 }
440
441 /* Retrieve the splitter positions */
442 cbData = sizeof(buffer);
443 Result = RegQueryValueExW(hKeyEventVwr, L"VSplitPos", NULL, &dwType, (LPBYTE)buffer, &cbData);
444 if (Result == ERROR_SUCCESS)
445 {
446 if (dwType == REG_SZ)
447 {
448 buffer[cbData / sizeof(WCHAR) - 1] = UNICODE_NULL;
449 Settings.nVSplitPos = (DWORD)_wtoi(buffer);
450 }
451 else if (dwType == REG_DWORD && cbData == sizeof(DWORD))
452 {
453 Settings.nVSplitPos = *(PDWORD)buffer;
454 }
455 }
456
457 cbData = sizeof(buffer);
458 Result = RegQueryValueExW(hKeyEventVwr, L"HSplitPos", NULL, &dwType, (LPBYTE)buffer, &cbData);
459 if (Result == ERROR_SUCCESS)
460 {
461 if (dwType == REG_SZ)
462 {
463 buffer[cbData / sizeof(WCHAR) - 1] = UNICODE_NULL;
464 Settings.nHSplitPos = (DWORD)_wtoi(buffer);
465 }
466 else if (dwType == REG_DWORD && cbData == sizeof(DWORD))
467 {
468 Settings.nHSplitPos = *(PDWORD)buffer;
469 }
470 }
471
472 /* Retrieve the geometry of the main window */
473 cbData = sizeof(buffer);
474 Result = RegQueryValueExW(hKeyEventVwr, L"Window", NULL, &dwType, (LPBYTE)buffer, &cbData);
475 if ((Result == ERROR_SUCCESS) && (dwType == REG_SZ))
476 buffer[cbData / sizeof(WCHAR) - 1] = UNICODE_NULL;
477 else
478 buffer[0] = UNICODE_NULL;
479
480 if (swscanf(buffer, L"%d %d %d %d %d",
481 &Settings.wpPos.rcNormalPosition.left,
482 &Settings.wpPos.rcNormalPosition.top,
483 &Settings.wpPos.rcNormalPosition.right,
484 &Settings.wpPos.rcNormalPosition.bottom,
485 &Settings.wpPos.showCmd) != 5)
486 {
487 /* Parsing failed, use defaults */
488 SetRect(&Settings.wpPos.rcNormalPosition,
490 Settings.wpPos.showCmd = nDefCmdShow; // SW_SHOWNORMAL;
491 }
492
493 RegCloseKey(hKeyEventVwr);
494 return TRUE;
495}
496
497BOOL
499{
500 HKEY hKeyEventVwr;
502 WCHAR buffer[100];
503
504 /* Try to create/open the Event Viewer user key */
507 0,
508 NULL,
511 NULL,
512 &hKeyEventVwr,
514 {
515 return FALSE;
516 }
517
518 dwSize = sizeof(Settings.bSaveSettings);
519 RegSetValueExW(hKeyEventVwr, L"SaveSettings", 0, REG_DWORD, (LPBYTE)&Settings.bSaveSettings, dwSize);
520
521 /* Do not save more settings if we are not asked to do so */
522 if (!Settings.bSaveSettings)
523 goto Quit;
524
525 dwSize = sizeof(Settings.bShowDetailsPane);
526 RegSetValueExW(hKeyEventVwr, L"DetailsPane", 0, REG_DWORD, (LPBYTE)&Settings.bShowDetailsPane, dwSize);
527
528 dwSize = sizeof(Settings.bShowGrid);
529 RegSetValueExW(hKeyEventVwr, L"ShowGrid", 0, REG_DWORD, (LPBYTE)&Settings.bShowGrid, dwSize);
530
531 dwSize = sizeof(Settings.bNewestEventsFirst);
532 RegSetValueExW(hKeyEventVwr, L"SortOrder", 0, REG_DWORD, (LPBYTE)&Settings.bNewestEventsFirst, dwSize);
533
534 Settings.nVSplitPos = nVSplitPos;
535 dwSize = sizeof(Settings.nVSplitPos);
536 RegSetValueExW(hKeyEventVwr, L"VSplitPos", 0, REG_DWORD, (LPBYTE)&Settings.nVSplitPos, dwSize);
537
538 Settings.nHSplitPos = nHSplitPos;
539 dwSize = sizeof(Settings.nHSplitPos);
540 RegSetValueExW(hKeyEventVwr, L"HSplitPos", 0, REG_DWORD, (LPBYTE)&Settings.nHSplitPos, dwSize);
541
543 L"%d %d %d %d %d",
544 Settings.wpPos.rcNormalPosition.left,
545 Settings.wpPos.rcNormalPosition.top,
546 Settings.wpPos.rcNormalPosition.right,
547 Settings.wpPos.rcNormalPosition.bottom,
548 Settings.wpPos.showCmd);
549
550 dwSize = (DWORD)((wcslen(buffer) + 1) * sizeof(WCHAR));
551 RegSetValueExW(hKeyEventVwr, L"Window", 0, REG_SZ, (LPBYTE)buffer, dwSize);
552
553Quit:
554 RegCloseKey(hKeyEventVwr);
555 return TRUE;
556}
557
558int APIENTRY
560 HINSTANCE hPrevInstance,
561 LPWSTR lpCmdLine,
562 int nCmdShow)
563{
566 HMODULE hRichEdit;
567 HACCEL hAccelTable;
568 MSG msg;
569
570 UNREFERENCED_PARAMETER(hPrevInstance);
571 UNREFERENCED_PARAMETER(lpCmdLine);
572
573 /* Whenever any of the common controls are used in your app,
574 * you must call InitCommonControlsEx() to register the classes
575 * for those controls. */
576 iccx.dwSize = sizeof(iccx);
579
580 /* Load the RichEdit DLL to add support for RichEdit controls */
581 hRichEdit = LoadLibraryW(L"riched20.dll");
582 if (!hRichEdit)
583 return -1;
584
585 msg.wParam = (WPARAM)-1;
586
587 /* Store the instance handle in the global variable */
589
590 /* Initialize global strings */
596
597 /*
598 * Process the command-line arguments. Note that we need the full
599 * command-line, with the program file included, and not just what
600 * WinMain() provides in its lpCmdLine parameter.
601 */
603 goto Quit;
604
606 goto Quit;
607
608 /* Load the settings */
609 LoadSettings(nCmdShow);
610
611 /* Perform application initialization */
613 goto Quit;
614
616
617 /* Create the Start/Stop enumerator thread */
618 // Manual-reset event
621 goto Cleanup;
622
623 // Auto-reset event
625 if (!hStartEnumEvent)
626 goto Cleanup;
627
630 NULL, 0, NULL);
631 if (!hThread)
632 goto Cleanup;
633
634 /* Retrieve the available event logs on this computer and create filters for them */
638
639 /* Open the user-specified logs if any are present on the command-line */
641 {
642 LPWSTR lpUserLog;
643 for (lpUserLog = lpszzUserLogsToLoad; *lpUserLog; lpUserLog += wcslen(lpUserLog) + 1)
644 {
645 OpenUserEventLogFile(lpUserLog);
646 }
647
648 /* Now cleanup the list of user logs */
649 cbUserLogsSize = 0;
652 }
653
654 /* Main message loop */
655 while (GetMessageW(&msg, NULL, 0, 0))
656 {
657 if (!TranslateAcceleratorW(hwndMainWindow, hAccelTable, &msg))
658 {
661 }
662 }
663
664 /* Save the settings */
665 SaveSettings();
666
667 /* Disconnect from computer */
669 {
670 /* We are connected to some other computer, close the old connection */
672 hkMachine = NULL;
673 }
674
675 /* Stop the enumerator thread */
679
680 /* Free the filters list and the event logs list */
682 FreeLogList();
683
684Cleanup:
685 /* Handle cleanup */
686 if (hStartEnumEvent)
690
691Quit:
692 /* Final cleanup */
694 {
695 cbUserLogsSize = 0;
698 }
699 if (lpComputerName)
700 {
703 }
704 FreeLibrary(hRichEdit);
705
706 return (int)msg.wParam;
707}
708
709
710/* GENERIC HELPER FUNCTIONS ***************************************************/
711
712VOID
714 OUT PSYSTEMTIME pSystemTime)
715{
716 SYSTEMTIME st1970 = { 1970, 1, 0, 1, 0, 0, 0, 0 };
717 FILETIME ftLocal;
718 union
719 {
720 FILETIME ft;
722 } u1970, uUCT;
723
724 uUCT.ft.dwHighDateTime = 0;
725 uUCT.ft.dwLowDateTime = EventTime;
726 SystemTimeToFileTime(&st1970, &u1970.ft);
727 uUCT.ll = uUCT.ll * 10000000 + u1970.ll;
728 FileTimeToLocalFileTime(&uUCT.ft, &ftLocal);
729 FileTimeToSystemTime(&ftLocal, pSystemTime);
730}
731
732/*
733 * This function takes in entry a path to a single DLL, in which
734 * the message string of ID dwMessageId has to be searched.
735 * The other parameters are similar to those of the FormatMessageW API.
736 */
737LPWSTR
739 IN LPCWSTR lpMessageDll,
740 IN DWORD dwFlags, // If we always use the same flags, just remove this param...
741 IN DWORD dwMessageId,
742 IN DWORD nSize,
743 IN va_list* Arguments OPTIONAL)
744{
747 LPWSTR lpMsgBuf = NULL;
748
749 hLibrary = LoadLibraryExW(lpMessageDll, NULL,
750 /* LOAD_LIBRARY_AS_IMAGE_RESOURCE | */ LOAD_LIBRARY_AS_DATAFILE);
751 if (hLibrary == NULL)
752 return NULL;
753
754 /* Sanitize dwFlags */
755 dwFlags &= ~FORMAT_MESSAGE_FROM_STRING;
757
759 {
760 /*
761 * Retrieve the message string without appending extra newlines.
762 * Wrap in SEH to protect from invalid string parameters.
763 */
765 {
767 /* FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_HMODULE |
768 FORMAT_MESSAGE_IGNORE_INSERTS | FORMAT_MESSAGE_MAX_WIDTH_MASK, */
769 hLibrary,
770 dwMessageId,
772 (LPWSTR)&lpMsgBuf,
773 nSize,
774 Arguments);
775 }
777 {
778 dwLength = 0;
779
780 /*
781 * An exception occurred while calling FormatMessage, this is usually
782 * the sign that a parameter was invalid, either 'lpMsgBuf' was NULL
783 * but we did not pass the flag FORMAT_MESSAGE_ALLOCATE_BUFFER, or the
784 * array pointer 'Arguments' was NULL or did not contain enough elements,
785 * and we did not pass the flag FORMAT_MESSAGE_IGNORE_INSERTS, and the
786 * message string expected too many inserts.
787 * In this last case only, we can call again FormatMessage but ignore
788 * explicitly the inserts. The string that we will return to the user
789 * will not be pre-formatted.
790 */
791 if (((dwFlags & FORMAT_MESSAGE_ALLOCATE_BUFFER) || lpMsgBuf) &&
793 {
794 /* Remove any possible harmful flags and always ignore inserts */
795 dwFlags &= ~FORMAT_MESSAGE_ARGUMENT_ARRAY;
797
798 /* If this call also throws an exception, we are really dead */
800 hLibrary,
801 dwMessageId,
803 (LPWSTR)&lpMsgBuf,
804 nSize,
805 NULL /* Arguments */);
806 }
807 }
808 _SEH2_END;
809 }
811 {
813 }
814 _SEH2_END;
815
816 if (dwLength == 0)
817 {
818 ASSERT(lpMsgBuf == NULL);
819 lpMsgBuf = NULL;
820 }
821 else
822 {
823 LPWSTR ptr;
824
825 ASSERT(lpMsgBuf);
826
827 /* Trim any trailing whitespace */
828 ptr = lpMsgBuf + dwLength - 1;
829 while (iswspace(*ptr))
830 *ptr-- = UNICODE_NULL;
831 }
832
833 return lpMsgBuf;
834}
835
836/*
837 * This function takes in entry a comma-separated list of DLLs, in which
838 * the message string of ID dwMessageId has to be searched.
839 * The other parameters are similar to those of the FormatMessageW API.
840 */
841LPWSTR
843 IN LPCWSTR lpMessageDllList,
844 IN DWORD dwFlags, // If we always use the same flags, just remove this param...
845 IN DWORD dwMessageId,
846 IN DWORD nSize,
847 IN va_list* Arguments OPTIONAL)
848{
850 SIZE_T cbLength;
851 LPWSTR szMessageDllList;
852 LPWSTR szDll;
853 LPWSTR lpMsgBuf = NULL;
854
855 /* Allocate a local buffer for the DLL list that can be tokenized */
856 // TODO: Optimize that!! Maybe we can cleverly use lpMessageDllList in read/write mode
857 // and cleverly temporarily replace the ';' by UNICODE_NULL, do our job, then reverse the change.
858 cbLength = (wcslen(lpMessageDllList) + 1) * sizeof(WCHAR);
859 szMessageDllList = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, cbLength);
860 if (!szMessageDllList)
861 return NULL;
862 CopyMemory(szMessageDllList, lpMessageDllList, cbLength);
863
864 /* Loop through the list of message DLLs */
865 szDll = wcstok(szMessageDllList, EVENT_DLL_SEPARATOR);
866 while ((szDll != NULL) && !Success)
867 {
868 // Uses LANG_USER_DEFAULT
869 lpMsgBuf = GetMessageStringFromDll(szDll,
870 dwFlags,
871 dwMessageId,
872 nSize,
873 Arguments);
874 if (lpMsgBuf)
875 {
876 /* The ID was found and the message was formatted */
877 Success = TRUE;
878 break;
879 }
880
881 /*
882 * The DLL could not be loaded, or the message could not be found,
883 * try the next DLL, if any.
884 */
886 }
887
888 HeapFree(GetProcessHeap(), 0, szMessageDllList);
889
890 return lpMsgBuf;
891}
892
893
894typedef struct
895{
896 LPWSTR pStartingAddress; // Pointer to the beginning of a parameter string in pMessage
897 LPWSTR pEndingAddress; // Pointer to the end of a parameter string in pMessage
898 DWORD pParameterID; // Parameter identifier found in pMessage
899 LPWSTR pParameter; // Actual parameter string
901
902DWORD
904 IN LPCWSTR lpMessageDllList,
905 IN BOOL bMessagePreFormatted,
906 IN CONST LPCWSTR pMessage,
907 OUT LPWSTR* pFinalMessage)
908{
909 /*
910 * This code is heavily adapted from the MSDN example:
911 * https://learn.microsoft.com/en-us/windows/win32/eventlog/querying-for-event-source-messages
912 * with bugs removed.
913 */
914
916 DWORD dwParamCount = 0; // Number of insertion strings found in pMessage
917 size_t cchBuffer = 0; // Size of the buffer in characters
918 size_t cchParams = 0; // Number of characters in all the parameter strings
919 size_t cch = 0;
920 DWORD i = 0;
921 param_strings_format_data* pParamData = NULL; // Array of pointers holding information about each parameter string in pMessage
922 LPWSTR pTempMessage = (LPWSTR)pMessage;
923 LPWSTR pTempFinalMessage = NULL;
924
925 *pFinalMessage = NULL;
926
927 /* Determine the number of parameter insertion strings in pMessage */
928 if (bMessagePreFormatted)
929 {
930 while ((pTempMessage = wcschr(pTempMessage, L'%')))
931 {
932 pTempMessage++;
933 if (iswdigit(*pTempMessage))
934 {
935 dwParamCount++;
936 while (iswdigit(*++pTempMessage)) ;
937 }
938 }
939 }
940 else
941 {
942 while ((pTempMessage = wcsstr(pTempMessage, L"%%")))
943 {
944 pTempMessage += 2;
945 if (iswdigit(*pTempMessage))
946 {
947 dwParamCount++;
948 while (iswdigit(*++pTempMessage)) ;
949 }
950 }
951 }
952
953 /* If there are no parameter insertion strings in pMessage, just return */
954 if (dwParamCount == 0)
955 {
956 // *pFinalMessage = NULL;
957 goto Cleanup;
958 }
959
960 /* Allocate the array of parameter string format data */
961 pParamData = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, dwParamCount * sizeof(param_strings_format_data));
962 if (!pParamData)
963 {
965 goto Cleanup;
966 }
967
968 /*
969 * Retrieve each parameter in pMessage and the beginning and end of the
970 * insertion string, as well as the message identifier of the parameter.
971 */
972 pTempMessage = (LPWSTR)pMessage;
973 if (bMessagePreFormatted)
974 {
975 while ((pTempMessage = wcschr(pTempMessage, L'%')) && (i < dwParamCount))
976 {
977 pTempMessage++;
978 if (iswdigit(*pTempMessage))
979 {
980 pParamData[i].pStartingAddress = pTempMessage-1;
981 pParamData[i].pParameterID = (DWORD)_wtol(pTempMessage);
982
983 while (iswdigit(*++pTempMessage)) ;
984
985 pParamData[i].pEndingAddress = pTempMessage;
986 i++;
987 }
988 }
989 }
990 else
991 {
992 while ((pTempMessage = wcsstr(pTempMessage, L"%%")) && (i < dwParamCount))
993 {
994 pTempMessage += 2;
995 if (iswdigit(*pTempMessage))
996 {
997 pParamData[i].pStartingAddress = pTempMessage-2;
998 pParamData[i].pParameterID = (DWORD)_wtol(pTempMessage);
999
1000 while (iswdigit(*++pTempMessage)) ;
1001
1002 pParamData[i].pEndingAddress = pTempMessage;
1003 i++;
1004 }
1005 }
1006 }
1007
1008 /* Retrieve each parameter string */
1009 for (i = 0; i < dwParamCount; i++)
1010 {
1011 // pParamData[i].pParameter = GetMessageString(pParamData[i].pParameterID, 0, NULL);
1012 pParamData[i].pParameter =
1013 GetMessageStringFromDllList(lpMessageDllList,
1016 pParamData[i].pParameterID,
1017 0, NULL);
1018 if (!pParamData[i].pParameter)
1019 {
1020 /* Skip the insertion string */
1021 continue;
1022 }
1023
1024 cchParams += wcslen(pParamData[i].pParameter);
1025 }
1026
1027 /*
1028 * Allocate the final message buffer, the size of which is based on the
1029 * length of the original message and the length of each parameter string.
1030 */
1031 cchBuffer = wcslen(pMessage) + cchParams + 1;
1032 *pFinalMessage = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, cchBuffer * sizeof(WCHAR));
1033 if (!*pFinalMessage)
1034 {
1036 goto Cleanup;
1037 }
1038
1039 pTempFinalMessage = *pFinalMessage;
1040
1041 /* Build the final message string */
1042 pTempMessage = (LPWSTR)pMessage;
1043 for (i = 0; i < dwParamCount; i++)
1044 {
1045 /* Append the segment from pMessage */
1046 cch = pParamData[i].pStartingAddress - pTempMessage;
1047 StringCchCopyNW(pTempFinalMessage, cchBuffer, pTempMessage, cch);
1048 pTempMessage = pParamData[i].pEndingAddress;
1049 cchBuffer -= cch;
1050 pTempFinalMessage += cch;
1051
1052 /* Append the parameter string */
1053 if (pParamData[i].pParameter)
1054 {
1055 StringCchCopyW(pTempFinalMessage, cchBuffer, pParamData[i].pParameter);
1056 cch = wcslen(pParamData[i].pParameter); // pTempFinalMessage
1057 }
1058 else
1059 {
1060 /*
1061 * We failed to retrieve the parameter string before, so just
1062 * place back the original string placeholder.
1063 */
1064 cch = pParamData[i].pEndingAddress /* == pTempMessage */ - pParamData[i].pStartingAddress;
1065 StringCchCopyNW(pTempFinalMessage, cchBuffer, pParamData[i].pStartingAddress, cch);
1066 // cch = wcslen(pTempFinalMessage);
1067 }
1068 cchBuffer -= cch;
1069 pTempFinalMessage += cch;
1070 }
1071
1072 /* Append the last segment from pMessage */
1073 StringCchCopyW(pTempFinalMessage, cchBuffer, pTempMessage);
1074
1075Cleanup:
1076
1077 // if (Status != ERROR_SUCCESS)
1078 // *pFinalMessage = NULL;
1079
1080 if (pParamData)
1081 {
1082 for (i = 0; i < dwParamCount; i++)
1083 {
1084 if (pParamData[i].pParameter)
1085 LocalFree(pParamData[i].pParameter);
1086 }
1087
1088 HeapFree(GetProcessHeap(), 0, pParamData);
1089 }
1090
1091 return Status;
1092}
1093
1094
1095/*
1096 * The following functions were adapted from
1097 * shell32!dialogs/filedefext.cpp:``SH_...'' functions.
1098 */
1099
1100UINT
1101FormatInteger(LONGLONG Num, LPWSTR pwszResult, UINT cchResultMax)
1102{
1103 WCHAR wszNumber[24];
1104 WCHAR wszDecimalSep[8], wszThousandSep[8];
1105 NUMBERFMTW nf;
1106 WCHAR wszGrouping[12];
1107 INT cchGrouping;
1108 INT cchResult;
1109 INT i;
1110
1111 // Print the number in uniform mode
1112 swprintf(wszNumber, L"%I64u", Num);
1113
1114 // Get system strings for decimal and thousand separators.
1115 GetLocaleInfoW(LOCALE_USER_DEFAULT, LOCALE_SDECIMAL, wszDecimalSep, _countof(wszDecimalSep));
1116 GetLocaleInfoW(LOCALE_USER_DEFAULT, LOCALE_STHOUSAND, wszThousandSep, _countof(wszThousandSep));
1117
1118 // Initialize format for printing the number in bytes
1119 ZeroMemory(&nf, sizeof(nf));
1120 nf.lpDecimalSep = wszDecimalSep;
1121 nf.lpThousandSep = wszThousandSep;
1122
1123 // Get system string for groups separator
1124 cchGrouping = GetLocaleInfoW(LOCALE_USER_DEFAULT,
1126 wszGrouping,
1127 _countof(wszGrouping));
1128
1129 // Convert grouping specs from string to integer
1130 for (i = 0; i < cchGrouping; i++)
1131 {
1132 WCHAR wch = wszGrouping[i];
1133
1134 if (wch >= L'0' && wch <= L'9')
1135 nf.Grouping = nf.Grouping * 10 + (wch - L'0');
1136 else if (wch != L';')
1137 break;
1138 }
1139
1140 if ((nf.Grouping % 10) == 0)
1141 nf.Grouping /= 10;
1142 else
1143 nf.Grouping *= 10;
1144
1145 // Format the number
1147 0,
1148 wszNumber,
1149 &nf,
1150 pwszResult,
1151 cchResultMax);
1152
1153 if (!cchResult)
1154 return 0;
1155
1156 // GetNumberFormatW returns number of characters including UNICODE_NULL
1157 return cchResult - 1;
1158}
1159
1160UINT
1161FormatByteSize(LONGLONG cbSize, LPWSTR pwszResult, UINT cchResultMax)
1162{
1163 UINT cchWritten, cchRemaining;
1164 LPWSTR pwszEnd;
1165 size_t cchStringRemaining;
1166
1167 /* Write formated bytes count */
1168 cchWritten = FormatInteger(cbSize, pwszResult, cchResultMax);
1169 if (!cchWritten)
1170 return 0;
1171
1172 /* Copy " bytes" to buffer */
1173 pwszEnd = pwszResult + cchWritten;
1174 cchRemaining = cchResultMax - cchWritten;
1175 StringCchCopyExW(pwszEnd, cchRemaining, L" ", &pwszEnd, &cchStringRemaining, 0);
1176 cchRemaining = (UINT)cchStringRemaining;
1177 cchWritten = LoadStringW(hInst, IDS_BYTES_FORMAT, pwszEnd, cchRemaining);
1178 cchRemaining -= cchWritten;
1179
1180 return cchResultMax - cchRemaining;
1181}
1182
1183LPWSTR
1184FormatFileSizeWithBytes(const PULARGE_INTEGER lpQwSize, LPWSTR pwszResult, UINT cchResultMax)
1185{
1186 UINT cchWritten, cchRemaining;
1187 LPWSTR pwszEnd;
1188 size_t cchCopyRemaining;
1189
1190 /* Format bytes in KBs, MBs etc */
1191 if (StrFormatByteSizeW(lpQwSize->QuadPart, pwszResult, cchResultMax) == NULL)
1192 return NULL;
1193
1194 /* If there is less bytes than 1KB, we have nothing to do */
1195 if (lpQwSize->QuadPart < 1024)
1196 return pwszResult;
1197
1198 /* Concatenate " (" */
1199 cchWritten = (UINT)wcslen(pwszResult);
1200 pwszEnd = pwszResult + cchWritten;
1201 cchRemaining = cchResultMax - cchWritten;
1202 StringCchCopyExW(pwszEnd, cchRemaining, L" (", &pwszEnd, &cchCopyRemaining, 0);
1203 cchRemaining = (UINT)cchCopyRemaining;
1204
1205 /* Write formated bytes count */
1206 cchWritten = FormatByteSize(lpQwSize->QuadPart, pwszEnd, cchRemaining);
1207 pwszEnd += cchWritten;
1208 cchRemaining -= cchWritten;
1209
1210 /* Copy ")" to the buffer */
1211 StringCchCopyW(pwszEnd, cchRemaining, L")");
1212
1213 return pwszResult;
1214}
1215
1216/* Adapted from shell32!dialogs/filedefext.cpp:``CFileDefExt::GetFileTimeString'' */
1217BOOL
1218GetFileTimeString(LPFILETIME lpFileTime, LPWSTR pwszResult, UINT cchResult)
1219{
1220 FILETIME ft;
1221 SYSTEMTIME st;
1222 int cchWritten;
1223 UINT cchRemaining = cchResult;
1224 size_t cchCopyRemaining;
1225 LPWSTR pwszEnd = pwszResult;
1226
1227 if (!FileTimeToLocalFileTime(lpFileTime, &ft) || !FileTimeToSystemTime(&ft, &st))
1228 return FALSE;
1229
1230 cchWritten = GetDateFormatW(LOCALE_USER_DEFAULT, DATE_LONGDATE, &st, NULL, pwszEnd, cchRemaining);
1231 if (cchWritten)
1232 --cchWritten; // GetDateFormatW returns count with terminating zero
1233 // else
1234 // ERR("GetDateFormatW failed\n");
1235
1236 cchRemaining -= cchWritten;
1237 pwszEnd += cchWritten;
1238
1239 StringCchCopyExW(pwszEnd, cchRemaining, L", ", &pwszEnd, &cchCopyRemaining, 0);
1240 cchRemaining = (UINT)cchCopyRemaining;
1241
1242 cchWritten = GetTimeFormatW(LOCALE_USER_DEFAULT, 0, &st, NULL, pwszEnd, cchRemaining);
1243 if (cchWritten)
1244 --cchWritten; // GetTimeFormatW returns count with terminating zero
1245 // else
1246 // ERR("GetTimeFormatW failed\n");
1247
1248 return TRUE;
1249}
1250
1251
1254 IN HTREEITEM hParent,
1255 IN LPWSTR lpText,
1256 IN INT Image,
1257 IN INT SelectedImage,
1259{
1260 TV_INSERTSTRUCTW Insert;
1261
1262 ZeroMemory(&Insert, sizeof(Insert));
1263
1264 Insert.item.mask = TVIF_TEXT | TVIF_PARAM | TVIF_IMAGE | TVIF_SELECTEDIMAGE;
1265 Insert.hInsertAfter = TVI_LAST;
1266 Insert.hParent = hParent;
1267 Insert.item.pszText = lpText;
1268 Insert.item.iImage = Image;
1269 Insert.item.iSelectedImage = SelectedImage;
1270 Insert.item.lParam = lParam;
1271
1272 Insert.item.mask |= TVIF_STATE;
1273 Insert.item.stateMask = TVIS_OVERLAYMASK;
1274 Insert.item.state = INDEXTOOVERLAYMASK(1);
1275
1276 return TreeView_InsertItem(hTreeView, &Insert);
1277}
1278
1279
1280/* LOG HELPER FUNCTIONS *******************************************************/
1281
1284 IN PCWSTR LogName,
1285 IN BOOL Permanent)
1286{
1287 PEVENTLOG EventLog;
1289
1290 /* Allocate a new event log entry */
1291 EventLog = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*EventLog));
1292 if (!EventLog)
1293 return NULL;
1294
1295 /* Allocate the computer name string (optional) and copy it */
1296 if (ComputerName)
1297 {
1298 cchName = wcslen(ComputerName) + 1;
1299 EventLog->ComputerName = HeapAlloc(GetProcessHeap(), 0, cchName * sizeof(WCHAR));
1300 if (EventLog->ComputerName)
1301 StringCchCopyW(EventLog->ComputerName, cchName, ComputerName);
1302 }
1303
1304 /* Allocate the event log name string and copy it */
1305 cchName = wcslen(LogName) + 1;
1306 EventLog->LogName = HeapAlloc(GetProcessHeap(), 0, cchName * sizeof(WCHAR));
1307 if (!EventLog->LogName)
1308 {
1309 if (EventLog->ComputerName)
1310 HeapFree(GetProcessHeap(), 0, EventLog->ComputerName);
1311 HeapFree(GetProcessHeap(), 0, EventLog);
1312 return NULL;
1313 }
1314 StringCchCopyW(EventLog->LogName, cchName, LogName);
1315
1316 EventLog->Permanent = Permanent;
1317
1318 return EventLog;
1319}
1320
1321VOID
1323{
1324 if (EventLog->LogName)
1325 HeapFree(GetProcessHeap(), 0, EventLog->LogName);
1326
1327 if (EventLog->ComputerName)
1328 HeapFree(GetProcessHeap(), 0, EventLog->ComputerName);
1329
1330 if (EventLog->FileName)
1331 HeapFree(GetProcessHeap(), 0, EventLog->FileName);
1332
1333 HeapFree(GetProcessHeap(), 0, EventLog);
1334}
1335
1336
1337PWSTR
1339{
1340 PWSTR pStr;
1341 ULONG Length;
1342
1343 if (!MultiStr)
1344 return NULL;
1345
1346 pStr = (PWSTR)MultiStr;
1347 while (*pStr) pStr += (wcslen(pStr) + 1);
1348 Length = MultiStr - pStr + 2;
1349
1350 pStr = HeapAlloc(GetProcessHeap(), 0, Length * sizeof(WCHAR));
1351 // NOTE: If we failed allocating the string, then fall back into no filter!
1352 if (pStr)
1353 CopyMemory(pStr, MultiStr, Length * sizeof(WCHAR));
1354
1355 return pStr;
1356}
1357
1359AllocEventLogFilter(// IN PCWSTR FilterName,
1361 IN BOOL Warning,
1362 IN BOOL Error,
1363 IN BOOL AuditSuccess,
1364 IN BOOL AuditFailure,
1365 IN PCWSTR Sources OPTIONAL,
1366 IN PCWSTR Users OPTIONAL,
1367 IN PCWSTR ComputerNames OPTIONAL,
1368 IN ULONG NumOfEventLogs,
1369 IN PEVENTLOG* EventLogs)
1370{
1371 PEVENTLOGFILTER EventLogFilter;
1372
1373 /* Allocate a new event log filter entry, big enough to accommodate the list of logs */
1374 EventLogFilter = HeapAlloc(GetProcessHeap(),
1376 FIELD_OFFSET(EVENTLOGFILTER, EventLogs[NumOfEventLogs]));
1377 if (!EventLogFilter)
1378 return NULL;
1379
1380 EventLogFilter->Information = Information;
1381 EventLogFilter->Warning = Warning;
1382 EventLogFilter->Error = Error;
1383 EventLogFilter->AuditSuccess = AuditSuccess;
1384 EventLogFilter->AuditFailure = AuditFailure;
1385
1386 /* Allocate and copy the sources, users, and computers multi-strings */
1387 EventLogFilter->Sources = AllocAndCopyMultiStr(Sources);
1388 EventLogFilter->Users = AllocAndCopyMultiStr(Users);
1389 EventLogFilter->ComputerNames = AllocAndCopyMultiStr(ComputerNames);
1390
1391 /* Copy the list of event logs */
1392 EventLogFilter->NumOfEventLogs = NumOfEventLogs;
1393 CopyMemory(EventLogFilter->EventLogs, EventLogs, NumOfEventLogs * sizeof(PEVENTLOG));
1394
1395 /* Initialize the filter reference count */
1396 EventLogFilter->ReferenceCount = 1;
1397
1398 return EventLogFilter;
1399}
1400
1401VOID
1403{
1404 if (EventLogFilter->Sources)
1405 HeapFree(GetProcessHeap(), 0, EventLogFilter->Sources);
1406
1407 if (EventLogFilter->Users)
1408 HeapFree(GetProcessHeap(), 0, EventLogFilter->Users);
1409
1410 if (EventLogFilter->ComputerNames)
1411 HeapFree(GetProcessHeap(), 0, EventLogFilter->ComputerNames);
1412
1413 HeapFree(GetProcessHeap(), 0, EventLogFilter);
1414}
1415
1417{
1418 ASSERT(EventLogFilter);
1419 return InterlockedIncrement(&EventLogFilter->ReferenceCount);
1420}
1421
1423{
1424 LONG RefCount;
1425
1426 ASSERT(EventLogFilter);
1427
1428 /* When the reference count reaches zero, delete the filter */
1429 RefCount = InterlockedDecrement(&EventLogFilter->ReferenceCount);
1430 if (RefCount <= 0)
1431 {
1432 /* Remove the filter from the list */
1434 EventLogFilter_Free(EventLogFilter);
1435 }
1436
1437 return RefCount;
1438}
1439
1440void
1442{
1443 WCHAR *c;
1444
1445 if (s != NULL)
1446 {
1447 c = s + wcslen(s) - 1;
1448 while (c >= s && iswspace(*c))
1449 --c;
1450 *++c = L'\0';
1451 }
1452}
1453
1454DWORD
1456 IN LPCWSTR ComputerName OPTIONAL,
1458 OUT LPWSTR lpFullFileName OPTIONAL,
1459 IN DWORD nSize)
1460{
1462
1463 /* Determine the needed size after expansion of any environment strings */
1465 if (dwLength == 0)
1466 {
1467 /* We failed, bail out */
1468 return 0;
1469 }
1470
1471 /* If the file path is on a remote computer, estimate its length */
1472 // FIXME: Use WNetGetUniversalName instead?
1473 if (ComputerName && *ComputerName)
1474 {
1475 /* Skip any leading backslashes */
1476 while (*ComputerName == L'\\')
1477 ++ComputerName;
1478
1479 if (*ComputerName)
1480 {
1481 /* Count 2 backslashes plus the computer name and one backslash separator */
1482 dwLength += 2 + wcslen(ComputerName) + 1;
1483 }
1484 }
1485
1486 /* Check whether we have enough space */
1487 if (dwLength > nSize)
1488 {
1489 /* No, return the needed size in characters (includes NULL-terminator) */
1490 return dwLength;
1491 }
1492
1493
1494 /* Now expand the file path */
1495 ASSERT(dwLength <= nSize);
1496
1497 /* Expand any existing environment strings */
1498 if (ExpandEnvironmentStringsW(lpFileName, lpFullFileName, dwLength) == 0)
1499 {
1500 /* We failed, bail out */
1501 return 0;
1502 }
1503
1504 /* If the file path is on a remote computer, retrieve the network share form of the file name */
1505 // FIXME: Use WNetGetUniversalName instead?
1506 if (ComputerName && *ComputerName)
1507 {
1508 /* Note that we previously skipped any potential leading backslashes */
1509
1510 /* Replace ':' by '$' in the drive letter */
1511 if (*lpFullFileName && lpFullFileName[1] == L':')
1512 lpFullFileName[1] = L'$';
1513
1514 /* Prepend the computer name */
1515 MoveMemory(lpFullFileName + 2 + wcslen(ComputerName) + 1,
1516 lpFullFileName, dwLength * sizeof(WCHAR) - (2 + wcslen(ComputerName) + 1) * sizeof(WCHAR));
1517 lpFullFileName[0] = L'\\';
1518 lpFullFileName[1] = L'\\';
1519 wcsncpy(lpFullFileName + 2, ComputerName, wcslen(ComputerName));
1520 lpFullFileName[2 + wcslen(ComputerName)] = L'\\';
1521 }
1522
1523 /* Return the number of stored characters (includes NULL-terminator) */
1524 return dwLength;
1525}
1526
1527BOOL
1530 IN LPCWSTR EntryName,
1531 OUT PWCHAR lpModuleName) // TODO: Add IN DWORD BufLen
1532{
1533 BOOL Success = FALSE;
1534 LONG Result;
1535 DWORD dwType, dwSize;
1537 WCHAR szKeyName[MAX_PATH];
1538 HKEY hLogKey = NULL;
1539 HKEY hSourceKey = NULL;
1540
1541 StringCbCopyW(szKeyName, sizeof(szKeyName), EVENTLOG_BASE_KEY);
1542 StringCbCatW(szKeyName, sizeof(szKeyName), lpLogName);
1543
1545 szKeyName,
1546 0,
1547 KEY_READ,
1548 &hLogKey);
1549 if (Result != ERROR_SUCCESS)
1550 return FALSE;
1551
1552 Result = RegOpenKeyExW(hLogKey,
1553 SourceName,
1554 0,
1556 &hSourceKey);
1557 if (Result != ERROR_SUCCESS)
1558 {
1559 RegCloseKey(hLogKey);
1560 return FALSE;
1561 }
1562
1563 dwSize = sizeof(szModuleName);
1564 Result = RegQueryValueExW(hSourceKey,
1565 EntryName,
1566 NULL,
1567 &dwType,
1569 &dwSize);
1570 if ((Result != ERROR_SUCCESS) || (dwType != REG_EXPAND_SZ && dwType != REG_SZ))
1571 {
1573 }
1574 else
1575 {
1576 /* NULL-terminate the string and expand it */
1577 szModuleName[dwSize / sizeof(WCHAR) - 1] = UNICODE_NULL;
1579 Success = TRUE;
1580 }
1581
1582 RegCloseKey(hSourceKey);
1583 RegCloseKey(hLogKey);
1584
1585 return Success;
1586}
1587
1588BOOL
1591 IN PEVENTLOGRECORD pevlr,
1592 OUT PWCHAR CategoryName) // TODO: Add IN DWORD BufLen
1593{
1594 BOOL Success = FALSE;
1595 WCHAR szMessageDLL[MAX_PATH];
1596 LPWSTR lpMsgBuf = NULL;
1597
1599 goto Quit;
1600
1601 /* Retrieve the message string without appending extra newlines */
1602 lpMsgBuf =
1603 GetMessageStringFromDllList(szMessageDLL,
1606 pevlr->EventCategory,
1608 NULL);
1609 if (lpMsgBuf)
1610 {
1611 /* Trim the string */
1612 TrimNulls(lpMsgBuf);
1613
1614 /* Copy the category name */
1615 StringCchCopyW(CategoryName, MAX_PATH, lpMsgBuf);
1616
1617 /* Free the buffer allocated by FormatMessage */
1618 LocalFree(lpMsgBuf);
1619
1620 /* The ID was found and the message was formatted */
1621 Success = TRUE;
1622 }
1623
1624Quit:
1625 if (!Success)
1626 {
1627 if (pevlr->EventCategory != 0)
1628 {
1629 StringCchPrintfW(CategoryName, MAX_PATH, L"(%lu)", pevlr->EventCategory);
1630 Success = TRUE;
1631 }
1632 }
1633
1634 return Success;
1635}
1636
1637
1638BOOL // NOTE: Used by evtdetctl.c
1641 IN PEVENTLOGRECORD pevlr,
1642 OUT PWCHAR EventText) // TODO: Add IN DWORD BufLen
1643{
1644 BOOL Success = FALSE;
1645 DWORD i;
1646 size_t cch;
1647 WCHAR SourceModuleName[1024];
1648 WCHAR ParameterModuleName[1024];
1649 BOOL IsParamModNameCached = FALSE;
1650 LPWSTR lpMsgBuf = NULL;
1651 LPWSTR szStringArray, szMessage;
1652 LPWSTR *szArguments;
1653
1654 /* Get the event string array */
1655 szStringArray = (LPWSTR)((LPBYTE)pevlr + pevlr->StringOffset);
1656
1657 /* NOTE: GetEventMessageFileDLL can return a comma-separated list of DLLs */
1659 goto Quit;
1660
1661 /* Allocate space for insertion strings */
1662 szArguments = HeapAlloc(GetProcessHeap(), 0, pevlr->NumStrings * sizeof(LPVOID));
1663 if (!szArguments)
1664 goto Quit;
1665
1666 if (!IsParamModNameCached)
1667 {
1668 /* Now that the parameter file list is loaded, no need to reload it at the next run! */
1669 IsParamModNameCached = GetEventMessageFileDLL(KeyName, SourceName, EVENT_PARAMETER_MESSAGE_FILE, ParameterModuleName);
1670 // FIXME: If the string loading failed the first time, no need to retry it just after???
1671 }
1672
1673 if (IsParamModNameCached)
1674 {
1675 /* Not yet support for reading messages from parameter message DLL */
1676 }
1677
1678 szMessage = szStringArray;
1679 /*
1680 * HACK:
1681 * We do some hackish preformatting of the cached event strings...
1682 * That's because after we pass the string to FormatMessage
1683 * (via GetMessageStringFromDllList) with the FORMAT_MESSAGE_ARGUMENT_ARRAY
1684 * flag, instead of ignoring the insertion parameters and do the formatting
1685 * by ourselves. Therefore, the resulting string should have the parameter
1686 * string placeholders starting with a single '%' instead of a mix of one
1687 * and two '%'.
1688 */
1689 /* HACK part 1: Compute the full length of the string array */
1690 cch = 0;
1691 for (i = 0; i < pevlr->NumStrings; i++)
1692 {
1693 szMessage += wcslen(szMessage) + 1;
1694 }
1695 cch = szMessage - szStringArray;
1696
1697 /* HACK part 2: Now do the HACK proper! */
1698 szMessage = szStringArray;
1699 for (i = 0; i < pevlr->NumStrings; i++)
1700 {
1701 lpMsgBuf = szMessage;
1702 while ((lpMsgBuf = wcsstr(lpMsgBuf, L"%%")))
1703 {
1704 if (iswdigit(lpMsgBuf[2]))
1705 {
1706 MoveMemory(lpMsgBuf, lpMsgBuf+1, ((szStringArray + cch) - lpMsgBuf - 1) * sizeof(WCHAR));
1707 }
1708 }
1709
1710 szArguments[i] = szMessage;
1711 szMessage += wcslen(szMessage) + 1;
1712 }
1713
1714 /* Retrieve the message string without appending extra newlines */
1715 lpMsgBuf =
1716 GetMessageStringFromDllList(SourceModuleName,
1719 pevlr->EventID,
1720 0,
1721 (va_list*)szArguments);
1722 if (lpMsgBuf)
1723 {
1724 /* Trim the string */
1725 TrimNulls(lpMsgBuf);
1726
1727 szMessage = NULL;
1728 Success = (ApplyParameterStringsToMessage(ParameterModuleName,
1729 TRUE,
1730 lpMsgBuf,
1731 &szMessage) == ERROR_SUCCESS);
1732 if (Success && szMessage)
1733 {
1734 /* Free the buffer allocated by FormatMessage */
1735 LocalFree(lpMsgBuf);
1736 lpMsgBuf = szMessage;
1737 }
1738
1739 /* Copy the event text */
1740 StringCchCopyW(EventText, EVENT_MESSAGE_EVENTTEXT_BUFFER, lpMsgBuf);
1741
1742 /* Free the buffer allocated by FormatMessage */
1743 LocalFree(lpMsgBuf);
1744 }
1745
1746 HeapFree(GetProcessHeap(), 0, szArguments);
1747
1748Quit:
1749 if (!Success)
1750 {
1751 /* Get a read-only pointer to the "event-not-found" string */
1754 StringCchPrintfW(EventText, EVENT_MESSAGE_EVENTTEXT_BUFFER, lpMsgBuf, (pevlr->EventID & 0xFFFF), SourceName);
1755
1756 /* Append the strings */
1757 szMessage = szStringArray;
1758 for (i = 0; i < pevlr->NumStrings; i++)
1759 {
1760 StringCchCatW(EventText, EVENT_MESSAGE_EVENTTEXT_BUFFER, szMessage);
1762 szMessage += wcslen(szMessage) + 1;
1763 }
1764 }
1765
1766 return Success;
1767}
1768
1769VOID
1771 OUT PWCHAR eventTypeText) // TODO: Add IN DWORD BufLen
1772{
1773 switch (dwEventType)
1774 {
1777 break;
1780 break;
1783 break;
1784 case EVENTLOG_SUCCESS:
1786 break;
1789 break;
1792 break;
1793 default:
1795 break;
1796 }
1797}
1798
1799BOOL
1801 IN OUT PSID *pLastSid,
1802 OUT PWCHAR pszUser) // TODO: Add IN DWORD BufLen
1803{
1804 PSID pCurrentSid;
1805 PWSTR StringSid;
1806 WCHAR szName[1024];
1807 WCHAR szDomain[1024];
1810 DWORD cchDomain = ARRAYSIZE(szDomain);
1811 BOOL Success = FALSE;
1812
1813 /* Point to the SID */
1814 pCurrentSid = (PSID)((LPBYTE)pelr + pelr->UserSidOffset);
1815
1816 if (!IsValidSid(pCurrentSid))
1817 {
1818 *pLastSid = NULL;
1819 return FALSE;
1820 }
1821 else if (*pLastSid && EqualSid(*pLastSid, pCurrentSid))
1822 {
1823 return TRUE;
1824 }
1825
1826 /* User SID */
1827 if (pelr->UserSidLength > 0)
1828 {
1829 /*
1830 * Try to retrieve the user account name and domain name corresponding
1831 * to the SID. If it cannot be retrieved, try to convert the SID to a
1832 * string-form. It should not be bigger than the user-provided buffer
1833 * 'pszUser', otherwise we return an error.
1834 */
1836 pCurrentSid,
1837 szName,
1838 &cchName,
1839 szDomain,
1840 &cchDomain,
1841 &peUse))
1842 {
1843 StringCchCopyW(pszUser, MAX_PATH, szName);
1844 Success = TRUE;
1845 }
1846 else if (ConvertSidToStringSidW(pCurrentSid, &StringSid))
1847 {
1848 /* Copy the string only if the user-provided buffer is big enough */
1849 if (wcslen(StringSid) + 1 <= MAX_PATH) // + 1 for NULL-terminator
1850 {
1851 StringCchCopyW(pszUser, MAX_PATH, StringSid);
1852 Success = TRUE;
1853 }
1854 else
1855 {
1857 Success = FALSE;
1858 }
1859
1860 /* Free the allocated buffer */
1861 LocalFree(StringSid);
1862 }
1863 }
1864
1865 *pLastSid = Success ? pCurrentSid : NULL;
1866
1867 return Success;
1868}
1869
1870
1872{
1873 DWORD iIndex;
1874
1875 if (!g_RecordPtrs)
1876 return;
1877
1878 for (iIndex = 0; iIndex < g_TotalRecords; iIndex++)
1879 {
1880 if (g_RecordPtrs[iIndex])
1881 HeapFree(GetProcessHeap(), 0, g_RecordPtrs[iIndex]);
1882 }
1885 g_TotalRecords = 0;
1886}
1887
1888BOOL
1890 IN PEVENTLOGRECORD pevlr)
1891{
1892 if ((pevlr->EventType == EVENTLOG_SUCCESS && !EventLogFilter->Information ) ||
1893 (pevlr->EventType == EVENTLOG_INFORMATION_TYPE && !EventLogFilter->Information ) ||
1894 (pevlr->EventType == EVENTLOG_WARNING_TYPE && !EventLogFilter->Warning ) ||
1895 (pevlr->EventType == EVENTLOG_ERROR_TYPE && !EventLogFilter->Error ) ||
1896 (pevlr->EventType == EVENTLOG_AUDIT_SUCCESS && !EventLogFilter->AuditSuccess) ||
1897 (pevlr->EventType == EVENTLOG_AUDIT_FAILURE && !EventLogFilter->AuditFailure))
1898 {
1899 return FALSE;
1900 }
1901 return TRUE;
1902}
1903
1904BOOL
1905FilterByString(IN PCWSTR FilterString, // This is a multi-string
1906 IN PWSTR String)
1907{
1908 PCWSTR pStr;
1909
1910 /* The filter string is NULL so it does not filter anything */
1911 if (!FilterString)
1912 return TRUE;
1913
1914 /*
1915 * If the filter string filters for an empty string AND the source string
1916 * is an empty string, we have a match (particular case of the last one).
1917 */
1918 if (!*FilterString && !*String)
1919 return TRUE;
1920
1921 // if (*FilterString || *String)
1922
1923 /*
1924 * If the filter string is empty BUT the source string is not empty,
1925 * OR vice-versa, we cannot have a match.
1926 */
1927 if ( (!*FilterString && *String) || (*FilterString && !*String) )
1928 return FALSE;
1929
1930 /*
1931 * If the filter string filters for at least a non-empty string,
1932 * browse it and search for a string that matches the source string.
1933 */
1934 // else if (*FilterString && *String)
1935 {
1936 pStr = FilterString;
1937 while (*pStr)
1938 {
1939 if (_wcsicmp(pStr, String) == 0)
1940 {
1941 /* We have a match, break the loop */
1942 break;
1943 }
1944
1945 pStr += (wcslen(pStr) + 1);
1946 }
1947 if (!*pStr) // && *String
1948 {
1949 /* We do not have a match */
1950 return FALSE;
1951 }
1952 }
1953
1954 /* We have a match */
1955 return TRUE;
1956}
1957
1958/*
1959 * The events enumerator thread.
1960 */
1961static DWORD WINAPI
1963{
1964 PEVENTLOGFILTER EventLogFilter = (PEVENTLOGFILTER)lpParameter;
1965 PEVENTLOG EventLog;
1966
1967 ULONG LogIndex;
1968 HANDLE hEventLog;
1969 PEVENTLOGRECORD pEvlr = NULL;
1970 PBYTE pEvlrEnd;
1971 PBYTE pEvlrBuffer;
1972 DWORD dwWanted, dwRead, dwNeeded, dwStatus = ERROR_SUCCESS;
1973 DWORD dwTotalRecords = 0, dwCurrentRecord = 0;
1974 DWORD dwFlags, dwMaxLength;
1975 size_t cchRemaining;
1976 LPWSTR lpszSourceName;
1977 LPWSTR lpszComputerName;
1978 BOOL bResult = TRUE; /* Read succeeded */
1980 PSID pLastSid = NULL;
1981 INT nItems;
1982
1983 UINT uStep = 0, uStepAt = 0, uPos = 0;
1984
1985 WCHAR szWindowTitle[MAX_PATH];
1986 WCHAR szStatusText[MAX_PATH];
1987 WCHAR szLocalDate[MAX_PATH];
1988 WCHAR szLocalTime[MAX_PATH];
1989 WCHAR szEventID[MAX_PATH];
1990 WCHAR szEventTypeText[MAX_LOADSTRING];
1991 WCHAR szCategoryID[MAX_PATH];
1992 WCHAR szUsername[MAX_PATH];
1993 WCHAR szNoUsername[MAX_PATH];
1994 WCHAR szCategory[MAX_PATH];
1995 WCHAR szNoCategory[MAX_PATH];
1996 PWCHAR lpTitleTemplateEnd;
1997
1999 LVITEMW lviEventItem;
2000
2002
2003 /* Save the current event log filter globally */
2004 EventLogFilter_AddRef(EventLogFilter);
2005 ActiveFilter = EventLogFilter;
2006
2008 EventLog = EventLogFilter->EventLogs[0];
2009
2010 // FIXME: Use something else instead of EventLog->LogName !!
2011
2012 /*
2013 * Use a different formatting, whether the event log filter holds
2014 * only one log, or many logs (the latter case is WIP TODO!)
2015 */
2016 if (EventLogFilter->NumOfEventLogs <= 1)
2017 {
2018 StringCchPrintfExW(szWindowTitle,
2019 ARRAYSIZE(szWindowTitle),
2020 &lpTitleTemplateEnd,
2021 &cchRemaining,
2022 0,
2023 szTitleTemplate, szTitle, EventLog->LogName); /* i = number of characters written */
2024 dwMaxLength = (DWORD)cchRemaining;
2025 if (!EventLog->ComputerName)
2026 GetComputerNameW(lpTitleTemplateEnd, &dwMaxLength);
2027 else
2028 StringCchCopyW(lpTitleTemplateEnd, dwMaxLength, EventLog->ComputerName);
2029
2030 StringCbPrintfW(szStatusText,
2031 sizeof(szStatusText),
2033 EventLog->LogName,
2034 0,
2035 0);
2036 }
2037 else
2038 {
2039 // TODO: Use a different title & implement filtering for multi-log filters !!
2040 // (EventLogFilter->NumOfEventLogs > 1)
2042 L"Many-logs filtering is not implemented yet!!",
2043 szTitle,
2045 }
2046
2047 /* Set the window title */
2048 SetWindowTextW(hwndMainWindow, szWindowTitle);
2049
2050 /* Update the status bar */
2051 StatusBar_SetText(hwndStatus, 0, szStatusText);
2052
2053
2054 /* Disable list view redraw */
2056
2057 /* Clear the list view and free the cached records */
2059 FreeRecords();
2060
2065
2066 /* Do a loop over the logs enumerated in the filter */
2067 // FIXME: For now we only support 1 event log per filter!
2068 LogIndex = 0;
2069 // for (LogIndex = 0; LogIndex < EventLogFilter->NumOfEventLogs; ++LogIndex)
2070 {
2071
2072 EventLog = EventLogFilter->EventLogs[LogIndex];
2073
2074 /* Open the event log */
2075 if (EventLog->Permanent)
2076 hEventLog = OpenEventLogW(EventLog->ComputerName, EventLog->LogName);
2077 else
2078 hEventLog = OpenBackupEventLogW(EventLog->ComputerName, EventLog->LogName); // FileName
2079
2080 if (hEventLog == NULL)
2081 {
2083 goto Cleanup;
2084 }
2085
2086 // GetOldestEventLogRecord(hEventLog, &dwThisRecord);
2087
2088 /* Get the total number of event log records */
2089 GetNumberOfEventLogRecords(hEventLog, &dwTotalRecords);
2090
2091 if (dwTotalRecords > 0)
2092 {
2095 }
2096 else
2097 {
2100 }
2101
2102 /* Set up the event records cache */
2103 g_RecordPtrs = HeapAlloc(hProcessHeap, HEAP_ZERO_MEMORY, dwTotalRecords * sizeof(*g_RecordPtrs));
2104 if (!g_RecordPtrs)
2105 {
2106 // ShowWin32Error(GetLastError());
2107 goto Quit;
2108 }
2109 g_TotalRecords = dwTotalRecords;
2110
2112 goto Quit;
2113
2114 LoadStringW(hInst, IDS_NOT_AVAILABLE, szNoUsername, ARRAYSIZE(szNoUsername));
2115 LoadStringW(hInst, IDS_NONE, szNoCategory, ARRAYSIZE(szNoCategory));
2116
2118 uStepAt = (dwTotalRecords / 100) + 1;
2119
2121
2122 /* 0x7ffff is the maximum buffer size ReadEventLog will accept */
2123 dwWanted = 0x7ffff;
2124 pEvlr = HeapAlloc(hProcessHeap, 0, dwWanted);
2125
2126 if (!pEvlr)
2127 goto Quit;
2128
2129 while (dwStatus == ERROR_SUCCESS)
2130 {
2131 bResult = ReadEventLogW(hEventLog, dwFlags, 0, pEvlr, dwWanted, &dwRead, &dwNeeded);
2133
2134 if (!bResult && dwStatus == ERROR_INSUFFICIENT_BUFFER)
2135 {
2136 pEvlr = HeapReAlloc(hProcessHeap, 0, pEvlr, dwNeeded);
2137 dwWanted = dwNeeded;
2138
2139 if (!pEvlr)
2140 break;
2141
2142 bResult = ReadEventLogW(hEventLog, dwFlags, 0, pEvlr, dwNeeded, &dwRead, &dwNeeded);
2143
2144 if (!bResult)
2145 break;
2146 }
2147 else if (!bResult)
2148 {
2149 /* Exit on other errors (ERROR_HANDLE_EOF) */
2150 break;
2151 }
2152
2153 pEvlrBuffer = (LPBYTE)pEvlr;
2154 pEvlrEnd = pEvlrBuffer + dwRead;
2155
2156 while (pEvlrBuffer < pEvlrEnd)
2157 {
2158 PEVENTLOGRECORD pEvlrTmp = (PEVENTLOGRECORD)pEvlrBuffer;
2159 PWSTR lpszUsername, lpszCategoryName;
2160 g_RecordPtrs[dwCurrentRecord] = NULL;
2161
2162 // ProgressBar_StepIt(hwndStatusProgress);
2163 uStep++;
2164 if (uStep % uStepAt == 0)
2165 {
2166 ++uPos;
2168 }
2169
2171 goto Quit;
2172
2173 /* Filter by event type */
2174 if (!FilterByType(EventLogFilter, pEvlrTmp))
2175 goto SkipEvent;
2176
2177 /* Get the event source name and filter it */
2178 lpszSourceName = (LPWSTR)(pEvlrBuffer + sizeof(EVENTLOGRECORD));
2179 if (!FilterByString(EventLogFilter->Sources, lpszSourceName))
2180 goto SkipEvent;
2181
2182 /* Get the computer name and filter it */
2183 lpszComputerName = (LPWSTR)(pEvlrBuffer + sizeof(EVENTLOGRECORD) + (wcslen(lpszSourceName) + 1) * sizeof(WCHAR));
2184 if (!FilterByString(EventLogFilter->ComputerNames, lpszComputerName))
2185 goto SkipEvent;
2186
2187 /* Compute the event time */
2189 GetDateFormatW(LOCALE_USER_DEFAULT, DATE_SHORTDATE, &time, NULL, szLocalDate, ARRAYSIZE(szLocalDate));
2190 GetTimeFormatW(LOCALE_USER_DEFAULT, 0, &time, NULL, szLocalTime, ARRAYSIZE(szLocalTime));
2191
2192 /* Get the username that generated the event, and filter it */
2193 lpszUsername = GetEventUserName(pEvlrTmp, &pLastSid, szUsername) ? szUsername : szNoUsername;
2194
2195 if (!FilterByString(EventLogFilter->Users, lpszUsername))
2196 goto SkipEvent;
2197
2198 // TODO: Filter by event ID and category
2199 GetEventType(pEvlrTmp->EventType, szEventTypeText);
2200
2201 lpszCategoryName = GetEventCategory(EventLog->LogName, lpszSourceName, pEvlrTmp, szCategory) ? szCategory : szNoCategory;
2202
2203 StringCbPrintfW(szEventID, sizeof(szEventID), L"%u", (pEvlrTmp->EventID & 0xFFFF));
2204 StringCbPrintfW(szCategoryID, sizeof(szCategoryID), L"%u", pEvlrTmp->EventCategory);
2205
2206 g_RecordPtrs[dwCurrentRecord] = HeapAlloc(hProcessHeap, 0, pEvlrTmp->Length);
2207 CopyMemory(g_RecordPtrs[dwCurrentRecord], pEvlrTmp, pEvlrTmp->Length);
2208
2209 lviEventItem.mask = LVIF_IMAGE | LVIF_TEXT | LVIF_PARAM;
2210 lviEventItem.iItem = 0;
2211 lviEventItem.iSubItem = 0;
2212 lviEventItem.lParam = (LPARAM)g_RecordPtrs[dwCurrentRecord];
2213 lviEventItem.pszText = szEventTypeText;
2214
2215 switch (pEvlrTmp->EventType)
2216 {
2217 case EVENTLOG_SUCCESS:
2219 lviEventItem.iImage = 0;
2220 break;
2221
2223 lviEventItem.iImage = 1;
2224 break;
2225
2227 lviEventItem.iImage = 2;
2228 break;
2229
2231 lviEventItem.iImage = 3;
2232 break;
2233
2235 lviEventItem.iImage = 4;
2236 break;
2237 }
2238
2239 lviEventItem.iItem = ListView_InsertItem(hwndListView, &lviEventItem);
2240
2241 ListView_SetItemText(hwndListView, lviEventItem.iItem, 1, szLocalDate);
2242 ListView_SetItemText(hwndListView, lviEventItem.iItem, 2, szLocalTime);
2243 ListView_SetItemText(hwndListView, lviEventItem.iItem, 3, lpszSourceName);
2244 ListView_SetItemText(hwndListView, lviEventItem.iItem, 4, lpszCategoryName);
2245 ListView_SetItemText(hwndListView, lviEventItem.iItem, 5, szEventID);
2246 ListView_SetItemText(hwndListView, lviEventItem.iItem, 6, lpszUsername);
2247 ListView_SetItemText(hwndListView, lviEventItem.iItem, 7, lpszComputerName);
2248
2249SkipEvent:
2250 pEvlrBuffer += pEvlrTmp->Length;
2251 dwCurrentRecord++;
2252 }
2253 }
2254
2255Quit:
2256
2257 if (pEvlr)
2258 HeapFree(hProcessHeap, 0, pEvlr);
2259
2260 /* Close the event log */
2261 CloseEventLog(hEventLog);
2262
2263 } // end-for (LogIndex)
2264
2265 /* All events loaded */
2266
2267Cleanup:
2270
2273
2274 // FIXME: Use something else instead of EventLog->LogName !!
2275
2276 /*
2277 * Use a different formatting, whether the event log filter holds
2278 * only one log, or many logs (the latter case is WIP TODO!)
2279 */
2280 if (EventLogFilter->NumOfEventLogs <= 1)
2281 {
2282 StringCbPrintfW(szStatusText,
2283 sizeof(szStatusText),
2285 EventLog->LogName,
2286 dwTotalRecords,
2288 }
2289 else
2290 {
2291 // TODO: Use a different title & implement filtering for multi-log filters !!
2292 // (EventLogFilter->NumOfEventLogs > 1)
2293 }
2294
2295 /* Update the status bar */
2296 StatusBar_SetText(hwndStatus, 0, szStatusText);
2297
2298 /* Resume list view redraw */
2300
2301 EventLogFilter_Release(EventLogFilter);
2302
2305
2306 return 0;
2307}
2308
2309/*
2310 * The purpose of this thread is to serialize the creation of the events
2311 * enumeration thread, since the Event Log Viewer currently only supports
2312 * one view, one event list, one enumeration.
2313 */
2314static DWORD WINAPI
2316{
2317 HANDLE WaitHandles[2];
2318 DWORD WaitResult;
2319
2320 WaitHandles[0] = hStartStopEnumEvent; // End-of-application event
2321 WaitHandles[1] = hStartEnumEvent; // Command event
2322
2323 while (TRUE)
2324 {
2325 WaitResult = WaitForMultipleObjects(ARRAYSIZE(WaitHandles),
2326 WaitHandles,
2327 FALSE, // WaitAny
2328 INFINITE);
2329 switch (WaitResult)
2330 {
2331 case WAIT_OBJECT_0 + 0:
2332 {
2333 /* End-of-application event signaled, quit this thread */
2334
2335 /* Stop the previous enumeration */
2337 {
2338 if (hStopEnumEvent)
2339 {
2342 // NOTE: The following is done by the enumeration thread just before terminating.
2343 // hStopEnumEvent = NULL;
2344 }
2345
2348 }
2349
2350 /* Clear the list view and free the cached records */
2352 FreeRecords();
2353
2354 /* Reset the active filter */
2356
2357 return 0;
2358 }
2359
2360 case WAIT_OBJECT_0 + 1:
2361 {
2362 /* Restart a new enumeration if needed */
2363 PEVENTLOGFILTER EventLogFilter;
2364
2365 /* Stop the previous enumeration */
2367 {
2368 if (hStopEnumEvent)
2369 {
2372 // NOTE: The following is done by the enumeration thread just before terminating.
2373 // hStopEnumEvent = NULL;
2374 }
2375
2378 }
2379
2380 /* Clear the list view and free the cached records */
2382 FreeRecords();
2383
2384 /* Reset the active filter */
2386
2387 EventLogFilter = InterlockedExchangePointer((PVOID*)&EnumFilter, NULL);
2388 if (!EventLogFilter)
2389 break;
2390
2391 // Manual-reset event
2393 if (!hStopEnumEvent)
2394 break;
2395
2397 0,
2399 (LPVOID)EventLogFilter,
2401 NULL);
2402 if (!hEnumEventsThread)
2403 {
2406 break;
2407 }
2408 // CloseHandle(hEnumEventsThread);
2410
2411 break;
2412 }
2413
2414 default:
2415 {
2416 /* Unknown command, must never go there! */
2417 return GetLastError();
2418 }
2419 }
2420 }
2421
2422 return 0;
2423}
2424
2425VOID
2427{
2428 /* Signal the enumerator thread we want to enumerate events */
2429 InterlockedExchangePointer((PVOID*)&EnumFilter, EventLogFilter);
2431 return;
2432}
2433
2434
2437{
2438 TVITEMEXW tvItemEx;
2439 HTREEITEM hti;
2440
2441 if (phti)
2442 *phti = NULL;
2443
2444 /* Get index of selected item */
2446 if (hti == NULL)
2447 return NULL; // No filter
2448
2449 tvItemEx.mask = TVIF_PARAM;
2450 tvItemEx.hItem = hti;
2451
2452 TreeView_GetItem(hwndTreeView, &tvItemEx);
2453
2454 if (phti)
2455 *phti = tvItemEx.hItem;
2456
2457 return (PEVENTLOGFILTER)tvItemEx.lParam;
2458}
2459
2460
2461VOID
2463{
2464 WIN32_FIND_DATAW FindData;
2465 HANDLE hFind;
2466 PEVENTLOG EventLog;
2467 PEVENTLOGFILTER EventLogFilter;
2468 SIZE_T cchFileName;
2470
2471 /* Check whether the file actually exists */
2472 hFind = FindFirstFileW(lpszFileName, &FindData);
2473 if (hFind == INVALID_HANDLE_VALUE)
2474 {
2476 return;
2477 }
2478 FindClose(hFind);
2479
2480 /* Allocate a new event log entry */
2481 EventLog = AllocEventLog(NULL, lpszFileName, FALSE);
2482 if (EventLog == NULL)
2483 {
2485 return;
2486 }
2487
2488 /* Allocate a new event log filter entry for this event log */
2489 EventLogFilter = AllocEventLogFilter(// LogName,
2490 TRUE, TRUE, TRUE, TRUE, TRUE,
2491 NULL, NULL, NULL,
2492 1, &EventLog);
2493 if (EventLogFilter == NULL)
2494 {
2496 EventLog_Free(EventLog);
2497 return;
2498 }
2499
2500 /* Add the event log and the filter into their lists */
2502 InsertTailList(&EventLogFilterList, &EventLogFilter->ListEntry);
2503
2504 /* Retrieve and cache the event log file */
2505 cchFileName = wcslen(lpszFileName) + 1;
2506 EventLog->FileName = HeapAlloc(GetProcessHeap(), 0, cchFileName * sizeof(WCHAR));
2507 if (EventLog->FileName)
2508 StringCchCopyW(EventLog->FileName, cchFileName, lpszFileName);
2509
2511 (LPWSTR)lpszFileName,
2512 2, 3, (LPARAM)EventLogFilter);
2513
2514 /* Select the event log */
2515 if (hItem)
2516 {
2517 // TreeView_Expand(hwndTreeView, htiUserLogs, TVE_EXPAND);
2520 }
2523}
2524
2525VOID
2527{
2528 WCHAR szFileName[MAX_PATH];
2529
2530 ZeroMemory(szFileName, sizeof(szFileName));
2531
2532 sfn.lpstrFile = szFileName;
2533 sfn.nMaxFile = ARRAYSIZE(szFileName);
2534
2535 if (!GetOpenFileNameW(&sfn))
2536 return;
2538
2540}
2541
2542VOID
2544{
2545 PEVENTLOG EventLog;
2546 HANDLE hEventLog;
2547 WCHAR szFileName[MAX_PATH];
2548
2549 /* Bail out if there is no available filter */
2550 if (!EventLogFilter)
2551 return;
2552
2553 ZeroMemory(szFileName, sizeof(szFileName));
2554
2555 sfn.lpstrFile = szFileName;
2556 sfn.nMaxFile = ARRAYSIZE(szFileName);
2557
2558 if (!GetSaveFileNameW(&sfn))
2559 return;
2560
2561 EventLogFilter_AddRef(EventLogFilter);
2562
2563 EventLog = EventLogFilter->EventLogs[0];
2564 hEventLog = OpenEventLogW(EventLog->ComputerName, EventLog->LogName);
2565
2566 EventLogFilter_Release(EventLogFilter);
2567
2568 if (!hEventLog)
2569 {
2571 return;
2572 }
2573
2574 if (!BackupEventLogW(hEventLog, szFileName))
2576
2577 CloseEventLog(hEventLog);
2578}
2579
2580VOID
2582{
2583 /* Bail out if there is no available filter */
2584 if (!EventLogFilter)
2585 return;
2586
2587 if (InterlockedCompareExchangePointer((PVOID*)&ActiveFilter, NULL, NULL) == EventLogFilter)
2588 {
2589 /* Signal the enumerator thread we want to stop enumerating events */
2590 // EnumEvents(NULL);
2593 }
2594
2595 /*
2596 * The deletion of the item automatically triggers a TVN_SELCHANGED
2597 * notification, that will reset the ActiveFilter (in case the item
2598 * selected is a filter). Otherwise we reset it there.
2599 */
2601
2602 /* Remove the filter from the list */
2603 RemoveEntryList(&EventLogFilter->ListEntry);
2604 EventLogFilter_Release(EventLogFilter);
2605
2606 // /* Select the default event log */
2607 // // TreeView_Expand(hwndTreeView, htiUserLogs, TVE_EXPAND);
2608 // TreeView_SelectItem(hwndTreeView, hItem);
2609 // TreeView_EnsureVisible(hwndTreeView, hItem);
2612}
2613
2614
2615BOOL
2617{
2618 BOOL Success;
2619 PEVENTLOG EventLog;
2620 HANDLE hEventLog;
2621 WCHAR szFileName[MAX_PATH];
2622 WCHAR szMessage[MAX_LOADSTRING];
2623
2624 /* Bail out if there is no available filter */
2625 if (!EventLogFilter)
2626 return FALSE;
2627
2628 ZeroMemory(szFileName, sizeof(szFileName));
2629 ZeroMemory(szMessage, sizeof(szMessage));
2630
2631 LoadStringW(hInst, IDS_CLEAREVENTS_MSG, szMessage, ARRAYSIZE(szMessage));
2632
2633 sfn.lpstrFile = szFileName;
2634 sfn.nMaxFile = ARRAYSIZE(szFileName);
2635
2637 {
2638 case IDCANCEL:
2639 return FALSE;
2640
2641 case IDNO:
2642 sfn.lpstrFile = NULL;
2643 break;
2644
2645 case IDYES:
2646 if (!GetSaveFileNameW(&sfn))
2647 return FALSE;
2648 break;
2649 }
2650
2651 EventLogFilter_AddRef(EventLogFilter);
2652
2653 EventLog = EventLogFilter->EventLogs[0];
2654 hEventLog = OpenEventLogW(EventLog->ComputerName, EventLog->LogName);
2655
2656 EventLogFilter_Release(EventLogFilter);
2657
2658 if (!hEventLog)
2659 {
2661 return FALSE;
2662 }
2663
2664 Success = ClearEventLogW(hEventLog, sfn.lpstrFile);
2665 if (!Success)
2667
2668 CloseEventLog(hEventLog);
2669 return Success;
2670}
2671
2672
2673VOID
2675{
2676 /* Bail out if there is no available filter */
2677 if (!EventLogFilter)
2678 return;
2679
2680 /* Reenumerate the events through the filter */
2681 EnumEvents(EventLogFilter);
2682}
2683
2684
2685ATOM
2687{
2688 WNDCLASSEXW wcex;
2689
2690 wcex.cbSize = sizeof(wcex);
2691 wcex.style = 0;
2692 wcex.lpfnWndProc = WndProc;
2693 wcex.cbClsExtra = 0;
2694 wcex.cbWndExtra = 0;
2695 wcex.hInstance = hInstance;
2698 wcex.hbrBackground = (HBRUSH)(COLOR_3DFACE + 1); // COLOR_WINDOW + 1
2703 IMAGE_ICON,
2704 16,
2705 16,
2706 LR_SHARED);
2707
2708 return RegisterClassExW(&wcex);
2709}
2710
2711
2712BOOL
2714 OUT PWCHAR lpModuleName, // TODO: Add IN DWORD BufLen
2715 OUT PDWORD pdwMessageID)
2716{
2717 BOOL Success = FALSE;
2718 LONG Result;
2719 HKEY hLogKey;
2720 WCHAR *KeyPath;
2721 SIZE_T cbKeyPath;
2722 DWORD dwType, cbData;
2723 DWORD dwMessageID = 0;
2725
2726 /* Use a default value for the message ID */
2727 *pdwMessageID = 0;
2728
2729 cbKeyPath = (wcslen(EVENTLOG_BASE_KEY) + wcslen(lpLogName) + 1) * sizeof(WCHAR);
2730 KeyPath = HeapAlloc(GetProcessHeap(), 0, cbKeyPath);
2731 if (!KeyPath)
2732 {
2734 return FALSE;
2735 }
2736
2737 StringCbCopyW(KeyPath, cbKeyPath, EVENTLOG_BASE_KEY);
2738 StringCbCatW(KeyPath, cbKeyPath, lpLogName);
2739
2740 Result = RegOpenKeyExW(hkMachine, KeyPath, 0, KEY_QUERY_VALUE, &hLogKey);
2741 HeapFree(GetProcessHeap(), 0, KeyPath);
2742 if (Result != ERROR_SUCCESS)
2743 {
2745 return FALSE;
2746 }
2747
2748 cbData = sizeof(szModuleName);
2749 Result = RegQueryValueExW(hLogKey,
2750 L"DisplayNameFile",
2751 NULL,
2752 &dwType,
2754 &cbData);
2755 if ((Result != ERROR_SUCCESS) || (dwType != REG_EXPAND_SZ && dwType != REG_SZ))
2756 {
2758 }
2759 else
2760 {
2761 /* NULL-terminate the string and expand it */
2762 szModuleName[cbData / sizeof(WCHAR) - 1] = UNICODE_NULL;
2764 Success = TRUE;
2765 }
2766
2767 /*
2768 * If we have a 'DisplayNameFile', query for 'DisplayNameID';
2769 * otherwise it's not really useful. 'DisplayNameID' is optional.
2770 */
2771 if (Success)
2772 {
2773 cbData = sizeof(dwMessageID);
2774 Result = RegQueryValueExW(hLogKey,
2775 L"DisplayNameID",
2776 NULL,
2777 &dwType,
2778 (LPBYTE)&dwMessageID,
2779 &cbData);
2780 if ((Result != ERROR_SUCCESS) || (dwType != REG_DWORD))
2781 dwMessageID = 0;
2782
2783 *pdwMessageID = dwMessageID;
2784 }
2785
2786 RegCloseKey(hLogKey);
2787
2788 return Success;
2789}
2790
2791
2792VOID
2794{
2795 LONG Result;
2796 HKEY hEventLogKey, hLogKey;
2797 DWORD dwNumLogs = 0;
2798 DWORD dwIndex, dwMaxKeyLength;
2799 DWORD dwType;
2800 PEVENTLOG EventLog;
2801 PEVENTLOGFILTER EventLogFilter;
2802 LPWSTR LogName = NULL;
2804 DWORD lpcName;
2805 DWORD dwMessageID;
2807 HTREEITEM hRootNode = NULL, hItem = NULL, hItemDefault = NULL;
2808
2810 {
2811 /* We are connected to some other computer, close the old connection */
2813 hkMachine = NULL;
2814 }
2816 {
2817 /* Use the local computer registry */
2819 }
2820 else
2821 {
2822 /* Connect to the remote computer registry */
2824 if (Result != ERROR_SUCCESS)
2825 {
2826 /* Connection failed, display a message and bail out */
2827 hkMachine = NULL;
2829 return;
2830 }
2831 }
2832
2833 /* Open the EventLog key */
2835 if (Result != ERROR_SUCCESS)
2836 {
2837 return;
2838 }
2839
2840 /* Retrieve the number of event logs enumerated as registry keys */
2841 Result = RegQueryInfoKeyW(hEventLogKey, NULL, NULL, NULL, &dwNumLogs, &dwMaxKeyLength,
2842 NULL, NULL, NULL, NULL, NULL, NULL);
2843 if (Result != ERROR_SUCCESS)
2844 {
2845 goto Quit;
2846 }
2847 if (!dwNumLogs)
2848 goto Quit;
2849
2850 /* Take the NULL terminator into account */
2851 ++dwMaxKeyLength;
2852
2853 /* Allocate the temporary buffer */
2854 LogName = HeapAlloc(GetProcessHeap(), 0, dwMaxKeyLength * sizeof(WCHAR));
2855 if (!LogName)
2856 goto Quit;
2857
2858 /* Enumerate and retrieve each event log name */
2859 for (dwIndex = 0; dwIndex < dwNumLogs; dwIndex++)
2860 {
2861 lpcName = dwMaxKeyLength;
2862 Result = RegEnumKeyExW(hEventLogKey, dwIndex, LogName, &lpcName, NULL, NULL, NULL, NULL);
2863 if (Result != ERROR_SUCCESS)
2864 continue;
2865
2866 /* Take the NULL terminator into account */
2867 ++lpcName;
2868
2869 /* Allocate a new event log entry */
2870 EventLog = AllocEventLog(lpComputerName, LogName, TRUE);
2871 if (EventLog == NULL)
2872 continue;
2873
2874 /* Allocate a new event log filter entry for this event log */
2875 EventLogFilter = AllocEventLogFilter(// LogName,
2876 TRUE, TRUE, TRUE, TRUE, TRUE,
2877 NULL, NULL, NULL,
2878 1, &EventLog);
2879 if (EventLogFilter == NULL)
2880 {
2881 EventLog_Free(EventLog);
2882 continue;
2883 }
2884
2885 /* Add the event log and the filter into their lists */
2887 InsertTailList(&EventLogFilterList, &EventLogFilter->ListEntry);
2888
2889 EventLog->FileName = NULL;
2890
2891 /* Retrieve and cache the event log file */
2892 Result = RegOpenKeyExW(hEventLogKey,
2893 LogName,
2894 0,
2896 &hLogKey);
2897 if (Result == ERROR_SUCCESS)
2898 {
2899 lpcName = 0;
2900 Result = RegQueryValueExW(hLogKey,
2901 L"File",
2902 NULL,
2903 &dwType,
2904 NULL,
2905 &lpcName);
2906 if ((Result != ERROR_SUCCESS) || (dwType != REG_EXPAND_SZ && dwType != REG_SZ))
2907 {
2908 // Windows' EventLog uses some kind of default value, we do not.
2909 EventLog->FileName = NULL;
2910 }
2911 else
2912 {
2913 lpcName = ROUND_DOWN(lpcName, sizeof(WCHAR));
2914 EventLog->FileName = HeapAlloc(GetProcessHeap(), 0, lpcName);
2915 if (EventLog->FileName)
2916 {
2917 Result = RegQueryValueExW(hLogKey,
2918 L"File",
2919 NULL,
2920 &dwType,
2921 (LPBYTE)EventLog->FileName,
2922 &lpcName);
2923 if (Result != ERROR_SUCCESS)
2924 {
2925 HeapFree(GetProcessHeap(), 0, EventLog->FileName);
2926 EventLog->FileName = NULL;
2927 }
2928 else
2929 {
2930 EventLog->FileName[lpcName / sizeof(WCHAR) - 1] = UNICODE_NULL;
2931 }
2932 }
2933 }
2934
2935 RegCloseKey(hLogKey);
2936 }
2937
2938 /* Get the display name for the event log */
2940
2942 if (GetDisplayNameFileAndID(LogName, szModuleName, &dwMessageID))
2943 {
2944 /* Retrieve the message string without appending extra newlines */
2949 dwMessageID,
2950 0,
2951 NULL);
2952 }
2953
2954 /*
2955 * Select the correct tree root node, whether the log is a System
2956 * or an Application log. Default to Application log otherwise.
2957 */
2958 hRootNode = htiAppLogs;
2959 for (lpcName = 0; lpcName < ARRAYSIZE(SystemLogs); ++lpcName)
2960 {
2961 /* Check whether the log name is part of the system logs */
2962 if (_wcsicmp(LogName, SystemLogs[lpcName]) == 0)
2963 {
2964 hRootNode = htiSystemLogs;
2965 break;
2966 }
2967 }
2968
2969 hItem = TreeViewAddItem(hwndTreeView, hRootNode,
2970 (lpDisplayName ? lpDisplayName : LogName),
2971 2, 3, (LPARAM)EventLogFilter);
2972
2973 /* Try to get the default event log: "Application" */
2974 if ((hItemDefault == NULL) && (_wcsicmp(LogName, SystemLogs[0]) == 0))
2975 {
2976 hItemDefault = hItem;
2977 }
2978
2979 /* Free the buffer allocated by FormatMessage */
2980 if (lpDisplayName)
2982 }
2983
2984 HeapFree(GetProcessHeap(), 0, LogName);
2985
2986Quit:
2987 RegCloseKey(hEventLogKey);
2988
2989 /* Select the default event log */
2990 if (hItemDefault)
2991 {
2992 // TreeView_Expand(hwndTreeView, hRootNode, TVE_EXPAND);
2993 TreeView_SelectItem(hwndTreeView, hItemDefault);
2994 TreeView_EnsureVisible(hwndTreeView, hItemDefault);
2995 }
2998
2999 return;
3000}
3001
3002VOID
3004{
3006 PEVENTLOG EventLog;
3007
3008 while (!IsListEmpty(&EventLogList))
3009 {
3011 EventLog = (PEVENTLOG)CONTAINING_RECORD(Entry, EVENTLOG, ListEntry);
3012 EventLog_Free(EventLog);
3013 }
3014
3015 return;
3016}
3017
3018VOID
3020{
3022 PEVENTLOGFILTER EventLogFilter;
3023
3025 {
3027 EventLogFilter = (PEVENTLOGFILTER)CONTAINING_RECORD(Entry, EVENTLOGFILTER, ListEntry);
3028 EventLogFilter_Free(EventLogFilter);
3029 }
3030
3032
3033 return;
3034}
3035
3036BOOL
3038{
3039 RECT rcClient, rs;
3040 LONG StatusHeight;
3041 HIMAGELIST hSmall;
3042 LVCOLUMNW lvc = {0};
3043 WCHAR szTemp[256];
3044 INT iColumn;
3045 static const struct
3046 {
3047 WORD width;
3048 WORD uID;
3049 } columnItems[] =
3050 {
3051 { 90, IDS_COLUMNTYPE },
3052 { 70, IDS_COLUMNDATE },
3053 { 70, IDS_COLUMNTIME },
3054 { 150, IDS_COLUMNSOURCE },
3055 { 100, IDS_COLUMNCATEGORY },
3056 { 60, IDS_COLUMNEVENT },
3057 { 120, IDS_COLUMNUSER },
3058 { 100, IDS_COLUMNCOMPUTER },
3059 };
3060
3061 /* Create the main window */
3062 rs = Settings.wpPos.rcNormalPosition;
3064 szTitle,
3066 rs.left, rs.top,
3067 (rs.right != CW_USEDEFAULT && rs.left != CW_USEDEFAULT) ? rs.right - rs.left : CW_USEDEFAULT,
3068 (rs.bottom != CW_USEDEFAULT && rs.top != CW_USEDEFAULT) ? rs.bottom - rs.top : CW_USEDEFAULT,
3069 NULL,
3070 NULL,
3071 hInstance,
3072 NULL);
3073 if (!hwndMainWindow)
3074 return FALSE;
3075
3076 /* Create the status bar */
3077 hwndStatus = CreateWindowExW(0, // no extended styles
3078 STATUSCLASSNAMEW, // status bar
3079 L"", // no text
3081 0, 0, 0, 0, // x, y, cx, cy
3082 hwndMainWindow, // parent window
3083 (HMENU)100, // window ID
3084 hInstance, // instance
3085 NULL); // window data
3086
3087 GetClientRect(hwndMainWindow, &rcClient);
3089 StatusHeight = rs.bottom - rs.top;
3090
3091 /* Create a progress bar in the status bar (hidden by default) */
3093 hwndStatusProgress = CreateWindowExW(0, // no extended styles
3094 PROGRESS_CLASSW, // status bar
3095 NULL, // no text
3096 WS_CHILD | PBS_SMOOTH, // styles
3097 rs.left, rs.top, // x, y
3098 rs.right - rs.left, rs.bottom - rs.top, // cx, cy
3099 hwndStatus, // parent window
3100 NULL, // window ID
3101 hInstance, // instance
3102 NULL); // window data
3103 /* Remove its static edge */
3107
3108 /* Initialize the splitter default positions */
3109 nVSplitPos = Settings.nVSplitPos;
3110 nHSplitPos = Settings.nHSplitPos;
3111
3112 /* Create the TreeView */
3115 NULL,
3116 // WS_CHILD | WS_VISIBLE | TVS_HASLINES | TVS_SHOWSELALWAYS,
3118 0, 0,
3120 (rcClient.bottom - rcClient.top) - StatusHeight,
3122 NULL,
3123 hInstance,
3124 NULL);
3125
3126 /* Create the ImageList */
3129 ILC_COLOR32 | ILC_MASK, // ILC_COLOR24
3130 1, 1);
3131
3132 /* Add event type icons to the ImageList: closed/opened folder, event log (normal/viewed) */
3137
3138 /* Assign the ImageList to the Tree View */
3140
3141 /* Add the event logs nodes */
3142 // "System Logs"
3145 // "Application Logs"
3148 // "User Logs"
3151
3152 /* Create the Event details pane (optional) */
3154 if (hwndEventDetails)
3155 {
3161 (rcClient.right - rcClient.left) - nVSplitPos - SPLIT_WIDTH/2,
3162 (rcClient.bottom - rcClient.top) - nHSplitPos - SPLIT_WIDTH/2 - StatusHeight,
3164 }
3165
3166 /* Create the ListView */
3169 NULL,
3172 0,
3173 (rcClient.right - rcClient.left) - nVSplitPos - SPLIT_WIDTH/2,
3174 hwndEventDetails && Settings.bShowDetailsPane
3176 : (rcClient.bottom - rcClient.top) - StatusHeight,
3178 NULL,
3179 hInstance,
3180 NULL);
3181
3182 /* Add the extended ListView styles */
3184
3185 /* Create the ImageList */
3188 ILC_COLOR32 | ILC_MASK, // ILC_COLOR24
3189 1, 1);
3190
3191 /* Add event type icons to the ImageList */
3197
3198 /* Assign the ImageList to the List View */
3200
3201 /* Now set up the listview with its columns */
3202 lvc.mask = LVCF_TEXT | LVCF_WIDTH;
3203 lvc.pszText = szTemp;
3204 for (iColumn = 0; iColumn < ARRAYSIZE(columnItems); ++iColumn)
3205 {
3206 lvc.cx = columnItems[iColumn].width;
3207 LoadStringW(hInstance, columnItems[iColumn].uID, szTemp, ARRAYSIZE(szTemp));
3208 ListView_InsertColumn(hwndListView, iColumn, &lvc);
3209 }
3210
3211 /* Initialize the save Dialog */
3212 ZeroMemory(&sfn, sizeof(sfn));
3214
3216
3217 sfn.lStructSize = sizeof(sfn);
3223 sfn.lpstrDefExt = L"evt";
3224
3225 ShowWindow(hwndMainWindow, Settings.wpPos.showCmd);
3227
3228 return TRUE;
3229}
3230
3232{
3233 RECT rs;
3234 LONG StatusHeight;
3235 LONG_PTR dwExStyle;
3236 HDWP hdwp;
3237
3238 /* Resize the status bar -- now done in WM_SIZE */
3239 // SendMessageW(hwndStatus, WM_SIZE, 0, 0);
3241 StatusHeight = rs.bottom - rs.top;
3242
3243 /*
3244 * Move the progress bar -- Take into account for extra size due to the static edge
3245 * (AdjustWindowRectEx() does not seem to work for the progress bar).
3246 */
3251 rs.left, rs.top, rs.right - rs.left, rs.bottom - rs.top,
3254
3255 /*
3256 * TODO: Adjust the splitter positions:
3257 * - Vertical splitter (1) : fixed position from the left window side.
3258 * - Horizontal splitter (2): fixed position from the bottom window side.
3259 */
3261 nHSplitPos = min(max(nHSplitPos, SPLIT_WIDTH/2), cy - SPLIT_WIDTH/2 - StatusHeight); // FIXME!
3262
3263 hdwp = BeginDeferWindowPos(3);
3264
3265 if (hdwp)
3266 hdwp = DeferWindowPos(hdwp,
3268 HWND_TOP,
3269 0, 0,
3271 cy - StatusHeight,
3273
3274 if (hdwp)
3275 hdwp = DeferWindowPos(hdwp,
3277 HWND_TOP,
3278 nVSplitPos + SPLIT_WIDTH/2, 0,
3280 hwndEventDetails && Settings.bShowDetailsPane
3282 : cy - StatusHeight,
3284
3285 if (hwndEventDetails && Settings.bShowDetailsPane && hdwp)
3286 hdwp = DeferWindowPos(hdwp,
3288 HWND_TOP,
3292 cy - nHSplitPos - SPLIT_WIDTH/2 - StatusHeight,
3294
3295 if (hdwp)
3296 EndDeferWindowPos(hdwp);
3297}
3298
3299
3302{
3303 RECT rect;
3304
3305 switch (uMsg)
3306 {
3307 case WM_CREATE:
3309 break;
3310
3311 case WM_DESTROY:
3312 {
3314 PostQuitMessage(0);
3315 break;
3316 }
3317
3318 case WM_NOTIFY:
3319 {
3321
3322 if (hdr->hwndFrom == hwndListView)
3323 {
3324 switch (hdr->code)
3325 {
3326 case LVN_ITEMCHANGED:
3327 {
3329
3330 if ( (pnmv->uChanged & LVIF_STATE) && /* The state has changed */
3331 (pnmv->uNewState & LVIS_SELECTED) /* The item has been (de)selected */ )
3332 {
3333 if (!hwndEventDetails)
3334 break;
3335
3336 /* Verify the index of selected item */
3337 if (pnmv->iItem == -1)
3338 {
3340 L"No selected items!",
3341 szTitle,
3343 break;
3344 }
3346 }
3347 break;
3348 }
3349
3350#ifdef LVN_ITEMACTIVATE
3351 case LVN_ITEMACTIVATE:
3352 {
3353 /* Get the index of the single focused selected item */
3355 INT iItem = lpnmitem->iItem;
3356 if (iItem != -1)
3358 break;
3359 }
3360#else // LVN_ITEMACTIVATE
3361 case NM_DBLCLK:
3362 case NM_RETURN:
3363 {
3364 /* Get the index of the single focused selected item */
3366 if (iItem != -1)
3368 break;
3369 }
3370#endif // LVN_ITEMACTIVATE
3371 }
3372 }
3373 else if (hdr->hwndFrom == hwndTreeView)
3374 {
3375 switch (hdr->code)
3376 {
3377 case TVN_BEGINLABELEDIT:
3378 {
3379 HTREEITEM hItem = ((LPNMTVDISPINFO)lParam)->item.hItem;
3380
3381 /* Disable label editing for root nodes */
3382 return ((hItem == htiSystemLogs) ||
3383 (hItem == htiAppLogs) ||
3384 (hItem == htiUserLogs));
3385 }
3386
3387 case TVN_ENDLABELEDIT:
3388 {
3389 TVITEMW item = ((LPNMTVDISPINFO)lParam)->item;
3390 HTREEITEM hItem = item.hItem;
3391
3392 /* Disable label editing for root nodes */
3393 if ((hItem == htiSystemLogs) ||
3394 (hItem == htiAppLogs) ||
3395 (hItem == htiUserLogs))
3396 {
3397 return FALSE;
3398 }
3399
3400 if (item.pszText)
3401 {
3402 LPWSTR pszText = item.pszText;
3403
3404 /* Trim leading whitespace */
3405 while (*pszText && iswspace(*pszText))
3406 ++pszText;
3407
3408 if (!*pszText)
3409 return FALSE;
3410
3411 return TRUE;
3412 }
3413 else
3414 {
3415 return FALSE;
3416 }
3417 }
3418
3419 case TVN_SELCHANGED:
3420 {
3421 PEVENTLOGFILTER EventLogFilter =
3422 (PEVENTLOGFILTER)((LPNMTREEVIEW)lParam)->itemNew.lParam;
3423
3424 // FIXME: It might be nice to reference here the filter,
3425 // so that we don't have to reference/dereference it many times
3426 // in the other functions???
3427
3428 // FIXME: This is a hack!!
3429 if (hwndEventDetails && EventLogFilter)
3430 {
3431 SendMessageW(hwndEventDetails, EVT_SETFILTER, 0, (LPARAM)EventLogFilter);
3432 }
3433
3434 if (EventLogFilter)
3435 {
3436 /*
3437 * If we have selected a filter, enable the menu commands;
3438 * they will possibly be updated after events enumeration.
3439 */
3445 }
3446 else
3447 {
3453 }
3454
3455 /*
3456 * The enumeration thread that is triggered by EnumEvents
3457 * will set a new value for the 'ActiveFilter'.
3458 */
3459 if (EventLogFilter)
3460 EnumEvents(EventLogFilter);
3461
3462 break;
3463 }
3464 }
3465 }
3466 break;
3467 }
3468
3469 case WM_COMMAND:
3470 {
3471 /* Parse the menu selections */
3472 switch (LOWORD(wParam))
3473 {
3474 case IDM_OPEN_EVENTLOG:
3476 break;
3477
3478 case IDM_SAVE_EVENTLOG:
3480 break;
3481
3482 case IDM_CLOSE_EVENTLOG:
3483 {
3484 HTREEITEM hti;
3485 PEVENTLOGFILTER EventLogFilter = GetSelectedFilter(&hti);
3486 CloseUserEventLog(EventLogFilter, hti);
3487 break;
3488 }
3489
3490 case IDM_CLEAR_EVENTS:
3491 {
3492 PEVENTLOGFILTER EventLogFilter = GetSelectedFilter(NULL);
3493 if (EventLogFilter && ClearEvents(EventLogFilter))
3494 Refresh(EventLogFilter);
3495 break;
3496 }
3497
3499 if (GetFocus() == hwndTreeView)
3501 break;
3502
3504 {
3505 PEVENTLOGFILTER EventLogFilter = GetSelectedFilter(NULL);
3506 // TODO: Check the returned value?
3507 if (EventLogFilter)
3508 EventLogProperties(hInst, hWnd, EventLogFilter);
3509 break;
3510 }
3511
3512 case IDM_LIST_NEWEST:
3513 case IDM_LIST_OLDEST:
3514 {
3515 BOOL bNewest = (LOWORD(wParam) == IDM_LIST_NEWEST);
3517
3518 if (bNewest != Settings.bNewestEventsFirst)
3519 {
3520 Settings.bNewestEventsFirst = bNewest;
3522 }
3523 break;
3524 }
3525
3526 case IDM_EVENT_DETAILS:
3527 {
3528 INT iItem;
3529 PEVENTLOGFILTER EventLogFilter;
3530
3531 /* Get the index of the single focused selected item */
3533 if (iItem == -1)
3534 {
3543 break;
3544 }
3545
3546 EventLogFilter = GetSelectedFilter(NULL);
3547 if (EventLogFilter)
3548 {
3549 EVENTDETAIL_INFO DetailInfo = {EventLogFilter, iItem};
3550
3551 EventLogFilter_AddRef(EventLogFilter);
3554 hWnd,
3556 (LPARAM)&DetailInfo);
3557 EventLogFilter_Release(EventLogFilter);
3558 }
3559 break;
3560 }
3561
3562 case IDM_REFRESH:
3564 break;
3565
3567 {
3568 Settings.bShowDetailsPane = !Settings.bShowDetailsPane;
3570 MF_BYCOMMAND | (Settings.bShowDetailsPane ? MF_CHECKED : MF_UNCHECKED));
3571
3573 if (Settings.bShowDetailsPane)
3574 {
3575 ResizeWnd(rect.right - rect.left, rect.bottom - rect.top);
3577 }
3578 else
3579 {
3581 ResizeWnd(rect.right - rect.left, rect.bottom - rect.top);
3582 }
3583
3584 break;
3585 }
3586
3588 {
3589 Settings.bShowGrid = !Settings.bShowGrid;
3591 MF_BYCOMMAND | (Settings.bShowGrid ? MF_CHECKED : MF_UNCHECKED));
3592
3594 break;
3595 }
3596
3597 case IDM_SAVE_SETTINGS:
3598 {
3599 Settings.bSaveSettings = !Settings.bSaveSettings;
3601 MF_BYCOMMAND | (Settings.bSaveSettings ? MF_CHECKED : MF_UNCHECKED));
3602 break;
3603 }
3604
3605 case IDM_ABOUT:
3606 {
3607 WCHAR szCopyright[MAX_LOADSTRING];
3608
3609 LoadStringW(hInst, IDS_COPYRIGHT, szCopyright, ARRAYSIZE(szCopyright));
3610 ShellAboutW(hWnd, szTitle, szCopyright,
3612 break;
3613 }
3614
3615 case IDM_HELP:
3617 L"Help not implemented yet!",
3618 szTitle,
3620 break;
3621
3622 case IDM_EXIT:
3624 break;
3625
3626 default:
3627 return DefWindowProcW(hWnd, uMsg, wParam, lParam);
3628 }
3629 break;
3630 }
3631
3632 case WM_INITMENU:
3633 {
3634 if ((HMENU)wParam != hMainMenu)
3635 break;
3636
3638 Settings.bNewestEventsFirst ? IDM_LIST_NEWEST : IDM_LIST_OLDEST,
3639 MF_BYCOMMAND);
3640
3641 if (!hwndEventDetails)
3642 {
3645 }
3647 MF_BYCOMMAND | (Settings.bShowDetailsPane ? MF_CHECKED : MF_UNCHECKED));
3648
3650 MF_BYCOMMAND | (Settings.bShowGrid ? MF_CHECKED : MF_UNCHECKED));
3651
3653 MF_BYCOMMAND | (Settings.bSaveSettings ? MF_CHECKED : MF_UNCHECKED));
3654
3655 break;
3656 }
3657
3658#if 0
3659 case WM_INITMENUPOPUP:
3660 lParam = lParam;
3661 break;
3662#endif
3663
3664 case WM_CONTEXTMENU:
3665 {
3666 RECT rc;
3668 TVHITTESTINFO hInfo = {0};
3669
3670 INT xPos = GET_X_LPARAM(lParam);
3671 INT yPos = GET_Y_LPARAM(lParam);
3672
3674 hInfo.pt.x = xPos - rc.left;
3675 hInfo.pt.y = yPos - rc.top;
3676
3678 if (hItem)
3679 {
3681
3683 {
3685
3686 DWORD dwCmdID = TrackPopupMenuEx(hCtxMenu,
3688 xPos, yPos, hWnd, NULL);
3690 }
3691 }
3692 break;
3693 }
3694
3695 case WM_SETCURSOR:
3696 {
3697 POINT pt;
3698
3699 if (LOWORD(lParam) != HTCLIENT)
3700 goto Default;
3701
3702 GetCursorPos(&pt);
3704
3705 /* Set the cursor for the vertical splitter */
3706 if (pt.x >= nVSplitPos - SPLIT_WIDTH/2 && pt.x < nVSplitPos + SPLIT_WIDTH/2 + 1)
3707 {
3708 RECT rs;
3711 if (pt.y >= rect.top && pt.y < rect.bottom - (rs.bottom - rs.top))
3712 {
3714 return TRUE;
3715 }
3716 }
3717 else
3718 /* Set the cursor for the horizontal splitter, if the Event details pane is displayed */
3719 if (hwndEventDetails && Settings.bShowDetailsPane &&
3720 (pt.y >= nHSplitPos - SPLIT_WIDTH/2 && pt.y < nHSplitPos + SPLIT_WIDTH/2 + 1))
3721 {
3722 // RECT rs;
3724 // GetWindowRect(hwndStatus, &rs);
3725 if (pt.x >= nVSplitPos + SPLIT_WIDTH/2 + 1 /* rect.left + (rs.bottom - rs.top) */ &&
3726 pt.x < rect.right)
3727 {
3729 return TRUE;
3730 }
3731 }
3732 goto Default;
3733 }
3734
3735 case WM_LBUTTONDOWN:
3736 {
3739
3740 /* Reset the splitter state */
3741 bSplit = 0;
3742
3743 /* Capture the cursor for the vertical splitter */
3744 if (x >= nVSplitPos - SPLIT_WIDTH/2 && x < nVSplitPos + SPLIT_WIDTH/2 + 1)
3745 {
3746 bSplit = 1;
3748 }
3749 else
3750 /* Capture the cursor for the horizontal splitter, if the Event details pane is displayed */
3751 if (hwndEventDetails && Settings.bShowDetailsPane &&
3752 (y >= nHSplitPos - SPLIT_WIDTH/2 && y < nHSplitPos + SPLIT_WIDTH/2 + 1))
3753 {
3754 bSplit = 2;
3756 }
3757 break;
3758 }
3759
3760 case WM_LBUTTONUP:
3761 case WM_RBUTTONDOWN:
3762 {
3763 if (GetCapture() != hWnd)
3764 break;
3765
3766 /* Adjust the correct splitter position */
3767 if (bSplit == 1)
3769 else if (bSplit == 2)
3771
3772 /* If we are splitting, resize the windows */
3773 if (bSplit != 0)
3774 {
3776 ResizeWnd(rect.right - rect.left, rect.bottom - rect.top);
3777 }
3778
3779 /* Reset the splitter state */
3780 bSplit = 0;
3781
3783 break;
3784 }
3785
3786 case WM_MOUSEMOVE:
3787 {
3788 if (GetCapture() != hWnd)
3789 break;
3790
3791 /* Move the correct splitter */
3792 if (bSplit == 1)
3793 {
3795
3797
3798 x = min(max(x, SPLIT_WIDTH/2), rect.right - rect.left - SPLIT_WIDTH/2);
3799 if (nVSplitPos != x)
3800 {
3801 nVSplitPos = x;
3802 ResizeWnd(rect.right - rect.left, rect.bottom - rect.top);
3803 }
3804 }
3805 else if (bSplit == 2)
3806 {
3807 RECT rs;
3809
3812
3813 y = min(max(y, SPLIT_WIDTH/2), rect.bottom - rect.top - SPLIT_WIDTH/2 - (rs.bottom - rs.top));
3814 if (nHSplitPos != y)
3815 {
3816 nHSplitPos = y;
3817 ResizeWnd(rect.right - rect.left, rect.bottom - rect.top);
3818 }
3819 }
3820 break;
3821 }
3822
3823 case WM_SIZE:
3824 {
3825 if (wParam != SIZE_MINIMIZED)
3826 {
3829 break;
3830 }
3831 /* Fall through the default case */
3832 }
3833
3834 default: Default:
3835 return DefWindowProcW(hWnd, uMsg, wParam, lParam);
3836 }
3837
3838 return 0;
3839}
3840
3841
3842static
3843VOID
3845{
3846 LPWSTR lpLogName = EventLog->LogName;
3847
3848 DWORD Result, dwType;
3849 DWORD dwMaxSize = 0, dwRetention = 0;
3850 BOOL Success;
3851 WIN32_FIND_DATAW FileInfo; // WIN32_FILE_ATTRIBUTE_DATA
3853 WCHAR wszBuf[MAX_PATH];
3854 WCHAR szTemp[MAX_LOADSTRING];
3856
3857 HKEY hLogKey;
3858 WCHAR *KeyPath;
3859 DWORD cbData;
3860 SIZE_T cbKeyPath;
3861
3862 if (EventLog->Permanent)
3863 {
3864
3865 cbKeyPath = (wcslen(EVENTLOG_BASE_KEY) + wcslen(lpLogName) + 1) * sizeof(WCHAR);
3866 KeyPath = HeapAlloc(GetProcessHeap(), 0, cbKeyPath);
3867 if (!KeyPath)
3868 {
3870 goto Quit;
3871 }
3872
3873 StringCbCopyW(KeyPath, cbKeyPath, EVENTLOG_BASE_KEY);
3874 StringCbCatW(KeyPath, cbKeyPath, lpLogName);
3875
3876 Result = RegOpenKeyExW(hkMachine, KeyPath, 0, KEY_QUERY_VALUE, &hLogKey);
3877 HeapFree(GetProcessHeap(), 0, KeyPath);
3878 if (Result != ERROR_SUCCESS)
3879 {
3881 goto Quit;
3882 }
3883
3884
3885 cbData = sizeof(dwMaxSize);
3886 Result = RegQueryValueExW(hLogKey,
3887 L"MaxSize",
3888 NULL,
3889 &dwType,
3890 (LPBYTE)&dwMaxSize,
3891 &cbData);
3892 if ((Result != ERROR_SUCCESS) || (dwType != REG_DWORD))
3893 {
3894 // dwMaxSize = 512 * 1024; /* 512 kBytes */
3895 /* Workstation: 512 KB; Server: 16384 KB */
3896 dwMaxSize = 16384 * 1024;
3897 }
3898 /* Convert in KB */
3899 dwMaxSize /= 1024;
3900
3901 cbData = sizeof(dwRetention);
3902 Result = RegQueryValueExW(hLogKey,
3903 L"Retention",
3904 NULL,
3905 &dwType,
3906 (LPBYTE)&dwRetention,
3907 &cbData);
3908 if ((Result != ERROR_SUCCESS) || (dwType != REG_DWORD))
3909 {
3910 /* By default, it is 604800 (secs) == 7 days. On Server, the retention is zeroed out. */
3911 dwRetention = 0;
3912 }
3913 /* Convert in days, rounded up */
3914 if (dwRetention != INFINITE)
3915 dwRetention = (dwRetention + 24*3600 - 1) / (24*3600);
3916
3917 RegCloseKey(hLogKey);
3918
3919 }
3920
3921Quit:
3922
3923 SetDlgItemTextW(hDlg, IDC_DISPLAYNAME, lpLogName); // FIXME!
3924 SetDlgItemTextW(hDlg, IDC_LOGNAME, lpLogName);
3925
3926 FileName = EventLog->FileName;
3927 if (FileName && *FileName)
3928 {
3929 /* Expand the file name. If the log file is on a remote computer, retrieve the network share form of the file name. */
3930 GetExpandedFilePathName(EventLog->ComputerName, FileName, wszBuf, ARRAYSIZE(wszBuf));
3931 FileName = wszBuf;
3932 }
3933 else
3934 {
3935 FileName = L"";
3936 }
3938
3939 if (FileName && *FileName)
3940 {
3941 /*
3942 * The general problem here (and in the shell as well) is that
3943 * GetFileAttributesEx fails for files that are opened without
3944 * shared access. To retrieve file information for those we need
3945 * to use something else: FindFirstFile, on the full file name.
3946 */
3950 if (!Success)
3951 {
3953 Success = (hFind != INVALID_HANDLE_VALUE);
3954 if (Success)
3955 FindClose(hFind);
3956 }
3957 }
3958 else
3959 {
3960 Success = FALSE;
3961 }
3962
3963 /* Starting there, FileName becomes invalid because we are reusing wszBuf */
3964
3965 if (Success)
3966 {
3967 FileSize.u.LowPart = FileInfo.nFileSizeLow;
3968 FileSize.u.HighPart = FileInfo.nFileSizeHigh;
3969 if (FormatFileSizeWithBytes(&FileSize, wszBuf, ARRAYSIZE(wszBuf)))
3970 SetDlgItemTextW(hDlg, IDC_SIZE_LABEL, wszBuf);
3971
3972 LoadStringW(hInst, IDS_NOT_AVAILABLE, szTemp, ARRAYSIZE(szTemp));
3973
3974 if (GetFileTimeString(&FileInfo.ftCreationTime, wszBuf, ARRAYSIZE(wszBuf)))
3975 SetDlgItemTextW(hDlg, IDC_CREATED_LABEL, wszBuf);
3976 else
3977 SetDlgItemTextW(hDlg, IDC_CREATED_LABEL, szTemp);
3978
3979 if (GetFileTimeString(&FileInfo.ftLastWriteTime, wszBuf, ARRAYSIZE(wszBuf)))
3980 SetDlgItemTextW(hDlg, IDC_MODIFIED_LABEL, wszBuf);
3981 else
3982 SetDlgItemTextW(hDlg, IDC_MODIFIED_LABEL, szTemp);
3983
3984 if (GetFileTimeString(&FileInfo.ftLastAccessTime, wszBuf, ARRAYSIZE(wszBuf)))
3985 SetDlgItemTextW(hDlg, IDC_ACCESSED_LABEL, wszBuf);
3986 else
3987 SetDlgItemTextW(hDlg, IDC_MODIFIED_LABEL, szTemp);
3988 }
3989 else
3990 {
3991 LoadStringW(hInst, IDS_NOT_AVAILABLE, szTemp, ARRAYSIZE(szTemp));
3992
3993 SetDlgItemTextW(hDlg, IDC_SIZE_LABEL, szTemp);
3994 SetDlgItemTextW(hDlg, IDC_CREATED_LABEL, szTemp);
3995 SetDlgItemTextW(hDlg, IDC_MODIFIED_LABEL, szTemp);
3996 SetDlgItemTextW(hDlg, IDC_ACCESSED_LABEL, szTemp);
3997 }
3998
3999 if (EventLog->Permanent)
4000 {
4003
4004 SetDlgItemInt(hDlg, IDC_EDIT_MAXLOGSIZE, dwMaxSize, FALSE);
4005 SetDlgItemInt(hDlg, IDC_EDIT_EVENTS_AGE, (dwRetention == 0) ? 7 : dwRetention, FALSE);
4006
4007 if (dwRetention == 0)
4008 {
4012 }
4013 else if (dwRetention == INFINITE)
4014 {
4018 }
4019 else
4020 {
4024 }
4025 }
4026 else
4027 {
4028 // TODO: Hide the unused controls! Or, just use another type of property sheet!
4029 }
4030}
4031
4032static
4033VOID
4035{
4036 LPWSTR lpLogName = EventLog->LogName;
4037
4038 LONG Result;
4039 DWORD dwMaxSize = 0, dwRetention = 0;
4040 HKEY hLogKey;
4041 WCHAR *KeyPath;
4042 SIZE_T cbKeyPath;
4043
4044 if (!EventLog->Permanent)
4045 return;
4046
4047 cbKeyPath = (wcslen(EVENTLOG_BASE_KEY) + wcslen(lpLogName) + 1) * sizeof(WCHAR);
4048 KeyPath = HeapAlloc(GetProcessHeap(), 0, cbKeyPath);
4049 if (!KeyPath)
4050 {
4052 return;
4053 }
4054
4055 StringCbCopyW(KeyPath, cbKeyPath, EVENTLOG_BASE_KEY);
4056 StringCbCatW(KeyPath, cbKeyPath, lpLogName);
4057
4058 Result = RegOpenKeyExW(hkMachine, KeyPath, 0, KEY_SET_VALUE, &hLogKey);
4059 HeapFree(GetProcessHeap(), 0, KeyPath);
4060 if (Result != ERROR_SUCCESS)
4061 {
4063 return;
4064 }
4065
4066 dwMaxSize = GetDlgItemInt(hDlg, IDC_EDIT_MAXLOGSIZE, NULL, FALSE) * 1024;
4067 RegSetValueExW(hLogKey,
4068 L"MaxSize",
4069 0,
4070 REG_DWORD,
4071 (LPBYTE)&dwMaxSize,
4072 sizeof(dwMaxSize));
4073
4075 dwRetention = 0;
4077 dwRetention = INFINITE;
4078 else // if (IsDlgButtonChecked(hDlg, IDC_OVERWRITE_OLDER_THAN) == BST_CHECKED)
4079 dwRetention = GetDlgItemInt(hDlg, IDC_EDIT_EVENTS_AGE, NULL, FALSE) * (24*3600);
4080
4081 RegSetValueExW(hLogKey,
4082 L"Retention",
4083 0,
4084 REG_DWORD,
4085 (LPBYTE)&dwRetention,
4086 sizeof(dwRetention));
4087
4088 RegCloseKey(hLogKey);
4089}
4090
4091/* Message handler for EventLog Properties dialog */
4094{
4095 PEVENTLOG EventLog;
4096 WCHAR szText[MAX_LOADSTRING];
4097
4098 EventLog = (PEVENTLOG)GetWindowLongPtrW(hDlg, DWLP_USER);
4099
4100 switch (uMsg)
4101 {
4102 case WM_INITDIALOG:
4103 {
4104 EventLog = (PEVENTLOG)((LPPROPSHEETPAGE)lParam)->lParam;
4105 SetWindowLongPtrW(hDlg, DWLP_USER, (LONG_PTR)EventLog);
4106
4107 InitPropertiesDlg(hDlg, EventLog);
4108
4109 PropSheet_UnChanged(GetParent(hDlg), hDlg);
4110 return (INT_PTR)TRUE;
4111 }
4112
4113 case WM_DESTROY:
4114 return (INT_PTR)TRUE;
4115
4116 case WM_NOTIFY:
4117 switch (((LPNMHDR)lParam)->code)
4118 {
4119 case PSN_APPLY:
4120 PropSheet_UnChanged(GetParent(hDlg), hDlg);
4121 SavePropertiesDlg(hDlg, EventLog);
4122 return (INT_PTR)TRUE;
4123 }
4124 break;
4125
4126 case WM_COMMAND:
4127 switch (LOWORD(wParam))
4128 {
4129 case IDOK:
4130 case IDCANCEL:
4131 EndDialog(hDlg, LOWORD(wParam));
4132 return (INT_PTR)TRUE;
4133
4134 case ID_CLEARLOG:
4135 {
4136 PEVENTLOGFILTER EventLogFilter = GetSelectedFilter(NULL);
4137 if (EventLogFilter && ClearEvents(EventLogFilter))
4138 {
4139 Refresh(EventLogFilter);
4140 InitPropertiesDlg(hDlg, EventLog);
4141 }
4142 return (INT_PTR)TRUE;
4143 }
4144
4147 if (HIWORD(wParam) == EN_CHANGE)
4148 {
4149 PropSheet_Changed(GetParent(hDlg), hDlg);
4150 }
4151 return (INT_PTR)TRUE;
4152
4154 {
4158 PropSheet_Changed(GetParent(hDlg), hDlg);
4159 return (INT_PTR)TRUE;
4160 }
4161
4163 {
4167 PropSheet_Changed(GetParent(hDlg), hDlg);
4168 return (INT_PTR)TRUE;
4169 }
4170
4171 case IDC_NO_OVERWRITE:
4172 {
4176 PropSheet_Changed(GetParent(hDlg), hDlg);
4177 return (INT_PTR)TRUE;
4178 }
4179
4181 {
4182 LoadStringW(hInst, IDS_RESTOREDEFAULTS, szText, _countof(szText));
4183
4184 if (MessageBoxW(hDlg, szText, szTitle, MB_YESNO | MB_ICONQUESTION) == IDYES)
4185 {
4187 /* Workstation: 512 KB; Server: 16384 KB */
4192 PropSheet_Changed(GetParent(hDlg), hDlg);
4193 }
4194 return (INT_PTR)TRUE;
4195 }
4196
4197 case IDHELP:
4198 MessageBoxW(hDlg,
4199 L"Help not implemented yet!",
4200 szTitle,
4202 return (INT_PTR)TRUE;
4203
4204 default:
4205 break;
4206 }
4207 break;
4208 }
4209
4210 return (INT_PTR)FALSE;
4211}
4212
4213INT_PTR
4215{
4216 INT_PTR ret = 0;
4217 PROPSHEETHEADERW psh;
4218 PROPSHEETPAGEW psp[1]; // 2
4219
4220 /*
4221 * Bail out if there is no available filter, or if the filter
4222 * contains more than one log.
4223 */
4224 if (!EventLogFilter)
4225 return 0;
4226
4227 EventLogFilter_AddRef(EventLogFilter);
4228
4229 if (EventLogFilter->NumOfEventLogs > 1 ||
4230 EventLogFilter->EventLogs[0] == NULL)
4231 {
4232 goto Quit;
4233 }
4234
4235 /* Header */
4236 psh.dwSize = sizeof(psh);
4237 psh.dwFlags = PSH_PROPSHEETPAGE /*| PSH_USEICONID */ | PSH_PROPTITLE | PSH_HASHELP /*| PSH_NOCONTEXTHELP */ /*| PSH_USECALLBACK */;
4238 psh.hInstance = hInstance;
4239 psh.hwndParent = hWndParent;
4240 // psh.pszIcon = MAKEINTRESOURCEW(IDI_APPICON); // Disabled because it only sets the small icon; the big icon is a stretched version of the small one.
4241 psh.pszCaption = EventLogFilter->EventLogs[0]->LogName;
4242 psh.nStartPage = 0;
4243 psh.ppsp = psp;
4244 psh.nPages = ARRAYSIZE(psp);
4245 // psh.pfnCallback = PropSheetCallback;
4246
4247 /* Log properties page */
4248 psp[0].dwSize = sizeof(psp[0]);
4249 psp[0].dwFlags = PSP_HASHELP;
4250 psp[0].hInstance = hInstance;
4253 psp[0].lParam = (LPARAM)EventLogFilter->EventLogs[0];
4254
4255#if 0
4256 /* TODO: Log sources page */
4257 psp[1].dwSize = sizeof(psp[1]);
4258 psp[1].dwFlags = PSP_HASHELP;
4259 psp[1].hInstance = hInstance;
4262 psp[1].lParam = (LPARAM)EventLogFilter->EventLogs[0];
4263#endif
4264
4265 /* Create the property sheet */
4266 ret = PropertySheetW(&psh);
4267
4268Quit:
4269 EventLogFilter_Release(EventLogFilter);
4270 return ret;
4271}
4272
4273/* Message handler for Event Details dialog */
4274static HWND hWndDetailsCtrl = NULL; // May go into the DWLP_USER
4276static INT cxMin, cyMin; // In window coordinates
4277static INT cxOld, cyOld; // In client coordinates
4278
4281{
4282 switch (uMsg)
4283 {
4284 case WM_INITDIALOG:
4285 {
4286 LONG_PTR dwStyle;
4287 RECT rcWnd, rect;
4288 INT iEventItem;
4289
4291 if (!hWndDetailsCtrl)
4292 {
4293 EndDialog(hDlg, 0);
4294 return (INT_PTR)TRUE;
4295 }
4296
4297 /* Create a size grip if the dialog has a sizing border */
4298 GetClientRect(hDlg, &rcWnd);
4299 dwStyle = GetWindowLongPtrW(hDlg, GWL_STYLE);
4300 if (dwStyle & WS_THICKFRAME /* == WS_SIZEBOX */)
4301 {
4302 INT sbVXSize = GetSystemMetrics(SM_CXVSCROLL);
4303 INT sbHYSize = GetSystemMetrics(SM_CYHSCROLL);
4304
4306 NULL,
4308 rcWnd.right - sbVXSize,
4309 rcWnd.bottom - sbHYSize,
4310 sbVXSize, sbHYSize,
4311 hDlg,
4312 NULL,
4313 hInst,
4314 NULL);
4315 }
4316
4317 // SetWindowLongPtrW(hDlg, DWLP_USER, (LONG_PTR)hWndDetailsCtrl);
4318
4319 /*
4320 * Compute the minimum window size (in window coordinates) by
4321 * adding the widths/heights of the "Help" and "Close" buttons,
4322 * together with the margins, and add some minimal spacing
4323 * between the buttons.
4324 */
4325 GetWindowRect(hDlg, &rcWnd);
4326 cxMin = cyMin = 0;
4327
4329 cxMin += (rect.right - rect.left) + (rect.left - rcWnd.left); // == (rect.right - rcWnd.left);
4330 cyMin += (rect.bottom - rect.top) + (rcWnd.bottom - rect.bottom); // == (rcWnd.bottom - rect.top);
4331
4333 cxMin += (rect.right - rect.left) + (rcWnd.right - rect.right); // == (rcWnd.right - rect.left);
4334 cyMin += (rect.bottom - rect.top) + (rcWnd.bottom - rect.bottom); // == (rcWnd.bottom - rect.top);
4335
4336 /*
4337 * Convert the window rect from window to client coordinates
4338 * in order to retrieve the sizes of the left and top margins,
4339 * and add some extra space.
4340 */
4341 MapWindowPoints(HWND_DESKTOP /*NULL*/, hDlg, (LPPOINT)&rcWnd, sizeof(RECT)/sizeof(POINT));
4342
4343 cxMin += -2*rcWnd.left; // Minimal spacing between the buttons == 2 * left margin
4344 cyMin += -rcWnd.top + 12; // Add some space on top
4345
4346 GetClientRect(hDlg, &rcWnd);
4347 cxOld = rcWnd.right - rcWnd.left;
4348 cyOld = rcWnd.bottom - rcWnd.top;
4349
4350 /* Show event info in dialog control */
4351 iEventItem = (lParam != 0 ? ((PEVENTDETAIL_INFO)lParam)->iEventItem : 0);
4353
4354 // SetWindowPos(hWndDetailsCtrl, NULL,
4355 // 0, 0,
4356 // (rcWnd.right - rcWnd.left),
4357 // (rcWnd.bottom - rcWnd.top),
4358 // SWP_NOZORDER | SWP_NOACTIVATE | SWP_SHOWWINDOW);
4359
4360 /*
4361 * Hide the placeholder static control and show the event details
4362 * control instead. Note that the placeholder is here so far just
4363 * to get the dimensions right in the dialog resource editor.
4364 * I plan to remove it and use a custom control with a suitable
4365 * window class for it, that would create the event details control
4366 * instead.
4367 */
4370 return (INT_PTR)TRUE;
4371 }
4372
4373 case WM_DESTROY:
4377 return (INT_PTR)TRUE;
4378
4379 case WM_COMMAND:
4380 switch (LOWORD(wParam))
4381 {
4382 case IDOK:
4383 case IDCANCEL:
4384 EndDialog(hDlg, LOWORD(wParam));
4385 return (INT_PTR)TRUE;
4386
4387 case IDHELP:
4388 MessageBoxW(hDlg,
4389 L"Help not implemented yet!",
4390 szTitle,
4392 return (INT_PTR)TRUE;
4393
4394 default:
4395 break;
4396 }
4397 break;
4398
4399 case WM_SETCURSOR:
4400 if (((HWND)wParam == hWndGrip) && (LOWORD(lParam) == HTCLIENT))
4401 {
4404 return (INT_PTR)TRUE;
4405 }
4406 break;
4407
4408 case WM_SIZING:
4409 {
4410 /* Forbid resizing the dialog smaller than its minimal size */
4411 PRECT dragRect = (PRECT)lParam;
4412
4413 if ((wParam == WMSZ_LEFT) || (wParam == WMSZ_TOPLEFT) || (wParam == WMSZ_BOTTOMLEFT))
4414 {
4415 if (dragRect->right - dragRect->left < cxMin)
4416 dragRect->left = dragRect->right - cxMin;
4417 }
4418
4420 {
4421 if (dragRect->right - dragRect->left < cxMin)
4422 dragRect->right = dragRect->left + cxMin;
4423 }
4424
4425 if ((wParam == WMSZ_TOP) || (wParam == WMSZ_TOPLEFT) || (wParam == WMSZ_TOPRIGHT))
4426 {
4427 if (dragRect->bottom - dragRect->top < cyMin)
4428 dragRect->top = dragRect->bottom - cyMin;
4429 }
4430
4432 {
4433 if (dragRect->bottom - dragRect->top < cyMin)
4434 dragRect->bottom = dragRect->top + cyMin;
4435 }
4436
4438 return (INT_PTR)TRUE;
4439 }
4440
4441 case WM_SIZE:
4442 {
4443 INT cx = LOWORD(lParam);
4444 INT cy = HIWORD(lParam);
4445
4446 HDWP hdwp;
4447 HWND hItemWnd;
4448 RECT rect;
4449
4450 hdwp = BeginDeferWindowPos(4);
4451
4452 /* Resize the event details control window */
4453
4454 hItemWnd = hWndDetailsCtrl;
4455 GetWindowRect(hItemWnd, &rect);
4456 MapWindowPoints(HWND_DESKTOP /*NULL*/, hDlg, (LPPOINT)&rect, sizeof(RECT)/sizeof(POINT));
4457
4458 if (hdwp)
4459 hdwp = DeferWindowPos(hdwp,
4460 hItemWnd,
4461 HWND_TOP,
4462 0, 0,
4463 (rect.right - rect.left) + (cx - cxOld),
4464 (rect.bottom - rect.top) + (cy - cyOld),
4466
4467 /* Move the buttons */
4468
4469 hItemWnd = GetDlgItem(hDlg, IDHELP);
4470 GetWindowRect(hItemWnd, &rect);
4471 MapWindowPoints(HWND_DESKTOP /*NULL*/, hDlg, (LPPOINT)&rect, sizeof(RECT)/sizeof(POINT));
4472
4473 if (hdwp)
4474 hdwp = DeferWindowPos(hdwp,
4475 hItemWnd,
4476 HWND_TOP,
4477 rect.left,
4478 rect.top + (cy - cyOld),
4479 0, 0,
4481
4482 hItemWnd = GetDlgItem(hDlg, IDOK);
4483 GetWindowRect(hItemWnd, &rect);
4484 MapWindowPoints(HWND_DESKTOP /*NULL*/, hDlg, (LPPOINT)&rect, sizeof(RECT)/sizeof(POINT));
4485
4486 if (hdwp)
4487 hdwp = DeferWindowPos(hdwp,
4488 hItemWnd,
4489 HWND_TOP,
4490 rect.left + (cx - cxOld),
4491 rect.top + (cy - cyOld),
4492 0, 0,
4494
4495 /* Move the size grip */
4496 if (hWndGrip && hdwp)
4497 {
4499 MapWindowPoints(HWND_DESKTOP /*NULL*/, hDlg, (LPPOINT)&rect, sizeof(RECT)/sizeof(POINT));
4500
4501 hdwp = DeferWindowPos(hdwp,
4502 hWndGrip,
4503 HWND_TOP,
4504 rect.left + (cx - cxOld),
4505 rect.top + (cy - cyOld),
4506 0, 0,
4508 }
4509
4510 if (hdwp)
4511 EndDeferWindowPos(hdwp);
4512
4513 /* Hide the size grip if we are in maximized mode */
4514 if (hWndGrip)
4516
4517 cxOld = cx;
4518 cyOld = cy;
4519
4521 return (INT_PTR)TRUE;
4522 }
4523 }
4524
4525 return (INT_PTR)FALSE;
4526}
static int argc
Definition: ServiceArgs.c:12
char * va_list
Definition: acmsvcex.h:78
int nItems
Definition: appswitch.c:56
#define InterlockedIncrement
Definition: armddk.h:53
#define InterlockedDecrement
Definition: armddk.h:52
WCHAR SourceName[256]
Definition: arping.c:28
#define msg(x)
Definition: auth_time.c:54
#define IDC_STATIC
Definition: resource.h:4
void SaveSettings(void)
Definition: settings.c:115
void LoadSettings(void)
Definition: settings.c:53
HWND hWnd
Definition: settings.c:17
#define IDS_USAGE
Definition: resource.h:3
#define IDS_APP_TITLE
Definition: resource.h:10
#define IDM_ABOUT
Definition: resource.h:29
#define IDM_EXIT
Definition: resource.h:27
#define IDD_GENERAL_PAGE
Definition: resource.h:6
#define IDI_EVENTVWR
Definition: resource.h:13
#define IDC_UPDOWN_EVENTS_AGE
Definition: resource.h:67
#define IDC_NO_OVERWRITE
Definition: resource.h:68
#define IDS_NOT_AVAILABLE
Definition: resource.h:136
#define IDM_EVENT_DETAILS_VIEW
Definition: resource.h:86
#define IDD_LOGPROPERTIES_GENERAL
Definition: resource.h:34
#define IDM_OPEN_EVENTLOG
Definition: resource.h:75
#define IDC_OVERWRITE_AS_NEEDED
Definition: resource.h:64
#define IDS_RESTOREDEFAULTS
Definition: resource.h:107
#define IDS_STATUS_MSG
Definition: resource.h:98
#define IDM_EVENTVWR
Definition: resource.h:74
#define ID_CLEARLOG
Definition: resource.h:71
#define IDC_DISPLAYNAME
Definition: resource.h:55
#define IDI_CLOSED_CATEGORY
Definition: resource.h:15
#define IDS_COLUMNTIME
Definition: resource.h:126
#define IDS_EVENTLOG_INFORMATION_TYPE
Definition: resource.h:116
#define IDS_COLUMNSOURCE
Definition: resource.h:127
#define IDS_EVENTLOG_SUCCESS
Definition: resource.h:119
#define IDI_OPENED_CATEGORY
Definition: resource.h:16
#define IDS_NO_ITEMS
Definition: resource.h:100
#define IDI_EVENTLOG
Definition: resource.h:14
#define IDS_COLUMNTYPE
Definition: resource.h:124
#define IDS_COLUMNCOMPUTER
Definition: resource.h:131
#define IDC_UPDOWN_MAXLOGSIZE
Definition: resource.h:63
#define IDC_LOGFILE
Definition: resource.h:57
#define IDS_COLUMNEVENT
Definition: resource.h:129
#define IDM_CLOSE_EVENTLOG
Definition: resource.h:77
#define IDM_EVENTWR_CTX
Definition: resource.h:91
#define IDC_OVERWRITE_OLDER_THAN
Definition: resource.h:65
#define IDS_EVENTSTRINGIDNOTFOUND
Definition: resource.h:106
#define IDC_CREATED_LABEL
Definition: resource.h:59
#define IDM_RENAME_EVENTLOG
Definition: resource.h:79
#define IDM_LIST_OLDEST
Definition: resource.h:83
#define IDM_EVENTLOG_SETTINGS
Definition: resource.h:80
#define IDI_AUDITFAILUREICON
Definition: resource.h:21
#define IDI_ERRORICON
Definition: resource.h:19
#define IDS_APP_TITLE_EX
Definition: resource.h:97
#define IDM_LIST_GRID_LINES
Definition: resource.h:87
#define IDI_AUDITSUCCESSICON
Definition: resource.h:20
#define IDM_EVENT_DETAILS
Definition: resource.h:84
#define IDS_CLEAREVENTS_MSG
Definition: resource.h:105
#define IDC_EDIT_MAXLOGSIZE
Definition: resource.h:62
#define IDI_INFORMATIONICON
Definition: resource.h:17
#define IDS_EVENTLOG_AUDIT_FAILURE
Definition: resource.h:118
#define IDS_EVENTLOG_ERROR_TYPE
Definition: resource.h:114
#define IDS_EVENTLOG_SYSTEM
Definition: resource.h:101
#define IDS_SAVE_FILTER
Definition: resource.h:104
#define IDM_SAVE_SETTINGS
Definition: resource.h:88
#define IDC_SIZE_LABEL
Definition: resource.h:58
#define IDS_NONE
Definition: resource.h:135
#define IDM_HELP
Definition: resource.h:89
#define IDM_REFRESH
Definition: resource.h:85
#define IDS_BYTES_FORMAT
Definition: resource.h:122
#define IDS_EVENTLOG_APP
Definition: resource.h:102
#define IDS_COLUMNUSER
Definition: resource.h:130
#define IDM_SAVE_EVENTLOG
Definition: resource.h:76
#define IDC_MODIFIED_LABEL
Definition: resource.h:60
#define IDA_EVENTVWR
Definition: resource.h:28
#define IDC_EDIT_EVENTS_AGE
Definition: resource.h:66
#define IDD_EVENTDETAILS_DLG
Definition: resource.h:32
#define IDC_RESTOREDEFAULTS
Definition: resource.h:69
#define IDS_EVENTLOG_WARNING_TYPE
Definition: resource.h:115
#define IDS_LOADING_WAIT
Definition: resource.h:99
#define IDS_COPYRIGHT
Definition: resource.h:95
#define IDC_ACCESSED_LABEL
Definition: resource.h:61
#define IDS_EVENTLOG_UNKNOWN_TYPE
Definition: resource.h:120
#define IDI_WARNINGICON
Definition: resource.h:18
#define IDS_EVENTLOG_AUDIT_SUCCESS
Definition: resource.h:117
#define IDM_CLEAR_EVENTS
Definition: resource.h:78
#define IDM_LIST_NEWEST
Definition: resource.h:82
#define IDS_COLUMNCATEGORY
Definition: resource.h:128
#define IDS_COLUMNDATE
Definition: resource.h:125
#define IDS_EVENTLOG_USER
Definition: resource.h:103
#define IDC_LOGNAME
Definition: resource.h:56
BOOL Error
Definition: chkdsk.c:66
#define RegCloseKey(hKey)
Definition: registry.h:49
w ll
Definition: byte_order.h:167
HINSTANCE hInstance
Definition: charmap.c:19
WPARAM wParam
Definition: combotst.c:138
LPARAM lParam
Definition: combotst.c:139
BOOL WINAPI InitCommonControlsEx(const INITCOMMONCONTROLSEX *lpInitCtrls)
Definition: commctrl.c:900
#define OFN_EXPLORER
Definition: commdlg.h:104
#define OFN_SHAREAWARE
Definition: commdlg.h:119
#define OFN_HIDEREADONLY
Definition: commdlg.h:107
BOOL WINAPI GetComputerNameW(LPWSTR lpBuffer, LPDWORD lpnSize)
Definition: compname.c:446
wcsncpy
HMODULE hLibrary
Definition: odbccp32.c:12
static TAGREF LPCWSTR LPDWORD LPVOID lpBuffer
Definition: db.cpp:175
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10
#define ERROR_OUTOFMEMORY
Definition: deptool.c:13
#define ERROR_SUCCESS
Definition: deptool.c:10
WORD ATOM
Definition: dimm.idl:113
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
#define APIENTRY
Definition: api.h:79
LONG WINAPI RegCreateKeyExW(_In_ HKEY hKey, _In_ LPCWSTR lpSubKey, _In_ DWORD Reserved, _In_opt_ LPWSTR lpClass, _In_ DWORD dwOptions, _In_ REGSAM samDesired, _In_opt_ LPSECURITY_ATTRIBUTES lpSecurityAttributes, _Out_ PHKEY phkResult, _Out_opt_ LPDWORD lpdwDisposition)
Definition: reg.c:1096
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3333
LONG WINAPI RegEnumKeyExW(_In_ HKEY hKey, _In_ DWORD dwIndex, _Out_ LPWSTR lpName, _Inout_ LPDWORD lpcbName, _Reserved_ LPDWORD lpReserved, _Out_opt_ LPWSTR lpClass, _Inout_opt_ LPDWORD lpcbClass, _Out_opt_ PFILETIME lpftLastWriteTime)
Definition: reg.c:2504
LONG WINAPI RegSetValueExW(_In_ HKEY hKey, _In_ LPCWSTR lpValueName, _In_ DWORD Reserved, _In_ DWORD dwType, _In_ CONST BYTE *lpData, _In_ DWORD cbData)
Definition: reg.c:4882
LONG WINAPI RegQueryInfoKeyW(HKEY hKey, LPWSTR lpClass, LPDWORD lpcClass, LPDWORD lpReserved, LPDWORD lpcSubKeys, LPDWORD lpcMaxSubKeyLen, LPDWORD lpcMaxClassLen, LPDWORD lpcValues, LPDWORD lpcMaxValueNameLen, LPDWORD lpcMaxValueLen, LPDWORD lpcbSecurityDescriptor, PFILETIME lpftLastWriteTime)
Definition: reg.c:3662
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4103
BOOL WINAPI LookupAccountSidW(LPCWSTR pSystemName, PSID pSid, LPWSTR pAccountName, LPDWORD pdwAccountName, LPWSTR pDomainName, LPDWORD pdwDomainName, PSID_NAME_USE peUse)
Definition: misc.c:537
HANDLE WINAPI OpenEventLogW(IN LPCWSTR lpUNCServerName, IN LPCWSTR lpSourceName)
Definition: eventlog.c:985
BOOL WINAPI ClearEventLogW(IN HANDLE hEventLog, IN LPCWSTR lpBackupFileName)
Definition: eventlog.c:367
BOOL WINAPI CloseEventLog(IN HANDLE hEventLog)
Definition: eventlog.c:427
BOOL WINAPI GetNumberOfEventLogRecords(IN HANDLE hEventLog, OUT PDWORD NumberOfRecords)
Definition: eventlog.c:570
HANDLE WINAPI OpenBackupEventLogW(IN LPCWSTR lpUNCServerName, IN LPCWSTR lpFileName)
Definition: eventlog.c:830
BOOL WINAPI BackupEventLogW(IN HANDLE hEventLog, IN LPCWSTR lpBackupFileName)
Definition: eventlog.c:245
BOOL WINAPI ReadEventLogW(IN HANDLE hEventLog, IN DWORD dwReadFlags, IN DWORD dwRecordOffset, OUT LPVOID lpBuffer, IN DWORD nNumberOfBytesToRead, OUT DWORD *pnBytesRead, OUT DWORD *pnMinNumberOfBytesNeeded)
Definition: eventlog.c:1154
BOOL WINAPI ConvertSidToStringSidW(PSID Sid, LPWSTR *StringSid)
Definition: security.c:3583
BOOL WINAPI IsValidSid(PSID pSid)
Definition: security.c:819
BOOL WINAPI EqualSid(PSID pSid1, PSID pSid2)
Definition: security.c:829
HIMAGELIST WINAPI ImageList_Create(INT cx, INT cy, UINT flags, INT cInitial, INT cGrow)
Definition: imagelist.c:814
INT_PTR WINAPI PropertySheetW(LPCPROPSHEETHEADERW lppsh)
Definition: propsheet.c:2916
BOOL WINAPI GetOpenFileNameW(OPENFILENAMEW *ofn)
Definition: filedlg.c:4736
BOOL WINAPI GetSaveFileNameW(LPOPENFILENAMEW ofn)
Definition: filedlg.c:4801
#define CloseHandle
Definition: compat.h:739
#define wcschr
Definition: compat.h:17
#define GetProcessHeap()
Definition: compat.h:736
#define SetLastError(x)
Definition: compat.h:752
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
#define HeapAlloc
Definition: compat.h:733
#define HeapReAlloc
Definition: compat.h:734
#define FreeLibrary(x)
Definition: compat.h:748
#define MAX_PATH
Definition: compat.h:34
#define HeapFree(x, y, z)
Definition: compat.h:735
#define CALLBACK
Definition: compat.h:35
#define LoadLibraryW(x)
Definition: compat.h:747
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
static DWORD DWORD * dwLength
Definition: fusion.c:86
static DWORD cchBuffer
Definition: fusion.c:85
DWORD WINAPI ExpandEnvironmentStringsW(IN LPCWSTR lpSrc, IN LPWSTR lpDst, IN DWORD nSize)
Definition: environ.c:519
BOOL WINAPI GetFileAttributesExW(LPCWSTR lpFileName, GET_FILEEX_INFO_LEVELS fInfoLevelId, LPVOID lpFileInformation)
Definition: fileinfo.c:552
HANDLE WINAPI FindFirstFileW(IN LPCWSTR lpFileName, OUT LPWIN32_FIND_DATAW lpFindFileData)
Definition: find.c:320
BOOL WINAPI FindClose(HANDLE hFindFile)
Definition: find.c:502
HINSTANCE WINAPI DECLSPEC_HOTPATCH LoadLibraryExW(LPCWSTR lpLibFileName, HANDLE hFile, DWORD dwFlags)
Definition: loader.c:288
LPWSTR WINAPI GetCommandLineW(VOID)
Definition: proc.c:2019
DWORD WINAPI ResumeThread(IN HANDLE hThread)
Definition: thread.c:567
HANDLE WINAPI DECLSPEC_HOTPATCH CreateThread(IN LPSECURITY_ATTRIBUTES lpThreadAttributes, IN DWORD dwStackSize, IN LPTHREAD_START_ROUTINE lpStartAddress, IN LPVOID lpParameter, IN DWORD dwCreationFlags, OUT LPDWORD lpThreadId)
Definition: thread.c:137
BOOL WINAPI FileTimeToSystemTime(IN CONST FILETIME *lpFileTime, OUT LPSYSTEMTIME lpSystemTime)
Definition: time.c:188
BOOL WINAPI SystemTimeToFileTime(IN CONST SYSTEMTIME *lpSystemTime, OUT LPFILETIME lpFileTime)
Definition: time.c:158
BOOL WINAPI FileTimeToLocalFileTime(IN CONST FILETIME *lpFileTime, OUT LPFILETIME lpLocalFileTime)
Definition: time.c:221
DWORD WINAPI FormatMessageW(DWORD dwFlags, LPCVOID lpSource, DWORD dwMessageId, DWORD dwLanguageId, LPWSTR lpBuffer, DWORD nSize, __ms_va_list *args)
Definition: format_msg.c:583
INT WINAPI GetLocaleInfoW(LCID lcid, LCTYPE lctype, LPWSTR buffer, INT len)
Definition: locale.c:1666
LPWSTR WINAPI StrFormatByteSizeW(LONGLONG llBytes, LPWSTR lpszDest, UINT cchMax)
Definition: string.c:2394
#define swprintf
Definition: precomp.h:40
static const WCHAR Cleanup[]
Definition: register.c:80
#define pt(x, y)
Definition: drawing.c:79
#define INFINITE
Definition: serial.h:102
#define InterlockedExchangePointer(Target, Value)
Definition: dshow.h:45
#define RemoveEntryList(Entry)
Definition: env_spec_w32.h:986
#define InsertTailList(ListHead, Entry)
#define IsListEmpty(ListHead)
Definition: env_spec_w32.h:954
#define RemoveHeadList(ListHead)
Definition: env_spec_w32.h:964
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
@ Success
Definition: eventcreate.c:712
BOOL GetEventCategory(IN LPCWSTR KeyName, IN LPCWSTR SourceName, IN PEVENTLOGRECORD pevlr, OUT PWCHAR CategoryName)
Definition: eventvwr.c:1589
WCHAR szEmptyList[MAX_LOADSTRING]
Definition: eventvwr.c:53
#define EVENT_DLL_SEPARATOR
Definition: eventvwr.c:38
DWORD GetExpandedFilePathName(IN LPCWSTR ComputerName OPTIONAL, IN LPCWSTR lpFileName, OUT LPWSTR lpFullFileName OPTIONAL, IN DWORD nSize)
Definition: eventvwr.c:1455
HANDLE hStopEnumEvent
Definition: eventvwr.c:90
HANDLE hEnumEventsThread
Definition: eventvwr.c:89
DWORD ApplyParameterStringsToMessage(IN LPCWSTR lpMessageDllList, IN BOOL bMessagePreFormatted, IN CONST LPCWSTR pMessage, OUT LPWSTR *pFinalMessage)
Definition: eventvwr.c:903
static const LPCWSTR SystemLogs[]
Definition: eventvwr.c:28
static INT cxMin
Definition: eventvwr.c:4276
VOID EventLogFilter_Free(IN PEVENTLOGFILTER EventLogFilter)
Definition: eventvwr.c:1402
VOID ShowWin32Error(IN DWORD dwError)
Definition: eventvwr.c:140
static const LPCWSTR EVNTVWR_PARAM_KEY
Definition: eventvwr.c:25
void TrimNulls(LPWSTR s)
Definition: eventvwr.c:1441
VOID EventLog_Free(IN PEVENTLOG EventLog)
Definition: eventvwr.c:1322
PEVENTLOGFILTER ActiveFilter
Definition: eventvwr.c:87
PEVENTLOGFILTER GetSelectedFilter(OUT HTREEITEM *phti OPTIONAL)
Definition: eventvwr.c:2436
static DWORD WINAPI StartStopEnumEventsThread(IN LPVOID lpParameter)
Definition: eventvwr.c:2315
#define SPLIT_WIDTH
Definition: eventvwr.c:45
LONG EventLogFilter_AddRef(IN PEVENTLOGFILTER EventLogFilter)
Definition: eventvwr.c:1416
PEVENTLOG AllocEventLog(IN PCWSTR ComputerName OPTIONAL, IN PCWSTR LogName, IN BOOL Permanent)
Definition: eventvwr.c:1283
HTREEITEM htiUserLogs
Definition: eventvwr.c:72
VOID BuildLogListAndFilterList(IN LPCWSTR lpComputerName)
Definition: eventvwr.c:2793
HTREEITEM htiAppLogs
Definition: eventvwr.c:72
BOOL GetEventMessage(IN LPCWSTR KeyName, IN LPCWSTR SourceName, IN PEVENTLOGRECORD pevlr, OUT PWCHAR EventText)
Definition: eventvwr.c:1639
BOOL GetDisplayNameFileAndID(IN LPCWSTR lpLogName, OUT PWCHAR lpModuleName, OUT PDWORD pdwMessageID)
Definition: eventvwr.c:2713
VOID ResizeWnd(INT cx, INT cy)
Definition: eventvwr.c:3231
HANDLE hStartEnumEvent
Definition: eventvwr.c:98
static INT cyMin
Definition: eventvwr.c:4276
LPWSTR lpComputerName
Definition: eventvwr.c:74
ATOM MyRegisterClass(HINSTANCE)
Definition: eventvwr.c:2686
LONG EventLogFilter_Release(IN PEVENTLOGFILTER EventLogFilter)
Definition: eventvwr.c:1422
VOID EventTimeToSystemTime(IN DWORD EventTime, OUT PSYSTEMTIME pSystemTime)
Definition: eventvwr.c:713
#define MAX_LOADSTRING
Definition: eventvwr.c:43
BOOL ProcessCmdLine(IN LPWSTR lpCmdLine)
Definition: eventvwr.c:184
VOID CloseUserEventLog(IN PEVENTLOGFILTER EventLogFilter, IN HTREEITEM hti)
Definition: eventvwr.c:2581
HWND hwndEventDetails
Definition: eventvwr.c:67
BYTE bSplit
Definition: eventvwr.c:58
BOOL FilterByString(IN PCWSTR FilterString, IN PWSTR String)
Definition: eventvwr.c:1905
LPWSTR GetMessageStringFromDll(IN LPCWSTR lpMessageDll, IN DWORD dwFlags, IN DWORD dwMessageId, IN DWORD nSize, IN va_list *Arguments OPTIONAL)
Definition: eventvwr.c:738
#define LVM_PROGRESS
Definition: eventvwr.c:21
#define EVENT_CATEGORY_MESSAGE_FILE
Definition: eventvwr.c:39
VOID OpenUserEventLogFile(IN LPCWSTR lpszFileName)
Definition: eventvwr.c:2462
SIZE_T cbUserLogsSize
Definition: eventvwr.c:76
HINSTANCE hInst
Definition: eventvwr.c:48
WCHAR szTitleTemplate[MAX_LOADSTRING]
Definition: eventvwr.c:50
WCHAR szStatusBarTemplate[MAX_LOADSTRING]
Definition: eventvwr.c:51
BOOL GetEventMessageFileDLL(IN LPCWSTR lpLogName, IN LPCWSTR SourceName, IN LPCWSTR EntryName, OUT PWCHAR lpModuleName)
Definition: eventvwr.c:1528
HMENU hMainMenu
Definition: eventvwr.c:70
WCHAR szLoadingWait[MAX_LOADSTRING]
Definition: eventvwr.c:52
INT_PTR CALLBACK EventLogPropProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: eventvwr.c:4093
BOOL FilterByType(IN PEVENTLOGFILTER EventLogFilter, IN PEVENTLOGRECORD pevlr)
Definition: eventvwr.c:1889
HWND hwndStatus
Definition: eventvwr.c:68
OPENFILENAMEW sfn
Definition: eventvwr.c:101
static const LPCWSTR EVENTVWR_WNDCLASS
Definition: eventvwr.c:23
LIST_ENTRY EventLogFilterList
Definition: eventvwr.c:86
BOOL GetEventUserName(IN PEVENTLOGRECORD pelr, IN OUT PSID *pLastSid, OUT PWCHAR pszUser)
Definition: eventvwr.c:1800
UINT FormatInteger(LONGLONG Num, LPWSTR pwszResult, UINT cchResultMax)
Definition: eventvwr.c:1101
HKEY hkMachine
Definition: eventvwr.c:78
static const LPCWSTR EVENTLOG_BASE_KEY
Definition: eventvwr.c:24
struct _SETTINGS * PSETTINGS
static INT cxOld
Definition: eventvwr.c:4277
BOOL GetFileTimeString(LPFILETIME lpFileTime, LPWSTR pwszResult, UINT cchResult)
Definition: eventvwr.c:1218
#define EVENT_MESSAGE_EVENTTEXT_BUFFER
Definition: eventvwr.c:36
LPWSTR lpszzUserLogsToLoad
Definition: eventvwr.c:75
DWORD g_TotalRecords
Definition: eventvwr.c:81
static HWND hWndGrip
Definition: eventvwr.c:4275
VOID FreeLogList(VOID)
Definition: eventvwr.c:3003
PWSTR AllocAndCopyMultiStr(IN PCWSTR MultiStr OPTIONAL)
Definition: eventvwr.c:1338
VOID GetEventType(IN WORD dwEventType, OUT PWCHAR eventTypeText)
Definition: eventvwr.c:1770
HWND hwndTreeView
Definition: eventvwr.c:65
BOOL ClearEvents(IN PEVENTLOGFILTER EventLogFilter)
Definition: eventvwr.c:2616
INT nVSplitPos
Definition: eventvwr.c:56
LIST_ENTRY EventLogList
Definition: eventvwr.c:85
static VOID FreeRecords(VOID)
Definition: eventvwr.c:1871
UINT FormatByteSize(LONGLONG cbSize, LPWSTR pwszResult, UINT cchResultMax)
Definition: eventvwr.c:1161
#define EVENT_PARAMETER_MESSAGE_FILE
Definition: eventvwr.c:41
int APIENTRY wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int nCmdShow)
Definition: eventvwr.c:559
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM)
Definition: eventvwr.c:3301
LPWSTR GetMessageStringFromDllList(IN LPCWSTR lpMessageDllList, IN DWORD dwFlags, IN DWORD dwMessageId, IN DWORD nSize, IN va_list *Arguments OPTIONAL)
Definition: eventvwr.c:842
SETTINGS Settings
Definition: eventvwr.c:116
PEVENTLOGRECORD * g_RecordPtrs
Definition: eventvwr.c:82
HANDLE hStartStopEnumEvent
Definition: eventvwr.c:97
INT nHSplitPos
Definition: eventvwr.c:57
WCHAR szSaveFilter[MAX_LOADSTRING]
Definition: eventvwr.c:54
VOID FreeLogFilterList(VOID)
Definition: eventvwr.c:3019
VOID EnumEvents(IN PEVENTLOGFILTER EventLogFilter)
Definition: eventvwr.c:2426
VOID OpenUserEventLog(VOID)
Definition: eventvwr.c:2526
static VOID SavePropertiesDlg(HWND hDlg, PEVENTLOG EventLog)
Definition: eventvwr.c:4034
HWND hwndStatusProgress
Definition: eventvwr.c:69
INT_PTR EventLogProperties(HINSTANCE, HWND, PEVENTLOGFILTER)
Definition: eventvwr.c:4214
PEVENTLOGFILTER EnumFilter
Definition: eventvwr.c:96
HTREEITEM TreeViewAddItem(IN HWND hTreeView, IN HTREEITEM hParent, IN LPWSTR lpText, IN INT Image, IN INT SelectedImage, IN LPARAM lParam)
Definition: eventvwr.c:1253
static HWND hWndDetailsCtrl
Definition: eventvwr.c:4274
#define EVENT_MESSAGE_FILE_BUFFER
Definition: eventvwr.c:37
VOID SaveEventLog(IN PEVENTLOGFILTER EventLogFilter)
Definition: eventvwr.c:2543
INT_PTR CALLBACK EventDetails(HWND, UINT, WPARAM, LPARAM)
Definition: eventvwr.c:4280
PEVENTLOGFILTER AllocEventLogFilter(IN BOOL Information, IN BOOL Warning, IN BOOL Error, IN BOOL AuditSuccess, IN BOOL AuditFailure, IN PCWSTR Sources OPTIONAL, IN PCWSTR Users OPTIONAL, IN PCWSTR ComputerNames OPTIONAL, IN ULONG NumOfEventLogs, IN PEVENTLOG *EventLogs)
Definition: eventvwr.c:1359
HWND hwndMainWindow
Definition: eventvwr.c:64
struct _SETTINGS SETTINGS
static DWORD WINAPI EnumEventsThread(IN LPVOID lpParameter)
Definition: eventvwr.c:1962
#define EVENT_MESSAGE_FILE
Definition: eventvwr.c:40
WCHAR szTitle[MAX_LOADSTRING]
Definition: eventvwr.c:49
LPWSTR FormatFileSizeWithBytes(const PULARGE_INTEGER lpQwSize, LPWSTR pwszResult, UINT cchResultMax)
Definition: eventvwr.c:1184
VOID DisplayUsage(VOID)
Definition: eventvwr.c:164
HWND hwndListView
Definition: eventvwr.c:66
BOOL InitInstance(HINSTANCE)
Definition: eventvwr.c:3037
HTREEITEM htiSystemLogs
Definition: eventvwr.c:72
static INT cyOld
Definition: eventvwr.c:4277
static VOID InitPropertiesDlg(HWND hDlg, PEVENTLOG EventLog)
Definition: eventvwr.c:3844
#define ProgressBar_SetRange(hwndCtl, range)
Definition: eventvwr.h:60
#define ROUND_DOWN(n, align)
Definition: eventvwr.h:33
#define ProgressBar_SetPos(hwndCtl, pos)
Definition: eventvwr.h:58
struct _EVENTLOG * PEVENTLOG
#define StatusBar_SetText(hwndCtl, index, data)
Definition: eventvwr.h:69
#define StatusBar_GetItemRect(hwndCtl, index, lprc)
Definition: eventvwr.h:67
#define ProgressBar_SetStep(hwndCtl, inc)
Definition: eventvwr.h:62
#define EnableDlgItem(hDlg, nID, bEnable)
Definition: eventvwr.h:55
struct _EVENTLOGFILTER * PEVENTLOGFILTER
VOID EnableEventDetailsButtons(HWND hWnd, BOOL bEnable)
Definition: evtdetctl.c:964
HWND CreateEventDetailsCtrl(HINSTANCE hInstance, HWND hParentWnd, LPARAM lParam)
Definition: evtdetctl.c:954
struct _EVENTDETAIL_INFO * PEVENTDETAIL_INFO
#define EVT_DISPLAY
Definition: evtdetctl.h:21
#define EVT_SETFILTER
Definition: evtdetctl.h:20
struct _FileName FileName
Definition: fatprocs.h:897
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
unsigned short WORD
Definition: ntddk_ex.h:93
_Must_inspect_result_ _Out_ PLARGE_INTEGER FileSize
Definition: fsrtlfuncs.h:108
Status
Definition: gdiplustypes.h:25
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
GLdouble s
Definition: gl.h:2039
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
GLint GLint GLsizei width
Definition: gl.h:1546
GLuint buffer
Definition: glext.h:5915
const GLubyte * c
Definition: glext.h:8905
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
HLOCAL NTAPI LocalFree(HLOCAL hMem)
Definition: heapmem.c:1594
#define iswspace(_c)
Definition: ctype.h:669
#define iswdigit(_c)
Definition: ctype.h:667
_Check_return_ _CRTIMP int __cdecl swscanf(_In_z_ const wchar_t *_Src, _In_z_ _Scanf_format_string_ const wchar_t *_Format,...)
_Check_return_ _CRTIMP int __cdecl _wtoi(_In_z_ const wchar_t *_Str)
_Check_return_ _CRTIMP long __cdecl _wtol(_In_z_ const wchar_t *_Str)
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
_CONST_RETURN wchar_t *__cdecl wcsstr(_In_z_ const wchar_t *_Str, _In_z_ const wchar_t *_SubStr)
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:90
#define InterlockedCompareExchangePointer
Definition: interlocked.h:129
char hdr[14]
Definition: iptest.cpp:33
HANDLE hProcessHeap
Definition: kbswitch.c:37
#define c
Definition: ke_i.h:80
#define REG_SZ
Definition: layer.c:22
INT WINAPI GetNumberFormatW(LCID lcid, DWORD dwFlags, LPCWSTR lpszValue, const NUMBERFMTW *lpFormat, LPWSTR lpNumberStr, int cchOut)
Definition: lcformat.c:1208
INT WINAPI GetTimeFormatW(LCID lcid, DWORD dwFlags, const SYSTEMTIME *lpTime, LPCWSTR lpFormat, LPWSTR lpTimeStr, INT cchOut)
Definition: lcformat.c:1089
INT WINAPI GetDateFormatW(LCID lcid, DWORD dwFlags, const SYSTEMTIME *lpTime, LPCWSTR lpFormat, LPWSTR lpDateStr, INT cchOut)
Definition: lcformat.c:989
if(dx< 0)
Definition: linetemp.h:194
enum _SID_NAME_USE SID_NAME_USE
void Refresh(void)
Definition: magnifier.c:317
__u16 time
Definition: mkdosfs.c:8
#define ASSERT(a)
Definition: mode.c:44
LPCWSTR LPCWSTR szModuleName
Definition: env.c:37
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:56
static PVOID ptr
Definition: dispmode.c:27
static HICON
Definition: imagelist.c:80
static DWORD DWORD void LPSTR DWORD cch
Definition: str.c:202
static const CLSID *static CLSID *static const GUID VARIANT VARIANT *static IServiceProvider DWORD *static HMENU
Definition: ordinal.c:63
static ATOM item
Definition: dde.c:856
#define min(a, b)
Definition: monoChain.cc:55
#define argv
Definition: mplay32.c:18
struct _SID * PSID
Definition: eventlog.c:35
INT_PTR CALLBACK GeneralPageWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
Definition: generalpage.c:25
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
unsigned int UINT
Definition: ndis.h:50
HANDLE hThread
Definition: wizard.c:28
#define KEY_READ
Definition: nt_native.h:1023
#define REG_OPTION_NON_VOLATILE
Definition: nt_native.h:1057
#define KEY_QUERY_VALUE
Definition: nt_native.h:1016
#define DWORD
Definition: nt_native.h:44
#define REG_EXPAND_SZ
Definition: nt_native.h:1494
#define KEY_SET_VALUE
Definition: nt_native.h:1017
#define LOCALE_USER_DEFAULT
#define UNICODE_NULL
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:325
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:102
#define L(x)
Definition: ntvdm.h:50
#define LOWORD(l)
Definition: pedump.c:82
#define WS_CHILD
Definition: pedump.c:617
#define CONST
Definition: pedump.c:81
#define WS_OVERLAPPEDWINDOW
Definition: pedump.c:637
BYTE * PBYTE
Definition: pedump.c:66
DWORD * PDWORD
Definition: pedump.c:68
#define WS_VISIBLE
Definition: pedump.c:620
long LONG
Definition: pedump.c:60
#define WS_CLIPSIBLINGS
Definition: pedump.c:618
#define WS_CLIPCHILDREN
Definition: pedump.c:619
#define WS_THICKFRAME
Definition: pedump.c:630
static const WCHAR szName[]
Definition: powrprof.c:45
#define PSP_HASHELP
Definition: prsht.h:28
#define PSH_PROPTITLE
Definition: prsht.h:40
#define PropSheet_Changed(d, w)
Definition: prsht.h:344
#define PSH_HASHELP
Definition: prsht.h:49
#define PropSheet_UnChanged(d, w)
Definition: prsht.h:358
#define PSN_APPLY
Definition: prsht.h:117
#define LPPROPSHEETPAGE
Definition: prsht.h:390
#define PSH_PROPSHEETPAGE
Definition: prsht.h:43
#define LVSIL_SMALL
Definition: commctrl.h:2304
_Out_opt_ int _Out_opt_ int * cy
Definition: commctrl.h:586
#define TVN_SELCHANGED
Definition: commctrl.h:3740
#define ListView_InsertItem(hwnd, pitem)
Definition: commctrl.h:2413
#define TVS_LINESATROOT
Definition: commctrl.h:3254
#define TVI_LAST
Definition: commctrl.h:3375
#define ListView_SetExtendedListViewStyleEx(hwndLV, dwMask, dw)
Definition: commctrl.h:2731
#define PROGRESS_CLASSW
Definition: commctrl.h:2181
#define TVIF_TEXT
Definition: commctrl.h:3271
#define TreeView_SelectItem(hwnd, hitem)
Definition: commctrl.h:3486
#define LVS_EX_LABELTIP
Definition: commctrl.h:2748
#define ListView_InsertColumn(hwnd, iCol, pcol)
Definition: commctrl.h:2641
#define NM_DBLCLK
Definition: commctrl.h:131
#define TVN_BEGINLABELEDIT
Definition: commctrl.h:3748
#define LVIF_STATE
Definition: commctrl.h:2317
#define LVS_EX_GRIDLINES
Definition: commctrl.h:2734
#define ListView_SetImageList(hwnd, himl, iImageList)
Definition: commctrl.h:2309
#define WC_LISTVIEWW
Definition: commctrl.h:2262
#define LVNI_SELECTED
Definition: commctrl.h:2429
#define TVIF_IMAGE
Definition: commctrl.h:3272
#define LVS_EX_HEADERDRAGDROP
Definition: commctrl.h:2738
#define CCS_BOTTOM
Definition: commctrl.h:2249
#define LVS_SHOWSELALWAYS
Definition: commctrl.h:2272
#define LVS_REPORT
Definition: commctrl.h:2267
#define TVSIL_NORMAL
Definition: commctrl.h:3448
#define LPNMTREEVIEW
Definition: commctrl.h:3648
#define LVCF_WIDTH
Definition: commctrl.h:2592
#define LVNI_FOCUSED
Definition: commctrl.h:2428
#define TreeView_EnsureVisible(hwnd, hitem)
Definition: commctrl.h:3550
_Out_opt_ int * cx
Definition: commctrl.h:585
#define STATUSCLASSNAMEW
Definition: commctrl.h:1941
#define UDM_SETRANGE
Definition: commctrl.h:2146
#define TreeView_GetParent(hwnd, hitem)
Definition: commctrl.h:3474
#define TVS_SHOWSELALWAYS
Definition: commctrl.h:3257
#define ILC_COLOR32
Definition: commctrl.h:358
#define ListView_GetNextItem(hwnd, i, flags)
Definition: commctrl.h:2439
#define TreeView_GetSelection(hwnd)
Definition: commctrl.h:3478
#define TreeView_GetItem(hwnd, pitem)
Definition: commctrl.h:3495
#define LVS_EX_FULLROWSELECT
Definition: commctrl.h:2739
#define TVN_ENDLABELEDIT
Definition: commctrl.h:3749
#define TVS_HASLINES
Definition: commctrl.h:3253
#define ListView_GetItemCount(hwnd)
Definition: commctrl.h:2312
struct tagNMITEMACTIVATE * LPNMITEMACTIVATE
#define ListView_SetExtendedListViewStyle(hwndLV, dw)
Definition: commctrl.h:2730
#define PBS_SMOOTH
Definition: commctrl.h:2185
#define LVIS_SELECTED
Definition: commctrl.h:2324
#define NM_RETURN
Definition: commctrl.h:132
#define WC_TREEVIEWW
Definition: commctrl.h:3248
#define LVIF_PARAM
Definition: commctrl.h:2316
#define TV_INSERTSTRUCTW
Definition: commctrl.h:3381
struct tagNMLISTVIEW * LPNMLISTVIEW
#define ListView_DeleteAllItems(hwnd)
Definition: commctrl.h:2419
#define ListView_SetItemText(hwndLV, i, iSubItem_, pszText_)
Definition: commctrl.h:2696
#define LVIF_TEXT
Definition: commctrl.h:2314
#define ImageList_AddIcon(himl, hicon)
Definition: commctrl.h:415
#define TVIS_OVERLAYMASK
Definition: commctrl.h:3292
#define TVS_HASBUTTONS
Definition: commctrl.h:3252
#define ILC_MASK
Definition: commctrl.h:351
#define TreeView_EditLabel(hwnd, hitem)
Definition: commctrl.h:3509
#define UDM_SETRANGE32
Definition: commctrl.h:2156
#define SBARS_SIZEGRIP
Definition: commctrl.h:1928
#define LVIF_IMAGE
Definition: commctrl.h:2315
#define INDEXTOOVERLAYMASK(i)
Definition: commctrl.h:425
#define TVIF_PARAM
Definition: commctrl.h:3273
#define LPNMTVDISPINFO
Definition: commctrl.h:3681
#define TVS_EDITLABELS
Definition: commctrl.h:3255
#define LVN_ITEMCHANGED
Definition: commctrl.h:3136
#define LVCF_TEXT
Definition: commctrl.h:2593
#define TreeView_SetImageList(hwnd, himl, iImage)
Definition: commctrl.h:3452
#define TreeView_HitTest(hwnd, lpht)
Definition: commctrl.h:3518
#define TreeView_InsertItem(hwnd, lpis)
Definition: commctrl.h:3417
#define TVIF_SELECTEDIMAGE
Definition: commctrl.h:3276
#define ICC_LISTVIEW_CLASSES
Definition: commctrl.h:58
#define TVIF_STATE
Definition: commctrl.h:3274
#define LVN_ITEMACTIVATE
Definition: commctrl.h:3152
#define TreeView_DeleteItem(hwnd, hitem)
Definition: commctrl.h:3420
#define WC_SCROLLBARW
Definition: commctrl.h:4734
DWORD dwStatus
Definition: mediaobj.idl:95
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:82
#define _SEH2_FINALLY
Definition: pseh2_64.h:130
#define _SEH2_END
Definition: pseh2_64.h:171
#define _SEH2_TRY
Definition: pseh2_64.h:71
#define IDHELP
Definition: resource_2.h:8
#define WM_CONTEXTMENU
Definition: richedit.h:64
#define WM_NOTIFY
Definition: richedit.h:61
#define REG_DWORD
Definition: sdbapi.c:596
_Check_return_ _CRTIMP int __cdecl _wcsicmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
_CRT_RESTORE_GCC_WARNINGS _Check_return_ _CRTIMP wchar_t *__cdecl wcstok(_Inout_opt_z_ wchar_t *_Str, _In_z_ const wchar_t *_Delim)
LPWSTR *WINAPI CommandLineToArgvW(LPCWSTR lpCmdline, int *numargs)
Definition: shell32_main.c:79
BOOL WINAPI ShellAboutW(HWND hWnd, LPCWSTR szApp, LPCWSTR szOtherStuff, HICON hIcon)
#define _countof(array)
Definition: sndvol32.h:70
& rect
Definition: startmenu.cpp:1413
PULONG MinorVersion OPTIONAL
Definition: CrossNt.h:68
STRSAFEAPI StringCchPrintfW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszFormat,...)
Definition: strsafe.h:530
STRSAFEAPI StringCchCopyExW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszSrc, STRSAFE_LPWSTR *ppszDestEnd, size_t *pcchRemaining, STRSAFE_DWORD dwFlags)
Definition: strsafe.h:184
STRSAFEAPI StringCchCatW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszSrc)
Definition: strsafe.h:325
STRSAFEAPI StringCchPrintfExW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPWSTR *ppszDestEnd, size_t *pcchRemaining, STRSAFE_DWORD dwFlags, STRSAFE_LPCWSTR pszFormat,...)
Definition: strsafe.h:585
STRSAFEAPI StringCbCopyW(STRSAFE_LPWSTR pszDest, size_t cbDest, STRSAFE_LPCWSTR pszSrc)
Definition: strsafe.h:166
STRSAFEAPI StringCchCopyW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszSrc)
Definition: strsafe.h:149
STRSAFEAPI StringCbPrintfW(STRSAFE_LPWSTR pszDest, size_t cbDest, STRSAFE_LPCWSTR pszFormat,...)
Definition: strsafe.h:557
STRSAFEAPI StringCchCopyNW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszSrc, size_t cchToCopy)
Definition: strsafe.h:236
STRSAFEAPI StringCbCatW(STRSAFE_LPWSTR pszDest, size_t cbDest, STRSAFE_LPCWSTR pszSrc)
Definition: strsafe.h:342
base of all file and directory entries
Definition: entries.h:83
PEVENTLOG EventLogs[ANYSIZE_ARRAY]
Definition: eventvwr.h:138
ULONG NumOfEventLogs
Definition: eventvwr.h:137
BOOL AuditSuccess
Definition: eventvwr.h:120
BOOL Information
Definition: eventvwr.h:117
PWSTR ComputerNames
Definition: eventvwr.h:134
LIST_ENTRY ListEntry
Definition: eventvwr.h:107
BOOL AuditFailure
Definition: eventvwr.h:121
LONG ReferenceCount
Definition: eventvwr.h:109
PWSTR LogName
Definition: eventvwr.h:93
PWSTR ComputerName
Definition: eventvwr.h:90
BOOL Permanent
Definition: eventvwr.h:97
PWSTR FileName
Definition: eventvwr.h:94
LIST_ENTRY ListEntry
Definition: eventvwr.h:86
Definition: typedefs.h:120
LPCPROPSHEETPAGEW ppsp
Definition: prsht.h:308
HINSTANCE hInstance
Definition: prsht.h:296
DWORD dwSize
Definition: prsht.h:293
DWORD dwFlags
Definition: prsht.h:294
HWND hwndParent
Definition: prsht.h:295
UINT nStartPage
Definition: prsht.h:304
LPCWSTR pszCaption
Definition: prsht.h:301
DLGPROC pfnDlgProc
Definition: prsht.h:226
DWORD dwSize
Definition: prsht.h:214
DWORD dwFlags
Definition: prsht.h:215
LPARAM lParam
Definition: prsht.h:227
LPCWSTR pszTemplate
Definition: prsht.h:218
HINSTANCE hInstance
Definition: prsht.h:216
INT nHSplitPos
Definition: eventvwr.c:112
BOOL bShowDetailsPane
Definition: eventvwr.c:107
WINDOWPLACEMENT wpPos
Definition: eventvwr.c:113
BOOL bShowGrid
Definition: eventvwr.c:108
BOOL bNewestEventsFirst
Definition: eventvwr.c:110
INT nVSplitPos
Definition: eventvwr.c:111
BOOL bSaveSettings
Definition: eventvwr.c:109
ULONGLONG QuadPart
Definition: ms-dtyp.idl:185
LPCWSTR lpszClassName
Definition: winuser.h:3237
LPCWSTR lpszMenuName
Definition: winuser.h:3236
HBRUSH hbrBackground
Definition: winuser.h:3235
WNDPROC lpfnWndProc
Definition: winuser.h:3229
UINT cbSize
Definition: winuser.h:3227
int cbWndExtra
Definition: winuser.h:3231
HCURSOR hCursor
Definition: winuser.h:3234
HICON hIconSm
Definition: winuser.h:3238
HINSTANCE hInstance
Definition: winuser.h:3232
UINT style
Definition: winuser.h:3228
int cbClsExtra
Definition: winuser.h:3230
HICON hIcon
Definition: winuser.h:3233
LPWSTR lpDecimalSep
Definition: winnls.h:647
UINT Grouping
Definition: winnls.h:646
LPWSTR lpThousandSep
Definition: winnls.h:648
Definition: inflate.c:139
LPWSTR pszText
Definition: commctrl.h:2572
LPWSTR pszText
Definition: commctrl.h:2370
int iSubItem
Definition: commctrl.h:2367
UINT mask
Definition: commctrl.h:2365
LPARAM lParam
Definition: commctrl.h:2373
int iImage
Definition: commctrl.h:2372
UINT uNewState
Definition: commctrl.h:3041
HINSTANCE hInstance
Definition: commdlg.h:362
HWND hwndOwner
Definition: commdlg.h:361
DWORD Flags
Definition: commdlg.h:373
LPWSTR lpstrFile
Definition: commdlg.h:367
LPCWSTR lpstrInitialDir
Definition: commdlg.h:371
LPCWSTR lpstrDefExt
Definition: commdlg.h:376
DWORD lStructSize
Definition: commdlg.h:360
DWORD nMaxFile
Definition: commdlg.h:368
LPCWSTR lpstrFilter
Definition: commdlg.h:363
long y
Definition: polytest.cpp:48
long x
Definition: polytest.cpp:48
LONG right
Definition: windef.h:308
LONG bottom
Definition: windef.h:309
LONG top
Definition: windef.h:307
LONG left
Definition: windef.h:306
LPARAM lParam
Definition: commctrl.h:3360
HTREEITEM hItem
Definition: commctrl.h:3352
#define max(a, b)
Definition: svc.c:63
DWORD WINAPI WaitForMultipleObjects(IN DWORD nCount, IN CONST HANDLE *lpHandles, IN BOOL bWaitAll, IN DWORD dwMilliseconds)
Definition: synch.c:151
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
HANDLE WINAPI DECLSPEC_HOTPATCH CreateEventW(IN LPSECURITY_ATTRIBUTES lpEventAttributes OPTIONAL, IN BOOL bManualReset, IN BOOL bInitialState, IN LPCWSTR lpName OPTIONAL)
Definition: synch.c:651
BOOL WINAPI DECLSPEC_HOTPATCH SetEvent(IN HANDLE hEvent)
Definition: synch.c:733
#define LANG_USER_DEFAULT
Definition: tnerror.cpp:50
#define towupper(c)
Definition: wctype.h:99
HTREEITEM hItem
Definition: treelist.h:37
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1829
uint16_t * PWSTR
Definition: typedefs.h:56
int32_t INT_PTR
Definition: typedefs.h:64
const uint16_t * PCWSTR
Definition: typedefs.h:57
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255
unsigned char * LPBYTE
Definition: typedefs.h:53
int64_t LONGLONG
Definition: typedefs.h:68
ULONG_PTR SIZE_T
Definition: typedefs.h:80
int32_t INT
Definition: typedefs.h:58
uint32_t ULONG_PTR
Definition: typedefs.h:65
#define IN
Definition: typedefs.h:39
#define MAKELONG(a, b)
Definition: typedefs.h:249
uint16_t * PWCHAR
Definition: typedefs.h:56
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260
uint32_t ULONG
Definition: typedefs.h:59
uint64_t ULONGLONG
Definition: typedefs.h:67
#define HIWORD(l)
Definition: typedefs.h:247
#define OUT
Definition: typedefs.h:40
struct _LARGE_INTEGER::@2379 u
int ret
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_POWER_POLICY_IDLE_SETTINGS Settings
Definition: wdfdevice.h:2595
_Must_inspect_result_ _In_ WDFDEVICE _In_ PCUNICODE_STRING KeyName
Definition: wdfdevice.h:2699
_Must_inspect_result_ _In_ WDFDEVICE _In_ WDFSTRING String
Definition: wdfdevice.h:2433
_In_ WDFREQUEST _In_ NTSTATUS _In_ ULONG_PTR Information
Definition: wdfrequest.h:1049
#define PRECT
Definition: precomp.h:27
#define ZeroMemory
Definition: winbase.h:1743
_In_ LPCSTR _Out_writes_to_opt_ cchDisplayName LPSTR lpDisplayName
Definition: winbase.h:2821
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
_In_ LPCSTR lpFileName
Definition: winbase.h:3102
#define FORMAT_MESSAGE_MAX_WIDTH_MASK
Definition: winbase.h:451
#define LOAD_LIBRARY_AS_DATAFILE
Definition: winbase.h:368
#define FORMAT_MESSAGE_IGNORE_INSERTS
Definition: winbase.h:446
#define CopyMemory
Definition: winbase.h:1741
#define MoveMemory
Definition: winbase.h:1740
#define FORMAT_MESSAGE_FROM_SYSTEM
Definition: winbase.h:449
#define FORMAT_MESSAGE_ALLOCATE_BUFFER
Definition: winbase.h:445
#define FORMAT_MESSAGE_ARGUMENT_ARRAY
Definition: winbase.h:450
#define FORMAT_MESSAGE_FROM_HMODULE
Definition: winbase.h:448
_In_ LPCSTR _Out_writes_bytes_to_opt_ cbSid PSID _Inout_ LPDWORD _Out_writes_to_opt_ cchReferencedDomainName LPSTR _Inout_ LPDWORD _Out_ PSID_NAME_USE peUse
Definition: winbase.h:2777
#define CREATE_SUSPENDED
Definition: winbase.h:181
@ GetFileExInfoStandard
Definition: winbase.h:1192
#define WAIT_OBJECT_0
Definition: winbase.h:432
*nSize LPSTR _Inout_ LPDWORD nSize
Definition: winbase.h:2115
_In_ PSID _Out_writes_to_opt_ cchName LPSTR _Inout_ LPDWORD cchName
Definition: winbase.h:2798
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1176
LONG_PTR LPARAM
Definition: windef.h:208
LONG_PTR LRESULT
Definition: windef.h:209
UINT_PTR WPARAM
Definition: windef.h:207
#define WINAPI
Definition: msvc.h:6
#define GET_Y_LPARAM(lp)
Definition: windowsx.h:300
#define GET_X_LPARAM(lp)
Definition: windowsx.h:299
#define LOCALE_SGROUPING
Definition: winnls.h:46
#define LOCALE_SDECIMAL
Definition: winnls.h:44
#define LOCALE_STHOUSAND
Definition: winnls.h:45
#define DATE_LONGDATE
Definition: winnls.h:199
#define DATE_SHORTDATE
Definition: winnls.h:198
#define EVENTLOG_ERROR_TYPE
Definition: winnt_old.h:2871
#define EVENTLOG_SEQUENTIAL_READ
Definition: winnt_old.h:2865
#define EVENTLOG_AUDIT_FAILURE
Definition: winnt_old.h:2875
#define EVENTLOG_INFORMATION_TYPE
Definition: winnt_old.h:2873
#define EVENTLOG_AUDIT_SUCCESS
Definition: winnt_old.h:2874
#define EVENTLOG_BACKWARDS_READ
Definition: winnt_old.h:2868
#define EVENTLOG_SUCCESS
Definition: winnt_old.h:2870
#define EVENTLOG_FORWARDS_READ
Definition: winnt_old.h:2867
#define EVENTLOG_WARNING_TYPE
Definition: winnt_old.h:2872
struct _EVENTLOGRECORD * PEVENTLOGRECORD
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12
#define HKEY_CURRENT_USER
Definition: winreg.h:11
#define RegConnectRegistry
Definition: winreg.h:495
HWND WINAPI GetFocus(void)
Definition: window.c:1875
HWND WINAPI SetCapture(_In_ HWND hWnd)
#define WS_EX_STATICEDGE
Definition: winuser.h:403
BOOL WINAPI IsWindow(_In_opt_ HWND)
#define SW_HIDE
Definition: winuser.h:779
#define SWP_NOACTIVATE
Definition: winuser.h:1253
#define MF_BYCOMMAND
Definition: winuser.h:202
#define DWLP_USER
Definition: winuser.h:883
#define GetWindowLongPtrW
Definition: winuser.h:4840
BOOL WINAPI TranslateMessage(_In_ const MSG *)
#define SBS_SIZEGRIP
Definition: winuser.h:332
#define MAKELPARAM(l, h)
Definition: winuser.h:4019
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
BOOL WINAPI ReleaseCapture(void)
Definition: message.c:2890
#define WMSZ_BOTTOMRIGHT
Definition: winuser.h:2482
LRESULT WINAPI DefWindowProcW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define WMSZ_BOTTOMLEFT
Definition: winuser.h:2481
#define IDCANCEL
Definition: winuser.h:842
BOOL WINAPI GetMessageW(_Out_ LPMSG, _In_opt_ HWND, _In_ UINT, _In_ UINT)
#define IMAGE_ICON
Definition: winuser.h:212
BOOL WINAPI GetWindowPlacement(_In_ HWND, _Inout_ WINDOWPLACEMENT *)
BOOL WINAPI GetWindowRect(_In_ HWND, _Out_ LPRECT)
#define WM_CREATE
Definition: winuser.h:1619
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
BOOL WINAPI SetWindowPos(_In_ HWND, _In_opt_ HWND, _In_ int, _In_ int, _In_ int, _In_ int, _In_ UINT)
#define SM_CXVSCROLL
Definition: winuser.h:972
__analysis_noreturn void WINAPI PostQuitMessage(_In_ int)
#define WM_SIZE
Definition: winuser.h:1622
#define SWP_NOMOVE
Definition: winuser.h:1255
#define WM_COMMAND
Definition: winuser.h:1751
HANDLE WINAPI LoadImageW(_In_opt_ HINSTANCE hInst, _In_ LPCWSTR name, _In_ UINT type, _In_ int cx, _In_ int cy, _In_ UINT fuLoad)
Definition: cursoricon.c:2541
#define IDC_ARROW
Definition: winuser.h:695
BOOL WINAPI GetCursorPos(_Out_ LPPOINT)
Definition: cursoricon.c:3033
#define WMSZ_TOP
Definition: winuser.h:2477
#define SM_CYSMICON
Definition: winuser.h:1024
BOOL WINAPI SetDlgItemTextW(_In_ HWND, _In_ int, _In_ LPCWSTR)
#define IDC_SIZENWSE
Definition: winuser.h:700
#define MF_CHECKED
Definition: winuser.h:132
HCURSOR WINAPI SetCursor(_In_opt_ HCURSOR)
#define SWP_NOSIZE
Definition: winuser.h:1256
#define WM_MOUSEMOVE
Definition: winuser.h:1786
HWND WINAPI GetCapture(void)
Definition: message.c:2881
#define SIZE_MINIMIZED
Definition: winuser.h:2517
#define WM_INITMENU
Definition: winuser.h:1756
#define TPM_NONOTIFY
Definition: winuser.h:2397
#define WM_INITDIALOG
Definition: winuser.h:1750
#define WM_LBUTTONDOWN
Definition: winuser.h:1787
#define MB_YESNO
Definition: winuser.h:828
BOOL WINAPI EndDeferWindowPos(_In_ HDWP)
HCURSOR WINAPI LoadCursorW(_In_opt_ HINSTANCE, _In_ LPCWSTR)
Definition: cursoricon.c:2443
BOOL WINAPI TrackPopupMenuEx(_In_ HMENU, _In_ UINT, _In_ int, _In_ int, _In_ HWND, _In_opt_ LPTPMPARAMS)
int WINAPI MapWindowPoints(_In_opt_ HWND hWndFrom, _In_opt_ HWND hWndTo, _Inout_updates_(cPoints) LPPOINT lpPoints, _In_ UINT cPoints)
int WINAPI MessageBoxW(_In_opt_ HWND hWnd, _In_opt_ LPCWSTR lpText, _In_opt_ LPCWSTR lpCaption, _In_ UINT uType)
#define WMSZ_LEFT
Definition: winuser.h:2475
#define MF_UNCHECKED
Definition: winuser.h:204
#define SM_CYHSCROLL
Definition: winuser.h:973
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
#define TPM_TOPALIGN
Definition: winuser.h:2394
#define IDOK
Definition: winuser.h:841
DWORD WINAPI CheckMenuItem(_In_ HMENU, _In_ UINT, _In_ UINT)
#define HWND_DESKTOP
Definition: winuser.h:1220
LRESULT WINAPI SendDlgItemMessageW(_In_ HWND, _In_ int, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define MB_ICONERROR
Definition: winuser.h:798
#define WM_RBUTTONDOWN
Definition: winuser.h:1790
BOOL WINAPI SetWindowTextW(_In_ HWND, _In_opt_ LPCWSTR)
UINT WINAPI IsDlgButtonChecked(_In_ HWND, _In_ int)
#define WMSZ_TOPLEFT
Definition: winuser.h:2478
#define IDC_SIZENS
Definition: winuser.h:703
#define SM_CXSMICON
Definition: winuser.h:1023
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
BOOL WINAPI SetDlgItemInt(_In_ HWND, _In_ int, _In_ UINT, _In_ BOOL)
#define HWND_TOP
Definition: winuser.h:1218
HMENU WINAPI GetSubMenu(_In_ HMENU, _In_ int)
HWND WINAPI SetFocus(_In_opt_ HWND)
#define WM_INITMENUPOPUP
Definition: winuser.h:1757
#define SIZE_MAXIMIZED
Definition: winuser.h:2518
#define MF_ENABLED
Definition: winuser.h:128
HWND WINAPI CreateWindowExW(_In_ DWORD dwExStyle, _In_opt_ LPCWSTR lpClassName, _In_opt_ LPCWSTR lpWindowName, _In_ DWORD dwStyle, _In_ int X, _In_ int Y, _In_ int nWidth, _In_ int nHeight, _In_opt_ HWND hWndParent, _In_opt_ HMENU hMenu, _In_opt_ HINSTANCE hInstance, _In_opt_ LPVOID lpParam)
#define TPM_LEFTALIGN
Definition: winuser.h:2388
#define WMSZ_TOPRIGHT
Definition: winuser.h:2479
#define IDNO
Definition: winuser.h:847
BOOL WINAPI UpdateWindow(_In_ HWND)
struct tagNMHDR * LPNMHDR
ATOM WINAPI RegisterClassExW(_In_ CONST WNDCLASSEXW *)
#define HTCLIENT
Definition: winuser.h:2486
#define SWP_SHOWWINDOW
Definition: winuser.h:1259
#define LR_SHARED
Definition: winuser.h:1111
#define MB_OK
Definition: winuser.h:801
#define CreateWindowW(a, b, c, d, e, f, g, h, i, j, k)
Definition: winuser.h:4327
#define WM_LBUTTONUP
Definition: winuser.h:1788
#define CW_USEDEFAULT
Definition: winuser.h:225
BOOL WINAPI CheckMenuRadioItem(_In_ HMENU, _In_ UINT, _In_ UINT, _In_ UINT, _In_ UINT)
HWND WINAPI GetParent(_In_ HWND)
HACCEL WINAPI LoadAcceleratorsW(_In_opt_ HINSTANCE, _In_ LPCWSTR)
#define WMSZ_BOTTOM
Definition: winuser.h:2480
#define WM_SIZING
Definition: winuser.h:1818
#define SWP_HIDEWINDOW
Definition: winuser.h:1252
#define SBS_SIZEBOXBOTTOMRIGHTALIGN
Definition: winuser.h:330
LRESULT WINAPI DispatchMessageW(_In_ const MSG *)
BOOL WINAPI CheckRadioButton(_In_ HWND, _In_ int, _In_ int, _In_ int)
#define MB_ICONQUESTION
Definition: winuser.h:800
#define DWLP_MSGRESULT
Definition: winuser.h:881
#define MB_ICONINFORMATION
Definition: winuser.h:813
#define WMSZ_RIGHT
Definition: winuser.h:2476
int WINAPI TranslateAcceleratorW(_In_ HWND, _In_ HACCEL, _In_ LPMSG)
#define WM_SETCURSOR
Definition: winuser.h:1647
HDWP WINAPI DeferWindowPos(_In_ HDWP, _In_ HWND, _In_opt_ HWND, _In_ int, _In_ int, _In_ int, _In_ int, _In_ UINT)
#define SW_SHOW
Definition: winuser.h:786
#define WM_DESTROY
Definition: winuser.h:1620
#define WS_EX_CLIENTEDGE
Definition: winuser.h:384
UINT WINAPI GetDlgItemInt(_In_ HWND, _In_ int, _Out_opt_ PBOOL, _In_ BOOL)
BOOL WINAPI InvalidateRect(_In_opt_ HWND, _In_opt_ LPCRECT, _In_ BOOL)
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
HMENU WINAPI LoadMenuW(_In_opt_ HINSTANCE, _In_ LPCWSTR)
#define IDYES
Definition: winuser.h:846
#define TPM_RETURNCMD
Definition: winuser.h:2398
#define SWP_NOZORDER
Definition: winuser.h:1258
#define SetWindowLongPtrW
Definition: winuser.h:5366
#define GWL_STYLE
Definition: winuser.h:863
#define IDC_SIZEWE
Definition: winuser.h:702
BOOL WINAPI IsWindowVisible(_In_ HWND)
BOOL WINAPI DestroyWindow(_In_ HWND)
BOOL WINAPI EnableMenuItem(_In_ HMENU, _In_ UINT, _In_ UINT)
#define MB_YESNOCANCEL
Definition: winuser.h:829
HICON WINAPI LoadIconW(_In_opt_ HINSTANCE hInstance, _In_ LPCWSTR lpIconName)
Definition: cursoricon.c:2413
int WINAPI GetSystemMetrics(_In_ int)
BOOL WINAPI MoveWindow(_In_ HWND, _In_ int, _In_ int, _In_ int, _In_ int, _In_ BOOL)
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define BST_CHECKED
Definition: winuser.h:197
HMENU WINAPI GetMenu(_In_ HWND)
BOOL WINAPI SetRect(_Out_ LPRECT, _In_ int, _In_ int, _In_ int, _In_ int)
INT_PTR WINAPI DialogBoxParamW(_In_opt_ HINSTANCE, _In_ LPCWSTR, _In_opt_ HWND, _In_opt_ DLGPROC, _In_ LPARAM)
HDWP WINAPI BeginDeferWindowPos(_In_ int)
BOOL WINAPI EndDialog(_In_ HWND, _In_ INT_PTR)
#define GWL_EXSTYLE
Definition: winuser.h:862
#define MF_GRAYED
Definition: winuser.h:129
#define EN_CHANGE
Definition: winuser.h:2033
#define COLOR_3DFACE
Definition: winuser.h:940
#define WM_SETREDRAW
Definition: winuser.h:1627
BOOL WINAPI ScreenToClient(_In_ HWND, _Inout_ LPPOINT)
_At_(*)(_In_ PWSK_CLIENT Client, _In_opt_ PUNICODE_STRING NodeName, _In_opt_ PUNICODE_STRING ServiceName, _In_opt_ ULONG NameSpace, _In_opt_ GUID *Provider, _In_opt_ PADDRINFOEXW Hints, _Outptr_ PADDRINFOEXW *Result, _In_opt_ PEPROCESS OwningProcess, _In_opt_ PETHREAD OwningThread, _Inout_ PIRP Irp Result)(Mem)) NTSTATUS(WSKAPI *PFN_WSK_GET_ADDRESS_INFO
Definition: wsk.h:409
__wchar_t WCHAR
Definition: xmlstorage.h:180
WCHAR * LPWSTR
Definition: xmlstorage.h:184
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
unsigned char BYTE
Definition: xxhash.c:193