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.

1123 lines
34 KiB

  1. /*++
  2. Copyright (c) 1998 Microsoft Corporation
  3. Module Name:
  4. fileops.h
  5. Abstract:
  6. Declares the file operation data structures and macros that access
  7. the file operations. Every operation on a file is recorded using
  8. routines declared here. The file op code keeps conflicting operations
  9. from being set on a file.
  10. See common\memdb\fileops.c for implementation details.
  11. Author:
  12. Jim Schmidt (jimschm) 23-Sep-1998 (complete redesign)
  13. Revision History:
  14. mvander 26-Map-1999 Added MODULESTATUS defines
  15. --*/
  16. #pragma once
  17. /*++
  18. Macro Expansion List Description:
  19. PATH_OPERATIONS defines a list of characteristics for operations that
  20. can be performed on a file.
  21. Some operation combinations are prohibited. See the code in fileops.c
  22. for a list of prohibited combinations.
  23. NOTES: - THERE CAN ONLY BE A MAX OF 16 DEFINITIONS!!
  24. - THE BITS MUST BE SORTED!!
  25. - CANNOT HAVE UNUSED BITS INBETWEEN OPERATIONS!!
  26. Line Syntax:
  27. DEFMAC(Bit, Name, CooperativeOperations, MaxProperties)
  28. Arguments:
  29. Bit - Specifies the single bit (MUST FIT IN 24 BITS), in sorted order
  30. Name - Specifies the name of the operation constant (will appear in
  31. OPERATION enum type)
  32. MemDbName - Specifies the name as stored in memdb
  33. MaxProperties - Specifies 0, 1 or UNLIMITED, indicating the number of
  34. properties that can be applied to the operation
  35. Variables and Types Generated From List:
  36. OPERATION
  37. g_OperationFlags
  38. --*/
  39. #define PATH_OPERATIONS \
  40. DEFMAC(0x0001, OPERATION_FILE_DELETE, Op01, 0) \
  41. DEFMAC(0x0002, OPERATION_FILE_DELETE_EXTERNAL, Op02, 0) \
  42. DEFMAC(0x0004, OPERATION_FILE_MOVE, Op03, 1) \
  43. DEFMAC(0x0008, OPERATION_FILE_COPY, Op04, UNLIMITED) \
  44. DEFMAC(0x0010, OPERATION_FILE_MOVE_EXTERNAL, Op05, 1) \
  45. DEFMAC(0x0020, OPERATION_CLEANUP, Op06, 0) \
  46. DEFMAC(0x0040, OPERATION_MIGDLL_HANDLED, Op07, 0) \
  47. DEFMAC(0x0080, OPERATION_CREATE_FILE, Op08, 0) \
  48. DEFMAC(0x0100, OPERATION_SHORT_FILE_NAME, Op09, 1) \
  49. DEFMAC(0x0200, OPERATION_LINK_EDIT, Op10, UNLIMITED) \
  50. DEFMAC(0x0400, OPERATION_SHELL_FOLDER, Op11, UNLIMITED) \
  51. DEFMAC(0x0800, OPERATION_TEMP_PATH, Op12, 2) \
  52. DEFMAC(0x1000, OPERATION_FILE_MOVE_BY_NT, Op13, 1) \
  53. DEFMAC(0x2000, OPERATION_FILE_MOVE_SHELL_FOLDER, Op14, 1) \
  54. DEFMAC(0x4000, OPERATION_PRESERVED_DIR, Op15, 0) \
  55. DEFMAC(0x8000, OPERATION_OS_FILE, Op16, 0) \
  56. DEFMAC(0x010000, OPERATION_FILE_DISABLED, Op17, 0) \
  57. DEFMAC(0x020000, OPERATION_LINK_STUB, Op18, UNLIMITED) \
  58. DEFMAC(0x040000, OPERATION_LONG_FILE_NAME, Op19, 0) \
  59. DEFMAC(0x080000, OPERATION_CHANGE_EXTERNAL, Op20, 0) \
  60. DEFMAC(0x100000, OPERATION_NUL_3, Opn3, 0) \
  61. DEFMAC(0x200000, OPERATION_NUL_2, Opn2, 0) \
  62. DEFMAC(0x400000, OPERATION_NUL_1, Opn1, 0) \
  63. //
  64. // Combined constants
  65. //
  66. #define ALL_MOVE_OPERATIONS (OPERATION_FILE_MOVE|OPERATION_FILE_MOVE_EXTERNAL|OPERATION_FILE_MOVE_BY_NT|OPERATION_FILE_MOVE_SHELL_FOLDER)
  67. #define ALL_COPY_OPERATIONS (OPERATION_FILE_COPY)
  68. #define ALL_DELETE_OPERATIONS (OPERATION_FILE_DELETE|OPERATION_CLEANUP|OPERATION_FILE_DELETE_EXTERNAL)
  69. #define ALL_OPERATIONS (0xffffff)
  70. #define ALL_DEST_CHANGE_OPERATIONS (ALL_MOVE_OPERATIONS|ALL_COPY_OPERATIONS)
  71. #define ALL_CHANGE_OPERATIONS (OPERATION_FILE_DISABLED|OPERATION_LINK_EDIT|OPERATION_LINK_STUB|OPERATION_CREATE_FILE|ALL_DEST_CHANGE_OPERATIONS|ALL_DELETE_OPERATIONS|OPERATION_CHANGE_EXTERNAL)
  72. #define ALL_CONTENT_CHANGE_OPERATIONS (ALL_DELETE_OPERATIONS|OPERATION_MIGDLL_HANDLED|OPERATION_CREATE_FILE|OPERATION_LINK_EDIT|OPERATION_LINK_STUB|OPERATION_FILE_DISABLED|OPERATION_CHANGE_EXTERNAL)
  73. //
  74. // Declare OPERATION type
  75. //
  76. #define DEFMAC(bit,name,memdbname,maxattribs) name = bit,
  77. typedef enum {
  78. PATH_OPERATIONS
  79. LAST_OPERATION
  80. } OPERATION;
  81. #undef DEFMAC
  82. #define INVALID_SEQUENCER 0
  83. //
  84. // File status flags returned by GetFileInfoOnNt and GetFileStatusOnNt
  85. //
  86. #define FILESTATUS_UNCHANGED 0x00
  87. #define FILESTATUS_DELETED 0x01
  88. #define FILESTATUS_MOVED 0x02
  89. #define FILESTATUS_REPLACED 0x04
  90. #define FILESTATUS_NTINSTALLED 0x08
  91. #define FILESTATUS_BACKUP 0x10
  92. //
  93. // Backup flags (for CleanOut memdb category)
  94. //
  95. #define BACKUP_FILE 0
  96. #define BACKUP_SUBDIRECTORY_FILES 1
  97. #define BACKUP_SUBDIRECTORY_TREE 2
  98. #define BACKUP_AND_CLEAN_TREE 3
  99. #define BACKUP_AND_CLEAN_SUBDIR 4
  100. //
  101. // When a file is announced, it can be announced with one of the following.
  102. //
  103. #define ACT_UNKNOWN 0
  104. #define ACT_REINSTALL 1 // application that needs to be reinstalled
  105. #define ACT_MINORPROBLEMS 2 // application with minor problems
  106. #define ACT_INCOMPATIBLE 3 // incompatible application - migdb based
  107. #define ACT_INC_SAFETY 4 // items removed for safety
  108. #define ACT_INC_NOBADAPPS 5 // incompatible application - no CheckBadApps entry
  109. #define ACT_REINSTALL_BLOCK 6 // application that needs to be reinstalled (highly suggested)
  110. #define ACT_INC_PREINSTUTIL 7 // incompatible preinstalled utility
  111. #define ACT_INC_SIMILAROSFUNC 8 // incompatible utility but NT has similar functionality
  112. #define ACT_INC_IHVUTIL 9 // incompatible hardware accessory
  113. #define USF_9X TEXT("9X")
  114. #define USF_9XA "9X"
  115. #define USF_9XW L"9X"
  116. #define USF_NT TEXT("NT")
  117. #define USF_NTA "NT"
  118. #define USF_NTW L"NT"
  119. //
  120. // Module status for use with MEMDB_CATEGORY_MODULE_CHECK
  121. //
  122. #define MODULESTATUS_NT_MODULE 0
  123. #define MODULESTATUS_CHECKED 1
  124. #define MODULESTATUS_CHECKING 2
  125. #define MODULESTATUS_UNCHECKED 3
  126. #define MODULESTATUS_BAD 4
  127. #define MODULESTATUS_FILENOTFOUND 5
  128. //
  129. // Enum types
  130. //
  131. typedef struct {
  132. // External members
  133. CHAR Path[MAX_MBCHAR_PATH];
  134. UINT Sequencer;
  135. // Internal members
  136. MEMDB_ENUMW MemDbEnum;
  137. } FILEOP_ENUMA, *PFILEOP_ENUMA;
  138. typedef struct {
  139. // External members
  140. WCHAR Path[MAX_WCHAR_PATH];
  141. UINT Sequencer;
  142. // Internal members
  143. MEMDB_ENUMW MemDbEnum;
  144. } FILEOP_ENUMW, *PFILEOP_ENUMW;
  145. typedef struct {
  146. // External members
  147. CHAR Property[MEMDB_MAX * 2];
  148. CHAR PropertyName[MEMDB_MAX * 2];
  149. // Internal members
  150. MEMDB_ENUMW MemDbEnum;
  151. } FILEOP_PROP_ENUMA, *PFILEOP_PROP_ENUMA;
  152. typedef struct {
  153. // External members
  154. WCHAR Property[MEMDB_MAX];
  155. WCHAR PropertyName[MEMDB_MAX];
  156. // Internal members
  157. MEMDB_ENUMW MemDbEnum;
  158. } FILEOP_PROP_ENUMW, *PFILEOP_PROP_ENUMW;
  159. typedef struct {
  160. // External
  161. PCWSTR Path;
  162. UINT Sequencer;
  163. PCWSTR Property;
  164. UINT PropertyNum;
  165. OPERATION CurrentOperation;
  166. BOOL PropertyValid;
  167. // Internal
  168. UINT State;
  169. DWORD Operations;
  170. UINT OperationNum;
  171. WCHAR FileSpec[MAX_WCHAR_PATH];
  172. FILEOP_ENUMW OpEnum;
  173. FILEOP_PROP_ENUMW PropEnum;
  174. } ALL_FILEOPS_ENUMW, *PALL_FILEOPS_ENUMW;
  175. typedef struct {
  176. // External
  177. CHAR Path[MAX_MBCHAR_PATH];
  178. UINT Sequencer;
  179. CHAR Property[MEMDB_MAX * 2];
  180. UINT PropertyNum;
  181. OPERATION CurrentOperation;
  182. BOOL PropertyValid;
  183. // Internal
  184. ALL_FILEOPS_ENUMW Enum;
  185. } ALL_FILEOPS_ENUMA, *PALL_FILEOPS_ENUMA;
  186. typedef struct _SHELLFOLDER_ENUMA {
  187. CHAR ShellFolder[MEMDB_MAX];
  188. PCSTR UserFixedName;
  189. PCSTR Side;
  190. MEMDB_ENUMA e;
  191. } SHELLFOLDER_ENUMA, *PSHELLFOLDER_ENUMA;
  192. typedef struct _SHELLFOLDER_ENUMW {
  193. WCHAR ShellFolder[MEMDB_MAX];
  194. PCWSTR UserFixedName;
  195. PCWSTR Side;
  196. MEMDB_ENUMW e;
  197. } SHELLFOLDER_ENUMW, *PSHELLFOLDER_ENUMW;
  198. typedef struct {
  199. CHAR SrcFile[MAX_MBCHAR_PATH];
  200. CHAR DestFile[MAX_MBCHAR_PATH];
  201. ALL_FILEOPS_ENUMA e;
  202. } FILERELOC_ENUMA, *PFILERELOC_ENUMA;
  203. //
  204. // Generalized file operations
  205. //
  206. VOID
  207. InitOperationTable (
  208. VOID
  209. );
  210. UINT
  211. AddOperationToPathA (
  212. IN PCSTR FileSpec,
  213. IN OPERATION Operation
  214. );
  215. UINT
  216. AddOperationToPathW (
  217. IN PCWSTR FileSpec,
  218. IN OPERATION Operation
  219. );
  220. BOOL
  221. AddPropertyToPathExA (
  222. IN UINT Sequencer,
  223. IN OPERATION Operation,
  224. IN PCSTR Property,
  225. IN PCSTR AlternateDataSection OPTIONAL
  226. );
  227. #define AddPropertyToPathA(seq,op,attr) AddPropertyToPathExA(seq,op,attr,NULL)
  228. BOOL
  229. AddPropertyToPathExW (
  230. IN UINT Sequencer,
  231. IN OPERATION Operation,
  232. IN PCWSTR Property,
  233. IN PCWSTR AlternateDataSection OPTIONAL
  234. );
  235. #define AddPropertyToPathW(seq,op,attr) AddPropertyToPathExW(seq,op,attr,NULL)
  236. BOOL
  237. AssociatePropertyWithPathA (
  238. IN PCSTR FileSpec,
  239. IN OPERATION Operation,
  240. IN PCSTR Property
  241. );
  242. BOOL
  243. AssociatePropertyWithPathW (
  244. IN PCWSTR FileSpec,
  245. IN OPERATION Operation,
  246. IN PCWSTR Property
  247. );
  248. UINT
  249. GetSequencerFromPathA (
  250. IN PCSTR FileSpec
  251. );
  252. UINT
  253. GetSequencerFromPathW (
  254. IN PCWSTR FileSpec
  255. );
  256. BOOL
  257. GetPathFromSequencerA (
  258. IN UINT Sequencer,
  259. OUT PSTR PathBuf
  260. );
  261. BOOL
  262. GetPathFromSequencerW (
  263. IN UINT Sequencer,
  264. OUT PWSTR PathBuf
  265. );
  266. DWORD
  267. GetOperationsOnPathA (
  268. IN PCSTR FileSpec
  269. );
  270. DWORD
  271. GetOperationsOnPathW (
  272. IN PCWSTR FileSpec
  273. );
  274. VOID
  275. RemoveOperationsFromSequencer (
  276. IN UINT Sequencer,
  277. IN DWORD Operations
  278. );
  279. VOID
  280. RemoveOperationsFromPathA (
  281. IN PCSTR FileSpec,
  282. IN DWORD Operations
  283. );
  284. #define RemoveAllOperationsFromPathA(file) RemoveOperationsFromPathA(file,ALL_OPERATIONS)
  285. VOID
  286. RemoveOperationsFromPathW (
  287. IN PCWSTR FileSpec,
  288. IN DWORD Operations
  289. );
  290. #define RemoveAllOperationsFromPathW(file) RemoveOperationsFromPathW(file,ALL_OPERATIONS)
  291. UINT
  292. ForceOperationOnPathA (
  293. IN PCSTR FileSpec,
  294. IN OPERATION Operation
  295. );
  296. UINT
  297. ForceOperationOnPathW (
  298. IN PCWSTR FileSpec,
  299. IN OPERATION Operation
  300. );
  301. BOOL
  302. IsFileMarkedForOperationA (
  303. IN PCSTR FileSpec,
  304. IN DWORD Operations
  305. );
  306. BOOL
  307. IsFileMarkedForOperationW (
  308. IN PCWSTR FileSpec,
  309. IN DWORD Operations
  310. );
  311. BOOL
  312. IsFileMarkedInDataA (
  313. IN PCSTR FileSpec
  314. );
  315. BOOL
  316. IsFileMarkedInDataW (
  317. IN PCWSTR FileSpec
  318. );
  319. DWORD
  320. GetPathPropertyOffset (
  321. IN UINT Sequencer,
  322. IN OPERATION Operation,
  323. IN DWORD Property
  324. );
  325. BOOL
  326. GetPathPropertyA (
  327. IN PCSTR FileSpec,
  328. IN DWORD Operations,
  329. IN DWORD Property,
  330. OUT PSTR PropertyBuf OPTIONAL // MEMDB_MAX
  331. );
  332. BOOL
  333. GetPathPropertyW (
  334. IN PCWSTR FileSpec,
  335. IN DWORD Operations,
  336. IN DWORD Property,
  337. OUT PWSTR PropertyBuf OPTIONAL // MEMDB_MAX
  338. );
  339. BOOL
  340. EnumFirstPathInOperationA (
  341. OUT PFILEOP_ENUMA EnumPtr,
  342. IN OPERATION Operation
  343. );
  344. BOOL
  345. EnumFirstPathInOperationW (
  346. OUT PFILEOP_ENUMW EnumPtr,
  347. IN OPERATION Operation
  348. );
  349. BOOL
  350. EnumNextPathInOperationA (
  351. IN OUT PFILEOP_ENUMA EnumPtr
  352. );
  353. BOOL
  354. EnumNextPathInOperationW (
  355. IN OUT PFILEOP_ENUMW EnumPtr
  356. );
  357. BOOL
  358. EnumFirstFileOpPropertyA (
  359. OUT PFILEOP_PROP_ENUMA EnumPtr,
  360. IN UINT Sequencer,
  361. IN OPERATION Operation
  362. );
  363. BOOL
  364. EnumFirstFileOpPropertyW (
  365. OUT PFILEOP_PROP_ENUMW EnumPtr,
  366. IN UINT Sequencer,
  367. IN OPERATION Operation
  368. );
  369. BOOL
  370. EnumNextFileOpPropertyA (
  371. IN OUT PFILEOP_PROP_ENUMA EnumPtr
  372. );
  373. BOOL
  374. EnumNextFileOpPropertyW (
  375. IN OUT PFILEOP_PROP_ENUMW EnumPtr
  376. );
  377. BOOL
  378. EnumFirstFileOpA (
  379. OUT PALL_FILEOPS_ENUMA EnumPtr,
  380. IN DWORD Operations,
  381. IN PCSTR FileSpec OPTIONAL
  382. );
  383. BOOL
  384. EnumFirstFileOpW (
  385. OUT PALL_FILEOPS_ENUMW EnumPtr,
  386. IN DWORD Operations,
  387. IN PCWSTR FileSpec OPTIONAL
  388. );
  389. BOOL
  390. EnumNextFileOpA (
  391. IN OUT PALL_FILEOPS_ENUMA EnumPtr
  392. );
  393. BOOL
  394. EnumNextFileOpW (
  395. IN OUT PALL_FILEOPS_ENUMW EnumPtr
  396. );
  397. BOOL
  398. TestPathsForOperationsA (
  399. IN PCSTR BaseFileSpec,
  400. IN DWORD OperationsToFind
  401. );
  402. BOOL
  403. TestPathsForOperationsW (
  404. IN PCWSTR BaseFileSpec,
  405. IN DWORD OperationsToFind
  406. );
  407. BOOL
  408. IsFileMarkedForAnnounceA (
  409. IN PCSTR FileSpec
  410. );
  411. BOOL
  412. IsFileMarkedAsKnownGoodA (
  413. IN PCSTR FileSpec
  414. );
  415. BOOL
  416. IsFileMarkedForAnnounceW (
  417. IN PCWSTR FileSpec
  418. );
  419. DWORD
  420. GetFileAnnouncementA (
  421. IN PCSTR FileSpec
  422. );
  423. DWORD
  424. GetFileAnnouncementW (
  425. IN PCWSTR FileSpec
  426. );
  427. DWORD
  428. GetFileAnnouncementContextA (
  429. IN PCSTR FileSpec
  430. );
  431. DWORD
  432. GetFileAnnouncementContextW (
  433. IN PCWSTR FileSpec
  434. );
  435. BOOL
  436. IsFileProvidedByNtA (
  437. IN PCSTR FileName
  438. );
  439. BOOL
  440. IsFileProvidedByNtW (
  441. IN PCWSTR FileName
  442. );
  443. BOOL
  444. GetNewPathForFileA (
  445. IN PCSTR SrcFileSpec,
  446. OUT PSTR NewPath
  447. );
  448. BOOL
  449. GetNewPathForFileW (
  450. IN PCWSTR SrcFileSpec,
  451. OUT PWSTR NewPath
  452. );
  453. BOOL
  454. AnnounceFileInReportA (
  455. IN PCSTR SrcFileSpec,
  456. IN DWORD ContextPtr,
  457. IN DWORD Action
  458. );
  459. BOOL
  460. MarkFileAsKnownGoodA (
  461. IN PCSTR SrcFileSpec
  462. );
  463. BOOL
  464. AddCompatibleShellA (
  465. IN PCSTR SrcFileSpec,
  466. IN DWORD ContextPtr
  467. );
  468. BOOL
  469. AddCompatibleRunKeyA (
  470. IN PCSTR SrcFileSpec,
  471. IN DWORD ContextPtr
  472. );
  473. BOOL
  474. AddCompatibleDosA (
  475. IN PCSTR SrcFileSpec,
  476. IN DWORD ContextPtr
  477. );
  478. BOOL
  479. AddControlPanelAppletA (
  480. IN PCSTR FileSpec,
  481. IN DWORD ContextPtr, OPTIONAL
  482. IN DWORD Action
  483. );
  484. BOOL
  485. AddCompatibleHlpA (
  486. IN PCSTR SrcFileSpec,
  487. IN DWORD ContextPtr
  488. );
  489. BOOL
  490. MarkFileForTemporaryMoveExA (
  491. IN PCSTR SrcFileSpec,
  492. IN PCSTR FinalDest,
  493. IN PCSTR TempSpec,
  494. IN BOOL TempSpecIsFile
  495. );
  496. #define MarkFileForTemporaryMoveA(s,d,t) MarkFileForTemporaryMoveExA(s,d,t,FALSE)
  497. PCSTR
  498. GetTemporaryLocationForFileA (
  499. IN PCSTR SourceFile
  500. );
  501. PCWSTR
  502. GetTemporaryLocationForFileW (
  503. IN PCWSTR SourceFile
  504. );
  505. BOOL
  506. MarkHiveForTemporaryMoveA (
  507. IN PCSTR HivePath,
  508. IN PCSTR TempDir,
  509. IN PCSTR UserName,
  510. IN BOOL DefaultHives,
  511. IN BOOL CreateOnly
  512. );
  513. VOID
  514. ComputeTemporaryPathA (
  515. IN PCSTR SourcePath,
  516. IN PCSTR SourcePrefix, OPTIONAL
  517. IN PCSTR TempPrefix, OPTIONAL
  518. IN PCSTR SetupTempDir,
  519. OUT PSTR TempPath
  520. );
  521. VOID
  522. MarkShellFolderForMoveA (
  523. IN PCSTR SrcPath,
  524. IN PCSTR TempPath
  525. );
  526. BOOL
  527. FileIsProvidedByNtA (
  528. IN PCSTR FullPath,
  529. IN PCSTR FileName,
  530. IN DWORD UserFlags
  531. );
  532. BOOL
  533. DeclareTemporaryFileA (
  534. IN PCSTR FileSpec
  535. );
  536. BOOL
  537. DeclareTemporaryFileW (
  538. IN PCWSTR FileSpec
  539. );
  540. BOOL
  541. EnumFirstFileRelocA (
  542. OUT PFILERELOC_ENUMA EnumPtr,
  543. IN PCSTR FileSpec OPTIONAL
  544. );
  545. BOOL
  546. EnumNextFileRelocA (
  547. IN OUT PFILERELOC_ENUMA EnumPtr
  548. );
  549. BOOL
  550. GetNtFilePathA (
  551. IN PCSTR FileName,
  552. OUT PSTR FullPath
  553. );
  554. BOOL
  555. GetNtFilePathW (
  556. IN PCWSTR FileName,
  557. OUT PWSTR FullPath
  558. );
  559. DWORD
  560. GetFileInfoOnNtA (
  561. IN PCSTR FileName,
  562. OUT PSTR NewFileName, // optional
  563. IN UINT BufferSize // required if NewFileName is specified, buffer size in chars
  564. );
  565. DWORD
  566. GetFileInfoOnNtW (
  567. IN PCWSTR FileName,
  568. OUT PWSTR NewFileName, // optional
  569. IN UINT BufferSize // required if NewFileName is specified, buffer size in chars
  570. );
  571. DWORD
  572. GetFileStatusOnNtA (
  573. IN PCSTR FileName
  574. );
  575. DWORD
  576. GetFileStatusOnNtW (
  577. IN PCWSTR FileName
  578. );
  579. PSTR
  580. GetPathStringOnNtA (
  581. IN PCSTR FileName
  582. );
  583. PWSTR
  584. GetPathStringOnNtW (
  585. IN PCWSTR FileName
  586. );
  587. PCWSTR
  588. SetCurrentUserW (
  589. IN PCWSTR User
  590. );
  591. PCSTR
  592. ExtractArgZeroExA (
  593. IN PCSTR CmdLine,
  594. OUT PSTR Buffer,
  595. IN PCSTR TerminatingChars, OPTIONAL
  596. IN BOOL KeepQuotes
  597. );
  598. #define ExtractArgZeroA(cmdline,buf) ExtractArgZeroExA(cmdline,buf,NULL,TRUE)
  599. PCWSTR
  600. ExtractArgZeroExW (
  601. IN PCWSTR CmdLine,
  602. OUT PWSTR Buffer,
  603. IN PCWSTR TerminatingChars, OPTIONAL
  604. IN BOOL KeepQuotes
  605. );
  606. #define ExtractArgZeroW(cmdline,buf) ExtractArgZeroExW(cmdline,buf,NULL,TRUE)
  607. BOOL
  608. CanSetOperationA (
  609. IN PCSTR FileSpec,
  610. IN OPERATION Operation
  611. );
  612. BOOL
  613. CanSetOperationW (
  614. IN PCWSTR FileSpec,
  615. IN OPERATION Operation
  616. );
  617. PCSTR
  618. GetSourceFileLongNameA (
  619. IN PCSTR ShortName
  620. );
  621. PCWSTR
  622. GetSourceFileLongNameW (
  623. IN PCWSTR ShortName
  624. );
  625. BOOL
  626. WriteBackupFilesA (
  627. IN BOOL Win9xSide,
  628. IN PCSTR TempDir,
  629. OUT ULARGE_INTEGER * OutAmountOfSpaceIfCompressed, OPTIONAL
  630. OUT ULARGE_INTEGER * OutAmountOfSpace, OPTIONAL
  631. IN INT CompressionFactor, OPTIONAL
  632. IN INT BootCabImagePadding, OPTIONAL
  633. OUT ULARGE_INTEGER * OutAmountOfSpaceForDelFiles, OPTIONAL
  634. OUT ULARGE_INTEGER * OutAmountOfSpaceClusterAligned OPTIONAL
  635. );
  636. BOOL
  637. WriteHashTableToFileW (
  638. IN HANDLE File,
  639. IN HASHTABLE FileTable
  640. );
  641. BOOL
  642. IsDirEmptyW(
  643. IN PCWSTR DirPathPtr
  644. );
  645. BOOL
  646. IsDirEmptyA(
  647. IN PCSTR DirPathPtr
  648. );
  649. VOID
  650. AddDirPathToEmptyDirsCategoryA(
  651. IN PCSTR DirPathPtr,
  652. IN BOOL AddParentDirIfFile, OPTIONAL
  653. IN BOOL AddParentDirIfFileExist OPTIONAL
  654. );
  655. VOID
  656. AddDirPathToEmptyDirsCategoryW(
  657. IN PCWSTR DirPathPtr,
  658. IN BOOL AddParentDirIfFile, OPTIONAL
  659. IN BOOL AddParentDirIfFileExist OPTIONAL
  660. );
  661. //
  662. // Wrapper macros
  663. //
  664. #define IsFileMarkedForPreDeleteA(file) IsFileMarkedForOperationA(file, OPERATION_FILE_DELETE)
  665. #define IsFileMarkedForPreDeleteW(file) IsFileMarkedForOperationW(file, OPERATION_FILE_DELETE)
  666. #define IsFileMarkedForPostDeleteA(file) IsFileMarkedForOperationA(file, OPERATION_CLEANUP)
  667. #define IsFileMarkedForPostDeleteW(file) IsFileMarkedForOperationW(file, OPERATION_CLEANUP)
  668. #define IsFileMarkedForDeleteA(file) IsFileMarkedForOperationA(file, ALL_DELETE_OPERATIONS)
  669. #define IsFileMarkedForDeleteW(file) IsFileMarkedForOperationW(file, ALL_DELETE_OPERATIONS)
  670. #define IsFileMarkedAsDestA(file) IsFileMarkedInDataA(file)
  671. #define IsFileMarkedAsDestW(file) IsFileMarkedInDataW(file)
  672. #define IsFileMarkedAsCopyA(file) IsFileMarkedForOperationA(file, OPERATION_FILE_COPY)
  673. #define IsFileMarkedAsCopyW(file) IsFileMarkedForOperationW(file, OPERATION_FILE_COPY)
  674. #define IsFileMarkedForMoveA(file) IsFileMarkedForOperationA(file, ALL_MOVE_OPERATIONS)
  675. #define IsFileMarkedForMoveW(file) IsFileMarkedForOperationW(file, ALL_MOVE_OPERATIONS)
  676. #define IsFileMarkedAsHandledA(file) IsFileMarkedForOperationA(file, OPERATION_MIGDLL_HANDLED)
  677. #define IsFileMarkedAsHandledW(file) IsFileMarkedForOperationW(file, OPERATION_MIGDLL_HANDLED)
  678. #define IsFileMarkedForChangeA(file) IsFileMarkedForOperationA(file, ALL_OPERATIONS)
  679. #define IsFileMarkedForChangeW(file) IsFileMarkedForOperationW(file, ALL_OPERATIONS)
  680. #define IsFileMarkedForCreationA(file) IsFileMarkedForOperationA(file, OPERATION_CREATE_FILE)
  681. #define IsFileMarkedForCreationW(file) IsFileMarkedForOperationW(file, OPERATION_CREATE_FILE)
  682. #define IsDirectoryMarkedAsEmptyA(file) IsFileMarkedForOperationA(file, OPERATION_PRESERVED_DIR)
  683. #define IsDirectoryMarkedAsEmptyW(file) IsFileMarkedForOperationW(file, OPERATION_PRESERVED_DIR)
  684. #define IsFileMarkedAsOsFileA(file) IsFileMarkedForOperationA(file, OPERATION_OS_FILE)
  685. #define IsFileMarkedAsOsFileW(file) IsFileMarkedForOperationW(file, OPERATION_OS_FILE)
  686. #define IsFileDisabledA(file) IsFileMarkedForOperationA(file, OPERATION_FILE_DISABLED)
  687. #define IsFileDisabledW(file) IsFileMarkedForOperationW(file, OPERATION_FILE_DISABLED)
  688. #define IsFileMarkedForBackupA(file) IsFileMarkedForOperationA(file, OPERATION_CHANGE_EXTERNAL)
  689. #define IsFileMarkedForBackupW(file) IsFileMarkedForOperationW(file, OPERATION_CHANGE_EXTERNAL)
  690. #define MarkFileForDeleteA(file) (AddOperationToPathA(file, OPERATION_FILE_DELETE) != INVALID_SEQUENCER)
  691. #define MarkFileForExternalDeleteA(file) (AddOperationToPathA(file, OPERATION_FILE_DELETE_EXTERNAL) != INVALID_SEQUENCER)
  692. #define MarkFileForMoveA(source,dest) AssociatePropertyWithPathA(source, OPERATION_FILE_MOVE, dest)
  693. #define MarkFileForCopyA(source,dest) AssociatePropertyWithPathA(source, OPERATION_FILE_COPY, dest)
  694. #define MarkFileForMoveExternalA(source,dest) AssociatePropertyWithPathA(source, OPERATION_FILE_MOVE_EXTERNAL, dest)
  695. #define MarkFileForShellFolderMoveA(source,dest) AssociatePropertyWithPathA(source, OPERATION_FILE_MOVE_SHELL_FOLDER, dest)
  696. #define MarkFileForMoveByNtA(source,dest) AssociatePropertyWithPathA(source, OPERATION_FILE_MOVE_BY_NT, dest)
  697. #define MarkFileForCleanUpA(file) (AddOperationToPathA(file, OPERATION_CLEANUP) != INVALID_SEQUENCER)
  698. #define MarkPathAsHandledA(path) (AddOperationToPathA(path, OPERATION_MIGDLL_HANDLED) != INVALID_SEQUENCER)
  699. #define MarkFileForCreationA(path) (AddOperationToPathA(path, OPERATION_CREATE_FILE) != INVALID_SEQUENCER)
  700. #define MarkDirectoryAsPreservedA(file) (AddOperationToPathA(file, OPERATION_PRESERVED_DIR) != INVALID_SEQUENCER)
  701. #define MarkFileAsOsFileA(file) (AddOperationToPathA(file, OPERATION_OS_FILE) != INVALID_SEQUENCER)
  702. #define MarkFileForBackupA(file) (AddOperationToPathA(file, OPERATION_CHANGE_EXTERNAL) != INVALID_SEQUENCER)
  703. #define DisableFileA(file) (AddOperationToPathA(file, OPERATION_FILE_DISABLED) != INVALID_SEQUENCER)
  704. #define MarkFileForDeleteW(file) (AddOperationToPathW(file, OPERATION_FILE_DELETE) != INVALID_SEQUENCER)
  705. #define MarkFileForExternalDeleteW(file) (AddOperationToPathW(file, OPERATION_FILE_DELETE_EXTERNAL) != INVALID_SEQUENCER)
  706. #define MarkFileForMoveW(source,dest) AssociatePropertyWithPathW(source, OPERATION_FILE_MOVE, dest)
  707. #define MarkFileForCopyW(source,dest) AssociatePropertyWithPathW(source, OPERATION_FILE_COPY, dest)
  708. #define MarkFileForMoveExternalW(source,dest) AssociatePropertyWithPathW(source, OPERATION_FILE_MOVE_EXTERNAL, dest)
  709. #define MarkFileForShellFolderMoveW(source,dest) AssociatePropertyWithPathW(source, OPERATION_FILE_MOVE_SHELL_FOLDER, dest)
  710. #define MarkFileForMoveByNtW(source,dest) AssociatePropertyWithPathW(source, OPERATION_FILE_MOVE_BY_NT, dest)
  711. #define MarkFileForCleanUpW(file) (AddOperationToPathW(file, OPERATION_CLEANUP) != INVALID_SEQUENCER)
  712. #define MarkPathAsHandledW(path) (AddOperationToPathW(path, OPERATION_MIGDLL_HANDLED) != INVALID_SEQUENCER)
  713. #define MarkFileForCreationW(path) (AddOperationToPathW(path, OPERATION_CREATE_FILE) != INVALID_SEQUENCER)
  714. #define MarkDirectoryAsPreservedW(file) (AddOperationToPathW(file, OPERATION_PRESERVED_DIR) != INVALID_SEQUENCER)
  715. #define MarkFileAsOsFileW(file) (AddOperationToPathW(file, OPERATION_OS_FILE) != INVALID_SEQUENCER)
  716. #define MarkFileForBackupW(file) (AddOperationToPathW(file, OPERATION_CHANGE_EXTERNAL) != INVALID_SEQUENCER)
  717. #define DisableFileW(file) (AddOperationToPathW(file, OPERATION_FILE_DISABLED) != INVALID_SEQUENCER)
  718. #ifndef UNICODE
  719. #define FILEOP_ENUM FILEOP_ENUMA
  720. #define FILEOP_PROP_ENUM FILEOP_PROP_ENUMA
  721. #define ALL_FILEOPS_ENUM ALL_FILEOPS_ENUMA
  722. #define SHELLFOLDER_ENUM SHELLFOLDER_ENUMA
  723. #define FILERELOC_ENUM FILERELOC_ENUMA
  724. #define AddOperationToPath AddOperationToPathA
  725. #define AddPropertyToPathEx AddPropertyToPathExA
  726. #define AssociatePropertyWithPath AssociatePropertyWithPathA
  727. #define GetSequencerFromPath GetSequencerFromPathA
  728. #define GetPathFromSequencer GetPathFromSequencerA
  729. #define GetOperationsOnPath GetOperationsOnPathA
  730. #define RemoveOperationsFromPath RemoveOperationsFromPathA
  731. #define IsFileMarkedForOperation IsFileMarkedForOperationA
  732. #define IsFileMarkedInData IsFileMarkedInDataA
  733. #define GetPathProperty GetPathPropertyA
  734. #define EnumFirstPathInOperation EnumFirstPathInOperationA
  735. #define EnumNextPathInOperation EnumNextPathInOperationA
  736. #define EnumFirstFileOpProperty EnumFirstFileOpPropertyA
  737. #define EnumNextFileOpProperty EnumNextFileOpPropertyA
  738. #define EnumFirstFileOp EnumFirstFileOpA
  739. #define EnumNextFileOp EnumNextFileOpA
  740. #define TestPathsForOperations TestPathsForOperationsA
  741. #define IsFileMarkedForAnnounce IsFileMarkedForAnnounceA
  742. #define GetFileAnnouncement GetFileAnnouncementA
  743. #define GetFileAnnouncementContext GetFileAnnouncementContextA
  744. #define IsFileMarkedAsKnownGood IsFileMarkedAsKnownGoodA
  745. #define IsFileProvidedByNt IsFileProvidedByNtA
  746. #define GetNewPathForFile GetNewPathForFileA
  747. #define AnnounceFileInReport AnnounceFileInReportA
  748. #define MarkFileAsKnownGood MarkFileAsKnownGoodA
  749. #define AddCompatibleShell AddCompatibleShellA
  750. #define AddCompatibleRunKey AddCompatibleRunKeyA
  751. #define AddCompatibleDos AddCompatibleDosA
  752. #define AddControlPanelApplet AddControlPanelAppletA
  753. #define AddCompatibleHlp AddCompatibleHlpA
  754. #define MarkFileForTemporaryMove MarkFileForTemporaryMoveA
  755. #define MarkFileForTemporaryMoveEx MarkFileForTemporaryMoveExA
  756. #define GetTemporaryLocationForFile GetTemporaryLocationForFileA
  757. #define MarkHiveForTemporaryMove MarkHiveForTemporaryMoveA
  758. #define ComputeTemporaryPath ComputeTemporaryPathA
  759. #define MarkShellFolderForMove MarkShellFolderForMoveA
  760. #define FileIsProvidedByNt FileIsProvidedByNtA
  761. #define DeclareTemporaryFile DeclareTemporaryFileA
  762. #define EnumFirstFileReloc EnumFirstFileRelocA
  763. #define EnumNextFileReloc EnumNextFileRelocA
  764. #define GetNtFilePath GetNtFilePathA
  765. #define GetFileInfoOnNt GetFileInfoOnNtA
  766. #define GetFileStatusOnNt GetFileStatusOnNtA
  767. #define GetPathStringOnNt GetPathStringOnNtA
  768. #define ExtractArgZeroEx ExtractArgZeroExA
  769. #define IsFileMarkedForPreDelete IsFileMarkedForPreDeleteA
  770. #define IsFileMarkedForPostDelete IsFileMarkedForPostDeleteA
  771. #define IsFileMarkedForDelete IsFileMarkedForDeleteA
  772. #define IsFileMarkedAsDest IsFileMarkedAsDestA
  773. #define IsFileMarkedAsCopy IsFileMarkedAsCopyA
  774. #define IsFileMarkedForMove IsFileMarkedForMoveA
  775. #define IsFileMarkedAsHandled IsFileMarkedAsHandledA
  776. #define IsFileMarkedForChange IsFileMarkedForChangeA
  777. #define IsFileMarkedForCreation IsFileMarkedForCreationA
  778. #define IsDirectoryMarkedAsEmpty IsDirectoryMarkedAsEmptyA
  779. #define MarkFileForDelete MarkFileForDeleteA
  780. #define MarkFileForExternalDelete MarkFileForExternalDeleteA
  781. #define MarkFileForMove MarkFileForMoveA
  782. #define MarkFileForCopy MarkFileForCopyA
  783. #define MarkFileForMoveExternal MarkFileForMoveExternalA
  784. #define MarkFileForShellFolderMove MarkFileForShellFolderMoveA
  785. #define MarkFileForMoveByNt MarkFileForMoveByNtA
  786. #define MarkFileForCleanUp MarkFileForCleanUpA
  787. #define MarkPathAsHandled MarkPathAsHandledA
  788. #define MarkFileForCreation MarkFileForCreationA
  789. #define MarkDirectoryAsPreserved MarkDirectoryAsPreservedA
  790. #define ExtractArgZero ExtractArgZeroA
  791. #define AddPropertyToPath AddPropertyToPathA
  792. #define RemoveAllOperationsFromPath RemoveAllOperationsFromPathA
  793. #define ForceOperationOnPath ForceOperationOnPathA
  794. #define MarkFileAsOsFile MarkFileAsOsFileA
  795. #define MarkFileForBackup MarkFileForBackupA
  796. #define IsFileMarkedAsOsFile IsFileMarkedAsOsFileA
  797. #define DisableFile DisableFileA
  798. #define IsFileDisabled IsFileDisabledA
  799. #define IsFileMarkedForBackup IsFileMarkedForBackupA
  800. #define CanSetOperation CanSetOperationA
  801. #define GetSourceFileLongName GetSourceFileLongNameA
  802. #define IsDirEmpty IsDirEmptyA
  803. #define AddDirPathToEmptyDirsCategory AddDirPathToEmptyDirsCategoryA
  804. #else
  805. #define FILEOP_ENUM FILEOP_ENUMW
  806. #define FILEOP_PROP_ENUM FILEOP_PROP_ENUMW
  807. #define ALL_FILEOPS_ENUM ALL_FILEOPS_ENUMW
  808. #define SHELLFOLDER_ENUM SHELLFOLDER_ENUMW
  809. #define FILERELOC_ENUM FILERELOC_ENUMW
  810. #define AddOperationToPath AddOperationToPathW
  811. #define AddPropertyToPathEx AddPropertyToPathExW
  812. #define AssociatePropertyWithPath AssociatePropertyWithPathW
  813. #define GetSequencerFromPath GetSequencerFromPathW
  814. #define GetPathFromSequencer GetPathFromSequencerW
  815. #define GetOperationsOnPath GetOperationsOnPathW
  816. #define RemoveOperationsFromPath RemoveOperationsFromPathW
  817. #define IsFileMarkedForOperation IsFileMarkedForOperationW
  818. #define IsFileMarkedInData IsFileMarkedInDataW
  819. #define GetPathProperty GetPathPropertyW
  820. #define EnumFirstPathInOperation EnumFirstPathInOperationW
  821. #define EnumNextPathInOperation EnumNextPathInOperationW
  822. #define EnumFirstFileOpProperty EnumFirstFileOpPropertyW
  823. #define EnumNextFileOpProperty EnumNextFileOpPropertyW
  824. #define EnumFirstFileOp EnumFirstFileOpW
  825. #define EnumNextFileOp EnumNextFileOpW
  826. #define TestPathsForOperations TestPathsForOperationsW
  827. #define IsFileMarkedForAnnounce IsFileMarkedForAnnounceW
  828. #define GetFileAnnouncement GetFileAnnouncementW
  829. #define GetFileAnnouncementContext GetFileAnnouncementContextW
  830. #define IsFileProvidedByNt IsFileProvidedByNtW
  831. #define GetNewPathForFile GetNewPathForFileW
  832. #define GetTemporaryLocationForFile GetTemporaryLocationForFileW
  833. #define DeclareTemporaryFile DeclareTemporaryFileW
  834. #define GetNtFilePath GetNtFilePathW
  835. #define GetFileInfoOnNt GetFileInfoOnNtW
  836. #define GetFileStatusOnNt GetFileStatusOnNtW
  837. #define GetPathStringOnNt GetPathStringOnNtW
  838. #define ExtractArgZeroEx ExtractArgZeroExW
  839. #define IsFileMarkedForPreDelete IsFileMarkedForPreDeleteW
  840. #define IsFileMarkedForPostDelete IsFileMarkedForPostDeleteW
  841. #define IsFileMarkedForDelete IsFileMarkedForDeleteW
  842. #define IsFileMarkedAsDest IsFileMarkedAsDestW
  843. #define IsFileMarkedAsCopy IsFileMarkedAsCopyW
  844. #define IsFileMarkedForMove IsFileMarkedForMoveW
  845. #define IsFileMarkedAsHandled IsFileMarkedAsHandledW
  846. #define IsFileMarkedForChange IsFileMarkedForChangeW
  847. #define IsFileMarkedForCreation IsFileMarkedForCreationW
  848. #define IsDirectoryMarkedAsEmpty IsDirectoryMarkedAsEmptyW
  849. #define MarkFileForDelete MarkFileForDeleteW
  850. #define MarkFileForExternalDelete MarkFileForExternalDeleteW
  851. #define MarkFileForMove MarkFileForMoveW
  852. #define MarkFileForCopy MarkFileForCopyW
  853. #define MarkFileForMoveExternal MarkFileForMoveExternalW
  854. #define MarkFileForShellFolderMove MarkFileForShellFolderMoveW
  855. #define MarkFileForMoveByNt MarkFileForMoveByNtW
  856. #define MarkFileForCleanUp MarkFileForCleanUpW
  857. #define MarkPathAsHandled MarkPathAsHandledW
  858. #define MarkFileForCreation MarkFileForCreationW
  859. #define MarkDirectoryAsPreserved MarkDirectoryAsPreservedW
  860. #define RecordSrcFromDest RecordSrcFromDestW
  861. #define ExtractArgZero ExtractArgZeroW
  862. #define AddPropertyToPath AddPropertyToPathW
  863. #define RemoveAllOperationsFromPath RemoveAllOperationsFromPathW
  864. #define ForceOperationOnPath ForceOperationOnPathW
  865. #define MarkFileAsOsFile MarkFileAsOsFileW
  866. #define MarkFileForBackup MarkFileForBackupW
  867. #define IsFileMarkedAsOsFile IsFileMarkedAsOsFileW
  868. #define DisableFile DisableFileW
  869. #define IsFileDisabled IsFileDisabledW
  870. #define IsFileMarkedForBackup IsFileMarkedForBackupW
  871. #define CanSetOperation CanSetOperationW
  872. #define GetSourceFileLongName GetSourceFileLongNameW
  873. #define IsDirEmpty IsDirEmptyW
  874. #define AddDirPathToEmptyDirsCategory AddDirPathToEmptyDirsCategoryW
  875. #endif