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.

496 lines
15 KiB

  1. //*************************************************************
  2. //
  3. // Copyright (c) Microsoft Corporation 1998
  4. // All rights reserved
  5. //
  6. // appinfo.hxx
  7. //
  8. //*************************************************************
  9. #ifndef _APPINFO_HXX_
  10. #define _APPINFO_HXX_
  11. typedef struct
  12. {
  13. GUID DeploymentId;
  14. DWORD Flags; // UPGRADE_* bit flags
  15. CAppInfo * pBaseApp;
  16. } UPGRADE_INFO;
  17. typedef enum
  18. {
  19. ACTION_NONE,
  20. ACTION_APPLY,
  21. ACTION_INSTALL,
  22. ACTION_REINSTALL,
  23. ACTION_UNINSTALL,
  24. ACTION_ORPHAN
  25. } APPACTION;
  26. #define UPGRADE_UNINSTALL 0x1 // The upgrade is a rip-n-replace
  27. #define UPGRADE_NOUNINSTALL 0x2 // The upgrade is an overlay
  28. #define UPGRADE_OVER 0x4 // A 'forward link', the app is upgrading over the other
  29. #define UPGRADE_BY 0x8 // A 'backward link', the app is being upgrade by the other
  30. #define UPGRADE_FORCE 0x10 // Upgrade is automatically forced
  31. #define UPGRADE_APPLIED 0x20 // Upgrade is being applied in this policy run
  32. #define UPGRADE_REVERSED 0x40 // This upgrade is not part of the deployment but is the result of an invalid precedence violating upgrade
  33. //
  34. // The following set of constants are used as indices and values in the
  35. // state transitions arrays used in CAppInfo::SetActionPass2 where upgrades
  36. // are dealt with.
  37. //
  38. // Base refers to the 'old' or 'child' in an upgrade relationship.
  39. // Upgraded refers to the 'new' or 'parent' in an upgrade relationship.
  40. //
  41. // Absent indicates that the application was not already advertised or
  42. // installed for the user/machine. Present indicates that is was.
  43. //
  44. // Notforced means the upgrade is optional. Force means the upgrade is
  45. // enforced by policy.
  46. //
  47. #define BASE_STATE_CHOICES 4
  48. #define BASE_STATE_ABSENT_NOTAPPLY 0
  49. #define BASE_STATE_ABSENT_APPLY 1
  50. #define BASE_STATE_PRESENT_NOTAPPLY 2
  51. #define BASE_STATE_PRESENT_APPLY 3
  52. #define UPGRADE_STATE_CHOICES 4
  53. #define UPGRADE_STATE_NOTFORCED_NOTAPPLY 0
  54. #define UPGRADE_STATE_NOTFORCED_APPLY 1
  55. #define UPGRADE_STATE_FORCED_NOTAPPLY 2
  56. #define UPGRADE_STATE_FORCED_APPLY 3
  57. #define NA 0
  58. #define NO 1
  59. #define YES 2
  60. #define SPECIAL1 3 // Yes if the upgrade app is present
  61. #define SPECIAL2 4 // Yes if the upgrade app is not present
  62. #define NO_RSOP_ENTRY 0 // Indicates that an rsop entry should not be logged
  63. // Whether Darwin INSTALLSTATE indicates app is advertised or installed.
  64. #define AppPresent( AppState ) \
  65. ( \
  66. (INSTALLSTATE_ADVERTISED == AppState) || \
  67. (INSTALLSTATE_LOCAL == AppState) || \
  68. (INSTALLSTATE_SOURCE == AppState) || \
  69. (INSTALLSTATE_DEFAULT == AppState) \
  70. )
  71. class CAppStatus : public CListItem, public CPolicyRecordStatus
  72. {
  73. friend class CConflict;
  74. friend class CAppList;
  75. };
  76. class CAppInfo : public CListItem
  77. {
  78. friend class CManagedAppProcessor;
  79. friend class CAppList;
  80. friend class CEvents;
  81. friend class CConflictList;
  82. friend class CConflict;
  83. friend error_status_t
  84. InstallBegin(
  85. handle_t hRpc,
  86. APPKEY * pAppType,
  87. PINSTALLCONTEXT * ppInstallContext,
  88. APPLICATION_INFO * pInstallInfo,
  89. UNINSTALL_APPS * pUninstallApps
  90. );
  91. friend error_status_t
  92. InstallManageApp(
  93. IN PINSTALLCONTEXT pInstallContext,
  94. IN PWSTR pwszDeploymentId,
  95. IN DWORD RollbackStatus,
  96. OUT boolean * pbInstall
  97. );
  98. friend error_status_t
  99. InstallUnmanageApp(
  100. IN PINSTALLCONTEXT pInstallContext,
  101. IN PWSTR pwszDeploymentId,
  102. IN boolean bUnadvertiseOnly
  103. );
  104. friend DWORD
  105. RemoveAppHelper(
  106. WCHAR * ProductCode,
  107. HANDLE hUserToken,
  108. HKEY hKeyRoot,
  109. DWORD ARPStatus,
  110. BOOL * pbProductFound
  111. );
  112. public:
  113. // Initialization from the Directory.
  114. CAppInfo(
  115. CManagedAppProcessor * pManApp,
  116. PACKAGEDISPINFO * pPackageInfo,
  117. BOOL bDemandInstall,
  118. BOOL & bStatus
  119. );
  120. // Initialization from the registry.
  121. CAppInfo(
  122. CManagedAppProcessor * pManApp,
  123. WCHAR * pwszDeploymentId,
  124. BOOL & bStatus
  125. );
  126. // Initialization from a local script file.
  127. CAppInfo(
  128. WCHAR * pwszDeploymentId
  129. );
  130. BOOL
  131. Initialize(
  132. PACKAGEDISPINFO * pPackageInfo
  133. );
  134. ~CAppInfo();
  135. DWORD
  136. InitializePass0();
  137. void
  138. SetActionPass1();
  139. void
  140. SetActionPass2();
  141. void
  142. SetActionPass3();
  143. void
  144. SetActionPass4();
  145. void
  146. SetAction(
  147. APPACTION Action,
  148. DWORD Reason,
  149. CAppInfo* pAppCause
  150. );
  151. DWORD
  152. ProcessApplyActions();
  153. DWORD
  154. ProcessUnapplyActions();
  155. DWORD
  156. ProcessTransformConflicts();
  157. DWORD
  158. CopyToManagedApplication(
  159. MANAGED_APP * pManagedApp
  160. );
  161. BOOL
  162. CopyToApplicationInfo(
  163. APPLICATION_INFO * pApplicationInfo
  164. );
  165. inline WCHAR *
  166. LocalScriptPath()
  167. {
  168. return _pwszLocalScriptPath;
  169. }
  170. inline WCHAR *
  171. ProductId()
  172. {
  173. return _pwszProductId;
  174. }
  175. inline DWORD
  176. InstallUILevel()
  177. {
  178. return _InstallUILevel;
  179. }
  180. inline APPACTION
  181. Action()
  182. {
  183. return _Action;
  184. }
  185. inline GUID&
  186. DeploymentId()
  187. {
  188. return _DeploymentId;
  189. }
  190. BOOL
  191. HasCategory(
  192. WCHAR * pwszCategory
  193. );
  194. DWORD
  195. Assign(
  196. DWORD ScriptFlags = 0,
  197. BOOL bDoAdvertise = TRUE,
  198. BOOL bAddAppData = TRUE
  199. );
  200. DWORD
  201. Install();
  202. DWORD
  203. Reinstall();
  204. DWORD
  205. Unassign(
  206. DWORD ScriptFlags = 0,
  207. BOOL bRemoveAppData = TRUE
  208. );
  209. DWORD
  210. Uninstall(
  211. BOOL bLogFailure = TRUE
  212. );
  213. void
  214. GetDeploymentId( WCHAR* wszDeploymentId)
  215. {
  216. GuidToString(
  217. _DeploymentId,
  218. wszDeploymentId);
  219. }
  220. HRESULT
  221. Write( CPolicyRecord* pRecord );
  222. HRESULT
  223. WriteRemovalProperties( CPolicyRecord* pRemovalRecord );
  224. HRESULT
  225. ClearRemovalProperties( CPolicyRecord* pRecord );
  226. LONG
  227. GetRsopEntryType();
  228. LONG
  229. GetPublicRsopEntryType();
  230. LONG
  231. GetEligibility();
  232. CConflictTable*
  233. GetConflictTable()
  234. {
  235. return &_SupersededApps;
  236. }
  237. BOOL IsSuperseded()
  238. {
  239. return _bSuperseded;
  240. }
  241. void
  242. Supersede()
  243. {
  244. _bSuperseded = TRUE;
  245. }
  246. HRESULT
  247. SetRemovingDeploymentId( GUID* pDeploymentId );
  248. void
  249. SetRsopFailureStatus(
  250. DWORD dwStatus,
  251. DWORD dwEventId);
  252. void
  253. ForceFailureStatus();
  254. private:
  255. void
  256. CheckScriptExistence();
  257. DWORD
  258. CopyScriptIfNeeded();
  259. DWORD
  260. EnforceAssignmentSecurity(
  261. BOOL * pbDidUninstall
  262. );
  263. DWORD
  264. RollbackUpgrades();
  265. BOOL
  266. RequiresUnmanagedRemoval();
  267. void
  268. AddToOverrideList(
  269. GUID * pDeploymentId
  270. );
  271. LONG
  272. InitializeRSOPTransformsList(
  273. PACKAGEDISPINFO* pPackageInfo
  274. );
  275. LONG
  276. InitializeRSOPArchitectureInfo(
  277. PACKAGEDISPINFO* pPackageInfo
  278. );
  279. LONG
  280. InitializeCategoriesList(
  281. PACKAGEDISPINFO* pPackageInfo
  282. );
  283. WCHAR*
  284. GetRsopAppCriteria();
  285. LONG
  286. UpdatePrecedence(
  287. CAppInfo* pLosingApp,
  288. DWORD dwConflict
  289. );
  290. void
  291. LogUpgrades( CPolicyRecord* pRecord );
  292. BOOL
  293. IsLocal();
  294. BOOL
  295. IsGpoInScope();
  296. CManagedAppProcessor * _pManApp; // The machine or user global state object.
  297. GUID _DeploymentId; // Unique static DS object id, never changes
  298. WCHAR * _pwszDeploymentName; // Friendly app name in the ADE/Directory, can change
  299. WCHAR * _pwszGPOId; // Unique static GPO id, a stringized guid, never changes
  300. WCHAR* _pwszSOMId; // DS path to scope of management for the gpo this app comes from
  301. WCHAR* _pwszGPODSPath; // DS Path to the GPO from which this app originates
  302. WCHAR * _pwszGPOName; // Friendly GPO name this app came from, can change
  303. WCHAR * _pwszProductId; // Darwin product id, a stringized guid, never changes
  304. WCHAR * _pwszLocalScriptPath; // Full path to local script
  305. WCHAR * _pwszGPTScriptPath; // Full path to GPT script
  306. DWORD _Upgrades;
  307. UPGRADE_INFO * _pUpgrades; // Apps 'this' is configured to upgrade, built from DS info
  308. DWORD _Overrides;
  309. GUID * _pOverrides; // Apps 'this' is superceding, built during processing
  310. WCHAR * _pwszSupercededIds; // List of superceded deployment ids from the registry
  311. WCHAR * _pwszPublisher; // Friendly name of app publisher
  312. WCHAR * _pwszSupportURL; // The editable support url
  313. DWORD _VersionHi; // High dword of app version
  314. DWORD _VersionLo; // Lo dword of app version
  315. DWORD _PathType; // Indicates setup.exe, darwin package, or other format
  316. FILETIME _USN; // Last modified time for DS package object
  317. LANGID _LangId; // Win32 language identifier
  318. DWORD _LanguageWeight; // magnitude indicates degree of language compatibility
  319. LONG _AssignCount; // Number of full assignments with script copy
  320. DWORD _LocalRevision; // From registry
  321. FILETIME _ScriptTime; // From registry
  322. DWORD _DirectoryRevision; // From Directory
  323. DWORD _InstallUILevel; // From Directory
  324. DWORD _ActFlags; // ACTFLG_s from the Directory
  325. INSTALLSTATE _InstallState; // Darwin install state, only valid if script is present
  326. BOOL _DemandInstall; // Whether we're doing a service-API driven install
  327. DWORD _State; // APPSTATE flags defined in registry.hxx
  328. APPACTION _Action; // Current action to perform on app
  329. DWORD _Status; // Final processing status
  330. BOOL _bNeedsUnmanagedRemove; // TRUE if an unmanaged version of this application must be uninstalled before this application can be applied
  331. BYTE* _rgSecurityDescriptor; // Security descriptor of package in DS in self-relative format
  332. LONG _cbSecurityDescriptor; // length in bytes of Security descriptor of package in DS in self-relative format
  333. CConflictTable _SupersededApps; // The list of applictions superseded by this application in the RSoP
  334. BOOL _bSuperseded; // TRUE if this app has been superseded by another application in the RSoP
  335. BOOL _bRollback; // TRUE if this app was removed but had to be reapplied as a result of a failed upgrade
  336. BOOL _bRemovalLogged; // TRUE if a removal entry was logged for this app (RSoP only)
  337. BOOL _bTransformConflict; // TRUE if a transform conflict occurred when this application was applied
  338. BOOL _bRestored; // TRUE if this app was removed on another machine when its gpo went out of scope
  339. // but came back in scope on this machine
  340. WCHAR** _rgwszTransforms; // List of transform paths that apply to the package, valid only when RSoP is enabled
  341. DWORD _cTransforms; // The number of transforms that apply to this application (RSoP) only
  342. WCHAR** _rgwszCategories; // List of application category guid strings -- valid only for ARP enum or RSoP enabled
  343. DWORD _cCategories; // The number of categories that apply to this application -- ARP or RSoP only
  344. WCHAR* _pwszPackageLocation; // The file system path of the Windows Installer package for this application (RSoP only)
  345. DWORD _cArchitectures; // The count of machine architectures for this application (RSoP only)
  346. LONG* _rgArchitectures; // A vector of Win32 PROCESSOR_ARCHITECTURE values that apply to this application (RSoP only)
  347. DWORD _PrimaryArchitecture; // The Win32 PROCESSOR_ARCHITECTURE value corresponding to the architecture that we are
  348. // assuming for this package. Most packages only support one architecture, so this is
  349. // usually the same as the architecture in _rgArchitectures[0]. (RSoP only)
  350. DWORD _dwApplyCause; // Reason this application was applied (RSoP only)
  351. DWORD _dwRemovalCause; // Reason this application was removed (RSoP only)
  352. WCHAR* _pwszRemovingDeploymentId; // Deployment Id of application that caused this app to get removed (RSoP only)
  353. CList _StatusList; // List of statuses for operations performed on this object (RSoP only)
  354. BOOL _bSupersedesAssigned; // TRUE if this app directly or indirectly supersedes an assigned app
  355. DWORD _dwUserApplyCause; // Current apply cause for user installed apps (RSoP only)
  356. WCHAR* _wszDemandSpec; // On-demand install specifier (if any) at the time the app was applied (e.g. clsid, progid, or file extension that caused install) -- allocated and must be freed in destructor
  357. WCHAR* _wszDemandProp; // The WMI property corresponding to the demand specifier (if any) -- this is not allocated and should not be freed by the destructor
  358. };
  359. DWORD
  360. CallMsiConfigureProduct(
  361. WCHAR * pwszProduct,
  362. int InstallLevel,
  363. INSTALLSTATE InstallState,
  364. WCHAR * pwszCommandLine
  365. );
  366. DWORD
  367. CallMsiReinstallProduct(
  368. WCHAR * pwszProduct
  369. );
  370. DWORD
  371. CallMsiAdvertiseScript(
  372. WCHAR * pwszScriptFile,
  373. DWORD Flags,
  374. PHKEY phkClasses,
  375. BOOL bRemoveItems
  376. );
  377. #endif