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.

483 lines
9.1 KiB

  1. //
  2. // Driver Verifier UI
  3. // Copyright (c) Microsoft Corporation, 1999
  4. //
  5. //
  6. //
  7. // module: VSetting.h
  8. // author: DMihai
  9. // created: 11/1/00
  10. //
  11. // Description:
  12. //
  13. //////////////////////////////////////////////////////////////////////
  14. #if !defined(AFX_VSETTING_H__478A94E4_3D60_4419_950C_2144CB86691D__INCLUDED_)
  15. #define AFX_VSETTING_H__478A94E4_3D60_4419_950C_2144CB86691D__INCLUDED_
  16. #if _MSC_VER > 1000
  17. #pragma once
  18. #endif // _MSC_VER > 1000
  19. #include "ProgCtrl.h"
  20. ///////////////////////////////////////////////////////////////
  21. //
  22. // CDriverData class
  23. //
  24. // Has information about one driver
  25. //
  26. class CDriverData : public CObject
  27. {
  28. public:
  29. CDriverData();
  30. CDriverData( const CDriverData &DriverData );
  31. CDriverData( LPCTSTR szDriverName );
  32. virtual ~CDriverData();
  33. public:
  34. //
  35. // Operators
  36. //
  37. //
  38. // Methods
  39. //
  40. BOOL LoadDriverImageData();
  41. //
  42. // Overrides
  43. //
  44. virtual void AssertValid( ) const;
  45. protected:
  46. BOOL LoadDriverHeaderData();
  47. BOOL LoadDriverVersionData();
  48. public:
  49. //
  50. // Type definitions
  51. //
  52. typedef enum
  53. {
  54. SignedNotVerifiedYet = 1,
  55. SignedYes,
  56. SignedNo
  57. } SignedTypeEnum;
  58. typedef enum
  59. {
  60. VerifyDriverNo = 1,
  61. VerifyDriverYes
  62. } VerifyDriverTypeEnum;
  63. public:
  64. //
  65. // Data
  66. //
  67. CString m_strName;
  68. SignedTypeEnum m_SignedStatus;
  69. VerifyDriverTypeEnum m_VerifyDriverStatus;
  70. //
  71. // If the current driver is a miniport then
  72. // m_strMiniportName is the driver it is linked against (videoprt.sys, etc.)
  73. //
  74. CString m_strMiniportName;
  75. //
  76. // If this is a "special driver" this is the name to add to the verification list
  77. //
  78. // - hal.dll for the HAL
  79. // - ntoskrnl.exe fro the kernel
  80. //
  81. CString m_strReservedName;
  82. //
  83. // Binary header info
  84. //
  85. WORD m_wMajorOperatingSystemVersion;
  86. WORD m_wMajorImageVersion;
  87. //
  88. // Version info
  89. //
  90. CString m_strCompanyName;
  91. CString m_strFileVersion;
  92. CString m_strFileDescription;
  93. };
  94. ///////////////////////////////////////////////////////////////
  95. //
  96. // CDriverDataArray class
  97. //
  98. // ObArray of CDriverData
  99. //
  100. class CDriverDataArray : public CObArray
  101. {
  102. public:
  103. ~CDriverDataArray();
  104. public:
  105. VOID DeleteAll();
  106. CDriverData *GetAt( INT_PTR nIndex ) const;
  107. public:
  108. //
  109. // Operators
  110. //
  111. CDriverDataArray &operator = (const CDriverDataArray &DriversSet);
  112. };
  113. ///////////////////////////////////////////////////////////////
  114. //
  115. // CDriversSet class
  116. //
  117. // Describes a set of drivers to verify
  118. //
  119. class CDriversSet : public CObject
  120. {
  121. public:
  122. CDriversSet();
  123. virtual ~CDriversSet();
  124. public:
  125. //
  126. // Find all installed unsigned drivers if we didn't do that already
  127. //
  128. BOOL LoadAllDriversData( HANDLE hAbortEvent,
  129. CVrfProgressCtrl &ProgressCtl );
  130. BOOL FindUnsignedDrivers( HANDLE hAbortEvent,
  131. CVrfProgressCtrl &ProgressCtl );
  132. BOOL ShouldDriverBeVerified( const CDriverData *pDriverData ) const;
  133. BOOL ShouldVerifySomeDrivers( ) const;
  134. BOOL GetDriversToVerify( CString &strDriversToVerify );
  135. //
  136. // Operators
  137. //
  138. CDriversSet &operator = (const CDriversSet &DriversSet);
  139. //
  140. // Add a new verifier data structure based on the name
  141. // Returns the new item's index in the array.
  142. //
  143. INT_PTR AddNewDriverData( LPCTSTR szDriverName, BOOL bForceIfFileNotFound = FALSE );
  144. //
  145. // Is this driver name already in our list?
  146. //
  147. BOOL IsDriverNameInList( LPCTSTR szDriverName );
  148. //
  149. // Overrides
  150. //
  151. virtual void AssertValid( ) const;
  152. protected:
  153. //
  154. // Load all installed driver names if we didn't do this already
  155. //
  156. BOOL LoadAllDriversNames( HANDLE hAbortEvent );
  157. public:
  158. //
  159. // Types
  160. //
  161. typedef enum
  162. {
  163. DriversSetCustom = 1,
  164. DriversSetOldOs,
  165. DriversSetNotSigned,
  166. DriversSetAllDrivers
  167. } DriversSetTypeEnum;
  168. //
  169. // Data
  170. //
  171. //
  172. // Standard, custom, etc.
  173. //
  174. DriversSetTypeEnum m_DriverSetType;
  175. //
  176. // Array with data for all the currently installed drivers
  177. //
  178. CDriverDataArray m_aDriverData;
  179. //
  180. // Extra drivers (not currenly installed) to verify
  181. //
  182. CStringArray m_astrNotInstalledDriversToVerify;
  183. //
  184. // Did we initialize already the driver data array?
  185. //
  186. BOOL m_bDriverDataInitialized;
  187. //
  188. // Did we initialize already the unsigned drivers member
  189. // of the driver data structure?
  190. //
  191. BOOL m_bUnsignedDriverDataInitialized;
  192. };
  193. ///////////////////////////////////////////////////////////////
  194. //
  195. // CSettingsBits class
  196. //
  197. // Describes a set of verifier settings bits
  198. //
  199. class CSettingsBits : public CObject
  200. {
  201. public:
  202. CSettingsBits();
  203. virtual ~CSettingsBits();
  204. public:
  205. //
  206. // Type definitions
  207. //
  208. typedef enum
  209. {
  210. SettingsTypeTypical = 1,
  211. SettingsTypeCustom,
  212. } SettingsTypeEnum;
  213. public:
  214. //
  215. // Operators
  216. //
  217. CSettingsBits &operator = (const CSettingsBits &VerifSettings);
  218. //
  219. // Overrides
  220. //
  221. virtual void AssertValid() const;
  222. //
  223. // Methods
  224. //
  225. VOID SetTypicalOnly();
  226. VOID EnableTypicalTests( BOOL bEnable );
  227. VOID EnableExcessiveTests( BOOL bEnable );
  228. VOID EnableLowResTests( BOOL bEnable );
  229. BOOL GetVerifierFlags( DWORD &dwVerifyFlags );
  230. public:
  231. //
  232. // Data
  233. //
  234. SettingsTypeEnum m_SettingsType;
  235. BOOL m_bSpecialPoolEnabled;
  236. BOOL m_bForceIrqlEnabled;
  237. BOOL m_bLowResEnabled;
  238. BOOL m_bPoolTrackingEnabled;
  239. BOOL m_bIoEnabled;
  240. BOOL m_bDeadlockDetectEnabled;
  241. BOOL m_bDMAVerifEnabled;
  242. BOOL m_bEnhIoEnabled;
  243. };
  244. ///////////////////////////////////////////////////////////////
  245. //
  246. // CVerifierSettings class
  247. //
  248. // Describes a set of drivers to verify and the verifier settings bits
  249. //
  250. class CVerifierSettings : public CObject
  251. {
  252. public:
  253. CVerifierSettings();
  254. virtual ~CVerifierSettings();
  255. public:
  256. //
  257. // Operators
  258. //
  259. CVerifierSettings &operator = (const CVerifierSettings &VerifSettings);
  260. //
  261. // Overrides
  262. //
  263. virtual void AssertValid() const;
  264. //
  265. // Methods
  266. //
  267. BOOL SaveToRegistry();
  268. public:
  269. //
  270. // Data
  271. //
  272. CSettingsBits m_SettingsBits;
  273. CDriversSet m_DriversSet;
  274. };
  275. //////////////////////////////////////////////////////////////////////
  276. //////////////////////////////////////////////////////////////////////
  277. //////////////////////////////////////////////////////////////////////
  278. //
  279. // Runtime data - queried from the kernel
  280. //
  281. //////////////////////////////////////////////////////////////////////
  282. //////////////////////////////////////////////////////////////////////
  283. //////////////////////////////////////////////////////////////////////
  284. //////////////////////////////////////////////////////////////////////
  285. //
  286. // class CRuntimeDriverData
  287. //
  288. class CRuntimeDriverData : public CObject
  289. {
  290. public:
  291. //
  292. // Construction
  293. //
  294. CRuntimeDriverData();
  295. public:
  296. //
  297. // Data
  298. //
  299. CString m_strName;
  300. ULONG Loads;
  301. ULONG Unloads;
  302. ULONG CurrentPagedPoolAllocations;
  303. ULONG CurrentNonPagedPoolAllocations;
  304. ULONG PeakPagedPoolAllocations;
  305. ULONG PeakNonPagedPoolAllocations;
  306. SIZE_T PagedPoolUsageInBytes;
  307. SIZE_T NonPagedPoolUsageInBytes;
  308. SIZE_T PeakPagedPoolUsageInBytes;
  309. SIZE_T PeakNonPagedPoolUsageInBytes;
  310. };
  311. //////////////////////////////////////////////////////////////////////
  312. //
  313. // class CRuntimeDriverDataArray
  314. //
  315. class CRuntimeDriverDataArray : public CObArray
  316. {
  317. public:
  318. ~CRuntimeDriverDataArray();
  319. public:
  320. CRuntimeDriverData *GetAt( INT_PTR nIndex );
  321. VOID DeleteAll();
  322. };
  323. //////////////////////////////////////////////////////////////////////
  324. //
  325. // class CRuntimeVerifierData
  326. //
  327. class CRuntimeVerifierData : public CObject
  328. {
  329. public:
  330. //
  331. // Construction
  332. //
  333. CRuntimeVerifierData();
  334. public:
  335. //
  336. // Methods
  337. //
  338. VOID FillWithDefaults();
  339. BOOL IsDriverVerified( LPCTSTR szDriveName );
  340. public:
  341. //
  342. // Data
  343. //
  344. BOOL m_bSpecialPool;
  345. BOOL m_bPoolTracking;
  346. BOOL m_bForceIrql;
  347. BOOL m_bIo;
  348. BOOL m_bEnhIo;
  349. BOOL m_bDeadlockDetect;
  350. BOOL m_bDMAVerif;
  351. BOOL m_bLowRes;
  352. ULONG RaiseIrqls;
  353. ULONG AcquireSpinLocks;
  354. ULONG SynchronizeExecutions;
  355. ULONG AllocationsAttempted;
  356. ULONG AllocationsSucceeded;
  357. ULONG AllocationsSucceededSpecialPool;
  358. ULONG AllocationsWithNoTag;
  359. ULONG Trims;
  360. ULONG AllocationsFailed;
  361. ULONG AllocationsFailedDeliberately;
  362. ULONG UnTrackedPool;
  363. DWORD Level;
  364. CRuntimeDriverDataArray m_RuntimeDriverDataArray;
  365. };
  366. #endif // !defined(AFX_VSETTING_H__478A94E4_3D60_4419_950C_2144CB86691D__INCLUDED_)