dismapi.h 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383
  1. /**
  2. * This file has no copyright assigned and is placed in the Public Domain.
  3. * This file is part of the mingw-w64 runtime package.
  4. * No warranty is given; refer to the file DISCLAIMER.PD within this package.
  5. */
  6. #ifndef _DISMAPI_H_
  7. #define _DISMAPI_H_
  8. #include <winapifamily.h>
  9. #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
  10. #ifdef __cplusplus
  11. extern "C"
  12. {
  13. #endif
  14. typedef UINT DismSession;
  15. typedef void(CALLBACK *DISM_PROGRESS_CALLBACK)(UINT Current, UINT Total, PVOID UserData);
  16. #define DISM_ONLINE_IMAGE L"DISM_{53BFAE52-B167-4E2F-A258-0A37B57FF845}"
  17. #define DISM_SESSION_DEFAULT 0
  18. #define DISM_MOUNT_READWRITE 0x00000000
  19. #define DISM_MOUNT_READONLY 0x00000001
  20. #define DISM_MOUNT_OPTIMIZE 0x00000002
  21. #define DISM_MOUNT_CHECK_INTEGRITY 0x00000004
  22. #define DISM_COMMIT_IMAGE 0x00000000
  23. #define DISM_DISCARD_IMAGE 0x00000001
  24. #define DISM_COMMIT_GENERATE_INTEGRITY 0x00010000
  25. #define DISM_COMMIT_APPEND 0x00020000
  26. #define DISM_COMMIT_MASK 0xffff0000
  27. /* https://docs.microsoft.com/en-us/windows-hardware/manufacture/desktop/dism/dism-api-enumerations */
  28. typedef enum _DismLogLevel
  29. {
  30. DismLogErrors = 0,
  31. DismLogErrorsWarnings,
  32. DismLogErrorsWarningsInfo
  33. } DismLogLevel;
  34. typedef enum _DismImageIdentifier
  35. {
  36. DismImageIndex = 0,
  37. DismImageName
  38. } DismImageIdentifier;
  39. typedef enum _DismMountMode
  40. {
  41. DismReadWrite = 0,
  42. DismReadOnly
  43. } DismMountMode;
  44. typedef enum _DismImageType
  45. {
  46. DismImageTypeUnsupported = -1,
  47. DismImageTypeWim = 0,
  48. DismImageTypeVhd = 1
  49. } DismImageType;
  50. typedef enum _DismImageBootable
  51. {
  52. DismImageBootableYes = 0,
  53. DismImageBootableNo,
  54. DismImageBootableUnknown
  55. } DismImageBootable;
  56. typedef enum _DismMountStatus
  57. {
  58. DismMountStatusOk = 0,
  59. DismMountStatusNeedsRemount,
  60. DismMountStatusInvalid
  61. } DismMountStatus;
  62. typedef enum _DismImageHealthState
  63. {
  64. DismImageHealthy = 0,
  65. DismImageRepairable,
  66. DismImageNonRepairable
  67. } DismImageHealthState;
  68. typedef enum _DismPackageIdentifier
  69. {
  70. DismPackageNone = 0,
  71. DismPackageName,
  72. DismPackagePath
  73. } DismPackageIdentifier;
  74. typedef enum _DismPackageFeatureState
  75. {
  76. DismStateNotPresent = 0,
  77. DismStateUninstallPending,
  78. DismStateStaged,
  79. DismStateResolved,
  80. DismStateRemoved = DismStateResolved,
  81. DismStateInstalled,
  82. DismStateInstallPending,
  83. DismStateSuperseded,
  84. DismStatePartiallyInstalled
  85. } DismPackageFeatureState;
  86. typedef enum _DismReleaseType
  87. {
  88. DismReleaseTypeCriticalUpdate = 0,
  89. DismReleaseTypeDriver,
  90. DismReleaseTypeFeaturePack,
  91. DismReleaseTypeHotfix,
  92. DismReleaseTypeSecurityUpdate,
  93. DismReleaseTypeSoftwareUpdate,
  94. DismReleaseTypeUpdate,
  95. DismReleaseTypeUpdateRollup,
  96. DismReleaseTypeLanguagePack,
  97. DismReleaseTypeFoundation,
  98. DismReleaseTypeServicePack,
  99. DismReleaseTypeProduct,
  100. DismReleaseTypeLocalPack,
  101. DismReleaseTypeOther,
  102. DismReleaseTypeOnDemandPack
  103. } DismReleaseType;
  104. typedef enum _DismRestartType
  105. {
  106. DismRestartNo = 0,
  107. DismRestartPossible,
  108. DismRestartRequired
  109. } DismRestartType;
  110. typedef enum _DismDriverSignature
  111. {
  112. DismDriverSignatureUnknown = 0,
  113. DismDriverSignatureUnsigned = 1,
  114. DismDriverSignatureSigned = 2
  115. } DismDriverSignature;
  116. typedef enum _DismFullyOfflineInstallableType
  117. {
  118. DismFullyOfflineInstallable = 0,
  119. DismFullyOfflineNotInstallable,
  120. DismFullyOfflineInstallableUndetermined
  121. } DismFullyOfflineInstallableType;
  122. /* https://docs.microsoft.com/en-us/windows-hardware/manufacture/desktop/dism/dism-api-structures */
  123. #pragma pack(push, 1)
  124. typedef struct _DismPackage
  125. {
  126. PCWSTR PackageName;
  127. DismPackageFeatureState PackageState;
  128. DismReleaseType ReleaseType;
  129. SYSTEMTIME InstallTime;
  130. } DismPackage;
  131. typedef struct _DismCustomProperty
  132. {
  133. PCWSTR Name;
  134. PCWSTR Value;
  135. PCWSTR Path;
  136. } DismCustomProperty;
  137. typedef struct _DismFeature
  138. {
  139. PCWSTR FeatureName;
  140. DismPackageFeatureState State;
  141. } DismFeature;
  142. typedef struct _DismCapability
  143. {
  144. PCWSTR Name;
  145. DismPackageFeatureState State;
  146. } DismCapability;
  147. typedef struct _DismPackageInfo
  148. {
  149. PCWSTR PackageName;
  150. DismPackageFeatureState PackageState;
  151. DismReleaseType ReleaseType;
  152. SYSTEMTIME InstallTime;
  153. WINBOOL Applicable;
  154. PCWSTR Copyright;
  155. PCWSTR Company;
  156. SYSTEMTIME CreationTime;
  157. PCWSTR DisplayName;
  158. PCWSTR Description;
  159. PCWSTR InstallClient;
  160. PCWSTR InstallPackageName;
  161. SYSTEMTIME LastUpdateTime;
  162. PCWSTR ProductName;
  163. PCWSTR ProductVersion;
  164. DismRestartType RestartRequired;
  165. DismFullyOfflineInstallableType FullyOffline;
  166. PCWSTR SupportInformation;
  167. DismCustomProperty *CustomProperty;
  168. UINT CustomPropertyCount;
  169. DismFeature *Feature;
  170. UINT FeatureCount;
  171. } DismPackageInfo;
  172. #ifdef __cplusplus
  173. typedef struct _DismPackageInfoEx : public _DismPackageInfo
  174. {
  175. #else
  176. typedef struct _DismPackageInfoEx
  177. {
  178. DismPackageInfo;
  179. #endif
  180. PCWSTR CapabilityId;
  181. } DismPackageInfoEx;
  182. typedef struct _DismFeatureInfo
  183. {
  184. PCWSTR FeatureName;
  185. DismPackageFeatureState FeatureState;
  186. PCWSTR DisplayName;
  187. PCWSTR Description;
  188. DismRestartType RestartRequired;
  189. DismCustomProperty *CustomProperty;
  190. UINT CustomPropertyCount;
  191. } DismFeatureInfo;
  192. typedef struct _DismCapabilityInfo
  193. {
  194. PCWSTR Name;
  195. DismPackageFeatureState State;
  196. PCWSTR DisplayName;
  197. PCWSTR Description;
  198. DWORD DownloadSize;
  199. DWORD InstallSize;
  200. } DismCapabilityInfo;
  201. typedef struct _DismString
  202. {
  203. PCWSTR Value;
  204. } DismString;
  205. typedef DismString DismLanguage;
  206. typedef struct _DismWimCustomizedInfo
  207. {
  208. UINT Size;
  209. UINT DirectoryCount;
  210. UINT FileCount;
  211. SYSTEMTIME CreatedTime;
  212. SYSTEMTIME ModifiedTime;
  213. } DismWimCustomizedInfo;
  214. typedef struct _DismImageInfo
  215. {
  216. DismImageType ImageType;
  217. UINT ImageIndex;
  218. PCWSTR ImageName;
  219. PCWSTR ImageDescription;
  220. UINT64 ImageSize;
  221. UINT Architecture;
  222. PCWSTR ProductName;
  223. PCWSTR EditionId;
  224. PCWSTR InstallationType;
  225. PCWSTR Hal;
  226. PCWSTR ProductType;
  227. PCWSTR ProductSuite;
  228. UINT MajorVersion;
  229. UINT MinorVersion;
  230. UINT Build;
  231. UINT SpBuild;
  232. UINT SpLevel;
  233. DismImageBootable Bootable;
  234. PCWSTR SystemRoot;
  235. DismLanguage *Language;
  236. UINT LanguageCount;
  237. UINT DefaultLanguageIndex;
  238. VOID *CustomizedInfo;
  239. } DismImageInfo;
  240. typedef struct _DismMountedImageInfo
  241. {
  242. PCWSTR MountPath;
  243. PCWSTR ImageFilePath;
  244. UINT ImageIndex;
  245. DismMountMode MountMode;
  246. DismMountStatus MountStatus;
  247. } DismMountedImageInfo;
  248. typedef struct _DismDriverPackage
  249. {
  250. PCWSTR PublishedName;
  251. PCWSTR OriginalFileName;
  252. WINBOOL InBox;
  253. PCWSTR CatalogFile;
  254. PCWSTR ClassName;
  255. PCWSTR ClassGuid;
  256. PCWSTR ClassDescription;
  257. WINBOOL BootCritical;
  258. DismDriverSignature DriverSignature;
  259. PCWSTR ProviderName;
  260. SYSTEMTIME Date;
  261. UINT MajorVersion;
  262. UINT MinorVersion;
  263. UINT Build;
  264. UINT Revision;
  265. } DismDriverPackage;
  266. typedef struct _DismDriver
  267. {
  268. PCWSTR ManufacturerName;
  269. PCWSTR HardwareDescription;
  270. PCWSTR HardwareId;
  271. UINT Architecture;
  272. PCWSTR ServiceName;
  273. PCWSTR CompatibleIds;
  274. PCWSTR ExcludeIds;
  275. } DismDriver;
  276. #pragma pack(pop)
  277. /* https://docs.microsoft.com/en-us/windows-hardware/manufacture/desktop/dism/dism-api-functions */
  278. HRESULT WINAPI DismInitialize (DismLogLevel LogLevel, PCWSTR LogFilePath, PCWSTR ScratchDirectory);
  279. HRESULT WINAPI DismShutdown (void);
  280. HRESULT WINAPI DismMountImage (PCWSTR ImageFilePath, PCWSTR MountPath, UINT ImageIndex, PCWSTR ImageName, DismImageIdentifier ImageIdentifier, DWORD Flags, HANDLE CancelEvent, DISM_PROGRESS_CALLBACK Progress, PVOID UserData);
  281. HRESULT WINAPI DismUnmountImage (PCWSTR MountPath, DWORD Flags, HANDLE CancelEvent, DISM_PROGRESS_CALLBACK Progress, PVOID UserData);
  282. HRESULT WINAPI DismOpenSession (PCWSTR ImagePath, PCWSTR WindowsDirectory, PCWSTR SystemDrive, DismSession *Session);
  283. HRESULT WINAPI DismCloseSession (DismSession Session);
  284. HRESULT WINAPI DismGetLastErrorMessage (DismString **ErrorMessage);
  285. HRESULT WINAPI DismRemountImage (PCWSTR MountPath);
  286. HRESULT WINAPI DismCommitImage (DismSession Session, DWORD Flags, HANDLE CancelEvent, DISM_PROGRESS_CALLBACK Progress, PVOID UserData);
  287. HRESULT WINAPI DismGetImageInfo (PCWSTR ImageFilePath, DismImageInfo **ImageInfo, UINT *Count);
  288. HRESULT WINAPI DismGetMountedImageInfo (DismMountedImageInfo **MountedImageInfo, UINT *Count);
  289. HRESULT WINAPI DismCleanupMountpoints (void);
  290. HRESULT WINAPI DismCheckImageHealth (DismSession Session, WINBOOL ScanImage, HANDLE CancelEvent, DISM_PROGRESS_CALLBACK Progress, PVOID UserData, DismImageHealthState *ImageHealth);
  291. HRESULT WINAPI DismRestoreImageHealth (DismSession Session, PCWSTR *SourcePaths, UINT SourcePathCount, WINBOOL LimitAccess, HANDLE CancelEvent, DISM_PROGRESS_CALLBACK Progress, PVOID UserData);
  292. HRESULT WINAPI DismDelete (VOID *DismStructure);
  293. HRESULT WINAPI DismAddPackage (DismSession Session, PCWSTR PackagePath, WINBOOL IgnoreCheck, WINBOOL PreventPending, HANDLE CancelEvent, DISM_PROGRESS_CALLBACK Progress, PVOID UserData);
  294. HRESULT WINAPI DismRemovePackage (DismSession Session, PCWSTR Identifier, DismPackageIdentifier PackageIdentifier, HANDLE CancelEvent, DISM_PROGRESS_CALLBACK Progress, PVOID UserData);
  295. HRESULT WINAPI DismEnableFeature (DismSession Session, PCWSTR FeatureName, PCWSTR Identifier, DismPackageIdentifier PackageIdentifier, WINBOOL LimitAccess, PCWSTR *SourcePaths, UINT SourcePathCount, WINBOOL EnableAll, HANDLE CancelEvent, DISM_PROGRESS_CALLBACK Progress, PVOID UserData);
  296. HRESULT WINAPI DismDisableFeature (DismSession Session, PCWSTR FeatureName, PCWSTR PackageName, WINBOOL RemovePayload, HANDLE CancelEvent, DISM_PROGRESS_CALLBACK Progress, PVOID UserData);
  297. HRESULT WINAPI DismGetPackages (DismSession Session, DismPackage **Package, UINT *Count);
  298. HRESULT WINAPI DismGetPackageInfo (DismSession Session, PCWSTR Identifier, DismPackageIdentifier PackageIdentifier, DismPackageInfo **PackageInfo);
  299. HRESULT WINAPI DismGetPackageInfoEx (DismSession Session, PCWSTR Identifier, DismPackageIdentifier PackageIdentifier, DismPackageInfoEx **PackageInfoEx);
  300. HRESULT WINAPI DismGetFeatures (DismSession Session, PCWSTR Identifier, DismPackageIdentifier PackageIdentifier, DismFeature **Feature, UINT *Count);
  301. HRESULT WINAPI DismGetFeatureInfo (DismSession Session, PCWSTR FeatureName, PCWSTR Identifier, DismPackageIdentifier PackageIdentifier, DismFeatureInfo **FeatureInfo);
  302. HRESULT WINAPI DismGetFeatureParent (DismSession Session, PCWSTR FeatureName, PCWSTR Identifier, DismPackageIdentifier PackageIdentifier, DismFeature **Feature, UINT *Count);
  303. HRESULT WINAPI DismApplyUnattend (DismSession Session, PCWSTR UnattendFile, WINBOOL SingleSession);
  304. HRESULT WINAPI DismAddDriver (DismSession Session, PCWSTR DriverPath, WINBOOL ForceUnsigned);
  305. HRESULT WINAPI DismRemoveDriver (DismSession Session, PCWSTR DriverPath);
  306. HRESULT WINAPI DismGetDrivers (DismSession Session, WINBOOL AllDrivers, DismDriverPackage **DriverPackage, UINT *Count);
  307. HRESULT WINAPI DismGetDriverInfo (DismSession Session, PCWSTR DriverPath, DismDriver **Driver, UINT *Count, DismDriverPackage **DriverPackage);
  308. HRESULT WINAPI DismGetCapabilities (DismSession Session, DismCapability **Capability, UINT *Count);
  309. HRESULT WINAPI DismGetCapabilityInfo (DismSession Session, PCWSTR Name, DismCapabilityInfo **Info);
  310. HRESULT WINAPI DismAddCapability (DismSession Session, PCWSTR Name, WINBOOL LimitAccess, PCWSTR *SourcePaths, UINT SourcePathCount, HANDLE CancelEvent, DISM_PROGRESS_CALLBACK Progress, PVOID UserData);
  311. HRESULT WINAPI DismRemoveCapability (DismSession Session, PCWSTR Name, HANDLE CancelEvent, DISM_PROGRESS_CALLBACK Progress, PVOID UserData);
  312. #define DISMAPI_S_RELOAD_IMAGE_SESSION_REQUIRED 0x00000001
  313. #define DISMAPI_E_DISMAPI_NOT_INITIALIZED 0xc0040001
  314. #define DISMAPI_E_SHUTDOWN_IN_PROGRESS 0xc0040002
  315. #define DISMAPI_E_OPEN_SESSION_HANDLES 0xc0040003
  316. #define DISMAPI_E_INVALID_DISM_SESSION 0xc0040004
  317. #define DISMAPI_E_INVALID_IMAGE_INDEX 0xc0040005
  318. #define DISMAPI_E_INVALID_IMAGE_NAME 0xc0040006
  319. #define DISMAPI_E_UNABLE_TO_UNMOUNT_IMAGE_PATH 0xc0040007
  320. #define DISMAPI_E_LOGGING_DISABLED 0xc0040009
  321. #define DISMAPI_E_OPEN_HANDLES_UNABLE_TO_UNMOUNT_IMAGE_PATH 0xc004000a
  322. #define DISMAPI_E_OPEN_HANDLES_UNABLE_TO_MOUNT_IMAGE_PATH 0xc004000b
  323. #define DISMAPI_E_OPEN_HANDLES_UNABLE_TO_REMOUNT_IMAGE_PATH 0xc004000c
  324. #define DISMAPI_E_PARENT_FEATURE_DISABLED 0xc004000d
  325. #define DISMAPI_E_MUST_SPECIFY_ONLINE_IMAGE 0xc004000e
  326. #define DISMAPI_E_INVALID_PRODUCT_KEY 0xc004000f
  327. #define DISMAPI_E_NEEDS_REMOUNT 0xc1510114
  328. #define DISMAPI_E_UNKNOWN_FEATURE 0x800f080c
  329. #define DISMAPI_E_BUSY 0x800f0902
  330. #ifdef __cplusplus
  331. }
  332. #endif
  333. #endif /* WINAPI_PARTITION_DESKTOP */
  334. #endif /* _DISMAPI_H_ */