WINE_DEFAULT_DEBUG_CHANNEL(advapi);
-static RPC_UNICODE_STRING EmptyString = { 0, 0, L"" };
+static RPC_UNICODE_STRING EmptyStringU = { 0, 0, L"" };
+static RPC_STRING EmptyStringA = { 0, 0, "" };
-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)
BackupFileName.Buffer = (LPSTR)lpBackupFileName;
BackupFileName.Length = BackupFileName.MaximumLength =
lpBackupFileName ? strlen(lpBackupFileName) : 0;
- BackupFileName.MaximumLength += sizeof(CHAR);
+ BackupFileName.MaximumLength += sizeof(CHAR);
RpcTryExcept
{
IN DWORD cbBufSize,
OUT LPDWORD pcbBytesNeeded)
{
- UNIMPLEMENTED;
- SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
- return FALSE;
+ NTSTATUS Status;
+
+ RpcTryExcept
+ {
+ Status = ElfrGetLogInformation(hEventLog,
+ dwInfoLevel,
+ (LPBYTE)lpBuffer,
+ cbBufSize,
+ pcbBytesNeeded);
+ }
+ RpcExcept(EXCEPTION_EXECUTE_HANDLER)
+ {
+ Status = I_RpcMapWin32Status(RpcExceptionCode());
+ }
+ RpcEndExcept;
+
+ if (!NT_SUCCESS(Status))
+ {
+ SetLastError(RtlNtStatusToDosError(Status));
+ return FALSE;
+ }
+
+ return TRUE;
}
SetLastError(ERROR_INVALID_PARAMETER);
return FALSE;
}
-
+
RpcTryExcept
{
Status = ElfrNumberOfRecords(hEventLog,
SetLastError(ERROR_INVALID_PARAMETER);
return FALSE;
}
-
+
RpcTryExcept
{
Status = ElfrOldestRecord(hEventLog,
OpenBackupEventLogA(IN LPCSTR lpUNCServerName,
IN LPCSTR lpFileName)
{
- UNICODE_STRING UNCServerName;
- UNICODE_STRING FileName;
- HANDLE Handle;
+ ANSI_STRING FileName;
+ IELF_HANDLE LogHandle;
+ NTSTATUS Status;
TRACE("%s, %s\n", lpUNCServerName, lpFileName);
- if (!RtlCreateUnicodeStringFromAsciiz(&UNCServerName, lpUNCServerName))
+ RtlInitAnsiString(&FileName, lpFileName);
+
+ RpcTryExcept
{
- SetLastError(ERROR_NOT_ENOUGH_MEMORY);
- return NULL;
+ Status = ElfrOpenBELA((LPSTR)lpUNCServerName,
+ (PRPC_STRING)&FileName,
+ 1,
+ 1,
+ &LogHandle);
+ }
+ RpcExcept(EXCEPTION_EXECUTE_HANDLER)
+ {
+ Status = I_RpcMapWin32Status(RpcExceptionCode());
}
+ RpcEndExcept;
- if (!RtlCreateUnicodeStringFromAsciiz(&FileName, lpFileName))
+ if (!NT_SUCCESS(Status))
{
- RtlFreeUnicodeString(&UNCServerName);
- SetLastError(ERROR_NOT_ENOUGH_MEMORY);
+ SetLastError(RtlNtStatusToDosError(Status));
return NULL;
}
- Handle = OpenBackupEventLogW(UNCServerName.Buffer,
- FileName.Buffer);
-
- RtlFreeUnicodeString(&UNCServerName);
- RtlFreeUnicodeString(&FileName);
-
- return Handle;
+ return (HANDLE)LogHandle;
}
* Failure: NULL
*/
HANDLE WINAPI
-OpenEventLogA(IN LPCSTR uncname,
- IN LPCSTR source)
+OpenEventLogA(IN LPCSTR lpUNCServerName,
+ IN LPCSTR lpSourceName)
{
- LPWSTR uncnameW, sourceW;
- HANDLE handle;
+ LPSTR UNCServerName;
+ ANSI_STRING SourceName;
+ IELF_HANDLE LogHandle = NULL;
+ NTSTATUS Status;
+
+ TRACE("%s, %s\n", lpUNCServerName, lpSourceName);
+
+ if (lpSourceName == NULL)
+ {
+ SetLastError(ERROR_INVALID_PARAMETER);
+ return NULL;
+ }
+
+ if (lpUNCServerName == NULL || *lpUNCServerName == 0)
+ UNCServerName = NULL;
+ else
+ UNCServerName = (LPSTR)lpUNCServerName;
+
+ RtlInitAnsiString(&SourceName, lpSourceName);
- uncnameW = SERV_dup(uncname);
- sourceW = SERV_dup(source);
- handle = OpenEventLogW(uncnameW, sourceW);
- HeapFree(GetProcessHeap(), 0, uncnameW);
- HeapFree(GetProcessHeap(), 0, sourceW);
+ RpcTryExcept
+ {
+ Status = ElfrOpenELA(UNCServerName,
+ (PRPC_STRING)&SourceName,
+ &EmptyStringA,
+ 1,
+ 1,
+ &LogHandle);
+ }
+ RpcExcept(EXCEPTION_EXECUTE_HANDLER)
+ {
+ Status = I_RpcMapWin32Status(RpcExceptionCode());
+ }
+ RpcEndExcept;
+
+ if (!NT_SUCCESS(Status))
+ {
+ SetLastError(RtlNtStatusToDosError(Status));
+ return NULL;
+ }
- return handle;
+ return (HANDLE)LogHandle;
}
OpenEventLogW(IN LPCWSTR lpUNCServerName,
IN LPCWSTR lpSourceName)
{
- RPC_UNICODE_STRING SourceName;
+ LPWSTR UNCServerName;
+ UNICODE_STRING SourceName;
IELF_HANDLE LogHandle;
NTSTATUS Status;
TRACE("%s, %s\n", debugstr_w(lpUNCServerName), debugstr_w(lpSourceName));
- SourceName.Buffer = (LPWSTR)lpSourceName;
- SourceName.Length = SourceName.MaximumLength =
- lpSourceName ? wcslen(lpSourceName) * sizeof(WCHAR) : 0;
- SourceName.MaximumLength += sizeof(WCHAR);
+ if (lpSourceName == NULL)
+ {
+ SetLastError(ERROR_INVALID_PARAMETER);
+ return NULL;
+ }
+
+ if (lpUNCServerName == NULL || *lpUNCServerName == 0)
+ UNCServerName = NULL;
+ else
+ UNCServerName = (LPWSTR)lpUNCServerName;
+
+ RtlInitUnicodeString(&SourceName, lpSourceName);
RpcTryExcept
{
- Status = ElfrOpenELW((LPWSTR)lpUNCServerName,
- &SourceName,
- &EmptyString,
+ Status = ElfrOpenELW(UNCServerName,
+ (PRPC_UNICODE_STRING)&SourceName,
+ &EmptyStringU,
1,
1,
&LogHandle);
RegisterEventSourceA(IN LPCSTR lpUNCServerName,
IN LPCSTR lpSourceName)
{
- UNICODE_STRING UNCServerName;
- UNICODE_STRING SourceName;
- HANDLE Handle;
+ ANSI_STRING SourceName;
+ IELF_HANDLE LogHandle;
+ NTSTATUS Status;
TRACE("%s, %s\n", lpUNCServerName, lpSourceName);
- if (!RtlCreateUnicodeStringFromAsciiz(&UNCServerName, lpUNCServerName))
+ RtlInitAnsiString(&SourceName, lpSourceName);
+
+ RpcTryExcept
{
- SetLastError(ERROR_NOT_ENOUGH_MEMORY);
- return NULL;
+ Status = ElfrRegisterEventSourceA((LPSTR)lpUNCServerName,
+ (PRPC_STRING)&SourceName,
+ &EmptyStringA,
+ 1,
+ 1,
+ &LogHandle);
}
+ RpcExcept(EXCEPTION_EXECUTE_HANDLER)
+ {
+ Status = I_RpcMapWin32Status(RpcExceptionCode());
+ }
+ RpcEndExcept;
- if (!RtlCreateUnicodeStringFromAsciiz(&SourceName, lpSourceName))
+ if (!NT_SUCCESS(Status))
{
- RtlFreeUnicodeString(&UNCServerName);
- SetLastError(ERROR_NOT_ENOUGH_MEMORY);
+ SetLastError(RtlNtStatusToDosError(Status));
return NULL;
}
- Handle = RegisterEventSourceW(UNCServerName.Buffer,
- SourceName.Buffer);
-
- RtlFreeUnicodeString(&UNCServerName);
- RtlFreeUnicodeString(&SourceName);
-
- return Handle;
+ return (HANDLE)LogHandle;
}
{
Status = ElfrRegisterEventSourceW((LPWSTR)lpUNCServerName,
&SourceName,
- &EmptyString,
+ &EmptyStringU,
1,
1,
&LogHandle);
IN LPCSTR *lpStrings,
IN LPVOID lpRawData)
{
- LPCWSTR *wideStrArray;
- UNICODE_STRING str;
+ NTSTATUS Status;
+ ANSI_STRING *Strings;
+ ANSI_STRING ComputerName;
WORD i;
- BOOL ret;
-
- if (wNumStrings == 0)
- return TRUE;
-
- if (lpStrings == NULL)
- return TRUE;
- wideStrArray = HeapAlloc(GetProcessHeap(),
- HEAP_ZERO_MEMORY,
- sizeof(LPCWSTR) * wNumStrings);
+ TRACE("%p, %u, %u, %lu, %p, %u, %lu, %p, %p\n",
+ hEventLog, wType, wCategory, dwEventID, lpUserSid,
+ wNumStrings, dwDataSize, lpStrings, lpRawData);
- for (i = 0; i < wNumStrings; i++)
+ Strings = HeapAlloc(GetProcessHeap(),
+ 0,
+ wNumStrings * sizeof(ANSI_STRING));
+ if (!Strings)
{
- if (!RtlCreateUnicodeStringFromAsciiz(&str, (PSTR)lpStrings[i]))
- break;
- wideStrArray[i] = str.Buffer;
+ SetLastError(ERROR_NOT_ENOUGH_MEMORY);
+ return FALSE;
}
- if (i == wNumStrings)
+ for (i = 0; i < wNumStrings; i++)
+ RtlInitAnsiString(&Strings[i], lpStrings[i]);
+
+ /*FIXME: ComputerName */
+ RtlInitAnsiString(&ComputerName, "");
+
+ RpcTryExcept
{
- ret = ReportEventW(hEventLog,
- wType,
- wCategory,
- dwEventID,
- lpUserSid,
- wNumStrings,
- dwDataSize,
- wideStrArray,
- lpRawData);
+ Status = ElfrReportEventA(hEventLog,
+ 0, /* FIXME: Time */
+ wType,
+ wCategory,
+ dwEventID,
+ wNumStrings,
+ dwDataSize,
+ (PRPC_STRING) &ComputerName,
+ lpUserSid,
+ (PRPC_STRING*) &Strings,
+ lpRawData,
+ 0,
+ NULL,
+ NULL);
}
- else
+ RpcExcept(EXCEPTION_EXECUTE_HANDLER)
{
- SetLastError(ERROR_NOT_ENOUGH_MEMORY);
- ret = FALSE;
+ Status = I_RpcMapWin32Status(RpcExceptionCode());
}
+ RpcEndExcept;
- for (i = 0; i < wNumStrings; i++)
+ HeapFree(GetProcessHeap(), 0, Strings);
+
+ if (!NT_SUCCESS(Status))
{
- if (wideStrArray[i])
- {
- HeapFree(GetProcessHeap(),
- 0,
- (PVOID)wideStrArray[i]);
- }
+ SetLastError(RtlNtStatusToDosError(Status));
+ return FALSE;
}
- HeapFree(GetProcessHeap(),
- 0,
- (PVOID)wideStrArray);
-
- return ret;
+ return TRUE;
}