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.

304 lines
7.4 KiB

  1. //+--------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1994 - 2001.
  5. //
  6. // File: msiclass.h
  7. //
  8. // Contents: msi class collection abstraction
  9. //
  10. // Classes:
  11. //
  12. //
  13. // History: 4-14-2000 adamed Created
  14. //
  15. //---------------------------------------------------------------------------
  16. #if !defined(__MSICLASS_H__)
  17. #define __MSICLASS_H__
  18. //
  19. // MSI Tables containing classes
  20. //
  21. #define TABLE_FILE_EXTENSIONS L"Extension"
  22. #define TABLE_CLSIDS L"Class"
  23. #define TABLE_PROGIDS L"ProgId"
  24. //
  25. // Package metadata queries
  26. //
  27. //
  28. // Property table queries -- used to find out global information about the package
  29. //
  30. //
  31. // This query is used to determine the package's global install level
  32. //
  33. #define QUERY_INSTALLLEVEL L"SELECT DISTINCT `Value` FROM `Property` WHERE `Property`=\'INSTALLLEVEL\'"
  34. // This query is used to determine the package's friendly name
  35. //
  36. #define QUERY_FRIENDLYNAME L"SELECT DISTINCT `Value` FROM `Property` WHERE `Property`=\'ProductName\'"
  37. //
  38. // Feature table queries -- these are used to find out which features will be
  39. // advertised so that we can later determine if the classes associated with the
  40. // features should be advertised
  41. //
  42. //
  43. // This query is less a query and more a modification operation. It adds an additional
  44. // temporary "_IsAdvertised" column to the table. We use this to perform joins in
  45. // subsequent queries.
  46. //
  47. #define QUERY_ADVERTISED_FEATURES_CREATE L"ALTER TABLE `Feature` ADD `_IsAdvertised` INT TEMPORARY HOLD"
  48. //
  49. // Again, this query really serves as a modification operation. This one initializes the
  50. // temporary "_IsAdvertised" column to 0, which in our parlance is the same as initializing
  51. // the column to "not advertised."
  52. //
  53. #define QUERY_ADVERTISED_FEATURES_INIT L"UPDATE `Feature` SET `_IsAdvertised`=0"
  54. //
  55. // This is a conventional query -- this returns all the features in the package
  56. //
  57. #define QUERY_ADVERTISED_FEATURES_RESULT L"SELECT `Feature`, `Level`, `Attributes` FROM `Feature`"
  58. //
  59. // Another modification query -- this eliminates the temporary changes (the additional
  60. // column) we made to the table in the create query.
  61. //
  62. #define QUERY_ADVERTISED_FEATURES_DESTROY L"ALTER TABLE `Feature` FREE"
  63. //
  64. // The last modification query -- this allows us to set a particular feature's "_IsAdvertised"
  65. // column to 1, which will indicate that the feature should be advertised.
  66. //
  67. #define QUERY_FEATURES_SET L"UPDATE `Feature` SET `_IsAdvertised`=1 WHERE `Feature`=?"
  68. //
  69. // Classes queries -- retrieves file extensions, clsid's, and progid's of the package
  70. //
  71. //
  72. // The rest of these queries are straightforward "read-only" queries. They are all joins
  73. // to the feature table, requiring that the feature table's "_IsAdvertised" property
  74. // is set to the advertised state (1). Thus, these queries will only give us classes that
  75. // should be advertised
  76. //
  77. //
  78. // File extensions query
  79. //
  80. #define QUERY_EXTENSIONS L"SELECT DISTINCT `Extension` FROM `Extension`, `Feature` WHERE `Extension` IS NOT NULL " \
  81. L"AND `Extension`.`Feature_`=`Feature`.`Feature` AND `Feature`.`_IsAdvertised`=1"
  82. //
  83. // Clsid query
  84. //
  85. #define QUERY_CLSIDS L"SELECT DISTINCT `CLSID`, `Context`, `Component`.`Attributes` FROM `Class`, `Feature`, " \
  86. L"`Component` WHERE `CLSID` IS NOT NULL AND `Class`.`Feature_`=`Feature`.`Feature` " \
  87. L"AND `Feature`.`_IsAdvertised`=1 AND `Component`.`Component`=`Class`.`Component_`"
  88. //
  89. // ProgId query
  90. //
  91. #define QUERY_VERSION_INDEPENDENT_PROGIDS L"SELECT DISTINCT `ProgId`,`CLSID` FROM `ProgId`, `Class`, `Feature` WHERE `ProgId` IS NOT NULL " \
  92. L"AND `ProgId`.`Class_`=`Class`.`CLSID` AND `Class`.`Feature_`=`Feature`.`Feature` " \
  93. L"AND `Feature`.`_IsAdvertised`=1"
  94. //
  95. // COM clsctx values as they are stored in the package's class (clsid) table
  96. //
  97. #define COM_INPROC_CONTEXT L"InprocServer32"
  98. #define COM_INPROCHANDLER_CONTEXT L"InprocHandler32"
  99. #define COM_LOCALSERVER_CONTEXT L"LocalServer32"
  100. #define COM_REMOTESERVER_CONTEXT L"RemoteServer"
  101. //
  102. // MSI attribute flags
  103. //
  104. #define MSI_64BIT_CLASS msidbComponentAttributes64bit
  105. #define MSI_DISABLEADVERTISE msidbFeatureAttributesDisallowAdvertise
  106. #define CLASS_ALLOC_SIZE 256
  107. //
  108. // Indices of colums for each read-only query
  109. //
  110. enum
  111. {
  112. PROPERTY_COLUMN_VALUE = 1
  113. };
  114. enum
  115. {
  116. FEATURE_COLUMN_FEATURE = 1,
  117. FEATURE_COLUMN_LEVEL,
  118. FEATURE_COLUMN_ATTRIBUTES
  119. };
  120. enum
  121. {
  122. EXTENSION_COLUMN_EXTENSION = 1
  123. };
  124. enum
  125. {
  126. CLSID_COLUMN_CLSID = 1,
  127. CLSID_COLUMN_CONTEXT,
  128. CLSID_COLUMN_ATTRIBUTES
  129. };
  130. enum
  131. {
  132. PROGID_COLUMN_PROGID = 1,
  133. PROGID_COLUMN_CLSID
  134. };
  135. enum
  136. {
  137. TYPE_EXTENSION,
  138. TYPE_CLSID,
  139. TYPE_PROGID,
  140. TYPE_COUNT
  141. };
  142. //
  143. // Structure describing where to write an atom
  144. // of class information. It is also used as
  145. // an intermediate scratch pad by CClassCollection
  146. // in between private method calls to keep track
  147. // of when and where to allocate new memory
  148. // for retrieved classes.
  149. //
  150. struct DataDestination
  151. {
  152. DataDestination(
  153. DWORD dwType,
  154. void** prgpvDestination,
  155. UINT* pcCurrent,
  156. UINT* pcMax);
  157. DWORD _cbElementSize;
  158. UINT* _pcCurrent;
  159. UINT* _pcMax;
  160. void** _ppvData;
  161. };
  162. //
  163. // Class that uses queries to create a collection of
  164. // a package's class data
  165. //
  166. class CClassCollection
  167. {
  168. public:
  169. CClassCollection( PACKAGEDETAIL* pPackageDetail );
  170. HRESULT
  171. GetClasses( BOOL bFileExtensionsOnly );
  172. private:
  173. LONG
  174. GetClsids();
  175. LONG
  176. GetProgIds();
  177. LONG
  178. GetExtensions();
  179. LONG
  180. GetElements(
  181. DWORD dwType,
  182. DataDestination* pDestination);
  183. LONG
  184. FlagAdvertisableFeatures();
  185. LONG
  186. RemoveAdvertisableFeatureFlags();
  187. LONG
  188. GetInstallLevel();
  189. LONG
  190. GetFriendlyName();
  191. LONG
  192. GetFeatureAdvertiseState(
  193. CMsiRecord* pFeatureRecord,
  194. BOOL* pbAdvertised );
  195. LONG
  196. AddElement(
  197. void* pvDataSource,
  198. DataDestination* pDataDestination);
  199. LONG
  200. ProcessElement(
  201. DWORD dwType,
  202. CMsiRecord* pRecord,
  203. DataDestination* pDataDestination);
  204. LONG
  205. ProcessExtension(
  206. CMsiRecord* pRecord,
  207. WCHAR** ppwszExtension);
  208. LONG
  209. ProcessClsid(
  210. CMsiRecord* pRecord,
  211. CLASSDETAIL* pClsid,
  212. BOOL* pbIgnoreClsid);
  213. LONG
  214. ProcessProgId(
  215. CMsiRecord* pRecord,
  216. DataDestination* pDataDestination,
  217. WCHAR** ppwszProgId);
  218. LONG
  219. FindClass(
  220. WCHAR* wszClsid,
  221. CLASSDETAIL** ppClass );
  222. void
  223. FreeClassDetail( CLASSDETAIL* pClass );
  224. CMsiDatabase _Database;
  225. PACKAGEDETAIL* _pPackageDetail;
  226. DWORD _cMaxClsids;
  227. DWORD _cMaxExtensions;
  228. UINT _InstallLevel;
  229. static WCHAR* _wszQueries[ TYPE_COUNT ];
  230. };
  231. #endif // __MSICLASS_H__