Author: ekohl
Date: Fri Oct 31 17:18:12 2008
New Revision: 37116
URL:
http://svn.reactos.org/svn/reactos?rev=37116&view=rev
Log:
EVENTLOG:
- Get rid of the globally created binding handle and use the WIDL-generated custom binding
handles and context handles instead.
- Add workarounds to eventlogrpc.idl because WIDL is not yet able to handle attributes in
typedefs correctly.
Modified:
trunk/reactos/base/services/eventlog/rpc.c
trunk/reactos/dll/win32/advapi32/service/eventlog.c
trunk/reactos/dll/win32/advapi32/service/rpc.c
trunk/reactos/include/reactos/idl/eventlogrpc.idl
Modified: trunk/reactos/base/services/eventlog/rpc.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/services/eventlog/rpc…
==============================================================================
--- trunk/reactos/base/services/eventlog/rpc.c [iso-8859-1] (original)
+++ trunk/reactos/base/services/eventlog/rpc.c [iso-8859-1] Fri Oct 31 17:18:12 2008
@@ -44,7 +44,6 @@
/* Function 0 */
NTSTATUS ElfrClearELFW(
- handle_t BindingHandle,
IELF_HANDLE LogHandle,
PRPC_UNICODE_STRING BackupFileName)
{
@@ -55,7 +54,6 @@
/* Function 1 */
NTSTATUS ElfrBackupELFW(
- handle_t BindingHandle,
IELF_HANDLE LogHandle,
PRPC_UNICODE_STRING BackupFileName)
{
@@ -66,7 +64,6 @@
/* Function 2 */
NTSTATUS ElfrCloseEL(
- handle_t BindingHandle,
IELF_HANDLE *LogHandle)
{
UNIMPLEMENTED;
@@ -76,7 +73,6 @@
/* Function 3 */
NTSTATUS ElfrDeregisterEventSource(
- handle_t BindingHandle,
IELF_HANDLE *LogHandle)
{
UNIMPLEMENTED;
@@ -86,7 +82,6 @@
/* Function 4 */
NTSTATUS ElfrNumberOfRecords(
- handle_t BindingHandle,
IELF_HANDLE LogHandle,
DWORD *NumberOfRecords)
{
@@ -97,7 +92,6 @@
/* Function 5 */
NTSTATUS ElfrOldestRecord(
- handle_t BindingHandle,
IELF_HANDLE LogHandle,
DWORD *OldestRecordNumber)
{
@@ -108,7 +102,6 @@
/* Function 6 */
NTSTATUS ElfrChangeNotify(
- handle_t BindingHandle,
IELF_HANDLE *LogHandle,
RPC_CLIENT_ID ClientId,
DWORD Event)
@@ -120,7 +113,6 @@
/* Function 7 */
NTSTATUS ElfrOpenELW(
- handle_t BindingHandle,
EVENTLOG_HANDLE_W UNCServerName,
PRPC_UNICODE_STRING ModuleName,
PRPC_UNICODE_STRING RegModuleName,
@@ -136,7 +128,6 @@
/* Function 8 */
NTSTATUS ElfrRegisterEventSourceW(
- handle_t BindingHandle,
EVENTLOG_HANDLE_W UNCServerName,
PRPC_UNICODE_STRING ModuleName,
PRPC_UNICODE_STRING RegModuleName,
@@ -152,7 +143,6 @@
/* Function 9 */
NTSTATUS ElfrOpenBELW(
- handle_t BindingHandle,
EVENTLOG_HANDLE_W UNCServerName,
PRPC_UNICODE_STRING BackupFileName,
DWORD MajorVersion,
@@ -166,7 +156,6 @@
/* Function 10 */
NTSTATUS ElfrReadELW(
- handle_t BindingHandle,
IELF_HANDLE LogHandle,
DWORD ReadFlags,
DWORD RecordOffset,
@@ -182,7 +171,6 @@
/* Function 11 */
NTSTATUS ElfrReportEventW(
- handle_t BindingHandle,
IELF_HANDLE LogHandle,
DWORD Time,
USHORT EventType,
@@ -233,7 +221,6 @@
/* Function 12 */
NTSTATUS ElfrClearELFA(
- handle_t BindingHandle,
IELF_HANDLE LogHandle,
PRPC_STRING BackupFileName)
{
@@ -244,7 +231,6 @@
/* Function 13 */
NTSTATUS ElfrBackupELFA(
- handle_t BindingHandle,
IELF_HANDLE LogHandle,
PRPC_STRING BackupFileName)
{
@@ -255,7 +241,6 @@
/* Function 14 */
NTSTATUS ElfrOpenELA(
- handle_t BindingHandle,
EVENTLOG_HANDLE_A UNCServerName,
PRPC_STRING ModuleName,
PRPC_STRING RegModuleName,
@@ -290,7 +275,6 @@
}
Status = ElfrOpenELW(
- BindingHandle,
UNCServerName ? UNCServerNameW.Buffer : NULL,
ModuleName ? (PRPC_UNICODE_STRING)&ModuleNameW : NULL,
RegModuleName ? (PRPC_UNICODE_STRING)&RegModuleNameW : NULL,
@@ -308,7 +292,6 @@
/* Function 15 */
NTSTATUS ElfrRegisterEventSourceA(
- handle_t BindingHandle,
EVENTLOG_HANDLE_A UNCServerName,
PRPC_STRING ModuleName,
PRPC_STRING RegModuleName,
@@ -323,7 +306,6 @@
/* Function 16 */
NTSTATUS ElfrOpenBELA(
- handle_t BindingHandle,
EVENTLOG_HANDLE_A UNCServerName,
PRPC_STRING BackupFileName,
DWORD MajorVersion,
@@ -337,7 +319,6 @@
/* Function 17 */
NTSTATUS ElfrReadELA(
- handle_t BindingHandle,
IELF_HANDLE LogHandle,
DWORD ReadFlags,
DWORD RecordOffset,
@@ -353,7 +334,6 @@
/* Function 18 */
NTSTATUS ElfrReportEventA(
- handle_t BindingHandle,
IELF_HANDLE LogHandle,
DWORD Time,
USHORT EventType,
@@ -403,7 +383,6 @@
/* Function 22 */
NTSTATUS ElfrGetLogInformation(
- handle_t BindingHandle,
IELF_HANDLE LogHandle,
DWORD InfoLevel,
BYTE *Buffer,
@@ -417,7 +396,6 @@
/* Function 23 */
NTSTATUS ElfrFlushEL(
- handle_t BindingHandle,
IELF_HANDLE LogHandle)
{
UNIMPLEMENTED;
@@ -427,7 +405,6 @@
/* Function 24 */
NTSTATUS ElfrReportEventAndSourceW(
- handle_t BindingHandle,
IELF_HANDLE LogHandle,
DWORD Time,
USHORT EventType,
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] Fri Oct 31 17:18:12
2008
@@ -27,14 +27,118 @@
WINE_DEFAULT_DEBUG_CHANNEL(advapi);
WINE_DECLARE_DEBUG_CHANNEL(eventlog);
-typedef struct _LOG_INFO
-{
- RPC_BINDING_HANDLE BindingHandle;
- IELF_HANDLE LogHandle;
- BOOL bLocal;
-} LOG_INFO, *PLOG_INFO;
-
static RPC_UNICODE_STRING EmptyString = { 0, 0, L"" };
+
+
+handle_t __RPC_USER
+EVENTLOG_HANDLE_A_bind(EVENTLOG_HANDLE_A UNCServerName)
+{
+ handle_t hBinding = NULL;
+ UCHAR *pszStringBinding;
+ RPC_STATUS status;
+
+ TRACE("EVENTLOG_HANDLE_A_bind() called\n");
+
+ status = RpcStringBindingComposeA(NULL,
+ (UCHAR *)"ncacn_np",
+ (UCHAR *)UNCServerName,
+ (UCHAR *)"\\pipe\\ntsvcs",
+ NULL,
+ (UCHAR **)&pszStringBinding);
+ if (status)
+ {
+ ERR("RpcStringBindingCompose returned 0x%x\n", status);
+ return NULL;
+ }
+
+ /* Set the binding handle that will be used to bind to the server. */
+ status = RpcBindingFromStringBindingA(pszStringBinding,
+ &hBinding);
+ if (status)
+ {
+ ERR("RpcBindingFromStringBinding returned 0x%x\n", status);
+ }
+
+ status = RpcStringFreeA(&pszStringBinding);
+ if (status)
+ {
+ ERR("RpcStringFree returned 0x%x\n", status);
+ }
+
+ return hBinding;
+}
+
+
+void __RPC_USER
+EVENTLOG_HANDLE_A_unbind(EVENTLOG_HANDLE_A UNCServerName,
+ handle_t hBinding)
+{
+ RPC_STATUS status;
+
+ TRACE("EVENTLOG_HANDLE_A_unbind() called\n");
+
+ status = RpcBindingFree(&hBinding);
+ if (status)
+ {
+ ERR("RpcBindingFree returned 0x%x\n", status);
+ }
+}
+
+
+handle_t __RPC_USER
+EVENTLOG_HANDLE_W_bind(EVENTLOG_HANDLE_W UNCServerName)
+{
+ handle_t hBinding = NULL;
+ LPWSTR pszStringBinding;
+ RPC_STATUS status;
+
+ TRACE("EVENTLOG_HANDLE_W_bind() called\n");
+
+ status = RpcStringBindingComposeW(NULL,
+ L"ncacn_np",
+ (LPWSTR)UNCServerName,
+ L"\\pipe\\EventLog",
+ NULL,
+ &pszStringBinding);
+ if (status)
+ {
+ ERR("RpcStringBindingCompose returned 0x%x\n", status);
+ return NULL;
+ }
+
+ /* Set the binding handle that will be used to bind to the server. */
+ status = RpcBindingFromStringBindingW(pszStringBinding,
+ &hBinding);
+ if (status)
+ {
+ ERR("RpcBindingFromStringBinding returned 0x%x\n", status);
+ }
+
+ status = RpcStringFreeW(&pszStringBinding);
+ if (status)
+ {
+ ERR("RpcStringFree returned 0x%x\n", status);
+ }
+
+ return hBinding;
+}
+
+
+void __RPC_USER
+EVENTLOG_HANDLE_W_unbind(EVENTLOG_HANDLE_W UNCServerName,
+ handle_t hBinding)
+{
+ RPC_STATUS status;
+
+ TRACE("EVENTLOG_HANDLE_W_unbind() called\n");
+
+ status = RpcBindingFree(&hBinding);
+ if (status)
+ {
+ ERR("RpcBindingFree returned 0x%x\n", status);
+ }
+}
+
/******************************************************************************
* BackupEventLogA [ADVAPI32.@]
@@ -43,9 +147,8 @@
BackupEventLogA(IN HANDLE hEventLog,
IN LPCSTR lpBackupFileName)
{
- PLOG_INFO pLog;
- NTSTATUS Status;
RPC_STRING BackupFileName;
+ NTSTATUS Status;
TRACE("%p, %s\n", hEventLog, lpBackupFileName);
@@ -53,15 +156,7 @@
BackupFileName.Length = BackupFileName.MaximumLength =
lpBackupFileName ? strlen(lpBackupFileName) : 0;
- pLog = (PLOG_INFO)hEventLog;
- if (!pLog)
- {
- SetLastError(ERROR_INVALID_HANDLE);
- return FALSE;
- }
-
- Status = ElfrBackupELFA(pLog->BindingHandle,
- pLog->LogHandle,
+ Status = ElfrBackupELFA(hEventLog,
&BackupFileName);
if (!NT_SUCCESS(Status))
{
@@ -83,9 +178,8 @@
BackupEventLogW(IN HANDLE hEventLog,
IN LPCWSTR lpBackupFileName)
{
- PLOG_INFO pLog;
- NTSTATUS Status;
RPC_UNICODE_STRING BackupFileName;
+ NTSTATUS Status;
TRACE("%p, %s\n", hEventLog, debugstr_w(lpBackupFileName));
@@ -93,15 +187,7 @@
BackupFileName.Length = BackupFileName.MaximumLength =
lpBackupFileName ? wcslen(lpBackupFileName) * sizeof(WCHAR) : 0;
- pLog = (PLOG_INFO)hEventLog;
- if (!pLog)
- {
- SetLastError(ERROR_INVALID_HANDLE);
- return FALSE;
- }
-
- Status = ElfrBackupELFW(pLog->BindingHandle,
- pLog->LogHandle,
+ Status = ElfrBackupELFW(hEventLog,
&BackupFileName);
if (!NT_SUCCESS(Status))
{
@@ -120,9 +206,8 @@
ClearEventLogA(IN HANDLE hEventLog,
IN LPCSTR lpBackupFileName)
{
- PLOG_INFO pLog;
- NTSTATUS Status;
RPC_STRING BackupFileName;
+ NTSTATUS Status;
TRACE("%p, %s\n", hEventLog, lpBackupFileName);
@@ -130,15 +215,7 @@
BackupFileName.Length = BackupFileName.MaximumLength =
lpBackupFileName ? strlen(lpBackupFileName) : 0;
- pLog = (PLOG_INFO)hEventLog;
- if (!pLog)
- {
- SetLastError(ERROR_INVALID_HANDLE);
- return FALSE;
- }
-
- Status = ElfrClearELFA(pLog->BindingHandle,
- pLog->LogHandle,
+ Status = ElfrClearELFA(hEventLog,
&BackupFileName);
if (!NT_SUCCESS(Status))
{
@@ -157,9 +234,8 @@
ClearEventLogW(IN HANDLE hEventLog,
IN LPCWSTR lpBackupFileName)
{
- PLOG_INFO pLog;
- NTSTATUS Status;
RPC_UNICODE_STRING BackupFileName;
+ NTSTATUS Status;
TRACE("%p, %s\n", hEventLog, debugstr_w(lpBackupFileName));
@@ -167,15 +243,7 @@
BackupFileName.Length = BackupFileName.MaximumLength =
lpBackupFileName ? wcslen(lpBackupFileName) * sizeof(WCHAR) : 0;
- pLog = (PLOG_INFO)hEventLog;
- if (!pLog)
- {
- SetLastError(ERROR_INVALID_HANDLE);
- return FALSE;
- }
-
- Status = ElfrClearELFW(pLog->BindingHandle,
- pLog->LogHandle,
+ Status = ElfrClearELFW(hEventLog,
&BackupFileName);
if (!NT_SUCCESS(Status))
{
@@ -193,35 +261,16 @@
BOOL WINAPI
CloseEventLog(IN HANDLE hEventLog)
{
- PLOG_INFO pLog;
NTSTATUS Status;
TRACE("%p\n", hEventLog);
- pLog = (PLOG_INFO)hEventLog;
- if (!pLog)
- return TRUE;
-
- if (pLog->bLocal == FALSE)
- {
- if (!EvtUnbindRpc(pLog->BindingHandle))
- {
- SetLastError(ERROR_ACCESS_DENIED);
- return FALSE;
- }
- }
- else
- {
- Status = ElfrCloseEL(pLog->BindingHandle,
- &pLog->LogHandle);
- if (!NT_SUCCESS(Status))
- {
- SetLastError(RtlNtStatusToDosError(Status));
- return FALSE;
- }
- }
-
- HeapFree(GetProcessHeap(), 0, pLog);
+ Status = ElfrCloseEL(&hEventLog);
+ if (!NT_SUCCESS(Status))
+ {
+ SetLastError(RtlNtStatusToDosError(Status));
+ return FALSE;
+ }
return TRUE;
}
@@ -239,17 +288,11 @@
BOOL WINAPI
DeregisterEventSource(IN HANDLE hEventLog)
{
- PLOG_INFO pLog;
NTSTATUS Status;
TRACE("%p\n", hEventLog);
- pLog = (PLOG_INFO)hEventLog;
- if (!pLog)
- return TRUE;
-
- Status = ElfrDeregisterEventSource(pLog->BindingHandle,
- &pLog->LogHandle);
+ Status = ElfrDeregisterEventSource(&hEventLog);
if (!NT_SUCCESS(Status))
{
SetLastError(RtlNtStatusToDosError(Status));
@@ -271,21 +314,12 @@
GetNumberOfEventLogRecords(IN HANDLE hEventLog,
OUT PDWORD NumberOfRecords)
{
- PLOG_INFO pLog;
NTSTATUS Status;
DWORD Records;
TRACE("%p, %p\n", hEventLog, NumberOfRecords);
- pLog = (PLOG_INFO)hEventLog;
- if (!pLog)
- {
- SetLastError(ERROR_INVALID_HANDLE);
- return FALSE;
- }
-
- Status = ElfrNumberOfRecords(pLog->BindingHandle,
- pLog->LogHandle,
+ Status = ElfrNumberOfRecords(hEventLog,
&Records);
if (!NT_SUCCESS(Status))
{
@@ -310,21 +344,12 @@
GetOldestEventLogRecord(IN HANDLE hEventLog,
OUT PDWORD OldestRecord)
{
- PLOG_INFO pLog;
NTSTATUS Status;
DWORD Oldest;
TRACE("%p, %p\n", hEventLog, OldestRecord);
- pLog = (PLOG_INFO)hEventLog;
- if (!pLog)
- {
- SetLastError(ERROR_INVALID_HANDLE);
- return FALSE;
- }
-
- Status = ElfrOldestRecord(pLog->BindingHandle,
- pLog->LogHandle,
+ Status = ElfrOldestRecord(hEventLog,
&Oldest);
if (!NT_SUCCESS(Status))
{
@@ -403,9 +428,9 @@
OpenBackupEventLogW(IN LPCWSTR lpUNCServerName,
IN LPCWSTR lpFileName)
{
- PLOG_INFO pLog;
- NTSTATUS Status;
RPC_UNICODE_STRING FileName;
+ IELF_HANDLE LogHandle;
+ NTSTATUS Status;
TRACE("%s, %s\n", debugstr_w(lpUNCServerName), debugstr_w(lpFileName));
@@ -413,52 +438,18 @@
FileName.Length = FileName.MaximumLength =
lpFileName ? wcslen(lpFileName) * sizeof(WCHAR) : 0;
- pLog = HeapAlloc(GetProcessHeap(), 0, sizeof(LOG_INFO));
- if (!pLog)
- {
- SetLastError(ERROR_NOT_ENOUGH_MEMORY);
- return NULL;
- }
-
- ZeroMemory(pLog, sizeof(LOG_INFO));
-
- if (lpUNCServerName == NULL || *lpUNCServerName == 0)
- {
- pLog->bLocal = TRUE;
-
- if (!EvtGetLocalHandle(&pLog->BindingHandle))
- {
- HeapFree(GetProcessHeap(), 0, pLog);
- SetLastError(ERROR_GEN_FAILURE);
- return NULL;
- }
- }
- else
- {
- pLog->bLocal = FALSE;
-
- if (!EvtBindRpc(lpUNCServerName, &pLog->BindingHandle))
- {
- HeapFree(GetProcessHeap(), 0, pLog);
- SetLastError(ERROR_INVALID_COMPUTERNAME);
- return NULL;
- }
- }
-
- Status = ElfrOpenBELW(pLog->BindingHandle,
- (LPWSTR)lpUNCServerName,
+ Status = ElfrOpenBELW((LPWSTR)lpUNCServerName,
&FileName,
0,
0,
- &pLog->LogHandle);
- if (!NT_SUCCESS(Status))
- {
- SetLastError(RtlNtStatusToDosError(Status));
- HeapFree(GetProcessHeap(), 0, pLog);
- return NULL;
- }
-
- return pLog;
+ &LogHandle);
+ if (!NT_SUCCESS(Status))
+ {
+ SetLastError(RtlNtStatusToDosError(Status));
+ return NULL;
+ }
+
+ return (HANDLE)LogHandle;
}
@@ -507,9 +498,9 @@
OpenEventLogW(IN LPCWSTR lpUNCServerName,
IN LPCWSTR lpSourceName)
{
- PLOG_INFO pLog;
- NTSTATUS Status;
RPC_UNICODE_STRING SourceName;
+ IELF_HANDLE LogHandle;
+ NTSTATUS Status;
TRACE("%s, %s\n", debugstr_w(lpUNCServerName), debugstr_w(lpSourceName));
@@ -517,53 +508,19 @@
SourceName.Length = SourceName.MaximumLength =
lpSourceName ? wcslen(lpSourceName) * sizeof(WCHAR) : 0;
- pLog = HeapAlloc(GetProcessHeap(), 0, sizeof(LOG_INFO));
- if (!pLog)
- {
- SetLastError(ERROR_NOT_ENOUGH_MEMORY);
- return NULL;
- }
-
- ZeroMemory(pLog, sizeof(LOG_INFO));
-
- if (lpUNCServerName == NULL || *lpUNCServerName == 0)
- {
- pLog->bLocal = TRUE;
-
- if (!EvtGetLocalHandle(&pLog->BindingHandle))
- {
- HeapFree(GetProcessHeap(), 0, pLog);
- SetLastError(ERROR_GEN_FAILURE);
- return NULL;
- }
- }
- else
- {
- pLog->bLocal = FALSE;
-
- if (!EvtBindRpc(lpUNCServerName, &pLog->BindingHandle))
- {
- HeapFree(GetProcessHeap(), 0, pLog);
- SetLastError(ERROR_INVALID_COMPUTERNAME);
- return NULL;
- }
- }
-
- Status = ElfrOpenELW(pLog->BindingHandle,
- (LPWSTR)lpUNCServerName,
+ Status = ElfrOpenELW((LPWSTR)lpUNCServerName,
&SourceName,
&EmptyString,
0,
0,
- &pLog->LogHandle);
- if (!NT_SUCCESS(Status))
- {
- SetLastError(RtlNtStatusToDosError(Status));
- HeapFree(GetProcessHeap(), 0, pLog);
- return NULL;
- }
-
- return pLog;
+ &LogHandle);
+ if (!NT_SUCCESS(Status))
+ {
+ SetLastError(RtlNtStatusToDosError(Status));
+ return NULL;
+ }
+
+ return (HANDLE)LogHandle;
}
@@ -579,7 +536,6 @@
OUT DWORD *pnBytesRead,
OUT DWORD *pnMinNumberOfBytesNeeded)
{
- PLOG_INFO pLog;
NTSTATUS Status;
DWORD bytesRead, minNumberOfBytesNeeded;
@@ -587,15 +543,7 @@
hEventLog, dwReadFlags, dwRecordOffset, lpBuffer,
nNumberOfBytesToRead, pnBytesRead, pnMinNumberOfBytesNeeded);
- pLog = (PLOG_INFO)hEventLog;
- if (!pLog)
- {
- SetLastError(ERROR_INVALID_HANDLE);
- return FALSE;
- }
-
- Status = ElfrReadELA(pLog->BindingHandle,
- pLog->LogHandle,
+ Status = ElfrReadELA(hEventLog,
dwReadFlags,
dwRecordOffset,
nNumberOfBytesToRead,
@@ -636,7 +584,6 @@
OUT DWORD *pnBytesRead,
OUT DWORD *pnMinNumberOfBytesNeeded)
{
- PLOG_INFO pLog;
NTSTATUS Status;
DWORD bytesRead, minNumberOfBytesNeeded;
@@ -644,15 +591,7 @@
hEventLog, dwReadFlags, dwRecordOffset, lpBuffer,
nNumberOfBytesToRead, pnBytesRead, pnMinNumberOfBytesNeeded);
- pLog = (PLOG_INFO)hEventLog;
- if (!pLog)
- {
- SetLastError(ERROR_INVALID_HANDLE);
- return FALSE;
- }
-
- Status = ElfrReadELW(pLog->BindingHandle,
- pLog->LogHandle,
+ Status = ElfrReadELW(hEventLog,
dwReadFlags,
dwRecordOffset,
nNumberOfBytesToRead,
@@ -724,9 +663,9 @@
RegisterEventSourceW(IN LPCWSTR lpUNCServerName,
IN LPCWSTR lpSourceName)
{
- PLOG_INFO pLog;
- NTSTATUS Status;
RPC_UNICODE_STRING SourceName;
+ IELF_HANDLE LogHandle;
+ NTSTATUS Status;
TRACE("%s, %s\n", debugstr_w(lpUNCServerName), debugstr_w(lpSourceName));
@@ -734,53 +673,19 @@
SourceName.Length = SourceName.MaximumLength =
lpSourceName ? wcslen(lpSourceName) * sizeof(WCHAR) : 0;
- pLog = HeapAlloc(GetProcessHeap(), 0, sizeof(LOG_INFO));
- if (!pLog)
- {
- SetLastError(ERROR_NOT_ENOUGH_MEMORY);
- return NULL;
- }
-
- ZeroMemory(pLog, sizeof(LOG_INFO));
-
- if (lpUNCServerName == NULL || *lpUNCServerName == 0)
- {
- pLog->bLocal = TRUE;
-
- if (!EvtGetLocalHandle(&pLog->BindingHandle))
- {
- HeapFree(GetProcessHeap(), 0, pLog);
- SetLastError(ERROR_GEN_FAILURE);
- return NULL;
- }
- }
- else
- {
- pLog->bLocal = FALSE;
-
- if (!EvtBindRpc(lpUNCServerName, &pLog->BindingHandle))
- {
- HeapFree(GetProcessHeap(), 0, pLog);
- SetLastError(ERROR_INVALID_COMPUTERNAME);
- return NULL;
- }
- }
-
- Status = ElfrRegisterEventSourceW(pLog->BindingHandle,
- (LPWSTR)lpUNCServerName,
+ Status = ElfrRegisterEventSourceW((LPWSTR)lpUNCServerName,
&SourceName,
&EmptyString,
0,
0,
- &pLog->LogHandle);
- if (!NT_SUCCESS(Status))
- {
- SetLastError(RtlNtStatusToDosError(Status));
- HeapFree(GetProcessHeap(), 0, pLog);
- return NULL;
- }
-
- return pLog;
+ &LogHandle);
+ if (!NT_SUCCESS(Status))
+ {
+ SetLastError(RtlNtStatusToDosError(Status));
+ return NULL;
+ }
+
+ return (HANDLE)LogHandle;
}
@@ -882,7 +787,6 @@
IN LPVOID lpRawData)
{
#if 0
- PLOG_INFO pLog;
NTSTATUS Status;
UNICODE_STRING *Strings;
WORD i;
@@ -890,13 +794,6 @@
TRACE("%p, %u, %u, %lu, %p, %u, %lu, %p, %p\n",
hEventLog, wType, wCategory, dwEventID, lpUserSid,
wNumStrings, dwDataSize, lpStrings, lpRawData);
-
- pLog = (PLOG_INFO)hEventLog;
- if (!pLog)
- {
- SetLastError(ERROR_INVALID_HANDLE);
- return FALSE;
- }
Strings = HeapAlloc(GetProcessHeap(),
0,
@@ -910,8 +807,7 @@
for (i = 0; i < wNumStrings; i++)
RtlInitUnicodeString(&Strings[i], lpStrings[i]);
- Status = ElfrReportEventW(pLog->BindingHandle,
- pLog->LogHandle,
+ Status = ElfrReportEventW(hEventLog,
0, /* FIXME: Time */
wType,
wCategory,
Modified: trunk/reactos/dll/win32/advapi32/service/rpc.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/advapi32/service…
==============================================================================
--- trunk/reactos/dll/win32/advapi32/service/rpc.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/advapi32/service/rpc.c [iso-8859-1] Fri Oct 31 17:18:12 2008
@@ -10,69 +10,6 @@
#include <advapi32.h>
-static RPC_BINDING_HANDLE LocalBindingHandle = NULL;
-
-RPC_STATUS
-EvtBindRpc(LPCWSTR pszMachine,
- RPC_BINDING_HANDLE* BindingHandle)
-{
- PWSTR pszStringBinding = NULL;
- RPC_STATUS Status;
-
- Status = RpcStringBindingComposeW(NULL,
- L"ncacn_np",
- (LPWSTR)pszMachine,
- L"\\pipe\\EventLog",
- NULL,
- &pszStringBinding);
- if (Status != RPC_S_OK)
- return Status;
-
- Status = RpcBindingFromStringBindingW(pszStringBinding,
- BindingHandle);
-
- RpcStringFreeW(&pszStringBinding);
-
- return Status;
-}
-
-RPC_STATUS
-EvtUnbindRpc(RPC_BINDING_HANDLE *BindingHandle)
-{
- if (BindingHandle != NULL)
- {
- RpcBindingFree(*BindingHandle);
- *BindingHandle = NULL;
- }
-
- return RPC_S_OK;
-}
-
-BOOL
-EvtGetLocalHandle(RPC_BINDING_HANDLE *BindingHandle)
-{
- if (LocalBindingHandle != NULL)
- {
- if (BindingHandle != NULL)
- *BindingHandle = LocalBindingHandle;
-
- return TRUE;
- }
-
- if (EvtBindRpc(NULL, &LocalBindingHandle) != RPC_S_OK)
- return FALSE;
-
- if (BindingHandle != NULL)
- *BindingHandle = LocalBindingHandle;
-
- return TRUE;
-}
-
-RPC_STATUS
-EvtUnbindLocalHandle(VOID)
-{
- return EvtUnbindRpc(&LocalBindingHandle);
-}
void __RPC_FAR * __RPC_USER
midl_user_allocate(size_t len)
Modified: trunk/reactos/include/reactos/idl/eventlogrpc.idl
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/reactos/idl/eventl…
==============================================================================
--- trunk/reactos/include/reactos/idl/eventlogrpc.idl [iso-8859-1] (original)
+++ trunk/reactos/include/reactos/idl/eventlogrpc.idl [iso-8859-1] Fri Oct 31 17:18:12
2008
@@ -17,10 +17,10 @@
[size_is(MaximumLength), length_is(Length)] LPSTR Buffer;
} RPC_STRING, *PRPC_STRING;
-typedef /*[context_handle]*/ unsigned long IELF_HANDLE;
+typedef [context_handle] PVOID IELF_HANDLE;
typedef IELF_HANDLE *PIELF_HANDLE;
-typedef /*[handle, unique]*/ LPWSTR EVENTLOG_HANDLE_W;
-typedef /*[handle, unique]*/ LPSTR EVENTLOG_HANDLE_A;
+typedef [handle, unique] LPWSTR EVENTLOG_HANDLE_W;
+typedef [handle, unique] LPSTR EVENTLOG_HANDLE_A;
typedef struct _RPC_CLIENT_ID {
DWORD UniqueProcess;
@@ -40,65 +40,41 @@
{
/* Function 0 */
NTSTATUS ElfrClearELFW(
-#ifndef __midl
- [in] handle_t BindingHandle,
-#endif
[in] IELF_HANDLE LogHandle,
[in, unique] PRPC_UNICODE_STRING BackupFileName);
/* Function 1 */
NTSTATUS ElfrBackupELFW(
-#ifndef __midl
- [in] handle_t BindingHandle,
-#endif
[in] IELF_HANDLE LogHandle,
[in, unique] PRPC_UNICODE_STRING BackupFileName);
/* Function 2 */
NTSTATUS ElfrCloseEL(
-#ifndef __midl
- [in] handle_t BindingHandle,
-#endif
[in, out] IELF_HANDLE *LogHandle);
/* Function 3 */
NTSTATUS ElfrDeregisterEventSource(
-#ifndef __midl
- [in] handle_t BindingHandle,
-#endif
[in, out] IELF_HANDLE *LogHandle);
/* Function 4 */
NTSTATUS ElfrNumberOfRecords(
-#ifndef __midl
- [in] handle_t BindingHandle,
-#endif
[in] IELF_HANDLE LogHandle,
[out] DWORD *NumberOfRecords);
/* Function 5 */
NTSTATUS ElfrOldestRecord(
-#ifndef __midl
- handle_t BindingHandle,
-#endif
[in] IELF_HANDLE LogHandle,
[out] DWORD *OldestRecordNumber);
/* Function 6 */
NTSTATUS ElfrChangeNotify(
-#ifndef __midl
- [in] handle_t BindingHandle,
-#endif
[in] IELF_HANDLE *LogHandle,
[in] RPC_CLIENT_ID ClientId,
[in] DWORD Event);
/* Function 7 */
NTSTATUS ElfrOpenELW(
-#ifndef __midl
- [in] handle_t BindingHandle,
-#endif
- [in] EVENTLOG_HANDLE_W UNCServerName,
+ [in, unique] EVENTLOG_HANDLE_W UNCServerName, /* FIXME */
[in] PRPC_UNICODE_STRING ModuleName,
[in] PRPC_UNICODE_STRING RegModuleName,
[in] DWORD MajorVersion,
@@ -107,10 +83,7 @@
/* Function 8 */
NTSTATUS ElfrRegisterEventSourceW(
-#ifndef __midl
- [in] handle_t BindingHandle,
-#endif
- [in] EVENTLOG_HANDLE_W UNCServerName,
+ [in, unique] EVENTLOG_HANDLE_W UNCServerName, /* FIXME */
[in] PRPC_UNICODE_STRING ModuleName,
[in] PRPC_UNICODE_STRING RegModuleName,
[in] DWORD MajorVersion,
@@ -119,10 +92,7 @@
/* Function 9 */
NTSTATUS ElfrOpenBELW(
-#ifndef __midl
- [in] handle_t BindingHandle,
-#endif
- [in] EVENTLOG_HANDLE_W UNCServerName,
+ [in, unique] EVENTLOG_HANDLE_W UNCServerName, /* FIXME */
[in] PRPC_UNICODE_STRING BackupFileName,
[in] DWORD MajorVersion,
[in] DWORD MinorVersion,
@@ -130,9 +100,6 @@
/* Function 10 */
NTSTATUS ElfrReadELW(
-#ifndef __midl
- [in] handle_t BindingHandle,
-#endif
[in] IELF_HANDLE LogHandle,
[in] DWORD ReadFlags,
[in] DWORD RecordOffset,
@@ -143,9 +110,6 @@
/* Function 11 */
NTSTATUS ElfrReportEventW(
-#ifndef __midl
- [in] handle_t BindingHandle,
-#endif
[in] IELF_HANDLE LogHandle,
[in] DWORD Time,
[in] USHORT EventType,
@@ -163,26 +127,17 @@
/* Function 12 */
NTSTATUS ElfrClearELFA(
-#ifndef __midl
- [in] handle_t BindingHandle,
-#endif
[in] IELF_HANDLE LogHandle,
[in, unique] PRPC_STRING BackupFileName);
/* Function 13 */
NTSTATUS ElfrBackupELFA(
-#ifndef __midl
- [in] handle_t BindingHandle,
-#endif
[in] IELF_HANDLE LogHandle,
[in, unique] PRPC_STRING BackupFileName);
/* Function 14 */
NTSTATUS ElfrOpenELA(
-#ifndef __midl
- [in] handle_t BindingHandle,
-#endif
- [in] EVENTLOG_HANDLE_A UNCServerName,
+ [in, unique] EVENTLOG_HANDLE_A UNCServerName, /* FIXME */
[in] PRPC_STRING ModuleName,
[in] PRPC_STRING RegModuleName,
[in] DWORD MajorVersion,
@@ -191,10 +146,7 @@
/* Function 15 */
NTSTATUS ElfrRegisterEventSourceA(
-#ifndef __midl
- [in] handle_t BindingHandle,
-#endif
- [in] EVENTLOG_HANDLE_A UNCServerName,
+ [in, unique] EVENTLOG_HANDLE_A UNCServerName, /* FIXME */
[in] PRPC_STRING ModuleName,
[in] PRPC_STRING RegModuleName,
[in] DWORD MajorVersion,
@@ -203,10 +155,7 @@
/* Function 16 */
NTSTATUS ElfrOpenBELA(
-#ifndef __midl
- [in] handle_t BindingHandle,
-#endif
- [in] EVENTLOG_HANDLE_A UNCServerName,
+ [in, unique] EVENTLOG_HANDLE_A UNCServerName, /* FIXME */
[in] PRPC_STRING BackupFileName,
[in] DWORD MajorVersion,
[in] DWORD MinorVersion,
@@ -214,9 +163,6 @@
/* Function 17 */
NTSTATUS ElfrReadELA(
-#ifndef __midl
- [in] handle_t BindingHandle,
-#endif
[in] IELF_HANDLE LogHandle,
[in] DWORD ReadFlags,
[in] DWORD RecordOffset,
@@ -227,9 +173,6 @@
/* Function 18 */
NTSTATUS ElfrReportEventA(
-#ifndef __midl
- [in] handle_t BindingHandle,
-#endif
[in] IELF_HANDLE LogHandle,
[in] DWORD Time,
[in] USHORT EventType,
@@ -268,9 +211,6 @@
/* Function 22 */
NTSTATUS ElfrGetLogInformation(
-#ifndef __midl
- [in] handle_t BindingHandle,
-#endif
[in] IELF_HANDLE LogHandle,
[in] DWORD InfoLevel,
[out, size_is(cbBufSize)] BYTE *Buffer,
@@ -279,16 +219,10 @@
/* Function 23 */
NTSTATUS ElfrFlushEL(
-#ifndef __midl
- [in] handle_t BindingHandle,
-#endif
[in] IELF_HANDLE LogHandle);
/* Function 24 */
NTSTATUS ElfrReportEventAndSourceW(
-#ifndef __midl
- [in] handle_t BindingHandle,
-#endif
[in] IELF_HANDLE LogHandle,
[in] DWORD Time,
[in] USHORT EventType,