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 /* Save the file name */
157 _tcscpy(exeName
, lpFilePart
);
159 if (lpFilePart
!= NULL
)
161 /* We're only interested in the path. Cut the file name off.
162 Also remove the trailing backslash unless the working directory
163 is only going to be a drive, ie. C:\ */
164 *(lpFilePart
--) = _T('\0');
165 if (!(lpFilePart
- szWorkingDir
== 2 && szWorkingDir
[1] == _T(':') &&
166 szWorkingDir
[2] == _T('\\')))
168 *lpFilePart
= _T('\0');
172 lpWorkingDir
= szWorkingDir
;
176 if (!SHGetSpecialFolderPath(0, path
, csidl
, TRUE
))
181 p
= PathAddBackslash(p
);
185 p
= PathAddBackslash(p
);
187 if (!LoadString(hDllInstance
, nIdName
, name
, sizeof(name
)/sizeof(name
[0])))
191 if (!LoadString(hDllInstance
, nIdTitle
, title
, sizeof(title
)/sizeof(title
[0])))
194 // FIXME: we should pass 'command' straight in here, but shell32 doesn't expand it
195 return SUCCEEDED(CreateShellLink(path
, exeName
, _T(""), lpWorkingDir
, NULL
, 0, title
));
200 CreateShortcutFolder(int csidl
, UINT nID
, LPTSTR name
, int nameLen
)
202 TCHAR path
[MAX_PATH
];
205 if (!SHGetSpecialFolderPath(0, path
, csidl
, TRUE
))
208 if (!LoadString(hDllInstance
, nID
, name
, nameLen
))
211 p
= PathAddBackslash(path
);
214 return CreateDirectory(path
, NULL
) || GetLastError()==ERROR_ALREADY_EXISTS
;
222 SID_IDENTIFIER_AUTHORITY SystemAuthority
= {SECURITY_NT_AUTHORITY
};
223 LARGE_INTEGER SystemTime
;
227 NtQuerySystemTime(&SystemTime
);
228 Seed
= &SystemTime
.u
.LowPart
;
230 Status
= RtlAllocateAndInitializeSid(
233 SECURITY_NT_NON_UNIQUE
,
242 return NT_SUCCESS(Status
);
252 ULONG Rid
[8] = {0, 0, 0, 0, 0, 0, 0, 0};
256 RidCount
= *RtlSubAuthorityCountSid (Src
);
258 for (i
= 0; i
< RidCount
; i
++)
259 Rid
[i
] = *RtlSubAuthoritySid (Src
, i
);
263 Rid
[RidCount
] = NewRid
;
267 RtlAllocateAndInitializeSid(
268 RtlIdentifierAuthoritySid(Src
),
286 WCHAR szTempDir
[MAX_PATH
];
287 WCHAR szBuffer
[MAX_PATH
];
291 if (RegOpenKeyExW(HKEY_LOCAL_MACHINE
,
292 L
"SYSTEM\\CurrentControlSet\\Control\\Session Manager\\Environment",
297 DebugPrint("Error: %lu\n", GetLastError());
302 dwLength
= MAX_PATH
* sizeof(WCHAR
);
303 if (RegQueryValueExW(hKey
,
310 DebugPrint("Error: %lu\n", GetLastError());
316 if (!ExpandEnvironmentStringsW(szBuffer
,
320 DebugPrint("Error: %lu\n", GetLastError());
325 /* Create profiles directory */
326 if (!CreateDirectoryW(szTempDir
, NULL
))
328 if (GetLastError() != ERROR_ALREADY_EXISTS
)
330 DebugPrint("Error: %lu\n", GetLastError());
341 InstallSysSetupInfDevices(VOID
)
343 INFCONTEXT InfContext
;
344 WCHAR LineBuffer
[256];
347 if (!SetupFindFirstLineW(hSysSetupInf
,
348 L
"DeviceInfsToInstall",
357 if (!SetupGetStringFieldW(&InfContext
,
360 sizeof(LineBuffer
)/sizeof(LineBuffer
[0]),
366 if (!SetupDiInstallClassW(NULL
, LineBuffer
, DI_QUIETINSTALL
, NULL
))
371 while (SetupFindNextLine(&InfContext
, &InfContext
));
376 InstallSysSetupInfComponents(VOID
)
378 INFCONTEXT InfContext
;
379 WCHAR NameBuffer
[256];
380 WCHAR SectionBuffer
[256];
381 HINF hComponentInf
= INVALID_HANDLE_VALUE
;
383 if (!SetupFindFirstLineW(hSysSetupInf
,
388 DPRINT("No Inf.Always section found\n");
394 if (!SetupGetStringFieldW(&InfContext
,
395 1, // Get the component name
397 sizeof(NameBuffer
)/sizeof(NameBuffer
[0]),
400 DebugPrint("Error while trying to get component name \n");
404 if (!SetupGetStringFieldW(&InfContext
,
405 2, // Get the component install section
407 sizeof(SectionBuffer
)/sizeof(SectionBuffer
[0]),
410 DebugPrint("Error while trying to get component install section \n");
414 DPRINT("Trying to execute install section '%S' from '%S' \n", SectionBuffer
, NameBuffer
);
416 hComponentInf
= SetupOpenInfFileW(NameBuffer
,
421 if (hComponentInf
== INVALID_HANDLE_VALUE
)
423 DebugPrint("SetupOpenInfFileW() failed to open '%S' (Error: %lu)\n", NameBuffer
,GetLastError());
427 if (!SetupInstallFromInfSectionW(NULL
,
434 SetupDefaultQueueCallbackW
,
439 DebugPrint("Error while trying to install : %S (Error: %lu)\n", NameBuffer
, GetLastError());
440 SetupCloseInfFile(hComponentInf
);
444 SetupCloseInfFile(hComponentInf
);
446 while (SetupFindNextLine(&InfContext
, &InfContext
));
453 EnableUserModePnpManager(VOID
)
455 SC_HANDLE hSCManager
= NULL
;
456 SC_HANDLE hService
= NULL
;
459 hSCManager
= OpenSCManagerW(NULL
, NULL
, SC_MANAGER_ENUMERATE_SERVICE
);
460 if (hSCManager
== NULL
)
462 DPRINT1("Unable to open the service control manager.\n");
463 DPRINT1("Last Error %d\n", GetLastError());
467 hService
= OpenServiceW(hSCManager
,
469 SERVICE_CHANGE_CONFIG
| SERVICE_START
);
470 if (hService
== NULL
)
472 DPRINT1("Unable to open PlugPlay service\n");
476 ret
= ChangeServiceConfigW(hService
,
481 NULL
, NULL
, NULL
, NULL
);
484 DPRINT1("Unable to change the service configuration\n");
488 ret
= StartServiceW(hService
, 0, NULL
);
489 if ((!ret
) && (GetLastError() != ERROR_SERVICE_ALREADY_RUNNING
))
491 DPRINT1("Unable to start service\n");
498 if (hSCManager
!= NULL
)
499 CloseServiceHandle(hSCManager
);
500 if (hService
!= NULL
)
501 CloseServiceHandle(hService
);
506 static INT_PTR CALLBACK
507 StatusMessageWindowProc(
513 UNREFERENCED_PARAMETER(wParam
);
521 if (!LoadStringW(hDllInstance
, IDS_STATUS_INSTALL_DEV
, szMsg
, sizeof(szMsg
)/sizeof(szMsg
[0])))
523 SetDlgItemTextW(hwndDlg
, IDC_STATUSLABEL
, szMsg
);
532 ShowStatusMessageThread(
533 IN LPVOID lpParameter
)
535 HWND
*phWnd
= (HWND
*)lpParameter
;
539 hWnd
= CreateDialogParam(
541 MAKEINTRESOURCE(IDD_STATUSWINDOW_DLG
),
543 StatusMessageWindowProc
,
549 ShowWindow(hWnd
, SW_SHOW
);
551 /* Message loop for the Status window */
552 while (GetMessage(&Msg
, NULL
, 0, 0))
554 TranslateMessage(&Msg
);
555 DispatchMessage(&Msg
);
573 return ERROR_INVALID_PARAMETER
;
576 rc
= RegQueryValueExW(hKey
, pszKey
, NULL
, &dwType
, NULL
, &cbData
);
577 if (rc
!= ERROR_SUCCESS
)
579 if (dwType
!= REG_SZ
)
580 return ERROR_FILE_NOT_FOUND
;
581 Value
= HeapAlloc(GetProcessHeap(), 0, cbData
+ sizeof(WCHAR
));
583 return ERROR_NOT_ENOUGH_MEMORY
;
584 rc
= RegQueryValueExW(hKey
, pszKey
, NULL
, NULL
, (LPBYTE
)Value
, &cbData
);
585 if (rc
!= ERROR_SUCCESS
)
587 HeapFree(GetProcessHeap(), 0, Value
);
590 /* NULL-terminate the string */
591 Value
[cbData
/ sizeof(WCHAR
)] = '\0';
594 return ERROR_SUCCESS
;
600 HKEY ControlKey
= NULL
;
601 LPWSTR SystemStartOptions
= NULL
;
602 LPWSTR CurrentOption
, NextOption
; /* Pointers into SystemStartOptions */
603 BOOL ConsoleBoot
= FALSE
;
608 L
"SYSTEM\\CurrentControlSet\\Control",
613 rc
= ReadRegSzKey(ControlKey
, L
"SystemStartOptions", &SystemStartOptions
);
614 if (rc
!= ERROR_SUCCESS
)
617 /* Check for CMDCONS in SystemStartOptions */
618 CurrentOption
= SystemStartOptions
;
619 while (CurrentOption
)
621 NextOption
= wcschr(CurrentOption
, L
' ');
624 if (wcsicmp(CurrentOption
, L
"CONSOLE") == 0)
626 DPRINT("Found %S. Switching to console boot\n", CurrentOption
);
630 CurrentOption
= NextOption
? NextOption
+ 1 : NULL
;
634 if (ControlKey
!= NULL
)
635 RegCloseKey(ControlKey
);
636 HeapFree(GetProcessHeap(), 0, SystemStartOptions
);
645 hSysSetupInf
= SetupOpenInfFileW(
650 if (hSysSetupInf
== INVALID_HANDLE_VALUE
)
652 DebugPrint("SetupOpenInfFileW() failed to open 'syssetup.inf' (Error: %lu)\n", GetLastError());
656 if (!InstallSysSetupInfDevices())
658 DebugPrint("InstallSysSetupInfDevices() failed!\n");
659 SetupCloseInfFile(hSysSetupInf
);
663 if(!InstallSysSetupInfComponents())
665 DebugPrint("InstallSysSetupInfComponents() failed!\n");
666 SetupCloseInfFile(hSysSetupInf
);
670 if (!IsConsoleBoot())
675 ShowStatusMessageThread
,
681 if (!EnableUserModePnpManager())
683 DebugPrint("EnableUserModePnpManager() failed!\n");
684 SetupCloseInfFile(hSysSetupInf
);
689 if (CMP_WaitNoPendingInstallEvents(INFINITE
) != WAIT_OBJECT_0
)
691 DebugPrint("CMP_WaitNoPendingInstallEvents() failed!\n");
692 SetupCloseInfFile(hSysSetupInf
);
702 InstallLiveCD(IN HINSTANCE hInstance
)
704 STARTUPINFOW StartupInfo
;
705 PROCESS_INFORMATION ProcessInformation
;
708 if (!CommonInstall())
710 SetupCloseInfFile(hSysSetupInf
);
713 StartupInfo
.cb
= sizeof(STARTUPINFOW
);
714 StartupInfo
.lpReserved
= NULL
;
715 StartupInfo
.lpDesktop
= NULL
;
716 StartupInfo
.lpTitle
= NULL
;
717 StartupInfo
.dwFlags
= 0;
718 StartupInfo
.cbReserved2
= 0;
719 StartupInfo
.lpReserved2
= 0;
720 res
= CreateProcessW(
730 &ProcessInformation
);
739 L
"You can shutdown your computer, or press ENTER to reboot",
747 CreateShortcuts(VOID
)
753 /* Create desktop shortcuts */
754 CreateShortcut(CSIDL_DESKTOP
, NULL
, IDS_SHORT_CMD
, _T("%SystemRoot%\\system32\\cmd.exe"), IDS_CMT_CMD
, TRUE
);
756 /* Create program startmenu shortcuts */
757 CreateShortcut(CSIDL_PROGRAMS
, NULL
, IDS_SHORT_EXPLORER
, _T("%SystemRoot%\\explorer.exe"), IDS_CMT_EXPLORER
, TRUE
);
758 CreateShortcut(CSIDL_PROGRAMS
, NULL
, IDS_SHORT_DOWNLOADER
, _T("%SystemRoot%\\system32\\rapps.exe"), IDS_CMT_DOWNLOADER
, TRUE
);
760 /* Create administrative tools startmenu shortcuts */
761 CreateShortcut(CSIDL_COMMON_ADMINTOOLS
, NULL
, IDS_SHORT_SERVICE
, _T("%SystemRoot%\\system32\\servman.exe"), IDS_CMT_SERVMAN
, TRUE
);
762 CreateShortcut(CSIDL_COMMON_ADMINTOOLS
, NULL
, IDS_SHORT_DEVICE
, _T("%SystemRoot%\\system32\\devmgmt.exe"), IDS_CMT_DEVMGMT
, TRUE
);
763 CreateShortcut(CSIDL_COMMON_ADMINTOOLS
, NULL
, IDS_SHORT_EVENTVIEW
, _T("%SystemRoot%\\system32\\eventvwr.exe"), IDS_CMT_EVENTVIEW
, TRUE
);
764 CreateShortcut(CSIDL_COMMON_ADMINTOOLS
, NULL
, IDS_SHORT_MSCONFIG
, _T("%SystemRoot%\\system32\\msconfig.exe"), IDS_CMT_MSCONFIG
, TRUE
);
766 /* Create and fill Accessories subfolder */
767 if (CreateShortcutFolder(CSIDL_PROGRAMS
, IDS_ACCESSORIES
, szFolder
, sizeof(szFolder
)/sizeof(szFolder
[0])))
769 CreateShortcut(CSIDL_PROGRAMS
, szFolder
, IDS_SHORT_CALC
, _T("%SystemRoot%\\system32\\calc.exe"), IDS_CMT_CALC
, TRUE
);
770 CreateShortcut(CSIDL_PROGRAMS
, szFolder
, IDS_SHORT_CMD
, _T("%SystemRoot%\\system32\\cmd.exe"), IDS_CMT_CMD
, TRUE
);
771 CreateShortcut(CSIDL_PROGRAMS
, szFolder
, IDS_SHORT_NOTEPAD
, _T("%SystemRoot%\\system32\\notepad.exe"), IDS_CMT_NOTEPAD
, TRUE
);
772 CreateShortcut(CSIDL_PROGRAMS
, szFolder
, IDS_SHORT_RDESKTOP
, _T("%SystemRoot%\\system32\\mstsc.exe"), IDS_CMT_RDESKTOP
, TRUE
);
773 CreateShortcut(CSIDL_PROGRAMS
, szFolder
, IDS_SHORT_SNAP
, _T("%SystemRoot%\\system32\\screenshot.exe"), IDS_CMT_SCREENSHOT
, TRUE
);
774 CreateShortcut(CSIDL_PROGRAMS
, szFolder
, IDS_SHORT_WORDPAD
, _T("%SystemRoot%\\system32\\wordpad.exe"), IDS_CMT_WORDPAD
, TRUE
);
775 CreateShortcut(CSIDL_PROGRAMS
, szFolder
, IDS_SHORT_PAINT
, _T("%SystemRoot%\\system32\\mspaint.exe"), IDS_CMT_PAINT
, TRUE
);
778 /* Create System Tools subfolder and fill if the exe is available */
779 if (CreateShortcutFolder(CSIDL_PROGRAMS
, IDS_SYS_TOOLS
, szFolder
, sizeof(szFolder
)/sizeof(szFolder
[0])))
781 CreateShortcut(CSIDL_PROGRAMS
, szFolder
, IDS_SHORT_CHARMAP
, _T("%SystemRoot%\\system32\\charmap.exe"), IDS_CMT_CHARMAP
, TRUE
);
782 CreateShortcut(CSIDL_PROGRAMS
, szFolder
, IDS_SHORT_KBSWITCH
, _T("%SystemRoot%\\system32\\kbswitch.exe"), IDS_CMT_KBSWITCH
, TRUE
);
783 CreateShortcut(CSIDL_PROGRAMS
, szFolder
, IDS_SHORT_REGEDIT
, _T("%SystemRoot%\\regedit.exe"), IDS_CMT_REGEDIT
, TRUE
);
784 CreateShortcut(CSIDL_PROGRAMS
, szFolder
, IDS_SHORT_DXDIAG
, _T("%SystemRoot%\\system32\\dxdiag.exe"), IDS_CMT_DXDIAG
, TRUE
);
787 /* Create Accessibility subfolder and fill if the exe is available */
788 if (CreateShortcutFolder(CSIDL_PROGRAMS
, IDS_SYS_ACCESSIBILITY
, szFolder
, sizeof(szFolder
)/sizeof(szFolder
[0])))
790 CreateShortcut(CSIDL_PROGRAMS
, szFolder
, IDS_SHORT_MAGNIFY
, _T("%SystemRoot%\\system32\\magnify.exe"), IDS_CMT_MAGNIFY
, TRUE
);
793 /* Create Entertainment subfolder and fill if the exe is available */
794 if (CreateShortcutFolder(CSIDL_PROGRAMS
, IDS_SYS_ENTERTAINMENT
, szFolder
, sizeof(szFolder
)/sizeof(szFolder
[0])))
796 CreateShortcut(CSIDL_PROGRAMS
, szFolder
, IDS_SHORT_MPLAY32
, _T("%SystemRoot%\\system32\\mplay32.exe"), IDS_CMT_MPLAY32
, TRUE
);
797 CreateShortcut(CSIDL_PROGRAMS
, szFolder
, IDS_SHORT_SNDVOL32
, _T("%SystemRoot%\\system32\\sndvol32.exe"), IDS_CMT_SNDVOL32
, TRUE
);
798 CreateShortcut(CSIDL_PROGRAMS
, szFolder
, IDS_SHORT_SNDREC32
, _T("%SystemRoot%\\system32\\sndrec32.exe"), IDS_CMT_SNDREC32
, TRUE
);
801 /* Create Games subfolder and fill if the exe is available */
802 if (CreateShortcutFolder(CSIDL_PROGRAMS
, IDS_GAMES
, szFolder
, sizeof(szFolder
)/sizeof(szFolder
[0])))
804 CreateShortcut(CSIDL_PROGRAMS
, szFolder
, IDS_SHORT_SOLITAIRE
, _T("%SystemRoot%\\system32\\sol.exe"), IDS_CMT_SOLITAIRE
, TRUE
);
805 CreateShortcut(CSIDL_PROGRAMS
, szFolder
, IDS_SHORT_WINEMINE
, _T("%SystemRoot%\\system32\\winmine.exe"), IDS_CMT_WINEMINE
, TRUE
);
806 CreateShortcut(CSIDL_PROGRAMS
, szFolder
, IDS_SHORT_SPIDER
, _T("%SystemRoot%\\system32\\spider.exe"), IDS_CMT_SPIDER
, TRUE
);
815 SetSetupType(DWORD dwSetupType
)
820 dwError
= RegOpenKeyExW(
826 if (dwError
!= ERROR_SUCCESS
)
829 dwError
= RegSetValueExW(
834 (LPBYTE
)&dwSetupType
,
837 if (dwError
!= ERROR_SUCCESS
)
844 InstallReactOS(HINSTANCE hInstance
)
846 TCHAR szBuffer
[MAX_PATH
];
849 TOKEN_PRIVILEGES privs
;
852 InitializeSetupActionLog(FALSE
);
853 LogItem(SYSSETUP_SEVERITY_INFORMATION
, L
"Installing ReactOS");
855 if (!InitializeProfiles())
857 DebugPrint("InitializeProfiles() failed");
861 if (!CreateShortcuts())
863 DebugPrint("InitializeProfiles() failed");
867 /* Initialize the Security Account Manager (SAM) */
868 if (!SamInitializeSAM())
870 DebugPrint("SamInitializeSAM() failed!");
874 /* Create the semi-random Domain-SID */
875 if (!CreateRandomSid(&DomainSid
))
877 DebugPrint("Domain-SID creation failed!");
881 /* Set the Domain SID (aka Computer SID) */
882 if (!SamSetDomainSid(DomainSid
))
884 DebugPrint("SamSetDomainSid() failed!");
885 RtlFreeSid(DomainSid
);
889 /* Append the Admin-RID */
890 AppendRidToSid(&AdminSid
, DomainSid
, DOMAIN_USER_RID_ADMIN
);
892 CreateTempDir(L
"TEMP");
893 CreateTempDir(L
"TMP");
895 if (GetWindowsDirectory(szBuffer
, sizeof(szBuffer
) / sizeof(TCHAR
)))
897 if (RegOpenKeyExW(HKEY_LOCAL_MACHINE
,
898 L
"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion",
901 &hKey
) == ERROR_SUCCESS
)
908 (wcslen(szBuffer
) + 1) * sizeof(WCHAR
));
915 (wcslen(szBuffer
) + 1) * sizeof(WCHAR
));
920 PathAddBackslash(szBuffer
);
921 _tcscat(szBuffer
, _T("system"));
922 CreateDirectory(szBuffer
, NULL
);
925 if (!CommonInstall())
930 /* Create the Administrator account */
931 if (!SamCreateUser(L
"Administrator", L
"", AdminSid
))
933 /* Check what the error was.
934 * If the Admin Account already exists, then it means Setup
935 * wasn't allowed to finish properly. Instead of rebooting
936 * and not completing it, let it restart instead
938 LastError
= GetLastError();
939 if (LastError
!= ERROR_USER_EXISTS
)
941 DebugPrint("SamCreateUser() failed!");
942 RtlFreeSid(AdminSid
);
943 RtlFreeSid(DomainSid
);
948 RtlFreeSid(AdminSid
);
949 RtlFreeSid(DomainSid
);
951 /* ROS HACK, as long as NtUnloadKey is not implemented */
953 NTSTATUS Status
= NtUnloadKey(NULL
);
954 if (Status
== STATUS_NOT_IMPLEMENTED
)
956 /* Create the Administrator profile */
957 PROFILEINFOW ProfileInfo
;
960 #define LOGON32_LOGON_NETWORK 3
961 ret
= LogonUserW(L
"Administrator", L
"", L
"", LOGON32_LOGON_NETWORK
, LOGON32_PROVIDER_DEFAULT
, &hToken
);
964 DebugPrint("LogonUserW() failed!");
967 ZeroMemory(&ProfileInfo
, sizeof(PROFILEINFOW
));
968 ProfileInfo
.dwSize
= sizeof(PROFILEINFOW
);
969 ProfileInfo
.lpUserName
= L
"Administrator";
970 ProfileInfo
.dwFlags
= PI_NOUI
;
971 LoadUserProfileW(hToken
, &ProfileInfo
);
976 DPRINT1("ROS HACK not needed anymore. Please remove it\n");
979 /* END OF ROS HACK */
981 SetupCloseInfFile(hSysSetupInf
);
984 LogItem(SYSSETUP_SEVERITY_INFORMATION
, L
"Installing ReactOS done");
985 TerminateSetupActionLog();
987 /* Get shutdown privilege */
988 if (! OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES
, &token
))
990 DebugPrint("OpenProcessToken() failed!");
993 if (!LookupPrivilegeValue(
996 &privs
.Privileges
[0].Luid
))
998 DebugPrint("LookupPrivilegeValue() failed!");
1001 privs
.PrivilegeCount
= 1;
1002 privs
.Privileges
[0].Attributes
= SE_PRIVILEGE_ENABLED
;
1003 if (AdjustTokenPrivileges(
1008 (PTOKEN_PRIVILEGES
)NULL
,
1011 DebugPrint("AdjustTokenPrivileges() failed!");
1015 ExitWindowsEx(EWX_REBOOT
, 0);
1024 SetupChangeFontSize(
1026 IN LPCWSTR lpszFontSize
)
1028 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
1036 SetupChangeLocaleEx(HWND hWnd
,
1038 LPCWSTR lpSrcRootPath
,
1043 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
1051 SetupChangeLocale(HWND hWnd
, LCID Lcid
)
1053 return SetupChangeLocaleEx(hWnd
, Lcid
, NULL
, 0, 0, 0);