Source code of Windows XP (NT5)
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.

334 lines
10 KiB

  1. #include "cstore.h"
  2. #define SCHEMA_VERSION_NUMBER 1740
  3. #define STRINGGUIDLEN 37
  4. #define STRINGGUIDRDNLEN 37+3
  5. typedef WCHAR STRINGGUID [STRINGGUIDLEN];
  6. typedef WCHAR STRINGGUIDRDN [STRINGGUIDRDNLEN];
  7. typedef FILETIME CSUSN;
  8. int StringFromGUID(REFGUID rguid, LPWSTR lptsz);
  9. int RDNFromGUID(REFGUID rguid, LPWSTR lptsz);
  10. void GUIDFromString(LPWSTR psz,
  11. GUID *pclsguid);
  12. BOOL IsNullGuid(REFGUID rguid);
  13. DWORD NumDigits10(DWORD Value);
  14. DWORD GetPropertyFromAttr(ADS_ATTR_INFO *pattr, DWORD cNum, WCHAR *szProperty);
  15. void FreeAttr(ADS_ATTR_INFO attr);
  16. void PackStrArrToAttr(ADS_ATTR_INFO *attr, WCHAR *szProperty,
  17. WCHAR **pszAttr, DWORD num);
  18. void PackDWArrToAttr(ADS_ATTR_INFO *attr, WCHAR *szProperty,
  19. DWORD *pAttr, DWORD num);
  20. void PackGUIDArrToAttr(ADS_ATTR_INFO *attr, WCHAR *szProperty,
  21. GUID *pAttr, DWORD num);
  22. void PackStrToAttr(ADS_ATTR_INFO *attr, WCHAR *szProperty,
  23. WCHAR *szAttr);
  24. void PackDWToAttr(ADS_ATTR_INFO *attr, WCHAR *szProperty,
  25. DWORD Attr);
  26. void PackGUIDToAttr(ADS_ATTR_INFO *attr, WCHAR *szProperty,
  27. GUID *pAttr);
  28. void PackBinToAttr(ADS_ATTR_INFO *attr, WCHAR *szProperty,
  29. BYTE *pAttr, DWORD sz);
  30. void PackStrArrToAttrEx(ADS_ATTR_INFO *attr, WCHAR *szProperty,
  31. WCHAR **pszAttr, DWORD num, BOOL APPEND);
  32. void PackDWArrToAttrEx(ADS_ATTR_INFO *attr, WCHAR *szProperty,
  33. DWORD *pAttr, DWORD num, BOOL APPEND);
  34. void PackGUIDArrToAttrEx(ADS_ATTR_INFO *attr, WCHAR *szProperty,
  35. GUID *pAttr, DWORD num, BOOL APPEND);
  36. // ADS_ATTR_INFO structure is returned in GetObjectAttributes.
  37. // this is the same structure as columns but has different
  38. // fields and has unfortunately 1 unused different member.
  39. // this doesn't actually copy and hence should be freed if required
  40. // by the user but allocates an array of req'd size in case
  41. // of Unpack*Arr
  42. template <class AttrOrCol>
  43. HRESULT UnpackStrArrFrom(AttrOrCol AorC, WCHAR ***ppszAttr, DWORD *num)
  44. {
  45. DWORD i;
  46. *num = 0;
  47. *ppszAttr = (LPOLESTR *)CoTaskMemAlloc(sizeof(LPOLESTR)*(AorC.dwNumValues));
  48. if (!(*ppszAttr))
  49. return E_OUTOFMEMORY;
  50. for (i = 0; (i < (AorC.dwNumValues)); i++)
  51. (*ppszAttr)[i] = AorC.pADsValues[i].DNString;
  52. *num = AorC.dwNumValues;
  53. return S_OK;
  54. }
  55. template <class AttrOrCol>
  56. HRESULT UnpackDWArrFrom(AttrOrCol AorC, DWORD **pAttr, DWORD *num)
  57. {
  58. DWORD i;
  59. ASSERT(AorC.dwADsType == ADSTYPE_INTEGER);
  60. *num = 0;
  61. *pAttr = (DWORD *)CoTaskMemAlloc(sizeof(DWORD)*(AorC.dwNumValues));
  62. if (!(*pAttr))
  63. return E_OUTOFMEMORY;
  64. for (i = 0; (i < (AorC.dwNumValues)); i++)
  65. (*pAttr)[i] = (DWORD)AorC.pADsValues[i].Integer;
  66. *num = AorC.dwNumValues;
  67. return S_OK;
  68. }
  69. template <class AttrOrCol>
  70. HRESULT UnpackStrFrom(AttrOrCol AorC, WCHAR **pszAttr)
  71. {
  72. ASSERT(AorC.dwNumValues <= 1);
  73. if (AorC.dwNumValues)
  74. *pszAttr = AorC.pADsValues[0].DNString;
  75. else
  76. *pszAttr = NULL;
  77. return S_OK;
  78. }
  79. template <class AttrOrCol>
  80. HRESULT UnpackDWFrom(AttrOrCol AorC, DWORD *pAttr)
  81. {
  82. ASSERT(AorC.dwADsType == ADSTYPE_INTEGER);
  83. ASSERT(AorC.dwNumValues <= 1);
  84. if (AorC.dwNumValues)
  85. *pAttr = (DWORD)AorC.pADsValues[0].Integer;
  86. else
  87. *pAttr = 0;
  88. return S_OK;
  89. }
  90. template <class AttrOrCol>
  91. HRESULT UnpackStrArrAllocFrom(AttrOrCol AorC, WCHAR ***ppszAttr, DWORD *num)
  92. {
  93. DWORD i;
  94. *num = 0;
  95. *ppszAttr = (LPOLESTR *)CoTaskMemAlloc(sizeof(LPOLESTR)*(AorC.dwNumValues));
  96. if (!(*ppszAttr))
  97. return E_OUTOFMEMORY;
  98. for (i = 0; (i < (AorC.dwNumValues)); i++) {
  99. (*ppszAttr)[i] = (WCHAR *)CoTaskMemAlloc(sizeof(WCHAR)*
  100. (1+wcslen(AorC.pADsValues[i].DNString)));
  101. if (!((*ppszAttr)[i])) // BUGBUG:: free all the remaining strings.
  102. return E_OUTOFMEMORY;
  103. wcscpy((*ppszAttr)[i], AorC.pADsValues[i].DNString);
  104. }
  105. *num = AorC.dwNumValues;
  106. return S_OK;
  107. }
  108. template <class AttrOrCol>
  109. HRESULT UnpackStrAllocFrom(AttrOrCol AorC, WCHAR **pszAttr)
  110. {
  111. ASSERT(AorC.dwNumValues <= 1);
  112. if (AorC.dwNumValues) {
  113. *pszAttr = (LPOLESTR)CoTaskMemAlloc(sizeof(WCHAR)*
  114. (wcslen(AorC.pADsValues[0].DNString)+1));
  115. if (!(*pszAttr))
  116. return E_OUTOFMEMORY;
  117. wcscpy(*pszAttr, AorC.pADsValues[0].DNString);
  118. }
  119. else
  120. *pszAttr = NULL;
  121. return S_OK;
  122. }
  123. // GUIDS are not returned properly when using GetObjectAttributes.
  124. // Use only search when a GUID has to be returned.
  125. template <class AttrOrCol>
  126. HRESULT UnpackGUIDFrom(AttrOrCol AorC, GUID *pAttr)
  127. {
  128. ASSERT(AorC.dwNumValues <= 1);
  129. if (AorC.dwNumValues) {
  130. ASSERT(AorC.pADsValues[0].OctetString.dwLength == sizeof(GUID));
  131. memcpy(pAttr, AorC.pADsValues[0].OctetString.lpValue,
  132. AorC.pADsValues[0].OctetString.dwLength);
  133. }
  134. else
  135. memset((void *)(pAttr), 0, sizeof(GUID));
  136. return S_OK;
  137. }
  138. template <class AttrOrCol>
  139. HRESULT UnpackGUIDArrFrom(AttrOrCol AorC, GUID **pAttr, DWORD *num)
  140. {
  141. DWORD i;
  142. *pAttr = (GUID *)CoTaskMemAlloc(sizeof(GUID)*AorC.dwNumValues);
  143. if (!(*pAttr))
  144. return E_OUTOFMEMORY;
  145. for (i = 0; i < (AorC.dwNumValues); i++)
  146. {
  147. ASSERT(AorC.pADsValues[i].OctetString.dwLength == sizeof(GUID));
  148. memcpy((*pAttr)+i, AorC.pADsValues[i].OctetString.lpValue,
  149. AorC.pADsValues[i].OctetString.dwLength);
  150. }
  151. *num = AorC.dwNumValues;
  152. return S_OK;
  153. }
  154. #define CLASSSTORE_EVENT_SOURCE L"Application Deployment"
  155. HRESULT RemapErrorCode(HRESULT ErrorCode, LPOLESTR szContainerName);
  156. void UnpackPlatform (DWORD *pdwArch, CSPLATFORM *pPlatform);
  157. void PackPlatform (DWORD dwArch, CSPLATFORM *pPlatform);
  158. ULONG FindDescription(LPOLESTR *desc, ULONG cdesc, LCID *plcid,
  159. LPOLESTR szDescription, BOOL GetPrimary);
  160. HRESULT GetCategoryLocaleDesc(LPOLESTR *pdesc, ULONG cdesc, LCID *plcid,
  161. LPOLESTR szDescription);
  162. HRESULT CreateRepository(LPOLESTR szParentPath,
  163. LPOLESTR szStoreName,
  164. LPOLESTR szPolicyName);
  165. HRESULT DeleteRepository(LPOLESTR szParentPath, LPOLESTR szStoreName);
  166. HRESULT GetRootPath(WCHAR *szRootPath);
  167. STDAPI
  168. ReleasePackageInfo(PACKAGEDISPINFO *PackageInfo);
  169. HRESULT GetPackageDetail (HANDLE hPackageADs,
  170. LPOLESTR szFullClassName,
  171. PACKAGEDETAIL *pPackageDetail);
  172. #define LDAPPREFIX L"LDAP://"
  173. #define LDAPPREFIXLENGTH 7
  174. #define LDAPPATHSEP L","
  175. #define CLASS_CS_CONTAINER L"classStore"
  176. #define CLASS_CS_CLASS L"classRegistration"
  177. #define CLASS_CS_PACKAGE L"packageRegistration"
  178. #define CLASS_CS_CATEGORY L"categoryRegistration"
  179. #define CLASSSTORECONTAINERNAME L"CN=Class Store"
  180. #define CLASSCONTAINERNAME L"CN=Classes"
  181. #define PACKAGECONTAINERNAME L"CN=Packages"
  182. #define CATEGORYCONTAINERNAME L"CN=Categories"
  183. #define APPCATEGORYCONTAINERNAME L"CN=AppCategories,CN=Default Domain Policy,CN=System,"
  184. //
  185. // ClassStoreContainer object propertynames
  186. //
  187. #define STOREVERSION L"appSchemaVersion"
  188. #define STOREUSN L"lastUpdateSequence"
  189. #define POLICYNAME L"extensionName"
  190. #define POLICYDN L"displayName"
  191. #define GPNAME L"displayName"
  192. //
  193. // Class object propertynames
  194. //
  195. #define PROGIDLIST L"cOMProgID"
  196. #define CLASSCLSID L"cOMCLSID"
  197. #define TREATASCLSID L"cOMTreatAsClassId"
  198. #define IMPL_CATEGORIES L"implementedCategories"
  199. #define REQ_CATEGORIES L"requiredCategories"
  200. #define CLASSREFCOUNTER L"flags" // BUGBUG:: schema to be put in.
  201. //
  202. // Package object propertynames
  203. //
  204. #define PKGTLBIDLIST L"cOMTypelibId"
  205. #define PKGCLSIDLIST L"cOMClassID"
  206. #define PKGPROGIDLIST L"cOMProgID"
  207. #define PKGIIDLIST L"cOMInterfaceID"
  208. #define PKGFILEEXTNLIST L"fileExtPriority"
  209. #define LOCALEID L"localeID"
  210. #define ARCHLIST L"machineArchitecture"
  211. #define VERSIONHI L"versionNumberHi"
  212. #define VERSIONLO L"versionNumberLo"
  213. #define REVISION L"revision"
  214. #define PACKAGETYPE L"packageType"
  215. #define PACKAGEFLAGS L"packageFlags"
  216. #define PACKAGENAME L"packageName"
  217. #define SCRIPTPATH L"msiScriptPath"
  218. #define SCRIPTNAME L"msiScriptName"
  219. #define SCRIPTSIZE L"msiScriptSize"
  220. #define HELPURL L"url"
  221. #define SETUPCOMMAND L"setupCommand"
  222. #define PKGUSN L"lastUpdateSequence"
  223. #define MSIFILELIST L"msiFileList"
  224. #define PKGCATEGORYLIST L"categories"
  225. #define UPGRADESPACKAGES L"canUpgradeScript"
  226. #define UILEVEL L"installUiLevel"
  227. #define PKGSCRIPT L"msiScript"
  228. #define PRODUCTCODE L"productCode"
  229. #define MVIPC L"upgradeProductCode" // BUGBUG:: Schema name has to change
  230. #define PUBLISHER L"vendor"
  231. //
  232. // Category object Propertynames
  233. //
  234. #define DESCRIPTION L"description"
  235. #define LOCALEDESCRIPTION L"localizedDescription"
  236. #define DEFAULT_LOCALE_ID L"localeID"
  237. #define CATEGORYCATID L"categoryId"
  238. #define OBJECTCLASS L"objectclass"
  239. #define OBJECTDN L"ADsPath"
  240. #define OBJECTGUID L"objectGUID"
  241. #define DEFAULTCLASSSTOREPATH L"defaultClassStore"
  242. #define CAT_DESC_DELIMITER L"::" // Between Locale & Desc in Category
  243. #define CAT_DESC_DELIM_LEN 2
  244. #define PKG_UPG_DELIMITER1 L"\\\\" // Between Class Store Name & PkgGuid
  245. #define PKG_UPG_DELIM1_LEN 2
  246. #define PKG_UPG_DELIMITER2 L":" // Between PkgGuid & Flag
  247. #define PKG_UPG_DELIM2_LEN 1
  248. extern LPOLESTR pszInstallInfoAttrNames[];
  249. extern DWORD cInstallInfoAttr;
  250. extern LPOLESTR pszPackageInfoAttrNames[];
  251. extern DWORD cPackageInfoAttr;
  252. extern LPOLESTR pszPackageDetailAttrNames[];
  253. extern DWORD cPackageDetailAttr;
  254. extern LPOLESTR pszDeleteAttrNames[];
  255. extern DWORD cDeleteAttr;
  256. extern LPOLESTR pszCategoryAttrNames[];
  257. extern DWORD cCategoryAttr;