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.

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