1 // Copyright © 2015, Peter Atashian
2 // Licensed under the MIT License <LICENSE.md>
3 //! Header file for the Service Control Manager
4 //80
5 pub const SERVICE_NO_CHANGE: ::DWORD = 0xffffffff;
6 pub const SERVICE_ACTIVE: ::DWORD = 0x00000001;
7 pub const SERVICE_INACTIVE: ::DWORD = 0x00000002;
8 pub const SERVICE_STATE_ALL: ::DWORD = SERVICE_ACTIVE | SERVICE_INACTIVE;
9 pub const SERVICE_CONTROL_STOP: ::DWORD = 0x00000001;
10 pub const SERVICE_CONTROL_PAUSE: ::DWORD = 0x00000002;
11 pub const SERVICE_CONTROL_CONTINUE: ::DWORD = 0x00000003;
12 pub const SERVICE_CONTROL_INTERROGATE: ::DWORD = 0x00000004;
13 pub const SERVICE_CONTROL_SHUTDOWN: ::DWORD = 0x00000005;
14 pub const SERVICE_CONTROL_PARAMCHANGE: ::DWORD = 0x00000006;
15 pub const SERVICE_CONTROL_NETBINDADD: ::DWORD = 0x00000007;
16 pub const SERVICE_CONTROL_NETBINDREMOVE: ::DWORD = 0x00000008;
17 pub const SERVICE_CONTROL_NETBINDENABLE: ::DWORD = 0x00000009;
18 pub const SERVICE_CONTROL_NETBINDDISABLE: ::DWORD = 0x0000000A;
19 pub const SERVICE_CONTROL_DEVICEEVENT: ::DWORD = 0x0000000B;
20 pub const SERVICE_CONTROL_HARDWAREPROFILECHANGE: ::DWORD = 0x0000000C;
21 pub const SERVICE_CONTROL_POWEREVENT: ::DWORD = 0x0000000D;
22 pub const SERVICE_CONTROL_SESSIONCHANGE: ::DWORD = 0x0000000E;
23 pub const SERVICE_CONTROL_PRESHUTDOWN: ::DWORD = 0x0000000F;
24 pub const SERVICE_CONTROL_TIMECHANGE: ::DWORD = 0x00000010;
25 pub const SERVICE_CONTROL_TRIGGEREVENT: ::DWORD = 0x00000020;
26 pub const SERVICE_STOPPED: ::DWORD = 0x00000001;
27 pub const SERVICE_START_PENDING: ::DWORD = 0x00000002;
28 pub const SERVICE_STOP_PENDING: ::DWORD = 0x00000003;
29 pub const SERVICE_RUNNING: ::DWORD = 0x00000004;
30 pub const SERVICE_CONTINUE_PENDING: ::DWORD = 0x00000005;
31 pub const SERVICE_PAUSE_PENDING: ::DWORD = 0x00000006;
32 pub const SERVICE_PAUSED: ::DWORD = 0x00000007;
33 pub const SERVICE_ACCEPT_STOP: ::DWORD = 0x00000001;
34 pub const SERVICE_ACCEPT_PAUSE_CONTINUE: ::DWORD = 0x00000002;
35 pub const SERVICE_ACCEPT_SHUTDOWN: ::DWORD = 0x00000004;
36 pub const SERVICE_ACCEPT_PARAMCHANGE: ::DWORD = 0x00000008;
37 pub const SERVICE_ACCEPT_NETBINDCHANGE: ::DWORD = 0x00000010;
38 pub const SERVICE_ACCEPT_HARDWAREPROFILECHANGE: ::DWORD = 0x00000020;
39 pub const SERVICE_ACCEPT_POWEREVENT: ::DWORD = 0x00000040;
40 pub const SERVICE_ACCEPT_SESSIONCHANGE: ::DWORD = 0x00000080;
41 pub const SERVICE_ACCEPT_PRESHUTDOWN: ::DWORD = 0x00000100;
42 pub const SERVICE_ACCEPT_TIMECHANGE: ::DWORD = 0x00000200;
43 pub const SERVICE_ACCEPT_TRIGGEREVENT: ::DWORD = 0x00000400;
44 pub const SC_MANAGER_CONNECT: ::DWORD = 0x0001;
45 pub const SC_MANAGER_CREATE_SERVICE: ::DWORD = 0x0002;
46 pub const SC_MANAGER_ENUMERATE_SERVICE: ::DWORD = 0x0004;
47 pub const SC_MANAGER_LOCK: ::DWORD = 0x0008;
48 pub const SC_MANAGER_QUERY_LOCK_STATUS: ::DWORD = 0x0010;
49 pub const SC_MANAGER_MODIFY_BOOT_CONFIG: ::DWORD = 0x0020;
50 pub const SC_MANAGER_ALL_ACCESS: ::DWORD = ::STANDARD_RIGHTS_REQUIRED | SC_MANAGER_CONNECT
51     | SC_MANAGER_CREATE_SERVICE | SC_MANAGER_ENUMERATE_SERVICE | SC_MANAGER_LOCK
52     | SC_MANAGER_QUERY_LOCK_STATUS | SC_MANAGER_MODIFY_BOOT_CONFIG;
53 pub const SERVICE_QUERY_CONFIG: ::DWORD = 0x0001;
54 pub const SERVICE_CHANGE_CONFIG: ::DWORD = 0x0002;
55 pub const SERVICE_QUERY_STATUS: ::DWORD = 0x0004;
56 pub const SERVICE_ENUMERATE_DEPENDENTS: ::DWORD = 0x0008;
57 pub const SERVICE_START: ::DWORD = 0x0010;
58 pub const SERVICE_STOP: ::DWORD = 0x0020;
59 pub const SERVICE_PAUSE_CONTINUE: ::DWORD = 0x0040;
60 pub const SERVICE_INTERROGATE: ::DWORD = 0x0080;
61 pub const SERVICE_USER_DEFINED_CONTROL: ::DWORD = 0x0100;
62 pub const SERVICE_ALL_ACCESS: ::DWORD = ::STANDARD_RIGHTS_REQUIRED | SERVICE_QUERY_CONFIG
63     | SERVICE_CHANGE_CONFIG | SERVICE_QUERY_STATUS | SERVICE_ENUMERATE_DEPENDENTS | SERVICE_START
64     | SERVICE_STOP | SERVICE_PAUSE_CONTINUE | SERVICE_INTERROGATE | SERVICE_USER_DEFINED_CONTROL;
65 pub const SERVICE_RUNS_IN_SYSTEM_PROCESS: ::DWORD = 0x00000001;
66 pub const SERVICE_CONFIG_DESCRIPTION: ::DWORD = 1;
67 pub const SERVICE_CONFIG_FAILURE_ACTIONS: ::DWORD = 2;
68 pub const SERVICE_CONFIG_DELAYED_AUTO_START_INFO: ::DWORD = 3;
69 pub const SERVICE_CONFIG_FAILURE_ACTIONS_FLAG: ::DWORD = 4;
70 pub const SERVICE_CONFIG_SERVICE_SID_INFO: ::DWORD = 5;
71 pub const SERVICE_CONFIG_REQUIRED_PRIVILEGES_INFO: ::DWORD = 6;
72 pub const SERVICE_CONFIG_PRESHUTDOWN_INFO: ::DWORD = 7;
73 pub const SERVICE_CONFIG_TRIGGER_INFO: ::DWORD = 8;
74 pub const SERVICE_CONFIG_PREFERRED_NODE: ::DWORD = 9;
75 pub const SERVICE_CONFIG_LAUNCH_PROTECTED: ::DWORD = 12;
76 pub const SERVICE_NOTIFY_STATUS_CHANGE_1: ::DWORD = 1;
77 pub const SERVICE_NOTIFY_STATUS_CHANGE_2: ::DWORD = 2;
78 pub const SERVICE_NOTIFY_STATUS_CHANGE: ::DWORD = SERVICE_NOTIFY_STATUS_CHANGE_2;
79 pub const SERVICE_NOTIFY_STOPPED: ::DWORD = 0x00000001;
80 pub const SERVICE_NOTIFY_START_PENDING: ::DWORD = 0x00000002;
81 pub const SERVICE_NOTIFY_STOP_PENDING: ::DWORD = 0x00000004;
82 pub const SERVICE_NOTIFY_RUNNING: ::DWORD = 0x00000008;
83 pub const SERVICE_NOTIFY_CONTINUE_PENDING: ::DWORD = 0x00000010;
84 pub const SERVICE_NOTIFY_PAUSE_PENDING: ::DWORD = 0x00000020;
85 pub const SERVICE_NOTIFY_PAUSED: ::DWORD = 0x00000040;
86 pub const SERVICE_NOTIFY_CREATED: ::DWORD = 0x00000080;
87 pub const SERVICE_NOTIFY_DELETED: ::DWORD = 0x00000100;
88 pub const SERVICE_NOTIFY_DELETE_PENDING: ::DWORD = 0x00000200;
89 pub const SERVICE_STOP_REASON_FLAG_MIN: ::DWORD = 0x00000000;
90 pub const SERVICE_STOP_REASON_FLAG_UNPLANNED: ::DWORD = 0x10000000;
91 pub const SERVICE_STOP_REASON_FLAG_CUSTOM: ::DWORD = 0x20000000;
92 pub const SERVICE_STOP_REASON_FLAG_PLANNED: ::DWORD = 0x40000000;
93 pub const SERVICE_STOP_REASON_FLAG_MAX: ::DWORD = 0x80000000;
94 pub const SERVICE_STOP_REASON_MAJOR_MIN: ::DWORD = 0x00000000;
95 pub const SERVICE_STOP_REASON_MAJOR_OTHER: ::DWORD = 0x00010000;
96 pub const SERVICE_STOP_REASON_MAJOR_HARDWARE: ::DWORD = 0x00020000;
97 pub const SERVICE_STOP_REASON_MAJOR_OPERATINGSYSTEM: ::DWORD = 0x00030000;
98 pub const SERVICE_STOP_REASON_MAJOR_SOFTWARE: ::DWORD = 0x00040000;
99 pub const SERVICE_STOP_REASON_MAJOR_APPLICATION: ::DWORD = 0x00050000;
100 pub const SERVICE_STOP_REASON_MAJOR_NONE: ::DWORD = 0x00060000;
101 pub const SERVICE_STOP_REASON_MAJOR_MAX: ::DWORD = 0x00070000;
102 pub const SERVICE_STOP_REASON_MAJOR_MIN_CUSTOM: ::DWORD = 0x00400000;
103 pub const SERVICE_STOP_REASON_MAJOR_MAX_CUSTOM: ::DWORD = 0x00ff0000;
104 pub const SERVICE_STOP_REASON_MINOR_MIN: ::DWORD = 0x00000000;
105 pub const SERVICE_STOP_REASON_MINOR_OTHER: ::DWORD = 0x00000001;
106 pub const SERVICE_STOP_REASON_MINOR_MAINTENANCE: ::DWORD = 0x00000002;
107 pub const SERVICE_STOP_REASON_MINOR_INSTALLATION: ::DWORD = 0x00000003;
108 pub const SERVICE_STOP_REASON_MINOR_UPGRADE: ::DWORD = 0x00000004;
109 pub const SERVICE_STOP_REASON_MINOR_RECONFIG: ::DWORD = 0x00000005;
110 pub const SERVICE_STOP_REASON_MINOR_HUNG: ::DWORD = 0x00000006;
111 pub const SERVICE_STOP_REASON_MINOR_UNSTABLE: ::DWORD = 0x00000007;
112 pub const SERVICE_STOP_REASON_MINOR_DISK: ::DWORD = 0x00000008;
113 pub const SERVICE_STOP_REASON_MINOR_NETWORKCARD: ::DWORD = 0x00000009;
114 pub const SERVICE_STOP_REASON_MINOR_ENVIRONMENT: ::DWORD = 0x0000000a;
115 pub const SERVICE_STOP_REASON_MINOR_HARDWARE_DRIVER: ::DWORD = 0x0000000b;
116 pub const SERVICE_STOP_REASON_MINOR_OTHERDRIVER: ::DWORD = 0x0000000c;
117 pub const SERVICE_STOP_REASON_MINOR_SERVICEPACK: ::DWORD = 0x0000000d;
118 pub const SERVICE_STOP_REASON_MINOR_SOFTWARE_UPDATE: ::DWORD = 0x0000000e;
119 pub const SERVICE_STOP_REASON_MINOR_SECURITYFIX: ::DWORD = 0x0000000f;
120 pub const SERVICE_STOP_REASON_MINOR_SECURITY: ::DWORD = 0x00000010;
121 pub const SERVICE_STOP_REASON_MINOR_NETWORK_CONNECTIVITY: ::DWORD = 0x00000011;
122 pub const SERVICE_STOP_REASON_MINOR_WMI: ::DWORD = 0x00000012;
123 pub const SERVICE_STOP_REASON_MINOR_SERVICEPACK_UNINSTALL: ::DWORD = 0x00000013;
124 pub const SERVICE_STOP_REASON_MINOR_SOFTWARE_UPDATE_UNINSTALL: ::DWORD = 0x00000014;
125 pub const SERVICE_STOP_REASON_MINOR_SECURITYFIX_UNINSTALL: ::DWORD = 0x00000015;
126 pub const SERVICE_STOP_REASON_MINOR_MMC: ::DWORD = 0x00000016;
127 pub const SERVICE_STOP_REASON_MINOR_NONE: ::DWORD = 0x00000017;
128 pub const SERVICE_STOP_REASON_MINOR_MAX: ::DWORD = 0x00000018;
129 pub const SERVICE_STOP_REASON_MINOR_MIN_CUSTOM: ::DWORD = 0x00000100;
130 pub const SERVICE_STOP_REASON_MINOR_MAX_CUSTOM: ::DWORD = 0x0000FFFF;
131 pub const SERVICE_CONTROL_STATUS_REASON_INFO: ::DWORD = 1;
132 pub const SERVICE_SID_TYPE_NONE: ::DWORD = 0x00000000;
133 pub const SERVICE_SID_TYPE_UNRESTRICTED: ::DWORD = 0x00000001;
134 pub const SERVICE_SID_TYPE_RESTRICTED: ::DWORD = 0x00000002 | SERVICE_SID_TYPE_UNRESTRICTED;
135 pub const SERVICE_TRIGGER_TYPE_DEVICE_INTERFACE_ARRIVAL: ::DWORD = 1;
136 pub const SERVICE_TRIGGER_TYPE_IP_ADDRESS_AVAILABILITY: ::DWORD = 2;
137 pub const SERVICE_TRIGGER_TYPE_DOMAIN_JOIN: ::DWORD = 3;
138 pub const SERVICE_TRIGGER_TYPE_FIREWALL_PORT_EVENT: ::DWORD = 4;
139 pub const SERVICE_TRIGGER_TYPE_GROUP_POLICY: ::DWORD = 5;
140 pub const SERVICE_TRIGGER_TYPE_NETWORK_ENDPOINT: ::DWORD = 6;
141 pub const SERVICE_TRIGGER_TYPE_CUSTOM_SYSTEM_STATE_CHANGE: ::DWORD = 7;
142 pub const SERVICE_TRIGGER_TYPE_CUSTOM: ::DWORD = 20;
143 pub const SERVICE_TRIGGER_DATA_TYPE_BINARY: ::DWORD = 1;
144 pub const SERVICE_TRIGGER_DATA_TYPE_STRING: ::DWORD = 2;
145 pub const SERVICE_TRIGGER_DATA_TYPE_LEVEL: ::DWORD = 3;
146 pub const SERVICE_TRIGGER_DATA_TYPE_KEYWORD_ANY: ::DWORD = 4;
147 pub const SERVICE_TRIGGER_DATA_TYPE_KEYWORD_ALL: ::DWORD = 5;
148 pub const SERVICE_START_REASON_DEMAND: ::DWORD = 0x00000001;
149 pub const SERVICE_START_REASON_AUTO: ::DWORD = 0x00000002;
150 pub const SERVICE_START_REASON_TRIGGER: ::DWORD = 0x00000004;
151 pub const SERVICE_START_REASON_RESTART_ON_FAILURE: ::DWORD = 0x00000008;
152 pub const SERVICE_START_REASON_DELAYEDAUTO: ::DWORD = 0x00000010;
153 pub const SERVICE_DYNAMIC_INFORMATION_LEVEL_START_REASON: ::DWORD = 1;
154 pub const SERVICE_LAUNCH_PROTECTED_NONE: ::DWORD = 0;
155 pub const SERVICE_LAUNCH_PROTECTED_WINDOWS: ::DWORD = 1;
156 pub const SERVICE_LAUNCH_PROTECTED_WINDOWS_LIGHT: ::DWORD = 2;
157 pub const SERVICE_LAUNCH_PROTECTED_ANTIMALWARE_LIGHT: ::DWORD = 3;
158 //678
159 DECLARE_HANDLE!(SC_HANDLE, SC_HANDLE__);
160 pub type LPSC_HANDLE = *mut SC_HANDLE;
161 DECLARE_HANDLE!(SERVICE_STATUS_HANDLE, SERVICE_STATUS_HANDLE__);
162 ENUM!{enum SC_STATUS_TYPE {
163     SC_STATUS_PROCESS_INFO = 0,
164 }}
165 ENUM!{enum _SC_ENUM_TYPE {
166     SC_ENUM_PROCESS_INFO = 0,
167 }}
168 //700
169 STRUCT!{struct SERVICE_STATUS {
170     dwServiceType: ::DWORD,
171     dwCurrentState: ::DWORD,
172     dwControlsAccepted: ::DWORD,
173     dwWin32ExitCode: ::DWORD,
174     dwServiceSpecificExitCode: ::DWORD,
175     dwCheckPoint: ::DWORD,
176     dwWaitHint: ::DWORD,
177 }}
178 pub type LPSERVICE_STATUS = *mut SERVICE_STATUS;
179 //848
180 pub type LPSERVICE_MAIN_FUNCTIONW = Option<unsafe extern "system" fn(
181     dwNumServicesArgs: ::DWORD, lpServiceArgVectors: *mut ::LPWSTR,
182 )>;
183 pub type LPSERVICE_MAIN_FUNCTIONA = Option<unsafe extern "system" fn(
184     dwNumServicesArgs: ::DWORD, lpServiceArgVectors: *mut ::LPSTR,
185 )>;
186 STRUCT!{nodebug struct SERVICE_TABLE_ENTRYA {
187     lpServiceName: ::LPCSTR,
188     lpServiceProc: LPSERVICE_MAIN_FUNCTIONA,
189 }}
190 pub type LPSERVICE_TABLE_ENTRYA = *mut SERVICE_TABLE_ENTRYA;
191 STRUCT!{nodebug struct SERVICE_TABLE_ENTRYW {
192     lpServiceName: ::LPCWSTR,
193     lpServiceProc: LPSERVICE_MAIN_FUNCTIONW,
194 }}
195 pub type LPSERVICE_TABLE_ENTRYW = *mut SERVICE_TABLE_ENTRYW;
196 //900
197 pub type LPHANDLER_FUNCTION = Option<unsafe extern "system" fn(dwControl: ::DWORD)>;
198 pub type LPHANDLER_FUNCTION_EX = Option<unsafe extern "system" fn(
199     dwControl: ::DWORD, dwEventType: ::DWORD, lpEventData: ::LPVOID, lpContext: ::LPVOID,
200 ) -> ::DWORD>;
201