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.

1069 lines
28 KiB

  1. //
  2. // Driver Verifier UI
  3. // Copyright (c) Microsoft Corporation, 1999
  4. //
  5. //
  6. //
  7. // module: RegPage.cpp
  8. // author: DMihai
  9. // created: 11/1/00
  10. //
  11. // Description:
  12. //
  13. #include "stdafx.h"
  14. #include "verifier.h"
  15. #include "RegPage.h"
  16. #include "VGlobal.h"
  17. #include "VrfUtil.h"
  18. #ifdef _DEBUG
  19. #define new DEBUG_NEW
  20. #undef THIS_FILE
  21. static char THIS_FILE[] = __FILE__;
  22. #endif
  23. //
  24. // Help IDs
  25. //
  26. static DWORD MyHelpIds[] =
  27. {
  28. IDC_REGSETT_SETTBITS_LIST, IDH_DV_SettingsEnabled_TestType,
  29. IDC_REGSETT_DRIVERS_LIST, IDH_DV_VerifyAllDrivers_NameDesc,
  30. 0, 0
  31. };
  32. /////////////////////////////////////////////////////////////////////////////
  33. // CCrtRegSettingsPage property page
  34. IMPLEMENT_DYNCREATE(CCrtRegSettingsPage, CVerifierPropertyPage)
  35. CCrtRegSettingsPage::CCrtRegSettingsPage()
  36. : CVerifierPropertyPage(CCrtRegSettingsPage::IDD)
  37. {
  38. //{{AFX_DATA_INIT(CCrtRegSettingsPage)
  39. // NOTE: the ClassWizard will add member initialization here
  40. //}}AFX_DATA_INIT
  41. //
  42. // Driver list sort parameters
  43. //
  44. m_nSortColumnIndexDrv = 0;
  45. m_bAscendDrvNameSort = FALSE;
  46. m_bAscendDrvDescrSort = FALSE;
  47. //
  48. // Settings bits sort parameters
  49. //
  50. m_nSortColumnIndexSettbits = 1;
  51. m_bAscendSortEnabledBits = FALSE;
  52. m_bAscendSortNameBits = FALSE;
  53. m_pParentSheet = NULL;
  54. }
  55. CCrtRegSettingsPage::~CCrtRegSettingsPage()
  56. {
  57. }
  58. void CCrtRegSettingsPage::DoDataExchange(CDataExchange* pDX)
  59. {
  60. CVerifierPropertyPage::DoDataExchange(pDX);
  61. //{{AFX_DATA_MAP(CCrtRegSettingsPage)
  62. DDX_Control(pDX, IDC_REGSETT_VERIFIED_DRV_STATIC, m_VerifiedDrvStatic);
  63. DDX_Control(pDX, IDC_REGSETT_NEXT_DESCR_STATIC, m_NextDescription);
  64. DDX_Control(pDX, IDC_REGSETT_SETTBITS_LIST, m_SettBitsList);
  65. DDX_Control(pDX, IDC_REGSETT_DRIVERS_LIST, m_DriversList);
  66. //}}AFX_DATA_MAP
  67. }
  68. BEGIN_MESSAGE_MAP(CCrtRegSettingsPage, CVerifierPropertyPage)
  69. //{{AFX_MSG_MAP(CCrtRegSettingsPage)
  70. ON_NOTIFY(LVN_COLUMNCLICK, IDC_REGSETT_DRIVERS_LIST, OnColumnclickDriversList)
  71. ON_NOTIFY(LVN_COLUMNCLICK, IDC_REGSETT_SETTBITS_LIST, OnColumnclickRegsettSettbitsList)
  72. ON_WM_CONTEXTMENU()
  73. ON_MESSAGE( WM_HELP, OnHelp )
  74. //}}AFX_MSG_MAP
  75. END_MESSAGE_MAP()
  76. /////////////////////////////////////////////////////////////
  77. //
  78. // Driver status list control methods
  79. //
  80. VOID CCrtRegSettingsPage::SetupListHeaderDrivers()
  81. {
  82. LVCOLUMN lvColumn;
  83. CRect rectWnd;
  84. CString strName;
  85. CString strDescription;
  86. VERIFY( strName.LoadString( IDS_NAME ) );
  87. VERIFY( strDescription.LoadString( IDS_DESCRIPTION ) );
  88. //
  89. // List's regtangle
  90. //
  91. m_DriversList.GetClientRect( &rectWnd );
  92. //
  93. // Column 0
  94. //
  95. ZeroMemory( &lvColumn, sizeof( lvColumn ) );
  96. lvColumn.mask = LVCF_FMT | LVCF_SUBITEM | LVCF_TEXT | LVCF_WIDTH;
  97. lvColumn.fmt = LVCFMT_LEFT;
  98. lvColumn.iSubItem = 0;
  99. lvColumn.cx = (int)( rectWnd.Width() * 0.30 );
  100. lvColumn.pszText = strName.GetBuffer( strName.GetLength() + 1 );
  101. if (NULL != lvColumn.pszText)
  102. {
  103. VERIFY( m_DriversList.InsertColumn( 0, &lvColumn ) != -1 );
  104. strName.ReleaseBuffer();
  105. }
  106. else
  107. {
  108. lvColumn.pszText = g_szVoidText;
  109. VERIFY( m_DriversList.InsertColumn( 0, &lvColumn ) != -1 );
  110. }
  111. //
  112. // Column 1
  113. //
  114. lvColumn.iSubItem = 1;
  115. lvColumn.cx = (int)( rectWnd.Width() * 0.70 );
  116. lvColumn.pszText = strDescription.GetBuffer( strDescription.GetLength() + 1 );
  117. if (NULL != lvColumn.pszText)
  118. {
  119. VERIFY( m_DriversList.InsertColumn( 1, &lvColumn ) != -1 );
  120. strDescription.ReleaseBuffer();
  121. }
  122. else
  123. {
  124. lvColumn.pszText = g_szVoidText;
  125. VERIFY( m_DriversList.InsertColumn( 1, &lvColumn ) != -1 );
  126. }
  127. }
  128. /////////////////////////////////////////////////////////////
  129. VOID CCrtRegSettingsPage::FillTheListDrivers()
  130. {
  131. LVITEM lvItem;
  132. int nActualIndex;
  133. BOOL *pbAlreadyInList;
  134. int nItemCount;
  135. int nCrtListItem;
  136. INT_PTR nCrtVerifiedDriver;
  137. INT_PTR nDriversNo;
  138. TCHAR szDriverName[ _MAX_PATH ];
  139. BOOL bResult;
  140. CString strText;
  141. if( g_bAllDriversVerified )
  142. {
  143. VERIFY( m_DriversList.DeleteAllItems() );
  144. goto Done;
  145. }
  146. //
  147. // The number of drivers marked to be verified in the registry
  148. //
  149. nDriversNo = g_astrVerifyDriverNamesRegistry.GetSize();
  150. if( nDriversNo == 0 )
  151. {
  152. //
  153. // Clear the list
  154. //
  155. VERIFY( m_DriversList.DeleteAllItems() );
  156. goto Done;
  157. }
  158. //
  159. // There are some drivers marked to be verified in the registry
  160. //
  161. pbAlreadyInList = new BOOL[ nDriversNo ];
  162. if( pbAlreadyInList == NULL )
  163. {
  164. goto Done;
  165. }
  166. for( nCrtVerifiedDriver = 0; nCrtVerifiedDriver < nDriversNo; nCrtVerifiedDriver++)
  167. {
  168. pbAlreadyInList[ nCrtVerifiedDriver ] = FALSE;
  169. }
  170. //
  171. // Parse all the current list items
  172. //
  173. nItemCount = m_DriversList.GetItemCount();
  174. for( nCrtListItem = 0; nCrtListItem < nItemCount; nCrtListItem++ )
  175. {
  176. //
  177. // Get the current driver's name from the list
  178. //
  179. ZeroMemory( &lvItem, sizeof( lvItem ) );
  180. lvItem.mask = LVIF_TEXT;
  181. lvItem.iItem = nCrtListItem;
  182. lvItem.iSubItem = 0;
  183. lvItem.pszText = szDriverName;
  184. lvItem.cchTextMax = ARRAY_LENGTH( szDriverName );
  185. bResult = m_DriversList.GetItem( &lvItem );
  186. if( bResult == FALSE )
  187. {
  188. //
  189. // Could not get the current item's attributes?!?
  190. //
  191. ASSERT( FALSE );
  192. //
  193. // Remove this item from the list
  194. //
  195. VERIFY( m_DriversList.DeleteItem( nCrtListItem ) );
  196. nCrtListItem -= 1;
  197. nItemCount -= 1;
  198. }
  199. else
  200. {
  201. //
  202. // See is the current driver is still in g_astrVerifyDriverNamesRegistry
  203. //
  204. for( nCrtVerifiedDriver = 0; nCrtVerifiedDriver < nDriversNo; nCrtVerifiedDriver++)
  205. {
  206. if( g_astrVerifyDriverNamesRegistry.GetAt( nCrtVerifiedDriver ).CompareNoCase( szDriverName ) == 0 )
  207. {
  208. //
  209. // update the item's data with the current index in the array
  210. //
  211. lvItem.mask = LVIF_PARAM;
  212. lvItem.lParam = nCrtVerifiedDriver;
  213. VERIFY( m_DriversList.SetItem( &lvItem ) != -1 );
  214. //
  215. // update the second column
  216. //
  217. UpdateDescriptionColumnDrivers( nCrtListItem, nCrtVerifiedDriver );
  218. //
  219. // mark the current driver as updated
  220. //
  221. pbAlreadyInList[ nCrtVerifiedDriver ] = TRUE;
  222. break;
  223. }
  224. }
  225. //
  226. // If the driver is no longer verified, remove it from the list
  227. //
  228. if( nCrtVerifiedDriver >= nDriversNo )
  229. {
  230. VERIFY( m_DriversList.DeleteItem( nCrtListItem ) );
  231. nCrtListItem -= 1;
  232. nItemCount -= 1;
  233. }
  234. }
  235. }
  236. //
  237. // Add the drivers that were not in the list before this update
  238. //
  239. for( nCrtVerifiedDriver = 0; nCrtVerifiedDriver < nDriversNo; nCrtVerifiedDriver++)
  240. {
  241. if( ! pbAlreadyInList[ nCrtVerifiedDriver ] )
  242. {
  243. //
  244. // add a new item for this
  245. //
  246. ZeroMemory( &lvItem, sizeof( lvItem ) );
  247. //
  248. // sub-item 0
  249. //
  250. lvItem.mask = LVIF_TEXT | LVIF_PARAM;
  251. lvItem.lParam = nCrtVerifiedDriver;
  252. lvItem.iItem = m_DriversList.GetItemCount();
  253. lvItem.iSubItem = 0;
  254. strText = g_astrVerifyDriverNamesRegistry.GetAt( nCrtVerifiedDriver );
  255. lvItem.pszText = strText.GetBuffer( strText.GetLength() + 1 );
  256. if( NULL != lvItem.pszText )
  257. {
  258. nActualIndex = m_DriversList.InsertItem( &lvItem );
  259. VERIFY( nActualIndex != -1 );
  260. strText.ReleaseBuffer();
  261. //
  262. // sub-item 1
  263. //
  264. UpdateDescriptionColumnDrivers( nActualIndex, nCrtVerifiedDriver );
  265. }
  266. }
  267. }
  268. ASSERT( NULL != pbAlreadyInList );
  269. delete [] pbAlreadyInList;
  270. Done:
  271. NOTHING;
  272. }
  273. /////////////////////////////////////////////////////////////
  274. VOID CCrtRegSettingsPage::UpdateDescriptionColumnDrivers( INT_PTR nItemIndex, INT_PTR nCrtDriver )
  275. {
  276. INT_PTR nInstalledDrivers;
  277. INT_PTR nCrtInstalledDriver;
  278. INT_PTR nNewDriverDataIndex;
  279. LVITEM lvItem;
  280. CString strDescription;
  281. CString strCrtDriverName;
  282. CDriverData *pCrtDriverData;
  283. CDriverDataArray &DriverDataArray = g_NewVerifierSettings.m_DriversSet.m_aDriverData;
  284. ASSERT( nItemIndex >= 0 &&
  285. nItemIndex < g_astrVerifyDriverNamesRegistry.GetSize() &&
  286. nItemIndex < m_DriversList.GetItemCount() &&
  287. nCrtDriver >= 0 &&
  288. nCrtDriver < g_astrVerifyDriverNamesRegistry.GetSize() &&
  289. nCrtDriver < m_DriversList.GetItemCount() );
  290. strCrtDriverName = g_astrVerifyDriverNamesRegistry.GetAt( nCrtDriver );
  291. ASSERT( strCrtDriverName.GetLength() > 0 );
  292. //
  293. // Search for this driver name in our g_NewVerifierSettings to get
  294. // the description
  295. //
  296. nInstalledDrivers = g_NewVerifierSettings.m_DriversSet.m_aDriverData.GetSize();
  297. for( nCrtInstalledDriver = 0; nCrtInstalledDriver < nInstalledDrivers; nCrtInstalledDriver += 1 )
  298. {
  299. pCrtDriverData = DriverDataArray.GetAt( nCrtInstalledDriver );
  300. ASSERT_VALID( pCrtDriverData );
  301. if( strCrtDriverName.CompareNoCase( pCrtDriverData->m_strName ) == 0 )
  302. {
  303. //
  304. // Found the driver version information
  305. //
  306. strDescription = pCrtDriverData->m_strFileDescription;
  307. break;
  308. }
  309. }
  310. if( nCrtInstalledDriver >= nInstalledDrivers )
  311. {
  312. //
  313. // Don't have already version information for this driver.
  314. // It may be one of the drivers that's not currently loaded so
  315. // try to get the version info.
  316. //
  317. nNewDriverDataIndex = g_NewVerifierSettings.m_DriversSet.AddNewDriverData( strCrtDriverName );
  318. if( nNewDriverDataIndex >= 0 )
  319. {
  320. //
  321. // Force refreshing the unsigned driver data
  322. //
  323. g_NewVerifierSettings.m_DriversSet.m_bUnsignedDriverDataInitialized = FALSE;
  324. //
  325. // Get the version information
  326. //
  327. pCrtDriverData = DriverDataArray.GetAt( nNewDriverDataIndex );
  328. ASSERT_VALID( pCrtDriverData );
  329. ASSERT( strCrtDriverName.CompareNoCase( pCrtDriverData->m_strName ) == 0 );
  330. strDescription = pCrtDriverData->m_strFileDescription;
  331. }
  332. }
  333. if( strDescription.GetLength() == 0 )
  334. {
  335. //
  336. // Didn't find the version info for this driver
  337. //
  338. VERIFY( strDescription.LoadString( IDS_UNKNOWN ) );
  339. }
  340. //
  341. // Update the list item
  342. //
  343. ZeroMemory( &lvItem, sizeof( lvItem ) );
  344. lvItem.mask = LVIF_TEXT;
  345. lvItem.iItem = (INT)nItemIndex;
  346. lvItem.iSubItem = 1;
  347. lvItem.pszText = strDescription.GetBuffer( strDescription.GetLength() + 1 );
  348. if (NULL != lvItem.pszText)
  349. {
  350. VERIFY( m_DriversList.SetItem( &lvItem ) );
  351. strDescription.ReleaseBuffer();
  352. }
  353. else
  354. {
  355. lvItem.pszText = g_szVoidText;
  356. VERIFY( m_DriversList.SetItem( &lvItem ) );
  357. }
  358. }
  359. /////////////////////////////////////////////////////////////
  360. int CALLBACK CCrtRegSettingsPage::DrvStringCmpFunc(
  361. LPARAM lParam1,
  362. LPARAM lParam2,
  363. LPARAM lParamSort)
  364. {
  365. CCrtRegSettingsPage *pThis = (CCrtRegSettingsPage *)lParamSort;
  366. ASSERT_VALID( pThis );
  367. return pThis->ListStrCmpFunc( lParam1,
  368. lParam2,
  369. pThis->m_DriversList,
  370. pThis->m_nSortColumnIndexDrv,
  371. (0 == pThis->m_nSortColumnIndexDrv) ?
  372. pThis->m_bAscendDrvNameSort : pThis->m_bAscendDrvDescrSort );
  373. }
  374. /////////////////////////////////////////////////////////////
  375. int CALLBACK CCrtRegSettingsPage::SettbitsStringCmpFunc(
  376. LPARAM lParam1,
  377. LPARAM lParam2,
  378. LPARAM lParamSort)
  379. {
  380. CCrtRegSettingsPage *pThis = (CCrtRegSettingsPage *)lParamSort;
  381. ASSERT_VALID( pThis );
  382. return pThis->ListStrCmpFunc( lParam1,
  383. lParam2,
  384. pThis->m_SettBitsList,
  385. pThis->m_nSortColumnIndexSettbits,
  386. (0 == pThis->m_nSortColumnIndexSettbits) ?
  387. pThis->m_bAscendSortEnabledBits : pThis->m_bAscendSortNameBits );
  388. }
  389. /////////////////////////////////////////////////////////////
  390. int CCrtRegSettingsPage::ListStrCmpFunc(
  391. LPARAM lParam1,
  392. LPARAM lParam2,
  393. CListCtrl &theList,
  394. INT nSortColumnIndex,
  395. BOOL bAscending )
  396. {
  397. int nCmpRez = 0;
  398. BOOL bSuccess;
  399. TCHAR szName1[ _MAX_PATH ];
  400. TCHAR szName2[ _MAX_PATH ];
  401. //
  402. // Get the first name
  403. //
  404. bSuccess = GetNameFromItemData( theList,
  405. nSortColumnIndex,
  406. lParam1,
  407. szName1,
  408. ARRAY_LENGTH( szName1 ) );
  409. if( FALSE == bSuccess )
  410. {
  411. ASSERT( FALSE );
  412. goto Done;
  413. }
  414. //
  415. // Get the second name
  416. //
  417. bSuccess = GetNameFromItemData( theList,
  418. nSortColumnIndex,
  419. lParam2,
  420. szName2,
  421. ARRAY_LENGTH( szName2 ) );
  422. if( FALSE == bSuccess )
  423. {
  424. ASSERT( FALSE );
  425. goto Done;
  426. }
  427. //
  428. // Compare the names
  429. //
  430. nCmpRez = _tcsicmp( szName1, szName2 );
  431. if( FALSE != bAscending )
  432. {
  433. nCmpRez *= -1;
  434. }
  435. Done:
  436. return nCmpRez;
  437. }
  438. /////////////////////////////////////////////////////////////////////////////
  439. BOOL CCrtRegSettingsPage::GetNameFromItemData( CListCtrl &theList,
  440. INT nColumnIndex,
  441. LPARAM lParam,
  442. TCHAR *szName,
  443. ULONG uNameBufferLength )
  444. {
  445. BOOL bSuccess = FALSE;
  446. INT nItemIndex;
  447. LVFINDINFO FindInfo;
  448. LVITEM lvItem;
  449. ZeroMemory( &FindInfo, sizeof( FindInfo ) );
  450. FindInfo.flags = LVFI_PARAM;
  451. FindInfo.lParam = lParam;
  452. nItemIndex = theList.FindItem( &FindInfo );
  453. if( nItemIndex >= 0 )
  454. {
  455. //
  456. // Found it
  457. //
  458. ZeroMemory( &lvItem, sizeof( lvItem ) );
  459. lvItem.mask = LVIF_TEXT;
  460. lvItem.iItem = nItemIndex;
  461. lvItem.iSubItem = nColumnIndex;
  462. lvItem.pszText = szName;
  463. lvItem.cchTextMax = uNameBufferLength;
  464. bSuccess = theList.GetItem( &lvItem );
  465. if( FALSE == bSuccess )
  466. {
  467. //
  468. // Could not get the current item's attributes?!?
  469. //
  470. ASSERT( FALSE );
  471. }
  472. }
  473. return bSuccess;
  474. }
  475. /////////////////////////////////////////////////////////////
  476. //
  477. // Settings bits list control methods
  478. //
  479. VOID CCrtRegSettingsPage::SetupListHeaderDriversSettBits()
  480. {
  481. CString strTitle;
  482. CRect rectWnd;
  483. LVCOLUMN lvColumn;
  484. //
  485. // The list's rectangle
  486. //
  487. m_SettBitsList.GetClientRect( &rectWnd );
  488. ZeroMemory( &lvColumn,
  489. sizeof( lvColumn ) );
  490. lvColumn.mask = LVCF_FMT | LVCF_SUBITEM | LVCF_TEXT | LVCF_WIDTH;
  491. lvColumn.fmt = LVCFMT_LEFT;
  492. //
  493. // Column 0
  494. //
  495. VERIFY( strTitle.LoadString( IDS_ENABLED_QUESTION ) );
  496. lvColumn.iSubItem = 0;
  497. lvColumn.cx = (int)( rectWnd.Width() * 0.25 );
  498. lvColumn.pszText = strTitle.GetBuffer( strTitle.GetLength() + 1 );
  499. if (NULL != lvColumn.pszText)
  500. {
  501. VERIFY( m_SettBitsList.InsertColumn( 0, &lvColumn ) != -1 );
  502. strTitle.ReleaseBuffer();
  503. }
  504. else
  505. {
  506. lvColumn.pszText = g_szVoidText;
  507. VERIFY( m_SettBitsList.InsertColumn( 0, &lvColumn ) != -1 );
  508. }
  509. //
  510. // Column 1
  511. //
  512. VERIFY( strTitle.LoadString( IDS_SETTING ) );
  513. lvColumn.iSubItem = 1;
  514. lvColumn.cx = (int)( rectWnd.Width() * 0.75 );
  515. lvColumn.pszText = strTitle.GetBuffer( strTitle.GetLength() + 1 );
  516. if (NULL != lvColumn.pszText)
  517. {
  518. VERIFY( m_SettBitsList.InsertColumn( 1, &lvColumn ) != -1 );
  519. strTitle.ReleaseBuffer();
  520. }
  521. else
  522. {
  523. lvColumn.pszText = g_szVoidText;
  524. VERIFY( m_SettBitsList.InsertColumn( 1, &lvColumn ) != -1 );
  525. }
  526. }
  527. /////////////////////////////////////////////////////////////
  528. VOID CCrtRegSettingsPage::FillTheListSettBits()
  529. {
  530. //
  531. // N.B.
  532. //
  533. // If you change this order you need to change IsSettBitEnabled as well
  534. //
  535. AddListItemSettBits( 0, 0 != ( g_dwVerifierFlagsRegistry & DRIVER_VERIFIER_SPECIAL_POOLING), IDS_SPECIAL_POOL );
  536. AddListItemSettBits( 1, 0 != ( g_dwVerifierFlagsRegistry & DRIVER_VERIFIER_TRACK_POOL_ALLOCATIONS), IDS_POOL_TRACKING );
  537. AddListItemSettBits( 2, 0 != ( g_dwVerifierFlagsRegistry & DRIVER_VERIFIER_FORCE_IRQL_CHECKING), IDS_FORCE_IRQL_CHECKING );
  538. AddListItemSettBits( 3, 0 != ( g_dwVerifierFlagsRegistry & DRIVER_VERIFIER_IO_CHECKING), IDS_IO_VERIFICATION );
  539. AddListItemSettBits( 4, 0 != ( g_dwVerifierFlagsRegistry & DRIVER_VERIFIER_ENHANCED_IO_CHECKING), IDS_ENH_IO_VERIFICATION );
  540. AddListItemSettBits( 5, 0 != ( g_dwVerifierFlagsRegistry & DRIVER_VERIFIER_DEADLOCK_DETECTION), IDS_DEADLOCK_DETECTION );
  541. AddListItemSettBits( 6, 0 != ( g_dwVerifierFlagsRegistry & DRIVER_VERIFIER_DMA_VERIFIER), IDS_DMA_CHECHKING );
  542. AddListItemSettBits( 7, 0 != ( g_dwVerifierFlagsRegistry & DRIVER_VERIFIER_INJECT_ALLOCATION_FAILURES),IDS_LOW_RESOURCE_SIMULATION );
  543. AddListItemSettBits( 8, g_OldDiskData.VerifyAnyDisk(), IDS_DISK_INTEGRITY_CHECKING );
  544. }
  545. /////////////////////////////////////////////////////////////
  546. VOID CCrtRegSettingsPage::RefreshListSettBits()
  547. {
  548. INT nListItems;
  549. INT nCrtListItem;
  550. INT_PTR nCrtVerifierBit;
  551. BOOL bEnabled;
  552. nListItems = m_SettBitsList.GetItemCount();
  553. for( nCrtListItem = 0; nCrtListItem < nListItems; nCrtListItem += 1 )
  554. {
  555. nCrtVerifierBit = m_SettBitsList.GetItemData( nCrtListItem );
  556. bEnabled = IsSettBitEnabled( nCrtVerifierBit );
  557. UpdateStatusColumnSettBits( nCrtListItem, bEnabled );
  558. }
  559. }
  560. /////////////////////////////////////////////////////////////////////////////
  561. BOOL CCrtRegSettingsPage::IsSettBitEnabled( INT_PTR nBitIndex )
  562. {
  563. BOOL bEnabled;
  564. //
  565. // N.B.
  566. //
  567. // If you change this switch statement you need to change FillTheListSettBits as well
  568. //
  569. switch( nBitIndex )
  570. {
  571. case 0:
  572. bEnabled = ( 0 != ( g_dwVerifierFlagsRegistry & DRIVER_VERIFIER_SPECIAL_POOLING) );
  573. break;
  574. case 1:
  575. bEnabled = ( 0 != ( g_dwVerifierFlagsRegistry & DRIVER_VERIFIER_TRACK_POOL_ALLOCATIONS) );
  576. break;
  577. case 2:
  578. bEnabled = ( 0 != ( g_dwVerifierFlagsRegistry & DRIVER_VERIFIER_FORCE_IRQL_CHECKING) );
  579. break;
  580. case 3:
  581. bEnabled = ( 0 != ( g_dwVerifierFlagsRegistry & DRIVER_VERIFIER_IO_CHECKING) );
  582. break;
  583. case 4:
  584. bEnabled = ( 0 != ( g_dwVerifierFlagsRegistry & DRIVER_VERIFIER_ENHANCED_IO_CHECKING) );
  585. break;
  586. case 5:
  587. bEnabled = ( 0 != ( g_dwVerifierFlagsRegistry & DRIVER_VERIFIER_DEADLOCK_DETECTION) );
  588. break;
  589. case 6:
  590. bEnabled = ( 0 != ( g_dwVerifierFlagsRegistry & DRIVER_VERIFIER_DMA_VERIFIER) );
  591. break;
  592. case 7:
  593. bEnabled = ( 0 != ( g_dwVerifierFlagsRegistry & DRIVER_VERIFIER_INJECT_ALLOCATION_FAILURES) );
  594. break;
  595. case 8:
  596. bEnabled = g_OldDiskData.VerifyAnyDisk();
  597. break;
  598. default:
  599. //
  600. // Oops, how did we get here ?!?
  601. //
  602. ASSERT( FALSE );
  603. bEnabled = FALSE;
  604. break;
  605. }
  606. return bEnabled;
  607. }
  608. /////////////////////////////////////////////////////////////////////////////
  609. VOID CCrtRegSettingsPage::AddListItemSettBits( INT nItemData,
  610. BOOL bEnabled,
  611. ULONG uIdResourceString )
  612. {
  613. INT nActualIndex;
  614. LVITEM lvItem;
  615. CString strText;
  616. ZeroMemory( &lvItem, sizeof( lvItem ) );
  617. //
  618. // LVITEM's member pszText is not a const pointer
  619. // so we need to GetBuffer here :-(
  620. //
  621. //
  622. // Sub-item 0 - enabled/diabled
  623. //
  624. if( FALSE == bEnabled )
  625. {
  626. VERIFY( strText.LoadString( IDS_NO ) );
  627. }
  628. else
  629. {
  630. VERIFY( strText.LoadString( IDS_YES ) );
  631. }
  632. lvItem.mask = LVIF_TEXT | LVIF_PARAM;
  633. lvItem.lParam = nItemData;
  634. lvItem.iItem = m_SettBitsList.GetItemCount();
  635. lvItem.pszText = strText.GetBuffer( strText.GetLength() + 1 );
  636. if (NULL != lvItem.pszText)
  637. {
  638. nActualIndex = m_SettBitsList.InsertItem( &lvItem );
  639. strText.ReleaseBuffer();
  640. }
  641. else
  642. {
  643. lvItem.pszText = g_szVoidText;
  644. nActualIndex = m_SettBitsList.InsertItem( &lvItem );
  645. }
  646. if( nActualIndex < 0 )
  647. {
  648. //
  649. // Could not add an item in the list - give up
  650. //
  651. goto Done;
  652. }
  653. //
  654. // Sub-item 1 - feature name
  655. //
  656. VERIFY( strText.LoadString( uIdResourceString ) );
  657. lvItem.pszText = strText.GetBuffer( strText.GetLength() + 1 );
  658. if( NULL == lvItem.pszText )
  659. {
  660. goto Done;
  661. }
  662. lvItem.mask = LVIF_TEXT;
  663. lvItem.iItem = nActualIndex;
  664. lvItem.iSubItem = 1;
  665. VERIFY( m_SettBitsList.SetItem( &lvItem ) );
  666. strText.ReleaseBuffer();
  667. Done:
  668. //
  669. // All done
  670. //
  671. NOTHING;
  672. }
  673. /////////////////////////////////////////////////////////////
  674. VOID CCrtRegSettingsPage::UpdateStatusColumnSettBits( INT nItemIndex, BOOL bEnabled )
  675. {
  676. LVITEM lvItem;
  677. CString strText;
  678. ASSERT( nItemIndex < m_SettBitsList.GetItemCount() );
  679. if( FALSE == bEnabled )
  680. {
  681. VERIFY( strText.LoadString( IDS_NO ) );
  682. }
  683. else
  684. {
  685. VERIFY( strText.LoadString( IDS_YES ) );
  686. }
  687. ZeroMemory( &lvItem, sizeof( lvItem ) );
  688. lvItem.mask = LVIF_TEXT;
  689. lvItem.iItem = nItemIndex;
  690. lvItem.iSubItem = 0;
  691. lvItem.pszText = strText.GetBuffer( strText.GetLength() + 1 );
  692. if (NULL != lvItem.pszText)
  693. {
  694. VERIFY( m_SettBitsList.SetItem( &lvItem ) );
  695. strText.ReleaseBuffer();
  696. }
  697. else
  698. {
  699. lvItem.pszText = g_szVoidText;
  700. VERIFY( m_SettBitsList.SetItem( &lvItem ) );
  701. }
  702. }
  703. /////////////////////////////////////////////////////////////
  704. //
  705. // Other methods
  706. //
  707. /////////////////////////////////////////////////////////////
  708. VOID CCrtRegSettingsPage::SortTheListDrivers()
  709. {
  710. m_DriversList.SortItems( DrvStringCmpFunc, (LPARAM)this );
  711. }
  712. /////////////////////////////////////////////////////////////
  713. VOID CCrtRegSettingsPage::SortTheListSettBits()
  714. {
  715. m_SettBitsList.SortItems( SettbitsStringCmpFunc, (LPARAM)this );
  716. }
  717. /////////////////////////////////////////////////////////////
  718. // CCrtRegSettingsPage message handlers
  719. BOOL CCrtRegSettingsPage::OnInitDialog()
  720. {
  721. CPropertyPage::OnInitDialog();
  722. //
  723. // Setup the settings bits list
  724. //
  725. m_SettBitsList.SetExtendedStyle(
  726. LVS_EX_FULLROWSELECT | m_SettBitsList.GetExtendedStyle() );
  727. m_SettBitsList.SetBkColor( ::GetSysColor( COLOR_3DFACE ) );
  728. m_SettBitsList.SetTextBkColor( ::GetSysColor( COLOR_3DFACE ) );
  729. SetupListHeaderDriversSettBits();
  730. FillTheListSettBits();
  731. //SortTheListSettBits();
  732. //
  733. // Setup the drivers list
  734. //
  735. m_DriversList.SetExtendedStyle(
  736. LVS_EX_FULLROWSELECT | m_DriversList.GetExtendedStyle() );
  737. m_DriversList.SetBkColor( ::GetSysColor( COLOR_3DFACE ) );
  738. m_DriversList.SetTextBkColor( ::GetSysColor( COLOR_3DFACE ) );
  739. SetupListHeaderDrivers();
  740. VrfSetWindowText( m_NextDescription, IDS_REGSETT_PAGE_NEXT_DESCR );
  741. return TRUE; // return TRUE unless you set the focus to a control
  742. // EXCEPTION: OCX Property Pages should return FALSE
  743. }
  744. /////////////////////////////////////////////////////////////////////////////
  745. BOOL CCrtRegSettingsPage::OnSetActive()
  746. {
  747. CString strDriversToVerify;
  748. ASSERT_VALID( m_pParentSheet );
  749. m_pParentSheet->SetWizardButtons( PSWIZB_BACK |
  750. PSWIZB_FINISH );
  751. //
  752. // Update the settings list
  753. //
  754. RefreshListSettBits();
  755. //
  756. // Update the drivers list
  757. //
  758. FillTheListDrivers();
  759. SortTheListDrivers();
  760. //
  761. // Verify all or verify selected drivers
  762. //
  763. if( g_bAllDriversVerified )
  764. {
  765. VERIFY( strDriversToVerify.LoadString( IDS_ALL_LOADED_DRIVERS ) );
  766. }
  767. else
  768. {
  769. VERIFY( strDriversToVerify.LoadString( IDS_FOLLOWING_DRIVERS ) );
  770. }
  771. m_VerifiedDrvStatic.SetWindowText( strDriversToVerify );
  772. return CVerifierPropertyPage::OnSetActive();
  773. }
  774. /////////////////////////////////////////////////////////////
  775. VOID CCrtRegSettingsPage::OnColumnclickDriversList(NMHDR* pNMHDR,
  776. LRESULT* pResult)
  777. {
  778. NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)pNMHDR;
  779. if( 0 == pNMListView->iSubItem )
  780. {
  781. if( m_nSortColumnIndexDrv == pNMListView->iSubItem )
  782. {
  783. m_bAscendDrvNameSort = !m_bAscendDrvNameSort;
  784. }
  785. }
  786. else
  787. {
  788. if( m_nSortColumnIndexDrv == pNMListView->iSubItem )
  789. {
  790. m_bAscendDrvDescrSort = !m_bAscendDrvDescrSort;
  791. }
  792. }
  793. m_nSortColumnIndexDrv = pNMListView->iSubItem;
  794. SortTheListDrivers();
  795. *pResult = 0;
  796. }
  797. /////////////////////////////////////////////////////////////
  798. void CCrtRegSettingsPage::OnColumnclickRegsettSettbitsList(NMHDR* pNMHDR, LRESULT* pResult)
  799. {
  800. NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)pNMHDR;
  801. if( 0 == pNMListView->iSubItem )
  802. {
  803. if( m_nSortColumnIndexSettbits == pNMListView->iSubItem )
  804. {
  805. m_bAscendSortEnabledBits = !m_bAscendSortEnabledBits;
  806. }
  807. }
  808. else
  809. {
  810. if( m_nSortColumnIndexSettbits == pNMListView->iSubItem )
  811. {
  812. m_bAscendSortNameBits = !m_bAscendSortNameBits;
  813. }
  814. }
  815. m_nSortColumnIndexSettbits = pNMListView->iSubItem;
  816. SortTheListSettBits();
  817. *pResult = 0;
  818. }
  819. /////////////////////////////////////////////////////////////
  820. LONG CCrtRegSettingsPage::OnHelp( WPARAM wParam, LPARAM lParam )
  821. {
  822. LONG lResult = 0;
  823. LPHELPINFO lpHelpInfo = (LPHELPINFO)lParam;
  824. ::WinHelp(
  825. (HWND) lpHelpInfo->hItemHandle,
  826. g_szVerifierHelpFile,
  827. HELP_WM_HELP,
  828. (DWORD_PTR) MyHelpIds );
  829. return lResult;
  830. }
  831. /////////////////////////////////////////////////////////////////////////////
  832. void CCrtRegSettingsPage::OnContextMenu(CWnd* pWnd, CPoint point)
  833. {
  834. ::WinHelp(
  835. pWnd->m_hWnd,
  836. g_szVerifierHelpFile,
  837. HELP_CONTEXTMENU,
  838. (DWORD_PTR) MyHelpIds );
  839. }