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.

564 lines
16 KiB

  1. /*++
  2. Copyright (c) 1995-2000 Microsoft Corporation
  3. Module Name:
  4. fileq.h
  5. Abstract:
  6. Private header file for setup file queue routines.
  7. A setup file queue is a list of pending rename, delete,
  8. and copy operations.
  9. Author:
  10. Ted Miller (tedm) 15-Feb-1995
  11. Revision History:
  12. Jamie Hunter (jamiehun) 13-Jan-1998
  13. Added backup & un-windable copying
  14. Gabe Schaffer (t-gabes) 19-Jul-1998
  15. Added LogCotext to SP_FILE_QUEUE
  16. --*/
  17. //
  18. // Declare this forward reference here so structures below can use it
  19. // before it's defined.
  20. //
  21. struct _SP_FILE_QUEUE;
  22. struct _SP_FILE_QUEUE_NODE;
  23. //
  24. // Define structure that describes a source media in use
  25. // in a particular file queue.
  26. //
  27. typedef struct _SOURCE_MEDIA_INFO {
  28. struct _SOURCE_MEDIA_INFO *Next;
  29. //
  30. // String IDs for description and tagfile.
  31. //
  32. LONG Description;
  33. LONG DescriptionDisplayName; // case-sensitive form for display.
  34. LONG Tagfile; // Tagfile & Cabfile would be the same string
  35. LONG Cabfile; // unless an explicit cabfile has been given
  36. //
  37. // String ID for source root path
  38. //
  39. LONG SourceRootPath;
  40. //
  41. // Copy queue for this media.
  42. //
  43. struct _SP_FILE_QUEUE_NODE *CopyQueue;
  44. UINT CopyNodeCount;
  45. //
  46. // Flags for this source media descriptor
  47. //
  48. DWORD Flags;
  49. } SOURCE_MEDIA_INFO, *PSOURCE_MEDIA_INFO;
  50. //
  51. // Define valid flags for SOURCE_MEDIA_INFO.Flags
  52. //
  53. #define SMI_FLAG_NO_SOURCE_ROOT_PATH 0x1
  54. #define SMI_FLAG_USE_SVCPACK_SOURCE_ROOT_PATH 0x2
  55. #define SMI_FLAG_USE_LOCAL_SOURCE_CAB 0x4
  56. //
  57. // Define structure that describes a catalog, used for signing
  58. // and file verification.
  59. //
  60. typedef struct _SPQ_CATALOG_INFO {
  61. struct _SPQ_CATALOG_INFO *Next;
  62. //
  63. // String ID for original filename of the catalog file,
  64. // such as specified in CatalogFile= in the [Version] section
  65. // of an inf file.
  66. //
  67. // This field may be -1, which indicates no CatalogFile= line
  68. // was specified in the INF.
  69. //
  70. LONG CatalogFileFromInf;
  71. //
  72. // String ID for original filename of the catalog file specified by the
  73. // INF for an alternate platform (the alternate platform having been setup
  74. // by a call to SetupSetFileQueueAlternatePlatform). This field is only
  75. // valid when the containing file queue has the FQF_USE_ALT_PLATFORM flag
  76. // set.
  77. //
  78. // This field may be -1, which indicates that no CatalogFile= line was
  79. // specified in the INF (or at least not one that can be used given the
  80. // currently active alternate platform parameters).
  81. //
  82. LONG AltCatalogFileFromInf;
  83. //
  84. // Also, maintain a temporary storage for the new alternate catalog string
  85. // ID to be used while we're processing the catalog list, retrieving the
  86. // platform-specific entries associated with each INF. This is done so that
  87. // if we encounter an error part-way through (e.g, out-of-memory or couldn't
  88. // load INF), then we don't have to maintain a separate list in order to do
  89. // a rollback.
  90. //
  91. LONG AltCatalogFileFromInfPending;
  92. //
  93. // String ID for the full (source) path of the INF.
  94. //
  95. LONG InfFullPath;
  96. //
  97. // String ID for the source INF's original (simple) name (may be -1 if the
  98. // source INF's original name is the same as its current name.
  99. //
  100. LONG InfOriginalName;
  101. //
  102. // String ID for the INF's final resting place (i.e., its name in the INF
  103. // directory, unless it's been part of an alternate catalog install, in
  104. // which case it will be the same as InfFullPath). This value will be -1
  105. // until the catalog node has been processed by _SetupVerifyQueuedCatalogs.
  106. // After that, its value will be equal to InfFullPath if the INF was in the
  107. // Inf directory in the first place, or was part of an alternate catalog
  108. // installation. Otherwise, it'll be the string ID for the unique name we
  109. // used when copying the INF into the Inf directory.
  110. //
  111. LONG InfFinalPath;
  112. #if 0
  113. //
  114. // Pointer to media descriptor for first file that caused this
  115. // catalog node to be enqueued. This gives a pretty good indicator
  116. // of which media we expect the catalog file to be on.
  117. //
  118. PSOURCE_MEDIA_INFO SourceMediaInfo;
  119. #endif
  120. //
  121. // Error code indicating the cause of failure to validate the catalog.
  122. //
  123. DWORD VerificationFailureError;
  124. //
  125. // CATINFO_FLAG flags containing information about this catalog node such
  126. // as whether it is the 'primary device INF' for a device installation.
  127. //
  128. DWORD Flags;
  129. //
  130. // Full filepath of catalog file. This is the catalog file as
  131. // it's been installed on the system.
  132. //
  133. TCHAR CatalogFilenameOnSystem[MAX_PATH];
  134. } SPQ_CATALOG_INFO, *PSPQ_CATALOG_INFO;
  135. //
  136. // Catalog node flags.
  137. //
  138. #define CATINFO_FLAG_PRIMARY_DEVICE_INF 0x00000001 // primary device INF for a
  139. // device installation queue
  140. #define CATINFO_FLAG_NEWLY_COPIED 0x00000002 // indicates whether INF/CAT
  141. // were newly copied when
  142. // this catalog node was
  143. // verified.
  144. //
  145. // Define structure that describes a node in a file queue.
  146. //
  147. typedef struct _SP_FILE_QUEUE_NODE {
  148. struct _SP_FILE_QUEUE_NODE *Next;
  149. //
  150. // Operation: copy, delete, rename
  151. //
  152. UINT Operation;
  153. //
  154. // Copy:
  155. //
  156. // String ID for source root path
  157. // (such as F:\ or \\SERVER\SHARE\SUBDIR).
  158. //
  159. // Delete: unused
  160. // Rename: unused
  161. //
  162. LONG SourceRootPath;
  163. //
  164. // Copy:
  165. //
  166. // String ID for rest of the path (between the root and the filename).
  167. // Generally this is the directory specified for the source media
  168. // in [SourceDisksNames].
  169. //
  170. // Not always specified (-1 if not specified).
  171. //
  172. // Delete: unused
  173. //
  174. // Rename: source path of file to be renamed
  175. //
  176. LONG SourcePath;
  177. //
  178. // Copy: String ID for source filename (filename only, no path).
  179. // Delete: unused
  180. // Rename: source filename of file to be renamed. If not specified
  181. // SourcePath contains complete full path of file.
  182. //
  183. LONG SourceFilename;
  184. //
  185. // Copy: String ID for the target directory (no filename).
  186. // Delete: part 1 of the full path of the file to delete (ie, path part)
  187. // Rename: Target directory for file (ie, rename is actually a move).
  188. // If not specified rename is a rename only (TargetFilename
  189. // contains the new filename).
  190. //
  191. LONG TargetDirectory;
  192. //
  193. // Copy: String ID for the target filename (filename only, no path),
  194. // Delete: part 2 of the full path of the file to delete (ie, file part)
  195. // If not specified then TargetDirectory contains complete full path.
  196. // Rename: supplies new filename for rename/move operation. Filename part only.
  197. //
  198. LONG TargetFilename;
  199. //
  200. // Copy : String ID for Security Descriptor information
  201. // Delete: Unused
  202. // Rename: Unused
  203. LONG SecurityDesc;
  204. //
  205. // Copy: Information about the source media on which this file can be found.
  206. // Delete: unused
  207. // Rename: unused
  208. //
  209. PSOURCE_MEDIA_INFO SourceMediaInfo;
  210. //
  211. // Style flags for file operation
  212. //
  213. DWORD StyleFlags;
  214. //
  215. // Internal-use flags: In-use disposition, etc.
  216. //
  217. UINT InternalFlags;
  218. //
  219. // Pointer to catalog info for this file, used for file signing.
  220. // May be NULL.
  221. //
  222. PSPQ_CATALOG_INFO CatalogInfo;
  223. } SP_FILE_QUEUE_NODE, *PSP_FILE_QUEUE_NODE;
  224. //
  225. // Internal flags.
  226. //
  227. #define INUSE_IN_USE 0x00000001 // file was in use
  228. #define INUSE_INF_WANTS_REBOOT 0x00000002 // file was in use and inf file
  229. // want reboot if this file was in use
  230. #define IQF_PROCESSED 0x00000004 // queue node was already processed
  231. #define IQF_DELAYED_DELETE_OK 0x00000008 // Use delayed delete if delete fails
  232. #define IQF_MATCH 0x00000010 // Node matches current file in cabinet
  233. #define IQF_LAST_MATCH 0x00000020 // Node is last in chain of matches
  234. #define IQF_FROM_BAD_OEM_INF 0x00000040 // Copynode from invalid (w.r.t. codesigning) OEM INF
  235. #define IQF_ALLOW_UNSIGNED 0x00000080 // node is unsigned but allow installation
  236. // (w.r.t. system file protection)
  237. #define IQF_TARGET_PROTECTED 0x00000100 // node is replacing a system file
  238. #define ST_SCE_SET 0
  239. #define ST_SCE_DELETE 1
  240. #define ST_SCE_RENAME 2
  241. #define ST_SCE_UNWIND 3
  242. #define ST_SCE_SERVICES 4
  243. //
  244. // Define structure describing a setup file operation queue.
  245. //
  246. typedef struct _SP_FILE_QUEUE {
  247. //
  248. // We'll maintain separate lists internally for each type
  249. // of queued operation. Each source media has its own copy queue.
  250. //
  251. //
  252. PSP_FILE_QUEUE_NODE BackupQueue;
  253. PSP_FILE_QUEUE_NODE DeleteQueue;
  254. PSP_FILE_QUEUE_NODE RenameQueue;
  255. //
  256. // Number of nodes in the various queues.
  257. //
  258. UINT CopyNodeCount;
  259. UINT DeleteNodeCount;
  260. UINT RenameNodeCount;
  261. UINT BackupNodeCount;
  262. //
  263. // Pointer to first source media descriptor.
  264. //
  265. PSOURCE_MEDIA_INFO SourceMediaList;
  266. //
  267. // Number of source media descriptors.
  268. //
  269. UINT SourceMediaCount;
  270. //
  271. // Pointer to head of linked list of catalog descriptor structures.
  272. // There will be one item in this list for each catalog file
  273. // referenced in any file's (copy) queue node.
  274. //
  275. PSPQ_CATALOG_INFO CatalogList;
  276. //
  277. // Specifies what driver signing policy was in effect when this file queue
  278. // was created. This will have been retrieved from the registry, or from
  279. // the DS, if applicable. This field can take one of three values:
  280. //
  281. // DRIVERSIGN_NONE - silently succeed installation of unsigned/
  282. // incorrectly-signed files. A PSS log entry will
  283. // be generated, however (as it will for all 3 types)
  284. // DRIVERSIGN_WARNING - warn the user, but let them choose whether or not
  285. // they still want to install the problematic file
  286. // DRIVERSIGN_BLOCKING - do not allow the file to be installed
  287. //
  288. // Note: the use of the term "file" above refers generically to both
  289. // individual files and packages (i.e., INF/CAT/driver file combinations)
  290. //
  291. DWORD DriverSigningPolicy;
  292. //
  293. // Specifies the window handle that owns any UI dealing with driver signing.
  294. // This is filled in based on the Owner argument passed into
  295. // _SetupVerifyQueuedCatalogs.
  296. //
  297. HWND hWndDriverSigningUi;
  298. //
  299. // If this queue has been marked as a device install queue, store the
  300. // description of the device being installed in case we need to popup a
  301. // digital signature verification failure dialog.
  302. //
  303. // (This value may be -1)
  304. //
  305. LONG DeviceDescStringId;
  306. //
  307. // Structure that contains alternate platform information that was
  308. // associated with the queue via SetupSetFileQueueAlternatePlatform. This
  309. // embedded structure is only valid if the FQF_USE_ALT_PLATFORM flag is set.
  310. //
  311. SP_ALTPLATFORM_INFO_V2 AltPlatformInfo;
  312. //
  313. // String ID of override catalog file to use (typically, goes hand-in-hand
  314. // with an AltPlatformInfo). If no catalog override is in effect, this
  315. // string ID will be -1.
  316. //
  317. LONG AltCatalogFile;
  318. //
  319. // Pointer to platform info structure to be used for digital signature
  320. // verification when there is no AltPlatformInfo associated with this file
  321. // queue. This is used when certclas.inf identifies a range of valid OS
  322. // versions to be used when validating drivers of a particular device setup
  323. // class. This field may be NULL, indicating that certclas.inf didn't
  324. // specify such an override, or that the queue isn't related to device
  325. // installation at all.
  326. //
  327. // This pointer must be freed when the structure is destroyed.
  328. //
  329. PSP_ALTPLATFORM_INFO_V2 ValidationPlatform;
  330. //
  331. // String table that all data structures associated with
  332. // this queue make use of.
  333. //
  334. // (NOTE: Since there is no locking mechanism on the enclosing
  335. // SP_FILE_QUEUE structure, this StringTable must handle its own
  336. // synchronization. Therefore, this string table contains 'live'
  337. // locks, and must be accessed with the public versions (in spapip.h)
  338. // of the StringTable* APIs.)
  339. //
  340. PVOID StringTable;
  341. //
  342. // Maintain a lock refcount for user-supplied queues contained in device
  343. // information elements. This ensures that the queue can't be deleted as
  344. // long as its being referenced in at least one device installation parameter
  345. // block.
  346. //
  347. DWORD LockRefCount;
  348. //
  349. // Queue flags.
  350. //
  351. DWORD Flags;
  352. //
  353. // SIS-related fields.
  354. //
  355. HANDLE SisSourceHandle;
  356. PCTSTR SisSourceDirectory;
  357. //
  358. // Backup and unwind fields
  359. //
  360. LONG BackupInfID; // stringID (relative to StringTable) of Inf file associated with backup
  361. LONG BackupInstanceID;
  362. LONG BackupDisplayNameID;
  363. LONG BackupDeviceInstanceID;
  364. LONG BackupDeviceDescID;
  365. LONG BackupMfgID;
  366. LONG BackupProviderNameID;
  367. LONG RestorePathID; // restore-point
  368. PVOID TargetLookupTable; // all entries here have associated data
  369. PSP_UNWIND_NODE UnwindQueue; // order of restore and file info
  370. PSP_DELAYMOVE_NODE DelayMoveQueue; // order of delayed renames
  371. PSP_DELAYMOVE_NODE DelayMoveQueueTail; // last of delayed renames
  372. //
  373. // Signature used for a primitive form of validation.
  374. //
  375. DWORD Signature;
  376. //
  377. // Pointer to log context for error logging
  378. //
  379. PSETUP_LOG_CONTEXT LogContext;
  380. //
  381. // crypto context handle acquired during digital signature verification
  382. // (starts out as NULL, if non-NULL when freeing queue, must release via
  383. // CryptCATAdminReleaseContext)
  384. //
  385. HCATADMIN hCatAdmin;
  386. //
  387. // handle to bad driver database acquired during check for blocked driver
  388. // (starts out as NULL, if non-NULL when freeing queue, must release via
  389. // SdbReleaseDatabase)
  390. //
  391. HSDB hSDBDrvMain;
  392. } SP_FILE_QUEUE, *PSP_FILE_QUEUE;
  393. #define SP_FILE_QUEUE_SIG 0xc78e1098
  394. //
  395. // Internal-use queue commit routine.
  396. //
  397. BOOL
  398. _SetupCommitFileQueue(
  399. IN HWND Owner, OPTIONAL
  400. IN HSPFILEQ QueueHandle,
  401. IN PVOID MsgHandler,
  402. IN PVOID Context,
  403. IN BOOL IsMsgHandlerNativeCharWidth
  404. );
  405. //
  406. // Internal-use, add a single copy to the queue
  407. //
  408. BOOL
  409. pSetupQueueSingleCopy(
  410. IN HSPFILEQ QueueHandle,
  411. IN HINF InfHandle,
  412. IN HINF ListInfHandle, OPTIONAL
  413. IN PCTSTR SectionName, OPTIONAL
  414. IN PCTSTR SourceRootPath,
  415. IN PCTSTR SourceFilename,
  416. IN PCTSTR TargetFilename,
  417. IN DWORD CopyStyle,
  418. IN PCTSTR SecurityDescriptor,
  419. IN PCTSTR CacheName
  420. );
  421. //
  422. // Internal-use
  423. //
  424. PTSTR
  425. pSetupFormFullPath(
  426. IN PVOID StringTable,
  427. IN LONG PathPart1,
  428. IN LONG PathPart2, OPTIONAL
  429. IN LONG PathPart3 OPTIONAL
  430. );
  431. DWORD
  432. pGetInfOriginalNameAndCatalogFile(
  433. IN PLOADED_INF Inf, OPTIONAL
  434. IN LPCTSTR CurrentName, OPTIONAL
  435. OUT PBOOL DifferentName, OPTIONAL
  436. OUT LPTSTR OriginalName, OPTIONAL
  437. IN DWORD OriginalNameSize,
  438. OUT LPTSTR OriginalCatalogName, OPTIONAL
  439. IN DWORD OriginalCatalogNameSize,
  440. IN PSP_ALTPLATFORM_INFO_V2 AltPlatformInfo OPTIONAL
  441. );
  442. DWORD
  443. _SetupVerifyQueuedCatalogs(
  444. IN HWND Owner,
  445. IN PSP_FILE_QUEUE Queue,
  446. IN DWORD Flags,
  447. OUT PTSTR DeviceInfFinalName, OPTIONAL
  448. OUT PBOOL DeviceInfNewlyCopied OPTIONAL
  449. );
  450. BOOL
  451. pSetupProtectedRenamesFlag(
  452. BOOL bSet
  453. );
  454. #ifdef UNICODE
  455. DWORD
  456. pSetupCallSCE(
  457. IN DWORD Operation,
  458. IN PCWSTR FullName,
  459. IN PSP_FILE_QUEUE Queue,
  460. IN PCWSTR String1,
  461. IN DWORD Index1,
  462. IN PSECURITY_DESCRIPTOR SecDesc OPTIONAL
  463. );
  464. #endif
  465. #define VERCAT_INSTALL_INF_AND_CAT 0x00000001
  466. #define VERCAT_NO_PROMPT_ON_ERROR 0x00000002
  467. #define VERCAT_PRIMARY_DEVICE_INF_FROM_INET 0x00000004
  468. #define FILEOP_INTERNAL_FAILED ((UINT)(-1)) // not a valid fileop, GetLastError has status
  469. #define FILEOP_RETURN_STATUS ((UINT)(-2)) // convert error to return value