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.

246 lines
4.3 KiB

  1. //
  2. // Driver Verifier UI
  3. // Copyright (c) Microsoft Corporation, 1999
  4. //
  5. //
  6. //
  7. // module: VGlobal.cpp
  8. // author: DMihai
  9. // created: 11/1/00
  10. //
  11. // Description
  12. //
  13. #include "stdafx.h"
  14. #include "verifier.h"
  15. #include "vglobal.h"
  16. #include "VrfUtil.h"
  17. //
  18. // Help file name
  19. //
  20. TCHAR g_szVerifierHelpFile[] = _T( "verifier.hlp" );
  21. //
  22. // Application name ("Driver Verifier Manager")
  23. //
  24. CString g_strAppName;
  25. //
  26. // Exe module handle - used for loading resources
  27. //
  28. HMODULE g_hProgramModule;
  29. //
  30. // GUI mode or command line mode?
  31. //
  32. BOOL g_bCommandLineMode = FALSE;
  33. //
  34. // Brush used to fill out the background of our steps lists
  35. //
  36. HBRUSH g_hDialogColorBrush = NULL;
  37. //
  38. // Path to %windir%\system32\drivers
  39. //
  40. CString g_strSystemDir;
  41. //
  42. // Path to %windir%\system32\drivers
  43. //
  44. CString g_strDriversDir;
  45. //
  46. // Initial current directory
  47. //
  48. CString g_strInitialCurrentDirectory;
  49. //
  50. // Filled out by CryptCATAdminAcquireContext
  51. //
  52. HCATADMIN g_hCatAdmin = NULL;
  53. //
  54. // Highest user address - used to filter out user-mode stuff
  55. // returned by NtQuerySystemInformation ( SystemModuleInformation )
  56. //
  57. PVOID g_pHighestUserAddress;
  58. //
  59. // Did we enable the debugprivilege already?
  60. //
  61. BOOL g_bPrivegeEnabled = FALSE;
  62. //
  63. // Need to reboot ?
  64. //
  65. BOOL g_bSettingsSaved = FALSE;
  66. //
  67. // Dummy text used to insert an item in a list control with checkboxes
  68. //
  69. TCHAR g_szVoidText[] = _T( "" );
  70. //
  71. // New registry settings
  72. //
  73. CVerifierSettings g_NewVerifierSettings;
  74. //
  75. // Are all drivers verified? (loaded from the registry)
  76. //
  77. BOOL g_bAllDriversVerified;
  78. //
  79. // Drivers to be verified names (loaded from the registry)
  80. // We have data in this array only if g_bAllDriversVerified == FALSE.
  81. //
  82. CStringArray g_astrVerifyDriverNamesRegistry;
  83. //
  84. // Verifier flags (loaded from the registry)
  85. //
  86. DWORD g_dwVerifierFlagsRegistry;
  87. ////////////////////////////////////////////////////////////////
  88. BOOL VerifInitalizeGlobalData( VOID )
  89. {
  90. BOOL bSuccess;
  91. LPTSTR szDirectory;
  92. ULONG uCharacters;
  93. MEMORYSTATUSEX MemoryStatusEx;
  94. //
  95. // Exe module handle - used for loading resources
  96. //
  97. g_hProgramModule = GetModuleHandle( NULL );
  98. bSuccess = FALSE;
  99. //
  100. // Load the app name from the resources
  101. //
  102. TRY
  103. {
  104. bSuccess = VrfLoadString( IDS_APPTITLE,
  105. g_strAppName );
  106. if( TRUE != bSuccess )
  107. {
  108. VrfErrorResourceFormat( IDS_CANNOT_LOAD_APP_TITLE );
  109. }
  110. }
  111. CATCH( CMemoryException, pMemException )
  112. {
  113. VrfErrorResourceFormat( IDS_NOT_ENOUGH_MEMORY );
  114. }
  115. END_CATCH
  116. if( TRUE != bSuccess )
  117. {
  118. goto Done;
  119. }
  120. //
  121. // Save the %windir%\system32 and %windir%\system32\drivers
  122. // paths in some global variables
  123. //
  124. szDirectory = g_strSystemDir.GetBuffer( MAX_PATH );
  125. if( NULL == szDirectory )
  126. {
  127. VrfErrorResourceFormat( IDS_NOT_ENOUGH_MEMORY );
  128. goto Done;
  129. }
  130. uCharacters = GetSystemDirectory( szDirectory,
  131. MAX_PATH );
  132. g_strSystemDir.ReleaseBuffer();
  133. if( uCharacters == 0 || uCharacters >= MAX_PATH )
  134. {
  135. VrfErrorResourceFormat( IDS_CANNOT_GET_SYSTEM_DIRECTORY );
  136. bSuccess = FALSE;
  137. goto Done;
  138. }
  139. g_strDriversDir = g_strSystemDir + "\\drivers" ;
  140. //
  141. // Save the initial current directory
  142. //
  143. szDirectory = g_strInitialCurrentDirectory.GetBuffer( MAX_PATH );
  144. if( NULL == szDirectory )
  145. {
  146. VrfErrorResourceFormat( IDS_NOT_ENOUGH_MEMORY );
  147. goto Done;
  148. }
  149. uCharacters = GetCurrentDirectory( MAX_PATH,
  150. szDirectory );
  151. g_strInitialCurrentDirectory.ReleaseBuffer();
  152. if( uCharacters == 0 || uCharacters >= MAX_PATH )
  153. {
  154. VrfErrorResourceFormat( IDS_CANNOT_GET_CURRENT_DIRECTORY );
  155. bSuccess = FALSE;
  156. goto Done;
  157. }
  158. //
  159. // We need the highest user-mode address to filter out user-mode stuff
  160. // returned by NtQuerySystemInformation ( SystemModuleInformation )
  161. //
  162. ZeroMemory( &MemoryStatusEx,
  163. sizeof( MemoryStatusEx ) );
  164. MemoryStatusEx.dwLength = sizeof( MemoryStatusEx );
  165. bSuccess = GlobalMemoryStatusEx( &MemoryStatusEx );
  166. if( TRUE != bSuccess )
  167. {
  168. goto Done;
  169. }
  170. g_pHighestUserAddress = (PVOID) MemoryStatusEx.ullTotalVirtual;
  171. Done:
  172. return bSuccess;
  173. }