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.

490 lines
12 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. //
  61. // File attributes to be set on the file. If specified sets these attributes.
  62. // If FILE_ATTRIBUTES_NONE then takes the default logic of attribute setting.
  63. //
  64. ULONG FileAttributes;
  65. } FILE_TO_COPY, *PFILE_TO_COPY;
  66. typedef struct _DISK_FILE_LIST {
  67. PWSTR MediaShortname;
  68. PWSTR Description;
  69. PWSTR TagFile;
  70. PWSTR Directory;
  71. ULONG FileCount;
  72. PFILE_TO_COPY FileList;
  73. } DISK_FILE_LIST, *PDISK_FILE_LIST;
  74. typedef struct _INCOMPATIBLE_FILE_ENTRY {
  75. //
  76. // Next in line
  77. //
  78. struct _INCOMPATIBLE_FILE_ENTRY *Next;
  79. //
  80. // Future - currently always zero
  81. //
  82. ULONG Flags;
  83. //
  84. // Short name (no path) of the file that is incompatible
  85. //
  86. PWSTR IncompatibleFileName;
  87. //
  88. // Version string (future use) of this file
  89. //
  90. PWSTR VersionString;
  91. //
  92. // Where it lives on the target media
  93. //
  94. PWSTR FullPathOnTarget;
  95. } INCOMPATIBLE_FILE_ENTRY, *PINCOMPATIBLE_FILE_ENTRY;
  96. typedef struct _INCOMPATIBLE_FILE_LIST {
  97. //
  98. // First entry in the list
  99. //
  100. PINCOMPATIBLE_FILE_ENTRY Head;
  101. //
  102. // Count, to speed things up
  103. //
  104. ULONG EntryCount;
  105. } INCOMPATIBLE_FILE_LIST, *PINCOMPATIBLE_FILE_LIST;
  106. #define COPY_ALWAYS 0x00000000
  107. #define COPY_ONLY_IF_PRESENT 0x00000001
  108. #define COPY_ONLY_IF_NOT_PRESENT 0x00000002
  109. #define COPY_NEVER 0x00000003
  110. #define COPY_DISPOSITION_MASK 0x0000000f
  111. #define COPY_DELETESOURCE 0x00000010
  112. #define COPY_SMASHLOCKS 0x00000020
  113. #define COPY_SOURCEISOEM 0x00000040
  114. #define COPY_OVERWRITEOEMFILE 0x00000080
  115. #define COPY_FORCENOCOMP 0x00000100
  116. #define COPY_SKIPIFMISSING 0x00000200
  117. #define COPY_NOVERSIONCHECK 0x00000400
  118. #define COPY_NODECOMP 0x00000800
  119. #define COPY_DECOMPRESS_SYSPREP 0x00001000 // decompress even if it's a sysprep image
  120. //
  121. // Flags in [FileFlags] section of txtsetup.sif
  122. //
  123. #define FILEFLG_SMASHLOCKS 0x00000001
  124. #define FILEFLG_FORCENOCOMP 0x00000002
  125. #define FILEFLG_UPGRADEOVERWRITEOEM 0x00000004
  126. #define FILEFLG_NOVERSIONCHECK 0x00000008
  127. #define FILEFLG_DONTDELETESOURCE 0x00000010
  128. #define SP_DELETE_FILESTODELETE 0
  129. #define SP_COUNT_FILESTODELETE 1
  130. //
  131. // Structure used to build a list of OEM inf files copied during the installation of OEM drivers
  132. //
  133. typedef struct _OEM_INF_FILE {
  134. struct _OEM_INF_FILE *Next;
  135. PWSTR InfName;
  136. } OEM_INF_FILE, *POEM_INF_FILE;
  137. //
  138. // Type of routine to be called from SpCopyFileWithRetry
  139. // when the screen needs repainting.
  140. //
  141. typedef
  142. VOID
  143. (*PCOPY_DRAW_ROUTINE) (
  144. IN PWSTR FullSourcePath, OPTIONAL
  145. IN PWSTR FullTargetPath, OPTIONAL
  146. IN BOOLEAN RepaintEntireScreen
  147. );
  148. //
  149. // Type of routine to be called from SpExpandFile
  150. // for each file found in cabinet.
  151. //
  152. typedef enum {
  153. EXPAND_COPY_FILE,
  154. EXPAND_COPIED_FILE,
  155. EXPAND_QUERY_OVERWRITE,
  156. EXPAND_NOTIFY_CANNOT_EXPAND,
  157. EXPAND_NOTIFY_MULTIPLE,
  158. EXPAND_NOTIFY_CREATE_FAILED
  159. } EXPAND_CALLBACK_MESSAGE;
  160. typedef enum {
  161. EXPAND_NO_ERROR = 0,
  162. EXPAND_SKIP_THIS_FILE,
  163. EXPAND_COPY_THIS_FILE,
  164. EXPAND_CONTINUE,
  165. EXPAND_ABORT
  166. } EXPAND_CALLBACK_RESULT;
  167. typedef
  168. EXPAND_CALLBACK_RESULT
  169. (*PEXPAND_CALLBACK) (
  170. IN EXPAND_CALLBACK_MESSAGE Message,
  171. IN PWSTR FileName,
  172. IN PLARGE_INTEGER FileSize,
  173. IN PLARGE_INTEGER FileTime,
  174. IN ULONG FileAttributes,
  175. IN PVOID CallbackContext
  176. );
  177. VOID
  178. SpCopyThirdPartyDrivers(
  179. IN PWSTR SourceDevicePath,
  180. IN PWSTR SysrootDevice,
  181. IN PWSTR Sysroot,
  182. IN PWSTR SyspartDevice,
  183. IN PWSTR SyspartDirectory,
  184. IN PDISK_FILE_LIST DiskFileLists,
  185. IN ULONG DiskCount
  186. );
  187. NTSTATUS
  188. SpCopyFileUsingNames(
  189. IN PWSTR SourceFilename,
  190. IN PWSTR TargetFilename,
  191. IN ULONG TargetAttributes,
  192. IN ULONG Flags
  193. );
  194. VOID
  195. SpValidateAndChecksumFile(
  196. IN HANDLE FileHandle, OPTIONAL
  197. IN PWSTR Filename, OPTIONAL
  198. OUT PBOOLEAN IsNtImage,
  199. OUT PULONG Checksum,
  200. OUT PBOOLEAN Valid
  201. );
  202. VOID
  203. SpCopyFileWithRetry(
  204. IN PFILE_TO_COPY FileToCopy,
  205. IN PWSTR SourceDevicePath,
  206. IN PWSTR DirectoryOnSourceDevice,
  207. IN PWSTR SourceDirectory, OPTIONAL
  208. IN PWSTR TargetRoot, OPTIONAL
  209. IN ULONG TargetFileAttributes,
  210. IN PCOPY_DRAW_ROUTINE DrawScreen,
  211. IN PULONG CheckSum,
  212. IN PBOOLEAN FileSkipped,
  213. IN ULONG Flags
  214. );
  215. VOID
  216. SpCopyFiles(
  217. IN PVOID SifHandle,
  218. IN PDISK_REGION SystemPartitionRegion,
  219. IN PDISK_REGION NtPartitionRegion,
  220. IN PWSTR Sysroot,
  221. IN PWSTR SystemPartitionDirectory,
  222. IN PWSTR SourceDevicePath,
  223. IN PWSTR DirectoryOnSourceDevice,
  224. IN PWSTR ThirdPartySourceDevicePath
  225. );
  226. VOID
  227. SpDeleteAndBackupFiles(
  228. IN PVOID SifHandle,
  229. IN PDISK_REGION TargetRegion,
  230. IN PWSTR TargetPath
  231. );
  232. //
  233. // The user may skip this operation, in which case SpCreateDirectory
  234. // returns FALSE.
  235. //
  236. #define CREATE_DIRECTORY_FLAG_SKIPPABLE (0x00000001)
  237. //
  238. // The headless spinner and error ui are not affected by this flag.
  239. //
  240. #define CREATE_DIRECTORY_FLAG_NO_STATUS_TEXT_UI (0x00000002)
  241. BOOLEAN
  242. SpCreateDirectory_Ustr(
  243. IN PCUNICODE_STRING DevicePath,
  244. IN PCUNICODE_STRING RootDirectory, OPTIONAL
  245. IN PCUNICODE_STRING Directory,
  246. IN ULONG DirAttrs,
  247. IN ULONG CreateFlags
  248. );
  249. BOOLEAN
  250. SpCreateDirectory(
  251. IN PCWSTR DevicePath,
  252. IN PCWSTR RootDirectory, OPTIONAL
  253. IN PCWSTR Directory,
  254. IN ULONG DirAttrs,
  255. IN ULONG CreateFlags
  256. );
  257. VOID
  258. SpCreateDirectoryStructureFromSif(
  259. IN PVOID SifHandle,
  260. IN PWSTR SifSection,
  261. IN PWSTR DevicePath,
  262. IN PWSTR RootDirectory
  263. );
  264. NTSTATUS
  265. SpMoveFileOrDirectory(
  266. IN PWSTR SrcPath,
  267. IN PWSTR DestPath
  268. );
  269. VOID
  270. SpCopyDirRecursive(
  271. IN PWSTR SrcPath,
  272. IN PWSTR DestDevPath,
  273. IN PWSTR DestDirPath,
  274. IN ULONG CopyFlags
  275. );
  276. //
  277. // Diamond/decompression routines.
  278. //
  279. VOID
  280. SpdInitialize(
  281. VOID
  282. );
  283. VOID
  284. SpdTerminate(
  285. VOID
  286. );
  287. BOOLEAN
  288. SpdIsCabinet(
  289. IN PVOID SourceBaseAddress,
  290. IN ULONG SourceFileSize,
  291. OUT PBOOLEAN ContainsMultipleFiles
  292. );
  293. BOOLEAN
  294. SpdIsCompressed(
  295. IN PVOID SourceBaseAddress,
  296. IN ULONG SourceFileSize
  297. );
  298. NTSTATUS
  299. SpdDecompressFile(
  300. IN PVOID SourceBaseAddress,
  301. IN ULONG SourceFileSize,
  302. IN HANDLE DestinationHandle
  303. );
  304. NTSTATUS
  305. SpdDecompressCabinet(
  306. IN PVOID SourceBaseAddress,
  307. IN ULONG SourceFileSize,
  308. IN PWSTR DestinationPath,
  309. IN PEXPAND_CALLBACK Callback,
  310. IN PVOID CallbackContext
  311. );
  312. NTSTATUS
  313. SpdDecompressFileFromDriverCab(
  314. IN PWSTR SourceFileName,
  315. IN PVOID SourceBaseAddress,
  316. IN ULONG SourceFileSize,
  317. IN HANDLE DestinationHandle,
  318. OUT PUSHORT pDate,
  319. OUT PUSHORT pTime
  320. );
  321. BOOLEAN
  322. SpTimeFromDosTime(
  323. IN USHORT Date,
  324. IN USHORT Time,
  325. OUT PLARGE_INTEGER UtcTime
  326. );
  327. VOID
  328. SpMigDeleteFile (
  329. PWSTR DosFileToDelete
  330. );
  331. VOID
  332. SpMigMoveFileOrDir (
  333. IN PWSTR SourceFileOrDir,
  334. IN PWSTR DestFileOrDir
  335. );
  336. VOID
  337. SpInitializeFileLists(
  338. IN PVOID SifHandle,
  339. OUT PDISK_FILE_LIST *DiskFileLists,
  340. OUT PULONG DiskCount
  341. );
  342. VOID
  343. SpAddSectionFilesToCopyList(
  344. IN PVOID SifHandle,
  345. IN PDISK_FILE_LIST DiskFileLists,
  346. IN ULONG DiskCount,
  347. IN PWSTR SectionName,
  348. IN PWSTR TargetDevicePath,
  349. IN PWSTR TargetDirectory,
  350. IN ULONG CopyOptions,
  351. IN BOOLEAN CheckForNoComp,
  352. IN BOOLEAN FileAttributesAvailable
  353. );
  354. VOID
  355. SpCopyFilesInCopyList(
  356. IN PVOID SifHandle,
  357. IN PDISK_FILE_LIST DiskFileLists,
  358. IN ULONG DiskCount,
  359. IN PWSTR SourceDevicePath,
  360. IN PWSTR DirectoryOnSourceDevice,
  361. IN PWSTR TargetRoot,
  362. IN PINCOMPATIBLE_FILE_LIST CompatibilityExceptionList OPTIONAL
  363. );
  364. VOID
  365. SpFreeCopyLists(
  366. IN OUT PDISK_FILE_LIST *DiskFileLists,
  367. IN ULONG DiskCount
  368. );
  369. NTSTATUS
  370. SpExpandFile(
  371. IN PWSTR SourceFilename,
  372. IN PWSTR TargetPathname,
  373. IN PEXPAND_CALLBACK Callback,
  374. IN PVOID CallbackContext
  375. );
  376. NTSTATUS
  377. SpCreateIncompatibleFileEntry(
  378. OUT PINCOMPATIBLE_FILE_ENTRY *TargetEntry,
  379. IN PWSTR FileName,
  380. IN PWSTR VersionString OPTIONAL,
  381. IN PWSTR TargetAbsolutePath OPTIONAL,
  382. IN ULONG Flags OPTIONAL
  383. );
  384. NTSTATUS
  385. SpFreeIncompatibleFileList(
  386. IN PINCOMPATIBLE_FILE_LIST FileListHead
  387. );
  388. BOOLEAN
  389. SpIsFileIncompatible(
  390. IN PINCOMPATIBLE_FILE_LIST FileList,
  391. IN PFILE_TO_COPY pFile,
  392. IN PWSTR TargetRoot OPTIONAL
  393. );
  394. NTSTATUS
  395. SpInitializeCompatibilityOverwriteLists(
  396. IN PVOID SifHandle,
  397. OUT PINCOMPATIBLE_FILE_LIST IncompatibleFileList
  398. );
  399. #endif // ndef _SPCOPY_DEFN_