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.

596 lines
24 KiB

  1. #include <fusenetincludes.h>
  2. #include <assemblycache.h>
  3. #include <msxml2.h>
  4. #include <manifestimport.h>
  5. #include <manifestdata.h>
  6. #include <dbglog.h>
  7. // fwd declaration
  8. HRESULT CheckPlatform(LPMANIFEST_DATA pPlatformData);
  9. // return: 0 for all satisfied
  10. HRESULT CheckPlatformRequirementsEx(LPASSEMBLY_MANIFEST_IMPORT pManifestImport,
  11. CDebugLog* pDbgLog, LPDWORD pdwNumMissingPlatforms, LPTPLATFORM_INFO* pptPlatform)
  12. {
  13. HRESULT hr = S_OK;
  14. MAKE_ERROR_MACROS_STATIC(hr);
  15. DWORD dwCount = 0;
  16. DWORD dwMissingCount = 0;
  17. LPMANIFEST_DATA pPlatformList = NULL;
  18. LPMANIFEST_DATA pPlatformData = NULL;
  19. DWORD cbProperty = 0, dwType = 0;
  20. LPASSEMBLY_IDENTITY pAsmId = NULL;
  21. LPTPLATFORM_INFO ptPlatform = NULL;
  22. LPWSTR pwzId = NULL;
  23. DWORD dwCC = 0;
  24. IF_NULL_EXIT(pManifestImport, E_INVALIDARG);
  25. IF_NULL_EXIT(pdwNumMissingPlatforms, E_INVALIDARG);
  26. IF_NULL_EXIT(pptPlatform, E_INVALIDARG);
  27. *pdwNumMissingPlatforms = 0;
  28. *pptPlatform = NULL;
  29. IF_FAILED_EXIT(CreateManifestData(L"platform list", &pPlatformList));
  30. IF_FAILED_EXIT(pManifestImport->GetNextPlatform(dwCount, &pPlatformData));
  31. while (hr == S_OK)
  32. {
  33. if (pDbgLog)
  34. {
  35. SAFEDELETEARRAY(pwzId);
  36. IF_FAILED_EXIT(pPlatformData->GetType(&pwzId));
  37. IF_NULL_EXIT(pwzId, E_FAIL);
  38. IF_FAILED_EXIT(FusionCompareString(pwzId, WZ_DATA_PLATFORM_MANAGED, 0));
  39. if (hr == S_OK)
  40. {
  41. SAFEDELETEARRAY(pwzId);
  42. IF_FAILED_EXIT(pPlatformData->Get(CAssemblyManifestImport::g_StringTable[CAssemblyManifestImport::AssemblyIdTag].pwz,
  43. (LPVOID*) &pAsmId, &cbProperty, &dwType));
  44. IF_NULL_EXIT(pAsmId, E_FAIL);
  45. IF_FALSE_EXIT(dwType == MAN_DATA_TYPE_IUNKNOWN_PTR, E_FAIL);
  46. IF_FAILED_EXIT(pAsmId->GetDisplayName(0, &pwzId, &dwCC));
  47. SAFERELEASE(pAsmId);
  48. }
  49. }
  50. IF_FAILED_EXIT(CheckPlatform(pPlatformData));
  51. if (hr == S_FALSE)
  52. {
  53. IF_FALSE_EXIT(dwMissingCount < dwMissingCount+1, HRESULT_FROM_WIN32(ERROR_ARITHMETIC_OVERFLOW));
  54. dwMissingCount++;
  55. // ISSUE-06/07/02-felixybc use linked-list instead?
  56. IF_FAILED_EXIT((static_cast<CManifestData*>(pPlatformList))->Set(dwMissingCount, (LPVOID) pPlatformData, sizeof(LPVOID), MAN_DATA_TYPE_IUNKNOWN_PTR));
  57. if (pDbgLog)
  58. {
  59. DEBUGOUT1(pDbgLog, 1, L" LOG: Missing dependent platform, id: %s", pwzId);
  60. }
  61. }
  62. else if (pDbgLog)
  63. {
  64. DEBUGOUT1(pDbgLog, 1, L" LOG: Found dependent platform, id: %s", pwzId);
  65. }
  66. SAFERELEASE(pPlatformData);
  67. IF_FALSE_EXIT(dwCount < dwCount+1, HRESULT_FROM_WIN32(ERROR_ARITHMETIC_OVERFLOW));
  68. dwCount++;
  69. // platform data is returned in order
  70. IF_FAILED_EXIT(pManifestImport->GetNextPlatform(dwCount, &pPlatformData));
  71. }
  72. // assemble platform struct
  73. if (dwMissingCount > 0)
  74. {
  75. IF_ALLOC_FAILED_EXIT(ptPlatform = new TPLATFORM_INFO[dwMissingCount]);
  76. // ISSUE - zero out memory pointed by ptPlatform
  77. for (DWORD dw = 0; dw < dwMissingCount; dw++)
  78. {
  79. IF_FAILED_EXIT((static_cast<CManifestData*>(pPlatformList))->Get(dw+1, (LPVOID *)&pPlatformData, &cbProperty, &dwType));
  80. IF_NULL_EXIT(pPlatformData, E_FAIL);
  81. IF_FALSE_EXIT(dwType == MAN_DATA_TYPE_IUNKNOWN_PTR, E_FAIL);
  82. // allow missing friendly name??
  83. IF_FAILED_EXIT(pPlatformData->Get(CAssemblyManifestImport::g_StringTable[CAssemblyManifestImport::FriendlyName].pwz,
  84. (LPVOID *)&((ptPlatform[dw]).pwzName), &cbProperty, &dwType));
  85. IF_NULL_EXIT(((ptPlatform[dw]).pwzName), E_FAIL);
  86. IF_FALSE_EXIT(dwType == MAN_DATA_TYPE_LPWSTR, E_FAIL);
  87. IF_FAILED_EXIT(pPlatformData->Get(CAssemblyManifestImport::g_StringTable[CAssemblyManifestImport::Href].pwz,
  88. (LPVOID *)&((ptPlatform[dw]).pwzURL), &cbProperty, &dwType));
  89. // allow missing URL
  90. if ((ptPlatform[dw]).pwzURL != NULL)
  91. {
  92. IF_FALSE_EXIT(dwType == MAN_DATA_TYPE_LPWSTR, E_FAIL);
  93. }
  94. // ISSUE-06/07/02-felixybc for internal use, need a different way to return Codebase
  95. SAFERELEASE(pPlatformData);
  96. if (pDbgLog)
  97. {
  98. DEBUGOUT2(pDbgLog, 1, L" LOG: Missing dependent platform data, friendlyName: %s; codebase/URL: %s",
  99. (ptPlatform[dw]).pwzName, (ptPlatform[dw]).pwzURL);
  100. }
  101. }
  102. }
  103. *pdwNumMissingPlatforms = dwMissingCount;
  104. *pptPlatform = ptPlatform;
  105. ptPlatform = NULL;
  106. exit:
  107. if (FAILED(hr) && ptPlatform)
  108. {
  109. for (DWORD dw = 0; dw < dwMissingCount; dw++)
  110. {
  111. SAFEDELETEARRAY((ptPlatform[dw]).pwzName);
  112. SAFEDELETEARRAY((ptPlatform[dw]).pwzURL);
  113. }
  114. SAFEDELETEARRAY(ptPlatform);
  115. }
  116. SAFEDELETEARRAY(pwzId);
  117. SAFERELEASE(pAsmId);
  118. SAFERELEASE(pPlatformData);
  119. SAFERELEASE(pPlatformList);
  120. return hr;
  121. }
  122. // return: 0 for all satisfied
  123. HRESULT CheckPlatformRequirements(LPASSEMBLY_MANIFEST_IMPORT pManifestImport,
  124. LPDWORD pdwNumMissingPlatforms, LPTPLATFORM_INFO* pptPlatform)
  125. {
  126. return CheckPlatformRequirementsEx(pManifestImport, NULL, pdwNumMissingPlatforms, pptPlatform);
  127. }
  128. #define WZ_PLATFORM_OS_TYPE_WORKSTATION L"workstation"
  129. #define WZ_PLATFORM_OS_TYPE_DOMAIN_CONTROLLER L"domainController"
  130. #define WZ_PLATFORM_OS_TYPE_SERVER L"server"
  131. #define WZ_PLATFORM_OS_SUITE_BACKOFFICE L"backoffice"
  132. #define WZ_PLATFORM_OS_SUITE_BLADE L"blade"
  133. #define WZ_PLATFORM_OS_SUITE_DATACENTER L"datacenter"
  134. #define WZ_PLATFORM_OS_SUITE_ENTERPRISE L"enterprise"
  135. #define WZ_PLATFORM_OS_SUITE_PERSONAL L"home" // note: different text
  136. #define WZ_PLATFORM_OS_SUITE_SMALLBUSINESS L"smallbusiness"
  137. #define WZ_PLATFORM_OS_SUITE_SMALLBUSINESS_RESTRICTED L"smallbusinessRestricted"
  138. #define WZ_PLATFORM_OS_SUITE_TERMINAL L"terminal"
  139. // our addition/definition:
  140. #define WZ_PLATFORM_OS_SUITE_PROFESSIONAL L"professional"
  141. // return: S_OK
  142. // S_FALSE
  143. // E_*
  144. HRESULT CheckOSHelper(LPMANIFEST_DATA pOSData)
  145. {
  146. HRESULT hr = S_OK;
  147. MAKE_ERROR_MACROS_STATIC(hr);
  148. LPWSTR pwzBuf = NULL;
  149. LPDWORD pdwVal = NULL;
  150. DWORD cbProperty = 0;
  151. DWORD dwType = 0;
  152. OSVERSIONINFOEX osvi;
  153. DWORDLONG dwlConditionMask = 0;
  154. DWORD dwTypeMask = 0;
  155. BOOL bCheckProfessionalSuite = FALSE;
  156. #define WORD_MAX 0xffff
  157. // verify type
  158. IF_FAILED_EXIT(pOSData->GetType(&pwzBuf));
  159. IF_FAILED_EXIT(FusionCompareString(WZ_DATA_OSVERSIONINFO, pwzBuf, 0));
  160. IF_FALSE_EXIT(hr == S_OK, E_INVALIDARG);
  161. SAFEDELETEARRAY(pwzBuf);
  162. // Initialize the OSVERSIONINFOEX structure.
  163. ZeroMemory(&osvi, sizeof(OSVERSIONINFOEX));
  164. osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);
  165. for (CAssemblyManifestImport::eStringTableId i = CAssemblyManifestImport::MajorVersion; i <= CAssemblyManifestImport::ProductType; i++)
  166. {
  167. if (i >= CAssemblyManifestImport::MajorVersion && i <= CAssemblyManifestImport::ServicePackMinor)
  168. {
  169. IF_FAILED_EXIT(pOSData->Get(CAssemblyManifestImport::g_StringTable[i].pwz,
  170. (LPVOID*) &pdwVal, &cbProperty, &dwType));
  171. if (pdwVal != NULL)
  172. {
  173. IF_FALSE_EXIT(dwType == MAN_DATA_TYPE_DWORD, E_FAIL);
  174. switch (i)
  175. {
  176. case CAssemblyManifestImport::MajorVersion:
  177. osvi.dwMajorVersion = *pdwVal;
  178. // Initialize the condition mask.
  179. VER_SET_CONDITION( dwlConditionMask, VER_MAJORVERSION,
  180. VER_GREATER_EQUAL );
  181. dwTypeMask |= VER_MAJORVERSION;
  182. break;
  183. case CAssemblyManifestImport::MinorVersion:
  184. osvi.dwMinorVersion = *pdwVal;
  185. VER_SET_CONDITION( dwlConditionMask, VER_MINORVERSION,
  186. VER_GREATER_EQUAL );
  187. dwTypeMask |= VER_MINORVERSION;
  188. break;
  189. case CAssemblyManifestImport::BuildNumber:
  190. osvi.dwBuildNumber = *pdwVal;
  191. VER_SET_CONDITION( dwlConditionMask, VER_BUILDNUMBER,
  192. VER_GREATER_EQUAL );
  193. dwTypeMask |= VER_BUILDNUMBER;
  194. break;
  195. case CAssemblyManifestImport::ServicePackMajor:
  196. // WORD
  197. osvi.wServicePackMajor = (WORD) ((*pdwVal) & WORD_MAX);
  198. VER_SET_CONDITION( dwlConditionMask, VER_SERVICEPACKMAJOR,
  199. VER_GREATER_EQUAL );
  200. dwTypeMask |= VER_SERVICEPACKMAJOR;
  201. break;
  202. case CAssemblyManifestImport::ServicePackMinor:
  203. // WORD
  204. osvi.wServicePackMinor = (WORD) ((*pdwVal) & WORD_MAX);
  205. VER_SET_CONDITION( dwlConditionMask, VER_SERVICEPACKMINOR,
  206. VER_GREATER_EQUAL );
  207. dwTypeMask |= VER_SERVICEPACKMINOR;
  208. break;
  209. //default: should not happen
  210. }
  211. SAFEDELETEARRAY(pdwVal);
  212. }
  213. }
  214. else
  215. {
  216. IF_FAILED_EXIT(pOSData->Get(CAssemblyManifestImport::g_StringTable[i].pwz,
  217. (LPVOID*) &pwzBuf, &cbProperty, &dwType));
  218. if (pwzBuf != NULL)
  219. {
  220. IF_FALSE_EXIT(dwType == MAN_DATA_TYPE_LPWSTR, E_FAIL);
  221. if (i == CAssemblyManifestImport::ProductType)
  222. {
  223. IF_FAILED_EXIT(FusionCompareString(WZ_PLATFORM_OS_TYPE_WORKSTATION, pwzBuf, 0));
  224. if (hr == S_OK)
  225. //VER_NT_WORKSTATION The system is running Windows NT 4.0 Workstation,
  226. // Windows 2000 Professional, Windows XP Home Edition, or Windows XP Professional.
  227. osvi.wProductType = VER_NT_WORKSTATION;
  228. else
  229. {
  230. IF_FAILED_EXIT(FusionCompareString(WZ_PLATFORM_OS_TYPE_DOMAIN_CONTROLLER, pwzBuf, 0));
  231. if (hr == S_OK)
  232. //VER_NT_DOMAIN_CONTROLLER The system is a domain controller.
  233. osvi.wProductType = VER_NT_DOMAIN_CONTROLLER;
  234. else
  235. {
  236. IF_FAILED_EXIT(FusionCompareString(WZ_PLATFORM_OS_TYPE_SERVER, pwzBuf, 0));
  237. if (hr == S_OK)
  238. //VER_NT_SERVER The system is a server.
  239. osvi.wProductType = VER_NT_SERVER;
  240. else
  241. {
  242. IF_FAILED_EXIT(E_FAIL);
  243. }
  244. }
  245. }
  246. VER_SET_CONDITION( dwlConditionMask, VER_PRODUCT_TYPE,
  247. VER_EQUAL );
  248. dwTypeMask |= VER_PRODUCT_TYPE;
  249. }
  250. else if (i == CAssemblyManifestImport::Suite)
  251. {
  252. // ISSUE-06/07/02-felixybc suite mask should allow specifying multiple with AND OR conditions
  253. // use goto done to avoid indenting.
  254. IF_FAILED_EXIT(FusionCompareString(WZ_PLATFORM_OS_SUITE_BACKOFFICE, pwzBuf, 0));
  255. if (hr == S_OK)
  256. //VER_SUITE_BACKOFFICE Microsoft BackOffice components are installed.
  257. osvi.wSuiteMask |= VER_SUITE_BACKOFFICE;
  258. else
  259. {
  260. IF_FAILED_EXIT(FusionCompareString(WZ_PLATFORM_OS_SUITE_BLADE, pwzBuf, 0));
  261. if (hr == S_OK)
  262. //VER_SUITE_BLADE Windows Web Server is installed.
  263. osvi.wSuiteMask |= VER_SUITE_BLADE;
  264. else
  265. {
  266. IF_FAILED_EXIT(FusionCompareString(WZ_PLATFORM_OS_SUITE_DATACENTER, pwzBuf, 0));
  267. if (hr == S_OK)
  268. //VER_SUITE_DATACENTER Windows 2000 or Windows Datacenter Server is installed.
  269. osvi.wSuiteMask |= VER_SUITE_DATACENTER;
  270. else
  271. {
  272. IF_FAILED_EXIT(FusionCompareString(WZ_PLATFORM_OS_SUITE_ENTERPRISE, pwzBuf, 0));
  273. if (hr == S_OK)
  274. //VER_SUITE_ENTERPRISE Windows 2000 Advanced Server or Windows Enterprise Server is installed.
  275. osvi.wSuiteMask |= VER_SUITE_ENTERPRISE;
  276. else
  277. {
  278. IF_FAILED_EXIT(FusionCompareString(WZ_PLATFORM_OS_SUITE_PERSONAL, pwzBuf, 0));
  279. if (hr == S_OK)
  280. //VER_SUITE_PERSONAL Windows XP Home Edition is installed.
  281. osvi.wSuiteMask |= VER_SUITE_PERSONAL;
  282. else
  283. {
  284. IF_FAILED_EXIT(FusionCompareString(WZ_PLATFORM_OS_SUITE_SMALLBUSINESS, pwzBuf, 0));
  285. if (hr == S_OK)
  286. //VER_SUITE_SMALLBUSINESS Microsoft Small Business Server is installed.
  287. osvi.wSuiteMask |= VER_SUITE_SMALLBUSINESS;
  288. else
  289. {
  290. IF_FAILED_EXIT(FusionCompareString(WZ_PLATFORM_OS_SUITE_SMALLBUSINESS_RESTRICTED, pwzBuf, 0));
  291. if (hr == S_OK)
  292. //VER_SUITE_SMALLBUSINESS_RESTRICTED Microsoft Small Business Server is installed with the restrictive client license in force.
  293. osvi.wSuiteMask |= VER_SUITE_SMALLBUSINESS_RESTRICTED;
  294. else
  295. {
  296. IF_FAILED_EXIT(FusionCompareString(WZ_PLATFORM_OS_SUITE_TERMINAL, pwzBuf, 0));
  297. if (hr == S_OK)
  298. //VER_SUITE_TERMINAL Terminal Services is installed.
  299. osvi.wSuiteMask |= VER_SUITE_TERMINAL;
  300. else
  301. {
  302. IF_FAILED_EXIT(FusionCompareString(WZ_PLATFORM_OS_SUITE_PROFESSIONAL, pwzBuf, 0));
  303. if (hr == S_OK)
  304. bCheckProfessionalSuite = TRUE;
  305. else
  306. {
  307. IF_FAILED_EXIT(E_FAIL);
  308. }
  309. }
  310. // more from winnt.h..
  311. //#define VER_SUITE_COMMUNICATIONS
  312. //#define VER_SUITE_EMBEDDEDNT
  313. //#define VER_SUITE_SINGLEUSERTS
  314. //#define VER_SUITE_EMBEDDED_RESTRICTED
  315. }
  316. }
  317. }
  318. }
  319. }
  320. }
  321. }
  322. // ISSUE-06/07/02-felixybc assume AND condition
  323. VER_SET_CONDITION( dwlConditionMask, VER_SUITENAME,
  324. VER_AND );
  325. dwTypeMask |= VER_SUITENAME;
  326. }
  327. //else should not happen
  328. //hr = E_FAIL;
  329. SAFEDELETEARRAY(pwzBuf);
  330. }
  331. }
  332. }
  333. // ISSUE-06/07/02-felixybc assume nt only
  334. osvi.dwPlatformId = VER_PLATFORM_WIN32_NT;
  335. VER_SET_CONDITION( dwlConditionMask, VER_PLATFORMID,
  336. VER_EQUAL );
  337. dwTypeMask |= VER_PLATFORMID;
  338. // Perform the test
  339. BOOL bResult = VerifyVersionInfo(
  340. &osvi,
  341. dwTypeMask,
  342. dwlConditionMask);
  343. if (!bResult)
  344. {
  345. DWORD dw = GetLastError();
  346. if (dw != ERROR_OLD_WIN_VERSION)
  347. hr = HRESULT_FROM_WIN32(dw);
  348. else
  349. hr = S_FALSE;
  350. }
  351. else
  352. {
  353. hr = S_OK;
  354. if (bCheckProfessionalSuite)
  355. {
  356. // do "professional" - do a GetVersionEx after to check suite
  357. // ISSUE-06/14/02-felixybc check 'professional'. API has no notion of professional
  358. // assume "not home" == "professional"
  359. // note: type==workstation for Home/Pro but suite==Home for Home
  360. OSVERSIONINFOEX osvx;
  361. ZeroMemory(&osvx, sizeof(OSVERSIONINFOEX));
  362. osvx.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);
  363. IF_WIN32_FALSE_EXIT(GetVersionEx((OSVERSIONINFO*) &osvx));
  364. if ((osvx.wSuiteMask & VER_SUITE_PERSONAL) || (osvx.wProductType != VER_NT_WORKSTATION))
  365. {
  366. hr = S_FALSE;
  367. }
  368. }
  369. }
  370. exit:
  371. SAFEDELETEARRAY(pwzBuf);
  372. SAFEDELETEARRAY(pdwVal);
  373. return hr;
  374. }
  375. HRESULT CheckOS(LPMANIFEST_DATA pPlatformData)
  376. {
  377. HRESULT hr = S_OK;
  378. MAKE_ERROR_MACROS_STATIC(hr);
  379. DWORD dwCount = 0;
  380. LPMANIFEST_DATA pOSData = NULL;
  381. DWORD cbProperty = 0;
  382. DWORD dwType = 0;
  383. BOOL bFound = FALSE;
  384. while (TRUE)
  385. {
  386. // test a list of versions - as soon as 1 is satisfied, this check succeeds
  387. IF_FAILED_EXIT((static_cast<CManifestData*>(pPlatformData))->Get(dwCount,
  388. (LPVOID*) &pOSData, &cbProperty, &dwType));
  389. if (pOSData == NULL)
  390. break;
  391. IF_FALSE_EXIT(dwType == MAN_DATA_TYPE_IUNKNOWN_PTR, HRESULT_FROM_WIN32(ERROR_BAD_FORMAT));
  392. IF_FAILED_EXIT(CheckOSHelper(pOSData));
  393. if (hr == S_OK)
  394. {
  395. bFound = TRUE;
  396. break;
  397. }
  398. SAFERELEASE(pOSData);
  399. dwCount++;
  400. }
  401. if (bFound)
  402. hr = S_OK;
  403. else
  404. hr = S_FALSE;
  405. exit:
  406. SAFERELEASE(pOSData);
  407. return hr;
  408. }
  409. HRESULT CheckDotNet(LPMANIFEST_DATA pPlatformData)
  410. {
  411. #define WZ_DOTNETREGPATH L"Software\\Microsoft\\.NetFramework\\Policy\\"
  412. HRESULT hr = S_OK;
  413. MAKE_ERROR_MACROS_STATIC(hr);
  414. DWORD dwCount = 0;
  415. LPWSTR pwzVersion = NULL;
  416. DWORD cbProperty = 0;
  417. DWORD dwType = 0;
  418. CString sRegPath;
  419. CString sVersion;
  420. CString sBuildNum;
  421. CRegImport *pRegImport = NULL;
  422. BOOL bFound = FALSE;
  423. while (TRUE)
  424. {
  425. // test a list of versions - as soon as 1 is found, this check succeeds
  426. IF_FAILED_EXIT((static_cast<CManifestData*>(pPlatformData))->Get(dwCount,
  427. (LPVOID*) &pwzVersion, &cbProperty, &dwType));
  428. if (pwzVersion == NULL)
  429. break;
  430. IF_FALSE_EXIT(dwType == MAN_DATA_TYPE_LPWSTR, HRESULT_FROM_WIN32(ERROR_BAD_FORMAT));
  431. IF_FAILED_EXIT(sVersion.TakeOwnership(pwzVersion, cbProperty/sizeof(WCHAR)));
  432. pwzVersion = NULL;
  433. // xml format: <supportedRuntime version="v1.0.4122" />
  434. // registry layout: HKLM\software\microsoft\.netframework\policy\v1.0, value name=4122
  435. IF_FAILED_EXIT(sVersion.SplitLastElement(L'.', sBuildNum));
  436. IF_FAILED_EXIT(sRegPath.Assign(WZ_DOTNETREGPATH));
  437. IF_FAILED_EXIT(sRegPath.Append(sVersion));
  438. // note: require access to HKLM
  439. IF_FAILED_EXIT(CRegImport::Create(&pRegImport, sRegPath._pwz, HKEY_LOCAL_MACHINE));
  440. if (hr == S_OK)
  441. {
  442. IF_FAILED_EXIT(pRegImport->Check(sBuildNum._pwz, bFound));
  443. if (bFound)
  444. break;
  445. SAFEDELETE(pRegImport);
  446. }
  447. dwCount++;
  448. }
  449. if (bFound)
  450. hr = S_OK;
  451. else
  452. hr = S_FALSE;
  453. exit:
  454. SAFEDELETEARRAY(pwzVersion);
  455. SAFEDELETE(pRegImport);
  456. return hr;
  457. }
  458. HRESULT CheckManagedPlatform(LPMANIFEST_DATA pPlatformData)
  459. {
  460. HRESULT hr = S_OK;
  461. MAKE_ERROR_MACROS_STATIC(hr);
  462. LPASSEMBLY_IDENTITY pAsmId = NULL;
  463. DWORD cbProperty = 0;
  464. DWORD dwType = 0;
  465. CString sAsmPath;
  466. // ISSUE-06/07/02-felixybc apply policy also; use Fusion's PreBind
  467. IF_FAILED_EXIT(pPlatformData->Get(CAssemblyManifestImport::g_StringTable[CAssemblyManifestImport::AssemblyIdTag].pwz,
  468. (LPVOID*) &pAsmId, &cbProperty, &dwType));
  469. IF_NULL_EXIT(pAsmId, E_FAIL);
  470. IF_FALSE_EXIT(dwType == MAN_DATA_TYPE_IUNKNOWN_PTR, E_FAIL);
  471. IF_FAILED_EXIT(CAssemblyCache::GlobalCacheLookup(pAsmId, sAsmPath));
  472. exit:
  473. SAFERELEASE(pAsmId);
  474. return hr;
  475. }
  476. HRESULT CheckPlatform(LPMANIFEST_DATA pPlatformData)
  477. {
  478. HRESULT hr = S_OK;
  479. MAKE_ERROR_MACROS_STATIC(hr);
  480. CString sPlatformType;
  481. LPWSTR pwzBuf = NULL;
  482. // get the platform type
  483. IF_FAILED_EXIT(pPlatformData->GetType(&pwzBuf));
  484. IF_NULL_EXIT(pwzBuf, E_FAIL);
  485. // use accessor.
  486. IF_FAILED_EXIT(sPlatformType.TakeOwnership(pwzBuf));
  487. pwzBuf = NULL;
  488. IF_FAILED_EXIT(sPlatformType.CompareString(WZ_DATA_PLATFORM_OS));
  489. if (hr == S_OK)
  490. {
  491. IF_FAILED_EXIT(CheckOS(pPlatformData));
  492. }
  493. else
  494. {
  495. IF_FAILED_EXIT(sPlatformType.CompareString(WZ_DATA_PLATFORM_DOTNET));
  496. if (hr == S_OK)
  497. {
  498. IF_FAILED_EXIT(CheckDotNet(pPlatformData));
  499. }
  500. else
  501. {
  502. /*IF_FAILED_EXIT(sName.CompareString(DX));
  503. if (hr == S_OK)
  504. {
  505. IF_FAILED_EXIT(CheckDirectX(pPlatformData));
  506. }
  507. else
  508. {*/
  509. IF_FAILED_EXIT(sPlatformType.CompareString(WZ_DATA_PLATFORM_MANAGED));
  510. if (hr == S_OK)
  511. {
  512. IF_FAILED_EXIT(CheckManagedPlatform(pPlatformData));
  513. }
  514. else
  515. hr = E_FAIL;
  516. //}
  517. }
  518. }
  519. exit:
  520. SAFEDELETEARRAY(pwzBuf);
  521. return hr;
  522. }