Author: spetreolle
Date: Mon Jan 18 17:03:30 2010
New Revision: 45131
URL:
http://svn.reactos.org/svn/reactos?rev=45131&view=rev
Log:
[ADVAPI]
Sync OpenEventLogA with wine.
RtlCreateUnicodeStringFromAsciiz breaks null checks.
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] Mon Jan 18 17:03:30
2010
@@ -28,6 +28,18 @@
static RPC_UNICODE_STRING EmptyString = { 0, 0, L"" };
+static inline LPWSTR SERV_dup( LPCSTR str )
+{
+ UINT len;
+ LPWSTR wstr;
+
+ if( !str )
+ return NULL;
+ len = MultiByteToWideChar( CP_ACP, 0, str, -1, NULL, 0 );
+ wstr = HeapAlloc( GetProcessHeap(), 0, len*sizeof (WCHAR) );
+ MultiByteToWideChar( CP_ACP, 0, str, -1, wstr, len );
+ return wstr;
+}
handle_t __RPC_USER
EVENTLOG_HANDLE_A_bind(EVENTLOG_HANDLE_A UNCServerName)
@@ -575,35 +587,32 @@
/******************************************************************************
* OpenEventLogA [ADVAPI32.@]
+ *
+ * Opens a handle to the specified event log.
+ *
+ * PARAMS
+ * lpUNCServerName [I] UNC name of the server on which the event log is
+ * opened.
+ * lpSourceName [I] Name of the log.
+ *
+ * RETURNS
+ * Success: Handle to an event log.
+ * Failure: NULL
*/
HANDLE WINAPI
-OpenEventLogA(IN LPCSTR lpUNCServerName,
- IN LPCSTR lpSourceName)
-{
- UNICODE_STRING UNCServerName;
- UNICODE_STRING SourceName;
- HANDLE Handle;
-
- if (!RtlCreateUnicodeStringFromAsciiz(&UNCServerName, lpUNCServerName))
- {
- SetLastError(ERROR_NOT_ENOUGH_MEMORY);
- return NULL;
- }
-
- if (!RtlCreateUnicodeStringFromAsciiz(&SourceName, lpSourceName))
- {
- RtlFreeUnicodeString(&UNCServerName);
- SetLastError(ERROR_NOT_ENOUGH_MEMORY);
- return NULL;
- }
-
- Handle = OpenEventLogW(UNCServerName.Buffer,
- SourceName.Buffer);
-
- RtlFreeUnicodeString(&UNCServerName);
- RtlFreeUnicodeString(&SourceName);
-
- return Handle;
+OpenEventLogA(IN LPCSTR uncname,
+ IN LPCSTR source)
+{
+ LPWSTR uncnameW, sourceW;
+ HANDLE handle;
+
+ uncnameW = SERV_dup(uncname);
+ sourceW = SERV_dup(source);
+ handle = OpenEventLogW(uncnameW, sourceW);
+ HeapFree(GetProcessHeap(), 0, uncnameW);
+ HeapFree(GetProcessHeap(), 0, sourceW);
+
+ return handle;
}