dll: service, eventlog

This commit is contained in:
Bill Zissimopoulos
2016-05-06 12:25:47 -07:00
parent d7a6f33d26
commit e53e915a72
2 changed files with 53 additions and 5 deletions

View File

@ -40,12 +40,51 @@ FSP_API VOID FspEventLogV(ULONG Type, PWSTR Format, va_list ap)
WCHAR Buf[1024], *Strings[1];
/* wvsprintfW is only safe with a 1024 WCHAR buffer */
DWORD EventId;
wvsprintfW(Buf, Format, ap);
Buf[(sizeof Buf / sizeof Buf[0]) - 1] = L'\0';
Strings[0] = Buf;
ReportEventW(FspEventLogHandle, (WORD)Type, 0, 1, 0, 1, 0, Strings, 0);
/*
* Event Identifier Format:
*
* 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1
* 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
* +---+-+-+-----------------------+-------------------------------+
* |Sev|C|R| Facility | Code |
* +---+-+-+-----------------------+-------------------------------+
*
* Sev - Severity:
* 00 - Success
* 01 - Informational
* 10 - Warning
* 11 - Error
*
* C - Customer:
* 0 - System code
* 1 - Customer code
*
* R - Reserved
*
* See https://msdn.microsoft.com/en-us/library/windows/desktop/aa363651(v=vs.85).aspx
*/
switch (Type)
{
case EVENTLOG_ERROR_TYPE:
EventId = 0xd0000001;
break;
case EVENTLOG_WARNING_TYPE:
EventId = 0xc0000001;
break;
case EVENTLOG_INFORMATION_TYPE:
case EVENTLOG_SUCCESS:
default:
EventId = 0x60000001;
break;
}
ReportEventW(FspEventLogHandle, (WORD)Type, 0, EventId, 0, 1, 0, Strings, 0);
}
static BOOL WINAPI FspEventLogRegisterEventSource(