diff --git a/dll/win32/syssetup/globals.h b/dll/win32/syssetup/globals.h index 8112102a0b7..2d97f95efdf 100644 --- a/dll/win32/syssetup/globals.h +++ b/dll/win32/syssetup/globals.h @@ -56,7 +56,7 @@ typedef struct _REGISTRATIONNOTIFY #define PM_ITEM_END (WM_APP + 3) /* End of a new Item - wParam = unused + wParam = item number lParam = Error Code */ #define PM_STEP_START (WM_APP + 4) @@ -89,7 +89,14 @@ InstallNetworkComponent( /* security.c */ -VOID InstallSecurity(VOID); +LONG +CountSecuritySteps(VOID); + +DWORD +InstallSecurity( + _In_ PITEMSDATA pItemsData, + _In_ PREGISTRATIONNOTIFY pNotify); + NTSTATUS SetAdministratorPassword(LPCWSTR Password); diff --git a/dll/win32/syssetup/install.c b/dll/win32/syssetup/install.c index 8895e0628c0..875c6ca75f2 100644 --- a/dll/win32/syssetup/install.c +++ b/dll/win32/syssetup/install.c @@ -1640,8 +1640,6 @@ InstallReactOS(VOID) InstallWizard(); - InstallSecurity(); - SetAutoAdminLogon(); SetupCloseInfFile(hSysSetupInf); diff --git a/dll/win32/syssetup/security.c b/dll/win32/syssetup/security.c index bae8bf8660a..1e9cd835ae5 100644 --- a/dll/win32/syssetup/security.c +++ b/dll/win32/syssetup/security.c @@ -234,7 +234,9 @@ SetPrimaryDomain(LPCWSTR DomainName, static VOID -InstallBuiltinAccounts(VOID) +InstallBuiltinAccounts( + _In_ PITEMSDATA pItemsData, + _In_ PREGISTRATIONNOTIFY pNotify) { LPWSTR BuiltinAccounts[] = { L"S-1-1-0", /* Everyone */ @@ -270,6 +272,9 @@ InstallBuiltinAccounts(VOID) for (i = 0; i < ARRAYSIZE(BuiltinAccounts); i++) { + pNotify->Progress++; + SendMessage(pItemsData->hwndDlg, PM_STEP_START, 0, (LPARAM)pNotify); + if (!ConvertStringSidToSid(BuiltinAccounts[i], &AccountSid)) { DPRINT1("ConvertStringSidToSid(%S) failed: %lu\n", BuiltinAccounts[i], GetLastError()); @@ -286,6 +291,8 @@ InstallBuiltinAccounts(VOID) } LocalFree(AccountSid); + + SendMessage(pItemsData->hwndDlg, PM_STEP_END, 0, (LPARAM)pNotify); } LsaClose(PolicyHandle); @@ -295,7 +302,9 @@ InstallBuiltinAccounts(VOID) static VOID InstallPrivileges( - HINF hSecurityInf) + _In_ HINF hSecurityInf, + _In_ PITEMSDATA pItemsData, + _In_ PREGISTRATIONNOTIFY pNotify) { LSA_OBJECT_ATTRIBUTES ObjectAttributes; WCHAR szPrivilegeString[256]; @@ -334,6 +343,9 @@ InstallPrivileges( do { + pNotify->Progress++; + SendMessage(pItemsData->hwndDlg, PM_STEP_START, 0, (LPARAM)pNotify); + /* Retrieve the privilege name */ if (!SetupGetStringFieldW(&InfContext, 0, @@ -427,6 +439,7 @@ InstallPrivileges( } } + SendMessage(pItemsData->hwndDlg, PM_STEP_END, 0, (LPARAM)pNotify); } while (SetupFindNextLine(&InfContext, &InfContext)); @@ -439,7 +452,9 @@ done: static VOID ApplyRegistryValues( - HINF hSecurityInf) + _In_ HINF hSecurityInf, + _In_ PITEMSDATA pItemsData, + _In_ PREGISTRATIONNOTIFY pNotify) { WCHAR szRegistryPath[MAX_PATH]; WCHAR szRootName[MAX_PATH]; @@ -465,7 +480,10 @@ ApplyRegistryValues( do { - /* Retrieve the privilege name */ + pNotify->Progress++; + SendMessage(pItemsData->hwndDlg, PM_STEP_START, 0, (LPARAM)pNotify); + + /* Retrieve the registry path */ if (!SetupGetStringFieldW(&InfContext, 0, szRegistryPath, @@ -630,6 +648,8 @@ ApplyRegistryValues( RegCloseKey(hKey); } + + SendMessage(pItemsData->hwndDlg, PM_STEP_END, 0, (LPARAM)pNotify); } while (SetupFindNextLine(&InfContext, &InfContext)); } @@ -639,6 +659,8 @@ static VOID ApplyEventlogSettings( _In_ HINF hSecurityInf, + _In_ PITEMSDATA pItemsData, + _In_ PREGISTRATIONNOTIFY pNotify, _In_ PWSTR pszSectionName, _In_ PWSTR pszLogName) { @@ -686,6 +708,9 @@ ApplyEventlogSettings( L"MaximumLogSize", &InfContext)) { + pNotify->Progress++; + SendMessage(pItemsData->hwndDlg, PM_STEP_START, 0, (LPARAM)pNotify); + DPRINT("MaximumLogSize\n"); dwValue = 0; SetupGetIntField(&InfContext, @@ -705,6 +730,8 @@ ApplyEventlogSettings( (LPBYTE)&dwValue, sizeof(dwValue)); } + + SendMessage(pItemsData->hwndDlg, PM_STEP_END, 0, (LPARAM)pNotify); } if (SetupFindFirstLineW(hSecurityInf, @@ -712,6 +739,9 @@ ApplyEventlogSettings( L"AuditLogRetentionPeriod", &InfContext)) { + pNotify->Progress++; + SendMessage(pItemsData->hwndDlg, PM_STEP_START, 0, (LPARAM)pNotify); + bValueSet = FALSE; dwValue = 0; SetupGetIntField(&InfContext, @@ -751,6 +781,8 @@ ApplyEventlogSettings( (LPBYTE)&dwValue, sizeof(dwValue)); } + + SendMessage(pItemsData->hwndDlg, PM_STEP_END, 0, (LPARAM)pNotify); } if (SetupFindFirstLineW(hSecurityInf, @@ -758,6 +790,9 @@ ApplyEventlogSettings( L"RestrictGuestAccess", &InfContext)) { + pNotify->Progress++; + SendMessage(pItemsData->hwndDlg, PM_STEP_START, 0, (LPARAM)pNotify); + dwValue = 0; SetupGetIntField(&InfContext, 1, @@ -772,6 +807,8 @@ ApplyEventlogSettings( (LPBYTE)&dwValue, sizeof(dwValue)); } + + SendMessage(pItemsData->hwndDlg, PM_STEP_END, 0, (LPARAM)pNotify); } RegCloseKey(hLogKey); @@ -783,6 +820,8 @@ static VOID ApplyPasswordSettings( _In_ HINF hSecurityInf, + _In_ PITEMSDATA pItemsData, + _In_ PREGISTRATIONNOTIFY pNotify, _In_ PWSTR pszSectionName) { INFCONTEXT InfContext; @@ -1564,9 +1603,51 @@ done: LsaClose(PolicyHandle); } +LONG +CountSecuritySteps(VOID) +{ + HINF hSecurityInf; + PWSTR pszSecurityInf; + LONG Steps = 0; -VOID -InstallSecurity(VOID) +// if (IsServer()) +// pszSecurityInf = L"defltsv.inf"; +// else + pszSecurityInf = L"defltwk.inf"; + + Steps += 10; // InstallBuiltinAccounts(); + + hSecurityInf = SetupOpenInfFileW(pszSecurityInf, + NULL, + INF_STYLE_WIN4, + NULL); + if (hSecurityInf != INVALID_HANDLE_VALUE) + { + /* Count InstallPrivilege steps */ + Steps += SetupGetLineCountW(hSecurityInf, L"Privilege Rights"); + + Steps += SetupGetLineCountW(hSecurityInf, L"Registry Values"); + + Steps += SetupGetLineCountW(hSecurityInf, L"Application Log"); + Steps += SetupGetLineCountW(hSecurityInf, L"Security Log"); + Steps += SetupGetLineCountW(hSecurityInf, L"System Log"); + + Steps += SetupGetLineCountW(hSecurityInf, L"System Access"); + + Steps += SetupGetLineCountW(hSecurityInf, L"Event Audit"); + + SetupCloseInfFile(hSecurityInf); + } + + Steps++; // SetPrimaryDomain + + return Steps; +} + +DWORD +InstallSecurity( + _In_ PITEMSDATA pItemsData, + _In_ PREGISTRATIONNOTIFY pNotify) { HINF hSecurityInf; PWSTR pszSecurityInf; @@ -1576,7 +1657,7 @@ InstallSecurity(VOID) // else pszSecurityInf = L"defltwk.inf"; - InstallBuiltinAccounts(); + InstallBuiltinAccounts(pItemsData, pNotify); hSecurityInf = SetupOpenInfFileW(pszSecurityInf, NULL, @@ -1584,14 +1665,14 @@ InstallSecurity(VOID) NULL); if (hSecurityInf != INVALID_HANDLE_VALUE) { - InstallPrivileges(hSecurityInf); - ApplyRegistryValues(hSecurityInf); + InstallPrivileges(hSecurityInf, pItemsData, pNotify); + ApplyRegistryValues(hSecurityInf, pItemsData, pNotify); - ApplyEventlogSettings(hSecurityInf, L"Application Log", L"Application"); - ApplyEventlogSettings(hSecurityInf, L"Security Log", L"Security"); - ApplyEventlogSettings(hSecurityInf, L"System Log", L"System"); + ApplyEventlogSettings(hSecurityInf, pItemsData, pNotify, L"Application Log", L"Application"); + ApplyEventlogSettings(hSecurityInf, pItemsData, pNotify, L"Security Log", L"Security"); + ApplyEventlogSettings(hSecurityInf, pItemsData, pNotify, L"System Log", L"System"); - ApplyPasswordSettings(hSecurityInf, L"System Access"); + ApplyPasswordSettings(hSecurityInf, pItemsData, pNotify, L"System Access"); ApplyLockoutSettings(hSecurityInf, L"System Access"); ApplyAccountSettings(hSecurityInf, L"System Access"); @@ -1602,6 +1683,8 @@ InstallSecurity(VOID) /* Hack */ SetPrimaryDomain(L"WORKGROUP", NULL); + + return ERROR_SUCCESS; } diff --git a/dll/win32/syssetup/wizard.c b/dll/win32/syssetup/wizard.c index e0744c7fa36..3727af2a9be 100644 --- a/dll/win32/syssetup/wizard.c +++ b/dll/win32/syssetup/wizard.c @@ -2357,6 +2357,31 @@ RegisterComponents( SendMessage(pItemsData->hwndDlg, PM_ITEM_END, 0, Error); } +static +VOID +SaveSettings( + PITEMSDATA pItemsData) +{ + LONG Steps = 0; + DWORD Error = NO_ERROR; + REGISTRATIONNOTIFY Notify; + + ZeroMemory(&Notify, sizeof(Notify)); + + /* Count steps */ + Steps = CountSecuritySteps(); + + /* Start the item */ + DPRINT("Install security: %ld Steps\n", Steps); + SendMessage(pItemsData->hwndDlg, PM_ITEM_START, 2, (LPARAM)Steps); + + /* Install steps */ + Error = InstallSecurity(pItemsData, &Notify); + + /* End the item */ + DPRINT("Install security: done\n"); + SendMessage(pItemsData->hwndDlg, PM_ITEM_END, 2, Error); +} static DWORD @@ -2376,7 +2401,11 @@ ItemCompletionThread( /* Step 1 - Installing start menu items */ InstallStartMenuItems(pItemsData); - /* FIXME: Add completion steps here! */ + /* Step 2 - Saving Settings */ + SaveSettings(pItemsData); + + /* Step 3 - Removing temporary files */ +// RemoveTempFiles(pItemsData); // FIXME: Move this call to a separate cleanup page! RtlCreateBootStatusDataFile(); @@ -2526,9 +2555,7 @@ ProcessPageDlgProc(HWND hwndDlg, /* Save pointer to the global setup data */ SetupData = (PSETUPDATA)((LPPROPSHEETPAGE)lParam)->lParam; SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (DWORD_PTR)SetupData); - ShowWindow(GetDlgItem(hwndDlg, IDC_TASKTEXT3), SW_HIDE); ShowWindow(GetDlgItem(hwndDlg, IDC_TASKTEXT4), SW_HIDE); - ShowWindow(GetDlgItem(hwndDlg, IDC_CHECK3), SW_HIDE); ShowWindow(GetDlgItem(hwndDlg, IDC_CHECK4), SW_HIDE); s_hCheckIcon = LoadImageW(hDllInstance, MAKEINTRESOURCEW(IDI_CHECKICON), IMAGE_ICON, 16, 16, 0); s_hArrowIcon = LoadImageW(hDllInstance, MAKEINTRESOURCEW(IDI_ARROWICON), IMAGE_ICON, 16, 16, 0);