Author: ekohl
Date: Fri May 17 21:44:27 2013
New Revision: 59029
URL:
http://svn.reactos.org/svn/reactos?rev=59029&view=rev
Log:
[SYSSETUP]
Revert revisions 59021 and 59020.
Modified:
trunk/reactos/dll/win32/syssetup/install.c
Modified: trunk/reactos/dll/win32/syssetup/install.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/syssetup/install…
==============================================================================
--- trunk/reactos/dll/win32/syssetup/install.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/syssetup/install.c [iso-8859-1] Fri May 17 21:44:27 2013
@@ -865,58 +865,12 @@
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
InstallReactOS(HINSTANCE hInstance)
{
TCHAR szBuffer[MAX_PATH];
+ HANDLE token;
+ TOKEN_PRIVILEGES privs;
HKEY hKey;
InitializeSetupActionLog(FALSE);
@@ -976,12 +930,7 @@
/* ROS HACK, as long as NtUnloadKey is not implemented */
{
- NTSTATUS Status;
-
- SetPrivilege(SE_RESTORE_NAME, SE_PRIVILEGE_ENABLED);
- Status = NtUnloadKey(NULL);
- SetPrivilege(SE_RESTORE_NAME, 0);
-
+ NTSTATUS Status = NtUnloadKey(NULL);
if (Status == STATUS_NOT_IMPLEMENTED)
{
/* Create the Administrator profile */
@@ -1015,7 +964,33 @@
LogItem(SYSSETUP_SEVERITY_INFORMATION, L"Installing ReactOS done");
TerminateSetupActionLog();
- SetPrivilege(SE_SHUTDOWN_NAME, SE_PRIVILEGE_ENABLED);
+ /* Get shutdown privilege */
+ 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);
return 0;