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: dll/win32/syssetup/install.c
24 * PROGRAMER: Eric Kohl
27 /* INCLUDES *****************************************************************/
35 CMP_WaitNoPendingInstallEvents(DWORD dwTimeout
);
37 /* GLOBALS ******************************************************************/
39 PSID DomainSid
= NULL
;
42 HINF hSysSetupInf
= INVALID_HANDLE_VALUE
;
44 /* FUNCTIONS ****************************************************************/
47 DebugPrint(char* fmt
,...)
53 vsprintf(buffer
, fmt
, ap
);
56 LogItem(SYSSETUP_SEVERITY_FATAL_ERROR
, L
"Failed");
58 strcat(buffer
, "\nRebooting now!");
66 HRESULT
CreateShellLink(LPCTSTR linkPath
, LPCTSTR cmd
, LPCTSTR arg
, LPCTSTR dir
, LPCTSTR iconPath
, int icon_nr
, LPCTSTR comment
)
71 WCHAR buffer
[MAX_PATH
];
74 HRESULT hr
= CoCreateInstance(&CLSID_ShellLink
, NULL
, CLSCTX_INPROC_SERVER
, &IID_IShellLink
, (LPVOID
*)&psl
);
78 hr
= psl
->lpVtbl
->SetPath(psl
, cmd
);
82 hr
= psl
->lpVtbl
->SetArguments(psl
, arg
);
87 hr
= psl
->lpVtbl
->SetWorkingDirectory(psl
, dir
);
92 hr
= psl
->lpVtbl
->SetIconLocation(psl
, iconPath
, icon_nr
);
97 hr
= psl
->lpVtbl
->SetDescription(psl
, comment
);
100 hr
= psl
->lpVtbl
->QueryInterface(psl
, &IID_IPersistFile
, (LPVOID
*)&ppf
);
105 hr
= ppf
->lpVtbl
->Save(ppf
, linkPath
, TRUE
);
107 MultiByteToWideChar(CP_ACP
, 0, linkPath
, -1, buffer
, MAX_PATH
);
109 hr
= ppf
->lpVtbl
->Save(ppf
, buffer
, TRUE
);
110 #endif /* _UNICODE */
112 ppf
->lpVtbl
->Release(ppf
);
115 psl
->lpVtbl
->Release(psl
);
123 CreateShortcut(int csidl
, LPCTSTR folder
, UINT nIdName
, LPCTSTR command
, UINT nIdTitle
, BOOL bCheckExistence
)
125 TCHAR path
[MAX_PATH
];
126 TCHAR exeName
[MAX_PATH
];
130 TCHAR szWorkingDir
[MAX_PATH
];
131 LPTSTR lpWorkingDir
= NULL
;
135 if (ExpandEnvironmentStrings(command
,
137 sizeof(path
) / sizeof(path
[0])) == 0)
145 if ((_taccess(path
, 0 )) == -1)
146 /* Expected error, don't return FALSE */
150 dwLen
= GetFullPathName(path
,
151 sizeof(szWorkingDir
) / sizeof(szWorkingDir
[0]),
154 if (dwLen
!= 0 && dwLen
<= sizeof(szWorkingDir
) / sizeof(szWorkingDir
[0]))
156 /* Since those should only be called with (.exe) files,
157 lpFilePart has not to be NULL */
158 ASSERT(lpFilePart
!= NULL
);
160 /* Save the file name */
161 _tcscpy(exeName
, lpFilePart
);
163 /* We're only interested in the path. Cut the file name off.
164 Also remove the trailing backslash unless the working directory
165 is only going to be a drive, ie. C:\ */
166 *(lpFilePart
--) = _T('\0');
167 if (!(lpFilePart
- szWorkingDir
== 2 && szWorkingDir
[1] == _T(':') &&
168 szWorkingDir
[2] == _T('\\')))
170 *lpFilePart
= _T('\0');
173 lpWorkingDir
= szWorkingDir
;
177 if (!SHGetSpecialFolderPath(0, path
, csidl
, TRUE
))
182 p
= PathAddBackslash(p
);
186 p
= PathAddBackslash(p
);
188 if (!LoadString(hDllInstance
, nIdName
, name
, sizeof(name
)/sizeof(name
[0])))
192 if (!LoadString(hDllInstance
, nIdTitle
, title
, sizeof(title
)/sizeof(title
[0])))
195 // FIXME: we should pass 'command' straight in here, but shell32 doesn't expand it
196 return SUCCEEDED(CreateShellLink(path
, exeName
, _T(""), lpWorkingDir
, NULL
, 0, title
));
201 CreateShortcutFolder(int csidl
, UINT nID
, LPTSTR name
, int nameLen
)
203 TCHAR path
[MAX_PATH
];
206 if (!SHGetSpecialFolderPath(0, path
, csidl
, TRUE
))
209 if (!LoadString(hDllInstance
, nID
, name
, nameLen
))
212 p
= PathAddBackslash(path
);
215 return CreateDirectory(path
, NULL
) || GetLastError()==ERROR_ALREADY_EXISTS
;
223 SID_IDENTIFIER_AUTHORITY SystemAuthority
= {SECURITY_NT_AUTHORITY
};
224 LARGE_INTEGER SystemTime
;
228 NtQuerySystemTime(&SystemTime
);
229 Seed
= &SystemTime
.u
.LowPart
;
231 Status
= RtlAllocateAndInitializeSid(
234 SECURITY_NT_NON_UNIQUE
,
243 return NT_SUCCESS(Status
);
253 ULONG Rid
[8] = {0, 0, 0, 0, 0, 0, 0, 0};
257 RidCount
= *RtlSubAuthorityCountSid (Src
);
259 for (i
= 0; i
< RidCount
; i
++)
260 Rid
[i
] = *RtlSubAuthoritySid (Src
, i
);
264 Rid
[RidCount
] = NewRid
;
268 RtlAllocateAndInitializeSid(
269 RtlIdentifierAuthoritySid(Src
),
287 WCHAR szTempDir
[MAX_PATH
];
288 WCHAR szBuffer
[MAX_PATH
];
292 if (RegOpenKeyExW(HKEY_LOCAL_MACHINE
,
293 L
"SYSTEM\\CurrentControlSet\\Control\\Session Manager\\Environment",
298 DebugPrint("Error: %lu\n", GetLastError());
303 dwLength
= MAX_PATH
* sizeof(WCHAR
);
304 if (RegQueryValueExW(hKey
,
311 DebugPrint("Error: %lu\n", GetLastError());
317 if (!ExpandEnvironmentStringsW(szBuffer
,
321 DebugPrint("Error: %lu\n", GetLastError());
326 /* Create profiles directory */
327 if (!CreateDirectoryW(szTempDir
, NULL
))
329 if (GetLastError() != ERROR_ALREADY_EXISTS
)
331 DebugPrint("Error: %lu\n", GetLastError());
342 InstallSysSetupInfDevices(VOID
)
344 INFCONTEXT InfContext
;
345 WCHAR LineBuffer
[256];
348 if (!SetupFindFirstLineW(hSysSetupInf
,
349 L
"DeviceInfsToInstall",
358 if (!SetupGetStringFieldW(&InfContext
,
361 sizeof(LineBuffer
)/sizeof(LineBuffer
[0]),
367 if (!SetupDiInstallClassW(NULL
, LineBuffer
, DI_QUIETINSTALL
, NULL
))
372 while (SetupFindNextLine(&InfContext
, &InfContext
));
377 InstallSysSetupInfComponents(VOID
)
379 INFCONTEXT InfContext
;
380 WCHAR NameBuffer
[256];
381 WCHAR SectionBuffer
[256];
382 HINF hComponentInf
= INVALID_HANDLE_VALUE
;
384 if (!SetupFindFirstLineW(hSysSetupInf
,
389 DPRINT("No Inf.Always section found\n");
395 if (!SetupGetStringFieldW(&InfContext
,
396 1, // Get the component name
398 sizeof(NameBuffer
)/sizeof(NameBuffer
[0]),
401 DebugPrint("Error while trying to get component name \n");
405 if (!SetupGetStringFieldW(&InfContext
,
406 2, // Get the component install section
408 sizeof(SectionBuffer
)/sizeof(SectionBuffer
[0]),
411 DebugPrint("Error while trying to get component install section \n");
415 DPRINT("Trying to execute install section '%S' from '%S' \n", SectionBuffer
, NameBuffer
);
417 hComponentInf
= SetupOpenInfFileW(NameBuffer
,
422 if (hComponentInf
== INVALID_HANDLE_VALUE
)
424 DebugPrint("SetupOpenInfFileW() failed to open '%S' (Error: %lu)\n", NameBuffer
,GetLastError());
428 if (!SetupInstallFromInfSectionW(NULL
,
435 SetupDefaultQueueCallbackW
,
440 DebugPrint("Error while trying to install : %S (Error: %lu)\n", NameBuffer
, GetLastError());
441 SetupCloseInfFile(hComponentInf
);
445 SetupCloseInfFile(hComponentInf
);
447 while (SetupFindNextLine(&InfContext
, &InfContext
));
454 EnableUserModePnpManager(VOID
)
456 SC_HANDLE hSCManager
= NULL
;
457 SC_HANDLE hService
= NULL
;
460 hSCManager
= OpenSCManagerW(NULL
, NULL
, SC_MANAGER_ENUMERATE_SERVICE
);
461 if (hSCManager
== NULL
)
463 DPRINT1("Unable to open the service control manager.\n");
464 DPRINT1("Last Error %d\n", GetLastError());
468 hService
= OpenServiceW(hSCManager
,
470 SERVICE_CHANGE_CONFIG
| SERVICE_START
);
471 if (hService
== NULL
)
473 DPRINT1("Unable to open PlugPlay service\n");
477 ret
= ChangeServiceConfigW(hService
,
482 NULL
, NULL
, NULL
, NULL
);
485 DPRINT1("Unable to change the service configuration\n");
489 ret
= StartServiceW(hService
, 0, NULL
);
490 if ((!ret
) && (GetLastError() != ERROR_SERVICE_ALREADY_RUNNING
))
492 DPRINT1("Unable to start service\n");
499 if (hSCManager
!= NULL
)
500 CloseServiceHandle(hSCManager
);
501 if (hService
!= NULL
)
502 CloseServiceHandle(hService
);
507 static INT_PTR CALLBACK
508 StatusMessageWindowProc(
514 UNREFERENCED_PARAMETER(wParam
);
522 if (!LoadStringW(hDllInstance
, IDS_STATUS_INSTALL_DEV
, szMsg
, sizeof(szMsg
)/sizeof(szMsg
[0])))
524 SetDlgItemTextW(hwndDlg
, IDC_STATUSLABEL
, szMsg
);
533 ShowStatusMessageThread(
534 IN LPVOID lpParameter
)
536 HWND
*phWnd
= (HWND
*)lpParameter
;
540 hWnd
= CreateDialogParam(
542 MAKEINTRESOURCE(IDD_STATUSWINDOW_DLG
),
544 StatusMessageWindowProc
,
550 ShowWindow(hWnd
, SW_SHOW
);
552 /* Message loop for the Status window */
553 while (GetMessage(&Msg
, NULL
, 0, 0))
555 TranslateMessage(&Msg
);
556 DispatchMessage(&Msg
);
574 return ERROR_INVALID_PARAMETER
;
577 rc
= RegQueryValueExW(hKey
, pszKey
, NULL
, &dwType
, NULL
, &cbData
);
578 if (rc
!= ERROR_SUCCESS
)
580 if (dwType
!= REG_SZ
)
581 return ERROR_FILE_NOT_FOUND
;
582 Value
= HeapAlloc(GetProcessHeap(), 0, cbData
+ sizeof(WCHAR
));
584 return ERROR_NOT_ENOUGH_MEMORY
;
585 rc
= RegQueryValueExW(hKey
, pszKey
, NULL
, NULL
, (LPBYTE
)Value
, &cbData
);
586 if (rc
!= ERROR_SUCCESS
)
588 HeapFree(GetProcessHeap(), 0, Value
);
591 /* NULL-terminate the string */
592 Value
[cbData
/ sizeof(WCHAR
)] = '\0';
595 return ERROR_SUCCESS
;
601 HKEY ControlKey
= NULL
;
602 LPWSTR SystemStartOptions
= NULL
;
603 LPWSTR CurrentOption
, NextOption
; /* Pointers into SystemStartOptions */
604 BOOL ConsoleBoot
= FALSE
;
609 L
"SYSTEM\\CurrentControlSet\\Control",
614 rc
= ReadRegSzKey(ControlKey
, L
"SystemStartOptions", &SystemStartOptions
);
615 if (rc
!= ERROR_SUCCESS
)
618 /* Check for CMDCONS in SystemStartOptions */
619 CurrentOption
= SystemStartOptions
;
620 while (CurrentOption
)
622 NextOption
= wcschr(CurrentOption
, L
' ');
625 if (wcsicmp(CurrentOption
, L
"CONSOLE") == 0)
627 DPRINT("Found %S. Switching to console boot\n", CurrentOption
);
631 CurrentOption
= NextOption
? NextOption
+ 1 : NULL
;
635 if (ControlKey
!= NULL
)
636 RegCloseKey(ControlKey
);
637 HeapFree(GetProcessHeap(), 0, SystemStartOptions
);
646 hSysSetupInf
= SetupOpenInfFileW(
651 if (hSysSetupInf
== INVALID_HANDLE_VALUE
)
653 DebugPrint("SetupOpenInfFileW() failed to open 'syssetup.inf' (Error: %lu)\n", GetLastError());
657 if (!InstallSysSetupInfDevices())
659 DebugPrint("InstallSysSetupInfDevices() failed!\n");
660 SetupCloseInfFile(hSysSetupInf
);
664 if(!InstallSysSetupInfComponents())
666 DebugPrint("InstallSysSetupInfComponents() failed!\n");
667 SetupCloseInfFile(hSysSetupInf
);
671 if (!IsConsoleBoot())
676 ShowStatusMessageThread
,
682 if (!EnableUserModePnpManager())
684 DebugPrint("EnableUserModePnpManager() failed!\n");
685 SetupCloseInfFile(hSysSetupInf
);
690 if (CMP_WaitNoPendingInstallEvents(INFINITE
) != WAIT_OBJECT_0
)
692 DebugPrint("CMP_WaitNoPendingInstallEvents() failed!\n");
693 SetupCloseInfFile(hSysSetupInf
);
703 InstallLiveCD(IN HINSTANCE hInstance
)
705 STARTUPINFOW StartupInfo
;
706 PROCESS_INFORMATION ProcessInformation
;
709 if (!CommonInstall())
711 SetupCloseInfFile(hSysSetupInf
);
714 StartupInfo
.cb
= sizeof(STARTUPINFOW
);
715 StartupInfo
.lpReserved
= NULL
;
716 StartupInfo
.lpDesktop
= NULL
;
717 StartupInfo
.lpTitle
= NULL
;
718 StartupInfo
.dwFlags
= 0;
719 StartupInfo
.cbReserved2
= 0;
720 StartupInfo
.lpReserved2
= 0;
721 res
= CreateProcessW(
731 &ProcessInformation
);
740 L
"You can shutdown your computer, or press ENTER to reboot",
748 CreateShortcuts(VOID
)
754 /* Create desktop shortcuts */
755 CreateShortcut(CSIDL_DESKTOP
, NULL
, IDS_SHORT_CMD
, _T("%SystemRoot%\\system32\\cmd.exe"), IDS_CMT_CMD
, TRUE
);
757 /* Create program startmenu shortcuts */
758 CreateShortcut(CSIDL_PROGRAMS
, NULL
, IDS_SHORT_EXPLORER
, _T("%SystemRoot%\\explorer.exe"), IDS_CMT_EXPLORER
, TRUE
);
759 CreateShortcut(CSIDL_PROGRAMS
, NULL
, IDS_SHORT_DOWNLOADER
, _T("%SystemRoot%\\system32\\rapps.exe"), IDS_CMT_DOWNLOADER
, TRUE
);
761 /* Create administrative tools startmenu shortcuts */
762 CreateShortcut(CSIDL_COMMON_ADMINTOOLS
, NULL
, IDS_SHORT_SERVICE
, _T("%SystemRoot%\\system32\\servman.exe"), IDS_CMT_SERVMAN
, TRUE
);
763 CreateShortcut(CSIDL_COMMON_ADMINTOOLS
, NULL
, IDS_SHORT_DEVICE
, _T("%SystemRoot%\\system32\\devmgmt.exe"), IDS_CMT_DEVMGMT
, TRUE
);
764 CreateShortcut(CSIDL_COMMON_ADMINTOOLS
, NULL
, IDS_SHORT_EVENTVIEW
, _T("%SystemRoot%\\system32\\eventvwr.exe"), IDS_CMT_EVENTVIEW
, TRUE
);
765 CreateShortcut(CSIDL_COMMON_ADMINTOOLS
, NULL
, IDS_SHORT_MSCONFIG
, _T("%SystemRoot%\\system32\\msconfig.exe"), IDS_CMT_MSCONFIG
, TRUE
);
767 /* Create and fill Accessories subfolder */
768 if (CreateShortcutFolder(CSIDL_PROGRAMS
, IDS_ACCESSORIES
, szFolder
, sizeof(szFolder
)/sizeof(szFolder
[0])))
770 CreateShortcut(CSIDL_PROGRAMS
, szFolder
, IDS_SHORT_CALC
, _T("%SystemRoot%\\system32\\calc.exe"), IDS_CMT_CALC
, TRUE
);
771 CreateShortcut(CSIDL_PROGRAMS
, szFolder
, IDS_SHORT_CMD
, _T("%SystemRoot%\\system32\\cmd.exe"), IDS_CMT_CMD
, TRUE
);
772 CreateShortcut(CSIDL_PROGRAMS
, szFolder
, IDS_SHORT_NOTEPAD
, _T("%SystemRoot%\\system32\\notepad.exe"), IDS_CMT_NOTEPAD
, TRUE
);
773 CreateShortcut(CSIDL_PROGRAMS
, szFolder
, IDS_SHORT_RDESKTOP
, _T("%SystemRoot%\\system32\\mstsc.exe"), IDS_CMT_RDESKTOP
, TRUE
);
774 CreateShortcut(CSIDL_PROGRAMS
, szFolder
, IDS_SHORT_SNAP
, _T("%SystemRoot%\\system32\\screenshot.exe"), IDS_CMT_SCREENSHOT
, TRUE
);
775 CreateShortcut(CSIDL_PROGRAMS
, szFolder
, IDS_SHORT_WORDPAD
, _T("%SystemRoot%\\system32\\wordpad.exe"), IDS_CMT_WORDPAD
, TRUE
);
776 CreateShortcut(CSIDL_PROGRAMS
, szFolder
, IDS_SHORT_PAINT
, _T("%SystemRoot%\\system32\\mspaint.exe"), IDS_CMT_PAINT
, TRUE
);
779 /* Create System Tools subfolder and fill if the exe is available */
780 if (CreateShortcutFolder(CSIDL_PROGRAMS
, IDS_SYS_TOOLS
, szFolder
, sizeof(szFolder
)/sizeof(szFolder
[0])))
782 CreateShortcut(CSIDL_PROGRAMS
, szFolder
, IDS_SHORT_CHARMAP
, _T("%SystemRoot%\\system32\\charmap.exe"), IDS_CMT_CHARMAP
, TRUE
);
783 CreateShortcut(CSIDL_PROGRAMS
, szFolder
, IDS_SHORT_KBSWITCH
, _T("%SystemRoot%\\system32\\kbswitch.exe"), IDS_CMT_KBSWITCH
, TRUE
);
784 CreateShortcut(CSIDL_PROGRAMS
, szFolder
, IDS_SHORT_REGEDIT
, _T("%SystemRoot%\\regedit.exe"), IDS_CMT_REGEDIT
, TRUE
);
785 CreateShortcut(CSIDL_PROGRAMS
, szFolder
, IDS_SHORT_DXDIAG
, _T("%SystemRoot%\\system32\\dxdiag.exe"), IDS_CMT_DXDIAG
, TRUE
);
788 /* Create Accessibility subfolder and fill if the exe is available */
789 if (CreateShortcutFolder(CSIDL_PROGRAMS
, IDS_SYS_ACCESSIBILITY
, szFolder
, sizeof(szFolder
)/sizeof(szFolder
[0])))
791 CreateShortcut(CSIDL_PROGRAMS
, szFolder
, IDS_SHORT_MAGNIFY
, _T("%SystemRoot%\\system32\\magnify.exe"), IDS_CMT_MAGNIFY
, TRUE
);
794 /* Create Entertainment subfolder and fill if the exe is available */
795 if (CreateShortcutFolder(CSIDL_PROGRAMS
, IDS_SYS_ENTERTAINMENT
, szFolder
, sizeof(szFolder
)/sizeof(szFolder
[0])))
797 CreateShortcut(CSIDL_PROGRAMS
, szFolder
, IDS_SHORT_MPLAY32
, _T("%SystemRoot%\\system32\\mplay32.exe"), IDS_CMT_MPLAY32
, TRUE
);
798 CreateShortcut(CSIDL_PROGRAMS
, szFolder
, IDS_SHORT_SNDVOL32
, _T("%SystemRoot%\\system32\\sndvol32.exe"), IDS_CMT_SNDVOL32
, TRUE
);
799 CreateShortcut(CSIDL_PROGRAMS
, szFolder
, IDS_SHORT_SNDREC32
, _T("%SystemRoot%\\system32\\sndrec32.exe"), IDS_CMT_SNDREC32
, TRUE
);
802 /* Create Games subfolder and fill if the exe is available */
803 if (CreateShortcutFolder(CSIDL_PROGRAMS
, IDS_GAMES
, szFolder
, sizeof(szFolder
)/sizeof(szFolder
[0])))
805 CreateShortcut(CSIDL_PROGRAMS
, szFolder
, IDS_SHORT_SOLITAIRE
, _T("%SystemRoot%\\system32\\sol.exe"), IDS_CMT_SOLITAIRE
, TRUE
);
806 CreateShortcut(CSIDL_PROGRAMS
, szFolder
, IDS_SHORT_WINEMINE
, _T("%SystemRoot%\\system32\\winmine.exe"), IDS_CMT_WINEMINE
, TRUE
);
807 CreateShortcut(CSIDL_PROGRAMS
, szFolder
, IDS_SHORT_SPIDER
, _T("%SystemRoot%\\system32\\spider.exe"), IDS_CMT_SPIDER
, TRUE
);
816 SetSetupType(DWORD dwSetupType
)
821 dwError
= RegOpenKeyExW(
827 if (dwError
!= ERROR_SUCCESS
)
830 dwError
= RegSetValueExW(
835 (LPBYTE
)&dwSetupType
,
838 if (dwError
!= ERROR_SUCCESS
)
845 InstallReactOS(HINSTANCE hInstance
)
847 TCHAR szBuffer
[MAX_PATH
];
850 TOKEN_PRIVILEGES privs
;
853 InitializeSetupActionLog(FALSE
);
854 LogItem(SYSSETUP_SEVERITY_INFORMATION
, L
"Installing ReactOS");
856 if (!InitializeProfiles())
858 DebugPrint("InitializeProfiles() failed");
862 if (!CreateShortcuts())
864 DebugPrint("InitializeProfiles() failed");
868 /* Initialize the Security Account Manager (SAM) */
869 if (!SamInitializeSAM())
871 DebugPrint("SamInitializeSAM() failed!");
875 /* Create the semi-random Domain-SID */
876 if (!CreateRandomSid(&DomainSid
))
878 DebugPrint("Domain-SID creation failed!");
882 /* Set the Domain SID (aka Computer SID) */
883 if (!SamSetDomainSid(DomainSid
))
885 DebugPrint("SamSetDomainSid() failed!");
886 RtlFreeSid(DomainSid
);
890 /* Append the Admin-RID */
891 AppendRidToSid(&AdminSid
, DomainSid
, DOMAIN_USER_RID_ADMIN
);
893 CreateTempDir(L
"TEMP");
894 CreateTempDir(L
"TMP");
896 if (GetWindowsDirectory(szBuffer
, sizeof(szBuffer
) / sizeof(TCHAR
)))
898 if (RegOpenKeyExW(HKEY_LOCAL_MACHINE
,
899 L
"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion",
902 &hKey
) == ERROR_SUCCESS
)
909 (wcslen(szBuffer
) + 1) * sizeof(WCHAR
));
916 (wcslen(szBuffer
) + 1) * sizeof(WCHAR
));
921 PathAddBackslash(szBuffer
);
922 _tcscat(szBuffer
, _T("system"));
923 CreateDirectory(szBuffer
, NULL
);
926 if (!CommonInstall())
931 /* Create the Administrator account */
932 if (!SamCreateUser(L
"Administrator", L
"", AdminSid
))
934 /* Check what the error was.
935 * If the Admin Account already exists, then it means Setup
936 * wasn't allowed to finish properly. Instead of rebooting
937 * and not completing it, let it restart instead
939 LastError
= GetLastError();
940 if (LastError
!= ERROR_USER_EXISTS
)
942 DebugPrint("SamCreateUser() failed!");
943 RtlFreeSid(AdminSid
);
944 RtlFreeSid(DomainSid
);
949 RtlFreeSid(AdminSid
);
950 RtlFreeSid(DomainSid
);
952 /* ROS HACK, as long as NtUnloadKey is not implemented */
954 NTSTATUS Status
= NtUnloadKey(NULL
);
955 if (Status
== STATUS_NOT_IMPLEMENTED
)
957 /* Create the Administrator profile */
958 PROFILEINFOW ProfileInfo
;
961 #define LOGON32_LOGON_NETWORK 3
962 ret
= LogonUserW(L
"Administrator", L
"", L
"", LOGON32_LOGON_NETWORK
, LOGON32_PROVIDER_DEFAULT
, &hToken
);
965 DebugPrint("LogonUserW() failed!");
968 ZeroMemory(&ProfileInfo
, sizeof(PROFILEINFOW
));
969 ProfileInfo
.dwSize
= sizeof(PROFILEINFOW
);
970 ProfileInfo
.lpUserName
= L
"Administrator";
971 ProfileInfo
.dwFlags
= PI_NOUI
;
972 LoadUserProfileW(hToken
, &ProfileInfo
);
977 DPRINT1("ROS HACK not needed anymore. Please remove it\n");
980 /* END OF ROS HACK */
982 SetupCloseInfFile(hSysSetupInf
);
985 LogItem(SYSSETUP_SEVERITY_INFORMATION
, L
"Installing ReactOS done");
986 TerminateSetupActionLog();
988 /* Get shutdown privilege */
989 if (! OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES
, &token
))
991 DebugPrint("OpenProcessToken() failed!");
994 if (!LookupPrivilegeValue(
997 &privs
.Privileges
[0].Luid
))
999 DebugPrint("LookupPrivilegeValue() failed!");
1002 privs
.PrivilegeCount
= 1;
1003 privs
.Privileges
[0].Attributes
= SE_PRIVILEGE_ENABLED
;
1004 if (AdjustTokenPrivileges(
1009 (PTOKEN_PRIVILEGES
)NULL
,
1012 DebugPrint("AdjustTokenPrivileges() failed!");
1016 ExitWindowsEx(EWX_REBOOT
, 0);
1025 SetupChangeFontSize(
1027 IN LPCWSTR lpszFontSize
)
1029 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
1037 SetupChangeLocaleEx(HWND hWnd
,
1039 LPCWSTR lpSrcRootPath
,
1044 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
1052 SetupChangeLocale(HWND hWnd
, LCID Lcid
)
1054 return SetupChangeLocaleEx(hWnd
, Lcid
, NULL
, 0, 0, 0);