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.

1649 lines
48 KiB

  1. ///////////////////////////////////////////////////////////////////////////////
  2. //
  3. // File: obj.h
  4. //
  5. // History: 19-Nov-99 markder Created.
  6. // 16-Nov-00 markder Converted from ShimDatabase.h, rewritten
  7. // 15-Jan-02 jdoherty Modified code to add ID to additional tags.
  8. //
  9. // Desc: This file contains definitions of the SdbDatabase object model.
  10. //
  11. ///////////////////////////////////////////////////////////////////////////////
  12. #if !defined(AFX_OBJ_H__5C16373A_D713_46CD_B8BF_7755216C62E0__INCLUDED_)
  13. #define AFX_OBJ_H__5C16373A_D713_46CD_B8BF_7755216C62E0__INCLUDED_
  14. #if _MSC_VER > 1000
  15. #pragma once
  16. #endif // _MSC_VER > 1000
  17. #include "xml.h"
  18. #include "utils.h"
  19. extern DWORD g_dwCurrentWriteFilter;
  20. extern DATE g_dtCurrentWriteRevisionCutoff;
  21. //
  22. // Common map types
  23. //
  24. typedef CMap<DWORD, DWORD, DWORD, DWORD> CMapDWORDToDWORD;
  25. //
  26. // These definitions are used by SdbMatchingFile::m_dwMask
  27. //
  28. #define SDB_MATCHINGINFO_SIZE 0x00000001
  29. #define SDB_MATCHINGINFO_CHECKSUM 0x00000002
  30. #define SDB_MATCHINGINFO_REGISTRY_ENTRY 0x00000004
  31. #define SDB_MATCHINGINFO_COMPANY_NAME 0x00000008
  32. #define SDB_MATCHINGINFO_PRODUCT_NAME 0x00000010
  33. #define SDB_MATCHINGINFO_PRODUCT_VERSION 0x00000020
  34. #define SDB_MATCHINGINFO_FILE_DESCRIPTION 0x00000040
  35. #define SDB_MATCHINGINFO_BIN_FILE_VERSION 0x00000080
  36. #define SDB_MATCHINGINFO_BIN_PRODUCT_VERSION 0x00000100
  37. #define SDB_MATCHINGINFO_MODULE_TYPE 0x00000200
  38. #define SDB_MATCHINGINFO_VERFILEDATEHI 0x00000400
  39. #define SDB_MATCHINGINFO_VERFILEDATELO 0x00000800
  40. #define SDB_MATCHINGINFO_VERFILEOS 0x00001000
  41. #define SDB_MATCHINGINFO_VERFILETYPE 0x00002000
  42. #define SDB_MATCHINGINFO_PE_CHECKSUM 0x00004000
  43. #define SDB_MATCHINGINFO_FILE_VERSION 0x00008000
  44. #define SDB_MATCHINGINFO_ORIGINAL_FILENAME 0x00010000
  45. #define SDB_MATCHINGINFO_INTERNAL_NAME 0x00020000
  46. #define SDB_MATCHINGINFO_LEGAL_COPYRIGHT 0x00040000
  47. #define SDB_MATCHINGINFO_16BIT_DESCRIPTION 0x00080000
  48. #define SDB_MATCHINGINFO_UPTO_BIN_PRODUCT_VERSION 0x00100000
  49. #define SDB_MATCHINGINFO_PREVOSMAJORVERSION 0x00200000
  50. #define SDB_MATCHINGINFO_PREVOSMINORVERSION 0x00400000
  51. #define SDB_MATCHINGINFO_PREVOSPLATFORMID 0x00800000
  52. #define SDB_MATCHINGINFO_PREVOSBUILDNO 0x01000000
  53. #define SDB_MATCHINGINFO_LINKER_VERSION 0x02000000
  54. #define SDB_MATCHINGINFO_16BIT_MODULE_NAME 0x04000000
  55. #define SDB_MATCHINGINFO_LINK_DATE 0x08000000
  56. #define SDB_MATCHINGINFO_UPTO_LINK_DATE 0x10000000
  57. #define SDB_MATCHINGINFO_VER_LANGUAGE 0x20000000
  58. #define SDB_MATCHINGINFO_UPTO_BIN_FILE_VERSION 0x40000000
  59. //
  60. // Possible MODULE_TYPE values
  61. //
  62. #define SDB_MATCHINGINFO_MODULE_TYPE_UNK 0
  63. #define SDB_MATCHINGINFO_MODULE_TYPE_DOS 1
  64. #define SDB_MATCHINGINFO_MODULE_TYPE_W16 2
  65. #define SDB_MATCHINGINFO_MODULE_TYPE_W32 3
  66. //
  67. // Filters
  68. //
  69. #define SDB_FILTER_EXCLUDE_ALL 0x00000000
  70. #define SDB_FILTER_DEFAULT 0x00000001
  71. #define SDB_FILTER_OVERRIDE 0x00000002
  72. #define SDB_FILTER_FIX 0x00000004
  73. #define SDB_FILTER_APPHELP 0x00000008
  74. #define SDB_FILTER_MSI 0x00000010
  75. #define SDB_FILTER_DRIVER 0x00000020
  76. #define SDB_FILTER_NTCOMPAT 0x00000040
  77. #define SDB_FILTER_INCLUDE_ALL 0xFFFFFFFF
  78. //
  79. // This enumeration is used by SdbFlag::m_dwType
  80. //
  81. enum
  82. {
  83. SDB_FLAG_UNKNOWN = 0,
  84. SDB_FLAG_KERNEL,
  85. SDB_FLAG_USER,
  86. SDB_FLAG_NTVDM1,
  87. SDB_FLAG_NTVDM2,
  88. SDB_FLAG_NTVDM3,
  89. SDB_FLAG_SHELL,
  90. SDB_FLAG_FUSION,
  91. SDB_FLAG_MAX_TYPE
  92. };
  93. //
  94. // This enumeration is used by SdbOutputFile::m_OutputType
  95. //
  96. enum SdbOutputType
  97. {
  98. SDB_OUTPUT_TYPE_UNKNOWN = 0,
  99. SDB_OUTPUT_TYPE_SDB,
  100. SDB_OUTPUT_TYPE_HTMLHELP,
  101. SDB_OUTPUT_TYPE_MIGDB_INX,
  102. SDB_OUTPUT_TYPE_MIGDB_TXT,
  103. SDB_OUTPUT_TYPE_WIN2K_REGISTRY,
  104. SDB_OUTPUT_TYPE_REDIR_MAP,
  105. SDB_OUTPUT_TYPE_NTCOMPAT_INF,
  106. SDB_OUTPUT_TYPE_NTCOMPAT_MESSAGE_INF,
  107. SDB_OUTPUT_TYPE_APPHELP_REPORT
  108. };
  109. //
  110. // This enumeration is used by SdbCaller::m_CallerType
  111. //
  112. enum SdbCallerType
  113. {
  114. SDB_CALLER_EXCLUDE = 0,
  115. SDB_CALLER_INCLUDE
  116. };
  117. //
  118. // This enumeration is used by SdbShim::m_Purpose
  119. //
  120. enum SdbPurpose
  121. {
  122. SDB_PURPOSE_GENERAL = 0,
  123. SDB_PURPOSE_SPECIFIC
  124. };
  125. //
  126. // This enumeration is used by SdbMessage::m_Type
  127. // These values are taken from badapps.h in shell\published
  128. // and are compatible with Win2k, do not change
  129. //
  130. enum SdbAppHelpType
  131. {
  132. SDB_APPHELP_NONE = 0,
  133. SDB_APPHELP_NOBLOCK = 1,
  134. SDB_APPHELP_HARDBLOCK = 2,
  135. SDB_APPHELP_MINORPROBLEM = 3,
  136. SDB_APPHELP_REINSTALL = 4,
  137. SDB_APPHELP_VERSIONSUB = 5,
  138. SDB_APPHELP_SHIM = 6
  139. };
  140. enum SdbMatchOperationType
  141. {
  142. SDB_MATCH_ALL = 0,
  143. SDB_MATCH_ANY
  144. };
  145. //
  146. // This enumeration is used by SdbData::m_DataType
  147. //
  148. enum SdbDataValueType
  149. {
  150. eValueNone = REG_NONE,
  151. eValueDWORD = REG_DWORD,
  152. eValueQWORD = REG_QWORD,
  153. eValueString = REG_SZ,
  154. eValueBinary = REG_BINARY
  155. };
  156. //
  157. // Forward declarations of all classes
  158. //
  159. class SdbApp;
  160. class SdbExe;
  161. class SdbFile;
  162. class SdbShim;
  163. class SdbFlag;
  164. class SdbData;
  165. class SdbAction;
  166. class SdbPatch;
  167. class SdbLayer;
  168. class SdbCaller;
  169. class SdbMessage;
  170. class SdbLibrary;
  171. class SdbShimRef;
  172. class SdbFlagRef;
  173. class SdbAppHelp;
  174. class SdbDatabase;
  175. class SdbLayerRef;
  176. class SdbAppHelpRef;
  177. class SdbMsiPackage;
  178. class SdbContactInfo;
  179. class SdbMsiTransform;
  180. class SdbWinNTUpgrade;
  181. class SdbMatchingFile;
  182. class SdbMessageField;
  183. class SdbWin9xMigration;
  184. class SdbMsiTransformRef;
  185. class SdbMsiCustomAction;
  186. class SdbMessageTemplate;
  187. class SdbMatchingRegistryEntry;
  188. class SdbMakefile;
  189. class SdbInputFile;
  190. class SdbOutputFile;
  191. ///////////////////////////////////////////////////////////////////////////////
  192. //
  193. // SdbArrayElement
  194. //
  195. // All elements contained in a SdbArray or SdbRefArray must be derived
  196. // from this base class. It defines the basic m_csName property which is
  197. // used throughout the object model for array lookup, sorting etc.
  198. //
  199. class SdbArrayElement
  200. {
  201. public:
  202. CString m_csName;
  203. ULONGLONG m_ullKey; // 64-bit key used to sort element within array
  204. SdbDatabase* m_pDB; // Pointer to root database object.
  205. DWORD m_dwFilter;
  206. DWORD m_dwSPMask;
  207. DWORD m_dwOSPlatform;
  208. CString m_csOSVersionSpec;
  209. CString m_csLangID;
  210. DATE m_dtLastRevision;
  211. SdbArrayElement() :
  212. m_ullKey(0),
  213. m_pDB(NULL),
  214. m_dwSPMask(0xFFFFFFFF),
  215. m_dwOSPlatform(OS_PLATFORM_ALL),
  216. m_dwFilter(SDB_FILTER_DEFAULT),
  217. m_dtLastRevision(0) {}
  218. virtual ~SdbArrayElement() { }
  219. virtual int Compare(const SdbArrayElement* pElement);
  220. virtual ULONGLONG MakeKey() {
  221. return SdbMakeIndexKeyFromString(m_csName);
  222. }
  223. virtual void PropagateFilter(DWORD dwFilter);
  224. //
  225. // Virtual persistance functions
  226. //
  227. virtual BOOL ReadFromXML(IXMLDOMNode* pNode, SdbDatabase* pDB);
  228. virtual BOOL WriteToSDB(PDB pdb);
  229. virtual BOOL WriteRefToSDB(PDB pdb);
  230. };
  231. ///////////////////////////////////////////////////////////////////////////////
  232. //
  233. // SdbArrayT
  234. //
  235. // This template is an extension of CPtrArray which
  236. // designates that the array owns its elements or simply
  237. // references them. If it owns them, it will delete them during
  238. // destruction. Array elements must be derived from SdbArrayElement
  239. // to be properly destructed.
  240. //
  241. // SdbArray and SdbRefArray are class instances of the template.
  242. //
  243. template <class T, BOOL bOwnsElements> class SdbArrayT;
  244. template <class T> class SdbArray : public SdbArrayT<T, TRUE> { };
  245. template <class T> class SdbRefArray : public SdbArrayT<T, FALSE> { };
  246. template <class T, BOOL bOwnsElements> class SdbArrayT : public CPtrArray
  247. {
  248. public:
  249. CMapStringToPtr m_mapName;
  250. //
  251. // 'LookupName' looks up an element in the array by name
  252. //
  253. SdbArrayElement* LookupName( LPCTSTR lpszName, long* piStart = NULL ) {
  254. return LookupName(lpszName, NULL, piStart);
  255. }
  256. SdbArrayElement* LookupName( LPCTSTR lpszName, LPCTSTR lpszLangID, long* piStart = NULL ) {
  257. CString csName;
  258. SdbArrayElement* pElement;
  259. if (lpszLangID) {
  260. csName.Format(_T("%s\\%s"), lpszLangID, lpszName);
  261. } else {
  262. csName = lpszName;
  263. }
  264. csName.MakeUpper();
  265. if (!m_mapName.Lookup(csName, (LPVOID&)pElement)) {
  266. pElement = NULL;
  267. }
  268. return pElement;
  269. }
  270. ~SdbArrayT()
  271. {
  272. LONG i = 0;
  273. if( bOwnsElements ) {
  274. for( i = 0; i < (LONG)GetSize(); i++ ) {
  275. delete (SdbArrayElement *) GetAt( i );
  276. }
  277. }
  278. }
  279. //
  280. // 'AddOrdered' will add the element to the array sorted by name
  281. //
  282. int AddOrdered(SdbArrayElement* pElement)
  283. {
  284. INT iLeft = 0;
  285. INT iRight = (INT) (GetSize() - 1);
  286. INT i = -1;
  287. INT iCmp;
  288. BOOL bFound = FALSE;
  289. SdbArrayElement* pElementCompare;
  290. if (0 == pElement->m_ullKey) {
  291. pElement->m_ullKey = pElement->MakeKey();
  292. }
  293. if (iRight >= 0) {
  294. do {
  295. i = (iLeft + iRight) / 2; // middle ground
  296. pElementCompare = (SdbArrayElement*)GetAt(i); // element that we're going to try
  297. iCmp = pElement->Compare(pElementCompare);
  298. if (iCmp <= 0) {
  299. iRight = i - 1;
  300. }
  301. if (iCmp >= 0) {
  302. iLeft = i + 1;
  303. }
  304. } while (iRight >= iLeft);
  305. }
  306. //
  307. // if the element was found -- we insert right where it's at
  308. // if not -- to the right of the current element
  309. //
  310. bFound = (iLeft - iRight) > 1;
  311. if (!bFound) {
  312. i = iRight + 1;
  313. }
  314. CPtrArray::InsertAt(i, pElement);
  315. return i;
  316. }
  317. //
  318. // 'Add' will simply add an element to the array, and add
  319. // to the name map that is used for look up.
  320. //
  321. INT Add(SdbArrayElement* pElement, SdbDatabase* pDB = NULL, BOOL bOrdered = FALSE)
  322. {
  323. CString csName;
  324. pElement->m_pDB = pDB;
  325. csName.MakeUpper();
  326. if (pElement->m_csLangID.GetLength()) {
  327. csName.Format(_T("%s\\%s"), pElement->m_csLangID, pElement->m_csName);
  328. } else {
  329. csName = pElement->m_csName;
  330. }
  331. csName.MakeUpper();
  332. m_mapName.SetAt(csName, (LPVOID)pElement);
  333. // also insert at the right place according to the imposed order
  334. return (INT)(bOrdered ? AddOrdered(pElement) : CPtrArray::Add(pElement));
  335. }
  336. int Append(const SdbArray<T>& rgArray)
  337. {
  338. SdbArrayElement* pElement;
  339. int nFirstElement = -1;
  340. int nThisElement = -1;
  341. //
  342. // Cannot own elements
  343. //
  344. if (!bOwnsElements) {
  345. for (long i = 0; i < rgArray.GetSize(); i++) {
  346. pElement = (SdbArrayElement *) rgArray.GetAt(i);
  347. nThisElement = Add(pElement, pElement->m_pDB);
  348. if (nFirstElement == -1) {
  349. nFirstElement = nThisElement;
  350. }
  351. }
  352. }
  353. return nFirstElement;
  354. }
  355. DWORD GetFilteredCount(DWORD dwFilter, DATE dtRevisionCutoff = 0)
  356. {
  357. DWORD dwCount = 0;
  358. long i = 0;
  359. SdbArrayElement* pElem;
  360. for (i = 0; i < GetSize(); i++) {
  361. pElem = (SdbArrayElement *) GetAt(i);
  362. if ((pElem->m_dwFilter & dwFilter) &&
  363. dtRevisionCutoff <= pElem->m_dtLastRevision) {
  364. dwCount++;
  365. }
  366. }
  367. return dwCount;
  368. }
  369. virtual void PropagateFilter(DWORD dwFilter)
  370. {
  371. long i = 0;
  372. SdbArrayElement* pElem;
  373. for (i = 0; i < GetSize(); i++) {
  374. pElem = (SdbArrayElement *) GetAt(i);
  375. pElem->PropagateFilter(dwFilter);
  376. }
  377. }
  378. //
  379. // 'ReadFromXML' will perform an XQL query on the pParentNode object and
  380. // populate the array with members -- each of which read themselves in from
  381. // the nodes returned by the query.
  382. //
  383. BOOL ReadFromXML(LPCTSTR szXQL, SdbDatabase* pDB, IXMLDOMNode* pParentNode, SdbArray<T>* pOwnerArray = NULL, BOOL bAddOrdered = FALSE, LPCTSTR lpszKeyAttribute = _T("NAME"))
  384. {
  385. BOOL bSuccess = FALSE;
  386. XMLNodeList XQL;
  387. IXMLDOMNodePtr cpNode;
  388. T* pNewObject = NULL;
  389. LONG i;
  390. CString csName;
  391. if (!XQL.Query(pParentNode, szXQL)) {
  392. SDBERROR_PROPOGATE();
  393. goto eh;
  394. }
  395. for (i = 0; i < (LONG)XQL.GetSize(); i++) {
  396. pNewObject = NULL;
  397. if (!XQL.GetItem(i, &cpNode)) {
  398. SDBERROR_PROPOGATE();
  399. goto eh;
  400. }
  401. if (bOwnsElements) {
  402. pNewObject = (T*) new T();
  403. if (pNewObject == NULL) {
  404. CString csFormat;
  405. csFormat.Format(_T("Error allocating new object to read \"%s\" tag"), szXQL);
  406. SDBERROR(csFormat);
  407. goto eh;
  408. }
  409. if (!pNewObject->ReadFromXML(cpNode, pDB)) {
  410. SDBERROR_PROPOGATE();
  411. goto eh;
  412. }
  413. } else {
  414. if (lpszKeyAttribute) {
  415. if (!GetAttribute(lpszKeyAttribute, cpNode, &csName)) {
  416. CString csFormat;
  417. csFormat.Format(_T("Error retrieving %s attribute on tag:\n\n%s\n\n"),
  418. lpszKeyAttribute, szXQL, GetXML(cpNode));
  419. SDBERROR(csFormat);
  420. goto eh;
  421. }
  422. }
  423. if (pOwnerArray == NULL) {
  424. SDBERROR(_T("Internal error: SdbArray::ReadFromXML() requires non-NULL ")
  425. _T("pOwnerArray for reference arrays."));
  426. goto eh;
  427. }
  428. pNewObject = (T*) pOwnerArray->LookupName(csName);
  429. if (!pNewObject && g_bStrict) {
  430. CString csFormat;
  431. csFormat.Format(_T("Tag \"%s\" references unknown LIBRARY item \"%s\":\n\n%s\n\n"),
  432. szXQL, csName, GetXML(cpNode));
  433. SDBERROR(csFormat);
  434. goto eh;
  435. }
  436. }
  437. if (pNewObject) {
  438. Add(pNewObject, pDB, bAddOrdered);
  439. }
  440. cpNode.Release();
  441. }
  442. bSuccess = TRUE;
  443. eh:
  444. return bSuccess;
  445. }
  446. //
  447. // 'WriteToSDB' will write each of the elements in the array out
  448. // to the SDB database specified by pdb.
  449. //
  450. BOOL WriteToSDB(PDB pdb, BOOL bReference = FALSE)
  451. {
  452. LONG i;
  453. T* pOb;
  454. for (i = 0; i < (LONG)GetSize(); i++) {
  455. pOb = (T*) GetAt(i);
  456. if ((g_dwCurrentWriteFilter & pOb->m_dwFilter) &&
  457. (pOb->m_dtLastRevision != 0 ? g_dtCurrentWriteRevisionCutoff <= pOb->m_dtLastRevision : TRUE)) {
  458. if (bReference) {
  459. if (!pOb->WriteRefToSDB(pdb)) {
  460. return FALSE;
  461. }
  462. } else {
  463. if (!pOb->WriteToSDB(pdb)) {
  464. return FALSE;
  465. }
  466. }
  467. }
  468. }
  469. return TRUE;
  470. }
  471. };
  472. ///////////////////////////////////////////////////////////////////////////////
  473. //
  474. // SdbLocalizedString
  475. //
  476. // The SdbLocalizedString object is simply a named string that also has a
  477. // LangID associated with it.
  478. //
  479. class SdbLocalizedString : public SdbArrayElement
  480. {
  481. public:
  482. CString m_csValue;
  483. };
  484. ///////////////////////////////////////////////////////////////////////////////
  485. //
  486. // SdbLibrary
  487. //
  488. // The SdbLibrary object contains the shims, patches and kernel flags and
  489. // layers that are referenced by App or Exe objects. NOTE: It is possible
  490. // to compile a database without entries in Library, with the assumption
  491. // that any references will be resolved when further databases in the
  492. // search path are opened.
  493. //
  494. class SdbLibrary : public SdbArrayElement
  495. {
  496. public:
  497. SdbArray<SdbFile> m_rgFiles;
  498. SdbArray<SdbShim> m_rgShims;
  499. SdbArray<SdbPatch> m_rgPatches;
  500. SdbArray<SdbLayer> m_rgLayers;
  501. SdbArray<SdbFlag> m_rgFlags;
  502. SdbArray<SdbCaller> m_rgCallers;
  503. SdbArray<SdbMsiTransform> m_rgMsiTransforms;
  504. void PropagateFilter(DWORD dwFilter)
  505. {
  506. SdbArrayElement::PropagateFilter(dwFilter);
  507. m_rgFiles.PropagateFilter(m_dwFilter);
  508. m_rgShims.PropagateFilter(m_dwFilter);
  509. m_rgPatches.PropagateFilter(m_dwFilter);
  510. m_rgLayers.PropagateFilter(m_dwFilter);
  511. m_rgFlags.PropagateFilter(m_dwFilter);
  512. m_rgCallers.PropagateFilter(m_dwFilter);
  513. m_rgMsiTransforms.PropagateFilter(m_dwFilter == SDB_FILTER_EXCLUDE_ALL ? SDB_FILTER_EXCLUDE_ALL : SDB_FILTER_MSI);
  514. }
  515. BOOL ReadFromXML(IXMLDOMNode* pNode, SdbDatabase* pDB);
  516. BOOL WriteToSDB(PDB pdb);
  517. //
  518. // method to clear out tagIDs before writing the db out
  519. //
  520. VOID SanitizeTagIDs(VOID);
  521. };
  522. ///////////////////////////////////////////////////////////////////////////////
  523. //
  524. // SdbDatabase
  525. //
  526. // This is the base class for the three database classes. It contains
  527. // any common properties between the three.
  528. //
  529. class SdbDatabase : public SdbArrayElement
  530. {
  531. public:
  532. SdbDatabase() :
  533. m_ID(GUID_NULL),
  534. m_pCurrentApp(NULL),
  535. m_pCurrentMakefile(NULL),
  536. m_pCurrentInputFile(NULL),
  537. m_pCurrentOutputFile(NULL),
  538. m_iiWildcardExeIndex(NULL),
  539. m_iiModuleExeIndex(NULL),
  540. m_iiMsiIDIndex(NULL),
  541. m_iiDrvIDIndex(NULL),
  542. m_iiShimIndex(NULL),
  543. m_iiMsiTransformIndex(NULL),
  544. m_iiMsiPackageIndex(NULL)
  545. {
  546. m_Library.m_pDB = this;
  547. }
  548. GUID m_ID;
  549. SdbMakefile* m_pCurrentMakefile;
  550. SdbInputFile* m_pCurrentInputFile;
  551. SdbOutputFile* m_pCurrentOutputFile;
  552. GUID m_CurrentDBID; // last written out dbid
  553. CString m_csCurrentLangID;
  554. IXMLDOMNodePtr m_cpCurrentDatabaseNode;
  555. SdbLibrary m_Library;
  556. //
  557. // Holding variables that are used while reading/writing
  558. //
  559. INDEXID m_iiWildcardExeIndex;
  560. INDEXID m_iiModuleExeIndex;
  561. INDEXID m_iiExeIndex;
  562. INDEXID m_iiShimIndex;
  563. INDEXID m_iiMsiTransformIndex;
  564. INDEXID m_iiMsiPackageIndex;
  565. INDEXID m_iiMsiIDIndex;
  566. INDEXID m_iiDrvIDIndex;
  567. INDEXID m_iiHtmlHelpID;
  568. SdbApp* m_pCurrentApp;
  569. IXMLDOMDocumentPtr m_cpTempXMLDoc;
  570. IXMLDOMNodePtr m_cpTempXML;
  571. SdbArray<SdbApp> m_rgApps;
  572. SdbArray<SdbAction> m_rgAction;
  573. SdbRefArray<SdbExe> m_rgExes;
  574. SdbRefArray<SdbExe> m_rgWildcardExes;
  575. SdbRefArray<SdbExe> m_rgModuleExes; // exes that match on module name
  576. SdbRefArray<SdbWinNTUpgrade> m_rgWinNTUpgradeEntries;
  577. SdbRefArray<SdbMsiPackage> m_rgMsiPackages;
  578. CString m_csHTMLHelpFirstScreen;
  579. SdbArray<SdbContactInfo> m_rgContactInfo;
  580. SdbArray<SdbMessage> m_rgMessages;
  581. SdbArray<SdbMessageTemplate> m_rgMessageTemplates;
  582. SdbArray<SdbLocalizedString> m_rgHTMLHelpTemplates;
  583. SdbArray<SdbLocalizedString> m_rgHTMLHelpFirstScreens;
  584. SdbArray<SdbLocalizedString> m_rgLocalizedAppNames;
  585. SdbArray<SdbLocalizedString> m_rgLocalizedVendorNames;
  586. SdbArray<SdbLocalizedString> m_rgRedirs;
  587. SdbArray<SdbAppHelp> m_rgAppHelps;
  588. //
  589. // Maps used to map IDs to their objects
  590. //
  591. CMapStringToPtr m_mapExeIDtoExe;
  592. SdbExe* LookupExe(DWORD dwTagID);
  593. BOOL ReplaceFields(CString csXML, CString* pcsReturn, SdbRefArray<SdbMessageField>* prgFields);
  594. BOOL ReplaceFieldsInXML(IXMLDOMNode* cpTargetNode, SdbRefArray<SdbMessageField>* prgFields);
  595. BOOL RedirectLinks(CString* pcsXML, LCID lcid, CString csRedirURL);
  596. BOOL HTMLtoText(CString csXML, CString* pcsReturn);
  597. DWORD GetNextSequentialID(CString csType);
  598. BOOL WriteAppHelpRefTag(
  599. PDB pdb,
  600. CString csHTMLHelpID,
  601. LCID langID,
  602. CString csURL,
  603. CString csAppTitle,
  604. CString csSummary);
  605. BOOL ConstructMessageParts(
  606. SdbAppHelp* pAppHelp,
  607. SdbMessage* pMessage,
  608. CString& csLangID,
  609. DWORD* pdwHTMLHelpID,
  610. CString* pcsURL,
  611. CString* pcsContactInformation,
  612. CString* pcsAppTitle,
  613. CString* pcsSummary,
  614. CString* pcsDetails);
  615. BOOL ConstructMigrationMessage(
  616. SdbWin9xMigration* pMigApp,
  617. SdbMessage* pMessage,
  618. CString* pcsMessage);
  619. void PropagateFilter(DWORD dwFilter)
  620. {
  621. SdbArrayElement::PropagateFilter(dwFilter);
  622. m_rgApps.PropagateFilter(m_dwFilter == SDB_FILTER_EXCLUDE_ALL ? SDB_FILTER_EXCLUDE_ALL : SDB_FILTER_FIX);
  623. m_rgAction.PropagateFilter(m_dwFilter == SDB_FILTER_EXCLUDE_ALL ? SDB_FILTER_EXCLUDE_ALL : SDB_FILTER_FIX);
  624. m_Library.PropagateFilter(m_dwFilter == SDB_FILTER_EXCLUDE_ALL ? SDB_FILTER_EXCLUDE_ALL : SDB_FILTER_FIX);
  625. }
  626. BOOL ReadFromXML(IXMLDOMNode* pNode, SdbDatabase* pDB);
  627. BOOL WriteToSDB(PDB pdb);
  628. BOOL IsStandardDatabase(VOID);
  629. };
  630. ///////////////////////////////////////////////////////////////////////////////
  631. //
  632. // SdbApp
  633. //
  634. // The SdbApp object groups Exe objects by application title and vendor. Note
  635. // that it contains only references to exes: Exe objects are owned by the
  636. // database object.
  637. //
  638. class SdbApp : public SdbArrayElement
  639. {
  640. public:
  641. CString m_csVendor;
  642. CString m_csVendorXML;
  643. CString m_csVersion;
  644. SdbArray<SdbExe> m_rgExes;
  645. SdbArray<SdbMsiPackage> m_rgMsiPackages;
  646. SdbArray<SdbWin9xMigration>
  647. m_rgWin9xMigEntries;
  648. SdbArray<SdbWinNTUpgrade>
  649. m_rgWinNTUpgradeEntries;
  650. SdbRefArray<SdbAppHelpRef> m_rgAppHelpRefs;
  651. CString m_csKeywords;
  652. BOOL m_bSeen;
  653. GUID m_ID;
  654. SdbApp():
  655. m_ID(GUID_NULL){}
  656. CString GetLocalizedAppName();
  657. CString GetLocalizedAppName(CString csLangID);
  658. CString GetLocalizedVendorName();
  659. CString GetLocalizedVendorName(CString csLangID);
  660. void PropagateFilter(DWORD dwFilter)
  661. {
  662. SdbArrayElement::PropagateFilter(dwFilter);
  663. m_rgExes.PropagateFilter(m_dwFilter);
  664. m_rgMsiPackages.PropagateFilter(m_dwFilter == SDB_FILTER_EXCLUDE_ALL ? SDB_FILTER_EXCLUDE_ALL : SDB_FILTER_MSI);
  665. m_rgWin9xMigEntries.PropagateFilter(m_dwFilter);
  666. m_rgWinNTUpgradeEntries.PropagateFilter(m_dwFilter);
  667. }
  668. BOOL ReadFromXML(IXMLDOMNode* pNode, SdbDatabase* pDB);
  669. };
  670. ///////////////////////////////////////////////////////////////////////////////
  671. //
  672. // SdbContactInfo
  673. //
  674. // The SdbContactInfo object contains all contact information for the vendor
  675. // portion of the AppHelp dialog. These values can be overridden in the
  676. // AppHelp object.
  677. //
  678. class SdbContactInfo : public SdbArrayElement
  679. {
  680. public:
  681. CString m_csXML;
  682. GUID m_ID;
  683. SdbContactInfo() :
  684. m_ID(GUID_NULL){}
  685. BOOL ReadFromXML(IXMLDOMNode* pNode, SdbDatabase* pDB);
  686. };
  687. ///////////////////////////////////////////////////////////////////////////////
  688. //
  689. // SdbMessageTemplate
  690. //
  691. // The SdbMessageTemplate object contains AppHelp messages to be used as 'templates'
  692. // for SdbMessage objects. A SdbMessage object can specify a template and
  693. // use its m_csText and m_csHTML values, or override one of them.
  694. //
  695. class SdbMessageTemplate : public SdbArrayElement
  696. {
  697. public:
  698. CString m_csSummaryXML;
  699. CString m_csDetailsXML;
  700. BOOL ReadFromXML(IXMLDOMNode* pNode, SdbDatabase* pDB);
  701. };
  702. ///////////////////////////////////////////////////////////////////////////////
  703. //
  704. // SdbMessage
  705. //
  706. // The SdbMessage object contains all information required for an AppHelp
  707. // dialog in localized form. A SdbAppHelp object references a single
  708. // SdbMessage object, but all of the text is localized in multiple languages.
  709. // A SdbMessage object can derive from a SdbMessageTemplate object, which
  710. // supplies the default m_csText and m_csHTML values.
  711. //
  712. class SdbMessage : public SdbArrayElement
  713. {
  714. public:
  715. SdbMessageTemplate* m_pTemplate;
  716. SdbArray<SdbMessageField> m_rgFields;
  717. CString m_csContactInfoXML; // Overriding ContactInfo object
  718. CString m_csSummaryXML; // Overriding Template object
  719. CString m_csDetailsXML; // Overriding Template object
  720. GUID m_ID;
  721. SdbMessage() :
  722. m_ID(GUID_NULL),
  723. m_pTemplate(NULL) {}
  724. BOOL ReadFromXML(IXMLDOMNode* pNode, SdbDatabase* pDB);
  725. };
  726. ///////////////////////////////////////////////////////////////////////////////
  727. //
  728. // SdbAppHelp
  729. //
  730. // The SdbAppHelp object is an instantiation of an AppHelp message. An
  731. // SdbAppHelp is the only object that contains the HTMLHELPID attribute,
  732. // which is needed for each unique AppHelp entry in the CHM file.
  733. //
  734. // HTMLHELPID is stored in SdbAppHelp::m_csName.
  735. //
  736. class SdbAppHelp : public SdbArrayElement
  737. {
  738. public:
  739. CString m_csMessage;
  740. SdbApp* m_pApp;
  741. SdbAppHelpType m_Type;
  742. BOOL m_bBlockUpgrade;
  743. CString m_csURL; // custom URL, if supplied
  744. CString m_csParameter1;
  745. SdbAppHelp() :
  746. m_bBlockUpgrade(FALSE),
  747. m_Type(SDB_APPHELP_NOBLOCK),
  748. m_pApp(NULL) { }
  749. void PropagateFilter(DWORD dwFilter)
  750. {
  751. //
  752. // We OR this one unconditionally to achieve the following
  753. // effect: If an HTMLHELPID is used at least once, it will
  754. // be included. If it is not used at all (given the current
  755. // filtering), it will never get an SDB_FILTER_APPHELP bit
  756. // set.
  757. //
  758. m_dwFilter |= dwFilter;
  759. }
  760. };
  761. ///////////////////////////////////////////////////////////////////////////////
  762. //
  763. // SdbAppHelpRef
  764. //
  765. // The SdbAppHelpRef object is an instantiation of an AppHelp object.
  766. //
  767. class SdbAppHelpRef : public SdbArrayElement
  768. {
  769. public:
  770. BOOL m_bApphelpOnly;
  771. SdbAppHelp* m_pAppHelp;
  772. IXMLDOMNodePtr m_cpNode;
  773. SdbAppHelpRef() :
  774. m_bApphelpOnly(FALSE),
  775. m_pAppHelp(NULL)
  776. {}
  777. void PropagateFilter(DWORD dwFilter)
  778. {
  779. SdbArrayElement::PropagateFilter(dwFilter);
  780. if (m_pAppHelp) {
  781. m_pAppHelp->PropagateFilter(m_dwFilter);
  782. }
  783. }
  784. BOOL ReadFromXML(IXMLDOMNode* pNode, SdbDatabase* pDB);
  785. BOOL WriteToSDB(PDB pdb);
  786. };
  787. ///////////////////////////////////////////////////////////////////////////////
  788. //
  789. // SdbMessageField
  790. //
  791. // The SdbMessageField object contains a name-value pair that can is used to
  792. // replace fields embedded in templates.
  793. //
  794. class SdbMessageField : public SdbArrayElement
  795. {
  796. public:
  797. CString m_csValue;
  798. BOOL ReadFromXML(IXMLDOMNode* pNode, SdbDatabase* pDB);
  799. };
  800. ///////////////////////////////////////////////////////////////////////////////
  801. //
  802. // SdbMatchingFile
  803. //
  804. // The SdbMatchingFile object contains all file information about files that
  805. // must be matched on for app identification. m_dwMask is used to indicate
  806. // which of the criteria contain valid values (see defines at top of file for
  807. // mask).
  808. //
  809. class SdbMatchingFile : public SdbArrayElement
  810. {
  811. public:
  812. DWORD m_dwMask;
  813. DWORD m_dwSize;
  814. DWORD m_dwChecksum;
  815. CString m_csCompanyName;
  816. CString m_csProductName;
  817. CString m_csProductVersion;
  818. CString m_csFileDescription;
  819. ULONGLONG m_ullBinFileVersion;
  820. ULONGLONG m_ullBinProductVersion;
  821. DWORD m_dwVerLanguage;
  822. DWORD m_dwModuleType;
  823. DWORD m_dwFileDateMS;
  824. DWORD m_dwFileDateLS;
  825. DWORD m_dwFileOS;
  826. DWORD m_dwFileType;
  827. ULONG m_ulPECheckSum;
  828. DWORD m_dwLinkerVersion;
  829. CString m_csFileVersion;
  830. CString m_csOriginalFileName;
  831. CString m_csInternalName;
  832. CString m_csLegalCopyright;
  833. CString m_cs16BitDescription;
  834. CString m_cs16BitModuleName;
  835. ULONGLONG m_ullUpToBinProductVersion;
  836. ULONGLONG m_ullUpToBinFileVersion;
  837. DWORD m_dwPrevOSMajorVersion;
  838. DWORD m_dwPrevOSMinorVersion;
  839. DWORD m_dwPrevOSPlatformID;
  840. DWORD m_dwPrevOSBuildNo;
  841. time_t m_timeLinkDate;
  842. time_t m_timeUpToLinkDate;
  843. BOOL m_bMatchLogicNot;
  844. CString m_csServiceName;
  845. CString m_csRegistryEntry;
  846. SdbMatchingFile() :
  847. m_dwMask(NULL),
  848. m_bMatchLogicNot(FALSE) {}
  849. BOOL IsValidForWin2k(CString csXML);
  850. BOOL ReadFromXML(IXMLDOMNode* pNode, SdbDatabase* pDB);
  851. BOOL WriteToSDB(PDB pdb);
  852. };
  853. ///////////////////////////////////////////////////////////////////////////////
  854. //
  855. // SdbMsiPackage
  856. //
  857. // The SdbMsiPackage object represents an Installer package that must be fixed via
  858. // application of a custom MSI_TRANSFORM
  859. //
  860. class SdbMsiPackage : public SdbArrayElement
  861. {
  862. public:
  863. //
  864. // Pointer to the (parent) app object
  865. //
  866. SdbApp* m_pApp;
  867. //
  868. // supplemental data for MSI_PACKAGE object
  869. // it is used to further identify the package
  870. //
  871. SdbArray<SdbData> m_rgData;
  872. //
  873. // MSI_TRANSFORM stuff designed to fix this package (references transforms in lib)
  874. //
  875. SdbArray<SdbMsiTransformRef> m_rgMsiTransformRefs;
  876. GUID m_MsiPackageID; // package id (non-unique guid)
  877. GUID m_ID; // exe id (unique guid)
  878. //
  879. // RUNTIME_PLATFORM attribute
  880. //
  881. DWORD m_dwRuntimePlatform;
  882. //
  883. // OS_SKU attribute
  884. //
  885. DWORD m_dwOSSKU;
  886. //
  887. // apphelp
  888. //
  889. SdbAppHelpRef m_AppHelpRef;
  890. //
  891. // shims and layers don't cut it, we need another entity here
  892. //
  893. SdbArray<SdbMsiCustomAction> m_rgCustomActions;
  894. //
  895. // we override the default MakeKey function
  896. // in order to sort the content by keys made from guid IDs instead of the name
  897. // secondary sort order will be provided by name
  898. //
  899. virtual ULONGLONG MakeKey() {
  900. return MAKEKEYFROMGUID(&m_ID);
  901. }
  902. SdbMsiPackage() :
  903. m_ID(GUID_NULL),
  904. m_dwRuntimePlatform(RUNTIME_PLATFORM_ANY),
  905. m_dwOSSKU(OS_SKU_ALL) {}
  906. void PropagateFilter(DWORD dwFilter)
  907. {
  908. SdbArrayElement::PropagateFilter(dwFilter);
  909. m_AppHelpRef.PropagateFilter(m_dwFilter == SDB_FILTER_EXCLUDE_ALL ? SDB_FILTER_EXCLUDE_ALL : SDB_FILTER_APPHELP);
  910. m_rgData.PropagateFilter(m_dwFilter);
  911. m_rgMsiTransformRefs.PropagateFilter(m_dwFilter);
  912. m_rgCustomActions.PropagateFilter(m_dwFilter);
  913. }
  914. BOOL ReadFromXML(IXMLDOMNode* pNode, SdbDatabase* pDB);
  915. BOOL WriteToSDB(PDB pdb);
  916. };
  917. ///////////////////////////////////////////////////////////////////////////////
  918. //
  919. // SdbMsiCustomAction
  920. //
  921. // The SdbMsiCustomAction object encapsulates custom actions and what we do
  922. // for them (shim/etc)
  923. //
  924. class SdbMsiCustomAction : public SdbArrayElement
  925. {
  926. public:
  927. SdbArray<SdbShimRef> m_rgShimRefs;
  928. SdbArray<SdbLayerRef> m_rgLayerRefs;
  929. void PropagateFilter(DWORD dwFilter)
  930. {
  931. SdbArrayElement::PropagateFilter(dwFilter);
  932. m_rgShimRefs.PropagateFilter(m_dwFilter);
  933. m_rgLayerRefs.PropagateFilter(m_dwFilter);
  934. }
  935. BOOL ReadFromXML(IXMLDOMNode* pNode, SdbDatabase* pDB);
  936. BOOL WriteToSDB(PDB pdb);
  937. };
  938. ///////////////////////////////////////////////////////////////////////////////
  939. //
  940. // SdbMsiTransform
  941. //
  942. // The SdbMsiTransform object encapsulates an MSI_TRANSFORM remedy.
  943. //
  944. class SdbMsiTransform : public SdbArrayElement
  945. {
  946. public:
  947. SdbMsiTransform() :
  948. m_tiTagID(NULL),
  949. m_pSdbFile(NULL) {}
  950. TAGID m_tiTagID; // tagid of this record
  951. SdbFile* m_pSdbFile; // pointer to the transform file
  952. CString m_csMsiTransformFile; // transform filename
  953. CString m_csDesc; // description
  954. BOOL ReadFromXML(IXMLDOMNode* pNode, SdbDatabase* pDB);
  955. BOOL WriteToSDB(PDB pdb);
  956. };
  957. ///////////////////////////////////////////////////////////////////////////////
  958. //
  959. // SdbMsiTransformRef
  960. //
  961. // The SdbMsiTransformRef object is a reference to an SdbMsiTransform object
  962. // in the library.
  963. //
  964. class SdbMsiTransformRef : public SdbArrayElement
  965. {
  966. public:
  967. SdbMsiTransformRef() :
  968. m_pMsiTransform(NULL) {}
  969. SdbMsiTransform* m_pMsiTransform;
  970. BOOL ReadFromXML(IXMLDOMNode* pNode, SdbDatabase* pDB);
  971. BOOL WriteToSDB(PDB pdb);
  972. };
  973. #define MATCH_DEFAULT ((DWORD)-1)
  974. ///////////////////////////////////////////////////////////////////////////////
  975. //
  976. // SdbExe
  977. //
  978. // The SdbExe object represents an executable that must be patched/shimmed.
  979. // The m_pApp member can be NULL, or it can contain a pointer to the SdbApp
  980. // object that groups it with other SdbExe objects.
  981. //
  982. class SdbExe : public SdbArrayElement
  983. {
  984. public:
  985. SdbApp* m_pApp;
  986. SdbArray<SdbShimRef> m_rgShimRefs;
  987. SdbArray<SdbLayerRef> m_rgLayerRefs;
  988. SdbArray<SdbFlagRef> m_rgFlagRefs;
  989. SdbArray<SdbMatchingFile> m_rgMatchingFiles;
  990. SdbArray<SdbData> m_rgData;
  991. SdbArray<SdbAction> m_rgAction;
  992. SdbRefArray<SdbPatch> m_rgPatches;
  993. SdbAppHelpRef m_AppHelpRef;
  994. CString m_csSXSManifest;
  995. GUID m_ID;
  996. BOOL m_bWildcardInName;
  997. BOOL m_bMatchOnModule;
  998. DWORD m_dwTagID;
  999. BOOL m_bSeen;
  1000. DWORD m_dwMatchMode; // modes include NORMAL, EXCLUSIVE, or ADDITIVE
  1001. DWORD m_dwRuntimePlatform;
  1002. DWORD m_dwOSSKU;
  1003. SdbExe() :
  1004. m_pApp(NULL),
  1005. m_dwTagID(0),
  1006. m_ID(GUID_NULL),
  1007. m_dwMatchMode(MATCH_DEFAULT),
  1008. m_bWildcardInName(FALSE),
  1009. m_dwRuntimePlatform(RUNTIME_PLATFORM_ANY),
  1010. m_dwOSSKU(OS_SKU_ALL),
  1011. m_bMatchOnModule(FALSE) {m_dwOSPlatform = OS_PLATFORM_I386;}
  1012. BOOL IsValidForWin2k(CString csXML);
  1013. void PropagateFilter(DWORD dwFilter)
  1014. {
  1015. SdbArrayElement::PropagateFilter(dwFilter);
  1016. m_rgShimRefs.PropagateFilter(m_dwFilter);
  1017. m_rgLayerRefs.PropagateFilter(m_dwFilter);
  1018. m_rgFlagRefs.PropagateFilter(m_dwFilter);
  1019. m_rgMatchingFiles.PropagateFilter(m_dwFilter);
  1020. m_rgData.PropagateFilter(m_dwFilter);
  1021. m_rgAction.PropagateFilter(m_dwFilter);
  1022. m_rgPatches.PropagateFilter(m_dwFilter);
  1023. m_AppHelpRef.PropagateFilter(m_dwFilter == SDB_FILTER_EXCLUDE_ALL ? SDB_FILTER_EXCLUDE_ALL : SDB_FILTER_APPHELP);
  1024. }
  1025. BOOL ReadFromXML(IXMLDOMNode* pNode, SdbDatabase* pDB);
  1026. BOOL WriteToSDB(PDB pdb);
  1027. int Compare(const SdbArrayElement* pElement);
  1028. };
  1029. ///////////////////////////////////////////////////////////////////////////////
  1030. //
  1031. // SdbFile
  1032. //
  1033. // The SdbFile object represents a binary file that can be stored in the
  1034. // database.
  1035. //
  1036. class SdbFile : public SdbArrayElement
  1037. {
  1038. public:
  1039. SdbFile() :
  1040. m_tiTagID(NULL) {}
  1041. TAGID m_tiTagID;
  1042. BOOL ReadFromXML(IXMLDOMNode* pNode, SdbDatabase* pDB);
  1043. BOOL WriteToSDB(PDB pdb);
  1044. };
  1045. ///////////////////////////////////////////////////////////////////////////////
  1046. //
  1047. // SdbShim
  1048. //
  1049. // The SdbShim object represents a shim, which contains Win32 API hooks.
  1050. // A shim's 'purpose' can be marked as GENERAL or SPECIFIC -- if it is GENERAL,
  1051. // it is appropriate for reuse, otherwise it is application specific.
  1052. //
  1053. class SdbShim : public SdbArrayElement
  1054. {
  1055. public:
  1056. SdbShim() :
  1057. m_ID(GUID_NULL),
  1058. m_tiTagID(NULL),
  1059. m_Purpose(SDB_PURPOSE_SPECIFIC),
  1060. m_bApplyAllShims(FALSE) {m_dwOSPlatform = OS_PLATFORM_I386;}
  1061. CString m_csShortName;
  1062. CString m_csDesc;
  1063. TAGID m_tiTagID;
  1064. CString m_csDllFile;
  1065. SdbPurpose m_Purpose;
  1066. BOOL m_bApplyAllShims;
  1067. GUID m_ID;
  1068. SdbArray<SdbCaller> m_rgCallers;
  1069. void PropagateFilter(DWORD dwFilter)
  1070. {
  1071. SdbArrayElement::PropagateFilter(dwFilter);
  1072. m_rgCallers.PropagateFilter(m_dwFilter);
  1073. }
  1074. BOOL ReadFromXML(IXMLDOMNode* pNode, SdbDatabase* pDB);
  1075. BOOL WriteToSDB(PDB pdb);
  1076. };
  1077. ///////////////////////////////////////////////////////////////////////////////
  1078. //
  1079. // SdbCaller
  1080. //
  1081. // The SdbCaller object contains inclusion/exclusion information for shims.
  1082. // It allows hooked APIs to be cased by the calling instruction address. For
  1083. // example, it is known that ATL.DLL requires accurate OS version information,
  1084. // and so any calls to GetVersionExA from ATL.DLL are assured to call the
  1085. // original API, rather than the shim hook. This is achieved by adding
  1086. // an EXCLUDE subtag to the SHIM tag.
  1087. //
  1088. class SdbCaller : public SdbArrayElement
  1089. {
  1090. public:
  1091. CString m_csModule;
  1092. SdbCallerType m_CallerType;
  1093. BOOL ReadFromXML(IXMLDOMNode* pNode, SdbDatabase* pDB);
  1094. BOOL WriteToSDB(PDB pdb);
  1095. };
  1096. ///////////////////////////////////////////////////////////////////////////////
  1097. //
  1098. // SdbShimRef
  1099. //
  1100. // The SdbShimRef object is simply a reference to a SdbShim object that exists
  1101. // in a library. It has separate inclusion/exclusion information, which is
  1102. // given higher priority than any such information in the SHIM tag within the
  1103. // corresponding library. It can contain an optional command line, which is
  1104. // passed in to the shim DLL via GetHookAPIs.
  1105. //
  1106. class SdbShimRef : public SdbArrayElement
  1107. {
  1108. public:
  1109. SdbShimRef() :
  1110. m_dwRecID(NULL),
  1111. m_pShim(NULL) {}
  1112. DWORD m_dwRecID;
  1113. SdbShim* m_pShim;
  1114. CString m_csCommandLine;
  1115. SdbArray<SdbCaller> m_rgCallers;
  1116. SdbArray<SdbData> m_rgData;
  1117. void PropagateFilter(DWORD dwFilter)
  1118. {
  1119. SdbArrayElement::PropagateFilter(dwFilter);
  1120. m_rgCallers.PropagateFilter(m_dwFilter);
  1121. m_rgData.PropagateFilter(m_dwFilter);
  1122. }
  1123. BOOL ReadFromXML(IXMLDOMNode* pNode, SdbDatabase* pDB);
  1124. BOOL WriteToSDB(PDB pdb);
  1125. };
  1126. ///////////////////////////////////////////////////////////////////////////////
  1127. //
  1128. // SdbPatch
  1129. //
  1130. // The SdbPatch object contains the patch binary that is parsed by the app
  1131. // compat mechanism at run-time. It contains patching instructions, including
  1132. // any bits to patch an executable's code with.
  1133. //
  1134. class SdbPatch : public SdbArrayElement
  1135. {
  1136. private:
  1137. BYTE* m_pBlob;
  1138. DWORD m_dwBlobMemSize;
  1139. DWORD m_dwBlobSize;
  1140. public:
  1141. TAGID m_tiTagID;
  1142. BOOL m_bUsed;
  1143. GUID m_ID;
  1144. SdbPatch() :
  1145. m_pBlob(NULL),
  1146. m_tiTagID(0),
  1147. m_dwBlobMemSize(0),
  1148. m_dwBlobSize(0),
  1149. m_ID(GUID_NULL),
  1150. m_bUsed(FALSE) {m_dwOSPlatform = OS_PLATFORM_I386;}
  1151. virtual ~SdbPatch()
  1152. {
  1153. if( m_pBlob != NULL )
  1154. delete m_pBlob;
  1155. }
  1156. PBYTE GetBlobBytes(void) {return m_pBlob;}
  1157. DWORD GetBlobSize(void) {return m_dwBlobSize;}
  1158. void AddBlobBytes( LPVOID pBytes, DWORD dwSize );
  1159. void ClearBlob();
  1160. BOOL ReadFromXML(IXMLDOMNode* pNode, SdbDatabase* pDB);
  1161. BOOL WriteToSDB(PDB pdb);
  1162. BOOL WriteRefToSDB(PDB pdb);
  1163. };
  1164. ///////////////////////////////////////////////////////////////////////////////
  1165. //
  1166. // SdbFlag
  1167. //
  1168. // The SdbFlag object contains a mask which is used by kernel-mode
  1169. // components in special compatibility casing constructs. These flags can be
  1170. // turned on by adding the FLAG subtag to an EXE tag.
  1171. //
  1172. class SdbFlag : public SdbArrayElement
  1173. {
  1174. public:
  1175. CString m_csDesc;
  1176. ULONGLONG m_ullMask;
  1177. DWORD m_dwType;
  1178. TAGID m_tiTagID;
  1179. SdbPurpose m_Purpose;
  1180. GUID m_ID;
  1181. SdbFlag() :
  1182. m_ID(GUID_NULL),
  1183. m_tiTagID(0),
  1184. m_Purpose(SDB_PURPOSE_SPECIFIC),
  1185. m_ullMask(0) {}
  1186. static ULONGLONG MakeMask(SdbRefArray<SdbFlag>* prgFlags, DWORD dwType);
  1187. static TAG TagFromType(DWORD dwType);
  1188. BOOL SetType(CString csType);
  1189. BOOL ReadFromXML(IXMLDOMNode* pNode, SdbDatabase* pDB);
  1190. BOOL WriteToSDB(PDB pdb);
  1191. };
  1192. ///////////////////////////////////////////////////////////////////////////////
  1193. //
  1194. // SdbFlagRef
  1195. //
  1196. // The SdbFlagRef object is simply a reference to a SdbFlag object that exists
  1197. // in a library.
  1198. //
  1199. class SdbFlagRef : public SdbArrayElement
  1200. {
  1201. public:
  1202. SdbFlagRef() :
  1203. m_pFlag(NULL) {}
  1204. SdbFlag* m_pFlag;
  1205. CString m_csCommandLine;
  1206. BOOL ReadFromXML(IXMLDOMNode* pNode, SdbDatabase* pDB);
  1207. BOOL WriteToSDB(PDB pdb);
  1208. };
  1209. ///////////////////////////////////////////////////////////////////////////////
  1210. //
  1211. // SdbLayer
  1212. //
  1213. // The SdbLayer object contains a set of shims and/or kernel flags that can be
  1214. // turned on to invoke a "compatibility mode". Presently, if the environment
  1215. // variable __COMPAT_LAYER is set to the name of this object, all shims and
  1216. // kernel flags contained by the layer will be invoked.
  1217. //
  1218. class SdbLayer : public SdbArrayElement
  1219. {
  1220. public:
  1221. CString m_csDesc;
  1222. CString m_csDisplayName;
  1223. TAGID m_tiTagID;
  1224. GUID m_ID;
  1225. SdbArray<SdbShimRef> m_rgShimRefs;
  1226. SdbArray<SdbFlagRef> m_rgFlagRefs;
  1227. SdbLayer ():
  1228. m_ID(GUID_NULL){m_dwOSPlatform = OS_PLATFORM_I386;}
  1229. void PropagateFilter(DWORD dwFilter)
  1230. {
  1231. SdbArrayElement::PropagateFilter(dwFilter);
  1232. m_rgShimRefs.PropagateFilter(m_dwFilter);
  1233. m_rgFlagRefs.PropagateFilter(m_dwFilter);
  1234. }
  1235. BOOL ReadFromXML(IXMLDOMNode* pNode, SdbDatabase* pDB);
  1236. BOOL WriteToSDB(PDB pdb);
  1237. };
  1238. ///////////////////////////////////////////////////////////////////////////////
  1239. //
  1240. // SdbLayerRef
  1241. //
  1242. // The SdbLayerRef object contains a reference to a layer that exists in the
  1243. // library. It exists to allow <EXE> entries that reference a layer defined
  1244. // in another database.
  1245. //
  1246. class SdbLayerRef : public SdbArrayElement
  1247. {
  1248. public:
  1249. SdbLayerRef() :
  1250. m_pLayer(NULL) {}
  1251. SdbLayer* m_pLayer;
  1252. SdbArray<SdbData> m_rgData;
  1253. BOOL ReadFromXML(IXMLDOMNode* pNode, SdbDatabase* pDB);
  1254. BOOL WriteToSDB(PDB pdb);
  1255. };
  1256. ///////////////////////////////////////////////////////////////////////////////
  1257. //
  1258. // SdbData
  1259. //
  1260. // The SdbData object contains a name-value pair that can be queried
  1261. // at runtime for any data.
  1262. //
  1263. class SdbData : public SdbArrayElement
  1264. {
  1265. private:
  1266. SdbDataValueType m_DataType;
  1267. DWORD m_dwDataSize;
  1268. //
  1269. // nested Data elements
  1270. //
  1271. SdbArray<SdbData> m_rgData;
  1272. public:
  1273. union {
  1274. DWORD m_dwValue; // m_DataType == REG_DWORD
  1275. ULONGLONG m_ullValue; // m_DataType == REG_QWORD
  1276. LPTSTR m_szValue; // m_DataType == REG_SZ
  1277. LPBYTE m_pBinValue; // m_DataType == REG_BINARY
  1278. };
  1279. SdbData() :
  1280. m_DataType(eValueNone),
  1281. m_dwDataSize(0),
  1282. m_ullValue(0) {}
  1283. ~SdbData() {
  1284. Clear();
  1285. }
  1286. void PropagateFilter(DWORD dwFilter)
  1287. {
  1288. SdbArrayElement::PropagateFilter(dwFilter);
  1289. m_rgData.PropagateFilter(m_dwFilter);
  1290. }
  1291. SdbDataValueType GetValueType() { return m_DataType; }
  1292. void Clear();
  1293. BOOL SetValue(SdbDataValueType DataType, LPCTSTR lpValue);
  1294. BOOL ReadFromXML(IXMLDOMNode* pNode, SdbDatabase* pDB);
  1295. BOOL WriteToSDB(PDB pdb);
  1296. };
  1297. ///////////////////////////////////////////////////////////////////////////////
  1298. //
  1299. // SdbAction
  1300. //
  1301. // The SdbAction object contains the type of the action and Data elements that
  1302. // provide any data needed to perform this action.
  1303. //
  1304. class SdbAction: public SdbArrayElement
  1305. {
  1306. private:
  1307. CString m_csType;
  1308. SdbArray<SdbData> m_rgData;
  1309. public:
  1310. SdbAction() {}
  1311. ~SdbAction() {}
  1312. void PropagateFilter(DWORD dwFilter)
  1313. {
  1314. SdbArrayElement::PropagateFilter(dwFilter);
  1315. m_rgData.PropagateFilter(m_dwFilter);
  1316. }
  1317. BOOL ReadFromXML(IXMLDOMNode* pNode, SdbDatabase* pDB);
  1318. BOOL WriteToSDB(PDB pdb);
  1319. };
  1320. class SdbMatchOperation : public SdbArrayElement
  1321. {
  1322. public:
  1323. SdbMatchOperationType m_Type;
  1324. SdbArray<SdbMatchingFile> m_rgMatchingFiles;
  1325. SdbArray<SdbMatchOperation> m_rgSubMatchOps;
  1326. SdbMatchOperation() :
  1327. m_Type(SDB_MATCH_ALL) {}
  1328. void PropagateFilter(DWORD dwFilter)
  1329. {
  1330. SdbArrayElement::PropagateFilter(dwFilter);
  1331. m_rgMatchingFiles.PropagateFilter(m_dwFilter);
  1332. m_rgSubMatchOps.PropagateFilter(m_dwFilter);
  1333. }
  1334. BOOL ReadFromXML(IXMLDOMNode* pNode, SdbDatabase* pDB);
  1335. };
  1336. class SdbWin9xMigration : public SdbArrayElement
  1337. {
  1338. public:
  1339. SdbWin9xMigration() :
  1340. m_pApp(NULL),
  1341. m_bShowInSimplifiedView(FALSE) {}
  1342. CString m_csSection;
  1343. CString m_csMessage;
  1344. GUID m_ID;
  1345. BOOL m_bShowInSimplifiedView;
  1346. SdbApp* m_pApp;
  1347. SdbMatchOperation m_MatchOp;
  1348. BOOL ReadFromXML(IXMLDOMNode* pNode, SdbDatabase* pDB);
  1349. };
  1350. class SdbMatchingRegistryEntry : public SdbArrayElement
  1351. {
  1352. public:
  1353. CString m_csValueName;
  1354. CString m_csValue;
  1355. BOOL ReadFromXML(IXMLDOMNode* pNode, SdbDatabase* pDB);
  1356. };
  1357. class SdbWinNTUpgrade : public SdbArrayElement
  1358. {
  1359. public:
  1360. SdbWinNTUpgrade() :
  1361. m_ID(GUID_NULL),
  1362. m_pApp(NULL) {}
  1363. SdbAppHelpRef m_AppHelpRef;
  1364. SdbMatchingFile m_MatchingFile;
  1365. SdbMatchingRegistryEntry m_MatchingRegistryEntry;
  1366. SdbApp* m_pApp;
  1367. GUID m_ID;
  1368. void PropagateFilter(DWORD dwFilter)
  1369. {
  1370. SdbArrayElement::PropagateFilter(dwFilter);
  1371. m_AppHelpRef.PropagateFilter(m_dwFilter == SDB_FILTER_EXCLUDE_ALL ? SDB_FILTER_EXCLUDE_ALL : SDB_FILTER_NTCOMPAT);
  1372. }
  1373. BOOL ReadFromXML(IXMLDOMNode* pNode, SdbDatabase* pDB);
  1374. };
  1375. #endif // !defined(AFX_OBJ_H__5C16373A_D713_46CD_B8BF_7755216C62E0__INCLUDED_)