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.

275 lines
8.0 KiB

  1. /*++
  2. Copyright (c) Microsoft Corporation. All rights reserved.
  3. Module Name:
  4. backup.h
  5. Abstract:
  6. Private header for....
  7. Routines to control backup during install process
  8. And restore of an old install process
  9. (See also backup.c)
  10. Author:
  11. Jamie Hunter (jamiehun) 13-Jan-1997
  12. Revision History:
  13. --*/
  14. typedef struct _SP_TARGET_ENT {
  15. //
  16. // Used for backup and unwind-backup
  17. // Data of TargetLookupTable of a file Queue
  18. //
  19. // this file information (strings in StringTable)
  20. LONG TargetRoot;
  21. LONG TargetSubDir;
  22. LONG TargetFilename;
  23. // where file is, or is-to-be backed up (strings in StringTable)
  24. LONG BackupRoot;
  25. LONG BackupSubDir;
  26. LONG BackupFilename;
  27. // if file has been renamed, what the new target is (string in TargetLookupTable)
  28. LONG NewTargetFilename;
  29. // Various flags as needed
  30. DWORD InternalFlags;
  31. // security attributes etc
  32. // (jamiehun TODO)
  33. } SP_TARGET_ENT, *PSP_TARGET_ENT;
  34. typedef struct _SP_UNWIND_NODE {
  35. //
  36. // List of things to unwind, FILO
  37. //
  38. struct _SP_UNWIND_NODE *NextNode;
  39. LONG TargetID; // TargetID to use for UNWIND
  40. PSECURITY_DESCRIPTOR SecurityDesc; // Security descriptor to apply
  41. FILETIME CreateTime; // Time stamps to apply
  42. FILETIME AccessTime;
  43. FILETIME WriteTime;
  44. } SP_UNWIND_NODE, *PSP_UNWIND_NODE;
  45. typedef struct _SP_DELAYMOVE_NODE {
  46. //
  47. // List of things to rename, FIFO
  48. //
  49. struct _SP_DELAYMOVE_NODE *NextNode;
  50. LONG SourceFilename; // What to rename
  51. LONG TargetFilename; // what to rename to
  52. DWORD SecurityDesc; // security descriptor index in the string table
  53. BOOL TargetIsProtected; // target file is a protected system file
  54. } SP_DELAYMOVE_NODE, *PSP_DELAYMOVE_NODE;
  55. #define SP_BKFLG_LATEBACKUP (1) // backup only if file is modified in any way
  56. #define SP_BKFLG_PREBACKUP (2) // backup uninstall files first
  57. #define SP_BKFLG_CALLBACK (4) // flag, indicating app should be callback aware
  58. #define SP_TEFLG_SAVED (0x00000001) // set if file already copied/moved to backup
  59. #define SP_TEFLG_TEMPNAME (0x00000002) // set if backup is temporary file
  60. #define SP_TEFLG_ORIGNAME (0x00000004) // set if backup specifies an original name
  61. #define SP_TEFLG_MODIFIED (0x00000008) // set if target has been modified/deleted (backup has original)
  62. #define SP_TEFLG_MOVED (0x00000010) // set if target has been moved (to NewTargetFilename)
  63. #define SP_TEFLG_BACKUPQUEUE (0x00000020) // set if backup queued in backup sub-queue
  64. #define SP_TEFLG_RESTORED (0x00000040) // set if file already restored during unwind operation
  65. #define SP_TEFLG_UNWIND (0x00000080) // set if file added to unwind list
  66. #define SP_TEFLG_SKIPPED (0x00000100) // we didn't manage to back it up, we cannot back it up, we should not try again
  67. #define SP_TEFLG_INUSE (0x00000200) // while backing up, we determined we cannot backup file because it cannot be read
  68. #define SP_TEFLG_RENAMEEXISTING (0x00000400) // rename existing file to temp filename in same directory.
  69. #define SP_TEFLG_PRUNE_COPY (0x00010000) // set during file pruning, detected this file is on copy queue
  70. #define SP_TEFLG_PRUNE_DEL (0x00020000) // set during file pruning, detected this file is on delete queue
  71. #define SP_TEFLG_PRUNE_RENSRC (0x00040000) // set during file pruning, detected this file is on rename queue
  72. #define SP_TEFLG_PRUNE_RENTARG (0x00080000) // file RENSRC is renamed to RENTARG
  73. #define SP_BACKUP_DRIVERFILES TEXT("DriverFiles")
  74. #define SP_BACKUP_OLDFILES TEXT("Temp") // relative to the windows directory
  75. #define SP_LASTGOOD_NAME TEXT("LastGood")
  76. //
  77. // these are private routines
  78. //
  79. DWORD
  80. pSetupQueueBackupCopy(
  81. IN HSPFILEQ QueueHandle,
  82. IN LONG TargetRootPath,
  83. IN LONG TargetSubDir, OPTIONAL
  84. IN LONG TargetFilename,
  85. IN LONG BackupRootPath,
  86. IN LONG BackupSubDir, OPTIONAL
  87. IN LONG BackupFilename
  88. );
  89. BOOL
  90. pSetupGetFullBackupPath(
  91. OUT PTSTR FullPath,
  92. IN PCTSTR Path,
  93. IN UINT TargetBufferSize,
  94. OUT PUINT RequiredSize OPTIONAL
  95. );
  96. DWORD
  97. pSetupBackupCopyString(
  98. IN PVOID DestStringTable,
  99. OUT PLONG DestStringID,
  100. IN PVOID SrcStringTable,
  101. IN LONG SrcStringID
  102. );
  103. DWORD
  104. pSetupBackupGetTargetByPath(
  105. IN HSPFILEQ QueueHandle,
  106. IN PVOID PathStringTable, OPTIONAL
  107. IN PCTSTR TargetPath, OPTIONAL
  108. IN LONG TargetRoot,
  109. IN LONG TargetSubDir, OPTIONAL
  110. IN LONG TargetFilename,
  111. OUT PLONG TableID, OPTIONAL
  112. OUT PSP_TARGET_ENT TargetInfo
  113. );
  114. DWORD
  115. pSetupBackupGetTargetByID(
  116. IN HSPFILEQ QueueHandle,
  117. IN LONG TableID,
  118. OUT PSP_TARGET_ENT TargetInfo
  119. );
  120. DWORD
  121. pSetupBackupSetTargetByID(
  122. IN HSPFILEQ QueueHandle,
  123. IN LONG TableID,
  124. IN PSP_TARGET_ENT TargetInfo
  125. );
  126. BOOL
  127. pSetupResetTarget(
  128. IN PVOID StringTable,
  129. IN LONG StringId,
  130. IN PCTSTR String, OPTIONAL
  131. IN PVOID ExtraData,
  132. IN UINT ExtraDataSize,
  133. IN LPARAM lParam
  134. );
  135. DWORD
  136. pSetupBackupAppendFiles(
  137. IN HSPFILEQ TargetQueueHandle,
  138. IN PCTSTR BackupSubDir,
  139. IN DWORD BackupFlags,
  140. IN HSPFILEQ SourceQueueHandle OPTIONAL
  141. );
  142. DWORD
  143. pSetupBackupFile(
  144. IN HSPFILEQ QueueHandle,
  145. IN PCTSTR TargetPath,
  146. IN PCTSTR BackupPath,
  147. IN LONG TargetID, OPTIONAL
  148. IN LONG TargetRootPath,
  149. IN LONG TargetSubDir,
  150. IN LONG TargetFilename,
  151. IN LONG BackupRootPath,
  152. IN LONG BackupSubDir,
  153. IN LONG BackupFilename,
  154. BOOL *DelayedBackup
  155. );
  156. VOID
  157. pSetupDeleteBackup(
  158. IN PCTSTR BackupInstance
  159. );
  160. DWORD
  161. pSetupGetCurrentlyInstalledDriverNode(
  162. IN HDEVINFO DeviceInfoSet,
  163. IN OUT PSP_DEVINFO_DATA DeviceInfoData
  164. );
  165. DWORD
  166. pSetupGetBackupQueue(
  167. IN PCTSTR DeviceID,
  168. IN OUT HSPFILEQ FileQueue,
  169. IN DWORD BackupFlags
  170. );
  171. BOOL
  172. PostDelayedMove(
  173. IN struct _SP_FILE_QUEUE *Queue,
  174. IN PCTSTR CurrentName,
  175. IN PCTSTR NewName, OPTIONAL
  176. IN DWORD SecurityDesc,
  177. IN BOOL TargetIsProtected
  178. );
  179. BOOL
  180. UnPostDelayedMove(
  181. IN struct _SP_FILE_QUEUE *Queue,
  182. IN PCTSTR CurrentName,
  183. IN PCTSTR NewName OPTIONAL
  184. );
  185. DWORD
  186. DoAllDelayedMoves(
  187. IN struct _SP_FILE_QUEUE *Queue
  188. );
  189. DWORD
  190. pSetupCompleteBackup(
  191. IN OUT HSPFILEQ FileQueue
  192. );
  193. VOID
  194. pSetupUnwindAll(
  195. IN struct _SP_FILE_QUEUE *Queue,
  196. IN BOOL Succeeded
  197. );
  198. VOID
  199. pSetupCleanupBackup(
  200. IN struct _SP_FILE_QUEUE *Queue
  201. );
  202. VOID
  203. RestoreRenamedOrBackedUpFile(
  204. IN PCTSTR TargetFilename,
  205. IN PCTSTR CurrentFilename,
  206. IN BOOL RenameFile,
  207. IN PSETUP_LOG_CONTEXT LogContext OPTIONAL
  208. );
  209. DWORD
  210. pSetupDoLastKnownGoodBackup(
  211. IN struct _SP_FILE_QUEUE *Queue, OPTIONAL
  212. IN PCTSTR TargetFilename,
  213. IN DWORD Flags,
  214. IN PSETUP_LOG_CONTEXT LogContext OPTIONAL
  215. );
  216. BOOL
  217. pSetupRestoreLastKnownGoodFile(
  218. IN PCTSTR TargetFilename,
  219. IN DWORD Flags,
  220. IN PSETUP_LOG_CONTEXT LogContext OPTIONAL
  221. );
  222. #define SP_LKG_FLAG_FORCECOPY 0x00000001 // if set, turns copy safety-guards off
  223. #define SP_LKG_FLAG_DELETEIFNEW 0x00000002 // if set, writes a delete entry for new files
  224. #define SP_LKG_FLAG_DELETEEXISTING 0x00000004 // if set, writes a delete entry for existing files
  225. #define SP_LKG_FLAG_DELETEOP 0x00000008 // if set, caller is deleting (or renaming) a file