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.

213 lines
6.0 KiB

  1. //+------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1996 - 1997
  5. //
  6. // File: appcont.hxx
  7. //
  8. // Contents: Definition for Class factory and IUnknown methods
  9. // for CAppContainer
  10. //
  11. // Author: DebiM
  12. //
  13. //-------------------------------------------------------------------------
  14. //
  15. // APPFILTER flags
  16. //
  17. const DWORD APPFILTER_INCLUDE_ASSIGNED = 0x1; // Add assigned
  18. const DWORD APPFILTER_INCLUDE_UPGRADES = 0x2; // Add packages that have upgrades
  19. const DWORD APPFILTER_REQUIRE_PUBLISHED = 0x10000; // Published
  20. const DWORD APPFILTER_REQUIRE_MSI = 0x40000; // Msi
  21. const DWORD APPFILTER_REQUIRE_VISIBLE = 0x80000; // Visible
  22. const DWORD APPFILTER_REQUIRE_AUTOINSTALL = 0x100000; // Auto-Install
  23. const DWORD APPFILTER_REQUIRE_NON_REMOVED = 0x200000; // Apps that are not removed
  24. const DWORD APPFILTER_REQUIRE_THIS_LANGUAGE = 0x400000; // Apps that match the language of the caller
  25. const DWORD APPFILTER_REQUIRE_THIS_PLATFORM = 0x800000; // Apps that match the platform of the caller
  26. const DWORD APPFILTER_CONTEXT_ARP = 0x1000000; // Indicates that the calling context is ARP
  27. const DWORD APPFILTER_CONTEXT_POLICY = 0x2000000; // Indicates that the calling context is policy
  28. const DWORD APPFILTER_CONTEXT_RSOP = 0x4000000; // Indicates that the context includes rsop logging
  29. const DWORD APPFILTER_INCLUDE_ALL = 0x8000000; // All
  30. void GetExpiredTime( FILETIME* pftCurrentTime, FILETIME* pftExpiredTime );
  31. class CAppContainerCF : public IClassFactory
  32. {
  33. public:
  34. CAppContainerCF();
  35. ~CAppContainerCF();
  36. virtual HRESULT __stdcall QueryInterface(REFIID riid, void * * ppvObject);
  37. virtual ULONG __stdcall AddRef();
  38. virtual ULONG __stdcall Release();
  39. virtual HRESULT __stdcall CreateInstance(IUnknown * pUnkOuter, REFIID riid, void * * ppvObject);
  40. virtual HRESULT __stdcall LockServer(BOOL fLock);
  41. HRESULT __stdcall CreateConnectedInstance(
  42. CServerContext* pServerContext,
  43. LPOLESTR pszPath,
  44. PSID pUserSid,
  45. PRSOPTOKEN pRsopToken,
  46. BOOL fCache,
  47. void * * ppvObject);
  48. protected:
  49. unsigned long m_uRefs;
  50. };
  51. #define CLSIDCACHESIZE 20
  52. #define MAXCLASSSTORES 20
  53. //
  54. // The purge time uses the interval of the FILETIME structure --
  55. // 100 ns intervals. This purge time represents 30 minutes. The math
  56. // below is performed at compile time -- all these values are in the
  57. // the range of a 64 bit integer -- there is no overflow
  58. //
  59. #define FILE_TIME_INTERVALS_PER_SECOND ( (ULONGLONG) 10000000 )
  60. #define CACHE_PURGE_TIME_MINUTES 30
  61. #define CACHE_PURGE_TIME_SECONDS ( CACHE_PURGE_TIME_MINUTES * 60 )
  62. #define CACHE_PURGE_TIME_FILETIME_INTERVAL ( CACHE_PURGE_TIME_SECONDS * FILE_TIME_INTERVALS_PER_SECOND )
  63. //
  64. // Cached Class Store Bindings
  65. //
  66. struct BindingsType {
  67. BindingsType()
  68. {
  69. memset( this, 0, sizeof(*this) );
  70. }
  71. LPOLESTR szStorePath;
  72. CServerContext ServerContext;
  73. IClassAccess *pIClassAccess;
  74. HRESULT Hr;
  75. PSID Sid;
  76. FILETIME Time;
  77. };
  78. typedef struct ClassStoreCache_t {
  79. BindingsType Bindings[MAXCLASSSTORES];
  80. DWORD start, end, sz;
  81. } ClassStoreCacheType;
  82. //
  83. // Cached results of on-demand activations
  84. //
  85. typedef struct CacheClsid_t {
  86. CLSID Clsid;
  87. DWORD Ctx;
  88. FILETIME Time;
  89. } CacheClsidType;
  90. typedef struct ClsidCache_t {
  91. CacheClsidType ElemArr[20];
  92. DWORD start, end, sz;
  93. } ClsidCacheType;
  94. //
  95. // ClassContainer class.
  96. //
  97. class CAppContainer :
  98. public IClassAccess
  99. {
  100. private:
  101. WCHAR m_szContainerName[_MAX_PATH];
  102. WCHAR * m_szPackageName;
  103. BOOL m_fOpen;
  104. HANDLE m_ADsContainer;
  105. HANDLE m_ADsPackageContainer;
  106. GUID m_PolicyId;
  107. ClsidCacheType m_KnownMissingClsidCache;
  108. WCHAR* m_szGpoPath;
  109. PRSOPTOKEN m_pRsopToken;
  110. CServerContext m_ServerContext;
  111. public:
  112. CAppContainer();
  113. CAppContainer(CServerContext* pServerContext, LPOLESTR pszPath, PRSOPTOKEN pRsopToken, HRESULT *phr);
  114. ~CAppContainer(void);
  115. // IUnknown
  116. HRESULT __stdcall QueryInterface(
  117. REFIID iid,
  118. void ** ppv );
  119. ULONG __stdcall AddRef();
  120. ULONG __stdcall Release();
  121. //
  122. // IClassAccess
  123. //
  124. HRESULT __stdcall GetAppInfo(
  125. uCLSSPEC * pClassSpec, // Class Spec (CLSID/Ext/MIME)
  126. QUERYCONTEXT * pQryContext, // Query Attributes
  127. PACKAGEDISPINFO * pPackageInfo
  128. );
  129. HRESULT __stdcall EnumPackages (
  130. LPOLESTR pszPackageName,
  131. GUID *pCategory,
  132. ULONGLONG *pLastUsn,
  133. DWORD dwAppFlags, // AppType options
  134. IEnumPackage **ppIEnumPackage
  135. );
  136. HRESULT __stdcall SetClassStorePath(
  137. LPOLESTR pszClassStorePath,
  138. void* pRsopToken
  139. )
  140. {
  141. return E_NOTIMPL;
  142. }
  143. //
  144. // Utility functions
  145. //
  146. HRESULT __stdcall GetPackageDetails (
  147. LPOLESTR pszPackageId,
  148. PACKAGEDETAIL *pPackageDetail
  149. );
  150. DWORD __stdcall ChooseBestFit(
  151. PACKAGEDISPINFO *PackageInfo,
  152. UINT *rgPriority,
  153. DWORD cRowsFetched
  154. );
  155. HRESULT __stdcall UpdateUsn(CSUSN *pStoreUsn);
  156. HRESULT __stdcall GetStoreUsn(CSUSN *pStoreUsn);
  157. //----------------------------------------------------------------------
  158. protected:
  159. unsigned long m_uRefs;
  160. };