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.

104 lines
2.2 KiB

  1. /*++
  2. Copyright (c) 2000 Microsoft Corporation
  3. Module Name:
  4. MECCommander.cpp
  5. Abstract:
  6. This dll prevents the MEC Commander install program from successfully
  7. calling the cpuid.exe. This is because the cpuid.exe can AV's with a
  8. divide by 0.
  9. Notes:
  10. This is an app specific shim.
  11. History:
  12. 11/18/1999 philipdu Created
  13. --*/
  14. #include "precomp.h"
  15. IMPLEMENT_SHIM_BEGIN(MECCommander)
  16. #include "ShimHookMacro.h"
  17. APIHOOK_ENUM_BEGIN
  18. APIHOOK_ENUM_ENTRY(CreateProcessA)
  19. APIHOOK_ENUM_END
  20. /*++
  21. We do not want to run this application since it AV's with a divide by zero
  22. calculation. The only purpose for this exe is to time the CPU. Since the
  23. final result of this calculation is a string in a dialog box we can safely
  24. bypass this. The app puts a string "Pentinum 166 or Better recommented" in
  25. the cases where it cannot get the CPU frequency. The interesting thing
  26. here is that the app will actually run better with this patch since this
  27. cpuid exe also faults on 9x.
  28. --*/
  29. BOOL
  30. APIHOOK(CreateProcessA)(
  31. LPCSTR lpApplicationName,
  32. LPSTR lpCommandLine,
  33. LPSECURITY_ATTRIBUTES lpProcessAttributes,
  34. LPSECURITY_ATTRIBUTES lpThreadAttributes,
  35. BOOL bInheritHandles,
  36. DWORD dwCreationFlags,
  37. LPVOID lpEnvironment,
  38. LPCSTR lpCurrentDirectory,
  39. LPSTARTUPINFOA lpStartupInfo,
  40. LPPROCESS_INFORMATION lpProcessInformation
  41. )
  42. {
  43. BOOL bRet;
  44. CSTRING_TRY
  45. {
  46. AppAndCommandLine acl(lpApplicationName, lpCommandLine);
  47. if (acl.GetApplicationName().CompareNoCase(L"cpuid.exe") == 0)
  48. {
  49. return FALSE;
  50. }
  51. }
  52. CSTRING_CATCH
  53. {
  54. // Do nothing
  55. }
  56. bRet = ORIGINAL_API(CreateProcessA)(
  57. lpApplicationName,
  58. lpCommandLine,
  59. lpProcessAttributes,
  60. lpThreadAttributes,
  61. bInheritHandles,
  62. dwCreationFlags,
  63. lpEnvironment,
  64. lpCurrentDirectory,
  65. lpStartupInfo,
  66. lpProcessInformation);
  67. return bRet;
  68. }
  69. /*++
  70. Register hooked functions
  71. --*/
  72. HOOK_BEGIN
  73. APIHOOK_ENTRY(Kernel32.DLL, CreateProcessA )
  74. HOOK_END
  75. IMPLEMENT_SHIM_END