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.

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