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 ******************************************************************/
21 /* FUNCTIONS *****************************************************************/
23 handle_t BindingHandle
= NULL
;
28 LPWSTR pszStringBinding
;
31 if (BindingHandle
!= NULL
)
34 status
= RpcStringBindingComposeW(NULL
,
42 DPRINT1("RpcStringBindingCompose returned 0x%x\n", status
);
46 /* Set the binding handle that will be used to bind to the server. */
47 status
= RpcBindingFromStringBindingW(pszStringBinding
,
51 DPRINT1("RpcBindingFromStringBinding returned 0x%x\n", status
);
54 status
= RpcStringFreeW(&pszStringBinding
);
57 DPRINT1("RpcStringFree returned 0x%x\n", status
);
68 if (BindingHandle
== NULL
)
71 status
= RpcBindingFree(&BindingHandle
);
74 DPRINT1("RpcBindingFree returned 0x%x\n", status
);
80 /**********************************************************************
81 * ChangeServiceConfig2A
86 ChangeServiceConfig2A(SC_HANDLE hService
,
93 DPRINT("ChangeServiceConfig2A() called\n");
95 /* Determine the length of the lpInfo parameter */
98 case SERVICE_CONFIG_DESCRIPTION
:
99 lpInfoSize
= sizeof(SERVICE_DESCRIPTIONA
);
102 case SERVICE_CONFIG_FAILURE_ACTIONS
:
103 lpInfoSize
= sizeof(SERVICE_FAILURE_ACTIONSA
);
107 DPRINT1("Unknown info level 0x%lx\n", dwInfoLevel
);
108 SetLastError(ERROR_INVALID_PARAMETER
);
117 dwError
= ScmrChangeServiceConfig2A(BindingHandle
,
118 (unsigned int)hService
,
122 if (dwError
!= ERROR_SUCCESS
)
124 DPRINT1("ScmrChangeServiceConfig2A() failed (Error %lu)\n", dwError
);
125 SetLastError(dwError
);
133 /**********************************************************************
134 * ChangeServiceConfig2W
139 ChangeServiceConfig2W(SC_HANDLE hService
,
146 DPRINT("ChangeServiceConfig2W() called\n");
148 /* Determine the length of the lpInfo parameter */
151 case SERVICE_CONFIG_DESCRIPTION
:
152 lpInfoSize
= sizeof(SERVICE_DESCRIPTIONW
);
155 case SERVICE_CONFIG_FAILURE_ACTIONS
:
156 lpInfoSize
= sizeof(SERVICE_FAILURE_ACTIONSW
);
160 DPRINT1("Unknown info level 0x%lx\n", dwInfoLevel
);
161 SetLastError(ERROR_INVALID_PARAMETER
);
170 dwError
= ScmrChangeServiceConfig2W(BindingHandle
,
171 (unsigned int)hService
,
175 if (dwError
!= ERROR_SUCCESS
)
177 DPRINT1("ScmrChangeServiceConfig2W() failed (Error %lu)\n", dwError
);
178 SetLastError(dwError
);
186 /**********************************************************************
187 * ChangeServiceConfigA
192 ChangeServiceConfigA(SC_HANDLE hService
,
195 DWORD dwErrorControl
,
196 LPCSTR lpBinaryPathName
,
197 LPCSTR lpLoadOrderGroup
,
199 LPCSTR lpDependencies
,
200 LPCSTR lpServiceStartName
,
202 LPCSTR lpDisplayName
)
205 DWORD dwDependenciesLength
= 0;
209 DPRINT("ChangeServiceConfigA() called\n");
211 /* Calculate the Dependencies length*/
212 if (lpDependencies
!= NULL
)
214 lpStr
= (LPSTR
)lpDependencies
;
217 dwLength
= strlen(lpStr
) + 1;
218 dwDependenciesLength
+= dwLength
;
219 lpStr
= lpStr
+ dwLength
;
221 dwDependenciesLength
++;
224 /* FIXME: Encrypt the password */
228 /* Call to services.exe using RPC */
229 dwError
= ScmrChangeServiceConfigA(BindingHandle
,
230 (unsigned int)hService
,
234 (LPSTR
)lpBinaryPathName
,
235 (LPSTR
)lpLoadOrderGroup
,
237 (LPSTR
)lpDependencies
,
238 dwDependenciesLength
,
239 (LPSTR
)lpServiceStartName
,
240 NULL
, /* FIXME: lpPassword */
241 0, /* FIXME: dwPasswordLength */
242 (LPSTR
)lpDisplayName
);
243 if (dwError
!= ERROR_SUCCESS
)
245 DPRINT1("ScmrChangeServiceConfigA() failed (Error %lu)\n", dwError
);
246 SetLastError(dwError
);
254 /**********************************************************************
255 * ChangeServiceConfigW
260 ChangeServiceConfigW(SC_HANDLE hService
,
263 DWORD dwErrorControl
,
264 LPCWSTR lpBinaryPathName
,
265 LPCWSTR lpLoadOrderGroup
,
267 LPCWSTR lpDependencies
,
268 LPCWSTR lpServiceStartName
,
270 LPCWSTR lpDisplayName
)
273 DWORD dwDependenciesLength
= 0;
277 DPRINT("ChangeServiceConfigW() called\n");
279 /* Calculate the Dependencies length*/
280 if (lpDependencies
!= NULL
)
282 lpStr
= (LPWSTR
)lpDependencies
;
285 dwLength
= wcslen(lpStr
) + 1;
286 dwDependenciesLength
+= dwLength
;
287 lpStr
= lpStr
+ dwLength
;
289 dwDependenciesLength
++;
292 /* FIXME: Encrypt the password */
296 /* Call to services.exe using RPC */
297 dwError
= ScmrChangeServiceConfigW(BindingHandle
,
298 (unsigned int)hService
,
302 (LPWSTR
)lpBinaryPathName
,
303 (LPWSTR
)lpLoadOrderGroup
,
305 (LPWSTR
)lpDependencies
,
306 dwDependenciesLength
,
307 (LPWSTR
)lpServiceStartName
,
308 NULL
, /* FIXME: lpPassword */
309 0, /* FIXME: dwPasswordLength */
310 (LPWSTR
)lpDisplayName
);
311 if (dwError
!= ERROR_SUCCESS
)
313 DPRINT1("ScmrChangeServiceConfigW() failed (Error %lu)\n", dwError
);
314 SetLastError(dwError
);
322 /**********************************************************************
328 CloseServiceHandle(SC_HANDLE hSCObject
)
332 DPRINT("CloseServiceHandle() called\n");
336 /* Call to services.exe using RPC */
337 dwError
= ScmrCloseServiceHandle(BindingHandle
,
338 (unsigned int)hSCObject
);
341 DPRINT1("ScmrCloseServiceHandle() failed (Error %lu)\n", dwError
);
342 SetLastError(dwError
);
346 DPRINT("CloseServiceHandle() done\n");
352 /**********************************************************************
358 ControlService(SC_HANDLE hService
,
360 LPSERVICE_STATUS lpServiceStatus
)
364 DPRINT("ControlService(%x, %x, %p)\n",
365 hService
, dwControl
, lpServiceStatus
);
369 /* Call to services.exe using RPC */
370 dwError
= ScmrControlService(BindingHandle
,
371 (unsigned int)hService
,
374 if (dwError
!= ERROR_SUCCESS
)
376 DPRINT1("ScmrControlService() failed (Error %lu)\n", dwError
);
377 SetLastError(dwError
);
381 DPRINT("ControlService() done\n");
387 /**********************************************************************
393 ControlServiceEx(IN SC_HANDLE hService
,
395 IN DWORD dwInfoLevel
,
396 IN OUT PVOID pControlParams
)
398 DPRINT1("ControlServiceEx(0x%p, 0x%x, 0x%x, 0x%p) UNIMPLEMENTED!\n",
399 hService
, dwControl
, dwInfoLevel
, pControlParams
);
400 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
406 /**********************************************************************
412 CreateServiceA(SC_HANDLE hSCManager
,
413 LPCSTR lpServiceName
,
414 LPCSTR lpDisplayName
,
415 DWORD dwDesiredAccess
,
418 DWORD dwErrorControl
,
419 LPCSTR lpBinaryPathName
,
420 LPCSTR lpLoadOrderGroup
,
422 LPCSTR lpDependencies
,
423 LPCSTR lpServiceStartName
,
426 SC_HANDLE RetVal
= NULL
;
427 LPWSTR lpServiceNameW
= NULL
;
428 LPWSTR lpDisplayNameW
= NULL
;
429 LPWSTR lpBinaryPathNameW
= NULL
;
430 LPWSTR lpLoadOrderGroupW
= NULL
;
431 LPWSTR lpDependenciesW
= NULL
;
432 LPWSTR lpServiceStartNameW
= NULL
;
433 LPWSTR lpPasswordW
= NULL
;
434 DWORD dwDependenciesLength
= 0;
438 int len
= MultiByteToWideChar(CP_ACP
, 0, lpServiceName
, -1, NULL
, 0);
439 lpServiceNameW
= HeapAlloc(GetProcessHeap(), 0, len
* sizeof(WCHAR
));
442 SetLastError(ERROR_NOT_ENOUGH_MEMORY
);
445 MultiByteToWideChar(CP_ACP
, 0, lpServiceName
, -1, lpServiceNameW
, len
);
447 len
= MultiByteToWideChar(CP_ACP
, 0, lpDisplayName
, -1, NULL
, 0);
448 lpDisplayNameW
= HeapAlloc(GetProcessHeap(), 0, len
* sizeof(WCHAR
));
451 SetLastError(ERROR_NOT_ENOUGH_MEMORY
);
454 MultiByteToWideChar(CP_ACP
, 0, lpDisplayName
, -1, lpDisplayNameW
, len
);
456 len
= MultiByteToWideChar(CP_ACP
, 0, lpBinaryPathName
, -1, NULL
, 0);
457 lpBinaryPathNameW
= HeapAlloc(GetProcessHeap(), 0, len
* sizeof(WCHAR
));
458 if (!lpBinaryPathNameW
)
460 SetLastError(ERROR_NOT_ENOUGH_MEMORY
);
463 MultiByteToWideChar(CP_ACP
, 0, lpDisplayName
, -1, lpBinaryPathNameW
, len
);
465 len
= MultiByteToWideChar(CP_ACP
, 0, lpLoadOrderGroup
, -1, NULL
, 0);
466 lpLoadOrderGroupW
= HeapAlloc(GetProcessHeap(), 0, len
* sizeof(WCHAR
));
467 if (!lpLoadOrderGroupW
)
469 SetLastError(ERROR_NOT_ENOUGH_MEMORY
);
472 MultiByteToWideChar(CP_ACP
, 0, lpLoadOrderGroup
, -1, lpLoadOrderGroupW
, len
);
474 if (lpDependencies
!= NULL
)
476 lpStr
= (LPSTR
)lpDependencies
;
479 dwLength
= strlen(lpStr
) + 1;
480 dwDependenciesLength
+= dwLength
;
481 lpStr
= lpStr
+ dwLength
;
483 dwDependenciesLength
++;
486 lpDependenciesW
= HeapAlloc(GetProcessHeap(), 0, dwDependenciesLength
* sizeof(WCHAR
));
487 if (!lpDependenciesW
)
489 SetLastError(ERROR_NOT_ENOUGH_MEMORY
);
492 MultiByteToWideChar(CP_ACP
, 0, lpDependencies
, -1, lpDependenciesW
, dwDependenciesLength
);
494 len
= MultiByteToWideChar(CP_ACP
, 0, lpServiceStartName
, -1, NULL
, 0);
495 lpServiceStartName
= HeapAlloc(GetProcessHeap(), 0, len
* sizeof(WCHAR
));
496 if (!lpServiceStartNameW
)
498 SetLastError(ERROR_NOT_ENOUGH_MEMORY
);
501 MultiByteToWideChar(CP_ACP
, 0, lpServiceStartName
, -1, lpServiceStartNameW
, len
);
503 len
= MultiByteToWideChar(CP_ACP
, 0, lpPassword
, -1, NULL
, 0);
504 lpPasswordW
= HeapAlloc(GetProcessHeap(), 0, len
* sizeof(WCHAR
));
507 SetLastError(ERROR_NOT_ENOUGH_MEMORY
);
510 MultiByteToWideChar(CP_ACP
, 0, lpPassword
, -1, lpPasswordW
, len
);
512 RetVal
= CreateServiceW(hSCManager
,
527 HeapFree(GetProcessHeap(), 0, lpServiceNameW
);
528 HeapFree(GetProcessHeap(), 0, lpDisplayNameW
);
529 HeapFree(GetProcessHeap(), 0, lpBinaryPathNameW
);
530 HeapFree(GetProcessHeap(), 0, lpLoadOrderGroupW
);
531 HeapFree(GetProcessHeap(), 0, lpDependenciesW
);
532 HeapFree(GetProcessHeap(), 0, lpServiceStartNameW
);
533 HeapFree(GetProcessHeap(), 0, lpPasswordW
);
539 /**********************************************************************
545 CreateServiceW(SC_HANDLE hSCManager
,
546 LPCWSTR lpServiceName
,
547 LPCWSTR lpDisplayName
,
548 DWORD dwDesiredAccess
,
551 DWORD dwErrorControl
,
552 LPCWSTR lpBinaryPathName
,
553 LPCWSTR lpLoadOrderGroup
,
555 LPCWSTR lpDependencies
,
556 LPCWSTR lpServiceStartName
,
559 SC_HANDLE hService
= NULL
;
560 DWORD dwDependenciesLength
= 0;
565 DPRINT("CreateServiceW() called\n");
567 /* Calculate the Dependencies length*/
568 if (lpDependencies
!= NULL
)
570 lpStr
= (LPWSTR
)lpDependencies
;
573 dwLength
= wcslen(lpStr
) + 1;
574 dwDependenciesLength
+= dwLength
;
575 lpStr
= lpStr
+ dwLength
;
577 dwDependenciesLength
++;
580 /* FIXME: Encrypt the password */
584 /* Call to services.exe using RPC */
585 dwError
= ScmrCreateServiceW(BindingHandle
,
586 (unsigned int)hSCManager
,
587 (LPWSTR
)lpServiceName
,
588 (LPWSTR
)lpDisplayName
,
593 (LPWSTR
)lpBinaryPathName
,
594 (LPWSTR
)lpLoadOrderGroup
,
596 (LPWSTR
)lpDependencies
,
597 dwDependenciesLength
,
598 (LPWSTR
)lpServiceStartName
,
599 NULL
, /* FIXME: lpPassword */
600 0, /* FIXME: dwPasswordLength */
601 (unsigned int *)&hService
);
602 if (dwError
!= ERROR_SUCCESS
)
604 DPRINT("ScmrCreateServiceW() failed (Error %lu)\n", dwError
);
605 SetLastError(dwError
);
613 /**********************************************************************
619 DeleteService(SC_HANDLE hService
)
623 DPRINT("DeleteService(%x)\n", hService
);
627 /* Call to services.exe using RPC */
628 dwError
= ScmrDeleteService(BindingHandle
,
629 (unsigned int)hService
);
630 if (dwError
!= ERROR_SUCCESS
)
632 DPRINT1("ScmrDeleteService() failed (Error %lu)\n", dwError
);
633 SetLastError(dwError
);
641 /**********************************************************************
642 * EnumDependentServicesA
647 EnumDependentServicesA(SC_HANDLE hService
,
648 DWORD dwServiceState
,
649 LPENUM_SERVICE_STATUSA lpServices
,
651 LPDWORD pcbBytesNeeded
,
652 LPDWORD lpServicesReturned
)
654 LPENUM_SERVICE_STATUSA lpStatusPtr
;
655 DWORD dwError
= ERROR_SUCCESS
;
658 DPRINT("EnumServicesStatusA() called\n");
662 dwError
= ScmrEnumDependentServicesA(BindingHandle
,
663 (unsigned int)hService
,
665 (unsigned char *)lpServices
,
670 lpStatusPtr
= (LPENUM_SERVICE_STATUSA
)lpServices
;
671 for (dwCount
= 0; dwCount
< *lpServicesReturned
; dwCount
++)
673 if (lpStatusPtr
->lpServiceName
)
674 lpStatusPtr
->lpServiceName
=
675 (LPSTR
)((ULONG_PTR
)lpServices
+ (ULONG_PTR
)lpStatusPtr
->lpServiceName
);
677 if (lpStatusPtr
->lpDisplayName
)
678 lpStatusPtr
->lpDisplayName
=
679 (LPSTR
)((ULONG_PTR
)lpServices
+ (ULONG_PTR
)lpStatusPtr
->lpDisplayName
);
684 if (dwError
!= ERROR_SUCCESS
)
686 DPRINT("ScmrEnumDependentServicesA() failed (Error %lu)\n", dwError
);
687 SetLastError(dwError
);
691 DPRINT("EnumDependentServicesA() done\n");
697 /**********************************************************************
698 * EnumDependentServicesW
703 EnumDependentServicesW(SC_HANDLE hService
,
704 DWORD dwServiceState
,
705 LPENUM_SERVICE_STATUSW lpServices
,
707 LPDWORD pcbBytesNeeded
,
708 LPDWORD lpServicesReturned
)
710 LPENUM_SERVICE_STATUSW lpStatusPtr
;
711 DWORD dwError
= ERROR_SUCCESS
;
714 DPRINT("EnumServicesStatusW() called\n");
718 dwError
= ScmrEnumDependentServicesW(BindingHandle
,
719 (unsigned int)hService
,
721 (unsigned char *)lpServices
,
726 lpStatusPtr
= (LPENUM_SERVICE_STATUSW
)lpServices
;
727 for (dwCount
= 0; dwCount
< *lpServicesReturned
; dwCount
++)
729 if (lpStatusPtr
->lpServiceName
)
730 lpStatusPtr
->lpServiceName
=
731 (LPWSTR
)((ULONG_PTR
)lpServices
+ (ULONG_PTR
)lpStatusPtr
->lpServiceName
);
733 if (lpStatusPtr
->lpDisplayName
)
734 lpStatusPtr
->lpDisplayName
=
735 (LPWSTR
)((ULONG_PTR
)lpServices
+ (ULONG_PTR
)lpStatusPtr
->lpDisplayName
);
740 if (dwError
!= ERROR_SUCCESS
)
742 DPRINT("ScmrEnumDependentServicesW() failed (Error %lu)\n", dwError
);
743 SetLastError(dwError
);
747 DPRINT("EnumDependentServicesW() done\n");
753 /**********************************************************************
761 SC_HANDLE hSCManager
,
763 DWORD dwServiceState
,
764 LPENUM_SERVICE_STATUSW lpServices
,
766 LPDWORD pcbBytesNeeded
,
767 LPDWORD lpServicesReturned
,
768 LPDWORD lpResumeHandle
,
771 DPRINT1("EnumServiceGroupW is unimplemented\n");
772 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
777 /**********************************************************************
778 * EnumServicesStatusA
783 EnumServicesStatusA(SC_HANDLE hSCManager
,
785 DWORD dwServiceState
,
786 LPENUM_SERVICE_STATUSA lpServices
,
788 LPDWORD pcbBytesNeeded
,
789 LPDWORD lpServicesReturned
,
790 LPDWORD lpResumeHandle
)
792 LPENUM_SERVICE_STATUSA lpStatusPtr
;
793 DWORD dwError
= ERROR_SUCCESS
;
796 DPRINT("EnumServicesStatusA() called\n");
800 dwError
= ScmrEnumServicesStatusA(BindingHandle
,
801 (unsigned int)hSCManager
,
804 (unsigned char *)lpServices
,
810 lpStatusPtr
= (LPENUM_SERVICE_STATUSA
)lpServices
;
811 for (dwCount
= 0; dwCount
< *lpServicesReturned
; dwCount
++)
813 if (lpStatusPtr
->lpServiceName
)
814 lpStatusPtr
->lpServiceName
=
815 (LPSTR
)((ULONG_PTR
)lpServices
+ (ULONG_PTR
)lpStatusPtr
->lpServiceName
);
817 if (lpStatusPtr
->lpDisplayName
)
818 lpStatusPtr
->lpDisplayName
=
819 (LPSTR
)((ULONG_PTR
)lpServices
+ (ULONG_PTR
)lpStatusPtr
->lpDisplayName
);
824 if (dwError
!= ERROR_SUCCESS
)
826 DPRINT("ScmrEnumServicesStatusA() failed (Error %lu)\n", dwError
);
827 SetLastError(dwError
);
831 DPRINT("EnumServicesStatusA() done\n");
837 /**********************************************************************
838 * EnumServicesStatusW
843 EnumServicesStatusW(SC_HANDLE hSCManager
,
845 DWORD dwServiceState
,
846 LPENUM_SERVICE_STATUSW lpServices
,
848 LPDWORD pcbBytesNeeded
,
849 LPDWORD lpServicesReturned
,
850 LPDWORD lpResumeHandle
)
852 LPENUM_SERVICE_STATUSW lpStatusPtr
;
853 DWORD dwError
= ERROR_SUCCESS
;
856 DPRINT("EnumServicesStatusW() called\n");
860 dwError
= ScmrEnumServicesStatusW(BindingHandle
,
861 (unsigned int)hSCManager
,
864 (unsigned char *)lpServices
,
870 lpStatusPtr
= (LPENUM_SERVICE_STATUSW
)lpServices
;
871 for (dwCount
= 0; dwCount
< *lpServicesReturned
; dwCount
++)
873 if (lpStatusPtr
->lpServiceName
)
874 lpStatusPtr
->lpServiceName
=
875 (LPWSTR
)((ULONG_PTR
)lpServices
+ (ULONG_PTR
)lpStatusPtr
->lpServiceName
);
877 if (lpStatusPtr
->lpDisplayName
)
878 lpStatusPtr
->lpDisplayName
=
879 (LPWSTR
)((ULONG_PTR
)lpServices
+ (ULONG_PTR
)lpStatusPtr
->lpDisplayName
);
884 if (dwError
!= ERROR_SUCCESS
)
886 DPRINT("ScmrEnumServicesStatusW() failed (Error %lu)\n", dwError
);
887 SetLastError(dwError
);
891 DPRINT("EnumServicesStatusW() done\n");
897 /**********************************************************************
898 * EnumServicesStatusExA
903 EnumServicesStatusExA(SC_HANDLE hSCManager
,
904 SC_ENUM_TYPE InfoLevel
,
906 DWORD dwServiceState
,
909 LPDWORD pcbBytesNeeded
,
910 LPDWORD lpServicesReturned
,
911 LPDWORD lpResumeHandle
,
914 LPENUM_SERVICE_STATUS_PROCESSA lpStatusPtr
;
915 DWORD dwError
= ERROR_SUCCESS
;
918 DPRINT("EnumServicesStatusExA() called\n");
922 dwError
= ScmrEnumServicesStatusExA(BindingHandle
,
923 (unsigned int)hSCManager
,
924 (unsigned long)InfoLevel
,
927 (unsigned char *)lpServices
,
932 (char *)pszGroupName
);
934 lpStatusPtr
= (LPENUM_SERVICE_STATUS_PROCESSA
)lpServices
;
935 for (dwCount
= 0; dwCount
< *lpServicesReturned
; dwCount
++)
937 if (lpStatusPtr
->lpServiceName
)
938 lpStatusPtr
->lpServiceName
=
939 (LPSTR
)((ULONG_PTR
)lpServices
+ (ULONG_PTR
)lpStatusPtr
->lpServiceName
);
941 if (lpStatusPtr
->lpDisplayName
)
942 lpStatusPtr
->lpDisplayName
=
943 (LPSTR
)((ULONG_PTR
)lpServices
+ (ULONG_PTR
)lpStatusPtr
->lpDisplayName
);
948 if (dwError
!= ERROR_SUCCESS
)
950 DPRINT1("ScmrEnumServicesStatusExA() failed (Error %lu)\n", dwError
);
951 SetLastError(dwError
);
955 DPRINT("EnumServicesStatusExA() done\n");
961 /**********************************************************************
962 * EnumServicesStatusExW
967 EnumServicesStatusExW(SC_HANDLE hSCManager
,
968 SC_ENUM_TYPE InfoLevel
,
970 DWORD dwServiceState
,
973 LPDWORD pcbBytesNeeded
,
974 LPDWORD lpServicesReturned
,
975 LPDWORD lpResumeHandle
,
976 LPCWSTR pszGroupName
)
978 LPENUM_SERVICE_STATUS_PROCESSW lpStatusPtr
;
979 DWORD dwError
= ERROR_SUCCESS
;
982 DPRINT("EnumServicesStatusExW() called\n");
986 dwError
= ScmrEnumServicesStatusExW(BindingHandle
,
987 (unsigned int)hSCManager
,
988 (unsigned long)InfoLevel
,
991 (unsigned char *)lpServices
,
996 (wchar_t *)pszGroupName
);
998 lpStatusPtr
= (LPENUM_SERVICE_STATUS_PROCESSW
)lpServices
;
999 for (dwCount
= 0; dwCount
< *lpServicesReturned
; dwCount
++)
1001 if (lpStatusPtr
->lpServiceName
)
1002 lpStatusPtr
->lpServiceName
=
1003 (LPWSTR
)((ULONG_PTR
)lpServices
+ (ULONG_PTR
)lpStatusPtr
->lpServiceName
);
1005 if (lpStatusPtr
->lpDisplayName
)
1006 lpStatusPtr
->lpDisplayName
=
1007 (LPWSTR
)((ULONG_PTR
)lpServices
+ (ULONG_PTR
)lpStatusPtr
->lpDisplayName
);
1012 if (dwError
!= ERROR_SUCCESS
)
1014 DPRINT1("ScmrEnumServicesStatusExW() failed (Error %lu)\n", dwError
);
1015 SetLastError(dwError
);
1019 DPRINT("EnumServicesStatusExW() done\n");
1025 /**********************************************************************
1026 * GetServiceDisplayNameA
1031 GetServiceDisplayNameA(SC_HANDLE hSCManager
,
1032 LPCSTR lpServiceName
,
1033 LPSTR lpDisplayName
,
1034 LPDWORD lpcchBuffer
)
1038 DPRINT("GetServiceDisplayNameA() called\n");
1042 dwError
= ScmrGetServiceDisplayNameA(BindingHandle
,
1043 (unsigned int)hSCManager
,
1044 (LPSTR
)lpServiceName
,
1047 if (dwError
!= ERROR_SUCCESS
)
1049 DPRINT1("ScmrGetServiceDisplayNameA() failed (Error %lu)\n", dwError
);
1050 SetLastError(dwError
);
1060 /**********************************************************************
1061 * GetServiceDisplayNameW
1066 GetServiceDisplayNameW(SC_HANDLE hSCManager
,
1067 LPCWSTR lpServiceName
,
1068 LPWSTR lpDisplayName
,
1069 LPDWORD lpcchBuffer
)
1073 DPRINT("GetServiceDisplayNameW() called\n");
1077 dwError
= ScmrGetServiceDisplayNameW(BindingHandle
,
1078 (unsigned int)hSCManager
,
1079 (LPWSTR
)lpServiceName
,
1082 if (dwError
!= ERROR_SUCCESS
)
1084 DPRINT1("ScmrGetServiceDisplayNameW() failed (Error %lu)\n", dwError
);
1085 SetLastError(dwError
);
1095 /**********************************************************************
1096 * GetServiceKeyNameA
1101 GetServiceKeyNameA(SC_HANDLE hSCManager
,
1102 LPCSTR lpDisplayName
,
1103 LPSTR lpServiceName
,
1104 LPDWORD lpcchBuffer
)
1108 DPRINT("GetServiceKeyNameA() called\n");
1112 dwError
= ScmrGetServiceKeyNameA(BindingHandle
,
1113 (unsigned int)hSCManager
,
1114 (LPSTR
)lpDisplayName
,
1117 if (dwError
!= ERROR_SUCCESS
)
1119 DPRINT1("ScmrGetServiceKeyNameA() failed (Error %lu)\n", dwError
);
1120 SetLastError(dwError
);
1130 /**********************************************************************
1131 * GetServiceKeyNameW
1136 GetServiceKeyNameW(SC_HANDLE hSCManager
,
1137 LPCWSTR lpDisplayName
,
1138 LPWSTR lpServiceName
,
1139 LPDWORD lpcchBuffer
)
1143 DPRINT("GetServiceKeyNameW() called\n");
1147 dwError
= ScmrGetServiceKeyNameW(BindingHandle
,
1148 (unsigned int)hSCManager
,
1149 (LPWSTR
)lpDisplayName
,
1152 if (dwError
!= ERROR_SUCCESS
)
1154 DPRINT1("ScmrGetServiceKeyNameW() failed (Error %lu)\n", dwError
);
1155 SetLastError(dwError
);
1165 /**********************************************************************
1166 * LockServiceDatabase
1171 LockServiceDatabase(SC_HANDLE hSCManager
)
1176 DPRINT("LockServiceDatabase(%x)\n", hSCManager
);
1180 /* Call to services.exe using RPC */
1181 dwError
= ScmrLockServiceDatabase(BindingHandle
,
1182 (unsigned int)hSCManager
,
1183 (unsigned int *)&hLock
);
1184 if (dwError
!= ERROR_SUCCESS
)
1186 DPRINT1("ScmrLockServiceDatabase() failed (Error %lu)\n", dwError
);
1187 SetLastError(dwError
);
1191 DPRINT("hLock = %p\n", hLock
);
1198 WaitForSCManager(VOID
)
1202 DPRINT("WaitForSCManager() called\n");
1204 /* Try to open the existing event */
1205 hEvent
= OpenEventW(SYNCHRONIZE
,
1207 L
"SvcctrlStartEvent_A3725DX");
1210 if (GetLastError() != ERROR_FILE_NOT_FOUND
)
1213 /* Try to create a new event */
1214 hEvent
= CreateEventW(NULL
,
1217 L
"SvcctrlStartEvent_A3725DX");
1220 /* Try to open the existing event again */
1221 hEvent
= OpenEventW(SYNCHRONIZE
,
1223 L
"SvcctrlStartEvent_A3725DX");
1229 /* Wait for 3 minutes */
1230 WaitForSingleObject(hEvent
, 180000);
1231 CloseHandle(hEvent
);
1233 DPRINT("ScmWaitForSCManager() done\n");
1237 /**********************************************************************
1243 OpenSCManagerA(LPCSTR lpMachineName
,
1244 LPCSTR lpDatabaseName
,
1245 DWORD dwDesiredAccess
)
1247 SC_HANDLE hScm
= NULL
;
1250 DPRINT("OpenSCManagerA(%s, %s, %lx)\n",
1251 lpMachineName
, lpDatabaseName
, dwDesiredAccess
);
1257 /* Call to services.exe using RPC */
1258 dwError
= ScmrOpenSCManagerA(BindingHandle
,
1259 (LPSTR
)lpMachineName
,
1260 (LPSTR
)lpDatabaseName
,
1262 (unsigned int*)&hScm
);
1263 if (dwError
!= ERROR_SUCCESS
)
1265 DPRINT1("ScmrOpenSCManagerA() failed (Error %lu)\n", dwError
);
1266 SetLastError(dwError
);
1270 DPRINT("hScm = %p\n", hScm
);
1276 /**********************************************************************
1282 OpenSCManagerW(LPCWSTR lpMachineName
,
1283 LPCWSTR lpDatabaseName
,
1284 DWORD dwDesiredAccess
)
1286 SC_HANDLE hScm
= NULL
;
1289 DPRINT("OpenSCManagerW(%S, %S, %lx)\n",
1290 lpMachineName
, lpDatabaseName
, dwDesiredAccess
);
1296 /* Call to services.exe using RPC */
1297 dwError
= ScmrOpenSCManagerW(BindingHandle
,
1298 (LPWSTR
)lpMachineName
,
1299 (LPWSTR
)lpDatabaseName
,
1301 (unsigned int*)&hScm
);
1302 if (dwError
!= ERROR_SUCCESS
)
1304 DPRINT1("ScmrOpenSCManagerW() failed (Error %lu)\n", dwError
);
1305 SetLastError(dwError
);
1309 DPRINT("hScm = %p\n", hScm
);
1315 /**********************************************************************
1321 OpenServiceA(SC_HANDLE hSCManager
,
1322 LPCSTR lpServiceName
,
1323 DWORD dwDesiredAccess
)
1325 SC_HANDLE hService
= NULL
;
1328 DPRINT("OpenServiceA(%p, %s, %lx)\n",
1329 hSCManager
, lpServiceName
, dwDesiredAccess
);
1333 /* Call to services.exe using RPC */
1334 dwError
= ScmrOpenServiceA(BindingHandle
,
1335 (unsigned int)hSCManager
,
1336 (LPSTR
)lpServiceName
,
1338 (unsigned int*)&hService
);
1339 if (dwError
!= ERROR_SUCCESS
)
1341 DPRINT1("ScmrOpenServiceA() failed (Error %lu)\n", dwError
);
1342 SetLastError(dwError
);
1346 DPRINT("hService = %p\n", hService
);
1352 /**********************************************************************
1358 OpenServiceW(SC_HANDLE hSCManager
,
1359 LPCWSTR lpServiceName
,
1360 DWORD dwDesiredAccess
)
1362 SC_HANDLE hService
= NULL
;
1365 DPRINT("OpenServiceW(%p, %S, %lx)\n",
1366 hSCManager
, lpServiceName
, dwDesiredAccess
);
1370 /* Call to services.exe using RPC */
1371 dwError
= ScmrOpenServiceW(BindingHandle
,
1372 (unsigned int)hSCManager
,
1373 (LPWSTR
)lpServiceName
,
1375 (unsigned int*)&hService
);
1376 if (dwError
!= ERROR_SUCCESS
)
1378 DPRINT1("ScmrOpenServiceW() failed (Error %lu)\n", dwError
);
1379 SetLastError(dwError
);
1383 DPRINT("hService = %p\n", hService
);
1389 /**********************************************************************
1390 * QueryServiceConfigA
1395 QueryServiceConfigA(SC_HANDLE hService
,
1396 LPQUERY_SERVICE_CONFIGA lpServiceConfig
,
1398 LPDWORD pcbBytesNeeded
)
1402 DPRINT("QueryServiceConfigA(%p, %p, %lu, %p)\n",
1403 hService
, lpServiceConfig
, cbBufSize
, pcbBytesNeeded
);
1407 /* Call to services.exe using RPC */
1408 dwError
= ScmrQueryServiceConfigA(BindingHandle
,
1409 (unsigned int)hService
,
1410 (unsigned char *)lpServiceConfig
,
1413 if (dwError
!= ERROR_SUCCESS
)
1415 DPRINT("ScmrQueryServiceConfigA() failed (Error %lu)\n", dwError
);
1416 SetLastError(dwError
);
1420 /* Adjust the pointers */
1421 if (lpServiceConfig
->lpBinaryPathName
)
1422 lpServiceConfig
->lpBinaryPathName
=
1423 (LPSTR
)((ULONG_PTR
)lpServiceConfig
+
1424 (ULONG_PTR
)lpServiceConfig
->lpBinaryPathName
);
1426 if (lpServiceConfig
->lpLoadOrderGroup
)
1427 lpServiceConfig
->lpLoadOrderGroup
=
1428 (LPSTR
)((ULONG_PTR
)lpServiceConfig
+
1429 (ULONG_PTR
)lpServiceConfig
->lpLoadOrderGroup
);
1431 if (lpServiceConfig
->lpDependencies
)
1432 lpServiceConfig
->lpDependencies
=
1433 (LPSTR
)((ULONG_PTR
)lpServiceConfig
+
1434 (ULONG_PTR
)lpServiceConfig
->lpDependencies
);
1436 if (lpServiceConfig
->lpServiceStartName
)
1437 lpServiceConfig
->lpServiceStartName
=
1438 (LPSTR
)((ULONG_PTR
)lpServiceConfig
+
1439 (ULONG_PTR
)lpServiceConfig
->lpServiceStartName
);
1441 if (lpServiceConfig
->lpDisplayName
)
1442 lpServiceConfig
->lpDisplayName
=
1443 (LPSTR
)((ULONG_PTR
)lpServiceConfig
+
1444 (ULONG_PTR
)lpServiceConfig
->lpDisplayName
);
1446 DPRINT("QueryServiceConfigA() done\n");
1452 /**********************************************************************
1453 * QueryServiceConfigW
1458 QueryServiceConfigW(SC_HANDLE hService
,
1459 LPQUERY_SERVICE_CONFIGW lpServiceConfig
,
1461 LPDWORD pcbBytesNeeded
)
1465 DPRINT("QueryServiceConfigW(%p, %p, %lu, %p)\n",
1466 hService
, lpServiceConfig
, cbBufSize
, pcbBytesNeeded
);
1470 /* Call to services.exe using RPC */
1471 dwError
= ScmrQueryServiceConfigW(BindingHandle
,
1472 (unsigned int)hService
,
1473 (unsigned char *)lpServiceConfig
,
1476 if (dwError
!= ERROR_SUCCESS
)
1478 DPRINT("ScmrQueryServiceConfigW() failed (Error %lu)\n", dwError
);
1479 SetLastError(dwError
);
1483 /* Adjust the pointers */
1484 if (lpServiceConfig
->lpBinaryPathName
)
1485 lpServiceConfig
->lpBinaryPathName
=
1486 (LPWSTR
)((ULONG_PTR
)lpServiceConfig
+
1487 (ULONG_PTR
)lpServiceConfig
->lpBinaryPathName
);
1489 if (lpServiceConfig
->lpLoadOrderGroup
)
1490 lpServiceConfig
->lpLoadOrderGroup
=
1491 (LPWSTR
)((ULONG_PTR
)lpServiceConfig
+
1492 (ULONG_PTR
)lpServiceConfig
->lpLoadOrderGroup
);
1494 if (lpServiceConfig
->lpDependencies
)
1495 lpServiceConfig
->lpDependencies
=
1496 (LPWSTR
)((ULONG_PTR
)lpServiceConfig
+
1497 (ULONG_PTR
)lpServiceConfig
->lpDependencies
);
1499 if (lpServiceConfig
->lpServiceStartName
)
1500 lpServiceConfig
->lpServiceStartName
=
1501 (LPWSTR
)((ULONG_PTR
)lpServiceConfig
+
1502 (ULONG_PTR
)lpServiceConfig
->lpServiceStartName
);
1504 if (lpServiceConfig
->lpDisplayName
)
1505 lpServiceConfig
->lpDisplayName
=
1506 (LPWSTR
)((ULONG_PTR
)lpServiceConfig
+
1507 (ULONG_PTR
)lpServiceConfig
->lpDisplayName
);
1509 DPRINT("QueryServiceConfigW() done\n");
1515 /**********************************************************************
1516 * QueryServiceConfig2A
1521 QueryServiceConfig2A(SC_HANDLE hService
,
1525 LPDWORD pcbBytesNeeded
)
1529 DPRINT("QueryServiceConfig2A(%p, %lu, %p, %lu, %p)\n",
1530 hService
, dwInfoLevel
, lpBuffer
, cbBufSize
, pcbBytesNeeded
);
1534 /* Call to services.exe using RPC */
1535 dwError
= ScmrQueryServiceConfig2A(BindingHandle
,
1536 (unsigned int)hService
,
1538 (unsigned char *)lpBuffer
,
1541 if (dwError
!= ERROR_SUCCESS
)
1543 DPRINT("ScmrQueryServiceConfig2A() failed (Error %lu)\n", dwError
);
1544 SetLastError(dwError
);
1548 switch (dwInfoLevel
)
1550 case SERVICE_CONFIG_DESCRIPTION
:
1552 LPSERVICE_DESCRIPTIONA lpPtr
= (LPSERVICE_DESCRIPTIONA
)lpBuffer
;
1554 if (lpPtr
->lpDescription
!= NULL
)
1555 lpPtr
->lpDescription
=
1556 (LPSTR
)((UINT_PTR
)lpPtr
+ (UINT_PTR
)lpPtr
->lpDescription
);
1560 case SERVICE_CONFIG_FAILURE_ACTIONS
:
1562 LPSERVICE_FAILURE_ACTIONSA lpPtr
= (LPSERVICE_FAILURE_ACTIONSA
)lpBuffer
;
1564 if (lpPtr
->lpRebootMsg
!= NULL
)
1565 lpPtr
->lpRebootMsg
=
1566 (LPSTR
)((UINT_PTR
)lpPtr
+ (UINT_PTR
)lpPtr
->lpRebootMsg
);
1568 if (lpPtr
->lpCommand
!= NULL
)
1570 (LPSTR
)((UINT_PTR
)lpPtr
+ (UINT_PTR
)lpPtr
->lpCommand
);
1572 if (lpPtr
->lpsaActions
!= NULL
)
1573 lpPtr
->lpsaActions
=
1574 (SC_ACTION
*)((UINT_PTR
)lpPtr
+ (UINT_PTR
)lpPtr
->lpsaActions
);
1579 DPRINT1("Unknown info level 0x%lx\n", dwInfoLevel
);
1580 SetLastError(ERROR_INVALID_PARAMETER
);
1584 DPRINT("QueryServiceConfig2A() done\n");
1590 /**********************************************************************
1591 * QueryServiceConfig2W
1596 QueryServiceConfig2W(SC_HANDLE hService
,
1600 LPDWORD pcbBytesNeeded
)
1604 DPRINT("QueryServiceConfig2W(%p, %lu, %p, %lu, %p)\n",
1605 hService
, dwInfoLevel
, lpBuffer
, cbBufSize
, pcbBytesNeeded
);
1609 /* Call to services.exe using RPC */
1610 dwError
= ScmrQueryServiceConfig2W(BindingHandle
,
1611 (unsigned int)hService
,
1613 (unsigned char *)lpBuffer
,
1616 if (dwError
!= ERROR_SUCCESS
)
1618 DPRINT("ScmrQueryServiceConfig2W() failed (Error %lu)\n", dwError
);
1619 SetLastError(dwError
);
1623 switch (dwInfoLevel
)
1625 case SERVICE_CONFIG_DESCRIPTION
:
1627 LPSERVICE_DESCRIPTIONW lpPtr
= (LPSERVICE_DESCRIPTIONW
)lpBuffer
;
1629 if (lpPtr
->lpDescription
!= NULL
)
1630 lpPtr
->lpDescription
=
1631 (LPWSTR
)((UINT_PTR
)lpPtr
+ (UINT_PTR
)lpPtr
->lpDescription
);
1635 case SERVICE_CONFIG_FAILURE_ACTIONS
:
1637 LPSERVICE_FAILURE_ACTIONSW lpPtr
= (LPSERVICE_FAILURE_ACTIONSW
)lpBuffer
;
1639 if (lpPtr
->lpRebootMsg
!= NULL
)
1640 lpPtr
->lpRebootMsg
=
1641 (LPWSTR
)((UINT_PTR
)lpPtr
+ (UINT_PTR
)lpPtr
->lpRebootMsg
);
1643 if (lpPtr
->lpCommand
!= NULL
)
1645 (LPWSTR
)((UINT_PTR
)lpPtr
+ (UINT_PTR
)lpPtr
->lpCommand
);
1647 if (lpPtr
->lpsaActions
!= NULL
)
1648 lpPtr
->lpsaActions
=
1649 (SC_ACTION
*)((UINT_PTR
)lpPtr
+ (UINT_PTR
)lpPtr
->lpsaActions
);
1654 DPRINT1("Unknown info level 0x%lx\n", dwInfoLevel
);
1655 SetLastError(ERROR_INVALID_PARAMETER
);
1659 DPRINT("QueryServiceConfig2W() done\n");
1665 /**********************************************************************
1666 * QueryServiceLockStatusA
1672 QueryServiceLockStatusA(
1673 SC_HANDLE hSCManager
,
1674 LPQUERY_SERVICE_LOCK_STATUSA lpLockStatus
,
1676 LPDWORD pcbBytesNeeded
)
1678 DPRINT1("QueryServiceLockStatusA is unimplemented\n");
1679 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
1684 /**********************************************************************
1685 * QueryServiceLockStatusW
1691 QueryServiceLockStatusW(
1692 SC_HANDLE hSCManager
,
1693 LPQUERY_SERVICE_LOCK_STATUSW lpLockStatus
,
1695 LPDWORD pcbBytesNeeded
)
1697 DPRINT1("QueryServiceLockStatusW is unimplemented\n");
1698 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
1703 /**********************************************************************
1704 * QueryServiceObjectSecurity
1709 QueryServiceObjectSecurity(SC_HANDLE hService
,
1710 SECURITY_INFORMATION dwSecurityInformation
,
1711 PSECURITY_DESCRIPTOR lpSecurityDescriptor
,
1713 LPDWORD pcbBytesNeeded
)
1717 DPRINT("QueryServiceObjectSecurity(%p, %lu, %p)\n",
1718 hService
, dwSecurityInformation
, lpSecurityDescriptor
);
1722 /* Call to services.exe using RPC */
1723 dwError
= ScmrQueryServiceObjectSecurity(BindingHandle
,
1724 (unsigned int)hService
,
1725 dwSecurityInformation
,
1726 (unsigned char *)lpSecurityDescriptor
,
1729 if (dwError
!= ERROR_SUCCESS
)
1731 DPRINT1("QueryServiceObjectSecurity() failed (Error %lu)\n", dwError
);
1732 SetLastError(dwError
);
1740 /**********************************************************************
1741 * QueryServiceStatus
1746 QueryServiceStatus(SC_HANDLE hService
,
1747 LPSERVICE_STATUS lpServiceStatus
)
1751 DPRINT("QueryServiceStatus(%p, %p)\n",
1752 hService
, lpServiceStatus
);
1756 /* Call to services.exe using RPC */
1757 dwError
= ScmrQueryServiceStatus(BindingHandle
,
1758 (unsigned int)hService
,
1760 if (dwError
!= ERROR_SUCCESS
)
1762 DPRINT1("ScmrQueryServiceStatus() failed (Error %lu)\n", dwError
);
1763 SetLastError(dwError
);
1771 /**********************************************************************
1772 * QueryServiceStatusEx
1777 QueryServiceStatusEx(SC_HANDLE hService
,
1778 SC_STATUS_TYPE InfoLevel
,
1781 LPDWORD pcbBytesNeeded
)
1785 DPRINT("QueryServiceStatusEx() called\n");
1789 /* Call to services.exe using RPC */
1790 dwError
= ScmrQueryServiceStatusEx(BindingHandle
,
1791 (unsigned int)hService
,
1796 if (dwError
!= ERROR_SUCCESS
)
1798 DPRINT("ScmrQueryServiceStatusEx() failed (Error %lu)\n", dwError
);
1799 SetLastError(dwError
);
1807 /**********************************************************************
1808 * SetServiceObjectSecurity
1813 SetServiceObjectSecurity(SC_HANDLE hService
,
1814 SECURITY_INFORMATION dwSecurityInformation
,
1815 PSECURITY_DESCRIPTOR lpSecurityDescriptor
)
1817 PSECURITY_DESCRIPTOR SelfRelativeSD
= NULL
;
1823 Status
= RtlMakeSelfRelativeSD(lpSecurityDescriptor
,
1826 if (Status
!= STATUS_BUFFER_TOO_SMALL
)
1828 SetLastError(ERROR_INVALID_PARAMETER
);
1832 SelfRelativeSD
= HeapAlloc(GetProcessHeap(), 0, Length
);
1833 if (SelfRelativeSD
== NULL
)
1835 SetLastError(ERROR_NOT_ENOUGH_MEMORY
);
1839 Status
= RtlMakeSelfRelativeSD(lpSecurityDescriptor
,
1842 if (!NT_SUCCESS(Status
))
1844 HeapFree(GetProcessHeap(), 0, SelfRelativeSD
);
1845 SetLastError(RtlNtStatusToDosError(Status
));
1851 /* Call to services.exe using RPC */
1852 dwError
= ScmrSetServiceObjectSecurity(BindingHandle
,
1853 (unsigned int)hService
,
1854 dwSecurityInformation
,
1855 (unsigned char *)SelfRelativeSD
,
1858 HeapFree(GetProcessHeap(), 0, SelfRelativeSD
);
1860 if (dwError
!= ERROR_SUCCESS
)
1862 DPRINT1("ScmrServiceObjectSecurity() failed (Error %lu)\n", dwError
);
1863 SetLastError(dwError
);
1871 /**********************************************************************
1877 StartServiceA(SC_HANDLE hService
,
1878 DWORD dwNumServiceArgs
,
1879 LPCSTR
*lpServiceArgVectors
)
1884 DPRINT("StartServiceA()\n");
1888 /* Call to services.exe using RPC */
1889 dwError
= ScmrStartServiceA(BindingHandle
,
1892 lpServiceArgVectors
);
1893 if (dwError
!= ERROR_SUCCESS
)
1895 DPRINT1("ScmrStartServiceA() failed (Error %lu)\n", dwError
);
1896 SetLastError(dwError
);
1909 for (i
= 0; i
< dwNumServiceArgs
; i
++)
1911 dwBufSize
+= (strlen(lpServiceArgVectors
[i
]) + 1);
1913 DPRINT1("dwBufSize: %lu\n", dwBufSize
);
1915 lpBuffer
= HeapAlloc(GetProcessHeap(), 0, dwBufSize
);
1916 if (lpBuffer
== NULL
)
1918 SetLastError(ERROR_NOT_ENOUGH_MEMORY
);
1923 for (i
= 0; i
< dwNumServiceArgs
; i
++)
1925 strcpy(lpStr
, lpServiceArgVectors
[i
]);
1926 lpStr
+= (strlen(lpServiceArgVectors
[i
]) + 1);
1929 dwError
= ScmrStartServiceA(BindingHandle
,
1930 (unsigned int)hService
,
1932 (unsigned char *)lpBuffer
,
1935 HeapFree(GetProcessHeap(), 0, lpBuffer
);
1937 if (dwError
!= ERROR_SUCCESS
)
1939 DPRINT1("ScmrStartServiceA() failed (Error %lu)\n", dwError
);
1940 SetLastError(dwError
);
1948 /**********************************************************************
1954 StartServiceW(SC_HANDLE hService
,
1955 DWORD dwNumServiceArgs
,
1956 LPCWSTR
*lpServiceArgVectors
)
1961 DPRINT("StartServiceW()\n");
1965 /* Call to services.exe using RPC */
1966 dwError
= ScmrStartServiceW(BindingHandle
,
1969 lpServiceArgVectors
);
1970 if (dwError
!= ERROR_SUCCESS
)
1972 DPRINT1("ScmrStartServiceW() failed (Error %lu)\n", dwError
);
1973 SetLastError(dwError
);
1986 for (i
= 0; i
< dwNumServiceArgs
; i
++)
1988 dwBufSize
+= ((wcslen(lpServiceArgVectors
[i
]) + 1) * sizeof(WCHAR
));
1990 DPRINT1("dwBufSize: %lu\n", dwBufSize
);
1992 lpBuffer
= HeapAlloc(GetProcessHeap(), 0, dwBufSize
);
1993 if (lpBuffer
== NULL
)
1995 SetLastError(ERROR_NOT_ENOUGH_MEMORY
);
2000 for (i
= 0; i
< dwNumServiceArgs
; i
++)
2002 wcscpy(lpStr
, lpServiceArgVectors
[i
]);
2003 lpStr
+= (wcslen(lpServiceArgVectors
[i
]) + 1);
2006 dwError
= ScmrStartServiceW(BindingHandle
,
2007 (unsigned int)hService
,
2009 (unsigned char *)lpBuffer
,
2012 HeapFree(GetProcessHeap(), 0, lpBuffer
);
2014 if (dwError
!= ERROR_SUCCESS
)
2016 DPRINT1("ScmrStartServiceW() failed (Error %lu)\n", dwError
);
2017 SetLastError(dwError
);
2025 /**********************************************************************
2026 * UnlockServiceDatabase
2031 UnlockServiceDatabase(SC_LOCK ScLock
)
2035 DPRINT("UnlockServiceDatabase(%x)\n", ScLock
);
2039 /* Call to services.exe using RPC */
2040 dwError
= ScmrUnlockServiceDatabase(BindingHandle
,
2041 (unsigned int)ScLock
);
2042 if (dwError
!= ERROR_SUCCESS
)
2044 DPRINT1("ScmrUnlockServiceDatabase() failed (Error %lu)\n", dwError
);
2045 SetLastError(dwError
);
2053 /**********************************************************************
2054 * NotifyBootConfigStatus
2059 NotifyBootConfigStatus(BOOL BootAcceptable
)
2063 DPRINT1("NotifyBootConfigStatus()\n");
2067 /* Call to services.exe using RPC */
2068 dwError
= ScmrNotifyBootConfigStatus(BindingHandle
,
2070 if (dwError
!= ERROR_SUCCESS
)
2072 DPRINT1("NotifyBootConfigStatus() failed (Error %lu)\n", dwError
);
2073 SetLastError(dwError
);
2081 void __RPC_FAR
* __RPC_USER
midl_user_allocate(size_t len
)
2083 return HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, len
);
2087 void __RPC_USER
midl_user_free(void __RPC_FAR
* ptr
)
2089 HeapFree(GetProcessHeap(), 0, ptr
);