Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygenstartrec.c
Go to the documentation of this file.
00001 /* 00002 * PROJECT: ReactOS System Control Panel Applet 00003 * LICENSE: GPL - See COPYING in the top level directory 00004 * FILE: dll/cpl/sysdm/startrec.c 00005 * PURPOSE: Computer settings for startup and recovery 00006 * COPYRIGHT: Copyright 2006 Ged Murphy <gedmurphy@gmail.com> 00007 * Copyright 2006 Christoph von Wittich <Christoph@ApiViewer.de> 00008 * Copyright 2007 Johannes Anderwald <johannes dot anderwald at student dot tugraz dot at> 00009 */ 00010 00011 #include "precomp.h" 00012 00013 typedef struct _STARTINFO 00014 { 00015 WCHAR szFreeldrIni[MAX_PATH + 15]; 00016 WCHAR szDumpFile[MAX_PATH]; 00017 WCHAR szMinidumpDir[MAX_PATH]; 00018 DWORD dwCrashDumpEnabled; 00019 INT iFreeLdrIni; 00020 } STARTINFO, *PSTARTINFO; 00021 00022 00023 static VOID 00024 SetTimeout(HWND hwndDlg, INT Timeout) 00025 { 00026 if (Timeout == 0) 00027 { 00028 EnableWindow(GetDlgItem(hwndDlg, IDC_STRRECLISTUPDWN), FALSE); 00029 EnableWindow(GetDlgItem(hwndDlg, IDC_STRRECLISTEDIT), FALSE); 00030 } 00031 else 00032 { 00033 EnableWindow(GetDlgItem(hwndDlg, IDC_STRRECLISTUPDWN), TRUE); 00034 EnableWindow(GetDlgItem(hwndDlg, IDC_STRRECLISTEDIT), TRUE); 00035 } 00036 SendDlgItemMessageW(hwndDlg, IDC_STRRECLISTUPDWN, UDM_SETRANGE, (WPARAM) 0, (LPARAM) MAKELONG((short) 999, 0)); 00037 SendDlgItemMessageW(hwndDlg, IDC_STRRECLISTUPDWN, UDM_SETPOS, (WPARAM) 0, (LPARAM) MAKELONG((short) Timeout, 0)); 00038 } 00039 00040 static VOID 00041 SetRecoveryTimeout(HWND hwndDlg, INT Timeout) 00042 { 00043 if (Timeout == 0) 00044 { 00045 EnableWindow(GetDlgItem(hwndDlg, IDC_STRRECRECUPDWN), FALSE); 00046 EnableWindow(GetDlgItem(hwndDlg, IDC_STRRECRECEDIT), FALSE); 00047 } 00048 else 00049 { 00050 EnableWindow(GetDlgItem(hwndDlg, IDC_STRRECRECUPDWN), TRUE); 00051 EnableWindow(GetDlgItem(hwndDlg, IDC_STRRECRECEDIT), TRUE); 00052 } 00053 SendDlgItemMessageW(hwndDlg, IDC_STRRECRECUPDWN, UDM_SETRANGE, (WPARAM) 0, (LPARAM) MAKELONG((short) 999, 0)); 00054 SendDlgItemMessageW(hwndDlg, IDC_STRRECRECUPDWN, UDM_SETPOS, (WPARAM) 0, (LPARAM) MAKELONG((short) Timeout, 0)); 00055 } 00056 00057 00058 static DWORD 00059 GetSystemDrive(WCHAR **szSystemDrive) 00060 { 00061 DWORD dwBufSize; 00062 00063 /* Get Path to freeldr.ini or boot.ini */ 00064 *szSystemDrive = HeapAlloc(GetProcessHeap(), 0, MAX_PATH * sizeof(WCHAR)); 00065 if (*szSystemDrive != NULL) 00066 { 00067 dwBufSize = GetEnvironmentVariableW(L"SystemDrive", *szSystemDrive, MAX_PATH); 00068 if (dwBufSize > MAX_PATH) 00069 { 00070 WCHAR *szTmp; 00071 DWORD dwBufSize2; 00072 00073 szTmp = HeapReAlloc(GetProcessHeap(), 0, *szSystemDrive, dwBufSize * sizeof(WCHAR)); 00074 if (szTmp == NULL) 00075 goto FailGetSysDrive; 00076 00077 *szSystemDrive = szTmp; 00078 00079 dwBufSize2 = GetEnvironmentVariableW(L"SystemDrive", *szSystemDrive, dwBufSize); 00080 if (dwBufSize2 > dwBufSize || dwBufSize2 == 0) 00081 goto FailGetSysDrive; 00082 } 00083 else if (dwBufSize == 0) 00084 { 00085 FailGetSysDrive: 00086 HeapFree(GetProcessHeap(), 0, *szSystemDrive); 00087 *szSystemDrive = NULL; 00088 return 0; 00089 } 00090 00091 return dwBufSize; 00092 } 00093 00094 return 0; 00095 } 00096 00097 static PBOOTRECORD 00098 ReadFreeldrSection(HINF hInf, WCHAR *szSectionName) 00099 { 00100 PBOOTRECORD pRecord; 00101 INFCONTEXT InfContext; 00102 WCHAR szName[MAX_PATH]; 00103 WCHAR szValue[MAX_PATH]; 00104 DWORD LineLength; 00105 00106 if (!SetupFindFirstLineW(hInf, 00107 szSectionName, 00108 NULL, 00109 &InfContext)) 00110 { 00111 /* Failed to find section */ 00112 return NULL; 00113 } 00114 00115 pRecord = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(BOOTRECORD)); 00116 if (pRecord == NULL) 00117 { 00118 return NULL; 00119 } 00120 00121 wcscpy(pRecord->szSectionName, szSectionName); 00122 00123 do 00124 { 00125 if (!SetupGetStringFieldW(&InfContext, 00126 0, 00127 szName, 00128 sizeof(szName) / sizeof(WCHAR), 00129 &LineLength)) 00130 { 00131 break; 00132 } 00133 00134 if (!SetupGetStringFieldW(&InfContext, 00135 1, 00136 szValue, 00137 sizeof(szValue) / sizeof(WCHAR), 00138 &LineLength)) 00139 { 00140 break; 00141 } 00142 00143 if (!_wcsnicmp(szName, L"BootType", 8)) 00144 { 00145 if (!_wcsnicmp(szValue, L"ReactOS", 7)) 00146 { 00147 // FIXME: Store as enum 00148 pRecord->BootType = 1; 00149 } 00150 else 00151 { 00152 pRecord->BootType = 0; 00153 } 00154 } 00155 else if (!_wcsnicmp(szName, L"SystemPath", 10)) 00156 { 00157 wcscpy(pRecord->szBootPath, szValue); 00158 } 00159 else if (!_wcsnicmp(szName, L"Options", 7)) 00160 { 00161 // FIXME: Store flags as values 00162 wcscpy(pRecord->szOptions, szValue); 00163 } 00164 00165 } 00166 while (SetupFindNextLine(&InfContext, &InfContext)); 00167 00168 return pRecord; 00169 } 00170 00171 00172 static INT 00173 LoadFreeldrSettings(HINF hInf, HWND hwndDlg) 00174 { 00175 INFCONTEXT InfContext; 00176 PBOOTRECORD pRecord; 00177 WCHAR szDefaultOs[MAX_PATH]; 00178 WCHAR szName[MAX_PATH]; 00179 WCHAR szValue[MAX_PATH]; 00180 DWORD LineLength; 00181 DWORD TimeOut; 00182 LRESULT lResult; 00183 00184 if (!SetupFindFirstLineW(hInf, 00185 L"FREELOADER", 00186 L"DefaultOS", 00187 &InfContext)) 00188 { 00189 /* Failed to find default os */ 00190 return FALSE; 00191 } 00192 00193 if (!SetupGetStringFieldW(&InfContext, 00194 1, 00195 szDefaultOs, 00196 sizeof(szDefaultOs) / sizeof(WCHAR), 00197 &LineLength)) 00198 { 00199 /* No key */ 00200 return FALSE; 00201 } 00202 00203 if (!SetupFindFirstLineW(hInf, 00204 L"FREELOADER", 00205 L"TimeOut", 00206 &InfContext)) 00207 { 00208 /* Expected to find timeout value */ 00209 return FALSE; 00210 } 00211 00212 00213 if (!SetupGetIntField(&InfContext, 00214 1, 00215 (PINT)&TimeOut)) 00216 { 00217 /* Failed to retrieve timeout */ 00218 return FALSE; 00219 } 00220 00221 if (!SetupFindFirstLineW(hInf, 00222 L"Operating Systems", 00223 NULL, 00224 &InfContext)) 00225 { 00226 /* Expected list of operating systems */ 00227 return FALSE; 00228 } 00229 00230 do 00231 { 00232 if (!SetupGetStringFieldW(&InfContext, 00233 0, 00234 szName, 00235 sizeof(szName) / sizeof(WCHAR), 00236 &LineLength)) 00237 { 00238 /* The ini file is messed up */ 00239 return FALSE; 00240 } 00241 00242 if (!SetupGetStringFieldW(&InfContext, 00243 1, 00244 szValue, 00245 sizeof(szValue) / sizeof(WCHAR), 00246 &LineLength)) 00247 { 00248 /* The ini file is messed up */ 00249 return FALSE; 00250 } 00251 00252 pRecord = ReadFreeldrSection(hInf, szName); 00253 if (pRecord) 00254 { 00255 lResult = SendDlgItemMessageW(hwndDlg, IDC_STRECOSCOMBO, CB_ADDSTRING, (WPARAM)0, (LPARAM)szValue); 00256 if (lResult != CB_ERR) 00257 { 00258 SendDlgItemMessageW(hwndDlg, IDC_STRECOSCOMBO, CB_SETITEMDATA, (WPARAM)lResult, (LPARAM)pRecord); 00259 if (!wcscmp(szDefaultOs, szName)) 00260 { 00261 /* We store the friendly name as key */ 00262 wcscpy(szDefaultOs, szValue); 00263 } 00264 } 00265 else 00266 { 00267 HeapFree(GetProcessHeap(), 0, pRecord); 00268 } 00269 } 00270 } 00271 while (SetupFindNextLine(&InfContext, &InfContext)); 00272 00273 /* Find default os in list */ 00274 lResult = SendDlgItemMessageW(hwndDlg, IDC_STRECOSCOMBO, CB_FINDSTRING, (WPARAM)-1, (LPARAM)szDefaultOs); 00275 if (lResult != CB_ERR) 00276 { 00277 /* Set cur sel */ 00278 SendDlgItemMessageW(hwndDlg, IDC_STRECOSCOMBO, CB_SETCURSEL, (WPARAM)lResult, (LPARAM)0); 00279 } 00280 00281 if(TimeOut) 00282 { 00283 SendDlgItemMessageW(hwndDlg, IDC_STRECLIST, BM_SETCHECK, (WPARAM)BST_CHECKED, (LPARAM)0); 00284 } 00285 00286 SetTimeout(hwndDlg, TimeOut); 00287 00288 return TRUE; 00289 } 00290 00291 static INT 00292 LoadBootSettings(HINF hInf, HWND hwndDlg) 00293 { 00294 INFCONTEXT InfContext; 00295 WCHAR szName[MAX_PATH]; 00296 WCHAR szValue[MAX_PATH]; 00297 DWORD LineLength; 00298 DWORD TimeOut = 0; 00299 WCHAR szDefaultOS[MAX_PATH]; 00300 WCHAR szOptions[MAX_PATH]; 00301 PBOOTRECORD pRecord; 00302 LRESULT lResult; 00303 00304 if(!SetupFindFirstLineW(hInf, 00305 L"boot loader", 00306 NULL, 00307 &InfContext)) 00308 { 00309 return FALSE; 00310 } 00311 00312 do 00313 { 00314 if (!SetupGetStringFieldW(&InfContext, 00315 0, 00316 szName, 00317 sizeof(szName) / sizeof(WCHAR), 00318 &LineLength)) 00319 { 00320 return FALSE; 00321 } 00322 00323 if (!SetupGetStringFieldW(&InfContext, 00324 1, 00325 szValue, 00326 sizeof(szValue) / sizeof(WCHAR), 00327 &LineLength)) 00328 { 00329 return FALSE; 00330 } 00331 00332 if (!_wcsnicmp(szName, L"timeout", 7)) 00333 { 00334 TimeOut = _wtoi(szValue); 00335 } 00336 00337 if (!_wcsnicmp(szName, L"default", 7)) 00338 { 00339 wcscpy(szDefaultOS, szValue); 00340 } 00341 00342 } 00343 while (SetupFindNextLine(&InfContext, &InfContext)); 00344 00345 if (!SetupFindFirstLineW(hInf, 00346 L"operating systems", 00347 NULL, 00348 &InfContext)) 00349 { 00350 /* Failed to find operating systems section */ 00351 return FALSE; 00352 } 00353 00354 do 00355 { 00356 if (!SetupGetStringFieldW(&InfContext, 00357 0, 00358 szName, 00359 sizeof(szName) / sizeof(WCHAR), 00360 &LineLength)) 00361 { 00362 return FALSE; 00363 } 00364 00365 if (!SetupGetStringFieldW(&InfContext, 00366 1, 00367 szValue, 00368 sizeof(szValue) / sizeof(WCHAR), 00369 &LineLength)) 00370 { 00371 return FALSE; 00372 } 00373 00374 SetupGetStringFieldW(&InfContext, 00375 2, 00376 szOptions, 00377 sizeof(szOptions) / sizeof(WCHAR), 00378 &LineLength); 00379 00380 pRecord = (PBOOTRECORD) HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(BOOTRECORD)); 00381 if (pRecord) 00382 { 00383 pRecord->BootType = 0; 00384 wcscpy(pRecord->szBootPath, szName); 00385 wcscpy(pRecord->szSectionName, szValue); 00386 wcscpy(pRecord->szOptions, szOptions); 00387 00388 if (!wcscmp(szName, szDefaultOS)) 00389 { 00390 /* ms boot ini stores the path not the friendly name */ 00391 wcscpy(szDefaultOS, szValue); 00392 } 00393 00394 lResult = SendDlgItemMessageW(hwndDlg, IDC_STRECOSCOMBO, CB_ADDSTRING, (WPARAM)0, (LPARAM)szValue); 00395 if (lResult != CB_ERR) 00396 { 00397 SendDlgItemMessageW(hwndDlg, IDC_STRECOSCOMBO, CB_SETITEMDATA, (WPARAM)lResult, (LPARAM)pRecord); 00398 } 00399 else 00400 { 00401 HeapFree(GetProcessHeap(), 0, pRecord); 00402 } 00403 } 00404 00405 } 00406 while (SetupFindNextLine(&InfContext, &InfContext)); 00407 00408 /* Find default os in list */ 00409 lResult = SendDlgItemMessageW(hwndDlg, IDC_STRECOSCOMBO, CB_FINDSTRING, (WPARAM)0, (LPARAM)szDefaultOS); 00410 if (lResult != CB_ERR) 00411 { 00412 /* Set cur sel */ 00413 SendDlgItemMessageW(hwndDlg, IDC_STRECOSCOMBO, CB_SETCURSEL, (WPARAM)lResult, (LPARAM)0); 00414 } 00415 00416 if(TimeOut) 00417 { 00418 SendDlgItemMessageW(hwndDlg, IDC_STRECLIST, BM_SETCHECK, (WPARAM)BST_CHECKED, (LPARAM)0); 00419 } 00420 00421 SetTimeout(hwndDlg, TimeOut); 00422 00423 return TRUE; 00424 } 00425 00426 static VOID 00427 DeleteBootRecords(HWND hwndDlg) 00428 { 00429 LRESULT lIndex; 00430 LONG index; 00431 PBOOTRECORD pRecord; 00432 00433 lIndex = SendDlgItemMessageW(hwndDlg, IDC_STRECOSCOMBO, CB_GETCOUNT, (WPARAM)0, (LPARAM)0); 00434 if (lIndex == CB_ERR) 00435 return; 00436 00437 for (index = 0; index <lIndex; index++) 00438 { 00439 pRecord = (PBOOTRECORD) SendDlgItemMessageW(hwndDlg, IDC_STRECOSCOMBO, CB_GETITEMDATA, (WPARAM)index, (LPARAM)0); 00440 if ((INT_PTR)pRecord != CB_ERR) 00441 { 00442 HeapFree(GetProcessHeap(), 0, pRecord); 00443 } 00444 } 00445 00446 SendDlgItemMessageW(hwndDlg, IDC_STRECOSCOMBO, CB_RESETCONTENT, (WPARAM)0, (LPARAM)0); 00447 } 00448 00449 static LRESULT 00450 LoadOSList(HWND hwndDlg, PSTARTINFO pStartInfo) 00451 { 00452 DWORD dwBufSize; 00453 WCHAR *szSystemDrive; 00454 HINF hInf; 00455 00456 dwBufSize = GetSystemDrive(&szSystemDrive); 00457 if (dwBufSize == 0) 00458 return FALSE; 00459 00460 wcscpy(pStartInfo->szFreeldrIni, szSystemDrive); 00461 wcscat(pStartInfo->szFreeldrIni, L"\\freeldr.ini"); 00462 00463 if (PathFileExistsW(pStartInfo->szFreeldrIni)) 00464 { 00465 /* Free resource previously allocated by GetSystemDrive() */ 00466 HeapFree(GetProcessHeap(), 0, szSystemDrive); 00467 /* freeldr.ini exists */ 00468 hInf = SetupOpenInfFileW(pStartInfo->szFreeldrIni, 00469 NULL, 00470 INF_STYLE_OLDNT, 00471 NULL); 00472 00473 if (hInf != INVALID_HANDLE_VALUE) 00474 { 00475 LoadFreeldrSettings(hInf, hwndDlg); 00476 SetupCloseInfFile(hInf); 00477 pStartInfo->iFreeLdrIni = 1; 00478 return TRUE; 00479 } 00480 return FALSE; 00481 } 00482 00483 /* Try loading boot.ini settings */ 00484 wcscpy(pStartInfo->szFreeldrIni, szSystemDrive); 00485 wcscat(pStartInfo->szFreeldrIni, L"\\boot.ini"); 00486 00487 /* Free resource previously allocated by GetSystemDrive() */ 00488 HeapFree(GetProcessHeap(), 0, szSystemDrive); 00489 00490 if (PathFileExistsW(pStartInfo->szFreeldrIni)) 00491 { 00492 /* Load boot.ini settings */ 00493 hInf = SetupOpenInfFileW(pStartInfo->szFreeldrIni, 00494 NULL, 00495 INF_STYLE_OLDNT, 00496 NULL); 00497 00498 if (hInf != INVALID_HANDLE_VALUE) 00499 { 00500 LoadBootSettings(hInf, hwndDlg); 00501 SetupCloseInfFile(hInf); 00502 pStartInfo->iFreeLdrIni = 2; 00503 return TRUE; 00504 } 00505 00506 return FALSE; 00507 } 00508 00509 return FALSE; 00510 } 00511 00512 static VOID 00513 SetCrashDlgItems(HWND hwnd, PSTARTINFO pStartInfo) 00514 { 00515 if (pStartInfo->dwCrashDumpEnabled == 0) 00516 { 00517 /* No crash information required */ 00518 EnableWindow(GetDlgItem(hwnd, IDC_STRRECDUMPFILE), FALSE); 00519 EnableWindow(GetDlgItem(hwnd, IDC_STRRECOVERWRITE), FALSE); 00520 } 00521 else if (pStartInfo->dwCrashDumpEnabled == 3) 00522 { 00523 /* Minidump type */ 00524 EnableWindow(GetDlgItem(hwnd, IDC_STRRECDUMPFILE), TRUE); 00525 EnableWindow(GetDlgItem(hwnd, IDC_STRRECOVERWRITE), FALSE); 00526 SendMessageW(GetDlgItem(hwnd, IDC_STRRECDUMPFILE), WM_SETTEXT, (WPARAM)0, (LPARAM)pStartInfo->szMinidumpDir); 00527 } 00528 else if (pStartInfo->dwCrashDumpEnabled == 1 || pStartInfo->dwCrashDumpEnabled == 2) 00529 { 00530 /* Kernel or complete dump */ 00531 EnableWindow(GetDlgItem(hwnd, IDC_STRRECDUMPFILE), TRUE); 00532 EnableWindow(GetDlgItem(hwnd, IDC_STRRECOVERWRITE), TRUE); 00533 SendMessageW(GetDlgItem(hwnd, IDC_STRRECDUMPFILE), WM_SETTEXT, (WPARAM)0, (LPARAM)pStartInfo->szDumpFile); 00534 } 00535 SendDlgItemMessageW(hwnd, IDC_STRRECDEBUGCOMBO, CB_SETCURSEL, (WPARAM)pStartInfo->dwCrashDumpEnabled, (LPARAM)0); 00536 } 00537 00538 static VOID 00539 WriteStartupRecoveryOptions(HWND hwndDlg, PSTARTINFO pStartInfo) 00540 { 00541 HKEY hKey; 00542 DWORD lResult; 00543 00544 if (RegOpenKeyExW(HKEY_LOCAL_MACHINE, 00545 L"System\\CurrentControlSet\\Control\\CrashControl", 00546 0, 00547 KEY_WRITE, 00548 &hKey) != ERROR_SUCCESS) 00549 { 00550 /* Failed to open key */ 00551 return; 00552 } 00553 00554 lResult = (DWORD) SendDlgItemMessage(hwndDlg, IDC_STRRECWRITEEVENT, BM_GETCHECK, (WPARAM)0, (LPARAM)0); 00555 RegSetValueExW(hKey, L"LogEvent", 0, REG_DWORD, (LPBYTE)&lResult, sizeof(lResult)); 00556 00557 lResult = (DWORD) SendDlgItemMessage(hwndDlg, IDC_STRRECSENDALERT, BM_GETCHECK, (WPARAM)0, (LPARAM)0); 00558 RegSetValueExW(hKey, L"SendAlert", 0, REG_DWORD, (LPBYTE)&lResult, sizeof(lResult)); 00559 00560 lResult = (DWORD) SendDlgItemMessage(hwndDlg, IDC_STRRECRESTART, BM_GETCHECK, (WPARAM)0, (LPARAM)0); 00561 RegSetValueExW(hKey, L"AutoReboot", 0, REG_DWORD, (LPBYTE)&lResult, sizeof(lResult)); 00562 00563 lResult = (DWORD) SendDlgItemMessage(hwndDlg, IDC_STRRECOVERWRITE, BM_GETCHECK, (WPARAM)0, (LPARAM)0); 00564 RegSetValueExW(hKey, L"Overwrite", 0, REG_DWORD, (LPBYTE)&lResult, sizeof(lResult)); 00565 00566 00567 if (pStartInfo->dwCrashDumpEnabled == 1 || pStartInfo->dwCrashDumpEnabled == 2) 00568 { 00569 SendDlgItemMessage(hwndDlg, IDC_STRRECDUMPFILE, WM_GETTEXT, (WPARAM)sizeof(pStartInfo->szDumpFile) / sizeof(WCHAR), (LPARAM)pStartInfo->szDumpFile); 00570 RegSetValueExW(hKey, L"DumpFile", 0, REG_EXPAND_SZ, (LPBYTE)pStartInfo->szDumpFile, (wcslen(pStartInfo->szDumpFile) + 1) * sizeof(WCHAR)); 00571 } 00572 else if (pStartInfo->dwCrashDumpEnabled == 3) 00573 { 00574 SendDlgItemMessage(hwndDlg, IDC_STRRECDUMPFILE, WM_GETTEXT, (WPARAM)sizeof(pStartInfo->szDumpFile) / sizeof(WCHAR), (LPARAM)pStartInfo->szDumpFile); 00575 RegSetValueExW(hKey, L"MinidumpDir", 0, REG_EXPAND_SZ, (LPBYTE)pStartInfo->szDumpFile, (wcslen(pStartInfo->szDumpFile) + 1) * sizeof(WCHAR)); 00576 } 00577 00578 RegSetValueExW(hKey, L"CrashDumpEnabled", 0, REG_DWORD, (LPBYTE)&pStartInfo->dwCrashDumpEnabled, sizeof(pStartInfo->dwCrashDumpEnabled)); 00579 RegCloseKey(hKey); 00580 } 00581 00582 static VOID 00583 LoadRecoveryOptions(HWND hwndDlg, PSTARTINFO pStartInfo) 00584 { 00585 HKEY hKey; 00586 WCHAR szName[MAX_PATH]; 00587 DWORD dwValue, dwValueLength, dwType; 00588 00589 if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, 00590 L"System\\CurrentControlSet\\Control\\CrashControl", 00591 0, 00592 KEY_READ, 00593 &hKey) != ERROR_SUCCESS) 00594 { 00595 /* Failed to open key */ 00596 return; 00597 } 00598 00599 dwValueLength = sizeof(DWORD); 00600 if (RegQueryValueExW(hKey, L"LogEvent", NULL, &dwType, (LPBYTE)&dwValue, &dwValueLength) == ERROR_SUCCESS && dwType == REG_DWORD && dwValue) 00601 SendDlgItemMessageW(hwndDlg, IDC_STRRECWRITEEVENT, BM_SETCHECK, (WPARAM)BST_CHECKED, (LPARAM)0); 00602 00603 dwValueLength = sizeof(DWORD); 00604 if (RegQueryValueExW(hKey, L"SendAlert", NULL, &dwType, (LPBYTE)&dwValue, &dwValueLength) == ERROR_SUCCESS && dwType == REG_DWORD && dwValue) 00605 SendDlgItemMessageW(hwndDlg, IDC_STRRECSENDALERT, BM_SETCHECK, (WPARAM)BST_CHECKED, (LPARAM)0); 00606 00607 dwValueLength = sizeof(DWORD); 00608 if (RegQueryValueExW(hKey, L"AutoReboot", NULL, &dwType, (LPBYTE)&dwValue, &dwValueLength) == ERROR_SUCCESS && dwType == REG_DWORD && dwValue) 00609 SendDlgItemMessageW(hwndDlg, IDC_STRRECRESTART, BM_SETCHECK, (WPARAM)BST_CHECKED, (LPARAM)0); 00610 00611 dwValueLength = sizeof(DWORD); 00612 if (RegQueryValueExW(hKey, L"Overwrite", NULL, &dwType, (LPBYTE)&dwValue, &dwValueLength) == ERROR_SUCCESS && dwType == REG_DWORD && dwValue) 00613 SendDlgItemMessageW(hwndDlg, IDC_STRRECOVERWRITE, BM_SETCHECK, (WPARAM)BST_CHECKED, (LPARAM)0); 00614 00615 dwValueLength = sizeof(DWORD); 00616 if (RegQueryValueExW(hKey, L"CrashDumpEnabled", NULL, &dwType, (LPBYTE)&dwValue, &dwValueLength) == ERROR_SUCCESS && dwType == REG_DWORD && dwValue) 00617 pStartInfo->dwCrashDumpEnabled = dwValue; 00618 00619 dwValueLength = sizeof(pStartInfo->szDumpFile); 00620 if (RegQueryValueExW(hKey, L"DumpFile", NULL, &dwType, (LPBYTE)pStartInfo->szDumpFile, &dwValueLength) != ERROR_SUCCESS) 00621 pStartInfo->szDumpFile[0] = L'\0'; 00622 00623 dwValueLength = sizeof(pStartInfo->szMinidumpDir); 00624 if (RegQueryValueExW(hKey, L"MinidumpDir", NULL, &dwType, (LPBYTE)pStartInfo->szMinidumpDir, &dwValueLength) != ERROR_SUCCESS) 00625 pStartInfo->szMinidumpDir[0] = L'\0'; 00626 00627 if (LoadStringW(hApplet, IDS_NO_DUMP, szName, sizeof(szName) / sizeof(WCHAR))) 00628 { 00629 szName[(sizeof(szName)/sizeof(WCHAR))-1] = L'\0'; 00630 SendDlgItemMessageW(hwndDlg, IDC_STRRECDEBUGCOMBO, CB_ADDSTRING, (WPARAM)0, (LPARAM) szName); 00631 } 00632 00633 if (LoadString(hApplet, IDS_FULL_DUMP, szName, sizeof(szName) / sizeof(WCHAR))) 00634 { 00635 szName[(sizeof(szName)/sizeof(WCHAR))-1] = L'\0'; 00636 SendDlgItemMessageW(hwndDlg, IDC_STRRECDEBUGCOMBO, CB_ADDSTRING, (WPARAM)0, (LPARAM) szName); 00637 } 00638 00639 if (LoadStringW(hApplet, IDS_KERNEL_DUMP, szName, sizeof(szName) / sizeof(WCHAR))) 00640 { 00641 szName[(sizeof(szName)/sizeof(WCHAR))-1] = L'\0'; 00642 SendDlgItemMessageW(hwndDlg, IDC_STRRECDEBUGCOMBO, CB_ADDSTRING, (WPARAM)0, (LPARAM) szName); 00643 } 00644 00645 if (LoadStringW(hApplet, IDS_MINI_DUMP, szName, sizeof(szName) / sizeof(WCHAR))) 00646 { 00647 szName[(sizeof(szName)/sizeof(WCHAR))-1] = L'\0'; 00648 SendDlgItemMessageW(hwndDlg, IDC_STRRECDEBUGCOMBO, CB_ADDSTRING, (WPARAM)0, (LPARAM) szName); 00649 } 00650 00651 SetCrashDlgItems(hwndDlg, pStartInfo); 00652 RegCloseKey(hKey); 00653 } 00654 00655 00656 /* Property page dialog callback */ 00657 INT_PTR CALLBACK 00658 StartRecDlgProc(HWND hwndDlg, 00659 UINT uMsg, 00660 WPARAM wParam, 00661 LPARAM lParam) 00662 { 00663 PSTARTINFO pStartInfo; 00664 PBOOTRECORD pRecord; 00665 int iTimeout; 00666 LRESULT lResult; 00667 WCHAR szTimeout[10]; 00668 00669 UNREFERENCED_PARAMETER(lParam); 00670 00671 pStartInfo = (PSTARTINFO)GetWindowLongPtr(hwndDlg, DWLP_USER); 00672 00673 switch(uMsg) 00674 { 00675 case WM_INITDIALOG: 00676 pStartInfo = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(STARTINFO)); 00677 SetWindowLongPtr(hwndDlg, DWLP_USER, (LONG_PTR)pStartInfo); 00678 00679 LoadRecoveryOptions(hwndDlg, pStartInfo); 00680 SetRecoveryTimeout(hwndDlg, 0); 00681 return LoadOSList(hwndDlg, pStartInfo); 00682 00683 case WM_DESTROY: 00684 DeleteBootRecords(hwndDlg); 00685 HeapFree(GetProcessHeap(), 0, pStartInfo); 00686 break; 00687 00688 case WM_COMMAND: 00689 switch(LOWORD(wParam)) 00690 { 00691 case IDC_STRRECEDIT: 00692 ShellExecuteW(0, L"open", L"notepad", pStartInfo->szFreeldrIni, NULL, SW_SHOWNORMAL); 00693 // FIXME: Use CreateProcess and wait untill finished 00694 // DeleteBootRecords(hwndDlg); 00695 // LoadOSList(hwndDlg); 00696 break; 00697 00698 case IDOK: 00699 /* Save timeout */ 00700 if (SendDlgItemMessage(hwndDlg, IDC_STRECLIST, BM_GETCHECK, (WPARAM)0, (LPARAM)0) == BST_CHECKED) 00701 iTimeout = SendDlgItemMessage(hwndDlg, IDC_STRRECLISTUPDWN, UDM_GETPOS, (WPARAM)0, (LPARAM)0); 00702 else 00703 iTimeout = 0; 00704 swprintf(szTimeout, L"%i", iTimeout); 00705 00706 lResult = SendDlgItemMessageW(hwndDlg, IDC_STRECOSCOMBO, CB_GETCURSEL, (WPARAM)0, (LPARAM)0); 00707 if (lResult == CB_ERR) 00708 { 00709 /* ? */ 00710 DeleteBootRecords(hwndDlg); 00711 return TRUE; 00712 } 00713 00714 pRecord = (PBOOTRECORD) SendDlgItemMessage(hwndDlg, IDC_STRECOSCOMBO, CB_GETITEMDATA, (WPARAM)lResult, (LPARAM)0); 00715 00716 if ((INT_PTR)pRecord != CB_ERR) 00717 { 00718 if (pStartInfo->iFreeLdrIni == 1) // FreeLdrIni style 00719 { 00720 /* Set default timeout */ 00721 WritePrivateProfileStringW(L"FREELOADER", 00722 L"TimeOut", 00723 szTimeout, 00724 pStartInfo->szFreeldrIni); 00725 /* Set default OS */ 00726 WritePrivateProfileStringW(L"FREELOADER", 00727 L"DefaultOS", 00728 pRecord->szSectionName, 00729 pStartInfo->szFreeldrIni); 00730 00731 } 00732 else if (pStartInfo->iFreeLdrIni == 2) // BootIni style 00733 { 00734 /* Set default timeout */ 00735 WritePrivateProfileStringW(L"boot loader", 00736 L"timeout", 00737 szTimeout, 00738 pStartInfo->szFreeldrIni); 00739 /* Set default OS */ 00740 WritePrivateProfileStringW(L"boot loader", 00741 L"default", 00742 pRecord->szBootPath, 00743 pStartInfo->szFreeldrIni); 00744 00745 } 00746 } 00747 00748 WriteStartupRecoveryOptions(hwndDlg, pStartInfo); 00749 EndDialog(hwndDlg, 00750 LOWORD(wParam)); 00751 return TRUE; 00752 00753 case IDCANCEL: 00754 EndDialog(hwndDlg, 00755 LOWORD(wParam)); 00756 return TRUE; 00757 00758 case IDC_STRECLIST: 00759 if (SendDlgItemMessage(hwndDlg, IDC_STRECLIST, BM_GETCHECK, (WPARAM)0, (LPARAM)0) == BST_CHECKED) 00760 SetTimeout(hwndDlg, 30); 00761 else 00762 SetTimeout(hwndDlg, 0); 00763 break; 00764 00765 case IDC_STRRECREC: 00766 if (SendDlgItemMessage(hwndDlg, IDC_STRRECREC, BM_GETCHECK, (WPARAM)0, (LPARAM)0) == BST_CHECKED) 00767 SetRecoveryTimeout(hwndDlg, 30); 00768 else 00769 SetRecoveryTimeout(hwndDlg, 0); 00770 break; 00771 00772 case IDC_STRRECDEBUGCOMBO: 00773 if (HIWORD(wParam) == CBN_SELCHANGE) 00774 { 00775 LRESULT lResult; 00776 00777 lResult = SendDlgItemMessage(hwndDlg, IDC_STRRECDEBUGCOMBO, CB_GETCURSEL, (WPARAM)0, (LPARAM)0); 00778 if (lResult != CB_ERR && lResult != (LRESULT)pStartInfo->dwCrashDumpEnabled) 00779 { 00780 if (pStartInfo->dwCrashDumpEnabled == 1 || pStartInfo->dwCrashDumpEnabled == 2) 00781 { 00782 SendDlgItemMessageW(hwndDlg, IDC_STRRECDUMPFILE, WM_GETTEXT, (WPARAM)sizeof(pStartInfo->szDumpFile) / sizeof(WCHAR), (LPARAM)pStartInfo->szDumpFile); 00783 } 00784 else if (pStartInfo->dwCrashDumpEnabled == 3) 00785 { 00786 SendDlgItemMessageW(hwndDlg, IDC_STRRECDUMPFILE, WM_GETTEXT, (WPARAM)sizeof(pStartInfo->szMinidumpDir) / sizeof(WCHAR), (LPARAM)pStartInfo->szMinidumpDir); 00787 } 00788 00789 pStartInfo->dwCrashDumpEnabled = (DWORD)lResult; 00790 SetCrashDlgItems(hwndDlg, pStartInfo); 00791 } 00792 } 00793 break; 00794 } 00795 break; 00796 } 00797 00798 return FALSE; 00799 } Generated on Thu May 24 2012 04:21:23 for ReactOS by
1.7.6.1
|