mirror of
https://github.com/reactos/reactos.git
synced 2024-07-10 22:55:05 +00:00
[REGEDIT]
- Improve permission acquirement for loading/unloading hives. Patch by Hermes Belusca See issue #7159 for more details. svn path=/trunk/; revision=56835
This commit is contained in:
parent
67c66d9d96
commit
473a15261d
|
@ -330,12 +330,10 @@ static BOOL EnablePrivilege(LPCTSTR lpszPrivilegeName, LPCTSTR lpszSystemName, B
|
||||||
lpszPrivilegeName,
|
lpszPrivilegeName,
|
||||||
&tp.Privileges[0].Luid))
|
&tp.Privileges[0].Luid))
|
||||||
{
|
{
|
||||||
bRet = AdjustTokenPrivileges(hToken,
|
bRet = AdjustTokenPrivileges(hToken, FALSE, &tp, 0, NULL, NULL);
|
||||||
FALSE,
|
|
||||||
&tp,
|
if (GetLastError() == ERROR_NOT_ALL_ASSIGNED)
|
||||||
sizeof(tp),
|
bRet = FALSE;
|
||||||
NULL,
|
|
||||||
NULL);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CloseHandle(hToken);
|
CloseHandle(hToken);
|
||||||
|
@ -374,16 +372,10 @@ static BOOL LoadHive(HWND hWnd)
|
||||||
{
|
{
|
||||||
LONG regLoadResult;
|
LONG regLoadResult;
|
||||||
|
|
||||||
/* Enable the required privileges */
|
/* Enable the 'restore' privilege, load the hive, disable the privilege */
|
||||||
EnablePrivilege(SE_BACKUP_NAME, NULL, TRUE);
|
|
||||||
EnablePrivilege(SE_RESTORE_NAME, NULL, TRUE);
|
EnablePrivilege(SE_RESTORE_NAME, NULL, TRUE);
|
||||||
|
|
||||||
/* Load the hive */
|
|
||||||
regLoadResult = RegLoadKey(hRootKey, xPath, ofn.lpstrFile);
|
regLoadResult = RegLoadKey(hRootKey, xPath, ofn.lpstrFile);
|
||||||
|
|
||||||
/* Disable the privileges */
|
|
||||||
EnablePrivilege(SE_RESTORE_NAME, NULL, FALSE);
|
EnablePrivilege(SE_RESTORE_NAME, NULL, FALSE);
|
||||||
EnablePrivilege(SE_BACKUP_NAME, NULL, FALSE);
|
|
||||||
|
|
||||||
if(regLoadResult == ERROR_SUCCESS)
|
if(regLoadResult == ERROR_SUCCESS)
|
||||||
{
|
{
|
||||||
|
@ -418,16 +410,10 @@ static BOOL UnloadHive(HWND hWnd)
|
||||||
/* load and set the caption and flags for dialog */
|
/* load and set the caption and flags for dialog */
|
||||||
LoadString(hInst, IDS_UNLOAD_HIVE, Caption, COUNT_OF(Caption));
|
LoadString(hInst, IDS_UNLOAD_HIVE, Caption, COUNT_OF(Caption));
|
||||||
|
|
||||||
/* Enable the required privileges */
|
/* Enable the 'restore' privilege, unload the hive, disable the privilege */
|
||||||
EnablePrivilege(SE_BACKUP_NAME, NULL, TRUE);
|
|
||||||
EnablePrivilege(SE_RESTORE_NAME, NULL, TRUE);
|
EnablePrivilege(SE_RESTORE_NAME, NULL, TRUE);
|
||||||
|
|
||||||
/* Unload the hive */
|
|
||||||
regUnloadResult = RegUnLoadKey(hRootKey, pszKeyPath);
|
regUnloadResult = RegUnLoadKey(hRootKey, pszKeyPath);
|
||||||
|
|
||||||
/* Disable the privileges */
|
|
||||||
EnablePrivilege(SE_RESTORE_NAME, NULL, FALSE);
|
EnablePrivilege(SE_RESTORE_NAME, NULL, FALSE);
|
||||||
EnablePrivilege(SE_BACKUP_NAME, NULL, FALSE);
|
|
||||||
|
|
||||||
if(regUnloadResult == ERROR_SUCCESS)
|
if(regUnloadResult == ERROR_SUCCESS)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue