ReactOS  0.4.14-dev-115-g4576127
startrec.c
Go to the documentation of this file.
1 /*
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>
9  */
10 
11 #include "precomp.h"
12 
13 #include <shlwapi.h>
14 
15 typedef struct _STARTINFO
16 {
23 
25 
26 static VOID
28 {
29  if (Timeout == 0)
30  {
33  }
34  else
35  {
38  }
39  SendDlgItemMessageW(hwndDlg, IDC_STRRECLISTUPDWN, UDM_SETRANGE, (WPARAM) 0, (LPARAM) MAKELONG((short) 999, 0));
41 }
42 
43 static VOID
45 {
46  if (Timeout == 0)
47  {
50  }
51  else
52  {
55  }
56  SendDlgItemMessageW(hwndDlg, IDC_STRRECRECUPDWN, UDM_SETRANGE, (WPARAM) 0, (LPARAM) MAKELONG((short) 999, 0));
58 }
59 
60 
61 static DWORD
62 GetSystemDrive(WCHAR **szSystemDrive)
63 {
64  DWORD dwBufSize;
65 
66  /* Get Path to freeldr.ini or boot.ini */
67  *szSystemDrive = HeapAlloc(GetProcessHeap(), 0, MAX_PATH * sizeof(WCHAR));
68  if (*szSystemDrive != NULL)
69  {
70  dwBufSize = GetEnvironmentVariableW(L"SystemDrive", *szSystemDrive, MAX_PATH);
71  if (dwBufSize > MAX_PATH)
72  {
73  WCHAR *szTmp;
74  DWORD dwBufSize2;
75 
76  szTmp = HeapReAlloc(GetProcessHeap(), 0, *szSystemDrive, dwBufSize * sizeof(WCHAR));
77  if (szTmp == NULL)
78  goto FailGetSysDrive;
79 
80  *szSystemDrive = szTmp;
81 
82  dwBufSize2 = GetEnvironmentVariableW(L"SystemDrive", *szSystemDrive, dwBufSize);
83  if (dwBufSize2 > dwBufSize || dwBufSize2 == 0)
84  goto FailGetSysDrive;
85  }
86  else if (dwBufSize == 0)
87  {
88 FailGetSysDrive:
89  HeapFree(GetProcessHeap(), 0, *szSystemDrive);
90  *szSystemDrive = NULL;
91  return 0;
92  }
93 
94  return dwBufSize;
95  }
96 
97  return 0;
98 }
99 
100 static PBOOTRECORD
101 ReadFreeldrSection(HINF hInf, WCHAR *szSectionName)
102 {
103  PBOOTRECORD pRecord;
104  INFCONTEXT InfContext;
106  WCHAR szValue[MAX_PATH];
107  DWORD LineLength;
108 
109  if (!SetupFindFirstLineW(hInf,
110  szSectionName,
111  NULL,
112  &InfContext))
113  {
114  /* Failed to find section */
115  return NULL;
116  }
117 
118  pRecord = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(BOOTRECORD));
119  if (pRecord == NULL)
120  {
121  return NULL;
122  }
123 
124  wcscpy(pRecord->szSectionName, szSectionName);
125 
126  do
127  {
128  if (!SetupGetStringFieldW(&InfContext,
129  0,
130  szName,
131  sizeof(szName) / sizeof(WCHAR),
132  &LineLength))
133  {
134  break;
135  }
136 
137  if (!SetupGetStringFieldW(&InfContext,
138  1,
139  szValue,
140  sizeof(szValue) / sizeof(WCHAR),
141  &LineLength))
142  {
143  break;
144  }
145 
146  if (!_wcsnicmp(szName, L"BootType", 8))
147  {
148  if (!_wcsnicmp(szValue, L"ReactOS", 7))
149  {
150  // FIXME: Store as enum
151  pRecord->BootType = 1;
152  }
153  else
154  {
155  pRecord->BootType = 0;
156  }
157  }
158  else if (!_wcsnicmp(szName, L"SystemPath", 10))
159  {
160  wcscpy(pRecord->szBootPath, szValue);
161  }
162  else if (!_wcsnicmp(szName, L"Options", 7))
163  {
164  // FIXME: Store flags as values
165  wcscpy(pRecord->szOptions, szValue);
166  }
167 
168  }
169  while (SetupFindNextLine(&InfContext, &InfContext));
170 
171  return pRecord;
172 }
173 
174 
175 static INT
177 {
178  INFCONTEXT InfContext;
179  PBOOTRECORD pRecord;
180  WCHAR szDefaultOs[MAX_PATH];
182  WCHAR szValue[MAX_PATH];
183  DWORD LineLength;
184  DWORD TimeOut;
185  LRESULT lResult;
186 
187  if (!SetupFindFirstLineW(hInf,
188  L"FREELOADER",
189  L"DefaultOS",
190  &InfContext))
191  {
192  /* Failed to find default os */
193  return FALSE;
194  }
195 
196  if (!SetupGetStringFieldW(&InfContext,
197  1,
198  szDefaultOs,
199  sizeof(szDefaultOs) / sizeof(WCHAR),
200  &LineLength))
201  {
202  /* No key */
203  return FALSE;
204  }
205 
206  if (!SetupFindFirstLineW(hInf,
207  L"FREELOADER",
208  L"TimeOut",
209  &InfContext))
210  {
211  /* Expected to find timeout value */
212  return FALSE;
213  }
214 
215 
216  if (!SetupGetIntField(&InfContext,
217  1,
218  (PINT)&TimeOut))
219  {
220  /* Failed to retrieve timeout */
221  return FALSE;
222  }
223 
224  if (!SetupFindFirstLineW(hInf,
225  L"Operating Systems",
226  NULL,
227  &InfContext))
228  {
229  /* Expected list of operating systems */
230  return FALSE;
231  }
232 
233  do
234  {
235  if (!SetupGetStringFieldW(&InfContext,
236  0,
237  szName,
238  sizeof(szName) / sizeof(WCHAR),
239  &LineLength))
240  {
241  /* The ini file is messed up */
242  return FALSE;
243  }
244 
245  if (!SetupGetStringFieldW(&InfContext,
246  1,
247  szValue,
248  sizeof(szValue) / sizeof(WCHAR),
249  &LineLength))
250  {
251  /* The ini file is messed up */
252  return FALSE;
253  }
254 
255  pRecord = ReadFreeldrSection(hInf, szName);
256  if (pRecord)
257  {
258  lResult = SendDlgItemMessageW(hwndDlg, IDC_STRECOSCOMBO, CB_ADDSTRING, (WPARAM)0, (LPARAM)szValue);
259  if (lResult != CB_ERR)
260  {
261  SendDlgItemMessageW(hwndDlg, IDC_STRECOSCOMBO, CB_SETITEMDATA, (WPARAM)lResult, (LPARAM)pRecord);
262  if (!wcscmp(szDefaultOs, szName))
263  {
264  /* We store the friendly name as key */
265  wcscpy(szDefaultOs, szValue);
266  }
267  }
268  else
269  {
270  HeapFree(GetProcessHeap(), 0, pRecord);
271  }
272  }
273  }
274  while (SetupFindNextLine(&InfContext, &InfContext));
275 
276  /* Find default os in list */
277  lResult = SendDlgItemMessageW(hwndDlg, IDC_STRECOSCOMBO, CB_FINDSTRING, (WPARAM)-1, (LPARAM)szDefaultOs);
278  if (lResult != CB_ERR)
279  {
280  /* Set cur sel */
282  }
283 
284  if(TimeOut)
285  {
287  }
288 
289  SetTimeout(hwndDlg, TimeOut);
290 
291  return TRUE;
292 }
293 
294 static INT
295 LoadBootSettings(HINF hInf, HWND hwndDlg)
296 {
297  INFCONTEXT InfContext;
299  WCHAR szValue[MAX_PATH];
300  DWORD LineLength;
301  DWORD TimeOut = 0;
302  WCHAR szDefaultOS[MAX_PATH];
303  WCHAR szOptions[MAX_PATH];
304  PBOOTRECORD pRecord;
305  LRESULT lResult;
306 
307  if(!SetupFindFirstLineW(hInf,
308  L"boot loader",
309  NULL,
310  &InfContext))
311  {
312  return FALSE;
313  }
314 
315  do
316  {
317  if (!SetupGetStringFieldW(&InfContext,
318  0,
319  szName,
320  sizeof(szName) / sizeof(WCHAR),
321  &LineLength))
322  {
323  return FALSE;
324  }
325 
326  if (!SetupGetStringFieldW(&InfContext,
327  1,
328  szValue,
329  sizeof(szValue) / sizeof(WCHAR),
330  &LineLength))
331  {
332  return FALSE;
333  }
334 
335  if (!_wcsnicmp(szName, L"timeout", 7))
336  {
337  TimeOut = _wtoi(szValue);
338  }
339 
340  if (!_wcsnicmp(szName, L"default", 7))
341  {
342  wcscpy(szDefaultOS, szValue);
343  }
344 
345  }
346  while (SetupFindNextLine(&InfContext, &InfContext));
347 
348  if (!SetupFindFirstLineW(hInf,
349  L"operating systems",
350  NULL,
351  &InfContext))
352  {
353  /* Failed to find operating systems section */
354  return FALSE;
355  }
356 
357  do
358  {
359  if (!SetupGetStringFieldW(&InfContext,
360  0,
361  szName,
362  sizeof(szName) / sizeof(WCHAR),
363  &LineLength))
364  {
365  return FALSE;
366  }
367 
368  if (!SetupGetStringFieldW(&InfContext,
369  1,
370  szValue,
371  sizeof(szValue) / sizeof(WCHAR),
372  &LineLength))
373  {
374  return FALSE;
375  }
376 
377  SetupGetStringFieldW(&InfContext,
378  2,
379  szOptions,
380  sizeof(szOptions) / sizeof(WCHAR),
381  &LineLength);
382 
384  if (pRecord)
385  {
386  pRecord->BootType = 0;
387  wcscpy(pRecord->szBootPath, szName);
388  wcscpy(pRecord->szSectionName, szValue);
389  wcscpy(pRecord->szOptions, szOptions);
390 
391  if (!wcscmp(szName, szDefaultOS))
392  {
393  /* ms boot ini stores the path not the friendly name */
394  wcscpy(szDefaultOS, szValue);
395  }
396 
397  lResult = SendDlgItemMessageW(hwndDlg, IDC_STRECOSCOMBO, CB_ADDSTRING, (WPARAM)0, (LPARAM)szValue);
398  if (lResult != CB_ERR)
399  {
400  SendDlgItemMessageW(hwndDlg, IDC_STRECOSCOMBO, CB_SETITEMDATA, (WPARAM)lResult, (LPARAM)pRecord);
401  }
402  else
403  {
404  HeapFree(GetProcessHeap(), 0, pRecord);
405  }
406  }
407 
408  }
409  while (SetupFindNextLine(&InfContext, &InfContext));
410 
411  /* Find default os in list */
412  lResult = SendDlgItemMessageW(hwndDlg, IDC_STRECOSCOMBO, CB_FINDSTRING, (WPARAM)0, (LPARAM)szDefaultOS);
413  if (lResult != CB_ERR)
414  {
415  /* Set cur sel */
417  }
418 
419  if(TimeOut)
420  {
422  }
423 
424  SetTimeout(hwndDlg, TimeOut);
425 
426  return TRUE;
427 }
428 
429 static VOID
431 {
432  LRESULT lIndex;
433  LONG index;
434  PBOOTRECORD pRecord;
435 
436  lIndex = SendDlgItemMessageW(hwndDlg, IDC_STRECOSCOMBO, CB_GETCOUNT, (WPARAM)0, (LPARAM)0);
437  if (lIndex == CB_ERR)
438  return;
439 
440  for (index = 0; index <lIndex; index++)
441  {
443  if ((INT_PTR)pRecord != CB_ERR)
444  {
445  HeapFree(GetProcessHeap(), 0, pRecord);
446  }
447  }
448 
450 }
451 
452 static LRESULT
453 LoadOSList(HWND hwndDlg, PSTARTINFO pStartInfo)
454 {
455  DWORD dwBufSize;
456  WCHAR *szSystemDrive;
457  HINF hInf;
458 
459  dwBufSize = GetSystemDrive(&szSystemDrive);
460  if (dwBufSize == 0)
461  return FALSE;
462 
463  wcscpy(pStartInfo->szFreeldrIni, szSystemDrive);
464  wcscat(pStartInfo->szFreeldrIni, L"\\freeldr.ini");
465 
466  if (PathFileExistsW(pStartInfo->szFreeldrIni))
467  {
468  /* Free resource previously allocated by GetSystemDrive() */
469  HeapFree(GetProcessHeap(), 0, szSystemDrive);
470  /* freeldr.ini exists */
471  hInf = SetupOpenInfFileW(pStartInfo->szFreeldrIni,
472  NULL,
474  NULL);
475 
476  if (hInf != INVALID_HANDLE_VALUE)
477  {
478  LoadFreeldrSettings(hInf, hwndDlg);
479  SetupCloseInfFile(hInf);
480  pStartInfo->iFreeLdrIni = 1;
481  return TRUE;
482  }
483  return FALSE;
484  }
485 
486  /* Try loading boot.ini settings */
487  wcscpy(pStartInfo->szFreeldrIni, szSystemDrive);
488  wcscat(pStartInfo->szFreeldrIni, L"\\boot.ini");
489 
490  /* Free resource previously allocated by GetSystemDrive() */
491  HeapFree(GetProcessHeap(), 0, szSystemDrive);
492 
493  if (PathFileExistsW(pStartInfo->szFreeldrIni))
494  {
495  /* Load boot.ini settings */
496  hInf = SetupOpenInfFileW(pStartInfo->szFreeldrIni,
497  NULL,
499  NULL);
500 
501  if (hInf != INVALID_HANDLE_VALUE)
502  {
503  LoadBootSettings(hInf, hwndDlg);
504  SetupCloseInfFile(hInf);
505  pStartInfo->iFreeLdrIni = 2;
506  return TRUE;
507  }
508 
509  return FALSE;
510  }
511 
512  return FALSE;
513 }
514 
515 static VOID
517 {
518  if (pStartInfo->dwCrashDumpEnabled == 0)
519  {
520  /* No crash information required */
523  }
524  else if (pStartInfo->dwCrashDumpEnabled == 3)
525  {
526  /* Minidump type */
530  }
531  else if (pStartInfo->dwCrashDumpEnabled == 1 || pStartInfo->dwCrashDumpEnabled == 2)
532  {
533  /* Kernel or complete dump */
537  }
539 }
540 
541 static VOID
543 {
544  HKEY hKey;
545  DWORD lResult;
546 
548  L"System\\CurrentControlSet\\Control\\CrashControl",
549  0,
550  NULL,
552  KEY_WRITE,
553  NULL,
554  &hKey,
555  NULL);
556  if (lResult != ERROR_SUCCESS)
557  {
558  /* Failed to open key */
559  SetLastError(lResult);
560  ShowLastWin32Error(hwndDlg);
561 
562  return;
563  }
564 
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));
567 
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));
570 
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));
573 
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));
576 
577 
578  if (pStartInfo->dwCrashDumpEnabled == 1 || pStartInfo->dwCrashDumpEnabled == 2)
579  {
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));
582  }
583  else if (pStartInfo->dwCrashDumpEnabled == 3)
584  {
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));
587  }
588 
589  RegSetValueExW(hKey, L"CrashDumpEnabled", 0, REG_DWORD, (LPBYTE)&pStartInfo->dwCrashDumpEnabled, sizeof(pStartInfo->dwCrashDumpEnabled));
590  RegCloseKey(hKey);
591 }
592 
593 static VOID
594 LoadRecoveryOptions(HWND hwndDlg, PSTARTINFO pStartInfo)
595 {
596  HKEY hKey;
598  DWORD dwValue, dwValueLength, dwType, dwResult;
599 
601  L"System\\CurrentControlSet\\Control\\CrashControl",
602  0,
603  NULL,
605  KEY_READ,
606  NULL,
607  &hKey,
608  NULL);
609  if (dwResult != ERROR_SUCCESS)
610  {
611  /* Failed to open key */
612  SetLastError(dwResult);
613  ShowLastWin32Error(hwndDlg);
614 
621 
623  return;
624  }
625 
626  dwValueLength = sizeof(DWORD);
627  if (RegQueryValueExW(hKey, L"LogEvent", NULL, &dwType, (LPBYTE)&dwValue, &dwValueLength) == ERROR_SUCCESS && dwType == REG_DWORD && dwValue)
629 
630  dwValueLength = sizeof(DWORD);
631  if (RegQueryValueExW(hKey, L"SendAlert", NULL, &dwType, (LPBYTE)&dwValue, &dwValueLength) == ERROR_SUCCESS && dwType == REG_DWORD && dwValue)
633 
634  dwValueLength = sizeof(DWORD);
635  if (RegQueryValueExW(hKey, L"AutoReboot", NULL, &dwType, (LPBYTE)&dwValue, &dwValueLength) == ERROR_SUCCESS && dwType == REG_DWORD && dwValue)
637 
638  dwValueLength = sizeof(DWORD);
639  if (RegQueryValueExW(hKey, L"Overwrite", NULL, &dwType, (LPBYTE)&dwValue, &dwValueLength) == ERROR_SUCCESS && dwType == REG_DWORD && dwValue)
641 
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;
645 
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';
649 
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';
653 
654  if (LoadStringW(hApplet, IDS_NO_DUMP, szName, sizeof(szName) / sizeof(WCHAR)))
655  {
656  szName[(sizeof(szName)/sizeof(WCHAR))-1] = L'\0';
658  }
659 
660  if (LoadStringW(hApplet, IDS_FULL_DUMP, szName, sizeof(szName) / sizeof(WCHAR)))
661  {
662  szName[(sizeof(szName)/sizeof(WCHAR))-1] = L'\0';
664  }
665 
666  if (LoadStringW(hApplet, IDS_KERNEL_DUMP, szName, sizeof(szName) / sizeof(WCHAR)))
667  {
668  szName[(sizeof(szName)/sizeof(WCHAR))-1] = L'\0';
670  }
671 
672  if (LoadStringW(hApplet, IDS_MINI_DUMP, szName, sizeof(szName) / sizeof(WCHAR)))
673  {
674  szName[(sizeof(szName)/sizeof(WCHAR))-1] = L'\0';
676  }
677 
678  SetCrashDlgItems(hwndDlg, pStartInfo);
679  RegCloseKey(hKey);
680 
682 }
683 
684 
685 /* Property page dialog callback */
688  UINT uMsg,
689  WPARAM wParam,
690  LPARAM lParam)
691 {
692  PSTARTINFO pStartInfo;
693  PBOOTRECORD pRecord;
694  int iTimeout;
695  LRESULT lResult;
696  WCHAR szTimeout[10];
697 
699 
700  pStartInfo = (PSTARTINFO)GetWindowLongPtr(hwndDlg, DWLP_USER);
701 
702  switch(uMsg)
703  {
704  case WM_INITDIALOG:
705  pStartInfo = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(STARTINFO));
706  SetWindowLongPtr(hwndDlg, DWLP_USER, (LONG_PTR)pStartInfo);
707 
708  LoadRecoveryOptions(hwndDlg, pStartInfo);
709  SetRecoveryTimeout(hwndDlg, 0);
710  return LoadOSList(hwndDlg, pStartInfo);
711 
712  case WM_DESTROY:
713  DeleteBootRecords(hwndDlg);
714  HeapFree(GetProcessHeap(), 0, pStartInfo);
715  break;
716 
717  case WM_COMMAND:
718  switch(LOWORD(wParam))
719  {
720  case IDC_STRRECEDIT:
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);
725  break;
726 
727  case IDOK:
728  /* Save timeout */
730  iTimeout = SendDlgItemMessage(hwndDlg, IDC_STRRECLISTUPDWN, UDM_GETPOS, (WPARAM)0, (LPARAM)0);
731  else
732  iTimeout = 0;
733  swprintf(szTimeout, L"%i", iTimeout);
734 
735  lResult = SendDlgItemMessageW(hwndDlg, IDC_STRECOSCOMBO, CB_GETCURSEL, (WPARAM)0, (LPARAM)0);
736  if (lResult == CB_ERR)
737  {
738  /* ? */
739  DeleteBootRecords(hwndDlg);
740  return TRUE;
741  }
742 
743  pRecord = (PBOOTRECORD) SendDlgItemMessage(hwndDlg, IDC_STRECOSCOMBO, CB_GETITEMDATA, (WPARAM)lResult, (LPARAM)0);
744 
745  if ((INT_PTR)pRecord != CB_ERR)
746  {
747  if (pStartInfo->iFreeLdrIni == 1) // FreeLdrIni style
748  {
749  /* Set default timeout */
750  WritePrivateProfileStringW(L"FREELOADER",
751  L"TimeOut",
752  szTimeout,
753  pStartInfo->szFreeldrIni);
754  /* Set default OS */
755  WritePrivateProfileStringW(L"FREELOADER",
756  L"DefaultOS",
757  pRecord->szSectionName,
758  pStartInfo->szFreeldrIni);
759 
760  }
761  else if (pStartInfo->iFreeLdrIni == 2) // BootIni style
762  {
763  /* Set default timeout */
764  WritePrivateProfileStringW(L"boot loader",
765  L"timeout",
766  szTimeout,
767  pStartInfo->szFreeldrIni);
768  /* Set default OS */
769  WritePrivateProfileStringW(L"boot loader",
770  L"default",
771  pRecord->szBootPath,
772  pStartInfo->szFreeldrIni);
773 
774  }
775  }
776 
778  {
779  WriteStartupRecoveryOptions(hwndDlg, pStartInfo);
780  }
781 
782  EndDialog(hwndDlg,
783  LOWORD(wParam));
784  return TRUE;
785 
786  case IDCANCEL:
787  EndDialog(hwndDlg,
788  LOWORD(wParam));
789  return TRUE;
790 
791  case IDC_STRECLIST:
793  SetTimeout(hwndDlg, 30);
794  else
795  SetTimeout(hwndDlg, 0);
796  break;
797 
798  case IDC_STRRECREC:
800  SetRecoveryTimeout(hwndDlg, 30);
801  else
802  SetRecoveryTimeout(hwndDlg, 0);
803  break;
804 
806  if (HIWORD(wParam) == CBN_SELCHANGE)
807  {
808  LRESULT lResult;
809 
811  if (lResult != CB_ERR && lResult != (LRESULT)pStartInfo->dwCrashDumpEnabled)
812  {
813  if (pStartInfo->dwCrashDumpEnabled == 1 || pStartInfo->dwCrashDumpEnabled == 2)
814  {
815  SendDlgItemMessageW(hwndDlg, IDC_STRRECDUMPFILE, WM_GETTEXT, (WPARAM)sizeof(pStartInfo->szDumpFile) / sizeof(WCHAR), (LPARAM)pStartInfo->szDumpFile);
816  }
817  else if (pStartInfo->dwCrashDumpEnabled == 3)
818  {
819  SendDlgItemMessageW(hwndDlg, IDC_STRRECDUMPFILE, WM_GETTEXT, (WPARAM)sizeof(pStartInfo->szMinidumpDir) / sizeof(WCHAR), (LPARAM)pStartInfo->szMinidumpDir);
820  }
821 
822  pStartInfo->dwCrashDumpEnabled = (DWORD)lResult;
823  SetCrashDlgItems(hwndDlg, pStartInfo);
824  }
825  }
826  break;
827  }
828  break;
829  }
830 
831  return FALSE;
832 }
BOOL WINAPI SetupFindFirstLineW(IN HINF InfHandle, IN PCWSTR Section, IN PCWSTR Key, IN OUT PINFCONTEXT Context)
Definition: infsupp.c:54
#define CB_SETITEMDATA
Definition: winuser.h:1948
WCHAR szBootPath[MAX_PATH]
Definition: precomp.h:83
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
DWORD BootType
Definition: precomp.h:81
#define TRUE
Definition: types.h:120
#define UDM_GETPOS
Definition: commctrl.h:2116
#define IDOK
Definition: winuser.h:824
WCHAR szDumpFile[MAX_PATH]
Definition: startrec.c:18
#define ERROR_SUCCESS
Definition: deptool.c:10
#define IDC_STRRECLISTUPDWN
Definition: resource.h:159
#define IDC_STRRECRECUPDWN
Definition: resource.h:162
#define KEY_READ
Definition: nt_native.h:1023
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:323
static INT LoadBootSettings(HINF hInf, HWND hwndDlg)
Definition: startrec.c:295
#define CB_GETITEMDATA
Definition: winuser.h:1932
#define IDS_NO_DUMP
Definition: resource.h:26
_Check_return_ _CRTIMP int __cdecl _wtoi(_In_z_ const wchar_t *_Str)
#define WM_GETTEXT
Definition: winuser.h:1600
#define INF_STYLE_OLDNT
Definition: infsupp.h:37
#define CALLBACK
Definition: compat.h:27
_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)
#define IDS_MINI_DUMP
Definition: resource.h:27
#define IDC_STRRECDEBUGCOMBO
Definition: resource.h:167
#define INVALID_HANDLE_VALUE
Definition: compat.h:391
HINSTANCE hApplet
Definition: access.c:17
UINT_PTR WPARAM
Definition: windef.h:207
#define SendDlgItemMessage
Definition: winuser.h:5743
int32_t INT_PTR
Definition: typedefs.h:62
HINF WINAPI SetupOpenInfFileW(PCWSTR name, PCWSTR class, DWORD style, UINT *error)
Definition: parser.c:1229
char szTmp[518]
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
#define DWORD
Definition: nt_native.h:44
int32_t INT
Definition: typedefs.h:56
#define SetWindowLongPtr
Definition: treelist.c:70
#define CB_GETCURSEL
Definition: winuser.h:1925
BOOL WINAPI EndDialog(_In_ HWND, _In_ INT_PTR)
WPARAM wParam
Definition: combotst.c:138
VOID WINAPI SetupCloseInfFile(IN HINF InfHandle)
Definition: infsupp.c:43
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
#define IDC_STRRECEDIT
Definition: resource.h:163
void ShowLastWin32Error(HWND hwndParent)
Definition: winutils.c:11
#define IDC_STRRECWRITEEVENT
Definition: resource.h:164
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
unsigned char * LPBYTE
Definition: typedefs.h:52
#define IDC_STRRECLISTEDIT
Definition: resource.h:158
unsigned int BOOL
Definition: ntddk_ex.h:94
#define IDC_STRRECRECEDIT
Definition: resource.h:161
long LONG
Definition: pedump.c:60
static VOID DeleteBootRecords(HWND hwndDlg)
Definition: startrec.c:430
#define IDS_FULL_DUMP
Definition: resource.h:29
#define CB_ADDSTRING
Definition: winuser.h:1918
#define MAKELONG(a, b)
Definition: typedefs.h:248
smooth NULL
Definition: ftsmooth.c:416
struct _BOOTRECORD * PBOOTRECORD
LONG_PTR LPARAM
Definition: windef.h:208
#define BM_GETCHECK
Definition: winuser.h:1900
BOOL WINAPI PathFileExistsW(LPCWSTR lpszPath)
Definition: path.c:1756
#define UDM_SETRANGE
Definition: commctrl.h:2113
GLuint index
Definition: glext.h:6031
#define WM_SETTEXT
Definition: winuser.h:1599
#define CB_RESETCONTENT
Definition: winuser.h:1941
#define CB_ERR
Definition: winuser.h:2410
#define WM_DESTROY
Definition: winuser.h:1591
INT iFreeLdrIni
Definition: startrec.c:21
#define IDC_STRRECDUMPFILE
Definition: resource.h:168
#define IDC_STRRECREC
Definition: resource.h:160
#define REG_OPTION_NON_VOLATILE
Definition: nt_native.h:1057
#define KEY_WRITE
Definition: nt_native.h:1031
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:4895
DWORD dwCrashDumpEnabled
Definition: startrec.c:20
#define IDS_KERNEL_DUMP
Definition: resource.h:28
#define BM_SETCHECK
Definition: winuser.h:1903
int * PINT
Definition: windef.h:177
#define IDC_STRECLIST
Definition: resource.h:157
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
static VOID SetRecoveryTimeout(HWND hwndDlg, INT Timeout)
Definition: startrec.c:44
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4116
if(!(yy_init))
Definition: macro.lex.yy.c:714
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
static VOID WriteStartupRecoveryOptions(HWND hwndDlg, PSTARTINFO pStartInfo)
Definition: startrec.c:542
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define MAX_PATH
Definition: compat.h:26
#define swprintf(buf, format,...)
Definition: sprintf.c:56
WCHAR szSectionName[128]
Definition: precomp.h:82
unsigned long DWORD
Definition: ntddk_ex.h:95
static VOID SetCrashDlgItems(HWND hwnd, PSTARTINFO pStartInfo)
Definition: startrec.c:516
#define SetLastError(x)
Definition: compat.h:409
static LRESULT LoadOSList(HWND hwndDlg, PSTARTINFO pStartInfo)
Definition: startrec.c:453
static INT LoadFreeldrSettings(HINF hInf, HWND hwndDlg)
Definition: startrec.c:176
LRESULT WINAPI SendDlgItemMessageW(_In_ HWND, _In_ int, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
static VOID SetTimeout(HWND hwndDlg, INT Timeout)
Definition: startrec.c:27
struct _BOOTRECORD BOOTRECORD
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
#define index(s, c)
Definition: various.h:29
static const WCHAR L[]
Definition: oid.c:1250
#define DWLP_USER
Definition: winuser.h:866
#define CB_SETCURSEL
Definition: winuser.h:1943
#define WM_COMMAND
Definition: winuser.h:1722
BOOL WINAPI WritePrivateProfileStringW(LPCWSTR section, LPCWSTR entry, LPCWSTR string, LPCWSTR filename)
Definition: profile.c:1453
BOOL WINAPI EnableWindow(_In_ HWND, _In_ BOOL)
WCHAR szFreeldrIni[MAX_PATH+15]
Definition: startrec.c:17
static PBOOTRECORD ReadFreeldrSection(HINF hInf, WCHAR *szSectionName)
Definition: startrec.c:101
WCHAR szOptions[512]
Definition: precomp.h:84
_Check_return_ _CRTIMP int __cdecl wcscmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
#define SW_SHOWNORMAL
Definition: winuser.h:764
static ULONG Timeout
Definition: ping.c:61
#define REG_EXPAND_SZ
Definition: nt_native.h:1494
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define HeapReAlloc
Definition: compat.h:393
static VOID LoadRecoveryOptions(HWND hwndDlg, PSTARTINFO pStartInfo)
Definition: startrec.c:594
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
_CRTIMP wchar_t *__cdecl wcscat(_Inout_updates_z_(_String_length_(_Dest)+_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
#define IDC_STRRECOVERWRITE
Definition: resource.h:169
struct _STARTINFO STARTINFO
#define UDM_SETPOS
Definition: commctrl.h:2115
unsigned int UINT
Definition: ndis.h:50
#define HEAP_ZERO_MEMORY
Definition: compat.h:123
#define CBN_SELCHANGE
Definition: winuser.h:1961
BOOL WINAPI SetupFindNextLine(IN PINFCONTEXT ContextIn, OUT PINFCONTEXT ContextOut)
Definition: infsupp.c:80
#define IDC_STRECOSCOMBO
Definition: resource.h:156
#define BST_CHECKED
Definition: winuser.h:197
static DWORD GetSystemDrive(WCHAR **szSystemDrive)
Definition: startrec.c:62
BOOL SaveRecoveryOptions
Definition: startrec.c:24
INT_PTR CALLBACK StartRecDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: startrec.c:687
static const WCHAR szName[]
Definition: msipriv.h:1194
BOOL WINAPI SetupGetIntField(IN PINFCONTEXT Context, IN ULONG FieldIndex, OUT INT *IntegerValue)
Definition: infsupp.c:146
HINSTANCE WINAPI ShellExecuteW(HWND hwnd, LPCWSTR lpVerb, LPCWSTR lpFile, LPCWSTR lpParameters, LPCWSTR lpDirectory, INT nShowCmd)
Definition: shlexec.cpp:2208
#define HIWORD(l)
Definition: typedefs.h:246
#define CB_GETCOUNT
Definition: winuser.h:1924
#define GetWindowLongPtr
Definition: treelist.c:73
#define IDCANCEL
Definition: winuser.h:825
LONG_PTR LRESULT
Definition: windef.h:209
#define GetEnvironmentVariableW(x, y, z)
Definition: compat.h:412
#define IDC_STRRECRESTART
Definition: resource.h:166
#define REG_DWORD
Definition: sdbapi.c:596
#define CB_FINDSTRING
Definition: winuser.h:1921
#define WM_INITDIALOG
Definition: winuser.h:1721
LPARAM lParam
Definition: combotst.c:139
#define LOWORD(l)
Definition: pedump.c:82
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define HeapFree(x, y, z)
Definition: compat.h:394
#define IDC_STRRECSENDALERT
Definition: resource.h:165
WCHAR szMinidumpDir[MAX_PATH]
Definition: startrec.c:19
struct _STARTINFO * PSTARTINFO
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12
BOOL WINAPI SetupGetStringFieldW(IN PINFCONTEXT Context, IN ULONG FieldIndex, OUT PWSTR ReturnBuffer, IN ULONG ReturnBufferSize, OUT PULONG RequiredSize)
Definition: infsupp.c:184