1 /* 2 * PROJECT: ReactOS Services 3 * LICENSE: GPL - See COPYING in the top level directory 4 * FILE: base/applications/sc/print.c 5 * PURPOSE: print service info 6 * COPYRIGHT: Copyright 2005 - 2006 Ged Murphy <gedmurphy@gmail.com> 7 * 8 */ 9 10 #include "sc.h" 11 12 VOID 13 PrintService(LPCTSTR lpServiceName, 14 LPSERVICE_STATUS_PROCESS pStatus, 15 BOOL bExtended) 16 { 17 _tprintf(_T("SERVICE_NAME: %s\n"), lpServiceName); 18 19 _tprintf(_T("\tTYPE : %x "), 20 (unsigned int)pStatus->dwServiceType); 21 switch (pStatus->dwServiceType) 22 { 23 case SERVICE_KERNEL_DRIVER: 24 _tprintf(_T("KERNEL_DRIVER\n")); 25 break; 26 27 case SERVICE_FILE_SYSTEM_DRIVER: 28 _tprintf(_T("FILE_SYSTEM_DRIVER\n")); 29 break; 30 31 case SERVICE_WIN32_OWN_PROCESS: 32 _tprintf(_T("WIN32_OWN_PROCESS\n")); 33 break; 34 35 case SERVICE_WIN32_SHARE_PROCESS: 36 _tprintf(_T("WIN32_SHARE_PROCESS\n")); 37 break; 38 39 case SERVICE_WIN32_OWN_PROCESS + SERVICE_INTERACTIVE_PROCESS: 40 _tprintf(_T("WIN32_OWN_PROCESS (interactive)\n")); 41 break; 42 43 case SERVICE_WIN32_SHARE_PROCESS + SERVICE_INTERACTIVE_PROCESS: 44 _tprintf(_T("WIN32_SHARE_PROCESS (interactive)\n")); 45 break; 46 47 default : _tprintf(_T("\n")); break; 48 } 49 50 _tprintf(_T("\tSTATE : %x "), 51 (unsigned int)pStatus->dwCurrentState); 52 53 switch (pStatus->dwCurrentState) 54 { 55 case 1 : _tprintf(_T("STOPPED\n")); break; 56 case 2 : _tprintf(_T("START_PENDING\n")); break; 57 case 3 : _tprintf(_T("STOP_PENDING\n")); break; 58 case 4 : _tprintf(_T("RUNNING\n")); break; 59 case 5 : _tprintf(_T("CONTINUE_PENDING\n")); break; 60 case 6 : _tprintf(_T("PAUSE_PENDING\n")); break; 61 case 7 : _tprintf(_T("PAUSED\n")); break; 62 default : _tprintf(_T("\n")); break; 63 } 64 65 _tprintf(_T("\t\t\t\t(")); 66 67 if (pStatus->dwControlsAccepted & SERVICE_ACCEPT_STOP) 68 _tprintf(_T("STOPPABLE,")); 69 else 70 _tprintf(_T("NOT_STOPPABLE,")); 71 72 if (pStatus->dwControlsAccepted & SERVICE_ACCEPT_PAUSE_CONTINUE) 73 _tprintf(_T("PAUSABLE,")); 74 else 75 _tprintf(_T("NOT_PAUSABLE,")); 76 77 if (pStatus->dwControlsAccepted & SERVICE_ACCEPT_SHUTDOWN) 78 _tprintf(_T("ACCEPTS_SHUTDOWN")); 79 else 80 _tprintf(_T("IGNORES_SHUTDOWN")); 81 82 _tprintf(_T(")\n")); 83 84 _tprintf(_T("\tWIN32_EXIT_CODE : %u (0x%x)\n"), 85 (unsigned int)pStatus->dwWin32ExitCode, 86 (unsigned int)pStatus->dwWin32ExitCode); 87 _tprintf(_T("\tSERVICE_EXIT_CODE : %u (0x%x)\n"), 88 (unsigned int)pStatus->dwServiceSpecificExitCode, 89 (unsigned int)pStatus->dwServiceSpecificExitCode); 90 _tprintf(_T("\tCHECKPOINT : 0x%x\n"), 91 (unsigned int)pStatus->dwCheckPoint); 92 _tprintf(_T("\tWAIT_HINT : 0x%x\n"), 93 (unsigned int)pStatus->dwWaitHint); 94 95 if (bExtended) 96 { 97 _tprintf(_T("\tPID : %lu\n"), 98 pStatus->dwProcessId); 99 _tprintf(_T("\tFLAGS : %lu\n"), 100 pStatus->dwServiceFlags); 101 } 102 103 _tprintf(_T("\n")); 104 } 105 106 107 VOID 108 PrintServiceStatus( 109 LPSERVICE_STATUS pStatus) 110 { 111 _tprintf(_T("\tTYPE : %x "), 112 (unsigned int)pStatus->dwServiceType); 113 switch (pStatus->dwServiceType) 114 { 115 case SERVICE_KERNEL_DRIVER: 116 _tprintf(_T("KERNEL_DRIVER\n")); 117 break; 118 119 case SERVICE_FILE_SYSTEM_DRIVER: 120 _tprintf(_T("FILE_SYSTEM_DRIVER\n")); 121 break; 122 123 case SERVICE_WIN32_OWN_PROCESS: 124 _tprintf(_T("WIN32_OWN_PROCESS\n")); 125 break; 126 127 case SERVICE_WIN32_SHARE_PROCESS: 128 _tprintf(_T("WIN32_SHARE_PROCESS\n")); 129 break; 130 131 case SERVICE_WIN32_OWN_PROCESS + SERVICE_INTERACTIVE_PROCESS: 132 _tprintf(_T("WIN32_OWN_PROCESS (interactive)\n")); 133 break; 134 135 case SERVICE_WIN32_SHARE_PROCESS + SERVICE_INTERACTIVE_PROCESS: 136 _tprintf(_T("WIN32_SHARE_PROCESS (interactive)\n")); 137 break; 138 139 default : _tprintf(_T("\n")); break; 140 } 141 142 _tprintf(_T("\tSTATE : %x "), 143 (unsigned int)pStatus->dwCurrentState); 144 145 switch (pStatus->dwCurrentState) 146 { 147 case 1 : _tprintf(_T("STOPPED\n")); break; 148 case 2 : _tprintf(_T("START_PENDING\n")); break; 149 case 3 : _tprintf(_T("STOP_PENDING\n")); break; 150 case 4 : _tprintf(_T("RUNNING\n")); break; 151 case 5 : _tprintf(_T("CONTINUE_PENDING\n")); break; 152 case 6 : _tprintf(_T("PAUSE_PENDING\n")); break; 153 case 7 : _tprintf(_T("PAUSED\n")); break; 154 default : _tprintf(_T("\n")); break; 155 } 156 157 _tprintf(_T("\t\t\t\t(")); 158 159 if (pStatus->dwControlsAccepted & SERVICE_ACCEPT_STOP) 160 _tprintf(_T("STOPPABLE,")); 161 else 162 _tprintf(_T("NOT_STOPPABLE,")); 163 164 if (pStatus->dwControlsAccepted & SERVICE_ACCEPT_PAUSE_CONTINUE) 165 _tprintf(_T("PAUSABLE,")); 166 else 167 _tprintf(_T("NOT_PAUSABLE,")); 168 169 if (pStatus->dwControlsAccepted & SERVICE_ACCEPT_SHUTDOWN) 170 _tprintf(_T("ACCEPTS_SHUTDOWN")); 171 else 172 _tprintf(_T("IGNORES_SHUTDOWN")); 173 174 _tprintf(_T(")\n")); 175 176 _tprintf(_T("\tWIN32_EXIT_CODE : %u (0x%x)\n"), 177 (unsigned int)pStatus->dwWin32ExitCode, 178 (unsigned int)pStatus->dwWin32ExitCode); 179 _tprintf(_T("\tSERVICE_EXIT_CODE : %u (0x%x)\n"), 180 (unsigned int)pStatus->dwServiceSpecificExitCode, 181 (unsigned int)pStatus->dwServiceSpecificExitCode); 182 _tprintf(_T("\tCHECKPOINT : 0x%x\n"), 183 (unsigned int)pStatus->dwCheckPoint); 184 _tprintf(_T("\tWAIT_HINT : 0x%x\n"), 185 (unsigned int)pStatus->dwWaitHint); 186 }