ReactOS  0.4.12-dev-945-g5a2911d
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_ 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)
 
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 246 of file scm.c.

249 {
251  DWORD dwError;
252 
253  TRACE("ChangeServiceConfig2A(%p %lu %p)\n",
254  hService, dwInfoLevel, lpInfo);
255 
256  if (lpInfo == NULL) return TRUE;
257 
258  /* Fill relevant field of the Info structure */
259  Info.dwInfoLevel = dwInfoLevel;
260  switch (dwInfoLevel)
261  {
263  Info.psd = lpInfo;
264  break;
265 
267  Info.psfa = lpInfo;
268  break;
269 
270  default:
271  WARN("Unknown info level 0x%lx\n", dwInfoLevel);
273  return FALSE;
274  }
275 
277  {
278  dwError = RChangeServiceConfig2A((SC_RPC_HANDLE)hService,
279  Info);
280  }
282  {
284  }
285  RpcEndExcept;
286 
287  if (dwError != ERROR_SUCCESS)
288  {
289  TRACE("RChangeServiceConfig2A() failed (Error %lu)\n", dwError);
290  SetLastError(dwError);
291  return FALSE;
292  }
293 
294  return TRUE;
295 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
#define RpcEndExcept
Definition: rpc.h:128
#define TRUE
Definition: types.h:120
#define ERROR_SUCCESS
Definition: deptool.c:10
#define WARN(fmt,...)
Definition: debug.h:111
#define SERVICE_CONFIG_DESCRIPTION
Definition: winsvc.h:65
struct TraceInfo Info
#define RpcTryExcept
Definition: rpc.h:126
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
smooth NULL
Definition: ftsmooth.c:416
#define RpcExceptionCode()
Definition: rpc.h:132
#define TRACE(s)
Definition: solgame.cpp:4
DWORD ScmRpcStatusToWinError(RPC_STATUS Status)
Definition: scm.c:146
#define SERVICE_CONFIG_FAILURE_ACTIONS
Definition: winsvc.h:66
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:409
_In_ DWORD dwInfoLevel
Definition: winsvc.h:422
DWORD WINAPI RChangeServiceConfig2A(SC_RPC_HANDLE hService, SC_RPC_CONFIG_INFOA Info)
Definition: rpcserver.c:5013
#define RpcExcept(expr)
Definition: rpc.h:127

◆ ChangeServiceConfig2W()

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

Definition at line 304 of file scm.c.

307 {
309  DWORD dwError;
310 
311  TRACE("ChangeServiceConfig2W(%p %lu %p)\n",
312  hService, dwInfoLevel, lpInfo);
313 
314  if (lpInfo == NULL) return TRUE;
315 
316  /* Fill relevant field of the Info structure */
317  Info.dwInfoLevel = dwInfoLevel;
318  switch (dwInfoLevel)
319  {
321  Info.psd = lpInfo;
322  break;
323 
325  Info.psfa = lpInfo;
326  break;
327 
328  default:
329  WARN("Unknown info level 0x%lx\n", dwInfoLevel);
331  return FALSE;
332  }
333 
335  {
336  dwError = RChangeServiceConfig2W((SC_RPC_HANDLE)hService,
337  Info);
338  }
340  {
342  }
343  RpcEndExcept;
344 
345  if (dwError != ERROR_SUCCESS)
346  {
347  TRACE("RChangeServiceConfig2W() failed (Error %lu)\n", dwError);
348  SetLastError(dwError);
349  return FALSE;
350  }
351 
352  return TRUE;
353 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
#define RpcEndExcept
Definition: rpc.h:128
#define TRUE
Definition: types.h:120
#define ERROR_SUCCESS
Definition: deptool.c:10
#define WARN(fmt,...)
Definition: debug.h:111
#define SERVICE_CONFIG_DESCRIPTION
Definition: winsvc.h:65
struct TraceInfo Info
#define RpcTryExcept
Definition: rpc.h:126
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
smooth NULL
Definition: ftsmooth.c:416
#define RpcExceptionCode()
Definition: rpc.h:132
#define TRACE(s)
Definition: solgame.cpp:4
DWORD ScmRpcStatusToWinError(RPC_STATUS Status)
Definition: scm.c:146
#define SERVICE_CONFIG_FAILURE_ACTIONS
Definition: winsvc.h:66
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:409
_In_ DWORD dwInfoLevel
Definition: winsvc.h:422
DWORD WINAPI RChangeServiceConfig2W(SC_RPC_HANDLE hService, SC_RPC_CONFIG_INFOW Info)
Definition: rpcserver.c:5414
#define RpcExcept(expr)
Definition: rpc.h:127

Referenced by ITERATE_InstallService(), 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 362 of file scm.c.

373 {
374  DWORD dwError;
375  DWORD dwDependenciesLength = 0;
376  SIZE_T cchLength;
377  LPCSTR lpStr;
378  DWORD dwPasswordSize = 0;
379  LPWSTR lpPasswordW = NULL;
380  LPBYTE lpEncryptedPassword = NULL;
381 
382  TRACE("ChangeServiceConfigA(%p %lu %lu %lu %s %s %p %s %s %s %s)\n",
383  hService, dwServiceType, dwStartType, dwErrorControl, debugstr_a(lpBinaryPathName),
384  debugstr_a(lpLoadOrderGroup), lpdwTagId, debugstr_a(lpDependencies),
385  debugstr_a(lpServiceStartName), debugstr_a(lpPassword), debugstr_a(lpDisplayName));
386 
387  /* Calculate the Dependencies length*/
388  if (lpDependencies != NULL)
389  {
390  lpStr = lpDependencies;
391  while (*lpStr)
392  {
393  cchLength = strlen(lpStr) + 1;
394  dwDependenciesLength += (DWORD)cchLength;
395  lpStr = lpStr + cchLength;
396  }
397  dwDependenciesLength++;
398  }
399 
400  if (lpPassword != NULL)
401  {
402  /* Convert the password to unicode */
403  lpPasswordW = HeapAlloc(GetProcessHeap(),
405  (strlen(lpPassword) + 1) * sizeof(WCHAR));
406  if (lpPasswordW == NULL)
407  {
409  return FALSE;
410  }
411 
413  0,
414  lpPassword,
415  -1,
416  lpPasswordW,
417  (int)(strlen(lpPassword) + 1));
418 
419  /* Encrypt the unicode password */
420  dwError = ScmEncryptPassword(lpPasswordW,
421  &lpEncryptedPassword,
422  &dwPasswordSize);
423  if (dwError != ERROR_SUCCESS)
424  goto done;
425  }
426 
428  {
429  dwError = RChangeServiceConfigA((SC_RPC_HANDLE)hService,
430  dwServiceType,
431  dwStartType,
432  dwErrorControl,
433  (LPSTR)lpBinaryPathName,
434  (LPSTR)lpLoadOrderGroup,
435  lpdwTagId,
436  (LPBYTE)lpDependencies,
437  dwDependenciesLength,
438  (LPSTR)lpServiceStartName,
439  lpEncryptedPassword,
440  dwPasswordSize,
442  }
444  {
446  }
447  RpcEndExcept;
448 
449 done:
450  if (lpPasswordW != NULL)
451  {
452  /* Wipe and release the password buffers */
453  SecureZeroMemory(lpPasswordW, (wcslen(lpPasswordW) + 1) * sizeof(WCHAR));
454  HeapFree(GetProcessHeap(), 0, lpPasswordW);
455 
456  if (lpEncryptedPassword != NULL)
457  {
458  SecureZeroMemory(lpEncryptedPassword, dwPasswordSize);
459  HeapFree(GetProcessHeap(), 0, lpEncryptedPassword);
460  }
461  }
462 
463  if (dwError != ERROR_SUCCESS)
464  {
465  TRACE("RChangeServiceConfigA() failed (Error %lu)\n", dwError);
466  SetLastError(dwError);
467  return FALSE;
468  }
469 
470  return TRUE;
471 }
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:3455
#define RpcEndExcept
Definition: rpc.h:128
#define TRUE
Definition: types.h:120
#define ERROR_SUCCESS
Definition: deptool.c:10
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
#define SecureZeroMemory
Definition: winbase.h:1636
#define CP_ACP
Definition: compat.h:99
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
char * LPSTR
Definition: xmlstorage.h:182
#define DWORD
Definition: nt_native.h:44
unsigned char * LPBYTE
Definition: typedefs.h:52
#define RpcTryExcept
Definition: rpc.h:126
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
smooth NULL
Definition: ftsmooth.c:416
const char * LPCSTR
Definition: xmlstorage.h:183
#define RpcExceptionCode()
Definition: rpc.h:132
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define debugstr_a
Definition: kernel32.h:31
DWORD ScmRpcStatusToWinError(RPC_STATUS Status)
Definition: scm.c:146
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:409
static DWORD ScmEncryptPassword(_In_ PCWSTR pClearTextPassword, _Out_ PBYTE *pEncryptedPassword, _Out_ PDWORD pEncryptedPasswordSize)
Definition: scm.c:173
ULONG_PTR SIZE_T
Definition: typedefs.h:78
#define HEAP_ZERO_MEMORY
Definition: compat.h:123
#define MultiByteToWideChar
Definition: compat.h:100
WCHAR * LPWSTR
Definition: xmlstorage.h:184
_In_ LPCSTR _Out_writes_to_opt_ cchDisplayName LPSTR lpDisplayName
Definition: winbase.h:2730
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define HeapFree(x, y, z)
Definition: compat.h:394
#define RpcExcept(expr)
Definition: rpc.h:127

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 480 of file scm.c.

491 {
492  DWORD dwError;
493  DWORD dwDependenciesLength = 0;
494  SIZE_T cchLength;
495  LPCWSTR lpStr;
496  DWORD dwPasswordSize = 0;
497  LPBYTE lpEncryptedPassword = NULL;
498 
499  TRACE("ChangeServiceConfigW(%p %lu %lu %lu %s %s %p %s %s %s %s)\n",
500  hService, dwServiceType, dwStartType, dwErrorControl, debugstr_w(lpBinaryPathName),
501  debugstr_w(lpLoadOrderGroup), lpdwTagId, debugstr_w(lpDependencies),
502  debugstr_w(lpServiceStartName), debugstr_w(lpPassword), debugstr_w(lpDisplayName));
503 
504  /* Calculate the Dependencies length*/
505  if (lpDependencies != NULL)
506  {
507  lpStr = lpDependencies;
508  while (*lpStr)
509  {
510  cchLength = wcslen(lpStr) + 1;
511  dwDependenciesLength += (DWORD)cchLength;
512  lpStr = lpStr + cchLength;
513  }
514  dwDependenciesLength++;
515  dwDependenciesLength *= sizeof(WCHAR);
516  }
517 
518  if (lpPassword != NULL)
519  {
520  dwError = ScmEncryptPassword(lpPassword,
521  &lpEncryptedPassword,
522  &dwPasswordSize);
523  if (dwError != ERROR_SUCCESS)
524  {
525  ERR("ScmEncryptPassword failed (Error %lu)\n", dwError);
526  goto done;
527  }
528  }
529 
531  {
532  dwError = RChangeServiceConfigW((SC_RPC_HANDLE)hService,
533  dwServiceType,
534  dwStartType,
535  dwErrorControl,
536  (LPWSTR)lpBinaryPathName,
537  (LPWSTR)lpLoadOrderGroup,
538  lpdwTagId,
539  (LPBYTE)lpDependencies,
540  dwDependenciesLength,
541  (LPWSTR)lpServiceStartName,
542  lpEncryptedPassword,
543  dwPasswordSize,
545  }
547  {
549  }
550  RpcEndExcept;
551 
552 done:
553  if (lpEncryptedPassword != NULL)
554  {
555  /* Wipe and release the password buffer */
556  SecureZeroMemory(lpEncryptedPassword, dwPasswordSize);
557  HeapFree(GetProcessHeap(), 0, lpEncryptedPassword);
558  }
559 
560  if (dwError != ERROR_SUCCESS)
561  {
562  TRACE("RChangeServiceConfigW() failed (Error %lu)\n", dwError);
563  SetLastError(dwError);
564  return FALSE;
565  }
566 
567  return TRUE;
568 }
#define RpcEndExcept
Definition: rpc.h:128
#define TRUE
Definition: types.h:120
#define ERROR_SUCCESS
Definition: deptool.c:10
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
#define SecureZeroMemory
Definition: winbase.h:1636
#define DWORD
Definition: nt_native.h:44
unsigned char * LPBYTE
Definition: typedefs.h:52
#define debugstr_w
Definition: kernel32.h:32
#define RpcTryExcept
Definition: rpc.h:126
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
smooth NULL
Definition: ftsmooth.c:416
#define RpcExceptionCode()
Definition: rpc.h:132
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:395
__wchar_t WCHAR
Definition: xmlstorage.h:180
DWORD ScmRpcStatusToWinError(RPC_STATUS Status)
Definition: scm.c:146
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:409
static DWORD ScmEncryptPassword(_In_ PCWSTR pClearTextPassword, _Out_ PBYTE *pEncryptedPassword, _Out_ PDWORD pEncryptedPasswordSize)
Definition: scm.c:173
#define ERR(fmt,...)
Definition: debug.h:109
ULONG_PTR SIZE_T
Definition: typedefs.h:78
WCHAR * LPWSTR
Definition: xmlstorage.h:184
_In_ LPCSTR _Out_writes_to_opt_ cchDisplayName LPSTR lpDisplayName
Definition: winbase.h:2730
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define HeapFree(x, y, z)
Definition: compat.h:394
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:1916
#define RpcExcept(expr)
Definition: rpc.h:127

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

◆ CloseServiceHandle()

BOOL WINAPI CloseServiceHandle ( SC_HANDLE  hSCObject)

Definition at line 577 of file scm.c.

578 {
579  DWORD dwError;
580 
581  TRACE("CloseServiceHandle(%p)\n",
582  hSCObject);
583 
584  if (!hSCObject)
585  {
587  return FALSE;
588  }
589 
591  {
592  dwError = RCloseServiceHandle((LPSC_RPC_HANDLE)&hSCObject);
593  }
595  {
597  }
598  RpcEndExcept;
599 
600  if (dwError)
601  {
602  TRACE("RCloseServiceHandle() failed (Error %lu)\n", dwError);
603  SetLastError(dwError);
604  return FALSE;
605  }
606 
607  TRACE("CloseServiceHandle() done\n");
608 
609  return TRUE;
610 }
#define RpcEndExcept
Definition: rpc.h:128
#define TRUE
Definition: types.h:120
#define ERROR_INVALID_HANDLE
Definition: compat.h:88
#define RpcTryExcept
Definition: rpc.h:126
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
#define RpcExceptionCode()
Definition: rpc.h:132
#define TRACE(s)
Definition: solgame.cpp:4
DWORD ScmRpcStatusToWinError(RPC_STATUS Status)
Definition: scm.c:146
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:409
DWORD WINAPI RCloseServiceHandle(LPSC_RPC_HANDLE hSCObject)
Definition: rpcserver.c:934
#define RpcExcept(expr)
Definition: rpc.h:127

Referenced by _RunRemoteTest(), AccpCloseObjectHandle(), AccpOpenNamedObject(), AddService(), check_service_is_installed(), 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(), InstallOneService(), installService(), CShellDispatch::IsServiceRunning(), ITERATE_DeleteService(), ITERATE_InstallService(), ITERATE_StartService(), ITERATE_StopService(), KmtCloseService(), KmtDeleteService(), KmtServiceCleanup(), main(), MMSYS_InstallDevice(), my_test_server(), PlayLogonSoundThread(), query_service_config(), QueryConfig(), QueryDescription(), QueryDriverInfo(), QueryFailure(), QueryService(), RegisterDriver(), RpcSsConfigureAsNetworkService(), RunTest(), SchedEventLogoff(), SchedStartShell(), SdSet(), SdShow(), ServiceInfo(), ServicesPageWndProc(), ServiceStart(), SetConfig(), SetDescription(), SetFailure(), SetServiceAccount(), SetServiceConfig(), SetServiceDescription(), SetupStartService(), 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 619 of file scm.c.

622 {
623  DWORD dwError;
624 
625  TRACE("ControlService(%p %lu %p)\n",
626  hService, dwControl, lpServiceStatus);
627 
629  {
630  dwError = RControlService((SC_RPC_HANDLE)hService,
631  dwControl,
632  lpServiceStatus);
633  }
635  {
637  }
638  RpcEndExcept;
639 
640  if (dwError != ERROR_SUCCESS)
641  {
642  TRACE("RControlService() failed (Error %lu)\n", dwError);
643  SetLastError(dwError);
644  return FALSE;
645  }
646 
647  TRACE("ControlService() done\n");
648 
649  return TRUE;
650 }
#define RpcEndExcept
Definition: rpc.h:128
#define TRUE
Definition: types.h:120
#define ERROR_SUCCESS
Definition: deptool.c:10
#define RpcTryExcept
Definition: rpc.h:126
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
#define RpcExceptionCode()
Definition: rpc.h:132
#define TRACE(s)
Definition: solgame.cpp:4
DWORD ScmRpcStatusToWinError(RPC_STATUS Status)
Definition: scm.c:146
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:409
DWORD WINAPI RControlService(SC_RPC_HANDLE hService, DWORD dwControl, LPSERVICE_STATUS lpServiceStatus)
Definition: rpcserver.c:1067
#define RpcExcept(expr)
Definition: rpc.h:127

Referenced by cmdContinue(), cmdPause(), CmdRemoveService(), cmdStop(), Control(), control_service(), DoControlService(), DoStopService(), KmtStopService(), my_test_server(), RequestAddition(), RunTest(), SchedEventLogoff(), SchedStartShell(), SetupInstallServicesFromInfSectionExW(), 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 659 of file scm.c.

663 {
664  FIXME("ControlServiceEx(%p %lu %lu %p)\n",
665  hService, dwControl, dwInfoLevel, pControlParams);
667  return FALSE;
668 }
#define FIXME(fmt,...)
Definition: debug.h:110
#define SetLastError(x)
Definition: compat.h:409
_In_ DWORD dwInfoLevel
Definition: winsvc.h:422
#define ERROR_CALL_NOT_IMPLEMENTED
Definition: compat.h:92

◆ 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 677 of file scm.c.

690 {
691  SC_HANDLE hService = NULL;
692  DWORD dwDependenciesLength = 0;
693  DWORD dwError;
694  SIZE_T cchLength;
695  LPCSTR lpStr;
696  DWORD dwPasswordSize = 0;
697  LPWSTR lpPasswordW = NULL;
698  LPBYTE lpEncryptedPassword = NULL;
699 
700  TRACE("CreateServiceA(%p %s %s %lx %lu %lu %lu %s %s %p %s %s %s)\n",
701  hSCManager, debugstr_a(lpServiceName), debugstr_a(lpDisplayName),
702  dwDesiredAccess, dwServiceType, dwStartType, dwErrorControl,
703  debugstr_a(lpBinaryPathName), debugstr_a(lpLoadOrderGroup), lpdwTagId,
704  debugstr_a(lpDependencies), debugstr_a(lpServiceStartName), debugstr_a(lpPassword));
705 
706  if (!hSCManager)
707  {
709  return NULL;
710  }
711 
712  /* Calculate the Dependencies length */
713  if (lpDependencies != NULL)
714  {
715  lpStr = lpDependencies;
716  while (*lpStr)
717  {
718  cchLength = strlen(lpStr) + 1;
719  dwDependenciesLength += (DWORD)cchLength;
720  lpStr = lpStr + cchLength;
721  }
722  dwDependenciesLength++;
723  }
724 
725  if (lpPassword != NULL)
726  {
727  /* Convert the password to unicode */
728  lpPasswordW = HeapAlloc(GetProcessHeap(),
730  (strlen(lpPassword) + 1) * sizeof(WCHAR));
731  if (lpPasswordW == NULL)
732  {
734  return FALSE;
735  }
736 
738  0,
739  lpPassword,
740  -1,
741  lpPasswordW,
742  (int)(strlen(lpPassword) + 1));
743 
744  /* Encrypt the password */
745  dwError = ScmEncryptPassword(lpPasswordW,
746  &lpEncryptedPassword,
747  &dwPasswordSize);
748  if (dwError != ERROR_SUCCESS)
749  goto done;
750  }
751 
753  {
755  (LPSTR)lpServiceName,
757  dwDesiredAccess,
758  dwServiceType,
759  dwStartType,
760  dwErrorControl,
761  (LPSTR)lpBinaryPathName,
762  (LPSTR)lpLoadOrderGroup,
763  lpdwTagId,
764  (LPBYTE)lpDependencies,
765  dwDependenciesLength,
766  (LPSTR)lpServiceStartName,
767  lpEncryptedPassword,
768  dwPasswordSize,
769  (SC_RPC_HANDLE *)&hService);
770  }
772  {
774  }
775  RpcEndExcept;
776 
777 done:
778  if (lpPasswordW != NULL)
779  {
780  /* Wipe and release the password buffers */
781  SecureZeroMemory(lpPasswordW, (wcslen(lpPasswordW) + 1) * sizeof(WCHAR));
782  HeapFree(GetProcessHeap(), 0, lpPasswordW);
783 
784  if (lpEncryptedPassword != NULL)
785  {
786  SecureZeroMemory(lpEncryptedPassword, dwPasswordSize);
787  HeapFree(GetProcessHeap(), 0, lpEncryptedPassword);
788  }
789  }
790 
791  SetLastError(dwError);
792  if (dwError != ERROR_SUCCESS)
793  {
794  TRACE("RCreateServiceA() failed (Error %lu)\n", dwError);
795  return NULL;
796  }
797 
798  return hService;
799 }
#define RpcEndExcept
Definition: rpc.h:128
#define ERROR_SUCCESS
Definition: deptool.c:10
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
#define SecureZeroMemory
Definition: winbase.h:1636
#define CP_ACP
Definition: compat.h:99
#define ERROR_INVALID_HANDLE
Definition: compat.h:88
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
char * LPSTR
Definition: xmlstorage.h:182
#define DWORD
Definition: nt_native.h:44
unsigned char * LPBYTE
Definition: typedefs.h:52
#define RpcTryExcept
Definition: rpc.h:126
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
smooth NULL
Definition: ftsmooth.c:416
const char * LPCSTR
Definition: xmlstorage.h:183
#define RpcExceptionCode()
Definition: rpc.h:132
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define debugstr_a
Definition: kernel32.h:31
DWORD ScmRpcStatusToWinError(RPC_STATUS Status)
Definition: scm.c:146
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:409
static DWORD ScmEncryptPassword(_In_ PCWSTR pClearTextPassword, _Out_ PBYTE *pEncryptedPassword, _Out_ PDWORD pEncryptedPasswordSize)
Definition: scm.c:173
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:3586
SC_HANDLE hSCManager
Definition: sc.c:12
ULONG_PTR SIZE_T
Definition: typedefs.h:78
#define HEAP_ZERO_MEMORY
Definition: compat.h:123
#define MultiByteToWideChar
Definition: compat.h:100
WCHAR * LPWSTR
Definition: xmlstorage.h:184
_In_ LPCSTR _Out_writes_to_opt_ cchDisplayName LPSTR lpDisplayName
Definition: winbase.h:2730
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define HeapFree(x, y, z)
Definition: compat.h:394
#define RpcExcept(expr)
Definition: rpc.h:127

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 808 of file scm.c.

821 {
822  SC_HANDLE hService = NULL;
823  DWORD dwDependenciesLength = 0;
824  DWORD dwError;
825  SIZE_T cchLength;
826  LPCWSTR lpStr;
827  DWORD dwPasswordSize = 0;
828  LPBYTE lpEncryptedPassword = NULL;
829 
830  TRACE("CreateServiceW(%p %s %s %lx %lu %lu %lu %s %s %p %s %s %s)\n",
831  hSCManager, debugstr_w(lpServiceName), debugstr_w(lpDisplayName),
832  dwDesiredAccess, dwServiceType, dwStartType, dwErrorControl,
833  debugstr_w(lpBinaryPathName), debugstr_w(lpLoadOrderGroup), lpdwTagId,
834  debugstr_w(lpDependencies), debugstr_w(lpServiceStartName), debugstr_w(lpPassword));
835 
836  if (!hSCManager)
837  {
839  return NULL;
840  }
841 
842  /* Calculate the Dependencies length */
843  if (lpDependencies != NULL)
844  {
845  lpStr = lpDependencies;
846  while (*lpStr)
847  {
848  cchLength = wcslen(lpStr) + 1;
849  dwDependenciesLength += (DWORD)cchLength;
850  lpStr = lpStr + cchLength;
851  }
852  dwDependenciesLength++;
853  dwDependenciesLength *= sizeof(WCHAR);
854  }
855 
856  if (lpPassword != NULL)
857  {
858  /* Encrypt the password */
859  dwError = ScmEncryptPassword(lpPassword,
860  &lpEncryptedPassword,
861  &dwPasswordSize);
862  if (dwError != ERROR_SUCCESS)
863  goto done;
864  }
865 
867  {
869  lpServiceName,
871  dwDesiredAccess,
872  dwServiceType,
873  dwStartType,
874  dwErrorControl,
875  lpBinaryPathName,
876  lpLoadOrderGroup,
877  lpdwTagId,
878  (LPBYTE)lpDependencies,
879  dwDependenciesLength,
880  lpServiceStartName,
881  lpEncryptedPassword,
882  dwPasswordSize,
883  (SC_RPC_HANDLE *)&hService);
884  }
886  {
888  }
889  RpcEndExcept;
890 
891 done:
892  if (lpEncryptedPassword != NULL)
893  {
894  /* Wipe and release the password buffers */
895  SecureZeroMemory(lpEncryptedPassword, dwPasswordSize);
896  HeapFree(GetProcessHeap(), 0, lpEncryptedPassword);
897  }
898 
899  SetLastError(dwError);
900  if (dwError != ERROR_SUCCESS)
901  {
902  TRACE("RCreateServiceW() failed (Error %lu)\n", dwError);
903  return NULL;
904  }
905 
906  return hService;
907 }
#define RpcEndExcept
Definition: rpc.h:128
#define ERROR_SUCCESS
Definition: deptool.c:10
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:2267
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
#define SecureZeroMemory
Definition: winbase.h:1636
#define ERROR_INVALID_HANDLE
Definition: compat.h:88
#define DWORD
Definition: nt_native.h:44
unsigned char * LPBYTE
Definition: typedefs.h:52
#define debugstr_w
Definition: kernel32.h:32
#define RpcTryExcept
Definition: rpc.h:126
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
smooth NULL
Definition: ftsmooth.c:416
#define RpcExceptionCode()
Definition: rpc.h:132
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:395
__wchar_t WCHAR
Definition: xmlstorage.h:180
DWORD ScmRpcStatusToWinError(RPC_STATUS Status)
Definition: scm.c:146
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:409
static DWORD ScmEncryptPassword(_In_ PCWSTR pClearTextPassword, _Out_ PBYTE *pEncryptedPassword, _Out_ PDWORD pEncryptedPasswordSize)
Definition: scm.c:173
SC_HANDLE hSCManager
Definition: sc.c:12
ULONG_PTR SIZE_T
Definition: typedefs.h:78
_In_ LPCSTR _Out_writes_to_opt_ cchDisplayName LPSTR lpDisplayName
Definition: winbase.h:2730
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define HeapFree(x, y, z)
Definition: compat.h:394
#define RpcExcept(expr)
Definition: rpc.h:127

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

◆ DeleteService()

BOOL WINAPI DeleteService ( SC_HANDLE  hService)

Definition at line 916 of file scm.c.

917 {
918  DWORD dwError;
919 
920  TRACE("DeleteService(%p)\n",
921  hService);
922 
924  {
925  dwError = RDeleteService((SC_RPC_HANDLE)hService);
926  }
928  {
930  }
931  RpcEndExcept;
932 
933  if (dwError != ERROR_SUCCESS)
934  {
935  TRACE("RDeleteService() failed (Error %lu)\n", dwError);
936  SetLastError(dwError);
937  return FALSE;
938  }
939 
940  return TRUE;
941 }
#define RpcEndExcept
Definition: rpc.h:128
#define TRUE
Definition: types.h:120
#define ERROR_SUCCESS
Definition: deptool.c:10
DWORD WINAPI RDeleteService(SC_RPC_HANDLE hService)
Definition: rpcserver.c:1302
#define RpcTryExcept
Definition: rpc.h:126
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
#define RpcExceptionCode()
Definition: rpc.h:132
#define TRACE(s)
Definition: solgame.cpp:4
DWORD ScmRpcStatusToWinError(RPC_STATUS Status)
Definition: scm.c:146
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:409
#define RpcExcept(expr)
Definition: rpc.h:127

Referenced by check_service_is_installed(), CmdRemoveService(), Delete(), delete_test_service(), DestroyService(), DoDeleteService(), DoUnregServer(), InstallOneService(), ITERATE_DeleteService(), KmtDeleteService(), my_test_server(), RunTest(), test_create_delete_svc(), test_driver_install(), test_get_displayname(), test_install_svc_from(), test_no_stop(), test_queryconfig2(), test_refcount(), test_runner(), test_sequence(), test_service(), test_SetupDiInstallClassExA(), test_SetupInstallServicesFromInfSectionExA(), test_SetupInstallServicesFromInfSectionExW(), test_start_stop(), uninstallService(), UnregisterDriver(), and VfdRemoveDriver().

◆ EnumDependentServicesA()

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

Definition at line 950 of file scm.c.

956 {
958  LPENUM_SERVICE_STATUSA lpStatusPtr;
959  DWORD dwBufferSize;
960  DWORD dwError;
961  DWORD dwCount;
962 
963  TRACE("EnumDependentServicesA(%p %lu %p %lu %p %p)\n",
964  hService, dwServiceState, lpServices, cbBufSize,
965  pcbBytesNeeded, lpServicesReturned);
966 
967  if (lpServices == NULL || cbBufSize < sizeof(ENUM_SERVICE_STATUSA))
968  {
969  lpStatusPtr = &ServiceStatus;
970  dwBufferSize = sizeof(ENUM_SERVICE_STATUSA);
971  }
972  else
973  {
974  lpStatusPtr = lpServices;
975  dwBufferSize = cbBufSize;
976  }
977 
979  {
980  dwError = REnumDependentServicesA((SC_RPC_HANDLE)hService,
981  dwServiceState,
982  (LPBYTE)lpStatusPtr,
983  dwBufferSize,
985  lpServicesReturned);
986  }
988  {
990  }
991  RpcEndExcept;
992 
993  if (dwError == ERROR_SUCCESS || dwError == ERROR_MORE_DATA)
994  {
995  for (dwCount = 0; dwCount < *lpServicesReturned; dwCount++)
996  {
997  if (lpStatusPtr->lpServiceName)
998  lpStatusPtr->lpServiceName =
999  (LPSTR)((ULONG_PTR)lpServices + (ULONG_PTR)lpStatusPtr->lpServiceName);
1000 
1001  if (lpStatusPtr->lpDisplayName)
1002  lpStatusPtr->lpDisplayName =
1003  (LPSTR)((ULONG_PTR)lpServices + (ULONG_PTR)lpStatusPtr->lpDisplayName);
1004 
1005  lpStatusPtr++;
1006  }
1007  }
1008 
1009  if (dwError != ERROR_SUCCESS)
1010  {
1011  TRACE("REnumDependentServicesA() failed (Error %lu)\n", dwError);
1012  SetLastError(dwError);
1013  return FALSE;
1014  }
1015 
1016  TRACE("EnumDependentServicesA() done\n");
1017 
1018  return TRUE;
1019 }
#define RpcEndExcept
Definition: rpc.h:128
_In_ DWORD _In_ DWORD _Out_ LPDWORD pcbBytesNeeded
Definition: winsvc.h:424
#define TRUE
Definition: types.h:120
#define ERROR_SUCCESS
Definition: deptool.c:10
static SERVICE_STATUS ServiceStatus
Definition: dcomlaunch.c:27
char * LPSTR
Definition: xmlstorage.h:182
uint32_t ULONG_PTR
Definition: typedefs.h:63
unsigned char * LPBYTE
Definition: typedefs.h:52
#define RpcTryExcept
Definition: rpc.h:126
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
smooth NULL
Definition: ftsmooth.c:416
#define RpcExceptionCode()
Definition: rpc.h:132
#define TRACE(s)
Definition: solgame.cpp:4
DWORD ScmRpcStatusToWinError(RPC_STATUS Status)
Definition: scm.c:146
unsigned long DWORD
Definition: ntddk_ex.h:95
_In_ DWORD _In_ DWORD cbBufSize
Definition: winsvc.h:424
#define SetLastError(x)
Definition: compat.h:409
#define ERROR_MORE_DATA
Definition: dderror.h:13
#define ULONG_PTR
Definition: config.h:101
DWORD WINAPI REnumDependentServicesA(SC_RPC_HANDLE hService, DWORD dwServiceState, LPBYTE lpServices, DWORD cbBufSize, LPBOUNDED_DWORD_256K pcbBytesNeeded, LPBOUNDED_DWORD_256K lpServicesReturned)
Definition: rpcserver.c:3739
struct _ENUM_SERVICE_STATUSA ENUM_SERVICE_STATUSA
#define RpcExcept(expr)
Definition: rpc.h:127

◆ EnumDependentServicesW()

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

Definition at line 1028 of file scm.c.

1034 {
1036  LPENUM_SERVICE_STATUSW lpStatusPtr;
1037  DWORD dwBufferSize;
1038  DWORD dwError;
1039  DWORD dwCount;
1040 
1041  TRACE("EnumDependentServicesW(%p %lu %p %lu %p %p)\n",
1042  hService, dwServiceState, lpServices, cbBufSize,
1043  pcbBytesNeeded, lpServicesReturned);
1044 
1045  if (lpServices == NULL || cbBufSize < sizeof(ENUM_SERVICE_STATUSW))
1046  {
1047  lpStatusPtr = &ServiceStatus;
1048  dwBufferSize = sizeof(ENUM_SERVICE_STATUSW);
1049  }
1050  else
1051  {
1052  lpStatusPtr = lpServices;
1053  dwBufferSize = cbBufSize;
1054  }
1055 
1056  RpcTryExcept
1057  {
1058  dwError = REnumDependentServicesW((SC_RPC_HANDLE)hService,
1059  dwServiceState,
1060  (LPBYTE)lpStatusPtr,
1061  dwBufferSize,
1063  lpServicesReturned);
1064  }
1066  {
1068  }
1069  RpcEndExcept;
1070 
1071  if (dwError == ERROR_SUCCESS || dwError == ERROR_MORE_DATA)
1072  {
1073  for (dwCount = 0; dwCount < *lpServicesReturned; dwCount++)
1074  {
1075  if (lpStatusPtr->lpServiceName)
1076  lpStatusPtr->lpServiceName =
1077  (LPWSTR)((ULONG_PTR)lpServices + (ULONG_PTR)lpStatusPtr->lpServiceName);
1078 
1079  if (lpStatusPtr->lpDisplayName)
1080  lpStatusPtr->lpDisplayName =
1081  (LPWSTR)((ULONG_PTR)lpServices + (ULONG_PTR)lpStatusPtr->lpDisplayName);
1082 
1083  lpStatusPtr++;
1084  }
1085  }
1086 
1087  if (dwError != ERROR_SUCCESS)
1088  {
1089  TRACE("REnumDependentServicesW() failed (Error %lu)\n", dwError);
1090  SetLastError(dwError);
1091  return FALSE;
1092  }
1093 
1094  TRACE("EnumDependentServicesW() done\n");
1095 
1096  return TRUE;
1097 }
#define RpcEndExcept
Definition: rpc.h:128
_In_ DWORD _In_ DWORD _Out_ LPDWORD pcbBytesNeeded
Definition: winsvc.h:424
#define TRUE
Definition: types.h:120
#define ERROR_SUCCESS
Definition: deptool.c:10
DWORD WINAPI REnumDependentServicesW(SC_RPC_HANDLE hService, DWORD dwServiceState, LPBYTE lpServices, DWORD cbBufSize, LPBOUNDED_DWORD_256K pcbBytesNeeded, LPBOUNDED_DWORD_256K lpServicesReturned)
Definition: rpcserver.c:2701
static SERVICE_STATUS ServiceStatus
Definition: dcomlaunch.c:27
uint32_t ULONG_PTR
Definition: typedefs.h:63
unsigned char * LPBYTE
Definition: typedefs.h:52
#define RpcTryExcept
Definition: rpc.h:126
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
smooth NULL
Definition: ftsmooth.c:416
#define RpcExceptionCode()
Definition: rpc.h:132
#define TRACE(s)
Definition: solgame.cpp:4
DWORD ScmRpcStatusToWinError(RPC_STATUS Status)
Definition: scm.c:146
unsigned long DWORD
Definition: ntddk_ex.h:95
_In_ DWORD _In_ DWORD cbBufSize
Definition: winsvc.h:424
#define SetLastError(x)
Definition: compat.h:409
struct _ENUM_SERVICE_STATUSW ENUM_SERVICE_STATUSW
#define ERROR_MORE_DATA
Definition: dderror.h:13
LPWSTR lpServiceName
Definition: winsvc.h:130
LPWSTR lpDisplayName
Definition: winsvc.h:131
#define ULONG_PTR
Definition: config.h:101
WCHAR * LPWSTR
Definition: xmlstorage.h:184
#define RpcExcept(expr)
Definition: rpc.h:127

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 1106 of file scm.c.

1115 {
1117  LPENUM_SERVICE_STATUSW lpStatusPtr;
1118  DWORD dwBufferSize;
1119  DWORD dwError;
1120  DWORD dwCount;
1121 
1122  TRACE("EnumServiceGroupW(%p %lu %lu %p %lu %p %p %p %s)\n",
1123  hSCManager, dwServiceType, dwServiceState, lpServices,
1124  cbBufSize, pcbBytesNeeded, lpServicesReturned,
1125  lpResumeHandle, debugstr_w(lpGroup));
1126 
1127  if (!hSCManager)
1128  {
1130  return FALSE;
1131  }
1132 
1133  if (pcbBytesNeeded == NULL || lpServicesReturned == NULL)
1134  {
1136  return FALSE;
1137  }
1138 
1139  if (lpServices == NULL || cbBufSize < sizeof(ENUM_SERVICE_STATUSW))
1140  {
1141  lpStatusPtr = &ServiceStatus;
1142  dwBufferSize = sizeof(ENUM_SERVICE_STATUSW);
1143  }
1144  else
1145  {
1146  lpStatusPtr = lpServices;
1147  dwBufferSize = cbBufSize;
1148  }
1149 
1150  RpcTryExcept
1151  {
1152  if (lpGroup == NULL)
1153  {
1155  dwServiceType,
1156  dwServiceState,
1157  (LPBYTE)lpStatusPtr,
1158  dwBufferSize,
1160  lpServicesReturned,
1161  lpResumeHandle);
1162  }
1163  else
1164  {
1166  dwServiceType,
1167  dwServiceState,
1168  (LPBYTE)lpStatusPtr,
1169  dwBufferSize,
1171  lpServicesReturned,
1172  lpResumeHandle,
1173  lpGroup);
1174  }
1175  }
1177  {
1179  }
1180  RpcEndExcept;
1181 
1182  if (dwError == ERROR_SUCCESS || dwError == ERROR_MORE_DATA)
1183  {
1184  for (dwCount = 0; dwCount < *lpServicesReturned; dwCount++)
1185  {
1186  if (lpStatusPtr->lpServiceName)
1187  lpStatusPtr->lpServiceName =
1188  (LPWSTR)((ULONG_PTR)lpServices + (ULONG_PTR)lpStatusPtr->lpServiceName);
1189 
1190  if (lpStatusPtr->lpDisplayName)
1191  lpStatusPtr->lpDisplayName =
1192  (LPWSTR)((ULONG_PTR)lpServices + (ULONG_PTR)lpStatusPtr->lpDisplayName);
1193 
1194  lpStatusPtr++;
1195  }
1196  }
1197 
1198  if (dwError != ERROR_SUCCESS)
1199  {
1200  TRACE("REnumServiceGroupW() failed (Error %lu)\n", dwError);
1201  SetLastError(dwError);
1202  return FALSE;
1203  }
1204 
1205  TRACE("EnumServiceGroupW() done\n");
1206 
1207  return TRUE;
1208 }
#define RpcEndExcept
Definition: rpc.h:128
_In_ DWORD _In_ DWORD _Out_ LPDWORD pcbBytesNeeded
Definition: winsvc.h:424
#define TRUE
Definition: types.h:120
#define ERROR_SUCCESS
Definition: deptool.c:10
#define ERROR_INVALID_HANDLE
Definition: compat.h:88
static SERVICE_STATUS ServiceStatus
Definition: dcomlaunch.c:27
uint32_t ULONG_PTR
Definition: typedefs.h:63
unsigned char * LPBYTE
Definition: typedefs.h:52
#define debugstr_w
Definition: kernel32.h:32
#define RpcTryExcept
Definition: rpc.h:126
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:4747
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
smooth NULL
Definition: ftsmooth.c:416
#define RpcExceptionCode()
Definition: rpc.h:132
#define TRACE(s)
Definition: solgame.cpp:4
DWORD ScmRpcStatusToWinError(RPC_STATUS Status)
Definition: scm.c:146
unsigned long DWORD
Definition: ntddk_ex.h:95
_In_ DWORD _In_ DWORD cbBufSize
Definition: winsvc.h:424
#define SetLastError(x)
Definition: compat.h:409
struct _ENUM_SERVICE_STATUSW ENUM_SERVICE_STATUSW
#define ERROR_INVALID_ADDRESS
Definition: compat.h:96
SC_HANDLE hSCManager
Definition: sc.c:12
#define ERROR_MORE_DATA
Definition: dderror.h:13
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:2836
LPWSTR lpServiceName
Definition: winsvc.h:130
LPWSTR lpDisplayName
Definition: winsvc.h:131
#define ULONG_PTR
Definition: config.h:101
WCHAR * LPWSTR
Definition: xmlstorage.h:184
#define RpcExcept(expr)
Definition: rpc.h:127

◆ 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 1217 of file scm.c.

1225 {
1227  LPENUM_SERVICE_STATUSA lpStatusPtr;
1228  DWORD dwBufferSize;
1229  DWORD dwError;
1230  DWORD dwCount;
1231 
1232  TRACE("EnumServicesStatusA(%p %lu %lu %p %lu %p %p %p)\n",
1233  hSCManager, dwServiceType, dwServiceState, lpServices,
1234  cbBufSize, pcbBytesNeeded, lpServicesReturned, lpResumeHandle);
1235 
1236  if (!hSCManager)
1237  {
1239  return FALSE;
1240  }
1241 
1242  if (pcbBytesNeeded == NULL || lpServicesReturned == NULL)
1243  {
1245  return FALSE;
1246  }
1247 
1248  if (lpServices == NULL || cbBufSize < sizeof(ENUM_SERVICE_STATUSA))
1249  {
1250  lpStatusPtr = &ServiceStatus;
1251  dwBufferSize = sizeof(ENUM_SERVICE_STATUSA);
1252  }
1253  else
1254  {
1255  lpStatusPtr = lpServices;
1256  dwBufferSize = cbBufSize;
1257  }
1258 
1259  RpcTryExcept
1260  {
1262  dwServiceType,
1263  dwServiceState,
1264  (LPBYTE)lpStatusPtr,
1265  dwBufferSize,
1267  lpServicesReturned,
1268  lpResumeHandle);
1269  }
1271  {
1273  }
1274  RpcEndExcept;
1275 
1276  if (dwError == ERROR_SUCCESS || dwError == ERROR_MORE_DATA)
1277  {
1278  for (dwCount = 0; dwCount < *lpServicesReturned; dwCount++)
1279  {
1280  if (lpStatusPtr->lpServiceName)
1281  lpStatusPtr->lpServiceName =
1282  (LPSTR)((ULONG_PTR)lpServices + (ULONG_PTR)lpStatusPtr->lpServiceName);
1283 
1284  if (lpStatusPtr->lpDisplayName)
1285  lpStatusPtr->lpDisplayName =
1286  (LPSTR)((ULONG_PTR)lpServices + (ULONG_PTR)lpStatusPtr->lpDisplayName);
1287 
1288  lpStatusPtr++;
1289  }
1290  }
1291 
1292  if (dwError != ERROR_SUCCESS)
1293  {
1294  TRACE("REnumServicesStatusA() failed (Error %lu)\n", dwError);
1295  SetLastError(dwError);
1296  return FALSE;
1297  }
1298 
1299  TRACE("EnumServicesStatusA() done\n");
1300 
1301  return TRUE;
1302 }
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:3893
#define RpcEndExcept
Definition: rpc.h:128
_In_ DWORD _In_ DWORD _Out_ LPDWORD pcbBytesNeeded
Definition: winsvc.h:424
#define TRUE
Definition: types.h:120
#define ERROR_SUCCESS
Definition: deptool.c:10
#define ERROR_INVALID_HANDLE
Definition: compat.h:88
static SERVICE_STATUS ServiceStatus
Definition: dcomlaunch.c:27
char * LPSTR
Definition: xmlstorage.h:182
uint32_t ULONG_PTR
Definition: typedefs.h:63
unsigned char * LPBYTE
Definition: typedefs.h:52
#define RpcTryExcept
Definition: rpc.h:126
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
smooth NULL
Definition: ftsmooth.c:416
#define RpcExceptionCode()
Definition: rpc.h:132
#define TRACE(s)
Definition: solgame.cpp:4
DWORD ScmRpcStatusToWinError(RPC_STATUS Status)
Definition: scm.c:146
unsigned long DWORD
Definition: ntddk_ex.h:95
_In_ DWORD _In_ DWORD cbBufSize
Definition: winsvc.h:424
#define SetLastError(x)
Definition: compat.h:409
#define ERROR_INVALID_ADDRESS
Definition: compat.h:96
SC_HANDLE hSCManager
Definition: sc.c:12
#define ERROR_MORE_DATA
Definition: dderror.h:13
#define ULONG_PTR
Definition: config.h:101
struct _ENUM_SERVICE_STATUSA ENUM_SERVICE_STATUSA
#define RpcExcept(expr)
Definition: rpc.h:127

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 1405 of file scm.c.

1415 {
1417  LPENUM_SERVICE_STATUS_PROCESSA lpStatusPtr;
1418  DWORD dwBufferSize;
1419  DWORD dwError;
1420  DWORD dwCount;
1421 
1422  TRACE("EnumServicesStatusExA(%p %lu %lu %p %lu %p %p %p %s)\n",
1423  hSCManager, dwServiceType, dwServiceState, lpServices,
1424  cbBufSize, pcbBytesNeeded, lpServicesReturned, lpResumeHandle,
1425  debugstr_a(pszGroupName));
1426 
1427  if (InfoLevel != SC_ENUM_PROCESS_INFO)
1428  {
1430  return FALSE;
1431  }
1432 
1433  if (!hSCManager)
1434  {
1436  return FALSE;
1437  }
1438 
1439  if (pcbBytesNeeded == NULL || lpServicesReturned == NULL)
1440  {
1442  return FALSE;
1443  }
1444 
1445  if (lpServices == NULL || cbBufSize < sizeof(ENUM_SERVICE_STATUS_PROCESSA))
1446  {
1447  lpStatusPtr = &ServiceStatus;
1448  dwBufferSize = sizeof(ENUM_SERVICE_STATUS_PROCESSA);
1449  }
1450  else
1451  {
1452  lpStatusPtr = (LPENUM_SERVICE_STATUS_PROCESSA)lpServices;
1453  dwBufferSize = cbBufSize;
1454  }
1455 
1456  RpcTryExcept
1457  {
1459  InfoLevel,
1460  dwServiceType,
1461  dwServiceState,
1462  (LPBYTE)lpStatusPtr,
1463  dwBufferSize,
1465  lpServicesReturned,
1466  lpResumeHandle,
1467  (LPSTR)pszGroupName);
1468  }
1470  {
1472  }
1473  RpcEndExcept;
1474 
1475  if (dwError == ERROR_SUCCESS || dwError == ERROR_MORE_DATA)
1476  {
1477  if (InfoLevel == SC_ENUM_PROCESS_INFO)
1478  {
1479  for (dwCount = 0; dwCount < *lpServicesReturned; dwCount++)
1480  {
1481  if (lpStatusPtr->lpServiceName)
1482  lpStatusPtr->lpServiceName =
1483  (LPSTR)((ULONG_PTR)lpServices + (ULONG_PTR)lpStatusPtr->lpServiceName);
1484 
1485  if (lpStatusPtr->lpDisplayName)
1486  lpStatusPtr->lpDisplayName =
1487  (LPSTR)((ULONG_PTR)lpServices + (ULONG_PTR)lpStatusPtr->lpDisplayName);
1488 
1489  lpStatusPtr++;
1490  }
1491  }
1492  }
1493 
1494  if (dwError != ERROR_SUCCESS)
1495  {
1496  TRACE("REnumServicesStatusExA() failed (Error %lu)\n", dwError);
1497  SetLastError(dwError);
1498  return FALSE;
1499  }
1500 
1501  TRACE("EnumServicesStatusExA() done\n");
1502 
1503  return TRUE;
1504 }
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:6090
#define RpcEndExcept
Definition: rpc.h:128
_In_ DWORD _In_ DWORD _Out_ LPDWORD pcbBytesNeeded
Definition: winsvc.h:424
#define TRUE
Definition: types.h:120
#define ERROR_SUCCESS
Definition: deptool.c:10
#define ERROR_INVALID_HANDLE
Definition: compat.h:88
static SERVICE_STATUS ServiceStatus
Definition: dcomlaunch.c:27
char * LPSTR
Definition: xmlstorage.h:182
uint32_t ULONG_PTR
Definition: typedefs.h:63
unsigned char * LPBYTE
Definition: typedefs.h:52
#define RpcTryExcept
Definition: rpc.h:126
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
smooth NULL
Definition: ftsmooth.c:416
struct _ENUM_SERVICE_STATUS_PROCESSA ENUM_SERVICE_STATUS_PROCESSA
#define RpcExceptionCode()
Definition: rpc.h:132
#define TRACE(s)
Definition: solgame.cpp:4
struct _ENUM_SERVICE_STATUS_PROCESSA * LPENUM_SERVICE_STATUS_PROCESSA
#define debugstr_a
Definition: kernel32.h:31
DWORD ScmRpcStatusToWinError(RPC_STATUS Status)
Definition: scm.c:146
unsigned long DWORD
Definition: ntddk_ex.h:95
_In_ DWORD _In_ DWORD cbBufSize
Definition: winsvc.h:424
#define SetLastError(x)
Definition: compat.h:409
#define ERROR_INVALID_ADDRESS
Definition: compat.h:96
SC_HANDLE hSCManager
Definition: sc.c:12
#define ERROR_MORE_DATA
Definition: dderror.h:13
#define ULONG_PTR
Definition: config.h:101
#define ERROR_INVALID_LEVEL
Definition: winerror.h:196
#define RpcExcept(expr)
Definition: rpc.h:127

◆ 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 1513 of file scm.c.

1523 {
1525  LPENUM_SERVICE_STATUS_PROCESSW lpStatusPtr;
1526  DWORD dwBufferSize;
1527  DWORD dwError;
1528  DWORD dwCount;
1529 
1530  TRACE("EnumServicesStatusExW(%p %lu %lu %p %lu %p %p %p %s)\n",
1531  hSCManager, dwServiceType, dwServiceState, lpServices,
1532  cbBufSize, pcbBytesNeeded, lpServicesReturned, lpResumeHandle,
1533  debugstr_w(pszGroupName));
1534 
1535  if (InfoLevel != SC_ENUM_PROCESS_INFO)
1536  {
1538  return FALSE;
1539  }
1540 
1541  if (!hSCManager)
1542  {
1544  return FALSE;
1545  }
1546 
1547  if (pcbBytesNeeded == NULL || lpServicesReturned == NULL)
1548  {
1550  return FALSE;
1551  }
1552 
1553  if (lpServices == NULL || cbBufSize < sizeof(ENUM_SERVICE_STATUS_PROCESSW))
1554  {
1555  lpStatusPtr = &ServiceStatus;
1556  dwBufferSize = sizeof(ENUM_SERVICE_STATUS_PROCESSW);
1557  }
1558  else
1559  {
1560  lpStatusPtr = (LPENUM_SERVICE_STATUS_PROCESSW)lpServices;
1561  dwBufferSize = cbBufSize;
1562  }
1563 
1564  RpcTryExcept
1565  {
1567  InfoLevel,
1568  dwServiceType,
1569  dwServiceState,
1570  (LPBYTE)lpStatusPtr,
1571  dwBufferSize,
1573  lpServicesReturned,
1574  lpResumeHandle,
1575  (LPWSTR)pszGroupName);
1576  }
1578  {
1580  }
1581  RpcEndExcept;
1582 
1583  if (dwError == ERROR_SUCCESS || dwError == ERROR_MORE_DATA)
1584  {
1585  if (InfoLevel == SC_ENUM_PROCESS_INFO)
1586  {
1587  for (dwCount = 0; dwCount < *lpServicesReturned; dwCount++)
1588  {
1589  if (lpStatusPtr->lpServiceName)
1590  lpStatusPtr->lpServiceName =
1591  (LPWSTR)((ULONG_PTR)lpServices + (ULONG_PTR)lpStatusPtr->lpServiceName);
1592 
1593  if (lpStatusPtr->lpDisplayName)
1594  lpStatusPtr->lpDisplayName =
1595  (LPWSTR)((ULONG_PTR)lpServices + (ULONG_PTR)lpStatusPtr->lpDisplayName);
1596 
1597  lpStatusPtr++;
1598  }
1599  }
1600  }
1601 
1602  if (dwError != ERROR_SUCCESS)
1603  {
1604  TRACE("REnumServicesStatusExW() failed (Error %lu)\n", dwError);
1605  SetLastError(dwError);
1606  return FALSE;
1607  }
1608 
1609  TRACE("EnumServicesStatusExW() done\n");
1610 
1611  return TRUE;
1612 }
#define RpcEndExcept
Definition: rpc.h:128
_In_ DWORD _In_ DWORD _Out_ LPDWORD pcbBytesNeeded
Definition: winsvc.h:424
#define TRUE
Definition: types.h:120
#define ERROR_SUCCESS
Definition: deptool.c:10
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:6229
#define ERROR_INVALID_HANDLE
Definition: compat.h:88
static SERVICE_STATUS ServiceStatus
Definition: dcomlaunch.c:27
uint32_t ULONG_PTR
Definition: typedefs.h:63
unsigned char * LPBYTE
Definition: typedefs.h:52
#define debugstr_w
Definition: kernel32.h:32
#define RpcTryExcept
Definition: rpc.h:126
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
smooth NULL
Definition: ftsmooth.c:416
#define RpcExceptionCode()
Definition: rpc.h:132
#define TRACE(s)
Definition: solgame.cpp:4
DWORD ScmRpcStatusToWinError(RPC_STATUS Status)
Definition: scm.c:146
unsigned long DWORD
Definition: ntddk_ex.h:95
_In_ DWORD _In_ DWORD cbBufSize
Definition: winsvc.h:424
#define SetLastError(x)
Definition: compat.h:409
#define ERROR_INVALID_ADDRESS
Definition: compat.h:96
struct _ENUM_SERVICE_STATUS_PROCESSW * LPENUM_SERVICE_STATUS_PROCESSW
SC_HANDLE hSCManager
Definition: sc.c:12
#define ERROR_MORE_DATA
Definition: dderror.h:13
struct _ENUM_SERVICE_STATUS_PROCESSW ENUM_SERVICE_STATUS_PROCESSW
#define ULONG_PTR
Definition: config.h:101
#define ERROR_INVALID_LEVEL
Definition: winerror.h:196
WCHAR * LPWSTR
Definition: xmlstorage.h:184
#define RpcExcept(expr)
Definition: rpc.h:127

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 1311 of file scm.c.

1319 {
1321  LPENUM_SERVICE_STATUSW lpStatusPtr;
1322  DWORD dwBufferSize;
1323  DWORD dwError;
1324  DWORD dwCount;
1325 
1326  TRACE("EnumServicesStatusW(%p %lu %lu %p %lu %p %p %p)\n",
1327  hSCManager, dwServiceType, dwServiceState, lpServices,
1328  cbBufSize, pcbBytesNeeded, lpServicesReturned, lpResumeHandle);
1329 
1330  if (!hSCManager)
1331  {
1333  return FALSE;
1334  }
1335 
1336  if (pcbBytesNeeded == NULL || lpServicesReturned == NULL)
1337  {
1339  return FALSE;
1340  }
1341 
1342  if (lpServices == NULL || cbBufSize < sizeof(ENUM_SERVICE_STATUSW))
1343  {
1344  lpStatusPtr = &ServiceStatus;
1345  dwBufferSize = sizeof(ENUM_SERVICE_STATUSW);
1346  }
1347  else
1348  {
1349  lpStatusPtr = lpServices;
1350  dwBufferSize = cbBufSize;
1351  }
1352 
1353  RpcTryExcept
1354  {
1356  dwServiceType,
1357  dwServiceState,
1358  (LPBYTE)lpStatusPtr,
1359  dwBufferSize,
1361  lpServicesReturned,
1362  lpResumeHandle);
1363  }
1365  {
1367  }
1368  RpcEndExcept;
1369 
1370  if (dwError == ERROR_SUCCESS || dwError == ERROR_MORE_DATA)
1371  {
1372  for (dwCount = 0; dwCount < *lpServicesReturned; dwCount++)
1373  {
1374  if (lpStatusPtr->lpServiceName)
1375  lpStatusPtr->lpServiceName =
1376  (LPWSTR)((ULONG_PTR)lpServices + (ULONG_PTR)lpStatusPtr->lpServiceName);
1377 
1378  if (lpStatusPtr->lpDisplayName)
1379  lpStatusPtr->lpDisplayName =
1380  (LPWSTR)((ULONG_PTR)lpServices + (ULONG_PTR)lpStatusPtr->lpDisplayName);
1381 
1382  lpStatusPtr++;
1383  }
1384  }
1385 
1386  if (dwError != ERROR_SUCCESS)
1387  {
1388  TRACE("REnumServicesStatusW() failed (Error %lu)\n", dwError);
1389  SetLastError(dwError);
1390  return FALSE;
1391  }
1392 
1393  TRACE("EnumServicesStatusW() done\n");
1394 
1395  return TRUE;
1396 }
#define RpcEndExcept
Definition: rpc.h:128
_In_ DWORD _In_ DWORD _Out_ LPDWORD pcbBytesNeeded
Definition: winsvc.h:424
#define TRUE
Definition: types.h:120
#define ERROR_SUCCESS
Definition: deptool.c:10
#define ERROR_INVALID_HANDLE
Definition: compat.h:88
static SERVICE_STATUS ServiceStatus
Definition: dcomlaunch.c:27
uint32_t ULONG_PTR
Definition: typedefs.h:63
unsigned char * LPBYTE
Definition: typedefs.h:52
#define RpcTryExcept
Definition: rpc.h:126
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
smooth NULL
Definition: ftsmooth.c:416
#define RpcExceptionCode()
Definition: rpc.h:132
#define TRACE(s)
Definition: solgame.cpp:4
DWORD ScmRpcStatusToWinError(RPC_STATUS Status)
Definition: scm.c:146
unsigned long DWORD
Definition: ntddk_ex.h:95
_In_ DWORD _In_ DWORD cbBufSize
Definition: winsvc.h:424
#define SetLastError(x)
Definition: compat.h:409
struct _ENUM_SERVICE_STATUSW ENUM_SERVICE_STATUSW
#define ERROR_INVALID_ADDRESS
Definition: compat.h:96
SC_HANDLE hSCManager
Definition: sc.c:12
#define ERROR_MORE_DATA
Definition: dderror.h:13
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:2836
LPWSTR lpServiceName
Definition: winsvc.h:130
LPWSTR lpDisplayName
Definition: winsvc.h:131
#define ULONG_PTR
Definition: config.h:101
WCHAR * LPWSTR
Definition: xmlstorage.h:184
#define RpcExcept(expr)
Definition: rpc.h:127

Referenced by EnumerateRunningServices(), and test_enum_svc().

◆ GetServiceDisplayNameA()

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

Definition at line 1621 of file scm.c.

1625 {
1626  DWORD dwError;
1628  CHAR szEmptyName[] = "";
1629 
1630  TRACE("GetServiceDisplayNameA(%p %s %p %p)\n",
1631  hSCManager, debugstr_a(lpServiceName), lpDisplayName, lpcchBuffer);
1632 
1633  if (!hSCManager)
1634  {
1636  return FALSE;
1637  }
1638 
1639  if (!lpDisplayName || *lpcchBuffer < sizeof(CHAR))
1640  {
1641  lpNameBuffer = szEmptyName;
1642  *lpcchBuffer = sizeof(CHAR);
1643  }
1644  else
1645  {
1647  }
1648 
1649  RpcTryExcept
1650  {
1652  lpServiceName,
1653  lpNameBuffer,
1654  lpcchBuffer);
1655  }
1657  {
1659  }
1660  RpcEndExcept;
1661 
1662  if (dwError != ERROR_SUCCESS)
1663  {
1664  TRACE("RGetServiceDisplayNameA() failed (Error %lu)\n", dwError);
1665  SetLastError(dwError);
1666  return FALSE;
1667  }
1668 
1669  return TRUE;
1670 }
#define RpcEndExcept
Definition: rpc.h:128
#define TRUE
Definition: types.h:120
#define ERROR_SUCCESS
Definition: deptool.c:10
char CHAR
Definition: xmlstorage.h:175
#define ERROR_INVALID_HANDLE
Definition: compat.h:88
char * LPSTR
Definition: xmlstorage.h:182
#define RpcTryExcept
Definition: rpc.h:126
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
static LPSTR lpNameBuffer
Definition: secur32.c:50
#define RpcExceptionCode()
Definition: rpc.h:132
#define TRACE(s)
Definition: solgame.cpp:4
#define debugstr_a
Definition: kernel32.h:31
DWORD ScmRpcStatusToWinError(RPC_STATUS Status)
Definition: scm.c:146
DWORD WINAPI RGetServiceDisplayNameA(SC_RPC_HANDLE hSCManager, LPCSTR lpServiceName, LPSTR lpDisplayName, LPBOUNDED_DWORD_4K lpcchBuffer)
Definition: rpcserver.c:4454
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:409
SC_HANDLE hSCManager
Definition: sc.c:12
#define CHAR(Char)
_In_ LPCSTR _Out_writes_to_opt_ cchDisplayName LPSTR lpDisplayName
Definition: winbase.h:2730
#define RpcExcept(expr)
Definition: rpc.h:127

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 1679 of file scm.c.

1683 {
1684  DWORD dwError;
1686  WCHAR szEmptyName[] = L"";
1687 
1688  TRACE("GetServiceDisplayNameW(%p %s %p %p)\n",
1689  hSCManager, debugstr_w(lpServiceName), lpDisplayName, lpcchBuffer);
1690 
1691  if (!hSCManager)
1692  {
1694  return FALSE;
1695  }
1696 
1697  /*
1698  * NOTE: A size of 1 character would be enough, but tests show that
1699  * Windows returns 2 characters instead, certainly due to a WCHAR/bytes
1700  * mismatch in their code.
1701  */
1702  if (!lpDisplayName || *lpcchBuffer < sizeof(WCHAR))
1703  {
1704  lpNameBuffer = szEmptyName;
1705  *lpcchBuffer = sizeof(WCHAR);
1706  }
1707  else
1708  {
1710  }
1711 
1712  RpcTryExcept
1713  {
1715  lpServiceName,
1716  lpNameBuffer,
1717  lpcchBuffer);
1718  }
1720  {
1722  }
1723  RpcEndExcept;
1724 
1725  if (dwError != ERROR_SUCCESS)
1726  {
1727  TRACE("RGetServiceDisplayNameW() failed (Error %lu)\n", dwError);
1728  SetLastError(dwError);
1729  return FALSE;
1730  }
1731 
1732  return TRUE;
1733 }
#define RpcEndExcept
Definition: rpc.h:128
#define TRUE
Definition: types.h:120
DWORD WINAPI RGetServiceDisplayNameW(SC_RPC_HANDLE hSCManager, LPCWSTR lpServiceName, LPWSTR lpDisplayName, DWORD *lpcchBuffer)
Definition: rpcserver.c:3311
#define ERROR_SUCCESS
Definition: deptool.c:10
#define ERROR_INVALID_HANDLE
Definition: compat.h:88
#define debugstr_w
Definition: kernel32.h:32
#define RpcTryExcept
Definition: rpc.h:126
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
static LPSTR lpNameBuffer
Definition: secur32.c:50
#define RpcExceptionCode()
Definition: rpc.h:132
#define TRACE(s)
Definition: solgame.cpp:4
__wchar_t WCHAR
Definition: xmlstorage.h:180
DWORD ScmRpcStatusToWinError(RPC_STATUS Status)
Definition: scm.c:146
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:409
static const WCHAR L[]
Definition: oid.c:1250
SC_HANDLE hSCManager
Definition: sc.c:12
WCHAR * LPWSTR
Definition: xmlstorage.h:184
_In_ LPCSTR _Out_writes_to_opt_ cchDisplayName LPSTR lpDisplayName
Definition: winbase.h:2730
#define RpcExcept(expr)
Definition: rpc.h:127

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 1742 of file scm.c.

1746 {
1747  DWORD dwError;
1749  CHAR szEmptyName[] = "";
1750 
1751  TRACE("GetServiceKeyNameA(%p %s %p %p)\n",
1752  hSCManager, debugstr_a(lpDisplayName), lpServiceName, lpcchBuffer);
1753 
1754  if (!hSCManager)
1755  {
1757  return FALSE;
1758  }
1759 
1760  if (!lpServiceName || *lpcchBuffer < sizeof(CHAR))
1761  {
1762  lpNameBuffer = szEmptyName;
1763  *lpcchBuffer = sizeof(CHAR);
1764  }
1765  else
1766  {
1767  lpNameBuffer = lpServiceName;
1768  }
1769 
1770  RpcTryExcept
1771  {
1773  lpDisplayName,
1774  lpNameBuffer,
1775  lpcchBuffer);
1776  }
1778  {
1779  /* HACK: because of a problem with rpcrt4, rpcserver is hacked to return 6 for ERROR_SERVICE_DOES_NOT_EXIST */
1781  }
1782  RpcEndExcept;
1783 
1784  if (dwError != ERROR_SUCCESS)
1785  {
1786  TRACE("RGetServiceKeyNameA() failed (Error %lu)\n", dwError);
1787  SetLastError(dwError);
1788  return FALSE;
1789  }
1790 
1791  return TRUE;
1792 }
#define RpcEndExcept
Definition: rpc.h:128
#define TRUE
Definition: types.h:120
#define ERROR_SUCCESS
Definition: deptool.c:10
char CHAR
Definition: xmlstorage.h:175
#define ERROR_INVALID_HANDLE
Definition: compat.h:88
char * LPSTR
Definition: xmlstorage.h:182
#define RpcTryExcept
Definition: rpc.h:126
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
static LPSTR lpNameBuffer
Definition: secur32.c:50
#define RpcExceptionCode()
Definition: rpc.h:132
#define TRACE(s)
Definition: solgame.cpp:4
#define debugstr_a
Definition: kernel32.h:31
DWORD ScmRpcStatusToWinError(RPC_STATUS Status)
Definition: scm.c:146
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:409
SC_HANDLE hSCManager
Definition: sc.c:12
DWORD WINAPI RGetServiceKeyNameA(SC_RPC_HANDLE hSCManager, LPCSTR lpDisplayName, LPSTR lpServiceName, LPBOUNDED_DWORD_4K lpcchBuffer)
Definition: rpcserver.c:4576
#define CHAR(Char)
_In_ LPCSTR _Out_writes_to_opt_ cchDisplayName LPSTR lpDisplayName
Definition: winbase.h:2730
#define RpcExcept(expr)
Definition: rpc.h:127

Referenced by test_get_servicekeyname().

◆ GetServiceKeyNameW()

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

Definition at line 1801 of file scm.c.

1805 {
1806  DWORD dwError;
1808  WCHAR szEmptyName[] = L"";
1809 
1810  TRACE("GetServiceKeyNameW(%p %s %p %p)\n",
1811  hSCManager, debugstr_w(lpDisplayName), lpServiceName, lpcchBuffer);
1812 
1813  if (!hSCManager)
1814  {
1816  return FALSE;
1817  }
1818 
1819  /*
1820  * NOTE: A size of 1 character would be enough, but tests show that
1821  * Windows returns 2 characters instead, certainly due to a WCHAR/bytes
1822  * mismatch in their code.
1823  */
1824  if (!lpServiceName || *lpcchBuffer < sizeof(WCHAR))
1825  {
1826  lpNameBuffer = szEmptyName;
1827  *lpcchBuffer = sizeof(WCHAR);
1828  }
1829  else
1830  {
1831  lpNameBuffer = lpServiceName;
1832  }
1833 
1834  RpcTryExcept
1835  {
1837  lpDisplayName,
1838  lpNameBuffer,
1839  lpcchBuffer);
1840  }
1842  {
1844  }
1845  RpcEndExcept;
1846 
1847  if (dwError != ERROR_SUCCESS)
1848  {
1849  TRACE("RGetServiceKeyNameW() failed (Error %lu)\n", dwError);
1850  SetLastError(dwError);
1851  return FALSE;
1852  }
1853 
1854  return TRUE;
1855 }
#define RpcEndExcept
Definition: rpc.h:128
#define TRUE
Definition: types.h:120
#define ERROR_SUCCESS
Definition: deptool.c:10
#define ERROR_INVALID_HANDLE
Definition: compat.h:88
DWORD WINAPI RGetServiceKeyNameW(SC_RPC_HANDLE hSCManager, LPCWSTR lpDisplayName, LPWSTR lpServiceName, DWORD *lpcchBuffer)
Definition: rpcserver.c:3374
#define debugstr_w
Definition: kernel32.h:32
#define RpcTryExcept
Definition: rpc.h:126
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
static LPSTR lpNameBuffer
Definition: secur32.c:50
#define RpcExceptionCode()
Definition: rpc.h:132
#define TRACE(s)
Definition: solgame.cpp:4
__wchar_t WCHAR
Definition: xmlstorage.h:180
DWORD ScmRpcStatusToWinError(RPC_STATUS Status)
Definition: scm.c:146
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:409
static const WCHAR L[]
Definition: oid.c:1250
SC_HANDLE hSCManager
Definition: sc.c:12
WCHAR * LPWSTR
Definition: xmlstorage.h:184
_In_ LPCSTR _Out_writes_to_opt_ cchDisplayName LPSTR lpDisplayName
Definition: winbase.h:2730
#define RpcExcept(expr)
Definition: rpc.h:127

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 3127 of file scm.c.

3130 {
3131  /*
3132  * We only support one information class and it
3133  * needs parameters
3134  */
3136  InOutParams == NULL)
3137  {
3138  return ERROR_INVALID_PARAMETER;
3139  }
3140 
3141  /* Validate input structure */
3142  if (InOutParams->InParams.dwPid == 0 || InOutParams->InParams.dwTag == 0)
3143  {
3144  return ERROR_INVALID_PARAMETER;
3145  }
3146 
3147  /* Validate output structure */
3148  if (InOutParams->OutParams.pszName != NULL)
3149  {
3150  return ERROR_INVALID_PARAMETER;
3151  }
3152 
3153  /* Call internal function for the RPC call */
3155 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
DWORD I_ScQueryServiceTagInfo(PVOID Unused, TAG_INFO_LEVEL dwInfoLevel, PTAG_INFO_NAME_FROM_TAG InOutParams)
Definition: scm.c:3027
_Must_inspect_result_ typedef _In_ PVOID Unused
Definition: iotypes.h:1128
TAG_INFO_NAME_FROM_TAG_OUT_PARAMS OutParams
Definition: svcctl.idl:320
TAG_INFO_NAME_FROM_TAG_IN_PARAMS InParams
Definition: svcctl.idl:319
smooth NULL
Definition: ftsmooth.c:416
_In_ DWORD dwInfoLevel
Definition: winsvc.h:422

◆ I_ScGetCurrentGroupStateW()

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

Definition at line 1864 of file scm.c.

1867 {
1868  DWORD dwError;
1869 
1870  TRACE("I_ScGetCurrentGroupStateW(%p %s %p)\n",
1871  hSCManager, debugstr_w(pszGroupName), pdwGroupState);
1872 
1873  RpcTryExcept
1874  {
1876  pszGroupName,
1877  pdwGroupState);
1878  }
1880  {
1882  }
1883  RpcEndExcept
1884 
1885  if (dwError != ERROR_SUCCESS)
1886  {
1887  TRACE("RI_ScGetCurrentGroupStateW() failed (Error %lu)\n", dwError);
1888  SetLastError(dwError);
1889  }
1890 
1891  return dwError;
1892 }
#define RpcEndExcept
Definition: rpc.h:128
#define ERROR_SUCCESS
Definition: deptool.c:10
#define debugstr_w
Definition: kernel32.h:32
#define RpcTryExcept
Definition: rpc.h:126
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
#define RpcExceptionCode()
Definition: rpc.h:132
#define TRACE(s)
Definition: solgame.cpp:4
DWORD ScmRpcStatusToWinError(RPC_STATUS Status)
Definition: scm.c:146
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:409
SC_HANDLE hSCManager
Definition: sc.c:12
DWORD WINAPI RI_ScGetCurrentGroupStateW(SC_RPC_HANDLE hSCManager, LPWSTR lpLoadOrderGroup, LPDWORD lpState)
Definition: rpcserver.c:4690
#define RpcExcept(expr)
Definition: rpc.h:127

◆ I_ScQueryServiceTagInfo()

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

Definition at line 3027 of file scm.c.

3030 {
3031  SC_HANDLE hScm;
3032  DWORD dwError;
3035  LPWSTR lpszName;
3036 
3037  /* We only support one class */
3039  {
3040  return ERROR_RETRY;
3041  }
3042 
3043  /* Validate input structure */
3044  if (InOutParams->InParams.dwPid == 0 || InOutParams->InParams.dwTag == 0)
3045  {
3046  return ERROR_INVALID_PARAMETER;
3047  }
3048 
3049  /* Validate output structure */
3050  if (InOutParams->OutParams.pszName != NULL)
3051  {
3052  return ERROR_INVALID_PARAMETER;
3053  }
3054 
3055  /* Open service manager */
3057  if (hScm == NULL)
3058  {
3059  return GetLastError();
3060  }
3061 
3062  /* Setup call parameters */
3063  InParams = &InOutParams->InParams;
3064  OutParams = NULL;
3065 
3066  /* Call SCM to query tag information */
3067  RpcTryExcept
3068  {
3069  dwError = RI_ScQueryServiceTagInfo(hScm, TagInfoLevelNameFromTag, &InParams, &OutParams);
3070  }
3072  {
3074  }
3075  RpcEndExcept;
3076 
3077  /* Quit if not a success */
3078  if (dwError != ERROR_SUCCESS)
3079  {
3080  goto Cleanup;
3081  }
3082 
3083  /* OutParams must be set now and we must have a name */
3084  if (OutParams == NULL ||
3085  OutParams->pszName == NULL)
3086  {
3087  dwError = ERROR_INVALID_DATA;
3088  goto Cleanup;
3089  }
3090 
3091  /* Copy back what SCM returned */
3092  lpszName = LocalAlloc(LPTR,
3093  sizeof(WCHAR) * wcslen(OutParams->pszName) + sizeof(UNICODE_NULL));
3094  if (lpszName == NULL)
3095  {
3096  dwError = GetLastError();
3097  goto Cleanup;
3098  }
3099 
3100  wcscpy(lpszName, OutParams->pszName);
3101  InOutParams->OutParams.pszName = lpszName;
3102  InOutParams->OutParams.TagType = OutParams->TagType;
3103 
3104 Cleanup:
3105  CloseServiceHandle(hScm);
3106 
3107  /* Free memory allocated by SCM */
3108  if (OutParams != NULL)
3109  {
3110  if (OutParams->pszName != NULL)
3111  {
3112  midl_user_free(OutParams->pszName);
3113  }
3114 
3115  midl_user_free(OutParams);
3116  }
3117 
3118  return dwError;
3119 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
#define SC_MANAGER_ENUMERATE_SERVICE
Definition: winsvc.h:16
#define midl_user_free
Definition: rpc.h:45
#define RpcEndExcept
Definition: rpc.h:128
#define ERROR_SUCCESS
Definition: deptool.c:10
TAG_INFO_NAME_FROM_TAG_OUT_PARAMS OutParams
Definition: svcctl.idl:320
TAG_INFO_NAME_FROM_TAG_IN_PARAMS InParams
Definition: svcctl.idl:319
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
#define UNICODE_NULL
#define RpcTryExcept
Definition: rpc.h:126
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
BOOL WINAPI CloseServiceHandle(SC_HANDLE hSCObject)
Definition: scm.c:577
smooth NULL
Definition: ftsmooth.c:416
#define RpcExceptionCode()
Definition: rpc.h:132
__wchar_t WCHAR
Definition: xmlstorage.h:180
DWORD ScmRpcStatusToWinError(RPC_STATUS Status)
Definition: scm.c:146
unsigned long DWORD
Definition: ntddk_ex.h:95
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
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:6587
SC_HANDLE WINAPI OpenSCManagerW(LPCWSTR lpMachineName, LPCWSTR lpDatabaseName, DWORD dwDesiredAccess)
Definition: scm.c:2011
static const WCHAR Cleanup[]
Definition: register.c:80
_In_ DWORD dwInfoLevel
Definition: winsvc.h:422
#define ERROR_INVALID_DATA
Definition: winerror.h:116
#define ERROR_RETRY
Definition: winerror.h:740
#define LPTR
Definition: winbase.h:362
HLOCAL NTAPI LocalAlloc(UINT uFlags, SIZE_T dwBytes)
Definition: heapmem.c:1373
WCHAR * LPWSTR
Definition: xmlstorage.h:184
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define RpcExcept(expr)
Definition: rpc.h:127

Referenced by I_QueryTagInformation().

◆ LockServiceDatabase()

SC_LOCK WINAPI LockServiceDatabase ( SC_HANDLE  hSCManager)

Definition at line 1901 of file scm.c.

1902 {
1903  SC_LOCK hLock;
1904  DWORD dwError;
1905 
1906  TRACE("LockServiceDatabase(%p)\n",
1907  hSCManager);
1908 
1909  RpcTryExcept
1910  {
1912  (SC_RPC_LOCK *)&hLock);
1913  }
1915  {
1917  }
1918  RpcEndExcept;
1919 
1920  if (dwError != ERROR_SUCCESS)
1921  {
1922  TRACE("RLockServiceDatabase() failed (Error %lu)\n", dwError);
1923  SetLastError(dwError);
1924  return NULL;
1925  }
1926 
1927  TRACE("hLock = %p\n", hLock);
1928 
1929  return hLock;
1930 }
#define RpcEndExcept
Definition: rpc.h:128
#define ERROR_SUCCESS
Definition: deptool.c:10
#define RpcTryExcept
Definition: rpc.h:126
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
smooth NULL
Definition: ftsmooth.c:416
#define RpcExceptionCode()
Definition: rpc.h:132
#define TRACE(s)
Definition: solgame.cpp:4
DWORD ScmRpcStatusToWinError(RPC_STATUS Status)
Definition: scm.c:146
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:409
SC_HANDLE hSCManager
Definition: sc.c:12
DWORD WINAPI RLockServiceDatabase(SC_RPC_HANDLE hSCManager, LPSC_RPC_LOCK lpLock)
Definition: rpcserver.c:1360
#define RpcExcept(expr)
Definition: rpc.h:127

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

◆ NotifyBootConfigStatus()

BOOL WINAPI NotifyBootConfigStatus ( BOOL  BootAcceptable)

Definition at line 2998 of file scm.c.

2999 {
3000  DWORD dwError;
3001 
3002  TRACE("NotifyBootConfigStatus(%u)\n",
3003  BootAcceptable);
3004 
3005  RpcTryExcept
3006  {
3007  dwError = RNotifyBootConfigStatus(NULL,
3008  BootAcceptable);
3009  }
3011  {
3013  }
3014  RpcEndExcept;
3015 
3016  if (dwError != ERROR_SUCCESS)
3017  {
3018  TRACE("NotifyBootConfigStatus() failed (Error %lu)\n", dwError);
3019  SetLastError(dwError);
3020  return FALSE;
3021  }
3022 
3023  return TRUE;
3024 }
#define RpcEndExcept
Definition: rpc.h:128
#define TRUE
Definition: types.h:120
#define ERROR_SUCCESS
Definition: deptool.c:10
#define RpcTryExcept
Definition: rpc.h:126
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
smooth NULL
Definition: ftsmooth.c:416
DWORD WINAPI RNotifyBootConfigStatus(SVCCTL_HANDLEW lpMachineName, DWORD BootAcceptable)
Definition: rpcserver.c:1847
#define RpcExceptionCode()
Definition: rpc.h:132
#define TRACE(s)
Definition: solgame.cpp:4
DWORD ScmRpcStatusToWinError(RPC_STATUS Status)
Definition: scm.c:146
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:409
#define RpcExcept(expr)
Definition: rpc.h:127

Referenced by _tmain().

◆ OpenSCManagerA()

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

Definition at line 1967 of file scm.c.

1970 {
1971  SC_HANDLE hScm = NULL;
1972  DWORD dwError;
1973 
1974  TRACE("OpenSCManagerA(%s %s %lx)\n",
1975  debugstr_a(lpMachineName), debugstr_a(lpDatabaseName), dwDesiredAccess);
1976 
1977  WaitForSCManager();
1978 
1979  RpcTryExcept
1980  {
1981  dwError = ROpenSCManagerA((LPSTR)lpMachineName,
1982  (LPSTR)lpDatabaseName,
1983  dwDesiredAccess,
1984  (SC_RPC_HANDLE *)&hScm);
1985  }
1987  {
1989  }
1990  RpcEndExcept;
1991 
1992  if (dwError != ERROR_SUCCESS)
1993  {
1994  TRACE("ROpenSCManagerA() failed (Error %lu)\n", dwError);
1995  SetLastError(dwError);
1996  return NULL;
1997  }
1998 
1999  TRACE("hScm = %p\n", hScm);
2000 
2001  return hScm;
2002 }
static VOID WaitForSCManager(VOID)
Definition: scm.c:1934
#define RpcEndExcept
Definition: rpc.h:128
#define ERROR_SUCCESS
Definition: deptool.c:10
char * LPSTR
Definition: xmlstorage.h:182
#define RpcTryExcept
Definition: rpc.h:126
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
smooth NULL
Definition: ftsmooth.c:416
#define RpcExceptionCode()
Definition: rpc.h:132
#define TRACE(s)
Definition: solgame.cpp:4
#define debugstr_a
Definition: kernel32.h:31
DWORD ScmRpcStatusToWinError(RPC_STATUS Status)
Definition: scm.c:146
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:409
DWORD WINAPI ROpenSCManagerA(LPSTR lpMachineName, LPSTR lpDatabaseName, DWORD dwDesiredAccess, LPSC_RPC_HANDLE lpScHandle)
Definition: rpcserver.c:4000
#define RpcExcept(expr)
Definition: rpc.h:127

Referenced by check_service_is_installed(), delete_test_service(), RunTest(), 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 2011 of file scm.c.

2014 {
2015  SC_HANDLE hScm = NULL;
2016  DWORD dwError;
2017 
2018  TRACE("OpenSCManagerW(%s %s %lx)\n",
2019  debugstr_w(lpMachineName), debugstr_w(lpDatabaseName), dwDesiredAccess);
2020 
2021  WaitForSCManager();
2022 
2023  RpcTryExcept
2024  {
2025  dwError = ROpenSCManagerW((LPWSTR)lpMachineName,
2026  (LPWSTR)lpDatabaseName,
2027  dwDesiredAccess,
2028  (SC_RPC_HANDLE *)&hScm);
2029  }
2031  {
2033  }
2034  RpcEndExcept;
2035 
2036  if (dwError != ERROR_SUCCESS)
2037  {
2038  TRACE("ROpenSCManagerW() failed (Error %lu)\n", dwError);
2039  SetLastError(dwError);
2040  return NULL;
2041  }
2042 
2043  TRACE("hScm = %p\n", hScm);
2044 
2045  return hScm;
2046 }
static VOID WaitForSCManager(VOID)
Definition: scm.c:1934
#define RpcEndExcept
Definition: rpc.h:128
#define ERROR_SUCCESS
Definition: deptool.c:10
DWORD WINAPI ROpenSCManagerW(LPWSTR lpMachineName, LPWSTR lpDatabaseName, DWORD dwDesiredAccess, LPSC_RPC_HANDLE lpScHandle)
Definition: rpcserver.c:2862
#define debugstr_w
Definition: kernel32.h:32
#define RpcTryExcept
Definition: rpc.h:126
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
smooth NULL
Definition: ftsmooth.c:416
#define RpcExceptionCode()
Definition: rpc.h:132
#define TRACE(s)
Definition: solgame.cpp:4
DWORD ScmRpcStatusToWinError(RPC_STATUS Status)
Definition: scm.c:146
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:409
WCHAR * LPWSTR
Definition: xmlstorage.h:184
#define RpcExcept(expr)
Definition: rpc.h:127

Referenced by _RunRemoteTest(), cmdStop(), control_service(), DoControlService(), DoCreate(), DoDeleteService(), DoRegServer(), DoStartService(), DoStopService(), DoUnregServer(), EnableUserModePnpManager(), EnumerateRunningServices(), fill_service(), GetServiceConfig(), GetServiceDescription(), GetServiceList(), GetServices(), GetThemeServiceProcessHandle(), I_ScQueryServiceTagInfo(), InstallOneService(), CShellDispatch::IsServiceRunning(), ITERATE_DeleteService(), ITERATE_InstallService(), ITERATE_StartService(), ITERATE_StopService(), my_test_server(), RegisterDriver(), 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 2055 of file scm.c.

2058 {
2059  SC_HANDLE hService = NULL;
2060  DWORD dwError;
2061 
2062  TRACE("OpenServiceA(%p %s %lx)\n",
2063  hSCManager, debugstr_a(lpServiceName), dwDesiredAccess);
2064 
2065  if (!hSCManager)
2066  {
2068  return NULL;
2069  }
2070 
2071  RpcTryExcept
2072  {
2074  (LPSTR)lpServiceName,
2075  dwDesiredAccess,
2076  (SC_RPC_HANDLE *)&hService);
2077  }
2079  {
2081  }
2082  RpcEndExcept;
2083 
2084  SetLastError(dwError);
2085  if (dwError != ERROR_SUCCESS)
2086  {
2087  TRACE("ROpenServiceA() failed (Error %lu)\n", dwError);
2088  return NULL;
2089  }
2090 
2091  TRACE("hService = %p\n", hService);
2092 
2093  return hService;
2094 }
#define RpcEndExcept
Definition: rpc.h:128
#define ERROR_SUCCESS
Definition: deptool.c:10
#define ERROR_INVALID_HANDLE
Definition: compat.h:88
char * LPSTR
Definition: xmlstorage.h:182
#define RpcTryExcept
Definition: rpc.h:126
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
smooth NULL
Definition: ftsmooth.c:416
#define RpcExceptionCode()
Definition: rpc.h:132
#define TRACE(s)
Definition: solgame.cpp:4
#define debugstr_a
Definition: kernel32.h:31
DWORD ScmRpcStatusToWinError(RPC_STATUS Status)
Definition: scm.c:146
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:409
SC_HANDLE hSCManager
Definition: sc.c:12
DWORD WINAPI ROpenServiceA(SC_RPC_HANDLE hSCManager, LPSTR lpServiceName, DWORD dwDesiredAccess, LPSC_RPC_HANDLE lpServiceHandle)
Definition: rpcserver.c:4038
#define RpcExcept(expr)
Definition: rpc.h:127

Referenced by check_service_is_installed(), delete_test_service(), 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 2103 of file scm.c.

2106 {
2107  SC_HANDLE hService = NULL;
2108  DWORD dwError;
2109 
2110  TRACE("OpenServiceW(%p %s %lx)\n",
2111  hSCManager, debugstr_w(lpServiceName), dwDesiredAccess);
2112 
2113  if (!hSCManager)
2114  {
2116  return NULL;
2117  }
2118 
2119  RpcTryExcept
2120  {
2122  (LPWSTR)lpServiceName,
2123  dwDesiredAccess,
2124  (SC_RPC_HANDLE *)&hService);
2125  }
2127  {
2129  }
2130  RpcEndExcept;
2131 
2132  SetLastError(dwError);
2133  if (dwError != ERROR_SUCCESS)
2134  {
2135  TRACE("ROpenServiceW() failed (Error %lu)\n", dwError);
2136  return NULL;
2137  }
2138 
2139  TRACE("hService = %p\n", hService);
2140 
2141  return hService;
2142 }
#define RpcEndExcept
Definition: rpc.h:128
#define ERROR_SUCCESS
Definition: deptool.c:10
#define ERROR_INVALID_HANDLE
Definition: compat.h:88
#define debugstr_w
Definition: kernel32.h:32
#define RpcTryExcept
Definition: rpc.h:126
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
smooth NULL
Definition: ftsmooth.c:416
#define RpcExceptionCode()
Definition: rpc.h:132
#define TRACE(s)
Definition: solgame.cpp:4
DWORD ScmRpcStatusToWinError(RPC_STATUS Status)
Definition: scm.c:146
DWORD WINAPI ROpenServiceW(SC_RPC_HANDLE hSCManager, LPWSTR lpServiceName, DWORD dwDesiredAccess, LPSC_RPC_HANDLE lpServiceHandle)
Definition: rpcserver.c:2914
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:409
SC_HANDLE hSCManager
Definition: sc.c:12
WCHAR * LPWSTR
Definition: xmlstorage.h:184
#define RpcExcept(expr)
Definition: rpc.h:127

Referenced by _RunRemoteTest(), AddService(), cmdStop(), control_service(), DoControlService(), DoDeleteService(), DoStartService(), DoStopService(), DoUnregServer(), EnableUserModePnpManager(), GetServiceConfig(), GetServiceDescription(), GetThemeServiceProcessHandle(), InstallOneService(), CShellDispatch::IsServiceRunning(), ITERATE_DeleteService(), ITERATE_StartService(), 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 2317 of file scm.c.

2322 {
2323  SERVICE_DESCRIPTIONA ServiceDescription;
2324  SERVICE_FAILURE_ACTIONSA ServiceFailureActions;
2325  LPBYTE lpTempBuffer;
2326  BOOL bUseTempBuffer = FALSE;
2327  DWORD dwBufferSize;
2328  DWORD dwError;
2329 
2330  TRACE("QueryServiceConfig2A(%p %lu %p %lu %p)\n",
2332 
2333  lpTempBuffer = lpBuffer;
2334  dwBufferSize = cbBufSize;
2335 
2336  switch (dwInfoLevel)
2337  {
2339  if ((lpBuffer == NULL) || (cbBufSize < sizeof(SERVICE_DESCRIPTIONA)))
2340  {
2341  lpTempBuffer = (LPBYTE)&ServiceDescription;
2342  dwBufferSize = sizeof(SERVICE_DESCRIPTIONA);
2343  bUseTempBuffer = TRUE;
2344  }
2345  break;
2346 
2348  if ((lpBuffer == NULL) || (cbBufSize < sizeof(SERVICE_FAILURE_ACTIONSA)))
2349  {
2350  lpTempBuffer = (LPBYTE)&ServiceFailureActions;
2351  dwBufferSize = sizeof(SERVICE_FAILURE_ACTIONSA);
2352  bUseTempBuffer = TRUE;
2353  }
2354  break;
2355 
2356  default:
2357  WARN("Unknown info level 0x%lx\n", dwInfoLevel);
2359  return FALSE;
2360  }
2361 
2362  RpcTryExcept
2363  {
2364  dwError = RQueryServiceConfig2A((SC_RPC_HANDLE)hService,
2365  dwInfoLevel,
2366  lpTempBuffer,
2367  dwBufferSize,
2368  pcbBytesNeeded);
2369  }
2371  {
2373  }
2374  RpcEndExcept;
2375 
2376  if (dwError != ERROR_SUCCESS)
2377  {
2378  TRACE("RQueryServiceConfig2A() failed (Error %lu)\n", dwError);
2379  SetLastError(dwError);
2380  return FALSE;
2381  }
2382 
2383  if (bUseTempBuffer != FALSE)
2384  {
2385  TRACE("RQueryServiceConfig2A() returns ERROR_INSUFFICIENT_BUFFER\n");
2386  *pcbBytesNeeded = dwBufferSize;
2388  return FALSE;
2389  }
2390 
2391  switch (dwInfoLevel)
2392  {
2394  {
2395  LPSERVICE_DESCRIPTIONA lpPtr = (LPSERVICE_DESCRIPTIONA)lpTempBuffer;
2396 
2397  if (lpPtr->lpDescription != NULL)
2398  lpPtr->lpDescription =
2399  (LPSTR)((ULONG_PTR)lpPtr + (ULONG_PTR)lpPtr->lpDescription);
2400  }
2401  break;
2402 
2404  {
2406 
2407  if (lpPtr->lpRebootMsg != NULL)
2408  lpPtr->lpRebootMsg =
2409  (LPSTR)((ULONG_PTR)lpPtr + (ULONG_PTR)lpPtr->lpRebootMsg);
2410 
2411  if (lpPtr->lpCommand != NULL)
2412  lpPtr->lpCommand =
2413  (LPSTR)((ULONG_PTR)lpPtr + (ULONG_PTR)lpPtr->lpCommand);
2414 
2415  if (lpPtr->lpsaActions != NULL)
2416  lpPtr->lpsaActions =
2417  (LPSC_ACTION)((ULONG_PTR)lpPtr + (ULONG_PTR)lpPtr->lpsaActions);
2418  }
2419  break;
2420  }
2421 
2422  TRACE("QueryServiceConfig2A() done\n");
2423 
2424  return TRUE;
2425 }
#define RpcEndExcept
Definition: rpc.h:128
_In_ DWORD _In_ DWORD _Out_ LPDWORD pcbBytesNeeded
Definition: winsvc.h:424
#define TRUE
Definition: types.h:120
struct _SERVICE_DESCRIPTIONA * LPSERVICE_DESCRIPTIONA
#define ERROR_SUCCESS
Definition: deptool.c:10
struct _SERVICE_FAILURE_ACTIONSA SERVICE_FAILURE_ACTIONSA
#define WARN(fmt,...)
Definition: debug.h:111
#define SERVICE_CONFIG_DESCRIPTION
Definition: winsvc.h:65
char * LPSTR
Definition: xmlstorage.h:182
uint32_t ULONG_PTR
Definition: typedefs.h:63
unsigned char * LPBYTE
Definition: typedefs.h:52
unsigned int BOOL
Definition: ntddk_ex.h:94
static TAGREF LPCWSTR LPDWORD LPVOID lpBuffer
Definition: db.cpp:173
#define RpcTryExcept
Definition: rpc.h:126
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
smooth NULL
Definition: ftsmooth.c:416
DWORD WINAPI RQueryServiceConfig2A(SC_RPC_HANDLE hService, DWORD dwInfoLevel, LPBYTE lpBuffer, DWORD cbBufSize, LPBOUNDED_DWORD_8K pcbBytesNeeded)
Definition: rpcserver.c:5546
#define RpcExceptionCode()
Definition: rpc.h:132
#define TRACE(s)
Definition: solgame.cpp:4
DWORD ScmRpcStatusToWinError(RPC_STATUS Status)
Definition: scm.c:146
#define SERVICE_CONFIG_FAILURE_ACTIONS
Definition: winsvc.h:66
unsigned long DWORD
Definition: ntddk_ex.h:95
_In_ DWORD _In_ DWORD cbBufSize
Definition: winsvc.h:424
#define SetLastError(x)
Definition: compat.h:409
_In_ DWORD dwInfoLevel
Definition: winsvc.h:422
struct _SERVICE_DESCRIPTIONA SERVICE_DESCRIPTIONA
SC_ACTION * lpsaActions
Definition: winsvc.h:213
#define ULONG_PTR
Definition: config.h:101
#define ERROR_INVALID_LEVEL
Definition: winerror.h:196
struct _SC_ACTION * LPSC_ACTION
struct _SERVICE_FAILURE_ACTIONSA * LPSERVICE_FAILURE_ACTIONSA
#define RpcExcept(expr)
Definition: rpc.h:127
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10

Referenced by QueryConfig2A().

◆ QueryServiceConfig2W()

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

Definition at line 2434 of file scm.c.

2439 {
2440  SERVICE_DESCRIPTIONW ServiceDescription;
2441  SERVICE_FAILURE_ACTIONSW ServiceFailureActions;
2442  LPBYTE lpTempBuffer;
2443  BOOL bUseTempBuffer = FALSE;
2444  DWORD dwBufferSize;
2445  DWORD dwError;
2446 
2447  TRACE("QueryServiceConfig2W(%p %lu %p %lu %p)\n",
2449 
2450  lpTempBuffer = lpBuffer;
2451  dwBufferSize = cbBufSize;
2452 
2453  switch (dwInfoLevel)
2454  {
2456  if ((lpBuffer == NULL) || (cbBufSize < sizeof(SERVICE_DESCRIPTIONW)))
2457  {
2458  lpTempBuffer = (LPBYTE)&ServiceDescription;
2459  dwBufferSize = sizeof(SERVICE_DESCRIPTIONW);
2460  bUseTempBuffer = TRUE;
2461  }
2462  break;
2463 
2465  if ((lpBuffer == NULL) || (cbBufSize < sizeof(SERVICE_FAILURE_ACTIONSW)))
2466  {
2467  lpTempBuffer = (LPBYTE)&ServiceFailureActions;
2468  dwBufferSize = sizeof(SERVICE_FAILURE_ACTIONSW);
2469  bUseTempBuffer = TRUE;
2470  }
2471  break;
2472 
2473  default:
2474  WARN("Unknown info level 0x%lx\n", dwInfoLevel);
2476  return FALSE;
2477  }
2478 
2479  RpcTryExcept
2480  {
2481  dwError = RQueryServiceConfig2W((SC_RPC_HANDLE)hService,
2482  dwInfoLevel,
2483  lpTempBuffer,
2484  dwBufferSize,
2485  pcbBytesNeeded);
2486  }
2488  {
2490  }
2491  RpcEndExcept;
2492 
2493  if (dwError != ERROR_SUCCESS)
2494  {
2495  TRACE("RQueryServiceConfig2W() failed (Error %lu)\n", dwError);
2496  SetLastError(dwError);
2497  return FALSE;
2498  }
2499 
2500  if (bUseTempBuffer != FALSE)
2501  {
2502  TRACE("RQueryServiceConfig2W() returns ERROR_INSUFFICIENT_BUFFER\n");
2503  *pcbBytesNeeded = dwBufferSize;
2505  return FALSE;
2506  }
2507 
2508  switch (dwInfoLevel)
2509  {
2511  {
2512  LPSERVICE_DESCRIPTIONW lpPtr = (LPSERVICE_DESCRIPTIONW)lpTempBuffer;
2513 
2514  if (lpPtr->lpDescription != NULL)
2515  lpPtr->lpDescription =
2516  (LPWSTR)((ULONG_PTR)lpPtr + (ULONG_PTR)lpPtr->lpDescription);
2517  }
2518  break;
2519 
2521  {
2523 
2524  if (lpPtr->lpRebootMsg != NULL)
2525  lpPtr->lpRebootMsg =
2526  (LPWSTR)((ULONG_PTR)lpPtr + (ULONG_PTR)lpPtr->lpRebootMsg);
2527 
2528  if (lpPtr->lpCommand != NULL)
2529  lpPtr->lpCommand =
2530  (LPWSTR)((ULONG_PTR)lpPtr + (ULONG_PTR)lpPtr->lpCommand);
2531 
2532  if (lpPtr->lpsaActions != NULL)
2533  lpPtr->lpsaActions =
2534  (LPSC_ACTION)((ULONG_PTR)lpPtr + (ULONG_PTR)lpPtr->lpsaActions);
2535  }
2536  break;
2537  }
2538 
2539  TRACE("QueryServiceConfig2W() done\n");
2540 
2541  return TRUE;
2542 }
#define RpcEndExcept
Definition: rpc.h:128
_In_ DWORD _In_ DWORD _Out_ LPDWORD pcbBytesNeeded
Definition: winsvc.h:424
#define TRUE
Definition: types.h:120
#define ERROR_SUCCESS
Definition: deptool.c:10
SC_ACTION * lpsaActions
Definition: winsvc.h:220
#define WARN(fmt,...)
Definition: debug.h:111
struct _SERVICE_DESCRIPTIONW SERVICE_DESCRIPTIONW
#define SERVICE_CONFIG_DESCRIPTION
Definition: winsvc.h:65
uint32_t ULONG_PTR
Definition: typedefs.h:63
unsigned char * LPBYTE
Definition: typedefs.h:52
unsigned int BOOL
Definition: ntddk_ex.h:94
DWORD WINAPI RQueryServiceConfig2W(SC_RPC_HANDLE hService, DWORD dwInfoLevel, LPBYTE lpBuffer, DWORD cbBufSize, LPBOUNDED_DWORD_8K pcbBytesNeeded)
Definition: rpcserver.c:5793
static TAGREF LPCWSTR LPDWORD LPVOID lpBuffer
Definition: db.cpp:173
#define RpcTryExcept
Definition: rpc.h:126
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
smooth NULL
Definition: ftsmooth.c:416
#define RpcExceptionCode()
Definition: rpc.h:132
#define TRACE(s)
Definition: solgame.cpp:4
struct _SERVICE_DESCRIPTIONW * LPSERVICE_DESCRIPTIONW
DWORD ScmRpcStatusToWinError(RPC_STATUS Status)
Definition: scm.c:146
struct _SERVICE_FAILURE_ACTIONSW SERVICE_FAILURE_ACTIONSW
#define SERVICE_CONFIG_FAILURE_ACTIONS
Definition: winsvc.h:66
unsigned long DWORD
Definition: ntddk_ex.h:95
_In_ DWORD _In_ DWORD cbBufSize
Definition: winsvc.h:424
#define SetLastError(x)
Definition: compat.h:409
LPWSTR lpDescription
Definition: winsvc.h:196
_In_ DWORD dwInfoLevel
Definition: winsvc.h:422
struct _SERVICE_FAILURE_ACTIONSW * LPSERVICE_FAILURE_ACTIONSW
#define ULONG_PTR
Definition: config.h:101
#define ERROR_INVALID_LEVEL
Definition: winerror.h:196
WCHAR * LPWSTR
Definition: xmlstorage.h:184
struct _SC_ACTION * LPSC_ACTION
#define RpcExcept(expr)
Definition: rpc.h:127
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10

Referenced by GetServiceDescription(), and QueryConfig2W().

◆ QueryServiceConfigA()

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

Definition at line 2151 of file scm.c.

2155 {
2156  QUERY_SERVICE_CONFIGA ServiceConfig;
2157  LPQUERY_SERVICE_CONFIGA lpConfigPtr;
2158  DWORD dwBufferSize;
2159  DWORD dwError;
2160 
2161  TRACE("QueryServiceConfigA(%p %p %lu %p)\n",
2162  hService, lpServiceConfig, cbBufSize, pcbBytesNeeded);
2163 
2164  if (lpServiceConfig == NULL ||
2165  cbBufSize < sizeof(QUERY_SERVICE_CONFIGA))
2166  {
2167  lpConfigPtr = &ServiceConfig;
2168  dwBufferSize = sizeof(QUERY_SERVICE_CONFIGA);
2169  }
2170  else
2171  {
2172  lpConfigPtr = lpServiceConfig;
2173  dwBufferSize = cbBufSize;
2174  }
2175 
2176  RpcTryExcept
2177  {
2178  dwError = RQueryServiceConfigA((SC_RPC_HANDLE)hService,
2179  (LPBYTE)lpConfigPtr,
2180  dwBufferSize,
2181  pcbBytesNeeded);
2182  }
2184  {
2186  }
2187  RpcEndExcept;
2188 
2189  if (dwError != ERROR_SUCCESS)
2190  {
2191  TRACE("RQueryServiceConfigA() failed (Error %lu)\n", dwError);
2192  SetLastError(dwError);
2193  return FALSE;
2194  }
2195 
2196  /* Adjust the pointers */
2197  if (lpConfigPtr->lpBinaryPathName)
2198  lpConfigPtr->lpBinaryPathName =
2199  (LPSTR)((ULONG_PTR)lpConfigPtr +
2200  (ULONG_PTR)lpConfigPtr->lpBinaryPathName);
2201 
2202  if (lpConfigPtr->lpLoadOrderGroup)
2203  lpConfigPtr->lpLoadOrderGroup =
2204  (LPSTR)((ULONG_PTR)lpConfigPtr +
2205  (ULONG_PTR)lpConfigPtr->lpLoadOrderGroup);
2206 
2207  if (lpConfigPtr->lpDependencies)
2208  lpConfigPtr->lpDependencies =
2209  (LPSTR)((ULONG_PTR)lpConfigPtr +
2210  (ULONG_PTR)lpConfigPtr->lpDependencies);
2211 
2212  if (lpConfigPtr->lpServiceStartName)
2213  lpConfigPtr->lpServiceStartName =
2214  (LPSTR)((ULONG_PTR)lpConfigPtr +
2215  (ULONG_PTR)lpConfigPtr->lpServiceStartName);
2216 
2217  if (lpConfigPtr->lpDisplayName)
2218  lpConfigPtr->lpDisplayName =
2219  (LPSTR)((ULONG_PTR)lpConfigPtr +
2220  (ULONG_PTR)lpConfigPtr->lpDisplayName);
2221 
2222  TRACE("QueryServiceConfigA() done\n");
2223 
2224  return TRUE;
2225 }
#define RpcEndExcept
Definition: rpc.h:128
_In_ DWORD _In_ DWORD _Out_ LPDWORD pcbBytesNeeded
Definition: winsvc.h:424
#define TRUE
Definition: types.h:120
#define ERROR_SUCCESS
Definition: deptool.c:10
LPSTR lpServiceStartName
Definition: winsvc.h:152
struct _QUERY_SERVICE_CONFIGA QUERY_SERVICE_CONFIGA
char * LPSTR
Definition: xmlstorage.h:182
uint32_t ULONG_PTR
Definition: typedefs.h:63
unsigned char * LPBYTE
Definition: typedefs.h:52
#define RpcTryExcept
Definition: rpc.h:126
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
smooth NULL
Definition: ftsmooth.c:416
#define RpcExceptionCode()
Definition: rpc.h:132
#define TRACE(s)
Definition: solgame.cpp:4
DWORD ScmRpcStatusToWinError(RPC_STATUS Status)
Definition: scm.c:146
unsigned long DWORD
Definition: ntddk_ex.h:95
_In_ DWORD _In_ DWORD cbBufSize
Definition: winsvc.h:424
#define SetLastError(x)
Definition: compat.h:409
#define ULONG_PTR
Definition: config.h:101
DWORD WINAPI RQueryServiceConfigA(SC_RPC_HANDLE hService, LPBYTE lpBuf, DWORD cbBufSize, LPBOUNDED_DWORD_8K pcbBytesNeeded)
Definition: rpcserver.c:4068
#define RpcExcept(expr)
Definition: rpc.h:127

Referenced by test_sequence().

◆ QueryServiceConfigW()

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

Definition at line 2234 of file scm.c.

2238 {
2239  QUERY_SERVICE_CONFIGW ServiceConfig;
2240  LPQUERY_SERVICE_CONFIGW lpConfigPtr;
2241  DWORD dwBufferSize;
2242  DWORD dwError;
2243 
2244  TRACE("QueryServiceConfigW(%p %p %lu %p)\n",
2245  hService, lpServiceConfig, cbBufSize, pcbBytesNeeded);
2246 
2247  if (lpServiceConfig == NULL ||
2248  cbBufSize < sizeof(QUERY_SERVICE_CONFIGW))
2249  {
2250  lpConfigPtr = &ServiceConfig;
2251  dwBufferSize = sizeof(QUERY_SERVICE_CONFIGW);
2252  }
2253  else
2254  {
2255  lpConfigPtr = lpServiceConfig;
2256  dwBufferSize = cbBufSize;
2257  }
2258 
2259  RpcTryExcept
2260  {
2261  dwError = RQueryServiceConfigW((SC_RPC_HANDLE)hService,
2262  (LPBYTE)lpConfigPtr,
2263  dwBufferSize,
2264  pcbBytesNeeded);
2265  }
2267  {
2269  }
2270  RpcEndExcept;
2271 
2272  if (dwError != ERROR_SUCCESS)
2273  {
2274  TRACE("RQueryServiceConfigW() failed (Error %lu)\n", dwError);
2275  SetLastError(dwError);
2276  return FALSE;
2277  }
2278 
2279  /* Adjust the pointers */
2280  if (lpConfigPtr->lpBinaryPathName)
2281  lpConfigPtr->lpBinaryPathName =
2282  (LPWSTR)((ULONG_PTR)lpConfigPtr +
2283  (ULONG_PTR)lpConfigPtr->lpBinaryPathName);
2284 
2285  if (lpConfigPtr->lpLoadOrderGroup)
2286  lpConfigPtr->lpLoadOrderGroup =
2287  (LPWSTR)((ULONG_PTR)lpConfigPtr +
2288  (ULONG_PTR)lpConfigPtr->lpLoadOrderGroup);
2289 
2290  if (lpConfigPtr->lpDependencies)
2291  lpConfigPtr->lpDependencies =
2292  (LPWSTR)((ULONG_PTR)lpConfigPtr +
2293  (ULONG_PTR)lpConfigPtr->lpDependencies);
2294 
2295  if (lpConfigPtr->lpServiceStartName)
2296  lpConfigPtr->lpServiceStartName =
2297  (LPWSTR)((ULONG_PTR)lpConfigPtr +
2298  (ULONG_PTR)lpConfigPtr->lpServiceStartName);
2299 
2300  if (lpConfigPtr->lpDisplayName)
2301  lpConfigPtr->lpDisplayName =
2302  (LPWSTR)((ULONG_PTR)lpConfigPtr +
2303  (ULONG_PTR)lpConfigPtr->lpDisplayName);
2304 
2305  TRACE("QueryServiceConfigW() done\n");
2306 
2307  return TRUE;
2308 }
DWORD WINAPI RQueryServiceConfigW(SC_RPC_HANDLE hService, LPBYTE lpBuf, DWORD cbBufSize, LPBOUNDED_DWORD_8K pcbBytesNeeded)
Definition: rpcserver.c:2997
#define RpcEndExcept
Definition: rpc.h:128
_In_ DWORD _In_ DWORD _Out_ LPDWORD pcbBytesNeeded
Definition: winsvc.h:424
struct _QUERY_SERVICE_CONFIGW QUERY_SERVICE_CONFIGW
#define TRUE
Definition: types.h:120
#define ERROR_SUCCESS
Definition: deptool.c:10
LPWSTR lpLoadOrderGroup
Definition: winsvc.h:160
uint32_t ULONG_PTR
Definition: typedefs.h:63
unsigned char * LPBYTE
Definition: typedefs.h:52
#define RpcTryExcept
Definition: rpc.h:126
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
smooth NULL
Definition: ftsmooth.c:416
#define RpcExceptionCode()
Definition: rpc.h:132
#define TRACE(s)
Definition: solgame.cpp:4
DWORD ScmRpcStatusToWinError(RPC_STATUS Status)
Definition: scm.c:146
unsigned long DWORD
Definition: ntddk_ex.h:95
_In_ DWORD _In_ DWORD cbBufSize
Definition: winsvc.h:424
#define SetLastError(x)
Definition: compat.h:409
LPWSTR lpServiceStartName
Definition: winsvc.h:163
#define ULONG_PTR
Definition: config.h:101
LPWSTR lpBinaryPathName
Definition: winsvc.h:159
WCHAR * LPWSTR
Definition: xmlstorage.h:184
#define RpcExcept(expr)
Definition: rpc.h:127

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 2551 of file scm.c.

2555 {
2556  QUERY_SERVICE_LOCK_STATUSA LockStatus;
2557  LPQUERY_SERVICE_LOCK_STATUSA lpStatusPtr;
2558  DWORD dwBufferSize;
2559  DWORD dwError;
2560 
2561  TRACE("QueryServiceLockStatusA(%p %p %lu %p)\n",
2562  hSCManager, lpLockStatus, cbBufSize, pcbBytesNeeded);
2563 
2564  if (lpLockStatus == NULL || cbBufSize < sizeof(QUERY_SERVICE_LOCK_STATUSA))
2565  {
2566  lpStatusPtr = &LockStatus;
2567  dwBufferSize = sizeof(QUERY_SERVICE_LOCK_STATUSA);
2568  }
2569  else
2570  {
2571  lpStatusPtr = lpLockStatus;
2572  dwBufferSize = cbBufSize;
2573  }
2574 
2575  RpcTryExcept
2576  {
2578  (LPBYTE)lpStatusPtr,
2579  dwBufferSize,
2580  pcbBytesNeeded);
2581  }
2583  {
2585  }
2586  RpcEndExcept;
2587 
2588  if (dwError != ERROR_SUCCESS)
2589  {
2590  TRACE("RQueryServiceLockStatusA() failed (Error %lu)\n", dwError);
2591  SetLastError(dwError);
2592  return FALSE;
2593  }
2594 
2595  if (lpStatusPtr->lpLockOwner != NULL)
2596  {
2597  lpStatusPtr->lpLockOwner =
2598  (LPSTR)((ULONG_PTR)lpStatusPtr + (ULONG_PTR)lpStatusPtr->lpLockOwner);
2599  }
2600 
2601  TRACE("QueryServiceLockStatusA() done\n");
2602 
2603  return TRUE;
2604 }
#define RpcEndExcept
Definition: rpc.h:128
_In_ DWORD _In_ DWORD _Out_ LPDWORD pcbBytesNeeded
Definition: winsvc.h:424
#define TRUE
Definition: types.h:120
#define ERROR_SUCCESS
Definition: deptool.c:10
char * LPSTR
Definition: xmlstorage.h:182
uint32_t ULONG_PTR
Definition: typedefs.h:63
unsigned char * LPBYTE
Definition: typedefs.h:52
#define RpcTryExcept
Definition: rpc.h:126
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
smooth NULL
Definition: ftsmooth.c:416
#define RpcExceptionCode()
Definition: rpc.h:132
#define TRACE(s)
Definition: solgame.cpp:4
DWORD ScmRpcStatusToWinError(RPC_STATUS Status)
Definition: scm.c:146
unsigned long DWORD
Definition: ntddk_ex.h:95
_In_ DWORD _In_ DWORD cbBufSize
Definition: winsvc.h:424
#define SetLastError(x)
Definition: compat.h:409
SC_HANDLE hSCManager
Definition: sc.c:12
struct _QUERY_SERVICE_LOCK_STATUSA QUERY_SERVICE_LOCK_STATUSA
DWORD WINAPI RQueryServiceLockStatusA(SC_RPC_HANDLE hSCManager, LPBYTE lpBuf, DWORD cbBufSize, LPBOUNDED_DWORD_4K pcbBytesNeeded)
Definition: rpcserver.c:4309
#define ULONG_PTR
Definition: config.h:101
#define RpcExcept(expr)
Definition: rpc.h:127

Referenced by Test_QueryLockStatusA().

◆ QueryServiceLockStatusW()

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

Definition at line 2613 of file scm.c.

2617 {
2618  QUERY_SERVICE_LOCK_STATUSW LockStatus;
2619  LPQUERY_SERVICE_LOCK_STATUSW lpStatusPtr;
2620  DWORD dwBufferSize;
2621  DWORD dwError;
2622 
2623  TRACE("QueryServiceLockStatusW(%p %p %lu %p)\n",
2624  hSCManager, lpLockStatus, cbBufSize, pcbBytesNeeded);
2625 
2626  if (lpLockStatus == NULL || cbBufSize < sizeof(QUERY_SERVICE_LOCK_STATUSW))
2627  {
2628  lpStatusPtr = &LockStatus;
2629  dwBufferSize = sizeof(QUERY_SERVICE_LOCK_STATUSW);
2630  }
2631  else
2632  {
2633  lpStatusPtr = lpLockStatus;
2634  dwBufferSize = cbBufSize;
2635  }
2636 
2637  RpcTryExcept
2638  {
2640  (LPBYTE)lpStatusPtr,
2641  dwBufferSize,
2642  pcbBytesNeeded);
2643  }
2645  {
2647  }
2648  RpcEndExcept;
2649 
2650  if (dwError != ERROR_SUCCESS)
2651  {
2652  TRACE("RQueryServiceLockStatusW() failed (Error %lu)\n", dwError);
2653  SetLastError(dwError);
2654  return FALSE;
2655  }
2656 
2657  if (lpStatusPtr->lpLockOwner != NULL)
2658  {
2659  lpStatusPtr->lpLockOwner =
2660  (LPWSTR)((ULONG_PTR)lpStatusPtr + (ULONG_PTR)lpStatusPtr->lpLockOwner);
2661  }
2662 
2663  TRACE("QueryServiceLockStatusW() done\n");
2664 
2665  return TRUE;
2666 }
#define RpcEndExcept
Definition: rpc.h:128
_In_ DWORD _In_ DWORD _Out_ LPDWORD pcbBytesNeeded
Definition: winsvc.h:424
#define TRUE
Definition: types.h:120
#define ERROR_SUCCESS
Definition: deptool.c:10
uint32_t ULONG_PTR
Definition: typedefs.h:63
unsigned char * LPBYTE
Definition: typedefs.h:52
#define RpcTryExcept
Definition: rpc.h:126
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
smooth NULL
Definition: ftsmooth.c:416
#define RpcExceptionCode()
Definition: rpc.h:132
#define TRACE(s)
Definition: solgame.cpp:4
struct _QUERY_SERVICE_LOCK_STATUSW QUERY_SERVICE_LOCK_STATUSW
DWORD ScmRpcStatusToWinError(RPC_STATUS Status)
Definition: scm.c:146
unsigned long DWORD
Definition: ntddk_ex.h:95
_In_ DWORD _In_ DWORD cbBufSize
Definition: winsvc.h:424
#define SetLastError(x)
Definition: compat.h:409
SC_HANDLE hSCManager
Definition: sc.c:12
#define ULONG_PTR
Definition: config.h:101
DWORD WINAPI RQueryServiceLockStatusW(SC_RPC_HANDLE hSCManager, LPBYTE lpBuf, DWORD cbBufSize, LPBOUNDED_DWORD_4K pcbBytesNeeded)
Definition: rpcserver.c:3205
WCHAR * LPWSTR
Definition: xmlstorage.h:184
#define RpcExcept(expr)
Definition: rpc.h:127

Referenced by Test_QueryLockStatusW().

◆ QueryServiceObjectSecurity()

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

Definition at line 2675 of file scm.c.

2680 {
2681  DWORD dwError;
2682 
2683  TRACE("QueryServiceObjectSecurity(%p %lu %p)\n",
2684  hService, dwSecurityInformation, lpSecurityDescriptor);
2685 
2686  RpcTryExcept
2687  {
2688  dwError = RQueryServiceObjectSecurity((SC_RPC_HANDLE)hService,
2689  dwSecurityInformation,
2690  (LPBYTE)lpSecurityDescriptor,
2691  cbBufSize,
2692  pcbBytesNeeded);
2693  }
2695  {
2697  }
2698  RpcEndExcept;
2699 
2700  if (dwError != ERROR_SUCCESS)
2701  {
2702  TRACE("QueryServiceObjectSecurity() failed (Error %lu)\n", dwError);
2703  SetLastError(dwError);
2704  return FALSE;
2705  }
2706 
2707  return TRUE;
2708 }
#define RpcEndExcept
Definition: rpc.h:128
_In_ DWORD _In_ DWORD _Out_ LPDWORD pcbBytesNeeded
Definition: winsvc.h:424
#define TRUE
Definition: types.h:120
#define ERROR_SUCCESS
Definition: deptool.c:10
DWORD WINAPI RQueryServiceObjectSecurity(SC_RPC_HANDLE hService, SECURITY_INFORMATION dwSecurityInformation, LPBYTE lpSecurityDescriptor, DWORD cbBufSize, LPBOUNDED_DWORD_256K pcbBytesNeeded)
Definition: rpcserver.c:1388
unsigned char * LPBYTE
Definition: typedefs.h:52
#define RpcTryExcept
Definition: rpc.h:126
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
#define RpcExceptionCode()
Definition: rpc.h:132
#define TRACE(s)
Definition: solgame.cpp:4
DWORD ScmRpcStatusToWinError(RPC_STATUS Status)
Definition: scm.c:146
unsigned long DWORD
Definition: ntddk_ex.h:95
_In_ DWORD _In_ DWORD cbBufSize
Definition: winsvc.h:424
#define SetLastError(x)
Definition: compat.h:409
#define RpcExcept(expr)
Definition: rpc.h:127

Referenced by AccRewriteGetHandleRights(), and SdShow().

◆ QueryServiceStatus()

BOOL WINAPI QueryServiceStatus ( SC_HANDLE  hService,
LPSERVICE_STATUS  lpServiceStatus 
)

Definition at line 2788 of file scm.c.

2790 {
2791  DWORD dwError;
2792 
2793  TRACE("QueryServiceStatus(%p %p)\n",
2794  hService, lpServiceStatus);
2795 
2796  if (!hService)
2797  {
2799  return FALSE;
2800  }
2801 
2802  RpcTryExcept
2803  {
2804  dwError = RQueryServiceStatus((SC_RPC_HANDLE)hService,
2805  lpServiceStatus);
2806  }
2808  {
2810  }
2811  RpcEndExcept;
2812 
2813  if (dwError != ERROR_SUCCESS)
2814  {
2815  TRACE("RQueryServiceStatus() failed (Error %lu)\n", dwError);
2816  SetLastError(dwError);
2817  return FALSE;
2818  }
2819 
2820  return TRUE;
2821 }
#define RpcEndExcept
Definition: rpc.h:128
#define TRUE
Definition: types.h:120
#define ERROR_SUCCESS
Definition: deptool.c:10
#define ERROR_INVALID_HANDLE
Definition: compat.h:88
#define RpcTryExcept
Definition: rpc.h:126
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
DWORD WINAPI RQueryServiceStatus(SC_RPC_HANDLE hService, LPSERVICE_STATUS lpServiceStatus)
Definition: rpcserver.c:1606
#define RpcExceptionCode()
Definition: rpc.h:132
#define TRACE(s)
Definition: solgame.cpp:4
DWORD ScmRpcStatusToWinError(RPC_STATUS Status)
Definition: scm.c:146
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:409
#define RpcExcept(expr)
Definition: rpc.h:127

Referenced by _RunRemoteTest(), CmdRemoveService(), KmtEnsureServiceState(), my_test_server(), QueryDriverInfo(), ServiceInfo(), ServiceStart(), 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 2830 of file scm.c.

2835 {
2836  DWORD dwError;
2837 
2838  TRACE("QueryServiceStatusEx(%p %lu %p %lu %p)\n",
2839  hService, InfoLevel, lpBuffer, cbBufSize, pcbBytesNeeded);
2840 
2841  if (InfoLevel != SC_STATUS_PROCESS_INFO)
2842  {
2844  return FALSE;
2845  }
2846 
2847  if (cbBufSize < sizeof(SERVICE_STATUS_PROCESS))
2848  {
2851  return FALSE;
2852  }
2853 
2854  RpcTryExcept
2855  {
2856  dwError = RQueryServiceStatusEx((SC_RPC_HANDLE)hService,
2857  InfoLevel,
2858  lpBuffer,
2859  cbBufSize,
2860  pcbBytesNeeded);
2861  }
2863  {
2865  }
2866  RpcEndExcept;
2867 
2868  if (dwError != ERROR_SUCCESS)
2869  {
2870  TRACE("RQueryServiceStatusEx() failed (Error %lu)\n", dwError);
2871  SetLastError(dwError);
2872  return FALSE;
2873  }
2874 
2875  return TRUE;
2876 }
#define RpcEndExcept
Definition: rpc.h:128
_In_ DWORD _In_ DWORD _Out_ LPDWORD pcbBytesNeeded
Definition: winsvc.h:424
#define TRUE
Definition: types.h:120
#define ERROR_SUCCESS
Definition: deptool.c:10
struct _SERVICE_STATUS_PROCESS SERVICE_STATUS_PROCESS
static TAGREF LPCWSTR LPDWORD LPVOID lpBuffer
Definition: db.cpp:173
#define RpcTryExcept
Definition: rpc.h:126
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
#define RpcExceptionCode()
Definition: rpc.h:132
#define TRACE(s)
Definition: solgame.cpp:4
DWORD ScmRpcStatusToWinError(RPC_STATUS Status)
Definition: scm.c:146
unsigned long DWORD
Definition: ntddk_ex.h:95
_In_ DWORD _In_ DWORD cbBufSize
Definition: winsvc.h:424
#define SetLastError(x)
Definition: compat.h:409
DWORD WINAPI RQueryServiceStatusEx(SC_RPC_HANDLE hService, SC_STATUS_TYPE InfoLevel, LPBYTE lpBuffer, DWORD cbBufSize, LPBOUNDED_DWORD_8K pcbBytesNeeded)
Definition: rpcserver.c:6017
#define ERROR_INVALID_LEVEL
Definition: winerror.h:196
#define RpcExcept(expr)
Definition: rpc.h:127
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10

Referenced by DoControlService(), DoStartService(), DoStopService(), 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_ PCWSTR  pClearTextPassword,
_Out_ PBYTE pEncryptedPassword,
_Out_ PDWORD  pEncryptedPasswordSize 
)
static

Definition at line 173 of file scm.c.

177 {
178  struct ustring inData, keyData, outData;
179  BYTE SessionKey[16];
180  PBYTE pBuffer;
182 
183  /* Get the session key */
185  SessionKey);
186  if (!NT_SUCCESS(Status))
187  {
188  ERR("SystemFunction028 failed (Status 0x%08lx)\n", Status);
190  }
191 
192  inData.Length = (wcslen(pClearTextPassword) + 1) * sizeof(WCHAR);
193  inData.MaximumLength = inData.Length;
194  inData.Buffer = (unsigned char *)pClearTextPassword;
195 
196  keyData.Length = sizeof(SessionKey);
197  keyData.MaximumLength = keyData.Length;
198  keyData.Buffer = SessionKey;
199 
200  outData.Length = 0;
201  outData.MaximumLength = 0;
202  outData.Buffer = NULL;
203 
204  /* Get the required buffer size */
205  Status = SystemFunction004(&inData,
206  &keyData,
207  &outData);
209  {
210  ERR("SystemFunction004 failed (Status 0x%08lx)\n", Status);
212  }
213 
214  /* Allocate a buffer for the encrypted password */
215  pBuffer = HeapAlloc(GetProcessHeap(), 0, outData.Length);
216  if (pBuffer == NULL)
217  return ERROR_OUTOFMEMORY;
218 
219  outData.MaximumLength = outData.Length;
220  outData.Buffer = pBuffer;
221 
222  /* Encrypt the password */
223  Status = SystemFunction004(&inData,
224  &keyData,
225  &outData);
226  if (!NT_SUCCESS(Status))
227  {
228  ERR("SystemFunction004 failed (Status 0x%08lx)\n", Status);
231  }
232 
233  *pEncryptedPassword = outData.Buffer;
234  *pEncryptedPasswordSize = outData.Length;
235 
236  return ERROR_SUCCESS;
237 }
#define ERROR_SUCCESS
Definition: deptool.c:10
LONG NTSTATUS
Definition: precomp.h:26
#define STATUS_BUFFER_TOO_SMALL
Definition: shellext.h:64
smooth NULL
Definition: ftsmooth.c:416
PVOID pBuffer
NTSTATUS WINAPI SystemFunction028(IN PVOID ContextHandle, OUT LPBYTE SessionKey)
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
NTSTATUS WINAPI SystemFunction004(const struct ustring *in, const struct ustring *key, struct ustring *out)
Definition: sysfunc.c:119
unsigned char BYTE
Definition: mem.h:68
Status
Definition: gdiplustypes.h:24
NTSYSAPI ULONG WINAPI RtlNtStatusToDosError(NTSTATUS)
#define ERR(fmt,...)
Definition: debug.h:109
Definition: config.c:18
BYTE * PBYTE
Definition: pedump.c:66
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define HeapFree(x, y, z)
Definition: compat.h:394
#define ERROR_OUTOFMEMORY
Definition: deptool.c:13

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  {
156  return ERROR_INVALID_HANDLE;
157 
161 
163  return ERROR_INVALID_ADDRESS;
164 
165  default:
166  return (DWORD)Status;
167  }
168 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
#define RPC_X_SS_IN_NULL_CONTEXT
Definition: winerror.h:1083
#define RPC_X_NULL_REF_POINTER
Definition: winerror.h:1087
#define ERROR_INVALID_HANDLE
Definition: compat.h:88
#define RPC_X_BYTE_COUNT_TOO_SMALL
Definition: winerror.h:1089
#define RPC_S_INVALID_BINDING
Definition: winerror.h:1013
#define TRACE(s)
Definition: solgame.cpp:4
unsigned long DWORD
Definition: ntddk_ex.h:95
#define ERROR_INVALID_ADDRESS
Definition: compat.h:96
#define RPC_X_ENUM_VALUE_OUT_OF_RANGE
Definition: winerror.h:1088
Status
Definition: gdiplustypes.h:24
#define STATUS_ACCESS_VIOLATION
Definition: ntstatus.h:228

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(), 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 2717 of file scm.c.

2720 {
2721  PSECURITY_DESCRIPTOR SelfRelativeSD = NULL;
2722  ULONG Length;
2723  NTSTATUS Status;
2724  DWORD dwError;
2725 
2726  TRACE("SetServiceObjectSecurity(%p %lu %p)\n",
2727  hService, dwSecurityInformation, lpSecurityDescriptor);
2728 
2729  Length = 0;
2730  Status = RtlMakeSelfRelativeSD(lpSecurityDescriptor,
2731  SelfRelativeSD,
2732  &Length);
2734  {
2736  return FALSE;
2737  }
2738 
2739  SelfRelativeSD = HeapAlloc(GetProcessHeap(), 0, Length);
2740  if (SelfRelativeSD == NULL)
2741  {
2743  return FALSE;
2744  }
2745 
2746  Status = RtlMakeSelfRelativeSD(lpSecurityDescriptor,
2747  SelfRelativeSD,
2748  &Length);
2749  if (!NT_SUCCESS(Status))
2750  {
2751  HeapFree(GetProcessHeap(), 0, SelfRelativeSD);
2753  return FALSE;
2754  }
2755 
2756  RpcTryExcept
2757  {
2758  dwError = RSetServiceObjectSecurity((SC_RPC_HANDLE)hService,
2759  dwSecurityInformation,
2760  (LPBYTE)SelfRelativeSD,
2761  Length);
2762  }
2764  {
2766  }
2767  RpcEndExcept;
2768 
2769  HeapFree(GetProcessHeap(), 0, SelfRelativeSD);
2770 
2771  if (dwError != ERROR_SUCCESS)
2772  {
2773  TRACE("RServiceObjectSecurity() failed (Error %lu)\n", dwError);
2774  SetLastError(dwError);
2775  return FALSE;
2776  }
2777 
2778  return TRUE;
2779 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
#define RpcEndExcept
Definition: rpc.h:128
#define TRUE
Definition: types.h:120
#define ERROR_SUCCESS
Definition: deptool.c:10
LONG NTSTATUS
Definition: precomp.h:26
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
#define STATUS_BUFFER_TOO_SMALL
Definition: shellext.h:64
unsigned char * LPBYTE
Definition: typedefs.h:52
#define RpcTryExcept
Definition: rpc.h:126
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
smooth NULL
Definition: ftsmooth.c:416
#define RpcExceptionCode()
Definition: rpc.h:132
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
DWORD ScmRpcStatusToWinError(RPC_STATUS Status)
Definition: scm.c:146
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:409
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
DWORD WINAPI RSetServiceObjectSecurity(SC_RPC_HANDLE hService, DWORD dwSecurityInformation, LPBYTE lpSecurityDescriptor, DWORD dwSecurityDescriptorSize)
Definition: rpcserver.c:1472
Status
Definition: gdiplustypes.h:24
NTSYSAPI ULONG WINAPI RtlNtStatusToDosError(NTSTATUS)
unsigned int ULONG
Definition: retypes.h:1
NTSYSAPI NTSTATUS NTAPI RtlMakeSelfRelativeSD(_In_ PSECURITY_DESCRIPTOR AbsoluteSD, _Out_ PSECURITY_DESCRIPTOR SelfRelativeSD, _Inout_ PULONG BufferLength)
#define HeapFree(x, y, z)
Definition: compat.h:394
#define RpcExcept(expr)
Definition: rpc.h:127

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

◆ StartServiceA()

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

Definition at line 2885 of file scm.c.

2888 {
2889  DWORD dwError;
2890 
2891  TRACE("StartServiceA(%p %lu %p)\n",
2892  hService, dwNumServiceArgs, lpServiceArgVectors);
2893 
2894  RpcTryExcept
2895  {
2896  dwError = RStartServiceA((SC_RPC_HANDLE)hService,
2897  dwNumServiceArgs,
2898  (LPSTRING_PTRSA)lpServiceArgVectors);
2899  }
2901  {
2903  }
2904  RpcEndExcept;
2905 
2906  if (dwError != ERROR_SUCCESS)
2907  {
2908  ERR("RStartServiceA() failed (Error %lu)\n", dwError);
2909  SetLastError(dwError);
2910  return FALSE;
2911  }
2912 
2913  return TRUE;
2914 }
#define RpcEndExcept
Definition: rpc.h:128
#define TRUE
Definition: types.h:120
#define ERROR_SUCCESS
Definition: deptool.c:10
DWORD WINAPI RStartServiceA(SC_RPC_HANDLE hService, DWORD argc, LPSTRING_PTRSA argv)
Definition: