Author: ekohl
Date: Sun Jan 8 10:08:33 2012
New Revision: 54878
URL:
http://svn.reactos.org/svn/reactos?rev=54878&view=rev
Log:
[ADVAPI32]
Pass an NT path to ElfrOpenBELW.
Modified:
trunk/reactos/dll/win32/advapi32/service/eventlog.c
Modified: trunk/reactos/dll/win32/advapi32/service/eventlog.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/advapi32/service…
==============================================================================
--- trunk/reactos/dll/win32/advapi32/service/eventlog.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/advapi32/service/eventlog.c [iso-8859-1] Sun Jan 8 10:08:33
2012
@@ -551,18 +551,101 @@
OpenBackupEventLogA(IN LPCSTR lpUNCServerName,
IN LPCSTR lpFileName)
{
- ANSI_STRING FileName;
+ ANSI_STRING UNCServerNameA;
+ UNICODE_STRING UNCServerNameW;
+ ANSI_STRING FileNameA;
+ UNICODE_STRING FileNameW;
+ HANDLE LogHandle;
+ NTSTATUS Status;
+
+ TRACE("%s, %s\n", lpUNCServerName, lpFileName);
+
+ /* Convert the server name to unicode */
+ if (lpUNCServerName == NULL)
+ {
+ RtlInitUnicodeString(&UNCServerNameW, NULL);
+ }
+ else
+ {
+ RtlInitAnsiString(&UNCServerNameA, lpUNCServerName);
+
+ Status = RtlAnsiStringToUnicodeString(&UNCServerNameW,
+ &UNCServerNameA,
+ TRUE);
+ if (!NT_SUCCESS(Status))
+ {
+ SetLastError(RtlNtStatusToDosError(Status));
+ return NULL;
+ }
+ }
+
+ /* Convert the file name to unicode */
+ if (lpFileName == NULL)
+ {
+ RtlInitUnicodeString(&FileNameW, NULL);
+ }
+ else
+ {
+ RtlInitAnsiString(&FileNameA, lpFileName);
+
+ Status = RtlAnsiStringToUnicodeString(&FileNameW,
+ &FileNameA,
+ TRUE);
+ if (!NT_SUCCESS(Status))
+ {
+ RtlFreeUnicodeString(&UNCServerNameW);
+ SetLastError(RtlNtStatusToDosError(Status));
+ return NULL;
+ }
+ }
+
+ /* Call the unicode function */
+ LogHandle = OpenBackupEventLogW(UNCServerNameW.Buffer,
+ FileNameW.Buffer);
+
+ /* Free the unicode strings */
+ RtlFreeUnicodeString(&UNCServerNameW);
+ RtlFreeUnicodeString(&FileNameW);
+
+ return LogHandle;
+}
+
+
+/******************************************************************************
+ * OpenBackupEventLogW [ADVAPI32.@]
+ *
+ * PARAMS
+ * lpUNCServerName []
+ * lpFileName []
+ */
+HANDLE WINAPI
+OpenBackupEventLogW(IN LPCWSTR lpUNCServerName,
+ IN LPCWSTR lpFileName)
+{
+ UNICODE_STRING FileNameW;
IELF_HANDLE LogHandle;
NTSTATUS Status;
- TRACE("%s, %s\n", lpUNCServerName, lpFileName);
-
- RtlInitAnsiString(&FileName, lpFileName);
-
- RpcTryExcept
- {
- Status = ElfrOpenBELA((LPSTR)lpUNCServerName,
- (PRPC_STRING)&FileName,
+ TRACE("%s, %s\n", debugstr_w(lpUNCServerName), debugstr_w(lpFileName));
+
+ if (lpFileName == NULL)
+ {
+ RtlInitUnicodeString(&FileNameW, NULL);
+ }
+ else
+ {
+ if (!RtlDosPathNameToNtPathName_U(lpFileName, &FileNameW,
+ NULL, NULL))
+ {
+ SetLastError(ERROR_INVALID_PARAMETER);
+ return NULL;
+ }
+ }
+
+ RpcTryExcept
+ {
+ Status = ElfrOpenBELW((LPWSTR)lpUNCServerName,
+ (PRPC_UNICODE_STRING)&FileNameW,
1,
1,
&LogHandle);
@@ -573,48 +656,8 @@
}
RpcEndExcept;
- if (!NT_SUCCESS(Status))
- {
- SetLastError(RtlNtStatusToDosError(Status));
- return NULL;
- }
-
- return (HANDLE)LogHandle;
-}
-
-
-/******************************************************************************
- * OpenBackupEventLogW [ADVAPI32.@]
- *
- * PARAMS
- * lpUNCServerName []
- * lpFileName []
- */
-HANDLE WINAPI
-OpenBackupEventLogW(IN LPCWSTR lpUNCServerName,
- IN LPCWSTR lpFileName)
-{
- UNICODE_STRING FileName;
- IELF_HANDLE LogHandle;
- NTSTATUS Status;
-
- TRACE("%s, %s\n", debugstr_w(lpUNCServerName), debugstr_w(lpFileName));
-
- RtlInitUnicodeString(&FileName, lpFileName);
-
- RpcTryExcept
- {
- Status = ElfrOpenBELW((LPWSTR)lpUNCServerName,
- (PRPC_UNICODE_STRING)&FileName,
- 1,
- 1,
- &LogHandle);
- }
- RpcExcept(EXCEPTION_EXECUTE_HANDLER)
- {
- Status = I_RpcMapWin32Status(RpcExceptionCode());
- }
- RpcEndExcept;
+ if (FileNameW.Buffer != NULL)
+ RtlFreeHeap(RtlGetProcessHeap(), 0, FileNameW.Buffer);
if (!NT_SUCCESS(Status))
{