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
)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
, -1, 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
++;
613 /* FIXME: Encrypt the password */
617 /* Call to services.exe using RPC */
618 dwError
= RCreateServiceW(BindingHandle
,
619 (SC_RPC_HANDLE
)hSCManager
,
620 (LPWSTR
)lpServiceName
,
621 (LPWSTR
)lpDisplayName
,
626 (LPWSTR
)lpBinaryPathName
,
627 (LPWSTR
)lpLoadOrderGroup
,
629 (LPBYTE
)lpDependencies
,
630 dwDependenciesLength
,
631 (LPWSTR
)lpServiceStartName
,
632 NULL
, /* FIXME: lpPassword */
633 0, /* FIXME: dwPasswordLength */
634 (SC_RPC_HANDLE
*)&hService
);
635 if (dwError
!= ERROR_SUCCESS
)
637 ERR("RCreateServiceW() failed (Error %lu)\n", dwError
);
638 SetLastError(dwError
);
646 /**********************************************************************
652 DeleteService(SC_HANDLE hService
)
656 TRACE("DeleteService(%x)\n", hService
);
660 /* Call to services.exe using RPC */
661 dwError
= RDeleteService(BindingHandle
,
662 (SC_RPC_HANDLE
)hService
);
663 if (dwError
!= ERROR_SUCCESS
)
665 ERR("RDeleteService() failed (Error %lu)\n", dwError
);
666 SetLastError(dwError
);
674 /**********************************************************************
675 * EnumDependentServicesA
680 EnumDependentServicesA(SC_HANDLE hService
,
681 DWORD dwServiceState
,
682 LPENUM_SERVICE_STATUSA lpServices
,
684 LPDWORD pcbBytesNeeded
,
685 LPDWORD lpServicesReturned
)
687 LPENUM_SERVICE_STATUSA lpStatusPtr
;
688 DWORD dwError
= ERROR_SUCCESS
;
691 TRACE("EnumServicesStatusA() called\n");
695 dwError
= REnumDependentServicesA(BindingHandle
,
696 (SC_RPC_HANDLE
)hService
,
703 lpStatusPtr
= (LPENUM_SERVICE_STATUSA
)lpServices
;
704 for (dwCount
= 0; dwCount
< *lpServicesReturned
; dwCount
++)
706 if (lpStatusPtr
->lpServiceName
)
707 lpStatusPtr
->lpServiceName
=
708 (LPSTR
)((ULONG_PTR
)lpServices
+ (ULONG_PTR
)lpStatusPtr
->lpServiceName
);
710 if (lpStatusPtr
->lpDisplayName
)
711 lpStatusPtr
->lpDisplayName
=
712 (LPSTR
)((ULONG_PTR
)lpServices
+ (ULONG_PTR
)lpStatusPtr
->lpDisplayName
);
717 if (dwError
!= ERROR_SUCCESS
)
719 ERR("REnumDependentServicesA() failed (Error %lu)\n", dwError
);
720 SetLastError(dwError
);
724 TRACE("EnumDependentServicesA() done\n");
730 /**********************************************************************
731 * EnumDependentServicesW
736 EnumDependentServicesW(SC_HANDLE hService
,
737 DWORD dwServiceState
,
738 LPENUM_SERVICE_STATUSW lpServices
,
740 LPDWORD pcbBytesNeeded
,
741 LPDWORD lpServicesReturned
)
743 LPENUM_SERVICE_STATUSW lpStatusPtr
;
744 DWORD dwError
= ERROR_SUCCESS
;
747 TRACE("EnumServicesStatusW() called\n");
751 dwError
= REnumDependentServicesW(BindingHandle
,
752 (SC_RPC_HANDLE
)hService
,
759 lpStatusPtr
= (LPENUM_SERVICE_STATUSW
)lpServices
;
760 for (dwCount
= 0; dwCount
< *lpServicesReturned
; dwCount
++)
762 if (lpStatusPtr
->lpServiceName
)
763 lpStatusPtr
->lpServiceName
=
764 (LPWSTR
)((ULONG_PTR
)lpServices
+ (ULONG_PTR
)lpStatusPtr
->lpServiceName
);
766 if (lpStatusPtr
->lpDisplayName
)
767 lpStatusPtr
->lpDisplayName
=
768 (LPWSTR
)((ULONG_PTR
)lpServices
+ (ULONG_PTR
)lpStatusPtr
->lpDisplayName
);
773 if (dwError
!= ERROR_SUCCESS
)
775 ERR("REnumDependentServicesW() failed (Error %lu)\n", dwError
);
776 SetLastError(dwError
);
780 TRACE("EnumDependentServicesW() done\n");
786 /**********************************************************************
794 SC_HANDLE hSCManager
,
796 DWORD dwServiceState
,
797 LPENUM_SERVICE_STATUSW lpServices
,
799 LPDWORD pcbBytesNeeded
,
800 LPDWORD lpServicesReturned
,
801 LPDWORD lpResumeHandle
,
804 FIXME("EnumServiceGroupW is unimplemented\n");
805 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
810 /**********************************************************************
811 * EnumServicesStatusA
816 EnumServicesStatusA(SC_HANDLE hSCManager
,
818 DWORD dwServiceState
,
819 LPENUM_SERVICE_STATUSA lpServices
,
821 LPDWORD pcbBytesNeeded
,
822 LPDWORD lpServicesReturned
,
823 LPDWORD lpResumeHandle
)
825 LPENUM_SERVICE_STATUSA lpStatusPtr
;
826 DWORD dwError
= ERROR_SUCCESS
;
829 TRACE("EnumServicesStatusA() called\n");
833 dwError
= REnumServicesStatusA(BindingHandle
,
834 (SC_RPC_HANDLE
)hSCManager
,
843 lpStatusPtr
= (LPENUM_SERVICE_STATUSA
)lpServices
;
844 for (dwCount
= 0; dwCount
< *lpServicesReturned
; dwCount
++)
846 if (lpStatusPtr
->lpServiceName
)
847 lpStatusPtr
->lpServiceName
=
848 (LPSTR
)((ULONG_PTR
)lpServices
+ (ULONG_PTR
)lpStatusPtr
->lpServiceName
);
850 if (lpStatusPtr
->lpDisplayName
)
851 lpStatusPtr
->lpDisplayName
=
852 (LPSTR
)((ULONG_PTR
)lpServices
+ (ULONG_PTR
)lpStatusPtr
->lpDisplayName
);
857 if (dwError
!= ERROR_SUCCESS
)
859 ERR("REnumServicesStatusA() failed (Error %lu)\n", dwError
);
860 SetLastError(dwError
);
864 TRACE("EnumServicesStatusA() done\n");
870 /**********************************************************************
871 * EnumServicesStatusW
876 EnumServicesStatusW(SC_HANDLE hSCManager
,
878 DWORD dwServiceState
,
879 LPENUM_SERVICE_STATUSW lpServices
,
881 LPDWORD pcbBytesNeeded
,
882 LPDWORD lpServicesReturned
,
883 LPDWORD lpResumeHandle
)
885 LPENUM_SERVICE_STATUSW lpStatusPtr
;
886 DWORD dwError
= ERROR_SUCCESS
;
889 TRACE("EnumServicesStatusW() called\n");
893 dwError
= REnumServicesStatusW(BindingHandle
,
894 (SC_RPC_HANDLE
)hSCManager
,
903 lpStatusPtr
= (LPENUM_SERVICE_STATUSW
)lpServices
;
904 for (dwCount
= 0; dwCount
< *lpServicesReturned
; dwCount
++)
906 if (lpStatusPtr
->lpServiceName
)
907 lpStatusPtr
->lpServiceName
=
908 (LPWSTR
)((ULONG_PTR
)lpServices
+ (ULONG_PTR
)lpStatusPtr
->lpServiceName
);
910 if (lpStatusPtr
->lpDisplayName
)
911 lpStatusPtr
->lpDisplayName
=
912 (LPWSTR
)((ULONG_PTR
)lpServices
+ (ULONG_PTR
)lpStatusPtr
->lpDisplayName
);
917 if (dwError
!= ERROR_SUCCESS
)
919 ERR("REnumServicesStatusW() failed (Error %lu)\n", dwError
);
920 SetLastError(dwError
);
924 TRACE("EnumServicesStatusW() done\n");
930 /**********************************************************************
931 * EnumServicesStatusExA
936 EnumServicesStatusExA(SC_HANDLE hSCManager
,
937 SC_ENUM_TYPE InfoLevel
,
939 DWORD dwServiceState
,
942 LPDWORD pcbBytesNeeded
,
943 LPDWORD lpServicesReturned
,
944 LPDWORD lpResumeHandle
,
947 LPENUM_SERVICE_STATUS_PROCESSA lpStatusPtr
;
948 DWORD dwError
= ERROR_SUCCESS
;
951 TRACE("EnumServicesStatusExA() called\n");
955 dwError
= REnumServicesStatusExA(BindingHandle
,
956 (SC_RPC_HANDLE
)hSCManager
,
965 (LPSTR
)pszGroupName
);
967 if (dwError
== ERROR_MORE_DATA
)
969 WARN("Required buffer size %ul\n", *pcbBytesNeeded
);
970 SetLastError(dwError
);
973 else if (dwError
== ERROR_SUCCESS
)
975 lpStatusPtr
= (LPENUM_SERVICE_STATUS_PROCESSA
)lpServices
;
976 for (dwCount
= 0; dwCount
< *lpServicesReturned
; dwCount
++)
978 if (lpStatusPtr
->lpServiceName
)
979 lpStatusPtr
->lpServiceName
=
980 (LPSTR
)((ULONG_PTR
)lpServices
+ (ULONG_PTR
)lpStatusPtr
->lpServiceName
);
982 if (lpStatusPtr
->lpDisplayName
)
983 lpStatusPtr
->lpDisplayName
=
984 (LPSTR
)((ULONG_PTR
)lpServices
+ (ULONG_PTR
)lpStatusPtr
->lpDisplayName
);
991 ERR("REnumServicesStatusExA() failed (Error %lu)\n", dwError
);
992 SetLastError(dwError
);
996 TRACE("EnumServicesStatusExA() done\n");
1002 /**********************************************************************
1003 * EnumServicesStatusExW
1008 EnumServicesStatusExW(SC_HANDLE hSCManager
,
1009 SC_ENUM_TYPE InfoLevel
,
1010 DWORD dwServiceType
,
1011 DWORD dwServiceState
,
1014 LPDWORD pcbBytesNeeded
,
1015 LPDWORD lpServicesReturned
,
1016 LPDWORD lpResumeHandle
,
1017 LPCWSTR pszGroupName
)
1019 LPENUM_SERVICE_STATUS_PROCESSW lpStatusPtr
;
1020 DWORD dwError
= ERROR_SUCCESS
;
1023 TRACE("EnumServicesStatusExW() called\n");
1027 dwError
= REnumServicesStatusExW(BindingHandle
,
1028 (SC_RPC_HANDLE
)hSCManager
,
1037 (LPWSTR
)pszGroupName
);
1039 if (dwError
== ERROR_MORE_DATA
)
1041 WARN("Required buffer size %ul\n", *pcbBytesNeeded
);
1042 SetLastError(dwError
);
1045 else if (dwError
== ERROR_SUCCESS
)
1047 lpStatusPtr
= (LPENUM_SERVICE_STATUS_PROCESSW
)lpServices
;
1048 for (dwCount
= 0; dwCount
< *lpServicesReturned
; dwCount
++)
1050 if (lpStatusPtr
->lpServiceName
)
1051 lpStatusPtr
->lpServiceName
=
1052 (LPWSTR
)((ULONG_PTR
)lpServices
+ (ULONG_PTR
)lpStatusPtr
->lpServiceName
);
1054 if (lpStatusPtr
->lpDisplayName
)
1055 lpStatusPtr
->lpDisplayName
=
1056 (LPWSTR
)((ULONG_PTR
)lpServices
+ (ULONG_PTR
)lpStatusPtr
->lpDisplayName
);
1063 ERR("REnumServicesStatusExW() failed (Error %lu)\n", dwError
);
1064 SetLastError(dwError
);
1068 TRACE("EnumServicesStatusExW() done\n");
1074 /**********************************************************************
1075 * GetServiceDisplayNameA
1080 GetServiceDisplayNameA(SC_HANDLE hSCManager
,
1081 LPCSTR lpServiceName
,
1082 LPSTR lpDisplayName
,
1083 LPDWORD lpcchBuffer
)
1087 TRACE("GetServiceDisplayNameA() called\n");
1091 dwError
= RGetServiceDisplayNameA(BindingHandle
,
1092 (SC_RPC_HANDLE
)hSCManager
,
1093 (LPSTR
)lpServiceName
,
1096 if (dwError
!= ERROR_SUCCESS
)
1098 ERR("RGetServiceDisplayNameA() failed (Error %lu)\n", dwError
);
1099 SetLastError(dwError
);
1109 /**********************************************************************
1110 * GetServiceDisplayNameW
1115 GetServiceDisplayNameW(SC_HANDLE hSCManager
,
1116 LPCWSTR lpServiceName
,
1117 LPWSTR lpDisplayName
,
1118 LPDWORD lpcchBuffer
)
1122 TRACE("GetServiceDisplayNameW() called\n");
1126 dwError
= RGetServiceDisplayNameW(BindingHandle
,
1127 (SC_RPC_HANDLE
)hSCManager
,
1128 (LPWSTR
)lpServiceName
,
1131 if (dwError
!= ERROR_SUCCESS
)
1133 ERR("RGetServiceDisplayNameW() failed (Error %lu)\n", dwError
);
1134 SetLastError(dwError
);
1144 /**********************************************************************
1145 * GetServiceKeyNameA
1150 GetServiceKeyNameA(SC_HANDLE hSCManager
,
1151 LPCSTR lpDisplayName
,
1152 LPSTR lpServiceName
,
1153 LPDWORD lpcchBuffer
)
1157 TRACE("GetServiceKeyNameA() called\n");
1161 dwError
= RGetServiceKeyNameA(BindingHandle
,
1162 (SC_RPC_HANDLE
)hSCManager
,
1163 (LPSTR
)lpDisplayName
,
1166 if (dwError
!= ERROR_SUCCESS
)
1168 ERR("RGetServiceKeyNameA() failed (Error %lu)\n", dwError
);
1169 SetLastError(dwError
);
1179 /**********************************************************************
1180 * GetServiceKeyNameW
1185 GetServiceKeyNameW(SC_HANDLE hSCManager
,
1186 LPCWSTR lpDisplayName
,
1187 LPWSTR lpServiceName
,
1188 LPDWORD lpcchBuffer
)
1192 TRACE("GetServiceKeyNameW() called\n");
1196 dwError
= RGetServiceKeyNameW(BindingHandle
,
1197 (SC_RPC_HANDLE
)hSCManager
,
1198 (LPWSTR
)lpDisplayName
,
1201 if (dwError
!= ERROR_SUCCESS
)
1203 ERR("RGetServiceKeyNameW() failed (Error %lu)\n", dwError
);
1204 SetLastError(dwError
);
1214 /**********************************************************************
1215 * LockServiceDatabase
1220 LockServiceDatabase(SC_HANDLE hSCManager
)
1225 TRACE("LockServiceDatabase(%x)\n", hSCManager
);
1229 /* Call to services.exe using RPC */
1230 dwError
= RLockServiceDatabase(BindingHandle
,
1231 (SC_RPC_HANDLE
)hSCManager
,
1232 (SC_RPC_LOCK
*)&hLock
);
1233 if (dwError
!= ERROR_SUCCESS
)
1235 ERR("RLockServiceDatabase() failed (Error %lu)\n", dwError
);
1236 SetLastError(dwError
);
1240 TRACE("hLock = %p\n", hLock
);
1247 WaitForSCManager(VOID
)
1251 TRACE("WaitForSCManager() called\n");
1253 /* Try to open the existing event */
1254 hEvent
= OpenEventW(SYNCHRONIZE
,
1256 L
"SvcctrlStartEvent_A3752DX");
1259 if (GetLastError() != ERROR_FILE_NOT_FOUND
)
1262 /* Try to create a new event */
1263 hEvent
= CreateEventW(NULL
,
1266 L
"SvcctrlStartEvent_A3752DX");
1269 /* Try to open the existing event again */
1270 hEvent
= OpenEventW(SYNCHRONIZE
,
1272 L
"SvcctrlStartEvent_A3752DX");
1278 /* Wait for 3 minutes */
1279 WaitForSingleObject(hEvent
, 180000);
1280 CloseHandle(hEvent
);
1282 TRACE("ScmWaitForSCManager() done\n");
1286 /**********************************************************************
1292 OpenSCManagerA(LPCSTR lpMachineName
,
1293 LPCSTR lpDatabaseName
,
1294 DWORD dwDesiredAccess
)
1296 SC_HANDLE hScm
= NULL
;
1299 TRACE("OpenSCManagerA(%s, %s, %lx)\n",
1300 lpMachineName
, lpDatabaseName
, dwDesiredAccess
);
1306 /* Call to services.exe using RPC */
1307 dwError
= ROpenSCManagerA(BindingHandle
,
1308 (LPSTR
)lpMachineName
,
1309 (LPSTR
)lpDatabaseName
,
1311 (SC_RPC_HANDLE
*)&hScm
);
1312 if (dwError
!= ERROR_SUCCESS
)
1314 ERR("ROpenSCManagerA() failed (Error %lu)\n", dwError
);
1315 SetLastError(dwError
);
1319 TRACE("hScm = %p\n", hScm
);
1325 /**********************************************************************
1331 OpenSCManagerW(LPCWSTR lpMachineName
,
1332 LPCWSTR lpDatabaseName
,
1333 DWORD dwDesiredAccess
)
1335 SC_HANDLE hScm
= NULL
;
1338 TRACE("OpenSCManagerW(%S, %S, %lx)\n",
1339 lpMachineName
, lpDatabaseName
, dwDesiredAccess
);
1345 /* Call to services.exe using RPC */
1346 dwError
= ROpenSCManagerW(BindingHandle
,
1347 (LPWSTR
)lpMachineName
,
1348 (LPWSTR
)lpDatabaseName
,
1350 (SC_RPC_HANDLE
*)&hScm
);
1351 if (dwError
!= ERROR_SUCCESS
)
1353 ERR("ROpenSCManagerW() failed (Error %lu)\n", dwError
);
1354 SetLastError(dwError
);
1358 TRACE("hScm = %p\n", hScm
);
1364 /**********************************************************************
1370 OpenServiceA(SC_HANDLE hSCManager
,
1371 LPCSTR lpServiceName
,
1372 DWORD dwDesiredAccess
)
1374 SC_HANDLE hService
= NULL
;
1377 TRACE("OpenServiceA(%p, %s, %lx)\n",
1378 hSCManager
, lpServiceName
, dwDesiredAccess
);
1382 /* Call to services.exe using RPC */
1383 dwError
= ROpenServiceA(BindingHandle
,
1384 (SC_RPC_HANDLE
)hSCManager
,
1385 (LPSTR
)lpServiceName
,
1387 (SC_RPC_HANDLE
*)&hService
);
1388 if (dwError
!= ERROR_SUCCESS
)
1390 ERR("ROpenServiceA() failed (Error %lu)\n", dwError
);
1391 SetLastError(dwError
);
1395 TRACE("hService = %p\n", hService
);
1401 /**********************************************************************
1407 OpenServiceW(SC_HANDLE hSCManager
,
1408 LPCWSTR lpServiceName
,
1409 DWORD dwDesiredAccess
)
1411 SC_HANDLE hService
= NULL
;
1414 TRACE("OpenServiceW(%p, %S, %lx)\n",
1415 hSCManager
, lpServiceName
, dwDesiredAccess
);
1419 /* Call to services.exe using RPC */
1420 dwError
= ROpenServiceW(BindingHandle
,
1421 (SC_RPC_HANDLE
)hSCManager
,
1422 (LPWSTR
)lpServiceName
,
1424 (SC_RPC_HANDLE
*)&hService
);
1425 if (dwError
!= ERROR_SUCCESS
)
1427 if (dwError
== ERROR_SERVICE_DOES_NOT_EXIST
)
1428 WARN("ROpenServiceW() failed (Error %lu)\n", dwError
);
1430 ERR("ROpenServiceW() failed (Error %lu)\n", dwError
);
1431 SetLastError(dwError
);
1435 TRACE("hService = %p\n", hService
);
1441 /**********************************************************************
1442 * QueryServiceConfigA
1447 QueryServiceConfigA(SC_HANDLE hService
,
1448 LPQUERY_SERVICE_CONFIGA lpServiceConfig
,
1450 LPDWORD pcbBytesNeeded
)
1454 TRACE("QueryServiceConfigA(%p, %p, %lu, %p)\n",
1455 hService
, lpServiceConfig
, cbBufSize
, pcbBytesNeeded
);
1459 /* Call to services.exe using RPC */
1460 dwError
= RQueryServiceConfigA(BindingHandle
,
1461 (SC_RPC_HANDLE
)hService
,
1465 if (dwError
!= ERROR_SUCCESS
)
1467 ERR("RQueryServiceConfigA() failed (Error %lu)\n", dwError
);
1468 SetLastError(dwError
);
1472 /* Adjust the pointers */
1473 if (lpServiceConfig
->lpBinaryPathName
)
1474 lpServiceConfig
->lpBinaryPathName
=
1475 (LPSTR
)((ULONG_PTR
)lpServiceConfig
+
1476 (ULONG_PTR
)lpServiceConfig
->lpBinaryPathName
);
1478 if (lpServiceConfig
->lpLoadOrderGroup
)
1479 lpServiceConfig
->lpLoadOrderGroup
=
1480 (LPSTR
)((ULONG_PTR
)lpServiceConfig
+
1481 (ULONG_PTR
)lpServiceConfig
->lpLoadOrderGroup
);
1483 if (lpServiceConfig
->lpDependencies
)
1484 lpServiceConfig
->lpDependencies
=
1485 (LPSTR
)((ULONG_PTR
)lpServiceConfig
+
1486 (ULONG_PTR
)lpServiceConfig
->lpDependencies
);
1488 if (lpServiceConfig
->lpServiceStartName
)
1489 lpServiceConfig
->lpServiceStartName
=
1490 (LPSTR
)((ULONG_PTR
)lpServiceConfig
+
1491 (ULONG_PTR
)lpServiceConfig
->lpServiceStartName
);
1493 if (lpServiceConfig
->lpDisplayName
)
1494 lpServiceConfig
->lpDisplayName
=
1495 (LPSTR
)((ULONG_PTR
)lpServiceConfig
+
1496 (ULONG_PTR
)lpServiceConfig
->lpDisplayName
);
1498 TRACE("QueryServiceConfigA() done\n");
1504 /**********************************************************************
1505 * QueryServiceConfigW
1510 QueryServiceConfigW(SC_HANDLE hService
,
1511 LPQUERY_SERVICE_CONFIGW lpServiceConfig
,
1513 LPDWORD pcbBytesNeeded
)
1517 TRACE("QueryServiceConfigW(%p, %p, %lu, %p)\n",
1518 hService
, lpServiceConfig
, cbBufSize
, pcbBytesNeeded
);
1522 /* Call to services.exe using RPC */
1523 dwError
= RQueryServiceConfigW(BindingHandle
,
1524 (SC_RPC_HANDLE
)hService
,
1525 (LPBYTE
)lpServiceConfig
,
1528 if (dwError
!= ERROR_SUCCESS
)
1530 if (dwError
== ERROR_INSUFFICIENT_BUFFER
)
1531 WARN("RQueryServiceConfigW() failed (Error %lu)\n", dwError
);
1533 ERR("RQueryServiceConfigW() failed (Error %lu)\n", dwError
);
1534 SetLastError(dwError
);
1538 /* Adjust the pointers */
1539 if (lpServiceConfig
->lpBinaryPathName
)
1540 lpServiceConfig
->lpBinaryPathName
=
1541 (LPWSTR
)((ULONG_PTR
)lpServiceConfig
+
1542 (ULONG_PTR
)lpServiceConfig
->lpBinaryPathName
);
1544 if (lpServiceConfig
->lpLoadOrderGroup
)
1545 lpServiceConfig
->lpLoadOrderGroup
=
1546 (LPWSTR
)((ULONG_PTR
)lpServiceConfig
+
1547 (ULONG_PTR
)lpServiceConfig
->lpLoadOrderGroup
);
1549 if (lpServiceConfig
->lpDependencies
)
1550 lpServiceConfig
->lpDependencies
=
1551 (LPWSTR
)((ULONG_PTR
)lpServiceConfig
+
1552 (ULONG_PTR
)lpServiceConfig
->lpDependencies
);
1554 if (lpServiceConfig
->lpServiceStartName
)
1555 lpServiceConfig
->lpServiceStartName
=
1556 (LPWSTR
)((ULONG_PTR
)lpServiceConfig
+
1557 (ULONG_PTR
)lpServiceConfig
->lpServiceStartName
);
1559 if (lpServiceConfig
->lpDisplayName
)
1560 lpServiceConfig
->lpDisplayName
=
1561 (LPWSTR
)((ULONG_PTR
)lpServiceConfig
+
1562 (ULONG_PTR
)lpServiceConfig
->lpDisplayName
);
1564 TRACE("QueryServiceConfigW() done\n");
1570 /**********************************************************************
1571 * QueryServiceConfig2A
1576 QueryServiceConfig2A(SC_HANDLE hService
,
1580 LPDWORD pcbBytesNeeded
)
1584 TRACE("QueryServiceConfig2A(%p, %lu, %p, %lu, %p)\n",
1585 hService
, dwInfoLevel
, lpBuffer
, cbBufSize
, pcbBytesNeeded
);
1589 /* Call to services.exe using RPC */
1590 dwError
= RQueryServiceConfig2A(BindingHandle
,
1591 (SC_RPC_HANDLE
)hService
,
1596 if (dwError
!= ERROR_SUCCESS
)
1598 ERR("RQueryServiceConfig2A() failed (Error %lu)\n", dwError
);
1599 SetLastError(dwError
);
1603 switch (dwInfoLevel
)
1605 case SERVICE_CONFIG_DESCRIPTION
:
1607 LPSERVICE_DESCRIPTIONA lpPtr
= (LPSERVICE_DESCRIPTIONA
)lpBuffer
;
1609 if (lpPtr
->lpDescription
!= NULL
)
1610 lpPtr
->lpDescription
=
1611 (LPSTR
)((UINT_PTR
)lpPtr
+ (UINT_PTR
)lpPtr
->lpDescription
);
1615 case SERVICE_CONFIG_FAILURE_ACTIONS
:
1617 LPSERVICE_FAILURE_ACTIONSA lpPtr
= (LPSERVICE_FAILURE_ACTIONSA
)lpBuffer
;
1619 if (lpPtr
->lpRebootMsg
!= NULL
)
1620 lpPtr
->lpRebootMsg
=
1621 (LPSTR
)((UINT_PTR
)lpPtr
+ (UINT_PTR
)lpPtr
->lpRebootMsg
);
1623 if (lpPtr
->lpCommand
!= NULL
)
1625 (LPSTR
)((UINT_PTR
)lpPtr
+ (UINT_PTR
)lpPtr
->lpCommand
);
1627 if (lpPtr
->lpsaActions
!= NULL
)
1628 lpPtr
->lpsaActions
=
1629 (SC_ACTION
*)((UINT_PTR
)lpPtr
+ (UINT_PTR
)lpPtr
->lpsaActions
);
1634 ERR("Unknown info level 0x%lx\n", dwInfoLevel
);
1635 SetLastError(ERROR_INVALID_PARAMETER
);
1639 TRACE("QueryServiceConfig2A() done\n");
1645 /**********************************************************************
1646 * QueryServiceConfig2W
1651 QueryServiceConfig2W(SC_HANDLE hService
,
1655 LPDWORD pcbBytesNeeded
)
1659 TRACE("QueryServiceConfig2W(%p, %lu, %p, %lu, %p)\n",
1660 hService
, dwInfoLevel
, lpBuffer
, cbBufSize
, pcbBytesNeeded
);
1664 /* Call to services.exe using RPC */
1665 dwError
= RQueryServiceConfig2W(BindingHandle
,
1666 (SC_RPC_HANDLE
)hService
,
1671 if (dwError
!= ERROR_SUCCESS
)
1673 ERR("RQueryServiceConfig2W() failed (Error %lu)\n", dwError
);
1674 SetLastError(dwError
);
1678 switch (dwInfoLevel
)
1680 case SERVICE_CONFIG_DESCRIPTION
:
1682 LPSERVICE_DESCRIPTIONW lpPtr
= (LPSERVICE_DESCRIPTIONW
)lpBuffer
;
1684 if (lpPtr
->lpDescription
!= NULL
)
1685 lpPtr
->lpDescription
=
1686 (LPWSTR
)((UINT_PTR
)lpPtr
+ (UINT_PTR
)lpPtr
->lpDescription
);
1690 case SERVICE_CONFIG_FAILURE_ACTIONS
:
1692 LPSERVICE_FAILURE_ACTIONSW lpPtr
= (LPSERVICE_FAILURE_ACTIONSW
)lpBuffer
;
1694 if (lpPtr
->lpRebootMsg
!= NULL
)
1695 lpPtr
->lpRebootMsg
=
1696 (LPWSTR
)((UINT_PTR
)lpPtr
+ (UINT_PTR
)lpPtr
->lpRebootMsg
);
1698 if (lpPtr
->lpCommand
!= NULL
)
1700 (LPWSTR
)((UINT_PTR
)lpPtr
+ (UINT_PTR
)lpPtr
->lpCommand
);
1702 if (lpPtr
->lpsaActions
!= NULL
)
1703 lpPtr
->lpsaActions
=
1704 (SC_ACTION
*)((UINT_PTR
)lpPtr
+ (UINT_PTR
)lpPtr
->lpsaActions
);
1709 WARN("Unknown info level 0x%lx\n", dwInfoLevel
);
1710 SetLastError(ERROR_INVALID_PARAMETER
);
1714 TRACE("QueryServiceConfig2W() done\n");
1720 /**********************************************************************
1721 * QueryServiceLockStatusA
1726 QueryServiceLockStatusA(SC_HANDLE hSCManager
,
1727 LPQUERY_SERVICE_LOCK_STATUSA lpLockStatus
,
1729 LPDWORD pcbBytesNeeded
)
1733 TRACE("QueryServiceLockStatusA() called\n");
1737 /* Call to services.exe using RPC */
1738 dwError
= RQueryServiceLockStatusA(BindingHandle
,
1739 (SC_RPC_HANDLE
)hSCManager
,
1743 if (dwError
!= ERROR_SUCCESS
)
1745 ERR("RQueryServiceLockStatusA() failed (Error %lu)\n", dwError
);
1746 SetLastError(dwError
);
1750 if (lpLockStatus
->lpLockOwner
!= NULL
)
1752 lpLockStatus
->lpLockOwner
=
1753 (LPSTR
)((UINT_PTR
)lpLockStatus
+ (UINT_PTR
)lpLockStatus
->lpLockOwner
);
1756 TRACE("QueryServiceLockStatusA() done\n");
1762 /**********************************************************************
1763 * QueryServiceLockStatusW
1768 QueryServiceLockStatusW(SC_HANDLE hSCManager
,
1769 LPQUERY_SERVICE_LOCK_STATUSW lpLockStatus
,
1771 LPDWORD pcbBytesNeeded
)
1775 TRACE("QueryServiceLockStatusW() called\n");
1779 /* Call to services.exe using RPC */
1780 dwError
= RQueryServiceLockStatusW(BindingHandle
,
1781 (SC_RPC_HANDLE
)hSCManager
,
1785 if (dwError
!= ERROR_SUCCESS
)
1787 ERR("RQueryServiceLockStatusW() failed (Error %lu)\n", dwError
);
1788 SetLastError(dwError
);
1792 if (lpLockStatus
->lpLockOwner
!= NULL
)
1794 lpLockStatus
->lpLockOwner
=
1795 (LPWSTR
)((UINT_PTR
)lpLockStatus
+ (UINT_PTR
)lpLockStatus
->lpLockOwner
);
1798 TRACE("QueryServiceLockStatusW() done\n");
1804 /**********************************************************************
1805 * QueryServiceObjectSecurity
1810 QueryServiceObjectSecurity(SC_HANDLE hService
,
1811 SECURITY_INFORMATION dwSecurityInformation
,
1812 PSECURITY_DESCRIPTOR lpSecurityDescriptor
,
1814 LPDWORD pcbBytesNeeded
)
1818 TRACE("QueryServiceObjectSecurity(%p, %lu, %p)\n",
1819 hService
, dwSecurityInformation
, lpSecurityDescriptor
);
1823 /* Call to services.exe using RPC */
1824 dwError
= RQueryServiceObjectSecurity(BindingHandle
,
1825 (SC_RPC_HANDLE
)hService
,
1826 dwSecurityInformation
,
1827 (LPBYTE
)lpSecurityDescriptor
,
1830 if (dwError
!= ERROR_SUCCESS
)
1832 ERR("QueryServiceObjectSecurity() failed (Error %lu)\n", dwError
);
1833 SetLastError(dwError
);
1840 /**********************************************************************
1841 * SetServiceObjectSecurity
1846 SetServiceObjectSecurity(SC_HANDLE hService
,
1847 SECURITY_INFORMATION dwSecurityInformation
,
1848 PSECURITY_DESCRIPTOR lpSecurityDescriptor
)
1850 PSECURITY_DESCRIPTOR SelfRelativeSD
= NULL
;
1856 Status
= RtlMakeSelfRelativeSD(lpSecurityDescriptor
,
1859 if (Status
!= STATUS_BUFFER_TOO_SMALL
)
1861 SetLastError(ERROR_INVALID_PARAMETER
);
1865 SelfRelativeSD
= HeapAlloc(GetProcessHeap(), 0, Length
);
1866 if (SelfRelativeSD
== NULL
)
1868 SetLastError(ERROR_NOT_ENOUGH_MEMORY
);
1872 Status
= RtlMakeSelfRelativeSD(lpSecurityDescriptor
,
1875 if (!NT_SUCCESS(Status
))
1877 HeapFree(GetProcessHeap(), 0, SelfRelativeSD
);
1878 SetLastError(RtlNtStatusToDosError(Status
));
1884 /* Call to services.exe using RPC */
1885 dwError
= RSetServiceObjectSecurity(BindingHandle
,
1886 (SC_RPC_HANDLE
)hService
,
1887 dwSecurityInformation
,
1888 (LPBYTE
)SelfRelativeSD
,
1891 HeapFree(GetProcessHeap(), 0, SelfRelativeSD
);
1893 if (dwError
!= ERROR_SUCCESS
)
1895 ERR("RServiceObjectSecurity() failed (Error %lu)\n", dwError
);
1896 SetLastError(dwError
);
1904 /**********************************************************************
1905 * QueryServiceStatus
1910 QueryServiceStatus(SC_HANDLE hService
,
1911 LPSERVICE_STATUS lpServiceStatus
)
1915 TRACE("QueryServiceStatus(%p, %p)\n",
1916 hService
, lpServiceStatus
);
1920 /* Call to services.exe using RPC */
1921 dwError
= RQueryServiceStatus(BindingHandle
,
1922 (SC_RPC_HANDLE
)hService
,
1924 if (dwError
!= ERROR_SUCCESS
)
1926 ERR("RQueryServiceStatus() failed (Error %lu)\n", dwError
);
1927 SetLastError(dwError
);
1935 /**********************************************************************
1936 * QueryServiceStatusEx
1941 QueryServiceStatusEx(SC_HANDLE hService
,
1942 SC_STATUS_TYPE InfoLevel
,
1945 LPDWORD pcbBytesNeeded
)
1949 TRACE("QueryServiceStatusEx() called\n");
1953 /* Call to services.exe using RPC */
1954 dwError
= RQueryServiceStatusEx(BindingHandle
,
1955 (SC_RPC_HANDLE
)hService
,
1960 if (dwError
!= ERROR_SUCCESS
)
1962 ERR("RQueryServiceStatusEx() failed (Error %lu)\n", dwError
);
1963 SetLastError(dwError
);
1971 /**********************************************************************
1977 StartServiceA(SC_HANDLE hService
,
1978 DWORD dwNumServiceArgs
,
1979 LPCSTR
*lpServiceArgVectors
)
1983 dwError
= RStartServiceA(BindingHandle
,
1984 (SC_RPC_HANDLE
)hService
,
1986 (LPSTRING_PTRSA
)lpServiceArgVectors
);
1989 if (dwError
!= ERROR_SUCCESS
)
1991 ERR("RStartServiceA() failed (Error %lu)\n", dwError
);
1992 SetLastError(dwError
);
2000 /**********************************************************************
2006 StartServiceW(SC_HANDLE hService
,
2007 DWORD dwNumServiceArgs
,
2008 LPCWSTR
*lpServiceArgVectors
)
2012 dwError
= RStartServiceW(BindingHandle
,
2013 (SC_RPC_HANDLE
)hService
,
2015 (LPSTRING_PTRSW
)lpServiceArgVectors
);
2017 if (dwError
!= ERROR_SUCCESS
)
2019 ERR("RStartServiceW() failed (Error %lu)\n", dwError
);
2020 SetLastError(dwError
);
2028 /**********************************************************************
2029 * UnlockServiceDatabase
2034 UnlockServiceDatabase(SC_LOCK ScLock
)
2038 TRACE("UnlockServiceDatabase(%x)\n", ScLock
);
2042 /* Call to services.exe using RPC */
2043 dwError
= RUnlockServiceDatabase(BindingHandle
,
2044 (SC_RPC_LOCK
)ScLock
);
2045 if (dwError
!= ERROR_SUCCESS
)
2047 ERR("RUnlockServiceDatabase() failed (Error %lu)\n", dwError
);
2048 SetLastError(dwError
);
2056 /**********************************************************************
2057 * NotifyBootConfigStatus
2062 NotifyBootConfigStatus(BOOL BootAcceptable
)
2066 TRACE("NotifyBootConfigStatus()\n");
2070 /* Call to services.exe using RPC */
2071 dwError
= RNotifyBootConfigStatus(BindingHandle
,
2074 if (dwError
!= ERROR_SUCCESS
)
2076 ERR("NotifyBootConfigStatus() failed (Error %lu)\n", dwError
);
2077 SetLastError(dwError
);