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.

92 lines
1.9 KiB

  1. /*++
  2. Copyright (c) 2000 Microsoft Corporation
  3. Module Name:
  4. CorrectActiveMoviePath.cpp
  5. Abstract:
  6. A hack for Railroad Tycoon 2 video playing. Apparently they have
  7. hardcoded paths for a WinExec call. Also see MSDN Article ID: Q176221
  8. Notes:
  9. This is a general purpose shim.
  10. History:
  11. 12/06/1999 linstev Created
  12. --*/
  13. #include "precomp.h"
  14. IMPLEMENT_SHIM_BEGIN(CorrectActiveMoviePath)
  15. #include "ShimHookMacro.h"
  16. APIHOOK_ENUM_BEGIN
  17. APIHOOK_ENUM_ENTRY(WinExec)
  18. APIHOOK_ENUM_END
  19. /*++
  20. This stub function breaks into WinExec and checks to see if lpCmdLine
  21. parameter includes AMOVIE.OCX or RUNDLL as well as /PLAY.
  22. --*/
  23. UINT
  24. APIHOOK(WinExec)(
  25. LPCSTR lpCmdLine,
  26. UINT uCmdShow
  27. )
  28. {
  29. CSTRING_TRY
  30. {
  31. CString csCl(lpCmdLine);
  32. csCl.MakeUpper();
  33. int nAmovieIndex = csCl.Find(L"AMOVIE.OCX,RUNDLL");
  34. if (nAmovieIndex >= 0)
  35. {
  36. int nPlayIndex = csCl.Find(L"/PLAY");
  37. if (nPlayIndex >= 0)
  38. {
  39. CString csNewCl;
  40. LONG success = RegQueryValueExW(csNewCl,
  41. HKEY_LOCAL_MACHINE,
  42. L"Software\\Microsoft\\Multimedia\\DirectXMedia",
  43. L"OCX.ocx");
  44. if (success == ERROR_SUCCESS)
  45. {
  46. csNewCl += L" ";
  47. csNewCl += csCl.Mid(nPlayIndex);
  48. return ORIGINAL_API(WinExec)(csNewCl.GetAnsi(), uCmdShow);
  49. }
  50. }
  51. }
  52. }
  53. CSTRING_CATCH
  54. {
  55. // Do Nothing
  56. }
  57. return ORIGINAL_API(WinExec)(lpCmdLine, uCmdShow);
  58. }
  59. /*++
  60. Register hooked functions
  61. --*/
  62. HOOK_BEGIN
  63. APIHOOK_ENTRY(KERNEL32.DLL, WinExec)
  64. HOOK_END
  65. IMPLEMENT_SHIM_END