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.

894 lines
24 KiB

  1. //
  2. // Driver Verifier UI
  3. // Copyright (c) Microsoft Corporation, 1999
  4. //
  5. //
  6. //
  7. // module: CmdLine.cpp
  8. // author: DMihai
  9. // created: 11/1/00
  10. //
  11. // Description:
  12. //
  13. #include "stdafx.h"
  14. #include "verifier.h"
  15. #include "CmdLine.h"
  16. #include "VrfUtil.h"
  17. #include "VGlobal.h"
  18. /////////////////////////////////////////////////////////////////////////////
  19. //
  20. // Execute command line
  21. //
  22. DWORD CmdLineExecute( INT argc, TCHAR *argv[] )
  23. {
  24. BOOL bFoundCmdLineSwitch;
  25. BOOL bHaveNewFlags;
  26. BOOL bHaveNewDrivers;
  27. BOOL bHaveVolatile;
  28. BOOL bVolatileAddDriver;
  29. BOOL bHaveDisk;
  30. DWORD dwExitCode;
  31. DWORD dwNewFlags;
  32. INT_PTR nDrivers;
  33. INT_PTR nCrtDriver;
  34. CStringArray astrNewDrivers;
  35. CString strAllDrivers;
  36. dwExitCode = EXIT_CODE_SUCCESS;
  37. //
  38. // See if the user asked for help
  39. //
  40. bFoundCmdLineSwitch = CmdLineExecuteIfHelp( argc,
  41. argv );
  42. if( TRUE == bFoundCmdLineSwitch )
  43. {
  44. //
  45. // We are done printing out the help strings
  46. //
  47. goto Done;
  48. }
  49. //
  50. // See if the user asked to reset all the existing verifier settings
  51. //
  52. bFoundCmdLineSwitch = CmdLineFindResetSwitch( argc,
  53. argv );
  54. if( TRUE == bFoundCmdLineSwitch )
  55. {
  56. if( VrfDeleteAllVerifierSettings() )
  57. {
  58. if( FALSE != g_bSettingsSaved )
  59. {
  60. //
  61. // Had some non-void verifier settings before
  62. //
  63. dwExitCode = EXIT_CODE_REBOOT_NEEDED;
  64. VrfMesssageFromResource( IDS_REBOOT );
  65. }
  66. else
  67. {
  68. //
  69. // Nothing has changed
  70. //
  71. dwExitCode = EXIT_CODE_SUCCESS;
  72. VrfMesssageFromResource( IDS_NO_SETTINGS_WERE_CHANGED );
  73. }
  74. }
  75. else
  76. {
  77. dwExitCode = EXIT_CODE_ERROR;
  78. }
  79. goto Done;
  80. //
  81. // We are deleting the settings
  82. //
  83. }
  84. //
  85. // See if we need to start logging statistics
  86. //
  87. bFoundCmdLineSwitch = CmdLineExecuteIfLog( argc,
  88. argv );
  89. if( TRUE == bFoundCmdLineSwitch )
  90. {
  91. //
  92. // We are done logging
  93. //
  94. goto Done;
  95. }
  96. //
  97. // See if the user asked to dump the current statistics
  98. // to the console
  99. //
  100. bFoundCmdLineSwitch = CmdLineExecuteIfQuery( argc,
  101. argv );
  102. if( TRUE == bFoundCmdLineSwitch )
  103. {
  104. //
  105. // We are done with the query
  106. //
  107. goto Done;
  108. }
  109. //
  110. // See if the user asked to dump the current registry settings
  111. //
  112. bFoundCmdLineSwitch = CmdLineExecuteIfQuerySettings( argc,
  113. argv );
  114. if( TRUE == bFoundCmdLineSwitch )
  115. {
  116. //
  117. // We are done with the settings query
  118. //
  119. goto Done;
  120. }
  121. //
  122. // Get the new flags, drivers and volatile
  123. // if they have been specified
  124. //
  125. bHaveNewFlags = FALSE;
  126. bHaveNewDrivers = FALSE;
  127. bHaveVolatile = FALSE;
  128. bHaveDisk = FALSE;
  129. CmdLineGetFlagsDriversVolatileDisk(
  130. argc,
  131. argv,
  132. dwNewFlags,
  133. bHaveNewFlags,
  134. astrNewDrivers,
  135. bHaveNewDrivers,
  136. bHaveVolatile,
  137. bVolatileAddDriver,
  138. bHaveDisk);
  139. //
  140. // Enable or disable the disk verifier for all disks.
  141. //
  142. g_NewVerifierSettings.m_aDiskData.SetVerifyAllDisks( bHaveDisk );
  143. g_NewVerifierSettings.m_aDiskData.SaveNewSettings();
  144. if( FALSE != bHaveNewFlags || FALSE != bHaveNewDrivers )
  145. {
  146. //
  147. // Some new drivers, disks and/or flags have been specified.
  148. //
  149. if( FALSE != bHaveVolatile )
  150. {
  151. if( FALSE != bHaveNewFlags || FALSE != bHaveNewDrivers )
  152. {
  153. //
  154. // Have new volative settings
  155. //
  156. if( bHaveNewFlags )
  157. {
  158. VrfSetNewFlagsVolatile( dwNewFlags );
  159. }
  160. else
  161. {
  162. if( astrNewDrivers.GetSize() > 0 )
  163. {
  164. //
  165. // Have some new drivers to add or remove
  166. // from the verify list
  167. //
  168. if( bVolatileAddDriver )
  169. {
  170. //
  171. // Add some drivers
  172. //
  173. VrfAddDriversVolatile( astrNewDrivers );
  174. }
  175. else
  176. {
  177. //
  178. // Remove some drivers
  179. //
  180. VrfRemoveDriversVolatile( astrNewDrivers );
  181. }
  182. }
  183. }
  184. }
  185. }
  186. else
  187. {
  188. //
  189. // Have new persistent settings (registry)
  190. //
  191. //
  192. // Try to get the old settings
  193. //
  194. VrtLoadCurrentRegistrySettings( g_bAllDriversVerified,
  195. g_astrVerifyDriverNamesRegistry,
  196. g_dwVerifierFlagsRegistry );
  197. if( bHaveNewDrivers )
  198. {
  199. //
  200. // Concat all the new driver names in only one string,
  201. // separated with spaces
  202. //
  203. nDrivers = astrNewDrivers.GetSize();
  204. for( nCrtDriver = 0; nCrtDriver < nDrivers; nCrtDriver += 1 )
  205. {
  206. if( strAllDrivers.GetLength() > 0 )
  207. {
  208. strAllDrivers += _T( ' ' );
  209. }
  210. strAllDrivers += astrNewDrivers.ElementAt( nCrtDriver );
  211. }
  212. }
  213. //
  214. // If:
  215. //
  216. // - we are switching to "all drivers verified" OR
  217. // - we are switching to a new set of drivers to be verified OR
  218. // - we are switching to other verifier flags
  219. //
  220. if( ( bHaveNewDrivers &&
  221. strAllDrivers.CompareNoCase( _T( "*" ) ) == 0 &&
  222. TRUE != g_bAllDriversVerified ) ||
  223. ( bHaveNewDrivers &&
  224. strAllDrivers.CompareNoCase( _T( "*" ) ) != 0 &&
  225. VrfIsDriversSetDifferent( strAllDrivers, g_astrVerifyDriverNamesRegistry ) ) ||
  226. ( bHaveNewFlags && dwNewFlags != g_dwVerifierFlagsRegistry ) )
  227. {
  228. //
  229. // These are different settings from what we had before
  230. //
  231. VrfWriteVerifierSettings( bHaveNewDrivers,
  232. strAllDrivers,
  233. bHaveNewFlags,
  234. dwNewFlags );
  235. }
  236. }
  237. }
  238. if( g_bSettingsSaved )
  239. {
  240. VrfMesssageFromResource( IDS_NEW_SETTINGS );
  241. g_OldDiskData = g_NewVerifierSettings.m_aDiskData;
  242. VrfDumpRegistrySettingsToConsole();
  243. _putts( _T("\n" ) );
  244. VrfMesssageFromResource( IDS_REBOOT );
  245. }
  246. else
  247. {
  248. VrfMesssageFromResource( IDS_NO_SETTINGS_WERE_CHANGED );
  249. }
  250. Done:
  251. return dwExitCode;
  252. }
  253. /////////////////////////////////////////////////////////////////////////////
  254. //
  255. // See if the user asked for help and print out the help strings
  256. //
  257. BOOL CmdLineExecuteIfHelp( INT argc,
  258. TCHAR *argv[] )
  259. {
  260. BOOL bPrintedHelp;
  261. TCHAR szCmdLineSwitch[ 64 ];
  262. bPrintedHelp = FALSE;
  263. VERIFY( VrfLoadString( IDS_HELP_CMDLINE_SWITCH,
  264. szCmdLineSwitch,
  265. ARRAY_LENGTH( szCmdLineSwitch ) ) );
  266. //
  267. // Search for help switch in the command line
  268. //
  269. if( argc == 2 && _tcsicmp( argv[ 1 ], szCmdLineSwitch) == 0)
  270. {
  271. CmdLinePrintHelpInformation();
  272. bPrintedHelp = TRUE;
  273. }
  274. return bPrintedHelp;
  275. }
  276. /////////////////////////////////////////////////////////////////////////////
  277. VOID CmdLinePrintHelpInformation()
  278. {
  279. VrfTPrintfResourceFormat( IDS_HELP_LINE1, VER_PRODUCTVERSION_STR );
  280. puts( VER_LEGALCOPYRIGHT_STR );
  281. VrfPrintStringFromResources( IDS_HELP_LINE3 );
  282. VrfPrintStringFromResources( IDS_HELP_LINE4 );
  283. VrfPrintStringFromResources( IDS_HELP_LINE5 );
  284. VrfPrintStringFromResources( IDS_HELP_LINE6 );
  285. VrfPrintStringFromResources( IDS_HELP_LINE7 );
  286. VrfPrintStringFromResources( IDS_HELP_LINE8 );
  287. VrfPrintStringFromResources( IDS_HELP_LINE9 );
  288. VrfPrintStringFromResources( IDS_HELP_LINE10 );
  289. VrfPrintStringFromResources( IDS_HELP_LINE11 );
  290. VrfPrintStringFromResources( IDS_HELP_LINE12 );
  291. VrfPrintStringFromResources( IDS_HELP_LINE13 );
  292. VrfPrintStringFromResources( IDS_HELP_LINE14 );
  293. VrfPrintStringFromResources( IDS_HELP_LINE15 );
  294. VrfPrintStringFromResources( IDS_HELP_LINE16 );
  295. VrfPrintStringFromResources( IDS_HELP_LINE17 );
  296. VrfPrintStringFromResources( IDS_HELP_LINE18 );
  297. VrfPrintStringFromResources( IDS_HELP_LINE19 );
  298. VrfPrintStringFromResources( IDS_HELP_LINE20 );
  299. VrfPrintStringFromResources( IDS_HELP_LINE21 );
  300. VrfPrintStringFromResources( IDS_HELP_LINE22 );
  301. VrfPrintStringFromResources( IDS_HELP_LINE23 );
  302. VrfPrintStringFromResources( IDS_HELP_LINE24 );
  303. VrfPrintStringFromResources( IDS_HELP_LINE25 );
  304. VrfPrintStringFromResources( IDS_HELP_LINE26 );
  305. VrfPrintStringFromResources( IDS_HELP_LINE27 );
  306. VrfPrintStringFromResources( IDS_HELP_LINE28 );
  307. VrfPrintStringFromResources( IDS_HELP_LINE29 );
  308. VrfPrintStringFromResources( IDS_HELP_LINE30 );
  309. VrfPrintStringFromResources( IDS_HELP_LINE31 );
  310. }
  311. /////////////////////////////////////////////////////////////////////////////
  312. //
  313. // See if the user asked to reset all the existing verifier settings
  314. //
  315. BOOL CmdLineFindResetSwitch( INT argc,
  316. TCHAR *argv[] )
  317. {
  318. BOOL bFound;
  319. TCHAR szCmdLineOption[ 64 ];
  320. bFound = FALSE;
  321. if( 2 == argc )
  322. {
  323. VERIFY( VrfLoadString( IDS_RESET_CMDLINE_SWITCH,
  324. szCmdLineOption,
  325. ARRAY_LENGTH( szCmdLineOption ) ) );
  326. bFound = ( _tcsicmp( argv[ 1 ], szCmdLineOption) == 0 );
  327. }
  328. return bFound;
  329. }
  330. /////////////////////////////////////////////////////////////////////////////
  331. //
  332. // See if we need to start logging statistics
  333. //
  334. BOOL CmdLineExecuteIfLog( INT argc,
  335. TCHAR *argv[] )
  336. {
  337. INT nCrtArg;
  338. BOOL bStartLogging;
  339. LPCTSTR szLogFileName;
  340. DWORD dwLogMillisec;
  341. FILE *file;
  342. TCHAR szLogCmdLineOption[ 64 ];
  343. TCHAR szIntervalCmdLineOption[ 64 ];
  344. bStartLogging = FALSE;
  345. szLogFileName = NULL;
  346. if( argc < 2 )
  347. {
  348. //
  349. // Need at least /log LOG_FILE_NAME IN THE CMD LINE
  350. //
  351. goto Done;
  352. }
  353. //
  354. // Default log period - 30 sec
  355. //
  356. dwLogMillisec = 30000;
  357. VERIFY( VrfLoadString( IDS_LOG_CMDLINE_SWITCH,
  358. szLogCmdLineOption,
  359. ARRAY_LENGTH( szLogCmdLineOption ) ) );
  360. VERIFY( VrfLoadString( IDS_INTERVAL_CMDLINE_SWITCH,
  361. szIntervalCmdLineOption,
  362. ARRAY_LENGTH( szIntervalCmdLineOption ) ) );
  363. for( nCrtArg = 1; nCrtArg < argc - 1; nCrtArg += 1 )
  364. {
  365. if( _tcsicmp( argv[ nCrtArg ], szLogCmdLineOption) == 0 )
  366. {
  367. //
  368. // Start logging
  369. //
  370. bStartLogging = TRUE;
  371. szLogFileName = argv[ nCrtArg + 1 ];
  372. }
  373. else
  374. {
  375. if( _tcsicmp( argv[ nCrtArg ], szIntervalCmdLineOption) == 0 )
  376. {
  377. //
  378. // Logging period
  379. //
  380. dwLogMillisec = _ttoi( argv[ nCrtArg + 1 ] ) * 1000;
  381. }
  382. }
  383. }
  384. if( TRUE == bStartLogging )
  385. {
  386. ASSERT( szLogFileName != NULL );
  387. while( TRUE )
  388. {
  389. //
  390. // Open the file
  391. //
  392. file = _tfopen( szLogFileName, TEXT("a+") );
  393. if( file == NULL )
  394. {
  395. //
  396. // print a error message
  397. //
  398. VrfTPrintfResourceFormat(
  399. IDS_CANT_APPEND_FILE,
  400. szLogFileName );
  401. break;
  402. }
  403. //
  404. // Dump current information
  405. //
  406. if( ! VrfDumpStateToFile ( file ) )
  407. {
  408. //
  409. // Insufficient disk space ?
  410. //
  411. VrfTPrintfResourceFormat(
  412. IDS_CANT_WRITE_FILE,
  413. szLogFileName );
  414. }
  415. fflush( file );
  416. VrfFTPrintf(
  417. file,
  418. TEXT("\n\n") );
  419. //
  420. // Close the file
  421. //
  422. fclose( file );
  423. //
  424. // Sleep
  425. //
  426. Sleep( dwLogMillisec );
  427. }
  428. }
  429. Done:
  430. return bStartLogging;
  431. }
  432. /////////////////////////////////////////////////////////////////////////////
  433. //
  434. // See if we need to dump the statistics to the console
  435. //
  436. BOOL CmdLineExecuteIfQuery( INT argc,
  437. TCHAR *argv[] )
  438. {
  439. BOOL bFoundCmdLineSwitch;
  440. TCHAR szCmdLineSwitch[ 64 ];
  441. bFoundCmdLineSwitch = FALSE;
  442. VERIFY( VrfLoadString( IDS_QUERY_CMDLINE_SWITCH,
  443. szCmdLineSwitch,
  444. ARRAY_LENGTH( szCmdLineSwitch ) ) );
  445. //
  446. // Search for our switch in the command line
  447. //
  448. if( argc == 2 && _tcsicmp( argv[1], szCmdLineSwitch) == 0)
  449. {
  450. bFoundCmdLineSwitch = TRUE;
  451. VrfDumpStateToFile( stdout );
  452. }
  453. return bFoundCmdLineSwitch;
  454. }
  455. /////////////////////////////////////////////////////////////////////////////
  456. //
  457. // See if we need to dump the statistics to the console
  458. //
  459. BOOL CmdLineExecuteIfQuerySettings( INT argc,
  460. TCHAR *argv[] )
  461. {
  462. BOOL bFoundCmdLineSwitch;
  463. TCHAR szCmdLineSwitch[ 64 ];
  464. bFoundCmdLineSwitch = FALSE;
  465. VERIFY( VrfLoadString( IDS_QUERYSETT_CMDLINE_SWITCH,
  466. szCmdLineSwitch,
  467. ARRAY_LENGTH( szCmdLineSwitch ) ) );
  468. //
  469. // Search for our switch in the command line
  470. //
  471. if( argc == 2 && _tcsicmp( argv[1], szCmdLineSwitch) == 0)
  472. {
  473. bFoundCmdLineSwitch = TRUE;
  474. VrfDumpRegistrySettingsToConsole();
  475. }
  476. return bFoundCmdLineSwitch;
  477. }
  478. /////////////////////////////////////////////////////////////////////////////
  479. //
  480. // Get the new flags, drivers and volatile
  481. // if they have been specified
  482. //
  483. VOID CmdLineGetFlagsDriversVolatileDisk( INT argc,
  484. TCHAR *argv[],
  485. DWORD &dwNewFlags,
  486. BOOL &bHaveNewFlags,
  487. CStringArray &astrNewDrivers,
  488. BOOL &bHaveNewDrivers,
  489. BOOL &bHaveVolatile,
  490. BOOL &bVolatileAddDriver,
  491. BOOL &bHaveDisk)
  492. {
  493. INT nCrtArg;
  494. NTSTATUS Status;
  495. UNICODE_STRING ustrFlags;
  496. TCHAR szFlagsCmdLineOption[ 64 ];
  497. TCHAR szDiskCmdLineOption[ 64 ];
  498. TCHAR szAllCmdLineOption[ 64 ];
  499. TCHAR szVolatileCmdLineOption[ 64 ];
  500. TCHAR szDriversCmdLineOption[ 64 ];
  501. TCHAR szAddDriversCmdLineOption[ 64 ];
  502. TCHAR szRemoveDriversCmdLineOption[ 64 ];
  503. TCHAR szStandardCmdLineOption[ 64 ];
  504. #ifndef UNICODE
  505. //
  506. // ANSI
  507. //
  508. INT nNameLength;
  509. LPWSTR szUnicodeName;
  510. #endif //#ifndef UNICODE
  511. astrNewDrivers.RemoveAll();
  512. bHaveNewFlags = FALSE;
  513. bHaveNewDrivers = FALSE;
  514. bHaveVolatile = FALSE;
  515. bHaveDisk = FALSE;
  516. //
  517. // Load the switches from the resources
  518. //
  519. VERIFY( VrfLoadString( IDS_FLAGS_CMDLINE_SWITCH,
  520. szFlagsCmdLineOption,
  521. ARRAY_LENGTH( szFlagsCmdLineOption ) ) );
  522. VERIFY( VrfLoadString( IDS_DISK_CMDLINE_SWITCH,
  523. szDiskCmdLineOption,
  524. ARRAY_LENGTH( szDiskCmdLineOption ) ) );
  525. VERIFY( VrfLoadString( IDS_ALL_CMDLINE_SWITCH,
  526. szAllCmdLineOption,
  527. ARRAY_LENGTH( szAllCmdLineOption ) ) );
  528. VERIFY( VrfLoadString( IDS_DONTREBOOT_CMDLINE_SWITCH,
  529. szVolatileCmdLineOption,
  530. ARRAY_LENGTH( szVolatileCmdLineOption ) ) );
  531. VERIFY( VrfLoadString( IDS_DRIVER_CMDLINE_SWITCH,
  532. szDriversCmdLineOption,
  533. ARRAY_LENGTH( szDriversCmdLineOption ) ) );
  534. VERIFY( VrfLoadString( IDS_ADDDRIVER_CMDLINE_SWITCH,
  535. szAddDriversCmdLineOption,
  536. ARRAY_LENGTH( szAddDriversCmdLineOption ) ) );
  537. VERIFY( VrfLoadString( IDS_REMOVEDRIVER_CMDLINE_SWITCH,
  538. szRemoveDriversCmdLineOption,
  539. ARRAY_LENGTH( szRemoveDriversCmdLineOption ) ) );
  540. VERIFY( VrfLoadString( IDS_STANDARD_CMDLINE_SWITCH,
  541. szStandardCmdLineOption,
  542. ARRAY_LENGTH( szStandardCmdLineOption ) ) );
  543. //
  544. // Parse all the cmd line arguments, looking for ours
  545. //
  546. for( nCrtArg = 1; nCrtArg < argc; nCrtArg += 1 )
  547. {
  548. if( _tcsicmp( argv[ nCrtArg ], szFlagsCmdLineOption) == 0 )
  549. {
  550. if( nCrtArg < argc - 1 )
  551. {
  552. //
  553. // Not the last cmd line arg - look for the flags next
  554. //
  555. #ifdef UNICODE
  556. //
  557. // UNICODE
  558. //
  559. RtlInitUnicodeString( &ustrFlags,
  560. argv[ nCrtArg + 1 ] );
  561. #else
  562. //
  563. // ANSI
  564. //
  565. nNameLength = strlen( argv[ nCrtArg + 1 ] );
  566. szUnicodeName = new WCHAR[ nNameLength + 1 ];
  567. if( NULL == szUnicodeName )
  568. {
  569. VrfErrorResourceFormat( IDS_NOT_ENOUGH_MEMORY );
  570. goto DoneWithFlags;
  571. }
  572. MultiByteToWideChar( CP_ACP,
  573. 0,
  574. argv[ nCrtArg + 1 ],
  575. -1,
  576. szUnicodeName,
  577. nNameLength + 1 );
  578. RtlInitUnicodeString( &ustrFlags,
  579. szUnicodeName );
  580. #endif
  581. Status = RtlUnicodeStringToInteger( &ustrFlags,
  582. 0,
  583. &dwNewFlags );
  584. if( NT_SUCCESS( Status ) )
  585. {
  586. bHaveNewFlags = TRUE;
  587. }
  588. #ifndef UNICODE
  589. //
  590. // ANSI
  591. //
  592. ASSERT( NULL != szUnicodeName );
  593. delete [] szUnicodeName;
  594. szUnicodeName = NULL;
  595. DoneWithFlags:
  596. NOTHING;
  597. #endif
  598. }
  599. }
  600. else if( _tcsicmp( argv[ nCrtArg ], szDiskCmdLineOption) == 0 )
  601. {
  602. //
  603. // Verify all disks.
  604. //
  605. bHaveVolatile = FALSE;
  606. bHaveDisk = TRUE;
  607. }
  608. else if( _tcsicmp( argv[ nCrtArg ], szAllCmdLineOption) == 0 )
  609. {
  610. //
  611. // Verify all drivers.
  612. //
  613. bHaveVolatile = FALSE;
  614. astrNewDrivers.Add( _T( '*' ) );
  615. bHaveNewDrivers = TRUE;
  616. }
  617. else if( _tcsicmp( argv[ nCrtArg ], szStandardCmdLineOption) == 0 )
  618. {
  619. //
  620. // Standard verifier flags.
  621. //
  622. dwNewFlags = VrfGetStandardFlags();
  623. bHaveNewFlags = TRUE;
  624. }
  625. else if( _tcsicmp( argv[ nCrtArg ], szVolatileCmdLineOption) == 0 )
  626. {
  627. //
  628. // Volatile
  629. //
  630. bHaveVolatile = TRUE;
  631. }
  632. else if( _tcsicmp( argv[ nCrtArg ], szDriversCmdLineOption) == 0 )
  633. {
  634. //
  635. // /Driver
  636. //
  637. bHaveVolatile = FALSE;
  638. CmdLineGetDriversFromArgv( argc,
  639. argv,
  640. nCrtArg + 1,
  641. astrNewDrivers,
  642. bHaveNewDrivers );
  643. //
  644. // All done - all the rest of argumentshave been driver names
  645. //
  646. break;
  647. }
  648. else if( bHaveVolatile && _tcsicmp( argv[ nCrtArg ], szAddDriversCmdLineOption) == 0 )
  649. {
  650. //
  651. // /adddriver
  652. //
  653. bVolatileAddDriver = TRUE;
  654. CmdLineGetDriversFromArgv( argc,
  655. argv,
  656. nCrtArg + 1,
  657. astrNewDrivers,
  658. bHaveNewDrivers );
  659. //
  660. // All done - all the rest of argumentshave been driver names
  661. //
  662. break;
  663. }
  664. else if( bHaveVolatile && _tcsicmp( argv[ nCrtArg ], szRemoveDriversCmdLineOption) == 0 )
  665. {
  666. //
  667. // /removedriver
  668. //
  669. bVolatileAddDriver = FALSE;
  670. CmdLineGetDriversFromArgv( argc,
  671. argv,
  672. nCrtArg + 1,
  673. astrNewDrivers,
  674. bHaveNewDrivers );
  675. //
  676. // All done - all the rest of arguments have been driver names
  677. //
  678. break;
  679. }
  680. }
  681. //
  682. // If we have new drivers look if they are miniports
  683. //
  684. if( bHaveNewDrivers )
  685. {
  686. VrfAddMiniports( astrNewDrivers );
  687. }
  688. }
  689. /////////////////////////////////////////////////////////////////////////////
  690. //
  691. // Everything that follows after /driver, /adddriver, /removedriver
  692. // should be driver names. Extract these from the command line
  693. //
  694. VOID CmdLineGetDriversFromArgv( INT argc,
  695. TCHAR *argv[],
  696. INT nFirstDriverArgIndex,
  697. CStringArray &astrNewDrivers,
  698. BOOL &bHaveNewDrivers )
  699. {
  700. INT nDriverArg;
  701. bHaveNewDrivers = FALSE;
  702. astrNewDrivers.RemoveAll();
  703. //
  704. // Everything in the command line from here on should be driver names
  705. //
  706. for( nDriverArg = nFirstDriverArgIndex; nDriverArg < argc; nDriverArg += 1 )
  707. {
  708. astrNewDrivers.Add( argv[ nDriverArg ] );
  709. }
  710. bHaveNewDrivers = ( astrNewDrivers.GetSize() > 0 );
  711. }