mirror of
https://github.com/reactos/reactos.git
synced 2025-08-04 16:35:49 +00:00
[SYSSETUP]
- Move set privilege code into a separate function. - Set the restore privilege to make NtUnloadKey work properly. svn path=/trunk/; revision=59020
This commit is contained in:
parent
a875a3dbd5
commit
32504caff2
1 changed files with 53 additions and 29 deletions
|
@ -806,12 +806,58 @@ SetSetupType(DWORD dwSetupType)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static
|
||||||
|
BOOL
|
||||||
|
SetPrivilege(IN LPTSTR lpPrivilegeName,
|
||||||
|
IN DWORD dwAttribute)
|
||||||
|
{
|
||||||
|
TOKEN_PRIVILEGES privs;
|
||||||
|
HANDLE hToken = NULL;
|
||||||
|
BOOL bResult = TRUE;
|
||||||
|
|
||||||
|
if (!OpenProcessToken(GetCurrentProcess(),
|
||||||
|
TOKEN_ADJUST_PRIVILEGES,
|
||||||
|
&hToken))
|
||||||
|
{
|
||||||
|
FatalError("OpenProcessToken() failed!");
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!LookupPrivilegeValue(NULL,
|
||||||
|
lpPrivilegeName,
|
||||||
|
&privs.Privileges[0].Luid))
|
||||||
|
{
|
||||||
|
FatalError("LookupPrivilegeValue() failed!");
|
||||||
|
bResult = FALSE;
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
|
|
||||||
|
privs.PrivilegeCount = 1;
|
||||||
|
privs.Privileges[0].Attributes = dwAttribute;
|
||||||
|
if (AdjustTokenPrivileges(hToken,
|
||||||
|
FALSE,
|
||||||
|
&privs,
|
||||||
|
0,
|
||||||
|
(PTOKEN_PRIVILEGES)NULL,
|
||||||
|
NULL) == 0)
|
||||||
|
{
|
||||||
|
FatalError("AdjustTokenPrivileges() failed!");
|
||||||
|
bResult = FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
done:
|
||||||
|
if (hToken != NULL)
|
||||||
|
CloseHandle(hToken);
|
||||||
|
|
||||||
|
return bResult;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
DWORD WINAPI
|
DWORD WINAPI
|
||||||
InstallReactOS(HINSTANCE hInstance)
|
InstallReactOS(HINSTANCE hInstance)
|
||||||
{
|
{
|
||||||
TCHAR szBuffer[MAX_PATH];
|
TCHAR szBuffer[MAX_PATH];
|
||||||
HANDLE token;
|
|
||||||
TOKEN_PRIVILEGES privs;
|
|
||||||
HKEY hKey;
|
HKEY hKey;
|
||||||
|
|
||||||
InitializeSetupActionLog(FALSE);
|
InitializeSetupActionLog(FALSE);
|
||||||
|
@ -869,6 +915,8 @@ InstallReactOS(HINSTANCE hInstance)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SetPrivilege(SE_RESTORE_NAME, SE_PRIVILEGE_ENABLED);
|
||||||
|
|
||||||
/* ROS HACK, as long as NtUnloadKey is not implemented */
|
/* ROS HACK, as long as NtUnloadKey is not implemented */
|
||||||
{
|
{
|
||||||
NTSTATUS Status = NtUnloadKey(NULL);
|
NTSTATUS Status = NtUnloadKey(NULL);
|
||||||
|
@ -899,39 +947,15 @@ InstallReactOS(HINSTANCE hInstance)
|
||||||
}
|
}
|
||||||
/* END OF ROS HACK */
|
/* END OF ROS HACK */
|
||||||
|
|
||||||
|
SetPrivilege(SE_RESTORE_NAME, 0);
|
||||||
|
|
||||||
SetupCloseInfFile(hSysSetupInf);
|
SetupCloseInfFile(hSysSetupInf);
|
||||||
SetSetupType(0);
|
SetSetupType(0);
|
||||||
|
|
||||||
LogItem(SYSSETUP_SEVERITY_INFORMATION, L"Installing ReactOS done");
|
LogItem(SYSSETUP_SEVERITY_INFORMATION, L"Installing ReactOS done");
|
||||||
TerminateSetupActionLog();
|
TerminateSetupActionLog();
|
||||||
|
|
||||||
/* Get shutdown privilege */
|
SetPrivilege(SE_SHUTDOWN_NAME, SE_PRIVILEGE_ENABLED);
|
||||||
if (!OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES, &token))
|
|
||||||
{
|
|
||||||
FatalError("OpenProcessToken() failed!");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
if (!LookupPrivilegeValue(
|
|
||||||
NULL,
|
|
||||||
SE_SHUTDOWN_NAME,
|
|
||||||
&privs.Privileges[0].Luid))
|
|
||||||
{
|
|
||||||
FatalError("LookupPrivilegeValue() failed!");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
privs.PrivilegeCount = 1;
|
|
||||||
privs.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
|
|
||||||
if (AdjustTokenPrivileges(
|
|
||||||
token,
|
|
||||||
FALSE,
|
|
||||||
&privs,
|
|
||||||
0,
|
|
||||||
(PTOKEN_PRIVILEGES)NULL,
|
|
||||||
NULL) == 0)
|
|
||||||
{
|
|
||||||
FatalError("AdjustTokenPrivileges() failed!");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
ExitWindowsEx(EWX_REBOOT, 0);
|
ExitWindowsEx(EWX_REBOOT, 0);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue