2006-11-08 11:47:44 +00:00
|
|
|
/*
|
|
|
|
* PROJECT: ReactOS System Control Panel Applet
|
|
|
|
* LICENSE: GPL - See COPYING in the top level directory
|
|
|
|
* FILE: dll/cpl/sysdm/startrec.c
|
|
|
|
* PURPOSE: Computer settings for startup and recovery
|
|
|
|
* COPYRIGHT: Copyright 2006 Ged Murphy <gedmurphy@gmail.com>
|
|
|
|
* Copyright 2006 Christoph von Wittich <Christoph@ApiViewer.de>
|
2013-09-15 13:06:05 +00:00
|
|
|
* Copyright 2007 Johannes Anderwald <johannes.anderwald@reactos.org>
|
2006-11-08 11:47:44 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "precomp.h"
|
2007-11-04 22:12:25 +00:00
|
|
|
|
2014-01-19 10:39:14 +00:00
|
|
|
#include <shlwapi.h>
|
|
|
|
|
2007-11-04 22:12:25 +00:00
|
|
|
typedef struct _STARTINFO
|
|
|
|
{
|
2008-10-30 10:46:55 +00:00
|
|
|
WCHAR szFreeldrIni[MAX_PATH + 15];
|
|
|
|
WCHAR szDumpFile[MAX_PATH];
|
|
|
|
WCHAR szMinidumpDir[MAX_PATH];
|
2007-11-04 22:12:25 +00:00
|
|
|
DWORD dwCrashDumpEnabled;
|
|
|
|
INT iFreeLdrIni;
|
|
|
|
} STARTINFO, *PSTARTINFO;
|
|
|
|
|
2014-12-26 13:11:57 +00:00
|
|
|
BOOL SaveRecoveryOptions;
|
2007-08-20 22:01:54 +00:00
|
|
|
|
2007-11-03 14:39:08 +00:00
|
|
|
static VOID
|
|
|
|
SetTimeout(HWND hwndDlg, INT Timeout)
|
2006-11-08 11:47:44 +00:00
|
|
|
{
|
2007-07-23 16:32:04 +00:00
|
|
|
if (Timeout == 0)
|
|
|
|
{
|
|
|
|
EnableWindow(GetDlgItem(hwndDlg, IDC_STRRECLISTUPDWN), FALSE);
|
2008-06-28 12:48:06 +00:00
|
|
|
EnableWindow(GetDlgItem(hwndDlg, IDC_STRRECLISTEDIT), FALSE);
|
2007-07-23 16:32:04 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
EnableWindow(GetDlgItem(hwndDlg, IDC_STRRECLISTUPDWN), TRUE);
|
2008-06-28 12:48:06 +00:00
|
|
|
EnableWindow(GetDlgItem(hwndDlg, IDC_STRRECLISTEDIT), TRUE);
|
2007-07-23 16:32:04 +00:00
|
|
|
}
|
2008-10-30 10:46:55 +00:00
|
|
|
SendDlgItemMessageW(hwndDlg, IDC_STRRECLISTUPDWN, UDM_SETRANGE, (WPARAM) 0, (LPARAM) MAKELONG((short) 999, 0));
|
|
|
|
SendDlgItemMessageW(hwndDlg, IDC_STRRECLISTUPDWN, UDM_SETPOS, (WPARAM) 0, (LPARAM) MAKELONG((short) Timeout, 0));
|
2006-11-08 11:47:44 +00:00
|
|
|
}
|
|
|
|
|
2008-06-28 12:48:06 +00:00
|
|
|
static VOID
|
|
|
|
SetRecoveryTimeout(HWND hwndDlg, INT Timeout)
|
|
|
|
{
|
|
|
|
if (Timeout == 0)
|
|
|
|
{
|
|
|
|
EnableWindow(GetDlgItem(hwndDlg, IDC_STRRECRECUPDWN), FALSE);
|
|
|
|
EnableWindow(GetDlgItem(hwndDlg, IDC_STRRECRECEDIT), FALSE);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
EnableWindow(GetDlgItem(hwndDlg, IDC_STRRECRECUPDWN), TRUE);
|
|
|
|
EnableWindow(GetDlgItem(hwndDlg, IDC_STRRECRECEDIT), TRUE);
|
|
|
|
}
|
2008-10-30 10:46:55 +00:00
|
|
|
SendDlgItemMessageW(hwndDlg, IDC_STRRECRECUPDWN, UDM_SETRANGE, (WPARAM) 0, (LPARAM) MAKELONG((short) 999, 0));
|
|
|
|
SendDlgItemMessageW(hwndDlg, IDC_STRRECRECUPDWN, UDM_SETPOS, (WPARAM) 0, (LPARAM) MAKELONG((short) Timeout, 0));
|
2008-06-28 12:48:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-11-03 14:39:08 +00:00
|
|
|
static DWORD
|
2008-10-30 10:46:55 +00:00
|
|
|
GetSystemDrive(WCHAR **szSystemDrive)
|
2006-11-08 11:47:44 +00:00
|
|
|
{
|
2007-08-20 19:21:54 +00:00
|
|
|
DWORD dwBufSize;
|
2007-11-03 14:39:08 +00:00
|
|
|
|
2011-11-29 14:55:58 +00:00
|
|
|
/* Get Path to freeldr.ini or boot.ini */
|
2008-10-30 10:46:55 +00:00
|
|
|
*szSystemDrive = HeapAlloc(GetProcessHeap(), 0, MAX_PATH * sizeof(WCHAR));
|
2008-11-24 18:05:51 +00:00
|
|
|
if (*szSystemDrive != NULL)
|
2007-08-20 19:21:54 +00:00
|
|
|
{
|
2008-10-30 10:46:55 +00:00
|
|
|
dwBufSize = GetEnvironmentVariableW(L"SystemDrive", *szSystemDrive, MAX_PATH);
|
2007-08-20 19:21:54 +00:00
|
|
|
if (dwBufSize > MAX_PATH)
|
|
|
|
{
|
2008-10-30 10:46:55 +00:00
|
|
|
WCHAR *szTmp;
|
2007-08-20 19:21:54 +00:00
|
|
|
DWORD dwBufSize2;
|
2007-07-23 16:32:04 +00:00
|
|
|
|
2008-10-30 10:46:55 +00:00
|
|
|
szTmp = HeapReAlloc(GetProcessHeap(), 0, *szSystemDrive, dwBufSize * sizeof(WCHAR));
|
2007-08-20 19:21:54 +00:00
|
|
|
if (szTmp == NULL)
|
|
|
|
goto FailGetSysDrive;
|
2007-07-23 16:32:04 +00:00
|
|
|
|
2007-08-20 19:21:54 +00:00
|
|
|
*szSystemDrive = szTmp;
|
|
|
|
|
2008-10-30 10:46:55 +00:00
|
|
|
dwBufSize2 = GetEnvironmentVariableW(L"SystemDrive", *szSystemDrive, dwBufSize);
|
2007-08-20 19:21:54 +00:00
|
|
|
if (dwBufSize2 > dwBufSize || dwBufSize2 == 0)
|
|
|
|
goto FailGetSysDrive;
|
|
|
|
}
|
|
|
|
else if (dwBufSize == 0)
|
|
|
|
{
|
|
|
|
FailGetSysDrive:
|
2008-11-24 18:05:51 +00:00
|
|
|
HeapFree(GetProcessHeap(), 0, *szSystemDrive);
|
2007-08-20 19:21:54 +00:00
|
|
|
*szSystemDrive = NULL;
|
2008-11-24 18:05:51 +00:00
|
|
|
return 0;
|
2007-08-20 19:21:54 +00:00
|
|
|
}
|
2007-11-03 14:39:08 +00:00
|
|
|
|
2007-08-20 19:21:54 +00:00
|
|
|
return dwBufSize;
|
|
|
|
}
|
2007-11-03 14:39:08 +00:00
|
|
|
|
2008-11-24 18:05:51 +00:00
|
|
|
return 0;
|
2007-08-20 19:21:54 +00:00
|
|
|
}
|
|
|
|
|
2007-11-03 14:39:08 +00:00
|
|
|
static PBOOTRECORD
|
2008-10-30 10:46:55 +00:00
|
|
|
ReadFreeldrSection(HINF hInf, WCHAR *szSectionName)
|
2007-08-20 19:21:54 +00:00
|
|
|
{
|
2007-11-03 14:39:08 +00:00
|
|
|
PBOOTRECORD pRecord;
|
|
|
|
INFCONTEXT InfContext;
|
2008-10-30 10:46:55 +00:00
|
|
|
WCHAR szName[MAX_PATH];
|
|
|
|
WCHAR szValue[MAX_PATH];
|
2007-11-03 14:39:08 +00:00
|
|
|
DWORD LineLength;
|
|
|
|
|
2008-10-30 10:46:55 +00:00
|
|
|
if (!SetupFindFirstLineW(hInf,
|
2007-11-03 14:39:08 +00:00
|
|
|
szSectionName,
|
|
|
|
NULL,
|
|
|
|
&InfContext))
|
|
|
|
{
|
2011-11-29 14:55:58 +00:00
|
|
|
/* Failed to find section */
|
2007-11-03 14:39:08 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
pRecord = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(BOOTRECORD));
|
|
|
|
if (pRecord == NULL)
|
|
|
|
{
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2008-10-30 10:46:55 +00:00
|
|
|
wcscpy(pRecord->szSectionName, szSectionName);
|
2007-08-20 19:21:54 +00:00
|
|
|
|
|
|
|
do
|
2007-07-23 16:32:04 +00:00
|
|
|
{
|
2008-10-30 10:46:55 +00:00
|
|
|
if (!SetupGetStringFieldW(&InfContext,
|
2007-08-20 19:21:54 +00:00
|
|
|
0,
|
|
|
|
szName,
|
2008-10-30 10:46:55 +00:00
|
|
|
sizeof(szName) / sizeof(WCHAR),
|
2007-08-20 19:21:54 +00:00
|
|
|
&LineLength))
|
2007-07-23 16:32:04 +00:00
|
|
|
{
|
2007-08-20 19:21:54 +00:00
|
|
|
break;
|
|
|
|
}
|
2007-07-23 16:32:04 +00:00
|
|
|
|
2008-10-30 10:46:55 +00:00
|
|
|
if (!SetupGetStringFieldW(&InfContext,
|
2007-08-20 19:21:54 +00:00
|
|
|
1,
|
|
|
|
szValue,
|
2008-10-30 10:46:55 +00:00
|
|
|
sizeof(szValue) / sizeof(WCHAR),
|
2007-08-20 19:21:54 +00:00
|
|
|
&LineLength))
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2008-12-23 01:23:25 +00:00
|
|
|
if (!_wcsnicmp(szName, L"BootType", 8))
|
2007-08-20 19:21:54 +00:00
|
|
|
{
|
2008-12-23 01:23:25 +00:00
|
|
|
if (!_wcsnicmp(szValue, L"ReactOS", 7))
|
2007-07-23 16:32:04 +00:00
|
|
|
{
|
2011-11-29 14:55:58 +00:00
|
|
|
// FIXME: Store as enum
|
2007-10-19 23:21:45 +00:00
|
|
|
pRecord->BootType = 1;
|
2007-08-20 19:21:54 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
pRecord->BootType = 0;
|
|
|
|
}
|
|
|
|
}
|
2008-12-23 01:23:25 +00:00
|
|
|
else if (!_wcsnicmp(szName, L"SystemPath", 10))
|
2007-08-20 19:21:54 +00:00
|
|
|
{
|
2008-10-30 10:46:55 +00:00
|
|
|
wcscpy(pRecord->szBootPath, szValue);
|
2007-08-20 19:21:54 +00:00
|
|
|
}
|
2008-12-23 01:23:25 +00:00
|
|
|
else if (!_wcsnicmp(szName, L"Options", 7))
|
2007-08-20 19:21:54 +00:00
|
|
|
{
|
2011-11-29 14:55:58 +00:00
|
|
|
// FIXME: Store flags as values
|
2008-10-30 10:46:55 +00:00
|
|
|
wcscpy(pRecord->szOptions, szValue);
|
2007-08-20 19:21:54 +00:00
|
|
|
}
|
2007-07-23 16:32:04 +00:00
|
|
|
|
2007-11-03 14:39:08 +00:00
|
|
|
}
|
|
|
|
while (SetupFindNextLine(&InfContext, &InfContext));
|
2007-07-23 16:32:04 +00:00
|
|
|
|
2007-08-20 19:21:54 +00:00
|
|
|
return pRecord;
|
|
|
|
}
|
2007-07-23 16:32:04 +00:00
|
|
|
|
|
|
|
|
2007-11-03 14:39:08 +00:00
|
|
|
static INT
|
|
|
|
LoadFreeldrSettings(HINF hInf, HWND hwndDlg)
|
2007-08-20 19:21:54 +00:00
|
|
|
{
|
|
|
|
INFCONTEXT InfContext;
|
|
|
|
PBOOTRECORD pRecord;
|
2008-10-30 10:46:55 +00:00
|
|
|
WCHAR szDefaultOs[MAX_PATH];
|
|
|
|
WCHAR szName[MAX_PATH];
|
|
|
|
WCHAR szValue[MAX_PATH];
|
2007-08-20 19:21:54 +00:00
|
|
|
DWORD LineLength;
|
|
|
|
DWORD TimeOut;
|
|
|
|
LRESULT lResult;
|
|
|
|
|
2008-10-30 10:46:55 +00:00
|
|
|
if (!SetupFindFirstLineW(hInf,
|
|
|
|
L"FREELOADER",
|
|
|
|
L"DefaultOS",
|
2007-08-20 19:21:54 +00:00
|
|
|
&InfContext))
|
|
|
|
{
|
2011-11-29 14:55:58 +00:00
|
|
|
/* Failed to find default os */
|
2007-08-20 19:21:54 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2008-10-30 10:46:55 +00:00
|
|
|
if (!SetupGetStringFieldW(&InfContext,
|
2007-08-20 19:21:54 +00:00
|
|
|
1,
|
|
|
|
szDefaultOs,
|
2008-10-30 10:46:55 +00:00
|
|
|
sizeof(szDefaultOs) / sizeof(WCHAR),
|
2007-08-20 19:21:54 +00:00
|
|
|
&LineLength))
|
|
|
|
{
|
2011-11-29 14:55:58 +00:00
|
|
|
/* No key */
|
2007-08-20 19:21:54 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2008-10-30 10:46:55 +00:00
|
|
|
if (!SetupFindFirstLineW(hInf,
|
|
|
|
L"FREELOADER",
|
|
|
|
L"TimeOut",
|
2007-08-20 19:21:54 +00:00
|
|
|
&InfContext))
|
|
|
|
{
|
2011-11-29 14:55:58 +00:00
|
|
|
/* Expected to find timeout value */
|
2007-08-20 19:21:54 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-10-19 23:21:45 +00:00
|
|
|
if (!SetupGetIntField(&InfContext,
|
2007-08-20 19:21:54 +00:00
|
|
|
1,
|
|
|
|
(PINT)&TimeOut))
|
|
|
|
{
|
2011-11-29 14:55:58 +00:00
|
|
|
/* Failed to retrieve timeout */
|
2007-08-20 19:21:54 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
2007-10-19 23:21:45 +00:00
|
|
|
|
2008-10-30 10:46:55 +00:00
|
|
|
if (!SetupFindFirstLineW(hInf,
|
|
|
|
L"Operating Systems",
|
2007-08-20 19:21:54 +00:00
|
|
|
NULL,
|
|
|
|
&InfContext))
|
|
|
|
{
|
2011-11-29 14:55:58 +00:00
|
|
|
/* Expected list of operating systems */
|
2007-08-20 19:21:54 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
do
|
|
|
|
{
|
2008-10-30 10:46:55 +00:00
|
|
|
if (!SetupGetStringFieldW(&InfContext,
|
2007-08-20 19:21:54 +00:00
|
|
|
0,
|
|
|
|
szName,
|
2008-10-30 10:46:55 +00:00
|
|
|
sizeof(szName) / sizeof(WCHAR),
|
2007-08-20 19:21:54 +00:00
|
|
|
&LineLength))
|
|
|
|
{
|
2011-11-29 14:55:58 +00:00
|
|
|
/* The ini file is messed up */
|
2007-08-20 19:21:54 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2008-10-30 10:46:55 +00:00
|
|
|
if (!SetupGetStringFieldW(&InfContext,
|
2007-08-20 19:21:54 +00:00
|
|
|
1,
|
|
|
|
szValue,
|
2008-10-30 10:46:55 +00:00
|
|
|
sizeof(szValue) / sizeof(WCHAR),
|
2007-08-20 19:21:54 +00:00
|
|
|
&LineLength))
|
|
|
|
{
|
2011-11-29 14:55:58 +00:00
|
|
|
/* The ini file is messed up */
|
2007-08-20 19:21:54 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
pRecord = ReadFreeldrSection(hInf, szName);
|
|
|
|
if (pRecord)
|
|
|
|
{
|
2008-10-30 10:46:55 +00:00
|
|
|
lResult = SendDlgItemMessageW(hwndDlg, IDC_STRECOSCOMBO, CB_ADDSTRING, (WPARAM)0, (LPARAM)szValue);
|
2007-08-20 19:21:54 +00:00
|
|
|
if (lResult != CB_ERR)
|
|
|
|
{
|
2008-10-30 10:46:55 +00:00
|
|
|
SendDlgItemMessageW(hwndDlg, IDC_STRECOSCOMBO, CB_SETITEMDATA, (WPARAM)lResult, (LPARAM)pRecord);
|
|
|
|
if (!wcscmp(szDefaultOs, szName))
|
2007-07-23 16:32:04 +00:00
|
|
|
{
|
2011-11-29 14:55:58 +00:00
|
|
|
/* We store the friendly name as key */
|
2008-10-30 10:46:55 +00:00
|
|
|
wcscpy(szDefaultOs, szValue);
|
2007-07-23 16:32:04 +00:00
|
|
|
}
|
|
|
|
}
|
2007-08-20 19:21:54 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
HeapFree(GetProcessHeap(), 0, pRecord);
|
|
|
|
}
|
|
|
|
}
|
2007-11-03 14:39:08 +00:00
|
|
|
}
|
|
|
|
while (SetupFindNextLine(&InfContext, &InfContext));
|
2007-07-26 14:56:01 +00:00
|
|
|
|
2011-11-29 14:55:58 +00:00
|
|
|
/* Find default os in list */
|
2008-10-30 10:46:55 +00:00
|
|
|
lResult = SendDlgItemMessageW(hwndDlg, IDC_STRECOSCOMBO, CB_FINDSTRING, (WPARAM)-1, (LPARAM)szDefaultOs);
|
2007-08-20 19:21:54 +00:00
|
|
|
if (lResult != CB_ERR)
|
|
|
|
{
|
2011-11-29 14:55:58 +00:00
|
|
|
/* Set cur sel */
|
2008-10-30 10:46:55 +00:00
|
|
|
SendDlgItemMessageW(hwndDlg, IDC_STRECOSCOMBO, CB_SETCURSEL, (WPARAM)lResult, (LPARAM)0);
|
2007-08-20 19:21:54 +00:00
|
|
|
}
|
2007-07-23 16:32:04 +00:00
|
|
|
|
2007-08-20 22:10:55 +00:00
|
|
|
if(TimeOut)
|
|
|
|
{
|
2008-10-30 10:46:55 +00:00
|
|
|
SendDlgItemMessageW(hwndDlg, IDC_STRECLIST, BM_SETCHECK, (WPARAM)BST_CHECKED, (LPARAM)0);
|
2007-08-20 22:10:55 +00:00
|
|
|
}
|
2007-11-03 14:39:08 +00:00
|
|
|
|
2007-08-20 19:21:54 +00:00
|
|
|
SetTimeout(hwndDlg, TimeOut);
|
2007-11-03 14:39:08 +00:00
|
|
|
|
2007-08-20 19:21:54 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
2007-07-23 16:32:04 +00:00
|
|
|
|
2007-11-03 14:39:08 +00:00
|
|
|
static INT
|
|
|
|
LoadBootSettings(HINF hInf, HWND hwndDlg)
|
2007-08-20 19:21:54 +00:00
|
|
|
{
|
|
|
|
INFCONTEXT InfContext;
|
2008-10-30 10:46:55 +00:00
|
|
|
WCHAR szName[MAX_PATH];
|
|
|
|
WCHAR szValue[MAX_PATH];
|
2007-08-20 19:21:54 +00:00
|
|
|
DWORD LineLength;
|
|
|
|
DWORD TimeOut = 0;
|
2008-10-30 10:46:55 +00:00
|
|
|
WCHAR szDefaultOS[MAX_PATH];
|
|
|
|
WCHAR szOptions[MAX_PATH];
|
2007-08-20 19:21:54 +00:00
|
|
|
PBOOTRECORD pRecord;
|
|
|
|
LRESULT lResult;
|
|
|
|
|
2008-10-30 10:46:55 +00:00
|
|
|
if(!SetupFindFirstLineW(hInf,
|
|
|
|
L"boot loader",
|
2007-08-20 19:21:54 +00:00
|
|
|
NULL,
|
|
|
|
&InfContext))
|
|
|
|
{
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
do
|
|
|
|
{
|
2008-10-30 10:46:55 +00:00
|
|
|
if (!SetupGetStringFieldW(&InfContext,
|
2007-10-19 23:21:45 +00:00
|
|
|
0,
|
2007-08-20 19:21:54 +00:00
|
|
|
szName,
|
2008-10-30 10:46:55 +00:00
|
|
|
sizeof(szName) / sizeof(WCHAR),
|
2007-08-20 19:21:54 +00:00
|
|
|
&LineLength))
|
|
|
|
{
|
|
|
|
return FALSE;
|
|
|
|
}
|
2007-07-23 16:32:04 +00:00
|
|
|
|
2008-10-30 10:46:55 +00:00
|
|
|
if (!SetupGetStringFieldW(&InfContext,
|
2007-10-19 23:21:45 +00:00
|
|
|
1,
|
2007-08-20 19:21:54 +00:00
|
|
|
szValue,
|
2008-10-30 10:46:55 +00:00
|
|
|
sizeof(szValue) / sizeof(WCHAR),
|
2007-08-20 19:21:54 +00:00
|
|
|
&LineLength))
|
|
|
|
{
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2008-12-23 01:23:25 +00:00
|
|
|
if (!_wcsnicmp(szName, L"timeout", 7))
|
2007-08-20 19:21:54 +00:00
|
|
|
{
|
2008-10-30 10:46:55 +00:00
|
|
|
TimeOut = _wtoi(szValue);
|
2007-08-20 19:21:54 +00:00
|
|
|
}
|
2007-10-19 23:21:45 +00:00
|
|
|
|
2008-12-23 01:23:25 +00:00
|
|
|
if (!_wcsnicmp(szName, L"default", 7))
|
2007-08-20 19:21:54 +00:00
|
|
|
{
|
2008-10-30 10:46:55 +00:00
|
|
|
wcscpy(szDefaultOS, szValue);
|
2007-08-20 19:21:54 +00:00
|
|
|
}
|
|
|
|
|
2007-11-03 14:39:08 +00:00
|
|
|
}
|
|
|
|
while (SetupFindNextLine(&InfContext, &InfContext));
|
2007-08-20 19:21:54 +00:00
|
|
|
|
2008-10-30 10:46:55 +00:00
|
|
|
if (!SetupFindFirstLineW(hInf,
|
|
|
|
L"operating systems",
|
2007-08-20 19:21:54 +00:00
|
|
|
NULL,
|
|
|
|
&InfContext))
|
|
|
|
{
|
2011-11-29 14:55:58 +00:00
|
|
|
/* Failed to find operating systems section */
|
2007-08-20 19:21:54 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
do
|
|
|
|
{
|
2008-10-30 10:46:55 +00:00
|
|
|
if (!SetupGetStringFieldW(&InfContext,
|
2007-10-19 23:21:45 +00:00
|
|
|
0,
|
2007-08-20 19:21:54 +00:00
|
|
|
szName,
|
2008-10-30 10:46:55 +00:00
|
|
|
sizeof(szName) / sizeof(WCHAR),
|
2007-08-20 19:21:54 +00:00
|
|
|
&LineLength))
|
|
|
|
{
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2008-10-30 10:46:55 +00:00
|
|
|
if (!SetupGetStringFieldW(&InfContext,
|
2007-10-19 23:21:45 +00:00
|
|
|
1,
|
2007-08-20 19:21:54 +00:00
|
|
|
szValue,
|
2008-10-30 10:46:55 +00:00
|
|
|
sizeof(szValue) / sizeof(WCHAR),
|
2007-08-20 19:21:54 +00:00
|
|
|
&LineLength))
|
|
|
|
{
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2008-10-30 10:46:55 +00:00
|
|
|
SetupGetStringFieldW(&InfContext,
|
2007-10-19 23:21:45 +00:00
|
|
|
2,
|
2007-08-20 19:21:54 +00:00
|
|
|
szOptions,
|
2008-10-30 10:46:55 +00:00
|
|
|
sizeof(szOptions) / sizeof(WCHAR),
|
2007-08-20 19:21:54 +00:00
|
|
|
&LineLength);
|
|
|
|
|
|
|
|
pRecord = (PBOOTRECORD) HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(BOOTRECORD));
|
|
|
|
if (pRecord)
|
|
|
|
{
|
|
|
|
pRecord->BootType = 0;
|
2008-10-30 10:46:55 +00:00
|
|
|
wcscpy(pRecord->szBootPath, szName);
|
|
|
|
wcscpy(pRecord->szSectionName, szValue);
|
|
|
|
wcscpy(pRecord->szOptions, szOptions);
|
2007-08-20 19:21:54 +00:00
|
|
|
|
2008-10-30 10:46:55 +00:00
|
|
|
if (!wcscmp(szName, szDefaultOS))
|
2007-08-20 19:21:54 +00:00
|
|
|
{
|
|
|
|
/* ms boot ini stores the path not the friendly name */
|
2008-10-30 10:46:55 +00:00
|
|
|
wcscpy(szDefaultOS, szValue);
|
2007-08-20 19:21:54 +00:00
|
|
|
}
|
|
|
|
|
2008-10-30 10:46:55 +00:00
|
|
|
lResult = SendDlgItemMessageW(hwndDlg, IDC_STRECOSCOMBO, CB_ADDSTRING, (WPARAM)0, (LPARAM)szValue);
|
2007-08-20 19:21:54 +00:00
|
|
|
if (lResult != CB_ERR)
|
|
|
|
{
|
2008-10-30 10:46:55 +00:00
|
|
|
SendDlgItemMessageW(hwndDlg, IDC_STRECOSCOMBO, CB_SETITEMDATA, (WPARAM)lResult, (LPARAM)pRecord);
|
2007-08-20 19:21:54 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
HeapFree(GetProcessHeap(), 0, pRecord);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-11-03 14:39:08 +00:00
|
|
|
}
|
|
|
|
while (SetupFindNextLine(&InfContext, &InfContext));
|
|
|
|
|
2011-11-29 14:55:58 +00:00
|
|
|
/* Find default os in list */
|
2008-10-30 10:46:55 +00:00
|
|
|
lResult = SendDlgItemMessageW(hwndDlg, IDC_STRECOSCOMBO, CB_FINDSTRING, (WPARAM)0, (LPARAM)szDefaultOS);
|
2007-08-20 19:21:54 +00:00
|
|
|
if (lResult != CB_ERR)
|
|
|
|
{
|
2011-11-29 14:55:58 +00:00
|
|
|
/* Set cur sel */
|
2008-10-30 10:46:55 +00:00
|
|
|
SendDlgItemMessageW(hwndDlg, IDC_STRECOSCOMBO, CB_SETCURSEL, (WPARAM)lResult, (LPARAM)0);
|
2007-08-20 19:21:54 +00:00
|
|
|
}
|
2007-11-03 14:39:08 +00:00
|
|
|
|
2007-08-20 22:10:55 +00:00
|
|
|
if(TimeOut)
|
|
|
|
{
|
2008-10-30 10:46:55 +00:00
|
|
|
SendDlgItemMessageW(hwndDlg, IDC_STRECLIST, BM_SETCHECK, (WPARAM)BST_CHECKED, (LPARAM)0);
|
2007-08-20 22:10:55 +00:00
|
|
|
}
|
2007-08-20 19:21:54 +00:00
|
|
|
|
|
|
|
SetTimeout(hwndDlg, TimeOut);
|
2007-11-03 14:39:08 +00:00
|
|
|
|
2007-08-20 19:21:54 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2007-11-03 14:39:08 +00:00
|
|
|
static VOID
|
|
|
|
DeleteBootRecords(HWND hwndDlg)
|
2007-08-20 19:21:54 +00:00
|
|
|
{
|
|
|
|
LRESULT lIndex;
|
|
|
|
LONG index;
|
|
|
|
PBOOTRECORD pRecord;
|
|
|
|
|
2008-10-30 10:46:55 +00:00
|
|
|
lIndex = SendDlgItemMessageW(hwndDlg, IDC_STRECOSCOMBO, CB_GETCOUNT, (WPARAM)0, (LPARAM)0);
|
2007-08-20 19:21:54 +00:00
|
|
|
if (lIndex == CB_ERR)
|
|
|
|
return;
|
|
|
|
|
|
|
|
for (index = 0; index <lIndex; index++)
|
|
|
|
{
|
2008-10-30 10:46:55 +00:00
|
|
|
pRecord = (PBOOTRECORD) SendDlgItemMessageW(hwndDlg, IDC_STRECOSCOMBO, CB_GETITEMDATA, (WPARAM)index, (LPARAM)0);
|
2009-04-29 22:20:59 +00:00
|
|
|
if ((INT_PTR)pRecord != CB_ERR)
|
2007-08-20 19:21:54 +00:00
|
|
|
{
|
|
|
|
HeapFree(GetProcessHeap(), 0, pRecord);
|
|
|
|
}
|
|
|
|
}
|
2007-11-03 14:39:08 +00:00
|
|
|
|
2008-10-30 10:46:55 +00:00
|
|
|
SendDlgItemMessageW(hwndDlg, IDC_STRECOSCOMBO, CB_RESETCONTENT, (WPARAM)0, (LPARAM)0);
|
2007-08-20 19:21:54 +00:00
|
|
|
}
|
|
|
|
|
2007-11-03 14:39:08 +00:00
|
|
|
static LRESULT
|
2007-11-04 22:12:25 +00:00
|
|
|
LoadOSList(HWND hwndDlg, PSTARTINFO pStartInfo)
|
2007-08-20 19:21:54 +00:00
|
|
|
{
|
|
|
|
DWORD dwBufSize;
|
2008-10-30 10:46:55 +00:00
|
|
|
WCHAR *szSystemDrive;
|
2007-08-20 19:21:54 +00:00
|
|
|
HINF hInf;
|
2007-10-19 23:21:45 +00:00
|
|
|
|
2007-08-20 19:21:54 +00:00
|
|
|
dwBufSize = GetSystemDrive(&szSystemDrive);
|
2008-11-24 18:05:51 +00:00
|
|
|
if (dwBufSize == 0)
|
2007-08-20 19:21:54 +00:00
|
|
|
return FALSE;
|
2007-10-19 23:21:45 +00:00
|
|
|
|
2008-10-30 10:46:55 +00:00
|
|
|
wcscpy(pStartInfo->szFreeldrIni, szSystemDrive);
|
|
|
|
wcscat(pStartInfo->szFreeldrIni, L"\\freeldr.ini");
|
2007-11-03 14:39:08 +00:00
|
|
|
|
2008-10-30 10:46:55 +00:00
|
|
|
if (PathFileExistsW(pStartInfo->szFreeldrIni))
|
2007-08-20 19:21:54 +00:00
|
|
|
{
|
2011-11-29 14:55:58 +00:00
|
|
|
/* Free resource previously allocated by GetSystemDrive() */
|
2008-11-24 18:05:51 +00:00
|
|
|
HeapFree(GetProcessHeap(), 0, szSystemDrive);
|
2007-08-20 19:21:54 +00:00
|
|
|
/* freeldr.ini exists */
|
2008-10-30 10:46:55 +00:00
|
|
|
hInf = SetupOpenInfFileW(pStartInfo->szFreeldrIni,
|
2007-08-20 19:21:54 +00:00
|
|
|
NULL,
|
|
|
|
INF_STYLE_OLDNT,
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
if (hInf != INVALID_HANDLE_VALUE)
|
|
|
|
{
|
|
|
|
LoadFreeldrSettings(hInf, hwndDlg);
|
|
|
|
SetupCloseInfFile(hInf);
|
2007-11-04 22:12:25 +00:00
|
|
|
pStartInfo->iFreeLdrIni = 1;
|
2007-08-20 19:21:54 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
2007-11-03 14:39:08 +00:00
|
|
|
|
2011-11-29 14:55:58 +00:00
|
|
|
/* Try loading boot.ini settings */
|
2008-10-30 10:46:55 +00:00
|
|
|
wcscpy(pStartInfo->szFreeldrIni, szSystemDrive);
|
|
|
|
wcscat(pStartInfo->szFreeldrIni, L"\\boot.ini");
|
2007-08-20 19:21:54 +00:00
|
|
|
|
2011-11-29 14:55:58 +00:00
|
|
|
/* Free resource previously allocated by GetSystemDrive() */
|
2008-11-24 18:05:51 +00:00
|
|
|
HeapFree(GetProcessHeap(), 0, szSystemDrive);
|
|
|
|
|
2008-10-30 10:46:55 +00:00
|
|
|
if (PathFileExistsW(pStartInfo->szFreeldrIni))
|
2007-08-20 19:21:54 +00:00
|
|
|
{
|
2011-11-29 14:55:58 +00:00
|
|
|
/* Load boot.ini settings */
|
2008-10-30 10:46:55 +00:00
|
|
|
hInf = SetupOpenInfFileW(pStartInfo->szFreeldrIni,
|
2007-08-20 19:21:54 +00:00
|
|
|
NULL,
|
|
|
|
INF_STYLE_OLDNT,
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
if (hInf != INVALID_HANDLE_VALUE)
|
|
|
|
{
|
|
|
|
LoadBootSettings(hInf, hwndDlg);
|
|
|
|
SetupCloseInfFile(hInf);
|
2007-11-04 22:12:25 +00:00
|
|
|
pStartInfo->iFreeLdrIni = 2;
|
2007-08-20 19:21:54 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
2007-11-03 14:39:08 +00:00
|
|
|
|
2007-08-20 19:21:54 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
2007-11-03 14:39:08 +00:00
|
|
|
|
2007-08-20 19:21:54 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2007-11-03 14:39:08 +00:00
|
|
|
static VOID
|
2007-11-04 22:12:25 +00:00
|
|
|
SetCrashDlgItems(HWND hwnd, PSTARTINFO pStartInfo)
|
2007-08-20 21:41:05 +00:00
|
|
|
{
|
2007-11-04 22:12:25 +00:00
|
|
|
if (pStartInfo->dwCrashDumpEnabled == 0)
|
2007-08-20 21:41:05 +00:00
|
|
|
{
|
2011-11-29 14:55:58 +00:00
|
|
|
/* No crash information required */
|
2007-08-20 21:41:05 +00:00
|
|
|
EnableWindow(GetDlgItem(hwnd, IDC_STRRECDUMPFILE), FALSE);
|
|
|
|
EnableWindow(GetDlgItem(hwnd, IDC_STRRECOVERWRITE), FALSE);
|
|
|
|
}
|
2007-11-04 22:12:25 +00:00
|
|
|
else if (pStartInfo->dwCrashDumpEnabled == 3)
|
2007-08-20 21:41:05 +00:00
|
|
|
{
|
2011-11-29 14:55:58 +00:00
|
|
|
/* Minidump type */
|
2007-08-20 21:41:05 +00:00
|
|
|
EnableWindow(GetDlgItem(hwnd, IDC_STRRECDUMPFILE), TRUE);
|
|
|
|
EnableWindow(GetDlgItem(hwnd, IDC_STRRECOVERWRITE), FALSE);
|
2008-10-30 10:46:55 +00:00
|
|
|
SendMessageW(GetDlgItem(hwnd, IDC_STRRECDUMPFILE), WM_SETTEXT, (WPARAM)0, (LPARAM)pStartInfo->szMinidumpDir);
|
2007-08-20 21:41:05 +00:00
|
|
|
}
|
2007-11-04 22:12:25 +00:00
|
|
|
else if (pStartInfo->dwCrashDumpEnabled == 1 || pStartInfo->dwCrashDumpEnabled == 2)
|
2007-08-20 21:41:05 +00:00
|
|
|
{
|
2011-11-29 14:55:58 +00:00
|
|
|
/* Kernel or complete dump */
|
2007-08-20 21:41:05 +00:00
|
|
|
EnableWindow(GetDlgItem(hwnd, IDC_STRRECDUMPFILE), TRUE);
|
|
|
|
EnableWindow(GetDlgItem(hwnd, IDC_STRRECOVERWRITE), TRUE);
|
2008-10-30 10:46:55 +00:00
|
|
|
SendMessageW(GetDlgItem(hwnd, IDC_STRRECDUMPFILE), WM_SETTEXT, (WPARAM)0, (LPARAM)pStartInfo->szDumpFile);
|
2007-08-20 21:41:05 +00:00
|
|
|
}
|
2008-10-30 10:46:55 +00:00
|
|
|
SendDlgItemMessageW(hwnd, IDC_STRRECDEBUGCOMBO, CB_SETCURSEL, (WPARAM)pStartInfo->dwCrashDumpEnabled, (LPARAM)0);
|
2007-08-20 21:41:05 +00:00
|
|
|
}
|
|
|
|
|
2007-11-03 14:39:08 +00:00
|
|
|
static VOID
|
2007-11-04 22:12:25 +00:00
|
|
|
WriteStartupRecoveryOptions(HWND hwndDlg, PSTARTINFO pStartInfo)
|
2007-08-20 22:01:54 +00:00
|
|
|
{
|
|
|
|
HKEY hKey;
|
|
|
|
DWORD lResult;
|
2007-11-04 22:12:25 +00:00
|
|
|
|
2014-12-26 13:11:57 +00:00
|
|
|
lResult = (DWORD)RegCreateKeyExW(HKEY_LOCAL_MACHINE,
|
|
|
|
L"System\\CurrentControlSet\\Control\\CrashControl",
|
|
|
|
0,
|
|
|
|
NULL,
|
|
|
|
REG_OPTION_NON_VOLATILE,
|
|
|
|
KEY_WRITE,
|
|
|
|
NULL,
|
|
|
|
&hKey,
|
|
|
|
NULL);
|
|
|
|
if (lResult != ERROR_SUCCESS)
|
|
|
|
{
|
|
|
|
/* Failed to open key */
|
|
|
|
SetLastError(lResult);
|
|
|
|
ShowLastWin32Error(hwndDlg);
|
|
|
|
|
2007-08-20 22:01:54 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
lResult = (DWORD) SendDlgItemMessage(hwndDlg, IDC_STRRECWRITEEVENT, BM_GETCHECK, (WPARAM)0, (LPARAM)0);
|
2008-10-30 10:46:55 +00:00
|
|
|
RegSetValueExW(hKey, L"LogEvent", 0, REG_DWORD, (LPBYTE)&lResult, sizeof(lResult));
|
2007-08-20 22:01:54 +00:00
|
|
|
|
|
|
|
lResult = (DWORD) SendDlgItemMessage(hwndDlg, IDC_STRRECSENDALERT, BM_GETCHECK, (WPARAM)0, (LPARAM)0);
|
2008-10-30 10:46:55 +00:00
|
|
|
RegSetValueExW(hKey, L"SendAlert", 0, REG_DWORD, (LPBYTE)&lResult, sizeof(lResult));
|
2007-08-20 22:01:54 +00:00
|
|
|
|
|
|
|
lResult = (DWORD) SendDlgItemMessage(hwndDlg, IDC_STRRECRESTART, BM_GETCHECK, (WPARAM)0, (LPARAM)0);
|
2008-10-30 10:46:55 +00:00
|
|
|
RegSetValueExW(hKey, L"AutoReboot", 0, REG_DWORD, (LPBYTE)&lResult, sizeof(lResult));
|
2007-08-20 22:01:54 +00:00
|
|
|
|
|
|
|
lResult = (DWORD) SendDlgItemMessage(hwndDlg, IDC_STRRECOVERWRITE, BM_GETCHECK, (WPARAM)0, (LPARAM)0);
|
2008-10-30 10:46:55 +00:00
|
|
|
RegSetValueExW(hKey, L"Overwrite", 0, REG_DWORD, (LPBYTE)&lResult, sizeof(lResult));
|
2007-08-20 22:01:54 +00:00
|
|
|
|
|
|
|
|
2007-11-04 22:12:25 +00:00
|
|
|
if (pStartInfo->dwCrashDumpEnabled == 1 || pStartInfo->dwCrashDumpEnabled == 2)
|
2007-08-20 22:01:54 +00:00
|
|
|
{
|
2008-10-30 10:46:55 +00:00
|
|
|
SendDlgItemMessage(hwndDlg, IDC_STRRECDUMPFILE, WM_GETTEXT, (WPARAM)sizeof(pStartInfo->szDumpFile) / sizeof(WCHAR), (LPARAM)pStartInfo->szDumpFile);
|
|
|
|
RegSetValueExW(hKey, L"DumpFile", 0, REG_EXPAND_SZ, (LPBYTE)pStartInfo->szDumpFile, (wcslen(pStartInfo->szDumpFile) + 1) * sizeof(WCHAR));
|
2007-08-20 22:01:54 +00:00
|
|
|
}
|
2007-11-04 22:12:25 +00:00
|
|
|
else if (pStartInfo->dwCrashDumpEnabled == 3)
|
2007-08-20 22:01:54 +00:00
|
|
|
{
|
2008-10-30 10:46:55 +00:00
|
|
|
SendDlgItemMessage(hwndDlg, IDC_STRRECDUMPFILE, WM_GETTEXT, (WPARAM)sizeof(pStartInfo->szDumpFile) / sizeof(WCHAR), (LPARAM)pStartInfo->szDumpFile);
|
|
|
|
RegSetValueExW(hKey, L"MinidumpDir", 0, REG_EXPAND_SZ, (LPBYTE)pStartInfo->szDumpFile, (wcslen(pStartInfo->szDumpFile) + 1) * sizeof(WCHAR));
|
2007-08-20 22:01:54 +00:00
|
|
|
}
|
|
|
|
|
2009-04-29 21:57:47 +00:00
|
|
|
RegSetValueExW(hKey, L"CrashDumpEnabled", 0, REG_DWORD, (LPBYTE)&pStartInfo->dwCrashDumpEnabled, sizeof(pStartInfo->dwCrashDumpEnabled));
|
2007-08-20 22:01:54 +00:00
|
|
|
RegCloseKey(hKey);
|
|
|
|
}
|
|
|
|
|
2007-11-03 14:39:08 +00:00
|
|
|
static VOID
|
2007-11-04 22:12:25 +00:00
|
|
|
LoadRecoveryOptions(HWND hwndDlg, PSTARTINFO pStartInfo)
|
2007-08-20 21:41:05 +00:00
|
|
|
{
|
|
|
|
HKEY hKey;
|
2008-10-30 10:46:55 +00:00
|
|
|
WCHAR szName[MAX_PATH];
|
2014-12-26 13:11:57 +00:00
|
|
|
DWORD dwValue, dwValueLength, dwType, dwResult;
|
|
|
|
|
|
|
|
dwResult = (DWORD)RegCreateKeyExW(HKEY_LOCAL_MACHINE,
|
|
|
|
L"System\\CurrentControlSet\\Control\\CrashControl",
|
|
|
|
0,
|
|
|
|
NULL,
|
|
|
|
REG_OPTION_NON_VOLATILE,
|
|
|
|
KEY_READ,
|
|
|
|
NULL,
|
|
|
|
&hKey,
|
|
|
|
NULL);
|
|
|
|
if (dwResult != ERROR_SUCCESS)
|
2007-08-20 21:41:05 +00:00
|
|
|
{
|
2011-11-29 14:55:58 +00:00
|
|
|
/* Failed to open key */
|
2014-12-26 13:11:57 +00:00
|
|
|
SetLastError(dwResult);
|
|
|
|
ShowLastWin32Error(hwndDlg);
|
|
|
|
|
|
|
|
EnableWindow(GetDlgItem(hwndDlg, IDC_STRRECWRITEEVENT), FALSE);
|
|
|
|
EnableWindow(GetDlgItem(hwndDlg, IDC_STRRECSENDALERT), FALSE);
|
|
|
|
EnableWindow(GetDlgItem(hwndDlg, IDC_STRRECRESTART), FALSE);
|
|
|
|
EnableWindow(GetDlgItem(hwndDlg, IDC_STRRECDEBUGCOMBO), FALSE);
|
|
|
|
EnableWindow(GetDlgItem(hwndDlg, IDC_STRRECDUMPFILE), FALSE);
|
|
|
|
EnableWindow(GetDlgItem(hwndDlg, IDC_STRRECOVERWRITE), FALSE);
|
|
|
|
|
|
|
|
SaveRecoveryOptions = FALSE;
|
2007-08-20 21:41:05 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2008-10-30 10:46:55 +00:00
|
|
|
dwValueLength = sizeof(DWORD);
|
|
|
|
if (RegQueryValueExW(hKey, L"LogEvent", NULL, &dwType, (LPBYTE)&dwValue, &dwValueLength) == ERROR_SUCCESS && dwType == REG_DWORD && dwValue)
|
|
|
|
SendDlgItemMessageW(hwndDlg, IDC_STRRECWRITEEVENT, BM_SETCHECK, (WPARAM)BST_CHECKED, (LPARAM)0);
|
2007-08-20 21:41:05 +00:00
|
|
|
|
2008-10-30 10:46:55 +00:00
|
|
|
dwValueLength = sizeof(DWORD);
|
|
|
|
if (RegQueryValueExW(hKey, L"SendAlert", NULL, &dwType, (LPBYTE)&dwValue, &dwValueLength) == ERROR_SUCCESS && dwType == REG_DWORD && dwValue)
|
|
|
|
SendDlgItemMessageW(hwndDlg, IDC_STRRECSENDALERT, BM_SETCHECK, (WPARAM)BST_CHECKED, (LPARAM)0);
|
2007-08-20 21:41:05 +00:00
|
|
|
|
2008-10-30 10:46:55 +00:00
|
|
|
dwValueLength = sizeof(DWORD);
|
|
|
|
if (RegQueryValueExW(hKey, L"AutoReboot", NULL, &dwType, (LPBYTE)&dwValue, &dwValueLength) == ERROR_SUCCESS && dwType == REG_DWORD && dwValue)
|
|
|
|
SendDlgItemMessageW(hwndDlg, IDC_STRRECRESTART, BM_SETCHECK, (WPARAM)BST_CHECKED, (LPARAM)0);
|
2007-08-20 21:41:05 +00:00
|
|
|
|
2008-10-30 10:46:55 +00:00
|
|
|
dwValueLength = sizeof(DWORD);
|
|
|
|
if (RegQueryValueExW(hKey, L"Overwrite", NULL, &dwType, (LPBYTE)&dwValue, &dwValueLength) == ERROR_SUCCESS && dwType == REG_DWORD && dwValue)
|
|
|
|
SendDlgItemMessageW(hwndDlg, IDC_STRRECOVERWRITE, BM_SETCHECK, (WPARAM)BST_CHECKED, (LPARAM)0);
|
|
|
|
|
|
|
|
dwValueLength = sizeof(DWORD);
|
|
|
|
if (RegQueryValueExW(hKey, L"CrashDumpEnabled", NULL, &dwType, (LPBYTE)&dwValue, &dwValueLength) == ERROR_SUCCESS && dwType == REG_DWORD && dwValue)
|
|
|
|
pStartInfo->dwCrashDumpEnabled = dwValue;
|
2007-08-20 21:41:05 +00:00
|
|
|
|
2008-10-30 10:46:55 +00:00
|
|
|
dwValueLength = sizeof(pStartInfo->szDumpFile);
|
|
|
|
if (RegQueryValueExW(hKey, L"DumpFile", NULL, &dwType, (LPBYTE)pStartInfo->szDumpFile, &dwValueLength) != ERROR_SUCCESS)
|
|
|
|
pStartInfo->szDumpFile[0] = L'\0';
|
2007-11-03 14:39:08 +00:00
|
|
|
|
2008-10-30 10:46:55 +00:00
|
|
|
dwValueLength = sizeof(pStartInfo->szMinidumpDir);
|
|
|
|
if (RegQueryValueExW(hKey, L"MinidumpDir", NULL, &dwType, (LPBYTE)pStartInfo->szMinidumpDir, &dwValueLength) != ERROR_SUCCESS)
|
|
|
|
pStartInfo->szMinidumpDir[0] = L'\0';
|
2007-11-03 14:39:08 +00:00
|
|
|
|
2008-10-30 10:46:55 +00:00
|
|
|
if (LoadStringW(hApplet, IDS_NO_DUMP, szName, sizeof(szName) / sizeof(WCHAR)))
|
|
|
|
{
|
|
|
|
szName[(sizeof(szName)/sizeof(WCHAR))-1] = L'\0';
|
|
|
|
SendDlgItemMessageW(hwndDlg, IDC_STRRECDEBUGCOMBO, CB_ADDSTRING, (WPARAM)0, (LPARAM) szName);
|
|
|
|
}
|
2007-11-03 14:39:08 +00:00
|
|
|
|
2014-12-26 13:11:57 +00:00
|
|
|
if (LoadStringW(hApplet, IDS_FULL_DUMP, szName, sizeof(szName) / sizeof(WCHAR)))
|
2008-10-30 10:46:55 +00:00
|
|
|
{
|
|
|
|
szName[(sizeof(szName)/sizeof(WCHAR))-1] = L'\0';
|
|
|
|
SendDlgItemMessageW(hwndDlg, IDC_STRRECDEBUGCOMBO, CB_ADDSTRING, (WPARAM)0, (LPARAM) szName);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (LoadStringW(hApplet, IDS_KERNEL_DUMP, szName, sizeof(szName) / sizeof(WCHAR)))
|
|
|
|
{
|
|
|
|
szName[(sizeof(szName)/sizeof(WCHAR))-1] = L'\0';
|
|
|
|
SendDlgItemMessageW(hwndDlg, IDC_STRRECDEBUGCOMBO, CB_ADDSTRING, (WPARAM)0, (LPARAM) szName);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (LoadStringW(hApplet, IDS_MINI_DUMP, szName, sizeof(szName) / sizeof(WCHAR)))
|
|
|
|
{
|
|
|
|
szName[(sizeof(szName)/sizeof(WCHAR))-1] = L'\0';
|
|
|
|
SendDlgItemMessageW(hwndDlg, IDC_STRRECDEBUGCOMBO, CB_ADDSTRING, (WPARAM)0, (LPARAM) szName);
|
|
|
|
}
|
2007-08-20 21:41:05 +00:00
|
|
|
|
2007-11-04 22:12:25 +00:00
|
|
|
SetCrashDlgItems(hwndDlg, pStartInfo);
|
2007-08-20 21:41:05 +00:00
|
|
|
RegCloseKey(hKey);
|
2014-12-26 13:11:57 +00:00
|
|
|
|
|
|
|
SaveRecoveryOptions = TRUE;
|
2007-08-20 21:41:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-08-20 19:21:54 +00:00
|
|
|
/* Property page dialog callback */
|
|
|
|
INT_PTR CALLBACK
|
|
|
|
StartRecDlgProc(HWND hwndDlg,
|
|
|
|
UINT uMsg,
|
|
|
|
WPARAM wParam,
|
|
|
|
LPARAM lParam)
|
|
|
|
{
|
2007-11-04 22:12:25 +00:00
|
|
|
PSTARTINFO pStartInfo;
|
2007-08-20 19:21:54 +00:00
|
|
|
PBOOTRECORD pRecord;
|
|
|
|
int iTimeout;
|
|
|
|
LRESULT lResult;
|
2008-10-30 10:46:55 +00:00
|
|
|
WCHAR szTimeout[10];
|
2007-08-20 19:21:54 +00:00
|
|
|
|
|
|
|
UNREFERENCED_PARAMETER(lParam);
|
|
|
|
|
2007-11-04 22:12:25 +00:00
|
|
|
pStartInfo = (PSTARTINFO)GetWindowLongPtr(hwndDlg, DWLP_USER);
|
|
|
|
|
2007-08-20 19:21:54 +00:00
|
|
|
switch(uMsg)
|
|
|
|
{
|
|
|
|
case WM_INITDIALOG:
|
2007-11-04 22:12:25 +00:00
|
|
|
pStartInfo = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(STARTINFO));
|
|
|
|
SetWindowLongPtr(hwndDlg, DWLP_USER, (LONG_PTR)pStartInfo);
|
|
|
|
|
|
|
|
LoadRecoveryOptions(hwndDlg, pStartInfo);
|
2008-06-28 12:48:06 +00:00
|
|
|
SetRecoveryTimeout(hwndDlg, 0);
|
2007-11-04 22:12:25 +00:00
|
|
|
return LoadOSList(hwndDlg, pStartInfo);
|
|
|
|
|
|
|
|
case WM_DESTROY:
|
|
|
|
DeleteBootRecords(hwndDlg);
|
|
|
|
HeapFree(GetProcessHeap(), 0, pStartInfo);
|
|
|
|
break;
|
2007-07-23 16:32:04 +00:00
|
|
|
|
|
|
|
case WM_COMMAND:
|
|
|
|
switch(LOWORD(wParam))
|
|
|
|
{
|
|
|
|
case IDC_STRRECEDIT:
|
2008-10-30 10:46:55 +00:00
|
|
|
ShellExecuteW(0, L"open", L"notepad", pStartInfo->szFreeldrIni, NULL, SW_SHOWNORMAL);
|
2011-11-29 14:55:58 +00:00
|
|
|
// FIXME: Use CreateProcess and wait untill finished
|
2007-11-03 14:39:08 +00:00
|
|
|
// DeleteBootRecords(hwndDlg);
|
|
|
|
// LoadOSList(hwndDlg);
|
2007-07-23 16:32:04 +00:00
|
|
|
break;
|
2007-11-03 14:39:08 +00:00
|
|
|
|
2007-07-23 16:32:04 +00:00
|
|
|
case IDOK:
|
2011-11-29 14:55:58 +00:00
|
|
|
/* Save timeout */
|
2007-07-23 16:32:04 +00:00
|
|
|
if (SendDlgItemMessage(hwndDlg, IDC_STRECLIST, BM_GETCHECK, (WPARAM)0, (LPARAM)0) == BST_CHECKED)
|
|
|
|
iTimeout = SendDlgItemMessage(hwndDlg, IDC_STRRECLISTUPDWN, UDM_GETPOS, (WPARAM)0, (LPARAM)0);
|
|
|
|
else
|
|
|
|
iTimeout = 0;
|
2008-10-30 10:46:55 +00:00
|
|
|
swprintf(szTimeout, L"%i", iTimeout);
|
2007-08-20 19:21:54 +00:00
|
|
|
|
2008-10-30 10:46:55 +00:00
|
|
|
lResult = SendDlgItemMessageW(hwndDlg, IDC_STRECOSCOMBO, CB_GETCURSEL, (WPARAM)0, (LPARAM)0);
|
2007-08-20 19:21:54 +00:00
|
|
|
if (lResult == CB_ERR)
|
|
|
|
{
|
|
|
|
/* ? */
|
|
|
|
DeleteBootRecords(hwndDlg);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
pRecord = (PBOOTRECORD) SendDlgItemMessage(hwndDlg, IDC_STRECOSCOMBO, CB_GETITEMDATA, (WPARAM)lResult, (LPARAM)0);
|
|
|
|
|
2009-04-29 22:20:59 +00:00
|
|
|
if ((INT_PTR)pRecord != CB_ERR)
|
2007-08-20 19:21:54 +00:00
|
|
|
{
|
2007-11-04 22:12:25 +00:00
|
|
|
if (pStartInfo->iFreeLdrIni == 1) // FreeLdrIni style
|
2007-08-20 19:21:54 +00:00
|
|
|
{
|
2011-11-29 14:55:58 +00:00
|
|
|
/* Set default timeout */
|
2008-10-30 10:46:55 +00:00
|
|
|
WritePrivateProfileStringW(L"FREELOADER",
|
|
|
|
L"TimeOut",
|
2007-08-20 19:21:54 +00:00
|
|
|
szTimeout,
|
2007-11-04 22:12:25 +00:00
|
|
|
pStartInfo->szFreeldrIni);
|
2011-11-29 14:55:58 +00:00
|
|
|
/* Set default OS */
|
2008-10-30 10:46:55 +00:00
|
|
|
WritePrivateProfileStringW(L"FREELOADER",
|
|
|
|
L"DefaultOS",
|
2007-08-20 19:21:54 +00:00
|
|
|
pRecord->szSectionName,
|
2007-11-04 22:12:25 +00:00
|
|
|
pStartInfo->szFreeldrIni);
|
2007-08-20 19:21:54 +00:00
|
|
|
|
|
|
|
}
|
2007-11-04 22:12:25 +00:00
|
|
|
else if (pStartInfo->iFreeLdrIni == 2) // BootIni style
|
2007-08-20 19:21:54 +00:00
|
|
|
{
|
2011-11-29 14:55:58 +00:00
|
|
|
/* Set default timeout */
|
2008-10-30 10:46:55 +00:00
|
|
|
WritePrivateProfileStringW(L"boot loader",
|
|
|
|
L"timeout",
|
2007-08-20 19:21:54 +00:00
|
|
|
szTimeout,
|
2007-11-04 22:12:25 +00:00
|
|
|
pStartInfo->szFreeldrIni);
|
2011-11-29 14:55:58 +00:00
|
|
|
/* Set default OS */
|
2008-10-30 10:46:55 +00:00
|
|
|
WritePrivateProfileStringW(L"boot loader",
|
|
|
|
L"default",
|
2007-08-20 19:21:54 +00:00
|
|
|
pRecord->szBootPath,
|
2007-11-04 22:12:25 +00:00
|
|
|
pStartInfo->szFreeldrIni);
|
2007-08-20 19:21:54 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
}
|
2007-11-03 14:39:08 +00:00
|
|
|
|
2014-12-26 13:11:57 +00:00
|
|
|
if (SaveRecoveryOptions)
|
|
|
|
{
|
|
|
|
WriteStartupRecoveryOptions(hwndDlg, pStartInfo);
|
|
|
|
}
|
|
|
|
|
2007-08-20 19:21:54 +00:00
|
|
|
EndDialog(hwndDlg,
|
|
|
|
LOWORD(wParam));
|
|
|
|
return TRUE;
|
2007-11-03 14:39:08 +00:00
|
|
|
|
2007-07-23 16:32:04 +00:00
|
|
|
case IDCANCEL:
|
|
|
|
EndDialog(hwndDlg,
|
|
|
|
LOWORD(wParam));
|
|
|
|
return TRUE;
|
2007-11-03 14:39:08 +00:00
|
|
|
|
2007-07-23 16:32:04 +00:00
|
|
|
case IDC_STRECLIST:
|
|
|
|
if (SendDlgItemMessage(hwndDlg, IDC_STRECLIST, BM_GETCHECK, (WPARAM)0, (LPARAM)0) == BST_CHECKED)
|
|
|
|
SetTimeout(hwndDlg, 30);
|
|
|
|
else
|
|
|
|
SetTimeout(hwndDlg, 0);
|
2007-11-03 14:39:08 +00:00
|
|
|
break;
|
|
|
|
|
2008-06-28 12:48:06 +00:00
|
|
|
case IDC_STRRECREC:
|
|
|
|
if (SendDlgItemMessage(hwndDlg, IDC_STRRECREC, BM_GETCHECK, (WPARAM)0, (LPARAM)0) == BST_CHECKED)
|
|
|
|
SetRecoveryTimeout(hwndDlg, 30);
|
|
|
|
else
|
|
|
|
SetRecoveryTimeout(hwndDlg, 0);
|
|
|
|
break;
|
|
|
|
|
2007-08-20 21:41:05 +00:00
|
|
|
case IDC_STRRECDEBUGCOMBO:
|
|
|
|
if (HIWORD(wParam) == CBN_SELCHANGE)
|
|
|
|
{
|
|
|
|
LRESULT lResult;
|
|
|
|
|
|
|
|
lResult = SendDlgItemMessage(hwndDlg, IDC_STRRECDEBUGCOMBO, CB_GETCURSEL, (WPARAM)0, (LPARAM)0);
|
2008-12-07 21:52:22 +00:00
|
|
|
if (lResult != CB_ERR && lResult != (LRESULT)pStartInfo->dwCrashDumpEnabled)
|
2007-08-20 21:41:05 +00:00
|
|
|
{
|
2007-11-04 22:12:25 +00:00
|
|
|
if (pStartInfo->dwCrashDumpEnabled == 1 || pStartInfo->dwCrashDumpEnabled == 2)
|
2007-08-20 21:41:05 +00:00
|
|
|
{
|
2008-10-30 10:46:55 +00:00
|
|
|
SendDlgItemMessageW(hwndDlg, IDC_STRRECDUMPFILE, WM_GETTEXT, (WPARAM)sizeof(pStartInfo->szDumpFile) / sizeof(WCHAR), (LPARAM)pStartInfo->szDumpFile);
|
2007-08-20 21:41:05 +00:00
|
|
|
}
|
2007-11-04 22:12:25 +00:00
|
|
|
else if (pStartInfo->dwCrashDumpEnabled == 3)
|
2007-08-20 21:41:05 +00:00
|
|
|
{
|
2008-10-30 10:46:55 +00:00
|
|
|
SendDlgItemMessageW(hwndDlg, IDC_STRRECDUMPFILE, WM_GETTEXT, (WPARAM)sizeof(pStartInfo->szMinidumpDir) / sizeof(WCHAR), (LPARAM)pStartInfo->szMinidumpDir);
|
2007-08-20 21:41:05 +00:00
|
|
|
}
|
2007-11-03 14:39:08 +00:00
|
|
|
|
2008-12-07 21:52:22 +00:00
|
|
|
pStartInfo->dwCrashDumpEnabled = (DWORD)lResult;
|
2007-11-04 22:12:25 +00:00
|
|
|
SetCrashDlgItems(hwndDlg, pStartInfo);
|
2007-08-20 21:41:05 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
2007-07-23 16:32:04 +00:00
|
|
|
}
|
2007-11-03 14:39:08 +00:00
|
|
|
break;
|
2007-07-23 16:32:04 +00:00
|
|
|
}
|
2007-11-03 14:39:08 +00:00
|
|
|
|
2007-07-23 16:32:04 +00:00
|
|
|
return FALSE;
|
2006-11-08 11:47:44 +00:00
|
|
|
}
|