Skip to content

Commit 957e387

Browse files
committed
[EVENTLOG]
- Add event sources "EventLog" and "Service Control Manager" to the registry. - Implement an internal event reporting function and report the successful start of the event logging service. svn path=/trunk/; revision=51529
1 parent 18ea9e1 commit 957e387

File tree

4 files changed

+64
-0
lines changed

4 files changed

+64
-0
lines changed

reactos/base/services/eventlog/eventlog.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,10 @@ ServiceMain(DWORD argc,
168168
{
169169
DPRINT("Service started\n");
170170
UpdateServiceStatus(SERVICE_RUNNING);
171+
172+
LogfReportEvent(EVENTLOG_INFORMATION_TYPE,
173+
0,
174+
EVENT_EventlogStarted);
171175
}
172176

173177
DPRINT("ServiceMain() done\n");

reactos/base/services/eventlog/eventlog.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#define WIN32_NO_STATUS
1414

1515
#include <windows.h>
16+
#include <netevent.h>
1617
#include <lpctypes.h>
1718
#include <lpcfuncs.h>
1819
#include <rtlfuncs.h>
@@ -177,6 +178,11 @@ PBYTE LogfAllocAndBuildNewRecord(LPDWORD lpRecSize,
177178
DWORD dwDataSize,
178179
LPVOID lpRawData);
179180

181+
VOID
182+
LogfReportEvent(WORD wType,
183+
WORD wCategory,
184+
DWORD dwEventId);
185+
180186
/* eventlog.c */
181187
extern HANDLE MyHeap;
182188

reactos/base/services/eventlog/file.c

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1049,3 +1049,53 @@ PBYTE LogfAllocAndBuildNewRecord(LPDWORD lpRecSize,
10491049
*lpRecSize = dwRecSize;
10501050
return Buffer;
10511051
}
1052+
1053+
1054+
VOID
1055+
LogfReportEvent(WORD wType,
1056+
WORD wCategory,
1057+
DWORD dwEventId)
1058+
{
1059+
WCHAR szComputerName[MAX_COMPUTERNAME_LENGTH + 1];
1060+
DWORD dwComputerNameLength = MAX_COMPUTERNAME_LENGTH + 1;
1061+
PEVENTSOURCE pEventSource = NULL;
1062+
PBYTE logBuffer;
1063+
DWORD lastRec;
1064+
DWORD recSize;
1065+
DWORD dwError;
1066+
1067+
if (!GetComputerNameW(szComputerName, &dwComputerNameLength))
1068+
{
1069+
szComputerName[0] = 0;
1070+
}
1071+
1072+
pEventSource = GetEventSourceByName(L"EventLog");
1073+
if (pEventSource == NULL)
1074+
{
1075+
return;
1076+
}
1077+
1078+
lastRec = LogfGetCurrentRecord(pEventSource->LogFile);
1079+
1080+
logBuffer = LogfAllocAndBuildNewRecord(&recSize,
1081+
lastRec,
1082+
wType,
1083+
wCategory,
1084+
dwEventId,
1085+
pEventSource->szName,
1086+
(LPCWSTR)szComputerName,
1087+
0,
1088+
NULL,
1089+
0, //wNumStrings,
1090+
NULL, //lpStrings,
1091+
0, //dwDataSize,
1092+
NULL); //lpRawData);
1093+
1094+
dwError = LogfWriteData(pEventSource->LogFile, recSize, logBuffer);
1095+
if (!dwError)
1096+
{
1097+
DPRINT1("ERROR WRITING TO EventLog %S\n", pEventSource->LogFile->FileName);
1098+
}
1099+
1100+
LogfFreeRecord(logBuffer);
1101+
}

reactos/boot/bootdata/hivesys_i386.inf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1148,10 +1148,14 @@ HKLM,"SYSTEM\CurrentControlSet\Services\EventLog","Type",0x00010001,0x00000010
11481148

11491149
HKLM,"SYSTEM\CurrentControlSet\Services\EventLog\Application",,0x00000010
11501150
HKLM,"SYSTEM\CurrentControlSet\Services\EventLog\Application","File",0x00020000,"%SystemRoot%\system32\config\AppEvent.Evt"
1151+
HKLM,"SYSTEM\CurrentControlSet\Services\EventLog\Application\Service Control Manager","EventMessageFile",0x00020000,"%SystemRoot%\system32\netevent.dll"
1152+
HKLM,"SYSTEM\CurrentControlSet\Services\EventLog\Application\Service Control Manager","TypesSupported",0x00010001,0x00000007
11511153
HKLM,"SYSTEM\CurrentControlSet\Services\EventLog\Security",,0x00000010
11521154
HKLM,"SYSTEM\CurrentControlSet\Services\EventLog\Security","File",0x00020000,"%SystemRoot%\system32\config\SecEvent.Evt"
11531155
HKLM,"SYSTEM\CurrentControlSet\Services\EventLog\System",,0x00000010
11541156
HKLM,"SYSTEM\CurrentControlSet\Services\EventLog\System","File",0x00020000,"%SystemRoot%\system32\config\SysEvent.Evt"
1157+
HKLM,"SYSTEM\CurrentControlSet\Services\EventLog\System\EventLog","EventMessageFile",0x00020000,"%SystemRoot%\system32\netevent.dll"
1158+
HKLM,"SYSTEM\CurrentControlSet\Services\EventLog\System\EventLog","TypesSupported",0x00010001,0x00000007
11551159

11561160
; Floppy driver
11571161
HKLM,"SYSTEM\CurrentControlSet\Services\Floppy","ErrorControl",0x00010001,0x00000000

0 commit comments

Comments
 (0)