Leaked source code of windows server 2003
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.

506 lines
15 KiB

  1. //
  2. // Driver Verifier UI
  3. // Copyright (c) Microsoft Corporation, 1999
  4. //
  5. //
  6. //
  7. // module: DSetPage.cpp
  8. // author: DMihai
  9. // created: 11/1/00
  10. //
  11. // Description:
  12. //
  13. #include "stdafx.h"
  14. #include "verifier.h"
  15. #include "DSetPage.h"
  16. #include "VSheet.h"
  17. #include "VrfUtil.h"
  18. #include "VGlobal.h"
  19. #ifdef _DEBUG
  20. #define new DEBUG_NEW
  21. #undef THIS_FILE
  22. static char THIS_FILE[] = __FILE__;
  23. #endif
  24. //
  25. // Change this if you add/remove/change order
  26. // of radio buttons on this page
  27. //
  28. #define FIRST_RADIO_BUTTON_ID IDC_DRVSET_NOTSIGNED_RADIO
  29. //
  30. // Help IDs
  31. //
  32. static DWORD MyHelpIds[] =
  33. {
  34. IDC_DRVSET_NOTSIGNED_RADIO, IDH_DV_SelectUnsigned,
  35. IDC_DRVSET_OLDVER_RADIO, IDH_DV_SelectOlderversions,
  36. IDC_DRVSET_ALLDRV_RADIO, IDH_DV_SelectAll,
  37. IDC_DRVSET_NAMESLIST_RADIO, IDH_DV_SelectFromList,
  38. 0, 0
  39. };
  40. /////////////////////////////////////////////////////////////////////////////
  41. // CDriverSetPage property page
  42. IMPLEMENT_DYNCREATE(CDriverSetPage, CVerifierPropertyPage)
  43. CDriverSetPage::CDriverSetPage()
  44. : CVerifierPropertyPage( CDriverSetPage::IDD )
  45. {
  46. //{{AFX_DATA_INIT(CDriverSetPage)
  47. m_nCrtRadio = -1;
  48. //}}AFX_DATA_INIT
  49. }
  50. CDriverSetPage::~CDriverSetPage()
  51. {
  52. }
  53. void CDriverSetPage::DoDataExchange(CDataExchange* pDX)
  54. {
  55. CVerifierPropertyPage::DoDataExchange(pDX);
  56. //{{AFX_DATA_MAP(CDriverSetPage)
  57. DDX_Control(pDX, IDC_DRVSET_NEXT_DESCR_STATIC, m_NextDescription);
  58. DDX_Radio(pDX, IDC_DRVSET_NOTSIGNED_RADIO, m_nCrtRadio);
  59. //}}AFX_DATA_MAP
  60. }
  61. BEGIN_MESSAGE_MAP(CDriverSetPage, CVerifierPropertyPage)
  62. //{{AFX_MSG_MAP(CDriverSetPage)
  63. ON_BN_CLICKED(IDC_DRVSET_ALLDRV_RADIO, OnAlldrvRadio)
  64. ON_BN_CLICKED(IDC_DRVSET_NAMESLIST_RADIO, OnNameslistRadio)
  65. ON_BN_CLICKED(IDC_DRVSET_NOTSIGNED_RADIO, OnNotsignedRadio)
  66. ON_BN_CLICKED(IDC_DRVSET_OLDVER_RADIO, OnOldverRadio)
  67. ON_WM_CONTEXTMENU()
  68. ON_MESSAGE( WM_HELP, OnHelp )
  69. //}}AFX_MSG_MAP
  70. END_MESSAGE_MAP()
  71. /////////////////////////////////////////////////////////////////////////////
  72. /////////////////////////////////////////////////////////////////////////////
  73. // CDriverSetPage message handlers
  74. /////////////////////////////////////////////////////////////////////////////
  75. LRESULT CDriverSetPage::OnWizardBack()
  76. {
  77. //
  78. // Kill a possible active worker thread
  79. //
  80. g_SlowProgressDlg.KillWorkerThread();
  81. return CVerifierPropertyPage::OnWizardBack();
  82. }
  83. /////////////////////////////////////////////////////////////////////////////
  84. LRESULT CDriverSetPage::OnWizardNext()
  85. {
  86. LRESULT lNextPageId;
  87. BOOL bHaveDriversToVerify;
  88. //
  89. // Kill a possible active worker thread
  90. //
  91. g_SlowProgressDlg.KillWorkerThread();
  92. //
  93. // Let's assume we cannot continue
  94. //
  95. lNextPageId = -1;
  96. if( UpdateData() == TRUE )
  97. {
  98. if( m_nCrtRadio != IDC_DRVSET_ALLDRV_RADIO - FIRST_RADIO_BUTTON_ID )
  99. {
  100. //
  101. // Look if we already have loaded the list of drivers
  102. // with version information, etc. and if we need it
  103. //
  104. ASSERT( IDC_DRVSET_ALLDRV_RADIO - FIRST_RADIO_BUTTON_ID != m_nCrtRadio );
  105. if( TRUE != g_NewVerifierSettings.m_DriversSet.m_bDriverDataInitialized )
  106. {
  107. if( NULL == g_SlowProgressDlg.m_hWnd )
  108. {
  109. //
  110. // This is the first time we are showing the
  111. // "slow progress" dialog so create it first
  112. //
  113. g_SlowProgressDlg.Create( CSlowProgressDlg::IDD, AfxGetMainWnd() );
  114. }
  115. //
  116. // Show the dialog
  117. //
  118. g_SlowProgressDlg.ShowWindow( SW_SHOW );
  119. //
  120. // Start the worker thread to do the work in background
  121. // while the initial thread updates the GUI. If the thread ends
  122. // successfully it will press our "Next" button at the end, after setting
  123. // g_NewVerifierSettings.m_DriversSet.m_bDriverDataInitialized to TRUE
  124. //
  125. g_SlowProgressDlg.StartWorkerThread( CSlowProgressDlg::LoadDriverDataWorkerThread,
  126. IDS_LOADING_DRIVER_INFORMATION );
  127. //
  128. // Wait for the "next" button again
  129. //
  130. goto Done;
  131. }
  132. }
  133. //
  134. // We have already loaded information (name, version, etc.) about
  135. // the currently loaded drivers if have gotten to this point and
  136. // we are not in the "verify all drivers" case.
  137. //
  138. //
  139. // Select the set of drivers corresponding to user's selection
  140. //
  141. switch( m_nCrtRadio )
  142. {
  143. case IDC_DRVSET_NAMESLIST_RADIO - FIRST_RADIO_BUTTON_ID:
  144. //
  145. // Custom list of drivers
  146. //
  147. g_NewVerifierSettings.m_DriversSet.m_DriverSetType = CDriversSet::DriversSetCustom;
  148. lNextPageId = IDD_SELECT_DRIVERS_PAGE;
  149. break;
  150. case IDC_DRVSET_OLDVER_RADIO - FIRST_RADIO_BUTTON_ID:
  151. //
  152. // Drivers compiled for old versions of Windows
  153. //
  154. //
  155. // The list of drivers is ready because we waited the
  156. // worker thread to finish up execution - go to the next page
  157. //
  158. g_NewVerifierSettings.m_DriversSet.m_DriverSetType = CDriversSet::DriversSetOldOs;
  159. bHaveDriversToVerify = g_NewVerifierSettings.m_DriversSet.ShouldVerifySomeDrivers();
  160. if( TRUE == bHaveDriversToVerify )
  161. {
  162. //
  163. // We have at least one old driver to verify
  164. //
  165. lNextPageId = IDD_CONFIRM_DRIVERS_PAGE;
  166. //
  167. // Set the title of the driver list confirmation page
  168. //
  169. ASSERT_VALID( m_pParentSheet );
  170. m_pParentSheet->SetContextStrings( IDS_OLD_DRIVERS_LIST );
  171. }
  172. else
  173. {
  174. //
  175. // We don't have any old drivers currently installed
  176. //
  177. VrfMesssageFromResource( IDS_NO_OLD_DRIVERS_FOUND );
  178. }
  179. break;
  180. case IDC_DRVSET_NOTSIGNED_RADIO - FIRST_RADIO_BUTTON_ID:
  181. //
  182. // Not signed drivers
  183. //
  184. if( FALSE == g_NewVerifierSettings.m_DriversSet.m_bUnsignedDriverDataInitialized )
  185. {
  186. //
  187. // We should have displayed the "slow progress" dialog
  188. // at least once before (when we have loaded the list of drivers)
  189. // so we don't even try to create the modeless dialog.
  190. //
  191. ASSERT( NULL != g_SlowProgressDlg.m_hWnd );
  192. //
  193. // Show the dialog though
  194. //
  195. g_SlowProgressDlg.ShowWindow( SW_SHOW );
  196. //
  197. // Start the worker thread to do the work in background
  198. // while the initial thread updates the GUI. If the thread ends
  199. // successfully it will press our "Next" button at the end, after setting
  200. // g_NewVerifierSettings.m_DriversSet.m_bDriverDataInitialized to TRUE
  201. //
  202. g_SlowProgressDlg.StartWorkerThread( CSlowProgressDlg::SearchUnsignedDriversWorkerThread,
  203. IDS_SEARCHING_FOR_UNSIGNED_DRIVERS );
  204. //
  205. // Wait for the "next" button again
  206. //
  207. goto Done;
  208. }
  209. else
  210. {
  211. g_NewVerifierSettings.m_DriversSet.m_DriverSetType = CDriversSet::DriversSetNotSigned;
  212. bHaveDriversToVerify = g_NewVerifierSettings.m_DriversSet.ShouldVerifySomeDrivers();
  213. if( TRUE == bHaveDriversToVerify )
  214. {
  215. //
  216. // The list of drivers is ready - go to the next page
  217. //
  218. lNextPageId = IDD_CONFIRM_DRIVERS_PAGE;
  219. //
  220. // Set the title of the driver list confirmation page
  221. //
  222. ASSERT_VALID( m_pParentSheet );
  223. m_pParentSheet->SetContextStrings( IDS_UNSIGNED_DRIVERS_LIST );
  224. }
  225. else
  226. {
  227. //
  228. // We don't have any unsigned drivers currently installed
  229. //
  230. VrfMesssageFromResource( IDS_NO_UNSIGNED_DRIVERS_FOUND );
  231. }
  232. }
  233. break;
  234. case IDC_DRVSET_ALLDRV_RADIO - FIRST_RADIO_BUTTON_ID:
  235. //
  236. // We can get here only if the disk integrity checking is enabled.
  237. //
  238. ASSERT( FALSE != g_bShowDiskPropertyPage ||
  239. FALSE != g_NewVerifierSettings.m_aDiskData.VerifyAnyDisk() );
  240. g_NewVerifierSettings.m_DriversSet.m_DriverSetType = CDriversSet::DriversSetAllDrivers;
  241. lNextPageId = IDD_DISK_LIST_PAGE;
  242. break;
  243. default:
  244. ASSERT( FALSE );
  245. break;
  246. }
  247. }
  248. GoingToNextPageNotify( lNextPageId );
  249. Done:
  250. return lNextPageId;
  251. }
  252. /////////////////////////////////////////////////////////////////////////////
  253. BOOL CDriverSetPage::OnWizardFinish()
  254. {
  255. BOOL bFinish;
  256. bFinish = FALSE;
  257. if( UpdateData( TRUE ) == TRUE )
  258. {
  259. //
  260. // If the user has pressed the "Finish" button that
  261. // would mean that she selected "all drivers" to be verified
  262. //
  263. ASSERT( IDC_DRVSET_ALLDRV_RADIO - FIRST_RADIO_BUTTON_ID == m_nCrtRadio );
  264. g_NewVerifierSettings.m_DriversSet.m_DriverSetType = CDriversSet::DriversSetAllDrivers;
  265. bFinish = g_NewVerifierSettings.SaveToRegistry();
  266. }
  267. CVerifierPropertyPage::OnWizardFinish();
  268. return bFinish;
  269. }
  270. /////////////////////////////////////////////////////////////////////////////
  271. BOOL CDriverSetPage::OnSetActive()
  272. {
  273. switch( m_nCrtRadio )
  274. {
  275. case IDC_DRVSET_NAMESLIST_RADIO - FIRST_RADIO_BUTTON_ID:
  276. VrfSetWindowText( m_NextDescription, IDS_DRVSET_PAGE_NEXT_DESCR_NAMELIST );
  277. m_pParentSheet->SetWizardButtons( PSWIZB_BACK | PSWIZB_NEXT );
  278. break;
  279. case IDC_DRVSET_OLDVER_RADIO - FIRST_RADIO_BUTTON_ID:
  280. VrfSetWindowText( m_NextDescription, IDS_DRVSET_PAGE_NEXT_DESCR_OLD );
  281. m_pParentSheet->SetWizardButtons( PSWIZB_BACK | PSWIZB_NEXT );
  282. break;
  283. case IDC_DRVSET_NOTSIGNED_RADIO - FIRST_RADIO_BUTTON_ID:
  284. VrfSetWindowText( m_NextDescription, IDS_DRVSET_PAGE_NEXT_DESCR_UNSIGNED );
  285. m_pParentSheet->SetWizardButtons( PSWIZB_BACK | PSWIZB_NEXT );
  286. break;
  287. case IDC_DRVSET_ALLDRV_RADIO - FIRST_RADIO_BUTTON_ID:
  288. if( (FALSE == g_bShowDiskPropertyPage) &&
  289. (FALSE == g_NewVerifierSettings.m_aDiskData.VerifyAnyDisk()) )
  290. {
  291. m_pParentSheet->SetWizardButtons( PSWIZB_BACK | PSWIZB_FINISH );
  292. VrfSetWindowText( m_NextDescription, IDS_DRVSET_PAGE_NEXT_DESCR_ALL );
  293. }
  294. else
  295. {
  296. VrfSetWindowText( m_NextDescription, IDS_DRVSET_PAGE_NEXT_DESCR_ALL_HAVEDISKS );
  297. m_pParentSheet->SetWizardButtons( PSWIZB_BACK | PSWIZB_NEXT );
  298. }
  299. break;
  300. default:
  301. ASSERT( FALSE );
  302. break;
  303. }
  304. return CVerifierPropertyPage::OnSetActive();
  305. }
  306. /////////////////////////////////////////////////////////////////////////////
  307. BOOL CDriverSetPage::OnInitDialog()
  308. {
  309. //
  310. // Don't try to reconstruct the current data from the registry
  311. // to the GUI because it's too hard. Always start with the
  312. // default radio button: unsigned drivers
  313. //
  314. m_nCrtRadio = IDC_DRVSET_NOTSIGNED_RADIO - FIRST_RADIO_BUTTON_ID;
  315. CVerifierPropertyPage::OnInitDialog();
  316. VrfSetWindowText( m_NextDescription, IDS_DRVSET_PAGE_NEXT_DESCR_UNSIGNED );
  317. return TRUE; // return TRUE unless you set the focus to a control
  318. // EXCEPTION: OCX Property Pages should return FALSE
  319. }
  320. /////////////////////////////////////////////////////////////////////////////
  321. void CDriverSetPage::OnAlldrvRadio()
  322. {
  323. ASSERT_VALID( m_pParentSheet );
  324. if( FALSE != g_bShowDiskPropertyPage ||
  325. FALSE != g_NewVerifierSettings.m_aDiskData.VerifyAnyDisk() )
  326. {
  327. //
  328. // We need to show the next page with the disks to be verified.
  329. //
  330. m_pParentSheet->SetWizardButtons( PSWIZB_BACK | PSWIZB_NEXT );
  331. VrfSetWindowText( m_NextDescription, IDS_DRVSET_PAGE_NEXT_DESCR_ALL_HAVEDISKS );
  332. }
  333. else
  334. {
  335. //
  336. // No disk integrity checking is enabled so this is the last page.
  337. //
  338. m_pParentSheet->SetWizardButtons( PSWIZB_BACK | PSWIZB_FINISH );
  339. VrfSetWindowText( m_NextDescription, IDS_DRVSET_PAGE_NEXT_DESCR_ALL );
  340. }
  341. }
  342. void CDriverSetPage::OnNameslistRadio()
  343. {
  344. ASSERT_VALID( m_pParentSheet );
  345. m_pParentSheet->SetWizardButtons( PSWIZB_BACK | PSWIZB_NEXT );
  346. VrfSetWindowText( m_NextDescription, IDS_DRVSET_PAGE_NEXT_DESCR_NAMELIST );
  347. }
  348. void CDriverSetPage::OnNotsignedRadio()
  349. {
  350. ASSERT_VALID( m_pParentSheet );
  351. m_pParentSheet->SetWizardButtons( PSWIZB_BACK | PSWIZB_NEXT );
  352. VrfSetWindowText( m_NextDescription, IDS_DRVSET_PAGE_NEXT_DESCR_UNSIGNED );
  353. }
  354. void CDriverSetPage::OnOldverRadio()
  355. {
  356. ASSERT_VALID( m_pParentSheet );
  357. m_pParentSheet->SetWizardButtons( PSWIZB_BACK | PSWIZB_NEXT );
  358. VrfSetWindowText( m_NextDescription, IDS_DRVSET_PAGE_NEXT_DESCR_OLD );
  359. }
  360. /////////////////////////////////////////////////////////////
  361. void CDriverSetPage::OnCancel()
  362. {
  363. g_SlowProgressDlg.KillWorkerThread();
  364. CVerifierPropertyPage::OnCancel();
  365. }
  366. /////////////////////////////////////////////////////////////
  367. LONG CDriverSetPage::OnHelp( WPARAM wParam, LPARAM lParam )
  368. {
  369. LONG lResult = 0;
  370. LPHELPINFO lpHelpInfo = (LPHELPINFO)lParam;
  371. ::WinHelp(
  372. (HWND) lpHelpInfo->hItemHandle,
  373. g_szVerifierHelpFile,
  374. HELP_WM_HELP,
  375. (DWORD_PTR) MyHelpIds );
  376. return lResult;
  377. }
  378. /////////////////////////////////////////////////////////////////////////////
  379. void CDriverSetPage::OnContextMenu(CWnd* pWnd, CPoint point)
  380. {
  381. ::WinHelp(
  382. pWnd->m_hWnd,
  383. g_szVerifierHelpFile,
  384. HELP_CONTEXTMENU,
  385. (DWORD_PTR) MyHelpIds );
  386. }