This source file includes following definitions.
- ControlService
- StartService
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 #include "LoadLibraryWrapper.hpp"
22
23
24 #include<winsvc.h>
25
26 namespace jmmcg { namespace NTUtils {
27
28 class win_exception;
29
30 class AFX_EXT_CLASS ServiceManipulation : virtual protected LoadLibraryWrapper {
31 public:
32 typedef win_exception exception_type;
33
34 __stdcall ServiceManipulation(const TCHAR * const machine=NULL);
35 __stdcall ~ServiceManipulation(void);
36
37 void __fastcall OpenService(const TCHAR * const service_name, const DWORD access);
38 inline unsigned long __fastcall ControlService(const DWORD dwControl,SERVICE_STATUS &status) noexcept(true) {if (!(*pControlService)(curr_service,dwControl,&status)) {return ::GetLastError();};return NULL;};
39 inline unsigned long __fastcall StartService(const DWORD num_args,const TCHAR **args) noexcept(true) {if (!(*pStartService)(curr_service,num_args,args)) {return ::GetLastError();};return NULL;};
40
41 private:
42 typedef BOOL (WINAPI * const CloseServiceHandleType)(SC_HANDLE hSCObject);
43 typedef SC_HANDLE (WINAPI * const OpenServiceType)(SC_HANDLE hSCManager,LPCTSTR lpServiceName,DWORD dwDesiredAccess);
44 typedef BOOL (WINAPI * const ControlServiceType)(SC_HANDLE hService,DWORD dwControl,LPSERVICE_STATUS lpServiceStatus);
45 typedef BOOL (WINAPI * const StartServiceType)(SC_HANDLE hService,DWORD dwNumServiceArgs,LPCTSTR *lpServiceArgVectors);
46
47 const CloseServiceHandleType pCloseServiceHandle;
48 const OpenServiceType pOpenService;
49 const ControlServiceType pControlService;
50 const StartServiceType pStartService;
51 SC_HANDLE scm;
52 SC_HANDLE curr_service;
53 const TCHAR *curr_service_name;
54
55
56 inline ServiceManipulation(const ServiceManipulation &);
57 inline ServiceManipulation & __fastcall operator=(const ServiceManipulation &);
58 };
59
60 } }