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 * ChangeServiceConfigA
92 LPCSTR lpBinaryPathName
,
93 LPCSTR lpLoadOrderGroup
,
95 LPCSTR lpDependencies
,
96 LPCSTR lpServiceStartName
,
100 DPRINT1("ChangeServiceConfigA is unimplemented\n");
101 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
106 /**********************************************************************
107 * ChangeServiceConfigW
112 ChangeServiceConfigW(SC_HANDLE hService
,
115 DWORD dwErrorControl
,
116 LPCWSTR lpBinaryPathName
,
117 LPCWSTR lpLoadOrderGroup
,
119 LPCWSTR lpDependencies
,
120 LPCWSTR lpServiceStartName
,
122 LPCWSTR lpDisplayName
)
125 DWORD dwDependenciesLength
= 0;
129 DPRINT("ChangeServiceConfigW() called\n");
131 /* Calculate the Dependencies length*/
132 if (lpDependencies
!= NULL
)
134 lpStr
= (LPWSTR
)lpDependencies
;
137 dwLength
= wcslen(lpStr
) + 1;
138 dwDependenciesLength
+= dwLength
;
139 lpStr
= lpStr
+ dwLength
;
141 dwDependenciesLength
++;
144 /* FIXME: Encrypt the password */
148 /* Call to services.exe using RPC */
149 dwError
= ScmrChangeServiceConfigW(BindingHandle
,
150 (unsigned int)hService
,
154 (LPWSTR
)lpBinaryPathName
,
155 (LPWSTR
)lpLoadOrderGroup
,
157 (LPWSTR
)lpDependencies
,
158 dwDependenciesLength
,
159 (LPWSTR
)lpServiceStartName
,
160 NULL
, /* FIXME: lpPassword */
161 0, /* FIXME: dwPasswordLength */
162 (LPWSTR
)lpDisplayName
);
163 if (dwError
!= ERROR_SUCCESS
)
165 DPRINT1("ScmrChangeServiceConfigW() failed (Error %lu)\n", dwError
);
166 SetLastError(dwError
);
174 /**********************************************************************
180 CloseServiceHandle(SC_HANDLE hSCObject
)
184 DPRINT("CloseServiceHandle() called\n");
188 /* Call to services.exe using RPC */
189 dwError
= ScmrCloseServiceHandle(BindingHandle
,
190 (unsigned int)hSCObject
);
193 DPRINT1("ScmrCloseServiceHandle() failed (Error %lu)\n", dwError
);
194 SetLastError(dwError
);
198 DPRINT("CloseServiceHandle() done\n");
204 /**********************************************************************
210 ControlService(SC_HANDLE hService
,
212 LPSERVICE_STATUS lpServiceStatus
)
216 DPRINT("ControlService(%x, %x, %p)\n",
217 hService
, dwControl
, lpServiceStatus
);
221 /* Call to services.exe using RPC */
222 dwError
= ScmrControlService(BindingHandle
,
223 (unsigned int)hService
,
226 if (dwError
!= ERROR_SUCCESS
)
228 DPRINT1("ScmrControlService() failed (Error %lu)\n", dwError
);
229 SetLastError(dwError
);
233 DPRINT("ControlService() done\n");
239 /**********************************************************************
245 ControlServiceEx(IN SC_HANDLE hService
,
247 IN DWORD dwInfoLevel
,
248 IN OUT PVOID pControlParams
)
250 DPRINT1("ControlServiceEx(0x%p, 0x%x, 0x%x, 0x%p) UNIMPLEMENTED!\n",
251 hService
, dwControl
, dwInfoLevel
, pControlParams
);
252 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
258 /**********************************************************************
265 CreateServiceA(SC_HANDLE hSCManager
,
266 LPCSTR lpServiceName
,
267 LPCSTR lpDisplayName
,
268 DWORD dwDesiredAccess
,
271 DWORD dwErrorControl
,
272 LPCSTR lpBinaryPathName
,
273 LPCSTR lpLoadOrderGroup
,
275 LPCSTR lpDependencies
,
276 LPCSTR lpServiceStartName
,
279 SC_HANDLE RetVal
= NULL
;
280 LPWSTR lpServiceNameW
= NULL
;
281 LPWSTR lpDisplayNameW
= NULL
;
282 LPWSTR lpBinaryPathNameW
= NULL
;
283 LPWSTR lpLoadOrderGroupW
= NULL
;
284 LPWSTR lpDependenciesW
= NULL
;
285 LPWSTR lpServiceStartNameW
= NULL
;
286 LPWSTR lpPasswordW
= NULL
;
287 DWORD dwDependenciesLength
= 0;
291 int len
= MultiByteToWideChar(CP_ACP
, 0, lpServiceName
, -1, NULL
, 0);
292 lpServiceNameW
= HeapAlloc(GetProcessHeap(), 0, len
* sizeof(WCHAR
));
295 SetLastError(ERROR_NOT_ENOUGH_MEMORY
);
298 MultiByteToWideChar(CP_ACP
, 0, lpServiceName
, -1, lpServiceNameW
, len
);
300 len
= MultiByteToWideChar(CP_ACP
, 0, lpDisplayName
, -1, NULL
, 0);
301 lpDisplayNameW
= HeapAlloc(GetProcessHeap(), 0, len
* sizeof(WCHAR
));
304 SetLastError(ERROR_NOT_ENOUGH_MEMORY
);
307 MultiByteToWideChar(CP_ACP
, 0, lpDisplayName
, -1, lpDisplayNameW
, len
);
309 len
= MultiByteToWideChar(CP_ACP
, 0, lpBinaryPathName
, -1, NULL
, 0);
310 lpBinaryPathNameW
= HeapAlloc(GetProcessHeap(), 0, len
* sizeof(WCHAR
));
311 if (!lpBinaryPathNameW
)
313 SetLastError(ERROR_NOT_ENOUGH_MEMORY
);
316 MultiByteToWideChar(CP_ACP
, 0, lpDisplayName
, -1, lpBinaryPathNameW
, len
);
318 len
= MultiByteToWideChar(CP_ACP
, 0, lpLoadOrderGroup
, -1, NULL
, 0);
319 lpLoadOrderGroupW
= HeapAlloc(GetProcessHeap(), 0, len
* sizeof(WCHAR
));
320 if (!lpLoadOrderGroupW
)
322 SetLastError(ERROR_NOT_ENOUGH_MEMORY
);
325 MultiByteToWideChar(CP_ACP
, 0, lpLoadOrderGroup
, -1, lpLoadOrderGroupW
, len
);
327 if (lpDependencies
!= NULL
)
329 lpStr
= (LPSTR
)lpDependencies
;
332 dwLength
= strlen(lpStr
) + 1;
333 dwDependenciesLength
+= dwLength
;
334 lpStr
= lpStr
+ dwLength
;
336 dwDependenciesLength
++;
339 lpDependenciesW
= HeapAlloc(GetProcessHeap(), 0, dwDependenciesLength
* sizeof(WCHAR
));
340 if (!lpDependenciesW
)
342 SetLastError(ERROR_NOT_ENOUGH_MEMORY
);
345 MultiByteToWideChar(CP_ACP
, 0, lpDependencies
, -1, lpDependenciesW
, dwDependenciesLength
);
347 len
= MultiByteToWideChar(CP_ACP
, 0, lpServiceStartName
, -1, NULL
, 0);
348 lpServiceStartName
= HeapAlloc(GetProcessHeap(), 0, len
* sizeof(WCHAR
));
349 if (!lpServiceStartNameW
)
351 SetLastError(ERROR_NOT_ENOUGH_MEMORY
);
354 MultiByteToWideChar(CP_ACP
, 0, lpServiceStartName
, -1, lpServiceStartNameW
, len
);
356 len
= MultiByteToWideChar(CP_ACP
, 0, lpPassword
, -1, NULL
, 0);
357 lpPasswordW
= HeapAlloc(GetProcessHeap(), 0, len
* sizeof(WCHAR
));
360 SetLastError(ERROR_NOT_ENOUGH_MEMORY
);
363 MultiByteToWideChar(CP_ACP
, 0, lpPassword
, -1, lpPasswordW
, len
);
365 RetVal
= CreateServiceW(hSCManager
,
380 HeapFree(GetProcessHeap(), 0, lpServiceNameW
);
381 HeapFree(GetProcessHeap(), 0, lpDisplayNameW
);
382 HeapFree(GetProcessHeap(), 0, lpBinaryPathNameW
);
383 HeapFree(GetProcessHeap(), 0, lpLoadOrderGroupW
);
384 HeapFree(GetProcessHeap(), 0, lpDependenciesW
);
385 HeapFree(GetProcessHeap(), 0, lpServiceStartNameW
);
386 HeapFree(GetProcessHeap(), 0, lpPasswordW
);
392 /**********************************************************************
398 CreateServiceW(SC_HANDLE hSCManager
,
399 LPCWSTR lpServiceName
,
400 LPCWSTR lpDisplayName
,
401 DWORD dwDesiredAccess
,
404 DWORD dwErrorControl
,
405 LPCWSTR lpBinaryPathName
,
406 LPCWSTR lpLoadOrderGroup
,
408 LPCWSTR lpDependencies
,
409 LPCWSTR lpServiceStartName
,
412 SC_HANDLE hService
= NULL
;
414 DWORD dwDependenciesLength
= 0;
418 DPRINT1("CreateServiceW() called\n");
420 /* Calculate the Dependencies length*/
421 if (lpDependencies
!= NULL
)
423 lpStr
= (LPWSTR
)lpDependencies
;
426 dwLength
= wcslen(lpStr
) + 1;
427 dwDependenciesLength
+= dwLength
;
428 lpStr
= lpStr
+ dwLength
;
430 dwDependenciesLength
++;
433 /* FIXME: Encrypt the password */
437 /* Call to services.exe using RPC */
438 dwError
= ScmrCreateServiceW(BindingHandle
,
439 (unsigned int)hSCManager
,
440 (LPWSTR
)lpServiceName
,
441 (LPWSTR
)lpDisplayName
,
446 (LPWSTR
)lpBinaryPathName
,
447 (LPWSTR
)lpLoadOrderGroup
,
449 (LPWSTR
)lpDependencies
,
450 dwDependenciesLength
,
451 (LPWSTR
)lpServiceStartName
,
452 NULL
, /* FIXME: lpPassword */
453 0, /* FIXME: dwPasswordLength */
454 (unsigned int *)&hService
);
455 if (dwError
!= ERROR_SUCCESS
)
457 DPRINT1("ScmrCreateServiceW() failed (Error %lu)\n", dwError
);
458 SetLastError(dwError
);
466 /**********************************************************************
472 DeleteService(SC_HANDLE hService
)
476 DPRINT("DeleteService(%x)\n", hService
);
480 /* Call to services.exe using RPC */
481 dwError
= ScmrDeleteService(BindingHandle
,
482 (unsigned int)hService
);
483 if (dwError
!= ERROR_SUCCESS
)
485 DPRINT1("ScmrDeleteService() failed (Error %lu)\n", dwError
);
486 SetLastError(dwError
);
494 /**********************************************************************
495 * EnumDependentServicesA
501 EnumDependentServicesA(
503 DWORD dwServiceState
,
504 LPENUM_SERVICE_STATUSA lpServices
,
506 LPDWORD pcbBytesNeeded
,
507 LPDWORD lpServicesReturned
)
509 DPRINT1("EnumDependentServicesA is unimplemented\n");
510 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
515 /**********************************************************************
516 * EnumDependentServicesW
522 EnumDependentServicesW(SC_HANDLE hService
,
523 DWORD dwServiceState
,
524 LPENUM_SERVICE_STATUSW lpServices
,
526 LPDWORD pcbBytesNeeded
,
527 LPDWORD lpServicesReturned
)
529 DPRINT1("EnumDependentServicesW is unimplemented\n");
530 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
535 /**********************************************************************
553 DPRINT1("EnumServiceGroupW is unimplemented\n");
554 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
559 /**********************************************************************
560 * EnumServicesStatusA
567 SC_HANDLE hSCManager
,
569 DWORD dwServiceState
,
570 LPENUM_SERVICE_STATUSA lpServices
,
572 LPDWORD pcbBytesNeeded
,
573 LPDWORD lpServicesReturned
,
574 LPDWORD lpResumeHandle
)
576 DPRINT1("EnumServicesStatusA is unimplemented\n");
577 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
582 /**********************************************************************
583 * EnumServicesStatusW
589 EnumServicesStatusW(SC_HANDLE hSCManager
,
591 DWORD dwServiceState
,
592 LPENUM_SERVICE_STATUSW lpServices
,
594 LPDWORD pcbBytesNeeded
,
595 LPDWORD lpServicesReturned
,
596 LPDWORD lpResumeHandle
)
599 DWORD dwError
= ERROR_SUCCESS
;
601 DPRINT1("EnumServicesStatusW() called\n");
605 dwError
= ScmrEnumServicesStatusW(BindingHandle
,
606 (unsigned int)hSCManager
,
609 (unsigned char *)lpServices
,
614 if (dwError
!= ERROR_SUCCESS
)
616 DPRINT1("ScmrEnumServicesStatusW() failed (Error %lu)\n", dwError
);
617 SetLastError(dwError
);
623 DPRINT1("ScmrEnumServicesStatusW() done\n");
628 DPRINT1("EnumServicesStatusW is unimplemented\n");
629 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
634 /**********************************************************************
635 * EnumServicesStatusExA
641 EnumServicesStatusExA(SC_HANDLE hSCManager
,
642 SC_ENUM_TYPE InfoLevel
,
644 DWORD dwServiceState
,
647 LPDWORD pcbBytesNeeded
,
648 LPDWORD lpServicesReturned
,
649 LPDWORD lpResumeHandle
,
652 DPRINT1("EnumServicesStatusExA is unimplemented\n");
653 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
658 /**********************************************************************
659 * EnumServicesStatusExW
665 EnumServicesStatusExW(SC_HANDLE hSCManager
,
666 SC_ENUM_TYPE InfoLevel
,
668 DWORD dwServiceState
,
671 LPDWORD pcbBytesNeeded
,
672 LPDWORD lpServicesReturned
,
673 LPDWORD lpResumeHandle
,
674 LPCWSTR pszGroupName
)
676 DPRINT1("EnumServicesStatusExW is unimplemented\n");
677 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
682 /**********************************************************************
683 * GetServiceDisplayNameA
689 GetServiceDisplayNameA(
690 SC_HANDLE hSCManager
,
691 LPCSTR lpServiceName
,
695 DPRINT1("GetServiceDisplayNameA is unimplemented\n");
696 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
701 /**********************************************************************
702 * GetServiceDisplayNameW
707 GetServiceDisplayNameW(SC_HANDLE hSCManager
,
708 LPCWSTR lpServiceName
,
709 LPWSTR lpDisplayName
,
714 DPRINT("GetServiceDisplayNameW() called\n");
718 dwError
= ScmrGetServiceDisplayNameW(BindingHandle
,
719 (unsigned int)hSCManager
,
720 (LPWSTR
)lpServiceName
,
723 if (dwError
!= ERROR_SUCCESS
)
725 DPRINT1("ScmrGetServiceDisplayNameW() failed (Error %lu)\n", dwError
);
726 SetLastError(dwError
);
736 /**********************************************************************
744 SC_HANDLE hSCManager
,
745 LPCSTR lpDisplayName
,
749 DPRINT1("GetServiceKeyNameA is unimplemented\n");
750 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
755 /**********************************************************************
761 GetServiceKeyNameW(SC_HANDLE hSCManager
,
762 LPCWSTR lpDisplayName
,
763 LPWSTR lpServiceName
,
768 DPRINT("GetServiceKeyNameW() called\n");
772 dwError
= ScmrGetServiceKeyNameW(BindingHandle
,
773 (unsigned int)hSCManager
,
774 (LPWSTR
)lpDisplayName
,
777 if (dwError
!= ERROR_SUCCESS
)
779 DPRINT1("ScmrGetServiceKeyNameW() failed (Error %lu)\n", dwError
);
780 SetLastError(dwError
);
790 /**********************************************************************
791 * LockServiceDatabase
796 LockServiceDatabase(SC_HANDLE hSCManager
)
801 DPRINT("LockServiceDatabase(%x)\n", hSCManager
);
805 /* Call to services.exe using RPC */
806 dwError
= ScmrLockServiceDatabase(BindingHandle
,
807 (unsigned int)hSCManager
,
808 (unsigned int *)&hLock
);
809 if (dwError
!= ERROR_SUCCESS
)
811 DPRINT1("ScmrLockServiceDatabase() failed (Error %lu)\n", dwError
);
812 SetLastError(dwError
);
816 DPRINT("hLock = %p\n", hLock
);
823 WaitForSCManager(VOID
)
827 DPRINT("WaitForSCManager() called\n");
829 /* Try to open the existing event */
830 hEvent
= OpenEventW(SYNCHRONIZE
,
832 L
"SvcctrlStartEvent_A3725DX");
835 if (GetLastError() != ERROR_FILE_NOT_FOUND
)
838 /* Try to create a new event */
839 hEvent
= CreateEventW(NULL
,
842 L
"SvcctrlStartEvent_A3725DX");
845 /* Try to open the existing event again */
846 hEvent
= OpenEventW(SYNCHRONIZE
,
848 L
"SvcctrlStartEvent_A3725DX");
854 /* Wait for 3 minutes */
855 WaitForSingleObject(hEvent
, 180000);
858 DPRINT("ScmWaitForSCManager() done\n");
862 /**********************************************************************
868 OpenSCManagerA(LPCSTR lpMachineName
,
869 LPCSTR lpDatabaseName
,
870 DWORD dwDesiredAccess
)
872 SC_HANDLE hScm
= NULL
;
875 DPRINT("OpenSCManagerA(%s, %s, %lx)\n",
876 lpMachineName
, lpDatabaseName
, dwDesiredAccess
);
882 /* Call to services.exe using RPC */
883 dwError
= ScmrOpenSCManagerA(BindingHandle
,
884 (LPSTR
)lpMachineName
,
885 (LPSTR
)lpDatabaseName
,
887 (unsigned int*)&hScm
);
888 if (dwError
!= ERROR_SUCCESS
)
890 DPRINT1("ScmrOpenSCManagerA() failed (Error %lu)\n", dwError
);
891 SetLastError(dwError
);
895 DPRINT("hScm = %p\n", hScm
);
901 /**********************************************************************
907 OpenSCManagerW(LPCWSTR lpMachineName
,
908 LPCWSTR lpDatabaseName
,
909 DWORD dwDesiredAccess
)
911 SC_HANDLE hScm
= NULL
;
914 DPRINT("OpenSCManagerW(%S, %S, %lx)\n",
915 lpMachineName
, lpDatabaseName
, dwDesiredAccess
);
921 /* Call to services.exe using RPC */
922 dwError
= ScmrOpenSCManagerW(BindingHandle
,
923 (LPWSTR
)lpMachineName
,
924 (LPWSTR
)lpDatabaseName
,
926 (unsigned int*)&hScm
);
927 if (dwError
!= ERROR_SUCCESS
)
929 DPRINT1("ScmrOpenSCManagerW() failed (Error %lu)\n", dwError
);
930 SetLastError(dwError
);
934 DPRINT("hScm = %p\n", hScm
);
940 /**********************************************************************
946 OpenServiceA(SC_HANDLE hSCManager
,
947 LPCSTR lpServiceName
,
948 DWORD dwDesiredAccess
)
950 SC_HANDLE hService
= NULL
;
953 DPRINT("OpenServiceA(%p, %s, %lx)\n",
954 hSCManager
, lpServiceName
, dwDesiredAccess
);
958 /* Call to services.exe using RPC */
959 dwError
= ScmrOpenServiceA(BindingHandle
,
960 (unsigned int)hSCManager
,
961 (LPSTR
)lpServiceName
,
963 (unsigned int*)&hService
);
964 if (dwError
!= ERROR_SUCCESS
)
966 DPRINT1("ScmrOpenServiceA() failed (Error %lu)\n", dwError
);
967 SetLastError(dwError
);
971 DPRINT("hService = %p\n", hService
);
977 /**********************************************************************
983 OpenServiceW(SC_HANDLE hSCManager
,
984 LPCWSTR lpServiceName
,
985 DWORD dwDesiredAccess
)
987 SC_HANDLE hService
= NULL
;
990 DPRINT("OpenServiceW(%p, %S, %lx)\n",
991 hSCManager
, lpServiceName
, dwDesiredAccess
);
995 /* Call to services.exe using RPC */
996 dwError
= ScmrOpenServiceW(BindingHandle
,
997 (unsigned int)hSCManager
,
998 (LPWSTR
)lpServiceName
,
1000 (unsigned int*)&hService
);
1001 if (dwError
!= ERROR_SUCCESS
)
1003 DPRINT1("ScmrOpenServiceW() failed (Error %lu)\n", dwError
);
1004 SetLastError(dwError
);
1008 DPRINT("hService = %p\n", hService
);
1014 /**********************************************************************
1015 * QueryServiceConfigA
1021 QueryServiceConfigA(
1023 LPQUERY_SERVICE_CONFIGA lpServiceConfig
,
1025 LPDWORD pcbBytesNeeded
)
1027 DPRINT1("QueryServiceConfigA is unimplemented\n");
1028 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
1033 /**********************************************************************
1034 * QueryServiceConfigW
1039 QueryServiceConfigW(SC_HANDLE hService
,
1040 LPQUERY_SERVICE_CONFIGW lpServiceConfig
,
1042 LPDWORD pcbBytesNeeded
)
1046 DPRINT("QueryServiceConfigW(%p, %p, %lu, %p)\n",
1047 hService
, lpServiceConfig
, cbBufSize
, pcbBytesNeeded
);
1051 /* Call to services.exe using RPC */
1052 dwError
= ScmrQueryServiceConfigW(BindingHandle
,
1053 (unsigned int)hService
,
1054 (unsigned char *)lpServiceConfig
,
1057 if (dwError
!= ERROR_SUCCESS
)
1059 DPRINT("ScmrQueryServiceConfigW() failed (Error %lu)\n", dwError
);
1060 SetLastError(dwError
);
1064 /* Adjust the pointers */
1065 if (lpServiceConfig
->lpBinaryPathName
)
1066 lpServiceConfig
->lpBinaryPathName
=
1067 (LPWSTR
)((ULONG_PTR
)lpServiceConfig
+
1068 (ULONG_PTR
)lpServiceConfig
->lpBinaryPathName
);
1070 if (lpServiceConfig
->lpLoadOrderGroup
)
1071 lpServiceConfig
->lpLoadOrderGroup
=
1072 (LPWSTR
)((ULONG_PTR
)lpServiceConfig
+
1073 (ULONG_PTR
)lpServiceConfig
->lpLoadOrderGroup
);
1075 if (lpServiceConfig
->lpDependencies
)
1076 lpServiceConfig
->lpDependencies
=
1077 (LPWSTR
)((ULONG_PTR
)lpServiceConfig
+
1078 (ULONG_PTR
)lpServiceConfig
->lpDependencies
);
1080 if (lpServiceConfig
->lpServiceStartName
)
1081 lpServiceConfig
->lpServiceStartName
=
1082 (LPWSTR
)((ULONG_PTR
)lpServiceConfig
+
1083 (ULONG_PTR
)lpServiceConfig
->lpServiceStartName
);
1085 if (lpServiceConfig
->lpDisplayName
)
1086 lpServiceConfig
->lpDisplayName
=
1087 (LPWSTR
)((ULONG_PTR
)lpServiceConfig
+
1088 (ULONG_PTR
)lpServiceConfig
->lpDisplayName
);
1090 DPRINT("QueryServiceConfigW() done\n");
1096 /**********************************************************************
1097 * QueryServiceConfig2A
1103 QueryServiceConfig2A(
1108 LPDWORD pcbBytesNeeded
)
1110 DPRINT1("QueryServiceConfig2A is unimplemented\n");
1115 /**********************************************************************
1116 * QueryServiceConfig2W
1122 QueryServiceConfig2W(
1127 LPDWORD pcbBytesNeeded
)
1129 DPRINT1("QueryServiceConfig2W is unimplemented\n");
1134 /**********************************************************************
1135 * QueryServiceLockStatusA
1141 QueryServiceLockStatusA(
1142 SC_HANDLE hSCManager
,
1143 LPQUERY_SERVICE_LOCK_STATUSA lpLockStatus
,
1145 LPDWORD pcbBytesNeeded
)
1147 DPRINT1("QueryServiceLockStatusA is unimplemented\n");
1148 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
1153 /**********************************************************************
1154 * QueryServiceLockStatusW
1160 QueryServiceLockStatusW(
1161 SC_HANDLE hSCManager
,
1162 LPQUERY_SERVICE_LOCK_STATUSW lpLockStatus
,
1164 LPDWORD pcbBytesNeeded
)
1166 DPRINT1("QueryServiceLockStatusW is unimplemented\n");
1167 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
1172 /**********************************************************************
1173 * QueryServiceObjectSecurity
1178 QueryServiceObjectSecurity(SC_HANDLE hService
,
1179 SECURITY_INFORMATION dwSecurityInformation
,
1180 PSECURITY_DESCRIPTOR lpSecurityDescriptor
,
1182 LPDWORD pcbBytesNeeded
)
1186 DPRINT("QueryServiceObjectSecurity(%p, %lu, %p)\n",
1187 hService
, dwSecurityInformation
, lpSecurityDescriptor
);
1191 /* Call to services.exe using RPC */
1192 dwError
= ScmrQueryServiceObjectSecurity(BindingHandle
,
1193 (unsigned int)hService
,
1194 dwSecurityInformation
,
1195 (unsigned char *)lpSecurityDescriptor
,
1198 if (dwError
!= ERROR_SUCCESS
)
1200 DPRINT1("QueryServiceObjectSecurity() failed (Error %lu)\n", dwError
);
1201 SetLastError(dwError
);
1209 /**********************************************************************
1210 * QueryServiceStatus
1215 QueryServiceStatus(SC_HANDLE hService
,
1216 LPSERVICE_STATUS lpServiceStatus
)
1220 DPRINT("QueryServiceStatus(%p, %p)\n",
1221 hService
, lpServiceStatus
);
1225 /* Call to services.exe using RPC */
1226 dwError
= ScmrQueryServiceStatus(BindingHandle
,
1227 (unsigned int)hService
,
1229 if (dwError
!= ERROR_SUCCESS
)
1231 DPRINT1("ScmrQueryServiceStatus() failed (Error %lu)\n", dwError
);
1232 SetLastError(dwError
);
1240 /**********************************************************************
1241 * QueryServiceStatusEx
1247 QueryServiceStatusEx(SC_HANDLE hService
,
1248 SC_STATUS_TYPE InfoLevel
,
1251 LPDWORD pcbBytesNeeded
)
1253 DPRINT1("QueryServiceStatusEx is unimplemented\n");
1254 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
1259 /**********************************************************************
1260 * SetServiceObjectSecurity
1265 SetServiceObjectSecurity(SC_HANDLE hService
,
1266 SECURITY_INFORMATION dwSecurityInformation
,
1267 PSECURITY_DESCRIPTOR lpSecurityDescriptor
)
1269 PSECURITY_DESCRIPTOR SelfRelativeSD
= NULL
;
1275 Status
= RtlMakeSelfRelativeSD(lpSecurityDescriptor
,
1278 if (Status
!= STATUS_BUFFER_TOO_SMALL
)
1280 SetLastError(ERROR_INVALID_PARAMETER
);
1284 SelfRelativeSD
= HeapAlloc(GetProcessHeap(), 0, Length
);
1285 if (SelfRelativeSD
== NULL
)
1287 SetLastError(ERROR_NOT_ENOUGH_MEMORY
);
1291 Status
= RtlMakeSelfRelativeSD(lpSecurityDescriptor
,
1294 if (!NT_SUCCESS(Status
))
1296 HeapFree(GetProcessHeap(), 0, SelfRelativeSD
);
1297 SetLastError(RtlNtStatusToDosError(Status
));
1303 /* Call to services.exe using RPC */
1304 dwError
= ScmrSetServiceObjectSecurity(BindingHandle
,
1305 (unsigned int)hService
,
1306 dwSecurityInformation
,
1307 (unsigned char *)SelfRelativeSD
,
1310 HeapFree(GetProcessHeap(), 0, SelfRelativeSD
);
1312 if (dwError
!= ERROR_SUCCESS
)
1314 DPRINT1("ScmrServiceObjectSecurity() failed (Error %lu)\n", dwError
);
1315 SetLastError(dwError
);
1323 /**********************************************************************
1332 DWORD dwNumServiceArgs
,
1333 LPCSTR
*lpServiceArgVectors
)
1335 DPRINT1("StartServiceA is unimplemented\n");
1336 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
1341 /**********************************************************************
1350 DWORD dwNumServiceArgs
,
1351 LPCWSTR
*lpServiceArgVectors
)
1353 DPRINT1("StartServiceW is unimplemented, but returns success...\n");
1354 //SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
1360 /**********************************************************************
1361 * UnlockServiceDatabase
1366 UnlockServiceDatabase(SC_LOCK ScLock
)
1370 DPRINT("UnlockServiceDatabase(%x)\n", ScLock
);
1374 /* Call to services.exe using RPC */
1375 dwError
= ScmrUnlockServiceDatabase(BindingHandle
,
1376 (unsigned int)ScLock
);
1377 if (dwError
!= ERROR_SUCCESS
)
1379 DPRINT1("ScmrUnlockServiceDatabase() failed (Error %lu)\n", dwError
);
1380 SetLastError(dwError
);
1388 /**********************************************************************
1389 * NotifyBootConfigStatus
1394 NotifyBootConfigStatus(BOOL BootAcceptable
)
1398 DPRINT1("NotifyBootConfigStatus()\n");
1402 /* Call to services.exe using RPC */
1403 dwError
= ScmrNotifyBootConfigStatus(BindingHandle
,
1405 if (dwError
!= ERROR_SUCCESS
)
1407 DPRINT1("NotifyBootConfigStatus() failed (Error %lu)\n", dwError
);
1408 SetLastError(dwError
);
1416 void __RPC_FAR
* __RPC_USER
midl_user_allocate(size_t len
)
1418 return HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, len
);
1422 void __RPC_USER
midl_user_free(void __RPC_FAR
* ptr
)
1424 HeapFree(GetProcessHeap(), 0, ptr
);