52 L"System\\CurrentControlSet\\Services",
83 L"System\\CurrentControlSet\\Services",
119 DWORD dwDependenciesLength)
122 SIZE_T cchGroupLength = 0;
123 SIZE_T cchServiceLength = 0;
130 if (*lpDependencies == 0)
141 (dwDependenciesLength + 2) *
sizeof(
WCHAR));
142 if (lpGroupDeps ==
NULL)
145 lpSrc = lpDependencies;
149 cchLength =
wcslen(lpSrc) + 1;
154 cchGroupLength += cchLength;
156 lpDst = lpDst + cchLength;
159 lpSrc = lpSrc + cchLength;
165 lpSrc = lpDependencies;
166 lpServiceDeps = lpDst;
169 cchLength =
wcslen(lpSrc) + 1;
172 cchServiceLength += cchLength;
174 lpDst = lpDst + cchLength;
177 lpSrc = lpSrc + cchLength;
182 if (cchGroupLength > 1)
199 if (cchServiceLength > 1)
229 DPRINT(
"ScmMarkServiceForDelete() called\n");
351 DWORD *lpdwDependenciesLength)
355 SIZE_T cchGroupsLength = 0;
356 SIZE_T cchServicesLength = 0;
362 *lpDependencies =
NULL;
363 *lpdwDependenciesLength = 0;
375 if (lpGroups ==
NULL && lpServices ==
NULL)
387 cchLength =
wcslen(lpSrc) + 1;
388 cchGroupsLength += cchLength + 1;
390 lpSrc = lpSrc + cchLength;
402 cchLength =
wcslen(lpSrc) + 1;
403 cchServicesLength += cchLength;
405 lpSrc = lpSrc + cchLength;
409 cchTotalLength = cchGroupsLength + cchServicesLength + 1;
410 DPRINT(
"cchTotalLength: %lu\n", cchTotalLength);
414 if (*lpDependencies ==
NULL)
426 *lpdwDependenciesLength = (
DWORD)cchTotalLength;
429 lpDest = *lpDependencies;
434 cchServicesLength *
sizeof(
WCHAR));
436 lpDest = lpDest + cchServicesLength;
445 cchLength =
wcslen(lpSrc) + 1;
452 lpDest = lpDest + cchLength;
453 lpSrc = lpSrc + cchLength;
483 ServiceNameLength =
wcslen(pszServiceName);
522 if (PolicyHandle !=
NULL)
538 DPRINT(
"ScmWriteSecurityDescriptor(%p %p)\n", hServiceKey, pSecurityDescriptor);
556 (
LPBYTE)pSecurityDescriptor,
572 DWORD dwBufferLength = 0;
576 DPRINT(
"ScmReadSecurityDescriptor(%p %p)\n", hServiceKey, ppSecurityDescriptor);
578 *ppSecurityDescriptor =
NULL;
587 DPRINT(
"RegOpenKeyExW() failed (Error %lu)\n", dwError);
603 DPRINT(
"RegQueryValueExW() failed (Error %lu)\n", dwError);
611 DPRINT(
"dwBufferLength: %lu\n", dwBufferLength);
615 if (pRelativeSD ==
NULL)
620 DPRINT(
"pRelativeSD: %lu\n", pRelativeSD);
632 *ppSecurityDescriptor = pRelativeSD;
638 if (hSecurityKey !=
NULL)
650 DWORD dwMaxSubkeyLen, dwMaxValueLen;
668 dwMaxLen =
max(dwMaxSubkeyLen, dwMaxValueLen);
714 struct ustring inData, keyData, outData;
724 DPRINT1(
"SystemFunction028 failed (Status 0x%08lx)\n",
Status);
728 inData.
Length = dwPasswordSize;
730 inData.
Buffer = pPassword;
732 keyData.
Length =
sizeof(SessionKey);
734 keyData.
Buffer = SessionKey;
746 DPRINT1(
"SystemFunction005 failed (Status 0x%08lx)\n",
Status);
764 DPRINT1(
"SystemFunction005 failed (Status 0x%08lx)\n",
Status);
static WCHAR ServiceName[]
static HANDLE hServicesKey
DWORD ScmReadString(HKEY hServiceKey, LPCWSTR lpValueName, LPWSTR *lpValue)
NTSTATUS WINAPI SystemFunction028(IN PVOID ContextHandle, OUT LPBYTE SessionKey)
DWORD ScmDecryptPassword(_In_ PVOID ContextHandle, _In_ PBYTE pPassword, _In_ DWORD dwPasswordSize, _Out_ PWSTR *pClearTextPassword)
DWORD ScmOpenServiceKey(LPWSTR lpServiceName, REGSAM samDesired, PHKEY phKey)
BOOL ScmIsDeleteFlagSet(HKEY hServiceKey)
DWORD ScmWriteSecurityDescriptor(_In_ HKEY hServiceKey, _In_ PSECURITY_DESCRIPTOR pSecurityDescriptor)
DWORD ScmSetServicePassword(IN PCWSTR pszServiceName, IN PCWSTR pszPassword)
DWORD ScmWriteDependencies(HKEY hServiceKey, LPCWSTR lpDependencies, DWORD dwDependenciesLength)
DWORD ScmReadSecurityDescriptor(_In_ HKEY hServiceKey, _Out_ PSECURITY_DESCRIPTOR *ppSecurityDescriptor)
NTSTATUS WINAPI SystemFunction005(const struct ustring *in, const struct ustring *key, struct ustring *out)
DWORD ScmReadDependencies(HKEY hServiceKey, LPWSTR *lpDependencies, DWORD *lpdwDependenciesLength)
DWORD ScmMarkServiceForDelete(PSERVICE pService)
DWORD ScmDeleteRegKey(_In_ HKEY hKey, _In_ PCWSTR pszSubKey)
DWORD ScmCreateServiceKey(LPCWSTR lpServiceName, REGSAM samDesired, PHKEY phKey)
PVOID NTAPI RtlAllocateHeap(IN PVOID HeapHandle, IN ULONG Flags, IN SIZE_T Size)
BOOLEAN NTAPI RtlFreeHeap(IN PVOID HeapHandle, IN ULONG Flags, IN PVOID HeapBase)
#define RegCloseKey(hKey)
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
#define ERROR_NOT_ENOUGH_MEMORY
#define NT_SUCCESS(StatCode)
LONG WINAPI RegCreateKeyExW(_In_ HKEY hKey, _In_ LPCWSTR lpSubKey, _In_ DWORD Reserved, _In_opt_ LPWSTR lpClass, _In_ DWORD dwOptions, _In_ REGSAM samDesired, _In_opt_ LPSECURITY_ATTRIBUTES lpSecurityAttributes, _Out_ PHKEY phkResult, _Out_opt_ LPDWORD lpdwDisposition)
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
LONG WINAPI RegEnumKeyExW(_In_ HKEY hKey, _In_ DWORD dwIndex, _Out_ LPWSTR lpName, _Inout_ LPDWORD lpcbName, _Reserved_ LPDWORD lpReserved, _Out_opt_ LPWSTR lpClass, _Inout_opt_ LPDWORD lpcbClass, _Out_opt_ PFILETIME lpftLastWriteTime)
LONG WINAPI RegSetValueExW(_In_ HKEY hKey, _In_ LPCWSTR lpValueName, _In_ DWORD Reserved, _In_ DWORD dwType, _In_ CONST BYTE *lpData, _In_ DWORD cbData)
LONG WINAPI RegDeleteKeyW(_In_ HKEY hKey, _In_ LPCWSTR lpSubKey)
LONG WINAPI RegDeleteValueW(HKEY hKey, LPCWSTR lpValueName)
LONG WINAPI RegQueryInfoKeyW(HKEY hKey, LPWSTR lpClass, LPDWORD lpcClass, LPDWORD lpReserved, LPDWORD lpcSubKeys, LPDWORD lpcMaxSubKeyLen, LPDWORD lpcMaxClassLen, LPDWORD lpcValues, LPDWORD lpcMaxValueNameLen, LPDWORD lpcMaxValueLen, LPDWORD lpcbSecurityDescriptor, PFILETIME lpftLastWriteTime)
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
NTSTATUS WINAPI LsaOpenPolicy(IN PLSA_UNICODE_STRING SystemName OPTIONAL, IN PLSA_OBJECT_ATTRIBUTES ObjectAttributes, IN ACCESS_MASK DesiredAccess, OUT PLSA_HANDLE PolicyHandle)
NTSTATUS WINAPI LsaStorePrivateData(IN LSA_HANDLE PolicyHandle, IN PLSA_UNICODE_STRING KeyName, IN PLSA_UNICODE_STRING PrivateData OPTIONAL)
NTSTATUS WINAPI LsaClose(IN LSA_HANDLE ObjectHandle)
#define ERROR_INVALID_PARAMETER
#define HeapFree(x, y, z)
DWORD WINAPI ExpandEnvironmentStringsW(IN LPCWSTR lpSrc, IN LPWSTR lpDst, IN DWORD nSize)
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
NTSYSAPI ULONG WINAPI RtlLengthSecurityDescriptor(PSECURITY_DESCRIPTOR)
NTSYSAPI ULONG WINAPI RtlNtStatusToDosError(NTSTATUS)
#define memcpy(s1, s2, n)
#define ERROR_FILE_NOT_FOUND
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define KEY_CREATE_SUB_KEY
#define REG_OPTION_NON_VOLATILE
#define REG_OPENED_EXISTING_KEY
#define UNICODE_STRING_MAX_CHARS
#define POLICY_CREATE_SECRET
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
_CRTIMP wchar_t *__cdecl wcscat(_Inout_updates_z_(_String_length_(_Dest)+_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
#define STATUS_BUFFER_TOO_SMALL
#define RtlZeroMemory(Destination, Length)
DWORD WINAPI GetLastError(void)
#define ERROR_SERVICE_EXISTS
#define HKEY_LOCAL_MACHINE
#define SC_GROUP_IDENTIFIERW