3 * Copyright (C) 2003 ReactOS Team
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 * COPYRIGHT: See COPYING in the top level directory
21 * PROJECT: ReactOS system libraries
22 * PURPOSE: System setup
23 * FILE: lib/syssetup/install.c
24 * PROGRAMER: Eric Kohl
27 /* INCLUDES *****************************************************************/
29 #define WIN32_NO_STATUS
31 #define NTOS_MODE_USER
32 #include <ndk/ntndk.h>
40 #include <samlib/samlib.h>
41 #include <syssetup/syssetup.h>
56 CMP_WaitNoPendingInstallEvents(DWORD dwTimeout
);
58 /* GLOBALS ******************************************************************/
60 PSID DomainSid
= NULL
;
63 HINF hSysSetupInf
= INVALID_HANDLE_VALUE
;
65 /* FUNCTIONS ****************************************************************/
68 DebugPrint(char* fmt
,...)
74 vsprintf(buffer
, fmt
, ap
);
77 LogItem(SYSSETUP_SEVERITY_FATAL_ERROR
, L
"Failed");
79 strcat(buffer
, "\nRebooting now!");
87 HRESULT
CreateShellLink(LPCTSTR linkPath
, LPCTSTR cmd
, LPCTSTR arg
, LPCTSTR dir
, LPCTSTR iconPath
, int icon_nr
, LPCTSTR comment
)
92 WCHAR buffer
[MAX_PATH
];
95 HRESULT hr
= CoCreateInstance(&CLSID_ShellLink
, NULL
, CLSCTX_INPROC_SERVER
, &IID_IShellLink
, (LPVOID
*)&psl
);
99 hr
= psl
->lpVtbl
->SetPath(psl
, cmd
);
103 hr
= psl
->lpVtbl
->SetArguments(psl
, arg
);
108 hr
= psl
->lpVtbl
->SetWorkingDirectory(psl
, dir
);
113 hr
= psl
->lpVtbl
->SetIconLocation(psl
, iconPath
, icon_nr
);
118 hr
= psl
->lpVtbl
->SetDescription(psl
, comment
);
121 hr
= psl
->lpVtbl
->QueryInterface(psl
, &IID_IPersistFile
, (LPVOID
*)&ppf
);
126 hr
= ppf
->lpVtbl
->Save(ppf
, linkPath
, TRUE
);
128 MultiByteToWideChar(CP_ACP
, 0, linkPath
, -1, buffer
, MAX_PATH
);
130 hr
= ppf
->lpVtbl
->Save(ppf
, buffer
, TRUE
);
131 #endif /* _UNICODE */
133 ppf
->lpVtbl
->Release(ppf
);
136 psl
->lpVtbl
->Release(psl
);
144 CreateShortcut(int csidl
, LPCTSTR folder
, UINT nIdName
, LPCTSTR command
, UINT nIdTitle
, BOOL bCheckExistence
)
146 TCHAR path
[MAX_PATH
];
147 TCHAR exeName
[MAX_PATH
];
151 TCHAR szWorkingDir
[MAX_PATH
];
152 LPTSTR lpWorkingDir
= NULL
;
156 if (ExpandEnvironmentStrings(command
,
158 sizeof(path
) / sizeof(path
[0])) == 0)
166 if ((_taccess(path
, 0 )) == -1)
167 /* Expected error, don't return FALSE */
171 dwLen
= GetFullPathName(path
,
172 sizeof(szWorkingDir
) / sizeof(szWorkingDir
[0]),
175 if (dwLen
!= 0 && dwLen
<= sizeof(szWorkingDir
) / sizeof(szWorkingDir
[0]))
177 /* Save the file name */
178 _tcscpy(exeName
, lpFilePart
);
180 if (lpFilePart
!= NULL
)
182 /* We're only interested in the path. Cut the file name off.
183 Also remove the trailing backslash unless the working directory
184 is only going to be a drive, ie. C:\ */
185 *(lpFilePart
--) = _T('\0');
186 if (!(lpFilePart
- szWorkingDir
== 2 && szWorkingDir
[1] == _T(':') &&
187 szWorkingDir
[2] == _T('\\')))
189 *lpFilePart
= _T('\0');
193 lpWorkingDir
= szWorkingDir
;
197 if (!SHGetSpecialFolderPath(0, path
, csidl
, TRUE
))
202 p
= PathAddBackslash(p
);
206 p
= PathAddBackslash(p
);
208 if (!LoadString(hDllInstance
, nIdName
, name
, sizeof(name
)/sizeof(name
[0])))
212 if (!LoadString(hDllInstance
, nIdTitle
, title
, sizeof(title
)/sizeof(title
[0])))
215 // FIXME: we should pass 'command' straight in here, but shell32 doesn't expand it
216 return SUCCEEDED(CreateShellLink(path
, exeName
, _T(""), lpWorkingDir
, NULL
, 0, title
));
221 CreateShortcutFolder(int csidl
, UINT nID
, LPTSTR name
, int nameLen
)
223 TCHAR path
[MAX_PATH
];
226 if (!SHGetSpecialFolderPath(0, path
, csidl
, TRUE
))
229 if (!LoadString(hDllInstance
, nID
, name
, nameLen
))
232 p
= PathAddBackslash(path
);
235 return CreateDirectory(path
, NULL
) || GetLastError()==ERROR_ALREADY_EXISTS
;
243 SID_IDENTIFIER_AUTHORITY SystemAuthority
= {SECURITY_NT_AUTHORITY
};
244 LARGE_INTEGER SystemTime
;
248 NtQuerySystemTime(&SystemTime
);
249 Seed
= &SystemTime
.u
.LowPart
;
251 Status
= RtlAllocateAndInitializeSid(
254 SECURITY_NT_NON_UNIQUE
,
263 return NT_SUCCESS(Status
);
273 ULONG Rid
[8] = {0, 0, 0, 0, 0, 0, 0, 0};
277 RidCount
= *RtlSubAuthorityCountSid (Src
);
279 for (i
= 0; i
< RidCount
; i
++)
280 Rid
[i
] = *RtlSubAuthoritySid (Src
, i
);
284 Rid
[RidCount
] = NewRid
;
288 RtlAllocateAndInitializeSid(
289 RtlIdentifierAuthoritySid(Src
),
307 WCHAR szTempDir
[MAX_PATH
];
308 WCHAR szBuffer
[MAX_PATH
];
312 if (RegOpenKeyExW(HKEY_LOCAL_MACHINE
,
313 L
"SYSTEM\\CurrentControlSet\\Control\\Session Manager\\Environment",
318 DebugPrint("Error: %lu\n", GetLastError());
323 dwLength
= MAX_PATH
* sizeof(WCHAR
);
324 if (RegQueryValueExW(hKey
,
331 DebugPrint("Error: %lu\n", GetLastError());
337 if (!ExpandEnvironmentStringsW(szBuffer
,
341 DebugPrint("Error: %lu\n", GetLastError());
346 /* Create profiles directory */
347 if (!CreateDirectoryW(szTempDir
, NULL
))
349 if (GetLastError() != ERROR_ALREADY_EXISTS
)
351 DebugPrint("Error: %lu\n", GetLastError());
362 InstallSysSetupInfDevices(VOID
)
364 INFCONTEXT InfContext
;
365 WCHAR LineBuffer
[256];
368 if (!SetupFindFirstLineW(hSysSetupInf
,
369 L
"DeviceInfsToInstall",
378 if (!SetupGetStringFieldW(&InfContext
,
381 sizeof(LineBuffer
)/sizeof(LineBuffer
[0]),
387 if (!SetupDiInstallClassW(NULL
, LineBuffer
, DI_QUIETINSTALL
, NULL
))
392 while (SetupFindNextLine(&InfContext
, &InfContext
));
397 InstallSysSetupInfComponents(VOID
)
399 INFCONTEXT InfContext
;
400 WCHAR NameBuffer
[256];
401 WCHAR SectionBuffer
[256];
402 HINF hComponentInf
= INVALID_HANDLE_VALUE
;
404 if (!SetupFindFirstLineW(hSysSetupInf
,
409 DPRINT("No Inf.Always section found\n");
415 if (!SetupGetStringFieldW(&InfContext
,
416 1, // Get the component name
418 sizeof(NameBuffer
)/sizeof(NameBuffer
[0]),
421 DebugPrint("Error while trying to get component name \n");
425 if (!SetupGetStringFieldW(&InfContext
,
426 2, // Get the component install section
428 sizeof(SectionBuffer
)/sizeof(SectionBuffer
[0]),
431 DebugPrint("Error while trying to get component install section \n");
435 DPRINT("Trying to execute install section '%S' from '%S' \n", SectionBuffer
, NameBuffer
);
437 hComponentInf
= SetupOpenInfFileW(NameBuffer
,
442 if (hComponentInf
== INVALID_HANDLE_VALUE
)
444 DebugPrint("SetupOpenInfFileW() failed to open '%S' (Error: %lu)\n", NameBuffer
,GetLastError());
448 if (!SetupInstallFromInfSectionW(NULL
,
455 SetupDefaultQueueCallbackW
,
460 DebugPrint("Error while trying to install : %S (Error: %lu)\n", NameBuffer
, GetLastError());
461 SetupCloseInfFile(hComponentInf
);
465 SetupCloseInfFile(hComponentInf
);
467 while (SetupFindNextLine(&InfContext
, &InfContext
));
474 EnableUserModePnpManager(VOID
)
476 SC_HANDLE hSCManager
= NULL
;
477 SC_HANDLE hService
= NULL
;
480 hSCManager
= OpenSCManager(NULL
, NULL
, 0);
481 if (hSCManager
== NULL
)
484 hService
= OpenServiceW(hSCManager
, L
"PlugPlay", SERVICE_CHANGE_CONFIG
| SERVICE_START
);
485 if (hService
== NULL
)
488 ret
= ChangeServiceConfigW(
490 SERVICE_NO_CHANGE
, SERVICE_AUTO_START
, SERVICE_NO_CHANGE
,
491 NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
);
495 ret
= StartServiceW(hService
, 0, NULL
);
502 if (hSCManager
!= NULL
)
503 CloseServiceHandle(hSCManager
);
504 if (hService
!= NULL
)
505 CloseServiceHandle(hService
);
511 StatusMessageWindowProc(
517 UNREFERENCED_PARAMETER(wParam
);
525 if (!LoadStringW(hDllInstance
, IDS_STATUS_INSTALL_DEV
, szMsg
, sizeof(szMsg
)/sizeof(szMsg
[0])))
527 SetDlgItemTextW(hwndDlg
, IDC_STATUSLABEL
, szMsg
);
536 ShowStatusMessageThread(
537 IN LPVOID lpParameter
)
539 HWND
*phWnd
= (HWND
*)lpParameter
;
543 hWnd
= CreateDialogParam(
545 MAKEINTRESOURCE(IDD_STATUSWINDOW_DLG
),
547 StatusMessageWindowProc
,
553 ShowWindow(hWnd
, SW_SHOW
);
555 /* Message loop for the Status window */
556 while (GetMessage(&Msg
, NULL
, 0, 0))
558 TranslateMessage(&Msg
);
559 DispatchMessage(&Msg
);
577 return ERROR_INVALID_PARAMETER
;
580 rc
= RegQueryValueExW(hKey
, pszKey
, NULL
, &dwType
, NULL
, &cbData
);
581 if (rc
!= ERROR_SUCCESS
)
583 if (dwType
!= REG_SZ
)
584 return ERROR_FILE_NOT_FOUND
;
585 Value
= HeapAlloc(GetProcessHeap(), 0, cbData
+ sizeof(WCHAR
));
587 return ERROR_NOT_ENOUGH_MEMORY
;
588 rc
= RegQueryValueExW(hKey
, pszKey
, NULL
, NULL
, (LPBYTE
)Value
, &cbData
);
589 if (rc
!= ERROR_SUCCESS
)
591 HeapFree(GetProcessHeap(), 0, Value
);
594 /* NULL-terminate the string */
595 Value
[cbData
/ sizeof(WCHAR
)] = '\0';
598 return ERROR_SUCCESS
;
604 HKEY ControlKey
= NULL
;
605 LPWSTR SystemStartOptions
= NULL
;
606 LPWSTR CurrentOption
, NextOption
; /* Pointers into SystemStartOptions */
607 BOOL ConsoleBoot
= FALSE
;
612 L
"SYSTEM\\CurrentControlSet\\Control",
617 rc
= ReadRegSzKey(ControlKey
, L
"SystemStartOptions", &SystemStartOptions
);
618 if (rc
!= ERROR_SUCCESS
)
621 /* Check for CMDCONS in SystemStartOptions */
622 CurrentOption
= SystemStartOptions
;
623 while (CurrentOption
)
625 NextOption
= wcschr(CurrentOption
, L
' ');
628 if (wcsicmp(CurrentOption
, L
"CONSOLE") == 0)
630 DPRINT("Found %S. Switching to console boot\n", CurrentOption
);
634 CurrentOption
= NextOption
? NextOption
+ 1 : NULL
;
638 if (ControlKey
!= NULL
)
639 RegCloseKey(ControlKey
);
640 HeapFree(GetProcessHeap(), 0, SystemStartOptions
);
649 hSysSetupInf
= SetupOpenInfFileW(
654 if (hSysSetupInf
== INVALID_HANDLE_VALUE
)
656 DebugPrint("SetupOpenInfFileW() failed to open 'syssetup.inf' (Error: %lu)\n", GetLastError());
660 if (!InstallSysSetupInfDevices())
662 DebugPrint("InstallSysSetupInfDevices() failed!\n");
663 SetupCloseInfFile(hSysSetupInf
);
667 if(!InstallSysSetupInfComponents())
669 DebugPrint("InstallSysSetupInfComponents() failed!\n");
670 SetupCloseInfFile(hSysSetupInf
);
674 if (!IsConsoleBoot())
679 ShowStatusMessageThread
,
685 if (!EnableUserModePnpManager())
687 DebugPrint("EnableUserModePnpManager() failed!\n");
688 SetupCloseInfFile(hSysSetupInf
);
693 if (CMP_WaitNoPendingInstallEvents(INFINITE
) != WAIT_OBJECT_0
)
695 DebugPrint("CMP_WaitNoPendingInstallEvents() failed!\n");
696 SetupCloseInfFile(hSysSetupInf
);
706 InstallLiveCD(IN HINSTANCE hInstance
)
708 STARTUPINFOW StartupInfo
;
709 PROCESS_INFORMATION ProcessInformation
;
712 if (!CommonInstall())
714 SetupCloseInfFile(hSysSetupInf
);
717 StartupInfo
.cb
= sizeof(STARTUPINFOW
);
718 StartupInfo
.lpReserved
= NULL
;
719 StartupInfo
.lpDesktop
= NULL
;
720 StartupInfo
.lpTitle
= NULL
;
721 StartupInfo
.dwFlags
= 0;
722 StartupInfo
.cbReserved2
= 0;
723 StartupInfo
.lpReserved2
= 0;
724 res
= CreateProcessW(
734 &ProcessInformation
);
743 L
"You can shutdown your computer, or press ENTER to reboot",
751 CreateShortcuts(VOID
)
757 /* Create desktop shortcuts */
758 CreateShortcut(CSIDL_DESKTOP
, NULL
, IDS_SHORT_CMD
, _T("%SystemRoot%\\system32\\cmd.exe"), IDS_CMT_CMD
, TRUE
);
760 /* Create program startmenu shortcuts */
761 CreateShortcut(CSIDL_PROGRAMS
, NULL
, IDS_SHORT_EXPLORER
, _T("%SystemRoot%\\explorer.exe"), IDS_CMT_EXPLORER
, TRUE
);
762 CreateShortcut(CSIDL_PROGRAMS
, NULL
, IDS_SHORT_DOWNLOADER
, _T("%SystemRoot%\\system32\\rapps.exe"), IDS_CMT_DOWNLOADER
, TRUE
);
764 /* Create administrative tools startmenu shortcuts */
765 CreateShortcut(CSIDL_COMMON_ADMINTOOLS
, NULL
, IDS_SHORT_SERVICE
, _T("%SystemRoot%\\system32\\servman.exe"), IDS_CMT_SERVMAN
, TRUE
);
766 CreateShortcut(CSIDL_COMMON_ADMINTOOLS
, NULL
, IDS_SHORT_DEVICE
, _T("%SystemRoot%\\system32\\devmgmt.exe"), IDS_CMT_DEVMGMT
, TRUE
);
767 CreateShortcut(CSIDL_COMMON_ADMINTOOLS
, NULL
, IDS_SHORT_EVENTVIEW
, _T("%SystemRoot%\\system32\\eventvwr.exe"), IDS_CMT_EVENTVIEW
, TRUE
);
768 CreateShortcut(CSIDL_COMMON_ADMINTOOLS
, NULL
, IDS_SHORT_MSCONFIG
, _T("%SystemRoot%\\system32\\msconfig.exe"), IDS_CMT_MSCONFIG
, TRUE
);
770 /* Create and fill Accessories subfolder */
771 if (CreateShortcutFolder(CSIDL_PROGRAMS
, IDS_ACCESSORIES
, szFolder
, sizeof(szFolder
)/sizeof(szFolder
[0])))
773 CreateShortcut(CSIDL_PROGRAMS
, szFolder
, IDS_SHORT_CALC
, _T("%SystemRoot%\\system32\\calc.exe"), IDS_CMT_CALC
, TRUE
);
774 CreateShortcut(CSIDL_PROGRAMS
, szFolder
, IDS_SHORT_CMD
, _T("%SystemRoot%\\system32\\cmd.exe"), IDS_CMT_CMD
, TRUE
);
775 CreateShortcut(CSIDL_PROGRAMS
, szFolder
, IDS_SHORT_NOTEPAD
, _T("%SystemRoot%\\system32\\notepad.exe"), IDS_CMT_NOTEPAD
, TRUE
);
776 CreateShortcut(CSIDL_PROGRAMS
, szFolder
, IDS_SHORT_RDESKTOP
, _T("%SystemRoot%\\system32\\mstsc.exe"), IDS_CMT_RDESKTOP
, TRUE
);
777 CreateShortcut(CSIDL_PROGRAMS
, szFolder
, IDS_SHORT_SNAP
, _T("%SystemRoot%\\system32\\screenshot.exe"), IDS_CMT_SCREENSHOT
, TRUE
);
778 CreateShortcut(CSIDL_PROGRAMS
, szFolder
, IDS_SHORT_WORDPAD
, _T("%SystemRoot%\\system32\\wordpad.exe"), IDS_CMT_WORDPAD
, TRUE
);
779 CreateShortcut(CSIDL_PROGRAMS
, szFolder
, IDS_SHORT_PAINT
, _T("%SystemRoot%\\system32\\paint.exe"), IDS_CMT_PAINT
, TRUE
);
782 /* Create System Tools subfolder and fill if the exe is available */
783 if (CreateShortcutFolder(CSIDL_PROGRAMS
, IDS_SYS_TOOLS
, szFolder
, sizeof(szFolder
)/sizeof(szFolder
[0])))
785 CreateShortcut(CSIDL_PROGRAMS
, szFolder
, IDS_SHORT_CHARMAP
, _T("%SystemRoot%\\system32\\charmap.exe"), IDS_CMT_CHARMAP
, TRUE
);
786 CreateShortcut(CSIDL_PROGRAMS
, szFolder
, IDS_SHORT_KBSWITCH
, _T("%SystemRoot%\\system32\\kbswitch.exe"), IDS_CMT_KBSWITCH
, TRUE
);
787 CreateShortcut(CSIDL_PROGRAMS
, szFolder
, IDS_SHORT_REGEDIT
, _T("%SystemRoot%\\regedit.exe"), IDS_CMT_REGEDIT
, TRUE
);
788 CreateShortcut(CSIDL_PROGRAMS
, szFolder
, IDS_SHORT_DXDIAG
, _T("%SystemRoot%\\system32\\dxdiag.exe"), IDS_CMT_DXDIAG
, TRUE
);
791 /* Create Accessibility subfolder and fill if the exe is available */
792 if (CreateShortcutFolder(CSIDL_PROGRAMS
, IDS_SYS_ACCESSIBILITY
, szFolder
, sizeof(szFolder
)/sizeof(szFolder
[0])))
794 CreateShortcut(CSIDL_PROGRAMS
, szFolder
, IDS_SHORT_MAGNIFY
, _T("%SystemRoot%\\system32\\magnify.exe"), IDS_CMT_MAGNIFY
, TRUE
);
797 /* Create Entertainment subfolder and fill if the exe is available */
798 if (CreateShortcutFolder(CSIDL_PROGRAMS
, IDS_SYS_ENTERTAINMENT
, szFolder
, sizeof(szFolder
)/sizeof(szFolder
[0])))
800 CreateShortcut(CSIDL_PROGRAMS
, szFolder
, IDS_SHORT_MPLAY32
, _T("%SystemRoot%\\system32\\mplay32.exe"), IDS_CMT_MPLAY32
, TRUE
);
801 CreateShortcut(CSIDL_PROGRAMS
, szFolder
, IDS_SHORT_SNDVOL32
, _T("%SystemRoot%\\system32\\sndvol32.exe"), IDS_CMT_SNDVOL32
, TRUE
);
802 CreateShortcut(CSIDL_PROGRAMS
, szFolder
, IDS_SHORT_SNDREC32
, _T("%SystemRoot%\\system32\\sndrec32.exe"), IDS_CMT_SNDREC32
, TRUE
);
805 /* Create Games subfolder and fill if the exe is available */
806 if (CreateShortcutFolder(CSIDL_PROGRAMS
, IDS_GAMES
, szFolder
, sizeof(szFolder
)/sizeof(szFolder
[0])))
808 CreateShortcut(CSIDL_PROGRAMS
, szFolder
, IDS_SHORT_SOLITAIRE
, _T("%SystemRoot%\\system32\\sol.exe"), IDS_CMT_SOLITAIRE
, TRUE
);
809 CreateShortcut(CSIDL_PROGRAMS
, szFolder
, IDS_SHORT_WINEMINE
, _T("%SystemRoot%\\system32\\winemine.exe"), IDS_CMT_WINEMINE
, TRUE
);
810 CreateShortcut(CSIDL_PROGRAMS
, szFolder
, IDS_SHORT_SPIDER
, _T("%SystemRoot%\\system32\\spider.exe"), IDS_CMT_SPIDER
, TRUE
);
819 SetSetupType(DWORD dwSetupType
)
824 dwError
= RegOpenKeyExW(
830 if (dwError
!= ERROR_SUCCESS
)
833 dwError
= RegSetValueExW(
838 (LPBYTE
)&dwSetupType
,
841 if (dwError
!= ERROR_SUCCESS
)
848 InstallReactOS(HINSTANCE hInstance
)
850 TCHAR szBuffer
[MAX_PATH
];
853 TOKEN_PRIVILEGES privs
;
855 InitializeSetupActionLog(FALSE
);
856 LogItem(SYSSETUP_SEVERITY_INFORMATION
, L
"Installing ReactOS");
858 if (!InitializeProfiles())
860 DebugPrint("InitializeProfiles() failed");
864 if (!CreateShortcuts())
866 DebugPrint("InitializeProfiles() failed");
870 /* Initialize the Security Account Manager (SAM) */
871 if (!SamInitializeSAM())
873 DebugPrint("SamInitializeSAM() failed!");
877 /* Create the semi-random Domain-SID */
878 if (!CreateRandomSid(&DomainSid
))
880 DebugPrint("Domain-SID creation failed!");
884 /* Set the Domain SID (aka Computer SID) */
885 if (!SamSetDomainSid(DomainSid
))
887 DebugPrint("SamSetDomainSid() failed!");
888 RtlFreeSid(DomainSid
);
892 /* Append the Admin-RID */
893 AppendRidToSid(&AdminSid
, DomainSid
, DOMAIN_USER_RID_ADMIN
);
895 CreateTempDir(L
"TEMP");
896 CreateTempDir(L
"TMP");
898 if (GetWindowsDirectory(szBuffer
, sizeof(szBuffer
) / sizeof(TCHAR
)))
900 PathAddBackslash(szBuffer
);
901 _tcscat(szBuffer
, _T("system"));
902 CreateDirectory(szBuffer
, NULL
);
905 if (!CommonInstall())
910 /* Create the Administrator account */
911 if (!SamCreateUser(L
"Administrator", L
"", AdminSid
))
913 /* Check what the error was.
914 * If the Admin Account already exists, then it means Setup
915 * wasn't allowed to finish properly. Instead of rebooting
916 * and not completing it, let it restart instead
918 LastError
= GetLastError();
919 if (LastError
!= ERROR_USER_EXISTS
)
921 DebugPrint("SamCreateUser() failed!");
922 RtlFreeSid(AdminSid
);
923 RtlFreeSid(DomainSid
);
928 RtlFreeSid(AdminSid
);
929 RtlFreeSid(DomainSid
);
931 /* ROS HACK, as long as NtUnloadKey is not implemented */
933 NTSTATUS Status
= NtUnloadKey(NULL
);
934 if (Status
== STATUS_NOT_IMPLEMENTED
)
936 /* Create the Administrator profile */
937 PROFILEINFOW ProfileInfo
;
940 #define LOGON32_LOGON_NETWORK 3
941 ret
= LogonUserW(L
"Administrator", L
"", L
"", LOGON32_LOGON_NETWORK
, LOGON32_PROVIDER_DEFAULT
, &hToken
);
944 DebugPrint("LogonUserW() failed!");
947 ZeroMemory(&ProfileInfo
, sizeof(PROFILEINFOW
));
948 ProfileInfo
.dwSize
= sizeof(PROFILEINFOW
);
949 ProfileInfo
.lpUserName
= L
"Administrator";
950 ProfileInfo
.dwFlags
= PI_NOUI
;
951 LoadUserProfileW(hToken
, &ProfileInfo
);
956 DPRINT1("ROS HACK not needed anymore. Please remove it\n");
959 /* END OF ROS HACK */
961 SetupCloseInfFile(hSysSetupInf
);
964 LogItem(SYSSETUP_SEVERITY_INFORMATION
, L
"Installing ReactOS done");
965 TerminateSetupActionLog();
967 /* Get shutdown privilege */
968 if (! OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES
, &token
))
970 DebugPrint("OpenProcessToken() failed!");
973 if (!LookupPrivilegeValue(
976 &privs
.Privileges
[0].Luid
))
978 DebugPrint("LookupPrivilegeValue() failed!");
981 privs
.PrivilegeCount
= 1;
982 privs
.Privileges
[0].Attributes
= SE_PRIVILEGE_ENABLED
;
983 if (AdjustTokenPrivileges(
988 (PTOKEN_PRIVILEGES
)NULL
,
991 DebugPrint("AdjustTokenPrivileges() failed!");
995 ExitWindowsEx(EWX_REBOOT
, 0);
1004 SetupChangeFontSize(
1006 IN LPCWSTR lpszFontSize
)
1008 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
1016 SetupChangeLocaleEx(HWND hWnd
,
1018 LPCWSTR lpSrcRootPath
,
1023 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
1031 SetupChangeLocale(HWND hWnd
, LCID Lcid
)
1033 return SetupChangeLocaleEx(hWnd
, Lcid
, NULL
, 0, 0, 0);