From 211657178822bc7f01a0f53293930890ca635e6e Mon Sep 17 00:00:00 2001 From: Eric Kohl Date: Mon, 12 Dec 2011 21:54:20 +0000 Subject: [PATCH] [ADVAPI32] ReportEventA/W: Strings must be passed to ElfrReportEventA/W as a pointer to an array of PANSI_STRINGs instead of a pointer to an array of ANSI_STRINGs. Now, strings appear in the event viewer. svn path=/trunk/; revision=54642 --- reactos/dll/win32/advapi32/service/eventlog.c | 50 +++++++++++++++---- 1 file changed, 39 insertions(+), 11 deletions(-) diff --git a/reactos/dll/win32/advapi32/service/eventlog.c b/reactos/dll/win32/advapi32/service/eventlog.c index 18d09e11789..e2e895e7dd5 100644 --- a/reactos/dll/win32/advapi32/service/eventlog.c +++ b/reactos/dll/win32/advapi32/service/eventlog.c @@ -940,7 +940,7 @@ ReportEventA(IN HANDLE hEventLog, IN LPVOID lpRawData) { NTSTATUS Status; - ANSI_STRING *Strings; + PANSI_STRING *Strings; ANSI_STRING ComputerName; WORD i; CHAR szComputerName[MAX_COMPUTERNAME_LENGTH + 1]; @@ -951,8 +951,8 @@ ReportEventA(IN HANDLE hEventLog, wNumStrings, dwDataSize, lpStrings, lpRawData); Strings = HeapAlloc(GetProcessHeap(), - 0, - wNumStrings * sizeof(ANSI_STRING)); + HEAP_ZERO_MEMORY, + wNumStrings * sizeof(PANSI_STRING)); if (!Strings) { SetLastError(ERROR_NOT_ENOUGH_MEMORY); @@ -960,7 +960,15 @@ ReportEventA(IN HANDLE hEventLog, } for (i = 0; i < wNumStrings; i++) - RtlInitAnsiString(&Strings[i], lpStrings[i]); + { + Strings[i] = HeapAlloc(GetProcessHeap(), + HEAP_ZERO_MEMORY, + sizeof(ANSI_STRING)); + if (Strings[i]) + { + RtlInitAnsiString(Strings[i], lpStrings[i]); + } + } dwSize = MAX_COMPUTERNAME_LENGTH + 1; GetComputerNameA(szComputerName, &dwSize); @@ -975,9 +983,9 @@ ReportEventA(IN HANDLE hEventLog, dwEventID, wNumStrings, dwDataSize, - (PRPC_STRING) &ComputerName, + (PRPC_STRING)&ComputerName, lpUserSid, - (PRPC_STRING*) &Strings, + (PRPC_STRING*)Strings, lpRawData, 0, NULL, @@ -989,6 +997,12 @@ ReportEventA(IN HANDLE hEventLog, } RpcEndExcept; + for (i = 0; i < wNumStrings; i++) + { + if (Strings[i] != NULL) + HeapFree(GetProcessHeap(), 0, Strings[i]); + } + HeapFree(GetProcessHeap(), 0, Strings); if (!NT_SUCCESS(Status)) @@ -1027,7 +1041,7 @@ ReportEventW(IN HANDLE hEventLog, IN LPVOID lpRawData) { NTSTATUS Status; - UNICODE_STRING *Strings; + PUNICODE_STRING *Strings; UNICODE_STRING ComputerName; WORD i; WCHAR szComputerName[MAX_COMPUTERNAME_LENGTH + 1]; @@ -1039,7 +1053,7 @@ ReportEventW(IN HANDLE hEventLog, Strings = HeapAlloc(GetProcessHeap(), 0, - wNumStrings * sizeof(UNICODE_STRING)); + wNumStrings * sizeof(PUNICODE_STRING)); if (!Strings) { SetLastError(ERROR_NOT_ENOUGH_MEMORY); @@ -1047,7 +1061,15 @@ ReportEventW(IN HANDLE hEventLog, } for (i = 0; i < wNumStrings; i++) - RtlInitUnicodeString(&Strings[i], lpStrings[i]); + { + Strings[i] = HeapAlloc(GetProcessHeap(), + HEAP_ZERO_MEMORY, + sizeof(ANSI_STRING)); + if (Strings[i]) + { + RtlInitUnicodeString(Strings[i], lpStrings[i]); + } + } dwSize = MAX_COMPUTERNAME_LENGTH + 1; GetComputerNameW(szComputerName, &dwSize); @@ -1062,9 +1084,9 @@ ReportEventW(IN HANDLE hEventLog, dwEventID, wNumStrings, dwDataSize, - (PRPC_UNICODE_STRING) &ComputerName, + (PRPC_UNICODE_STRING)&ComputerName, lpUserSid, - (PRPC_UNICODE_STRING*) &Strings, + (PRPC_UNICODE_STRING*)Strings, lpRawData, 0, NULL, @@ -1076,6 +1098,12 @@ ReportEventW(IN HANDLE hEventLog, } RpcEndExcept; + for (i = 0; i < wNumStrings; i++) + { + if (Strings[i] != NULL) + HeapFree(GetProcessHeap(), 0, Strings[i]); + } + HeapFree(GetProcessHeap(), 0, Strings); if (!NT_SUCCESS(Status)) -- 2.17.1