2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS system libraries
4 * FILE: lib/advapi32/service/scm.c
5 * PURPOSE: Service control manager functions
6 * PROGRAMMER: Emanuele Aliberti
13 /* INCLUDES ******************************************************************/
17 #include "wine/debug.h"
19 WINE_DEFAULT_DEBUG_CHANNEL(advapi
);
22 /* FUNCTIONS *****************************************************************/
24 handle_t BindingHandle
= NULL
;
29 LPWSTR pszStringBinding
;
32 if (BindingHandle
!= NULL
)
35 status
= RpcStringBindingComposeW(NULL
,
43 TRACE("RpcStringBindingCompose returned 0x%x\n", status
);
47 /* Set the binding handle that will be used to bind to the server. */
48 status
= RpcBindingFromStringBindingW(pszStringBinding
,
52 TRACE("RpcBindingFromStringBinding returned 0x%x\n", status
);
55 status
= RpcStringFreeW(&pszStringBinding
);
58 TRACE("RpcStringFree returned 0x%x\n", status
);
69 if (BindingHandle
== NULL
)
72 status
= RpcBindingFree(&BindingHandle
);
75 TRACE("RpcBindingFree returned 0x%x\n", status
);
81 /**********************************************************************
82 * ChangeServiceConfig2A
87 ChangeServiceConfig2A(SC_HANDLE hService
,
91 SC_RPC_CONFIG_INFOA Info
;
94 TRACE("ChangeServiceConfig2A() called\n");
96 /* Fill relevent field of the Info structure */
97 Info
.dwInfoLevel
= dwInfoLevel
;
100 case SERVICE_CONFIG_DESCRIPTION
:
101 Info
.psd
= (LPSERVICE_DESCRIPTIONA
)&lpInfo
;
104 case SERVICE_CONFIG_FAILURE_ACTIONS
:
105 Info
.psfa
= (LPSERVICE_FAILURE_ACTIONSA
)&lpInfo
;
109 WARN("Unknown info level 0x%lx\n", dwInfoLevel
);
110 SetLastError(ERROR_INVALID_PARAMETER
);
119 dwError
= RChangeServiceConfig2A(BindingHandle
,
120 (SC_RPC_HANDLE
)(ULONG_PTR
)hService
,
122 if (dwError
!= ERROR_SUCCESS
)
124 ERR("RChangeServiceConfig2A() failed (Error %lu)\n", dwError
);
125 SetLastError(dwError
);
133 /**********************************************************************
134 * ChangeServiceConfig2W
139 ChangeServiceConfig2W(SC_HANDLE hService
,
143 SC_RPC_CONFIG_INFOW Info
;
146 TRACE("ChangeServiceConfig2W() called\n");
148 /* Fill relevent field of the Info structure */
149 Info
.dwInfoLevel
= dwInfoLevel
;
152 case SERVICE_CONFIG_DESCRIPTION
:
154 Info
.psd
= (LPSERVICE_DESCRIPTIONW
)&lpInfo
;
158 case SERVICE_CONFIG_FAILURE_ACTIONS
:
159 Info
.psfa
= (LPSERVICE_FAILURE_ACTIONSW
)&lpInfo
;
163 WARN("Unknown info level 0x%lx\n", dwInfoLevel
);
164 SetLastError(ERROR_INVALID_PARAMETER
);
173 dwError
= RChangeServiceConfig2W(BindingHandle
,
174 (SC_RPC_HANDLE
)hService
,
176 if (dwError
!= ERROR_SUCCESS
)
178 ERR("RChangeServiceConfig2W() failed (Error %lu)\n", dwError
);
179 SetLastError(dwError
);
187 /**********************************************************************
188 * ChangeServiceConfigA
193 ChangeServiceConfigA(SC_HANDLE hService
,
196 DWORD dwErrorControl
,
197 LPCSTR lpBinaryPathName
,
198 LPCSTR lpLoadOrderGroup
,
200 LPCSTR lpDependencies
,
201 LPCSTR lpServiceStartName
,
203 LPCSTR lpDisplayName
)
206 DWORD dwDependenciesLength
= 0;
210 TRACE("ChangeServiceConfigA() called\n");
212 /* Calculate the Dependencies length*/
213 if (lpDependencies
!= NULL
)
215 lpStr
= (LPSTR
)lpDependencies
;
218 dwLength
= strlen(lpStr
) + 1;
219 dwDependenciesLength
+= dwLength
;
220 lpStr
= lpStr
+ dwLength
;
222 dwDependenciesLength
++;
225 /* FIXME: Encrypt the password */
229 /* Call to services.exe using RPC */
230 dwError
= RChangeServiceConfigA(BindingHandle
,
231 (SC_RPC_HANDLE
)hService
,
235 (LPSTR
)lpBinaryPathName
,
236 (LPSTR
)lpLoadOrderGroup
,
238 (LPSTR
)lpDependencies
,
239 dwDependenciesLength
,
240 (LPSTR
)lpServiceStartName
,
241 NULL
, /* FIXME: lpPassword */
242 0, /* FIXME: dwPasswordLength */
243 (LPSTR
)lpDisplayName
);
244 if (dwError
!= ERROR_SUCCESS
)
246 ERR("RChangeServiceConfigA() failed (Error %lu)\n", dwError
);
247 SetLastError(dwError
);
255 /**********************************************************************
256 * ChangeServiceConfigW
261 ChangeServiceConfigW(SC_HANDLE hService
,
264 DWORD dwErrorControl
,
265 LPCWSTR lpBinaryPathName
,
266 LPCWSTR lpLoadOrderGroup
,
268 LPCWSTR lpDependencies
,
269 LPCWSTR lpServiceStartName
,
271 LPCWSTR lpDisplayName
)
274 DWORD dwDependenciesLength
= 0;
278 TRACE("ChangeServiceConfigW() called\n");
280 /* Calculate the Dependencies length*/
281 if (lpDependencies
!= NULL
)
283 lpStr
= (LPWSTR
)lpDependencies
;
286 dwLength
= wcslen(lpStr
) + 1;
287 dwDependenciesLength
+= dwLength
;
288 lpStr
= lpStr
+ dwLength
;
290 dwDependenciesLength
++;
293 /* FIXME: Encrypt the password */
297 /* Call to services.exe using RPC */
298 dwError
= RChangeServiceConfigW(BindingHandle
,
299 (SC_RPC_HANDLE
)hService
,
303 (LPWSTR
)lpBinaryPathName
,
304 (LPWSTR
)lpLoadOrderGroup
,
306 (LPBYTE
)lpDependencies
,
307 dwDependenciesLength
,
308 (LPWSTR
)lpServiceStartName
,
309 NULL
, /* FIXME: lpPassword */
310 0, /* FIXME: dwPasswordLength */
311 (LPWSTR
)lpDisplayName
);
312 if (dwError
!= ERROR_SUCCESS
)
314 ERR("RChangeServiceConfigW() failed (Error %lu)\n", dwError
);
315 SetLastError(dwError
);
323 /**********************************************************************
329 CloseServiceHandle(SC_HANDLE hSCObject
)
333 TRACE("CloseServiceHandle() called\n");
337 /* Call to services.exe using RPC */
338 dwError
= RCloseServiceHandle(BindingHandle
,
339 (LPSC_RPC_HANDLE
)&hSCObject
);
342 ERR("RCloseServiceHandle() failed (Error %lu)\n", dwError
);
343 SetLastError(dwError
);
347 TRACE("CloseServiceHandle() done\n");
353 /**********************************************************************
359 ControlService(SC_HANDLE hService
,
361 LPSERVICE_STATUS lpServiceStatus
)
365 TRACE("ControlService(%x, %x, %p)\n",
366 hService
, dwControl
, lpServiceStatus
);
370 /* Call to services.exe using RPC */
371 dwError
= RControlService(BindingHandle
,
372 (SC_RPC_HANDLE
)hService
,
375 if (dwError
!= ERROR_SUCCESS
)
377 ERR("RControlService() failed (Error %lu)\n", dwError
);
378 SetLastError(dwError
);
382 TRACE("ControlService() done\n");
388 /**********************************************************************
394 ControlServiceEx(IN SC_HANDLE hService
,
396 IN DWORD dwInfoLevel
,
397 IN OUT PVOID pControlParams
)
399 FIXME("ControlServiceEx(0x%p, 0x%x, 0x%x, 0x%p) UNIMPLEMENTED!\n",
400 hService
, dwControl
, dwInfoLevel
, pControlParams
);
401 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
407 /**********************************************************************
413 CreateServiceA(SC_HANDLE hSCManager
,
414 LPCSTR lpServiceName
,
415 LPCSTR lpDisplayName
,
416 DWORD dwDesiredAccess
,
419 DWORD dwErrorControl
,
420 LPCSTR lpBinaryPathName
,
421 LPCSTR lpLoadOrderGroup
,
423 LPCSTR lpDependencies
,
424 LPCSTR lpServiceStartName
,
427 SC_HANDLE RetVal
= NULL
;
428 LPWSTR lpServiceNameW
= NULL
;
429 LPWSTR lpDisplayNameW
= NULL
;
430 LPWSTR lpBinaryPathNameW
= NULL
;
431 LPWSTR lpLoadOrderGroupW
= NULL
;
432 LPWSTR lpDependenciesW
= NULL
;
433 LPWSTR lpServiceStartNameW
= NULL
;
434 LPWSTR lpPasswordW
= NULL
;
435 DWORD dwDependenciesLength
= 0;
442 len
= MultiByteToWideChar(CP_ACP
, 0, lpServiceName
, -1, NULL
, 0);
443 lpServiceNameW
= HeapAlloc(GetProcessHeap(), 0, len
* sizeof(WCHAR
));
446 SetLastError(ERROR_NOT_ENOUGH_MEMORY
);
449 MultiByteToWideChar(CP_ACP
, 0, lpServiceName
, -1, lpServiceNameW
, len
);
454 len
= MultiByteToWideChar(CP_ACP
, 0, lpDisplayName
, -1, NULL
, 0);
455 lpDisplayNameW
= HeapAlloc(GetProcessHeap(), 0, len
* sizeof(WCHAR
));
458 SetLastError(ERROR_NOT_ENOUGH_MEMORY
);
461 MultiByteToWideChar(CP_ACP
, 0, lpDisplayName
, -1, lpDisplayNameW
, len
);
464 if (lpBinaryPathName
)
466 len
= MultiByteToWideChar(CP_ACP
, 0, lpBinaryPathName
, -1, NULL
, 0);
467 lpBinaryPathNameW
= HeapAlloc(GetProcessHeap(), 0, len
* sizeof(WCHAR
));
468 if (!lpBinaryPathNameW
)
470 SetLastError(ERROR_NOT_ENOUGH_MEMORY
);
473 MultiByteToWideChar(CP_ACP
, 0, lpBinaryPathName
, -1, lpBinaryPathNameW
, len
);
476 if (lpLoadOrderGroup
)
478 len
= MultiByteToWideChar(CP_ACP
, 0, lpLoadOrderGroup
, -1, NULL
, 0);
479 lpLoadOrderGroupW
= HeapAlloc(GetProcessHeap(), 0, len
* sizeof(WCHAR
));
480 if (!lpLoadOrderGroupW
)
482 SetLastError(ERROR_NOT_ENOUGH_MEMORY
);
485 MultiByteToWideChar(CP_ACP
, 0, lpLoadOrderGroup
, -1, lpLoadOrderGroupW
, len
);
490 lpStr
= (LPSTR
)lpDependencies
;
493 dwLength
= strlen(lpStr
) + 1;
494 dwDependenciesLength
+= dwLength
;
495 lpStr
= lpStr
+ dwLength
;
497 dwDependenciesLength
++;
499 lpDependenciesW
= HeapAlloc(GetProcessHeap(), 0, dwDependenciesLength
* sizeof(WCHAR
));
500 if (!lpDependenciesW
)
502 SetLastError(ERROR_NOT_ENOUGH_MEMORY
);
505 MultiByteToWideChar(CP_ACP
, 0, lpDependencies
, dwDependenciesLength
, lpDependenciesW
, dwDependenciesLength
);
508 if (lpServiceStartName
)
510 len
= MultiByteToWideChar(CP_ACP
, 0, lpServiceStartName
, -1, NULL
, 0);
511 lpServiceStartNameW
= HeapAlloc(GetProcessHeap(), 0, len
* sizeof(WCHAR
));
512 if (!lpServiceStartNameW
)
514 SetLastError(ERROR_NOT_ENOUGH_MEMORY
);
517 MultiByteToWideChar(CP_ACP
, 0, lpServiceStartName
, -1, lpServiceStartNameW
, len
);
522 len
= MultiByteToWideChar(CP_ACP
, 0, lpPassword
, -1, NULL
, 0);
523 lpPasswordW
= HeapAlloc(GetProcessHeap(), 0, len
* sizeof(WCHAR
));
526 SetLastError(ERROR_NOT_ENOUGH_MEMORY
);
529 MultiByteToWideChar(CP_ACP
, 0, lpPassword
, -1, lpPasswordW
, len
);
532 RetVal
= CreateServiceW(hSCManager
,
547 if (lpServiceNameW
!=NULL
)
548 HeapFree(GetProcessHeap(), 0, lpServiceNameW
);
550 if (lpDisplayNameW
!= NULL
)
551 HeapFree(GetProcessHeap(), 0, lpDisplayNameW
);
553 if (lpBinaryPathNameW
!= NULL
)
554 HeapFree(GetProcessHeap(), 0, lpBinaryPathNameW
);
556 if (lpLoadOrderGroupW
!= NULL
)
557 HeapFree(GetProcessHeap(), 0, lpLoadOrderGroupW
);
559 if (lpDependenciesW
!= NULL
)
560 HeapFree(GetProcessHeap(), 0, lpDependenciesW
);
562 if (lpServiceStartNameW
!= NULL
)
563 HeapFree(GetProcessHeap(), 0, lpServiceStartNameW
);
565 if (lpPasswordW
!= NULL
)
566 HeapFree(GetProcessHeap(), 0, lpPasswordW
);
572 /**********************************************************************
578 CreateServiceW(SC_HANDLE hSCManager
,
579 LPCWSTR lpServiceName
,
580 LPCWSTR lpDisplayName
,
581 DWORD dwDesiredAccess
,
584 DWORD dwErrorControl
,
585 LPCWSTR lpBinaryPathName
,
586 LPCWSTR lpLoadOrderGroup
,
588 LPCWSTR lpDependencies
,
589 LPCWSTR lpServiceStartName
,
592 SC_HANDLE hService
= NULL
;
593 DWORD dwDependenciesLength
= 0;
598 TRACE("CreateServiceW() called\n");
600 /* Calculate the Dependencies length*/
601 if (lpDependencies
!= NULL
)
603 lpStr
= (LPWSTR
)lpDependencies
;
606 dwLength
= wcslen(lpStr
) + 1;
607 dwDependenciesLength
+= dwLength
;
608 lpStr
= lpStr
+ dwLength
;
610 dwDependenciesLength
++;
612 dwDependenciesLength
*= sizeof(WCHAR
);
615 /* FIXME: Encrypt the password */
619 /* Call to services.exe using RPC */
620 dwError
= RCreateServiceW(BindingHandle
,
621 (SC_RPC_HANDLE
)hSCManager
,
622 (LPWSTR
)lpServiceName
,
623 (LPWSTR
)lpDisplayName
,
628 (LPWSTR
)lpBinaryPathName
,
629 (LPWSTR
)lpLoadOrderGroup
,
631 (LPBYTE
)lpDependencies
,
632 dwDependenciesLength
,
633 (LPWSTR
)lpServiceStartName
,
634 NULL
, /* FIXME: lpPassword */
635 0, /* FIXME: dwPasswordLength */
636 (SC_RPC_HANDLE
*)&hService
);
637 if (dwError
!= ERROR_SUCCESS
)
639 ERR("RCreateServiceW() failed (Error %lu)\n", dwError
);
640 SetLastError(dwError
);
648 /**********************************************************************
654 DeleteService(SC_HANDLE hService
)
658 TRACE("DeleteService(%x)\n", hService
);
662 /* Call to services.exe using RPC */
663 dwError
= RDeleteService(BindingHandle
,
664 (SC_RPC_HANDLE
)hService
);
665 if (dwError
!= ERROR_SUCCESS
)
667 ERR("RDeleteService() failed (Error %lu)\n", dwError
);
668 SetLastError(dwError
);
676 /**********************************************************************
677 * EnumDependentServicesA
682 EnumDependentServicesA(SC_HANDLE hService
,
683 DWORD dwServiceState
,
684 LPENUM_SERVICE_STATUSA lpServices
,
686 LPDWORD pcbBytesNeeded
,
687 LPDWORD lpServicesReturned
)
689 LPENUM_SERVICE_STATUSA lpStatusPtr
;
690 DWORD dwError
= ERROR_SUCCESS
;
693 TRACE("EnumServicesStatusA() called\n");
697 dwError
= REnumDependentServicesA(BindingHandle
,
698 (SC_RPC_HANDLE
)hService
,
705 lpStatusPtr
= (LPENUM_SERVICE_STATUSA
)lpServices
;
706 for (dwCount
= 0; dwCount
< *lpServicesReturned
; dwCount
++)
708 if (lpStatusPtr
->lpServiceName
)
709 lpStatusPtr
->lpServiceName
=
710 (LPSTR
)((ULONG_PTR
)lpServices
+ (ULONG_PTR
)lpStatusPtr
->lpServiceName
);
712 if (lpStatusPtr
->lpDisplayName
)
713 lpStatusPtr
->lpDisplayName
=
714 (LPSTR
)((ULONG_PTR
)lpServices
+ (ULONG_PTR
)lpStatusPtr
->lpDisplayName
);
719 if (dwError
!= ERROR_SUCCESS
)
721 ERR("REnumDependentServicesA() failed (Error %lu)\n", dwError
);
722 SetLastError(dwError
);
726 TRACE("EnumDependentServicesA() done\n");
732 /**********************************************************************
733 * EnumDependentServicesW
738 EnumDependentServicesW(SC_HANDLE hService
,
739 DWORD dwServiceState
,
740 LPENUM_SERVICE_STATUSW lpServices
,
742 LPDWORD pcbBytesNeeded
,
743 LPDWORD lpServicesReturned
)
745 LPENUM_SERVICE_STATUSW lpStatusPtr
;
746 DWORD dwError
= ERROR_SUCCESS
;
749 TRACE("EnumServicesStatusW() called\n");
753 dwError
= REnumDependentServicesW(BindingHandle
,
754 (SC_RPC_HANDLE
)hService
,
761 lpStatusPtr
= (LPENUM_SERVICE_STATUSW
)lpServices
;
762 for (dwCount
= 0; dwCount
< *lpServicesReturned
; dwCount
++)
764 if (lpStatusPtr
->lpServiceName
)
765 lpStatusPtr
->lpServiceName
=
766 (LPWSTR
)((ULONG_PTR
)lpServices
+ (ULONG_PTR
)lpStatusPtr
->lpServiceName
);
768 if (lpStatusPtr
->lpDisplayName
)
769 lpStatusPtr
->lpDisplayName
=
770 (LPWSTR
)((ULONG_PTR
)lpServices
+ (ULONG_PTR
)lpStatusPtr
->lpDisplayName
);
775 if (dwError
!= ERROR_SUCCESS
)
777 ERR("REnumDependentServicesW() failed (Error %lu)\n", dwError
);
778 SetLastError(dwError
);
782 TRACE("EnumDependentServicesW() done\n");
788 /**********************************************************************
796 SC_HANDLE hSCManager
,
798 DWORD dwServiceState
,
799 LPENUM_SERVICE_STATUSW lpServices
,
801 LPDWORD pcbBytesNeeded
,
802 LPDWORD lpServicesReturned
,
803 LPDWORD lpResumeHandle
,
806 FIXME("EnumServiceGroupW is unimplemented\n");
807 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
812 /**********************************************************************
813 * EnumServicesStatusA
818 EnumServicesStatusA(SC_HANDLE hSCManager
,
820 DWORD dwServiceState
,
821 LPENUM_SERVICE_STATUSA lpServices
,
823 LPDWORD pcbBytesNeeded
,
824 LPDWORD lpServicesReturned
,
825 LPDWORD lpResumeHandle
)
827 LPENUM_SERVICE_STATUSA lpStatusPtr
;
828 DWORD dwError
= ERROR_SUCCESS
;
831 TRACE("EnumServicesStatusA() called\n");
835 dwError
= REnumServicesStatusA(BindingHandle
,
836 (SC_RPC_HANDLE
)hSCManager
,
845 lpStatusPtr
= (LPENUM_SERVICE_STATUSA
)lpServices
;
846 for (dwCount
= 0; dwCount
< *lpServicesReturned
; dwCount
++)
848 if (lpStatusPtr
->lpServiceName
)
849 lpStatusPtr
->lpServiceName
=
850 (LPSTR
)((ULONG_PTR
)lpServices
+ (ULONG_PTR
)lpStatusPtr
->lpServiceName
);
852 if (lpStatusPtr
->lpDisplayName
)
853 lpStatusPtr
->lpDisplayName
=
854 (LPSTR
)((ULONG_PTR
)lpServices
+ (ULONG_PTR
)lpStatusPtr
->lpDisplayName
);
859 if (dwError
!= ERROR_SUCCESS
)
861 ERR("REnumServicesStatusA() failed (Error %lu)\n", dwError
);
862 SetLastError(dwError
);
866 TRACE("EnumServicesStatusA() done\n");
872 /**********************************************************************
873 * EnumServicesStatusW
878 EnumServicesStatusW(SC_HANDLE hSCManager
,
880 DWORD dwServiceState
,
881 LPENUM_SERVICE_STATUSW lpServices
,
883 LPDWORD pcbBytesNeeded
,
884 LPDWORD lpServicesReturned
,
885 LPDWORD lpResumeHandle
)
887 LPENUM_SERVICE_STATUSW lpStatusPtr
;
888 DWORD dwError
= ERROR_SUCCESS
;
891 TRACE("EnumServicesStatusW() called\n");
895 dwError
= REnumServicesStatusW(BindingHandle
,
896 (SC_RPC_HANDLE
)hSCManager
,
905 lpStatusPtr
= (LPENUM_SERVICE_STATUSW
)lpServices
;
906 for (dwCount
= 0; dwCount
< *lpServicesReturned
; dwCount
++)
908 if (lpStatusPtr
->lpServiceName
)
909 lpStatusPtr
->lpServiceName
=
910 (LPWSTR
)((ULONG_PTR
)lpServices
+ (ULONG_PTR
)lpStatusPtr
->lpServiceName
);
912 if (lpStatusPtr
->lpDisplayName
)
913 lpStatusPtr
->lpDisplayName
=
914 (LPWSTR
)((ULONG_PTR
)lpServices
+ (ULONG_PTR
)lpStatusPtr
->lpDisplayName
);
919 if (dwError
!= ERROR_SUCCESS
)
921 ERR("REnumServicesStatusW() failed (Error %lu)\n", dwError
);
922 SetLastError(dwError
);
926 TRACE("EnumServicesStatusW() done\n");
932 /**********************************************************************
933 * EnumServicesStatusExA
938 EnumServicesStatusExA(SC_HANDLE hSCManager
,
939 SC_ENUM_TYPE InfoLevel
,
941 DWORD dwServiceState
,
944 LPDWORD pcbBytesNeeded
,
945 LPDWORD lpServicesReturned
,
946 LPDWORD lpResumeHandle
,
949 LPENUM_SERVICE_STATUS_PROCESSA lpStatusPtr
;
950 DWORD dwError
= ERROR_SUCCESS
;
953 TRACE("EnumServicesStatusExA() called\n");
957 dwError
= REnumServicesStatusExA(BindingHandle
,
958 (SC_RPC_HANDLE
)hSCManager
,
967 (LPSTR
)pszGroupName
);
969 if (dwError
== ERROR_MORE_DATA
)
971 WARN("Required buffer size %ul\n", *pcbBytesNeeded
);
972 SetLastError(dwError
);
975 else if (dwError
== ERROR_SUCCESS
)
977 lpStatusPtr
= (LPENUM_SERVICE_STATUS_PROCESSA
)lpServices
;
978 for (dwCount
= 0; dwCount
< *lpServicesReturned
; dwCount
++)
980 if (lpStatusPtr
->lpServiceName
)
981 lpStatusPtr
->lpServiceName
=
982 (LPSTR
)((ULONG_PTR
)lpServices
+ (ULONG_PTR
)lpStatusPtr
->lpServiceName
);
984 if (lpStatusPtr
->lpDisplayName
)
985 lpStatusPtr
->lpDisplayName
=
986 (LPSTR
)((ULONG_PTR
)lpServices
+ (ULONG_PTR
)lpStatusPtr
->lpDisplayName
);
993 ERR("REnumServicesStatusExA() failed (Error %lu)\n", dwError
);
994 SetLastError(dwError
);
998 TRACE("EnumServicesStatusExA() done\n");
1004 /**********************************************************************
1005 * EnumServicesStatusExW
1010 EnumServicesStatusExW(SC_HANDLE hSCManager
,
1011 SC_ENUM_TYPE InfoLevel
,
1012 DWORD dwServiceType
,
1013 DWORD dwServiceState
,
1016 LPDWORD pcbBytesNeeded
,
1017 LPDWORD lpServicesReturned
,
1018 LPDWORD lpResumeHandle
,
1019 LPCWSTR pszGroupName
)
1021 LPENUM_SERVICE_STATUS_PROCESSW lpStatusPtr
;
1022 DWORD dwError
= ERROR_SUCCESS
;
1025 TRACE("EnumServicesStatusExW() called\n");
1029 dwError
= REnumServicesStatusExW(BindingHandle
,
1030 (SC_RPC_HANDLE
)hSCManager
,
1039 (LPWSTR
)pszGroupName
);
1041 if (dwError
== ERROR_MORE_DATA
)
1043 WARN("Required buffer size %ul\n", *pcbBytesNeeded
);
1044 SetLastError(dwError
);
1047 else if (dwError
== ERROR_SUCCESS
)
1049 lpStatusPtr
= (LPENUM_SERVICE_STATUS_PROCESSW
)lpServices
;
1050 for (dwCount
= 0; dwCount
< *lpServicesReturned
; dwCount
++)
1052 if (lpStatusPtr
->lpServiceName
)
1053 lpStatusPtr
->lpServiceName
=
1054 (LPWSTR
)((ULONG_PTR
)lpServices
+ (ULONG_PTR
)lpStatusPtr
->lpServiceName
);
1056 if (lpStatusPtr
->lpDisplayName
)
1057 lpStatusPtr
->lpDisplayName
=
1058 (LPWSTR
)((ULONG_PTR
)lpServices
+ (ULONG_PTR
)lpStatusPtr
->lpDisplayName
);
1065 ERR("REnumServicesStatusExW() failed (Error %lu)\n", dwError
);
1066 SetLastError(dwError
);
1070 TRACE("EnumServicesStatusExW() done\n");
1076 /**********************************************************************
1077 * GetServiceDisplayNameA
1082 GetServiceDisplayNameA(SC_HANDLE hSCManager
,
1083 LPCSTR lpServiceName
,
1084 LPSTR lpDisplayName
,
1085 LPDWORD lpcchBuffer
)
1089 TRACE("GetServiceDisplayNameA() called\n");
1093 dwError
= RGetServiceDisplayNameA(BindingHandle
,
1094 (SC_RPC_HANDLE
)hSCManager
,
1095 (LPSTR
)lpServiceName
,
1098 if (dwError
!= ERROR_SUCCESS
)
1100 ERR("RGetServiceDisplayNameA() failed (Error %lu)\n", dwError
);
1101 SetLastError(dwError
);
1111 /**********************************************************************
1112 * GetServiceDisplayNameW
1117 GetServiceDisplayNameW(SC_HANDLE hSCManager
,
1118 LPCWSTR lpServiceName
,
1119 LPWSTR lpDisplayName
,
1120 LPDWORD lpcchBuffer
)
1124 TRACE("GetServiceDisplayNameW() called\n");
1128 dwError
= RGetServiceDisplayNameW(BindingHandle
,
1129 (SC_RPC_HANDLE
)hSCManager
,
1130 (LPWSTR
)lpServiceName
,
1133 if (dwError
!= ERROR_SUCCESS
)
1135 ERR("RGetServiceDisplayNameW() failed (Error %lu)\n", dwError
);
1136 SetLastError(dwError
);
1146 /**********************************************************************
1147 * GetServiceKeyNameA
1152 GetServiceKeyNameA(SC_HANDLE hSCManager
,
1153 LPCSTR lpDisplayName
,
1154 LPSTR lpServiceName
,
1155 LPDWORD lpcchBuffer
)
1159 TRACE("GetServiceKeyNameA() called\n");
1163 dwError
= RGetServiceKeyNameA(BindingHandle
,
1164 (SC_RPC_HANDLE
)hSCManager
,
1165 (LPSTR
)lpDisplayName
,
1168 if (dwError
!= ERROR_SUCCESS
)
1170 ERR("RGetServiceKeyNameA() failed (Error %lu)\n", dwError
);
1171 SetLastError(dwError
);
1181 /**********************************************************************
1182 * GetServiceKeyNameW
1187 GetServiceKeyNameW(SC_HANDLE hSCManager
,
1188 LPCWSTR lpDisplayName
,
1189 LPWSTR lpServiceName
,
1190 LPDWORD lpcchBuffer
)
1194 TRACE("GetServiceKeyNameW() called\n");
1198 dwError
= RGetServiceKeyNameW(BindingHandle
,
1199 (SC_RPC_HANDLE
)hSCManager
,
1200 (LPWSTR
)lpDisplayName
,
1203 if (dwError
!= ERROR_SUCCESS
)
1205 ERR("RGetServiceKeyNameW() failed (Error %lu)\n", dwError
);
1206 SetLastError(dwError
);
1216 /**********************************************************************
1217 * LockServiceDatabase
1222 LockServiceDatabase(SC_HANDLE hSCManager
)
1227 TRACE("LockServiceDatabase(%x)\n", hSCManager
);
1231 /* Call to services.exe using RPC */
1232 dwError
= RLockServiceDatabase(BindingHandle
,
1233 (SC_RPC_HANDLE
)hSCManager
,
1234 (SC_RPC_LOCK
*)&hLock
);
1235 if (dwError
!= ERROR_SUCCESS
)
1237 ERR("RLockServiceDatabase() failed (Error %lu)\n", dwError
);
1238 SetLastError(dwError
);
1242 TRACE("hLock = %p\n", hLock
);
1249 WaitForSCManager(VOID
)
1253 TRACE("WaitForSCManager() called\n");
1255 /* Try to open the existing event */
1256 hEvent
= OpenEventW(SYNCHRONIZE
,
1258 L
"SvcctrlStartEvent_A3752DX");
1261 if (GetLastError() != ERROR_FILE_NOT_FOUND
)
1264 /* Try to create a new event */
1265 hEvent
= CreateEventW(NULL
,
1268 L
"SvcctrlStartEvent_A3752DX");
1271 /* Try to open the existing event again */
1272 hEvent
= OpenEventW(SYNCHRONIZE
,
1274 L
"SvcctrlStartEvent_A3752DX");
1280 /* Wait for 3 minutes */
1281 WaitForSingleObject(hEvent
, 180000);
1282 CloseHandle(hEvent
);
1284 TRACE("ScmWaitForSCManager() done\n");
1288 /**********************************************************************
1294 OpenSCManagerA(LPCSTR lpMachineName
,
1295 LPCSTR lpDatabaseName
,
1296 DWORD dwDesiredAccess
)
1298 SC_HANDLE hScm
= NULL
;
1301 TRACE("OpenSCManagerA(%s, %s, %lx)\n",
1302 lpMachineName
, lpDatabaseName
, dwDesiredAccess
);
1308 /* Call to services.exe using RPC */
1309 dwError
= ROpenSCManagerA(BindingHandle
,
1310 (LPSTR
)lpMachineName
,
1311 (LPSTR
)lpDatabaseName
,
1313 (SC_RPC_HANDLE
*)&hScm
);
1314 if (dwError
!= ERROR_SUCCESS
)
1316 ERR("ROpenSCManagerA() failed (Error %lu)\n", dwError
);
1317 SetLastError(dwError
);
1321 TRACE("hScm = %p\n", hScm
);
1327 /**********************************************************************
1333 OpenSCManagerW(LPCWSTR lpMachineName
,
1334 LPCWSTR lpDatabaseName
,
1335 DWORD dwDesiredAccess
)
1337 SC_HANDLE hScm
= NULL
;
1340 TRACE("OpenSCManagerW(%S, %S, %lx)\n",
1341 lpMachineName
, lpDatabaseName
, dwDesiredAccess
);
1347 /* Call to services.exe using RPC */
1348 dwError
= ROpenSCManagerW(BindingHandle
,
1349 (LPWSTR
)lpMachineName
,
1350 (LPWSTR
)lpDatabaseName
,
1352 (SC_RPC_HANDLE
*)&hScm
);
1353 if (dwError
!= ERROR_SUCCESS
)
1355 ERR("ROpenSCManagerW() failed (Error %lu)\n", dwError
);
1356 SetLastError(dwError
);
1360 TRACE("hScm = %p\n", hScm
);
1366 /**********************************************************************
1372 OpenServiceA(SC_HANDLE hSCManager
,
1373 LPCSTR lpServiceName
,
1374 DWORD dwDesiredAccess
)
1376 SC_HANDLE hService
= NULL
;
1379 TRACE("OpenServiceA(%p, %s, %lx)\n",
1380 hSCManager
, lpServiceName
, dwDesiredAccess
);
1384 /* Call to services.exe using RPC */
1385 dwError
= ROpenServiceA(BindingHandle
,
1386 (SC_RPC_HANDLE
)hSCManager
,
1387 (LPSTR
)lpServiceName
,
1389 (SC_RPC_HANDLE
*)&hService
);
1390 if (dwError
!= ERROR_SUCCESS
)
1392 ERR("ROpenServiceA() failed (Error %lu)\n", dwError
);
1393 SetLastError(dwError
);
1397 TRACE("hService = %p\n", hService
);
1403 /**********************************************************************
1409 OpenServiceW(SC_HANDLE hSCManager
,
1410 LPCWSTR lpServiceName
,
1411 DWORD dwDesiredAccess
)
1413 SC_HANDLE hService
= NULL
;
1416 TRACE("OpenServiceW(%p, %S, %lx)\n",
1417 hSCManager
, lpServiceName
, dwDesiredAccess
);
1421 /* Call to services.exe using RPC */
1422 dwError
= ROpenServiceW(BindingHandle
,
1423 (SC_RPC_HANDLE
)hSCManager
,
1424 (LPWSTR
)lpServiceName
,
1426 (SC_RPC_HANDLE
*)&hService
);
1427 if (dwError
!= ERROR_SUCCESS
)
1429 if (dwError
== ERROR_SERVICE_DOES_NOT_EXIST
)
1430 WARN("ROpenServiceW() failed (Error %lu)\n", dwError
);
1432 ERR("ROpenServiceW() failed (Error %lu)\n", dwError
);
1433 SetLastError(dwError
);
1437 TRACE("hService = %p\n", hService
);
1443 /**********************************************************************
1444 * QueryServiceConfigA
1449 QueryServiceConfigA(SC_HANDLE hService
,
1450 LPQUERY_SERVICE_CONFIGA lpServiceConfig
,
1452 LPDWORD pcbBytesNeeded
)
1456 TRACE("QueryServiceConfigA(%p, %p, %lu, %p)\n",
1457 hService
, lpServiceConfig
, cbBufSize
, pcbBytesNeeded
);
1461 /* Call to services.exe using RPC */
1462 dwError
= RQueryServiceConfigA(BindingHandle
,
1463 (SC_RPC_HANDLE
)hService
,
1467 if (dwError
!= ERROR_SUCCESS
)
1469 ERR("RQueryServiceConfigA() failed (Error %lu)\n", dwError
);
1470 SetLastError(dwError
);
1474 /* Adjust the pointers */
1475 if (lpServiceConfig
->lpBinaryPathName
)
1476 lpServiceConfig
->lpBinaryPathName
=
1477 (LPSTR
)((ULONG_PTR
)lpServiceConfig
+
1478 (ULONG_PTR
)lpServiceConfig
->lpBinaryPathName
);
1480 if (lpServiceConfig
->lpLoadOrderGroup
)
1481 lpServiceConfig
->lpLoadOrderGroup
=
1482 (LPSTR
)((ULONG_PTR
)lpServiceConfig
+
1483 (ULONG_PTR
)lpServiceConfig
->lpLoadOrderGroup
);
1485 if (lpServiceConfig
->lpDependencies
)
1486 lpServiceConfig
->lpDependencies
=
1487 (LPSTR
)((ULONG_PTR
)lpServiceConfig
+
1488 (ULONG_PTR
)lpServiceConfig
->lpDependencies
);
1490 if (lpServiceConfig
->lpServiceStartName
)
1491 lpServiceConfig
->lpServiceStartName
=
1492 (LPSTR
)((ULONG_PTR
)lpServiceConfig
+
1493 (ULONG_PTR
)lpServiceConfig
->lpServiceStartName
);
1495 if (lpServiceConfig
->lpDisplayName
)
1496 lpServiceConfig
->lpDisplayName
=
1497 (LPSTR
)((ULONG_PTR
)lpServiceConfig
+
1498 (ULONG_PTR
)lpServiceConfig
->lpDisplayName
);
1500 TRACE("QueryServiceConfigA() done\n");
1506 /**********************************************************************
1507 * QueryServiceConfigW
1512 QueryServiceConfigW(SC_HANDLE hService
,
1513 LPQUERY_SERVICE_CONFIGW lpServiceConfig
,
1515 LPDWORD pcbBytesNeeded
)
1519 TRACE("QueryServiceConfigW(%p, %p, %lu, %p)\n",
1520 hService
, lpServiceConfig
, cbBufSize
, pcbBytesNeeded
);
1524 /* Call to services.exe using RPC */
1525 dwError
= RQueryServiceConfigW(BindingHandle
,
1526 (SC_RPC_HANDLE
)hService
,
1527 (LPBYTE
)lpServiceConfig
,
1530 if (dwError
!= ERROR_SUCCESS
)
1532 if (dwError
== ERROR_INSUFFICIENT_BUFFER
)
1533 WARN("RQueryServiceConfigW() failed (Error %lu)\n", dwError
);
1535 ERR("RQueryServiceConfigW() failed (Error %lu)\n", dwError
);
1536 SetLastError(dwError
);
1540 /* Adjust the pointers */
1541 if (lpServiceConfig
->lpBinaryPathName
)
1542 lpServiceConfig
->lpBinaryPathName
=
1543 (LPWSTR
)((ULONG_PTR
)lpServiceConfig
+
1544 (ULONG_PTR
)lpServiceConfig
->lpBinaryPathName
);
1546 if (lpServiceConfig
->lpLoadOrderGroup
)
1547 lpServiceConfig
->lpLoadOrderGroup
=
1548 (LPWSTR
)((ULONG_PTR
)lpServiceConfig
+
1549 (ULONG_PTR
)lpServiceConfig
->lpLoadOrderGroup
);
1551 if (lpServiceConfig
->lpDependencies
)
1552 lpServiceConfig
->lpDependencies
=
1553 (LPWSTR
)((ULONG_PTR
)lpServiceConfig
+
1554 (ULONG_PTR
)lpServiceConfig
->lpDependencies
);
1556 if (lpServiceConfig
->lpServiceStartName
)
1557 lpServiceConfig
->lpServiceStartName
=
1558 (LPWSTR
)((ULONG_PTR
)lpServiceConfig
+
1559 (ULONG_PTR
)lpServiceConfig
->lpServiceStartName
);
1561 if (lpServiceConfig
->lpDisplayName
)
1562 lpServiceConfig
->lpDisplayName
=
1563 (LPWSTR
)((ULONG_PTR
)lpServiceConfig
+
1564 (ULONG_PTR
)lpServiceConfig
->lpDisplayName
);
1566 TRACE("QueryServiceConfigW() done\n");
1572 /**********************************************************************
1573 * QueryServiceConfig2A
1578 QueryServiceConfig2A(SC_HANDLE hService
,
1582 LPDWORD pcbBytesNeeded
)
1586 TRACE("QueryServiceConfig2A(%p, %lu, %p, %lu, %p)\n",
1587 hService
, dwInfoLevel
, lpBuffer
, cbBufSize
, pcbBytesNeeded
);
1591 /* Call to services.exe using RPC */
1592 dwError
= RQueryServiceConfig2A(BindingHandle
,
1593 (SC_RPC_HANDLE
)hService
,
1598 if (dwError
!= ERROR_SUCCESS
)
1600 ERR("RQueryServiceConfig2A() failed (Error %lu)\n", dwError
);
1601 SetLastError(dwError
);
1605 switch (dwInfoLevel
)
1607 case SERVICE_CONFIG_DESCRIPTION
:
1609 LPSERVICE_DESCRIPTIONA lpPtr
= (LPSERVICE_DESCRIPTIONA
)lpBuffer
;
1611 if (lpPtr
->lpDescription
!= NULL
)
1612 lpPtr
->lpDescription
=
1613 (LPSTR
)((UINT_PTR
)lpPtr
+ (UINT_PTR
)lpPtr
->lpDescription
);
1617 case SERVICE_CONFIG_FAILURE_ACTIONS
:
1619 LPSERVICE_FAILURE_ACTIONSA lpPtr
= (LPSERVICE_FAILURE_ACTIONSA
)lpBuffer
;
1621 if (lpPtr
->lpRebootMsg
!= NULL
)
1622 lpPtr
->lpRebootMsg
=
1623 (LPSTR
)((UINT_PTR
)lpPtr
+ (UINT_PTR
)lpPtr
->lpRebootMsg
);
1625 if (lpPtr
->lpCommand
!= NULL
)
1627 (LPSTR
)((UINT_PTR
)lpPtr
+ (UINT_PTR
)lpPtr
->lpCommand
);
1629 if (lpPtr
->lpsaActions
!= NULL
)
1630 lpPtr
->lpsaActions
=
1631 (SC_ACTION
*)((UINT_PTR
)lpPtr
+ (UINT_PTR
)lpPtr
->lpsaActions
);
1636 ERR("Unknown info level 0x%lx\n", dwInfoLevel
);
1637 SetLastError(ERROR_INVALID_PARAMETER
);
1641 TRACE("QueryServiceConfig2A() done\n");
1647 /**********************************************************************
1648 * QueryServiceConfig2W
1653 QueryServiceConfig2W(SC_HANDLE hService
,
1657 LPDWORD pcbBytesNeeded
)
1661 TRACE("QueryServiceConfig2W(%p, %lu, %p, %lu, %p)\n",
1662 hService
, dwInfoLevel
, lpBuffer
, cbBufSize
, pcbBytesNeeded
);
1666 /* Call to services.exe using RPC */
1667 dwError
= RQueryServiceConfig2W(BindingHandle
,
1668 (SC_RPC_HANDLE
)hService
,
1673 if (dwError
!= ERROR_SUCCESS
)
1675 ERR("RQueryServiceConfig2W() failed (Error %lu)\n", dwError
);
1676 SetLastError(dwError
);
1680 switch (dwInfoLevel
)
1682 case SERVICE_CONFIG_DESCRIPTION
:
1684 LPSERVICE_DESCRIPTIONW lpPtr
= (LPSERVICE_DESCRIPTIONW
)lpBuffer
;
1686 if (lpPtr
->lpDescription
!= NULL
)
1687 lpPtr
->lpDescription
=
1688 (LPWSTR
)((UINT_PTR
)lpPtr
+ (UINT_PTR
)lpPtr
->lpDescription
);
1692 case SERVICE_CONFIG_FAILURE_ACTIONS
:
1694 LPSERVICE_FAILURE_ACTIONSW lpPtr
= (LPSERVICE_FAILURE_ACTIONSW
)lpBuffer
;
1696 if (lpPtr
->lpRebootMsg
!= NULL
)
1697 lpPtr
->lpRebootMsg
=
1698 (LPWSTR
)((UINT_PTR
)lpPtr
+ (UINT_PTR
)lpPtr
->lpRebootMsg
);
1700 if (lpPtr
->lpCommand
!= NULL
)
1702 (LPWSTR
)((UINT_PTR
)lpPtr
+ (UINT_PTR
)lpPtr
->lpCommand
);
1704 if (lpPtr
->lpsaActions
!= NULL
)
1705 lpPtr
->lpsaActions
=
1706 (SC_ACTION
*)((UINT_PTR
)lpPtr
+ (UINT_PTR
)lpPtr
->lpsaActions
);
1711 WARN("Unknown info level 0x%lx\n", dwInfoLevel
);
1712 SetLastError(ERROR_INVALID_PARAMETER
);
1716 TRACE("QueryServiceConfig2W() done\n");
1722 /**********************************************************************
1723 * QueryServiceLockStatusA
1728 QueryServiceLockStatusA(SC_HANDLE hSCManager
,
1729 LPQUERY_SERVICE_LOCK_STATUSA lpLockStatus
,
1731 LPDWORD pcbBytesNeeded
)
1735 TRACE("QueryServiceLockStatusA() called\n");
1739 /* Call to services.exe using RPC */
1740 dwError
= RQueryServiceLockStatusA(BindingHandle
,
1741 (SC_RPC_HANDLE
)hSCManager
,
1745 if (dwError
!= ERROR_SUCCESS
)
1747 ERR("RQueryServiceLockStatusA() failed (Error %lu)\n", dwError
);
1748 SetLastError(dwError
);
1752 if (lpLockStatus
->lpLockOwner
!= NULL
)
1754 lpLockStatus
->lpLockOwner
=
1755 (LPSTR
)((UINT_PTR
)lpLockStatus
+ (UINT_PTR
)lpLockStatus
->lpLockOwner
);
1758 TRACE("QueryServiceLockStatusA() done\n");
1764 /**********************************************************************
1765 * QueryServiceLockStatusW
1770 QueryServiceLockStatusW(SC_HANDLE hSCManager
,
1771 LPQUERY_SERVICE_LOCK_STATUSW lpLockStatus
,
1773 LPDWORD pcbBytesNeeded
)
1777 TRACE("QueryServiceLockStatusW() called\n");
1781 /* Call to services.exe using RPC */
1782 dwError
= RQueryServiceLockStatusW(BindingHandle
,
1783 (SC_RPC_HANDLE
)hSCManager
,
1787 if (dwError
!= ERROR_SUCCESS
)
1789 ERR("RQueryServiceLockStatusW() failed (Error %lu)\n", dwError
);
1790 SetLastError(dwError
);
1794 if (lpLockStatus
->lpLockOwner
!= NULL
)
1796 lpLockStatus
->lpLockOwner
=
1797 (LPWSTR
)((UINT_PTR
)lpLockStatus
+ (UINT_PTR
)lpLockStatus
->lpLockOwner
);
1800 TRACE("QueryServiceLockStatusW() done\n");
1806 /**********************************************************************
1807 * QueryServiceObjectSecurity
1812 QueryServiceObjectSecurity(SC_HANDLE hService
,
1813 SECURITY_INFORMATION dwSecurityInformation
,
1814 PSECURITY_DESCRIPTOR lpSecurityDescriptor
,
1816 LPDWORD pcbBytesNeeded
)
1820 TRACE("QueryServiceObjectSecurity(%p, %lu, %p)\n",
1821 hService
, dwSecurityInformation
, lpSecurityDescriptor
);
1825 /* Call to services.exe using RPC */
1826 dwError
= RQueryServiceObjectSecurity(BindingHandle
,
1827 (SC_RPC_HANDLE
)hService
,
1828 dwSecurityInformation
,
1829 (LPBYTE
)lpSecurityDescriptor
,
1832 if (dwError
!= ERROR_SUCCESS
)
1834 ERR("QueryServiceObjectSecurity() failed (Error %lu)\n", dwError
);
1835 SetLastError(dwError
);
1842 /**********************************************************************
1843 * SetServiceObjectSecurity
1848 SetServiceObjectSecurity(SC_HANDLE hService
,
1849 SECURITY_INFORMATION dwSecurityInformation
,
1850 PSECURITY_DESCRIPTOR lpSecurityDescriptor
)
1852 PSECURITY_DESCRIPTOR SelfRelativeSD
= NULL
;
1858 Status
= RtlMakeSelfRelativeSD(lpSecurityDescriptor
,
1861 if (Status
!= STATUS_BUFFER_TOO_SMALL
)
1863 SetLastError(ERROR_INVALID_PARAMETER
);
1867 SelfRelativeSD
= HeapAlloc(GetProcessHeap(), 0, Length
);
1868 if (SelfRelativeSD
== NULL
)
1870 SetLastError(ERROR_NOT_ENOUGH_MEMORY
);
1874 Status
= RtlMakeSelfRelativeSD(lpSecurityDescriptor
,
1877 if (!NT_SUCCESS(Status
))
1879 HeapFree(GetProcessHeap(), 0, SelfRelativeSD
);
1880 SetLastError(RtlNtStatusToDosError(Status
));
1886 /* Call to services.exe using RPC */
1887 dwError
= RSetServiceObjectSecurity(BindingHandle
,
1888 (SC_RPC_HANDLE
)hService
,
1889 dwSecurityInformation
,
1890 (LPBYTE
)SelfRelativeSD
,
1893 HeapFree(GetProcessHeap(), 0, SelfRelativeSD
);
1895 if (dwError
!= ERROR_SUCCESS
)
1897 ERR("RServiceObjectSecurity() failed (Error %lu)\n", dwError
);
1898 SetLastError(dwError
);
1906 /**********************************************************************
1907 * QueryServiceStatus
1912 QueryServiceStatus(SC_HANDLE hService
,
1913 LPSERVICE_STATUS lpServiceStatus
)
1917 TRACE("QueryServiceStatus(%p, %p)\n",
1918 hService
, lpServiceStatus
);
1922 /* Call to services.exe using RPC */
1923 dwError
= RQueryServiceStatus(BindingHandle
,
1924 (SC_RPC_HANDLE
)hService
,
1926 if (dwError
!= ERROR_SUCCESS
)
1928 ERR("RQueryServiceStatus() failed (Error %lu)\n", dwError
);
1929 SetLastError(dwError
);
1937 /**********************************************************************
1938 * QueryServiceStatusEx
1943 QueryServiceStatusEx(SC_HANDLE hService
,
1944 SC_STATUS_TYPE InfoLevel
,
1947 LPDWORD pcbBytesNeeded
)
1951 TRACE("QueryServiceStatusEx() called\n");
1955 /* Call to services.exe using RPC */
1956 dwError
= RQueryServiceStatusEx(BindingHandle
,
1957 (SC_RPC_HANDLE
)hService
,
1962 if (dwError
!= ERROR_SUCCESS
)
1964 ERR("RQueryServiceStatusEx() failed (Error %lu)\n", dwError
);
1965 SetLastError(dwError
);
1973 /**********************************************************************
1979 StartServiceA(SC_HANDLE hService
,
1980 DWORD dwNumServiceArgs
,
1981 LPCSTR
*lpServiceArgVectors
)
1985 dwError
= RStartServiceA(BindingHandle
,
1986 (SC_RPC_HANDLE
)hService
,
1988 (LPSTRING_PTRSA
)lpServiceArgVectors
);
1991 if (dwError
!= ERROR_SUCCESS
)
1993 ERR("RStartServiceA() failed (Error %lu)\n", dwError
);
1994 SetLastError(dwError
);
2002 /**********************************************************************
2008 StartServiceW(SC_HANDLE hService
,
2009 DWORD dwNumServiceArgs
,
2010 LPCWSTR
*lpServiceArgVectors
)
2014 dwError
= RStartServiceW(BindingHandle
,
2015 (SC_RPC_HANDLE
)hService
,
2017 (LPSTRING_PTRSW
)lpServiceArgVectors
);
2019 if (dwError
!= ERROR_SUCCESS
)
2021 ERR("RStartServiceW() failed (Error %lu)\n", dwError
);
2022 SetLastError(dwError
);
2030 /**********************************************************************
2031 * UnlockServiceDatabase
2036 UnlockServiceDatabase(SC_LOCK ScLock
)
2040 TRACE("UnlockServiceDatabase(%x)\n", ScLock
);
2044 /* Call to services.exe using RPC */
2045 dwError
= RUnlockServiceDatabase(BindingHandle
,
2046 (SC_RPC_LOCK
)ScLock
);
2047 if (dwError
!= ERROR_SUCCESS
)
2049 ERR("RUnlockServiceDatabase() failed (Error %lu)\n", dwError
);
2050 SetLastError(dwError
);
2058 /**********************************************************************
2059 * NotifyBootConfigStatus
2064 NotifyBootConfigStatus(BOOL BootAcceptable
)
2068 TRACE("NotifyBootConfigStatus()\n");
2072 /* Call to services.exe using RPC */
2073 dwError
= RNotifyBootConfigStatus(BindingHandle
,
2076 if (dwError
!= ERROR_SUCCESS
)
2078 ERR("NotifyBootConfigStatus() failed (Error %lu)\n", dwError
);
2079 SetLastError(dwError
);