From a94be714560906f10a01d745bcaf4d2a77620d54 Mon Sep 17 00:00:00 2001 From: Eric Kohl Date: Fri, 16 Dec 2011 18:18:20 +0000 Subject: [PATCH 1/1] [EVENTLOG] Implement ElfrBackupELFA and ElfrReportEventA. svn path=/trunk/; revision=54664 --- reactos/base/services/eventlog/rpc.c | 117 ++++++++++++++++++++++++++- 1 file changed, 113 insertions(+), 4 deletions(-) diff --git a/reactos/base/services/eventlog/rpc.c b/reactos/base/services/eventlog/rpc.c index f5f88b32e46..0526e5dbd30 100644 --- a/reactos/base/services/eventlog/rpc.c +++ b/reactos/base/services/eventlog/rpc.c @@ -540,8 +540,21 @@ NTSTATUS ElfrBackupELFA( IELF_HANDLE LogHandle, PRPC_STRING BackupFileName) { - UNIMPLEMENTED; - return STATUS_NOT_IMPLEMENTED; + UNICODE_STRING BackupFileNameW; + NTSTATUS Status; + + Status = RtlAnsiStringToUnicodeString(&BackupFileNameW, + (PANSI_STRING)BackupFileName, + TRUE); + if (!NT_SUCCESS(Status)) + return Status; + + Status = ElfrBackupELFW(LogHandle, + (PRPC_UNICODE_STRING)&BackupFileNameW); + + RtlFreeUnicodeString(&BackupFileNameW); + + return Status; } @@ -673,8 +686,104 @@ NTSTATUS ElfrReportEventA( DWORD *RecordNumber, DWORD *TimeWritten) { - UNIMPLEMENTED; - return STATUS_NOT_IMPLEMENTED; + UNICODE_STRING ComputerNameW; + PUNICODE_STRING *StringsArrayW = NULL; + NTSTATUS Status = STATUS_SUCCESS; + USHORT i; + + DPRINT("ElfrReportEventA(%hu)\n", NumStrings); + +#if 0 + for (i = 0; i < NumStrings; i++) + { + if (Strings[i] == NULL) + { + DPRINT1("String %hu is null\n", i); + } + else + { + DPRINT1("String %hu: %Z\n", i, Strings[i]); + } + } +#endif + + Status = RtlAnsiStringToUnicodeString((PUNICODE_STRING)&ComputerNameW, + (PANSI_STRING)ComputerName, + TRUE); + if (!NT_SUCCESS(Status)) + return Status; + + if (NumStrings != 0) + { + StringsArrayW = HeapAlloc(MyHeap, + HEAP_ZERO_MEMORY, + NumStrings * sizeof (PUNICODE_STRING)); + if (StringsArrayW == NULL) + { + Status = STATUS_NO_MEMORY; + goto Done; + } + + for (i = 0; i < NumStrings; i++) + { + if (Strings[i] != NULL) + { + StringsArrayW[i] = HeapAlloc(MyHeap, + HEAP_ZERO_MEMORY, + sizeof(UNICODE_STRING)); + if (StringsArrayW[i] == NULL) + { + Status = STATUS_NO_MEMORY; + break; + } + + Status = RtlAnsiStringToUnicodeString(StringsArrayW[i], + (PANSI_STRING)Strings[i], + TRUE); + } + + if (!NT_SUCCESS(Status)) + break; + } + } + + if (NT_SUCCESS(Status)) + { + Status = ElfrReportEventW(LogHandle, + Time, + EventType, + EventCategory, + EventID, + NumStrings, + DataSize, + (PRPC_UNICODE_STRING)&ComputerNameW, + UserSID, + (PRPC_UNICODE_STRING*)StringsArrayW, + Data, + Flags, + RecordNumber, + TimeWritten); + } + +Done: + for (i = 0; i < NumStrings; i++) + { + if (StringsArrayW[i] != NULL) + { + if (StringsArrayW[i]->Buffer) + { + RtlFreeUnicodeString(StringsArrayW[i]); + HeapFree(MyHeap, 0, StringsArrayW[i]); + } + } + } + + if (StringsArrayW != NULL) + HeapFree(MyHeap, 0, StringsArrayW); + + RtlFreeUnicodeString(&ComputerNameW); + + return Status; } -- 2.17.1