ReactOS 0.4.15-dev-5667-ged97270
startrec.c File Reference
#include "precomp.h"
#include <shlwapi.h>
Include dependency graph for startrec.c:

Go to the source code of this file.

Classes

struct  _BOOTRECORD
 
struct  _STARTINFO
 

Typedefs

typedef struct _BOOTRECORD BOOTRECORD
 
typedef struct _BOOTRECORDPBOOTRECORD
 
typedef struct _STARTINFO STARTINFO
 
typedef struct _STARTINFOPSTARTINFO
 

Functions

static VOID SetTimeout (HWND hwndDlg, INT Timeout)
 
static VOID SetRecoveryTimeout (HWND hwndDlg, INT Timeout)
 
static DWORD GetSystemDrive (WCHAR **szSystemDrive)
 
static PBOOTRECORD ReadFreeldrSection (HINF hInf, WCHAR *szSectionName)
 
static INT LoadFreeldrSettings (HINF hInf, HWND hwndDlg)
 
static INT LoadBootSettings (HINF hInf, HWND hwndDlg)
 
static VOID DeleteBootRecords (HWND hwndDlg)
 
static LRESULT LoadOSList (HWND hwndDlg, PSTARTINFO pStartInfo)
 
static VOID SetCrashDlgItems (HWND hwnd, PSTARTINFO pStartInfo)
 
static VOID WriteStartupRecoveryOptions (HWND hwndDlg, PSTARTINFO pStartInfo)
 
static VOID LoadRecoveryOptions (HWND hwndDlg, PSTARTINFO pStartInfo)
 
INT_PTR CALLBACK StartRecDlgProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
 

Variables

BOOL SaveRecoveryOptions
 

Typedef Documentation

◆ BOOTRECORD

◆ PBOOTRECORD

◆ PSTARTINFO

◆ STARTINFO

Function Documentation

◆ DeleteBootRecords()

static VOID DeleteBootRecords ( HWND  hwndDlg)
static

Definition at line 438 of file startrec.c.

439{
440 LRESULT lIndex;
441 LONG index;
442 PBOOTRECORD pRecord;
443
445 if (lIndex == CB_ERR)
446 return;
447
448 for (index = 0; index <lIndex; index++)
449 {
451 if ((INT_PTR)pRecord != CB_ERR)
452 {
453 HeapFree(GetProcessHeap(), 0, pRecord);
454 }
455 }
456
458}
#define index(s, c)
Definition: various.h:29
#define IDC_STRECOSCOMBO
Definition: resource.h:174
#define GetProcessHeap()
Definition: compat.h:736
#define HeapFree(x, y, z)
Definition: compat.h:735
GLuint index
Definition: glext.h:6031
long LONG
Definition: pedump.c:60
struct _BOOTRECORD * PBOOTRECORD
int32_t INT_PTR
Definition: typedefs.h:64
LONG_PTR LPARAM
Definition: windef.h:208
LONG_PTR LRESULT
Definition: windef.h:209
UINT_PTR WPARAM
Definition: windef.h:207
#define CB_ERR
Definition: winuser.h:2425
#define CB_RESETCONTENT
Definition: winuser.h:1949
#define CB_GETCOUNT
Definition: winuser.h:1932
LRESULT WINAPI SendDlgItemMessageW(_In_ HWND, _In_ int, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define CB_GETITEMDATA
Definition: winuser.h:1940

Referenced by StartRecDlgProc().

◆ GetSystemDrive()

static DWORD GetSystemDrive ( WCHAR **  szSystemDrive)
static

Definition at line 70 of file startrec.c.

71{
72 DWORD dwBufSize;
73
74 /* Get Path to freeldr.ini or boot.ini */
75 *szSystemDrive = HeapAlloc(GetProcessHeap(), 0, MAX_PATH * sizeof(WCHAR));
76 if (*szSystemDrive != NULL)
77 {
78 dwBufSize = GetEnvironmentVariableW(L"SystemDrive", *szSystemDrive, MAX_PATH);
79 if (dwBufSize > MAX_PATH)
80 {
81 WCHAR *szTmp;
82 DWORD dwBufSize2;
83
84 szTmp = HeapReAlloc(GetProcessHeap(), 0, *szSystemDrive, dwBufSize * sizeof(WCHAR));
85 if (szTmp == NULL)
86 goto FailGetSysDrive;
87
88 *szSystemDrive = szTmp;
89
90 dwBufSize2 = GetEnvironmentVariableW(L"SystemDrive", *szSystemDrive, dwBufSize);
91 if (dwBufSize2 > dwBufSize || dwBufSize2 == 0)
92 goto FailGetSysDrive;
93 }
94 else if (dwBufSize == 0)
95 {
96FailGetSysDrive:
97 HeapFree(GetProcessHeap(), 0, *szSystemDrive);
98 *szSystemDrive = NULL;
99 return 0;
100 }
101
102 return dwBufSize;
103 }
104
105 return 0;
106}
char szTmp[518]
#define NULL
Definition: types.h:112
#define GetEnvironmentVariableW(x, y, z)
Definition: compat.h:755
#define HeapAlloc
Definition: compat.h:733
#define HeapReAlloc
Definition: compat.h:734
#define MAX_PATH
Definition: compat.h:34
unsigned long DWORD
Definition: ntddk_ex.h:95
#define L(x)
Definition: ntvdm.h:50
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by LoadOSList().

◆ LoadBootSettings()

static INT LoadBootSettings ( HINF  hInf,
HWND  hwndDlg 
)
static

Definition at line 303 of file startrec.c.

304{
305 INFCONTEXT InfContext;
307 WCHAR szValue[MAX_PATH];
308 DWORD LineLength;
309 DWORD TimeOut = 0;
310 WCHAR szDefaultOS[MAX_PATH];
311 WCHAR szOptions[MAX_PATH];
312 PBOOTRECORD pRecord;
313 LRESULT lResult;
314
315 if(!SetupFindFirstLineW(hInf,
316 L"boot loader",
317 NULL,
318 &InfContext))
319 {
320 return FALSE;
321 }
322
323 do
324 {
325 if (!SetupGetStringFieldW(&InfContext,
326 0,
327 szName,
328 sizeof(szName) / sizeof(WCHAR),
329 &LineLength))
330 {
331 return FALSE;
332 }
333
334 if (!SetupGetStringFieldW(&InfContext,
335 1,
336 szValue,
337 sizeof(szValue) / sizeof(WCHAR),
338 &LineLength))
339 {
340 return FALSE;
341 }
342
343 if (!_wcsnicmp(szName, L"timeout", 7))
344 {
345 TimeOut = _wtoi(szValue);
346 }
347
348 if (!_wcsnicmp(szName, L"default", 7))
349 {
350 wcscpy(szDefaultOS, szValue);
351 }
352
353 }
354 while (SetupFindNextLine(&InfContext, &InfContext));
355
356 if (!SetupFindFirstLineW(hInf,
357 L"operating systems",
358 NULL,
359 &InfContext))
360 {
361 /* Failed to find operating systems section */
362 return FALSE;
363 }
364
365 do
366 {
367 if (!SetupGetStringFieldW(&InfContext,
368 0,
369 szName,
370 sizeof(szName) / sizeof(WCHAR),
371 &LineLength))
372 {
373 return FALSE;
374 }
375
376 if (!SetupGetStringFieldW(&InfContext,
377 1,
378 szValue,
379 sizeof(szValue) / sizeof(WCHAR),
380 &LineLength))
381 {
382 return FALSE;
383 }
384
385 SetupGetStringFieldW(&InfContext,
386 2,
387 szOptions,
388 sizeof(szOptions) / sizeof(WCHAR),
389 &LineLength);
390
392 if (pRecord)
393 {
394 pRecord->BootType = 0;
395 wcscpy(pRecord->szBootPath, szName);
396 wcscpy(pRecord->szSectionName, szValue);
397 wcscpy(pRecord->szOptions, szOptions);
398
399 if (!wcscmp(szName, szDefaultOS))
400 {
401 /* ms boot ini stores the path not the friendly name */
402 wcscpy(szDefaultOS, szValue);
403 }
404
405 lResult = SendDlgItemMessageW(hwndDlg, IDC_STRECOSCOMBO, CB_ADDSTRING, (WPARAM)0, (LPARAM)szValue);
406 if (lResult != CB_ERR)
407 {
408 SendDlgItemMessageW(hwndDlg, IDC_STRECOSCOMBO, CB_SETITEMDATA, (WPARAM)lResult, (LPARAM)pRecord);
409 }
410 else
411 {
412 HeapFree(GetProcessHeap(), 0, pRecord);
413 }
414 }
415
416 }
417 while (SetupFindNextLine(&InfContext, &InfContext));
418
419 /* Find default os in list */
420 lResult = SendDlgItemMessageW(hwndDlg, IDC_STRECOSCOMBO, CB_FINDSTRING, (WPARAM)0, (LPARAM)szDefaultOS);
421 if (lResult != CB_ERR)
422 {
423 /* Set cur sel */
425 }
426
427 if(TimeOut)
428 {
430 }
431
432 SetTimeout(hwndDlg, TimeOut);
433
434 return TRUE;
435}
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define IDC_STRECLIST
Definition: resource.h:175
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
_Check_return_ _CRTIMP int __cdecl _wtoi(_In_z_ const wchar_t *_Str)
static const WCHAR szName[]
Definition: powrprof.c:45
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
_Check_return_ _CRTIMP int __cdecl wcscmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
_Check_return_ _CRTIMP int __cdecl _wcsnicmp(_In_reads_or_z_(_MaxCount) const wchar_t *_Str1, _In_reads_or_z_(_MaxCount) const wchar_t *_Str2, _In_ size_t _MaxCount)
struct _BOOTRECORD BOOTRECORD
static VOID SetTimeout(HWND hwndDlg, INT Timeout)
Definition: startrec.c:35
WCHAR szBootPath[MAX_PATH]
Definition: startrec.c:19
WCHAR szSectionName[128]
Definition: startrec.c:18
WCHAR szOptions[512]
Definition: startrec.c:20
DWORD BootType
Definition: startrec.c:17
BOOL WINAPI SetupGetStringFieldW(IN PINFCONTEXT Context, IN ULONG FieldIndex, OUT PWSTR ReturnBuffer, IN ULONG ReturnBufferSize, OUT PULONG RequiredSize)
Definition: infsupp.c:184
BOOL WINAPI SetupFindFirstLineW(IN HINF InfHandle, IN PCWSTR Section, IN PCWSTR Key, IN OUT PINFCONTEXT Context)
Definition: infsupp.c:54
BOOL WINAPI SetupFindNextLine(IN PINFCONTEXT ContextIn, OUT PINFCONTEXT ContextOut)
Definition: infsupp.c:80
#define CB_SETITEMDATA
Definition: winuser.h:1956
#define CB_SETCURSEL
Definition: winuser.h:1951
#define BM_SETCHECK
Definition: winuser.h:1911
#define CB_ADDSTRING
Definition: winuser.h:1926
#define CB_FINDSTRING
Definition: winuser.h:1929
#define BST_CHECKED
Definition: winuser.h:197

Referenced by LoadOSList().

◆ LoadFreeldrSettings()

static INT LoadFreeldrSettings ( HINF  hInf,
HWND  hwndDlg 
)
static

Definition at line 184 of file startrec.c.

185{
186 INFCONTEXT InfContext;
187 PBOOTRECORD pRecord;
188 WCHAR szDefaultOs[MAX_PATH];
190 WCHAR szValue[MAX_PATH];
191 DWORD LineLength;
192 DWORD TimeOut;
193 LRESULT lResult;
194
195 if (!SetupFindFirstLineW(hInf,
196 L"FREELOADER",
197 L"DefaultOS",
198 &InfContext))
199 {
200 /* Failed to find default os */
201 return FALSE;
202 }
203
204 if (!SetupGetStringFieldW(&InfContext,
205 1,
206 szDefaultOs,
207 sizeof(szDefaultOs) / sizeof(WCHAR),
208 &LineLength))
209 {
210 /* No key */
211 return FALSE;
212 }
213
214 if (!SetupFindFirstLineW(hInf,
215 L"FREELOADER",
216 L"TimeOut",
217 &InfContext))
218 {
219 /* Expected to find timeout value */
220 return FALSE;
221 }
222
223
224 if (!SetupGetIntField(&InfContext,
225 1,
226 (PINT)&TimeOut))
227 {
228 /* Failed to retrieve timeout */
229 return FALSE;
230 }
231
232 if (!SetupFindFirstLineW(hInf,
233 L"Operating Systems",
234 NULL,
235 &InfContext))
236 {
237 /* Expected list of operating systems */
238 return FALSE;
239 }
240
241 do
242 {
243 if (!SetupGetStringFieldW(&InfContext,
244 0,
245 szName,
246 sizeof(szName) / sizeof(WCHAR),
247 &LineLength))
248 {
249 /* The ini file is messed up */
250 return FALSE;
251 }
252
253 if (!SetupGetStringFieldW(&InfContext,
254 1,
255 szValue,
256 sizeof(szValue) / sizeof(WCHAR),
257 &LineLength))
258 {
259 /* The ini file is messed up */
260 return FALSE;
261 }
262
263 pRecord = ReadFreeldrSection(hInf, szName);
264 if (pRecord)
265 {
266 lResult = SendDlgItemMessageW(hwndDlg, IDC_STRECOSCOMBO, CB_ADDSTRING, (WPARAM)0, (LPARAM)szValue);
267 if (lResult != CB_ERR)
268 {
269 SendDlgItemMessageW(hwndDlg, IDC_STRECOSCOMBO, CB_SETITEMDATA, (WPARAM)lResult, (LPARAM)pRecord);
270 if (!wcscmp(szDefaultOs, szName))
271 {
272 /* We store the friendly name as key */
273 wcscpy(szDefaultOs, szValue);
274 }
275 }
276 else
277 {
278 HeapFree(GetProcessHeap(), 0, pRecord);
279 }
280 }
281 }
282 while (SetupFindNextLine(&InfContext, &InfContext));
283
284 /* Find default os in list */
285 lResult = SendDlgItemMessageW(hwndDlg, IDC_STRECOSCOMBO, CB_FINDSTRING, (WPARAM)-1, (LPARAM)szDefaultOs);
286 if (lResult != CB_ERR)
287 {
288 /* Set cur sel */
290 }
291
292 if(TimeOut)
293 {
295 }
296
297 SetTimeout(hwndDlg, TimeOut);
298
299 return TRUE;
300}
static PBOOTRECORD ReadFreeldrSection(HINF hInf, WCHAR *szSectionName)
Definition: startrec.c:109
BOOL WINAPI SetupGetIntField(IN PINFCONTEXT Context, IN ULONG FieldIndex, OUT INT *IntegerValue)
Definition: infsupp.c:146
int * PINT
Definition: windef.h:177

Referenced by LoadOSList().

◆ LoadOSList()

static LRESULT LoadOSList ( HWND  hwndDlg,
PSTARTINFO  pStartInfo 
)
static

Definition at line 461 of file startrec.c.

462{
463 DWORD dwBufSize;
464 WCHAR *szSystemDrive;
465 HINF hInf;
466
467 dwBufSize = GetSystemDrive(&szSystemDrive);
468 if (dwBufSize == 0)
469 return FALSE;
470
471 wcscpy(pStartInfo->szFreeldrIni, szSystemDrive);
472 wcscat(pStartInfo->szFreeldrIni, L"\\freeldr.ini");
473
474 if (PathFileExistsW(pStartInfo->szFreeldrIni))
475 {
476 /* Free resource previously allocated by GetSystemDrive() */
477 HeapFree(GetProcessHeap(), 0, szSystemDrive);
478 /* freeldr.ini exists */
479 hInf = SetupOpenInfFileW(pStartInfo->szFreeldrIni,
480 NULL,
482 NULL);
483
484 if (hInf != INVALID_HANDLE_VALUE)
485 {
486 LoadFreeldrSettings(hInf, hwndDlg);
487 SetupCloseInfFile(hInf);
488 pStartInfo->iFreeLdrIni = 1;
489 return TRUE;
490 }
491 return FALSE;
492 }
493
494 /* Try loading boot.ini settings */
495 wcscpy(pStartInfo->szFreeldrIni, szSystemDrive);
496 wcscat(pStartInfo->szFreeldrIni, L"\\boot.ini");
497
498 /* Free resource previously allocated by GetSystemDrive() */
499 HeapFree(GetProcessHeap(), 0, szSystemDrive);
500
501 if (PathFileExistsW(pStartInfo->szFreeldrIni))
502 {
503 /* Load boot.ini settings */
504 hInf = SetupOpenInfFileW(pStartInfo->szFreeldrIni,
505 NULL,
507 NULL);
508
509 if (hInf != INVALID_HANDLE_VALUE)
510 {
511 LoadBootSettings(hInf, hwndDlg);
512 SetupCloseInfFile(hInf);
513 pStartInfo->iFreeLdrIni = 2;
514 return TRUE;
515 }
516
517 return FALSE;
518 }
519
520 return FALSE;
521}
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
HINF WINAPI SetupOpenInfFileW(PCWSTR name, PCWSTR class, DWORD style, UINT *error)
Definition: parser.c:1229
BOOL WINAPI PathFileExistsW(LPCWSTR lpszPath)
Definition: path.c:1776
#define INF_STYLE_OLDNT
Definition: infsupp.h:37
_CRTIMP wchar_t *__cdecl wcscat(_Inout_updates_z_(_String_length_(_Dest)+_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
static DWORD GetSystemDrive(WCHAR **szSystemDrive)
Definition: startrec.c:70
static INT LoadBootSettings(HINF hInf, HWND hwndDlg)
Definition: startrec.c:303
static INT LoadFreeldrSettings(HINF hInf, HWND hwndDlg)
Definition: startrec.c:184
INT iFreeLdrIni
Definition: startrec.c:29
WCHAR szFreeldrIni[MAX_PATH+15]
Definition: startrec.c:25
VOID WINAPI SetupCloseInfFile(IN HINF InfHandle)
Definition: infsupp.c:43

Referenced by StartRecDlgProc().

◆ LoadRecoveryOptions()

static VOID LoadRecoveryOptions ( HWND  hwndDlg,
PSTARTINFO  pStartInfo 
)
static

Definition at line 602 of file startrec.c.

603{
604 HKEY hKey;
606 DWORD dwValue, dwValueLength, dwType, dwResult;
607
609 L"System\\CurrentControlSet\\Control\\CrashControl",
610 0,
611 NULL,
613 KEY_READ,
614 NULL,
615 &hKey,
616 NULL);
617 if (dwResult != ERROR_SUCCESS)
618 {
619 /* Failed to open key */
620 SetLastError(dwResult);
621 ShowLastWin32Error(hwndDlg);
622
629
631 return;
632 }
633
634 dwValueLength = sizeof(DWORD);
635 if (RegQueryValueExW(hKey, L"LogEvent", NULL, &dwType, (LPBYTE)&dwValue, &dwValueLength) == ERROR_SUCCESS && dwType == REG_DWORD && dwValue)
637
638 dwValueLength = sizeof(DWORD);
639 if (RegQueryValueExW(hKey, L"SendAlert", NULL, &dwType, (LPBYTE)&dwValue, &dwValueLength) == ERROR_SUCCESS && dwType == REG_DWORD && dwValue)
641
642 dwValueLength = sizeof(DWORD);
643 if (RegQueryValueExW(hKey, L"AutoReboot", NULL, &dwType, (LPBYTE)&dwValue, &dwValueLength) == ERROR_SUCCESS && dwType == REG_DWORD && dwValue)
645
646 dwValueLength = sizeof(DWORD);
647 if (RegQueryValueExW(hKey, L"Overwrite", NULL, &dwType, (LPBYTE)&dwValue, &dwValueLength) == ERROR_SUCCESS && dwType == REG_DWORD && dwValue)
649
650 dwValueLength = sizeof(DWORD);
651 if (RegQueryValueExW(hKey, L"CrashDumpEnabled", NULL, &dwType, (LPBYTE)&dwValue, &dwValueLength) == ERROR_SUCCESS && dwType == REG_DWORD && dwValue)
652 pStartInfo->dwCrashDumpEnabled = dwValue;
653
654 dwValueLength = sizeof(pStartInfo->szDumpFile);
655 if (RegQueryValueExW(hKey, L"DumpFile", NULL, &dwType, (LPBYTE)pStartInfo->szDumpFile, &dwValueLength) != ERROR_SUCCESS)
656 pStartInfo->szDumpFile[0] = L'\0';
657
658 dwValueLength = sizeof(pStartInfo->szMinidumpDir);
659 if (RegQueryValueExW(hKey, L"MinidumpDir", NULL, &dwType, (LPBYTE)pStartInfo->szMinidumpDir, &dwValueLength) != ERROR_SUCCESS)
660 pStartInfo->szMinidumpDir[0] = L'\0';
661
662 if (LoadStringW(hApplet, IDS_NO_DUMP, szName, sizeof(szName) / sizeof(WCHAR)))
663 {
664 szName[(sizeof(szName)/sizeof(WCHAR))-1] = L'\0';
666 }
667
668 if (LoadStringW(hApplet, IDS_FULL_DUMP, szName, sizeof(szName) / sizeof(WCHAR)))
669 {
670 szName[(sizeof(szName)/sizeof(WCHAR))-1] = L'\0';
672 }
673
674 if (LoadStringW(hApplet, IDS_KERNEL_DUMP, szName, sizeof(szName) / sizeof(WCHAR)))
675 {
676 szName[(sizeof(szName)/sizeof(WCHAR))-1] = L'\0';
678 }
679
680 if (LoadStringW(hApplet, IDS_MINI_DUMP, szName, sizeof(szName) / sizeof(WCHAR)))
681 {
682 szName[(sizeof(szName)/sizeof(WCHAR))-1] = L'\0';
684 }
685
686 SetCrashDlgItems(hwndDlg, pStartInfo);
688
690}
#define RegCloseKey(hKey)
Definition: registry.h:47
#define ERROR_SUCCESS
Definition: deptool.c:10
HINSTANCE hApplet
Definition: access.c:17
#define IDS_NO_DUMP
Definition: resource.h:27
#define IDS_FULL_DUMP
Definition: resource.h:30
#define IDC_STRRECDEBUGCOMBO
Definition: resource.h:185
#define IDC_STRRECOVERWRITE
Definition: resource.h:187
#define IDC_STRRECRESTART
Definition: resource.h:184
#define IDC_STRRECSENDALERT
Definition: resource.h:183
#define IDC_STRRECWRITEEVENT
Definition: resource.h:182
#define IDS_KERNEL_DUMP
Definition: resource.h:29
#define IDS_MINI_DUMP
Definition: resource.h:28
#define IDC_STRRECDUMPFILE
Definition: resource.h:186
LONG WINAPI RegCreateKeyExW(_In_ HKEY hKey, _In_ LPCWSTR lpSubKey, _In_ DWORD Reserved, _In_opt_ LPWSTR lpClass, _In_ DWORD dwOptions, _In_ REGSAM samDesired, _In_opt_ LPSECURITY_ATTRIBUTES lpSecurityAttributes, _Out_ PHKEY phkResult, _Out_opt_ LPDWORD lpdwDisposition)
Definition: reg.c:1091
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4121
#define SetLastError(x)
Definition: compat.h:752
FxAutoRegKey hKey
if(dx< 0)
Definition: linetemp.h:194
#define KEY_READ
Definition: nt_native.h:1023
#define REG_OPTION_NON_VOLATILE
Definition: nt_native.h:1057
#define DWORD
Definition: nt_native.h:44
#define REG_DWORD
Definition: sdbapi.c:596
static VOID SetCrashDlgItems(HWND hwnd, PSTARTINFO pStartInfo)
Definition: startrec.c:524
BOOL SaveRecoveryOptions
Definition: startrec.c:32
DWORD dwCrashDumpEnabled
Definition: startrec.c:28
WCHAR szMinidumpDir[MAX_PATH]
Definition: startrec.c:27
WCHAR szDumpFile[MAX_PATH]
Definition: startrec.c:26
unsigned char * LPBYTE
Definition: typedefs.h:53
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
BOOL WINAPI EnableWindow(_In_ HWND, _In_ BOOL)
void ShowLastWin32Error(HWND hwndParent)
Definition: winutils.c:11

Referenced by StartRecDlgProc().

◆ ReadFreeldrSection()

static PBOOTRECORD ReadFreeldrSection ( HINF  hInf,
WCHAR szSectionName 
)
static

Definition at line 109 of file startrec.c.

110{
111 PBOOTRECORD pRecord;
112 INFCONTEXT InfContext;
114 WCHAR szValue[MAX_PATH];
115 DWORD LineLength;
116
117 if (!SetupFindFirstLineW(hInf,
118 szSectionName,
119 NULL,
120 &InfContext))
121 {
122 /* Failed to find section */
123 return NULL;
124 }
125
127 if (pRecord == NULL)
128 {
129 return NULL;
130 }
131
132 wcscpy(pRecord->szSectionName, szSectionName);
133
134 do
135 {
136 if (!SetupGetStringFieldW(&InfContext,
137 0,
138 szName,
139 sizeof(szName) / sizeof(WCHAR),
140 &LineLength))
141 {
142 break;
143 }
144
145 if (!SetupGetStringFieldW(&InfContext,
146 1,
147 szValue,
148 sizeof(szValue) / sizeof(WCHAR),
149 &LineLength))
150 {
151 break;
152 }
153
154 if (!_wcsnicmp(szName, L"BootType", 8))
155 {
156 if (!_wcsnicmp(szValue, L"ReactOS", 7))
157 {
158 // FIXME: Store as enum
159 pRecord->BootType = 1;
160 }
161 else
162 {
163 pRecord->BootType = 0;
164 }
165 }
166 else if (!_wcsnicmp(szName, L"SystemPath", 10))
167 {
168 wcscpy(pRecord->szBootPath, szValue);
169 }
170 else if (!_wcsnicmp(szName, L"Options", 7))
171 {
172 // FIXME: Store flags as values
173 wcscpy(pRecord->szOptions, szValue);
174 }
175
176 }
177 while (SetupFindNextLine(&InfContext, &InfContext));
178
179 return pRecord;
180}

Referenced by LoadFreeldrSettings().

◆ SetCrashDlgItems()

static VOID SetCrashDlgItems ( HWND  hwnd,
PSTARTINFO  pStartInfo 
)
static

Definition at line 524 of file startrec.c.

525{
526 if (pStartInfo->dwCrashDumpEnabled == 0)
527 {
528 /* No crash information required */
531 }
532 else if (pStartInfo->dwCrashDumpEnabled == 3)
533 {
534 /* Minidump type */
538 }
539 else if (pStartInfo->dwCrashDumpEnabled == 1 || pStartInfo->dwCrashDumpEnabled == 2)
540 {
541 /* Kernel or complete dump */
545 }
547}
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4023
#define WM_SETTEXT
Definition: winuser.h:1607
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)

Referenced by LoadRecoveryOptions(), and StartRecDlgProc().

◆ SetRecoveryTimeout()

static VOID SetRecoveryTimeout ( HWND  hwndDlg,
INT  Timeout 
)
static

Definition at line 52 of file startrec.c.

53{
54 if (Timeout == 0)
55 {
58 }
59 else
60 {
63 }
66}
#define IDC_STRRECRECUPDWN
Definition: resource.h:180
#define IDC_STRRECRECEDIT
Definition: resource.h:179
static ULONG Timeout
Definition: ping.c:61
#define UDM_SETPOS
Definition: commctrl.h:2143
#define UDM_SETRANGE
Definition: commctrl.h:2141
#define MAKELONG(a, b)
Definition: typedefs.h:249

Referenced by StartRecDlgProc().

◆ SetTimeout()

static VOID SetTimeout ( HWND  hwndDlg,
INT  Timeout 
)
static

Definition at line 35 of file startrec.c.

36{
37 if (Timeout == 0)
38 {
41 }
42 else
43 {
46 }
49}
#define IDC_STRRECLISTUPDWN
Definition: resource.h:177
#define IDC_STRRECLISTEDIT
Definition: resource.h:176

Referenced by LoadBootSettings(), LoadFreeldrSettings(), and StartRecDlgProc().

◆ StartRecDlgProc()

INT_PTR CALLBACK StartRecDlgProc ( HWND  hwndDlg,
UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam 
)

Definition at line 695 of file startrec.c.

699{
700 PSTARTINFO pStartInfo;
701 PBOOTRECORD pRecord;
702 int iTimeout;
703 LRESULT lResult;
704 WCHAR szTimeout[10];
705
707
708 pStartInfo = (PSTARTINFO)GetWindowLongPtr(hwndDlg, DWLP_USER);
709
710 switch(uMsg)
711 {
712 case WM_INITDIALOG:
713 pStartInfo = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(STARTINFO));
714 SetWindowLongPtr(hwndDlg, DWLP_USER, (LONG_PTR)pStartInfo);
715
716 LoadRecoveryOptions(hwndDlg, pStartInfo);
717 SetRecoveryTimeout(hwndDlg, 0);
718 return LoadOSList(hwndDlg, pStartInfo);
719
720 case WM_DESTROY:
721 DeleteBootRecords(hwndDlg);
722 HeapFree(GetProcessHeap(), 0, pStartInfo);
723 break;
724
725 case WM_COMMAND:
726 switch(LOWORD(wParam))
727 {
728 case IDC_STRRECEDIT:
729 ShellExecuteW(0, L"open", L"notepad", pStartInfo->szFreeldrIni, NULL, SW_SHOWNORMAL);
730 // FIXME: Use CreateProcess and wait untill finished
731 // DeleteBootRecords(hwndDlg);
732 // LoadOSList(hwndDlg);
733 break;
734
735 case IDOK:
736 /* Save timeout */
738 iTimeout = SendDlgItemMessage(hwndDlg, IDC_STRRECLISTUPDWN, UDM_GETPOS, (WPARAM)0, (LPARAM)0);
739 else
740 iTimeout = 0;
741 swprintf(szTimeout, L"%i", iTimeout);
742
744 if (lResult == CB_ERR)
745 {
746 /* ? */
747 DeleteBootRecords(hwndDlg);
748 return TRUE;
749 }
750
751 pRecord = (PBOOTRECORD) SendDlgItemMessage(hwndDlg, IDC_STRECOSCOMBO, CB_GETITEMDATA, (WPARAM)lResult, (LPARAM)0);
752
753 if ((INT_PTR)pRecord != CB_ERR)
754 {
755 if (pStartInfo->iFreeLdrIni == 1) // FreeLdrIni style
756 {
757 /* Set default timeout */
758 WritePrivateProfileStringW(L"FREELOADER",
759 L"TimeOut",
760 szTimeout,
761 pStartInfo->szFreeldrIni);
762 /* Set default OS */
763 WritePrivateProfileStringW(L"FREELOADER",
764 L"DefaultOS",
765 pRecord->szSectionName,
766 pStartInfo->szFreeldrIni);
767
768 }
769 else if (pStartInfo->iFreeLdrIni == 2) // BootIni style
770 {
771 /* Set default timeout */
772 WritePrivateProfileStringW(L"boot loader",
773 L"timeout",
774 szTimeout,
775 pStartInfo->szFreeldrIni);
776 /* Set default OS */
777 WritePrivateProfileStringW(L"boot loader",
778 L"default",
779 pRecord->szBootPath,
780 pStartInfo->szFreeldrIni);
781
782 }
783 }
784
786 {
787 WriteStartupRecoveryOptions(hwndDlg, pStartInfo);
788 }
789
790 EndDialog(hwndDlg,
791 LOWORD(wParam));
792 return TRUE;
793
794 case IDCANCEL:
795 EndDialog(hwndDlg,
796 LOWORD(wParam));
797 return TRUE;
798
799 case IDC_STRECLIST:
801 SetTimeout(hwndDlg, 30);
802 else
803 SetTimeout(hwndDlg, 0);
804 break;
805
806 case IDC_STRRECREC:
808 SetRecoveryTimeout(hwndDlg, 30);
809 else
810 SetRecoveryTimeout(hwndDlg, 0);
811 break;
812
815 {
816 LRESULT lResult;
817
819 if (lResult != CB_ERR && lResult != (LRESULT)pStartInfo->dwCrashDumpEnabled)
820 {
821 if (pStartInfo->dwCrashDumpEnabled == 1 || pStartInfo->dwCrashDumpEnabled == 2)
822 {
823 SendDlgItemMessageW(hwndDlg, IDC_STRRECDUMPFILE, WM_GETTEXT, (WPARAM)sizeof(pStartInfo->szDumpFile) / sizeof(WCHAR), (LPARAM)pStartInfo->szDumpFile);
824 }
825 else if (pStartInfo->dwCrashDumpEnabled == 3)
826 {
827 SendDlgItemMessageW(hwndDlg, IDC_STRRECDUMPFILE, WM_GETTEXT, (WPARAM)sizeof(pStartInfo->szMinidumpDir) / sizeof(WCHAR), (LPARAM)pStartInfo->szMinidumpDir);
828 }
829
830 pStartInfo->dwCrashDumpEnabled = (DWORD)lResult;
831 SetCrashDlgItems(hwndDlg, pStartInfo);
832 }
833 }
834 break;
835 }
836 break;
837 }
838
839 return FALSE;
840}
WPARAM wParam
Definition: combotst.c:138
LPARAM lParam
Definition: combotst.c:139
#define IDC_STRRECREC
Definition: resource.h:178
#define IDC_STRRECEDIT
Definition: resource.h:181
BOOL WINAPI WritePrivateProfileStringW(LPCWSTR section, LPCWSTR entry, LPCWSTR string, LPCWSTR filename)
Definition: profile.c:1453
#define swprintf
Definition: precomp.h:40
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
#define LOWORD(l)
Definition: pedump.c:82
#define UDM_GETPOS
Definition: commctrl.h:2144
HINSTANCE WINAPI ShellExecuteW(HWND hwnd, LPCWSTR lpVerb, LPCWSTR lpFile, LPCWSTR lpParameters, LPCWSTR lpDirectory, INT nShowCmd)
Definition: shlexec.cpp:2346
static VOID SetRecoveryTimeout(HWND hwndDlg, INT Timeout)
Definition: startrec.c:52
static LRESULT LoadOSList(HWND hwndDlg, PSTARTINFO pStartInfo)
Definition: startrec.c:461
struct _STARTINFO * PSTARTINFO
static VOID WriteStartupRecoveryOptions(HWND hwndDlg, PSTARTINFO pStartInfo)
Definition: startrec.c:550
static VOID LoadRecoveryOptions(HWND hwndDlg, PSTARTINFO pStartInfo)
Definition: startrec.c:602
static VOID DeleteBootRecords(HWND hwndDlg)
Definition: startrec.c:438
#define GetWindowLongPtr
Definition: treelist.c:73
#define SetWindowLongPtr
Definition: treelist.c:70
#define HIWORD(l)
Definition: typedefs.h:247
#define SW_SHOWNORMAL
Definition: winuser.h:764
#define DWLP_USER
Definition: winuser.h:866
#define IDCANCEL
Definition: winuser.h:825
#define WM_COMMAND
Definition: winuser.h:1730
#define WM_GETTEXT
Definition: winuser.h:1608
#define WM_INITDIALOG
Definition: winuser.h:1729
#define IDOK
Definition: winuser.h:824
#define CBN_SELCHANGE
Definition: winuser.h:1969
#define WM_DESTROY
Definition: winuser.h:1599
#define CB_GETCURSEL
Definition: winuser.h:1933
#define SendDlgItemMessage
Definition: winuser.h:5832
#define BM_GETCHECK
Definition: winuser.h:1908
BOOL WINAPI EndDialog(_In_ HWND, _In_ INT_PTR)

Referenced by AdvancedPageProc().

◆ WriteStartupRecoveryOptions()

static VOID WriteStartupRecoveryOptions ( HWND  hwndDlg,
PSTARTINFO  pStartInfo 
)
static

Definition at line 550 of file startrec.c.

551{
552 HKEY hKey;
553 DWORD lResult;
554
556 L"System\\CurrentControlSet\\Control\\CrashControl",
557 0,
558 NULL,
560 KEY_WRITE,
561 NULL,
562 &hKey,
563 NULL);
564 if (lResult != ERROR_SUCCESS)
565 {
566 /* Failed to open key */
567 SetLastError(lResult);
568 ShowLastWin32Error(hwndDlg);
569
570 return;
571 }
572
574 RegSetValueExW(hKey, L"LogEvent", 0, REG_DWORD, (LPBYTE)&lResult, sizeof(lResult));
575
577 RegSetValueExW(hKey, L"SendAlert", 0, REG_DWORD, (LPBYTE)&lResult, sizeof(lResult));
578
579 lResult = (DWORD) SendDlgItemMessage(hwndDlg, IDC_STRRECRESTART, BM_GETCHECK, (WPARAM)0, (LPARAM)0);
580 RegSetValueExW(hKey, L"AutoReboot", 0, REG_DWORD, (LPBYTE)&lResult, sizeof(lResult));
581
583 RegSetValueExW(hKey, L"Overwrite", 0, REG_DWORD, (LPBYTE)&lResult, sizeof(lResult));
584
585
586 if (pStartInfo->dwCrashDumpEnabled == 1 || pStartInfo->dwCrashDumpEnabled == 2)
587 {
588 SendDlgItemMessage(hwndDlg, IDC_STRRECDUMPFILE, WM_GETTEXT, (WPARAM)sizeof(pStartInfo->szDumpFile) / sizeof(WCHAR), (LPARAM)pStartInfo->szDumpFile);
589 RegSetValueExW(hKey, L"DumpFile", 0, REG_EXPAND_SZ, (LPBYTE)pStartInfo->szDumpFile, (wcslen(pStartInfo->szDumpFile) + 1) * sizeof(WCHAR));
590 }
591 else if (pStartInfo->dwCrashDumpEnabled == 3)
592 {
593 SendDlgItemMessage(hwndDlg, IDC_STRRECDUMPFILE, WM_GETTEXT, (WPARAM)sizeof(pStartInfo->szDumpFile) / sizeof(WCHAR), (LPARAM)pStartInfo->szDumpFile);
594 RegSetValueExW(hKey, L"MinidumpDir", 0, REG_EXPAND_SZ, (LPBYTE)pStartInfo->szDumpFile, (wcslen(pStartInfo->szDumpFile) + 1) * sizeof(WCHAR));
595 }
596
597 RegSetValueExW(hKey, L"CrashDumpEnabled", 0, REG_DWORD, (LPBYTE)&pStartInfo->dwCrashDumpEnabled, sizeof(pStartInfo->dwCrashDumpEnabled));
599}
LONG WINAPI RegSetValueExW(_In_ HKEY hKey, _In_ LPCWSTR lpValueName, _In_ DWORD Reserved, _In_ DWORD dwType, _In_ CONST BYTE *lpData, _In_ DWORD cbData)
Definition: reg.c:4900
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define KEY_WRITE
Definition: nt_native.h:1031
#define REG_EXPAND_SZ
Definition: nt_native.h:1494

Referenced by StartRecDlgProc().

Variable Documentation

◆ SaveRecoveryOptions

BOOL SaveRecoveryOptions

Definition at line 32 of file startrec.c.

Referenced by LoadRecoveryOptions(), and StartRecDlgProc().