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.

261 lines
8.4 KiB

  1. /****************************************************************************************************************
  2. FILENAME: DfrgCmn.h
  3. COPYRIGHT 2001 Microsoft Corporation and Executive Software International, Inc.
  4. REVISION HISTORY:
  5. 0.0E00 - 21 April 1997 - Zack Gainsforth - Created file from FileSys.h
  6. DESCRIPTION:
  7. This is the header file for stuff that is common to both the defragmenter engines and the GUI.
  8. /****************************************************************************************************************/
  9. #ifndef _DFRGCMN_H
  10. #define _DFRGCMN_H
  11. #include "vString.hpp"
  12. #include "vStandard.h"
  13. #define SIMPLE_DISPLAY TRUE
  14. // for string compare
  15. #define MATCH 0
  16. // event name for syncing up with a console app
  17. #define DEFRAG_COMPLETE_EVENT_NAME TEXT("DiskDefragmenter.Event.Volume")
  18. // event name for preventing multiple instances
  19. #define IS_OK_TO_RUN_SEMAPHORE_NAME TEXT("Global\\DiskDefragmenter.Semaphore.MultiInstance")
  20. // for the EngineState()
  21. #define ENGINE_STATE_NULL 0 // Means it hasn't begun running yet.
  22. #define ENGINE_STATE_IDLE 1 // Means it is instantiated, but not running
  23. #define ENGINE_STATE_RUNNING 2 // Means it is running
  24. // for the DefragMode()
  25. #define NONE 0
  26. #define ANALYZE 1
  27. #define DEFRAG 2
  28. #define DEFRAG_FAILED 0x10000000 // set the bit if defrag failed
  29. #define GUID_LENGTH 51
  30. // for DefragState()
  31. #define DEFRAG_STATE_NONE 0 // set when the engine starts, always set thereafter
  32. #define DEFRAG_STATE_USER_STOPPED 1 // set when user stops anal or defrag
  33. #define DEFRAG_STATE_ANALYZING 2 // set during analyze phase only
  34. #define DEFRAG_STATE_ANALYZED 3 // set when volume is analyzed and graphic data is available
  35. #define DEFRAG_STATE_REANALYZING 4 // set during reanalyze phase only
  36. #define DEFRAG_STATE_DEFRAGMENTING 5 // set when defragging is going on
  37. #define DEFRAG_STATE_DEFRAGMENTED 6 // set when defragging is complete
  38. #define DEFRAG_STATE_ENGINE_DEAD 7 // set when engine connection is lost
  39. #define DEFRAG_STATE_BOOT_OPTIMIZING 8 // set when the engine is optimising the boot files
  40. //The number of milliseconds to wait for the DiskView mutex before erroring out.
  41. #define DISKDISPLAYMUTEXWAITINTERVAL 20000
  42. //The number of milliseconds between resetting the communication link.
  43. #define RESETCOMMLINKTIMER 30000
  44. //These are the WM_COMMAND messages that the GUI can send to the engine.
  45. #define ID_ANALYZE 8100
  46. #define ID_DEFRAG 8101
  47. #define ID_STOP 8102
  48. #define ID_PAUSE 8103
  49. #define ID_CONTINUE 8104
  50. #define ID_ABORT 8105
  51. #define ID_INITIALIZE_DRIVE 8106
  52. #define ID_SETDISPDIMENSIONS 8107
  53. #define ID_INIT_VOLUME_COMM 8108
  54. #define ID_PAUSE_ON_SNAPSHOT 8109
  55. #define ID_ABORT_ON_SNAPSHOT 8110
  56. //These are the WM_COMMAND messages that the engine can send to the GUI
  57. #define ID_BEGIN_SCAN 8200
  58. #define ID_DISP_DATA 8201
  59. #define ID_END_SCAN 8202
  60. #define ID_STATUS 8203
  61. #define ID_TERMINATING 8204
  62. #define ID_ENGINE_START 8205
  63. #define ID_FRAGGED_DATA 8206
  64. #define ID_REPORT_TEXT_DATA 8207
  65. #define ID_NO_GRAPHICS_MEMORY 8208
  66. #define ID_ERROR 8209
  67. //These are the WM_COMMAND messages that can be sent either way.
  68. #define ID_PING 8300
  69. //These are the WM_COMMAND messages that are used internally in the engines.
  70. #define ID_INITIALIZE 8400
  71. //These are the WM_COMMAND messages that are used internally in the UI.
  72. #define ID_REPORT 8500
  73. #define ID_REFRESH 8501
  74. #define ID_HELP_CONTENTS 8502
  75. #define ID_ABORTANDSTART 8503
  76. //The names used to create and find other instances of the the window for the DfrgNtfs engine.
  77. #define DFRGNTFS_CLASS TEXT("DfrgNtfsClass")
  78. #define DFRGNTFS_WINDOW TEXT("DfrgNtfs")
  79. //The names used to create and find other instances of the the window for the DfrgFat engine.
  80. #define DFRGFAT_CLASS TEXT("DfrgFatClass")
  81. #define DFRGFAT_WINDOW TEXT("DfrgFat")
  82. //Structure with the data necessary to initialize the DiskDisplay in the GUI when the scan starts.
  83. typedef struct {
  84. TCHAR cVolumeName[GUID_LENGTH];
  85. TCHAR cVolumeTag[GUID_LENGTH];
  86. TCHAR cDisplayLabel[GUID_LENGTH];
  87. TCHAR cFileSystem[16];
  88. }BEGIN_SCAN_INFO;
  89. //Structure sent when the engine starts and has initialized.
  90. typedef struct {
  91. TCHAR cVolumeName[GUID_LENGTH];
  92. TCHAR cFileSystem[16];
  93. DWORD dwAnalyzeOrDefrag;
  94. }ENGINE_START_DATA;
  95. //Structure sent from the engine when the engine dies
  96. typedef struct {
  97. TCHAR cVolumeName[GUID_LENGTH];
  98. TCHAR cFileSystem[16];
  99. DWORD dwAnalyzeOrDefrag;
  100. }END_SCAN_DATA;
  101. //Contains all the various statistics about the disk drive that will be used to
  102. //create a text display in the UI.
  103. typedef struct {
  104. TCHAR cVolumeName[GUID_LENGTH];
  105. TCHAR cVolumeLabel[100]; // added
  106. TCHAR cDrive;
  107. TCHAR cFileSystem[16];
  108. LONGLONG DiskSize;
  109. LONGLONG BytesPerCluster;
  110. LONGLONG UsedSpace;
  111. LONGLONG FreeSpace;
  112. LONGLONG FreeSpacePercent;
  113. LONGLONG UsableFreeSpace;
  114. LONGLONG UsableFreeSpacePercent;
  115. LONGLONG PagefileBytes;
  116. LONGLONG PagefileFrags;
  117. LONGLONG TotalDirectories;
  118. LONGLONG FragmentedDirectories;
  119. LONGLONG ExcessDirFrags;
  120. LONGLONG TotalFiles;
  121. LONGLONG AvgFileSize;
  122. LONGLONG NumFraggedFiles;
  123. LONGLONG NumExcessFrags;
  124. LONGLONG PercentDiskFragged;
  125. LONGLONG AvgFragsPerFile;
  126. LONGLONG MFTBytes;
  127. LONGLONG InUseMFTRecords;
  128. LONGLONG TotalMFTRecords;
  129. LONGLONG MFTExtents;
  130. LONGLONG FreeSpaceFragPercent;
  131. }TEXT_DATA;
  132. //Structure containing data for DiskDisplay to display.
  133. //Any of the DWORD fields can contain zero to indicate that no data is held for analyze or defrag.
  134. //The defrag line array always comes after the analyze line array. However, it may be that only
  135. //one or the other is present.
  136. typedef struct {
  137. TCHAR cVolumeName[GUID_LENGTH];
  138. DWORD dwAnalyzeNumLines;
  139. DWORD dwDefragNumLines;
  140. BYTE LineArray;
  141. }DISPLAY_DATA;
  142. //Structure containing display dimensions for the DiskView from the UI.
  143. typedef struct {
  144. //Either of these may contain 0
  145. DWORD AnalyzeLineCount;
  146. DWORD DefragLineCount;
  147. BOOL bSendGraphicsUpdate; // set to true if you want an immediate update from the engine
  148. }SET_DISP_DATA;
  149. //Structure containing status data about the engine.
  150. typedef struct {
  151. TCHAR cVolumeName[GUID_LENGTH];
  152. DWORD dwPercentDone; //0 to 100
  153. DWORD dwEngineState; // conforms to states given at top of file (STATE_xxxx)
  154. DWORD dwPass; //0 through 7.
  155. TCHAR vsFileName[200]; //the file name of the last moved file
  156. //acs//
  157. // DWORD dwAnalyzePass; //0 or 1.
  158. // DWORD dwAnalyzePercent; //0 to 100
  159. // DWORD dwDefragPass; //0 through 7.
  160. // DWORD dwDefragPercent; //0 to 100
  161. }STATUS_DATA;
  162. //Structure containing error code and text when the engine encounters a problem.
  163. // (see codes below)
  164. typedef struct {
  165. TCHAR cVolumeName[GUID_LENGTH];
  166. DWORD dwErrCode;
  167. TCHAR cErrText[1000];
  168. }ERROR_DATA;
  169. //Structure sent when there is no data to send.
  170. typedef struct {
  171. TCHAR cVolumeName[GUID_LENGTH];
  172. }NOT_DATA;
  173. //Defines whether we are supposed to simply analyze the disk, or analyze and defragment it.
  174. #define NONE 0
  175. #define ANALYZE 1
  176. #define DEFRAG 2
  177. //Engine error codes
  178. //Note that these values are also used by programs that launch
  179. //the defragger to interpret the exit code.
  180. #define ENG_NOERR 0
  181. #define ENG_USER_CANCELLED 1
  182. #define ENGERR_BAD_PARAM 2
  183. #define ENGERR_UNKNOWN 3
  184. #define ENGERR_NOMEM 4
  185. #define ENGERR_GENERAL 5
  186. #define ENGERR_SYSTEM 6
  187. #define ENGERR_LOW_FREESPACE 7
  188. #define ENGERR_CORRUPT_MFT 8
  189. #define ENGERR_RETRY 9
  190. #include "Message.h"
  191. //Message window.
  192. #ifndef GLOBAL_DATAHOME
  193. extern
  194. #endif
  195. BOOL bMessageWindowActive
  196. #ifdef GLOBAL_DATAHOME
  197. = TRUE
  198. #endif
  199. ;
  200. //Allow Messageboxes.
  201. #ifndef GLOBAL_DATAHOME
  202. extern
  203. #endif
  204. BOOL bPopups
  205. #ifdef GLOBAL_DATAHOME
  206. = TRUE
  207. #endif
  208. ;
  209. //If an error occurred which is identified, a message is printed at that location giving data
  210. //to the user. Otherwise, more generic errors are outputted as the code filters up.
  211. #ifndef GLOBAL_DATAHOME
  212. extern
  213. #endif
  214. BOOL bIdentifiedErrorPath
  215. #ifdef GLOBAL_DATAHOME
  216. = FALSE
  217. #endif
  218. ;
  219. #endif // #ifndef _DFRGCMN_H