mirror of
https://github.com/reactos/reactos.git
synced 2024-11-18 13:01:40 +00:00
[SERVICES]
Delete service registry keys recursively. svn path=/trunk/; revision=73400
This commit is contained in:
parent
bb759c3378
commit
a96ca3a4c1
3 changed files with 65 additions and 3 deletions
|
@ -615,4 +615,62 @@ done:
|
||||||
return dwError;
|
return dwError;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
DWORD
|
||||||
|
ScmDeleteServiceKey(
|
||||||
|
_In_ HKEY hServicesKey,
|
||||||
|
_In_ PCWSTR pszServiceName)
|
||||||
|
{
|
||||||
|
DWORD dwMaxSubkeyLen, dwMaxValueLen;
|
||||||
|
DWORD dwMaxLen, dwSize;
|
||||||
|
PWSTR pszName = NULL;
|
||||||
|
HKEY hServiceKey;
|
||||||
|
DWORD dwError;
|
||||||
|
|
||||||
|
dwError = RegOpenKeyExW(hServicesKey, pszServiceName, 0, KEY_READ, &hServiceKey);
|
||||||
|
if (dwError != ERROR_SUCCESS)
|
||||||
|
return dwError;
|
||||||
|
|
||||||
|
/* Get maximum length of key and value names */
|
||||||
|
dwError = RegQueryInfoKeyW(hServiceKey, NULL, NULL, NULL, NULL,
|
||||||
|
&dwMaxSubkeyLen, NULL, NULL, &dwMaxValueLen, NULL, NULL, NULL);
|
||||||
|
if (dwError != ERROR_SUCCESS)
|
||||||
|
goto done;
|
||||||
|
|
||||||
|
dwMaxSubkeyLen++;
|
||||||
|
dwMaxValueLen++;
|
||||||
|
dwMaxLen = max(dwMaxSubkeyLen, dwMaxValueLen);
|
||||||
|
|
||||||
|
/* Allocate the name buffer */
|
||||||
|
pszName = HeapAlloc(GetProcessHeap(), 0, dwMaxLen * sizeof(WCHAR));
|
||||||
|
if (pszName == NULL)
|
||||||
|
{
|
||||||
|
dwError = ERROR_NOT_ENOUGH_MEMORY;
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Recursively delete all the subkeys */
|
||||||
|
while (TRUE)
|
||||||
|
{
|
||||||
|
dwSize = dwMaxLen;
|
||||||
|
if (RegEnumKeyExW(hServiceKey, 0, pszName, &dwSize,
|
||||||
|
NULL, NULL, NULL, NULL))
|
||||||
|
break;
|
||||||
|
|
||||||
|
dwError = ScmDeleteServiceKey(hServiceKey, pszName);
|
||||||
|
if (dwError != ERROR_SUCCESS)
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
|
|
||||||
|
dwError = RegDeleteKeyW(hServicesKey, pszServiceName);
|
||||||
|
|
||||||
|
done:
|
||||||
|
if (pszName != NULL)
|
||||||
|
HeapFree(GetProcessHeap(), 0, pszName);
|
||||||
|
|
||||||
|
RegCloseKey(hServiceKey);
|
||||||
|
|
||||||
|
return dwError;
|
||||||
|
}
|
||||||
|
|
||||||
/* EOF */
|
/* EOF */
|
||||||
|
|
|
@ -1026,7 +1026,7 @@ DWORD RCloseServiceHandle(
|
||||||
it is now safe to delete the service */
|
it is now safe to delete the service */
|
||||||
|
|
||||||
/* Delete the Service Key */
|
/* Delete the Service Key */
|
||||||
dwError = RegDeleteKeyW(hServicesKey,
|
dwError = ScmDeleteServiceKey(hServicesKey,
|
||||||
lpService->lpServiceName);
|
lpService->lpServiceName);
|
||||||
|
|
||||||
RegCloseKey(hServicesKey);
|
RegCloseKey(hServicesKey);
|
||||||
|
@ -1443,7 +1443,7 @@ DWORD RSetServiceObjectSecurity(
|
||||||
{
|
{
|
||||||
PSERVICE_HANDLE hSvc;
|
PSERVICE_HANDLE hSvc;
|
||||||
PSERVICE lpService;
|
PSERVICE lpService;
|
||||||
ULONG DesiredAccess = 0;
|
ACCESS_MASK DesiredAccess = 0;
|
||||||
HANDLE hToken = NULL;
|
HANDLE hToken = NULL;
|
||||||
HKEY hServiceKey = NULL;
|
HKEY hServiceKey = NULL;
|
||||||
BOOL bDatabaseLocked = FALSE;
|
BOOL bDatabaseLocked = FALSE;
|
||||||
|
|
|
@ -142,6 +142,10 @@ ScmReadSecurityDescriptor(
|
||||||
_In_ HKEY hServiceKey,
|
_In_ HKEY hServiceKey,
|
||||||
_Out_ PSECURITY_DESCRIPTOR *ppSecurityDescriptor);
|
_Out_ PSECURITY_DESCRIPTOR *ppSecurityDescriptor);
|
||||||
|
|
||||||
|
DWORD
|
||||||
|
ScmDeleteServiceKey(
|
||||||
|
_In_ HKEY hServicesKey,
|
||||||
|
_In_ PCWSTR pszServiceName);
|
||||||
|
|
||||||
/* controlset.c */
|
/* controlset.c */
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue