4 * Copyright 2020 Dmitry Timoshkov
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
26 #include "wine/debug.h"
28 WINE_DEFAULT_DEBUG_CHANNEL(eventlog
);
30 static SERVICE_STATUS_HANDLE svc_handle
;
31 static HANDLE done_event
;
33 static void eventlog_update_status(DWORD state
)
35 SERVICE_STATUS status
;
37 status
.dwServiceType
= SERVICE_WIN32
;
38 status
.dwControlsAccepted
= SERVICE_ACCEPT_STOP
| SERVICE_ACCEPT_SHUTDOWN
;
39 status
.dwWin32ExitCode
= 0;
40 status
.dwServiceSpecificExitCode
= 0;
41 status
.dwCheckPoint
= 0;
42 status
.dwWaitHint
= 0;
43 status
.dwCurrentState
= state
;
45 SetServiceStatus(svc_handle
, &status
);
48 static void WINAPI
eventlog_handler(DWORD control
)
50 TRACE("%#lx\n", control
);
54 case SERVICE_CONTROL_STOP
:
55 case SERVICE_CONTROL_SHUTDOWN
:
56 eventlog_update_status(SERVICE_STOP_PENDING
);
61 eventlog_update_status(SERVICE_RUNNING
);
66 void WINAPI
ServiceMain(DWORD argc
, LPWSTR
*argv
)
68 TRACE("starting Event Log Service\n");
70 svc_handle
= RegisterServiceCtrlHandlerW(L
"EventLog", eventlog_handler
);
73 ERR("RegisterServiceCtrlHandler error %lu\n", GetLastError());
77 eventlog_update_status(SERVICE_RUNNING
);
79 done_event
= CreateEventW(NULL
, TRUE
, FALSE
, NULL
);
80 WaitForSingleObject(done_event
, INFINITE
);
81 CloseHandle(done_event
);
83 eventlog_update_status(SERVICE_STOPPED
);
85 TRACE("exiting Event Log Service\n");