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.

775 lines
20 KiB

  1. ///////////////////////////////////////////////////////////////////////////////
  2. //
  3. // File: obj.cpp
  4. //
  5. // History: 16-Nov-00 markder Created.
  6. //
  7. // Desc: This file contains various member functions/constructors
  8. // used by the SdbDatabase object model.
  9. //
  10. ///////////////////////////////////////////////////////////////////////////////
  11. #include "StdAfx.h"
  12. #include "make.h"
  13. ////////////////////////////////////////////////////////////////////////////////////
  14. //
  15. // Func: ReadFromXML, WriteToSDB, WriteRefToSDB
  16. //
  17. // Desc: Each element that can be initialized from XML must implement
  18. // ReadFromXML. Similarly, each object that can persist itself
  19. // in an SDB file must implement WriteToSDB. A special case of
  20. // WriteToSDB is when an object is written differently if it
  21. // is a reference to an object in the LIBRARY, in which case
  22. // the object must implement WriteRefToSDB.
  23. //
  24. BOOL SdbArrayElement::ReadFromXML(
  25. IXMLDOMNode* pNode,
  26. SdbDatabase* pDB)
  27. {
  28. SDBERROR(_T("ReadFromXML not implemented for this object"));
  29. return FALSE;
  30. }
  31. BOOL SdbArrayElement::WriteToSDB(PDB pdb)
  32. {
  33. SDBERROR(_T("WriteToSDB not implemented for this object."));
  34. return FALSE;
  35. }
  36. BOOL SdbArrayElement::WriteRefToSDB(PDB pdb)
  37. {
  38. SDBERROR(_T("WriteRefToSDB not implemented for this object."));
  39. return FALSE;
  40. }
  41. void SdbArrayElement::PropagateFilter(DWORD dwFilter)
  42. {
  43. if (!(m_dwFilter & SDB_FILTER_OVERRIDE)) {
  44. m_dwFilter |= dwFilter;
  45. }
  46. if (dwFilter == SDB_FILTER_EXCLUDE_ALL) {
  47. m_dwFilter = SDB_FILTER_EXCLUDE_ALL;
  48. }
  49. if (m_csOSVersionSpec.GetLength() &&
  50. m_pDB->m_pCurrentMakefile->m_flOSVersion != 0.0) {
  51. if (FilterOSVersion(m_pDB->m_pCurrentMakefile->m_flOSVersion,
  52. m_csOSVersionSpec,
  53. &m_dwSPMask)) {
  54. m_dwFilter = SDB_FILTER_EXCLUDE_ALL;
  55. }
  56. }
  57. if (!(m_dwOSPlatform & m_pDB->m_pCurrentMakefile->m_dwOSPlatform)) {
  58. m_dwFilter = SDB_FILTER_EXCLUDE_ALL;
  59. }
  60. }
  61. ////////////////////////////////////////////////////////////////////////////////////
  62. //
  63. // Func: Compare
  64. //
  65. // Desc: Compare two elements - first compare the keys (m_ullKey member)
  66. // then names, return < 0 if this element should precede pElement
  67. // > 0 if this element should follow pElement
  68. // = 0 if the elements are equal
  69. //
  70. int SdbArrayElement::Compare(const SdbArrayElement* pElement) {
  71. //
  72. // compare key first
  73. //
  74. if (m_ullKey < pElement->m_ullKey) {
  75. return -1;
  76. }
  77. //
  78. // we are either greater or equal
  79. //
  80. if (m_ullKey > pElement->m_ullKey) {
  81. return 1;
  82. }
  83. //
  84. // equal keys, compare names
  85. //
  86. return m_csName.CompareNoCase(pElement->m_csName);
  87. }
  88. int SdbExe::Compare(const SdbArrayElement* pElement) {
  89. int nRet = SdbArrayElement::Compare(pElement);
  90. if (nRet == 0) {
  91. //
  92. // the keys are equal, but we want to put the additive one(s) before the non-additive
  93. //
  94. if (m_dwMatchMode == MATCH_ADDITIVE && ((SdbExe*)pElement)->m_dwMatchMode != MATCH_ADDITIVE) {
  95. nRet = -1;
  96. } else if (m_dwMatchMode != MATCH_ADDITIVE && ((SdbExe*)pElement)->m_dwMatchMode == MATCH_ADDITIVE) {
  97. nRet = 1;
  98. }
  99. }
  100. return nRet;
  101. }
  102. ////////////////////////////////////////////////////////////////////////////////////
  103. //
  104. // Func: SdbPatch::AddBlobBytes, SdbPatch::ClearBlob
  105. //
  106. // Desc: Helper functions to add to the SdbPatch 'blob', which is a series
  107. // of opcodes and instructions that define how to match on memory
  108. // and 'patch' it safely.
  109. //
  110. void SdbPatch::AddBlobBytes( LPVOID pBytes, DWORD dwSize )
  111. {
  112. PBYTE pOldBuffer = NULL;
  113. DWORD dwOldBufferSize = 0;
  114. if( m_pBlob == NULL )
  115. {
  116. m_dwBlobMemSize = dwSize > 1000 ? dwSize : 1000;
  117. m_pBlob = new BYTE[m_dwBlobMemSize];
  118. m_dwBlobSize = 0;
  119. }
  120. if( dwSize > m_dwBlobMemSize - m_dwBlobSize )
  121. {
  122. pOldBuffer = m_pBlob;
  123. dwOldBufferSize = m_dwBlobMemSize;
  124. m_dwBlobMemSize = ( m_dwBlobMemSize * 2 ) + dwSize;
  125. m_pBlob = new BYTE[m_dwBlobMemSize];
  126. if( pOldBuffer )
  127. {
  128. memcpy( m_pBlob, pOldBuffer, dwOldBufferSize );
  129. delete pOldBuffer;
  130. }
  131. }
  132. memcpy( (LPVOID) (m_pBlob + m_dwBlobSize ), pBytes, dwSize );
  133. m_dwBlobSize += dwSize;
  134. }
  135. void SdbPatch::ClearBlob()
  136. {
  137. if (m_pBlob != NULL) {
  138. delete m_pBlob;
  139. m_pBlob = NULL;
  140. }
  141. m_dwBlobMemSize = 0;
  142. m_dwBlobSize = 0;
  143. }
  144. ////////////////////////////////////////////////////////////////////////////////////
  145. //
  146. // Func: SdbData::SetValue, SdbData::Clear
  147. //
  148. // Desc: Accessor functions to set/clear the value of a data object.
  149. // The object mimics the registry in the way that it can store
  150. // DWORDs, strings or binary data.
  151. //
  152. BOOL SdbData::SetValue(SdbDataValueType DataType, LPCTSTR szValue)
  153. {
  154. Clear();
  155. m_DataType = DataType;
  156. m_dwDataSize = 0;
  157. switch(DataType) {
  158. case eValueDWORD:
  159. m_dwDataSize = sizeof(m_dwValue);
  160. m_dwValue = StringToDword(szValue);
  161. break;
  162. case eValueQWORD:
  163. m_dwDataSize = sizeof(m_ullValue);
  164. m_ullValue = StringToQword(szValue);
  165. break;
  166. case eValueBinary:
  167. m_dwDataSize = GetByteStringSize(szValue);
  168. m_pBinValue = new BYTE[m_dwDataSize];
  169. if (m_pBinValue == NULL) {
  170. return FALSE;
  171. }
  172. GetBytesFromString(szValue, m_pBinValue, m_dwDataSize);
  173. break;
  174. case eValueString:
  175. m_szValue = new TCHAR[_tcslen(szValue) + 1];
  176. if (m_szValue == NULL) {
  177. return FALSE;
  178. }
  179. StringCchCopy(m_szValue, _tcslen(szValue) + 1, szValue);
  180. break;
  181. }
  182. return TRUE;
  183. }
  184. void SdbData::Clear()
  185. {
  186. switch(m_DataType) {
  187. case eValueString:
  188. if (NULL != m_szValue) {
  189. delete[] m_szValue;
  190. }
  191. break;
  192. case eValueBinary:
  193. if (NULL != m_pBinValue) {
  194. delete[] m_pBinValue;
  195. }
  196. break;
  197. }
  198. m_DataType = eValueNone;
  199. }
  200. BOOL SdbDatabase::IsStandardDatabase(VOID)
  201. {
  202. const GUID* rgpGUID[] = {
  203. &GUID_SYSMAIN_SDB,
  204. &GUID_APPHELP_SDB,
  205. &GUID_SYSTEST_SDB,
  206. &GUID_DRVMAIN_SDB,
  207. &GUID_MSIMAIN_SDB
  208. };
  209. int i;
  210. for (i = 0; i < ARRAYSIZE(rgpGUID); ++i) {
  211. if (*rgpGUID[i] == m_CurrentDBID) {
  212. return TRUE;
  213. }
  214. }
  215. return FALSE;
  216. }
  217. BOOL SdbDatabase::ReplaceFields(CString csXML, CString* pcsReturn, SdbRefArray<SdbMessageField>* prgFields)
  218. {
  219. BOOL bSuccess = FALSE;
  220. XMLNodeList XQL;
  221. IXMLDOMNodePtr cpTargetNode;
  222. IXMLDOMNodePtr cpCurrentNode;
  223. IXMLDOMNodePtr cpNewTextNode;
  224. IXMLDOMNodePtr cpParentNode;
  225. IXMLDOMNodePtr cpOldNode;
  226. IXMLDOMDocument* pDocument;
  227. CString csFieldName, csTempXML;
  228. CHAR* lpBuf;
  229. BSTR bsText = NULL;
  230. VARIANT vType;
  231. long i;
  232. SdbMessageField* pField;
  233. VariantInit(&vType);
  234. vType.vt = VT_I4;
  235. vType.lVal = NODE_TEXT;
  236. #ifdef UNICODE
  237. // lpBuf = (LPSTR) csTempXML.GetBuffer(10);
  238. // lpBuf[0] = (CHAR) 0xFF;
  239. // lpBuf[1] = (CHAR) 0xFE;
  240. // lpBuf[2] = 0x00;
  241. // lpBuf[3] = 0x00;
  242. // csTempXML.ReleaseBuffer();
  243. csTempXML += L"<?xml version=\"1.0\" encoding=\"UTF-16\"?>";
  244. #else
  245. csTempXML = "<?xml version=\"1.0\" encoding=\"Windows-1252\"?>";
  246. #endif
  247. csTempXML += _T("<_TARGET>");
  248. csTempXML += csXML;
  249. csTempXML += _T("</_TARGET>");
  250. //
  251. // Replace all <, > and &amp; in fields with ugly markers to be replaced later
  252. //
  253. for (i = 0; i < prgFields->GetSize(); i++) {
  254. pField = (SdbMessageField *) prgFields->GetAt(i);
  255. pField->m_csValue.Replace(_T("&lt;"), _T("____REAL_LESS_THAN____"));
  256. pField->m_csValue.Replace(_T("&gt;"), _T("____REAL_GREATER_THAN____"));
  257. pField->m_csValue.Replace(_T("<"), _T("____LESS_THAN____"));
  258. pField->m_csValue.Replace(_T(">"), _T("____GREATER_THAN____"));
  259. pField->m_csValue.Replace(_T("&amp;"), _T("____AMP____"));
  260. pField->m_csValue.Replace(_T("&nbsp;"), _T("____NBSP____"));
  261. }
  262. //
  263. // Load the XML into the temporary DOM
  264. //
  265. if (!OpenXML(csTempXML, &m_cpTempXML, TRUE, &m_cpTempXMLDoc)) {
  266. SDBERROR_PROPOGATE();
  267. goto eh;
  268. }
  269. if (!XQL.Query(m_cpTempXML, _T("_TARGET"))) {
  270. SDBERROR_PROPOGATE();
  271. goto eh;
  272. }
  273. if (!XQL.GetItem(0, &cpTargetNode)) {
  274. SDBERROR_PROPOGATE();
  275. goto eh;
  276. }
  277. XQL.Query(cpTargetNode, _T("//*"));
  278. for (i = 0; i < XQL.GetSize(); i++) {
  279. if (!XQL.GetItem(i, &cpCurrentNode)) {
  280. SDBERROR_PROPOGATE();
  281. goto eh;
  282. }
  283. if (GetNodeName(cpCurrentNode) == _T("FIELD")) {
  284. GetAttribute(_T("NAME"), cpCurrentNode, &csFieldName);
  285. pField = (SdbMessageField *) prgFields->LookupName(csFieldName);
  286. if (pField != NULL) {
  287. bsText = pField->m_csValue.AllocSysString();
  288. if (FAILED(m_cpTempXML->get_ownerDocument(&pDocument))) {
  289. SDBERROR(_T("createNode failed while adding attribute"));
  290. goto eh;
  291. }
  292. if (FAILED(m_cpTempXMLDoc->createNode(vType, NULL, NULL, &cpNewTextNode))) {
  293. SDBERROR(_T("createNode failed while adding attribute"));
  294. goto eh;
  295. }
  296. if (FAILED(cpNewTextNode->put_text(bsText))) {
  297. SDBERROR(_T("Could not set text property of FIELD object."));
  298. goto eh;
  299. }
  300. if (FAILED(cpCurrentNode->get_parentNode(&cpParentNode))) {
  301. SDBERROR(_T("Could not retrieve parent node of FIELD object."));
  302. goto eh;
  303. }
  304. if (FAILED(cpParentNode->replaceChild(cpNewTextNode, cpCurrentNode, &cpOldNode))) {
  305. SDBERROR(_T("Could not replace <FIELD> node with text node."));
  306. goto eh;
  307. }
  308. cpNewTextNode = NULL;
  309. cpOldNode = NULL;
  310. SysFreeString(bsText);
  311. bsText = NULL;
  312. }
  313. }
  314. cpCurrentNode.Release();
  315. }
  316. *pcsReturn = GetInnerXML(cpTargetNode);
  317. //
  318. // Turn the ugly markers back to prettiness
  319. //
  320. pcsReturn->Replace(_T("____REAL_LESS_THAN____"), _T("&lt;"));
  321. pcsReturn->Replace(_T("____REAL_GREATER_THAN____"), _T("&gt;"));
  322. pcsReturn->Replace(_T("____LESS_THAN____"), _T("<"));
  323. pcsReturn->Replace(_T("____GREATER_THAN____"), _T(">"));
  324. pcsReturn->Replace(_T("____AMP____"), _T("&amp;"));
  325. pcsReturn->Replace(_T("____NBSP____"), _T("&nbsp;"));
  326. bSuccess = TRUE;
  327. eh:
  328. VariantClear(&vType);
  329. if (bsText) {
  330. SysFreeString(bsText);
  331. }
  332. return bSuccess;
  333. }
  334. BOOL SdbDatabase::RedirectLinks(CString* pcsXML, LCID lcid, CString csRedirURL)
  335. {
  336. BOOL bSuccess = FALSE;
  337. XMLNodeList XQL;
  338. IXMLDOMNodePtr cpTargetNode;
  339. IXMLDOMNodePtr cpCurrentNode;
  340. CString csRedirID, csFinalRedirURL, csLCID;
  341. CString csTempXML;
  342. long i;
  343. csLCID.Format(_T("%X"), lcid);
  344. csTempXML = _T("<?xml version=\"1.0\"?><_TARGET>");
  345. csTempXML += *pcsXML;
  346. csTempXML += _T("</_TARGET>");
  347. if (!OpenXML(csTempXML, &m_cpTempXML, TRUE, &m_cpTempXMLDoc)) {
  348. SDBERROR_PROPOGATE();
  349. goto eh;
  350. }
  351. if (!XQL.Query(m_cpTempXML, _T("_TARGET"))) {
  352. SDBERROR_PROPOGATE();
  353. goto eh;
  354. }
  355. if (!XQL.GetItem(0, &cpTargetNode)) {
  356. SDBERROR_PROPOGATE();
  357. goto eh;
  358. }
  359. if (!XQL.Query(m_cpTempXML, _T("//A"))) {
  360. SDBERROR_PROPOGATE();
  361. goto eh;
  362. }
  363. for (i = 0; i < XQL.GetSize(); i++) {
  364. if (!XQL.GetItem(i, &cpCurrentNode)) {
  365. SDBERROR_PROPOGATE();
  366. goto eh;
  367. }
  368. if (!GetAttribute(_T("REDIR_ID"), cpCurrentNode, &csRedirID)) {
  369. SDBERROR_FORMAT((_T("REDIR_ID not found on <A> element:\n%s\n"),
  370. *pcsXML));
  371. goto eh;
  372. }
  373. csFinalRedirURL = csRedirURL;
  374. csFinalRedirURL.Replace(_T("$REDIR_ID$"), csRedirID);
  375. csFinalRedirURL.Replace(_T("$LCID$"), csLCID);
  376. if (!AddAttribute(cpCurrentNode, _T("HREF"), csFinalRedirURL)) {
  377. SDBERROR_FORMAT((_T("Could not replace HREF attribute on <A> tag:\n%s\n"),
  378. *pcsXML));
  379. goto eh;
  380. }
  381. if (!AddAttribute(cpCurrentNode, _T("TARGET"), _T("_new"))) {
  382. SDBERROR_FORMAT((_T("Could not add TARGET=\"_new\" attribute on <A> tag:\n%s\n"),
  383. *pcsXML));
  384. goto eh;
  385. }
  386. if (!RemoveAttribute(_T("REDIR_ID"), cpCurrentNode)) {
  387. SDBERROR_FORMAT((_T("Could not remove REDIR_ID attribute on <A> tag:\n%s\n"),
  388. *pcsXML));
  389. goto eh;
  390. }
  391. }
  392. *pcsXML = GetInnerXML(cpTargetNode);
  393. bSuccess = TRUE;
  394. eh:
  395. return bSuccess;
  396. }
  397. BOOL SdbDatabase::HTMLtoText(CString csXML, CString* pcsReturn)
  398. {
  399. BOOL bSuccess = FALSE;
  400. XMLNodeList XQL;
  401. IXMLDOMNodePtr cpTargetNode;
  402. IXMLDOMNodePtr cpCurrentNode;
  403. IXMLDOMDocument* pDocument;
  404. DOMNodeType NodeType;
  405. CString csTempXML;
  406. BSTR bsText = NULL;
  407. long i;
  408. csTempXML = _T("<?xml version=\"1.0\"?><_TARGET>");
  409. csTempXML += csXML;
  410. csTempXML += _T("</_TARGET>");
  411. pcsReturn->Empty();
  412. //
  413. // Load the XML into the temporary DOM
  414. //
  415. if (!OpenXML(csTempXML, &m_cpTempXML, TRUE, &m_cpTempXMLDoc)) {
  416. SDBERROR_PROPOGATE();
  417. goto eh;
  418. }
  419. if (!XQL.Query(m_cpTempXML, _T("_TARGET"))) {
  420. SDBERROR_PROPOGATE();
  421. goto eh;
  422. }
  423. if (!XQL.GetItem(0, &cpTargetNode)) {
  424. SDBERROR_PROPOGATE();
  425. goto eh;
  426. }
  427. XQL.Query(cpTargetNode, _T("//"));
  428. for (i = 0; i < XQL.GetSize(); i++) {
  429. if (!XQL.GetItem(i, &cpCurrentNode)) {
  430. SDBERROR_PROPOGATE();
  431. goto eh;
  432. }
  433. if (FAILED(cpCurrentNode->get_nodeType(&NodeType))) {
  434. SDBERROR(_T("Error retrieving nodeType attribute."));
  435. goto eh;
  436. }
  437. if (NodeType == NODE_TEXT) {
  438. *pcsReturn += _T(" ");
  439. *pcsReturn += GetText(cpCurrentNode);
  440. *pcsReturn += _T(" ");
  441. } else {
  442. if (GetNodeName(cpCurrentNode) == _T("BR")) {
  443. *pcsReturn += _T("\n");
  444. }
  445. if (GetNodeName(cpCurrentNode) == _T("P")) {
  446. *pcsReturn += _T("\n\n");
  447. }
  448. }
  449. cpCurrentNode.Release();
  450. }
  451. bSuccess = TRUE;
  452. eh:
  453. if (bsText) {
  454. SysFreeString(bsText);
  455. }
  456. return bSuccess;
  457. }
  458. CString SdbApp::GetLocalizedAppName()
  459. {
  460. return GetLocalizedAppName(m_pDB->m_pCurrentMakefile->m_csLangID);
  461. }
  462. CString SdbApp::GetLocalizedAppName(CString csLangID)
  463. {
  464. CString csLookup(m_csName);
  465. SdbLocalizedString* pLocString = NULL;
  466. csLookup.MakeUpper();
  467. pLocString = (SdbLocalizedString *) m_pDB->m_rgLocalizedAppNames.LookupName(csLookup, csLangID);
  468. if (pLocString) {
  469. return pLocString->m_csValue;
  470. } else {
  471. return m_csName;
  472. }
  473. }
  474. CString SdbApp::GetLocalizedVendorName()
  475. {
  476. return GetLocalizedVendorName(m_pDB->m_pCurrentMakefile->m_csLangID);
  477. }
  478. CString SdbApp::GetLocalizedVendorName(CString csLangID)
  479. {
  480. CString csLookup(m_csVendor);
  481. SdbLocalizedString* pLocString = NULL;
  482. csLookup.MakeUpper();
  483. pLocString = (SdbLocalizedString *)
  484. m_pDB->m_rgLocalizedVendorNames.LookupName(csLookup, csLangID);
  485. if (pLocString) {
  486. return pLocString->m_csValue;
  487. } else {
  488. return m_csVendor;
  489. }
  490. }
  491. BOOL SdbExe::IsValidForWin2k(CString csXML)
  492. {
  493. BOOL bReturn = FALSE;
  494. SdbMatchingFile* pMFile;
  495. if (!FilterOSVersion(5.0, m_csOSVersionSpec, &m_dwSPMask)) {
  496. if (m_csName.GetLength() > 1 &&
  497. m_csName.FindOneOf(_T("*?")) != -1) {
  498. SDBERROR_FORMAT((
  499. _T("Wildcards not supported on Win2k. Add OS_VERSION=\"gte5.1\" to <EXE>:\n%s\n"),
  500. csXML));
  501. goto eh;
  502. }
  503. for (long i = 0; i < m_rgMatchingFiles.GetSize(); i++) {
  504. pMFile = (SdbMatchingFile *) m_rgMatchingFiles.GetAt(i);
  505. if (!pMFile->IsValidForWin2k(csXML)) {
  506. SDBERROR_PROPOGATE();
  507. goto eh;
  508. }
  509. }
  510. }
  511. bReturn = TRUE;
  512. eh:
  513. return bReturn;
  514. }
  515. BOOL SdbMatchingFile::IsValidForWin2k(CString csXML)
  516. {
  517. BOOL bReturn = FALSE;
  518. if (m_bMatchLogicNot) {
  519. SDBERROR_FORMAT((
  520. _T("LOGIC=\"NOT\" not supported on Win2k, add OS_VERSION=\"gte5.1\" to <EXE>:\n%s\n"),
  521. csXML));
  522. goto eh;
  523. }
  524. if (m_dwMask &
  525. (SDB_MATCHINGINFO_LINK_DATE | SDB_MATCHINGINFO_UPTO_LINK_DATE)) {
  526. SDBERROR_FORMAT((
  527. _T("LINK_DATE and UPTO_LINK_DATE not supported on Win2k, add OS_VERSION=\"gte5.1\" to <EXE>:\n%s\n"),
  528. csXML));
  529. goto eh;
  530. }
  531. if (m_csCompanyName.FindOneOf(_T("*?")) != -1 ||
  532. m_csProductName.FindOneOf(_T("*?")) != -1 ||
  533. m_csProductVersion.FindOneOf(_T("*?")) != -1 ||
  534. m_csFileDescription.FindOneOf(_T("*?")) != -1 ||
  535. m_csFileVersion.FindOneOf(_T("*?")) != -1 ||
  536. m_csOriginalFileName.FindOneOf(_T("*?")) != -1 ||
  537. m_csInternalName.FindOneOf(_T("*?")) != -1 ||
  538. m_csLegalCopyright.FindOneOf(_T("*?")) != -1 ||
  539. m_cs16BitDescription.FindOneOf(_T("*?")) != -1 ||
  540. m_cs16BitModuleName.FindOneOf(_T("*?")) != -1) {
  541. SDBERROR_FORMAT((
  542. _T("Wildcards not supported on Win2k, add OS_VERSION=\"gte5.1\" to <EXE>:\n%s\n"),
  543. csXML));
  544. goto eh;
  545. }
  546. if ((m_ullBinFileVersion & 0x000000000000FFFF) == 0x000000000000FFFF ||
  547. (m_ullBinProductVersion & 0x000000000000FFFF) == 0x000000000000FFFF)
  548. {
  549. SDBERROR_FORMAT((
  550. _T("Non-exact matching on binary version not supported on Win2k, add OS_VERSION=\"gte5.1\" to <EXE>:\n%s\n"),
  551. csXML));
  552. goto eh;
  553. }
  554. bReturn = TRUE;
  555. eh:
  556. return bReturn;
  557. }
  558. ULONGLONG SdbFlag::MakeMask(SdbRefArray<SdbFlag>* prgFlags, DWORD dwType)
  559. {
  560. SdbFlag* pFlag;
  561. long i;
  562. ULONGLONG ullMask = 0;
  563. for (i = 0; i < prgFlags->GetSize(); i++) {
  564. pFlag = (SdbFlag *) prgFlags->GetAt(i);
  565. if (pFlag->m_dwType == dwType) {
  566. ullMask |= pFlag->m_ullMask;
  567. }
  568. }
  569. return ullMask;
  570. }
  571. BOOL SdbFlag::SetType(CString csType)
  572. {
  573. csType.MakeUpper();
  574. if (csType == _T("KERNEL")) {
  575. m_dwType = SDB_FLAG_KERNEL;
  576. } else if (csType == _T("USER")) {
  577. m_dwType = SDB_FLAG_USER;
  578. } else if (csType == _T("SHELL")) {
  579. m_dwType = SDB_FLAG_SHELL;
  580. } else if (csType == _T("FUSION")) {
  581. m_dwType = SDB_FLAG_FUSION;
  582. } else if (csType == _T("NTVDM1")) {
  583. m_dwType = SDB_FLAG_NTVDM1;
  584. } else if (csType == _T("NTVDM2")) {
  585. m_dwType = SDB_FLAG_NTVDM2;
  586. } else if (csType == _T("NTVDM3")) {
  587. m_dwType = SDB_FLAG_NTVDM3;
  588. } else {
  589. return FALSE;
  590. }
  591. return TRUE;
  592. }
  593. TAG SdbFlag::TagFromType(DWORD dwType)
  594. {
  595. TAG tReturn = TAG_NULL;
  596. switch (dwType) {
  597. case SDB_FLAG_KERNEL:
  598. tReturn = TAG_FLAG_MASK_KERNEL;
  599. break;
  600. case SDB_FLAG_USER:
  601. tReturn = TAG_FLAG_MASK_USER;
  602. break;
  603. case SDB_FLAG_SHELL:
  604. tReturn = TAG_FLAG_MASK_SHELL;
  605. break;
  606. case SDB_FLAG_FUSION:
  607. tReturn = TAG_FLAG_MASK_FUSION;
  608. break;
  609. case SDB_FLAG_NTVDM1:
  610. tReturn = TAG_FLAGS_NTVDM1;
  611. break;
  612. case SDB_FLAG_NTVDM2:
  613. tReturn = TAG_FLAGS_NTVDM2;
  614. break;
  615. case SDB_FLAG_NTVDM3:
  616. tReturn = TAG_FLAGS_NTVDM3;
  617. break;
  618. default:
  619. break;
  620. }
  621. return tReturn;
  622. }