67 DPRINT(
"ServiceControlHandler() called\n");
72 DPRINT(
" SERVICE_CONTROL_STOP received\n");
84 DPRINT(
" SERVICE_CONTROL_PAUSE received\n");
89 DPRINT(
" SERVICE_CONTROL_CONTINUE received\n");
94 DPRINT(
" SERVICE_CONTROL_INTERROGATE received\n");
100 DPRINT(
" SERVICE_CONTROL_SHUTDOWN received\n");
110 DPRINT1(
" Control %lu received\n", dwControl);
129 DPRINT(
"Cannot create PortThread\n");
144 DPRINT(
"Cannot create RpcThread\n");
166 ZeroMemory(&versionInfo,
sizeof(versionInfo));
197 &
str, &cchRemain, 0);
203 L"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion",
209 dwValueLength = cchRemain;
240 DPRINT(
"ServiceMain() called\n");
248 DPRINT1(
"RegisterServiceCtrlHandlerW() failed! (Error %lu)\n", dwError);
257 DPRINT(
"Service stopped (dwError: %lu\n", dwError);
262 DPRINT(
"Service started\n");
276 DPRINT(
"ServiceMain() done\n");
283 DWORD MaxValueLen, ValueLen,
Type, ExpandedLen;
288 ULONG ulMaxSize, ulRetention;
291 DPRINT(
"LoadLogFile: `%S'\n", LogName);
305 DPRINT1(
"Cannot allocate heap!\n");
309 ValueLen = MaxValueLen;
323 MaxValueLen = (
wcslen(
L"%SystemRoot%\\System32\\Config\\") +
329 DPRINT1(
"Cannot reallocate heap!\n");
335 StringCbCopyW(Buf, MaxValueLen,
L"%SystemRoot%\\System32\\Config\\");
339 ValueLen = MaxValueLen;
358 DPRINT1(
"Cannot allocate heap!\n");
367 DPRINT1(
"Cannot convert path!\n");
373 DPRINT(
"%S -> %S\n", Buf, Expanded);
375 ValueLen =
sizeof(ulMaxSize);
384 ulMaxSize = 512 * 1024;
394 ValueLen =
sizeof(ulRetention);
411 sizeof(ulRetention));
420 DPRINT1(
"Failed to create %S! (Status %08lx)\n", Expanded,
Status);
432 DWORD MaxLognameLen, LognameLen;
450 DPRINT1(
"Error: cannot allocate heap!\n");
454 LognameLen = MaxLognameLen;
469 DPRINT1(
"Failed to open %S key.\n", Buf);
475 if (pLogFile !=
NULL)
477 DPRINT(
"Loaded %S\n", Buf);
482 DPRINT1(
"Failed to load %S\n", Buf);
487 LognameLen = MaxLognameLen;
510 DPRINT(
"LiveCD detected\n");
516 L"SYSTEM\\CurrentControlSet\\Services\\EventLog",
522 DPRINT1(
"Fatal error: cannot open eventlog registry key.\n");
533 DPRINT1(
"The 'EventLog' source is unavailable. The EventLog service will not be able to log its own events.\n");
551 DPRINT1(
"PRINT_RECORD(0x%p)\n", pRec);
559 DbgPrint(
"TimeGenerated = %hu.%hu.%hu %hu:%hu:%hu\n",
565 DbgPrint(
"TimeWritten = %hu.%hu.%hu %hu:%hu:%hu\n",
574 DbgPrint(
"EventType = EVENTLOG_ERROR_TYPE\n");
577 DbgPrint(
"EventType = EVENTLOG_WARNING_TYPE\n");
580 DbgPrint(
"EventType = EVENTLOG_INFORMATION_TYPE\n");
583 DbgPrint(
"EventType = EVENTLOG_AUDIT_SUCCESS\n");
586 DbgPrint(
"EventType = EVENTLOG_AUDIT_FAILURE\n");
static SERVICE_STATUS_HANDLE(WINAPI *pRegisterServiceCtrlHandlerExA)(LPCSTR
DWORD WINAPI RpcThreadRoutine(LPVOID lpParameter)
VOID PRINT_RECORD(PEVENTLOGRECORD pRec)
static WCHAR ServiceName[]
static PLOGFILE LoadLogFile(HKEY hKey, PWSTR LogName)
PEVENTSOURCE EventLogSource
static DWORD ServiceInit(VOID)
static DWORD WINAPI ServiceControlHandler(DWORD dwControl, DWORD dwEventType, LPVOID lpEventData, LPVOID lpContext)
static VOID UpdateServiceStatus(DWORD dwState)
SERVICE_STATUS_HANDLE ServiceStatusHandle
static BOOL LoadLogFiles(HKEY eventlogKey)
static VOID CALLBACK ServiceMain(DWORD, LPWSTR *)
SERVICE_STATUS ServiceStatus
static VOID ReportProductInfoEvent(VOID)
static SERVICE_TABLE_ENTRYW ServiceTable[2]
#define RegCloseKey(hKey)
#define NT_SUCCESS(StatCode)
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
LONG WINAPI RegEnumKeyExW(_In_ HKEY hKey, _In_ DWORD dwIndex, _Out_ LPWSTR lpName, _Inout_ LPDWORD lpcbName, _Reserved_ LPDWORD lpReserved, _Out_opt_ LPWSTR lpClass, _Inout_opt_ LPDWORD lpcbClass, _Out_opt_ PFILETIME lpftLastWriteTime)
LONG WINAPI RegSetValueExW(_In_ HKEY hKey, _In_ LPCWSTR lpValueName, _In_ DWORD Reserved, _In_ DWORD dwType, _In_ CONST BYTE *lpData, _In_ DWORD cbData)
LONG WINAPI RegQueryInfoKeyW(HKEY hKey, LPWSTR lpClass, LPDWORD lpcClass, LPDWORD lpReserved, LPDWORD lpcSubKeys, LPDWORD lpcMaxSubKeyLen, LPDWORD lpcMaxClassLen, LPDWORD lpcValues, LPDWORD lpcMaxValueNameLen, LPDWORD lpcMaxValueLen, LPDWORD lpcbSecurityDescriptor, PFILETIME lpftLastWriteTime)
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
#define ERROR_CALL_NOT_IMPLEMENTED
#define HeapFree(x, y, z)
DWORD WINAPI ExpandEnvironmentStringsW(IN LPCWSTR lpSrc, IN LPWSTR lpDst, IN DWORD nSize)
UINT WINAPI GetDriveTypeW(IN LPCWSTR lpRootPathName)
UINT WINAPI GetSystemWindowsDirectoryW(OUT LPWSTR lpBuffer, IN UINT uSize)
HANDLE WINAPI DECLSPEC_HOTPATCH CreateThread(IN LPSECURITY_ATTRIBUTES lpThreadAttributes, IN DWORD dwStackSize, IN LPTHREAD_START_ROUTINE lpStartAddress, IN LPVOID lpParameter, IN DWORD dwCreationFlags, OUT LPDWORD lpThreadId)
BOOL WINAPI GetVersionExW(IN LPOSVERSIONINFOW lpVersionInformation)
BOOLEAN RtlTimeToTimeFields(IN PLARGE_INTEGER Time, IN PTIME_FIELDS TimeFields)
VOID LogfReportEvent(USHORT wType, USHORT wCategory, ULONG dwEventId, USHORT wNumStrings, PWSTR pStrings, ULONG dwDataSize, PVOID pRawData)
NTSTATUS LogfCreate(PLOGFILE *LogFile, PCWSTR LogName, PUNICODE_STRING FileName, ULONG MaxSize, ULONG Retention, BOOLEAN Permanent, BOOLEAN Backup)
BOOL LoadEventSources(HKEY hKey, PLOGFILE pLogFile)
VOID InitEventSourceList(VOID)
VOID LogfListInitialize(VOID)
NTSTATUS WINAPI PortThreadRoutine(PVOID Param)
PEVENTSOURCE GetEventSourceByName(LPCWSTR Name)
#define ROUND_DOWN(n, align)
struct _FileName FileName
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
static PLARGE_INTEGER Time
NTSYSAPI VOID NTAPI RtlSecondsSince1970ToTime(_In_ ULONG SecondsSince1970, _Out_ PLARGE_INTEGER Time)
NTSYSAPI BOOLEAN NTAPI RtlDosPathNameToNtPathName_U(_In_opt_z_ PCWSTR DosPathName, _Out_ PUNICODE_STRING NtPathName, _Out_opt_ PCWSTR *NtFileNamePart, _Out_opt_ PRTL_RELATIVE_NAME_U DirectoryInfo)
#define EVENT_EventLogProductInfo
#define EVENT_EventlogStarted
#define EVENT_EventlogStopped
#define UNREFERENCED_PARAMETER(P)
RPC_STATUS WINAPI RpcMgmtStopServerListening(RPC_BINDING_HANDLE Binding)
SERVICE_STATUS_HANDLE WINAPI RegisterServiceCtrlHandlerExW(LPCWSTR lpServiceName, LPHANDLER_FUNCTION_EX lpHandlerProc, LPVOID lpContext)
BOOL WINAPI SetServiceStatus(SERVICE_STATUS_HANDLE hServiceStatus, LPSERVICE_STATUS lpServiceStatus)
STRSAFEAPI StringCchCopyExW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszSrc, STRSAFE_LPWSTR *ppszDestEnd, size_t *pcchRemaining, STRSAFE_DWORD dwFlags)
STRSAFEAPI StringCchPrintfExW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPWSTR *ppszDestEnd, size_t *pcchRemaining, STRSAFE_DWORD dwFlags, STRSAFE_LPCWSTR pszFormat,...)
STRSAFEAPI StringCbCopyW(STRSAFE_LPWSTR pszDest, size_t cbDest, STRSAFE_LPCWSTR pszSrc)
STRSAFEAPI StringCbCatW(STRSAFE_LPWSTR pszDest, size_t cbDest, STRSAFE_LPCWSTR pszSrc)
DWORD ClosingRecordNumber
ULONG dwOSVersionInfoSize
DWORD dwServiceSpecificExitCode
DWORD WINAPI GetLastError(void)
DWORD(WINAPI * LPTHREAD_START_ROUTINE)(LPVOID)
#define EVENTLOG_ERROR_TYPE
#define EVENTLOG_AUDIT_FAILURE
#define EVENTLOG_INFORMATION_TYPE
#define EVENTLOG_AUDIT_SUCCESS
struct _EVENTLOGRECORD EVENTLOGRECORD
#define EVENTLOG_WARNING_TYPE
#define HKEY_LOCAL_MACHINE
#define SERVICE_STOP_PENDING
#define SERVICE_CONTROL_SHUTDOWN
#define StartServiceCtrlDispatcher
#define SERVICE_START_PENDING
#define SERVICE_CONTROL_CONTINUE
#define SERVICE_CONTROL_STOP
#define SERVICE_PAUSE_PENDING
#define SERVICE_CONTROL_PAUSE
#define SERVICE_CONTROL_INTERROGATE
#define SERVICE_CONTINUE_PENDING
_At_(*)(_In_ PWSK_CLIENT Client, _In_opt_ PUNICODE_STRING NodeName, _In_opt_ PUNICODE_STRING ServiceName, _In_opt_ ULONG NameSpace, _In_opt_ GUID *Provider, _In_opt_ PADDRINFOEXW Hints, _Outptr_ PADDRINFOEXW *Result, _In_opt_ PEPROCESS OwningProcess, _In_opt_ PETHREAD OwningThread, _Inout_ PIRP Irp Result)(Mem)) NTSTATUS(WSKAPI *PFN_WSK_GET_ADDRESS_INFO
#define SERVICE_WIN32_OWN_PROCESS