2 * PROJECT: ReactOS System Control Panel Applet
3 * LICENSE: GPL - See COPYING in the top level directory
4 * FILE: dll/cpl/sysdm/startrec.c
5 * PURPOSE: Computer settings for startup and recovery
6 * COPYRIGHT: Copyright 2006 Ged Murphy <gedmurphy@gmail.com>
7 * Copyright 2006 Christoph von Wittich <Christoph@ApiViewer.de>
8 * Copyright 2007 Johannes Anderwald <johannes.anderwald@reactos.org>
15 typedef struct _STARTINFO
17 WCHAR szFreeldrIni
[MAX_PATH
+ 15];
18 WCHAR szDumpFile
[MAX_PATH
];
19 WCHAR szMinidumpDir
[MAX_PATH
];
20 DWORD dwCrashDumpEnabled
;
22 } STARTINFO
, *PSTARTINFO
;
24 BOOL SaveRecoveryOptions
;
27 SetTimeout(HWND hwndDlg
, INT Timeout
)
31 EnableWindow(GetDlgItem(hwndDlg
, IDC_STRRECLISTUPDWN
), FALSE
);
32 EnableWindow(GetDlgItem(hwndDlg
, IDC_STRRECLISTEDIT
), FALSE
);
36 EnableWindow(GetDlgItem(hwndDlg
, IDC_STRRECLISTUPDWN
), TRUE
);
37 EnableWindow(GetDlgItem(hwndDlg
, IDC_STRRECLISTEDIT
), TRUE
);
39 SendDlgItemMessageW(hwndDlg
, IDC_STRRECLISTUPDWN
, UDM_SETRANGE
, (WPARAM
) 0, (LPARAM
) MAKELONG((short) 999, 0));
40 SendDlgItemMessageW(hwndDlg
, IDC_STRRECLISTUPDWN
, UDM_SETPOS
, (WPARAM
) 0, (LPARAM
) MAKELONG((short) Timeout
, 0));
44 SetRecoveryTimeout(HWND hwndDlg
, INT Timeout
)
48 EnableWindow(GetDlgItem(hwndDlg
, IDC_STRRECRECUPDWN
), FALSE
);
49 EnableWindow(GetDlgItem(hwndDlg
, IDC_STRRECRECEDIT
), FALSE
);
53 EnableWindow(GetDlgItem(hwndDlg
, IDC_STRRECRECUPDWN
), TRUE
);
54 EnableWindow(GetDlgItem(hwndDlg
, IDC_STRRECRECEDIT
), TRUE
);
56 SendDlgItemMessageW(hwndDlg
, IDC_STRRECRECUPDWN
, UDM_SETRANGE
, (WPARAM
) 0, (LPARAM
) MAKELONG((short) 999, 0));
57 SendDlgItemMessageW(hwndDlg
, IDC_STRRECRECUPDWN
, UDM_SETPOS
, (WPARAM
) 0, (LPARAM
) MAKELONG((short) Timeout
, 0));
62 GetSystemDrive(WCHAR
**szSystemDrive
)
66 /* Get Path to freeldr.ini or boot.ini */
67 *szSystemDrive
= HeapAlloc(GetProcessHeap(), 0, MAX_PATH
* sizeof(WCHAR
));
68 if (*szSystemDrive
!= NULL
)
70 dwBufSize
= GetEnvironmentVariableW(L
"SystemDrive", *szSystemDrive
, MAX_PATH
);
71 if (dwBufSize
> MAX_PATH
)
76 szTmp
= HeapReAlloc(GetProcessHeap(), 0, *szSystemDrive
, dwBufSize
* sizeof(WCHAR
));
80 *szSystemDrive
= szTmp
;
82 dwBufSize2
= GetEnvironmentVariableW(L
"SystemDrive", *szSystemDrive
, dwBufSize
);
83 if (dwBufSize2
> dwBufSize
|| dwBufSize2
== 0)
86 else if (dwBufSize
== 0)
89 HeapFree(GetProcessHeap(), 0, *szSystemDrive
);
90 *szSystemDrive
= NULL
;
101 ReadFreeldrSection(HINF hInf
, WCHAR
*szSectionName
)
104 INFCONTEXT InfContext
;
105 WCHAR szName
[MAX_PATH
];
106 WCHAR szValue
[MAX_PATH
];
109 if (!SetupFindFirstLineW(hInf
,
114 /* Failed to find section */
118 pRecord
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(BOOTRECORD
));
124 wcscpy(pRecord
->szSectionName
, szSectionName
);
128 if (!SetupGetStringFieldW(&InfContext
,
131 sizeof(szName
) / sizeof(WCHAR
),
137 if (!SetupGetStringFieldW(&InfContext
,
140 sizeof(szValue
) / sizeof(WCHAR
),
146 if (!_wcsnicmp(szName
, L
"BootType", 8))
148 if (!_wcsnicmp(szValue
, L
"ReactOS", 7))
150 // FIXME: Store as enum
151 pRecord
->BootType
= 1;
155 pRecord
->BootType
= 0;
158 else if (!_wcsnicmp(szName
, L
"SystemPath", 10))
160 wcscpy(pRecord
->szBootPath
, szValue
);
162 else if (!_wcsnicmp(szName
, L
"Options", 7))
164 // FIXME: Store flags as values
165 wcscpy(pRecord
->szOptions
, szValue
);
169 while (SetupFindNextLine(&InfContext
, &InfContext
));
176 LoadFreeldrSettings(HINF hInf
, HWND hwndDlg
)
178 INFCONTEXT InfContext
;
180 WCHAR szDefaultOs
[MAX_PATH
];
181 WCHAR szName
[MAX_PATH
];
182 WCHAR szValue
[MAX_PATH
];
187 if (!SetupFindFirstLineW(hInf
,
192 /* Failed to find default os */
196 if (!SetupGetStringFieldW(&InfContext
,
199 sizeof(szDefaultOs
) / sizeof(WCHAR
),
206 if (!SetupFindFirstLineW(hInf
,
211 /* Expected to find timeout value */
216 if (!SetupGetIntField(&InfContext
,
220 /* Failed to retrieve timeout */
224 if (!SetupFindFirstLineW(hInf
,
225 L
"Operating Systems",
229 /* Expected list of operating systems */
235 if (!SetupGetStringFieldW(&InfContext
,
238 sizeof(szName
) / sizeof(WCHAR
),
241 /* The ini file is messed up */
245 if (!SetupGetStringFieldW(&InfContext
,
248 sizeof(szValue
) / sizeof(WCHAR
),
251 /* The ini file is messed up */
255 pRecord
= ReadFreeldrSection(hInf
, szName
);
258 lResult
= SendDlgItemMessageW(hwndDlg
, IDC_STRECOSCOMBO
, CB_ADDSTRING
, (WPARAM
)0, (LPARAM
)szValue
);
259 if (lResult
!= CB_ERR
)
261 SendDlgItemMessageW(hwndDlg
, IDC_STRECOSCOMBO
, CB_SETITEMDATA
, (WPARAM
)lResult
, (LPARAM
)pRecord
);
262 if (!wcscmp(szDefaultOs
, szName
))
264 /* We store the friendly name as key */
265 wcscpy(szDefaultOs
, szValue
);
270 HeapFree(GetProcessHeap(), 0, pRecord
);
274 while (SetupFindNextLine(&InfContext
, &InfContext
));
276 /* Find default os in list */
277 lResult
= SendDlgItemMessageW(hwndDlg
, IDC_STRECOSCOMBO
, CB_FINDSTRING
, (WPARAM
)-1, (LPARAM
)szDefaultOs
);
278 if (lResult
!= CB_ERR
)
281 SendDlgItemMessageW(hwndDlg
, IDC_STRECOSCOMBO
, CB_SETCURSEL
, (WPARAM
)lResult
, (LPARAM
)0);
286 SendDlgItemMessageW(hwndDlg
, IDC_STRECLIST
, BM_SETCHECK
, (WPARAM
)BST_CHECKED
, (LPARAM
)0);
289 SetTimeout(hwndDlg
, TimeOut
);
295 LoadBootSettings(HINF hInf
, HWND hwndDlg
)
297 INFCONTEXT InfContext
;
298 WCHAR szName
[MAX_PATH
];
299 WCHAR szValue
[MAX_PATH
];
302 WCHAR szDefaultOS
[MAX_PATH
];
303 WCHAR szOptions
[MAX_PATH
];
307 if(!SetupFindFirstLineW(hInf
,
317 if (!SetupGetStringFieldW(&InfContext
,
320 sizeof(szName
) / sizeof(WCHAR
),
326 if (!SetupGetStringFieldW(&InfContext
,
329 sizeof(szValue
) / sizeof(WCHAR
),
335 if (!_wcsnicmp(szName
, L
"timeout", 7))
337 TimeOut
= _wtoi(szValue
);
340 if (!_wcsnicmp(szName
, L
"default", 7))
342 wcscpy(szDefaultOS
, szValue
);
346 while (SetupFindNextLine(&InfContext
, &InfContext
));
348 if (!SetupFindFirstLineW(hInf
,
349 L
"operating systems",
353 /* Failed to find operating systems section */
359 if (!SetupGetStringFieldW(&InfContext
,
362 sizeof(szName
) / sizeof(WCHAR
),
368 if (!SetupGetStringFieldW(&InfContext
,
371 sizeof(szValue
) / sizeof(WCHAR
),
377 SetupGetStringFieldW(&InfContext
,
380 sizeof(szOptions
) / sizeof(WCHAR
),
383 pRecord
= (PBOOTRECORD
) HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(BOOTRECORD
));
386 pRecord
->BootType
= 0;
387 wcscpy(pRecord
->szBootPath
, szName
);
388 wcscpy(pRecord
->szSectionName
, szValue
);
389 wcscpy(pRecord
->szOptions
, szOptions
);
391 if (!wcscmp(szName
, szDefaultOS
))
393 /* ms boot ini stores the path not the friendly name */
394 wcscpy(szDefaultOS
, szValue
);
397 lResult
= SendDlgItemMessageW(hwndDlg
, IDC_STRECOSCOMBO
, CB_ADDSTRING
, (WPARAM
)0, (LPARAM
)szValue
);
398 if (lResult
!= CB_ERR
)
400 SendDlgItemMessageW(hwndDlg
, IDC_STRECOSCOMBO
, CB_SETITEMDATA
, (WPARAM
)lResult
, (LPARAM
)pRecord
);
404 HeapFree(GetProcessHeap(), 0, pRecord
);
409 while (SetupFindNextLine(&InfContext
, &InfContext
));
411 /* Find default os in list */
412 lResult
= SendDlgItemMessageW(hwndDlg
, IDC_STRECOSCOMBO
, CB_FINDSTRING
, (WPARAM
)0, (LPARAM
)szDefaultOS
);
413 if (lResult
!= CB_ERR
)
416 SendDlgItemMessageW(hwndDlg
, IDC_STRECOSCOMBO
, CB_SETCURSEL
, (WPARAM
)lResult
, (LPARAM
)0);
421 SendDlgItemMessageW(hwndDlg
, IDC_STRECLIST
, BM_SETCHECK
, (WPARAM
)BST_CHECKED
, (LPARAM
)0);
424 SetTimeout(hwndDlg
, TimeOut
);
430 DeleteBootRecords(HWND hwndDlg
)
436 lIndex
= SendDlgItemMessageW(hwndDlg
, IDC_STRECOSCOMBO
, CB_GETCOUNT
, (WPARAM
)0, (LPARAM
)0);
437 if (lIndex
== CB_ERR
)
440 for (index
= 0; index
<lIndex
; index
++)
442 pRecord
= (PBOOTRECORD
) SendDlgItemMessageW(hwndDlg
, IDC_STRECOSCOMBO
, CB_GETITEMDATA
, (WPARAM
)index
, (LPARAM
)0);
443 if ((INT_PTR
)pRecord
!= CB_ERR
)
445 HeapFree(GetProcessHeap(), 0, pRecord
);
449 SendDlgItemMessageW(hwndDlg
, IDC_STRECOSCOMBO
, CB_RESETCONTENT
, (WPARAM
)0, (LPARAM
)0);
453 LoadOSList(HWND hwndDlg
, PSTARTINFO pStartInfo
)
456 WCHAR
*szSystemDrive
;
459 dwBufSize
= GetSystemDrive(&szSystemDrive
);
463 wcscpy(pStartInfo
->szFreeldrIni
, szSystemDrive
);
464 wcscat(pStartInfo
->szFreeldrIni
, L
"\\freeldr.ini");
466 if (PathFileExistsW(pStartInfo
->szFreeldrIni
))
468 /* Free resource previously allocated by GetSystemDrive() */
469 HeapFree(GetProcessHeap(), 0, szSystemDrive
);
470 /* freeldr.ini exists */
471 hInf
= SetupOpenInfFileW(pStartInfo
->szFreeldrIni
,
476 if (hInf
!= INVALID_HANDLE_VALUE
)
478 LoadFreeldrSettings(hInf
, hwndDlg
);
479 SetupCloseInfFile(hInf
);
480 pStartInfo
->iFreeLdrIni
= 1;
486 /* Try loading boot.ini settings */
487 wcscpy(pStartInfo
->szFreeldrIni
, szSystemDrive
);
488 wcscat(pStartInfo
->szFreeldrIni
, L
"\\boot.ini");
490 /* Free resource previously allocated by GetSystemDrive() */
491 HeapFree(GetProcessHeap(), 0, szSystemDrive
);
493 if (PathFileExistsW(pStartInfo
->szFreeldrIni
))
495 /* Load boot.ini settings */
496 hInf
= SetupOpenInfFileW(pStartInfo
->szFreeldrIni
,
501 if (hInf
!= INVALID_HANDLE_VALUE
)
503 LoadBootSettings(hInf
, hwndDlg
);
504 SetupCloseInfFile(hInf
);
505 pStartInfo
->iFreeLdrIni
= 2;
516 SetCrashDlgItems(HWND hwnd
, PSTARTINFO pStartInfo
)
518 if (pStartInfo
->dwCrashDumpEnabled
== 0)
520 /* No crash information required */
521 EnableWindow(GetDlgItem(hwnd
, IDC_STRRECDUMPFILE
), FALSE
);
522 EnableWindow(GetDlgItem(hwnd
, IDC_STRRECOVERWRITE
), FALSE
);
524 else if (pStartInfo
->dwCrashDumpEnabled
== 3)
527 EnableWindow(GetDlgItem(hwnd
, IDC_STRRECDUMPFILE
), TRUE
);
528 EnableWindow(GetDlgItem(hwnd
, IDC_STRRECOVERWRITE
), FALSE
);
529 SendMessageW(GetDlgItem(hwnd
, IDC_STRRECDUMPFILE
), WM_SETTEXT
, (WPARAM
)0, (LPARAM
)pStartInfo
->szMinidumpDir
);
531 else if (pStartInfo
->dwCrashDumpEnabled
== 1 || pStartInfo
->dwCrashDumpEnabled
== 2)
533 /* Kernel or complete dump */
534 EnableWindow(GetDlgItem(hwnd
, IDC_STRRECDUMPFILE
), TRUE
);
535 EnableWindow(GetDlgItem(hwnd
, IDC_STRRECOVERWRITE
), TRUE
);
536 SendMessageW(GetDlgItem(hwnd
, IDC_STRRECDUMPFILE
), WM_SETTEXT
, (WPARAM
)0, (LPARAM
)pStartInfo
->szDumpFile
);
538 SendDlgItemMessageW(hwnd
, IDC_STRRECDEBUGCOMBO
, CB_SETCURSEL
, (WPARAM
)pStartInfo
->dwCrashDumpEnabled
, (LPARAM
)0);
542 WriteStartupRecoveryOptions(HWND hwndDlg
, PSTARTINFO pStartInfo
)
547 lResult
= (DWORD
)RegCreateKeyExW(HKEY_LOCAL_MACHINE
,
548 L
"System\\CurrentControlSet\\Control\\CrashControl",
551 REG_OPTION_NON_VOLATILE
,
556 if (lResult
!= ERROR_SUCCESS
)
558 /* Failed to open key */
559 SetLastError(lResult
);
560 ShowLastWin32Error(hwndDlg
);
565 lResult
= (DWORD
) SendDlgItemMessage(hwndDlg
, IDC_STRRECWRITEEVENT
, BM_GETCHECK
, (WPARAM
)0, (LPARAM
)0);
566 RegSetValueExW(hKey
, L
"LogEvent", 0, REG_DWORD
, (LPBYTE
)&lResult
, sizeof(lResult
));
568 lResult
= (DWORD
) SendDlgItemMessage(hwndDlg
, IDC_STRRECSENDALERT
, BM_GETCHECK
, (WPARAM
)0, (LPARAM
)0);
569 RegSetValueExW(hKey
, L
"SendAlert", 0, REG_DWORD
, (LPBYTE
)&lResult
, sizeof(lResult
));
571 lResult
= (DWORD
) SendDlgItemMessage(hwndDlg
, IDC_STRRECRESTART
, BM_GETCHECK
, (WPARAM
)0, (LPARAM
)0);
572 RegSetValueExW(hKey
, L
"AutoReboot", 0, REG_DWORD
, (LPBYTE
)&lResult
, sizeof(lResult
));
574 lResult
= (DWORD
) SendDlgItemMessage(hwndDlg
, IDC_STRRECOVERWRITE
, BM_GETCHECK
, (WPARAM
)0, (LPARAM
)0);
575 RegSetValueExW(hKey
, L
"Overwrite", 0, REG_DWORD
, (LPBYTE
)&lResult
, sizeof(lResult
));
578 if (pStartInfo
->dwCrashDumpEnabled
== 1 || pStartInfo
->dwCrashDumpEnabled
== 2)
580 SendDlgItemMessage(hwndDlg
, IDC_STRRECDUMPFILE
, WM_GETTEXT
, (WPARAM
)sizeof(pStartInfo
->szDumpFile
) / sizeof(WCHAR
), (LPARAM
)pStartInfo
->szDumpFile
);
581 RegSetValueExW(hKey
, L
"DumpFile", 0, REG_EXPAND_SZ
, (LPBYTE
)pStartInfo
->szDumpFile
, (wcslen(pStartInfo
->szDumpFile
) + 1) * sizeof(WCHAR
));
583 else if (pStartInfo
->dwCrashDumpEnabled
== 3)
585 SendDlgItemMessage(hwndDlg
, IDC_STRRECDUMPFILE
, WM_GETTEXT
, (WPARAM
)sizeof(pStartInfo
->szDumpFile
) / sizeof(WCHAR
), (LPARAM
)pStartInfo
->szDumpFile
);
586 RegSetValueExW(hKey
, L
"MinidumpDir", 0, REG_EXPAND_SZ
, (LPBYTE
)pStartInfo
->szDumpFile
, (wcslen(pStartInfo
->szDumpFile
) + 1) * sizeof(WCHAR
));
589 RegSetValueExW(hKey
, L
"CrashDumpEnabled", 0, REG_DWORD
, (LPBYTE
)&pStartInfo
->dwCrashDumpEnabled
, sizeof(pStartInfo
->dwCrashDumpEnabled
));
594 LoadRecoveryOptions(HWND hwndDlg
, PSTARTINFO pStartInfo
)
597 WCHAR szName
[MAX_PATH
];
598 DWORD dwValue
, dwValueLength
, dwType
, dwResult
;
600 dwResult
= (DWORD
)RegCreateKeyExW(HKEY_LOCAL_MACHINE
,
601 L
"System\\CurrentControlSet\\Control\\CrashControl",
604 REG_OPTION_NON_VOLATILE
,
609 if (dwResult
!= ERROR_SUCCESS
)
611 /* Failed to open key */
612 SetLastError(dwResult
);
613 ShowLastWin32Error(hwndDlg
);
615 EnableWindow(GetDlgItem(hwndDlg
, IDC_STRRECWRITEEVENT
), FALSE
);
616 EnableWindow(GetDlgItem(hwndDlg
, IDC_STRRECSENDALERT
), FALSE
);
617 EnableWindow(GetDlgItem(hwndDlg
, IDC_STRRECRESTART
), FALSE
);
618 EnableWindow(GetDlgItem(hwndDlg
, IDC_STRRECDEBUGCOMBO
), FALSE
);
619 EnableWindow(GetDlgItem(hwndDlg
, IDC_STRRECDUMPFILE
), FALSE
);
620 EnableWindow(GetDlgItem(hwndDlg
, IDC_STRRECOVERWRITE
), FALSE
);
622 SaveRecoveryOptions
= FALSE
;
626 dwValueLength
= sizeof(DWORD
);
627 if (RegQueryValueExW(hKey
, L
"LogEvent", NULL
, &dwType
, (LPBYTE
)&dwValue
, &dwValueLength
) == ERROR_SUCCESS
&& dwType
== REG_DWORD
&& dwValue
)
628 SendDlgItemMessageW(hwndDlg
, IDC_STRRECWRITEEVENT
, BM_SETCHECK
, (WPARAM
)BST_CHECKED
, (LPARAM
)0);
630 dwValueLength
= sizeof(DWORD
);
631 if (RegQueryValueExW(hKey
, L
"SendAlert", NULL
, &dwType
, (LPBYTE
)&dwValue
, &dwValueLength
) == ERROR_SUCCESS
&& dwType
== REG_DWORD
&& dwValue
)
632 SendDlgItemMessageW(hwndDlg
, IDC_STRRECSENDALERT
, BM_SETCHECK
, (WPARAM
)BST_CHECKED
, (LPARAM
)0);
634 dwValueLength
= sizeof(DWORD
);
635 if (RegQueryValueExW(hKey
, L
"AutoReboot", NULL
, &dwType
, (LPBYTE
)&dwValue
, &dwValueLength
) == ERROR_SUCCESS
&& dwType
== REG_DWORD
&& dwValue
)
636 SendDlgItemMessageW(hwndDlg
, IDC_STRRECRESTART
, BM_SETCHECK
, (WPARAM
)BST_CHECKED
, (LPARAM
)0);
638 dwValueLength
= sizeof(DWORD
);
639 if (RegQueryValueExW(hKey
, L
"Overwrite", NULL
, &dwType
, (LPBYTE
)&dwValue
, &dwValueLength
) == ERROR_SUCCESS
&& dwType
== REG_DWORD
&& dwValue
)
640 SendDlgItemMessageW(hwndDlg
, IDC_STRRECOVERWRITE
, BM_SETCHECK
, (WPARAM
)BST_CHECKED
, (LPARAM
)0);
642 dwValueLength
= sizeof(DWORD
);
643 if (RegQueryValueExW(hKey
, L
"CrashDumpEnabled", NULL
, &dwType
, (LPBYTE
)&dwValue
, &dwValueLength
) == ERROR_SUCCESS
&& dwType
== REG_DWORD
&& dwValue
)
644 pStartInfo
->dwCrashDumpEnabled
= dwValue
;
646 dwValueLength
= sizeof(pStartInfo
->szDumpFile
);
647 if (RegQueryValueExW(hKey
, L
"DumpFile", NULL
, &dwType
, (LPBYTE
)pStartInfo
->szDumpFile
, &dwValueLength
) != ERROR_SUCCESS
)
648 pStartInfo
->szDumpFile
[0] = L
'\0';
650 dwValueLength
= sizeof(pStartInfo
->szMinidumpDir
);
651 if (RegQueryValueExW(hKey
, L
"MinidumpDir", NULL
, &dwType
, (LPBYTE
)pStartInfo
->szMinidumpDir
, &dwValueLength
) != ERROR_SUCCESS
)
652 pStartInfo
->szMinidumpDir
[0] = L
'\0';
654 if (LoadStringW(hApplet
, IDS_NO_DUMP
, szName
, sizeof(szName
) / sizeof(WCHAR
)))
656 szName
[(sizeof(szName
)/sizeof(WCHAR
))-1] = L
'\0';
657 SendDlgItemMessageW(hwndDlg
, IDC_STRRECDEBUGCOMBO
, CB_ADDSTRING
, (WPARAM
)0, (LPARAM
) szName
);
660 if (LoadStringW(hApplet
, IDS_FULL_DUMP
, szName
, sizeof(szName
) / sizeof(WCHAR
)))
662 szName
[(sizeof(szName
)/sizeof(WCHAR
))-1] = L
'\0';
663 SendDlgItemMessageW(hwndDlg
, IDC_STRRECDEBUGCOMBO
, CB_ADDSTRING
, (WPARAM
)0, (LPARAM
) szName
);
666 if (LoadStringW(hApplet
, IDS_KERNEL_DUMP
, szName
, sizeof(szName
) / sizeof(WCHAR
)))
668 szName
[(sizeof(szName
)/sizeof(WCHAR
))-1] = L
'\0';
669 SendDlgItemMessageW(hwndDlg
, IDC_STRRECDEBUGCOMBO
, CB_ADDSTRING
, (WPARAM
)0, (LPARAM
) szName
);
672 if (LoadStringW(hApplet
, IDS_MINI_DUMP
, szName
, sizeof(szName
) / sizeof(WCHAR
)))
674 szName
[(sizeof(szName
)/sizeof(WCHAR
))-1] = L
'\0';
675 SendDlgItemMessageW(hwndDlg
, IDC_STRRECDEBUGCOMBO
, CB_ADDSTRING
, (WPARAM
)0, (LPARAM
) szName
);
678 SetCrashDlgItems(hwndDlg
, pStartInfo
);
681 SaveRecoveryOptions
= TRUE
;
685 /* Property page dialog callback */
687 StartRecDlgProc(HWND hwndDlg
,
692 PSTARTINFO pStartInfo
;
698 UNREFERENCED_PARAMETER(lParam
);
700 pStartInfo
= (PSTARTINFO
)GetWindowLongPtr(hwndDlg
, DWLP_USER
);
705 pStartInfo
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(STARTINFO
));
706 SetWindowLongPtr(hwndDlg
, DWLP_USER
, (LONG_PTR
)pStartInfo
);
708 LoadRecoveryOptions(hwndDlg
, pStartInfo
);
709 SetRecoveryTimeout(hwndDlg
, 0);
710 return LoadOSList(hwndDlg
, pStartInfo
);
713 DeleteBootRecords(hwndDlg
);
714 HeapFree(GetProcessHeap(), 0, pStartInfo
);
718 switch(LOWORD(wParam
))
721 ShellExecuteW(0, L
"open", L
"notepad", pStartInfo
->szFreeldrIni
, NULL
, SW_SHOWNORMAL
);
722 // FIXME: Use CreateProcess and wait untill finished
723 // DeleteBootRecords(hwndDlg);
724 // LoadOSList(hwndDlg);
729 if (SendDlgItemMessage(hwndDlg
, IDC_STRECLIST
, BM_GETCHECK
, (WPARAM
)0, (LPARAM
)0) == BST_CHECKED
)
730 iTimeout
= SendDlgItemMessage(hwndDlg
, IDC_STRRECLISTUPDWN
, UDM_GETPOS
, (WPARAM
)0, (LPARAM
)0);
733 swprintf(szTimeout
, L
"%i", iTimeout
);
735 lResult
= SendDlgItemMessageW(hwndDlg
, IDC_STRECOSCOMBO
, CB_GETCURSEL
, (WPARAM
)0, (LPARAM
)0);
736 if (lResult
== CB_ERR
)
739 DeleteBootRecords(hwndDlg
);
743 pRecord
= (PBOOTRECORD
) SendDlgItemMessage(hwndDlg
, IDC_STRECOSCOMBO
, CB_GETITEMDATA
, (WPARAM
)lResult
, (LPARAM
)0);
745 if ((INT_PTR
)pRecord
!= CB_ERR
)
747 if (pStartInfo
->iFreeLdrIni
== 1) // FreeLdrIni style
749 /* Set default timeout */
750 WritePrivateProfileStringW(L
"FREELOADER",
753 pStartInfo
->szFreeldrIni
);
755 WritePrivateProfileStringW(L
"FREELOADER",
757 pRecord
->szSectionName
,
758 pStartInfo
->szFreeldrIni
);
761 else if (pStartInfo
->iFreeLdrIni
== 2) // BootIni style
763 /* Set default timeout */
764 WritePrivateProfileStringW(L
"boot loader",
767 pStartInfo
->szFreeldrIni
);
769 WritePrivateProfileStringW(L
"boot loader",
772 pStartInfo
->szFreeldrIni
);
777 if (SaveRecoveryOptions
)
779 WriteStartupRecoveryOptions(hwndDlg
, pStartInfo
);
792 if (SendDlgItemMessage(hwndDlg
, IDC_STRECLIST
, BM_GETCHECK
, (WPARAM
)0, (LPARAM
)0) == BST_CHECKED
)
793 SetTimeout(hwndDlg
, 30);
795 SetTimeout(hwndDlg
, 0);
799 if (SendDlgItemMessage(hwndDlg
, IDC_STRRECREC
, BM_GETCHECK
, (WPARAM
)0, (LPARAM
)0) == BST_CHECKED
)
800 SetRecoveryTimeout(hwndDlg
, 30);
802 SetRecoveryTimeout(hwndDlg
, 0);
805 case IDC_STRRECDEBUGCOMBO
:
806 if (HIWORD(wParam
) == CBN_SELCHANGE
)
810 lResult
= SendDlgItemMessage(hwndDlg
, IDC_STRRECDEBUGCOMBO
, CB_GETCURSEL
, (WPARAM
)0, (LPARAM
)0);
811 if (lResult
!= CB_ERR
&& lResult
!= (LRESULT
)pStartInfo
->dwCrashDumpEnabled
)
813 if (pStartInfo
->dwCrashDumpEnabled
== 1 || pStartInfo
->dwCrashDumpEnabled
== 2)
815 SendDlgItemMessageW(hwndDlg
, IDC_STRRECDUMPFILE
, WM_GETTEXT
, (WPARAM
)sizeof(pStartInfo
->szDumpFile
) / sizeof(WCHAR
), (LPARAM
)pStartInfo
->szDumpFile
);
817 else if (pStartInfo
->dwCrashDumpEnabled
== 3)
819 SendDlgItemMessageW(hwndDlg
, IDC_STRRECDUMPFILE
, WM_GETTEXT
, (WPARAM
)sizeof(pStartInfo
->szMinidumpDir
) / sizeof(WCHAR
), (LPARAM
)pStartInfo
->szMinidumpDir
);
822 pStartInfo
->dwCrashDumpEnabled
= (DWORD
)lResult
;
823 SetCrashDlgItems(hwndDlg
, pStartInfo
);