/*
 * Event Log RPC interface definition
 */

#include <ms-dtyp.idl>

cpp_quote("#if !defined(__EVENTLOG_H__) && !defined(__ADVAPI32_H)")
typedef long NTSTATUS;
cpp_quote("#endif")

#define MAX_BATCH_BUFF 0x0007FFFF

typedef [range(0, MAX_BATCH_BUFF)] unsigned long RULONG;
typedef struct _RPC_STRING {
    USHORT Length;
    USHORT MaximumLength;
    [size_is(MaximumLength), length_is(Length)] LPSTR Buffer;
} RPC_STRING, *PRPC_STRING;

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 struct _RPC_CLIENT_ID {
    DWORD UniqueProcess;
    DWORD UniqueThread;
} RPC_CLIENT_ID, *PRPC_CLIENT_ID;

[
    uuid(82273FDC-E32A-18C3-3F78-827929DC23EA),
    version(0.0),
    pointer_default(unique),
    endpoint("ncacn_np:[\\pipe\\EventLog]")
#ifndef __midl
    ,explicit_handle
#endif
]

interface eventlog
{
    /* Function 0 */
    NTSTATUS ElfrClearELFW(
        [in] IELF_HANDLE LogHandle,
        [in, unique] PRPC_UNICODE_STRING BackupFileName);

    /* Function 1 */
     NTSTATUS ElfrBackupELFW(
        [in] IELF_HANDLE LogHandle,
        [in, unique] PRPC_UNICODE_STRING BackupFileName);

    /* Function 2 */
    NTSTATUS ElfrCloseEL(
        [in, out] IELF_HANDLE *LogHandle);

    /* Function 3 */
    NTSTATUS ElfrDeregisterEventSource(
        [in, out] IELF_HANDLE *LogHandle);

    /* Function 4 */
    NTSTATUS ElfrNumberOfRecords(
        [in] IELF_HANDLE LogHandle,
        [out] DWORD *NumberOfRecords);

    /* Function 5 */
    NTSTATUS ElfrOldestRecord(
        [in] IELF_HANDLE LogHandle,
        [out] DWORD *OldestRecordNumber);

    /* Function 6 */
    NTSTATUS ElfrChangeNotify(
        [in] IELF_HANDLE *LogHandle,
        [in] RPC_CLIENT_ID ClientId,
        [in] DWORD Event);

    /* Function 7 */
    NTSTATUS ElfrOpenELW(
        [in, unique] EVENTLOG_HANDLE_W UNCServerName, /* FIXME */
        [in] PRPC_UNICODE_STRING ModuleName,
        [in] PRPC_UNICODE_STRING RegModuleName,
        [in] DWORD MajorVersion,
        [in] DWORD MinorVersion,
        [out] IELF_HANDLE* LogHandle);

    /* Function 8 */
    NTSTATUS ElfrRegisterEventSourceW(
        [in, unique] EVENTLOG_HANDLE_W UNCServerName, /* FIXME */
        [in] PRPC_UNICODE_STRING ModuleName,
        [in] PRPC_UNICODE_STRING RegModuleName,
        [in] DWORD MajorVersion,
        [in] DWORD MinorVersion,
        [out] IELF_HANDLE* LogHandle);

    /* Function 9 */
    NTSTATUS ElfrOpenBELW(
        [in, unique] EVENTLOG_HANDLE_W UNCServerName, /* FIXME */
        [in] PRPC_UNICODE_STRING BackupFileName,
        [in] DWORD MajorVersion,
        [in] DWORD MinorVersion,
        [out] IELF_HANDLE* LogHandle);

    /* Function 10 */
    NTSTATUS ElfrReadELW(
        [in] IELF_HANDLE LogHandle,
        [in] DWORD ReadFlags,
        [in] DWORD RecordOffset,
        [in] RULONG NumberOfBytesToRead,
        [out, size_is(NumberOfBytesToRead)] BYTE *Buffer,
        [out] DWORD *NumberOfBytesRead,
        [out] DWORD *MinNumberOfBytesNeeded);

    /* Function 11 */
    NTSTATUS ElfrReportEventW(
        [in] IELF_HANDLE LogHandle,
        [in] DWORD Time,
        [in] USHORT EventType,
        [in] USHORT EventCategory,
        [in] DWORD EventID,
        [in/*, max_is(256)*/] USHORT NumStrings,
        [in, range(0, 61440)] DWORD DataSize,
        [in] PRPC_UNICODE_STRING ComputerName,
        [in, unique] PRPC_SID UserSID,
        [in, size_is(NumStrings), unique] PRPC_UNICODE_STRING Strings[*],
        [in, size_is(DataSize), unique] BYTE *Data,
        [in] USHORT Flags,
        [in, out, unique] DWORD *RecordNumber,
        [in, out, unique] DWORD *TimeWritten);

    /* Function 12 */
    NTSTATUS ElfrClearELFA(
        [in] IELF_HANDLE LogHandle,
        [in, unique] PRPC_STRING BackupFileName);

    /* Function 13 */
     NTSTATUS ElfrBackupELFA(
        [in] IELF_HANDLE LogHandle,
        [in, unique] PRPC_STRING BackupFileName);

    /* Function 14 */
    NTSTATUS ElfrOpenELA(
        [in, unique] EVENTLOG_HANDLE_A UNCServerName, /* FIXME */
        [in] PRPC_STRING ModuleName,
        [in] PRPC_STRING RegModuleName,
        [in] DWORD MajorVersion,
        [in] DWORD MinorVersion,
        [out] IELF_HANDLE* LogHandle);

    /* Function 15 */
    NTSTATUS ElfrRegisterEventSourceA(
        [in, unique] EVENTLOG_HANDLE_A UNCServerName, /* FIXME */
        [in] PRPC_STRING ModuleName,
        [in] PRPC_STRING RegModuleName,
        [in] DWORD MajorVersion,
        [in] DWORD MinorVersion,
        [out] IELF_HANDLE* LogHandle);

    /* Function 16 */
    NTSTATUS ElfrOpenBELA(
        [in, unique] EVENTLOG_HANDLE_A UNCServerName, /* FIXME */
        [in] PRPC_STRING BackupFileName,
        [in] DWORD MajorVersion,
        [in] DWORD MinorVersion,
        [out] IELF_HANDLE* LogHandle);

    /* Function 17 */
    NTSTATUS ElfrReadELA(
        [in] IELF_HANDLE LogHandle,
        [in] DWORD ReadFlags,
        [in] DWORD RecordOffset,
        [in] RULONG NumberOfBytesToRead,
        [out, size_is(NumberOfBytesToRead)] BYTE *Buffer,
        [out] DWORD *NumberOfBytesRead,
        [out] DWORD *MinNumberOfBytesNeeded);

    /* Function 18 */
    NTSTATUS ElfrReportEventA(
        [in] IELF_HANDLE LogHandle,
        [in] DWORD Time,
        [in] USHORT EventType,
        [in] USHORT EventCategory,
        [in] DWORD EventID,
        [in/*, max_is(256)*/] USHORT NumStrings,
        [in, range(0, 61440)] DWORD DataSize,
        [in] PRPC_STRING ComputerName,
        [in, unique] PRPC_SID UserSID,
        [in, size_is(NumStrings), unique] PRPC_STRING Strings[*],
        [in, size_is(DataSize), unique] BYTE *Data,
        [in] USHORT Flags,
        [in, out, unique] DWORD *RecordNumber,
        [in, out, unique] DWORD *TimeWritten);

    /* Function 19 */
    NTSTATUS ElfrRegisterClusterSvc(
        [in] handle_t BindingHandle);

    /* Function 20 */
    NTSTATUS ElfrDeregisterClusterSvc(
        [in] handle_t BindingHandle);

    /* Function 21 */
    NTSTATUS ElfrWriteClusterEvents(
        [in] handle_t BindingHandle);

    /* Function 22 */
    NTSTATUS ElfrGetLogInformation(
        [in] IELF_HANDLE LogHandle,
        [in] DWORD InfoLevel,
        [out, size_is(cbBufSize)] BYTE *Buffer,
        [in, range(0, 1024)] DWORD cbBufSize,
        [out] DWORD *pcbBytesNeeded);

    /* Function 23 */
    NTSTATUS ElfrFlushEL(
        [in] IELF_HANDLE LogHandle);

    /* Function 24 */
    NTSTATUS ElfrReportEventAndSourceW(
        [in] IELF_HANDLE LogHandle,
        [in] DWORD Time,
        [in] USHORT EventType,
        [in] USHORT EventCategory,
        [in] ULONG EventID,
        [in] PRPC_UNICODE_STRING SourceName,
        [in/*, max_is(256)*/] USHORT NumStrings,
        [in, range(0, 61440)] DWORD DataSize,
        [in] PRPC_UNICODE_STRING ComputerName,
        [in, unique] PRPC_SID UserSID,
        [in, size_is(NumStrings), unique] PRPC_UNICODE_STRING Strings[*],
        [in, size_is(DataSize), unique] BYTE *Data,
        [in] USHORT Flags,
        [in, out, unique] DWORD *RecordNumber,
        [in, out, unique] DWORD *TimeWritten);
}
