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.

275 lines
6.5 KiB

  1. //
  2. // Driver Verifier UI
  3. // Copyright (c) Microsoft Corporation, 1999
  4. //
  5. //
  6. //
  7. // module: VBitsDlg.cpp
  8. // author: DMihai
  9. // created: 11/1/00
  10. //
  11. // Description:
  12. //
  13. #include "stdafx.h"
  14. #include "verifier.h"
  15. #include "VBitsDlg.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. // CVolatileBitsDlg dialog
  25. CVolatileBitsDlg::CVolatileBitsDlg(CWnd* pParent /*=NULL*/)
  26. : CDialog(CVolatileBitsDlg::IDD, pParent)
  27. {
  28. //{{AFX_DATA_INIT(CVolatileBitsDlg)
  29. // NOTE: the ClassWizard will add member initialization here
  30. //}}AFX_DATA_INIT
  31. }
  32. void CVolatileBitsDlg::DoDataExchange(CDataExchange* pDX)
  33. {
  34. CDialog::DoDataExchange(pDX);
  35. //{{AFX_DATA_MAP(CVolatileBitsDlg)
  36. DDX_Control(pDX, IDC_VOLBITS_LIST, m_SettingsList);
  37. //}}AFX_DATA_MAP
  38. }
  39. BEGIN_MESSAGE_MAP(CVolatileBitsDlg, CDialog)
  40. //{{AFX_MSG_MAP(CVolatileBitsDlg)
  41. ON_WM_HELPINFO()
  42. //}}AFX_MSG_MAP
  43. END_MESSAGE_MAP()
  44. /////////////////////////////////////////////////////////////////////////////
  45. VOID CVolatileBitsDlg::SetupListHeader()
  46. {
  47. CString strTitle;
  48. CRect rectWnd;
  49. LVCOLUMN lvColumn;
  50. //
  51. // The list's rectangle
  52. //
  53. m_SettingsList.GetClientRect( &rectWnd );
  54. ZeroMemory( &lvColumn,
  55. sizeof( lvColumn ) );
  56. lvColumn.mask = LVCF_FMT | LVCF_SUBITEM | LVCF_TEXT | LVCF_WIDTH;
  57. lvColumn.fmt = LVCFMT_LEFT;
  58. //
  59. // Column 0
  60. //
  61. VERIFY( strTitle.LoadString( IDS_ENABLED_QUESTION ) );
  62. lvColumn.iSubItem = 0;
  63. lvColumn.cx = (int)( rectWnd.Width() * 0.20 );
  64. lvColumn.pszText = strTitle.GetBuffer( strTitle.GetLength() + 1 );
  65. if (NULL != lvColumn.pszText)
  66. {
  67. VERIFY( m_SettingsList.InsertColumn( 0, &lvColumn ) != -1 );
  68. strTitle.ReleaseBuffer();
  69. }
  70. else
  71. {
  72. lvColumn.pszText = g_szVoidText;
  73. VERIFY( m_SettingsList.InsertColumn( 0, &lvColumn ) != -1 );
  74. }
  75. //
  76. // Column 1
  77. //
  78. VERIFY( strTitle.LoadString( IDS_SETTING ) );
  79. lvColumn.iSubItem = 1;
  80. lvColumn.cx = (int)( rectWnd.Width() * 0.79 );
  81. lvColumn.pszText = strTitle.GetBuffer( strTitle.GetLength() + 1 );
  82. if (NULL != lvColumn.pszText)
  83. {
  84. VERIFY( m_SettingsList.InsertColumn( 1, &lvColumn ) != -1 );
  85. strTitle.ReleaseBuffer();
  86. }
  87. else
  88. {
  89. lvColumn.pszText = g_szVoidText;
  90. VERIFY( m_SettingsList.InsertColumn( 1, &lvColumn ) != -1 );
  91. }
  92. }
  93. /////////////////////////////////////////////////////////////////////////////
  94. VOID CVolatileBitsDlg::FillTheList( DWORD dwVerifierBits )
  95. {
  96. //
  97. // N.B.
  98. //
  99. // If you change this order then you need to
  100. // change GetNewVerifierFlags as well
  101. //
  102. AddListItem( IDS_SPECIAL_POOL, ( ( dwVerifierBits & DRIVER_VERIFIER_SPECIAL_POOLING ) != 0 ) );
  103. AddListItem( IDS_FORCE_IRQL_CHECKING, ( ( dwVerifierBits & DRIVER_VERIFIER_FORCE_IRQL_CHECKING ) != 0 ) );
  104. AddListItem( IDS_LOW_RESOURCE_SIMULATION,( ( dwVerifierBits & DRIVER_VERIFIER_INJECT_ALLOCATION_FAILURES ) != 0 ) );
  105. }
  106. /////////////////////////////////////////////////////////////////////////////
  107. DWORD CVolatileBitsDlg::GetNewVerifierFlags()
  108. {
  109. //
  110. // N.B.
  111. //
  112. // If you change this order then you need to
  113. // change FillTheList as well
  114. //
  115. DWORD dwNewFlags;
  116. dwNewFlags = 0;
  117. if( m_SettingsList.GetCheck( 0 ) )
  118. {
  119. dwNewFlags |= DRIVER_VERIFIER_SPECIAL_POOLING;
  120. }
  121. if( m_SettingsList.GetCheck( 1 ) )
  122. {
  123. dwNewFlags |= DRIVER_VERIFIER_FORCE_IRQL_CHECKING;
  124. }
  125. if( m_SettingsList.GetCheck( 2 ) )
  126. {
  127. dwNewFlags |= DRIVER_VERIFIER_INJECT_ALLOCATION_FAILURES;
  128. }
  129. return dwNewFlags;
  130. }
  131. /////////////////////////////////////////////////////////////////////////////
  132. VOID CVolatileBitsDlg::AddListItem( ULONG uIdResourceString, BOOL bInitiallyEnabled )
  133. {
  134. INT nActualIndex;
  135. LVITEM lvItem;
  136. CString strName;
  137. ZeroMemory( &lvItem, sizeof( lvItem ) );
  138. //
  139. // LVITEM's member pszText is not a const pointer
  140. // so we need to GetBuffer here :-(
  141. //
  142. //
  143. // Sub-item 0 - enabled/diabled - empty text and a checkbox
  144. //
  145. lvItem.pszText = g_szVoidText;
  146. lvItem.mask = LVIF_TEXT;
  147. lvItem.iItem = m_SettingsList.GetItemCount();
  148. nActualIndex = m_SettingsList.InsertItem( &lvItem );
  149. if( nActualIndex < 0 )
  150. {
  151. //
  152. // Could not add an item in the list - give up
  153. //
  154. goto Done;
  155. }
  156. m_SettingsList.SetCheck( nActualIndex, bInitiallyEnabled );
  157. //
  158. // Sub-item 1 - feature name
  159. //
  160. VERIFY( strName.LoadString( uIdResourceString ) );
  161. lvItem.pszText = strName.GetBuffer( strName.GetLength() + 1 );
  162. if( NULL == lvItem.pszText )
  163. {
  164. goto Done;
  165. }
  166. lvItem.mask = LVIF_TEXT;
  167. lvItem.iItem = nActualIndex;
  168. lvItem.iSubItem = 1;
  169. VERIFY( m_SettingsList.SetItem( &lvItem ) );
  170. strName.ReleaseBuffer();
  171. Done:
  172. //
  173. // All done
  174. //
  175. NOTHING;
  176. }
  177. /////////////////////////////////////////////////////////////////////////////
  178. // CVolatileBitsDlg message handlers
  179. BOOL CVolatileBitsDlg::OnInitDialog()
  180. {
  181. CRuntimeVerifierData RuntimeVerifierData;
  182. //
  183. // Start with the current settings
  184. //
  185. VrfGetRuntimeVerifierData( &RuntimeVerifierData );
  186. CDialog::OnInitDialog();
  187. m_SettingsList.SetExtendedStyle(
  188. LVS_EX_FULLROWSELECT | LVS_EX_CHECKBOXES | m_SettingsList.GetExtendedStyle() );
  189. SetupListHeader();
  190. FillTheList( RuntimeVerifierData.Level );
  191. return TRUE; // return TRUE unless you set the focus to a control
  192. // EXCEPTION: OCX Property Pages should return FALSE
  193. }
  194. /////////////////////////////////////////////////////////////////////////////
  195. void CVolatileBitsDlg::OnOK()
  196. {
  197. DWORD dwNewVerifierBits;
  198. dwNewVerifierBits = GetNewVerifierFlags();
  199. if( VrfSetNewFlagsVolatile( dwNewVerifierBits ) )
  200. {
  201. CDialog::OnOK();
  202. }
  203. //
  204. // If VrfSetNewFlagsVolatile fails we wait for the Cancel button
  205. //
  206. }
  207. /////////////////////////////////////////////////////////////////////////////
  208. BOOL CVolatileBitsDlg::OnHelpInfo(HELPINFO* pHelpInfo)
  209. {
  210. return TRUE;
  211. }