ReactOS 0.4.16-dev-306-g647d351
misc.cpp
Go to the documentation of this file.
1/*
2 * PROJECT: ReactOS Automatic Testing Utility
3 * LICENSE: GPL-2.0+ (https://spdx.org/licenses/GPL-2.0+)
4 * PURPOSE: Functions for writing to the Event Log
5 * COPYRIGHT: Copyright 2009 Dmitry Chapyshev (dmitry@reactos.org)
6 */
7
8#include "precomp.h"
10
11VOID
13{
14 WCHAR szBuf[MAX_PATH] = L"SYSTEM\\CurrentControlSet\\Services\\EventLog\\Application\\RosAutotest";
16 DWORD dwCategoryNum = 1;
17 DWORD dwDisp, dwData;
18 HKEY hKey;
19
21 szBuf, 0, NULL,
23 KEY_WRITE, NULL, &hKey, &dwDisp) != ERROR_SUCCESS)
24 {
25 return;
26 }
27
28 if (!GetModuleFileName(NULL, szPath, sizeof(szPath) / sizeof(szPath[0])))
29 return;
30
32 L"EventMessageFile",
33 0,
36 (DWORD)(wcslen(szPath) + 1) * sizeof(WCHAR)) != ERROR_SUCCESS)
37 {
39 return;
40 }
41
44
46 L"TypesSupported",
47 0,
49 (LPBYTE)&dwData,
50 sizeof(DWORD)) != ERROR_SUCCESS)
51 {
53 return;
54 }
55
57 L"CategoryMessageFile",
58 0,
61 (DWORD)(wcslen(szPath) + 1) * sizeof(WCHAR)) != ERROR_SUCCESS)
62 {
64 return;
65 }
66
68 L"CategoryCount",
69 0,
71 (LPBYTE)&dwCategoryNum,
72 sizeof(DWORD)) != ERROR_SUCCESS)
73 {
75 return;
76 }
77
79
80 hLog = RegisterEventSourceW(NULL, L"RosAutotest");
81}
82
83
84VOID
86{
88}
89
90
91BOOL
92WriteLogMessage(WORD wType, DWORD dwEventID, LPWSTR lpMsg)
93{
94 if (!ReportEventW(hLog,
95 wType,
96 0,
97 dwEventID,
98 NULL,
99 1,
100 0,
101 (LPCWSTR*)&lpMsg,
102 NULL))
103 {
104 return FALSE;
105 }
106
107 return TRUE;
108}
VOID InitLogs()
Definition: misc.cpp:205
VOID FreeLogs()
Definition: misc.cpp:243
#define RegCloseKey(hKey)
Definition: registry.h:49
#define ERROR_SUCCESS
Definition: deptool.c:10
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
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 RegSetValueExW(_In_ HKEY hKey, _In_ LPCWSTR lpValueName, _In_ DWORD Reserved, _In_ DWORD dwType, _In_ CONST BYTE *lpData, _In_ DWORD cbData)
Definition: reg.c:4882
BOOL WINAPI ReportEventW(IN HANDLE hEventLog, IN WORD wType, IN WORD wCategory, IN DWORD dwEventID, IN PSID lpUserSid, IN WORD wNumStrings, IN DWORD dwDataSize, IN LPCWSTR *lpStrings, IN LPVOID lpRawData)
Definition: eventlog.c:1516
BOOL WINAPI DeregisterEventSource(IN HANDLE hEventLog)
Definition: eventlog.c:473
HANDLE WINAPI RegisterEventSourceW(IN LPCWSTR lpUNCServerName, IN LPCWSTR lpSourceName)
Definition: eventlog.c:1295
#define MAX_PATH
Definition: compat.h:34
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
unsigned short WORD
Definition: ntddk_ex.h:93
FxAutoRegKey hKey
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
LPCWSTR szPath
Definition: env.c:37
HANDLE hLog
Definition: misc.cpp:9
BOOL WriteLogMessage(WORD wType, DWORD dwEventID, LPWSTR lpMsg)
Definition: misc.cpp:92
static HANDLE ULONG_PTR dwData
Definition: file.c:35
#define REG_OPTION_NON_VOLATILE
Definition: nt_native.h:1057
#define KEY_WRITE
Definition: nt_native.h:1031
#define REG_EXPAND_SZ
Definition: nt_native.h:1494
#define L(x)
Definition: ntvdm.h:50
#define REG_DWORD
Definition: sdbapi.c:596
unsigned char * LPBYTE
Definition: typedefs.h:53
#define GetModuleFileName
Definition: winbase.h:3856
#define EVENTLOG_ERROR_TYPE
Definition: winnt_old.h:2863
#define EVENTLOG_INFORMATION_TYPE
Definition: winnt_old.h:2865
#define EVENTLOG_WARNING_TYPE
Definition: winnt_old.h:2864
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12
__wchar_t WCHAR
Definition: xmlstorage.h:180
WCHAR * LPWSTR
Definition: xmlstorage.h:184
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185