Output is modelled on behaviour observed under the Windows 10.
Signed-off-by: Dmitry Timoshkov dmitry@baikal.ru --- programs/sc/sc.c | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+)
diff --git a/programs/sc/sc.c b/programs/sc/sc.c index 4e642874237..4407ab5bcab 100644 --- a/programs/sc/sc.c +++ b/programs/sc/sc.c @@ -175,6 +175,26 @@ static void usage( void ) exit( 1 ); }
+static const WCHAR *service_type_string( DWORD type ) +{ + switch (type) + { + case SERVICE_WIN32_OWN_PROCESS: return L"WIN32_OWN_PROCESS"; + case SERVICE_WIN32_SHARE_PROCESS: return L"WIN32_SHARE_PROCESS"; + case SERVICE_WIN32: return L"WIN32"; + default: return L""; + } +} + +static const WCHAR *service_state_string( DWORD state ) +{ + static const WCHAR * const state_str[] = { L"", L"STOPPED", L"START_PENDING" + L"STOP_PENDING", L"RUNNING", L"CONTINUE_PENDING", L"PAUSE_PENDING", L"PAUSED" }; + + if (state <= ARRAY_SIZE( state_str )) return state_str[ state ]; + return L""; +} + int __cdecl wmain( int argc, const WCHAR *argv[] ) { SC_HANDLE manager, service; @@ -285,6 +305,33 @@ int __cdecl wmain( int argc, const WCHAR *argv[] ) } else WINE_ERR("failed to open service %lu\n", GetLastError()); } + else if (!wcsicmp( argv[1], L"query" )) + { + service = OpenServiceW( manager, argv[2], SERVICE_QUERY_STATUS ); + if (service) + { + SERVICE_STATUS status; + + ret = QueryServiceStatus( service, &status ); + if (!ret) + WINE_ERR("failed to query service status %lu\n", GetLastError()); + else + printf( "SERVICE_NAME: %ws\n" + " TYPE : %lx %ws\n" + " STATE : %lx %ws\n" + " WIN32_EXIT_CODE : %lu (0x%lx)\n" + " SERVICE_EXIT_CODE : %lu (0x%lx)\n" + " CHECKPOINT : 0x%lx\n" + " WAIT_HINT : 0x%lx\n", + argv[2], status.dwServiceType, service_type_string( status.dwServiceType ), + status.dwCurrentState, service_state_string( status.dwCurrentState ), + status.dwControlsAccepted, status.dwWin32ExitCode, + status.dwServiceSpecificExitCode, status.dwCheckPoint, + status.dwWaitHint ); + CloseServiceHandle( service ); + } + else WINE_ERR("failed to open service %lu\n", GetLastError()); + } else if (!wcsicmp( argv[1], L"sdset" )) { WINE_FIXME("SdSet command not supported, faking success\n");