| 21 | #define SERVICE_NAME "ApolloService" |
| 22 | |
| 23 | DWORD WINAPI HandlerEx(DWORD dwControl, DWORD dwEventType, LPVOID lpEventData, LPVOID lpContext) { |
| 24 | switch (dwControl) { |
| 25 | case SERVICE_CONTROL_INTERROGATE: |
| 26 | return NO_ERROR; |
| 27 | |
| 28 | case SERVICE_CONTROL_SESSIONCHANGE: |
| 29 | // If a new session connects to the console, restart Sunshine |
| 30 | // to allow it to spawn inside the new console session. |
| 31 | if (dwEventType == WTS_CONSOLE_CONNECT) { |
| 32 | SetEvent(session_change_event); |
| 33 | } |
| 34 | return NO_ERROR; |
| 35 | |
| 36 | case SERVICE_CONTROL_PRESHUTDOWN: |
| 37 | // The system is shutting down |
| 38 | case SERVICE_CONTROL_STOP: |
| 39 | // Let SCM know we're stopping in up to 30 seconds |
| 40 | service_status.dwCurrentState = SERVICE_STOP_PENDING; |
| 41 | service_status.dwControlsAccepted = 0; |
| 42 | service_status.dwWaitHint = 30 * 1000; |
| 43 | SetServiceStatus(service_status_handle, &service_status); |
| 44 | |
| 45 | // Trigger ServiceMain() to start cleanup |
| 46 | SetEvent(stop_event); |
| 47 | return NO_ERROR; |
| 48 | |
| 49 | default: |
| 50 | return ERROR_CALL_NOT_IMPLEMENTED; |
| 51 | } |
| 52 | } |
| 53 | |
| 54 | HANDLE CreateJobObjectForChildProcess() { |
| 55 | HANDLE job_handle = CreateJobObjectW(nullptr, nullptr); |
nothing calls this directly
no outgoing calls
no test coverage detected