Author: ekohl
Date: Sun Nov 17 22:30:55 2013
New Revision: 61026
URL:
http://svn.reactos.org/svn/reactos?rev=61026&view=rev
Log:
[EVENTLOG]
LogfInitializeExisting: Do not try to write to a file that has been opened as a backup
file. It has been opened read-only.
Modified:
trunk/reactos/base/services/eventlog/file.c
Modified: trunk/reactos/base/services/eventlog/file.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/services/eventlog/fil…
==============================================================================
--- trunk/reactos/base/services/eventlog/file.c [iso-8859-1] (original)
+++ trunk/reactos/base/services/eventlog/file.c [iso-8859-1] Sun Nov 17 22:30:55 2013
@@ -82,7 +82,7 @@
static NTSTATUS
-LogfInitializeExisting(PLOGFILE LogFile)
+LogfInitializeExisting(PLOGFILE LogFile, BOOL Backup)
{
DWORD dwRead;
DWORD dwRecordsNumber = 0;
@@ -264,27 +264,30 @@
But for now limit EventLog size to just under 5K. */
LogFile->Header.MaxSize = 5000;
- if (SetFilePointer(LogFile->hFile, 0, NULL, FILE_BEGIN) ==
- INVALID_SET_FILE_POINTER)
- {
- DPRINT1("SetFilePointer() failed! %d\n", GetLastError());
- return STATUS_EVENTLOG_FILE_CORRUPT;
- }
-
- if (!WriteFile(LogFile->hFile,
- &LogFile->Header,
- sizeof(EVENTLOGHEADER),
- &dwRead,
- NULL))
- {
- DPRINT1("WriteFile failed! %d\n", GetLastError());
- return STATUS_EVENTLOG_FILE_CORRUPT;
- }
-
- if (!FlushFileBuffers(LogFile->hFile))
- {
- DPRINT1("FlushFileBuffers failed! %d\n", GetLastError());
- return STATUS_EVENTLOG_FILE_CORRUPT;
+ if (!Backup)
+ {
+ if (SetFilePointer(LogFile->hFile, 0, NULL, FILE_BEGIN) ==
+ INVALID_SET_FILE_POINTER)
+ {
+ DPRINT1("SetFilePointer() failed! %d\n", GetLastError());
+ return STATUS_EVENTLOG_FILE_CORRUPT;
+ }
+
+ if (!WriteFile(LogFile->hFile,
+ &LogFile->Header,
+ sizeof(EVENTLOGHEADER),
+ &dwRead,
+ NULL))
+ {
+ DPRINT1("WriteFile failed! %d\n", GetLastError());
+ return STATUS_EVENTLOG_FILE_CORRUPT;
+ }
+
+ if (!FlushFileBuffers(LogFile->hFile))
+ {
+ DPRINT1("FlushFileBuffers failed! %d\n", GetLastError());
+ return STATUS_EVENTLOG_FILE_CORRUPT;
+ }
}
return STATUS_SUCCESS;
@@ -380,7 +383,7 @@
if (bCreateNew)
Status = LogfInitializeNew(pLogFile);
else
- Status = LogfInitializeExisting(pLogFile);
+ Status = LogfInitializeExisting(pLogFile, Backup);
if (!NT_SUCCESS(Status))
goto fail;