Shared.Struct.pas 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434
  1. unit Shared.Struct;
  2. {
  3. Inno Setup
  4. Copyright (C) 1997-2025 Jordan Russell
  5. Portions by Martijn Laan
  6. For conditions of distribution and use, see LICENSE.TXT.
  7. Various records and other types that are shared by the ISCmplr, Setup,
  8. SetupLdr, and Uninst projects
  9. }
  10. interface
  11. uses
  12. Windows, Shared.Int64Em, SHA256;
  13. const
  14. SetupTitle = 'Inno Setup';
  15. SetupVersion = '6.5.0-dev';
  16. SetupBinVersion = (6 shl 24) + (4 shl 16) + (3 shl 8) + 0;
  17. type
  18. TSetupID = array[0..63] of AnsiChar;
  19. TUninstallLogID = array[0..63] of AnsiChar;
  20. TMessagesHdrID = array[0..63] of AnsiChar;
  21. TMessagesLangOptionsID = array[1..8] of AnsiChar;
  22. TCompID = array[1..4] of AnsiChar;
  23. TDiskSliceID = array[1..8] of AnsiChar;
  24. const
  25. { SetupID is used by the Setup program to check if the SETUP.0 file is
  26. compatible with it. If you make any modifications to the records in
  27. this file it's recommended you change SetupID. Any change will do (like
  28. changing the letters or numbers), as long as your format is
  29. unrecognizable by the standard Inno Setup. }
  30. SetupID: TSetupID = 'Inno Setup Setup Data (6.5.0)';
  31. UninstallLogID: array[Boolean] of TUninstallLogID =
  32. ('Inno Setup Uninstall Log (b)', 'Inno Setup Uninstall Log (b) 64-bit');
  33. MessagesHdrID: TMessagesHdrID = 'Inno Setup Messages (6.5.0) (u)';
  34. MessagesLangOptionsID: TMessagesLangOptionsID = '!mlo!001';
  35. ZLIBID: TCompID = 'zlb'#26;
  36. DiskSliceID: TDiskSliceID = 'idska32'#26;
  37. type
  38. TSetupVersionDataVersion = packed record
  39. Build: Word;
  40. Minor, Major: Byte;
  41. end;
  42. TSetupVersionData = packed record
  43. WinVersion, NTVersion: Cardinal;
  44. NTServicePack: Word;
  45. end;
  46. TSetupHeaderOption = (shDisableStartupPrompt, shCreateAppDir,
  47. shAllowNoIcons, shAlwaysRestart, shAlwaysUsePersonalGroup,
  48. shEnableDirDoesntExistWarning,
  49. shPassword, shAllowRootDirectory, shDisableFinishedPage, shUsePreviousAppDir,
  50. shUsePreviousGroup, shUpdateUninstallLogAppName,
  51. shUsePreviousSetupType, shDisableReadyMemo, shAlwaysShowComponentsList,
  52. shFlatComponentsList, shShowComponentSizes, shUsePreviousTasks,
  53. shDisableReadyPage, shAlwaysShowDirOnReadyPage, shAlwaysShowGroupOnReadyPage,
  54. shAllowUNCPath, shUserInfoPage, shUsePreviousUserInfo,
  55. shUninstallRestartComputer, shRestartIfNeededByRun, shShowTasksTreeLines,
  56. shAllowCancelDuringInstall, shWizardImageStretch, shAppendDefaultDirName,
  57. shAppendDefaultGroupName, shSetupLogging,
  58. shSignedUninstaller, shUsePreviousLanguage, shDisableWelcomePage,
  59. shCloseApplications, shRestartApplications, shAllowNetworkDrive,
  60. shForceCloseApplications, shAppNameHasConsts, shUsePreviousPrivileges,
  61. shWizardResizable, shUninstallLogging);
  62. TSetupLanguageDetectionMethod = (ldUILanguage, ldLocale, ldNone);
  63. TSetupCompressMethod = (cmStored, cmZip, cmBzip, cmLZMA, cmLZMA2);
  64. TSetupKDFSalt = array[0..15] of Byte;
  65. TSetupEncryptionKey = array[0..31] of Byte;
  66. TSetupEncryptionNonce = record
  67. RandomXorStartOffset: Int64;
  68. RandomXorFirstSlice: Int32;
  69. RemainingRandom: array[0..2] of Int32;
  70. end;
  71. TSetupProcessorArchitecture = (paUnknown, paX86, paX64, paArm32, paArm64);
  72. TSetupProcessorArchitectures = set of TSetupProcessorArchitecture;
  73. TSetupDisablePage = (dpAuto, dpNo, dpYes);
  74. TSetupPrivilegesRequired = (prNone, prPowerUser, prAdmin, prLowest);
  75. TSetupPrivilegesRequiredOverride = (proCommandLine, proDialog);
  76. TSetupPrivilegesRequiredOverrides = set of TSetupPrivilegesRequiredOverride;
  77. TSetupWizardStyle = (wsClassic, wsModern);
  78. const
  79. SetupProcessorArchitectureNames: array[TSetupProcessorArchitecture] of String =
  80. ('Unknown', 'x86', 'x64', 'Arm32', 'Arm64');
  81. type
  82. { Should not contain strings }
  83. TSetupEncryptionHeader = packed record
  84. EncryptionUse: (euNone, euFiles, euFull);
  85. KDFSalt: TSetupKDFSalt;
  86. KDFIterations: Integer;
  87. BaseNonce: TSetupEncryptionNonce;
  88. PasswordTest: Integer;
  89. end;
  90. const
  91. SetupHeaderStrings = 34;
  92. SetupHeaderAnsiStrings = 4;
  93. type
  94. TSetupHeader = packed record
  95. AppName, AppVerName, AppId, AppCopyright, AppPublisher, AppPublisherURL,
  96. AppSupportPhone, AppSupportURL, AppUpdatesURL, AppVersion, DefaultDirName,
  97. DefaultGroupName, BaseFilename, UninstallFilesDir, UninstallDisplayName,
  98. UninstallDisplayIcon, AppMutex, DefaultUserInfoName, DefaultUserInfoOrg,
  99. DefaultUserInfoSerial, AppReadmeFile, AppContact, AppComments,
  100. AppModifyPath, CreateUninstallRegKey, Uninstallable, CloseApplicationsFilter,
  101. SetupMutex, ChangesEnvironment, ChangesAssociations,
  102. ArchitecturesAllowed, ArchitecturesInstallIn64BitMode, CloseApplicationsFilterExcludes,
  103. SevenZipLibraryName: String;
  104. LicenseText, InfoBeforeText, InfoAfterText, CompiledCodeText: AnsiString;
  105. NumLanguageEntries, NumCustomMessageEntries, NumPermissionEntries,
  106. NumTypeEntries, NumComponentEntries, NumTaskEntries, NumDirEntries,
  107. NumISSigKeyEntries, NumFileEntries, NumFileLocationEntries, NumIconEntries, NumIniEntries,
  108. NumRegistryEntries, NumInstallDeleteEntries, NumUninstallDeleteEntries,
  109. NumRunEntries, NumUninstallRunEntries: Integer;
  110. MinVersion, OnlyBelowVersion: TSetupVersionData;
  111. WizardStyle: TSetupWizardStyle;
  112. WizardSizePercentX, WizardSizePercentY: Integer;
  113. WizardImageAlphaFormat: (afIgnored, afDefined, afPremultiplied); // Must be same as Graphics.TAlphaFormat
  114. ExtraDiskSpaceRequired: Integer64;
  115. SlicesPerDisk: Integer;
  116. UninstallLogMode: (lmAppend, lmNew, lmOverwrite);
  117. DirExistsWarning: (ddAuto, ddNo, ddYes);
  118. PrivilegesRequired: TSetupPrivilegesRequired;
  119. PrivilegesRequiredOverridesAllowed: TSetupPrivilegesRequiredOverrides;
  120. ShowLanguageDialog: (slYes, slNo, slAuto);
  121. LanguageDetectionMethod: TSetupLanguageDetectionMethod;
  122. CompressMethod: TSetupCompressMethod;
  123. DisableDirPage, DisableProgramGroupPage: TSetupDisablePage;
  124. UninstallDisplaySize: Integer64;
  125. Options: set of TSetupHeaderOption;
  126. end;
  127. const
  128. SetupPermissionEntryStrings = 0;
  129. SetupPermissionEntryAnsiStrings = 1;
  130. type
  131. PSetupPermissionEntry = ^TSetupPermissionEntry;
  132. TSetupPermissionEntry = packed record
  133. Permissions: AnsiString; { an array of TGrantPermissionEntry's }
  134. end;
  135. const
  136. SetupLanguageEntryStrings = 6;
  137. SetupLanguageEntryAnsiStrings = 4;
  138. type
  139. PSetupLanguageEntry = ^TSetupLanguageEntry;
  140. TSetupLanguageEntry = packed record
  141. Name, LanguageName, DialogFontName, TitleFontName, WelcomeFontName,
  142. CopyrightFontName: String;
  143. Data, LicenseText, InfoBeforeText, InfoAfterText: AnsiString;
  144. LanguageID: Cardinal;
  145. DialogFontSize: Integer;
  146. TitleFontSize: Integer;
  147. WelcomeFontSize: Integer;
  148. CopyrightFontSize: Integer;
  149. RightToLeft: Boolean;
  150. end;
  151. const
  152. SetupCustomMessageEntryStrings = 2;
  153. SetupCustomMessageEntryAnsiStrings = 0;
  154. type
  155. PSetupCustomMessageEntry = ^TSetupCustomMessageEntry;
  156. TSetupCustomMessageEntry = packed record
  157. Name, Value: String;
  158. LangIndex: Integer;
  159. end;
  160. const
  161. SetupTypeEntryStrings = 4;
  162. SetupTypeEntryAnsiStrings = 0;
  163. type
  164. TSetupTypeOption = (toIsCustom);
  165. TSetupTypeOptions = set of TSetupTypeOption;
  166. TSetupTypeType = (ttUser, ttDefaultFull, ttDefaultCompact, ttDefaultCustom);
  167. PSetupTypeEntry = ^TSetupTypeEntry;
  168. TSetupTypeEntry = packed record
  169. Name, Description, Languages, CheckOnce: String;
  170. MinVersion, OnlyBelowVersion: TSetupVersionData;
  171. Options: TSetupTypeOptions;
  172. Typ: TSetupTypeType;
  173. { internally used: }
  174. Size: Integer64;
  175. end;
  176. const
  177. SetupComponentEntryStrings = 5;
  178. SetupComponentEntryAnsiStrings = 0;
  179. type
  180. PSetupComponentEntry = ^TSetupComponentEntry;
  181. TSetupComponentEntry = packed record
  182. Name, Description, Types, Languages, CheckOnce: String;
  183. ExtraDiskSpaceRequired: Integer64;
  184. Level: Integer;
  185. Used: Boolean;
  186. MinVersion, OnlyBelowVersion: TSetupVersionData;
  187. Options: set of (coFixed, coRestart, coDisableNoUninstallWarning,
  188. coExclusive, coDontInheritCheck);
  189. { internally used: }
  190. Size: Integer64;
  191. end;
  192. const
  193. SetupTaskEntryStrings = 6;
  194. SetupTaskEntryAnsiStrings = 0;
  195. type
  196. PSetupTaskEntry = ^TSetupTaskEntry;
  197. TSetupTaskEntry = packed record
  198. Name, Description, GroupDescription, Components, Languages, Check: String;
  199. Level: Integer;
  200. Used: Boolean;
  201. MinVersion, OnlyBelowVersion: TSetupVersionData;
  202. Options: set of (toExclusive, toUnchecked, toRestart, toCheckedOnce,
  203. toDontInheritCheck);
  204. end;
  205. const
  206. SetupDirEntryStrings = 7;
  207. SetupDirEntryAnsiStrings = 0;
  208. type
  209. PSetupDirEntry = ^TSetupDirEntry;
  210. TSetupDirEntry = packed record
  211. DirName: String;
  212. Components, Tasks, Languages, Check, AfterInstall, BeforeInstall: String;
  213. Attribs: Integer;
  214. MinVersion, OnlyBelowVersion: TSetupVersionData;
  215. PermissionsEntry: Smallint;
  216. Options: set of (doUninsNeverUninstall, doDeleteAfterInstall,
  217. doUninsAlwaysUninstall, doSetNTFSCompression, doUnsetNTFSCompression);
  218. end;
  219. const
  220. SetupISSigKeyEntryStrings = 3;
  221. SetupISSigKeyEntryAnsiStrings = 0;
  222. type
  223. PSetupISSigKeyEntry = ^TSetupISSigKeyEntry;
  224. TSetupISSigKeyEntry = packed record
  225. PublicX, PublicY, RuntimeID: String;
  226. end;
  227. const
  228. SetupFileEntryStrings = 15;
  229. SetupFileEntryAnsiStrings = 1;
  230. type
  231. PSetupFileEntry = ^TSetupFileEntry;
  232. TSetupFileVerificationType = (fvNone, fvHash, fvISSig);
  233. TSetupFileVerification = packed record
  234. ISSigAllowedKeys: AnsiString; { Must be first }
  235. Hash: TSHA256Digest;
  236. Typ: TSetupFileVerificationType;
  237. end;
  238. TSetupFileEntry = packed record
  239. SourceFilename, DestName, InstallFontName, StrongAssemblyName, Components,
  240. Tasks, Languages, Check, AfterInstall, BeforeInstall, Excludes,
  241. DownloadISSigSource, DownloadUserName, DownloadPassword, ExtractArchivePassword: String;
  242. Verification: TSetupFileVerification; { Must be first after strings }
  243. MinVersion, OnlyBelowVersion: TSetupVersionData;
  244. LocationEntry: Integer;
  245. Attribs: Integer;
  246. ExternalSize: Integer64;
  247. PermissionsEntry: Smallint;
  248. Options: set of (foConfirmOverwrite, foUninsNeverUninstall, foRestartReplace,
  249. foDeleteAfterInstall, foRegisterServer, foRegisterTypeLib, foSharedFile,
  250. foCompareTimeStamp, foFontIsntTrueType,
  251. foSkipIfSourceDoesntExist, foOverwriteReadOnly, foOverwriteSameVersion,
  252. foCustomDestName, foOnlyIfDestFileExists, foNoRegError,
  253. foUninsRestartDelete, foOnlyIfDoesntExist, foIgnoreVersion,
  254. foPromptIfOlder, foDontCopy, foUninsRemoveReadOnly,
  255. foRecurseSubDirsExternal, foReplaceSameVersionIfContentsDiffer,
  256. foDontVerifyChecksum, foUninsNoSharedFilePrompt, foCreateAllSubDirs,
  257. fo32Bit, fo64Bit, foExternalSizePreset, foSetNTFSCompression,
  258. foUnsetNTFSCompression, foGacInstall, foDownload,
  259. foExtractArchive);
  260. FileType: (ftUserFile, ftUninstExe);
  261. end;
  262. const
  263. SetupFileLocationEntryStrings = 0;
  264. SetupFileLocationEntryAnsiStrings = 0;
  265. type
  266. PSetupFileLocationEntry = ^TSetupFileLocationEntry;
  267. TSetupFileLocationEntry = packed record
  268. FirstSlice, LastSlice: Integer;
  269. StartOffset: Longint;
  270. ChunkSuboffset: Integer64;
  271. OriginalSize: Integer64;
  272. ChunkCompressedSize: Integer64;
  273. SHA256Sum: TSHA256Digest;
  274. SourceTimeStamp: TFileTime;
  275. FileVersionMS, FileVersionLS: DWORD;
  276. Flags: set of (floVersionInfoValid, floTimeStampInUTC, floCallInstructionOptimized,
  277. floChunkEncrypted, floChunkCompressed);
  278. end;
  279. const
  280. SetupIconEntryStrings = 13;
  281. SetupIconEntryAnsiStrings = 0;
  282. type
  283. TSetupIconCloseOnExit = (icNoSetting, icYes, icNo);
  284. PSetupIconEntry = ^TSetupIconEntry;
  285. TSetupIconEntry = packed record
  286. IconName, Filename, Parameters, WorkingDir, IconFilename, Comment: String;
  287. Components, Tasks, Languages, Check, AfterInstall, BeforeInstall: String;
  288. AppUserModelID: String;
  289. AppUserModelToastActivatorCLSID: TGUID;
  290. MinVersion, OnlyBelowVersion: TSetupVersionData;
  291. IconIndex, ShowCmd: Integer;
  292. CloseOnExit: TSetupIconCloseOnExit;
  293. HotKey: Word;
  294. Options: set of (ioUninsNeverUninstall, ioCreateOnlyIfFileExists,
  295. ioUseAppPaths, ioExcludeFromShowInNewInstall,
  296. ioPreventPinning, ioHasAppUserModelToastActivatorCLSID);
  297. end;
  298. const
  299. SetupIniEntryStrings = 10;
  300. SetupIniEntryAnsiStrings = 0;
  301. type
  302. PSetupIniEntry = ^TSetupIniEntry;
  303. TSetupIniEntry = packed record
  304. Filename, Section, Entry, Value: String;
  305. Components, Tasks, Languages, Check, AfterInstall, BeforeInstall: String;
  306. MinVersion, OnlyBelowVersion: TSetupVersionData;
  307. Options: set of (ioCreateKeyIfDoesntExist, ioUninsDeleteEntry,
  308. ioUninsDeleteEntireSection, ioUninsDeleteSectionIfEmpty,
  309. { internally used: }
  310. ioHasValue);
  311. end;
  312. const
  313. SetupRegistryEntryStrings = 9;
  314. SetupRegistryEntryAnsiStrings = 0;
  315. type
  316. PSetupRegistryEntry = ^TSetupRegistryEntry;
  317. TSetupRegistryEntry = packed record
  318. Subkey, ValueName, ValueData: String;
  319. Components, Tasks, Languages, Check, AfterInstall, BeforeInstall: String;
  320. MinVersion, OnlyBelowVersion: TSetupVersionData;
  321. RootKey: HKEY;
  322. PermissionsEntry: Smallint;
  323. Typ: (rtNone, rtString, rtExpandString, rtDWord, rtBinary, rtMultiString, rtQWord);
  324. Options: set of (roCreateValueIfDoesntExist, roUninsDeleteValue,
  325. roUninsClearValue, roUninsDeleteEntireKey, roUninsDeleteEntireKeyIfEmpty,
  326. roPreserveStringType, roDeleteKey, roDeleteValue, roNoError,
  327. roDontCreateKey, ro32Bit, ro64Bit);
  328. end;
  329. const
  330. SetupDeleteEntryStrings = 7;
  331. SetupDeleteEntryAnsiStrings = 0;
  332. type
  333. TSetupDeleteType = (dfFiles, dfFilesAndOrSubdirs, dfDirIfEmpty);
  334. PSetupDeleteEntry = ^TSetupDeleteEntry;
  335. TSetupDeleteEntry = packed record
  336. Name: String;
  337. Components, Tasks, Languages, Check, AfterInstall, BeforeInstall: String;
  338. MinVersion, OnlyBelowVersion: TSetupVersionData;
  339. DeleteType: TSetupDeleteType;
  340. end;
  341. const
  342. SetupRunEntryStrings = 13;
  343. SetupRunEntryAnsiStrings = 0;
  344. type
  345. PSetupRunEntry = ^TSetupRunEntry;
  346. TSetupRunEntry = packed record
  347. Name, Parameters, WorkingDir, RunOnceId, StatusMsg, Verb: String;
  348. Description, Components, Tasks, Languages, Check, AfterInstall, BeforeInstall: String;
  349. MinVersion, OnlyBelowVersion: TSetupVersionData;
  350. ShowCmd: Integer;
  351. Wait: (rwWaitUntilTerminated, rwNoWait, rwWaitUntilIdle);
  352. Options: set of (roShellExec, roSkipIfDoesntExist,
  353. roPostInstall, roUnchecked, roSkipIfSilent, roSkipIfNotSilent,
  354. roHideWizard, roRun32Bit, roRun64Bit, roRunAsOriginalUser,
  355. roDontLogParameters, roLogOutput);
  356. end;
  357. const
  358. MaxGrantPermissionEntries = 32; { must keep in synch with Helper.c }
  359. type
  360. { TGrantPermissionEntry is stored inside string fields named 'Permissions' }
  361. TGrantPermissionSid = record { must keep in synch with Helper.c }
  362. Authority: TSIDIdentifierAuthority;
  363. SubAuthCount: Byte;
  364. SubAuth: array[0..1] of DWORD;
  365. end;
  366. TGrantPermissionEntry = record { must keep in synch with Helper.c }
  367. Sid: TGrantPermissionSid;
  368. AccessMask: DWORD;
  369. end;
  370. { A TDiskSliceHeader record follows DiskSliceID in a SETUP-*.BIN file }
  371. TDiskSliceHeader = packed record
  372. TotalSize: Cardinal;
  373. end;
  374. { A TMessageHeader record follows MessagesHdrID in a SETUP.MSG file }
  375. TMessagesHeader = packed record
  376. NumMessages: Cardinal;
  377. TotalSize: Cardinal;
  378. NotTotalSize: Cardinal;
  379. CRCMessages: Longint;
  380. end;
  381. { TSetupLdrOffsetTable is stored inside SetupLdr's SetupLdrOffsetTableResID
  382. RCDATA resource }
  383. PSetupLdrOffsetTable = ^TSetupLdrOffsetTable;
  384. TSetupLdrOffsetTable = record
  385. ID: array[1..12] of AnsiChar; { = SetupLdrOffsetTableID }
  386. Version: UInt32; { = SetupLdrOffsetTableVersion }
  387. TotalSize: Int64; { Minimum expected size of setup.exe }
  388. OffsetEXE: Int64; { Offset of compressed setup.e32 }
  389. UncompressedSizeEXE: UInt32; { Size of setup.e32 before compression }
  390. CRCEXE: Int32; { CRC of setup.e32 before compression }
  391. Offset0: Int64; { Offset of embedded setup-0.bin data }
  392. Offset1: Int64; { Offset of embedded setup-1.bin data,
  393. or 0 when DiskSpanning=yes }
  394. ReservedPadding: UInt32; { Not set (just provides padding) }
  395. TableCRC: Int32; { CRC of all prior fields in this record }
  396. end;
  397. { TMessagesLangOptions is a simplified version of TSetupLanguageEntry that
  398. is used by the uninstaller and RegSvr }
  399. TMessagesLangOptions = packed record
  400. ID: TMessagesLangOptionsID;
  401. DialogFontName: array[0..31] of Char;
  402. DialogFontSize: Integer;
  403. Flags: set of (lfRightToLeft);
  404. end;
  405. TUninstallerMsgTail = packed record
  406. ID: Longint;
  407. Offset: Longint;
  408. end;
  409. const
  410. SetupLdrOffsetTableResID = 11111;
  411. SetupLdrOffsetTableID = 'rDlPtS'#$CD#$E6#$D7#$7B#$0B#$2A;
  412. SetupLdrOffsetTableVersion = 2;
  413. SetupExeModeOffset = $30;
  414. SetupExeModeUninstaller = $6E556E49;
  415. SetupExeModeRegSvr = $53526E49;
  416. UninstallerMsgTailID = $67734D49;
  417. implementation
  418. end.