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.

301 lines
6.6 KiB

  1. /*++
  2. Copyright (c) 1998 Microsoft Corporation
  3. Module Name:
  4. copy.h
  5. Abstract:
  6. This the include file for supporting copying files, creating new files, and
  7. copying the registries to the remote server.
  8. Author:
  9. Sean Selitrennikoff - 4/5/98
  10. Revision History:
  11. --*/
  12. extern WCHAR pConfigPath[MAX_PATH];
  13. //
  14. // Define structure for an on-disk master boot record. (pulled from
  15. // private\windows\setup\textmode\kernel\sppartit.h)
  16. //
  17. typedef struct _ON_DISK_PTE {
  18. UCHAR ActiveFlag;
  19. UCHAR StartHead;
  20. UCHAR StartSector;
  21. UCHAR StartCylinder;
  22. UCHAR SystemId;
  23. UCHAR EndHead;
  24. UCHAR EndSector;
  25. UCHAR EndCylinder;
  26. UCHAR RelativeSectors[4];
  27. UCHAR SectorCount[4];
  28. } ON_DISK_PTE, *PON_DISK_PTE;
  29. typedef struct _ON_DISK_MBR {
  30. UCHAR BootCode[440];
  31. UCHAR NTFTSignature[4];
  32. UCHAR Filler[2];
  33. ON_DISK_PTE PartitionTable[4];
  34. UCHAR AA55Signature[2];
  35. } ON_DISK_MBR, *PON_DISK_MBR;
  36. #define ALIGN(p,val) (PVOID)((((UINT_PTR)(p) + (val) - 1)) & (~((val) - 1)))
  37. #define U_USHORT(p) (*(USHORT UNALIGNED *)(p))
  38. #define U_ULONG(p) (*(ULONG UNALIGNED *)(p))
  39. typedef struct _MIRROR_VOLUME_INFO {
  40. LIST_ENTRY ListEntry;
  41. DWORD MirrorTableIndex;
  42. WCHAR DriveLetter;
  43. UCHAR PartitionType;
  44. BOOLEAN PartitionActive;
  45. BOOLEAN IsBootDisk;
  46. BOOLEAN CompressedVolume;
  47. PWCHAR MirrorUncPath;
  48. DWORD DiskNumber;
  49. DWORD PartitionNumber;
  50. DWORD DiskSignature;
  51. DWORD BlockSize;
  52. DWORD LastUSNMirrored;
  53. ULONG FileSystemFlags;
  54. WCHAR FileSystemName[16];
  55. PWCHAR VolumeLabel;
  56. PWCHAR NtName;
  57. PWCHAR ArcName;
  58. LARGE_INTEGER DiskSpaceUsed;
  59. LARGE_INTEGER StartingOffset;
  60. LARGE_INTEGER PartitionSize;
  61. } MIRROR_VOLUME_INFO, *PMIRROR_VOLUME_INFO;
  62. typedef struct _MIRROR_CFG_INFO {
  63. DWORD MirrorVersion;
  64. DWORD FileLength;
  65. DWORD NumberVolumes;
  66. PWCHAR SystemPath;
  67. BOOLEAN SysPrepImage; // if FALSE, means it's a mirror
  68. BOOLEAN Debug;
  69. ULONG NumberOfProcessors;
  70. ULONG MajorVersion;
  71. ULONG MinorVersion;
  72. ULONG BuildNumber;
  73. ULONG KernelFileVersionMS;
  74. ULONG KernelFileVersionLS;
  75. ULONG KernelFileFlags;
  76. PWCHAR CSDVersion;
  77. PWCHAR ProcessorArchitecture;
  78. PWCHAR CurrentType;
  79. PWCHAR HalName;
  80. LIST_ENTRY MirrorVolumeList;
  81. } MIRROR_CFG_INFO, *PMIRROR_CFG_INFO;
  82. extern PMIRROR_CFG_INFO GlobalMirrorCfgInfo;
  83. typedef struct _IMIRROR_IGNORE_FILE_LIST {
  84. LIST_ENTRY ListEntry;
  85. USHORT FileNameLength;
  86. WCHAR FileName[1];
  87. } IMIRROR_IGNORE_FILE_LIST, *PIMIRROR_IGNORE_FILE_LIST;
  88. //
  89. // Main processing functions
  90. //
  91. NTSTATUS
  92. AddCopyToDoItems(
  93. VOID
  94. );
  95. //
  96. // Functions for processing each to do item
  97. //
  98. NTSTATUS
  99. CopyCopyFiles(
  100. IN PVOID pBuffer,
  101. IN ULONG Length
  102. );
  103. NTSTATUS
  104. CopyCopyPartitions(
  105. IN PVOID pBuffer,
  106. IN ULONG Length
  107. );
  108. NTSTATUS
  109. CopyCopyRegistry(
  110. IN PVOID pBuffer,
  111. IN ULONG Length
  112. );
  113. //
  114. // Helper functions in filecopy.c
  115. //
  116. #if 0
  117. NTSTATUS
  118. DoFileCopy(
  119. IN PWSTR pMachineDir,
  120. IN PWSTR pSrc,
  121. IN BOOLEAN CheckConfig
  122. );
  123. NTSTATUS
  124. CopyNode(
  125. IN PWIN32_FIND_DATA pSrcFindData,
  126. IN BOOLEAN fFirstTime
  127. );
  128. #endif
  129. DWORD
  130. CallBackFn(LPCWSTR lpszName,
  131. DWORD dwStatus,
  132. DWORD dwHintFlags,
  133. DWORD dwPinCount,
  134. WIN32_FIND_DATAW *lpFind32,
  135. DWORD dwReason,
  136. DWORD dwParam1,
  137. DWORD dwParam2,
  138. DWORD dwContext
  139. );
  140. #if 0
  141. BOOLEAN
  142. CopyPath(
  143. IN OUT PWCHAR *ppDest,
  144. IN OUT PULONG pLength,
  145. IN PWCHAR pSrc
  146. );
  147. BOOLEAN
  148. CatPath(
  149. IN OUT PWCHAR *ppDest,
  150. IN OUT PULONG pLength,
  151. IN PWCHAR pSrc
  152. );
  153. #endif
  154. //
  155. // Helper functions in regcopy.c
  156. //
  157. DWORD
  158. DoFullRegBackup(
  159. PWCHAR MirrorRoot
  160. );
  161. DWORD
  162. DoSpecificRegBackup(
  163. PWSTR HivePath,
  164. HKEY HiveRoot,
  165. PWSTR HiveName
  166. );
  167. DWORD
  168. GetRegistryFileList(
  169. PLIST_ENTRY ListHead
  170. );
  171. //
  172. // Global Defines
  173. //
  174. #define TMP_BUFFER_SIZE 1024
  175. #define ARRAYSIZE( _x ) ( sizeof( _x ) / sizeof( _x[ 0 ] ) )
  176. //
  177. // Global variables
  178. //
  179. extern BYTE TmpBuffer[TMP_BUFFER_SIZE];
  180. extern BYTE TmpBuffer2[TMP_BUFFER_SIZE];
  181. extern BYTE TmpBuffer3[TMP_BUFFER_SIZE];
  182. extern HANDLE ghInst;
  183. //
  184. // Memory functions
  185. //
  186. #define IMirrorAllocMem(x) LocalAlloc( LPTR, x)
  187. #define IMirrorFreeMem(x) LocalFree(x)
  188. #define IMirrorReallocMem(x, sz) LocalReAlloc(x, sz, LMEM_MOVEABLE)
  189. //
  190. // Error handling
  191. //
  192. #define IMirrorHandleError(_s, _f) ((Callbacks.ErrorFn != NULL) ? \
  193. Callbacks.ErrorFn(Callbacks.Context, _s, _f) : 0)
  194. #define IMirrorNowDoing(_f, _s) ((Callbacks.NowDoingFn != NULL) ? \
  195. Callbacks.NowDoingFn(Callbacks.Context, _f, _s) : 0)
  196. #define IMirrorGetMirrorDir(_s, _l) ((Callbacks.GetMirrorDirFn != NULL) ? \
  197. Callbacks.GetMirrorDirFn(Callbacks.Context, _s, _l) : 0)
  198. #define IMirrorGetSetupPath(_s, _p, _l) ((Callbacks.GetSetupFn != NULL) ? \
  199. Callbacks.GetSetupFn(Callbacks.Context, _s, _p, _l) : 0)
  200. #define IMirrorSetSystemPath(_p, _l) ((Callbacks.SetSystemDirFn != NULL) ? \
  201. Callbacks.SetSystemDirFn(Callbacks.Context, _p, _l) : 0)
  202. #define IMirrorFileCreate(_f, _a, _e) ((Callbacks.FileCreateFn != NULL) ? \
  203. Callbacks.FileCreateFn(Callbacks.Context, _f, _a, _e) : 0)
  204. #define IMirrorRegSaveError(_p, _s) ((Callbacks.RegSaveErrorFn != NULL) ? \
  205. Callbacks.RegSaveErrorFn(Callbacks.Context, _p, _s) : 0)
  206. #define IMirrorReinit() ((Callbacks.ReinitFn != NULL) ? \
  207. Callbacks.ReinitFn(Callbacks.Context) : 0)
  208. //
  209. // To Do item functions
  210. //
  211. NTSTATUS
  212. GetNextToDoItem(
  213. OUT PIMIRROR_TODO Item,
  214. OUT PVOID *Buffer,
  215. OUT PULONG Length
  216. );
  217. NTSTATUS
  218. AddToDoItem(
  219. IN IMIRROR_TODO Item,
  220. IN PVOID Buffer,
  221. IN ULONG Length
  222. );
  223. NTSTATUS
  224. ModifyToDoItem(
  225. IN IMIRROR_TODO Item,
  226. IN PVOID Buffer,
  227. IN ULONG Length
  228. );
  229. NTSTATUS
  230. CopyToDoItemParameters(
  231. IN IMIRROR_TODO Item,
  232. OUT PVOID Buffer,
  233. IN OUT PULONG Length
  234. );
  235. NTSTATUS
  236. WriteMirrorConfigFile(
  237. PWCHAR DestFile
  238. );
  239. NTSTATUS
  240. SaveBootSector(
  241. DWORD DiskNumber,
  242. DWORD PartitionNumber,
  243. DWORD BlockSize,
  244. PWCHAR DestFile
  245. );
  246. extern WCHAR pConfigPath[MAX_PATH];
  247. extern WCHAR pSystemPath[MAX_PATH];
  248. extern WCHAR pCSDVersion[128];
  249. extern WCHAR pProcessorArchitecture[64];
  250. extern WCHAR pCurrentType[128];
  251. extern WCHAR pHalName[128];