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.

226 lines
6.7 KiB

  1. //
  2. // Enable driver verifier support for ntoskrnl
  3. // Copyright (c) Microsoft Corporation, 1999
  4. //
  5. //
  6. // module: main.cxx
  7. // author: DMihai
  8. // created: 04/19/99
  9. // description: command line parsing and help information
  10. //
  11. #include <windows.h>
  12. #include <tchar.h>
  13. #include <stdlib.h>
  14. #include <stdio.h>
  15. #include <common.ver>
  16. #include "resid.hxx"
  17. #include "resutil.hxx"
  18. #include "genutil.hxx"
  19. #include "regutil.hxx"
  20. TCHAR strKernelModuleName[] = _T( "ntoskrnl.exe" );
  21. void
  22. DisplayHelpInformation();
  23. //////////////////////////////////////////////////////////
  24. extern "C" int _cdecl
  25. wmain( int argc, TCHAR *argv[] )
  26. {
  27. BOOL bResult;
  28. BOOL bChangeFlags;
  29. BOOL bEnableKrnVerifier;
  30. BOOL bDisableKernelVerifier;
  31. BOOL bShowStatus;
  32. DWORD dwVerifierFlags;
  33. DWORD dwIoLevel;
  34. int nCrtCmdLineArg;
  35. TCHAR strEnableCmdLineOption[ 64 ];
  36. TCHAR strFlagsCmdLineOption[ 64 ];
  37. TCHAR strDisableCmdLineOption[ 64 ];
  38. TCHAR strStatusCmdLineOption[ 64 ];
  39. TCHAR strIoLevelCmdLineOption[ 64 ];
  40. bResult =
  41. GetStringFromResources( IDS_ENABLE_CMDLINE_OPTION, strEnableCmdLineOption, ARRAY_LEN( strEnableCmdLineOption ) ) &&
  42. GetStringFromResources( IDS_FLAGS_CMDLINE_OPTION, strFlagsCmdLineOption, ARRAY_LEN( strFlagsCmdLineOption ) ) &&
  43. GetStringFromResources( IDS_DISABLE_CMDLINE_OPTION, strDisableCmdLineOption, ARRAY_LEN( strDisableCmdLineOption ) ) &&
  44. GetStringFromResources( IDS_STATUS_CMDLINE_OPTION, strStatusCmdLineOption, ARRAY_LEN( strStatusCmdLineOption ) ) &&
  45. GetStringFromResources( IDS_IOLEVEL_CMDLINE_OPTION, strIoLevelCmdLineOption, ARRAY_LEN( strIoLevelCmdLineOption ) );
  46. bEnableKrnVerifier = FALSE;
  47. bDisableKernelVerifier = FALSE;
  48. bChangeFlags = FALSE;
  49. bShowStatus = FALSE;
  50. dwVerifierFlags = -1;
  51. dwIoLevel = 1;
  52. for( nCrtCmdLineArg = 0; nCrtCmdLineArg < argc; nCrtCmdLineArg ++ )
  53. {
  54. //
  55. // look for /enable
  56. //
  57. if( _tcsicmp( argv[ nCrtCmdLineArg ], strEnableCmdLineOption ) == 0 )
  58. {
  59. bEnableKrnVerifier = TRUE;
  60. }
  61. else
  62. {
  63. //
  64. // look for /flags
  65. //
  66. if( _tcsicmp( argv[ nCrtCmdLineArg ], strFlagsCmdLineOption ) == 0 )
  67. {
  68. if( nCrtCmdLineArg + 1 < argc )
  69. {
  70. //
  71. // new value for verifier flags
  72. //
  73. dwVerifierFlags = _ttoi( argv[ nCrtCmdLineArg + 1 ] );
  74. bChangeFlags = TRUE;
  75. }
  76. // else ignore the /flags paramater
  77. }
  78. else
  79. {
  80. //
  81. // look for /iolevel
  82. //
  83. if( _tcsicmp( argv[ nCrtCmdLineArg ], strIoLevelCmdLineOption ) == 0 )
  84. {
  85. if( nCrtCmdLineArg + 1 < argc )
  86. {
  87. //
  88. // new value for the IO verification level
  89. //
  90. dwIoLevel = _ttoi( argv[ nCrtCmdLineArg + 1 ] );
  91. if( dwIoLevel != 2 )
  92. {
  93. //
  94. // only levels 1 & 2 are supported
  95. //
  96. dwIoLevel = 1;
  97. }
  98. }
  99. // else ignore the /iolevel paramater
  100. }
  101. else
  102. {
  103. //
  104. // look for /disable
  105. //
  106. if( _tcsicmp( argv[ nCrtCmdLineArg ], strDisableCmdLineOption ) == 0 )
  107. {
  108. bDisableKernelVerifier = TRUE;
  109. }
  110. else
  111. {
  112. //
  113. // look for /status
  114. //
  115. if( _tcsicmp( argv[ nCrtCmdLineArg ], strStatusCmdLineOption ) == 0 )
  116. {
  117. bShowStatus = TRUE;
  118. }
  119. // else -> unknown cmd line param
  120. }
  121. }
  122. }
  123. }
  124. }
  125. if( bEnableKrnVerifier == TRUE || bChangeFlags == TRUE )
  126. {
  127. //
  128. // this will exit the process with the appropriate exit code
  129. //
  130. WriteVerifierKeys(
  131. bEnableKrnVerifier,
  132. dwVerifierFlags,
  133. dwIoLevel,
  134. strKernelModuleName );
  135. }
  136. else
  137. {
  138. if( bDisableKernelVerifier == TRUE )
  139. {
  140. //
  141. // this will exit process with the appropriate exit code
  142. //
  143. RemoveModuleNameFromRegistry( strKernelModuleName );
  144. }
  145. else
  146. {
  147. if( bShowStatus == TRUE )
  148. {
  149. //
  150. // this will exit process with the appropriate exit code
  151. //
  152. DumpStatusFromRegistry( strKernelModuleName );
  153. }
  154. else
  155. {
  156. DisplayHelpInformation();
  157. }
  158. }
  159. }
  160. return 0;
  161. }
  162. ///////////////////////////////////////////////////////////
  163. void
  164. DisplayHelpInformation()
  165. {
  166. PrintStringFromResources( IDS_HELP_LINE1 );
  167. puts( VER_LEGALCOPYRIGHT_STR );
  168. PrintStringFromResources( IDS_HELP_LINE3 );
  169. PrintStringFromResources( IDS_HELP_LINE4 );
  170. PrintStringFromResources( IDS_HELP_LINE5 );
  171. PrintStringFromResources( IDS_HELP_LINE6 );
  172. PrintStringFromResources( IDS_HELP_LINE7 );
  173. PrintStringFromResources( IDS_HELP_LINE8 );
  174. PrintStringFromResources( IDS_HELP_LINE9 );
  175. PrintStringFromResources( IDS_HELP_LINE10 );
  176. PrintStringFromResources( IDS_HELP_LINE11 );
  177. PrintStringFromResources( IDS_HELP_LINE12 );
  178. PrintStringFromResources( IDS_HELP_LINE13 );
  179. PrintStringFromResources( IDS_HELP_LINE14 );
  180. PrintStringFromResources( IDS_HELP_LINE15 );
  181. PrintStringFromResources( IDS_HELP_LINE16 );
  182. PrintStringFromResources( IDS_HELP_LINE17 );
  183. PrintStringFromResources( IDS_HELP_LINE18 );
  184. PrintStringFromResources( IDS_HELP_LINE19 );
  185. PrintStringFromResources( IDS_HELP_LINE20 );
  186. PrintStringFromResources( IDS_HELP_LINE21 );
  187. PrintStringFromResources( IDS_HELP_LINE22 );
  188. PrintStringFromResources( IDS_HELP_LINE23 );
  189. PrintStringFromResources( IDS_HELP_LINE24 );
  190. PrintStringFromResources( IDS_HELP_LINE25 );
  191. exit( EXIT_CODE_NOTHING_CHANGED );
  192. }