[EVENTVWR/EVENTLOG]
authorEric Kohl <eric.kohl@reactos.org>
Mon, 2 May 2011 19:38:23 +0000 (19:38 +0000)
committerEric Kohl <eric.kohl@reactos.org>
Mon, 2 May 2011 19:38:23 +0000 (19:38 +0000)
Fix a double off-by-one bug:
- The eventlog service was reporting one event more than was available (+1).
- The event viewer did not display the latest event from the eventlog service (-1).

See issue #6182 for more details.

svn path=/trunk/; revision=51558

reactos/base/applications/mscutils/eventvwr/eventvwr.c
reactos/base/services/eventlog/rpc.c

index 7f0a5e5..db3b6f7 100644 (file)
@@ -503,7 +503,7 @@ QueryEventMessages(LPWSTR lpMachineName,
     HWND hwndDlg;
     HANDLE hEventLog;
     EVENTLOGRECORD *pevlr;
     HWND hwndDlg;
     HANDLE hEventLog;
     EVENTLOGRECORD *pevlr;
-    DWORD dwRead, dwNeeded, dwThisRecord, dwTotalRecords = 0, dwCurrentRecord = 1, dwRecordsToRead = 0, dwFlags, dwMaxLength;
+    DWORD dwRead, dwNeeded, dwThisRecord, dwTotalRecords = 0, dwCurrentRecord = 0, dwRecordsToRead = 0, dwFlags, dwMaxLength;
     LPWSTR lpSourceName;
     LPWSTR lpComputerName;
     LPSTR lpData;
     LPWSTR lpSourceName;
     LPWSTR lpComputerName;
     LPSTR lpData;
index cf85575..5991da7 100644 (file)
@@ -199,6 +199,7 @@ NTSTATUS ElfrNumberOfRecords(
     DWORD *NumberOfRecords)
 {
     PLOGHANDLE lpLogHandle;
     DWORD *NumberOfRecords)
 {
     PLOGHANDLE lpLogHandle;
+    DWORD dwRecords;
 
     lpLogHandle = ElfGetLogHandleEntryByHandle(LogHandle);
     if (!lpLogHandle)
 
     lpLogHandle = ElfGetLogHandleEntryByHandle(LogHandle);
     if (!lpLogHandle)
@@ -206,7 +207,9 @@ NTSTATUS ElfrNumberOfRecords(
         return STATUS_INVALID_HANDLE;
     }
 
         return STATUS_INVALID_HANDLE;
     }
 
-    *NumberOfRecords = lpLogHandle->LogFile->Header.CurrentRecordNumber;
+    dwRecords = lpLogHandle->LogFile->Header.CurrentRecordNumber;
+
+    *NumberOfRecords = (dwRecords > 0) ? (dwRecords - 1) : 0;
 
     return STATUS_SUCCESS;
 }
 
     return STATUS_SUCCESS;
 }