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;
515 if (PolicyHandle !=
NULL)
531 DPRINT(
"ScmWriteSecurityDescriptor(%p %p)\n", hServiceKey, pSecurityDescriptor);
549 (
LPBYTE)pSecurityDescriptor,
565 DWORD dwBufferLength = 0;
569 DPRINT(
"ScmReadSecurityDescriptor(%p %p)\n", hServiceKey, ppSecurityDescriptor);
571 *ppSecurityDescriptor =
NULL;
580 DPRINT(
"RegOpenKeyExW() failed (Error %lu)\n", dwError);
596 DPRINT(
"RegQueryValueExW() failed (Error %lu)\n", dwError);
604 DPRINT(
"dwBufferLength: %lu\n", dwBufferLength);
608 if (pRelativeSD ==
NULL)
613 DPRINT(
"pRelativeSD: %lu\n", pRelativeSD);
625 *ppSecurityDescriptor = pRelativeSD;
631 if (hSecurityKey !=
NULL)
643 DWORD dwMaxSubkeyLen, dwMaxValueLen;
661 dwMaxLen =
max(dwMaxSubkeyLen, dwMaxValueLen);
706 struct ustring inData, keyData, outData;
716 DPRINT1(
"SystemFunction028 failed (Status 0x%08lx)\n",
Status);
720 inData.
Length = dwPasswordSize;
722 inData.
Buffer = pPassword;
724 keyData.
Length =
sizeof(SessionKey);
726 keyData.
Buffer = SessionKey;
738 DPRINT1(
"SystemFunction005 failed (Status 0x%08lx)\n",
Status);
756 DPRINT1(
"SystemFunction005 failed (Status 0x%08lx)\n",
Status);
DWORD ScmDecryptPassword(_In_ PBYTE pPassword, _In_ DWORD dwPasswordSize, _Out_ PWSTR *pClearTextPassword)
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
NTSTATUS WINAPI SystemFunction005(const struct ustring *in, const struct ustring *key, struct ustring *out)
DWORD ScmDeleteRegKey(_In_ HKEY hKey, _In_ PCWSTR pszSubKey)
NTSTATUS WINAPI LsaStorePrivateData(IN LSA_HANDLE PolicyHandle, IN PLSA_UNICODE_STRING KeyName, IN PLSA_UNICODE_STRING PrivateData OPTIONAL)
#define SC_GROUP_IDENTIFIERW
BOOLEAN NTAPI RtlFreeHeap(IN PVOID HeapHandle, IN ULONG Flags, IN PVOID HeapBase)
LONG WINAPI RegDeleteKeyW(_In_ HKEY hKey, _In_ LPCWSTR lpSubKey)
NTSTATUS WINAPI LsaClose(IN LSA_HANDLE ObjectHandle)
#define ERROR_NOT_ENOUGH_MEMORY
DWORD WINAPI GetLastError(VOID)
DWORD ScmReadDependencies(HKEY hServiceKey, LPWSTR *lpDependencies, DWORD *lpdwDependenciesLength)
#define REG_OPENED_EXISTING_KEY
NTSYSAPI ULONG WINAPI RtlLengthSecurityDescriptor(PSECURITY_DESCRIPTOR)
DWORD ScmWriteDependencies(HKEY hServiceKey, LPCWSTR lpDependencies, DWORD dwDependenciesLength)
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)
#define STATUS_BUFFER_TOO_SMALL
NTSTATUS WINAPI LsaOpenPolicy(IN PLSA_UNICODE_STRING SystemName OPTIONAL, IN PLSA_OBJECT_ATTRIBUTES ObjectAttributes, IN ACCESS_MASK DesiredAccess, OUT PLSA_HANDLE PolicyHandle)
NTSYSAPI ULONG WINAPI RtlNtStatusToDosError(NTSTATUS)
LONG WINAPI RegCloseKey(HKEY hKey)
DWORD ScmCreateServiceKey(LPCWSTR lpServiceName, REGSAM samDesired, PHKEY phKey)
#define ERROR_FILE_NOT_FOUND
PVOID NTAPI RtlAllocateHeap(IN PVOID HeapHandle, IN ULONG Flags, IN SIZE_T Size)
#define REG_OPTION_NON_VOLATILE
LONG WINAPI RegSetValueExW(_In_ HKEY hKey, _In_ LPCWSTR lpValueName, _In_ DWORD Reserved, _In_ DWORD dwType, _In_ CONST BYTE *lpData, _In_ DWORD cbData)
static HANDLE hServicesKey
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
#define NT_SUCCESS(StatCode)
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)
#define ERROR_SERVICE_EXISTS
DWORD ScmSetServicePassword(IN PCWSTR pszServiceName, IN PCWSTR pszPassword)
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
BOOL ScmIsDeleteFlagSet(HKEY hServiceKey)
#define memcpy(s1, s2, n)
DWORD ScmReadString(HKEY hServiceKey, LPCWSTR lpValueName, LPWSTR *lpValue)
DWORD ScmMarkServiceForDelete(PSERVICE pService)
DWORD ScmWriteSecurityDescriptor(_In_ HKEY hServiceKey, _In_ PSECURITY_DESCRIPTOR pSecurityDescriptor)
LONG WINAPI RegDeleteValueW(HKEY hKey, LPCWSTR lpValueName)
NTSTATUS WINAPI SystemFunction028(IN PVOID ContextHandle, OUT LPBYTE SessionKey)
_CRTIMP wchar_t *__cdecl wcscat(_Inout_updates_z_(_String_length_(_Dest)+_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
DWORD WINAPI ExpandEnvironmentStringsW(IN LPCWSTR lpSrc, IN LPWSTR lpDst, IN DWORD nSize)
DWORD ScmOpenServiceKey(LPWSTR lpServiceName, REGSAM samDesired, PHKEY phKey)
#define POLICY_CREATE_SECRET
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define RtlZeroMemory(Destination, Length)
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)
#define KEY_CREATE_SUB_KEY
DWORD ScmReadSecurityDescriptor(_In_ HKEY hServiceKey, _Out_ PSECURITY_DESCRIPTOR *ppSecurityDescriptor)
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define HeapFree(x, y, z)
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
#define HKEY_LOCAL_MACHINE