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.

470 lines
10 KiB

  1. /*++
  2. Copyright (c) 1993 Microsoft Corporation
  3. Module Name:
  4. spcopy.h
  5. Abstract:
  6. Header file for file copying functions in text setup.
  7. Author:
  8. Ted Miller (tedm) 29-October-1993
  9. Revision History:
  10. 02-Oct-1996 jimschm Added SpMoveWin9xFiles
  11. 24-Feb-1997 jimschm Added SpDeleteWin9xFiles
  12. 28-Feb-1997 marcw Moved *Win9x* functions to i386\win9xupg.c.
  13. Added declarations for SpMigDeleteFile and SpMigMoveFileOrDir
  14. --*/
  15. #ifndef _SPCOPY_DEFN_
  16. #define _SPCOPY_DEFN_
  17. //
  18. // Define structure used to describe a file to be copied
  19. // to the target installation.
  20. //
  21. typedef struct _FILE_TO_COPY {
  22. struct _FILE_TO_COPY *Next;
  23. //
  24. // Name of the file to be copied, as it exists on the source media
  25. // (file name part only -- no paths).
  26. //
  27. PWSTR SourceFilename;
  28. //
  29. // Directory to which this file is to be copied.
  30. //
  31. PWSTR TargetDirectory;
  32. //
  33. // Name of file as it should exist on the target.
  34. //
  35. PWSTR TargetFilename;
  36. //
  37. // Path to target partition. This is useful because
  38. // be will have to copy files to the nt drive and system partition,
  39. // and we don't want to serialize these lists (ie, we don't want to
  40. // worry about where the target is).
  41. //
  42. PWSTR TargetDevicePath;
  43. //
  44. // Flag indicating whether TargetDirectory is absolute. If not, then it
  45. // is relative to a directory determined at run time (ie, sysroot).
  46. // This is useful for files that get copied to the system partition.
  47. //
  48. BOOLEAN AbsoluteTargetDirectory;
  49. //
  50. // Disposition flag to indicate the conditions under which the file
  51. // is to be copied. Can be one of the following, which may be ORed with
  52. // any of the COPY_xxx flags below.
  53. //
  54. // COPY_ALWAYS : always copied
  55. // COPY_ONLY_IF_PRESENT : copied only if present on the target
  56. // COPY_ONLY_IF_NOT_PRESENT : not copied if present on the target
  57. // COPY_NEVER : never copied
  58. //
  59. ULONG Flags;
  60. } FILE_TO_COPY, *PFILE_TO_COPY;
  61. typedef struct _DISK_FILE_LIST {
  62. PWSTR MediaShortname;
  63. PWSTR Description;
  64. PWSTR TagFile;
  65. PWSTR Directory;
  66. ULONG FileCount;
  67. PFILE_TO_COPY FileList;
  68. } DISK_FILE_LIST, *PDISK_FILE_LIST;
  69. typedef struct _INCOMPATIBLE_FILE_ENTRY {
  70. //
  71. // Next in line
  72. //
  73. struct _INCOMPATIBLE_FILE_ENTRY *Next;
  74. //
  75. // Future - currently always zero
  76. //
  77. ULONG Flags;
  78. //
  79. // Short name (no path) of the file that is incompatible
  80. //
  81. PWSTR IncompatibleFileName;
  82. //
  83. // Version string (future use) of this file
  84. //
  85. PWSTR VersionString;
  86. //
  87. // Where it lives on the target media
  88. //
  89. PWSTR FullPathOnTarget;
  90. } INCOMPATIBLE_FILE_ENTRY, *PINCOMPATIBLE_FILE_ENTRY;
  91. typedef struct _INCOMPATIBLE_FILE_LIST {
  92. //
  93. // First entry in the list
  94. //
  95. PINCOMPATIBLE_FILE_ENTRY Head;
  96. //
  97. // Count, to speed things up
  98. //
  99. ULONG EntryCount;
  100. } INCOMPATIBLE_FILE_LIST, *PINCOMPATIBLE_FILE_LIST;
  101. #define COPY_ALWAYS 0x00000000
  102. #define COPY_ONLY_IF_PRESENT 0x00000001
  103. #define COPY_ONLY_IF_NOT_PRESENT 0x00000002
  104. #define COPY_NEVER 0x00000003
  105. #define COPY_DISPOSITION_MASK 0x0000000f
  106. #define COPY_DELETESOURCE 0x00000010
  107. #define COPY_SMASHLOCKS 0x00000020
  108. #define COPY_SOURCEISOEM 0x00000040
  109. #define COPY_OVERWRITEOEMFILE 0x00000080
  110. #define COPY_FORCENOCOMP 0x00000100
  111. #define COPY_SKIPIFMISSING 0x00000200
  112. #define COPY_NOVERSIONCHECK 0x00000400
  113. #define COPY_NODECOMP 0x00000800
  114. #define COPY_DECOMPRESS_SYSPREP 0x00001000 // decompress even if it's a sysprep image
  115. //
  116. // Flags in [FileFlags] section of txtsetup.sif
  117. //
  118. #define FILEFLG_SMASHLOCKS 0x00000001
  119. #define FILEFLG_FORCENOCOMP 0x00000002
  120. #define FILEFLG_UPGRADEOVERWRITEOEM 0x00000004
  121. #define FILEFLG_NOVERSIONCHECK 0x00000008
  122. #define FILEFLG_DONTDELETESOURCE 0x00000010
  123. #define SP_DELETE_FILESTODELETE 0
  124. #define SP_COUNT_FILESTODELETE 1
  125. //
  126. // Structure used to build a list of OEM inf files copied during the installation of OEM drivers
  127. //
  128. typedef struct _OEM_INF_FILE {
  129. struct _OEM_INF_FILE *Next;
  130. PWSTR InfName;
  131. } OEM_INF_FILE, *POEM_INF_FILE;
  132. //
  133. // Type of routine to be called from SpCopyFileWithRetry
  134. // when the screen needs repainting.
  135. //
  136. typedef
  137. VOID
  138. (*PCOPY_DRAW_ROUTINE) (
  139. IN PWSTR FullSourcePath, OPTIONAL
  140. IN PWSTR FullTargetPath, OPTIONAL
  141. IN BOOLEAN RepaintEntireScreen
  142. );
  143. //
  144. // Type of routine to be called from SpExpandFile
  145. // for each file found in cabinet.
  146. //
  147. typedef enum {
  148. EXPAND_COPY_FILE,
  149. EXPAND_COPIED_FILE,
  150. EXPAND_QUERY_OVERWRITE,
  151. EXPAND_NOTIFY_CANNOT_EXPAND,
  152. EXPAND_NOTIFY_MULTIPLE,
  153. EXPAND_NOTIFY_CREATE_FAILED
  154. } EXPAND_CALLBACK_MESSAGE;
  155. typedef enum {
  156. EXPAND_NO_ERROR = 0,
  157. EXPAND_SKIP_THIS_FILE,
  158. EXPAND_COPY_THIS_FILE,
  159. EXPAND_CONTINUE,
  160. EXPAND_ABORT
  161. } EXPAND_CALLBACK_RESULT;
  162. typedef
  163. EXPAND_CALLBACK_RESULT
  164. (*PEXPAND_CALLBACK) (
  165. IN EXPAND_CALLBACK_MESSAGE Message,
  166. IN PWSTR FileName,
  167. IN PLARGE_INTEGER FileSize,
  168. IN PLARGE_INTEGER FileTime,
  169. IN ULONG FileAttributes,
  170. IN PVOID CallbackContext
  171. );
  172. VOID
  173. SpCopyThirdPartyDrivers(
  174. IN PWSTR SourceDevicePath,
  175. IN PWSTR SysrootDevice,
  176. IN PWSTR Sysroot,
  177. IN PWSTR SyspartDevice,
  178. IN PWSTR SyspartDirectory,
  179. IN PDISK_FILE_LIST DiskFileLists,
  180. IN ULONG DiskCount
  181. );
  182. NTSTATUS
  183. SpCopyFileUsingNames(
  184. IN PWSTR SourceFilename,
  185. IN PWSTR TargetFilename,
  186. IN ULONG TargetAttributes,
  187. IN ULONG Flags
  188. );
  189. VOID
  190. SpValidateAndChecksumFile(
  191. IN HANDLE FileHandle, OPTIONAL
  192. IN PWSTR Filename, OPTIONAL
  193. OUT PBOOLEAN IsNtImage,
  194. OUT PULONG Checksum,
  195. OUT PBOOLEAN Valid
  196. );
  197. VOID
  198. SpCopyFileWithRetry(
  199. IN PFILE_TO_COPY FileToCopy,
  200. IN PWSTR SourceDevicePath,
  201. IN PWSTR DirectoryOnSourceDevice,
  202. IN PWSTR SourceDirectory, OPTIONAL
  203. IN PWSTR TargetRoot, OPTIONAL
  204. IN ULONG TargetFileAttributes,
  205. IN PCOPY_DRAW_ROUTINE DrawScreen,
  206. IN PULONG CheckSum,
  207. IN PBOOLEAN FileSkipped,
  208. IN ULONG Flags
  209. );
  210. VOID
  211. SpCopyFiles(
  212. IN PVOID SifHandle,
  213. IN PDISK_REGION SystemPartitionRegion,
  214. IN PDISK_REGION NtPartitionRegion,
  215. IN PWSTR Sysroot,
  216. IN PWSTR SystemPartitionDirectory,
  217. IN PWSTR SourceDevicePath,
  218. IN PWSTR DirectoryOnSourceDevice,
  219. IN PWSTR ThirdPartySourceDevicePath
  220. );
  221. VOID
  222. SpDeleteAndBackupFiles(
  223. IN PVOID SifHandle,
  224. IN PDISK_REGION TargetRegion,
  225. IN PWSTR TargetPath
  226. );
  227. //
  228. // The user may skip this operation, in which case SpCreateDirectory
  229. // returns FALSE.
  230. //
  231. #define CREATE_DIRECTORY_FLAG_SKIPPABLE (0x00000001)
  232. BOOLEAN
  233. SpCreateDirectory(
  234. IN PCWSTR DevicePath,
  235. IN PCWSTR RootDirectory, OPTIONAL
  236. IN PCWSTR Directory,
  237. IN ULONG DirAttrs,
  238. IN ULONG CreateFlags
  239. );
  240. VOID
  241. SpCreateDirectoryStructureFromSif(
  242. IN PVOID SifHandle,
  243. IN PWSTR SifSection,
  244. IN PWSTR DevicePath,
  245. IN PWSTR RootDirectory
  246. );
  247. NTSTATUS
  248. SpMoveFileOrDirectory(
  249. IN PWSTR SrcPath,
  250. IN PWSTR DestPath
  251. );
  252. VOID
  253. SpCopyDirRecursive(
  254. IN PWSTR SrcPath,
  255. IN PWSTR DestDevPath,
  256. IN PWSTR DestDirPath,
  257. IN ULONG CopyFlags
  258. );
  259. //
  260. // Diamond/decompression routines.
  261. //
  262. VOID
  263. SpdInitialize(
  264. VOID
  265. );
  266. VOID
  267. SpdTerminate(
  268. VOID
  269. );
  270. BOOLEAN
  271. SpdIsCabinet(
  272. IN PVOID SourceBaseAddress,
  273. IN ULONG SourceFileSize,
  274. OUT PBOOLEAN ContainsMultipleFiles
  275. );
  276. BOOLEAN
  277. SpdIsCompressed(
  278. IN PVOID SourceBaseAddress,
  279. IN ULONG SourceFileSize
  280. );
  281. NTSTATUS
  282. SpdDecompressFile(
  283. IN PVOID SourceBaseAddress,
  284. IN ULONG SourceFileSize,
  285. IN HANDLE DestinationHandle
  286. );
  287. NTSTATUS
  288. SpdDecompressCabinet(
  289. IN PVOID SourceBaseAddress,
  290. IN ULONG SourceFileSize,
  291. IN PWSTR DestinationPath,
  292. IN PEXPAND_CALLBACK Callback,
  293. IN PVOID CallbackContext
  294. );
  295. NTSTATUS
  296. SpdDecompressFileFromDriverCab(
  297. IN PWSTR SourceFileName,
  298. IN PVOID SourceBaseAddress,
  299. IN ULONG SourceFileSize,
  300. IN HANDLE DestinationHandle,
  301. OUT PUSHORT pDate,
  302. OUT PUSHORT pTime
  303. );
  304. BOOLEAN
  305. SpTimeFromDosTime(
  306. IN USHORT Date,
  307. IN USHORT Time,
  308. OUT PLARGE_INTEGER UtcTime
  309. );
  310. VOID
  311. SpMigDeleteFile (
  312. PWSTR DosFileToDelete
  313. );
  314. VOID
  315. SpMigMoveFileOrDir (
  316. IN PWSTR SourceFileOrDir,
  317. IN PWSTR DestFileOrDir
  318. );
  319. VOID
  320. SpInitializeFileLists(
  321. IN PVOID SifHandle,
  322. OUT PDISK_FILE_LIST *DiskFileLists,
  323. OUT PULONG DiskCount
  324. );
  325. VOID
  326. SpAddSectionFilesToCopyList(
  327. IN PVOID SifHandle,
  328. IN PDISK_FILE_LIST DiskFileLists,
  329. IN ULONG DiskCount,
  330. IN PWSTR SectionName,
  331. IN PWSTR TargetDevicePath,
  332. IN PWSTR TargetDirectory,
  333. IN ULONG CopyOptions,
  334. IN BOOLEAN CheckForNoComp
  335. );
  336. VOID
  337. SpCopyFilesInCopyList(
  338. IN PVOID SifHandle,
  339. IN PDISK_FILE_LIST DiskFileLists,
  340. IN ULONG DiskCount,
  341. IN PWSTR SourceDevicePath,
  342. IN PWSTR DirectoryOnSourceDevice,
  343. IN PWSTR TargetRoot,
  344. IN PINCOMPATIBLE_FILE_LIST CompatibilityExceptionList OPTIONAL
  345. );
  346. VOID
  347. SpFreeCopyLists(
  348. IN OUT PDISK_FILE_LIST *DiskFileLists,
  349. IN ULONG DiskCount
  350. );
  351. NTSTATUS
  352. SpExpandFile(
  353. IN PWSTR SourceFilename,
  354. IN PWSTR TargetPathname,
  355. IN PEXPAND_CALLBACK Callback,
  356. IN PVOID CallbackContext
  357. );
  358. NTSTATUS
  359. SpCreateIncompatibleFileEntry(
  360. OUT PINCOMPATIBLE_FILE_ENTRY *TargetEntry,
  361. IN PWSTR FileName,
  362. IN PWSTR VersionString OPTIONAL,
  363. IN PWSTR TargetAbsolutePath OPTIONAL,
  364. IN ULONG Flags OPTIONAL
  365. );
  366. NTSTATUS
  367. SpFreeIncompatibleFileList(
  368. IN PINCOMPATIBLE_FILE_LIST FileListHead
  369. );
  370. BOOLEAN
  371. SpIsFileIncompatible(
  372. IN PINCOMPATIBLE_FILE_LIST FileList,
  373. IN PFILE_TO_COPY pFile,
  374. IN PWSTR TargetRoot OPTIONAL
  375. );
  376. NTSTATUS
  377. SpInitializeCompatibilityOverwriteLists(
  378. IN PVOID SifHandle,
  379. OUT PINCOMPATIBLE_FILE_LIST IncompatibleFileList
  380. );
  381. #endif // ndef _SPCOPY_DEFN_