diff --git a/base/system/userinit/livecd.c b/base/system/userinit/livecd.c index 86d3eb70fc2..57b031a716b 100644 --- a/base/system/userinit/livecd.c +++ b/base/system/userinit/livecd.c @@ -11,6 +11,13 @@ HWND hList; HWND hLocaleList; BOOL bSpain = FALSE; +typedef struct _LIVECD_UNATTEND +{ + BOOL bEnabled; + LCID LocaleID; +} LIVECD_UNATTEND; + + /* * Taken and adapted from dll/cpl/sysdm/general.c */ @@ -158,6 +165,7 @@ LocalesEnumProc(LPTSTR lpLocale) if (!IsValidLocale(lcid, LCID_INSTALLED)) return TRUE; + // See http://archives.miloush.net/michkap/archive/2006/09/23/768178.html for why we handle spain differently if (lcid == MAKELCID(MAKELANGID(LANG_SPANISH, SUBLANG_SPANISH), SORT_DEFAULT) || lcid == MAKELCID(MAKELANGID(LANG_SPANISH, SUBLANG_SPANISH_MODERN), SORT_DEFAULT)) { @@ -194,17 +202,25 @@ LocalesEnumProc(LPTSTR lpLocale) static VOID -CreateLanguagesList(HWND hwnd) +CreateLanguagesList(HWND hwnd, PSTATE pState) { WCHAR langSel[255]; + LCID Locale = 0; hList = hwnd; bSpain = FALSE; EnumSystemLocalesW(LocalesEnumProc, LCID_SUPPORTED); - /* Select current locale */ - /* or should it be System and not user? */ - GetLocaleInfoW(GetUserDefaultLCID(), LOCALE_SLANGUAGE, langSel, ARRAYSIZE(langSel)); + if (pState->Unattend->bEnabled) + Locale = pState->Unattend->LocaleID; + + if (!Locale) + { + /* Select current locale */ + /* or should it be System and not user? */ + Locale = GetUserDefaultLCID(); + } + GetLocaleInfoW(Locale, LOCALE_SLANGUAGE, langSel, ARRAYSIZE(langSel)); SendMessageW(hList, CB_SELECTSTRING, @@ -618,8 +634,13 @@ LocaleDlgProc( CenterWindow(hwndDlg); /* Fill the language and keyboard layout lists */ - CreateLanguagesList(GetDlgItem(hwndDlg, IDC_LANGUAGELIST)); + CreateLanguagesList(GetDlgItem(hwndDlg, IDC_LANGUAGELIST), pState); CreateKeyboardLayoutList(GetDlgItem(hwndDlg, IDC_LAYOUTLIST)); + if (pState->Unattend->bEnabled) + { + // Advance to the next page + PostMessageW(hwndDlg, WM_COMMAND, MAKELONG(IDOK, BN_CLICKED), 0L); + } return FALSE; case WM_DRAWITEM: @@ -746,6 +767,13 @@ StartDlgProc( /* Center the dialog window */ CenterWindow(hwndDlg); + + if (pState->Unattend->bEnabled) + { + // Click on the 'Run' button + PostMessageW(hwndDlg, WM_COMMAND, MAKELONG(IDC_RUN, BN_CLICKED), 0L); + } + return FALSE; case WM_DRAWITEM: @@ -805,13 +833,59 @@ StartDlgProc( return FALSE; } +VOID ParseUnattend(LPCWSTR UnattendInf, LIVECD_UNATTEND* pUnattend) +{ + WCHAR Buffer[MAX_PATH]; + + pUnattend->bEnabled = FALSE; + + if (!GetPrivateProfileStringW(L"Unattend", L"Signature", L"", Buffer, _countof(Buffer), UnattendInf)) + { + ERR("Unable to parse Signature\n"); + return; + } + + if (_wcsicmp(Buffer, L"$ReactOS$") && _wcsicmp(Buffer, L"$Windows NT$")) + { + TRACE("Unknown signature: %S\n", Buffer); + return; + } + + if (!GetPrivateProfileStringW(L"Unattend", L"UnattendSetupEnabled", L"", Buffer, _countof(Buffer), UnattendInf)) + { + ERR("Unable to parse UnattendSetupEnabled\n"); + return; + } + + if (_wcsicmp(Buffer, L"yes")) + { + TRACE("Unattended setup is not enabled\n", Buffer); + return; + } + + pUnattend->bEnabled = TRUE; + pUnattend->LocaleID = 0; + + if (GetPrivateProfileStringW(L"Unattend", L"LocaleID", L"", Buffer, _countof(Buffer), UnattendInf) && Buffer[0]) + { + pUnattend->LocaleID = wcstol(Buffer, NULL, 16); + } +} VOID RunLiveCD( PSTATE pState) { + LIVECD_UNATTEND Unattend = {0}; + WCHAR UnattendInf[MAX_PATH]; + InitLogo(&pState->ImageInfo, NULL); + GetWindowsDirectoryW(UnattendInf, _countof(UnattendInf)); + wcscat(UnattendInf, L"\\unattend.inf"); + ParseUnattend(UnattendInf, &Unattend); + pState->Unattend = &Unattend; + while (pState->NextPage != DONE) { switch (pState->NextPage) diff --git a/base/system/userinit/userinit.h b/base/system/userinit/userinit.h index 46079756a6c..c34f287d09c 100644 --- a/base/system/userinit/userinit.h +++ b/base/system/userinit/userinit.h @@ -58,6 +58,7 @@ typedef struct PAGESTATE NextPage; RUN Run; IMGINFO ImageInfo; + struct _LIVECD_UNATTEND* Unattend; } STATE, *PSTATE; diff --git a/boot/bootdata/CMakeLists.txt b/boot/bootdata/CMakeLists.txt index fd5696b46fe..f1e6153f8a7 100644 --- a/boot/bootdata/CMakeLists.txt +++ b/boot/bootdata/CMakeLists.txt @@ -62,6 +62,7 @@ add_cd_file(FILE ${CMAKE_CURRENT_SOURCE_DIR}/hybridcd.ini DESTINATION root NAME_ # Unattend add_cd_file(FILE ${CMAKE_CURRENT_SOURCE_DIR}/bootcdregtest/unattend.inf DESTINATION reactos NO_CAB FOR regtest) add_cd_file(FILE ${CMAKE_CURRENT_SOURCE_DIR}/bootcd/unattend.inf DESTINATION reactos NO_CAB FOR bootcd) +add_cd_file(FILE ${CMAKE_CURRENT_SOURCE_DIR}/livecd/unattend.inf DESTINATION reactos NO_CAB FOR livecd) # LiveCD shortcuts macro(add_livecd_shortcut name app dest) diff --git a/boot/bootdata/livecd/.keep b/boot/bootdata/livecd/.keep deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/boot/bootdata/livecd/unattend.inf b/boot/bootdata/livecd/unattend.inf new file mode 100644 index 00000000000..9336b0ff791 --- /dev/null +++ b/boot/bootdata/livecd/unattend.inf @@ -0,0 +1,13 @@ +[Unattend] +Signature = "$ReactOS$" + +; Set UnattendSetupEnabled to yes in order to boot the livecd immediately to desktop +; yes - unattend setup enabled +; no - unattend setup disabled +UnattendSetupEnabled = no + +; set this option to automatically +; specify language in the language setup +; see hivesys.inf for available languages +LocaleID = 409 +