Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

320 lines
9.2 KiB

  1. /*++
  2. Microsoft Confidential
  3. Copyright (c) 1992-1997 Microsoft Corporation
  4. All rights reserved
  5. Module Name:
  6. startup.c
  7. Abstract:
  8. Implements the Startup/Recovery dialog of the System
  9. Control Panel Applet
  10. Author:
  11. Eric Flo (ericflo) 19-Jun-1995
  12. Revision History:
  13. 15-Oct-1997 scotthal
  14. Complete overhaul
  15. --*/
  16. #include <sysdm.h>
  17. #ifdef _X86_
  18. extern TCHAR szBootIni[];
  19. #endif
  20. //
  21. // Globals for this dialog
  22. //
  23. #define CSEC_START_MAX 9999 // Maximum number of seconds allowed
  24. BOOL g_fStartupInitializing;
  25. BOOL g_fRebootRequired = FALSE;
  26. #if defined(_X86_) || defined(EFI_NVRAM_ENABLED)
  27. BOOL g_fSystemStartupEnabled = TRUE;
  28. #else
  29. BOOL g_fSystemStartupEnabled = FALSE;
  30. #endif
  31. //
  32. // Help ID's
  33. //
  34. DWORD aStartupHelpIds[] = {
  35. IDC_STARTUP_SYS_OS_LABEL, (IDH_STARTUP + 0),
  36. IDC_STARTUP_SYS_OS, (IDH_STARTUP + 0),
  37. IDC_STARTUP_SYS_ENABLECOUNTDOWN, (IDH_STARTUP + 1),
  38. IDC_STARTUP_SYS_SECONDS, (IDH_STARTUP + 2),
  39. IDC_STARTUP_SYS_SECONDS_LABEL, (IDH_STARTUP + 2),
  40. IDC_STARTUP_CDMP_TXT1, (IDH_STARTUP + 3),
  41. IDC_STARTUP_CDMP_LOG, (IDH_STARTUP + 4),
  42. IDC_STARTUP_CDMP_SEND, (IDH_STARTUP + 5),
  43. IDC_STARTUP_CDMP_FILENAME, (IDH_STARTUP + 7),
  44. IDC_STARTUP_CDMP_OVERWRITE, (IDH_STARTUP + 13),
  45. IDC_STARTUP_CDMP_AUTOREBOOT, (IDH_STARTUP + 9),
  46. IDC_STARTUP_SYSTEM_GRP, (IDH_STARTUP + 10),
  47. IDC_STARTUP_SYS_SECSCROLL, (IDH_STARTUP + 11),
  48. IDC_STARTUP_CDMP_GRP, (IDH_STARTUP + 12),
  49. IDC_STARTUP_CDMP_DEBUGINFO_GROUP, (IDH_STARTUP + 14),
  50. IDC_STARTUP_CDMP_TYPE, (IDH_STARTUP + 8),
  51. IDC_STARTUP_CDMP_FILE_LABEL, (IDH_STARTUP + 7),
  52. IDC_STARTUP_SYS_EDIT_LABEL, (IDH_STARTUP + 15),
  53. IDC_SYS_EDIT_BUTTION, (IDH_STARTUP + 16),
  54. 0, 0
  55. };
  56. INT_PTR
  57. APIENTRY
  58. StartupDlgProc(
  59. IN HWND hDlg,
  60. IN UINT uMsg,
  61. IN WPARAM wParam,
  62. IN LPARAM lParam
  63. )
  64. /*++
  65. Routine Description:
  66. Handles messages sent to the Startup/Recovery dialog box
  67. Arguments:
  68. hDlg -
  69. Supplies window handle
  70. uMsg -
  71. Supplies message being sent
  72. wParam -
  73. Supplies message parameter
  74. lParam -
  75. Supplies message parameter
  76. Return Value:
  77. TRUE if message was handled
  78. FALSE if message was unhandled
  79. --*/
  80. {
  81. int iRet;
  82. // If any controls on this page are touched by the user,
  83. // enable the "Apply" button.
  84. if ((WM_COMMAND == uMsg) && (!g_fStartupInitializing)) {
  85. switch (HIWORD(wParam)) {
  86. case EN_CHANGE:
  87. case BN_CLICKED:
  88. case CBN_SELCHANGE:
  89. PropSheet_Changed(GetParent(hDlg), hDlg);
  90. break;
  91. default:
  92. break;
  93. } // switch (HIWORD(wParam))
  94. } // if ((WM_COMMAND...
  95. // Call the Core Dump stuff first. Only handle
  96. // messages not handled by the Core Dump stuff.
  97. iRet = CoreDumpDlgProc(hDlg, uMsg, wParam, lParam);
  98. switch( iRet ) {
  99. case RET_CONTINUE: {
  100. break;
  101. }
  102. case RET_BREAK: {
  103. return TRUE;
  104. }
  105. case RET_ERROR: {
  106. SetWindowLongPtr (hDlg, DWLP_MSGRESULT, PSNRET_INVALID_NOCHANGEPAGE);
  107. return TRUE;
  108. }
  109. case RET_CHANGE_NO_REBOOT:
  110. case RET_NO_CHANGE: {
  111. break;
  112. }
  113. case RET_VIRTUAL_CHANGE:
  114. case RET_RECOVER_CHANGE:
  115. case RET_VIRT_AND_RECOVER: {
  116. g_fRebootRequired = TRUE;
  117. MsgBoxParam(
  118. hDlg,
  119. IDS_SYSDM_RESTART,
  120. IDS_SYSDM_TITLE,
  121. MB_OK | MB_ICONINFORMATION
  122. );
  123. break;
  124. }
  125. }
  126. switch (uMsg)
  127. {
  128. case WM_INITDIALOG:
  129. g_fStartupInitializing = TRUE;
  130. StartListInit(hDlg, wParam, lParam);
  131. AutoAdvancedBootInit(hDlg, wParam, lParam);
  132. g_fStartupInitializing = FALSE;
  133. if (!IsUserAdmin())
  134. {
  135. EnableWindow(GetDlgItem(hDlg, IDC_SYS_EDIT_BUTTION), FALSE);
  136. EnableWindow(GetDlgItem(hDlg, IDC_STARTUP_SYS_EDIT_LABEL), FALSE);
  137. EnableWindow(GetDlgItem(hDlg, IDC_STARTUP_AUTOLKG), FALSE);
  138. EnableWindow(GetDlgItem(hDlg, IDC_STARTUP_AUTOLKG_SECONDS_LABEL), FALSE);
  139. EnableWindow(GetDlgItem(hDlg, IDC_STARTUP_AUTOLKG_SECONDS), FALSE);
  140. EnableWindow(GetDlgItem(hDlg, IDC_STARTUP_AUTOLKG_SECSCROLL), FALSE);
  141. }
  142. if (!g_fSystemStartupEnabled)
  143. {
  144. EnableWindow(GetDlgItem(hDlg, IDC_STARTUP_SYSTEM_GRP), FALSE);
  145. EnableWindow(GetDlgItem(hDlg, IDC_STARTUP_SYS_OS), FALSE);
  146. EnableWindow(GetDlgItem(hDlg, IDC_STARTUP_SYS_OS_LABEL), FALSE);
  147. EnableWindow(GetDlgItem(hDlg, IDC_STARTUP_SYS_ENABLECOUNTDOWN), FALSE);
  148. EnableWindow(GetDlgItem(hDlg, IDC_STARTUP_SYS_SECONDS_LABEL), FALSE);
  149. EnableWindow(GetDlgItem(hDlg, IDC_STARTUP_SYS_SECONDS), FALSE);
  150. EnableWindow(GetDlgItem(hDlg, IDC_STARTUP_SYS_EDIT_LABEL), FALSE);
  151. EnableWindow(GetDlgItem(hDlg, IDC_SYS_EDIT_BUTTION), FALSE);
  152. }
  153. break;
  154. case WM_COMMAND:
  155. switch (LOWORD(wParam)) {
  156. case IDC_STARTUP_AUTOLKG:
  157. if (HIWORD(wParam) == BN_CLICKED) {
  158. BOOL fEnabled;
  159. fEnabled = !IsDlgButtonChecked(hDlg, IDC_STARTUP_AUTOLKG);
  160. CheckDlgButton(hDlg, IDC_STARTUP_AUTOLKG, fEnabled);
  161. EnableWindow(GetDlgItem (hDlg, IDC_STARTUP_AUTOLKG_SECONDS), fEnabled);
  162. EnableWindow(GetDlgItem (hDlg, IDC_STARTUP_AUTOLKG_SECSCROLL), fEnabled);
  163. }
  164. break;
  165. case IDC_STARTUP_SYS_ENABLECOUNTDOWN:
  166. if (HIWORD(wParam) == BN_CLICKED) {
  167. int timeout;
  168. timeout = IsDlgButtonChecked(hDlg, IDC_STARTUP_SYS_ENABLECOUNTDOWN) ? 0 : 30;
  169. CheckDlgButton(hDlg, IDC_STARTUP_SYS_ENABLECOUNTDOWN,
  170. (BOOL) timeout);
  171. SetDlgItemInt(hDlg, IDC_STARTUP_SYS_SECONDS, timeout, FALSE);
  172. EnableWindow(GetDlgItem (hDlg, IDC_STARTUP_SYS_SECONDS), (BOOL) timeout);
  173. EnableWindow(GetDlgItem (hDlg, IDC_STARTUP_SYS_SECSCROLL), (BOOL) timeout);
  174. }
  175. break;
  176. case IDOK: {
  177. int r1, r2;
  178. if((RET_BREAK != StartListExit(hDlg, wParam, lParam)) &&
  179. (RET_BREAK != AutoAdvancedBootExit(hDlg, wParam, lParam)))
  180. {
  181. EndDialog(hDlg, 0);
  182. } // if
  183. break;
  184. }
  185. case IDCANCEL:
  186. AutoAdvancedBootExit(hDlg, wParam, lParam);
  187. EndDialog(hDlg, 0);
  188. break;
  189. case IDC_STARTUP_SYS_SECONDS:
  190. if (HIWORD(wParam) == EN_UPDATE) {
  191. if (!CheckVal(hDlg, IDC_STARTUP_SYS_SECONDS, FORMIN, FORMAX, IDS_SYSDM_ENTERSECONDS)) {
  192. SetDlgItemInt(hDlg, IDC_STARTUP_SYS_SECONDS, FORDEF, FALSE);
  193. SendMessage((HWND) lParam, EM_SETSEL, 0, -1);
  194. } // if (!CheckVal(...
  195. } // if (HIWORD(wParam == EN_UPDATE)
  196. break;
  197. case IDC_STARTUP_AUTOLKG_SECONDS:
  198. if (HIWORD(wParam) == EN_UPDATE)
  199. {
  200. if (!CheckVal(hDlg, IDC_STARTUP_AUTOLKG_SECONDS, 0, 200, IDS_SYSDM_ENTERSECONDS))
  201. {
  202. SetDlgItemInt(hDlg, IDC_STARTUP_AUTOLKG_SECONDS, 30, FALSE);
  203. SendMessage((HWND) lParam, EM_SETSEL, 0, -1);
  204. } // if (!CheckVal(...
  205. } // if (HIWORD(wParam == EN_UPDATE)
  206. break;
  207. case IDC_SYS_EDIT_BUTTION:
  208. {
  209. // invoke notepad.exe to edit boot.ini file
  210. DWORD dwFileAttr;
  211. SHELLEXECUTEINFO ExecInfo = {0};
  212. #ifdef _X86_
  213. ExecInfo.lpParameters = szBootIni;
  214. #else
  215. ExecInfo.lpParameters = TEXT("c:\\boot.ini");
  216. #endif // _X86_
  217. ExecInfo.lpFile = TEXT("NOTEPAD.EXE");
  218. ExecInfo.nShow = SW_SHOWNORMAL;
  219. ExecInfo.cbSize = sizeof(SHELLEXECUTEINFO);
  220. // Change Read-only file attrs on Boot.ini file if necessary
  221. if ((dwFileAttr = GetFileAttributes (ExecInfo.lpParameters)) != 0xFFFFFFFF)
  222. {
  223. if (dwFileAttr & FILE_ATTRIBUTE_READONLY)
  224. {
  225. SetFileAttributes (ExecInfo.lpParameters, dwFileAttr & ~FILE_ATTRIBUTE_READONLY);
  226. }
  227. }
  228. ShellExecuteEx(&ExecInfo);
  229. }
  230. break;
  231. } // switch (LOWORD(wParam))
  232. break;
  233. case WM_DESTROY:
  234. StartListDestroy(hDlg, wParam, lParam);
  235. break;
  236. case WM_HELP: // F1
  237. WinHelp((HWND)((LPHELPINFO) lParam)->hItemHandle, HELP_FILE, HELP_WM_HELP,
  238. (DWORD_PTR) (LPSTR) aStartupHelpIds);
  239. break;
  240. case WM_CONTEXTMENU: // right mouse click
  241. WinHelp((HWND) wParam, HELP_FILE, HELP_CONTEXTMENU,
  242. (DWORD_PTR) (LPSTR) aStartupHelpIds);
  243. break;
  244. default:
  245. return FALSE;
  246. }
  247. return TRUE;
  248. }