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.

450 lines
12 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. //
  99. // Look if we already have loaded the list of drivers
  100. // with version information, etc. and if we need it
  101. //
  102. ASSERT( IDC_DRVSET_ALLDRV_RADIO - FIRST_RADIO_BUTTON_ID != m_nCrtRadio );
  103. if( TRUE != g_NewVerifierSettings.m_DriversSet.m_bDriverDataInitialized )
  104. {
  105. if( NULL == g_SlowProgressDlg.m_hWnd )
  106. {
  107. //
  108. // This is the first time we are showing the
  109. // "slow progress" dialog so create it first
  110. //
  111. g_SlowProgressDlg.Create( CSlowProgressDlg::IDD, AfxGetMainWnd() );
  112. }
  113. //
  114. // Show the dialog
  115. //
  116. g_SlowProgressDlg.ShowWindow( SW_SHOW );
  117. //
  118. // Start the worker thread to do the work in background
  119. // while the initial thread updates the GUI. If the thread ends
  120. // successfully it will press our "Next" button at the end, after setting
  121. // g_NewVerifierSettings.m_DriversSet.m_bDriverDataInitialized to TRUE
  122. //
  123. g_SlowProgressDlg.StartWorkerThread( CSlowProgressDlg::LoadDriverDataWorkerThread,
  124. IDS_LOADING_DRIVER_INFORMATION );
  125. //
  126. // Wait for the "next" button again
  127. //
  128. goto Done;
  129. }
  130. //
  131. // We have already loaded information (name, version, etc.) about
  132. // the currently loaded drivers if have gotten to this point
  133. //
  134. //
  135. // Select the set of drivers corresponding to user's selection
  136. //
  137. switch( m_nCrtRadio )
  138. {
  139. case IDC_DRVSET_NAMESLIST_RADIO - FIRST_RADIO_BUTTON_ID:
  140. //
  141. // Custom list of drivers
  142. //
  143. g_NewVerifierSettings.m_DriversSet.m_DriverSetType = CDriversSet::DriversSetCustom;
  144. lNextPageId = IDD_SELECT_DRIVERS_PAGE;
  145. break;
  146. case IDC_DRVSET_OLDVER_RADIO - FIRST_RADIO_BUTTON_ID:
  147. //
  148. // Drivers compiled for old versions of Windows
  149. //
  150. //
  151. // The list of drivers is ready because we waited the
  152. // worker thread to finish up execution - go to the next page
  153. //
  154. g_NewVerifierSettings.m_DriversSet.m_DriverSetType = CDriversSet::DriversSetOldOs;
  155. bHaveDriversToVerify = g_NewVerifierSettings.m_DriversSet.ShouldVerifySomeDrivers();
  156. if( TRUE == bHaveDriversToVerify )
  157. {
  158. //
  159. // We have at least one old driver to verify
  160. //
  161. lNextPageId = IDD_CONFIRM_DRIVERS_PAGE;
  162. //
  163. // Set the title of the driver list confirmation page
  164. //
  165. ASSERT_VALID( m_pParentSheet );
  166. m_pParentSheet->SetContextStrings( IDS_OLD_DRIVERS_LIST );
  167. }
  168. else
  169. {
  170. //
  171. // We don't have any old drivers currently installed
  172. //
  173. VrfMesssageFromResource( IDS_NO_OLD_DRIVERS_FOUND );
  174. }
  175. break;
  176. case IDC_DRVSET_NOTSIGNED_RADIO - FIRST_RADIO_BUTTON_ID:
  177. //
  178. // Not signed drivers
  179. //
  180. if( FALSE == g_NewVerifierSettings.m_DriversSet.m_bUnsignedDriverDataInitialized )
  181. {
  182. //
  183. // We should have displayed the "slow progress" dialog
  184. // at least once before (when we have loaded the list of drivers)
  185. // so we don't even try to create the modeless dialog.
  186. //
  187. ASSERT( NULL != g_SlowProgressDlg.m_hWnd );
  188. //
  189. // Show the dialog though
  190. //
  191. g_SlowProgressDlg.ShowWindow( SW_SHOW );
  192. //
  193. // Start the worker thread to do the work in background
  194. // while the initial thread updates the GUI. If the thread ends
  195. // successfully it will press our "Next" button at the end, after setting
  196. // g_NewVerifierSettings.m_DriversSet.m_bDriverDataInitialized to TRUE
  197. //
  198. g_SlowProgressDlg.StartWorkerThread( CSlowProgressDlg::SearchUnsignedDriversWorkerThread,
  199. IDS_SEARCHING_FOR_UNSIGNED_DRIVERS );
  200. //
  201. // Wait for the "next" button again
  202. //
  203. goto Done;
  204. }
  205. else
  206. {
  207. g_NewVerifierSettings.m_DriversSet.m_DriverSetType = CDriversSet::DriversSetNotSigned;
  208. bHaveDriversToVerify = g_NewVerifierSettings.m_DriversSet.ShouldVerifySomeDrivers();
  209. if( TRUE == bHaveDriversToVerify )
  210. {
  211. //
  212. // The list of drivers is ready - go to the next page
  213. //
  214. lNextPageId = IDD_CONFIRM_DRIVERS_PAGE;
  215. //
  216. // Set the title of the driver list confirmation page
  217. //
  218. ASSERT_VALID( m_pParentSheet );
  219. m_pParentSheet->SetContextStrings( IDS_UNSIGNED_DRIVERS_LIST );
  220. }
  221. else
  222. {
  223. //
  224. // We don't have any unsigned drivers currently installed
  225. //
  226. VrfMesssageFromResource( IDS_NO_UNSIGNED_DRIVERS_FOUND );
  227. }
  228. }
  229. break;
  230. case CDriversSet::DriversSetAllDrivers:
  231. //
  232. // We should have only a "Finish" button
  233. // if "all drivers" is selected, not a "Next" button.
  234. // This is a bug!
  235. //
  236. default:
  237. ASSERT( FALSE );
  238. break;
  239. }
  240. }
  241. GoingToNextPageNotify( lNextPageId );
  242. Done:
  243. return lNextPageId;
  244. }
  245. /////////////////////////////////////////////////////////////////////////////
  246. BOOL CDriverSetPage::OnWizardFinish()
  247. {
  248. BOOL bFinish;
  249. bFinish = FALSE;
  250. if( UpdateData( TRUE ) == TRUE )
  251. {
  252. //
  253. // If the user has pressed the "Finish" button that
  254. // would mean that she selected "all drivers" to be verified
  255. //
  256. ASSERT( IDC_DRVSET_ALLDRV_RADIO - FIRST_RADIO_BUTTON_ID == m_nCrtRadio );
  257. g_NewVerifierSettings.m_DriversSet.m_DriverSetType = CDriversSet::DriversSetAllDrivers;
  258. bFinish = g_NewVerifierSettings.SaveToRegistry();
  259. }
  260. CVerifierPropertyPage::OnWizardFinish();
  261. return bFinish;
  262. }
  263. /////////////////////////////////////////////////////////////////////////////
  264. BOOL CDriverSetPage::OnSetActive()
  265. {
  266. if( IDC_DRVSET_ALLDRV_RADIO - FIRST_RADIO_BUTTON_ID == m_nCrtRadio )
  267. {
  268. m_pParentSheet->SetWizardButtons( PSWIZB_BACK | PSWIZB_FINISH );
  269. }
  270. else
  271. {
  272. m_pParentSheet->SetWizardButtons( PSWIZB_BACK | PSWIZB_NEXT );
  273. }
  274. return CVerifierPropertyPage::OnSetActive();
  275. }
  276. /////////////////////////////////////////////////////////////////////////////
  277. BOOL CDriverSetPage::OnInitDialog()
  278. {
  279. //
  280. // Don't try to reconstruct the current data from the registry
  281. // to the GUI because it's too hard. Always start with the
  282. // default radio button: unsigned drivers
  283. //
  284. m_nCrtRadio = IDC_DRVSET_NOTSIGNED_RADIO - FIRST_RADIO_BUTTON_ID;
  285. CVerifierPropertyPage::OnInitDialog();
  286. VrfSetWindowText( m_NextDescription, IDS_DRVSET_PAGE_NEXT_DESCR_UNSIGNED );
  287. return TRUE; // return TRUE unless you set the focus to a control
  288. // EXCEPTION: OCX Property Pages should return FALSE
  289. }
  290. /////////////////////////////////////////////////////////////////////////////
  291. void CDriverSetPage::OnAlldrvRadio()
  292. {
  293. ASSERT_VALID( m_pParentSheet );
  294. m_pParentSheet->SetWizardButtons( PSWIZB_BACK | PSWIZB_FINISH );
  295. VrfSetWindowText( m_NextDescription, IDS_DRVSET_PAGE_NEXT_DESCR_ALL );
  296. }
  297. void CDriverSetPage::OnNameslistRadio()
  298. {
  299. ASSERT_VALID( m_pParentSheet );
  300. m_pParentSheet->SetWizardButtons( PSWIZB_BACK | PSWIZB_NEXT );
  301. VrfSetWindowText( m_NextDescription, IDS_DRVSET_PAGE_NEXT_DESCR_NAMELIST );
  302. }
  303. void CDriverSetPage::OnNotsignedRadio()
  304. {
  305. ASSERT_VALID( m_pParentSheet );
  306. m_pParentSheet->SetWizardButtons( PSWIZB_BACK | PSWIZB_NEXT );
  307. VrfSetWindowText( m_NextDescription, IDS_DRVSET_PAGE_NEXT_DESCR_UNSIGNED );
  308. }
  309. void CDriverSetPage::OnOldverRadio()
  310. {
  311. ASSERT_VALID( m_pParentSheet );
  312. m_pParentSheet->SetWizardButtons( PSWIZB_BACK | PSWIZB_NEXT );
  313. VrfSetWindowText( m_NextDescription, IDS_DRVSET_PAGE_NEXT_DESCR_OLD );
  314. }
  315. /////////////////////////////////////////////////////////////
  316. void CDriverSetPage::OnCancel()
  317. {
  318. g_SlowProgressDlg.KillWorkerThread();
  319. CVerifierPropertyPage::OnCancel();
  320. }
  321. /////////////////////////////////////////////////////////////
  322. LONG CDriverSetPage::OnHelp( WPARAM wParam, LPARAM lParam )
  323. {
  324. LONG lResult = 0;
  325. LPHELPINFO lpHelpInfo = (LPHELPINFO)lParam;
  326. ::WinHelp(
  327. (HWND) lpHelpInfo->hItemHandle,
  328. g_szVerifierHelpFile,
  329. HELP_WM_HELP,
  330. (DWORD_PTR) MyHelpIds );
  331. return lResult;
  332. }
  333. /////////////////////////////////////////////////////////////////////////////
  334. void CDriverSetPage::OnContextMenu(CWnd* pWnd, CPoint point)
  335. {
  336. ::WinHelp(
  337. pWnd->m_hWnd,
  338. g_szVerifierHelpFile,
  339. HELP_CONTEXTMENU,
  340. (DWORD_PTR) MyHelpIds );
  341. }