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.

156 lines
4.5 KiB

  1. /*++
  2. Copyright (c) 2001 Microsoft Corporation
  3. Module Name:
  4. WorksSuite2001.cpp
  5. Abstract:
  6. Added the hook for CreateProcess to prevent IE5Setup.exe from starting
  7. up if the system has a higher version of IE.
  8. Notes:
  9. This is an app specific.
  10. History:
  11. 03/28/2001 a-larrsh Created
  12. 07/13/2001 prashkud Added hook for CreateProcess
  13. 01/11/2001 robkenny Removed code that was deleting Shockwave files whenever this shim loaded.
  14. --*/
  15. #include "precomp.h"
  16. IMPLEMENT_SHIM_BEGIN(WorksSuite2001)
  17. #include "ShimHookMacro.h"
  18. #include "userenv.h"
  19. APIHOOK_ENUM_BEGIN
  20. APIHOOK_ENUM_ENTRY(CreateProcessA)
  21. APIHOOK_ENUM_END
  22. /*++
  23. Hooks CreateProcessA and if the process being invoked is "ie5setup.exe",
  24. determines the IE version on the system and if it is higher than IE 5.5,
  25. launches an harmless .exe like "rundll32.exe" instead.
  26. --*/
  27. BOOL
  28. APIHOOK(CreateProcessA)(
  29. LPCSTR lpApplicationName,
  30. LPSTR lpCommandLine,
  31. LPSECURITY_ATTRIBUTES lpProcessAttributes,
  32. LPSECURITY_ATTRIBUTES lpThreadAttributes,
  33. BOOL bInheritHandles,
  34. DWORD dwCreationFlags,
  35. LPVOID lpEnvironment,
  36. LPCSTR lpCurrentDirectory,
  37. LPSTARTUPINFOA lpStartupInfo,
  38. LPPROCESS_INFORMATION lpProcessInformation
  39. )
  40. {
  41. DPFN( eDbgLevelSpew, "[CreateProcessA] appname:(%s)\ncommandline:(%s)",
  42. lpApplicationName, lpCommandLine );
  43. CSTRING_TRY
  44. {
  45. CString csAppName(lpApplicationName);
  46. CString csCmdLine(lpCommandLine);
  47. if ((csAppName.Find(L"ie5setup.exe") != -1) ||
  48. (csCmdLine.Find(L"ie5setup.exe") != -1))
  49. {
  50. //
  51. // App has called CreateProcess on ie5setup.exe.
  52. // Check the version of IE that we have on the machine.
  53. //
  54. HKEY hKey = NULL;
  55. if ((RegOpenKeyExW(HKEY_LOCAL_MACHINE,
  56. L"Software\\Microsoft\\Internet Explorer",
  57. 0,
  58. KEY_QUERY_VALUE,
  59. &hKey) == ERROR_SUCCESS))
  60. {
  61. WCHAR wszBuf[MAX_PATH];
  62. DWORD dwSize = MAX_PATH;
  63. if (RegQueryValueExW(hKey, L"Version", NULL, NULL,
  64. (LPBYTE)wszBuf, &dwSize) == ERROR_SUCCESS)
  65. {
  66. WCHAR *StopString = NULL;
  67. CStringParser csParser(wszBuf, L".");
  68. // We need at least the major and minor version numbers from the version string
  69. if (csParser.GetCount() >= 2)
  70. {
  71. long lVal = wcstol(csParser[0].Get(), &StopString, 10);
  72. if (lVal > 5)
  73. {
  74. //
  75. // Call rundll32.exe, which is harmless
  76. //
  77. csAppName = "";
  78. csCmdLine = "rundll32.exe";
  79. }
  80. else
  81. {
  82. // check the 2nd value
  83. StopString = NULL;
  84. lVal = 0;
  85. lVal = wcstol(csParser[1].Get(), &StopString, 10);
  86. if (lVal > 5)
  87. {
  88. csAppName = "";
  89. csCmdLine = "rundll32.exe";
  90. }
  91. }
  92. }
  93. }
  94. RegCloseKey(hKey);
  95. }
  96. }
  97. return ORIGINAL_API(CreateProcessA)(
  98. csAppName.GetAnsiNIE(),csCmdLine.GetAnsiNIE(),
  99. lpProcessAttributes,lpThreadAttributes, bInheritHandles,
  100. dwCreationFlags, lpEnvironment,lpCurrentDirectory,
  101. lpStartupInfo,lpProcessInformation);
  102. }
  103. CSTRING_CATCH
  104. {
  105. // Do nothing
  106. }
  107. return ORIGINAL_API(CreateProcessA)(lpApplicationName,
  108. lpCommandLine, lpProcessAttributes,
  109. lpThreadAttributes, bInheritHandles,
  110. dwCreationFlags, lpEnvironment,
  111. lpCurrentDirectory, lpStartupInfo,lpProcessInformation);
  112. }
  113. /*++
  114. Register hooked functions
  115. --*/
  116. HOOK_BEGIN
  117. APIHOOK_ENTRY(KERNEL32.DLL, CreateProcessA)
  118. HOOK_END
  119. IMPLEMENT_SHIM_END