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.

160 lines
5.2 KiB

  1. #include <pch.cxx>
  2. #pragma hdrstop
  3. #include <ole2.h>
  4. #include "trkwks.hxx"
  5. #include "dltadmin.hxx"
  6. BOOL
  7. DltAdminEnumOids( ULONG cArgs, TCHAR * const rgptszArgs[], ULONG *pcEaten )
  8. {
  9. LONG iVol = 0;
  10. LONG iArg = 0;
  11. BOOL fSuccess = FALSE;
  12. BOOL fCrossVolumeOnly = FALSE;
  13. BOOL fShowPath = FALSE;
  14. BOOL fShowBirth = FALSE;
  15. BOOL fAllVolumes = TRUE;
  16. if( 1 <= cArgs && IsHelpArgument( rgptszArgs[0] ))
  17. {
  18. *pcEaten = 1;
  19. printf( "\nOption EnumOIDs\n"
  20. " Purpose: Enumerate the object IDs on one or more volumes\n"
  21. " Usage: -enumoids [-<options>] [drive letter (all drives if omitted)]\n"
  22. " Options: -x => Show only files with cross-volume bit set\n"
  23. " -b => Show the birth ID too\n"
  24. " -f => Show the filename too\n"
  25. " E.g.: -enumoids\n"
  26. " -enumoids -xb d:\n" );
  27. return( TRUE );
  28. }
  29. if( cArgs > 0 &&
  30. ( TEXT('/') == rgptszArgs[iArg][0]
  31. ||
  32. TEXT('-') == rgptszArgs[iArg][0]
  33. ) )
  34. {
  35. _tcslwr( rgptszArgs[iArg] );
  36. for( LONG iOption = 1; TEXT('\0') != rgptszArgs[0][iOption]; iOption++ )
  37. {
  38. switch( rgptszArgs[iArg][iOption] )
  39. {
  40. case TEXT('x'):
  41. fCrossVolumeOnly = TRUE;
  42. break;
  43. case TEXT('b'):
  44. fShowBirth = TRUE;
  45. break;
  46. case TEXT('f'):
  47. fShowPath = TRUE;
  48. break;
  49. default:
  50. _tprintf( TEXT("Ignoring invalid option (use -? for help): %c\n"), rgptszArgs[0][iOption] );
  51. break;
  52. }
  53. }
  54. iArg++;
  55. (*pcEaten)++;
  56. }
  57. if( cArgs > iArg )
  58. {
  59. _tcslwr( rgptszArgs[iArg] );
  60. if( TEXT(':') != rgptszArgs[iArg][1]
  61. ||
  62. TEXT('a') > rgptszArgs[iArg][0]
  63. ||
  64. TEXT('z') < rgptszArgs[iArg][0] )
  65. {
  66. printf( "Invalid arguments. Use -? for help\n" );
  67. return( FALSE );
  68. }
  69. (*pcEaten)++;
  70. iVol = rgptszArgs[iArg][0] - TEXT('a');
  71. fAllVolumes = FALSE;
  72. }
  73. while( iVol < 26 )
  74. {
  75. if( IsLocalObjectVolume( iVol ))
  76. {
  77. LONG lLastError = 0;
  78. printf( "Volume %c:\n", iVol+TEXT('a') );
  79. __try // __finally
  80. {
  81. CObjId objid;
  82. CDomainRelativeObjId droidBirth;
  83. CObjIdEnumerator oie;
  84. ULONG cObjId = 0;
  85. if(oie.Initialize(CVolumeDeviceName(iVol)) == TRUE)
  86. {
  87. if( oie.FindFirst( &objid, &droidBirth ))
  88. {
  89. do
  90. {
  91. if( fCrossVolumeOnly && droidBirth.GetVolumeId().GetUserBitState()
  92. ||
  93. !fCrossVolumeOnly )
  94. {
  95. if( droidBirth.GetVolumeId().GetUserBitState() )
  96. printf( " x " );
  97. else
  98. printf( " " );
  99. _tprintf( TEXT("objid = %s\n"),
  100. static_cast<const TCHAR*>(CStringize(objid)));
  101. if( fShowBirth )
  102. {
  103. _tprintf( TEXT(" %s (birth volid)\n"),
  104. static_cast<const TCHAR*>(CStringize(droidBirth.GetVolumeId() )));
  105. _tprintf( TEXT(" %s (birth objid)\n"),
  106. static_cast<const TCHAR*>(CStringize(droidBirth.GetObjId() )));
  107. }
  108. if( fShowPath )
  109. {
  110. TCHAR tszPath[ MAX_PATH + 1 ];
  111. NTSTATUS status = FindLocalPath( iVol, objid, &droidBirth, &tszPath[2] );
  112. if( NT_SUCCESS(status) )
  113. {
  114. tszPath[0] = VolChar(iVol);
  115. tszPath[1] = TEXT(':');
  116. _tprintf( TEXT(" %s\n"), tszPath );
  117. }
  118. else
  119. _tprintf( TEXT(" %s (%08x)\n"), TEXT("<not found>"), status );
  120. }
  121. }
  122. } while(oie.FindNext(&objid, &droidBirth));
  123. }
  124. }
  125. }
  126. __except( BreakOnDebuggableException() )
  127. {
  128. printf( "Exception occurred: %08x\n", GetExceptionCode() );
  129. }
  130. } // if( IsLocalObjectVolume( iVol ))
  131. if( !fAllVolumes )
  132. break;
  133. iVol++;
  134. } // while( iVol < 26 )
  135. return( TRUE );
  136. }