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>
16 typedef struct _STARTINFO
18 WCHAR szFreeldrIni
[MAX_PATH
+ 15];
19 WCHAR szDumpFile
[MAX_PATH
];
20 WCHAR szMinidumpDir
[MAX_PATH
];
21 DWORD dwCrashDumpEnabled
;
23 } STARTINFO
, *PSTARTINFO
;
25 BOOL SaveRecoveryOptions
;
28 SetTimeout(HWND hwndDlg
, INT Timeout
)
32 EnableWindow(GetDlgItem(hwndDlg
, IDC_STRRECLISTUPDWN
), FALSE
);
33 EnableWindow(GetDlgItem(hwndDlg
, IDC_STRRECLISTEDIT
), FALSE
);
37 EnableWindow(GetDlgItem(hwndDlg
, IDC_STRRECLISTUPDWN
), TRUE
);
38 EnableWindow(GetDlgItem(hwndDlg
, IDC_STRRECLISTEDIT
), TRUE
);
40 SendDlgItemMessageW(hwndDlg
, IDC_STRRECLISTUPDWN
, UDM_SETRANGE
, (WPARAM
) 0, (LPARAM
) MAKELONG((short) 999, 0));
41 SendDlgItemMessageW(hwndDlg
, IDC_STRRECLISTUPDWN
, UDM_SETPOS
, (WPARAM
) 0, (LPARAM
) MAKELONG((short) Timeout
, 0));
45 SetRecoveryTimeout(HWND hwndDlg
, INT Timeout
)
49 EnableWindow(GetDlgItem(hwndDlg
, IDC_STRRECRECUPDWN
), FALSE
);
50 EnableWindow(GetDlgItem(hwndDlg
, IDC_STRRECRECEDIT
), FALSE
);
54 EnableWindow(GetDlgItem(hwndDlg
, IDC_STRRECRECUPDWN
), TRUE
);
55 EnableWindow(GetDlgItem(hwndDlg
, IDC_STRRECRECEDIT
), TRUE
);
57 SendDlgItemMessageW(hwndDlg
, IDC_STRRECRECUPDWN
, UDM_SETRANGE
, (WPARAM
) 0, (LPARAM
) MAKELONG((short) 999, 0));
58 SendDlgItemMessageW(hwndDlg
, IDC_STRRECRECUPDWN
, UDM_SETPOS
, (WPARAM
) 0, (LPARAM
) MAKELONG((short) Timeout
, 0));
63 GetSystemDrive(WCHAR
**szSystemDrive
)
67 /* Get Path to freeldr.ini or boot.ini */
68 *szSystemDrive
= HeapAlloc(GetProcessHeap(), 0, MAX_PATH
* sizeof(WCHAR
));
69 if (*szSystemDrive
!= NULL
)
71 dwBufSize
= GetEnvironmentVariableW(L
"SystemDrive", *szSystemDrive
, MAX_PATH
);
72 if (dwBufSize
> MAX_PATH
)
77 szTmp
= HeapReAlloc(GetProcessHeap(), 0, *szSystemDrive
, dwBufSize
* sizeof(WCHAR
));
81 *szSystemDrive
= szTmp
;
83 dwBufSize2
= GetEnvironmentVariableW(L
"SystemDrive", *szSystemDrive
, dwBufSize
);
84 if (dwBufSize2
> dwBufSize
|| dwBufSize2
== 0)
87 else if (dwBufSize
== 0)
90 HeapFree(GetProcessHeap(), 0, *szSystemDrive
);
91 *szSystemDrive
= NULL
;
102 ReadFreeldrSection(HINF hInf
, WCHAR
*szSectionName
)
105 INFCONTEXT InfContext
;
106 WCHAR szName
[MAX_PATH
];
107 WCHAR szValue
[MAX_PATH
];
110 if (!SetupFindFirstLineW(hInf
,
115 /* Failed to find section */
119 pRecord
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(BOOTRECORD
));
125 wcscpy(pRecord
->szSectionName
, szSectionName
);
129 if (!SetupGetStringFieldW(&InfContext
,
132 sizeof(szName
) / sizeof(WCHAR
),
138 if (!SetupGetStringFieldW(&InfContext
,
141 sizeof(szValue
) / sizeof(WCHAR
),
147 if (!_wcsnicmp(szName
, L
"BootType", 8))
149 if (!_wcsnicmp(szValue
, L
"ReactOS", 7))
151 // FIXME: Store as enum
152 pRecord
->BootType
= 1;
156 pRecord
->BootType
= 0;
159 else if (!_wcsnicmp(szName
, L
"SystemPath", 10))
161 wcscpy(pRecord
->szBootPath
, szValue
);
163 else if (!_wcsnicmp(szName
, L
"Options", 7))
165 // FIXME: Store flags as values
166 wcscpy(pRecord
->szOptions
, szValue
);
170 while (SetupFindNextLine(&InfContext
, &InfContext
));
177 LoadFreeldrSettings(HINF hInf
, HWND hwndDlg
)
179 INFCONTEXT InfContext
;
181 WCHAR szDefaultOs
[MAX_PATH
];
182 WCHAR szName
[MAX_PATH
];
183 WCHAR szValue
[MAX_PATH
];
188 if (!SetupFindFirstLineW(hInf
,
193 /* Failed to find default os */
197 if (!SetupGetStringFieldW(&InfContext
,
200 sizeof(szDefaultOs
) / sizeof(WCHAR
),
207 if (!SetupFindFirstLineW(hInf
,
212 /* Expected to find timeout value */
217 if (!SetupGetIntField(&InfContext
,
221 /* Failed to retrieve timeout */
225 if (!SetupFindFirstLineW(hInf
,
226 L
"Operating Systems",
230 /* Expected list of operating systems */
236 if (!SetupGetStringFieldW(&InfContext
,
239 sizeof(szName
) / sizeof(WCHAR
),
242 /* The ini file is messed up */
246 if (!SetupGetStringFieldW(&InfContext
,
249 sizeof(szValue
) / sizeof(WCHAR
),
252 /* The ini file is messed up */
256 pRecord
= ReadFreeldrSection(hInf
, szName
);
259 lResult
= SendDlgItemMessageW(hwndDlg
, IDC_STRECOSCOMBO
, CB_ADDSTRING
, (WPARAM
)0, (LPARAM
)szValue
);
260 if (lResult
!= CB_ERR
)
262 SendDlgItemMessageW(hwndDlg
, IDC_STRECOSCOMBO
, CB_SETITEMDATA
, (WPARAM
)lResult
, (LPARAM
)pRecord
);
263 if (!wcscmp(szDefaultOs
, szName
))
265 /* We store the friendly name as key */
266 wcscpy(szDefaultOs
, szValue
);
271 HeapFree(GetProcessHeap(), 0, pRecord
);
275 while (SetupFindNextLine(&InfContext
, &InfContext
));
277 /* Find default os in list */
278 lResult
= SendDlgItemMessageW(hwndDlg
, IDC_STRECOSCOMBO
, CB_FINDSTRING
, (WPARAM
)-1, (LPARAM
)szDefaultOs
);
279 if (lResult
!= CB_ERR
)
282 SendDlgItemMessageW(hwndDlg
, IDC_STRECOSCOMBO
, CB_SETCURSEL
, (WPARAM
)lResult
, (LPARAM
)0);
287 SendDlgItemMessageW(hwndDlg
, IDC_STRECLIST
, BM_SETCHECK
, (WPARAM
)BST_CHECKED
, (LPARAM
)0);
290 SetTimeout(hwndDlg
, TimeOut
);
296 LoadBootSettings(HINF hInf
, HWND hwndDlg
)
298 INFCONTEXT InfContext
;
299 WCHAR szName
[MAX_PATH
];
300 WCHAR szValue
[MAX_PATH
];
303 WCHAR szDefaultOS
[MAX_PATH
];
304 WCHAR szOptions
[MAX_PATH
];
308 if(!SetupFindFirstLineW(hInf
,
318 if (!SetupGetStringFieldW(&InfContext
,
321 sizeof(szName
) / sizeof(WCHAR
),
327 if (!SetupGetStringFieldW(&InfContext
,
330 sizeof(szValue
) / sizeof(WCHAR
),
336 if (!_wcsnicmp(szName
, L
"timeout", 7))
338 TimeOut
= _wtoi(szValue
);
341 if (!_wcsnicmp(szName
, L
"default", 7))
343 wcscpy(szDefaultOS
, szValue
);
347 while (SetupFindNextLine(&InfContext
, &InfContext
));
349 if (!SetupFindFirstLineW(hInf
,
350 L
"operating systems",
354 /* Failed to find operating systems section */
360 if (!SetupGetStringFieldW(&InfContext
,
363 sizeof(szName
) / sizeof(WCHAR
),
369 if (!SetupGetStringFieldW(&InfContext
,
372 sizeof(szValue
) / sizeof(WCHAR
),
378 SetupGetStringFieldW(&InfContext
,
381 sizeof(szOptions
) / sizeof(WCHAR
),
384 pRecord
= (PBOOTRECORD
) HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(BOOTRECORD
));
387 pRecord
->BootType
= 0;
388 wcscpy(pRecord
->szBootPath
, szName
);
389 wcscpy(pRecord
->szSectionName
, szValue
);
390 wcscpy(pRecord
->szOptions
, szOptions
);
392 if (!wcscmp(szName
, szDefaultOS
))
394 /* ms boot ini stores the path not the friendly name */
395 wcscpy(szDefaultOS
, szValue
);
398 lResult
= SendDlgItemMessageW(hwndDlg
, IDC_STRECOSCOMBO
, CB_ADDSTRING
, (WPARAM
)0, (LPARAM
)szValue
);
399 if (lResult
!= CB_ERR
)
401 SendDlgItemMessageW(hwndDlg
, IDC_STRECOSCOMBO
, CB_SETITEMDATA
, (WPARAM
)lResult
, (LPARAM
)pRecord
);
405 HeapFree(GetProcessHeap(), 0, pRecord
);
410 while (SetupFindNextLine(&InfContext
, &InfContext
));
412 /* Find default os in list */
413 lResult
= SendDlgItemMessageW(hwndDlg
, IDC_STRECOSCOMBO
, CB_FINDSTRING
, (WPARAM
)0, (LPARAM
)szDefaultOS
);
414 if (lResult
!= CB_ERR
)
417 SendDlgItemMessageW(hwndDlg
, IDC_STRECOSCOMBO
, CB_SETCURSEL
, (WPARAM
)lResult
, (LPARAM
)0);
422 SendDlgItemMessageW(hwndDlg
, IDC_STRECLIST
, BM_SETCHECK
, (WPARAM
)BST_CHECKED
, (LPARAM
)0);
425 SetTimeout(hwndDlg
, TimeOut
);
431 DeleteBootRecords(HWND hwndDlg
)
437 lIndex
= SendDlgItemMessageW(hwndDlg
, IDC_STRECOSCOMBO
, CB_GETCOUNT
, (WPARAM
)0, (LPARAM
)0);
438 if (lIndex
== CB_ERR
)
441 for (index
= 0; index
<lIndex
; index
++)
443 pRecord
= (PBOOTRECORD
) SendDlgItemMessageW(hwndDlg
, IDC_STRECOSCOMBO
, CB_GETITEMDATA
, (WPARAM
)index
, (LPARAM
)0);
444 if ((INT_PTR
)pRecord
!= CB_ERR
)
446 HeapFree(GetProcessHeap(), 0, pRecord
);
450 SendDlgItemMessageW(hwndDlg
, IDC_STRECOSCOMBO
, CB_RESETCONTENT
, (WPARAM
)0, (LPARAM
)0);
454 LoadOSList(HWND hwndDlg
, PSTARTINFO pStartInfo
)
457 WCHAR
*szSystemDrive
;
460 dwBufSize
= GetSystemDrive(&szSystemDrive
);
464 wcscpy(pStartInfo
->szFreeldrIni
, szSystemDrive
);
465 wcscat(pStartInfo
->szFreeldrIni
, L
"\\freeldr.ini");
467 if (PathFileExistsW(pStartInfo
->szFreeldrIni
))
469 /* Free resource previously allocated by GetSystemDrive() */
470 HeapFree(GetProcessHeap(), 0, szSystemDrive
);
471 /* freeldr.ini exists */
472 hInf
= SetupOpenInfFileW(pStartInfo
->szFreeldrIni
,
477 if (hInf
!= INVALID_HANDLE_VALUE
)
479 LoadFreeldrSettings(hInf
, hwndDlg
);
480 SetupCloseInfFile(hInf
);
481 pStartInfo
->iFreeLdrIni
= 1;
487 /* Try loading boot.ini settings */
488 wcscpy(pStartInfo
->szFreeldrIni
, szSystemDrive
);
489 wcscat(pStartInfo
->szFreeldrIni
, L
"\\boot.ini");
491 /* Free resource previously allocated by GetSystemDrive() */
492 HeapFree(GetProcessHeap(), 0, szSystemDrive
);
494 if (PathFileExistsW(pStartInfo
->szFreeldrIni
))
496 /* Load boot.ini settings */
497 hInf
= SetupOpenInfFileW(pStartInfo
->szFreeldrIni
,
502 if (hInf
!= INVALID_HANDLE_VALUE
)
504 LoadBootSettings(hInf
, hwndDlg
);
505 SetupCloseInfFile(hInf
);
506 pStartInfo
->iFreeLdrIni
= 2;
517 SetCrashDlgItems(HWND hwnd
, PSTARTINFO pStartInfo
)
519 if (pStartInfo
->dwCrashDumpEnabled
== 0)
521 /* No crash information required */
522 EnableWindow(GetDlgItem(hwnd
, IDC_STRRECDUMPFILE
), FALSE
);
523 EnableWindow(GetDlgItem(hwnd
, IDC_STRRECOVERWRITE
), FALSE
);
525 else if (pStartInfo
->dwCrashDumpEnabled
== 3)
528 EnableWindow(GetDlgItem(hwnd
, IDC_STRRECDUMPFILE
), TRUE
);
529 EnableWindow(GetDlgItem(hwnd
, IDC_STRRECOVERWRITE
), FALSE
);
530 SendMessageW(GetDlgItem(hwnd
, IDC_STRRECDUMPFILE
), WM_SETTEXT
, (WPARAM
)0, (LPARAM
)pStartInfo
->szMinidumpDir
);
532 else if (pStartInfo
->dwCrashDumpEnabled
== 1 || pStartInfo
->dwCrashDumpEnabled
== 2)
534 /* Kernel or complete dump */
535 EnableWindow(GetDlgItem(hwnd
, IDC_STRRECDUMPFILE
), TRUE
);
536 EnableWindow(GetDlgItem(hwnd
, IDC_STRRECOVERWRITE
), TRUE
);
537 SendMessageW(GetDlgItem(hwnd
, IDC_STRRECDUMPFILE
), WM_SETTEXT
, (WPARAM
)0, (LPARAM
)pStartInfo
->szDumpFile
);
539 SendDlgItemMessageW(hwnd
, IDC_STRRECDEBUGCOMBO
, CB_SETCURSEL
, (WPARAM
)pStartInfo
->dwCrashDumpEnabled
, (LPARAM
)0);
543 WriteStartupRecoveryOptions(HWND hwndDlg
, PSTARTINFO pStartInfo
)
548 lResult
= (DWORD
)RegCreateKeyExW(HKEY_LOCAL_MACHINE
,
549 L
"System\\CurrentControlSet\\Control\\CrashControl",
552 REG_OPTION_NON_VOLATILE
,
557 if (lResult
!= ERROR_SUCCESS
)
559 /* Failed to open key */
560 SetLastError(lResult
);
561 ShowLastWin32Error(hwndDlg
);
566 lResult
= (DWORD
) SendDlgItemMessage(hwndDlg
, IDC_STRRECWRITEEVENT
, BM_GETCHECK
, (WPARAM
)0, (LPARAM
)0);
567 RegSetValueExW(hKey
, L
"LogEvent", 0, REG_DWORD
, (LPBYTE
)&lResult
, sizeof(lResult
));
569 lResult
= (DWORD
) SendDlgItemMessage(hwndDlg
, IDC_STRRECSENDALERT
, BM_GETCHECK
, (WPARAM
)0, (LPARAM
)0);
570 RegSetValueExW(hKey
, L
"SendAlert", 0, REG_DWORD
, (LPBYTE
)&lResult
, sizeof(lResult
));
572 lResult
= (DWORD
) SendDlgItemMessage(hwndDlg
, IDC_STRRECRESTART
, BM_GETCHECK
, (WPARAM
)0, (LPARAM
)0);
573 RegSetValueExW(hKey
, L
"AutoReboot", 0, REG_DWORD
, (LPBYTE
)&lResult
, sizeof(lResult
));
575 lResult
= (DWORD
) SendDlgItemMessage(hwndDlg
, IDC_STRRECOVERWRITE
, BM_GETCHECK
, (WPARAM
)0, (LPARAM
)0);
576 RegSetValueExW(hKey
, L
"Overwrite", 0, REG_DWORD
, (LPBYTE
)&lResult
, sizeof(lResult
));
579 if (pStartInfo
->dwCrashDumpEnabled
== 1 || pStartInfo
->dwCrashDumpEnabled
== 2)
581 SendDlgItemMessage(hwndDlg
, IDC_STRRECDUMPFILE
, WM_GETTEXT
, (WPARAM
)sizeof(pStartInfo
->szDumpFile
) / sizeof(WCHAR
), (LPARAM
)pStartInfo
->szDumpFile
);
582 RegSetValueExW(hKey
, L
"DumpFile", 0, REG_EXPAND_SZ
, (LPBYTE
)pStartInfo
->szDumpFile
, (wcslen(pStartInfo
->szDumpFile
) + 1) * sizeof(WCHAR
));
584 else if (pStartInfo
->dwCrashDumpEnabled
== 3)
586 SendDlgItemMessage(hwndDlg
, IDC_STRRECDUMPFILE
, WM_GETTEXT
, (WPARAM
)sizeof(pStartInfo
->szDumpFile
) / sizeof(WCHAR
), (LPARAM
)pStartInfo
->szDumpFile
);
587 RegSetValueExW(hKey
, L
"MinidumpDir", 0, REG_EXPAND_SZ
, (LPBYTE
)pStartInfo
->szDumpFile
, (wcslen(pStartInfo
->szDumpFile
) + 1) * sizeof(WCHAR
));
590 RegSetValueExW(hKey
, L
"CrashDumpEnabled", 0, REG_DWORD
, (LPBYTE
)&pStartInfo
->dwCrashDumpEnabled
, sizeof(pStartInfo
->dwCrashDumpEnabled
));
595 LoadRecoveryOptions(HWND hwndDlg
, PSTARTINFO pStartInfo
)
598 WCHAR szName
[MAX_PATH
];
599 DWORD dwValue
, dwValueLength
, dwType
, dwResult
;
601 dwResult
= (DWORD
)RegCreateKeyExW(HKEY_LOCAL_MACHINE
,
602 L
"System\\CurrentControlSet\\Control\\CrashControl",
605 REG_OPTION_NON_VOLATILE
,
610 if (dwResult
!= ERROR_SUCCESS
)
612 /* Failed to open key */
613 SetLastError(dwResult
);
614 ShowLastWin32Error(hwndDlg
);
616 EnableWindow(GetDlgItem(hwndDlg
, IDC_STRRECWRITEEVENT
), FALSE
);
617 EnableWindow(GetDlgItem(hwndDlg
, IDC_STRRECSENDALERT
), FALSE
);
618 EnableWindow(GetDlgItem(hwndDlg
, IDC_STRRECRESTART
), FALSE
);
619 EnableWindow(GetDlgItem(hwndDlg
, IDC_STRRECDEBUGCOMBO
), FALSE
);
620 EnableWindow(GetDlgItem(hwndDlg
, IDC_STRRECDUMPFILE
), FALSE
);
621 EnableWindow(GetDlgItem(hwndDlg
, IDC_STRRECOVERWRITE
), FALSE
);
623 SaveRecoveryOptions
= FALSE
;
627 dwValueLength
= sizeof(DWORD
);
628 if (RegQueryValueExW(hKey
, L
"LogEvent", NULL
, &dwType
, (LPBYTE
)&dwValue
, &dwValueLength
) == ERROR_SUCCESS
&& dwType
== REG_DWORD
&& dwValue
)
629 SendDlgItemMessageW(hwndDlg
, IDC_STRRECWRITEEVENT
, BM_SETCHECK
, (WPARAM
)BST_CHECKED
, (LPARAM
)0);
631 dwValueLength
= sizeof(DWORD
);
632 if (RegQueryValueExW(hKey
, L
"SendAlert", NULL
, &dwType
, (LPBYTE
)&dwValue
, &dwValueLength
) == ERROR_SUCCESS
&& dwType
== REG_DWORD
&& dwValue
)
633 SendDlgItemMessageW(hwndDlg
, IDC_STRRECSENDALERT
, BM_SETCHECK
, (WPARAM
)BST_CHECKED
, (LPARAM
)0);
635 dwValueLength
= sizeof(DWORD
);
636 if (RegQueryValueExW(hKey
, L
"AutoReboot", NULL
, &dwType
, (LPBYTE
)&dwValue
, &dwValueLength
) == ERROR_SUCCESS
&& dwType
== REG_DWORD
&& dwValue
)
637 SendDlgItemMessageW(hwndDlg
, IDC_STRRECRESTART
, BM_SETCHECK
, (WPARAM
)BST_CHECKED
, (LPARAM
)0);
639 dwValueLength
= sizeof(DWORD
);
640 if (RegQueryValueExW(hKey
, L
"Overwrite", NULL
, &dwType
, (LPBYTE
)&dwValue
, &dwValueLength
) == ERROR_SUCCESS
&& dwType
== REG_DWORD
&& dwValue
)
641 SendDlgItemMessageW(hwndDlg
, IDC_STRRECOVERWRITE
, BM_SETCHECK
, (WPARAM
)BST_CHECKED
, (LPARAM
)0);
643 dwValueLength
= sizeof(DWORD
);
644 if (RegQueryValueExW(hKey
, L
"CrashDumpEnabled", NULL
, &dwType
, (LPBYTE
)&dwValue
, &dwValueLength
) == ERROR_SUCCESS
&& dwType
== REG_DWORD
&& dwValue
)
645 pStartInfo
->dwCrashDumpEnabled
= dwValue
;
647 dwValueLength
= sizeof(pStartInfo
->szDumpFile
);
648 if (RegQueryValueExW(hKey
, L
"DumpFile", NULL
, &dwType
, (LPBYTE
)pStartInfo
->szDumpFile
, &dwValueLength
) != ERROR_SUCCESS
)
649 pStartInfo
->szDumpFile
[0] = L
'\0';
651 dwValueLength
= sizeof(pStartInfo
->szMinidumpDir
);
652 if (RegQueryValueExW(hKey
, L
"MinidumpDir", NULL
, &dwType
, (LPBYTE
)pStartInfo
->szMinidumpDir
, &dwValueLength
) != ERROR_SUCCESS
)
653 pStartInfo
->szMinidumpDir
[0] = L
'\0';
655 if (LoadStringW(hApplet
, IDS_NO_DUMP
, szName
, sizeof(szName
) / sizeof(WCHAR
)))
657 szName
[(sizeof(szName
)/sizeof(WCHAR
))-1] = L
'\0';
658 SendDlgItemMessageW(hwndDlg
, IDC_STRRECDEBUGCOMBO
, CB_ADDSTRING
, (WPARAM
)0, (LPARAM
) szName
);
661 if (LoadStringW(hApplet
, IDS_FULL_DUMP
, szName
, sizeof(szName
) / sizeof(WCHAR
)))
663 szName
[(sizeof(szName
)/sizeof(WCHAR
))-1] = L
'\0';
664 SendDlgItemMessageW(hwndDlg
, IDC_STRRECDEBUGCOMBO
, CB_ADDSTRING
, (WPARAM
)0, (LPARAM
) szName
);
667 if (LoadStringW(hApplet
, IDS_KERNEL_DUMP
, szName
, sizeof(szName
) / sizeof(WCHAR
)))
669 szName
[(sizeof(szName
)/sizeof(WCHAR
))-1] = L
'\0';
670 SendDlgItemMessageW(hwndDlg
, IDC_STRRECDEBUGCOMBO
, CB_ADDSTRING
, (WPARAM
)0, (LPARAM
) szName
);
673 if (LoadStringW(hApplet
, IDS_MINI_DUMP
, szName
, sizeof(szName
) / sizeof(WCHAR
)))
675 szName
[(sizeof(szName
)/sizeof(WCHAR
))-1] = L
'\0';
676 SendDlgItemMessageW(hwndDlg
, IDC_STRRECDEBUGCOMBO
, CB_ADDSTRING
, (WPARAM
)0, (LPARAM
) szName
);
679 SetCrashDlgItems(hwndDlg
, pStartInfo
);
682 SaveRecoveryOptions
= TRUE
;
686 /* Property page dialog callback */
688 StartRecDlgProc(HWND hwndDlg
,
693 PSTARTINFO pStartInfo
;
699 UNREFERENCED_PARAMETER(lParam
);
701 pStartInfo
= (PSTARTINFO
)GetWindowLongPtr(hwndDlg
, DWLP_USER
);
706 pStartInfo
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(STARTINFO
));
707 SetWindowLongPtr(hwndDlg
, DWLP_USER
, (LONG_PTR
)pStartInfo
);
709 LoadRecoveryOptions(hwndDlg
, pStartInfo
);
710 SetRecoveryTimeout(hwndDlg
, 0);
711 return LoadOSList(hwndDlg
, pStartInfo
);
714 DeleteBootRecords(hwndDlg
);
715 HeapFree(GetProcessHeap(), 0, pStartInfo
);
719 switch(LOWORD(wParam
))
722 ShellExecuteW(0, L
"open", L
"notepad", pStartInfo
->szFreeldrIni
, NULL
, SW_SHOWNORMAL
);
723 // FIXME: Use CreateProcess and wait untill finished
724 // DeleteBootRecords(hwndDlg);
725 // LoadOSList(hwndDlg);
730 if (SendDlgItemMessage(hwndDlg
, IDC_STRECLIST
, BM_GETCHECK
, (WPARAM
)0, (LPARAM
)0) == BST_CHECKED
)
731 iTimeout
= SendDlgItemMessage(hwndDlg
, IDC_STRRECLISTUPDWN
, UDM_GETPOS
, (WPARAM
)0, (LPARAM
)0);
734 swprintf(szTimeout
, L
"%i", iTimeout
);
736 lResult
= SendDlgItemMessageW(hwndDlg
, IDC_STRECOSCOMBO
, CB_GETCURSEL
, (WPARAM
)0, (LPARAM
)0);
737 if (lResult
== CB_ERR
)
740 DeleteBootRecords(hwndDlg
);
744 pRecord
= (PBOOTRECORD
) SendDlgItemMessage(hwndDlg
, IDC_STRECOSCOMBO
, CB_GETITEMDATA
, (WPARAM
)lResult
, (LPARAM
)0);
746 if ((INT_PTR
)pRecord
!= CB_ERR
)
748 if (pStartInfo
->iFreeLdrIni
== 1) // FreeLdrIni style
750 /* Set default timeout */
751 WritePrivateProfileStringW(L
"FREELOADER",
754 pStartInfo
->szFreeldrIni
);
756 WritePrivateProfileStringW(L
"FREELOADER",
758 pRecord
->szSectionName
,
759 pStartInfo
->szFreeldrIni
);
762 else if (pStartInfo
->iFreeLdrIni
== 2) // BootIni style
764 /* Set default timeout */
765 WritePrivateProfileStringW(L
"boot loader",
768 pStartInfo
->szFreeldrIni
);
770 WritePrivateProfileStringW(L
"boot loader",
773 pStartInfo
->szFreeldrIni
);
778 if (SaveRecoveryOptions
)
780 WriteStartupRecoveryOptions(hwndDlg
, pStartInfo
);
793 if (SendDlgItemMessage(hwndDlg
, IDC_STRECLIST
, BM_GETCHECK
, (WPARAM
)0, (LPARAM
)0) == BST_CHECKED
)
794 SetTimeout(hwndDlg
, 30);
796 SetTimeout(hwndDlg
, 0);
800 if (SendDlgItemMessage(hwndDlg
, IDC_STRRECREC
, BM_GETCHECK
, (WPARAM
)0, (LPARAM
)0) == BST_CHECKED
)
801 SetRecoveryTimeout(hwndDlg
, 30);
803 SetRecoveryTimeout(hwndDlg
, 0);
806 case IDC_STRRECDEBUGCOMBO
:
807 if (HIWORD(wParam
) == CBN_SELCHANGE
)
811 lResult
= SendDlgItemMessage(hwndDlg
, IDC_STRRECDEBUGCOMBO
, CB_GETCURSEL
, (WPARAM
)0, (LPARAM
)0);
812 if (lResult
!= CB_ERR
&& lResult
!= (LRESULT
)pStartInfo
->dwCrashDumpEnabled
)
814 if (pStartInfo
->dwCrashDumpEnabled
== 1 || pStartInfo
->dwCrashDumpEnabled
== 2)
816 SendDlgItemMessageW(hwndDlg
, IDC_STRRECDUMPFILE
, WM_GETTEXT
, (WPARAM
)sizeof(pStartInfo
->szDumpFile
) / sizeof(WCHAR
), (LPARAM
)pStartInfo
->szDumpFile
);
818 else if (pStartInfo
->dwCrashDumpEnabled
== 3)
820 SendDlgItemMessageW(hwndDlg
, IDC_STRRECDUMPFILE
, WM_GETTEXT
, (WPARAM
)sizeof(pStartInfo
->szMinidumpDir
) / sizeof(WCHAR
), (LPARAM
)pStartInfo
->szMinidumpDir
);
823 pStartInfo
->dwCrashDumpEnabled
= (DWORD
)lResult
;
824 SetCrashDlgItems(hwndDlg
, pStartInfo
);