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.

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