1 /* 2 * PROJECT: ReactOS Services 3 * LICENSE: GPL-2.0+ (https://spdx.org/licenses/GPL-2.0+) 4 * FILE: base/applications/sc/print.c 5 * PURPOSE: print service info 6 * COPYRIGHT: Copyright 2005 - 2006 Ged Murphy <gedmurphy@gmail.com> 7 * Copyright 2016 Eric Kohl <eric.kohl@reactos.org> 8 */ 9 10 #include "sc.h" 11 12 VOID 13 PrintService(LPCTSTR lpServiceName, 14 LPCTSTR lpDisplayName, 15 LPSERVICE_STATUS_PROCESS pStatus, 16 BOOL bExtended) 17 { 18 _tprintf(_T("SERVICE_NAME: %s\n"), lpServiceName); 19 20 if (lpDisplayName) 21 _tprintf(_T("DISPLAY_NAME: %s\n"), lpDisplayName); 22 23 // Re-use PrintServiceStatus(), as SERVICE_STATUS_PROCESS is in fact an extension of SERVICE_STATUS. 24 PrintServiceStatus((LPSERVICE_STATUS)pStatus); 25 26 if (bExtended) 27 { 28 _tprintf(_T("\tPID : %lu\n"), 29 pStatus->dwProcessId); 30 _tprintf(_T("\tFLAGS : %lu\n"), 31 pStatus->dwServiceFlags); 32 } 33 34 _tprintf(_T("\n")); 35 } 36 37 38 VOID 39 PrintServiceStatus( 40 LPSERVICE_STATUS pStatus) 41 { 42 _tprintf(_T("\tTYPE : %x "), 43 (unsigned int)pStatus->dwServiceType); 44 45 switch (pStatus->dwServiceType) 46 { 47 case SERVICE_KERNEL_DRIVER: 48 _tprintf(_T("KERNEL_DRIVER\n")); 49 break; 50 case SERVICE_FILE_SYSTEM_DRIVER: 51 _tprintf(_T("FILE_SYSTEM_DRIVER\n")); 52 break; 53 case SERVICE_WIN32_OWN_PROCESS: 54 _tprintf(_T("WIN32_OWN_PROCESS\n")); 55 break; 56 case SERVICE_WIN32_SHARE_PROCESS: 57 _tprintf(_T("WIN32_SHARE_PROCESS\n")); 58 break; 59 case SERVICE_WIN32_OWN_PROCESS + SERVICE_INTERACTIVE_PROCESS: 60 _tprintf(_T("WIN32_OWN_PROCESS (interactive)\n")); 61 break; 62 case SERVICE_WIN32_SHARE_PROCESS + SERVICE_INTERACTIVE_PROCESS: 63 _tprintf(_T("WIN32_SHARE_PROCESS (interactive)\n")); 64 break; 65 default: 66 _tprintf(_T("\n")); 67 } 68 69 _tprintf(_T("\tSTATE : %x "), 70 (unsigned int)pStatus->dwCurrentState); 71 72 switch (pStatus->dwCurrentState) 73 { 74 case SERVICE_STOPPED: 75 _tprintf(_T("STOPPED\n")); 76 break; 77 case SERVICE_START_PENDING: 78 _tprintf(_T("START_PENDING\n")); 79 break; 80 case SERVICE_STOP_PENDING: 81 _tprintf(_T("STOP_PENDING\n")); 82 break; 83 case SERVICE_RUNNING: 84 _tprintf(_T("RUNNING\n")); 85 break; 86 case SERVICE_CONTINUE_PENDING: 87 _tprintf(_T("CONTINUE_PENDING\n")); 88 break; 89 case SERVICE_PAUSE_PENDING: 90 _tprintf(_T("PAUSE_PENDING\n")); 91 break; 92 case SERVICE_PAUSED: 93 _tprintf(_T("PAUSED\n")); 94 break; 95 default: 96 _tprintf(_T("\n")); 97 } 98 99 _tprintf(_T("\t\t\t\t(")); 100 101 if (pStatus->dwControlsAccepted & SERVICE_ACCEPT_STOP) 102 _tprintf(_T("STOPPABLE,")); 103 else 104 _tprintf(_T("NOT_STOPPABLE,")); 105 106 if (pStatus->dwControlsAccepted & SERVICE_ACCEPT_PAUSE_CONTINUE) 107 _tprintf(_T("PAUSABLE,")); 108 else 109 _tprintf(_T("NOT_PAUSABLE,")); 110 111 if (pStatus->dwControlsAccepted & SERVICE_ACCEPT_SHUTDOWN) 112 _tprintf(_T("ACCEPTS_SHUTDOWN")); 113 else 114 _tprintf(_T("IGNORES_SHUTDOWN")); 115 116 _tprintf(_T(")\n")); 117 118 _tprintf(_T("\tWIN32_EXIT_CODE : %u (0x%x)\n"), 119 (unsigned int)pStatus->dwWin32ExitCode, 120 (unsigned int)pStatus->dwWin32ExitCode); 121 _tprintf(_T("\tSERVICE_EXIT_CODE : %u (0x%x)\n"), 122 (unsigned int)pStatus->dwServiceSpecificExitCode, 123 (unsigned int)pStatus->dwServiceSpecificExitCode); 124 _tprintf(_T("\tCHECKPOINT : 0x%x\n"), 125 (unsigned int)pStatus->dwCheckPoint); 126 _tprintf(_T("\tWAIT_HINT : 0x%x\n"), 127 (unsigned int)pStatus->dwWaitHint); 128 } 129