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.

633 lines
21 KiB

  1. #include "pch.h"
  2. #include "iedetect.h"
  3. #include "sdsutils.h"
  4. HINSTANCE g_hInstance = NULL;
  5. HANDLE g_hHeap = NULL;
  6. DWORD MyDetectInternetExplorer(LPSTR guid, LPSTR pLocal,
  7. DWORD dwAskVer, DWORD dwAskBuild,
  8. LPDWORD pdwInstalledVer, LPDWORD pdwInstalledBuild)
  9. {
  10. DWORD dwRet = DET_NOTINSTALLED;
  11. char szValue[MAX_PATH];
  12. HKEY hKey = NULL;
  13. DWORD dwSize;
  14. DWORD dwInstalledVer, dwInstalledBuild;
  15. dwInstalledVer = (DWORD)-1;
  16. dwInstalledBuild = (DWORD)-1;
  17. if(RegOpenKeyExA(HKEY_LOCAL_MACHINE, IE_KEY, 0, KEY_READ, &hKey) == ERROR_SUCCESS)
  18. {
  19. dwSize = sizeof(szValue);
  20. if(RegQueryValueEx(hKey, VERSION_KEY, 0, NULL, (LPBYTE)szValue, &dwSize) == ERROR_SUCCESS)
  21. {
  22. // Everything is fine. This should be IE4 or greater.
  23. ConvertVersionStrToDwords(szValue, '.', &dwInstalledVer, &dwInstalledBuild);
  24. dwRet = CompareVersions(dwAskVer, dwAskBuild, dwInstalledVer, dwInstalledBuild);
  25. }
  26. else if(RegQueryValueEx(hKey, BUILD_KEY, 0, NULL, (LPBYTE)szValue, &dwSize) == ERROR_SUCCESS)
  27. {
  28. // See if we find a IE3 entry.
  29. ConvertVersionStrToDwords(szValue, '.', &dwInstalledVer, &dwInstalledBuild);
  30. // Now generate a IE3 version number.
  31. dwInstalledBuild = (DWORD)HIWORD(dwInstalledVer);
  32. dwInstalledVer = IE_3_MS_VERSION; // 4.70 IE3 major version
  33. dwRet = CompareVersions(dwAskVer, dwAskBuild, dwInstalledVer, dwInstalledBuild);
  34. }
  35. RegCloseKey(hKey);
  36. }
  37. // If we could not find anything, check the AppPath for Iexplore.exe
  38. if (dwInstalledVer == (DWORD)-1)
  39. {
  40. if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, IEXPLORE_APPPATH_KEY, 0, KEY_QUERY_VALUE, &hKey) == ERROR_SUCCESS)
  41. {
  42. dwSize = sizeof(szValue);
  43. if (RegQueryValueEx(hKey, NULL, 0, NULL, (LPBYTE)szValue, &dwSize) == ERROR_SUCCESS)
  44. {
  45. GetVersionFromFile(szValue, &dwInstalledVer, &dwInstalledBuild, TRUE);
  46. if ((dwInstalledVer != 0) && (dwInstalledBuild != 0))
  47. dwRet = CompareVersions(dwAskVer, dwAskBuild, dwInstalledVer, dwInstalledBuild);
  48. }
  49. RegCloseKey(hKey);
  50. }
  51. }
  52. if (pdwInstalledVer && pdwInstalledBuild)
  53. {
  54. *pdwInstalledVer = dwInstalledVer;
  55. *pdwInstalledBuild = dwInstalledBuild;
  56. }
  57. return dwRet;
  58. }
  59. DWORD WINAPI DetectInternetExplorer(DETECTION_STRUCT *pDet)
  60. {
  61. return(MyDetectInternetExplorer(pDet->pszGUID, pDet->pszLocale, pDet->dwAskVer, pDet->dwAskBuild,
  62. pDet->pdwInstalledVer, pDet->pdwInstalledBuild));
  63. }
  64. DWORD WINAPI DetectDCOM(DETECTION_STRUCT *pDet)
  65. {
  66. DWORD dwRet = DET_NOTINSTALLED;
  67. DWORD dwInstalledVer, dwInstalledBuild;
  68. dwInstalledVer = (DWORD) -1;
  69. dwInstalledBuild = (DWORD) -1;
  70. if (FRunningOnNT())
  71. {
  72. // On NT assume DCOM is installed;
  73. dwRet = DET_NEWVERSIONINSTALLED;
  74. }
  75. else
  76. {
  77. char szFile[MAX_PATH];
  78. char szRenameFile[MAX_PATH];
  79. GetSystemDirectory(szFile, sizeof(szFile));
  80. AddPath(szFile, "ole32.dll");
  81. ReadFromWininitOrPFRO(szFile, szRenameFile);
  82. if (*szRenameFile != '\0')
  83. GetVersionFromFile(szRenameFile, &dwInstalledVer, &dwInstalledBuild, TRUE);
  84. else
  85. GetVersionFromFile(szFile, &dwInstalledVer, &dwInstalledBuild, TRUE);
  86. if (dwInstalledVer != 0)
  87. dwRet = CompareVersions(pDet->dwAskVer, pDet->dwAskBuild, dwInstalledVer, dwInstalledBuild);
  88. }
  89. if (pDet->pdwInstalledVer && pDet->pdwInstalledBuild)
  90. {
  91. *(pDet->pdwInstalledVer) = dwInstalledVer;
  92. *(pDet->pdwInstalledBuild) = dwInstalledBuild;
  93. }
  94. return dwRet;
  95. }
  96. LPSTR g_szMFCFiles[] = { "MFC40.DLL", "MSVCRT40.DLL", "OLEPRO32.DLL", NULL};
  97. DWORD WINAPI DetectMFC(DETECTION_STRUCT *pDet)
  98. {
  99. DWORD dwRet = DET_NOTINSTALLED;
  100. LPSTR lpTmp;
  101. char szFile[MAX_PATH];
  102. BOOL bInstallMFC = FALSE;
  103. UINT uiIndex = 0;
  104. lpTmp = g_szMFCFiles[uiIndex];
  105. while (!bInstallMFC && lpTmp)
  106. {
  107. GetSystemDirectory(szFile, sizeof(szFile));
  108. AddPath(szFile, lpTmp);
  109. if (GetFileAttributes(szFile) == 0xFFFFFFFF)
  110. bInstallMFC = TRUE;
  111. uiIndex++;
  112. lpTmp = g_szMFCFiles[uiIndex];
  113. }
  114. if (bInstallMFC)
  115. dwRet = DET_NOTINSTALLED;
  116. else
  117. dwRet = DET_INSTALLED;
  118. if (pDet->pdwInstalledVer && pDet->pdwInstalledBuild)
  119. {
  120. *(pDet->pdwInstalledVer) = (DWORD)-1;
  121. *(pDet->pdwInstalledBuild) = (DWORD)-1;
  122. }
  123. return dwRet;
  124. }
  125. // Detection for MediaPlayer, called DirectShow in IE4
  126. //
  127. // For IE lite we want to ask for DirectShow version 2.0. Unfortunatly
  128. // the version in the registry and the versino of the files don't reflect this.
  129. // Also the version in the CIF and the version of the files don't fit anymore
  130. // in IE5.Therefore the code below spezial cases the 2.0 case, which ie lite
  131. // should ask for. All other modes are asking for the version of the CIF and
  132. // the detection code has to get the version from the registry.
  133. //
  134. #define DIRECTSHOW_IE4_VER 0x00050001
  135. #define DIRECTSHOW_IE4_BUILD 0x00120400
  136. DWORD WINAPI DetectDirectShow(DETECTION_STRUCT *pDet)
  137. {
  138. DWORD dwRet = DET_NOTINSTALLED;
  139. DWORD dwVerDevenum, dwBuildDevenum;
  140. DWORD dwVerQuartz, dwBuildQuartz;
  141. DWORD dwInstalledVer, dwInstalledBuild;
  142. char szFile[MAX_PATH];
  143. dwInstalledVer = dwInstalledBuild = (DWORD)-1;
  144. if (pDet->dwAskVer == 0x00020000)
  145. {
  146. // Called for ie-lite
  147. GetSystemDirectory( szFile, sizeof(szFile) );
  148. AddPath(szFile, "quartz.dll");
  149. if (SUCCEEDED(GetVersionFromFile(szFile, &dwVerQuartz, &dwBuildQuartz, TRUE)))
  150. {
  151. GetSystemDirectory( szFile, sizeof(szFile) );
  152. AddPath(szFile, "devenum.dll");
  153. if (SUCCEEDED(GetVersionFromFile(szFile, &dwVerDevenum, &dwBuildDevenum, TRUE)))
  154. {
  155. // Both files found.
  156. if ((dwVerQuartz == dwVerDevenum) &&
  157. (dwBuildQuartz == dwBuildDevenum) &&
  158. ((dwVerQuartz > DIRECTSHOW_IE4_VER) ||
  159. ((dwVerQuartz == DIRECTSHOW_IE4_VER) && (dwBuildQuartz >= DIRECTSHOW_IE4_BUILD))) )
  160. {
  161. dwRet = DET_INSTALLED;
  162. }
  163. }
  164. }
  165. }
  166. else
  167. {
  168. // If we got a version number passed in, check against the installed version from
  169. // the 'Installed component' branch for that GUID.
  170. if (GetVersionFromGuid(pDet->pszGUID, &dwInstalledVer, &dwInstalledBuild))
  171. dwRet = CompareVersions(pDet->dwAskVer, pDet->dwAskBuild, dwInstalledVer, dwInstalledBuild);
  172. }
  173. if (pDet->pdwInstalledVer && pDet->pdwInstalledBuild)
  174. {
  175. *(pDet->pdwInstalledVer) = dwInstalledVer;
  176. *(pDet->pdwInstalledBuild) = dwInstalledBuild;
  177. }
  178. return dwRet;
  179. }
  180. #define DIRECTXD3_MSVER 0x00040002
  181. #define DIRECTXD3_LSVER 0x0000041E
  182. #define DIRECTXDD_MSVER 0x00040004
  183. #define DIRECTXDD_LSVER 0x00000044
  184. DETECT_FILES DirectX_Win[] =
  185. { {"S", "d3dim.dll", DIRECTXD3_MSVER, DIRECTXD3_LSVER},
  186. {"S", "d3drg16f.dll", DIRECTXD3_MSVER, DIRECTXD3_LSVER},
  187. {"S", "d3drgbf.dll", DIRECTXD3_MSVER, DIRECTXD3_LSVER},
  188. {"S", "d3drm.dll", DIRECTXD3_MSVER, DIRECTXD3_LSVER},
  189. {"S", "d3dxof.dll", DIRECTXD3_MSVER, DIRECTXD3_LSVER},
  190. {"S", "ddhelp.exe", DIRECTXDD_MSVER, DIRECTXDD_LSVER},
  191. {"S", "ddraw.dll", DIRECTXDD_MSVER, DIRECTXDD_LSVER},
  192. {"S", "ddraw16.dll", DIRECTXDD_MSVER, DIRECTXDD_LSVER},
  193. {"S", "dsound.dll", DIRECTXDD_MSVER, DIRECTXDD_LSVER},
  194. {"\0", "", 0, 0} };
  195. DWORD WINAPI DetectDirectX(DETECTION_STRUCT *pDet)
  196. {
  197. int iIndex = 0;
  198. DWORD dwRet = DET_NOTINSTALLED;
  199. DWORD dwInstalledVer, dwInstalledBuild;
  200. dwInstalledVer = dwInstalledBuild = (DWORD)-1;
  201. if (FRunningOnNT())
  202. {
  203. // On NT assume DirectXMini is newer.
  204. dwRet = DET_NEWVERSIONINSTALLED;
  205. }
  206. else
  207. {
  208. if (pDet->dwAskVer == 0)
  209. {
  210. // Call for ie-lite,
  211. // just check if IE4 is installed.
  212. dwRet = MyDetectInternetExplorer(pDet->pszGUID, pDet->pszLocale,
  213. IE_4_MS_VERSION, 0,
  214. &dwInstalledVer, &dwInstalledBuild);
  215. if (dwRet == DET_OLDVERSIONINSTALLED)
  216. dwRet = DET_NOTINSTALLED;
  217. if (dwRet == DET_NEWVERSIONINSTALLED)
  218. dwRet = DET_INSTALLED;
  219. }
  220. else
  221. {
  222. do
  223. {
  224. if (DirectX_Win[iIndex].cPath[0])
  225. dwRet = CheckFile(DirectX_Win[iIndex]);
  226. iIndex++;
  227. } while (((dwRet == DET_INSTALLED) || (dwRet == DET_NEWVERSIONINSTALLED)) && (DirectX_Win[iIndex].cPath[0] != '\0'));
  228. }
  229. }
  230. if (pDet->pdwInstalledVer && pDet->pdwInstalledBuild)
  231. {
  232. *(pDet->pdwInstalledVer) = dwInstalledVer;
  233. *(pDet->pdwInstalledBuild) = dwInstalledBuild;
  234. }
  235. return dwRet;
  236. }
  237. #define DDRAWEX_MSVER 0x00040047
  238. #define DDRAWEX_LSVER 0x04580000
  239. DETECT_FILES DDrawEx[] =
  240. { {"S", "ddrawex.dll", DDRAWEX_MSVER, DDRAWEX_LSVER },
  241. {"\0", "", 0, 0} };
  242. DWORD WINAPI DetectDirectDraw(DETECTION_STRUCT *pDet)
  243. {
  244. int iIndex = 0;
  245. DWORD dwRet = DET_NOTINSTALLED;
  246. DWORD dwInstalledVer, dwInstalledBuild;
  247. do
  248. {
  249. if (DDrawEx[iIndex].cPath[0])
  250. dwRet = CheckFile(DDrawEx[iIndex]);
  251. iIndex++;
  252. } while (((dwRet == DET_INSTALLED) || (dwRet == DET_NEWVERSIONINSTALLED)) && (DDrawEx[iIndex].cPath[0] != '\0'));
  253. dwInstalledVer = dwInstalledBuild = (DWORD)-1;
  254. if (pDet->pdwInstalledVer && pDet->pdwInstalledBuild)
  255. {
  256. *(pDet->pdwInstalledVer) = dwInstalledVer;
  257. *(pDet->pdwInstalledBuild) = dwInstalledBuild;
  258. }
  259. return dwRet;
  260. }
  261. DWORD WINAPI DetectICW(DETECTION_STRUCT *pDet)
  262. {
  263. DWORD dwRet = DET_NOTINSTALLED;
  264. DWORD dwInstalledVer, dwInstalledBuild;
  265. dwInstalledVer = dwInstalledBuild = (DWORD)-1;
  266. if (pDet->dwAskVer == 0)
  267. {
  268. // Call for ie-lite,
  269. // just check if IE4 is installed.
  270. // If we don't get a version number pass in, assume we only check for default browser
  271. if (IsIEDefaultBrowser())
  272. dwRet = DET_INSTALLED;
  273. }
  274. else
  275. {
  276. // If we got a version number passed in, check against the installed version from
  277. // the 'Installed component' branch for that GUID.
  278. if (GetVersionFromGuid(pDet->pszGUID, &dwInstalledVer, &dwInstalledBuild))
  279. dwRet = CompareVersions(pDet->dwAskVer, pDet->dwAskBuild, dwInstalledVer, dwInstalledBuild);
  280. }
  281. if (pDet->pdwInstalledVer && pDet->pdwInstalledBuild)
  282. {
  283. *(pDet->pdwInstalledVer) = dwInstalledVer;
  284. *(pDet->pdwInstalledBuild) = dwInstalledBuild;
  285. }
  286. return dwRet;
  287. }
  288. // NT version of setupapi.dll (4.0.1381.10)
  289. #define SETUPAPI_NT_MSVER 0x00040000
  290. #define SETUPAPI_NT_LSVER 0x0565000A
  291. // Win9x version of setupapi.dll (5.0.1453.7)
  292. #define SETUPAPI_WIN_MSVER 0x00050000
  293. #define SETUPAPI_WIN_LSVER 0x05AD0007
  294. // Win9x version of cfgmgr32.dll (4.10.0.1422)
  295. #define CFGMGR32_WIN_MSVER 0x0004000a
  296. #define CFGMGR32_WIN_LSVER 0x0000058e
  297. // minimal Cabinet.dll version (1.0.601.4)
  298. #define CABINET_MSVER 0x00010000
  299. #define CABINET_LSVER 0x02590004
  300. // Version of w95inf16.dll
  301. #define W95INF16_MSVER 0x00040047
  302. #define W95INF16_LSVER 0x02c00000
  303. // Version of w95inf32.dll
  304. #define W95INF32_MSVER 0x00040047
  305. #define W95INF32_LSVER 0x00100000
  306. // Version of regsvr32.exe
  307. #define REGSVR32_MSVER 0x00050000
  308. #define REGSVR32_LSVER 0x06310001
  309. // Note: for now we only allow 10 characters in the cPath part of the structure.
  310. // If more characters are needed change the amount below.
  311. //
  312. DETECT_FILES Gensetup_W95[] =
  313. { {"S", "cabinet.dll", CABINET_MSVER, CABINET_LSVER },
  314. {"S", "setupapi.dll", SETUPAPI_WIN_MSVER, SETUPAPI_WIN_LSVER},
  315. {"S", "cfgmgr32.dll", CFGMGR32_WIN_MSVER, CFGMGR32_WIN_LSVER},
  316. {"S", "regsvr32.exe", REGSVR32_MSVER, REGSVR32_LSVER },
  317. {"S", "w95inf16.dll", W95INF16_MSVER, W95INF16_LSVER },
  318. {"S", "w95inf32.dll", W95INF32_MSVER, W95INF32_LSVER },
  319. {"W,C", "extract.exe", -1, -1 },
  320. {"W,C", "iextract.exe", -1, -1 },
  321. {"\0", "", 0, 0} };
  322. DETECT_FILES Gensetup_NT[] =
  323. { {"S", "cabinet.dll", CABINET_MSVER, CABINET_LSVER },
  324. {"S", "setupapi.dll", SETUPAPI_NT_MSVER, SETUPAPI_NT_LSVER},
  325. {"S", "regsvr32.exe", REGSVR32_MSVER, REGSVR32_LSVER },
  326. {"W", "extract.exe", -1, -1 },
  327. {"W", "iextract.exe", -1, -1 },
  328. {"\0", "", 0, 0} };
  329. DWORD WINAPI DetectGenSetup(DETECTION_STRUCT *pDet)
  330. {
  331. DWORD dwRet = DET_NOTINSTALLED;
  332. int iIndex = 0;
  333. DETECT_FILES *Detect_Files;
  334. if (FRunningOnNT())
  335. Detect_Files = Gensetup_NT;
  336. else
  337. Detect_Files = Gensetup_W95;
  338. do
  339. {
  340. if (Detect_Files[iIndex].cPath[0])
  341. dwRet = CheckFile(Detect_Files[iIndex]);
  342. iIndex++;
  343. } while (((dwRet == DET_INSTALLED) || (dwRet == DET_NEWVERSIONINSTALLED)) && (Detect_Files[iIndex].cPath[0] != '\0'));
  344. return dwRet;
  345. }
  346. DWORD WINAPI DetectOfflinePkg(DETECTION_STRUCT *pDet)
  347. {
  348. DWORD dwRet = DET_NOTINSTALLED;
  349. DWORD dwInstalledVer, dwInstalledBuild;
  350. char szFile[MAX_PATH];
  351. char szRenameFile[MAX_PATH];
  352. dwInstalledVer = dwInstalledBuild = (DWORD)-1;
  353. // If we got a version number passed in, check against the installed version from
  354. // the 'Installed component' branch for that GUID.
  355. if (GetVersionFromGuid(pDet->pszGUID, &dwInstalledVer, &dwInstalledBuild))
  356. dwRet = CompareVersions(pDet->dwAskVer, pDet->dwAskBuild, dwInstalledVer, dwInstalledBuild);
  357. if (dwRet == DET_NOTINSTALLED)
  358. {
  359. // check if webcheck.dll is on the users machine, we should update it.
  360. GetSystemDirectory( szFile, sizeof(szFile) );
  361. AddPath(szFile, "webcheck.dll");
  362. ReadFromWininitOrPFRO(szFile, szRenameFile);
  363. if (*szRenameFile != '\0')
  364. GetVersionFromFile(szRenameFile, &dwInstalledVer, &dwInstalledBuild, TRUE);
  365. else
  366. GetVersionFromFile(szFile, &dwInstalledVer, &dwInstalledBuild, TRUE);
  367. if (dwInstalledVer != 0)
  368. dwRet = CompareVersions(pDet->dwAskVer, pDet->dwAskBuild, dwInstalledVer, dwInstalledBuild);
  369. }
  370. if (pDet->pdwInstalledVer && pDet->pdwInstalledBuild)
  371. {
  372. *(pDet->pdwInstalledVer) = dwInstalledVer;
  373. *(pDet->pdwInstalledBuild) = dwInstalledBuild;
  374. }
  375. return dwRet;
  376. }
  377. DWORD WINAPI DetectJapaneseFontPatch(DETECTION_STRUCT *pDet)
  378. {
  379. DWORD dwInstalledVer, dwInstalledBuild;
  380. DWORD dwRet = DET_NEWVERSIONINSTALLED;
  381. if (pDet->pdwInstalledVer && pDet->pdwInstalledBuild)
  382. {
  383. *(pDet->pdwInstalledVer) = -1;
  384. *(pDet->pdwInstalledBuild) = -1;
  385. }
  386. if (GetSystemDefaultLCID() == 1041)
  387. {
  388. // If we are running locale Japanese, Install the font.
  389. dwRet = DET_NOTINSTALLED;
  390. }
  391. // If we are running on a Japanese system, see if the component is installed using the GUID
  392. if (dwRet == DET_NOTINSTALLED)
  393. {
  394. if (GetVersionFromGuid(pDet->pszGUID, pDet->pdwInstalledVer, pDet->pdwInstalledBuild))
  395. {
  396. dwRet = CompareVersions(pDet->dwAskVer, pDet->dwAskBuild, *(pDet->pdwInstalledVer), *(pDet->pdwInstalledBuild));
  397. }
  398. }
  399. return dwRet;
  400. }
  401. DWORD WINAPI DetectAOLSupport(DETECTION_STRUCT *pDet)
  402. {
  403. DWORD dwRet = DET_NOTINSTALLED;
  404. DWORD dwInstalledVer, dwInstalledBuild;
  405. dwInstalledVer = dwInstalledBuild = (DWORD)-1;
  406. if (pDet->dwAskVer == 0)
  407. {
  408. // Call for ie-lite,
  409. char szFile[MAX_PATH];
  410. GetSystemDirectory( szFile, sizeof(szFile) );
  411. AddPath(szFile, "jgaw400.dll");
  412. // See if one of the AOL support files exist.
  413. if (GetFileAttributes(szFile) == 0xFFFFFFFF)
  414. {
  415. dwRet = DET_NOTINSTALLED;
  416. }
  417. else
  418. {
  419. dwRet = DET_INSTALLED;
  420. }
  421. }
  422. else
  423. {
  424. // If we got a version number passed in, check against the installed version from
  425. // the 'Installed component' branch for that GUID.
  426. if (GetVersionFromGuid(pDet->pszGUID, &dwInstalledVer, &dwInstalledBuild))
  427. dwRet = CompareVersions(pDet->dwAskVer, pDet->dwAskBuild, dwInstalledVer, dwInstalledBuild);
  428. }
  429. if (pDet->pdwInstalledVer && pDet->pdwInstalledBuild)
  430. {
  431. *(pDet->pdwInstalledVer) = dwInstalledVer;
  432. *(pDet->pdwInstalledBuild) = dwInstalledBuild;
  433. }
  434. return dwRet;
  435. }
  436. DWORD WINAPI DetectHTMLHelp(DETECTION_STRUCT *pDet)
  437. {
  438. return DetectFile(pDet, "hhctrl.ocx");
  439. }
  440. DWORD WINAPI DetectOLEAutomation(DETECTION_STRUCT *pDet)
  441. {
  442. return DetectFile(pDet, "oleaut32.dll");
  443. }
  444. DWORD WINAPI DetectJavaVM(DETECTION_STRUCT *pDet)
  445. {
  446. HKEY hKey;
  447. DWORD dwRet = DET_NOTINSTALLED;
  448. char szValue[MAX_PATH];
  449. DWORD dwValue = 0;
  450. DWORD dwSize;
  451. lstrcpy(szValue, COMPONENT_KEY);
  452. AddPath(szValue, pDet->pszGUID);
  453. if(RegOpenKeyExA(HKEY_LOCAL_MACHINE, szValue, 0, KEY_READ, &hKey) == ERROR_SUCCESS)
  454. {
  455. dwSize = sizeof(dwValue);
  456. if(RegQueryValueEx(hKey, "IgnoreFile", 0, NULL, (LPBYTE)&dwValue, &dwSize) == ERROR_SUCCESS)
  457. {
  458. if (dwValue != 0)
  459. {
  460. dwRet = DET_INSTALLED;
  461. if (pDet->pdwInstalledVer && pDet->pdwInstalledBuild)
  462. {
  463. *(pDet->pdwInstalledVer) = (DWORD)-1;
  464. *(pDet->pdwInstalledBuild) = (DWORD)-1;
  465. }
  466. }
  467. }
  468. else
  469. dwValue = 0;
  470. RegCloseKey(hKey);
  471. }
  472. if (dwValue == 0)
  473. dwRet = DetectFile(pDet, "msjava.dll");
  474. return dwRet;
  475. }
  476. #define MSAPSSPC_MSVER 0x00050000
  477. #define MSAPSSPC_LSVER 0x00001E31
  478. DETECT_FILES msn_auth[] =
  479. { {"S", "MSAPSSPC.dll", MSAPSSPC_MSVER, MSAPSSPC_LSVER },
  480. {"\0", "", 0, 0} };
  481. DWORD WINAPI DetectMsn_Auth(DETECTION_STRUCT *pDet)
  482. {
  483. int iIndex = 0;
  484. DWORD dwRet = DET_NOTINSTALLED;
  485. DWORD dwInstalledVer, dwInstalledBuild;
  486. do
  487. {
  488. if (msn_auth[iIndex].cPath[0])
  489. dwRet = CheckFile(msn_auth[iIndex]);
  490. iIndex++;
  491. } while (((dwRet == DET_INSTALLED) || (dwRet == DET_NEWVERSIONINSTALLED)) && (msn_auth[iIndex].cPath[0] != '\0'));
  492. dwInstalledVer = dwInstalledBuild = (DWORD)-1;
  493. if (pDet->pdwInstalledVer && pDet->pdwInstalledBuild)
  494. {
  495. *(pDet->pdwInstalledVer) = dwInstalledVer;
  496. *(pDet->pdwInstalledBuild) = dwInstalledBuild;
  497. }
  498. return dwRet;
  499. }
  500. DWORD WINAPI DetectTdc(DETECTION_STRUCT *pDet)
  501. {
  502. return DetectFile(pDet, "tdc.ocx");
  503. }
  504. DWORD WINAPI DetectMDAC(DETECTION_STRUCT *pDet)
  505. {
  506. char szValue[MAX_PATH];
  507. HKEY hKey = NULL;
  508. DWORD dwSize;
  509. DWORD dwRet = DET_NOTINSTALLED;
  510. DWORD dwInstalledVer, dwInstalledBuild;
  511. dwInstalledVer = (DWORD)-1;
  512. dwInstalledBuild = (DWORD)-1;
  513. if(RegOpenKeyExA(HKEY_LOCAL_MACHINE, "Software\\Microsoft\\DataAccess", 0, KEY_READ, &hKey) == ERROR_SUCCESS)
  514. {
  515. dwSize = sizeof(szValue);
  516. if (RegQueryValueEx(hKey, "FullInstallVer", NULL, NULL, (LPBYTE)szValue, &dwSize) == ERROR_SUCCESS)
  517. {
  518. ConvertVersionStrToDwords(szValue, '.', &dwInstalledVer, &dwInstalledBuild);
  519. dwRet = CompareVersions(pDet->dwAskVer, pDet->dwAskBuild, dwInstalledVer, dwInstalledBuild);
  520. }
  521. RegCloseKey(hKey);
  522. }
  523. // Did not find the registry key or entry,
  524. // need to do file comparison to detect MDAC version 2.1
  525. if (dwRet == DET_NOTINSTALLED)
  526. {
  527. char szRenameFile[MAX_PATH];
  528. if(RegOpenKeyExA(HKEY_LOCAL_MACHINE, REGSTR_PATH_SETUP, 0, KEY_READ, &hKey) == ERROR_SUCCESS)
  529. {
  530. dwSize = sizeof(szValue);
  531. if (RegQueryValueEx(hKey, "CommonFilesDir", NULL, NULL, (LPBYTE)szValue, &dwSize) == ERROR_SUCCESS)
  532. {
  533. AddPath(szValue, "system\\ado\\msado15.dll");
  534. ReadFromWininitOrPFRO(szValue, szRenameFile);
  535. if (*szRenameFile != '\0')
  536. GetVersionFromFile(szRenameFile, &dwInstalledVer, &dwInstalledBuild, TRUE);
  537. else
  538. GetVersionFromFile(szValue, &dwInstalledVer, &dwInstalledBuild, TRUE);
  539. dwRet = CompareVersions(pDet->dwAskVer, pDet->dwAskBuild, dwInstalledVer, dwInstalledBuild);
  540. }
  541. RegCloseKey(hKey);
  542. }
  543. }
  544. return dwRet;
  545. }
  546. STDAPI_(BOOL) DllMain(HANDLE hDll, DWORD dwReason, void *lpReserved)
  547. {
  548. DWORD dwThreadID;
  549. switch(dwReason)
  550. {
  551. case DLL_PROCESS_ATTACH:
  552. g_hInstance = (HINSTANCE)hDll;
  553. g_hHeap = GetProcessHeap();
  554. DisableThreadLibraryCalls(g_hInstance);
  555. break;
  556. case DLL_PROCESS_DETACH:
  557. break;
  558. default:
  559. break;
  560. }
  561. return TRUE;
  562. }