1 /* $Id: scm.c,v 1.9 2002/07/20 13:31:34 ekohl Exp $
3 * COPYRIGHT: See COPYING in the top level directory
4 * PROJECT: ReactOS system libraries
5 * FILE: lib/advapi32/service/scm.c
6 * PURPOSE: Service control manager functions
7 * PROGRAMMER: Emanuele Aliberti
13 /* INCLUDES ******************************************************************/
16 #include <ddk/ntddk.h>
18 /* FUNCTIONS *****************************************************************/
20 /**********************************************************************
21 * ChangeServiceConfigA
30 LPCSTR lpBinaryPathName
,
31 LPCSTR lpLoadOrderGroup
,
33 LPCSTR lpDependencies
,
34 LPCSTR lpServiceStartName
,
39 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
44 /**********************************************************************
45 * ChangeServiceConfigW
54 LPCWSTR lpBinaryPathName
,
55 LPCWSTR lpLoadOrderGroup
,
57 LPCWSTR lpDependencies
,
58 LPCWSTR lpServiceStartName
,
63 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
68 /**********************************************************************
73 CloseServiceHandle( SC_HANDLE hSCObject
)
75 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
80 /**********************************************************************
88 LPSERVICE_STATUS lpServiceStatus
91 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
96 /**********************************************************************
102 SC_HANDLE hSCManager
,
103 LPCSTR lpServiceName
,
104 LPCSTR lpDisplayName
,
105 DWORD dwDesiredAccess
,
108 DWORD dwErrorControl
,
109 LPCSTR lpBinaryPathName
,
110 LPCSTR lpLoadOrderGroup
,
112 LPCSTR lpDependencies
,
113 LPCSTR lpServiceStartName
,
117 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
122 /**********************************************************************
128 SC_HANDLE hSCManager
,
129 LPCWSTR lpServiceName
,
130 LPCWSTR lpDisplayName
,
131 DWORD dwDesiredAccess
,
134 DWORD dwErrorControl
,
135 LPCWSTR lpBinaryPathName
,
136 LPCWSTR lpLoadOrderGroup
,
138 LPCWSTR lpDependencies
,
139 LPCWSTR lpServiceStartName
,
143 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
148 /**********************************************************************
153 DeleteService( SC_HANDLE hService
)
155 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
160 /**********************************************************************
161 * EnumDependentServicesA
165 EnumDependentServicesA(
167 DWORD dwServiceState
,
168 LPENUM_SERVICE_STATUSA lpServices
,
170 LPDWORD pcbBytesNeeded
,
171 LPDWORD lpServicesReturned
174 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
179 /**********************************************************************
180 * EnumDependentServicesW
184 EnumDependentServicesW(
186 DWORD dwServiceState
,
187 LPENUM_SERVICE_STATUSW lpServices
,
189 LPDWORD pcbBytesNeeded
,
190 LPDWORD lpServicesReturned
193 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
198 /**********************************************************************
217 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
222 /**********************************************************************
223 * EnumServicesStatusA
227 EnumServicesStatusA (
228 SC_HANDLE hSCManager
,
230 DWORD dwServiceState
,
231 LPENUM_SERVICE_STATUSA lpServices
,
233 LPDWORD pcbBytesNeeded
,
234 LPDWORD lpServicesReturned
,
235 LPDWORD lpResumeHandle
238 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
243 /**********************************************************************
244 * EnumServicesStatusExA
248 EnumServicesStatusExA(VOID
)
250 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
255 /**********************************************************************
256 * EnumServicesStatusExW
260 EnumServicesStatusExW(VOID
)
262 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
267 /**********************************************************************
268 * EnumServicesStatusW
273 SC_HANDLE hSCManager
,
275 DWORD dwServiceState
,
276 LPENUM_SERVICE_STATUSW lpServices
,
278 LPDWORD pcbBytesNeeded
,
279 LPDWORD lpServicesReturned
,
280 LPDWORD lpResumeHandle
283 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
288 /**********************************************************************
289 * GetServiceDisplayNameA
293 GetServiceDisplayNameA(
294 SC_HANDLE hSCManager
,
295 LPCSTR lpServiceName
,
300 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
305 /**********************************************************************
306 * GetServiceDisplayNameW
310 GetServiceDisplayNameW(
311 SC_HANDLE hSCManager
,
312 LPCWSTR lpServiceName
,
313 LPWSTR lpDisplayName
,
317 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
322 /**********************************************************************
328 SC_HANDLE hSCManager
,
329 LPCSTR lpDisplayName
,
334 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
339 /**********************************************************************
345 SC_HANDLE hSCManager
,
346 LPCWSTR lpDisplayName
,
347 LPWSTR lpServiceName
,
351 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
355 /**********************************************************************
356 * LockServiceDatabase
364 SetLastError (ERROR_CALL_NOT_IMPLEMENTED
);
369 /**********************************************************************
373 OpenSCManagerA(LPCSTR lpMachineName
,
374 LPCSTR lpDatabaseName
,
375 DWORD dwDesiredAccess
)
378 UNICODE_STRING MachineNameW
;
379 UNICODE_STRING DatabaseNameW
;
380 ANSI_STRING MachineNameA
;
381 ANSI_STRING DatabaseNameA
;
383 RtlInitAnsiString(&MachineNameA
, (LPSTR
)lpMachineName
);
384 RtlAnsiStringToUnicodeString(&MachineNameW
,
387 RtlInitAnsiString(&DatabaseNameA
, (LPSTR
)lpDatabaseName
);
388 RtlAnsiStringToUnicodeString(&DatabaseNameW
,
392 Handle
= OpenSCManagerW(MachineNameW
.Buffer
,
393 DatabaseNameW
.Buffer
,
396 RtlFreeHeap(GetProcessHeap(),
398 MachineNameW
.Buffer
);
399 RtlFreeHeap(GetProcessHeap(),
401 DatabaseNameW
.Buffer
);
407 /**********************************************************************
411 OpenSCManagerW(LPCWSTR lpMachineName
,
412 LPCWSTR lpDatabaseName
,
413 DWORD dwDesiredAccess
)
418 LPWSTR lpszPipeName
= L
"\\\\.\\pipe\\Ntsvcs";
420 if (lpMachineName
== NULL
|| wcslen(lpMachineName
) == 0)
422 if (lpDatabaseName
!= NULL
&& wcscmp(lpDatabaseName
, SERVICES_ACTIVE_DATABASEW
) != 0)
427 // Try to open a named pipe; wait for it, if necessary
431 lpszPipeName
, // pipe name
434 NULL
, // no security attributes
435 OPEN_EXISTING
, // opens existing pipe
436 0, // default attributes
437 NULL
); // no template file
439 // Break if the pipe handle is valid
441 if (hPipe
!= INVALID_HANDLE_VALUE
)
444 // Exit if an error other than ERROR_PIPE_BUSY occurs
446 if (GetLastError() != ERROR_PIPE_BUSY
)
451 // All pipe instances are busy, so wait for 20 seconds
453 if (!WaitNamedPipeW(lpszPipeName
, 20000))
459 // The pipe connected; change to message-read mode
461 dwMode
= PIPE_READMODE_MESSAGE
;
462 fSuccess
= SetNamedPipeHandleState(
463 hPipe
, // pipe handle
464 &dwMode
, // new pipe mode
465 NULL
, // don't set maximum bytes
466 NULL
); // don't set maximum time
473 // Send a message to the pipe server
475 lpvMessage
= (argc
> 1) ? argv
[1] : "default message";
477 fSuccess
= WriteFile(
478 hPipe
, // pipe handle
479 lpvMessage
, // message
480 strlen(lpvMessage
) + 1, // message length
481 &cbWritten
, // bytes written
482 NULL
); // not overlapped
491 // Read from the pipe
494 hPipe
, // pipe handle
495 chBuf
, // buffer to receive reply
496 512, // size of buffer
497 &cbRead
, // number of bytes read
498 NULL
); // not overlapped
500 if (! fSuccess
&& GetLastError() != ERROR_MORE_DATA
)
503 // Reply from the pipe is written to STDOUT.
505 if (!WriteFile(GetStdHandle(STD_OUTPUT_HANDLE
),
506 chBuf
, cbRead
, &cbWritten
, NULL
))
511 } while (!fSuccess
); // repeat loop if ERROR_MORE_DATA
512 //CloseHandle(hPipe);
518 /* FIXME: Connect to remote SCM */
524 /**********************************************************************
528 OpenServiceA(SC_HANDLE hSCManager
,
529 LPCSTR lpServiceName
,
530 DWORD dwDesiredAccess
)
532 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
537 /**********************************************************************
543 SC_HANDLE hSCManager
,
544 LPCWSTR lpServiceName
,
545 DWORD dwDesiredAccess
548 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
553 /**********************************************************************
554 * PrivilegedServiceAuditAlarmA
558 PrivilegedServiceAuditAlarmA(
559 LPCSTR SubsystemName
,
562 PPRIVILEGE_SET Privileges
,
566 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
571 /**********************************************************************
572 * PrivilegedServiceAuditAlarmW
576 PrivilegedServiceAuditAlarmW(
577 LPCWSTR SubsystemName
,
580 PPRIVILEGE_SET Privileges
,
584 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
589 /**********************************************************************
590 * QueryServiceConfigA
596 LPQUERY_SERVICE_CONFIGA lpServiceConfig
,
598 LPDWORD pcbBytesNeeded
601 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
606 /**********************************************************************
607 * QueryServiceConfigW
613 LPQUERY_SERVICE_CONFIGW lpServiceConfig
,
615 LPDWORD pcbBytesNeeded
618 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
623 /**********************************************************************
624 * QueryServiceLockStatusA
628 QueryServiceLockStatusA(
629 SC_HANDLE hSCManager
,
630 LPQUERY_SERVICE_LOCK_STATUSA lpLockStatus
,
632 LPDWORD pcbBytesNeeded
635 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
640 /**********************************************************************
641 * QueryServiceLockStatusW
645 QueryServiceLockStatusW(
646 SC_HANDLE hSCManager
,
647 LPQUERY_SERVICE_LOCK_STATUSW lpLockStatus
,
649 LPDWORD pcbBytesNeeded
652 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
657 /**********************************************************************
658 * QueryServiceObjectSecurity
662 QueryServiceObjectSecurity(
664 SECURITY_INFORMATION dwSecurityInformation
,
665 PSECURITY_DESCRIPTOR lpSecurityDescriptor
,
667 LPDWORD pcbBytesNeeded
670 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
675 /**********************************************************************
682 LPSERVICE_STATUS lpServiceStatus
685 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
690 /**********************************************************************
691 * QueryServiceStatusEx
695 QueryServiceStatusEx(VOID
)
697 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
702 /**********************************************************************
709 DWORD dwNumServiceArgs
,
710 LPCSTR
*lpServiceArgVectors
713 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
720 /**********************************************************************
727 DWORD dwNumServiceArgs
,
728 LPCWSTR
*lpServiceArgVectors
731 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
736 /**********************************************************************
737 * UnlockServiceDatabase
741 UnlockServiceDatabase(
745 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);