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.

132 lines
3.8 KiB

  1. // enumr.c
  2. #include "oidtst.h"
  3. void
  4. FsTestDumpReparsePointIndexEntries (
  5. IN PFILE_REPARSE_POINT_INFORMATION ReparsePointInfo,
  6. IN ULONG LengthInBytes
  7. )
  8. {
  9. ULONG ReturnedCount;
  10. ULONG Idx;
  11. ReturnedCount = LengthInBytes / sizeof( FILE_REPARSE_POINT_INFORMATION );
  12. printf( "\n\nFound %x reparse point index entries", ReturnedCount );
  13. for (Idx = 0; Idx < ReturnedCount; Idx += 1) {
  14. printf( "\nEntry %x", Idx );
  15. printf( "\nTag %x", ReparsePointInfo[Idx].Tag );
  16. printf( "\nFileReference " );
  17. FsTestHexDumpLongs( &ReparsePointInfo[Idx].FileReference, 8 );
  18. printf( "\n" );
  19. }
  20. }
  21. int
  22. FsTestEnumerateReparsePoints (
  23. IN HANDLE hFile
  24. )
  25. {
  26. IO_STATUS_BLOCK IoStatusBlock;
  27. NTSTATUS Status;
  28. FILE_REPARSE_POINT_INFORMATION ReparsePointInfo[4];
  29. BOOLEAN ReturnSingleEntry = FALSE;
  30. FILE_INFORMATION_CLASS InfoClass = FileReparsePointInformation;
  31. Status = NtQueryDirectoryFile( hFile,
  32. NULL, // Event
  33. NULL, // ApcRoutine
  34. NULL, // ApcContext
  35. &IoStatusBlock,
  36. &ReparsePointInfo[0],
  37. sizeof(ReparsePointInfo),
  38. InfoClass,
  39. ReturnSingleEntry,
  40. NULL, // FileName
  41. TRUE ); // RestartScan
  42. if (Status == STATUS_SUCCESS) {
  43. FsTestDumpReparsePointIndexEntries( &ReparsePointInfo[0], IoStatusBlock.Information );
  44. }
  45. while (Status == STATUS_SUCCESS) {
  46. RtlFillMemory( ReparsePointInfo, sizeof(ReparsePointInfo), 0x51 );
  47. Status = NtQueryDirectoryFile( hFile,
  48. NULL, // Event
  49. NULL, // ApcRoutine
  50. NULL, // ApcContext
  51. &IoStatusBlock,
  52. &ReparsePointInfo[0],
  53. sizeof(ReparsePointInfo),
  54. InfoClass,
  55. ReturnSingleEntry,
  56. NULL, // FileName
  57. FALSE ); // RestartScan
  58. if (Status == STATUS_SUCCESS) {
  59. FsTestDumpReparsePointIndexEntries( &ReparsePointInfo[0], IoStatusBlock.Information );
  60. }
  61. }
  62. printf( "\n" );
  63. return FsTestDecipherStatus( Status );
  64. }
  65. VOID
  66. _cdecl
  67. main (
  68. int argc,
  69. char *argv[]
  70. )
  71. {
  72. HANDLE hFile;
  73. char Buffer[80];
  74. //
  75. // Get parameters
  76. //
  77. if (argc < 2) {
  78. printf("This program enumerates the reparse points (if any) for a volume (ntfs only).\n\n");
  79. printf("usage: %s driveletter\n", argv[0]);
  80. return;
  81. }
  82. strcpy( Buffer, argv[1] );
  83. strcat( Buffer, "\\$Extend\\$Reparse:$R:$INDEX_ALLOCATION" );
  84. hFile = CreateFile( Buffer,
  85. GENERIC_READ,
  86. FILE_SHARE_READ,
  87. NULL,
  88. OPEN_EXISTING,
  89. FILE_FLAG_BACKUP_SEMANTICS | SECURITY_IMPERSONATION,
  90. NULL );
  91. if ( hFile == INVALID_HANDLE_VALUE ) {
  92. printf( "Error opening directory %s (dec) %d\n", Buffer, GetLastError() );
  93. return;
  94. }
  95. printf( "\nUsing directory:%s\n", Buffer );
  96. FsTestEnumerateReparsePoints( hFile );
  97. CloseHandle( hFile );
  98. return;
  99. }