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
10 /* INCLUDES ******************************************************************/
13 WINE_DEFAULT_DEBUG_CHANNEL(advapi
);
16 /* FUNCTIONS *****************************************************************/
19 SVCCTL_HANDLEA_bind(SVCCTL_HANDLEA szMachineName
)
21 handle_t hBinding
= NULL
;
22 RPC_CSTR pszStringBinding
;
25 TRACE("SVCCTL_HANDLEA_bind(%s)\n",
26 debugstr_a(szMachineName
));
28 status
= RpcStringBindingComposeA(NULL
,
30 (RPC_CSTR
)szMachineName
,
31 (RPC_CSTR
)"\\pipe\\ntsvcs",
34 if (status
!= RPC_S_OK
)
36 ERR("RpcStringBindingCompose returned 0x%x\n", status
);
40 /* Set the binding handle that will be used to bind to the server. */
41 status
= RpcBindingFromStringBindingA(pszStringBinding
,
43 if (status
!= RPC_S_OK
)
45 ERR("RpcBindingFromStringBinding returned 0x%x\n", status
);
48 status
= RpcStringFreeA(&pszStringBinding
);
49 if (status
!= RPC_S_OK
)
51 ERR("RpcStringFree returned 0x%x\n", status
);
59 SVCCTL_HANDLEA_unbind(SVCCTL_HANDLEA szMachineName
,
64 TRACE("SVCCTL_HANDLEA_unbind(%s %p)\n",
65 debugstr_a(szMachineName
), hBinding
);
67 status
= RpcBindingFree(&hBinding
);
68 if (status
!= RPC_S_OK
)
70 ERR("RpcBindingFree returned 0x%x\n", status
);
76 SVCCTL_HANDLEW_bind(SVCCTL_HANDLEW szMachineName
)
78 handle_t hBinding
= NULL
;
79 RPC_WSTR pszStringBinding
;
82 TRACE("SVCCTL_HANDLEW_bind(%s)\n",
83 debugstr_w(szMachineName
));
85 status
= RpcStringBindingComposeW(NULL
,
91 if (status
!= RPC_S_OK
)
93 ERR("RpcStringBindingCompose returned 0x%x\n", status
);
97 /* Set the binding handle that will be used to bind to the server. */
98 status
= RpcBindingFromStringBindingW(pszStringBinding
,
100 if (status
!= RPC_S_OK
)
102 ERR("RpcBindingFromStringBinding returned 0x%x\n", status
);
105 status
= RpcStringFreeW(&pszStringBinding
);
106 if (status
!= RPC_S_OK
)
108 ERR("RpcStringFree returned 0x%x\n", status
);
116 SVCCTL_HANDLEW_unbind(SVCCTL_HANDLEW szMachineName
,
121 TRACE("SVCCTL_HANDLEW_unbind(%s %p)\n",
122 debugstr_w(szMachineName
), hBinding
);
124 status
= RpcBindingFree(&hBinding
);
125 if (status
!= RPC_S_OK
)
127 ERR("RpcBindingFree returned 0x%x\n", status
);
133 ScmRpcStatusToWinError(RPC_STATUS Status
)
135 TRACE("ScmRpcStatusToWinError(%lx)\n",
140 case STATUS_ACCESS_VIOLATION
:
141 case RPC_S_INVALID_BINDING
:
142 case RPC_X_SS_IN_NULL_CONTEXT
:
143 return ERROR_INVALID_HANDLE
;
145 case RPC_X_ENUM_VALUE_OUT_OF_RANGE
:
146 case RPC_X_BYTE_COUNT_TOO_SMALL
:
147 return ERROR_INVALID_PARAMETER
;
149 case RPC_X_NULL_REF_POINTER
:
150 return ERROR_INVALID_ADDRESS
;
153 return (DWORD
)Status
;
158 /**********************************************************************
159 * ChangeServiceConfig2A
164 ChangeServiceConfig2A(SC_HANDLE hService
,
168 SC_RPC_CONFIG_INFOA Info
;
171 TRACE("ChangeServiceConfig2A(%p %lu %p)\n",
172 hService
, dwInfoLevel
, lpInfo
);
174 if (lpInfo
== NULL
) return TRUE
;
176 /* Fill relevant field of the Info structure */
177 Info
.dwInfoLevel
= dwInfoLevel
;
180 case SERVICE_CONFIG_DESCRIPTION
:
184 case SERVICE_CONFIG_FAILURE_ACTIONS
:
189 WARN("Unknown info level 0x%lx\n", dwInfoLevel
);
190 SetLastError(ERROR_INVALID_PARAMETER
);
196 dwError
= RChangeServiceConfig2A((SC_RPC_HANDLE
)hService
,
199 RpcExcept(EXCEPTION_EXECUTE_HANDLER
)
201 dwError
= ScmRpcStatusToWinError(RpcExceptionCode());
205 if (dwError
!= ERROR_SUCCESS
)
207 TRACE("RChangeServiceConfig2A() failed (Error %lu)\n", dwError
);
208 SetLastError(dwError
);
216 /**********************************************************************
217 * ChangeServiceConfig2W
222 ChangeServiceConfig2W(SC_HANDLE hService
,
226 SC_RPC_CONFIG_INFOW Info
;
229 TRACE("ChangeServiceConfig2W(%p %lu %p)\n",
230 hService
, dwInfoLevel
, lpInfo
);
232 if (lpInfo
== NULL
) return TRUE
;
234 /* Fill relevant field of the Info structure */
235 Info
.dwInfoLevel
= dwInfoLevel
;
238 case SERVICE_CONFIG_DESCRIPTION
:
242 case SERVICE_CONFIG_FAILURE_ACTIONS
:
247 WARN("Unknown info level 0x%lx\n", dwInfoLevel
);
248 SetLastError(ERROR_INVALID_PARAMETER
);
254 dwError
= RChangeServiceConfig2W((SC_RPC_HANDLE
)hService
,
257 RpcExcept(EXCEPTION_EXECUTE_HANDLER
)
259 dwError
= ScmRpcStatusToWinError(RpcExceptionCode());
263 if (dwError
!= ERROR_SUCCESS
)
265 TRACE("RChangeServiceConfig2W() failed (Error %lu)\n", dwError
);
266 SetLastError(dwError
);
274 /**********************************************************************
275 * ChangeServiceConfigA
280 ChangeServiceConfigA(SC_HANDLE hService
,
283 DWORD dwErrorControl
,
284 LPCSTR lpBinaryPathName
,
285 LPCSTR lpLoadOrderGroup
,
287 LPCSTR lpDependencies
,
288 LPCSTR lpServiceStartName
,
290 LPCSTR lpDisplayName
)
293 DWORD dwDependenciesLength
= 0;
296 DWORD dwPasswordLength
= 0;
297 LPWSTR lpPasswordW
= NULL
;
298 LPBYTE lpEncryptedPassword
= NULL
;
300 TRACE("ChangeServiceConfigA(%p %lu %lu %lu %s %s %p %s %s %s %s)\n",
301 dwServiceType
, dwStartType
, dwErrorControl
, debugstr_a(lpBinaryPathName
),
302 debugstr_a(lpLoadOrderGroup
), lpdwTagId
, debugstr_a(lpDependencies
),
303 debugstr_a(lpServiceStartName
), debugstr_a(lpPassword
), debugstr_a(lpDisplayName
));
305 /* Calculate the Dependencies length*/
306 if (lpDependencies
!= NULL
)
308 lpStr
= lpDependencies
;
311 cchLength
= strlen(lpStr
) + 1;
312 dwDependenciesLength
+= (DWORD
)cchLength
;
313 lpStr
= lpStr
+ cchLength
;
315 dwDependenciesLength
++;
318 if (lpPassword
!= NULL
)
320 /* Convert the password to unicode */
321 lpPasswordW
= HeapAlloc(GetProcessHeap(),
323 (strlen(lpPassword
) + 1) * sizeof(WCHAR
));
324 if (lpPasswordW
== NULL
)
326 SetLastError(ERROR_NOT_ENOUGH_MEMORY
);
330 MultiByteToWideChar(CP_ACP
,
335 (int)(strlen(lpPassword
) + 1));
337 /* FIXME: Encrypt the password */
338 lpEncryptedPassword
= (LPBYTE
)lpPasswordW
;
339 dwPasswordLength
= (wcslen(lpPasswordW
) + 1) * sizeof(WCHAR
);
344 dwError
= RChangeServiceConfigA((SC_RPC_HANDLE
)hService
,
348 (LPSTR
)lpBinaryPathName
,
349 (LPSTR
)lpLoadOrderGroup
,
351 (LPBYTE
)lpDependencies
,
352 dwDependenciesLength
,
353 (LPSTR
)lpServiceStartName
,
356 (LPSTR
)lpDisplayName
);
358 RpcExcept(EXCEPTION_EXECUTE_HANDLER
)
360 dwError
= ScmRpcStatusToWinError(RpcExceptionCode());
364 if (lpPasswordW
!= NULL
)
365 HeapFree(GetProcessHeap(), 0, lpPasswordW
);
367 if (dwError
!= ERROR_SUCCESS
)
369 TRACE("RChangeServiceConfigA() failed (Error %lu)\n", dwError
);
370 SetLastError(dwError
);
378 /**********************************************************************
379 * ChangeServiceConfigW
384 ChangeServiceConfigW(SC_HANDLE hService
,
387 DWORD dwErrorControl
,
388 LPCWSTR lpBinaryPathName
,
389 LPCWSTR lpLoadOrderGroup
,
391 LPCWSTR lpDependencies
,
392 LPCWSTR lpServiceStartName
,
394 LPCWSTR lpDisplayName
)
397 DWORD dwDependenciesLength
= 0;
400 DWORD dwPasswordLength
= 0;
401 LPBYTE lpEncryptedPassword
= NULL
;
403 TRACE("ChangeServiceConfigW(%p %lu %lu %lu %s %s %p %s %s %s %s)\n",
404 dwServiceType
, dwStartType
, dwErrorControl
, debugstr_w(lpBinaryPathName
),
405 debugstr_w(lpLoadOrderGroup
), lpdwTagId
, debugstr_w(lpDependencies
),
406 debugstr_w(lpServiceStartName
), debugstr_w(lpPassword
), debugstr_w(lpDisplayName
));
408 /* Calculate the Dependencies length*/
409 if (lpDependencies
!= NULL
)
411 lpStr
= lpDependencies
;
414 cchLength
= wcslen(lpStr
) + 1;
415 dwDependenciesLength
+= (DWORD
)cchLength
;
416 lpStr
= lpStr
+ cchLength
;
418 dwDependenciesLength
++;
419 dwDependenciesLength
*= sizeof(WCHAR
);
422 if (lpPassword
!= NULL
)
424 /* FIXME: Encrypt the password */
425 lpEncryptedPassword
= (LPBYTE
)lpPassword
;
426 dwPasswordLength
= (wcslen(lpPassword
) + 1) * sizeof(WCHAR
);
431 dwError
= RChangeServiceConfigW((SC_RPC_HANDLE
)hService
,
435 (LPWSTR
)lpBinaryPathName
,
436 (LPWSTR
)lpLoadOrderGroup
,
438 (LPBYTE
)lpDependencies
,
439 dwDependenciesLength
,
440 (LPWSTR
)lpServiceStartName
,
443 (LPWSTR
)lpDisplayName
);
445 RpcExcept(EXCEPTION_EXECUTE_HANDLER
)
447 dwError
= ScmRpcStatusToWinError(RpcExceptionCode());
451 if (dwError
!= ERROR_SUCCESS
)
453 TRACE("RChangeServiceConfigW() failed (Error %lu)\n", dwError
);
454 SetLastError(dwError
);
462 /**********************************************************************
468 CloseServiceHandle(SC_HANDLE hSCObject
)
472 TRACE("CloseServiceHandle(%p)\n",
477 SetLastError(ERROR_INVALID_HANDLE
);
483 dwError
= RCloseServiceHandle((LPSC_RPC_HANDLE
)&hSCObject
);
485 RpcExcept(EXCEPTION_EXECUTE_HANDLER
)
487 dwError
= ScmRpcStatusToWinError(RpcExceptionCode());
493 TRACE("RCloseServiceHandle() failed (Error %lu)\n", dwError
);
494 SetLastError(dwError
);
498 TRACE("CloseServiceHandle() done\n");
504 /**********************************************************************
510 ControlService(SC_HANDLE hService
,
512 LPSERVICE_STATUS lpServiceStatus
)
516 TRACE("ControlService(%p %lu %p)\n",
517 hService
, dwControl
, lpServiceStatus
);
521 dwError
= RControlService((SC_RPC_HANDLE
)hService
,
525 RpcExcept(EXCEPTION_EXECUTE_HANDLER
)
527 dwError
= ScmRpcStatusToWinError(RpcExceptionCode());
531 if (dwError
!= ERROR_SUCCESS
)
533 TRACE("RControlService() failed (Error %lu)\n", dwError
);
534 SetLastError(dwError
);
538 TRACE("ControlService() done\n");
544 /**********************************************************************
550 ControlServiceEx(IN SC_HANDLE hService
,
552 IN DWORD dwInfoLevel
,
553 IN OUT PVOID pControlParams
)
555 FIXME("ControlServiceEx(%p %lu %lu %p)\n",
556 hService
, dwControl
, dwInfoLevel
, pControlParams
);
557 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
562 /**********************************************************************
568 CreateServiceA(SC_HANDLE hSCManager
,
569 LPCSTR lpServiceName
,
570 LPCSTR lpDisplayName
,
571 DWORD dwDesiredAccess
,
574 DWORD dwErrorControl
,
575 LPCSTR lpBinaryPathName
,
576 LPCSTR lpLoadOrderGroup
,
578 LPCSTR lpDependencies
,
579 LPCSTR lpServiceStartName
,
582 SC_HANDLE hService
= NULL
;
583 DWORD dwDependenciesLength
= 0;
587 DWORD dwPasswordLength
= 0;
588 LPWSTR lpPasswordW
= NULL
;
589 LPBYTE lpEncryptedPassword
= NULL
;
591 TRACE("CreateServiceA(%p %s %s %lx %lu %lu %lu %s %s %p %s %s %s)\n",
592 hSCManager
, debugstr_a(lpServiceName
), debugstr_a(lpDisplayName
),
593 dwDesiredAccess
, dwServiceType
, dwStartType
, dwErrorControl
,
594 debugstr_a(lpBinaryPathName
), debugstr_a(lpLoadOrderGroup
), lpdwTagId
,
595 debugstr_a(lpDependencies
), debugstr_a(lpServiceStartName
), debugstr_a(lpPassword
));
599 SetLastError(ERROR_INVALID_HANDLE
);
603 /* Calculate the Dependencies length */
604 if (lpDependencies
!= NULL
)
606 lpStr
= lpDependencies
;
609 cchLength
= strlen(lpStr
) + 1;
610 dwDependenciesLength
+= (DWORD
)cchLength
;
611 lpStr
= lpStr
+ cchLength
;
613 dwDependenciesLength
++;
616 if (lpPassword
!= NULL
)
618 /* Convert the password to unicode */
619 lpPasswordW
= HeapAlloc(GetProcessHeap(),
621 (strlen(lpPassword
) + 1) * sizeof(WCHAR
));
622 if (lpPasswordW
== NULL
)
624 SetLastError(ERROR_NOT_ENOUGH_MEMORY
);
628 MultiByteToWideChar(CP_ACP
,
633 (int)(strlen(lpPassword
) + 1));
635 /* FIXME: Encrypt the password */
636 lpEncryptedPassword
= (LPBYTE
)lpPasswordW
;
637 dwPasswordLength
= (wcslen(lpPasswordW
) + 1) * sizeof(WCHAR
);
642 dwError
= RCreateServiceA((SC_RPC_HANDLE
)hSCManager
,
643 (LPSTR
)lpServiceName
,
644 (LPSTR
)lpDisplayName
,
649 (LPSTR
)lpBinaryPathName
,
650 (LPSTR
)lpLoadOrderGroup
,
652 (LPBYTE
)lpDependencies
,
653 dwDependenciesLength
,
654 (LPSTR
)lpServiceStartName
,
657 (SC_RPC_HANDLE
*)&hService
);
659 RpcExcept(EXCEPTION_EXECUTE_HANDLER
)
661 dwError
= ScmRpcStatusToWinError(RpcExceptionCode());
665 if (lpPasswordW
!= NULL
)
666 HeapFree(GetProcessHeap(), 0, lpPasswordW
);
668 SetLastError(dwError
);
669 if (dwError
!= ERROR_SUCCESS
)
671 TRACE("RCreateServiceA() failed (Error %lu)\n", dwError
);
679 /**********************************************************************
685 CreateServiceW(SC_HANDLE hSCManager
,
686 LPCWSTR lpServiceName
,
687 LPCWSTR lpDisplayName
,
688 DWORD dwDesiredAccess
,
691 DWORD dwErrorControl
,
692 LPCWSTR lpBinaryPathName
,
693 LPCWSTR lpLoadOrderGroup
,
695 LPCWSTR lpDependencies
,
696 LPCWSTR lpServiceStartName
,
699 SC_HANDLE hService
= NULL
;
700 DWORD dwDependenciesLength
= 0;
704 DWORD dwPasswordLength
= 0;
705 LPBYTE lpEncryptedPassword
= NULL
;
707 TRACE("CreateServiceW(%p %s %s %lx %lu %lu %lu %s %s %p %s %s %s)\n",
708 hSCManager
, debugstr_w(lpServiceName
), debugstr_w(lpDisplayName
),
709 dwDesiredAccess
, dwServiceType
, dwStartType
, dwErrorControl
,
710 debugstr_w(lpBinaryPathName
), debugstr_w(lpLoadOrderGroup
), lpdwTagId
,
711 debugstr_w(lpDependencies
), debugstr_w(lpServiceStartName
), debugstr_w(lpPassword
));
715 SetLastError(ERROR_INVALID_HANDLE
);
719 /* Calculate the Dependencies length */
720 if (lpDependencies
!= NULL
)
722 lpStr
= lpDependencies
;
725 cchLength
= wcslen(lpStr
) + 1;
726 dwDependenciesLength
+= (DWORD
)cchLength
;
727 lpStr
= lpStr
+ cchLength
;
729 dwDependenciesLength
++;
730 dwDependenciesLength
*= sizeof(WCHAR
);
733 if (lpPassword
!= NULL
)
735 /* FIXME: Encrypt the password */
736 lpEncryptedPassword
= (LPBYTE
)lpPassword
;
737 dwPasswordLength
= (wcslen(lpPassword
) + 1) * sizeof(WCHAR
);
742 dwError
= RCreateServiceW((SC_RPC_HANDLE
)hSCManager
,
752 (LPBYTE
)lpDependencies
,
753 dwDependenciesLength
,
757 (SC_RPC_HANDLE
*)&hService
);
759 RpcExcept(EXCEPTION_EXECUTE_HANDLER
)
761 dwError
= ScmRpcStatusToWinError(RpcExceptionCode());
765 SetLastError(dwError
);
766 if (dwError
!= ERROR_SUCCESS
)
768 TRACE("RCreateServiceW() failed (Error %lu)\n", dwError
);
776 /**********************************************************************
782 DeleteService(SC_HANDLE hService
)
786 TRACE("DeleteService(%p)\n",
791 dwError
= RDeleteService((SC_RPC_HANDLE
)hService
);
793 RpcExcept(EXCEPTION_EXECUTE_HANDLER
)
795 dwError
= ScmRpcStatusToWinError(RpcExceptionCode());
799 if (dwError
!= ERROR_SUCCESS
)
801 TRACE("RDeleteService() failed (Error %lu)\n", dwError
);
802 SetLastError(dwError
);
810 /**********************************************************************
811 * EnumDependentServicesA
816 EnumDependentServicesA(SC_HANDLE hService
,
817 DWORD dwServiceState
,
818 LPENUM_SERVICE_STATUSA lpServices
,
820 LPDWORD pcbBytesNeeded
,
821 LPDWORD lpServicesReturned
)
823 ENUM_SERVICE_STATUSA ServiceStatus
;
824 LPENUM_SERVICE_STATUSA lpStatusPtr
;
829 TRACE("EnumDependentServicesA(%p %lu %p %lu %p %p)\n",
830 hService
, dwServiceState
, lpServices
, cbBufSize
,
831 pcbBytesNeeded
, lpServicesReturned
);
833 if (lpServices
== NULL
|| cbBufSize
< sizeof(ENUM_SERVICE_STATUSA
))
835 lpStatusPtr
= &ServiceStatus
;
836 dwBufferSize
= sizeof(ENUM_SERVICE_STATUSA
);
840 lpStatusPtr
= lpServices
;
841 dwBufferSize
= cbBufSize
;
846 dwError
= REnumDependentServicesA((SC_RPC_HANDLE
)hService
,
853 RpcExcept(EXCEPTION_EXECUTE_HANDLER
)
855 dwError
= ScmRpcStatusToWinError(RpcExceptionCode());
859 if (dwError
== ERROR_SUCCESS
|| dwError
== ERROR_MORE_DATA
)
861 for (dwCount
= 0; dwCount
< *lpServicesReturned
; dwCount
++)
863 if (lpStatusPtr
->lpServiceName
)
864 lpStatusPtr
->lpServiceName
=
865 (LPSTR
)((ULONG_PTR
)lpServices
+ (ULONG_PTR
)lpStatusPtr
->lpServiceName
);
867 if (lpStatusPtr
->lpDisplayName
)
868 lpStatusPtr
->lpDisplayName
=
869 (LPSTR
)((ULONG_PTR
)lpServices
+ (ULONG_PTR
)lpStatusPtr
->lpDisplayName
);
875 if (dwError
!= ERROR_SUCCESS
)
877 TRACE("REnumDependentServicesA() failed (Error %lu)\n", dwError
);
878 SetLastError(dwError
);
882 TRACE("EnumDependentServicesA() done\n");
888 /**********************************************************************
889 * EnumDependentServicesW
894 EnumDependentServicesW(SC_HANDLE hService
,
895 DWORD dwServiceState
,
896 LPENUM_SERVICE_STATUSW lpServices
,
898 LPDWORD pcbBytesNeeded
,
899 LPDWORD lpServicesReturned
)
901 ENUM_SERVICE_STATUSW ServiceStatus
;
902 LPENUM_SERVICE_STATUSW lpStatusPtr
;
907 TRACE("EnumDependentServicesW(%p %lu %p %lu %p %p)\n",
908 hService
, dwServiceState
, lpServices
, cbBufSize
,
909 pcbBytesNeeded
, lpServicesReturned
);
911 if (lpServices
== NULL
|| cbBufSize
< sizeof(ENUM_SERVICE_STATUSW
))
913 lpStatusPtr
= &ServiceStatus
;
914 dwBufferSize
= sizeof(ENUM_SERVICE_STATUSW
);
918 lpStatusPtr
= lpServices
;
919 dwBufferSize
= cbBufSize
;
924 dwError
= REnumDependentServicesW((SC_RPC_HANDLE
)hService
,
931 RpcExcept(EXCEPTION_EXECUTE_HANDLER
)
933 dwError
= ScmRpcStatusToWinError(RpcExceptionCode());
937 if (dwError
== ERROR_SUCCESS
|| dwError
== ERROR_MORE_DATA
)
939 for (dwCount
= 0; dwCount
< *lpServicesReturned
; dwCount
++)
941 if (lpStatusPtr
->lpServiceName
)
942 lpStatusPtr
->lpServiceName
=
943 (LPWSTR
)((ULONG_PTR
)lpServices
+ (ULONG_PTR
)lpStatusPtr
->lpServiceName
);
945 if (lpStatusPtr
->lpDisplayName
)
946 lpStatusPtr
->lpDisplayName
=
947 (LPWSTR
)((ULONG_PTR
)lpServices
+ (ULONG_PTR
)lpStatusPtr
->lpDisplayName
);
953 if (dwError
!= ERROR_SUCCESS
)
955 TRACE("REnumDependentServicesW() failed (Error %lu)\n", dwError
);
956 SetLastError(dwError
);
960 TRACE("EnumDependentServicesW() done\n");
966 /**********************************************************************
972 EnumServiceGroupW(SC_HANDLE hSCManager
,
974 DWORD dwServiceState
,
975 LPENUM_SERVICE_STATUSW lpServices
,
977 LPDWORD pcbBytesNeeded
,
978 LPDWORD lpServicesReturned
,
979 LPDWORD lpResumeHandle
,
982 ENUM_SERVICE_STATUSW ServiceStatus
;
983 LPENUM_SERVICE_STATUSW lpStatusPtr
;
988 TRACE("EnumServiceGroupW(%p %lu %lu %p %lu %p %p %p %s)\n",
989 hSCManager
, dwServiceType
, dwServiceState
, lpServices
,
990 cbBufSize
, pcbBytesNeeded
, lpServicesReturned
,
991 lpResumeHandle
, debugstr_w(lpGroup
));
995 SetLastError(ERROR_INVALID_HANDLE
);
999 if (pcbBytesNeeded
== NULL
|| lpServicesReturned
== NULL
)
1001 SetLastError(ERROR_INVALID_ADDRESS
);
1005 if (lpServices
== NULL
|| cbBufSize
< sizeof(ENUM_SERVICE_STATUSW
))
1007 lpStatusPtr
= &ServiceStatus
;
1008 dwBufferSize
= sizeof(ENUM_SERVICE_STATUSW
);
1012 lpStatusPtr
= lpServices
;
1013 dwBufferSize
= cbBufSize
;
1018 if (lpGroup
== NULL
)
1020 dwError
= REnumServicesStatusW((SC_RPC_HANDLE
)hSCManager
,
1023 (LPBYTE
)lpStatusPtr
,
1031 dwError
= REnumServiceGroupW((SC_RPC_HANDLE
)hSCManager
,
1034 (LPBYTE
)lpStatusPtr
,
1042 RpcExcept(EXCEPTION_EXECUTE_HANDLER
)
1044 dwError
= ScmRpcStatusToWinError(RpcExceptionCode());
1048 if (dwError
== ERROR_SUCCESS
|| dwError
== ERROR_MORE_DATA
)
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
);
1064 if (dwError
!= ERROR_SUCCESS
)
1066 TRACE("REnumServiceGroupW() failed (Error %lu)\n", dwError
);
1067 SetLastError(dwError
);
1071 TRACE("EnumServiceGroupW() done\n");
1077 /**********************************************************************
1078 * EnumServicesStatusA
1083 EnumServicesStatusA(SC_HANDLE hSCManager
,
1084 DWORD dwServiceType
,
1085 DWORD dwServiceState
,
1086 LPENUM_SERVICE_STATUSA lpServices
,
1088 LPDWORD pcbBytesNeeded
,
1089 LPDWORD lpServicesReturned
,
1090 LPDWORD lpResumeHandle
)
1092 ENUM_SERVICE_STATUSA ServiceStatus
;
1093 LPENUM_SERVICE_STATUSA lpStatusPtr
;
1098 TRACE("EnumServicesStatusA(%p %lu %lu %p %lu %p %p %p)\n",
1099 hSCManager
, dwServiceType
, dwServiceState
, lpServices
,
1100 cbBufSize
, pcbBytesNeeded
, lpServicesReturned
, lpResumeHandle
);
1104 SetLastError(ERROR_INVALID_HANDLE
);
1108 if (pcbBytesNeeded
== NULL
|| lpServicesReturned
== NULL
)
1110 SetLastError(ERROR_INVALID_ADDRESS
);
1114 if (lpServices
== NULL
|| cbBufSize
< sizeof(ENUM_SERVICE_STATUSA
))
1116 lpStatusPtr
= &ServiceStatus
;
1117 dwBufferSize
= sizeof(ENUM_SERVICE_STATUSA
);
1121 lpStatusPtr
= lpServices
;
1122 dwBufferSize
= cbBufSize
;
1127 dwError
= REnumServicesStatusA((SC_RPC_HANDLE
)hSCManager
,
1130 (LPBYTE
)lpStatusPtr
,
1136 RpcExcept(EXCEPTION_EXECUTE_HANDLER
)
1138 dwError
= ScmRpcStatusToWinError(RpcExceptionCode());
1142 if (dwError
== ERROR_SUCCESS
|| dwError
== ERROR_MORE_DATA
)
1144 for (dwCount
= 0; dwCount
< *lpServicesReturned
; dwCount
++)
1146 if (lpStatusPtr
->lpServiceName
)
1147 lpStatusPtr
->lpServiceName
=
1148 (LPSTR
)((ULONG_PTR
)lpServices
+ (ULONG_PTR
)lpStatusPtr
->lpServiceName
);
1150 if (lpStatusPtr
->lpDisplayName
)
1151 lpStatusPtr
->lpDisplayName
=
1152 (LPSTR
)((ULONG_PTR
)lpServices
+ (ULONG_PTR
)lpStatusPtr
->lpDisplayName
);
1158 if (dwError
!= ERROR_SUCCESS
)
1160 TRACE("REnumServicesStatusA() failed (Error %lu)\n", dwError
);
1161 SetLastError(dwError
);
1165 TRACE("EnumServicesStatusA() done\n");
1171 /**********************************************************************
1172 * EnumServicesStatusW
1177 EnumServicesStatusW(SC_HANDLE hSCManager
,
1178 DWORD dwServiceType
,
1179 DWORD dwServiceState
,
1180 LPENUM_SERVICE_STATUSW lpServices
,
1182 LPDWORD pcbBytesNeeded
,
1183 LPDWORD lpServicesReturned
,
1184 LPDWORD lpResumeHandle
)
1186 ENUM_SERVICE_STATUSW ServiceStatus
;
1187 LPENUM_SERVICE_STATUSW lpStatusPtr
;
1192 TRACE("EnumServicesStatusW(%p %lu %lu %p %lu %p %p %p)\n",
1193 hSCManager
, dwServiceType
, dwServiceState
, lpServices
,
1194 cbBufSize
, pcbBytesNeeded
, lpServicesReturned
, lpResumeHandle
);
1198 SetLastError(ERROR_INVALID_HANDLE
);
1202 if (pcbBytesNeeded
== NULL
|| lpServicesReturned
== NULL
)
1204 SetLastError(ERROR_INVALID_ADDRESS
);
1208 if (lpServices
== NULL
|| cbBufSize
< sizeof(ENUM_SERVICE_STATUSW
))
1210 lpStatusPtr
= &ServiceStatus
;
1211 dwBufferSize
= sizeof(ENUM_SERVICE_STATUSW
);
1215 lpStatusPtr
= lpServices
;
1216 dwBufferSize
= cbBufSize
;
1221 dwError
= REnumServicesStatusW((SC_RPC_HANDLE
)hSCManager
,
1224 (LPBYTE
)lpStatusPtr
,
1230 RpcExcept(EXCEPTION_EXECUTE_HANDLER
)
1232 dwError
= ScmRpcStatusToWinError(RpcExceptionCode());
1236 if (dwError
== ERROR_SUCCESS
|| dwError
== ERROR_MORE_DATA
)
1238 for (dwCount
= 0; dwCount
< *lpServicesReturned
; dwCount
++)
1240 if (lpStatusPtr
->lpServiceName
)
1241 lpStatusPtr
->lpServiceName
=
1242 (LPWSTR
)((ULONG_PTR
)lpServices
+ (ULONG_PTR
)lpStatusPtr
->lpServiceName
);
1244 if (lpStatusPtr
->lpDisplayName
)
1245 lpStatusPtr
->lpDisplayName
=
1246 (LPWSTR
)((ULONG_PTR
)lpServices
+ (ULONG_PTR
)lpStatusPtr
->lpDisplayName
);
1252 if (dwError
!= ERROR_SUCCESS
)
1254 TRACE("REnumServicesStatusW() failed (Error %lu)\n", dwError
);
1255 SetLastError(dwError
);
1259 TRACE("EnumServicesStatusW() done\n");
1265 /**********************************************************************
1266 * EnumServicesStatusExA
1271 EnumServicesStatusExA(SC_HANDLE hSCManager
,
1272 SC_ENUM_TYPE InfoLevel
,
1273 DWORD dwServiceType
,
1274 DWORD dwServiceState
,
1277 LPDWORD pcbBytesNeeded
,
1278 LPDWORD lpServicesReturned
,
1279 LPDWORD lpResumeHandle
,
1280 LPCSTR pszGroupName
)
1282 ENUM_SERVICE_STATUS_PROCESSA ServiceStatus
;
1283 LPENUM_SERVICE_STATUS_PROCESSA lpStatusPtr
;
1288 TRACE("EnumServicesStatusExA(%p %lu %lu %p %lu %p %p %p %s)\n",
1289 hSCManager
, dwServiceType
, dwServiceState
, lpServices
,
1290 cbBufSize
, pcbBytesNeeded
, lpServicesReturned
, lpResumeHandle
,
1291 debugstr_a(pszGroupName
));
1293 if (InfoLevel
!= SC_ENUM_PROCESS_INFO
)
1295 SetLastError(ERROR_INVALID_LEVEL
);
1301 SetLastError(ERROR_INVALID_HANDLE
);
1305 if (pcbBytesNeeded
== NULL
|| lpServicesReturned
== NULL
)
1307 SetLastError(ERROR_INVALID_ADDRESS
);
1311 if (lpServices
== NULL
|| cbBufSize
< sizeof(ENUM_SERVICE_STATUS_PROCESSA
))
1313 lpStatusPtr
= &ServiceStatus
;
1314 dwBufferSize
= sizeof(ENUM_SERVICE_STATUS_PROCESSA
);
1318 lpStatusPtr
= (LPENUM_SERVICE_STATUS_PROCESSA
)lpServices
;
1319 dwBufferSize
= cbBufSize
;
1324 dwError
= REnumServicesStatusExA((SC_RPC_HANDLE
)hSCManager
,
1328 (LPBYTE
)lpStatusPtr
,
1333 (LPSTR
)pszGroupName
);
1335 RpcExcept(EXCEPTION_EXECUTE_HANDLER
)
1337 dwError
= ScmRpcStatusToWinError(RpcExceptionCode());
1341 if (dwError
== ERROR_SUCCESS
|| dwError
== ERROR_MORE_DATA
)
1343 if (InfoLevel
== SC_ENUM_PROCESS_INFO
)
1345 for (dwCount
= 0; dwCount
< *lpServicesReturned
; dwCount
++)
1347 if (lpStatusPtr
->lpServiceName
)
1348 lpStatusPtr
->lpServiceName
=
1349 (LPSTR
)((ULONG_PTR
)lpServices
+ (ULONG_PTR
)lpStatusPtr
->lpServiceName
);
1351 if (lpStatusPtr
->lpDisplayName
)
1352 lpStatusPtr
->lpDisplayName
=
1353 (LPSTR
)((ULONG_PTR
)lpServices
+ (ULONG_PTR
)lpStatusPtr
->lpDisplayName
);
1360 if (dwError
!= ERROR_SUCCESS
)
1362 TRACE("REnumServicesStatusExA() failed (Error %lu)\n", dwError
);
1363 SetLastError(dwError
);
1367 TRACE("EnumServicesStatusExA() done\n");
1373 /**********************************************************************
1374 * EnumServicesStatusExW
1379 EnumServicesStatusExW(SC_HANDLE hSCManager
,
1380 SC_ENUM_TYPE InfoLevel
,
1381 DWORD dwServiceType
,
1382 DWORD dwServiceState
,
1385 LPDWORD pcbBytesNeeded
,
1386 LPDWORD lpServicesReturned
,
1387 LPDWORD lpResumeHandle
,
1388 LPCWSTR pszGroupName
)
1390 ENUM_SERVICE_STATUS_PROCESSW ServiceStatus
;
1391 LPENUM_SERVICE_STATUS_PROCESSW lpStatusPtr
;
1396 TRACE("EnumServicesStatusExW(%p %lu %lu %p %lu %p %p %p %s)\n",
1397 hSCManager
, dwServiceType
, dwServiceState
, lpServices
,
1398 cbBufSize
, pcbBytesNeeded
, lpServicesReturned
, lpResumeHandle
,
1399 debugstr_w(pszGroupName
));
1401 if (InfoLevel
!= SC_ENUM_PROCESS_INFO
)
1403 SetLastError(ERROR_INVALID_LEVEL
);
1409 SetLastError(ERROR_INVALID_HANDLE
);
1413 if (pcbBytesNeeded
== NULL
|| lpServicesReturned
== NULL
)
1415 SetLastError(ERROR_INVALID_ADDRESS
);
1419 if (lpServices
== NULL
|| cbBufSize
< sizeof(ENUM_SERVICE_STATUS_PROCESSW
))
1421 lpStatusPtr
= &ServiceStatus
;
1422 dwBufferSize
= sizeof(ENUM_SERVICE_STATUS_PROCESSW
);
1426 lpStatusPtr
= (LPENUM_SERVICE_STATUS_PROCESSW
)lpServices
;
1427 dwBufferSize
= cbBufSize
;
1432 dwError
= REnumServicesStatusExW((SC_RPC_HANDLE
)hSCManager
,
1436 (LPBYTE
)lpStatusPtr
,
1441 (LPWSTR
)pszGroupName
);
1443 RpcExcept(EXCEPTION_EXECUTE_HANDLER
)
1445 dwError
= ScmRpcStatusToWinError(RpcExceptionCode());
1449 if (dwError
== ERROR_SUCCESS
|| dwError
== ERROR_MORE_DATA
)
1451 if (InfoLevel
== SC_ENUM_PROCESS_INFO
)
1453 for (dwCount
= 0; dwCount
< *lpServicesReturned
; dwCount
++)
1455 if (lpStatusPtr
->lpServiceName
)
1456 lpStatusPtr
->lpServiceName
=
1457 (LPWSTR
)((ULONG_PTR
)lpServices
+ (ULONG_PTR
)lpStatusPtr
->lpServiceName
);
1459 if (lpStatusPtr
->lpDisplayName
)
1460 lpStatusPtr
->lpDisplayName
=
1461 (LPWSTR
)((ULONG_PTR
)lpServices
+ (ULONG_PTR
)lpStatusPtr
->lpDisplayName
);
1468 if (dwError
!= ERROR_SUCCESS
)
1470 TRACE("REnumServicesStatusExW() failed (Error %lu)\n", dwError
);
1471 SetLastError(dwError
);
1475 TRACE("EnumServicesStatusExW() done\n");
1481 /**********************************************************************
1482 * GetServiceDisplayNameA
1487 GetServiceDisplayNameA(SC_HANDLE hSCManager
,
1488 LPCSTR lpServiceName
,
1489 LPSTR lpDisplayName
,
1490 LPDWORD lpcchBuffer
)
1494 CHAR szEmptyName
[] = "";
1496 TRACE("GetServiceDisplayNameA(%p %s %p %p)\n",
1497 hSCManager
, debugstr_a(lpServiceName
), lpDisplayName
, lpcchBuffer
);
1501 SetLastError(ERROR_INVALID_HANDLE
);
1505 if (!lpDisplayName
|| *lpcchBuffer
< sizeof(CHAR
))
1507 lpNameBuffer
= szEmptyName
;
1508 *lpcchBuffer
= sizeof(CHAR
);
1512 lpNameBuffer
= lpDisplayName
;
1517 dwError
= RGetServiceDisplayNameA((SC_RPC_HANDLE
)hSCManager
,
1522 RpcExcept(EXCEPTION_EXECUTE_HANDLER
)
1524 dwError
= ScmRpcStatusToWinError(RpcExceptionCode());
1528 if (dwError
!= ERROR_SUCCESS
)
1530 TRACE("RGetServiceDisplayNameA() failed (Error %lu)\n", dwError
);
1531 SetLastError(dwError
);
1539 /**********************************************************************
1540 * GetServiceDisplayNameW
1545 GetServiceDisplayNameW(SC_HANDLE hSCManager
,
1546 LPCWSTR lpServiceName
,
1547 LPWSTR lpDisplayName
,
1548 LPDWORD lpcchBuffer
)
1551 LPWSTR lpNameBuffer
;
1552 WCHAR szEmptyName
[] = L
"";
1554 TRACE("GetServiceDisplayNameW(%p %s %p %p)\n",
1555 hSCManager
, debugstr_w(lpServiceName
), lpDisplayName
, lpcchBuffer
);
1559 SetLastError(ERROR_INVALID_HANDLE
);
1563 if (!lpDisplayName
|| *lpcchBuffer
< sizeof(WCHAR
))
1565 lpNameBuffer
= szEmptyName
;
1566 *lpcchBuffer
= sizeof(WCHAR
);
1570 lpNameBuffer
= lpDisplayName
;
1575 dwError
= RGetServiceDisplayNameW((SC_RPC_HANDLE
)hSCManager
,
1580 RpcExcept(EXCEPTION_EXECUTE_HANDLER
)
1582 dwError
= ScmRpcStatusToWinError(RpcExceptionCode());
1586 if (dwError
!= ERROR_SUCCESS
)
1588 TRACE("RGetServiceDisplayNameW() failed (Error %lu)\n", dwError
);
1589 SetLastError(dwError
);
1597 /**********************************************************************
1598 * GetServiceKeyNameA
1603 GetServiceKeyNameA(SC_HANDLE hSCManager
,
1604 LPCSTR lpDisplayName
,
1605 LPSTR lpServiceName
,
1606 LPDWORD lpcchBuffer
)
1610 CHAR szEmptyName
[] = "";
1612 TRACE("GetServiceKeyNameA(%p %s %p %p)\n",
1613 hSCManager
, debugstr_a(lpDisplayName
), lpServiceName
, lpcchBuffer
);
1617 SetLastError(ERROR_INVALID_HANDLE
);
1621 if (!lpServiceName
|| *lpcchBuffer
< sizeof(CHAR
))
1623 lpNameBuffer
= szEmptyName
;
1624 *lpcchBuffer
= sizeof(CHAR
);
1628 lpNameBuffer
= lpServiceName
;
1633 dwError
= RGetServiceKeyNameA((SC_RPC_HANDLE
)hSCManager
,
1638 RpcExcept(EXCEPTION_EXECUTE_HANDLER
)
1640 /* HACK: because of a problem with rpcrt4, rpcserver is hacked to return 6 for ERROR_SERVICE_DOES_NOT_EXIST */
1641 dwError
= ScmRpcStatusToWinError(RpcExceptionCode());
1645 if (dwError
!= ERROR_SUCCESS
)
1647 TRACE("RGetServiceKeyNameA() failed (Error %lu)\n", dwError
);
1648 SetLastError(dwError
);
1656 /**********************************************************************
1657 * GetServiceKeyNameW
1662 GetServiceKeyNameW(SC_HANDLE hSCManager
,
1663 LPCWSTR lpDisplayName
,
1664 LPWSTR lpServiceName
,
1665 LPDWORD lpcchBuffer
)
1668 LPWSTR lpNameBuffer
;
1669 WCHAR szEmptyName
[] = L
"";
1671 TRACE("GetServiceKeyNameW(%p %s %p %p)\n",
1672 hSCManager
, debugstr_w(lpDisplayName
), lpServiceName
, lpcchBuffer
);
1676 SetLastError(ERROR_INVALID_HANDLE
);
1680 if (!lpServiceName
|| *lpcchBuffer
< sizeof(WCHAR
))
1682 lpNameBuffer
= szEmptyName
;
1683 *lpcchBuffer
= sizeof(WCHAR
);
1687 lpNameBuffer
= lpServiceName
;
1692 dwError
= RGetServiceKeyNameW((SC_RPC_HANDLE
)hSCManager
,
1697 RpcExcept(EXCEPTION_EXECUTE_HANDLER
)
1699 dwError
= ScmRpcStatusToWinError(RpcExceptionCode());
1703 if (dwError
!= ERROR_SUCCESS
)
1705 TRACE("RGetServiceKeyNameW() failed (Error %lu)\n", dwError
);
1706 SetLastError(dwError
);
1714 /**********************************************************************
1715 * I_ScGetCurrentGroupStateW
1720 I_ScGetCurrentGroupStateW(SC_HANDLE hSCManager
,
1721 LPWSTR pszGroupName
,
1722 LPDWORD pdwGroupState
)
1726 TRACE("I_ScGetCurrentGroupStateW(%p %s %p)\n",
1727 hSCManager
, debugstr_w(pszGroupName
), pdwGroupState
);
1731 dwError
= RI_ScGetCurrentGroupStateW((SC_RPC_HANDLE
)hSCManager
,
1735 RpcExcept(EXCEPTION_EXECUTE_HANDLER
)
1737 dwError
= ScmRpcStatusToWinError(RpcExceptionCode());
1741 if (dwError
!= ERROR_SUCCESS
)
1743 TRACE("RI_ScGetCurrentGroupStateW() failed (Error %lu)\n", dwError
);
1744 SetLastError(dwError
);
1751 /**********************************************************************
1752 * LockServiceDatabase
1757 LockServiceDatabase(SC_HANDLE hSCManager
)
1762 TRACE("LockServiceDatabase(%p)\n",
1767 dwError
= RLockServiceDatabase((SC_RPC_HANDLE
)hSCManager
,
1768 (SC_RPC_LOCK
*)&hLock
);
1770 RpcExcept(EXCEPTION_EXECUTE_HANDLER
)
1772 dwError
= ScmRpcStatusToWinError(RpcExceptionCode());
1776 if (dwError
!= ERROR_SUCCESS
)
1778 TRACE("RLockServiceDatabase() failed (Error %lu)\n", dwError
);
1779 SetLastError(dwError
);
1783 TRACE("hLock = %p\n", hLock
);
1790 WaitForSCManager(VOID
)
1794 TRACE("WaitForSCManager()\n");
1796 /* Try to open the existing event */
1797 hEvent
= OpenEventW(SYNCHRONIZE
, FALSE
, SCM_START_EVENT
);
1800 if (GetLastError() != ERROR_FILE_NOT_FOUND
)
1803 /* Try to create a new event */
1804 hEvent
= CreateEventW(NULL
, TRUE
, FALSE
, SCM_START_EVENT
);
1809 /* Wait for 3 minutes */
1810 WaitForSingleObject(hEvent
, 180000);
1811 CloseHandle(hEvent
);
1813 TRACE("ScmWaitForSCManager() done\n");
1817 /**********************************************************************
1823 OpenSCManagerA(LPCSTR lpMachineName
,
1824 LPCSTR lpDatabaseName
,
1825 DWORD dwDesiredAccess
)
1827 SC_HANDLE hScm
= NULL
;
1830 TRACE("OpenSCManagerA(%s %s %lx)\n",
1831 debugstr_a(lpMachineName
), debugstr_a(lpDatabaseName
), dwDesiredAccess
);
1837 dwError
= ROpenSCManagerA((LPSTR
)lpMachineName
,
1838 (LPSTR
)lpDatabaseName
,
1840 (SC_RPC_HANDLE
*)&hScm
);
1842 RpcExcept(EXCEPTION_EXECUTE_HANDLER
)
1844 dwError
= ScmRpcStatusToWinError(RpcExceptionCode());
1848 if (dwError
!= ERROR_SUCCESS
)
1850 TRACE("ROpenSCManagerA() failed (Error %lu)\n", dwError
);
1851 SetLastError(dwError
);
1855 TRACE("hScm = %p\n", hScm
);
1861 /**********************************************************************
1867 OpenSCManagerW(LPCWSTR lpMachineName
,
1868 LPCWSTR lpDatabaseName
,
1869 DWORD dwDesiredAccess
)
1871 SC_HANDLE hScm
= NULL
;
1874 TRACE("OpenSCManagerW(%s %s %lx)\n",
1875 debugstr_w(lpMachineName
), debugstr_w(lpDatabaseName
), dwDesiredAccess
);
1881 dwError
= ROpenSCManagerW((LPWSTR
)lpMachineName
,
1882 (LPWSTR
)lpDatabaseName
,
1884 (SC_RPC_HANDLE
*)&hScm
);
1886 RpcExcept(EXCEPTION_EXECUTE_HANDLER
)
1888 dwError
= ScmRpcStatusToWinError(RpcExceptionCode());
1892 if (dwError
!= ERROR_SUCCESS
)
1894 TRACE("ROpenSCManagerW() failed (Error %lu)\n", dwError
);
1895 SetLastError(dwError
);
1899 TRACE("hScm = %p\n", hScm
);
1905 /**********************************************************************
1911 OpenServiceA(SC_HANDLE hSCManager
,
1912 LPCSTR lpServiceName
,
1913 DWORD dwDesiredAccess
)
1915 SC_HANDLE hService
= NULL
;
1918 TRACE("OpenServiceA(%p %s %lx)\n",
1919 hSCManager
, debugstr_a(lpServiceName
), dwDesiredAccess
);
1923 SetLastError(ERROR_INVALID_HANDLE
);
1929 dwError
= ROpenServiceA((SC_RPC_HANDLE
)hSCManager
,
1930 (LPSTR
)lpServiceName
,
1932 (SC_RPC_HANDLE
*)&hService
);
1934 RpcExcept(EXCEPTION_EXECUTE_HANDLER
)
1936 dwError
= ScmRpcStatusToWinError(RpcExceptionCode());
1940 SetLastError(dwError
);
1941 if (dwError
!= ERROR_SUCCESS
)
1943 TRACE("ROpenServiceA() failed (Error %lu)\n", dwError
);
1947 TRACE("hService = %p\n", hService
);
1953 /**********************************************************************
1959 OpenServiceW(SC_HANDLE hSCManager
,
1960 LPCWSTR lpServiceName
,
1961 DWORD dwDesiredAccess
)
1963 SC_HANDLE hService
= NULL
;
1966 TRACE("OpenServiceW(%p %s %lx)\n",
1967 hSCManager
, debugstr_w(lpServiceName
), dwDesiredAccess
);
1971 SetLastError(ERROR_INVALID_HANDLE
);
1977 dwError
= ROpenServiceW((SC_RPC_HANDLE
)hSCManager
,
1978 (LPWSTR
)lpServiceName
,
1980 (SC_RPC_HANDLE
*)&hService
);
1982 RpcExcept(EXCEPTION_EXECUTE_HANDLER
)
1984 dwError
= ScmRpcStatusToWinError(RpcExceptionCode());
1988 SetLastError(dwError
);
1989 if (dwError
!= ERROR_SUCCESS
)
1991 TRACE("ROpenServiceW() failed (Error %lu)\n", dwError
);
1995 TRACE("hService = %p\n", hService
);
2001 /**********************************************************************
2002 * QueryServiceConfigA
2007 QueryServiceConfigA(SC_HANDLE hService
,
2008 LPQUERY_SERVICE_CONFIGA lpServiceConfig
,
2010 LPDWORD pcbBytesNeeded
)
2012 QUERY_SERVICE_CONFIGA ServiceConfig
;
2013 LPQUERY_SERVICE_CONFIGA lpConfigPtr
;
2017 TRACE("QueryServiceConfigA(%p %p %lu %p)\n",
2018 hService
, lpServiceConfig
, cbBufSize
, pcbBytesNeeded
);
2020 if (lpServiceConfig
== NULL
||
2021 cbBufSize
< sizeof(QUERY_SERVICE_CONFIGA
))
2023 lpConfigPtr
= &ServiceConfig
;
2024 dwBufferSize
= sizeof(QUERY_SERVICE_CONFIGA
);
2028 lpConfigPtr
= lpServiceConfig
;
2029 dwBufferSize
= cbBufSize
;
2034 dwError
= RQueryServiceConfigA((SC_RPC_HANDLE
)hService
,
2035 (LPBYTE
)lpConfigPtr
,
2039 RpcExcept(EXCEPTION_EXECUTE_HANDLER
)
2041 dwError
= ScmRpcStatusToWinError(RpcExceptionCode());
2045 if (dwError
!= ERROR_SUCCESS
)
2047 TRACE("RQueryServiceConfigA() failed (Error %lu)\n", dwError
);
2048 SetLastError(dwError
);
2052 /* Adjust the pointers */
2053 if (lpConfigPtr
->lpBinaryPathName
)
2054 lpConfigPtr
->lpBinaryPathName
=
2055 (LPSTR
)((ULONG_PTR
)lpConfigPtr
+
2056 (ULONG_PTR
)lpConfigPtr
->lpBinaryPathName
);
2058 if (lpConfigPtr
->lpLoadOrderGroup
)
2059 lpConfigPtr
->lpLoadOrderGroup
=
2060 (LPSTR
)((ULONG_PTR
)lpConfigPtr
+
2061 (ULONG_PTR
)lpConfigPtr
->lpLoadOrderGroup
);
2063 if (lpConfigPtr
->lpDependencies
)
2064 lpConfigPtr
->lpDependencies
=
2065 (LPSTR
)((ULONG_PTR
)lpConfigPtr
+
2066 (ULONG_PTR
)lpConfigPtr
->lpDependencies
);
2068 if (lpConfigPtr
->lpServiceStartName
)
2069 lpConfigPtr
->lpServiceStartName
=
2070 (LPSTR
)((ULONG_PTR
)lpConfigPtr
+
2071 (ULONG_PTR
)lpConfigPtr
->lpServiceStartName
);
2073 if (lpConfigPtr
->lpDisplayName
)
2074 lpConfigPtr
->lpDisplayName
=
2075 (LPSTR
)((ULONG_PTR
)lpConfigPtr
+
2076 (ULONG_PTR
)lpConfigPtr
->lpDisplayName
);
2078 TRACE("QueryServiceConfigA() done\n");
2084 /**********************************************************************
2085 * QueryServiceConfigW
2090 QueryServiceConfigW(SC_HANDLE hService
,
2091 LPQUERY_SERVICE_CONFIGW lpServiceConfig
,
2093 LPDWORD pcbBytesNeeded
)
2095 QUERY_SERVICE_CONFIGW ServiceConfig
;
2096 LPQUERY_SERVICE_CONFIGW lpConfigPtr
;
2100 TRACE("QueryServiceConfigW(%p %p %lu %p)\n",
2101 hService
, lpServiceConfig
, cbBufSize
, pcbBytesNeeded
);
2103 if (lpServiceConfig
== NULL
||
2104 cbBufSize
< sizeof(QUERY_SERVICE_CONFIGW
))
2106 lpConfigPtr
= &ServiceConfig
;
2107 dwBufferSize
= sizeof(QUERY_SERVICE_CONFIGW
);
2111 lpConfigPtr
= lpServiceConfig
;
2112 dwBufferSize
= cbBufSize
;
2117 dwError
= RQueryServiceConfigW((SC_RPC_HANDLE
)hService
,
2118 (LPBYTE
)lpConfigPtr
,
2122 RpcExcept(EXCEPTION_EXECUTE_HANDLER
)
2124 dwError
= ScmRpcStatusToWinError(RpcExceptionCode());
2128 if (dwError
!= ERROR_SUCCESS
)
2130 TRACE("RQueryServiceConfigW() failed (Error %lu)\n", dwError
);
2131 SetLastError(dwError
);
2135 /* Adjust the pointers */
2136 if (lpConfigPtr
->lpBinaryPathName
)
2137 lpConfigPtr
->lpBinaryPathName
=
2138 (LPWSTR
)((ULONG_PTR
)lpConfigPtr
+
2139 (ULONG_PTR
)lpConfigPtr
->lpBinaryPathName
);
2141 if (lpConfigPtr
->lpLoadOrderGroup
)
2142 lpConfigPtr
->lpLoadOrderGroup
=
2143 (LPWSTR
)((ULONG_PTR
)lpConfigPtr
+
2144 (ULONG_PTR
)lpConfigPtr
->lpLoadOrderGroup
);
2146 if (lpConfigPtr
->lpDependencies
)
2147 lpConfigPtr
->lpDependencies
=
2148 (LPWSTR
)((ULONG_PTR
)lpConfigPtr
+
2149 (ULONG_PTR
)lpConfigPtr
->lpDependencies
);
2151 if (lpConfigPtr
->lpServiceStartName
)
2152 lpConfigPtr
->lpServiceStartName
=
2153 (LPWSTR
)((ULONG_PTR
)lpConfigPtr
+
2154 (ULONG_PTR
)lpConfigPtr
->lpServiceStartName
);
2156 if (lpConfigPtr
->lpDisplayName
)
2157 lpConfigPtr
->lpDisplayName
=
2158 (LPWSTR
)((ULONG_PTR
)lpConfigPtr
+
2159 (ULONG_PTR
)lpConfigPtr
->lpDisplayName
);
2161 TRACE("QueryServiceConfigW() done\n");
2167 /**********************************************************************
2168 * QueryServiceConfig2A
2173 QueryServiceConfig2A(SC_HANDLE hService
,
2177 LPDWORD pcbBytesNeeded
)
2179 SERVICE_DESCRIPTIONA ServiceDescription
;
2180 SERVICE_FAILURE_ACTIONSA ServiceFailureActions
;
2181 LPBYTE lpTempBuffer
;
2182 BOOL bUseTempBuffer
= FALSE
;
2186 TRACE("QueryServiceConfig2A(%p %lu %p %lu %p)\n",
2187 hService
, dwInfoLevel
, lpBuffer
, cbBufSize
, pcbBytesNeeded
);
2189 lpTempBuffer
= lpBuffer
;
2190 dwBufferSize
= cbBufSize
;
2192 switch (dwInfoLevel
)
2194 case SERVICE_CONFIG_DESCRIPTION
:
2195 if ((lpBuffer
== NULL
) || (cbBufSize
< sizeof(SERVICE_DESCRIPTIONA
)))
2197 lpTempBuffer
= (LPBYTE
)&ServiceDescription
;
2198 dwBufferSize
= sizeof(SERVICE_DESCRIPTIONA
);
2199 bUseTempBuffer
= TRUE
;
2203 case SERVICE_CONFIG_FAILURE_ACTIONS
:
2204 if ((lpBuffer
== NULL
) || (cbBufSize
< sizeof(SERVICE_FAILURE_ACTIONSA
)))
2206 lpTempBuffer
= (LPBYTE
)&ServiceFailureActions
;
2207 dwBufferSize
= sizeof(SERVICE_FAILURE_ACTIONSA
);
2208 bUseTempBuffer
= TRUE
;
2213 WARN("Unknown info level 0x%lx\n", dwInfoLevel
);
2214 SetLastError(ERROR_INVALID_LEVEL
);
2220 dwError
= RQueryServiceConfig2A((SC_RPC_HANDLE
)hService
,
2226 RpcExcept(EXCEPTION_EXECUTE_HANDLER
)
2228 dwError
= ScmRpcStatusToWinError(RpcExceptionCode());
2232 if (dwError
!= ERROR_SUCCESS
)
2234 TRACE("RQueryServiceConfig2A() failed (Error %lu)\n", dwError
);
2235 SetLastError(dwError
);
2239 if (bUseTempBuffer
!= FALSE
)
2241 TRACE("RQueryServiceConfig2A() returns ERROR_INSUFFICIENT_BUFFER\n");
2242 *pcbBytesNeeded
= dwBufferSize
;
2243 SetLastError(ERROR_INSUFFICIENT_BUFFER
);
2247 switch (dwInfoLevel
)
2249 case SERVICE_CONFIG_DESCRIPTION
:
2251 LPSERVICE_DESCRIPTIONA lpPtr
= (LPSERVICE_DESCRIPTIONA
)lpTempBuffer
;
2253 if (lpPtr
->lpDescription
!= NULL
)
2254 lpPtr
->lpDescription
=
2255 (LPSTR
)((ULONG_PTR
)lpPtr
+ (ULONG_PTR
)lpPtr
->lpDescription
);
2259 case SERVICE_CONFIG_FAILURE_ACTIONS
:
2261 LPSERVICE_FAILURE_ACTIONSA lpPtr
= (LPSERVICE_FAILURE_ACTIONSA
)lpTempBuffer
;
2263 if (lpPtr
->lpRebootMsg
!= NULL
)
2264 lpPtr
->lpRebootMsg
=
2265 (LPSTR
)((ULONG_PTR
)lpPtr
+ (ULONG_PTR
)lpPtr
->lpRebootMsg
);
2267 if (lpPtr
->lpCommand
!= NULL
)
2269 (LPSTR
)((ULONG_PTR
)lpPtr
+ (ULONG_PTR
)lpPtr
->lpCommand
);
2271 if (lpPtr
->lpsaActions
!= NULL
)
2272 lpPtr
->lpsaActions
=
2273 (LPSC_ACTION
)((ULONG_PTR
)lpPtr
+ (ULONG_PTR
)lpPtr
->lpsaActions
);
2278 TRACE("QueryServiceConfig2A() done\n");
2284 /**********************************************************************
2285 * QueryServiceConfig2W
2290 QueryServiceConfig2W(SC_HANDLE hService
,
2294 LPDWORD pcbBytesNeeded
)
2296 SERVICE_DESCRIPTIONW ServiceDescription
;
2297 SERVICE_FAILURE_ACTIONSW ServiceFailureActions
;
2298 LPBYTE lpTempBuffer
;
2299 BOOL bUseTempBuffer
= FALSE
;
2303 TRACE("QueryServiceConfig2W(%p %lu %p %lu %p)\n",
2304 hService
, dwInfoLevel
, lpBuffer
, cbBufSize
, pcbBytesNeeded
);
2306 lpTempBuffer
= lpBuffer
;
2307 dwBufferSize
= cbBufSize
;
2309 switch (dwInfoLevel
)
2311 case SERVICE_CONFIG_DESCRIPTION
:
2312 if ((lpBuffer
== NULL
) || (cbBufSize
< sizeof(SERVICE_DESCRIPTIONW
)))
2314 lpTempBuffer
= (LPBYTE
)&ServiceDescription
;
2315 dwBufferSize
= sizeof(SERVICE_DESCRIPTIONW
);
2316 bUseTempBuffer
= TRUE
;
2320 case SERVICE_CONFIG_FAILURE_ACTIONS
:
2321 if ((lpBuffer
== NULL
) || (cbBufSize
< sizeof(SERVICE_FAILURE_ACTIONSW
)))
2323 lpTempBuffer
= (LPBYTE
)&ServiceFailureActions
;
2324 dwBufferSize
= sizeof(SERVICE_FAILURE_ACTIONSW
);
2325 bUseTempBuffer
= TRUE
;
2330 WARN("Unknown info level 0x%lx\n", dwInfoLevel
);
2331 SetLastError(ERROR_INVALID_LEVEL
);
2337 dwError
= RQueryServiceConfig2W((SC_RPC_HANDLE
)hService
,
2343 RpcExcept(EXCEPTION_EXECUTE_HANDLER
)
2345 dwError
= ScmRpcStatusToWinError(RpcExceptionCode());
2349 if (dwError
!= ERROR_SUCCESS
)
2351 TRACE("RQueryServiceConfig2W() failed (Error %lu)\n", dwError
);
2352 SetLastError(dwError
);
2356 if (bUseTempBuffer
!= FALSE
)
2358 TRACE("RQueryServiceConfig2W() returns ERROR_INSUFFICIENT_BUFFER\n");
2359 *pcbBytesNeeded
= dwBufferSize
;
2360 SetLastError(ERROR_INSUFFICIENT_BUFFER
);
2364 switch (dwInfoLevel
)
2366 case SERVICE_CONFIG_DESCRIPTION
:
2368 LPSERVICE_DESCRIPTIONW lpPtr
= (LPSERVICE_DESCRIPTIONW
)lpTempBuffer
;
2370 if (lpPtr
->lpDescription
!= NULL
)
2371 lpPtr
->lpDescription
=
2372 (LPWSTR
)((ULONG_PTR
)lpPtr
+ (ULONG_PTR
)lpPtr
->lpDescription
);
2376 case SERVICE_CONFIG_FAILURE_ACTIONS
:
2378 LPSERVICE_FAILURE_ACTIONSW lpPtr
= (LPSERVICE_FAILURE_ACTIONSW
)lpTempBuffer
;
2380 if (lpPtr
->lpRebootMsg
!= NULL
)
2381 lpPtr
->lpRebootMsg
=
2382 (LPWSTR
)((ULONG_PTR
)lpPtr
+ (ULONG_PTR
)lpPtr
->lpRebootMsg
);
2384 if (lpPtr
->lpCommand
!= NULL
)
2386 (LPWSTR
)((ULONG_PTR
)lpPtr
+ (ULONG_PTR
)lpPtr
->lpCommand
);
2388 if (lpPtr
->lpsaActions
!= NULL
)
2389 lpPtr
->lpsaActions
=
2390 (LPSC_ACTION
)((ULONG_PTR
)lpPtr
+ (ULONG_PTR
)lpPtr
->lpsaActions
);
2395 TRACE("QueryServiceConfig2W() done\n");
2401 /**********************************************************************
2402 * QueryServiceLockStatusA
2407 QueryServiceLockStatusA(SC_HANDLE hSCManager
,
2408 LPQUERY_SERVICE_LOCK_STATUSA lpLockStatus
,
2410 LPDWORD pcbBytesNeeded
)
2412 QUERY_SERVICE_LOCK_STATUSA LockStatus
;
2413 LPQUERY_SERVICE_LOCK_STATUSA lpStatusPtr
;
2417 TRACE("QueryServiceLockStatusA(%p %p %lu %p)\n",
2418 hSCManager
, lpLockStatus
, cbBufSize
, pcbBytesNeeded
);
2420 if (lpLockStatus
== NULL
|| cbBufSize
< sizeof(QUERY_SERVICE_LOCK_STATUSA
))
2422 lpStatusPtr
= &LockStatus
;
2423 dwBufferSize
= sizeof(QUERY_SERVICE_LOCK_STATUSA
);
2427 lpStatusPtr
= lpLockStatus
;
2428 dwBufferSize
= cbBufSize
;
2433 dwError
= RQueryServiceLockStatusA((SC_RPC_HANDLE
)hSCManager
,
2434 (LPBYTE
)lpStatusPtr
,
2438 RpcExcept(EXCEPTION_EXECUTE_HANDLER
)
2440 dwError
= ScmRpcStatusToWinError(RpcExceptionCode());
2444 if (dwError
!= ERROR_SUCCESS
)
2446 TRACE("RQueryServiceLockStatusA() failed (Error %lu)\n", dwError
);
2447 SetLastError(dwError
);
2451 if (lpStatusPtr
->lpLockOwner
!= NULL
)
2453 lpStatusPtr
->lpLockOwner
=
2454 (LPSTR
)((ULONG_PTR
)lpStatusPtr
+ (ULONG_PTR
)lpStatusPtr
->lpLockOwner
);
2457 TRACE("QueryServiceLockStatusA() done\n");
2463 /**********************************************************************
2464 * QueryServiceLockStatusW
2469 QueryServiceLockStatusW(SC_HANDLE hSCManager
,
2470 LPQUERY_SERVICE_LOCK_STATUSW lpLockStatus
,
2472 LPDWORD pcbBytesNeeded
)
2474 QUERY_SERVICE_LOCK_STATUSW LockStatus
;
2475 LPQUERY_SERVICE_LOCK_STATUSW lpStatusPtr
;
2479 TRACE("QueryServiceLockStatusW(%p %p %lu %p)\n",
2480 hSCManager
, lpLockStatus
, cbBufSize
, pcbBytesNeeded
);
2482 if (lpLockStatus
== NULL
|| cbBufSize
< sizeof(QUERY_SERVICE_LOCK_STATUSW
))
2484 lpStatusPtr
= &LockStatus
;
2485 dwBufferSize
= sizeof(QUERY_SERVICE_LOCK_STATUSW
);
2489 lpStatusPtr
= lpLockStatus
;
2490 dwBufferSize
= cbBufSize
;
2495 dwError
= RQueryServiceLockStatusW((SC_RPC_HANDLE
)hSCManager
,
2496 (LPBYTE
)lpStatusPtr
,
2500 RpcExcept(EXCEPTION_EXECUTE_HANDLER
)
2502 dwError
= ScmRpcStatusToWinError(RpcExceptionCode());
2506 if (dwError
!= ERROR_SUCCESS
)
2508 TRACE("RQueryServiceLockStatusW() failed (Error %lu)\n", dwError
);
2509 SetLastError(dwError
);
2513 if (lpStatusPtr
->lpLockOwner
!= NULL
)
2515 lpStatusPtr
->lpLockOwner
=
2516 (LPWSTR
)((ULONG_PTR
)lpStatusPtr
+ (ULONG_PTR
)lpStatusPtr
->lpLockOwner
);
2519 TRACE("QueryServiceLockStatusW() done\n");
2525 /**********************************************************************
2526 * QueryServiceObjectSecurity
2531 QueryServiceObjectSecurity(SC_HANDLE hService
,
2532 SECURITY_INFORMATION dwSecurityInformation
,
2533 PSECURITY_DESCRIPTOR lpSecurityDescriptor
,
2535 LPDWORD pcbBytesNeeded
)
2539 TRACE("QueryServiceObjectSecurity(%p %lu %p)\n",
2540 hService
, dwSecurityInformation
, lpSecurityDescriptor
);
2544 dwError
= RQueryServiceObjectSecurity((SC_RPC_HANDLE
)hService
,
2545 dwSecurityInformation
,
2546 (LPBYTE
)lpSecurityDescriptor
,
2550 RpcExcept(EXCEPTION_EXECUTE_HANDLER
)
2552 dwError
= ScmRpcStatusToWinError(RpcExceptionCode());
2556 if (dwError
!= ERROR_SUCCESS
)
2558 TRACE("QueryServiceObjectSecurity() failed (Error %lu)\n", dwError
);
2559 SetLastError(dwError
);
2567 /**********************************************************************
2568 * SetServiceObjectSecurity
2573 SetServiceObjectSecurity(SC_HANDLE hService
,
2574 SECURITY_INFORMATION dwSecurityInformation
,
2575 PSECURITY_DESCRIPTOR lpSecurityDescriptor
)
2577 PSECURITY_DESCRIPTOR SelfRelativeSD
= NULL
;
2582 TRACE("SetServiceObjectSecurity(%p %lu %p)\n",
2583 hService
, dwSecurityInformation
, lpSecurityDescriptor
);
2586 Status
= RtlMakeSelfRelativeSD(lpSecurityDescriptor
,
2589 if (Status
!= STATUS_BUFFER_TOO_SMALL
)
2591 SetLastError(ERROR_INVALID_PARAMETER
);
2595 SelfRelativeSD
= HeapAlloc(GetProcessHeap(), 0, Length
);
2596 if (SelfRelativeSD
== NULL
)
2598 SetLastError(ERROR_NOT_ENOUGH_MEMORY
);
2602 Status
= RtlMakeSelfRelativeSD(lpSecurityDescriptor
,
2605 if (!NT_SUCCESS(Status
))
2607 HeapFree(GetProcessHeap(), 0, SelfRelativeSD
);
2608 SetLastError(RtlNtStatusToDosError(Status
));
2614 dwError
= RSetServiceObjectSecurity((SC_RPC_HANDLE
)hService
,
2615 dwSecurityInformation
,
2616 (LPBYTE
)SelfRelativeSD
,
2619 RpcExcept(EXCEPTION_EXECUTE_HANDLER
)
2621 dwError
= ScmRpcStatusToWinError(RpcExceptionCode());
2625 HeapFree(GetProcessHeap(), 0, SelfRelativeSD
);
2627 if (dwError
!= ERROR_SUCCESS
)
2629 TRACE("RServiceObjectSecurity() failed (Error %lu)\n", dwError
);
2630 SetLastError(dwError
);
2638 /**********************************************************************
2639 * QueryServiceStatus
2644 QueryServiceStatus(SC_HANDLE hService
,
2645 LPSERVICE_STATUS lpServiceStatus
)
2649 TRACE("QueryServiceStatus(%p %p)\n",
2650 hService
, lpServiceStatus
);
2654 SetLastError(ERROR_INVALID_HANDLE
);
2660 dwError
= RQueryServiceStatus((SC_RPC_HANDLE
)hService
,
2663 RpcExcept(EXCEPTION_EXECUTE_HANDLER
)
2665 dwError
= ScmRpcStatusToWinError(RpcExceptionCode());
2669 if (dwError
!= ERROR_SUCCESS
)
2671 TRACE("RQueryServiceStatus() failed (Error %lu)\n", dwError
);
2672 SetLastError(dwError
);
2680 /**********************************************************************
2681 * QueryServiceStatusEx
2686 QueryServiceStatusEx(SC_HANDLE hService
,
2687 SC_STATUS_TYPE InfoLevel
,
2690 LPDWORD pcbBytesNeeded
)
2694 TRACE("QueryServiceStatusEx(%p %lu %p %lu %p)\n",
2695 hService
, InfoLevel
, lpBuffer
, cbBufSize
, pcbBytesNeeded
);
2697 if (InfoLevel
!= SC_STATUS_PROCESS_INFO
)
2699 SetLastError(ERROR_INVALID_LEVEL
);
2703 if (cbBufSize
< sizeof(SERVICE_STATUS_PROCESS
))
2705 *pcbBytesNeeded
= sizeof(SERVICE_STATUS_PROCESS
);
2706 SetLastError(ERROR_INSUFFICIENT_BUFFER
);
2712 dwError
= RQueryServiceStatusEx((SC_RPC_HANDLE
)hService
,
2718 RpcExcept(EXCEPTION_EXECUTE_HANDLER
)
2720 dwError
= ScmRpcStatusToWinError(RpcExceptionCode());
2724 if (dwError
!= ERROR_SUCCESS
)
2726 TRACE("RQueryServiceStatusEx() failed (Error %lu)\n", dwError
);
2727 SetLastError(dwError
);
2735 /**********************************************************************
2741 StartServiceA(SC_HANDLE hService
,
2742 DWORD dwNumServiceArgs
,
2743 LPCSTR
*lpServiceArgVectors
)
2747 TRACE("StartServiceA(%p %lu %p)\n",
2748 hService
, dwNumServiceArgs
, lpServiceArgVectors
);
2752 dwError
= RStartServiceA((SC_RPC_HANDLE
)hService
,
2754 (LPSTRING_PTRSA
)lpServiceArgVectors
);
2756 RpcExcept(EXCEPTION_EXECUTE_HANDLER
)
2758 dwError
= ScmRpcStatusToWinError(RpcExceptionCode());
2762 if (dwError
!= ERROR_SUCCESS
)
2764 ERR("RStartServiceA() failed (Error %lu)\n", dwError
);
2765 SetLastError(dwError
);
2773 /**********************************************************************
2779 StartServiceW(SC_HANDLE hService
,
2780 DWORD dwNumServiceArgs
,
2781 LPCWSTR
*lpServiceArgVectors
)
2785 TRACE("StartServiceW(%p %lu %p)\n",
2786 hService
, dwNumServiceArgs
, lpServiceArgVectors
);
2790 dwError
= RStartServiceW((SC_RPC_HANDLE
)hService
,
2792 (LPSTRING_PTRSW
)lpServiceArgVectors
);
2794 RpcExcept(EXCEPTION_EXECUTE_HANDLER
)
2796 dwError
= ScmRpcStatusToWinError(RpcExceptionCode());
2800 if (dwError
!= ERROR_SUCCESS
)
2802 ERR("RStartServiceW() failed (Error %lu)\n", dwError
);
2803 SetLastError(dwError
);
2811 /**********************************************************************
2812 * UnlockServiceDatabase
2817 UnlockServiceDatabase(SC_LOCK ScLock
)
2821 TRACE("UnlockServiceDatabase(%x)\n",
2826 dwError
= RUnlockServiceDatabase((LPSC_RPC_LOCK
)&ScLock
);
2828 RpcExcept(EXCEPTION_EXECUTE_HANDLER
)
2830 dwError
= ScmRpcStatusToWinError(RpcExceptionCode());
2834 if (dwError
== ERROR_INVALID_HANDLE
)
2835 dwError
= ERROR_INVALID_SERVICE_LOCK
;
2837 if (dwError
!= ERROR_SUCCESS
)
2839 TRACE("RUnlockServiceDatabase() failed (Error %lu)\n", dwError
);
2840 SetLastError(dwError
);
2848 /**********************************************************************
2849 * NotifyBootConfigStatus
2854 NotifyBootConfigStatus(BOOL BootAcceptable
)
2858 TRACE("NotifyBootConfigStatus(%u)\n",
2863 dwError
= RNotifyBootConfigStatus(NULL
,
2866 RpcExcept(EXCEPTION_EXECUTE_HANDLER
)
2868 dwError
= ScmRpcStatusToWinError(RpcExceptionCode());
2872 if (dwError
!= ERROR_SUCCESS
)
2874 TRACE("NotifyBootConfigStatus() failed (Error %lu)\n", dwError
);
2875 SetLastError(dwError
);