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.

172 lines
4.8 KiB

  1. /**************************************************************************************************
  2. FILENAME: DfrgNtfs.h
  3. COPYRIGHT 2001 Microsoft Corporation and Executive Software International, Inc.
  4. REVISION HISTORY:
  5. 1.0.00 Andy Staffer - 17 May 1997 - Created.
  6. /*************************************************************************************************/
  7. // If ESI_MESSAGE_WINDOW is defined, then the Message() routine is set active otherwise it is set
  8. // to NULL so there is no overhead costs.
  9. #ifdef ESI_MESSAGE_WINDOW
  10. #define DisplayNtfsFileSpecs() DisplayNtfsFileSpecsFunction()
  11. #else
  12. #define DisplayNtfsFileSpecs()
  13. #endif
  14. /*************************************************************************************************/
  15. /////////////////////////////////
  16. // ACPI Support
  17. /////////////////////////////////
  18. #define STATUS_AC_POWER_OFFLINE 0
  19. #define STATUS_BATTERY_POWER_LOW 2
  20. #define STATUS_BATTERY_POWER_CRITICAL 4
  21. #define STATUS_POWER_UNKNOWN 255
  22. #define BOOT_OPTIMIZE_REGISTRY_PATH TEXT("SOFTWARE\\Microsoft\\Dfrg\\BootOptimizeFunction")
  23. #define BOOT_OPTIMIZE_REGISTRY_LCNSTARTLOCATION TEXT("LcnStartLocation")
  24. #define BOOT_OPTIMIZE_REGISTRY_LCNENDLOCATION TEXT("LcnEndLocation")
  25. LRESULT CALLBACK
  26. MainWndProc(
  27. IN HWND hWnd,
  28. IN UINT uMsg,
  29. IN WPARAM wParam,
  30. IN LPARAM lParam
  31. );
  32. //This intialize DCOM and the message window.
  33. BOOL Initialize();
  34. //This gets data about the volume and initializes variables and so forth for the Dfrg engine.
  35. BOOL InitializeDrive(IN PTCHAR pCommandLine);
  36. //Initializes defrag specific stuff before defragging, and after scanning.
  37. BOOL InitializeDefrag();
  38. //Sends status data to the UI.
  39. VOID SendStatusData();
  40. //Send the report text data to the UI.
  41. VOID SendReportData();
  42. //Sends the graphical data to the UI.
  43. void SendGraphicsData();
  44. //Notifies the UI there is not enough memory for graphics.
  45. void SendGraphicsMemoryErr();
  46. // send error to client to display for user
  47. VOID SendErrData(PTCHAR pErrText, DWORD ErrCode = ENGERR_UNKNOWN);
  48. //This is the exit routine that cleans up after being called by WM_CLOSE.
  49. VOID Exit();
  50. //This gets the MFT bitmap which has one bit set for each file record that is in use.
  51. BOOL GetMftBitmap();
  52. //This gets the names of the pagefiles on a given drive and stores them in a list.
  53. BOOL
  54. GetPagefileNames(
  55. TCHAR cDrive,
  56. HANDLE* phPageFileNames,
  57. TCHAR** ppPageFileNames
  58. );
  59. //Checks a file to see if it is a pagefile.
  60. BOOL CheckForPagefileFat();
  61. //Checks a file to see if it is a pagefile.
  62. BOOL
  63. CheckForPagefileNtfs(
  64. IN LONGLONG FileRecordNumber,
  65. IN FILE_RECORD_SEGMENT_HEADER* pFileRecord
  66. );
  67. //Checks a given file name to see if it matches that of one of the pagefiles on a drive.
  68. BOOL
  69. CheckPagefileNameMatch(
  70. IN TCHAR* pCompareName,
  71. IN TCHAR* pPageFileNames
  72. );
  73. //Display various statistics about the volume.
  74. VOID DisplayNtfsVolumeStats();
  75. //Displays the data about a given file on a FAT volume.
  76. VOID DisplayNtfsFileSpecsFunction();
  77. //This is the analyze thread's main routine.
  78. BOOL AnalyzeThread();
  79. //Determines how big the file lists will have to be.
  80. BOOL PreScanNtfs();
  81. //Fills in the file lists.
  82. BOOL ScanNtfs(IN CONST BOOL fAnalyseOnly);
  83. //This is the defrag thread's main routine.
  84. BOOL DefragThread();
  85. //This defrags all the files in the file lists.
  86. BOOL DefragNtfs();
  87. //Tells the caller to end the current pass if there was no space to move a file into.
  88. BOOL EndPassIfNoSpaces();
  89. BOOL NextFileIfFalse();
  90. //When a file cannot be fully defragmented, this routine will partially defragment it.
  91. BOOL PartialDefragNtfs();
  92. //Once a spot has been found for a file, this will move it there.
  93. BOOL MoveNtfsFile();
  94. //Gets a FRS for the prescan. This reads in chunks of the MFT directly by DASD reads for speed.
  95. //This is only permissible for the prescan since DASD reads may be out of sync with the drive's cache.
  96. BOOL
  97. GetFrs(
  98. IN LONGLONG* pFileRecordNumber,
  99. IN EXTENT_LIST* pMftExtentList,
  100. IN UCHAR* pMftBitmap,
  101. IN FILE_RECORD_SEGMENT_HEADER* pMftBuffer,
  102. OUT FILE_RECORD_SEGMENT_HEADER* pFileRecord
  103. );
  104. //Read the function's header comment -- it must be run to "decode" a MFT record before using it.
  105. AdjustUSA(IN OUT FILE_RECORD_SEGMENT_HEADER* pFrs);
  106. //Allocate memory for the file lists.
  107. BOOL AllocateFileLists(IN CONST BOOL fAnalyseOnly);
  108. //Free up the memory allocated for the file lists.
  109. BOOL DeallocateFileLists();
  110. BOOL UpdateDiskView();
  111. //Sends the most fragged list to the UI.
  112. BOOL SendMostFraggedList(IN CONST BOOL fAnalyseOnly);
  113. BOOL
  114. AllocateFreeSpaceListsWithMultipleTrees();
  115. VOID
  116. ClearFreeSpaceListWithMultipleTrees();
  117. VOID
  118. ClearFreeSpaceTable();
  119. BOOL
  120. ConsolidateFreeSpace(
  121. IN CONST LONGLONG MinimumLength,
  122. IN CONST DWORD dwDesparationFactor,
  123. IN CONST BOOL bDefragMftZone
  124. );