From: Ged Murphy Date: Mon, 7 Nov 2005 21:14:03 +0000 (+0000) Subject: Add information letting us know creation deletion of services has worked. X-Git-Tag: backups/ros-branch-0_2_9@19949~856 X-Git-Url: https://git.reactos.org/?p=reactos.git;a=commitdiff_plain;h=dedb760816ae40a050f4d78d1b1f667e92cf58f2 Add information letting us know creation deletion of services has worked. comment out testing debug info. svn path=/trunk/; revision=19042 --- diff --git a/reactos/subsys/system/sc/control.c b/reactos/subsys/system/sc/control.c index e9965d7e37e..2fac5fe6198 100644 --- a/reactos/subsys/system/sc/control.c +++ b/reactos/subsys/system/sc/control.c @@ -20,7 +20,8 @@ BOOL Control(DWORD Control, LPCTSTR ServiceName, LPCTSTR *Args) { SC_HANDLE hSc; SERVICE_STATUS Status; - + +#ifdef SCDBG /* testing */ _tprintf(_T("service to control - %s\n\n"), ServiceName); _tprintf(_T("command - %lu\n\n"), Control); @@ -30,7 +31,7 @@ BOOL Control(DWORD Control, LPCTSTR ServiceName, LPCTSTR *Args) printf("%s\n", *Args); Args++; } - +#endif /* SCDBG */ hSc = OpenService(hSCManager, ServiceName, SERVICE_INTERROGATE | SERVICE_PAUSE_CONTINUE | @@ -46,7 +47,7 @@ BOOL Control(DWORD Control, LPCTSTR ServiceName, LPCTSTR *Args) if (! ControlService(hSc, Control, &Status)) { - _tprintf(_T("controlService failed\n")); + _tprintf(_T("[SC] controlService FAILED %lu:\n\n"), GetLastError()); ReportLastError(); return FALSE; } diff --git a/reactos/subsys/system/sc/create.c b/reactos/subsys/system/sc/create.c index 3fe1e573cdf..027bc51f962 100644 --- a/reactos/subsys/system/sc/create.c +++ b/reactos/subsys/system/sc/create.c @@ -19,7 +19,8 @@ BOOL Create(LPCTSTR ServiceName, LPCTSTR *ServiceArgs) if ((! ServiceName) || (! BinaryPathName)) return CreateUsage(); - + +#ifdef SCDBG /* testing */ printf("service to create - %s\n", ServiceName); printf("Binary path - %s\n", BinaryPathName); @@ -29,7 +30,7 @@ BOOL Create(LPCTSTR ServiceName, LPCTSTR *ServiceArgs) printf("%s\n", *Options); Options++; } - +#endif hSc = CreateService(hSCManager, ServiceName, ServiceName, @@ -50,9 +51,8 @@ BOOL Create(LPCTSTR ServiceName, LPCTSTR *ServiceArgs) ReportLastError(); return FALSE; } - else - { - CloseServiceHandle(hSc); - return TRUE; - } + + _tprintf(_T("[SC] CreateService SUCCESS\n")); + CloseServiceHandle(hSc); + return TRUE; } diff --git a/reactos/subsys/system/sc/delete.c b/reactos/subsys/system/sc/delete.c index 0a831d97caa..2873108ee3e 100644 --- a/reactos/subsys/system/sc/delete.c +++ b/reactos/subsys/system/sc/delete.c @@ -15,8 +15,10 @@ BOOL Delete(LPCTSTR ServiceName) { SC_HANDLE hSc; +#ifdef SCDBG /* testing */ printf("service to delete - %s\n\n", ServiceName); +#endif hSc = OpenService(hSCManager, ServiceName, DELETE); @@ -34,6 +36,7 @@ BOOL Delete(LPCTSTR ServiceName) return FALSE; } + _tprintf(_T("[SC] DeleteService SUCCESS\n")); CloseServiceHandle(hSc); return TRUE; } diff --git a/reactos/subsys/system/sc/sc.c b/reactos/subsys/system/sc/sc.c index 657d6d786bd..e17ff4feaa4 100644 --- a/reactos/subsys/system/sc/sc.c +++ b/reactos/subsys/system/sc/sc.c @@ -58,8 +58,12 @@ INT ScControl(LPTSTR MachineName, // remote machine name _tprintf(_T("Remote service control is not yet implemented\n")); return 2; } - - hSCManager = OpenSCManager(MachineName, NULL, SC_MANAGER_ALL_ACCESS); + + /* if we are emurating the services, we don't need administrator access */ + if ( (_tcsicmp(Command, _T("query")) == 0) || (_tcsicmp(Command, _T("queryex")) == 0) ) + hSCManager = OpenSCManager(MachineName, NULL, SC_MANAGER_ENUMERATE_SERVICE); + else + hSCManager = OpenSCManager(MachineName, NULL, SC_MANAGER_ALL_ACCESS); if (hSCManager == NULL) { _tprintf(_T("[SC] OpenSCManager FAILED %lu:\n\n"), GetLastError()); diff --git a/reactos/subsys/system/sc/sc.h b/reactos/subsys/system/sc/sc.h index 43c7fd2be68..c9dc2826eec 100644 --- a/reactos/subsys/system/sc/sc.h +++ b/reactos/subsys/system/sc/sc.h @@ -4,7 +4,7 @@ extern SC_HANDLE hSCManager; // declared in sc.c -//#define DBG +//#define SCDBG /* control functions */ BOOL Query(LPCTSTR ServiceName, LPCTSTR *ServiceArgs, BOOL bExtended); diff --git a/reactos/subsys/system/sc/start.c b/reactos/subsys/system/sc/start.c index 0ad094df89e..bb4277d74ae 100644 --- a/reactos/subsys/system/sc/start.c +++ b/reactos/subsys/system/sc/start.c @@ -14,9 +14,10 @@ BOOL Start(LPCTSTR ServiceName, LPCTSTR *ServiceArgs, INT ArgCount) { SC_HANDLE hSc; - SERVICE_STATUS_PROCESS ServiceStatus; + SERVICE_STATUS_PROCESS ServiceStatus, ServiceStatus2; DWORD BytesNeeded; +#ifdef SCDBG /* testing */ _tprintf(_T("service to start - %s\n\n"), ServiceName); _tprintf(_T("Arguments :\n")); @@ -25,7 +26,7 @@ BOOL Start(LPCTSTR ServiceName, LPCTSTR *ServiceArgs, INT ArgCount) printf("%s\n", *ServiceArgs); ServiceArgs++; } - +#endif /* get a handle to the service requested for starting */ hSc = OpenService(hSCManager, ServiceName, SERVICE_ALL_ACCESS); @@ -40,7 +41,7 @@ BOOL Start(LPCTSTR ServiceName, LPCTSTR *ServiceArgs, INT ArgCount) /* start the service opened */ if (! StartService(hSc, ArgCount, ServiceArgs)) { - _tprintf(_T("StartService failed\n")); + _tprintf(_T("[SC] StartService FAILED %lu:\n\n"), GetLastError()); ReportLastError(); return FALSE; } @@ -77,11 +78,22 @@ BOOL Start(LPCTSTR ServiceName, LPCTSTR *ServiceArgs, INT ArgCount) } } + QueryServiceStatusEx(hSc, SC_STATUS_PROCESS_INFO, (LPBYTE)&ServiceStatus2, + sizeof(SERVICE_STATUS_PROCESS), &BytesNeeded); + CloseServiceHandle(hSc); if (ServiceStatus.dwCurrentState == SERVICE_RUNNING) { - _tprintf(_T("%s is running\n"), ServiceName); + _tprintf(_T("\nSERVICE_NAME: %s\n"), ServiceName); + _tprintf(_T("\tTYPE : %lu\n"), ServiceStatus2.dwServiceType); + _tprintf(_T("\tSTATE : %lu\n"), ServiceStatus2.dwCurrentState); + _tprintf(_T("\tWIN32_EXIT_CODE : %lu\n"), ServiceStatus2.dwWin32ExitCode); + _tprintf(_T("\tCHECKPOINT : %lu\n"), ServiceStatus2.dwCheckPoint); + _tprintf(_T("\tWAIT_HINT : %lu\n"), ServiceStatus2.dwWaitHint); + _tprintf(_T("\tPID : %lu\n"), ServiceStatus2.dwProcessId); + _tprintf(_T("\tFLAGS : %lu\n"), ServiceStatus2.dwServiceFlags); + return TRUE; } else