ReactOS 0.4.15-dev-7924-g5949c20
scm.c File Reference
#include <advapi32.h>
Include dependency graph for scm.c:

Go to the source code of this file.

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (advapi)
 
NTSTATUS WINAPI SystemFunction004 (const struct ustring *in, const struct ustring *key, struct ustring *out)
 
NTSTATUS WINAPI SystemFunction028 (IN PVOID ContextHandle, OUT LPBYTE SessionKey)
 
handle_t __RPC_USER SVCCTL_HANDLEA_bind (SVCCTL_HANDLEA szMachineName)
 
void __RPC_USER SVCCTL_HANDLEA_unbind (SVCCTL_HANDLEA szMachineName, handle_t hBinding)
 
handle_t __RPC_USER SVCCTL_HANDLEW_bind (SVCCTL_HANDLEW szMachineName)
 
void __RPC_USER SVCCTL_HANDLEW_unbind (SVCCTL_HANDLEW szMachineName, handle_t hBinding)
 
DWORD ScmRpcStatusToWinError (RPC_STATUS Status)
 
static DWORD ScmEncryptPassword (_In_ PVOID ContextHandle, _In_ PCWSTR pClearTextPassword, _Out_ PBYTE *pEncryptedPassword, _Out_ PDWORD pEncryptedPasswordSize)
 
BOOL WINAPI ChangeServiceConfig2A (SC_HANDLE hService, DWORD dwInfoLevel, LPVOID lpInfo)
 
BOOL WINAPI ChangeServiceConfig2W (SC_HANDLE hService, DWORD dwInfoLevel, LPVOID lpInfo)
 
BOOL WINAPI ChangeServiceConfigA (SC_HANDLE hService, DWORD dwServiceType, DWORD dwStartType, DWORD dwErrorControl, LPCSTR lpBinaryPathName, LPCSTR lpLoadOrderGroup, LPDWORD lpdwTagId, LPCSTR lpDependencies, LPCSTR lpServiceStartName, LPCSTR lpPassword, LPCSTR lpDisplayName)
 
BOOL WINAPI ChangeServiceConfigW (SC_HANDLE hService, DWORD dwServiceType, DWORD dwStartType, DWORD dwErrorControl, LPCWSTR lpBinaryPathName, LPCWSTR lpLoadOrderGroup, LPDWORD lpdwTagId, LPCWSTR lpDependencies, LPCWSTR lpServiceStartName, LPCWSTR lpPassword, LPCWSTR lpDisplayName)
 
BOOL WINAPI CloseServiceHandle (SC_HANDLE hSCObject)
 
BOOL WINAPI ControlService (SC_HANDLE hService, DWORD dwControl, LPSERVICE_STATUS lpServiceStatus)
 
BOOL WINAPI ControlServiceEx (IN SC_HANDLE hService, IN DWORD dwControl, IN DWORD dwInfoLevel, IN OUT PVOID pControlParams)
 
SC_HANDLE WINAPI CreateServiceA (SC_HANDLE hSCManager, LPCSTR lpServiceName, LPCSTR lpDisplayName, DWORD dwDesiredAccess, DWORD dwServiceType, DWORD dwStartType, DWORD dwErrorControl, LPCSTR lpBinaryPathName, LPCSTR lpLoadOrderGroup, LPDWORD lpdwTagId, LPCSTR lpDependencies, LPCSTR lpServiceStartName, LPCSTR lpPassword)
 
SC_HANDLE WINAPI CreateServiceW (SC_HANDLE hSCManager, LPCWSTR lpServiceName, LPCWSTR lpDisplayName, DWORD dwDesiredAccess, DWORD dwServiceType, DWORD dwStartType, DWORD dwErrorControl, LPCWSTR lpBinaryPathName, LPCWSTR lpLoadOrderGroup, LPDWORD lpdwTagId, LPCWSTR lpDependencies, LPCWSTR lpServiceStartName, LPCWSTR lpPassword)
 
BOOL WINAPI DeleteService (SC_HANDLE hService)
 
BOOL WINAPI EnumDependentServicesA (SC_HANDLE hService, DWORD dwServiceState, LPENUM_SERVICE_STATUSA lpServices, DWORD cbBufSize, LPDWORD pcbBytesNeeded, LPDWORD lpServicesReturned)
 
BOOL WINAPI EnumDependentServicesW (SC_HANDLE hService, DWORD dwServiceState, LPENUM_SERVICE_STATUSW lpServices, DWORD cbBufSize, LPDWORD pcbBytesNeeded, LPDWORD lpServicesReturned)
 
BOOL WINAPI EnumServiceGroupW (SC_HANDLE hSCManager, DWORD dwServiceType, DWORD dwServiceState, LPENUM_SERVICE_STATUSW lpServices, DWORD cbBufSize, LPDWORD pcbBytesNeeded, LPDWORD lpServicesReturned, LPDWORD lpResumeHandle, LPCWSTR lpGroup)
 
BOOL WINAPI EnumServicesStatusA (SC_HANDLE hSCManager, DWORD dwServiceType, DWORD dwServiceState, LPENUM_SERVICE_STATUSA lpServices, DWORD cbBufSize, LPDWORD pcbBytesNeeded, LPDWORD lpServicesReturned, LPDWORD lpResumeHandle)
 
BOOL WINAPI EnumServicesStatusW (SC_HANDLE hSCManager, DWORD dwServiceType, DWORD dwServiceState, LPENUM_SERVICE_STATUSW lpServices, DWORD cbBufSize, LPDWORD pcbBytesNeeded, LPDWORD lpServicesReturned, LPDWORD lpResumeHandle)
 
BOOL WINAPI EnumServicesStatusExA (SC_HANDLE hSCManager, SC_ENUM_TYPE InfoLevel, DWORD dwServiceType, DWORD dwServiceState, LPBYTE lpServices, DWORD cbBufSize, LPDWORD pcbBytesNeeded, LPDWORD lpServicesReturned, LPDWORD lpResumeHandle, LPCSTR pszGroupName)
 
BOOL WINAPI EnumServicesStatusExW (SC_HANDLE hSCManager, SC_ENUM_TYPE InfoLevel, DWORD dwServiceType, DWORD dwServiceState, LPBYTE lpServices, DWORD cbBufSize, LPDWORD pcbBytesNeeded, LPDWORD lpServicesReturned, LPDWORD lpResumeHandle, LPCWSTR pszGroupName)
 
BOOL WINAPI GetServiceDisplayNameA (SC_HANDLE hSCManager, LPCSTR lpServiceName, LPSTR lpDisplayName, LPDWORD lpcchBuffer)
 
BOOL WINAPI GetServiceDisplayNameW (SC_HANDLE hSCManager, LPCWSTR lpServiceName, LPWSTR lpDisplayName, LPDWORD lpcchBuffer)
 
BOOL WINAPI GetServiceKeyNameA (SC_HANDLE hSCManager, LPCSTR lpDisplayName, LPSTR lpServiceName, LPDWORD lpcchBuffer)
 
BOOL WINAPI GetServiceKeyNameW (SC_HANDLE hSCManager, LPCWSTR lpDisplayName, LPWSTR lpServiceName, LPDWORD lpcchBuffer)
 
DWORD WINAPI I_ScGetCurrentGroupStateW (SC_HANDLE hSCManager, LPWSTR pszGroupName, LPDWORD pdwGroupState)
 
DWORD WINAPI I_ScValidatePnpService (_In_ LPCWSTR pszMachineName, _In_ LPCWSTR pszServiceName, _Out_ SERVICE_STATUS_HANDLE *phServiceStatus)
 
SC_LOCK WINAPI LockServiceDatabase (SC_HANDLE hSCManager)
 
static VOID WaitForSCManager (VOID)
 
SC_HANDLE WINAPI OpenSCManagerA (LPCSTR lpMachineName, LPCSTR lpDatabaseName, DWORD dwDesiredAccess)
 
SC_HANDLE WINAPI OpenSCManagerW (LPCWSTR lpMachineName, LPCWSTR lpDatabaseName, DWORD dwDesiredAccess)
 
SC_HANDLE WINAPI OpenServiceA (SC_HANDLE hSCManager, LPCSTR lpServiceName, DWORD dwDesiredAccess)
 
SC_HANDLE WINAPI OpenServiceW (SC_HANDLE hSCManager, LPCWSTR lpServiceName, DWORD dwDesiredAccess)
 
BOOL WINAPI QueryServiceConfigA (SC_HANDLE hService, LPQUERY_SERVICE_CONFIGA lpServiceConfig, DWORD cbBufSize, LPDWORD pcbBytesNeeded)
 
BOOL WINAPI QueryServiceConfigW (SC_HANDLE hService, LPQUERY_SERVICE_CONFIGW lpServiceConfig, DWORD cbBufSize, LPDWORD pcbBytesNeeded)
 
BOOL WINAPI QueryServiceConfig2A (SC_HANDLE hService, DWORD dwInfoLevel, LPBYTE lpBuffer, DWORD cbBufSize, LPDWORD pcbBytesNeeded)
 
BOOL WINAPI QueryServiceConfig2W (SC_HANDLE hService, DWORD dwInfoLevel, LPBYTE lpBuffer, DWORD cbBufSize, LPDWORD pcbBytesNeeded)
 
BOOL WINAPI QueryServiceLockStatusA (SC_HANDLE hSCManager, LPQUERY_SERVICE_LOCK_STATUSA lpLockStatus, DWORD cbBufSize, LPDWORD pcbBytesNeeded)
 
BOOL WINAPI QueryServiceLockStatusW (SC_HANDLE hSCManager, LPQUERY_SERVICE_LOCK_STATUSW lpLockStatus, DWORD cbBufSize, LPDWORD pcbBytesNeeded)
 
BOOL WINAPI QueryServiceObjectSecurity (SC_HANDLE hService, SECURITY_INFORMATION dwSecurityInformation, PSECURITY_DESCRIPTOR lpSecurityDescriptor, DWORD cbBufSize, LPDWORD pcbBytesNeeded)
 
BOOL WINAPI SetServiceObjectSecurity (SC_HANDLE hService, SECURITY_INFORMATION dwSecurityInformation, PSECURITY_DESCRIPTOR lpSecurityDescriptor)
 
BOOL WINAPI QueryServiceStatus (SC_HANDLE hService, LPSERVICE_STATUS lpServiceStatus)
 
BOOL WINAPI QueryServiceStatusEx (SC_HANDLE hService, SC_STATUS_TYPE InfoLevel, LPBYTE lpBuffer, DWORD cbBufSize, LPDWORD pcbBytesNeeded)
 
BOOL WINAPI StartServiceA (SC_HANDLE hService, DWORD dwNumServiceArgs, LPCSTR *lpServiceArgVectors)
 
BOOL WINAPI StartServiceW (SC_HANDLE hService, DWORD dwNumServiceArgs, LPCWSTR *lpServiceArgVectors)
 
BOOL WINAPI UnlockServiceDatabase (SC_LOCK ScLock)
 
BOOL WINAPI NotifyBootConfigStatus (BOOL BootAcceptable)
 
DWORD I_ScQueryServiceTagInfo (PVOID Unused, TAG_INFO_LEVEL dwInfoLevel, PTAG_INFO_NAME_FROM_TAG InOutParams)
 
DWORD WINAPI I_QueryTagInformation (PVOID Unused, TAG_INFO_LEVEL dwInfoLevel, PTAG_INFO_NAME_FROM_TAG InOutParams)
 

Function Documentation

◆ ChangeServiceConfig2A()

BOOL WINAPI ChangeServiceConfig2A ( SC_HANDLE  hService,
DWORD  dwInfoLevel,
LPVOID  lpInfo 
)

Definition at line 247 of file scm.c.

250{
252 DWORD dwError;
253
254 TRACE("ChangeServiceConfig2A(%p %lu %p)\n",
255 hService, dwInfoLevel, lpInfo);
256
257 if (lpInfo == NULL) return TRUE;
258
259 /* Fill relevant field of the Info structure */
260 Info.dwInfoLevel = dwInfoLevel;
261 switch (dwInfoLevel)
262 {
264 Info.psd = lpInfo;
265 break;
266
268 Info.psfa = lpInfo;
269 break;
270
271 default:
272 WARN("Unknown info level 0x%lx\n", dwInfoLevel);
274 return FALSE;
275 }
276
278 {
279 dwError = RChangeServiceConfig2A((SC_RPC_HANDLE)hService,
280 Info);
281 }
283 {
285 }
287
288 if (dwError != ERROR_SUCCESS)
289 {
290 TRACE("RChangeServiceConfig2A() failed (Error %lu)\n", dwError);
291 SetLastError(dwError);
292 return FALSE;
293 }
294
295 return TRUE;
296}
DWORD WINAPI RChangeServiceConfig2A(SC_RPC_HANDLE hService, SC_RPC_CONFIG_INFOA Info)
Definition: rpcserver.c:5019
#define WARN(fmt,...)
Definition: debug.h:112
#define ERROR_SUCCESS
Definition: deptool.c:10
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
#define SetLastError(x)
Definition: compat.h:752
unsigned long DWORD
Definition: ntddk_ex.h:95
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
DWORD ScmRpcStatusToWinError(RPC_STATUS Status)
Definition: scm.c:146
#define RpcEndExcept
Definition: rpc.h:128
#define RpcTryExcept
Definition: rpc.h:126
#define RpcExcept(expr)
Definition: rpc.h:127
#define RpcExceptionCode()
Definition: rpc.h:132
#define TRACE(s)
Definition: solgame.cpp:4
_Must_inspect_result_ _In_ WDFCHILDLIST _In_ PWDF_CHILD_LIST_ITERATOR _Out_ WDFDEVICE _Inout_opt_ PWDF_CHILD_RETRIEVE_INFO Info
Definition: wdfchildlist.h:690
#define SERVICE_CONFIG_DESCRIPTION
Definition: winsvc.h:65
_In_ DWORD dwInfoLevel
Definition: winsvc.h:422
#define SERVICE_CONFIG_FAILURE_ACTIONS
Definition: winsvc.h:66

◆ ChangeServiceConfig2W()

BOOL WINAPI ChangeServiceConfig2W ( SC_HANDLE  hService,
DWORD  dwInfoLevel,
LPVOID  lpInfo 
)

Definition at line 305 of file scm.c.

308{
310 DWORD dwError;
311
312 TRACE("ChangeServiceConfig2W(%p %lu %p)\n",
313 hService, dwInfoLevel, lpInfo);
314
315 if (lpInfo == NULL) return TRUE;
316
317 /* Fill relevant field of the Info structure */
318 Info.dwInfoLevel = dwInfoLevel;
319 switch (dwInfoLevel)
320 {
322 Info.psd = lpInfo;
323 break;
324
326 Info.psfa = lpInfo;
327 break;
328
329 default:
330 WARN("Unknown info level 0x%lx\n", dwInfoLevel);
332 return FALSE;
333 }
334
336 {
337 dwError = RChangeServiceConfig2W((SC_RPC_HANDLE)hService,
338 Info);
339 }
341 {
343 }
345
346 if (dwError != ERROR_SUCCESS)
347 {
348 TRACE("RChangeServiceConfig2W() failed (Error %lu)\n", dwError);
349 SetLastError(dwError);
350 return FALSE;
351 }
352
353 return TRUE;
354}
DWORD WINAPI RChangeServiceConfig2W(SC_RPC_HANDLE hService, SC_RPC_CONFIG_INFOW Info)
Definition: rpcserver.c:5420

Referenced by ITERATE_InstallService(), RegisterService(), and SetServiceDescription().

◆ ChangeServiceConfigA()

BOOL WINAPI ChangeServiceConfigA ( SC_HANDLE  hService,
DWORD  dwServiceType,
DWORD  dwStartType,
DWORD  dwErrorControl,
LPCSTR  lpBinaryPathName,
LPCSTR  lpLoadOrderGroup,
LPDWORD  lpdwTagId,
LPCSTR  lpDependencies,
LPCSTR  lpServiceStartName,
LPCSTR  lpPassword,
LPCSTR  lpDisplayName 
)

Definition at line 363 of file scm.c.

374{
375 DWORD dwError;
376 DWORD dwDependenciesLength = 0;
377 SIZE_T cchLength;
378 LPCSTR lpStr;
379 DWORD dwPasswordSize = 0;
380 LPWSTR lpPasswordW = NULL;
381 LPBYTE lpEncryptedPassword = NULL;
382
383 TRACE("ChangeServiceConfigA(%p %lu %lu %lu %s %s %p %s %s %s %s)\n",
384 hService, dwServiceType, dwStartType, dwErrorControl, debugstr_a(lpBinaryPathName),
385 debugstr_a(lpLoadOrderGroup), lpdwTagId, debugstr_a(lpDependencies),
386 debugstr_a(lpServiceStartName), debugstr_a(lpPassword), debugstr_a(lpDisplayName));
387
388 /* Calculate the Dependencies length*/
389 if (lpDependencies != NULL)
390 {
391 lpStr = lpDependencies;
392 while (*lpStr)
393 {
394 cchLength = strlen(lpStr) + 1;
395 dwDependenciesLength += (DWORD)cchLength;
396 lpStr = lpStr + cchLength;
397 }
398 dwDependenciesLength++;
399 }
400
401 if (lpPassword != NULL)
402 {
403 /* Convert the password to unicode */
404 lpPasswordW = HeapAlloc(GetProcessHeap(),
406 (strlen(lpPassword) + 1) * sizeof(WCHAR));
407 if (lpPasswordW == NULL)
408 {
410 return FALSE;
411 }
412
414 0,
415 lpPassword,
416 -1,
417 lpPasswordW,
418 (int)(strlen(lpPassword) + 1));
419
420 /* Encrypt the unicode password */
421 dwError = ScmEncryptPassword(hService,
422 lpPasswordW,
423 &lpEncryptedPassword,
424 &dwPasswordSize);
425 if (dwError != ERROR_SUCCESS)
426 goto done;
427 }
428
430 {
431 dwError = RChangeServiceConfigA((SC_RPC_HANDLE)hService,
432 dwServiceType,
433 dwStartType,
434 dwErrorControl,
435 (LPSTR)lpBinaryPathName,
436 (LPSTR)lpLoadOrderGroup,
437 lpdwTagId,
438 (LPBYTE)lpDependencies,
439 dwDependenciesLength,
440 (LPSTR)lpServiceStartName,
441 lpEncryptedPassword,
442 dwPasswordSize,
444 }
446 {
448 }
450
451done:
452 if (lpPasswordW != NULL)
453 {
454 /* Wipe and release the password buffers */
455 SecureZeroMemory(lpPasswordW, (wcslen(lpPasswordW) + 1) * sizeof(WCHAR));
456 HeapFree(GetProcessHeap(), 0, lpPasswordW);
457
458 if (lpEncryptedPassword != NULL)
459 {
460 SecureZeroMemory(lpEncryptedPassword, dwPasswordSize);
461 HeapFree(GetProcessHeap(), 0, lpEncryptedPassword);
462 }
463 }
464
465 if (dwError != ERROR_SUCCESS)
466 {
467 TRACE("RChangeServiceConfigA() failed (Error %lu)\n", dwError);
468 SetLastError(dwError);
469 return FALSE;
470 }
471
472 return TRUE;
473}
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
DWORD WINAPI RChangeServiceConfigA(SC_RPC_HANDLE hService, DWORD dwServiceType, DWORD dwStartType, DWORD dwErrorControl, LPSTR lpBinaryPathName, LPSTR lpLoadOrderGroup, LPDWORD lpdwTagId, LPBYTE lpDependencies, DWORD dwDependSize, LPSTR lpServiceStartName, LPBYTE lpPassword, DWORD dwPwSize, LPSTR lpDisplayName)
Definition: rpcserver.c:3461
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
#define GetProcessHeap()
Definition: compat.h:736
#define CP_ACP
Definition: compat.h:109
#define HeapAlloc
Definition: compat.h:733
#define HeapFree(x, y, z)
Definition: compat.h:735
#define MultiByteToWideChar
Definition: compat.h:110
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define debugstr_a
Definition: kernel32.h:31
#define DWORD
Definition: nt_native.h:44
static DWORD ScmEncryptPassword(_In_ PVOID ContextHandle, _In_ PCWSTR pClearTextPassword, _Out_ PBYTE *pEncryptedPassword, _Out_ PDWORD pEncryptedPasswordSize)
Definition: scm.c:173
unsigned char * LPBYTE
Definition: typedefs.h:53
ULONG_PTR SIZE_T
Definition: typedefs.h:80
#define SecureZeroMemory
Definition: winbase.h:1713
_In_ LPCSTR _Out_writes_to_opt_ cchDisplayName LPSTR lpDisplayName
Definition: winbase.h:2790
const char * LPCSTR
Definition: xmlstorage.h:183
char * LPSTR
Definition: xmlstorage.h:182
__wchar_t WCHAR
Definition: xmlstorage.h:180
WCHAR * LPWSTR
Definition: xmlstorage.h:184

Referenced by test_sequence(), and test_start_stop().

◆ ChangeServiceConfigW()

BOOL WINAPI ChangeServiceConfigW ( SC_HANDLE  hService,
DWORD  dwServiceType,
DWORD  dwStartType,
DWORD  dwErrorControl,
LPCWSTR  lpBinaryPathName,
LPCWSTR  lpLoadOrderGroup,
LPDWORD  lpdwTagId,
LPCWSTR  lpDependencies,
LPCWSTR  lpServiceStartName,
LPCWSTR  lpPassword,
LPCWSTR  lpDisplayName 
)

Definition at line 482 of file scm.c.

493{
494 DWORD dwError;
495 DWORD dwDependenciesLength = 0;
496 SIZE_T cchLength;
497 LPCWSTR lpStr;
498 DWORD dwPasswordSize = 0;
499 LPBYTE lpEncryptedPassword = NULL;
500
501 TRACE("ChangeServiceConfigW(%p %lu %lu %lu %s %s %p %s %s %s %s)\n",
502 hService, dwServiceType, dwStartType, dwErrorControl, debugstr_w(lpBinaryPathName),
503 debugstr_w(lpLoadOrderGroup), lpdwTagId, debugstr_w(lpDependencies),
504 debugstr_w(lpServiceStartName), debugstr_w(lpPassword), debugstr_w(lpDisplayName));
505
506 /* Calculate the Dependencies length*/
507 if (lpDependencies != NULL)
508 {
509 lpStr = lpDependencies;
510 while (*lpStr)
511 {
512 cchLength = wcslen(lpStr) + 1;
513 dwDependenciesLength += (DWORD)cchLength;
514 lpStr = lpStr + cchLength;
515 }
516 dwDependenciesLength++;
517 dwDependenciesLength *= sizeof(WCHAR);
518 }
519
520 if (lpPassword != NULL)
521 {
522 dwError = ScmEncryptPassword(hService,
523 lpPassword,
524 &lpEncryptedPassword,
525 &dwPasswordSize);
526 if (dwError != ERROR_SUCCESS)
527 {
528 ERR("ScmEncryptPassword failed (Error %lu)\n", dwError);
529 goto done;
530 }
531 }
532
534 {
535 dwError = RChangeServiceConfigW((SC_RPC_HANDLE)hService,
536 dwServiceType,
537 dwStartType,
538 dwErrorControl,
539 (LPWSTR)lpBinaryPathName,
540 (LPWSTR)lpLoadOrderGroup,
541 lpdwTagId,
542 (LPBYTE)lpDependencies,
543 dwDependenciesLength,
544 (LPWSTR)lpServiceStartName,
545 lpEncryptedPassword,
546 dwPasswordSize,
548 }
550 {
552 }
554
555done:
556 if (lpEncryptedPassword != NULL)
557 {
558 /* Wipe and release the password buffer */
559 SecureZeroMemory(lpEncryptedPassword, dwPasswordSize);
560 HeapFree(GetProcessHeap(), 0, lpEncryptedPassword);
561 }
562
563 if (dwError != ERROR_SUCCESS)
564 {
565 TRACE("RChangeServiceConfigW() failed (Error %lu)\n", dwError);
566 SetLastError(dwError);
567 return FALSE;
568 }
569
570 return TRUE;
571}
DWORD WINAPI RChangeServiceConfigW(SC_RPC_HANDLE hService, DWORD dwServiceType, DWORD dwStartType, DWORD dwErrorControl, LPWSTR lpBinaryPathName, LPWSTR lpLoadOrderGroup, LPDWORD lpdwTagId, LPBYTE lpDependencies, DWORD dwDependSize, LPWSTR lpServiceStartName, LPBYTE lpPassword, DWORD dwPwSize, LPWSTR lpDisplayName)
Definition: rpcserver.c:1920
#define ERR(fmt,...)
Definition: debug.h:110
#define debugstr_w
Definition: kernel32.h:32
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185

Referenced by EnableUserModePnpManager(), InstallOneService(), MMSYS_InstallDevice(), my_test_server(), RpcSsConfigureAsNetworkService(), ServicesPageWndProc(), SetServiceAccount(), SetServiceConfig(), SHELL32_ControlService(), and Test_LockUnlockServiceDatabaseWithServiceStart().

◆ CloseServiceHandle()

BOOL WINAPI CloseServiceHandle ( SC_HANDLE  hSCObject)

Definition at line 580 of file scm.c.

581{
582 DWORD dwError;
583
584 TRACE("CloseServiceHandle(%p)\n",
585 hSCObject);
586
587 if (!hSCObject)
588 {
590 return FALSE;
591 }
592
594 {
595 dwError = RCloseServiceHandle((LPSC_RPC_HANDLE)&hSCObject);
596 }
598 {
600 }
602
603 if (dwError)
604 {
605 TRACE("RCloseServiceHandle() failed (Error %lu)\n", dwError);
606 SetLastError(dwError);
607 return FALSE;
608 }
609
610 TRACE("CloseServiceHandle() done\n");
611
612 return TRUE;
613}
DWORD WINAPI RCloseServiceHandle(LPSC_RPC_HANDLE hSCObject)
Definition: rpcserver.c:936
#define ERROR_INVALID_HANDLE
Definition: compat.h:98

Referenced by _RunRemoteTest(), AccpCloseObjectHandle(), AccpOpenNamedObject(), AddService(), CShellDispatch::CanStartStopService(), cmdContinue(), CmdInstallService(), cmdPause(), CmdRemoveService(), cmdStop(), Control(), control_service(), Create(), Delete(), delete_test_service(), DestroyService(), DoControlService(), DoCreate(), DoDeleteService(), DoRegServer(), DoStartService(), DoStopService(), DoUnregServer(), EnableUserModePnpManager(), EnumDepend(), EnumerateRunningServices(), EnumServices(), fill_service(), GetDisplayName(), GetKeyName(), GetServiceConfig(), GetServiceDescription(), GetServiceFailure(), GetServiceList(), GetServices(), GetThemeServiceProcessHandle(), I_ScQueryServiceTagInfo(), I_ScValidatePnpService(), InstallOneService(), installService(), CShellDispatch::IsServiceRunning(), ITERATE_DeleteService(), ITERATE_InstallService(), ITERATE_StartService(), ITERATE_StopService(), KmtCloseService(), KmtDeleteService(), KmtServiceCleanup(), main(), MMSYS_InstallDevice(), my_test_server(), OpenServiceHelper(), PlayLogonSoundThread(), query_service_config(), QueryConfig(), QueryDescription(), QueryDriverInfo(), QueryFailure(), QueryService(), RegisterDriver(), RegisterService(), RpcSsConfigureAsNetworkService(), RunTest(), SchedEventLogoff(), SchedStartShell(), sds_absent(), sds_present(), SdSet(), SdShow(), ServiceInfo(), ServicesPageWndProc(), ServiceStart(), SetConfig(), SetDescription(), SetFailure(), SetServiceAccount(), SetServiceConfig(), SetServiceDescription(), SetupStartService(), SHELL32_ControlService(), sis_absent(), sis_present(), sss_started(), sss_stopped(), Start(), start_local_service(), start_rpcss(), start_service(), START_TEST(), StartAudioService(), StartDriver(), StartOneService(), StartSystemAudioServices(), stop_service(), stop_service_dependents(), StopDriver(), test_close(), test_create_delete_svc(), Test_CreateService(), test_delete_services(), test_driver_install(), test_enum_svc(), test_get_displayname(), test_get_servicekeyname(), test_install_services(), test_install_svc_from(), Test_LockUnlockServiceDatabase(), Test_LockUnlockServiceDatabaseWithServiceStart(), test_no_stop(), test_open_scm(), test_open_svc(), test_query_svc(), test_queryconfig2(), Test_QueryLockStatusA(), Test_QueryLockStatusW(), Test_QueryServiceConfig2A(), Test_QueryServiceConfig2W(), test_refcount(), test_regconnectregistry(), test_runner(), test_sequence(), test_service(), test_servicenotify(), test_SetupDiInstallClassExA(), test_SetupInstallServicesFromInfSectionExA(), test_SetupInstallServicesFromInfSectionExW(), test_start_stop(), test_start_stop_services(), ThemeWaitForServiceReady(), TV1_AddDependantsToTree(), TV2_GetDependants(), TV2_HasDependantServices(), uninstallService(), UnregisterDriver(), UpdateServiceStatus(), VfdConfigDriver(), VfdGetDriverConfig(), VfdGetDriverState(), VfdInstallDriver(), VfdRemoveDriver(), VfdStartDriver(), VfdStopDriver(), and WahDisableNonIFSHandleSupport().

◆ ControlService()

BOOL WINAPI ControlService ( SC_HANDLE  hService,
DWORD  dwControl,
LPSERVICE_STATUS  lpServiceStatus 
)

Definition at line 622 of file scm.c.

625{
626 DWORD dwError;
627
628 TRACE("ControlService(%p %lu %p)\n",
629 hService, dwControl, lpServiceStatus);
630
632 {
633 dwError = RControlService((SC_RPC_HANDLE)hService,
634 dwControl,
635 lpServiceStatus);
636 }
638 {
640 }
642
643 if (dwError != ERROR_SUCCESS)
644 {
645 TRACE("RControlService() failed (Error %lu)\n", dwError);
646 SetLastError(dwError);
647 return FALSE;
648 }
649
650 TRACE("ControlService() done\n");
651
652 return TRUE;
653}
DWORD WINAPI RControlService(SC_RPC_HANDLE hService, DWORD dwControl, LPSERVICE_STATUS lpServiceStatus)
Definition: rpcserver.c:1069

Referenced by cmdContinue(), cmdPause(), CmdRemoveService(), cmdStop(), Control(), control_service(), DoControlService(), DoStopService(), KmtStopService(), my_test_server(), RequestAddition(), RunTest(), SchedEventLogoff(), SchedStartShell(), SetupInstallServicesFromInfSectionExW(), SHELL32_ControlService(), stop_service(), stop_service_dependents(), StopDriver(), stopService(), Test_LockUnlockServiceDatabaseWithServiceStart(), test_no_stop(), test_service(), test_servicenotify(), test_start_stop_services(), try_start_stop(), and VfdStopDriver().

◆ ControlServiceEx()

BOOL WINAPI ControlServiceEx ( IN SC_HANDLE  hService,
IN DWORD  dwControl,
IN DWORD  dwInfoLevel,
IN OUT PVOID  pControlParams 
)

Definition at line 662 of file scm.c.

666{
667 FIXME("ControlServiceEx(%p %lu %lu %p)\n",
668 hService, dwControl, dwInfoLevel, pControlParams);
670 return FALSE;
671}
#define FIXME(fmt,...)
Definition: debug.h:111
#define ERROR_CALL_NOT_IMPLEMENTED
Definition: compat.h:102

◆ CreateServiceA()

SC_HANDLE WINAPI CreateServiceA ( SC_HANDLE  hSCManager,
LPCSTR  lpServiceName,
LPCSTR  lpDisplayName,
DWORD  dwDesiredAccess,
DWORD  dwServiceType,
DWORD  dwStartType,
DWORD  dwErrorControl,
LPCSTR  lpBinaryPathName,
LPCSTR  lpLoadOrderGroup,
LPDWORD  lpdwTagId,
LPCSTR  lpDependencies,
LPCSTR  lpServiceStartName,
LPCSTR  lpPassword 
)

Definition at line 680 of file scm.c.

693{
694 SC_HANDLE hService = NULL;
695 DWORD dwDependenciesLength = 0;
696 DWORD dwError;
697 SIZE_T cchLength;
698 LPCSTR lpStr;
699 DWORD dwPasswordSize = 0;
700 LPWSTR lpPasswordW = NULL;
701 LPBYTE lpEncryptedPassword = NULL;
702
703 TRACE("CreateServiceA(%p %s %s %lx %lu %lu %lu %s %s %p %s %s %s)\n",
705 dwDesiredAccess, dwServiceType, dwStartType, dwErrorControl,
706 debugstr_a(lpBinaryPathName), debugstr_a(lpLoadOrderGroup), lpdwTagId,
707 debugstr_a(lpDependencies), debugstr_a(lpServiceStartName), debugstr_a(lpPassword));
708
709 if (!hSCManager)
710 {
712 return NULL;
713 }
714
715 /* Calculate the Dependencies length */
716 if (lpDependencies != NULL)
717 {
718 lpStr = lpDependencies;
719 while (*lpStr)
720 {
721 cchLength = strlen(lpStr) + 1;
722 dwDependenciesLength += (DWORD)cchLength;
723 lpStr = lpStr + cchLength;
724 }
725 dwDependenciesLength++;
726 }
727
728 if (lpPassword != NULL)
729 {
730 /* Convert the password to unicode */
731 lpPasswordW = HeapAlloc(GetProcessHeap(),
733 (strlen(lpPassword) + 1) * sizeof(WCHAR));
734 if (lpPasswordW == NULL)
735 {
737 return FALSE;
738 }
739
741 0,
742 lpPassword,
743 -1,
744 lpPasswordW,
745 (int)(strlen(lpPassword) + 1));
746
747 /* Encrypt the password */
749 lpPasswordW,
750 &lpEncryptedPassword,
751 &dwPasswordSize);
752 if (dwError != ERROR_SUCCESS)
753 goto done;
754 }
755
757 {
759 (LPSTR)lpServiceName,
761 dwDesiredAccess,
762 dwServiceType,
763 dwStartType,
764 dwErrorControl,
765 (LPSTR)lpBinaryPathName,
766 (LPSTR)lpLoadOrderGroup,
767 lpdwTagId,
768 (LPBYTE)lpDependencies,
769 dwDependenciesLength,
770 (LPSTR)lpServiceStartName,
771 lpEncryptedPassword,
772 dwPasswordSize,
773 (SC_RPC_HANDLE *)&hService);
774 }
776 {
778 }
780
781done:
782 if (lpPasswordW != NULL)
783 {
784 /* Wipe and release the password buffers */
785 SecureZeroMemory(lpPasswordW, (wcslen(lpPasswordW) + 1) * sizeof(WCHAR));
786 HeapFree(GetProcessHeap(), 0, lpPasswordW);
787
788 if (lpEncryptedPassword != NULL)
789 {
790 SecureZeroMemory(lpEncryptedPassword, dwPasswordSize);
791 HeapFree(GetProcessHeap(), 0, lpEncryptedPassword);
792 }
793 }
794
795 SetLastError(dwError);
796 if (dwError != ERROR_SUCCESS)
797 {
798 TRACE("RCreateServiceA() failed (Error %lu)\n", dwError);
799 return NULL;
800 }
801
802 return hService;
803}
DWORD WINAPI RCreateServiceA(SC_RPC_HANDLE hSCManager, LPSTR lpServiceName, LPSTR lpDisplayName, DWORD dwDesiredAccess, DWORD dwServiceType, DWORD dwStartType, DWORD dwErrorControl, LPSTR lpBinaryPathName, LPSTR lpLoadOrderGroup, LPDWORD lpdwTagId, LPBYTE lpDependencies, DWORD dwDependSize, LPSTR lpServiceStartName, LPBYTE lpPassword, DWORD dwPwSize, LPSC_RPC_HANDLE lpServiceHandle)
Definition: rpcserver.c:3592
SC_HANDLE hSCManager
Definition: sc.c:12

Referenced by InstallService(), register_service(), register_service_exA(), test_create_delete_svc(), test_delete_services(), test_get_displayname(), test_queryconfig2(), test_refcount(), test_sequence(), and test_start_stop().

◆ CreateServiceW()

SC_HANDLE WINAPI CreateServiceW ( SC_HANDLE  hSCManager,
LPCWSTR  lpServiceName,
LPCWSTR  lpDisplayName,
DWORD  dwDesiredAccess,
DWORD  dwServiceType,
DWORD  dwStartType,
DWORD  dwErrorControl,
LPCWSTR  lpBinaryPathName,
LPCWSTR  lpLoadOrderGroup,
LPDWORD  lpdwTagId,
LPCWSTR  lpDependencies,
LPCWSTR  lpServiceStartName,
LPCWSTR  lpPassword 
)

Definition at line 812 of file scm.c.

825{
826 SC_HANDLE hService = NULL;
827 DWORD dwDependenciesLength = 0;
828 DWORD dwError;
829 SIZE_T cchLength;
830 LPCWSTR lpStr;
831 DWORD dwPasswordSize = 0;
832 LPBYTE lpEncryptedPassword = NULL;
833
834 TRACE("CreateServiceW(%p %s %s %lx %lu %lu %lu %s %s %p %s %s %s)\n",
836 dwDesiredAccess, dwServiceType, dwStartType, dwErrorControl,
837 debugstr_w(lpBinaryPathName), debugstr_w(lpLoadOrderGroup), lpdwTagId,
838 debugstr_w(lpDependencies), debugstr_w(lpServiceStartName), debugstr_w(lpPassword));
839
840 if (!hSCManager)
841 {
843 return NULL;
844 }
845
846 /* Calculate the Dependencies length */
847 if (lpDependencies != NULL)
848 {
849 lpStr = lpDependencies;
850 while (*lpStr)
851 {
852 cchLength = wcslen(lpStr) + 1;
853 dwDependenciesLength += (DWORD)cchLength;
854 lpStr = lpStr + cchLength;
855 }
856 dwDependenciesLength++;
857 dwDependenciesLength *= sizeof(WCHAR);
858 }
859
860 if (lpPassword != NULL)
861 {
862 /* Encrypt the password */
864 lpPassword,
865 &lpEncryptedPassword,
866 &dwPasswordSize);
867 if (dwError != ERROR_SUCCESS)
868 goto done;
869 }
870
872 {
874 lpServiceName,
876 dwDesiredAccess,
877 dwServiceType,
878 dwStartType,
879 dwErrorControl,
880 lpBinaryPathName,
881 lpLoadOrderGroup,
882 lpdwTagId,
883 (LPBYTE)lpDependencies,
884 dwDependenciesLength,
885 lpServiceStartName,
886 lpEncryptedPassword,
887 dwPasswordSize,
888 (SC_RPC_HANDLE *)&hService);
889 }
891 {
893 }
895
896done:
897 if (lpEncryptedPassword != NULL)
898 {
899 /* Wipe and release the password buffers */
900 SecureZeroMemory(lpEncryptedPassword, dwPasswordSize);
901 HeapFree(GetProcessHeap(), 0, lpEncryptedPassword);
902 }
903
904 SetLastError(dwError);
905 if (dwError != ERROR_SUCCESS)
906 {
907 TRACE("RCreateServiceW() failed (Error %lu)\n", dwError);
908 return NULL;
909 }
910
911 return hService;
912}
DWORD WINAPI RCreateServiceW(SC_RPC_HANDLE hSCManager, LPCWSTR lpServiceName, LPCWSTR lpDisplayName, DWORD dwDesiredAccess, DWORD dwServiceType, DWORD dwStartType, DWORD dwErrorControl, LPCWSTR lpBinaryPathName, LPCWSTR lpLoadOrderGroup, LPDWORD lpdwTagId, LPBYTE lpDependencies, DWORD dwDependSize, LPCWSTR lpServiceStartName, LPBYTE lpPassword, DWORD dwPwSize, LPSC_RPC_HANDLE lpServiceHandle)
Definition: rpcserver.c:2272

Referenced by _RunRemoteTest(), DoCreate(), DoRegServer(), InstallOneService(), ITERATE_InstallService(), MakeService(), register_service(), register_service_exW(), RegisterDriver(), RegisterService(), and Test_CreateService().

◆ DeleteService()

BOOL WINAPI DeleteService ( SC_HANDLE  hService)

◆ EnumDependentServicesA()

BOOL WINAPI EnumDependentServicesA ( SC_HANDLE  hService,
DWORD  dwServiceState,
LPENUM_SERVICE_STATUSA  lpServices,
DWORD  cbBufSize,
LPDWORD  pcbBytesNeeded,
LPDWORD  lpServicesReturned 
)

Definition at line 955 of file scm.c.

961{
963 LPENUM_SERVICE_STATUSA lpStatusPtr;
964 DWORD dwBufferSize;
965 DWORD dwError;
966 DWORD dwCount;
967
968 TRACE("EnumDependentServicesA(%p %lu %p %lu %p %p)\n",
969 hService, dwServiceState, lpServices, cbBufSize,
970 pcbBytesNeeded, lpServicesReturned);
971
972 if (lpServices == NULL || cbBufSize < sizeof(ENUM_SERVICE_STATUSA))
973 {
974 lpStatusPtr = &ServiceStatus;
975 dwBufferSize = sizeof(ENUM_SERVICE_STATUSA);
976 }
977 else
978 {
979 lpStatusPtr = lpServices;
980 dwBufferSize = cbBufSize;
981 }
982
984 {
985 dwError = REnumDependentServicesA((SC_RPC_HANDLE)hService,
986 dwServiceState,
987 (LPBYTE)lpStatusPtr,
988 dwBufferSize,
990 lpServicesReturned);
991 }
993 {
995 }
997
998 if (dwError == ERROR_SUCCESS || dwError == ERROR_MORE_DATA)
999 {
1000 for (dwCount = 0; dwCount < *lpServicesReturned; dwCount++)
1001 {
1002 if (lpStatusPtr->lpServiceName)
1003 lpStatusPtr->lpServiceName =
1004 (LPSTR)((ULONG_PTR)lpServices + (ULONG_PTR)lpStatusPtr->lpServiceName);
1005
1006 if (lpStatusPtr->lpDisplayName)
1007 lpStatusPtr->lpDisplayName =
1008 (LPSTR)((ULONG_PTR)lpServices + (ULONG_PTR)lpStatusPtr->lpDisplayName);
1009
1010 lpStatusPtr++;
1011 }
1012 }
1013
1014 if (dwError != ERROR_SUCCESS)
1015 {
1016 TRACE("REnumDependentServicesA() failed (Error %lu)\n", dwError);
1017 SetLastError(dwError);
1018 return FALSE;
1019 }
1020
1021 TRACE("EnumDependentServicesA() done\n");
1022
1023 return TRUE;
1024}
static SERVICE_STATUS ServiceStatus
Definition: browser.c:22
DWORD WINAPI REnumDependentServicesA(SC_RPC_HANDLE hService, DWORD dwServiceState, LPBYTE lpServices, DWORD cbBufSize, LPBOUNDED_DWORD_256K pcbBytesNeeded, LPBOUNDED_DWORD_256K lpServicesReturned)
Definition: rpcserver.c:3745
#define ERROR_MORE_DATA
Definition: dderror.h:13
#define ULONG_PTR
Definition: config.h:101
uint32_t ULONG_PTR
Definition: typedefs.h:65
_In_ DWORD _In_ DWORD _Out_ LPDWORD pcbBytesNeeded
Definition: winsvc.h:425
_In_ DWORD _In_ DWORD cbBufSize
Definition: winsvc.h:424
struct _ENUM_SERVICE_STATUSA ENUM_SERVICE_STATUSA

◆ EnumDependentServicesW()

BOOL WINAPI EnumDependentServicesW ( SC_HANDLE  hService,
DWORD  dwServiceState,
LPENUM_SERVICE_STATUSW  lpServices,
DWORD  cbBufSize,
LPDWORD  pcbBytesNeeded,
LPDWORD  lpServicesReturned 
)

Definition at line 1033 of file scm.c.

1039{
1041 LPENUM_SERVICE_STATUSW lpStatusPtr;
1042 DWORD dwBufferSize;
1043 DWORD dwError;
1044 DWORD dwCount;
1045
1046 TRACE("EnumDependentServicesW(%p %lu %p %lu %p %p)\n",
1047 hService, dwServiceState, lpServices, cbBufSize,
1048 pcbBytesNeeded, lpServicesReturned);
1049
1050 if (lpServices == NULL || cbBufSize < sizeof(ENUM_SERVICE_STATUSW))
1051 {
1052 lpStatusPtr = &ServiceStatus;
1053 dwBufferSize = sizeof(ENUM_SERVICE_STATUSW);
1054 }
1055 else
1056 {
1057 lpStatusPtr = lpServices;
1058 dwBufferSize = cbBufSize;
1059 }
1060
1062 {
1063 dwError = REnumDependentServicesW((SC_RPC_HANDLE)hService,
1064 dwServiceState,
1065 (LPBYTE)lpStatusPtr,
1066 dwBufferSize,
1068 lpServicesReturned);
1069 }
1071 {
1073 }
1075
1076 if (dwError == ERROR_SUCCESS || dwError == ERROR_MORE_DATA)
1077 {
1078 for (dwCount = 0; dwCount < *lpServicesReturned; dwCount++)
1079 {
1080 if (lpStatusPtr->lpServiceName)
1081 lpStatusPtr->lpServiceName =
1082 (LPWSTR)((ULONG_PTR)lpServices + (ULONG_PTR)lpStatusPtr->lpServiceName);
1083
1084 if (lpStatusPtr->lpDisplayName)
1085 lpStatusPtr->lpDisplayName =
1086 (LPWSTR)((ULONG_PTR)lpServices + (ULONG_PTR)lpStatusPtr->lpDisplayName);
1087
1088 lpStatusPtr++;
1089 }
1090 }
1091
1092 if (dwError != ERROR_SUCCESS)
1093 {
1094 TRACE("REnumDependentServicesW() failed (Error %lu)\n", dwError);
1095 SetLastError(dwError);
1096 return FALSE;
1097 }
1098
1099 TRACE("EnumDependentServicesW() done\n");
1100
1101 return TRUE;
1102}
DWORD WINAPI REnumDependentServicesW(SC_RPC_HANDLE hService, DWORD dwServiceState, LPBYTE lpServices, DWORD cbBufSize, LPBOUNDED_DWORD_256K pcbBytesNeeded, LPBOUNDED_DWORD_256K lpServicesReturned)
Definition: rpcserver.c:2707
LPWSTR lpDisplayName
Definition: winsvc.h:131
LPWSTR lpServiceName
Definition: winsvc.h:130
struct _ENUM_SERVICE_STATUSW ENUM_SERVICE_STATUSW

Referenced by stop_service_dependents(), and TV2_GetDependants().

◆ EnumServiceGroupW()

BOOL WINAPI EnumServiceGroupW ( SC_HANDLE  hSCManager,
DWORD  dwServiceType,
DWORD  dwServiceState,
LPENUM_SERVICE_STATUSW  lpServices,
DWORD  cbBufSize,
LPDWORD  pcbBytesNeeded,
LPDWORD  lpServicesReturned,
LPDWORD  lpResumeHandle,
LPCWSTR  lpGroup 
)

Definition at line 1111 of file scm.c.

1120{
1122 LPENUM_SERVICE_STATUSW lpStatusPtr;
1123 DWORD dwBufferSize;
1124 DWORD dwError;
1125 DWORD dwCount;
1126
1127 TRACE("EnumServiceGroupW(%p %lu %lu %p %lu %p %p %p %s)\n",
1128 hSCManager, dwServiceType, dwServiceState, lpServices,
1129 cbBufSize, pcbBytesNeeded, lpServicesReturned,
1130 lpResumeHandle, debugstr_w(lpGroup));
1131
1132 if (!hSCManager)
1133 {
1135 return FALSE;
1136 }
1137
1138 if (pcbBytesNeeded == NULL || lpServicesReturned == NULL)
1139 {
1141 return FALSE;
1142 }
1143
1144 if (lpServices == NULL || cbBufSize < sizeof(ENUM_SERVICE_STATUSW))
1145 {
1146 lpStatusPtr = &ServiceStatus;
1147 dwBufferSize = sizeof(ENUM_SERVICE_STATUSW);
1148 }
1149 else
1150 {
1151 lpStatusPtr = lpServices;
1152 dwBufferSize = cbBufSize;
1153 }
1154
1156 {
1157 if (lpGroup == NULL)
1158 {
1160 dwServiceType,
1161 dwServiceState,
1162 (LPBYTE)lpStatusPtr,
1163 dwBufferSize,
1165 lpServicesReturned,
1166 lpResumeHandle);
1167 }
1168 else
1169 {
1171 dwServiceType,
1172 dwServiceState,
1173 (LPBYTE)lpStatusPtr,
1174 dwBufferSize,
1176 lpServicesReturned,
1177 lpResumeHandle,
1178 lpGroup);
1179 }
1180 }
1182 {
1184 }
1186
1187 if (dwError == ERROR_SUCCESS || dwError == ERROR_MORE_DATA)
1188 {
1189 for (dwCount = 0; dwCount < *lpServicesReturned; dwCount++)
1190 {
1191 if (lpStatusPtr->lpServiceName)
1192 lpStatusPtr->lpServiceName =
1193 (LPWSTR)((ULONG_PTR)lpServices + (ULONG_PTR)lpStatusPtr->lpServiceName);
1194
1195 if (lpStatusPtr->lpDisplayName)
1196 lpStatusPtr->lpDisplayName =
1197 (LPWSTR)((ULONG_PTR)lpServices + (ULONG_PTR)lpStatusPtr->lpDisplayName);
1198
1199 lpStatusPtr++;
1200 }
1201 }
1202
1203 if (dwError != ERROR_SUCCESS)
1204 {
1205 TRACE("REnumServiceGroupW() failed (Error %lu)\n", dwError);
1206 SetLastError(dwError);
1207 return FALSE;
1208 }
1209
1210 TRACE("EnumServiceGroupW() done\n");
1211
1212 return TRUE;
1213}
DWORD WINAPI REnumServiceGroupW(SC_RPC_HANDLE hSCManager, DWORD dwServiceType, DWORD dwServiceState, LPBYTE lpBuffer, DWORD cbBufSize, LPBOUNDED_DWORD_256K pcbBytesNeeded, LPBOUNDED_DWORD_256K lpServicesReturned, LPBOUNDED_DWORD_256K lpResumeIndex, LPCWSTR pszGroupName)
Definition: rpcserver.c:4753
DWORD WINAPI REnumServicesStatusW(SC_RPC_HANDLE hSCManager, DWORD dwServiceType, DWORD dwServiceState, LPBYTE lpBuffer, DWORD dwBufSize, LPBOUNDED_DWORD_256K pcbBytesNeeded, LPBOUNDED_DWORD_256K lpServicesReturned, LPBOUNDED_DWORD_256K lpResumeHandle)
Definition: rpcserver.c:2842
#define ERROR_INVALID_ADDRESS
Definition: compat.h:106

◆ EnumServicesStatusA()

BOOL WINAPI EnumServicesStatusA ( SC_HANDLE  hSCManager,
DWORD  dwServiceType,
DWORD  dwServiceState,
LPENUM_SERVICE_STATUSA  lpServices,
DWORD  cbBufSize,
LPDWORD  pcbBytesNeeded,
LPDWORD  lpServicesReturned,
LPDWORD  lpResumeHandle 
)

Definition at line 1222 of file scm.c.

1230{
1232 LPENUM_SERVICE_STATUSA lpStatusPtr;
1233 DWORD dwBufferSize;
1234 DWORD dwError;
1235 DWORD dwCount;
1236
1237 TRACE("EnumServicesStatusA(%p %lu %lu %p %lu %p %p %p)\n",
1238 hSCManager, dwServiceType, dwServiceState, lpServices,
1239 cbBufSize, pcbBytesNeeded, lpServicesReturned, lpResumeHandle);
1240
1241 if (!hSCManager)
1242 {
1244 return FALSE;
1245 }
1246
1247 if (pcbBytesNeeded == NULL || lpServicesReturned == NULL)
1248 {
1250 return FALSE;
1251 }
1252
1253 if (lpServices == NULL || cbBufSize < sizeof(ENUM_SERVICE_STATUSA))
1254 {
1255 lpStatusPtr = &ServiceStatus;
1256 dwBufferSize = sizeof(ENUM_SERVICE_STATUSA);
1257 }
1258 else
1259 {
1260 lpStatusPtr = lpServices;
1261 dwBufferSize = cbBufSize;
1262 }
1263
1265 {
1267 dwServiceType,
1268 dwServiceState,
1269 (LPBYTE)lpStatusPtr,
1270 dwBufferSize,
1272 lpServicesReturned,
1273 lpResumeHandle);
1274 }
1276 {
1278 }
1280
1281 if (dwError == ERROR_SUCCESS || dwError == ERROR_MORE_DATA)
1282 {
1283 for (dwCount = 0; dwCount < *lpServicesReturned; dwCount++)
1284 {
1285 if (lpStatusPtr->lpServiceName)
1286 lpStatusPtr->lpServiceName =
1287 (LPSTR)((ULONG_PTR)lpServices + (ULONG_PTR)lpStatusPtr->lpServiceName);
1288
1289 if (lpStatusPtr->lpDisplayName)
1290 lpStatusPtr->lpDisplayName =
1291 (LPSTR)((ULONG_PTR)lpServices + (ULONG_PTR)lpStatusPtr->lpDisplayName);
1292
1293 lpStatusPtr++;
1294 }
1295 }
1296
1297 if (dwError != ERROR_SUCCESS)
1298 {
1299 TRACE("REnumServicesStatusA() failed (Error %lu)\n", dwError);
1300 SetLastError(dwError);
1301 return FALSE;
1302 }
1303
1304 TRACE("EnumServicesStatusA() done\n");
1305
1306 return TRUE;
1307}
DWORD WINAPI REnumServicesStatusA(SC_RPC_HANDLE hSCManager, DWORD dwServiceType, DWORD dwServiceState, LPBYTE lpBuffer, DWORD dwBufSize, LPBOUNDED_DWORD_256K pcbBytesNeeded, LPBOUNDED_DWORD_256K lpServicesReturned, LPBOUNDED_DWORD_256K lpResumeHandle)
Definition: rpcserver.c:3899

Referenced by test_enum_svc().

◆ EnumServicesStatusExA()

BOOL WINAPI EnumServicesStatusExA ( SC_HANDLE  hSCManager,
SC_ENUM_TYPE  InfoLevel,
DWORD  dwServiceType,
DWORD  dwServiceState,
LPBYTE  lpServices,
DWORD  cbBufSize,
LPDWORD  pcbBytesNeeded,
LPDWORD  lpServicesReturned,
LPDWORD  lpResumeHandle,
LPCSTR  pszGroupName 
)

Definition at line 1410 of file scm.c.

1420{
1423 DWORD dwBufferSize;
1424 DWORD dwError;
1425 DWORD dwCount;
1426
1427 TRACE("EnumServicesStatusExA(%p %lu %lu %p %lu %p %p %p %s)\n",
1428 hSCManager, dwServiceType, dwServiceState, lpServices,
1429 cbBufSize, pcbBytesNeeded, lpServicesReturned, lpResumeHandle,
1430 debugstr_a(pszGroupName));
1431
1432 if (InfoLevel != SC_ENUM_PROCESS_INFO)
1433 {
1435 return FALSE;
1436 }
1437
1438 if (!hSCManager)
1439 {
1441 return FALSE;
1442 }
1443
1444 if (pcbBytesNeeded == NULL || lpServicesReturned == NULL)
1445 {
1447 return FALSE;
1448 }
1449
1450 if (lpServices == NULL || cbBufSize < sizeof(ENUM_SERVICE_STATUS_PROCESSA))
1451 {
1452 lpStatusPtr = &ServiceStatus;
1453 dwBufferSize = sizeof(ENUM_SERVICE_STATUS_PROCESSA);
1454 }
1455 else
1456 {
1457 lpStatusPtr = (LPENUM_SERVICE_STATUS_PROCESSA)lpServices;
1458 dwBufferSize = cbBufSize;
1459 }
1460
1462 {
1464 InfoLevel,
1465 dwServiceType,
1466 dwServiceState,
1467 (LPBYTE)lpStatusPtr,
1468 dwBufferSize,
1470 lpServicesReturned,
1471 lpResumeHandle,
1472 (LPSTR)pszGroupName);
1473 }
1475 {
1477 }
1479
1480 if (dwError == ERROR_SUCCESS || dwError == ERROR_MORE_DATA)
1481 {
1482 if (InfoLevel == SC_ENUM_PROCESS_INFO)
1483 {
1484 for (dwCount = 0; dwCount < *lpServicesReturned; dwCount++)
1485 {
1486 if (lpStatusPtr->lpServiceName)
1487 lpStatusPtr->lpServiceName =
1488 (LPSTR)((ULONG_PTR)lpServices + (ULONG_PTR)lpStatusPtr->lpServiceName);
1489
1490 if (lpStatusPtr->lpDisplayName)
1491 lpStatusPtr->lpDisplayName =
1492 (LPSTR)((ULONG_PTR)lpServices + (ULONG_PTR)lpStatusPtr->lpDisplayName);
1493
1494 lpStatusPtr++;
1495 }
1496 }
1497 }
1498
1499 if (dwError != ERROR_SUCCESS)
1500 {
1501 TRACE("REnumServicesStatusExA() failed (Error %lu)\n", dwError);
1502 SetLastError(dwError);
1503 return FALSE;
1504 }
1505
1506 TRACE("EnumServicesStatusExA() done\n");
1507
1508 return TRUE;
1509}
DWORD WINAPI REnumServicesStatusExA(SC_RPC_HANDLE hSCManager, SC_ENUM_TYPE InfoLevel, DWORD dwServiceType, DWORD dwServiceState, LPBYTE lpBuffer, DWORD cbBufSize, LPBOUNDED_DWORD_256K pcbBytesNeeded, LPBOUNDED_DWORD_256K lpServicesReturned, LPBOUNDED_DWORD_256K lpResumeIndex, LPCSTR pszGroupName)
Definition: rpcserver.c:6096
#define ERROR_INVALID_LEVEL
Definition: winerror.h:196
struct _ENUM_SERVICE_STATUS_PROCESSA ENUM_SERVICE_STATUS_PROCESSA
struct _ENUM_SERVICE_STATUS_PROCESSA * LPENUM_SERVICE_STATUS_PROCESSA
@ SC_ENUM_PROCESS_INFO
Definition: winsvc.h:122

◆ EnumServicesStatusExW()

BOOL WINAPI EnumServicesStatusExW ( SC_HANDLE  hSCManager,
SC_ENUM_TYPE  InfoLevel,
DWORD  dwServiceType,
DWORD  dwServiceState,
LPBYTE  lpServices,
DWORD  cbBufSize,
LPDWORD  pcbBytesNeeded,
LPDWORD  lpServicesReturned,
LPDWORD  lpResumeHandle,
LPCWSTR  pszGroupName 
)

Definition at line 1518 of file scm.c.

1528{
1531 DWORD dwBufferSize;
1532 DWORD dwError;
1533 DWORD dwCount;
1534
1535 TRACE("EnumServicesStatusExW(%p %lu %lu %p %lu %p %p %p %s)\n",
1536 hSCManager, dwServiceType, dwServiceState, lpServices,
1537 cbBufSize, pcbBytesNeeded, lpServicesReturned, lpResumeHandle,
1538 debugstr_w(pszGroupName));
1539
1540 if (InfoLevel != SC_ENUM_PROCESS_INFO)
1541 {
1543 return FALSE;
1544 }
1545
1546 if (!hSCManager)
1547 {
1549 return FALSE;
1550 }
1551
1552 if (pcbBytesNeeded == NULL || lpServicesReturned == NULL)
1553 {
1555 return FALSE;
1556 }
1557
1558 if (lpServices == NULL || cbBufSize < sizeof(ENUM_SERVICE_STATUS_PROCESSW))
1559 {
1560 lpStatusPtr = &ServiceStatus;
1561 dwBufferSize = sizeof(ENUM_SERVICE_STATUS_PROCESSW);
1562 }
1563 else
1564 {
1565 lpStatusPtr = (LPENUM_SERVICE_STATUS_PROCESSW)lpServices;
1566 dwBufferSize = cbBufSize;
1567 }
1568
1570 {
1572 InfoLevel,
1573 dwServiceType,
1574 dwServiceState,
1575 (LPBYTE)lpStatusPtr,
1576 dwBufferSize,
1578 lpServicesReturned,
1579 lpResumeHandle,
1580 (LPWSTR)pszGroupName);
1581 }
1583 {
1585 }
1587
1588 if (dwError == ERROR_SUCCESS || dwError == ERROR_MORE_DATA)
1589 {
1590 if (InfoLevel == SC_ENUM_PROCESS_INFO)
1591 {
1592 for (dwCount = 0; dwCount < *lpServicesReturned; dwCount++)
1593 {
1594 if (lpStatusPtr->lpServiceName)
1595 lpStatusPtr->lpServiceName =
1596 (LPWSTR)((ULONG_PTR)lpServices + (ULONG_PTR)lpStatusPtr->lpServiceName);
1597
1598 if (lpStatusPtr->lpDisplayName)
1599 lpStatusPtr->lpDisplayName =
1600 (LPWSTR)((ULONG_PTR)lpServices + (ULONG_PTR)lpStatusPtr->lpDisplayName);
1601
1602 lpStatusPtr++;
1603 }
1604 }
1605 }
1606
1607 if (dwError != ERROR_SUCCESS)
1608 {
1609 TRACE("REnumServicesStatusExW() failed (Error %lu)\n", dwError);
1610 SetLastError(dwError);
1611 return FALSE;
1612 }
1613
1614 TRACE("EnumServicesStatusExW() done\n");
1615
1616 return TRUE;
1617}
DWORD WINAPI REnumServicesStatusExW(SC_RPC_HANDLE hSCManager, SC_ENUM_TYPE InfoLevel, DWORD dwServiceType, DWORD dwServiceState, LPBYTE lpBuffer, DWORD cbBufSize, LPBOUNDED_DWORD_256K pcbBytesNeeded, LPBOUNDED_DWORD_256K lpServicesReturned, LPBOUNDED_DWORD_256K lpResumeIndex, LPCWSTR pszGroupName)
Definition: rpcserver.c:6235
struct _ENUM_SERVICE_STATUS_PROCESSW * LPENUM_SERVICE_STATUS_PROCESSW
struct _ENUM_SERVICE_STATUS_PROCESSW ENUM_SERVICE_STATUS_PROCESSW

Referenced by fill_service(), and GetServices().

◆ EnumServicesStatusW()

BOOL WINAPI EnumServicesStatusW ( SC_HANDLE  hSCManager,
DWORD  dwServiceType,
DWORD  dwServiceState,
LPENUM_SERVICE_STATUSW  lpServices,
DWORD  cbBufSize,
LPDWORD  pcbBytesNeeded,
LPDWORD  lpServicesReturned,
LPDWORD  lpResumeHandle 
)

Definition at line 1316 of file scm.c.

1324{
1326 LPENUM_SERVICE_STATUSW lpStatusPtr;
1327 DWORD dwBufferSize;
1328 DWORD dwError;
1329 DWORD dwCount;
1330
1331 TRACE("EnumServicesStatusW(%p %lu %lu %p %lu %p %p %p)\n",
1332 hSCManager, dwServiceType, dwServiceState, lpServices,
1333 cbBufSize, pcbBytesNeeded, lpServicesReturned, lpResumeHandle);
1334
1335 if (!hSCManager)
1336 {
1338 return FALSE;
1339 }
1340
1341 if (pcbBytesNeeded == NULL || lpServicesReturned == NULL)
1342 {
1344 return FALSE;
1345 }
1346
1347 if (lpServices == NULL || cbBufSize < sizeof(ENUM_SERVICE_STATUSW))
1348 {
1349 lpStatusPtr = &ServiceStatus;
1350 dwBufferSize = sizeof(ENUM_SERVICE_STATUSW);
1351 }
1352 else
1353 {
1354 lpStatusPtr = lpServices;
1355 dwBufferSize = cbBufSize;
1356 }
1357
1359 {
1361 dwServiceType,
1362 dwServiceState,
1363 (LPBYTE)lpStatusPtr,
1364 dwBufferSize,
1366 lpServicesReturned,
1367 lpResumeHandle);
1368 }
1370 {
1372 }
1374
1375 if (dwError == ERROR_SUCCESS || dwError == ERROR_MORE_DATA)
1376 {
1377 for (dwCount = 0; dwCount < *lpServicesReturned; dwCount++)
1378 {
1379 if (lpStatusPtr->lpServiceName)
1380 lpStatusPtr->lpServiceName =
1381 (LPWSTR)((ULONG_PTR)lpServices + (ULONG_PTR)lpStatusPtr->lpServiceName);
1382
1383 if (lpStatusPtr->lpDisplayName)
1384 lpStatusPtr->lpDisplayName =
1385 (LPWSTR)((ULONG_PTR)lpServices + (ULONG_PTR)lpStatusPtr->lpDisplayName);
1386
1387 lpStatusPtr++;
1388 }
1389 }
1390
1391 if (dwError != ERROR_SUCCESS)
1392 {
1393 TRACE("REnumServicesStatusW() failed (Error %lu)\n", dwError);
1394 SetLastError(dwError);
1395 return FALSE;
1396 }
1397
1398 TRACE("EnumServicesStatusW() done\n");
1399
1400 return TRUE;
1401}

Referenced by EnumerateRunningServices(), and test_enum_svc().

◆ GetServiceDisplayNameA()

BOOL WINAPI GetServiceDisplayNameA ( SC_HANDLE  hSCManager,
LPCSTR  lpServiceName,
LPSTR  lpDisplayName,
LPDWORD  lpcchBuffer 
)

Definition at line 1626 of file scm.c.

1630{
1631 DWORD dwError;
1633 CHAR szEmptyName[] = "";
1634
1635 TRACE("GetServiceDisplayNameA(%p %s %p %p)\n",
1636 hSCManager, debugstr_a(lpServiceName), lpDisplayName, lpcchBuffer);
1637
1638 if (!hSCManager)
1639 {
1641 return FALSE;
1642 }
1643
1644 if (!lpDisplayName || *lpcchBuffer < sizeof(CHAR))
1645 {
1646 lpNameBuffer = szEmptyName;
1647 *lpcchBuffer = sizeof(CHAR);
1648 }
1649 else
1650 {
1652 }
1653
1655 {
1657 lpServiceName,
1659 lpcchBuffer);
1660 }
1662 {
1664 }
1666
1667 if (dwError != ERROR_SUCCESS)
1668 {
1669 TRACE("RGetServiceDisplayNameA() failed (Error %lu)\n", dwError);
1670 SetLastError(dwError);
1671 return FALSE;
1672 }
1673
1674 return TRUE;
1675}
#define CHAR(Char)
DWORD WINAPI RGetServiceDisplayNameA(SC_RPC_HANDLE hSCManager, LPCSTR lpServiceName, LPSTR lpDisplayName, LPBOUNDED_DWORD_4K lpcchBuffer)
Definition: rpcserver.c:4460
static LPSTR lpNameBuffer
Definition: secur32.c:50
char CHAR
Definition: xmlstorage.h:175

Referenced by test_create_delete_svc(), test_get_displayname(), test_get_servicekeyname(), and test_open_svc().

◆ GetServiceDisplayNameW()

BOOL WINAPI GetServiceDisplayNameW ( SC_HANDLE  hSCManager,
LPCWSTR  lpServiceName,
LPWSTR  lpDisplayName,
LPDWORD  lpcchBuffer 
)

Definition at line 1684 of file scm.c.

1688{
1689 DWORD dwError;
1691 WCHAR szEmptyName[] = L"";
1692
1693 TRACE("GetServiceDisplayNameW(%p %s %p %p)\n",
1694 hSCManager, debugstr_w(lpServiceName), lpDisplayName, lpcchBuffer);
1695
1696 if (!hSCManager)
1697 {
1699 return FALSE;
1700 }
1701
1702 /*
1703 * NOTE: A size of 1 character would be enough, but tests show that
1704 * Windows returns 2 characters instead, certainly due to a WCHAR/bytes
1705 * mismatch in their code.
1706 */
1707 if (!lpDisplayName || *lpcchBuffer < sizeof(WCHAR))
1708 {
1709 lpNameBuffer = szEmptyName;
1710 *lpcchBuffer = sizeof(WCHAR);
1711 }
1712 else
1713 {
1715 }
1716
1718 {
1720 lpServiceName,
1722 lpcchBuffer);
1723 }
1725 {
1727 }
1729
1730 if (dwError != ERROR_SUCCESS)
1731 {
1732 TRACE("RGetServiceDisplayNameW() failed (Error %lu)\n", dwError);
1733 SetLastError(dwError);
1734 return FALSE;
1735 }
1736
1737 return TRUE;
1738}
DWORD WINAPI RGetServiceDisplayNameW(SC_RPC_HANDLE hSCManager, LPCWSTR lpServiceName, LPWSTR lpDisplayName, DWORD *lpcchBuffer)
Definition: rpcserver.c:3317
#define L(x)
Definition: ntvdm.h:50

Referenced by ITERATE_DeleteService(), ITERATE_StartService(), ITERATE_StopService(), and test_get_displayname().

◆ GetServiceKeyNameA()

BOOL WINAPI GetServiceKeyNameA ( SC_HANDLE  hSCManager,
LPCSTR  lpDisplayName,
LPSTR  lpServiceName,
LPDWORD  lpcchBuffer 
)

Definition at line 1747 of file scm.c.

1751{
1752 DWORD dwError;
1754 CHAR szEmptyName[] = "";
1755
1756 TRACE("GetServiceKeyNameA(%p %s %p %p)\n",
1757 hSCManager, debugstr_a(lpDisplayName), lpServiceName, lpcchBuffer);
1758
1759 if (!hSCManager)
1760 {
1762 return FALSE;
1763 }
1764
1765 if (!lpServiceName || *lpcchBuffer < sizeof(CHAR))
1766 {
1767 lpNameBuffer = szEmptyName;
1768 *lpcchBuffer = sizeof(CHAR);
1769 }
1770 else
1771 {
1772 lpNameBuffer = lpServiceName;
1773 }
1774
1776 {
1780 lpcchBuffer);
1781 }
1783 {
1784 /* HACK: because of a problem with rpcrt4, rpcserver is hacked to return 6 for ERROR_SERVICE_DOES_NOT_EXIST */
1786 }
1788
1789 if (dwError != ERROR_SUCCESS)
1790 {
1791 TRACE("RGetServiceKeyNameA() failed (Error %lu)\n", dwError);
1792 SetLastError(dwError);
1793 return FALSE;
1794 }
1795
1796 return TRUE;
1797}
DWORD WINAPI RGetServiceKeyNameA(SC_RPC_HANDLE hSCManager, LPCSTR lpDisplayName, LPSTR lpServiceName, LPBOUNDED_DWORD_4K lpcchBuffer)
Definition: rpcserver.c:4582

Referenced by test_get_servicekeyname().

◆ GetServiceKeyNameW()

BOOL WINAPI GetServiceKeyNameW ( SC_HANDLE  hSCManager,
LPCWSTR  lpDisplayName,
LPWSTR  lpServiceName,
LPDWORD  lpcchBuffer 
)

Definition at line 1806 of file scm.c.

1810{
1811 DWORD dwError;
1813 WCHAR szEmptyName[] = L"";
1814
1815 TRACE("GetServiceKeyNameW(%p %s %p %p)\n",
1816 hSCManager, debugstr_w(lpDisplayName), lpServiceName, lpcchBuffer);
1817
1818 if (!hSCManager)
1819 {
1821 return FALSE;
1822 }
1823
1824 /*
1825 * NOTE: A size of 1 character would be enough, but tests show that
1826 * Windows returns 2 characters instead, certainly due to a WCHAR/bytes
1827 * mismatch in their code.
1828 */
1829 if (!lpServiceName || *lpcchBuffer < sizeof(WCHAR))
1830 {
1831 lpNameBuffer = szEmptyName;
1832 *lpcchBuffer = sizeof(WCHAR);
1833 }
1834 else
1835 {
1836 lpNameBuffer = lpServiceName;
1837 }
1838
1840 {
1844 lpcchBuffer);
1845 }
1847 {
1849 }
1851
1852 if (dwError != ERROR_SUCCESS)
1853 {
1854 TRACE("RGetServiceKeyNameW() failed (Error %lu)\n", dwError);
1855 SetLastError(dwError);
1856 return FALSE;
1857 }
1858
1859 return TRUE;
1860}
DWORD WINAPI RGetServiceKeyNameW(SC_RPC_HANDLE hSCManager, LPCWSTR lpDisplayName, LPWSTR lpServiceName, DWORD *lpcchBuffer)
Definition: rpcserver.c:3380

Referenced by test_get_servicekeyname().

◆ I_QueryTagInformation()

DWORD WINAPI I_QueryTagInformation ( PVOID  Unused,
TAG_INFO_LEVEL  dwInfoLevel,
PTAG_INFO_NAME_FROM_TAG  InOutParams 
)

Definition at line 3184 of file scm.c.

3187{
3188 /*
3189 * We only support one information class and it
3190 * needs parameters
3191 */
3193 InOutParams == NULL)
3194 {
3196 }
3197
3198 /* Validate input structure */
3199 if (InOutParams->InParams.dwPid == 0 || InOutParams->InParams.dwTag == 0)
3200 {
3202 }
3203
3204 /* Validate output structure */
3205 if (InOutParams->OutParams.pszName != NULL)
3206 {
3208 }
3209
3210 /* Call internal function for the RPC call */
3212}
#define Unused(x)
Definition: atlwin.h:28
DWORD I_ScQueryServiceTagInfo(PVOID Unused, TAG_INFO_LEVEL dwInfoLevel, PTAG_INFO_NAME_FROM_TAG InOutParams)
Definition: scm.c:3084
TAG_INFO_NAME_FROM_TAG_OUT_PARAMS OutParams
Definition: svcctl.idl:320
TAG_INFO_NAME_FROM_TAG_IN_PARAMS InParams
Definition: svcctl.idl:319
@ TagInfoLevelNameFromTag
Definition: svcctl.idl:300

◆ I_ScGetCurrentGroupStateW()

DWORD WINAPI I_ScGetCurrentGroupStateW ( SC_HANDLE  hSCManager,
LPWSTR  pszGroupName,
LPDWORD  pdwGroupState 
)

Definition at line 1869 of file scm.c.

1872{
1873 DWORD dwError;
1874
1875 TRACE("I_ScGetCurrentGroupStateW(%p %s %p)\n",
1876 hSCManager, debugstr_w(pszGroupName), pdwGroupState);
1877
1879 {
1881 pszGroupName,
1882 pdwGroupState);
1883 }
1885 {
1887 }
1889
1890 if (dwError != ERROR_SUCCESS)
1891 {
1892 TRACE("RI_ScGetCurrentGroupStateW() failed (Error %lu)\n", dwError);
1893 SetLastError(dwError);
1894 }
1895
1896 return dwError;
1897}
DWORD WINAPI RI_ScGetCurrentGroupStateW(SC_RPC_HANDLE hSCManager, LPWSTR lpLoadOrderGroup, LPDWORD lpState)
Definition: rpcserver.c:4696

◆ I_ScQueryServiceTagInfo()

DWORD I_ScQueryServiceTagInfo ( PVOID  Unused,
TAG_INFO_LEVEL  dwInfoLevel,
PTAG_INFO_NAME_FROM_TAG  InOutParams 
)

Definition at line 3084 of file scm.c.

3087{
3088 SC_HANDLE hScm;
3089 DWORD dwError;
3092 LPWSTR lpszName;
3093
3094 /* We only support one class */
3096 {
3097 return ERROR_RETRY;
3098 }
3099
3100 /* Validate input structure */
3101 if (InOutParams->InParams.dwPid == 0 || InOutParams->InParams.dwTag == 0)
3102 {
3104 }
3105
3106 /* Validate output structure */
3107 if (InOutParams->OutParams.pszName != NULL)
3108 {
3110 }
3111
3112 /* Open service manager */
3114 if (hScm == NULL)
3115 {
3116 return GetLastError();
3117 }
3118
3119 /* Setup call parameters */
3120 InParams = &InOutParams->InParams;
3121 OutParams = NULL;
3122
3123 /* Call SCM to query tag information */
3125 {
3126 dwError = RI_ScQueryServiceTagInfo(hScm, TagInfoLevelNameFromTag, &InParams, &OutParams);
3127 }
3129 {
3131 }
3133
3134 /* Quit if not a success */
3135 if (dwError != ERROR_SUCCESS)
3136 {
3137 goto Cleanup;
3138 }
3139
3140 /* OutParams must be set now and we must have a name */
3141 if (OutParams == NULL ||
3142 OutParams->pszName == NULL)
3143 {
3144 dwError = ERROR_INVALID_DATA;
3145 goto Cleanup;
3146 }
3147
3148 /* Copy back what SCM returned */
3149 lpszName = LocalAlloc(LPTR,
3150 sizeof(WCHAR) * wcslen(OutParams->pszName) + sizeof(UNICODE_NULL));
3151 if (lpszName == NULL)
3152 {
3153 dwError = GetLastError();
3154 goto Cleanup;
3155 }
3156
3157 wcscpy(lpszName, OutParams->pszName);
3158 InOutParams->OutParams.pszName = lpszName;
3159 InOutParams->OutParams.TagType = OutParams->TagType;
3160
3161Cleanup:
3162 CloseServiceHandle(hScm);
3163
3164 /* Free memory allocated by SCM */
3165 if (OutParams != NULL)
3166 {
3167 if (OutParams->pszName != NULL)
3168 {
3169 midl_user_free(OutParams->pszName);
3170 }
3171
3172 midl_user_free(OutParams);
3173 }
3174
3175 return dwError;
3176}
DWORD WINAPI RI_ScQueryServiceTagInfo(SC_RPC_HANDLE hSCManager, TAG_INFO_LEVEL dwInfoLevel, PTAG_INFO_NAME_FROM_TAG_IN_PARAMS *lpInParams, PTAG_INFO_NAME_FROM_TAG_OUT_PARAMS *lpOutParams)
Definition: rpcserver.c:6593
static const WCHAR Cleanup[]
Definition: register.c:80
HLOCAL NTAPI LocalAlloc(UINT uFlags, SIZE_T dwBytes)
Definition: heapmem.c:1390
#define UNICODE_NULL
SC_HANDLE WINAPI OpenSCManagerW(LPCWSTR lpMachineName, LPCWSTR lpDatabaseName, DWORD dwDesiredAccess)
Definition: scm.c:2068
BOOL WINAPI CloseServiceHandle(SC_HANDLE hSCObject)
Definition: scm.c:580
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
#define midl_user_free
Definition: rpc.h:45
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
#define LPTR
Definition: winbase.h:381
#define ERROR_RETRY
Definition: winerror.h:740
#define ERROR_INVALID_DATA
Definition: winerror.h:116
#define SC_MANAGER_ENUMERATE_SERVICE
Definition: winsvc.h:16

Referenced by I_QueryTagInformation().

◆ I_ScValidatePnpService()

DWORD WINAPI I_ScValidatePnpService ( _In_ LPCWSTR  pszMachineName,
_In_ LPCWSTR  pszServiceName,
_Out_ SERVICE_STATUS_HANDLE phServiceStatus 
)

Definition at line 1909 of file scm.c.

1913{
1916 DWORD dwError;
1917
1918 TRACE("I_ScValidatePnpService(%S %S %p)\n",
1919 pszMachineName, pszServiceName, phServiceStatus);
1920
1921 hSCManager = OpenSCManagerW(pszMachineName,
1924 if (hSCManager == NULL)
1925 {
1926 dwError = GetLastError();
1927 goto done;
1928 }
1929
1931 {
1933 (LPWSTR)pszServiceName,
1935 }
1937 {
1939 }
1941
1942 *phServiceStatus = hServiceStatus;
1943
1944done:
1945 if (hSCManager != NULL)
1947
1948 return dwError;
1949}
static SERVICE_STATUS_HANDLE(WINAPI *pRegisterServiceCtrlHandlerExA)(LPCSTR
DWORD WINAPI RI_ScValidatePnPService(_In_ SC_RPC_HANDLE hSCManager, _In_ LPWSTR pszServiceName, _Out_ RPC_SERVICE_STATUS_HANDLE *phServiceStatus)
Definition: rpcserver.c:6714
ULONG_PTR RPC_SERVICE_STATUS_HANDLE
Definition: svcctl.idl:20
SERVICE_STATUS_HANDLE hServiceStatus
Definition: main.c:10
#define SC_MANAGER_CONNECT
Definition: winsvc.h:14
#define SERVICES_ACTIVE_DATABASEW
Definition: winsvc.h:8

◆ LockServiceDatabase()

SC_LOCK WINAPI LockServiceDatabase ( SC_HANDLE  hSCManager)

Definition at line 1958 of file scm.c.

1959{
1960 SC_LOCK hLock;
1961 DWORD dwError;
1962
1963 TRACE("LockServiceDatabase(%p)\n",
1964 hSCManager);
1965
1967 {
1969 (SC_RPC_LOCK *)&hLock);
1970 }
1972 {
1974 }
1976
1977 if (dwError != ERROR_SUCCESS)
1978 {
1979 TRACE("RLockServiceDatabase() failed (Error %lu)\n", dwError);
1980 SetLastError(dwError);
1981 return NULL;
1982 }
1983
1984 TRACE("hLock = %p\n", hLock);
1985
1986 return hLock;
1987}
DWORD WINAPI RLockServiceDatabase(SC_RPC_HANDLE hSCManager, LPSC_RPC_LOCK lpLock)
Definition: rpcserver.c:1362

Referenced by SetServiceAccount(), SetServiceConfig(), SetServiceDescription(), Test_LockUnlockServiceDatabase(), Test_LockUnlockServiceDatabaseWithServiceStart(), Test_QueryLockStatusA(), and Test_QueryLockStatusW().

◆ NotifyBootConfigStatus()

BOOL WINAPI NotifyBootConfigStatus ( BOOL  BootAcceptable)

Definition at line 3055 of file scm.c.

3056{
3057 DWORD dwError;
3058
3059 TRACE("NotifyBootConfigStatus(%u)\n",
3060 BootAcceptable);
3061
3063 {
3064 dwError = RNotifyBootConfigStatus(NULL,
3065 BootAcceptable);
3066 }
3068 {
3070 }
3072
3073 if (dwError != ERROR_SUCCESS)
3074 {
3075 TRACE("NotifyBootConfigStatus() failed (Error %lu)\n", dwError);
3076 SetLastError(dwError);
3077 return FALSE;
3078 }
3079
3080 return TRUE;
3081}
DWORD WINAPI RNotifyBootConfigStatus(SVCCTL_HANDLEW lpMachineName, DWORD BootAcceptable)
Definition: rpcserver.c:1849

Referenced by _tmain().

◆ OpenSCManagerA()

SC_HANDLE WINAPI OpenSCManagerA ( LPCSTR  lpMachineName,
LPCSTR  lpDatabaseName,
DWORD  dwDesiredAccess 
)

Definition at line 2024 of file scm.c.

2027{
2028 SC_HANDLE hScm = NULL;
2029 DWORD dwError;
2030
2031 TRACE("OpenSCManagerA(%s %s %lx)\n",
2032 debugstr_a(lpMachineName), debugstr_a(lpDatabaseName), dwDesiredAccess);
2033
2035
2037 {
2038 dwError = ROpenSCManagerA((LPSTR)lpMachineName,
2039 (LPSTR)lpDatabaseName,
2040 dwDesiredAccess,
2041 (SC_RPC_HANDLE *)&hScm);
2042 }
2044 {
2046 }
2048
2049 SetLastError(dwError);
2050 if (dwError != ERROR_SUCCESS)
2051 {
2052 TRACE("ROpenSCManagerA() failed (Error %lu)\n", dwError);
2053 return NULL;
2054 }
2055
2056 TRACE("hScm = %p\n", hScm);
2057
2058 return hScm;
2059}
DWORD WINAPI ROpenSCManagerA(LPSTR lpMachineName, LPSTR lpDatabaseName, DWORD dwDesiredAccess, LPSC_RPC_HANDLE lpScHandle)
Definition: rpcserver.c:4006
static VOID WaitForSCManager(VOID)
Definition: scm.c:1991

Referenced by delete_test_service(), RunTest(), sds_absent(), sds_present(), sis_absent(), sis_present(), sss_started(), sss_stopped(), START_TEST(), test_close(), test_create_delete_svc(), test_delete_services(), test_driver_install(), test_enum_svc(), test_get_displayname(), test_get_servicekeyname(), test_install_services(), test_install_svc_from(), test_open_scm(), test_open_svc(), test_query_svc(), test_queryconfig2(), Test_QueryLockStatusA(), Test_QueryServiceConfig2A(), test_refcount(), test_regconnectregistry(), test_sequence(), test_SetupDiInstallClassExA(), test_SetupInstallServicesFromInfSectionExA(), test_start_stop(), and test_start_stop_services().

◆ OpenSCManagerW()

SC_HANDLE WINAPI OpenSCManagerW ( LPCWSTR  lpMachineName,
LPCWSTR  lpDatabaseName,
DWORD  dwDesiredAccess 
)

Definition at line 2068 of file scm.c.

2071{
2072 SC_HANDLE hScm = NULL;
2073 DWORD dwError;
2074
2075 TRACE("OpenSCManagerW(%s %s %lx)\n",
2076 debugstr_w(lpMachineName), debugstr_w(lpDatabaseName), dwDesiredAccess);
2077
2079
2081 {
2082 dwError = ROpenSCManagerW((LPWSTR)lpMachineName,
2083 (LPWSTR)lpDatabaseName,
2084 dwDesiredAccess,
2085 (SC_RPC_HANDLE *)&hScm);
2086 }
2088 {
2090 }
2092
2093 SetLastError(dwError);
2094 if (dwError != ERROR_SUCCESS)
2095 {
2096 TRACE("ROpenSCManagerW() failed (Error %lu)\n", dwError);
2097 return NULL;
2098 }
2099
2100 TRACE("hScm = %p\n", hScm);
2101
2102 return hScm;
2103}
DWORD WINAPI ROpenSCManagerW(LPWSTR lpMachineName, LPWSTR lpDatabaseName, DWORD dwDesiredAccess, LPSC_RPC_HANDLE lpScHandle)
Definition: rpcserver.c:2868

Referenced by _RunRemoteTest(), cmdStop(), control_service(), DoControlService(), DoCreate(), DoDeleteService(), DoRegServer(), DoStartService(), DoStopService(), DoUnregServer(), EnableUserModePnpManager(), EnumerateRunningServices(), fill_service(), GetServiceConfig(), GetServiceDescription(), GetServiceList(), GetServices(), GetThemeServiceProcessHandle(), I_ScQueryServiceTagInfo(), I_ScValidatePnpService(), InstallOneService(), CShellDispatch::IsServiceRunning(), ITERATE_DeleteService(), ITERATE_InstallService(), ITERATE_StartService(), ITERATE_StopService(), MMSYS_InstallDevice(), my_test_server(), OpenServiceHelper(), RegisterDriver(), RegisterService(), RpcSsConfigureAsNetworkService(), SchedEventLogoff(), SchedStartShell(), ServicesPageWndProc(), SetServiceAccount(), SetServiceConfig(), SetServiceDescription(), SetupStartService(), start_local_service(), start_rpcss(), start_service(), START_TEST(), StartDriver(), StartOneService(), stop_service(), StopDriver(), Test_CreateService(), Test_LockUnlockServiceDatabase(), Test_LockUnlockServiceDatabaseWithServiceStart(), Test_QueryLockStatusW(), Test_QueryServiceConfig2W(), test_service(), test_SetupInstallServicesFromInfSectionExW(), ThemeWaitForServiceReady(), TV1_AddDependantsToTree(), TV2_GetDependants(), TV2_HasDependantServices(), UnregisterDriver(), and UpdateServiceStatus().

◆ OpenServiceA()

SC_HANDLE WINAPI OpenServiceA ( SC_HANDLE  hSCManager,
LPCSTR  lpServiceName,
DWORD  dwDesiredAccess 
)

Definition at line 2112 of file scm.c.

2115{
2116 SC_HANDLE hService = NULL;
2117 DWORD dwError;
2118
2119 TRACE("OpenServiceA(%p %s %lx)\n",
2120 hSCManager, debugstr_a(lpServiceName), dwDesiredAccess);
2121
2122 if (!hSCManager)
2123 {
2125 return NULL;
2126 }
2127
2129 {
2131 (LPSTR)lpServiceName,
2132 dwDesiredAccess,
2133 (SC_RPC_HANDLE *)&hService);
2134 }
2136 {
2138 }
2140
2141 SetLastError(dwError);
2142 if (dwError != ERROR_SUCCESS)
2143 {
2144 TRACE("ROpenServiceA() failed (Error %lu)\n", dwError);
2145 return NULL;
2146 }
2147
2148 TRACE("hService = %p\n", hService);
2149
2150 return hService;
2151}
DWORD WINAPI ROpenServiceA(SC_RPC_HANDLE hSCManager, LPSTR lpServiceName, DWORD dwDesiredAccess, LPSC_RPC_HANDLE lpServiceHandle)
Definition: rpcserver.c:4044

Referenced by delete_test_service(), sds_absent(), sds_present(), sis_absent(), sis_present(), sss_started(), sss_stopped(), test_create_delete_svc(), test_delete_services(), test_driver_install(), test_get_displayname(), test_get_servicekeyname(), test_install_services(), test_install_svc_from(), test_open_svc(), test_query_svc(), test_queryconfig2(), Test_QueryServiceConfig2A(), test_refcount(), test_sequence(), test_servicenotify(), test_SetupDiInstallClassExA(), test_SetupInstallServicesFromInfSectionExA(), test_start_stop(), and test_start_stop_services().

◆ OpenServiceW()

SC_HANDLE WINAPI OpenServiceW ( SC_HANDLE  hSCManager,
LPCWSTR  lpServiceName,
DWORD  dwDesiredAccess 
)

Definition at line 2160 of file scm.c.

2163{
2164 SC_HANDLE hService = NULL;
2165 DWORD dwError;
2166
2167 TRACE("OpenServiceW(%p %s %lx)\n",
2168 hSCManager, debugstr_w(lpServiceName), dwDesiredAccess);
2169
2170 if (!hSCManager)
2171 {
2173 return NULL;
2174 }
2175
2177 {
2179 (LPWSTR)lpServiceName,
2180 dwDesiredAccess,
2181 (SC_RPC_HANDLE *)&hService);
2182 }
2184 {
2186 }
2188
2189 SetLastError(dwError);
2190 if (dwError != ERROR_SUCCESS)
2191 {
2192 TRACE("ROpenServiceW() failed (Error %lu)\n", dwError);
2193 return NULL;
2194 }
2195
2196 TRACE("hService = %p\n", hService);
2197
2198 return hService;
2199}
DWORD WINAPI ROpenServiceW(SC_RPC_HANDLE hSCManager, LPWSTR lpServiceName, DWORD dwDesiredAccess, LPSC_RPC_HANDLE lpServiceHandle)
Definition: rpcserver.c:2920

Referenced by _RunRemoteTest(), AddService(), cmdStop(), control_service(), DoControlService(), DoDeleteService(), DoStartService(), DoStopService(), DoUnregServer(), EnableUserModePnpManager(), GetServiceConfig(), GetServiceDescription(), GetThemeServiceProcessHandle(), InstallOneService(), CShellDispatch::IsServiceRunning(), ITERATE_DeleteService(), ITERATE_StartService(), MMSYS_InstallDevice(), OpenServiceHelper(), PlayLogonSoundThread(), query_service_config(), RpcSsConfigureAsNetworkService(), SchedEventLogoff(), SchedStartShell(), ServicesPageWndProc(), SetServiceAccount(), SetServiceConfig(), SetServiceDescription(), SetupStartService(), start_local_service(), start_rpcss(), start_service(), StartDriver(), StartOneService(), stop_service(), stop_service_dependents(), StopDriver(), Test_LockUnlockServiceDatabaseWithServiceStart(), Test_QueryServiceConfig2W(), test_service(), test_SetupInstallServicesFromInfSectionExW(), ThemeWaitForServiceReady(), TV1_AddDependantsToTree(), TV2_GetDependants(), TV2_HasDependantServices(), UnregisterDriver(), and UpdateServiceStatus().

◆ QueryServiceConfig2A()

BOOL WINAPI QueryServiceConfig2A ( SC_HANDLE  hService,
DWORD  dwInfoLevel,
LPBYTE  lpBuffer,
DWORD  cbBufSize,
LPDWORD  pcbBytesNeeded 
)

Definition at line 2374 of file scm.c.

2379{
2380 SERVICE_DESCRIPTIONA ServiceDescription;
2381 SERVICE_FAILURE_ACTIONSA ServiceFailureActions;
2382 LPBYTE lpTempBuffer;
2383 BOOL bUseTempBuffer = FALSE;
2384 DWORD dwBufferSize;
2385 DWORD dwError;
2386
2387 TRACE("QueryServiceConfig2A(%p %lu %p %lu %p)\n",
2389
2390 lpTempBuffer = lpBuffer;
2391 dwBufferSize = cbBufSize;
2392
2393 switch (dwInfoLevel)
2394 {
2396 if ((lpBuffer == NULL) || (cbBufSize < sizeof(SERVICE_DESCRIPTIONA)))
2397 {
2398 lpTempBuffer = (LPBYTE)&ServiceDescription;
2399 dwBufferSize = sizeof(SERVICE_DESCRIPTIONA);
2400 bUseTempBuffer = TRUE;
2401 }
2402 break;
2403
2405 if ((lpBuffer == NULL) || (cbBufSize < sizeof(SERVICE_FAILURE_ACTIONSA)))
2406 {
2407 lpTempBuffer = (LPBYTE)&ServiceFailureActions;
2408 dwBufferSize = sizeof(SERVICE_FAILURE_ACTIONSA);
2409 bUseTempBuffer = TRUE;
2410 }
2411 break;
2412
2413 default:
2414 WARN("Unknown info level 0x%lx\n", dwInfoLevel);
2416 return FALSE;
2417 }
2418
2420 {
2421 dwError = RQueryServiceConfig2A((SC_RPC_HANDLE)hService,
2423 lpTempBuffer,
2424 dwBufferSize,
2426 }
2428 {
2430 }
2432
2433 if (dwError != ERROR_SUCCESS)
2434 {
2435 TRACE("RQueryServiceConfig2A() failed (Error %lu)\n", dwError);
2436 SetLastError(dwError);
2437 return FALSE;
2438 }
2439
2440 if (bUseTempBuffer != FALSE)
2441 {
2442 TRACE("RQueryServiceConfig2A() returns ERROR_INSUFFICIENT_BUFFER\n");
2443 *pcbBytesNeeded = dwBufferSize;
2445 return FALSE;
2446 }
2447
2448 switch (dwInfoLevel)
2449 {
2451 {
2452 LPSERVICE_DESCRIPTIONA lpPtr = (LPSERVICE_DESCRIPTIONA)lpTempBuffer;
2453
2454 if (lpPtr->lpDescription != NULL)
2455 lpPtr->lpDescription =
2456 (LPSTR)((ULONG_PTR)lpPtr + (ULONG_PTR)lpPtr->lpDescription);
2457 }
2458 break;
2459
2461 {
2463
2464 if (lpPtr->lpRebootMsg != NULL)
2465 lpPtr->lpRebootMsg =
2466 (LPSTR)((ULONG_PTR)lpPtr + (ULONG_PTR)lpPtr->lpRebootMsg);
2467
2468 if (lpPtr->lpCommand != NULL)
2469 lpPtr->lpCommand =
2470 (LPSTR)((ULONG_PTR)lpPtr + (ULONG_PTR)lpPtr->lpCommand);
2471
2472 if (lpPtr->lpsaActions != NULL)
2473 lpPtr->lpsaActions =
2474 (LPSC_ACTION)((ULONG_PTR)lpPtr + (ULONG_PTR)lpPtr->lpsaActions);
2475 }
2476 break;
2477 }
2478
2479 TRACE("QueryServiceConfig2A() done\n");
2480
2481 return TRUE;
2482}
DWORD WINAPI RQueryServiceConfig2A(SC_RPC_HANDLE hService, DWORD dwInfoLevel, LPBYTE lpBuffer, DWORD cbBufSize, LPBOUNDED_DWORD_8K pcbBytesNeeded)
Definition: rpcserver.c:5552
static TAGREF LPCWSTR LPDWORD LPVOID lpBuffer
Definition: db.cpp:175
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10
unsigned int BOOL
Definition: ntddk_ex.h:94
SC_ACTION * lpsaActions
Definition: winsvc.h:213
struct _SERVICE_DESCRIPTIONA SERVICE_DESCRIPTIONA
struct _SERVICE_FAILURE_ACTIONSA * LPSERVICE_FAILURE_ACTIONSA
struct _SC_ACTION * LPSC_ACTION
struct _SERVICE_DESCRIPTIONA * LPSERVICE_DESCRIPTIONA
struct _SERVICE_FAILURE_ACTIONSA SERVICE_FAILURE_ACTIONSA

Referenced by QueryConfig2A().

◆ QueryServiceConfig2W()

BOOL WINAPI QueryServiceConfig2W ( SC_HANDLE  hService,
DWORD  dwInfoLevel,
LPBYTE  lpBuffer,
DWORD  cbBufSize,
LPDWORD  pcbBytesNeeded 
)

Definition at line 2491 of file scm.c.

2496{
2497 SERVICE_DESCRIPTIONW ServiceDescription;
2498 SERVICE_FAILURE_ACTIONSW ServiceFailureActions;
2499 LPBYTE lpTempBuffer;
2500 BOOL bUseTempBuffer = FALSE;
2501 DWORD dwBufferSize;
2502 DWORD dwError;
2503
2504 TRACE("QueryServiceConfig2W(%p %lu %p %lu %p)\n",
2506
2507 lpTempBuffer = lpBuffer;
2508 dwBufferSize = cbBufSize;
2509
2510 switch (dwInfoLevel)
2511 {
2513 if ((lpBuffer == NULL) || (cbBufSize < sizeof(SERVICE_DESCRIPTIONW)))
2514 {
2515 lpTempBuffer = (LPBYTE)&ServiceDescription;
2516 dwBufferSize = sizeof(SERVICE_DESCRIPTIONW);
2517 bUseTempBuffer = TRUE;
2518 }
2519 break;
2520
2522 if ((lpBuffer == NULL) || (cbBufSize < sizeof(SERVICE_FAILURE_ACTIONSW)))
2523 {
2524 lpTempBuffer = (LPBYTE)&ServiceFailureActions;
2525 dwBufferSize = sizeof(SERVICE_FAILURE_ACTIONSW);
2526 bUseTempBuffer = TRUE;
2527 }
2528 break;
2529
2530 default:
2531 WARN("Unknown info level 0x%lx\n", dwInfoLevel);
2533 return FALSE;
2534 }
2535
2537 {
2538 dwError = RQueryServiceConfig2W((SC_RPC_HANDLE)hService,
2540 lpTempBuffer,
2541 dwBufferSize,
2543 }
2545 {
2547 }
2549
2550 if (dwError != ERROR_SUCCESS)
2551 {
2552 TRACE("RQueryServiceConfig2W() failed (Error %lu)\n", dwError);
2553 SetLastError(dwError);
2554 return FALSE;
2555 }
2556
2557 if (bUseTempBuffer != FALSE)
2558 {
2559 TRACE("RQueryServiceConfig2W() returns ERROR_INSUFFICIENT_BUFFER\n");
2560 *pcbBytesNeeded = dwBufferSize;
2562 return FALSE;
2563 }
2564
2565 switch (dwInfoLevel)
2566 {
2568 {
2569 LPSERVICE_DESCRIPTIONW lpPtr = (LPSERVICE_DESCRIPTIONW)lpTempBuffer;
2570
2571 if (lpPtr->lpDescription != NULL)
2572 lpPtr->lpDescription =
2573 (LPWSTR)((ULONG_PTR)lpPtr + (ULONG_PTR)lpPtr->lpDescription);
2574 }
2575 break;
2576
2578 {
2580
2581 if (lpPtr->lpRebootMsg != NULL)
2582 lpPtr->lpRebootMsg =
2583 (LPWSTR)((ULONG_PTR)lpPtr + (ULONG_PTR)lpPtr->lpRebootMsg);
2584
2585 if (lpPtr->lpCommand != NULL)
2586 lpPtr->lpCommand =
2587 (LPWSTR)((ULONG_PTR)lpPtr + (ULONG_PTR)lpPtr->lpCommand);
2588
2589 if (lpPtr->lpsaActions != NULL)
2590 lpPtr->lpsaActions =
2591 (LPSC_ACTION)((ULONG_PTR)lpPtr + (ULONG_PTR)lpPtr->lpsaActions);
2592 }
2593 break;
2594 }
2595
2596 TRACE("QueryServiceConfig2W() done\n");
2597
2598 return TRUE;
2599}
DWORD WINAPI RQueryServiceConfig2W(SC_RPC_HANDLE hService, DWORD dwInfoLevel, LPBYTE lpBuffer, DWORD cbBufSize, LPBOUNDED_DWORD_8K pcbBytesNeeded)
Definition: rpcserver.c:5799
LPWSTR lpDescription
Definition: winsvc.h:196
SC_ACTION * lpsaActions
Definition: winsvc.h:220
struct _SERVICE_FAILURE_ACTIONSW SERVICE_FAILURE_ACTIONSW
struct _SERVICE_DESCRIPTIONW SERVICE_DESCRIPTIONW
struct _SERVICE_DESCRIPTIONW * LPSERVICE_DESCRIPTIONW
struct _SERVICE_FAILURE_ACTIONSW * LPSERVICE_FAILURE_ACTIONSW

Referenced by GetServiceDescription(), and QueryConfig2W().

◆ QueryServiceConfigA()

BOOL WINAPI QueryServiceConfigA ( SC_HANDLE  hService,
LPQUERY_SERVICE_CONFIGA  lpServiceConfig,
DWORD  cbBufSize,
LPDWORD  pcbBytesNeeded 
)

Definition at line 2208 of file scm.c.

2212{
2213 QUERY_SERVICE_CONFIGA ServiceConfig;
2214 LPQUERY_SERVICE_CONFIGA lpConfigPtr;
2215 DWORD dwBufferSize;
2216 DWORD dwError;
2217
2218 TRACE("QueryServiceConfigA(%p %p %lu %p)\n",
2219 hService, lpServiceConfig, cbBufSize, pcbBytesNeeded);
2220
2221 if (lpServiceConfig == NULL ||
2223 {
2224 lpConfigPtr = &ServiceConfig;
2225 dwBufferSize = sizeof(QUERY_SERVICE_CONFIGA);
2226 }
2227 else
2228 {
2229 lpConfigPtr = lpServiceConfig;
2230 dwBufferSize = cbBufSize;
2231 }
2232
2234 {
2235 dwError = RQueryServiceConfigA((SC_RPC_HANDLE)hService,
2236 (LPBYTE)lpConfigPtr,
2237 dwBufferSize,
2239 }
2241 {
2243 }
2245
2246 if (dwError != ERROR_SUCCESS)
2247 {
2248 TRACE("RQueryServiceConfigA() failed (Error %lu)\n", dwError);
2249 SetLastError(dwError);
2250 return FALSE;
2251 }
2252
2253 /* Adjust the pointers */
2254 if (lpConfigPtr->lpBinaryPathName)
2255 lpConfigPtr->lpBinaryPathName =
2256 (LPSTR)((ULONG_PTR)lpConfigPtr +
2257 (ULONG_PTR)lpConfigPtr->lpBinaryPathName);
2258
2259 if (lpConfigPtr->lpLoadOrderGroup)
2260 lpConfigPtr->lpLoadOrderGroup =
2261 (LPSTR)((ULONG_PTR)lpConfigPtr +
2262 (ULONG_PTR)lpConfigPtr->lpLoadOrderGroup);
2263
2264 if (lpConfigPtr->lpDependencies)
2265 lpConfigPtr->lpDependencies =
2266 (LPSTR)((ULONG_PTR)lpConfigPtr +
2267 (ULONG_PTR)lpConfigPtr->lpDependencies);
2268
2269 if (lpConfigPtr->lpServiceStartName)
2270 lpConfigPtr->lpServiceStartName =
2271 (LPSTR)((ULONG_PTR)lpConfigPtr +
2272 (ULONG_PTR)lpConfigPtr->lpServiceStartName);
2273
2274 if (lpConfigPtr->lpDisplayName)
2275 lpConfigPtr->lpDisplayName =
2276 (LPSTR)((ULONG_PTR)lpConfigPtr +
2277 (ULONG_PTR)lpConfigPtr->lpDisplayName);
2278
2279 TRACE("QueryServiceConfigA() done\n");
2280
2281 return TRUE;
2282}
DWORD WINAPI RQueryServiceConfigA(SC_RPC_HANDLE hService, LPBYTE lpBuf, DWORD cbBufSize, LPBOUNDED_DWORD_8K pcbBytesNeeded)
Definition: rpcserver.c:4074
LPSTR lpServiceStartName
Definition: winsvc.h:152
struct _QUERY_SERVICE_CONFIGA QUERY_SERVICE_CONFIGA

Referenced by test_sequence().

◆ QueryServiceConfigW()

BOOL WINAPI QueryServiceConfigW ( SC_HANDLE  hService,
LPQUERY_SERVICE_CONFIGW  lpServiceConfig,
DWORD  cbBufSize,
LPDWORD  pcbBytesNeeded 
)

Definition at line 2291 of file scm.c.

2295{
2296 QUERY_SERVICE_CONFIGW ServiceConfig;
2297 LPQUERY_SERVICE_CONFIGW lpConfigPtr;
2298 DWORD dwBufferSize;
2299 DWORD dwError;
2300
2301 TRACE("QueryServiceConfigW(%p %p %lu %p)\n",
2302 hService, lpServiceConfig, cbBufSize, pcbBytesNeeded);
2303
2304 if (lpServiceConfig == NULL ||
2306 {
2307 lpConfigPtr = &ServiceConfig;
2308 dwBufferSize = sizeof(QUERY_SERVICE_CONFIGW);
2309 }
2310 else
2311 {
2312 lpConfigPtr = lpServiceConfig;
2313 dwBufferSize = cbBufSize;
2314 }
2315
2317 {
2318 dwError = RQueryServiceConfigW((SC_RPC_HANDLE)hService,
2319 (LPBYTE)lpConfigPtr,
2320 dwBufferSize,
2322 }
2324 {
2326 }
2328
2329 if (dwError != ERROR_SUCCESS)
2330 {
2331 TRACE("RQueryServiceConfigW() failed (Error %lu)\n", dwError);
2332 SetLastError(dwError);
2333 return FALSE;
2334 }
2335
2336 /* Adjust the pointers */
2337 if (lpConfigPtr->lpBinaryPathName)
2338 lpConfigPtr->lpBinaryPathName =
2339 (LPWSTR)((ULONG_PTR)lpConfigPtr +
2340 (ULONG_PTR)lpConfigPtr->lpBinaryPathName);
2341
2342 if (lpConfigPtr->lpLoadOrderGroup)
2343 lpConfigPtr->lpLoadOrderGroup =
2344 (LPWSTR)((ULONG_PTR)lpConfigPtr +
2345 (ULONG_PTR)lpConfigPtr->lpLoadOrderGroup);
2346
2347 if (lpConfigPtr->lpDependencies)
2348 lpConfigPtr->lpDependencies =
2349 (LPWSTR)((ULONG_PTR)lpConfigPtr +
2350 (ULONG_PTR)lpConfigPtr->lpDependencies);
2351
2352 if (lpConfigPtr->lpServiceStartName)
2353 lpConfigPtr->lpServiceStartName =
2354 (LPWSTR)((ULONG_PTR)lpConfigPtr +
2355 (ULONG_PTR)lpConfigPtr->lpServiceStartName);
2356
2357 if (lpConfigPtr->lpDisplayName)
2358 lpConfigPtr->lpDisplayName =
2359 (LPWSTR)((ULONG_PTR)lpConfigPtr +
2360 (ULONG_PTR)lpConfigPtr->lpDisplayName);
2361
2362 TRACE("QueryServiceConfigW() done\n");
2363
2364 return TRUE;
2365}
DWORD WINAPI RQueryServiceConfigW(SC_RPC_HANDLE hService, LPBYTE lpBuf, DWORD cbBufSize, LPBOUNDED_DWORD_8K pcbBytesNeeded)
Definition: rpcserver.c:3003
LPWSTR lpServiceStartName
Definition: winsvc.h:163
LPWSTR lpBinaryPathName
Definition: winsvc.h:159
LPWSTR lpLoadOrderGroup
Definition: winsvc.h:160
struct _QUERY_SERVICE_CONFIGW QUERY_SERVICE_CONFIGW

Referenced by AddService(), GetServiceConfig(), InstallOneService(), query_service_config(), ServicesPageWndProc(), Test_LockUnlockServiceDatabaseWithServiceStart(), and TV1_GetDependants().

◆ QueryServiceLockStatusA()

BOOL WINAPI QueryServiceLockStatusA ( SC_HANDLE  hSCManager,
LPQUERY_SERVICE_LOCK_STATUSA  lpLockStatus,
DWORD  cbBufSize,
LPDWORD  pcbBytesNeeded 
)

Definition at line 2608 of file scm.c.

2612{
2613 QUERY_SERVICE_LOCK_STATUSA LockStatus;
2614 LPQUERY_SERVICE_LOCK_STATUSA lpStatusPtr;
2615 DWORD dwBufferSize;
2616 DWORD dwError;
2617
2618 TRACE("QueryServiceLockStatusA(%p %p %lu %p)\n",
2619 hSCManager, lpLockStatus, cbBufSize, pcbBytesNeeded);
2620
2621 if (lpLockStatus == NULL || cbBufSize < sizeof(QUERY_SERVICE_LOCK_STATUSA))
2622 {
2623 lpStatusPtr = &LockStatus;
2624 dwBufferSize = sizeof(QUERY_SERVICE_LOCK_STATUSA);
2625 }
2626 else
2627 {
2628 lpStatusPtr = lpLockStatus;
2629 dwBufferSize = cbBufSize;
2630 }
2631
2633 {
2635 (LPBYTE)lpStatusPtr,
2636 dwBufferSize,
2638 }
2640 {
2642 }
2644
2645 if (dwError != ERROR_SUCCESS)
2646 {
2647 TRACE("RQueryServiceLockStatusA() failed (Error %lu)\n", dwError);
2648 SetLastError(dwError);
2649 return FALSE;
2650 }
2651
2652 if (lpStatusPtr->lpLockOwner != NULL)
2653 {
2654 lpStatusPtr->lpLockOwner =
2655 (LPSTR)((ULONG_PTR)lpStatusPtr + (ULONG_PTR)lpStatusPtr->lpLockOwner);
2656 }
2657
2658 TRACE("QueryServiceLockStatusA() done\n");
2659
2660 return TRUE;
2661}
DWORD WINAPI RQueryServiceLockStatusA(SC_RPC_HANDLE hSCManager, LPBYTE lpBuf, DWORD cbBufSize, LPBOUNDED_DWORD_4K pcbBytesNeeded)
Definition: rpcserver.c:4315
struct _QUERY_SERVICE_LOCK_STATUSA QUERY_SERVICE_LOCK_STATUSA

Referenced by Test_QueryLockStatusA().

◆ QueryServiceLockStatusW()

BOOL WINAPI QueryServiceLockStatusW ( SC_HANDLE  hSCManager,
LPQUERY_SERVICE_LOCK_STATUSW  lpLockStatus,
DWORD  cbBufSize,
LPDWORD  pcbBytesNeeded 
)

Definition at line 2670 of file scm.c.

2674{
2675 QUERY_SERVICE_LOCK_STATUSW LockStatus;
2676 LPQUERY_SERVICE_LOCK_STATUSW lpStatusPtr;
2677 DWORD dwBufferSize;
2678 DWORD dwError;
2679
2680 TRACE("QueryServiceLockStatusW(%p %p %lu %p)\n",
2681 hSCManager, lpLockStatus, cbBufSize, pcbBytesNeeded);
2682
2683 if (lpLockStatus == NULL || cbBufSize < sizeof(QUERY_SERVICE_LOCK_STATUSW))
2684 {
2685 lpStatusPtr = &LockStatus;
2686 dwBufferSize = sizeof(QUERY_SERVICE_LOCK_STATUSW);
2687 }
2688 else
2689 {
2690 lpStatusPtr = lpLockStatus;
2691 dwBufferSize = cbBufSize;
2692 }
2693
2695 {
2697 (LPBYTE)lpStatusPtr,
2698 dwBufferSize,
2700 }
2702 {
2704 }
2706
2707 if (dwError != ERROR_SUCCESS)
2708 {
2709 TRACE("RQueryServiceLockStatusW() failed (Error %lu)\n", dwError);
2710 SetLastError(dwError);
2711 return FALSE;
2712 }
2713
2714 if (lpStatusPtr->lpLockOwner != NULL)
2715 {
2716 lpStatusPtr->lpLockOwner =
2717 (LPWSTR)((ULONG_PTR)lpStatusPtr + (ULONG_PTR)lpStatusPtr->lpLockOwner);
2718 }
2719
2720 TRACE("QueryServiceLockStatusW() done\n");
2721
2722 return TRUE;
2723}
DWORD WINAPI RQueryServiceLockStatusW(SC_RPC_HANDLE hSCManager, LPBYTE lpBuf, DWORD cbBufSize, LPBOUNDED_DWORD_4K pcbBytesNeeded)
Definition: rpcserver.c:3211
struct _QUERY_SERVICE_LOCK_STATUSW QUERY_SERVICE_LOCK_STATUSW

Referenced by Test_QueryLockStatusW().

◆ QueryServiceObjectSecurity()

BOOL WINAPI QueryServiceObjectSecurity ( SC_HANDLE  hService,
SECURITY_INFORMATION  dwSecurityInformation,
PSECURITY_DESCRIPTOR  lpSecurityDescriptor,
DWORD  cbBufSize,
LPDWORD  pcbBytesNeeded 
)

Definition at line 2732 of file scm.c.

2737{
2738 DWORD dwError;
2739
2740 TRACE("QueryServiceObjectSecurity(%p %lu %p)\n",
2741 hService, dwSecurityInformation, lpSecurityDescriptor);
2742
2744 {
2745 dwError = RQueryServiceObjectSecurity((SC_RPC_HANDLE)hService,
2746 dwSecurityInformation,
2747 (LPBYTE)lpSecurityDescriptor,
2748 cbBufSize,
2750 }
2752 {
2754 }
2756
2757 if (dwError != ERROR_SUCCESS)
2758 {
2759 TRACE("QueryServiceObjectSecurity() failed (Error %lu)\n", dwError);
2760 SetLastError(dwError);
2761 return FALSE;
2762 }
2763
2764 return TRUE;
2765}
DWORD WINAPI RQueryServiceObjectSecurity(SC_RPC_HANDLE hService, SECURITY_INFORMATION dwSecurityInformation, LPBYTE lpSecurityDescriptor, DWORD cbBufSize, LPBOUNDED_DWORD_256K pcbBytesNeeded)
Definition: rpcserver.c:1390

Referenced by AccRewriteGetHandleRights(), and SdShow().

◆ QueryServiceStatus()

BOOL WINAPI QueryServiceStatus ( SC_HANDLE  hService,
LPSERVICE_STATUS  lpServiceStatus 
)

Definition at line 2845 of file scm.c.

2847{
2848 DWORD dwError;
2849
2850 TRACE("QueryServiceStatus(%p %p)\n",
2851 hService, lpServiceStatus);
2852
2853 if (!hService)
2854 {
2856 return FALSE;
2857 }
2858
2860 {
2861 dwError = RQueryServiceStatus((SC_RPC_HANDLE)hService,
2862 lpServiceStatus);
2863 }
2865 {
2867 }
2869
2870 if (dwError != ERROR_SUCCESS)
2871 {
2872 TRACE("RQueryServiceStatus() failed (Error %lu)\n", dwError);
2873 SetLastError(dwError);
2874 return FALSE;
2875 }
2876
2877 return TRUE;
2878}
DWORD WINAPI RQueryServiceStatus(SC_RPC_HANDLE hService, LPSERVICE_STATUS lpServiceStatus)
Definition: rpcserver.c:1608

Referenced by _RunRemoteTest(), CmdRemoveService(), KmtEnsureServiceState(), my_test_server(), QueryDriverInfo(), ServiceInfo(), ServiceStart(), sss_started(), sss_stopped(), stopService(), Test_LockUnlockServiceDatabaseWithServiceStart(), test_no_stop(), test_query_svc(), test_service(), test_startA(), test_startW(), VfdGetDriverState(), VfdStartDriver(), and VfdStopDriver().

◆ QueryServiceStatusEx()

BOOL WINAPI QueryServiceStatusEx ( SC_HANDLE  hService,
SC_STATUS_TYPE  InfoLevel,
LPBYTE  lpBuffer,
DWORD  cbBufSize,
LPDWORD  pcbBytesNeeded 
)

Definition at line 2887 of file scm.c.

2892{
2893 DWORD dwError;
2894
2895 TRACE("QueryServiceStatusEx(%p %lu %p %lu %p)\n",
2896 hService, InfoLevel, lpBuffer, cbBufSize, pcbBytesNeeded);
2897
2898 if (InfoLevel != SC_STATUS_PROCESS_INFO)
2899 {
2901 return FALSE;
2902 }
2903
2904 if (cbBufSize < sizeof(SERVICE_STATUS_PROCESS))
2905 {
2908 return FALSE;
2909 }
2910
2912 {
2913 dwError = RQueryServiceStatusEx((SC_RPC_HANDLE)hService,
2914 InfoLevel,
2915 lpBuffer,
2916 cbBufSize,
2918 }
2920 {
2922 }
2924
2925 if (dwError != ERROR_SUCCESS)
2926 {
2927 TRACE("RQueryServiceStatusEx() failed (Error %lu)\n", dwError);
2928 SetLastError(dwError);
2929 return FALSE;
2930 }
2931
2932 return TRUE;
2933}
DWORD WINAPI RQueryServiceStatusEx(SC_RPC_HANDLE hService, SC_STATUS_TYPE InfoLevel, LPBYTE lpBuffer, DWORD cbBufSize, LPBOUNDED_DWORD_8K pcbBytesNeeded)
Definition: rpcserver.c:6023
@ SC_STATUS_PROCESS_INFO
Definition: winsvc.h:119
struct _SERVICE_STATUS_PROCESS SERVICE_STATUS_PROCESS

Referenced by DoControlService(), DoStartService(), DoStopService(), EnableUserModePnpManager(), GetThemeServiceProcessHandle(), CShellDispatch::IsServiceRunning(), ITERATE_StartService(), PlayLogonSoundThread(), QueryService(), start_rpcss(), stop_service(), test_no_stop(), test_service(), ThemeWaitForServiceReady(), UpdateServiceStatus(), WaitForService(), and WaitService().

◆ ScmEncryptPassword()

static DWORD ScmEncryptPassword ( _In_ PVOID  ContextHandle,
_In_ PCWSTR  pClearTextPassword,
_Out_ PBYTE pEncryptedPassword,
_Out_ PDWORD  pEncryptedPasswordSize 
)
static

Definition at line 173 of file scm.c.

178{
179 struct ustring inData, keyData, outData;
180 BYTE SessionKey[16];
183
184 /* Get the session key */
185 Status = SystemFunction028(ContextHandle,
186 SessionKey);
187 if (!NT_SUCCESS(Status))
188 {
189 ERR("SystemFunction028 failed (Status 0x%08lx)\n", Status);
191 }
192
193 inData.Length = (wcslen(pClearTextPassword) + 1) * sizeof(WCHAR);
194 inData.MaximumLength = inData.Length;
195 inData.Buffer = (unsigned char *)pClearTextPassword;
196
197 keyData.Length = sizeof(SessionKey);
198 keyData.MaximumLength = keyData.Length;
199 keyData.Buffer = SessionKey;
200
201 outData.Length = 0;
202 outData.MaximumLength = 0;
203 outData.Buffer = NULL;
204
205 /* Get the required buffer size */
206 Status = SystemFunction004(&inData,
207 &keyData,
208 &outData);
210 {
211 ERR("SystemFunction004 failed (Status 0x%08lx)\n", Status);
213 }
214
215 /* Allocate a buffer for the encrypted password */
216 pBuffer = HeapAlloc(GetProcessHeap(), 0, outData.Length);
217 if (pBuffer == NULL)
218 return ERROR_OUTOFMEMORY;
219
220 outData.MaximumLength = outData.Length;
221 outData.Buffer = pBuffer;
222
223 /* Encrypt the password */
224 Status = SystemFunction004(&inData,
225 &keyData,
226 &outData);
227 if (!NT_SUCCESS(Status))
228 {
229 ERR("SystemFunction004 failed (Status 0x%08lx)\n", Status);
232 }
233
234 *pEncryptedPassword = outData.Buffer;
235 *pEncryptedPasswordSize = outData.Length;
236
237 return ERROR_SUCCESS;
238}
LONG NTSTATUS
Definition: precomp.h:26
#define ERROR_OUTOFMEMORY
Definition: deptool.c:13
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
Status
Definition: gdiplustypes.h:25
NTSYSAPI ULONG WINAPI RtlNtStatusToDosError(NTSTATUS)
BYTE * PBYTE
Definition: pedump.c:66
PVOID pBuffer
NTSTATUS WINAPI SystemFunction028(IN PVOID ContextHandle, OUT LPBYTE SessionKey)
NTSTATUS WINAPI SystemFunction004(const struct ustring *in, const struct ustring *key, struct ustring *out)
Definition: sysfunc.c:119
#define STATUS_BUFFER_TOO_SMALL
Definition: shellext.h:69
Definition: config.c:19
unsigned char BYTE
Definition: xxhash.c:193

Referenced by ChangeServiceConfigA(), ChangeServiceConfigW(), CreateServiceA(), and CreateServiceW().

◆ ScmRpcStatusToWinError()

DWORD ScmRpcStatusToWinError ( RPC_STATUS  Status)

Definition at line 146 of file scm.c.

147{
148 TRACE("ScmRpcStatusToWinError(%lx)\n",
149 Status);
150
151 switch (Status)
152 {
157
161
164
165 default:
166 return (DWORD)Status;
167 }
168}
#define STATUS_ACCESS_VIOLATION
Definition: ntstatus.h:242
#define RPC_X_ENUM_VALUE_OUT_OF_RANGE
Definition: winerror.h:1088
#define RPC_X_SS_IN_NULL_CONTEXT
Definition: winerror.h:1083
#define RPC_X_NULL_REF_POINTER
Definition: winerror.h:1087
#define RPC_X_BYTE_COUNT_TOO_SMALL
Definition: winerror.h:1089
#define RPC_S_INVALID_BINDING
Definition: winerror.h:1013

Referenced by ChangeServiceConfig2A(), ChangeServiceConfig2W(), ChangeServiceConfigA(), ChangeServiceConfigW(), CloseServiceHandle(), ControlService(), CreateServiceA(), CreateServiceW(), DeleteService(), EnumDependentServicesA(), EnumDependentServicesW(), EnumServiceGroupW(), EnumServicesStatusA(), EnumServicesStatusExA(), EnumServicesStatusExW(), EnumServicesStatusW(), GetServiceDisplayNameA(), GetServiceDisplayNameW(), GetServiceKeyNameA(), GetServiceKeyNameW(), I_ScGetCurrentGroupStateW(), I_ScQueryServiceTagInfo(), I_ScSetServiceBitsA(), I_ScSetServiceBitsW(), I_ScValidatePnpService(), LockServiceDatabase(), NotifyBootConfigStatus(), OpenSCManagerA(), OpenSCManagerW(), OpenServiceA(), OpenServiceW(), QueryServiceConfig2A(), QueryServiceConfig2W(), QueryServiceConfigA(), QueryServiceConfigW(), QueryServiceLockStatusA(), QueryServiceLockStatusW(), QueryServiceObjectSecurity(), QueryServiceStatus(), QueryServiceStatusEx(), SetServiceObjectSecurity(), SetServiceStatus(), StartServiceA(), StartServiceW(), and UnlockServiceDatabase().

◆ SetServiceObjectSecurity()

BOOL WINAPI SetServiceObjectSecurity ( SC_HANDLE  hService,
SECURITY_INFORMATION  dwSecurityInformation,
PSECURITY_DESCRIPTOR  lpSecurityDescriptor 
)

Definition at line 2774 of file scm.c.

2777{
2778 PSECURITY_DESCRIPTOR SelfRelativeSD = NULL;
2779 ULONG Length;
2781 DWORD dwError;
2782
2783 TRACE("SetServiceObjectSecurity(%p %lu %p)\n",
2784 hService, dwSecurityInformation, lpSecurityDescriptor);
2785
2786 Length = 0;
2787 Status = RtlMakeSelfRelativeSD(lpSecurityDescriptor,
2788 SelfRelativeSD,
2789 &Length);
2791 {
2793 return FALSE;
2794 }
2795
2796 SelfRelativeSD = HeapAlloc(GetProcessHeap(), 0, Length);
2797 if (SelfRelativeSD == NULL)
2798 {
2800 return FALSE;
2801 }
2802
2803 Status = RtlMakeSelfRelativeSD(lpSecurityDescriptor,
2804 SelfRelativeSD,
2805 &Length);
2806 if (!NT_SUCCESS(Status))
2807 {
2808 HeapFree(GetProcessHeap(), 0, SelfRelativeSD);
2810 return FALSE;
2811 }
2812
2814 {
2815 dwError = RSetServiceObjectSecurity((SC_RPC_HANDLE)hService,
2816 dwSecurityInformation,
2817 (LPBYTE)SelfRelativeSD,
2818 Length);
2819 }
2821 {
2823 }
2825
2826 HeapFree(GetProcessHeap(), 0, SelfRelativeSD);
2827
2828 if (dwError != ERROR_SUCCESS)
2829 {
2830 TRACE("RServiceObjectSecurity() failed (Error %lu)\n", dwError);
2831 SetLastError(dwError);
2832 return FALSE;
2833 }
2834
2835 return TRUE;
2836}
DWORD WINAPI RSetServiceObjectSecurity(SC_RPC_HANDLE hService, DWORD dwSecurityInformation, LPBYTE lpSecurityDescriptor, DWORD dwSecurityDescriptorSize)
Definition: rpcserver.c:1474
NTSYSAPI NTSTATUS NTAPI RtlMakeSelfRelativeSD(_In_ PSECURITY_DESCRIPTOR AbsoluteSD, _Out_ PSECURITY_DESCRIPTOR SelfRelativeSD, _Inout_ PULONG BufferLength)
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:102
uint32_t ULONG
Definition: typedefs.h:59

Referenced by AccRewriteSetHandleRights(), InstallOneService(), and SdSet().

◆ StartServiceA()

BOOL WINAPI StartServiceA ( SC_HANDLE  hService,
DWORD  dwNumServiceArgs,
LPCSTR lpServiceArgVectors 
)

Definition at line 2942 of file scm.c.

2945{
2946 DWORD dwError;
2947
2948 TRACE("StartServiceA(%p %lu %p)\n",
2949 hService, dwNumServiceArgs, lpServiceArgVectors);
2950
2952 {
2953 dwError = RStartServiceA((SC_RPC_HANDLE)hService,
2954 dwNumServiceArgs,
2955 (LPSTRING_PTRSA)lpServiceArgVectors);
2956 }
2958 {
2960 }
2962
2963 if (dwError != ERROR_SUCCESS)
2964 {
2965 ERR("RStartServiceA() failed (Error %lu)\n", dwError);
2966 SetLastError(dwError);
2967 return FALSE;
2968 }
2969
2970 return TRUE;
2971}
DWORD WINAPI RStartServiceA(SC_RPC_HANDLE hService, DWORD argc, LPSTRING_PTRSA argv)
Definition: rpcserver.c:4358

Referenced by RunTest(), test_no_stop(), test_service(), test_servicenotify(), test_start_stop_services(), test_startA(), and try_start_stop().

◆ StartServiceW()

BOOL WINAPI StartServiceW ( SC_HANDLE  hService,
DWORD  dwNumServiceArgs,
LPCWSTR lpServiceArgVectors 
)

Definition at line 2980 of file scm.c.

2983{
2984 DWORD dwError;
2985
2986 TRACE("StartServiceW(%p %lu %p)\n",
2987 hService, dwNumServiceArgs, lpServiceArgVectors);
2988
2990 {
2991 dwError = RStartServiceW((SC_RPC_HANDLE)hService,
2992 dwNumServiceArgs,
2993 (LPSTRING_PTRSW)lpServiceArgVectors);
2994 }
2996 {
2998 }
3000
3001 if (dwError != ERROR_SUCCESS)
3002 {
3003 ERR("RStartServiceW() failed (Error %lu)\n", dwError);
3004 SetLastError(dwError);
3005 return FALSE;
3006 }
3007
3008 return TRUE;
3009}
DWORD WINAPI RStartServiceW(SC_RPC_HANDLE hService, DWORD argc, LPSTRING_PTRSW argv)
Definition: rpcserver.c:3254

Referenced by _RunRemoteTest(), DoStartService(), EnableUserModePnpManager(), ITERATE_StartService(), MMSYS_InstallDevice(), my_test_server(), start_local_service(), start_rpcss(), start_service(), StartDriver(), StartOneService(), Test_LockUnlockServiceDatabaseWithServiceStart(), and test_startW().

◆ SVCCTL_HANDLEA_bind()

handle_t __RPC_USER SVCCTL_HANDLEA_bind ( SVCCTL_HANDLEA  szMachineName)

Definition at line 32 of file scm.c.

33{
35 RPC_CSTR pszStringBinding;
37
38 TRACE("SVCCTL_HANDLEA_bind(%s)\n",
39 debugstr_a(szMachineName));
40
42 (RPC_CSTR)"ncacn_np",
43 (RPC_CSTR)szMachineName,
44 (RPC_CSTR)"\\pipe\\ntsvcs",
45 NULL,
46 &pszStringBinding);
47 if (status != RPC_S_OK)
48 {
49 ERR("RpcStringBindingCompose returned 0x%x\n", status);
50 return NULL;
51 }
52
53 /* Set the binding handle that will be used to bind to the server. */
54 status = RpcBindingFromStringBindingA(pszStringBinding,
55 &hBinding);
56 if (status != RPC_S_OK)
57 {
58 ERR("RpcBindingFromStringBinding returned 0x%x\n", status);
59 }
60
61 status = RpcStringFreeA(&pszStringBinding);
62 if (status != RPC_S_OK)
63 {
64 ERR("RpcStringFree returned 0x%x\n", status);
65 }
66
67 return hBinding;
68}
handle_t hBinding
Definition: ctx_c.c:54
RPC_STATUS WINAPI RpcStringBindingComposeA(RPC_CSTR ObjUuid, RPC_CSTR Protseq, RPC_CSTR NetworkAddr, RPC_CSTR Endpoint, RPC_CSTR Options, RPC_CSTR *StringBinding)
Definition: rpc_binding.c:457
RPC_STATUS WINAPI RpcBindingFromStringBindingA(RPC_CSTR StringBinding, RPC_BINDING_HANDLE *Binding)
Definition: rpc_binding.c:840
unsigned char * RPC_CSTR
Definition: rpcdce.h:45
#define RPC_S_OK
Definition: rpcnterr.h:22
RPC_STATUS WINAPI RpcStringFreeA(RPC_CSTR *String)
Definition: rpcrt4_main.c:158
long RPC_STATUS
Definition: rpc.h:52
Definition: ps.c:97

◆ SVCCTL_HANDLEA_unbind()

void __RPC_USER SVCCTL_HANDLEA_unbind ( SVCCTL_HANDLEA  szMachineName,
handle_t  hBinding 
)

Definition at line 72 of file scm.c.

74{
76
77 TRACE("SVCCTL_HANDLEA_unbind(%s %p)\n",
78 debugstr_a(szMachineName), hBinding);
79
81 if (status != RPC_S_OK)
82 {
83 ERR("RpcBindingFree returned 0x%x\n", status);
84 }
85}
RPC_STATUS WINAPI RpcBindingFree(RPC_BINDING_HANDLE *Binding)
Definition: rpc_binding.c:787

◆ SVCCTL_HANDLEW_bind()

handle_t __RPC_USER SVCCTL_HANDLEW_bind ( SVCCTL_HANDLEW  szMachineName)

Definition at line 89 of file scm.c.

90{
92 RPC_WSTR pszStringBinding;
94
95 TRACE("SVCCTL_HANDLEW_bind(%s)\n",
96 debugstr_w(szMachineName));
97
99 L"ncacn_np",
100 szMachineName,
101 L"\\pipe\\ntsvcs",
102 NULL,
103 &pszStringBinding);
104 if (status != RPC_S_OK)
105 {
106 ERR("RpcStringBindingCompose returned 0x%x\n", status);
107 return NULL;
108 }
109
110 /* Set the binding handle that will be used to bind to the server. */
111 status = RpcBindingFromStringBindingW(pszStringBinding,
112 &hBinding);
113 if (status != RPC_S_OK)
114 {
115 ERR("RpcBindingFromStringBinding returned 0x%x\n", status);
116 }
117
118 status = RpcStringFreeW(&pszStringBinding);
119 if (status != RPC_S_OK)
120 {
121 ERR("RpcStringFree returned 0x%x\n", status);
122 }
123
124 return hBinding;
125}
RPC_STATUS WINAPI RpcBindingFromStringBindingW(RPC_WSTR StringBinding, RPC_BINDING_HANDLE *Binding)
Definition: rpc_binding.c:880
RPC_STATUS WINAPI RpcStringBindingComposeW(RPC_WSTR ObjUuid, RPC_WSTR Protseq, RPC_WSTR NetworkAddr, RPC_WSTR Endpoint, RPC_WSTR Options, RPC_WSTR *StringBinding)
Definition: rpc_binding.c:510
unsigned short * RPC_WSTR
Definition: rpcdce.h:46
RPC_STATUS WINAPI RpcStringFreeW(RPC_WSTR *String)
Definition: rpcrt4_main.c:175

◆ SVCCTL_HANDLEW_unbind()

void __RPC_USER SVCCTL_HANDLEW_unbind ( SVCCTL_HANDLEW  szMachineName,
handle_t  hBinding 
)

Definition at line 129 of file scm.c.

131{
133
134 TRACE("SVCCTL_HANDLEW_unbind(%s %p)\n",
135 debugstr_w(szMachineName), hBinding);
136
138 if (status != RPC_S_OK)
139 {
140 ERR("RpcBindingFree returned 0x%x\n", status);
141 }
142}

◆ SystemFunction004()

NTSTATUS WINAPI SystemFunction004 ( const struct ustring in,
const struct ustring key,
struct ustring out 
)

Definition at line 119 of file sysfunc.c.

122{
123 union {
124 unsigned char uc[8];
125 unsigned int ui[2];
126 } data;
127 unsigned char deskey[7];
128 unsigned int crypt_len, ofs;
129
130 if (key->Length<=0)
132
133 crypt_len = ((in->Length+7)&~7);
134 if (out->MaximumLength < (crypt_len+8))
135 {
136 out->Length = crypt_len + 8;
138 }
139
140 data.ui[0] = in->Length;
141 data.ui[1] = 1;
142
143 if (key->Length<sizeof deskey)
144 {
145 memset(deskey, 0, sizeof deskey);
146 memcpy(deskey, key->Buffer, key->Length);
147 }
148 else
149 memcpy(deskey, key->Buffer, sizeof deskey);
150
151 CRYPT_DEShash(out->Buffer, deskey, data.uc);
152
153 for(ofs=0; ofs<(crypt_len-8); ofs+=8)
154 CRYPT_DEShash(out->Buffer+8+ofs, deskey, in->Buffer+ofs);
155
156 memset(data.uc, 0, sizeof data.uc);
157 memcpy(data.uc, in->Buffer+ofs, in->Length +8-crypt_len);
158 CRYPT_DEShash(out->Buffer+8+ofs, deskey, data.uc);
159
160 out->Length = crypt_len+8;
161
162 return STATUS_SUCCESS;
163}
unsigned char * CRYPT_DEShash(unsigned char *dst, const unsigned char *key, const unsigned char *src) DECLSPEC_HIDDEN
Definition: crypt_des.c:259
static void deskey(const unsigned char *key, short edf, ulong32 *keyout)
Definition: des.c:1285
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
GLuint in
Definition: glext.h:9616
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define STATUS_INVALID_PARAMETER_2
Definition: ntstatus.h:476
UINT ui
Definition: oleauto.h:49
static FILE * out
Definition: regtests2xml.c:44
#define memset(x, y, z)
Definition: compat.h:39
#define STATUS_SUCCESS
Definition: shellext.h:65
Definition: copy.c:22

Referenced by ScmEncryptPassword().

◆ SystemFunction028()

NTSTATUS WINAPI SystemFunction028 ( IN PVOID  ContextHandle,
OUT LPBYTE  SessionKey 
)

Referenced by ScmEncryptPassword().

◆ UnlockServiceDatabase()

BOOL WINAPI UnlockServiceDatabase ( SC_LOCK  ScLock)

Definition at line 3018 of file scm.c.

3019{
3020 DWORD dwError;
3021
3022 TRACE("UnlockServiceDatabase(%x)\n",
3023 ScLock);
3024
3026 {
3027 dwError = RUnlockServiceDatabase((LPSC_RPC_LOCK)&ScLock);
3028 }
3030 {
3032 }
3034
3035 if (dwError == ERROR_INVALID_HANDLE)
3037
3038 if (dwError != ERROR_SUCCESS)
3039 {
3040 TRACE("RUnlockServiceDatabase() failed (Error %lu)\n", dwError);
3041 SetLastError(dwError);
3042 return FALSE;
3043 }
3044
3045 return TRUE;
3046}
DWORD WINAPI RUnlockServiceDatabase(LPSC_RPC_LOCK Lock)
Definition: rpcserver.c:1838
#define ERROR_INVALID_SERVICE_LOCK
Definition: winerror.h:622

Referenced by SetServiceAccount(), SetServiceConfig(), SetServiceDescription(), Test_LockUnlockServiceDatabase(), Test_LockUnlockServiceDatabaseWithServiceStart(), Test_QueryLockStatusA(), and Test_QueryLockStatusW().

◆ WaitForSCManager()

static VOID WaitForSCManager ( VOID  )
static

Definition at line 1991 of file scm.c.

1992{
1993 HANDLE hEvent;
1994
1995 TRACE("WaitForSCManager()\n");
1996
1997 /* Try to open the existing event */
1999 if (hEvent == NULL)
2000 {
2002 return;
2003
2004 /* Try to create a new event */
2006 if (hEvent == NULL)
2007 return;
2008 }
2009
2010 /* Wait for 3 minutes */
2011 WaitForSingleObject(hEvent, 180000);
2013
2014 TRACE("ScmWaitForSCManager() done\n");
2015}
#define CloseHandle
Definition: compat.h:739
#define ERROR_FILE_NOT_FOUND
Definition: disk.h:79
static HANDLE hEvent
Definition: comm.c:54
#define SYNCHRONIZE
Definition: nt_native.h:61
#define SCM_START_EVENT
Definition: services.h:26
HANDLE WINAPI DECLSPEC_HOTPATCH OpenEventW(IN DWORD dwDesiredAccess, IN BOOL bInheritHandle, IN LPCWSTR lpName)
Definition: synch.c:682
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
HANDLE WINAPI DECLSPEC_HOTPATCH CreateEventW(IN LPSECURITY_ATTRIBUTES lpEventAttributes OPTIONAL, IN BOOL bManualReset, IN BOOL bInitialState, IN LPCWSTR lpName OPTIONAL)
Definition: synch.c:651

Referenced by OpenSCManagerA(), and OpenSCManagerW().

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( advapi  )