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 *****************************************************************/
38 #include <ndk/cmfuncs.h>
44 CMP_WaitNoPendingInstallEvents(DWORD dwTimeout
);
47 SetupStartService(LPCWSTR lpServiceName
, BOOL bWait
);
49 /* GLOBALS ******************************************************************/
51 HINF hSysSetupInf
= INVALID_HANDLE_VALUE
;
54 /* FUNCTIONS ****************************************************************/
57 FatalError(char *pszFmt
,...)
63 vsprintf(szBuffer
, pszFmt
, ap
);
66 LogItem(SYSSETUP_SEVERITY_FATAL_ERROR
, L
"Failed");
68 strcat(szBuffer
, "\nRebooting now!");
88 WCHAR wszBuf
[MAX_PATH
];
91 HRESULT hr
= CoCreateInstance(&CLSID_ShellLink
, NULL
, CLSCTX_INPROC_SERVER
, &IID_IShellLink
, (LPVOID
*)&psl
);
95 hr
= psl
->lpVtbl
->SetPath(psl
, pszCmd
);
99 hr
= psl
->lpVtbl
->SetArguments(psl
, pszArg
);
104 hr
= psl
->lpVtbl
->SetWorkingDirectory(psl
, pszDir
);
109 hr
= psl
->lpVtbl
->SetIconLocation(psl
, pszIconPath
, iIconNr
);
114 hr
= psl
->lpVtbl
->SetDescription(psl
, pszComment
);
117 hr
= psl
->lpVtbl
->QueryInterface(psl
, &IID_IPersistFile
, (LPVOID
*)&ppf
);
122 hr
= ppf
->lpVtbl
->Save(ppf
, pszLinkPath
, TRUE
);
124 MultiByteToWideChar(CP_ACP
, 0, pszLinkPath
, -1, wszBuf
, MAX_PATH
);
126 hr
= ppf
->lpVtbl
->Save(ppf
, wszBuf
, TRUE
);
127 #endif /* _UNICODE */
129 ppf
->lpVtbl
->Release(ppf
);
132 psl
->lpVtbl
->Release(psl
);
144 LPCTSTR pszDescription
,
147 TCHAR szPath
[MAX_PATH
];
148 TCHAR szExeName
[MAX_PATH
];
150 TCHAR szWorkingDirBuf
[MAX_PATH
];
151 LPTSTR pszWorkingDir
= NULL
;
155 if (ExpandEnvironmentStrings(pszCommand
,
157 sizeof(szPath
) / sizeof(szPath
[0])) == 0)
159 _tcscpy(szPath
, pszCommand
);
162 if ((_taccess(szPath
, 0 )) == -1)
163 /* Expected error, don't return FALSE */
166 dwLen
= GetFullPathName(szPath
,
167 sizeof(szWorkingDirBuf
) / sizeof(szWorkingDirBuf
[0]),
170 if (dwLen
!= 0 && dwLen
<= sizeof(szWorkingDirBuf
) / sizeof(szWorkingDirBuf
[0]))
172 /* Since those should only be called with (.exe) files,
173 lpFilePart has not to be NULL */
174 ASSERT(lpFilePart
!= NULL
);
176 /* Save the file name */
177 _tcscpy(szExeName
, lpFilePart
);
179 /* We're only interested in the path. Cut the file name off.
180 Also remove the trailing backslash unless the working directory
181 is only going to be a drive, ie. C:\ */
182 *(lpFilePart
--) = _T('\0');
183 if (!(lpFilePart
- szWorkingDirBuf
== 2 && szWorkingDirBuf
[1] == _T(':') &&
184 szWorkingDirBuf
[2] == _T('\\')))
186 *lpFilePart
= _T('\0');
189 pszWorkingDir
= szWorkingDirBuf
;
192 _tcscpy(szPath
, pszFolder
);
194 Ptr
= PathAddBackslash(szPath
);
196 _tcscpy(Ptr
, pszName
);
198 // FIXME: we should pass 'command' straight in here, but shell32 doesn't expand it
199 return SUCCEEDED(CreateShellLink(szPath
, szExeName
, _T(""), pszWorkingDir
, szExeName
, iIconNr
, pszDescription
));
203 static BOOL
CreateShortcutsFromSection(HINF hinf
, LPWSTR pszSection
, LPCWSTR pszFolder
)
206 WCHAR szCommand
[MAX_PATH
];
207 WCHAR szName
[MAX_PATH
];
208 WCHAR szDescription
[MAX_PATH
];
211 if (!SetupFindFirstLine(hinf
, pszSection
, NULL
, &Context
))
216 if (SetupGetFieldCount(&Context
) < 4)
219 if (!SetupGetStringFieldW(&Context
, 1, szCommand
, MAX_PATH
, NULL
))
222 if (!SetupGetStringFieldW(&Context
, 2, szName
, MAX_PATH
, NULL
))
225 if (!SetupGetStringFieldW(&Context
, 3, szDescription
, MAX_PATH
, NULL
))
228 if (!SetupGetIntField(&Context
, 4, &iIconNr
))
231 _tcscat(szName
, L
".lnk");
233 CreateShortcut(pszFolder
, szName
, szCommand
, szDescription
, iIconNr
);
235 }while (SetupFindNextLine(&Context
, &Context
));
240 static BOOL
CreateShortcuts(HINF hinf
, LPCWSTR szSection
)
243 WCHAR szPath
[MAX_PATH
];
244 WCHAR szFolder
[MAX_PATH
];
245 WCHAR szFolderSection
[MAX_PATH
];
250 if (!SetupFindFirstLine(hinf
, szSection
, NULL
, &Context
))
255 if (SetupGetFieldCount(&Context
) < 2)
258 if (!SetupGetStringFieldW(&Context
, 0, szFolderSection
, MAX_PATH
, NULL
))
261 if (!SetupGetIntField(&Context
, 1, &csidl
))
264 if (!SetupGetStringFieldW(&Context
, 2, szFolder
, MAX_PATH
, NULL
))
267 if (FAILED(SHGetFolderPathAndSubDirW(NULL
, csidl
|CSIDL_FLAG_CREATE
, (HANDLE
)-1, SHGFP_TYPE_DEFAULT
, szFolder
, szPath
)))
270 CreateShortcutsFromSection(hinf
, szFolderSection
, szPath
);
272 }while (SetupFindNextLine(&Context
, &Context
));
283 WCHAR szTempDir
[MAX_PATH
];
284 WCHAR szBuffer
[MAX_PATH
];
288 if (RegOpenKeyExW(HKEY_LOCAL_MACHINE
,
289 L
"SYSTEM\\CurrentControlSet\\Control\\Session Manager\\Environment",
292 &hKey
) != ERROR_SUCCESS
)
294 FatalError("Error: %lu\n", GetLastError());
299 dwLength
= MAX_PATH
* sizeof(WCHAR
);
300 if (RegQueryValueExW(hKey
,
305 &dwLength
) != ERROR_SUCCESS
)
307 FatalError("Error: %lu\n", GetLastError());
312 if (!ExpandEnvironmentStringsW(szBuffer
,
316 FatalError("Error: %lu\n", GetLastError());
320 /* Create profiles directory */
321 if (!CreateDirectoryW(szTempDir
, NULL
))
323 if (GetLastError() != ERROR_ALREADY_EXISTS
)
325 FatalError("Error: %lu\n", GetLastError());
335 InstallSysSetupInfDevices(VOID
)
337 INFCONTEXT InfContext
;
338 WCHAR szLineBuffer
[256];
341 if (!SetupFindFirstLineW(hSysSetupInf
,
342 L
"DeviceInfsToInstall",
351 if (!SetupGetStringFieldW(&InfContext
,
354 sizeof(szLineBuffer
)/sizeof(szLineBuffer
[0]),
360 if (!SetupDiInstallClassW(NULL
, szLineBuffer
, DI_QUIETINSTALL
, NULL
))
365 while (SetupFindNextLine(&InfContext
, &InfContext
));
371 InstallSysSetupInfComponents(VOID
)
373 INFCONTEXT InfContext
;
374 WCHAR szNameBuffer
[256];
375 WCHAR szSectionBuffer
[256];
376 HINF hComponentInf
= INVALID_HANDLE_VALUE
;
378 if (!SetupFindFirstLineW(hSysSetupInf
,
383 DPRINT("No Inf.Always section found\n");
389 if (!SetupGetStringFieldW(&InfContext
,
390 1, // Get the component name
392 sizeof(szNameBuffer
)/sizeof(szNameBuffer
[0]),
395 FatalError("Error while trying to get component name \n");
399 if (!SetupGetStringFieldW(&InfContext
,
400 2, // Get the component install section
402 sizeof(szSectionBuffer
)/sizeof(szSectionBuffer
[0]),
405 FatalError("Error while trying to get component install section \n");
409 DPRINT("Trying to execute install section '%S' from '%S' \n", szSectionBuffer
, szNameBuffer
);
411 hComponentInf
= SetupOpenInfFileW(szNameBuffer
,
416 if (hComponentInf
== INVALID_HANDLE_VALUE
)
418 FatalError("SetupOpenInfFileW() failed to open '%S' (Error: %lu)\n", szNameBuffer
, GetLastError());
422 if (!SetupInstallFromInfSectionW(NULL
,
429 SetupDefaultQueueCallbackW
,
434 FatalError("Error while trying to install : %S (Error: %lu)\n", szNameBuffer
, GetLastError());
435 SetupCloseInfFile(hComponentInf
);
439 SetupCloseInfFile(hComponentInf
);
441 while (SetupFindNextLine(&InfContext
, &InfContext
));
451 RegisterTypeLibraries (HINF hinf
, LPCWSTR szSection
)
453 INFCONTEXT InfContext
;
455 WCHAR szName
[MAX_PATH
];
456 WCHAR szPath
[MAX_PATH
];
462 /* Begin iterating the entries in the inf section */
463 res
= SetupFindFirstLine(hinf
, szSection
, NULL
, &InfContext
);
464 if (!res
) return FALSE
;
468 /* Get the name of the current type library */
469 if (!SetupGetStringFieldW(&InfContext
, 1, szName
, MAX_PATH
, NULL
))
471 FatalError("SetupGetStringFieldW failed\n");
475 if (!SetupGetIntField(&InfContext
, 2, &csidl
))
476 csidl
= CSIDL_SYSTEM
;
478 hret
= SHGetFolderPathW(NULL
, csidl
, NULL
, 0, szPath
);
481 FatalError("SHGetFolderPathW failed hret=0x%lx\n", hret
);
485 p
= PathAddBackslash(szPath
);
488 hmod
= LoadLibraryW(szName
);
491 FatalError("LoadLibraryW failed\n");
495 __wine_register_resources(hmod
);
497 }while (SetupFindNextLine(&InfContext
, &InfContext
));
503 EnableUserModePnpManager(VOID
)
505 SC_HANDLE hSCManager
= NULL
;
506 SC_HANDLE hService
= NULL
;
509 hSCManager
= OpenSCManagerW(NULL
, NULL
, SC_MANAGER_ENUMERATE_SERVICE
);
510 if (hSCManager
== NULL
)
512 DPRINT1("Unable to open the service control manager.\n");
513 DPRINT1("Last Error %d\n", GetLastError());
517 hService
= OpenServiceW(hSCManager
,
519 SERVICE_CHANGE_CONFIG
| SERVICE_START
);
520 if (hService
== NULL
)
522 DPRINT1("Unable to open PlugPlay service\n");
526 bRet
= ChangeServiceConfigW(hService
,
531 NULL
, NULL
, NULL
, NULL
);
534 DPRINT1("Unable to change the service configuration\n");
538 bRet
= StartServiceW(hService
, 0, NULL
);
539 if (!bRet
&& (GetLastError() != ERROR_SERVICE_ALREADY_RUNNING
))
541 DPRINT1("Unable to start service\n");
548 if (hService
!= NULL
)
549 CloseServiceHandle(hService
);
550 if (hSCManager
!= NULL
)
551 CloseServiceHandle(hSCManager
);
555 static INT_PTR CALLBACK
556 StatusMessageWindowProc(
562 UNREFERENCED_PARAMETER(wParam
);
570 if (!LoadStringW(hDllInstance
, IDS_STATUS_INSTALL_DEV
, szMsg
, sizeof(szMsg
)/sizeof(szMsg
[0])))
572 SetDlgItemTextW(hwndDlg
, IDC_STATUSLABEL
, szMsg
);
580 ShowStatusMessageThread(
581 IN LPVOID lpParameter
)
583 HWND
*phWnd
= (HWND
*)lpParameter
;
587 hWnd
= CreateDialogParam(
589 MAKEINTRESOURCE(IDD_STATUSWINDOW_DLG
),
591 StatusMessageWindowProc
,
597 ShowWindow(hWnd
, SW_SHOW
);
599 /* Message loop for the Status window */
600 while (GetMessage(&Msg
, NULL
, 0, 0))
602 TranslateMessage(&Msg
);
603 DispatchMessage(&Msg
);
621 return ERROR_INVALID_PARAMETER
;
624 rc
= RegQueryValueExW(hKey
, pszKey
, NULL
, &dwType
, NULL
, &cbData
);
625 if (rc
!= ERROR_SUCCESS
)
627 if (dwType
!= REG_SZ
)
628 return ERROR_FILE_NOT_FOUND
;
629 pwszValue
= HeapAlloc(GetProcessHeap(), 0, cbData
+ sizeof(WCHAR
));
631 return ERROR_NOT_ENOUGH_MEMORY
;
632 rc
= RegQueryValueExW(hKey
, pszKey
, NULL
, NULL
, (LPBYTE
)pwszValue
, &cbData
);
633 if (rc
!= ERROR_SUCCESS
)
635 HeapFree(GetProcessHeap(), 0, pwszValue
);
638 /* NULL-terminate the string */
639 pwszValue
[cbData
/ sizeof(WCHAR
)] = '\0';
642 return ERROR_SUCCESS
;
648 HKEY hControlKey
= NULL
;
649 LPWSTR pwszSystemStartOptions
= NULL
;
650 LPWSTR pwszCurrentOption
, pwszNextOption
; /* Pointers into SystemStartOptions */
651 BOOL bConsoleBoot
= FALSE
;
656 L
"SYSTEM\\CurrentControlSet\\Control",
660 if (rc
!= ERROR_SUCCESS
)
663 rc
= ReadRegSzKey(hControlKey
, L
"SystemStartOptions", &pwszSystemStartOptions
);
664 if (rc
!= ERROR_SUCCESS
)
667 /* Check for CONSOLE switch in SystemStartOptions */
668 pwszCurrentOption
= pwszSystemStartOptions
;
669 while (pwszCurrentOption
)
671 pwszNextOption
= wcschr(pwszCurrentOption
, L
' ');
673 *pwszNextOption
= L
'\0';
674 if (wcsicmp(pwszCurrentOption
, L
"CONSOLE") == 0)
676 DPRINT("Found %S. Switching to console boot\n", pwszCurrentOption
);
680 pwszCurrentOption
= pwszNextOption
? pwszNextOption
+ 1 : NULL
;
684 if (hControlKey
!= NULL
)
685 RegCloseKey(hControlKey
);
686 if (pwszSystemStartOptions
)
687 HeapFree(GetProcessHeap(), 0, pwszSystemStartOptions
);
696 hSysSetupInf
= SetupOpenInfFileW(
701 if (hSysSetupInf
== INVALID_HANDLE_VALUE
)
703 FatalError("SetupOpenInfFileW() failed to open 'syssetup.inf' (Error: %lu)\n", GetLastError());
707 if (!InstallSysSetupInfDevices())
709 FatalError("InstallSysSetupInfDevices() failed!\n");
713 if(!InstallSysSetupInfComponents())
715 FatalError("InstallSysSetupInfComponents() failed!\n");
719 if (!IsConsoleBoot())
723 hThread
= CreateThread(
726 ShowStatusMessageThread
,
732 CloseHandle(hThread
);
735 if (!EnableUserModePnpManager())
737 FatalError("EnableUserModePnpManager() failed!\n");
741 if (CMP_WaitNoPendingInstallEvents(INFINITE
) != WAIT_OBJECT_0
)
743 FatalError("CMP_WaitNoPendingInstallEvents() failed!\n");
753 SetupCloseInfFile(hSysSetupInf
);
758 InstallLiveCD(IN HINSTANCE hInstance
)
760 STARTUPINFOW StartupInfo
;
761 PROCESS_INFORMATION ProcessInformation
;
764 if (!CommonInstall())
767 /* Register components */
770 if (!SetupInstallFromInfSectionW(NULL
,
771 hSysSetupInf
, L
"RegistrationPhase2",
773 0, NULL
, 0, NULL
, NULL
, NULL
, NULL
))
775 DPRINT1("SetupInstallFromInfSectionW failed!\n");
778 RegisterTypeLibraries(hSysSetupInf
, L
"TypeLibraries");
780 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
782 DPRINT1("Catching exception\n");
786 SetupCloseInfFile(hSysSetupInf
);
789 ZeroMemory(&StartupInfo
, sizeof(StartupInfo
));
790 StartupInfo
.cb
= sizeof(StartupInfo
);
791 bRes
= CreateProcessW(
801 &ProcessInformation
);
805 CloseHandle(ProcessInformation
.hThread
);
806 CloseHandle(ProcessInformation
.hProcess
);
813 L
"Failed to load LiveCD! You can shutdown your computer, or press ENTER to reboot.",
821 SetSetupType(DWORD dwSetupType
)
826 dwError
= RegOpenKeyExW(
832 if (dwError
!= ERROR_SUCCESS
)
835 dwError
= RegSetValueExW(
840 (LPBYTE
)&dwSetupType
,
843 if (dwError
!= ERROR_SUCCESS
)
849 /* Install a section of a .inf file
850 * Returns TRUE if success, FALSE if failure. Error code can
851 * be retrieved with GetLastError()
858 IN LPCWSTR InfSection OPTIONAL
,
859 IN LPCWSTR InfService OPTIONAL
)
861 WCHAR Buffer
[MAX_PATH
];
862 HINF hInf
= INVALID_HANDLE_VALUE
;
864 PVOID Context
= NULL
;
867 /* Get Windows directory */
868 BufferSize
= MAX_PATH
- 5 - wcslen(InfFile
);
869 if (GetWindowsDirectoryW(Buffer
, BufferSize
) > BufferSize
)
871 /* Function failed */
872 SetLastError(ERROR_GEN_FAILURE
);
875 /* We have enough space to add some information in the buffer */
876 if (Buffer
[wcslen(Buffer
) - 1] != '\\')
877 wcscat(Buffer
, L
"\\");
878 wcscat(Buffer
, L
"Inf\\");
879 wcscat(Buffer
, InfFile
);
881 /* Install specified section */
882 hInf
= SetupOpenInfFileW(Buffer
, NULL
, INF_STYLE_WIN4
, NULL
);
883 if (hInf
== INVALID_HANDLE_VALUE
)
886 Context
= SetupInitDefaultQueueCallback(hWnd
);
891 if (ret
&& InfSection
)
893 ret
= SetupInstallFromInfSectionW(
895 InfSection
, SPINST_ALL
,
896 NULL
, NULL
, SP_COPY_NEWER
,
897 SetupDefaultQueueCallbackW
, Context
,
900 if (ret
&& InfService
)
902 ret
= SetupInstallServicesFromInfSectionW(
903 hInf
, InfService
, 0);
908 SetupTermDefaultQueueCallback(Context
);
909 if (hInf
!= INVALID_HANDLE_VALUE
)
910 SetupCloseInfFile(hInf
);
914 static DWORD CALLBACK
915 HotkeyThread(LPVOID Parameter
)
920 DPRINT("HotkeyThread start\n");
922 hotkey
= GlobalAddAtomW(L
"Setup Shift+F10 Hotkey");
924 if (!RegisterHotKey(NULL
, hotkey
, MOD_SHIFT
, VK_F10
))
925 DPRINT1("RegisterHotKey failed with %lu\n", GetLastError());
927 while (GetMessage(&msg
, NULL
, 0, 0))
929 if (msg
.hwnd
== NULL
&& msg
.message
== WM_HOTKEY
&& msg
.wParam
== hotkey
)
931 STARTUPINFOW si
= { sizeof(si
) };
932 PROCESS_INFORMATION pi
;
934 if (CreateProcessW(L
"cmd.exe",
945 CloseHandle(pi
.hProcess
);
946 CloseHandle(pi
.hThread
);
950 DPRINT1("Failed to launch command prompt: %lu\n", GetLastError());
955 UnregisterHotKey(NULL
, hotkey
);
956 GlobalDeleteAtom(hotkey
);
958 DPRINT("HotkeyThread terminate\n");
963 InstallReactOS(HINSTANCE hInstance
)
965 TCHAR szBuffer
[MAX_PATH
];
967 TOKEN_PRIVILEGES privs
;
970 HANDLE hHotkeyThread
;
973 InitializeSetupActionLog(FALSE
);
974 LogItem(SYSSETUP_SEVERITY_INFORMATION
, L
"Installing ReactOS");
976 if (!InitializeProfiles())
978 FatalError("InitializeProfiles() failed");
982 CreateTempDir(L
"TEMP");
983 CreateTempDir(L
"TMP");
985 if (GetWindowsDirectory(szBuffer
, sizeof(szBuffer
) / sizeof(TCHAR
)))
987 if (RegOpenKeyExW(HKEY_LOCAL_MACHINE
,
988 L
"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion",
991 &hKey
) == ERROR_SUCCESS
)
998 (wcslen(szBuffer
) + 1) * sizeof(WCHAR
));
1000 RegSetValueExW(hKey
,
1005 (wcslen(szBuffer
) + 1) * sizeof(WCHAR
));
1010 PathAddBackslash(szBuffer
);
1011 _tcscat(szBuffer
, _T("system"));
1012 CreateDirectory(szBuffer
, NULL
);
1015 hHotkeyThread
= CreateThread(NULL
, 0, HotkeyThread
, NULL
, 0, NULL
);
1017 /* Hack: Install TCP/IP protocol driver */
1018 ret
= InstallInfSection(NULL
,
1020 L
"MS_TCPIP.PrimaryInstall",
1021 L
"MS_TCPIP.PrimaryInstall.Services");
1022 if (!ret
&& GetLastError() != ERROR_FILE_NOT_FOUND
)
1024 DPRINT("InstallInfSection() failed with error 0x%lx\n", GetLastError());
1028 /* Start the TCP/IP protocol driver */
1029 SetupStartService(L
"Tcpip", FALSE
);
1033 if (!CommonInstall())
1040 SetAutoAdminLogon();
1042 hShortcutsInf
= SetupOpenInfFileW(L
"shortcuts.inf",
1046 if (hShortcutsInf
== INVALID_HANDLE_VALUE
)
1048 FatalError("Failed to open shortcuts.inf");
1052 if (!CreateShortcuts(hShortcutsInf
, L
"ShortcutFolders"))
1054 FatalError("CreateShortcuts() failed");
1058 SetupCloseInfFile(hShortcutsInf
);
1060 /* ROS HACK, as long as NtUnloadKey is not implemented */
1062 NTSTATUS Status
= NtUnloadKey(NULL
);
1063 if (Status
== STATUS_NOT_IMPLEMENTED
)
1065 /* Create the Administrator profile */
1066 PROFILEINFOW ProfileInfo
;
1070 ret
= LogonUserW(AdminInfo
.Name
,
1073 LOGON32_LOGON_INTERACTIVE
,
1074 LOGON32_PROVIDER_DEFAULT
,
1078 FatalError("LogonUserW() failed!");
1081 ZeroMemory(&ProfileInfo
, sizeof(PROFILEINFOW
));
1082 ProfileInfo
.dwSize
= sizeof(PROFILEINFOW
);
1083 ProfileInfo
.lpUserName
= L
"Administrator";
1084 ProfileInfo
.dwFlags
= PI_NOUI
;
1085 LoadUserProfileW(hToken
, &ProfileInfo
);
1086 CloseHandle(hToken
);
1090 DPRINT1("ROS HACK not needed anymore. Please remove it\n");
1093 /* END OF ROS HACK */
1095 SetupCloseInfFile(hSysSetupInf
);
1100 PostThreadMessage(GetThreadId(hHotkeyThread
), WM_QUIT
, 0, 0);
1101 CloseHandle(hHotkeyThread
);
1104 LogItem(SYSSETUP_SEVERITY_INFORMATION
, L
"Installing ReactOS done");
1105 TerminateSetupActionLog();
1107 if (AdminInfo
.Name
!= NULL
)
1108 RtlFreeHeap(RtlGetProcessHeap(), 0, AdminInfo
.Name
);
1110 if (AdminInfo
.Domain
!= NULL
)
1111 RtlFreeHeap(RtlGetProcessHeap(), 0, AdminInfo
.Domain
);
1113 if (AdminInfo
.Password
!= NULL
)
1114 RtlFreeHeap(RtlGetProcessHeap(), 0, AdminInfo
.Password
);
1116 /* Get shutdown privilege */
1117 if (!OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES
, &token
))
1119 FatalError("OpenProcessToken() failed!");
1122 if (!LookupPrivilegeValue(
1125 &privs
.Privileges
[0].Luid
))
1127 FatalError("LookupPrivilegeValue() failed!");
1130 privs
.PrivilegeCount
= 1;
1131 privs
.Privileges
[0].Attributes
= SE_PRIVILEGE_ENABLED
;
1132 if (AdjustTokenPrivileges(
1137 (PTOKEN_PRIVILEGES
)NULL
,
1140 FatalError("AdjustTokenPrivileges() failed!");
1144 ExitWindowsEx(EWX_REBOOT
, 0);
1153 SetupChangeFontSize(
1155 IN LPCWSTR lpszFontSize
)
1157 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
1165 SetupChangeLocaleEx(HWND hWnd
,
1167 LPCWSTR lpSrcRootPath
,
1172 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
1180 SetupChangeLocale(HWND hWnd
, LCID Lcid
)
1182 return SetupChangeLocaleEx(hWnd
, Lcid
, NULL
, 0, 0, 0);
1189 LPCWSTR lpServiceName
,
1192 SC_HANDLE hManager
= NULL
;
1193 SC_HANDLE hService
= NULL
;
1194 DWORD dwError
= ERROR_SUCCESS
;
1196 hManager
= OpenSCManagerW(NULL
,
1198 SC_MANAGER_ALL_ACCESS
);
1199 if (hManager
== NULL
)
1201 dwError
= GetLastError();
1205 hService
= OpenServiceW(hManager
,
1208 if (hService
== NULL
)
1210 dwError
= GetLastError();
1214 if (!StartService(hService
, 0, NULL
))
1216 dwError
= GetLastError();
1221 if (hService
!= NULL
)
1222 CloseServiceHandle(hService
);
1224 if (hManager
!= NULL
)
1225 CloseServiceHandle(hManager
);