Author: ekohl
Date: Sun Jan 8 23:03:23 2012
New Revision: 54886
URL:
http://svn.reactos.org/svn/reactos?rev=54886&view=rev
Log:
[EVENTLOG]
- Simplify ElfCreateEventLogHandle, ElfDeleteEventLogHandle and their callers.
- Implement ElfrOpenBELA and ElfrOpenBELW.
- Add ElfDeleteEventLogHandle stub.
Modified:
trunk/reactos/base/services/eventlog/rpc.c
Modified: trunk/reactos/base/services/eventlog/rpc.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/services/eventlog/rpc…
==============================================================================
--- trunk/reactos/base/services/eventlog/rpc.c [iso-8859-1] (original)
+++ trunk/reactos/base/services/eventlog/rpc.c [iso-8859-1] Sun Jan 8 23:03:23 2012
@@ -44,12 +44,17 @@
return 0;
}
-PLOGHANDLE ElfCreateEventLogHandle(LPCWSTR Name, BOOL Create)
+
+static NTSTATUS
+ElfCreateEventLogHandle(PLOGHANDLE *LogHandle,
+ LPCWSTR Name,
+ BOOL Create)
{
PLOGHANDLE lpLogHandle;
PLOGFILE currentLogFile = NULL;
INT i, LogsActive;
PEVENTSOURCE pEventSource;
+ NTSTATUS Status;
DPRINT("ElfCreateEventLogHandle(Name: %S)\n", Name);
@@ -58,7 +63,7 @@
if (!lpLogHandle)
{
DPRINT1("Failed to allocate Heap!\n");
- return NULL;
+ return STATUS_NO_MEMORY;
}
wcscpy(lpLogHandle->szName, Name);
@@ -68,7 +73,8 @@
if (LogsActive == 0)
{
DPRINT1("EventLog service reports no log files!\n");
- goto Cleanup;
+ Status = STATUS_UNSUCCESSFUL;
+ goto Done;
}
/* If Creating, default to the Application Log in case we fail, as documented on MSDN
*/
@@ -114,45 +120,60 @@
}
if (!lpLogHandle->LogFile)
- goto Cleanup;
-
- /* Append log handle */
- InsertTailList(&LogHandleListHead, &lpLogHandle->LogHandleListEntry);
+ Status = STATUS_UNSUCCESSFUL;
+
+Done:
+ if (NT_SUCCESS(Status))
+ {
+ /* Append log handle */
+ InsertTailList(&LogHandleListHead, &lpLogHandle->LogHandleListEntry);
+ *LogHandle = lpLogHandle;
+ }
+ else
+ {
+ HeapFree(GetProcessHeap(), 0, lpLogHandle);
+ }
+
+ return Status;
+}
+
+
+static NTSTATUS
+ElfCreateBackupLogHandle(PLOGHANDLE *LogHandle,
+ PUNICODE_STRING FileName)
+{
+ DPRINT("ElfCreateBackupLogHandle(FileName: %wZ)\n", FileName);
+ return STATUS_NOT_IMPLEMENTED;
+}
+
+
+PLOGHANDLE ElfGetLogHandleEntryByHandle(IELF_HANDLE EventLogHandle)
+{
+ PLOGHANDLE lpLogHandle;
+
+ if (IsListEmpty(&LogHandleListHead))
+ {
+ return NULL;
+ }
+
+ lpLogHandle = CONTAINING_RECORD((PLOGHANDLE)EventLogHandle, LOGHANDLE,
LogHandleListEntry);
return lpLogHandle;
-
-Cleanup:
- HeapFree(GetProcessHeap(), 0, lpLogHandle);
-
- return NULL;
-}
-
-PLOGHANDLE ElfGetLogHandleEntryByHandle(IELF_HANDLE EventLogHandle)
-{
- PLOGHANDLE lpLogHandle;
-
- if (IsListEmpty(&LogHandleListHead))
- {
- return NULL;
- }
-
- lpLogHandle = CONTAINING_RECORD((PLOGHANDLE)EventLogHandle, LOGHANDLE,
LogHandleListEntry);
-
- return lpLogHandle;
-}
-
-BOOL ElfDeleteEventLogHandle(IELF_HANDLE EventLogHandle)
+}
+
+
+static NTSTATUS
+ElfDeleteEventLogHandle(IELF_HANDLE EventLogHandle)
{
PLOGHANDLE lpLogHandle = (PLOGHANDLE)EventLogHandle;
+
if (!ElfGetLogHandleEntryByHandle(lpLogHandle))
- {
- return FALSE;
- }
+ return STATUS_INVALID_HANDLE;
RemoveEntryList(&lpLogHandle->LogHandleListEntry);
HeapFree(GetProcessHeap(),0,lpLogHandle);
- return TRUE;
+ return STATUS_SUCCESS;
}
/* Function 0 */
@@ -199,12 +220,7 @@
NTSTATUS ElfrCloseEL(
IELF_HANDLE *LogHandle)
{
- if (!ElfDeleteEventLogHandle(*LogHandle))
- {
- return STATUS_INVALID_HANDLE;
- }
-
- return STATUS_SUCCESS;
+ return ElfDeleteEventLogHandle(*LogHandle);
}
@@ -212,12 +228,7 @@
NTSTATUS ElfrDeregisterEventSource(
IELF_HANDLE *LogHandle)
{
- if (!ElfDeleteEventLogHandle(*LogHandle))
- {
- return STATUS_INVALID_HANDLE;
- }
-
- return STATUS_SUCCESS;
+ return ElfDeleteEventLogHandle(*LogHandle);
}
@@ -307,14 +318,9 @@
/*FIXME: Must verify that caller has read access */
- *LogHandle = ElfCreateEventLogHandle(ModuleName->Buffer, FALSE);
-
- if (*LogHandle == NULL)
- {
- return STATUS_INVALID_PARAMETER;
- }
-
- return STATUS_SUCCESS;
+ return ElfCreateEventLogHandle((PLOGHANDLE *)LogHandle,
+ ModuleName->Buffer,
+ FALSE);
}
@@ -342,9 +348,9 @@
/*FIXME: Must verify that caller has write access */
- *LogHandle = ElfCreateEventLogHandle(ModuleName->Buffer, TRUE);
-
- return STATUS_SUCCESS;
+ return ElfCreateEventLogHandle((PLOGHANDLE *)LogHandle,
+ ModuleName->Buffer,
+ TRUE);
}
@@ -356,8 +362,17 @@
DWORD MinorVersion,
IELF_HANDLE *LogHandle)
{
- UNIMPLEMENTED;
- return STATUS_NOT_IMPLEMENTED;
+ DPRINT("ElfrOpenBELW(%wZ)\n", BackupFileName);
+
+ if ((MajorVersion != 1) || (MinorVersion != 1))
+ return STATUS_INVALID_PARAMETER;
+
+ /*FIXME: UNCServerName must specify the server */
+
+ /*FIXME: Must verify that caller has read access */
+
+ return ElfCreateBackupLogHandle((PLOGHANDLE *)LogHandle,
+ (PUNICODE_STRING)BackupFileName);
}
@@ -605,16 +620,13 @@
/* FIXME: Must verify that caller has read access */
- *LogHandle = ElfCreateEventLogHandle(ModuleNameW.Buffer, FALSE);
+ Status = ElfCreateEventLogHandle((PLOGHANDLE *)LogHandle,
+ ModuleNameW.Buffer,
+ FALSE);
RtlFreeUnicodeString(&ModuleNameW);
- if (*LogHandle == NULL)
- {
- return STATUS_INVALID_PARAMETER;
- }
-
- return STATUS_SUCCESS;
+ return Status;
}
@@ -654,12 +666,13 @@
/* FIXME: Must verify that caller has write access */
- *LogHandle = ElfCreateEventLogHandle(ModuleNameW.Buffer,
- TRUE);
+ Status = ElfCreateEventLogHandle((PLOGHANDLE *)LogHandle,
+ ModuleNameW.Buffer,
+ TRUE);
RtlFreeUnicodeString(&ModuleNameW);
- return STATUS_SUCCESS;
+ return Status;
}
@@ -671,8 +684,36 @@
DWORD MinorVersion,
IELF_HANDLE *LogHandle)
{
- UNIMPLEMENTED;
- return STATUS_NOT_IMPLEMENTED;
+ UNICODE_STRING BackupFileNameW;
+ NTSTATUS Status;
+
+ DPRINT("ElfrOpenBELA(%Z)\n", BackupFileName);
+
+ Status = RtlAnsiStringToUnicodeString(&BackupFileNameW,
+ (PANSI_STRING)BackupFileName,
+ TRUE);
+ if (!NT_SUCCESS(Status))
+ {
+ DPRINT1("RtlAnsiStringToUnicodeString failed (Status 0x%08lx)\n",
Status);
+ return Status;
+ }
+
+ if ((MajorVersion != 1) || (MinorVersion != 1))
+ {
+ RtlFreeUnicodeString(&BackupFileNameW);
+ return STATUS_INVALID_PARAMETER;
+ }
+
+ /*FIXME: UNCServerName must specify the server */
+
+ /*FIXME: Must verify that caller has read access */
+
+ Status = ElfCreateBackupLogHandle((PLOGHANDLE *)LogHandle,
+ &BackupFileNameW);
+
+ RtlFreeUnicodeString(&BackupFileNameW);
+
+ return Status;
}