1de3e6a70a504a9867de63c273cd001fd36d7895
[reactos.git] / reactos / lib / advapi32 / service / scm.c
1 /*
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
7 * Eric Kohl
8 * UPDATE HISTORY:
9 * 19990413 EA created
10 * 19990515 EA
11 */
12
13 /* INCLUDES ******************************************************************/
14
15 #include <advapi32.h>
16 #include "svcctl_c.h"
17
18 #define NDEBUG
19 #include <debug.h>
20
21 /* FUNCTIONS *****************************************************************/
22
23 handle_t BindingHandle = NULL;
24
25 static VOID
26 HandleBind(VOID)
27 {
28 LPWSTR pszStringBinding;
29 RPC_STATUS status;
30
31 if (BindingHandle != NULL)
32 return;
33
34 status = RpcStringBindingComposeW(NULL,
35 L"ncacn_np",
36 NULL,
37 L"\\pipe\\ntsvcs",
38 NULL,
39 &pszStringBinding);
40 if (status)
41 {
42 DPRINT1("RpcStringBindingCompose returned 0x%x\n", status);
43 return;
44 }
45
46 /* Set the binding handle that will be used to bind to the server. */
47 status = RpcBindingFromStringBindingW(pszStringBinding,
48 &BindingHandle);
49 if (status)
50 {
51 DPRINT1("RpcBindingFromStringBinding returned 0x%x\n", status);
52 }
53
54 status = RpcStringFreeW(&pszStringBinding);
55 if (status)
56 {
57 DPRINT1("RpcStringFree returned 0x%x\n", status);
58 }
59 }
60
61
62 #if 0
63 static VOID
64 HandleUnbind(VOID)
65 {
66 RPC_STATUS status;
67
68 if (BindingHandle == NULL)
69 return;
70
71 status = RpcBindingFree(&BindingHandle);
72 if (status)
73 {
74 DPRINT1("RpcBindingFree returned 0x%x\n", status);
75 }
76 }
77 #endif
78
79
80 /**********************************************************************
81 * ChangeServiceConfigA
82 *
83 * @unimplemented
84 */
85 BOOL
86 STDCALL
87 ChangeServiceConfigA(
88 SC_HANDLE hService,
89 DWORD dwServiceType,
90 DWORD dwStartType,
91 DWORD dwErrorControl,
92 LPCSTR lpBinaryPathName,
93 LPCSTR lpLoadOrderGroup,
94 LPDWORD lpdwTagId,
95 LPCSTR lpDependencies,
96 LPCSTR lpServiceStartName,
97 LPCSTR lpPassword,
98 LPCSTR lpDisplayName)
99 {
100 DPRINT1("ChangeServiceConfigA is unimplemented\n");
101 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
102 return FALSE;
103 }
104
105
106 /**********************************************************************
107 * ChangeServiceConfigW
108 *
109 * @unimplemented
110 */
111 BOOL
112 STDCALL
113 ChangeServiceConfigW(
114 SC_HANDLE hService,
115 DWORD dwServiceType,
116 DWORD dwStartType,
117 DWORD dwErrorControl,
118 LPCWSTR lpBinaryPathName,
119 LPCWSTR lpLoadOrderGroup,
120 LPDWORD lpdwTagId,
121 LPCWSTR lpDependencies,
122 LPCWSTR lpServiceStartName,
123 LPCWSTR lpPassword,
124 LPCWSTR lpDisplayName)
125 {
126 DPRINT1("ChangeServiceConfigW is unimplemented\n");
127 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
128 return FALSE;
129 }
130
131
132 /**********************************************************************
133 * CloseServiceHandle
134 *
135 * @implemented
136 */
137 BOOL STDCALL
138 CloseServiceHandle(SC_HANDLE hSCObject)
139 {
140 DWORD dwError;
141
142 DPRINT("CloseServiceHandle() called\n");
143
144 HandleBind();
145
146 /* Call to services.exe using RPC */
147 dwError = ScmrCloseServiceHandle(BindingHandle,
148 (unsigned int)hSCObject);
149 if (dwError)
150 {
151 DPRINT1("ScmrCloseServiceHandle() failed (Error %lu)\n", dwError);
152 SetLastError(dwError);
153 return FALSE;
154 }
155
156 DPRINT("CloseServiceHandle() done\n");
157
158 return TRUE;
159 }
160
161
162 /**********************************************************************
163 * ControlService
164 *
165 * @unimplemented
166 */
167 BOOL STDCALL
168 ControlService(SC_HANDLE hService,
169 DWORD dwControl,
170 LPSERVICE_STATUS lpServiceStatus)
171 {
172 DWORD dwError;
173
174 DPRINT("ControlService(%x, %x, %p)\n",
175 hService, dwControl, lpServiceStatus);
176
177 HandleBind();
178
179 /* Call to services.exe using RPC */
180 dwError = ScmrControlService(BindingHandle,
181 (unsigned int)hService,
182 dwControl,
183 lpServiceStatus);
184 if (dwError != ERROR_SUCCESS)
185 {
186 DPRINT1("ScmrControlService() failed (Error %lu)\n", dwError);
187 SetLastError(dwError);
188 return FALSE;
189 }
190
191 DPRINT("ControlService() done\n");
192
193 return TRUE;
194 }
195
196
197 /**********************************************************************
198 * CreateServiceA
199 *
200 * @unimplemented
201 */
202 SC_HANDLE
203 STDCALL
204 CreateServiceA(
205 SC_HANDLE hSCManager,
206 LPCSTR lpServiceName,
207 LPCSTR lpDisplayName,
208 DWORD dwDesiredAccess,
209 DWORD dwServiceType,
210 DWORD dwStartType,
211 DWORD dwErrorControl,
212 LPCSTR lpBinaryPathName,
213 LPCSTR lpLoadOrderGroup,
214 LPDWORD lpdwTagId,
215 LPCSTR lpDependencies,
216 LPCSTR lpServiceStartName,
217 LPCSTR lpPassword)
218 {
219 DPRINT1("CreateServiceA is unimplemented, but returning INVALID_HANDLE_VALUE instead of NULL\n");
220 return INVALID_HANDLE_VALUE;
221 }
222
223
224 /**********************************************************************
225 * CreateServiceW
226 *
227 * @unimplemented
228 */
229 SC_HANDLE
230 STDCALL
231 CreateServiceW(
232 SC_HANDLE hSCManager,
233 LPCWSTR lpServiceName,
234 LPCWSTR lpDisplayName,
235 DWORD dwDesiredAccess,
236 DWORD dwServiceType,
237 DWORD dwStartType,
238 DWORD dwErrorControl,
239 LPCWSTR lpBinaryPathName,
240 LPCWSTR lpLoadOrderGroup,
241 LPDWORD lpdwTagId,
242 LPCWSTR lpDependencies,
243 LPCWSTR lpServiceStartName,
244 LPCWSTR lpPassword)
245 {
246 DPRINT1("CreateServiceW is unimplemented, but returning INVALID_HANDLE_VALUE instead of NULL\n");
247 return INVALID_HANDLE_VALUE;
248 }
249
250
251 /**********************************************************************
252 * DeleteService
253 *
254 * @implemented
255 */
256 BOOL STDCALL
257 DeleteService(SC_HANDLE hService)
258 {
259 DWORD dwError;
260
261 DPRINT("DeleteService(%x)\n", hService);
262
263 HandleBind();
264
265 /* Call to services.exe using RPC */
266 dwError = ScmrDeleteService(BindingHandle,
267 (unsigned int)hService);
268 if (dwError != ERROR_SUCCESS)
269 {
270 DPRINT1("ScmrDeleteService() failed (Error %lu)\n", dwError);
271 SetLastError(dwError);
272 return FALSE;
273 }
274
275 return TRUE;
276 }
277
278
279 /**********************************************************************
280 * EnumDependentServicesA
281 *
282 * @unimplemented
283 */
284 BOOL
285 STDCALL
286 EnumDependentServicesA(
287 SC_HANDLE hService,
288 DWORD dwServiceState,
289 LPENUM_SERVICE_STATUSA lpServices,
290 DWORD cbBufSize,
291 LPDWORD pcbBytesNeeded,
292 LPDWORD lpServicesReturned)
293 {
294 DPRINT1("EnumDependentServicesA is unimplemented\n");
295 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
296 return FALSE;
297 }
298
299
300 /**********************************************************************
301 * EnumDependentServicesW
302 *
303 * @unimplemented
304 */
305 BOOL
306 STDCALL
307 EnumDependentServicesW(
308 SC_HANDLE hService,
309 DWORD dwServiceState,
310 LPENUM_SERVICE_STATUSW lpServices,
311 DWORD cbBufSize,
312 LPDWORD pcbBytesNeeded,
313 LPDWORD lpServicesReturned)
314 {
315 DPRINT1("EnumDependentServicesW is unimplemented\n");
316 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
317 return FALSE;
318 }
319
320
321 /**********************************************************************
322 * EnumServiceGroupW
323 *
324 * @unimplemented
325 */
326 BOOL
327 STDCALL
328 EnumServiceGroupW (
329 DWORD Unknown0,
330 DWORD Unknown1,
331 DWORD Unknown2,
332 DWORD Unknown3,
333 DWORD Unknown4,
334 DWORD Unknown5,
335 DWORD Unknown6,
336 DWORD Unknown7,
337 DWORD Unknown8)
338 {
339 DPRINT1("EnumServiceGroupW is unimplemented\n");
340 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
341 return FALSE;
342 }
343
344
345 /**********************************************************************
346 * EnumServicesStatusA
347 *
348 * @unimplemented
349 */
350 BOOL
351 STDCALL
352 EnumServicesStatusA (
353 SC_HANDLE hSCManager,
354 DWORD dwServiceType,
355 DWORD dwServiceState,
356 LPENUM_SERVICE_STATUSA lpServices,
357 DWORD cbBufSize,
358 LPDWORD pcbBytesNeeded,
359 LPDWORD lpServicesReturned,
360 LPDWORD lpResumeHandle)
361 {
362 DPRINT1("EnumServicesStatusA is unimplemented\n");
363 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
364 return FALSE;
365 }
366
367
368 /**********************************************************************
369 * EnumServicesStatusExA
370 *
371 * @unimplemented
372 */
373 BOOL
374 STDCALL
375 EnumServicesStatusExA(SC_HANDLE hSCManager,
376 SC_ENUM_TYPE InfoLevel,
377 DWORD dwServiceType,
378 DWORD dwServiceState,
379 LPBYTE lpServices,
380 DWORD cbBufSize,
381 LPDWORD pcbBytesNeeded,
382 LPDWORD lpServicesReturned,
383 LPDWORD lpResumeHandle,
384 LPCSTR pszGroupName)
385 {
386 DPRINT1("EnumServicesStatusExA is unimplemented\n");
387 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
388 return FALSE;
389 }
390
391
392 /**********************************************************************
393 * EnumServicesStatusExW
394 *
395 * @unimplemented
396 */
397 BOOL
398 STDCALL
399 EnumServicesStatusExW(SC_HANDLE hSCManager,
400 SC_ENUM_TYPE InfoLevel,
401 DWORD dwServiceType,
402 DWORD dwServiceState,
403 LPBYTE lpServices,
404 DWORD cbBufSize,
405 LPDWORD pcbBytesNeeded,
406 LPDWORD lpServicesReturned,
407 LPDWORD lpResumeHandle,
408 LPCWSTR pszGroupName)
409 {
410 DPRINT1("EnumServicesStatusExW is unimplemented\n");
411 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
412 return FALSE;
413 }
414
415
416 /**********************************************************************
417 * EnumServicesStatusW
418 *
419 * @unimplemented
420 */
421 BOOL
422 STDCALL
423 EnumServicesStatusW(
424 SC_HANDLE hSCManager,
425 DWORD dwServiceType,
426 DWORD dwServiceState,
427 LPENUM_SERVICE_STATUSW lpServices,
428 DWORD cbBufSize,
429 LPDWORD pcbBytesNeeded,
430 LPDWORD lpServicesReturned,
431 LPDWORD lpResumeHandle)
432 {
433 DPRINT1("EnumServicesStatusW is unimplemented\n");
434 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
435 return FALSE;
436 }
437
438
439 /**********************************************************************
440 * GetServiceDisplayNameA
441 *
442 * @unimplemented
443 */
444 BOOL
445 STDCALL
446 GetServiceDisplayNameA(
447 SC_HANDLE hSCManager,
448 LPCSTR lpServiceName,
449 LPSTR lpDisplayName,
450 LPDWORD lpcchBuffer)
451 {
452 DPRINT1("GetServiceDisplayNameA is unimplemented\n");
453 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
454 return FALSE;
455 }
456
457
458 /**********************************************************************
459 * GetServiceDisplayNameW
460 *
461 * @unimplemented
462 */
463 BOOL
464 STDCALL
465 GetServiceDisplayNameW(
466 SC_HANDLE hSCManager,
467 LPCWSTR lpServiceName,
468 LPWSTR lpDisplayName,
469 LPDWORD lpcchBuffer)
470 {
471 DPRINT1("GetServiceDisplayNameW is unimplemented\n");
472 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
473 return FALSE;
474 }
475
476
477 /**********************************************************************
478 * GetServiceKeyNameA
479 *
480 * @unimplemented
481 */
482 BOOL
483 STDCALL
484 GetServiceKeyNameA(
485 SC_HANDLE hSCManager,
486 LPCSTR lpDisplayName,
487 LPSTR lpServiceName,
488 LPDWORD lpcchBuffer)
489 {
490 DPRINT1("GetServiceKeyNameA is unimplemented\n");
491 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
492 return FALSE;
493 }
494
495
496 /**********************************************************************
497 * GetServiceKeyNameW
498 *
499 * @unimplemented
500 */
501 BOOL
502 STDCALL
503 GetServiceKeyNameW(
504 SC_HANDLE hSCManager,
505 LPCWSTR lpDisplayName,
506 LPWSTR lpServiceName,
507 LPDWORD lpcchBuffer)
508 {
509 DPRINT1("GetServiceKeyNameW is unimplemented\n");
510 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
511 return FALSE;
512 }
513
514
515 /**********************************************************************
516 * LockServiceDatabase
517 *
518 * @implemented
519 */
520 SC_LOCK STDCALL
521 LockServiceDatabase(SC_HANDLE hSCManager)
522 {
523 SC_LOCK hLock;
524 DWORD dwError;
525
526 DPRINT("LockServiceDatabase(%x)\n", hSCManager);
527
528 HandleBind();
529
530 /* Call to services.exe using RPC */
531 dwError = ScmrLockServiceDatabase(BindingHandle,
532 (unsigned int)hSCManager,
533 (unsigned int *)&hLock);
534 if (dwError != ERROR_SUCCESS)
535 {
536 DPRINT1("ScmrLockServiceDatabase() failed (Error %lu)\n", dwError);
537 SetLastError(dwError);
538 return NULL;
539 }
540
541 DPRINT("hLock = %p\n", hLock);
542
543 return hLock;
544 }
545
546
547 static VOID
548 WaitForSCManager(VOID)
549 {
550 HANDLE hEvent;
551
552 DPRINT("WaitForSCManager() called\n");
553
554 /* Try to open the existing event */
555 hEvent = OpenEventW(SYNCHRONIZE,
556 FALSE,
557 L"SvcctrlStartEvent_A3725DX");
558 if (hEvent == NULL)
559 {
560 if (GetLastError() != ERROR_FILE_NOT_FOUND)
561 return;
562
563 /* Try to create a new event */
564 hEvent = CreateEventW(NULL,
565 TRUE,
566 FALSE,
567 L"SvcctrlStartEvent_A3725DX");
568 if (hEvent == NULL)
569 {
570 /* Try to open the existing event again */
571 hEvent = OpenEventW(SYNCHRONIZE,
572 FALSE,
573 L"SvcctrlStartEvent_A3725DX");
574 if (hEvent == NULL)
575 return;
576 }
577 }
578
579 /* Wait for 3 minutes */
580 WaitForSingleObject(hEvent, 180000);
581 CloseHandle(hEvent);
582
583 DPRINT("ScmWaitForSCManager() done\n");
584 }
585
586
587 /**********************************************************************
588 * OpenSCManagerA
589 *
590 * @implemented
591 */
592 SC_HANDLE STDCALL
593 OpenSCManagerA(LPCSTR lpMachineName,
594 LPCSTR lpDatabaseName,
595 DWORD dwDesiredAccess)
596 {
597 SC_HANDLE hScm = NULL;
598 DWORD dwError;
599
600 DPRINT("OpenSCManagerA(%s, %s, %lx)\n",
601 lpMachineName, lpDatabaseName, dwDesiredAccess);
602
603 WaitForSCManager();
604
605 HandleBind();
606
607 /* Call to services.exe using RPC */
608 dwError = ScmrOpenSCManagerA(BindingHandle,
609 (LPSTR)lpMachineName,
610 (LPSTR)lpDatabaseName,
611 dwDesiredAccess,
612 (unsigned int*)&hScm);
613 if (dwError != ERROR_SUCCESS)
614 {
615 DPRINT1("ScmrOpenSCManagerA() failed (Error %lu)\n", dwError);
616 SetLastError(dwError);
617 return NULL;
618 }
619
620 DPRINT("hScm = %p\n", hScm);
621
622 return hScm;
623 }
624
625
626 /**********************************************************************
627 * OpenSCManagerW
628 *
629 * @implemented
630 */
631 SC_HANDLE STDCALL
632 OpenSCManagerW(LPCWSTR lpMachineName,
633 LPCWSTR lpDatabaseName,
634 DWORD dwDesiredAccess)
635 {
636 SC_HANDLE hScm = NULL;
637 DWORD dwError;
638
639 DPRINT("OpenSCManagerW(%S, %S, %lx)\n",
640 lpMachineName, lpDatabaseName, dwDesiredAccess);
641
642 WaitForSCManager();
643
644 HandleBind();
645
646 /* Call to services.exe using RPC */
647 dwError = ScmrOpenSCManagerW(BindingHandle,
648 (LPWSTR)lpMachineName,
649 (LPWSTR)lpDatabaseName,
650 dwDesiredAccess,
651 (unsigned int*)&hScm);
652 if (dwError != ERROR_SUCCESS)
653 {
654 DPRINT1("ScmrOpenSCManagerW() failed (Error %lu)\n", dwError);
655 SetLastError(dwError);
656 return NULL;
657 }
658
659 DPRINT("hScm = %p\n", hScm);
660
661 return hScm;
662 }
663
664
665 /**********************************************************************
666 * OpenServiceA
667 *
668 * @implemented
669 */
670 SC_HANDLE STDCALL
671 OpenServiceA(SC_HANDLE hSCManager,
672 LPCSTR lpServiceName,
673 DWORD dwDesiredAccess)
674 {
675 SC_HANDLE hService = NULL;
676 DWORD dwError;
677
678 DPRINT("OpenServiceA(%p, %s, %lx)\n",
679 hSCManager, lpServiceName, dwDesiredAccess);
680
681 HandleBind();
682
683 /* Call to services.exe using RPC */
684 dwError = ScmrOpenServiceA(BindingHandle,
685 (unsigned int)hSCManager,
686 (LPSTR)lpServiceName,
687 dwDesiredAccess,
688 (unsigned int*)&hService);
689 if (dwError != ERROR_SUCCESS)
690 {
691 DPRINT1("ScmrOpenServiceA() failed (Error %lu)\n", dwError);
692 SetLastError(dwError);
693 return NULL;
694 }
695
696 DPRINT("hService = %p\n", hService);
697
698 return hService;
699 }
700
701
702 /**********************************************************************
703 * OpenServiceW
704 *
705 * @implemented
706 */
707 SC_HANDLE STDCALL
708 OpenServiceW(SC_HANDLE hSCManager,
709 LPCWSTR lpServiceName,
710 DWORD dwDesiredAccess)
711 {
712 SC_HANDLE hService = NULL;
713 DWORD dwError;
714
715 DPRINT("OpenServiceW(%p, %S, %lx)\n",
716 hSCManager, lpServiceName, dwDesiredAccess);
717
718 HandleBind();
719
720 /* Call to services.exe using RPC */
721 dwError = ScmrOpenServiceW(BindingHandle,
722 (unsigned int)hSCManager,
723 (LPWSTR)lpServiceName,
724 dwDesiredAccess,
725 (unsigned int*)&hService);
726 if (dwError != ERROR_SUCCESS)
727 {
728 DPRINT1("ScmrOpenServiceW() failed (Error %lu)\n", dwError);
729 SetLastError(dwError);
730 return NULL;
731 }
732
733 DPRINT("hService = %p\n", hService);
734
735 return hService;
736 }
737
738
739 /**********************************************************************
740 * QueryServiceConfigA
741 *
742 * @unimplemented
743 */
744 BOOL
745 STDCALL
746 QueryServiceConfigA(
747 SC_HANDLE hService,
748 LPQUERY_SERVICE_CONFIGA lpServiceConfig,
749 DWORD cbBufSize,
750 LPDWORD pcbBytesNeeded)
751 {
752 DPRINT1("QueryServiceConfigA is unimplemented\n");
753 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
754 return FALSE;
755 }
756
757
758 /**********************************************************************
759 * QueryServiceConfigW
760 *
761 * @unimplemented
762 */
763 BOOL
764 STDCALL
765 QueryServiceConfigW(
766 SC_HANDLE hService,
767 LPQUERY_SERVICE_CONFIGW lpServiceConfig,
768 DWORD cbBufSize,
769 LPDWORD pcbBytesNeeded)
770 {
771 DPRINT1("QueryServiceConfigW is unimplemented\n");
772 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
773 return FALSE;
774 }
775
776
777 /**********************************************************************
778 * QueryServiceLockStatusA
779 *
780 * @unimplemented
781 */
782 BOOL
783 STDCALL
784 QueryServiceLockStatusA(
785 SC_HANDLE hSCManager,
786 LPQUERY_SERVICE_LOCK_STATUSA lpLockStatus,
787 DWORD cbBufSize,
788 LPDWORD pcbBytesNeeded)
789 {
790 DPRINT1("QueryServiceLockStatusA is unimplemented\n");
791 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
792 return FALSE;
793 }
794
795
796 /**********************************************************************
797 * QueryServiceLockStatusW
798 *
799 * @unimplemented
800 */
801 BOOL
802 STDCALL
803 QueryServiceLockStatusW(
804 SC_HANDLE hSCManager,
805 LPQUERY_SERVICE_LOCK_STATUSW lpLockStatus,
806 DWORD cbBufSize,
807 LPDWORD pcbBytesNeeded)
808 {
809 DPRINT1("QueryServiceLockStatusW is unimplemented\n");
810 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
811 return FALSE;
812 }
813
814
815 /**********************************************************************
816 * QueryServiceObjectSecurity
817 *
818 * @unimplemented
819 */
820 BOOL
821 STDCALL
822 QueryServiceObjectSecurity(
823 SC_HANDLE hService,
824 SECURITY_INFORMATION dwSecurityInformation,
825 PSECURITY_DESCRIPTOR lpSecurityDescriptor,
826 DWORD cbBufSize,
827 LPDWORD pcbBytesNeeded)
828 {
829 DPRINT1("QueryServiceObjectSecurity is unimplemented\n");
830 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
831 return FALSE;
832 }
833
834
835 /**********************************************************************
836 * QueryServiceStatus
837 *
838 * @implemented
839 */
840 BOOL STDCALL
841 QueryServiceStatus(SC_HANDLE hService,
842 LPSERVICE_STATUS lpServiceStatus)
843 {
844 DWORD dwError;
845
846 DPRINT("QueryServiceStatus(%p, %p)\n",
847 hService, lpServiceStatus);
848
849 HandleBind();
850
851 /* Call to services.exe using RPC */
852 dwError = ScmrQueryServiceStatus(BindingHandle,
853 (unsigned int)hService,
854 lpServiceStatus);
855 if (dwError != ERROR_SUCCESS)
856 {
857 DPRINT1("ScmrQueryServiceStatus() failed (Error %lu)\n", dwError);
858 SetLastError(dwError);
859 return FALSE;
860 }
861
862 return TRUE;
863 }
864
865
866 /**********************************************************************
867 * QueryServiceStatusEx
868 *
869 * @unimplemented
870 */
871 BOOL
872 STDCALL
873 QueryServiceStatusEx(SC_HANDLE hService,
874 SC_STATUS_TYPE InfoLevel,
875 LPBYTE lpBuffer,
876 DWORD cbBufSize,
877 LPDWORD pcbBytesNeeded)
878 {
879 DPRINT1("QueryServiceStatusEx is unimplemented\n");
880 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
881 return FALSE;
882 }
883
884
885 /**********************************************************************
886 * StartServiceA
887 *
888 * @unimplemented
889 */
890 BOOL
891 STDCALL
892 StartServiceA(
893 SC_HANDLE hService,
894 DWORD dwNumServiceArgs,
895 LPCSTR *lpServiceArgVectors)
896 {
897 DPRINT1("StartServiceA is unimplemented\n");
898 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
899 return FALSE;
900 }
901
902
903 /**********************************************************************
904 * StartServiceW
905 *
906 * @unimplemented
907 */
908 BOOL
909 STDCALL
910 StartServiceW(
911 SC_HANDLE hService,
912 DWORD dwNumServiceArgs,
913 LPCWSTR *lpServiceArgVectors)
914 {
915 DPRINT1("StartServiceW is unimplemented\n");
916 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
917 return FALSE;
918 }
919
920
921 /**********************************************************************
922 * UnlockServiceDatabase
923 *
924 * @implemented
925 */
926 BOOL STDCALL
927 UnlockServiceDatabase(SC_LOCK ScLock)
928 {
929 DWORD dwError;
930
931 #if 0
932 DPRINT("UnlockServiceDatabase(%x)\n", hSCManager);
933 #endif
934
935 HandleBind();
936
937 /* Call to services.exe using RPC */
938 dwError = ScmrUnlockServiceDatabase(BindingHandle,
939 (unsigned int)ScLock);
940 if (dwError != ERROR_SUCCESS)
941 {
942 DPRINT1("ScmrUnlockServiceDatabase() failed (Error %lu)\n", dwError);
943 SetLastError(dwError);
944 return FALSE;
945 }
946
947 return TRUE;
948 }
949
950
951 void __RPC_FAR * __RPC_USER midl_user_allocate(size_t len)
952 {
953 return HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, len);
954 }
955
956 void __RPC_USER midl_user_free(void __RPC_FAR * ptr)
957 {
958 HeapFree(GetProcessHeap(), 0, ptr);
959 }
960
961 /* EOF */