libjmmcg
release_579_6_g8cffd
A C++ library containing an eclectic mix of useful, advanced components.
ServiceManipulation.hpp
Go to the documentation of this file.
1
/******************************************************************************
2
** Copyright © 2002 by J.M.McGuiness, coder@hussar.me.uk
3
**
4
** This library is free software; you can redistribute it and/or
5
** modify it under the terms of the GNU Lesser General Public
6
** License as published by the Free Software Foundation; either
7
** version 2.1 of the License, or (at your option) any later version.
8
**
9
** This library is distributed in the hope that it will be useful,
10
** but WITHOUT ANY WARRANTY; without even the implied warranty of
11
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12
** Lesser General Public License for more details.
13
**
14
** You should have received a copy of the GNU Lesser General Public
15
** License along with this library; if not, write to the Free Software
16
** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17
*/
18
19
#
include
"LoadLibraryWrapper.hpp"
20
21
// For the Service Manager functions. (NT only.)
22
#
include
<
winsvc
.
h
>
23
24
namespace
jmmcg
{
namespace
NTUtils
{
25
26
class
win_exception;
27
28
class
AFX_EXT_CLASS
ServiceManipulation
:
virtual
protected
LoadLibraryWrapper
{
29
public
:
30
typedef
win_exception
exception_type
;
31
32
__stdcall
ServiceManipulation
(
const
TCHAR
*
const
machine
=
NULL
);
33
__stdcall
~
ServiceManipulation
(
void
);
34
35
void
__fastcall
OpenService
(
const
TCHAR
*
const
service_name
,
const
DWORD
access
);
36
inline
unsigned
long
__fastcall
ControlService
(
const
DWORD
dwControl
,
SERVICE_STATUS
&
status
)
noexcept
(
true
) {
if
(!(*
pControlService
)(
curr_service
,
dwControl
,&
status
)) {
return
::
GetLastError
();};
return
NULL
;};
37
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
;};
38
39
private
:
40
typedef
/*WINADVAPI*/
BOOL
(
WINAPI
*
const
CloseServiceHandleType
)(
SC_HANDLE
hSCObject
);
41
typedef
/*WINADVAPI*/
SC_HANDLE
(
WINAPI
*
const
OpenServiceType
)(
SC_HANDLE
hSCManager
,
LPCTSTR
lpServiceName
,
DWORD
dwDesiredAccess
);
42
typedef
/*WINADVAPI*/
BOOL
(
WINAPI
*
const
ControlServiceType
)(
SC_HANDLE
hService
,
DWORD
dwControl
,
LPSERVICE_STATUS
lpServiceStatus
);
43
typedef
/*WINADVAPI*/
BOOL
(
WINAPI
*
const
StartServiceType
)(
SC_HANDLE
hService
,
DWORD
dwNumServiceArgs
,
LPCTSTR
*
lpServiceArgVectors
);
44
45
const
CloseServiceHandleType
pCloseServiceHandle
;
46
const
OpenServiceType
pOpenService
;
47
const
ControlServiceType
pControlService
;
48
const
StartServiceType
pStartService
;
49
SC_HANDLE
scm
;
50
SC_HANDLE
curr_service
;
51
const
TCHAR
*
curr_service_name
;
52
53
// Stop any compiler silliness...
54
inline
ServiceManipulation
(
const
ServiceManipulation
&);
55
inline
ServiceManipulation
&
__fastcall
operator
=(
const
ServiceManipulation
&);
56
};
57
58
} }
experimental
NT-based
NTSpecific
ServiceManipulation.hpp
Generated on Tue May 11 2021 17:22:00 for libjmmcg by
1.9.2