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.

141 lines
3.0 KiB

  1. /*++
  2. Copyright (c) 1999 Microsoft Corporation
  3. Module Name:
  4. Riven.cpp
  5. Abstract:
  6. A hack for Riven. The game gets confused about what windows version it's
  7. running under and tries to handle it's own messages. A simple ver lie
  8. fixes this issue, but causes the game to use a win9x only method to
  9. eject the CD.
  10. Fix:
  11. We can get ddraw to correctly handle alt+tabbing by turning off the
  12. DDSCL_NOWINDOWCHANGES flag on IDirectDraw->SetCooperativeLevel
  13. Notes:
  14. This is an app specific hack, but could fix other similar issues.
  15. Created:
  16. 11/23/1999 linstev
  17. --*/
  18. #include "precomp.h"
  19. IMPLEMENT_SHIM_BEGIN(Riven)
  20. #include "ShimHookMacro.h"
  21. APIHOOK_ENUM_BEGIN
  22. APIHOOK_ENUM_ENTRY_DIRECTX_COMSERVER()
  23. APIHOOK_ENUM_END
  24. IMPLEMENT_DIRECTX_COMSERVER_HOOKS()
  25. /*++
  26. IDirectDraw::SetCooperativeLevel hook
  27. --*/
  28. HRESULT
  29. COMHOOK(IDirectDraw, SetCooperativeLevel)(
  30. PVOID pThis,
  31. HWND hWnd,
  32. DWORD dwFlags
  33. )
  34. {
  35. if (dwFlags & DDSCL_NOWINDOWCHANGES)
  36. {
  37. dwFlags &= ~DDSCL_NOWINDOWCHANGES;
  38. LOGN(eDbgLevelError, "Removed NOWINDOWCHANGES flag");
  39. }
  40. return ORIGINAL_COM(IDirectDraw, SetCooperativeLevel, pThis)(
  41. pThis,
  42. hWnd,
  43. dwFlags);
  44. }
  45. HRESULT
  46. COMHOOK(IDirectDraw2, SetCooperativeLevel)(
  47. PVOID pThis,
  48. HWND hWnd,
  49. DWORD dwFlags
  50. )
  51. {
  52. if (dwFlags & DDSCL_NOWINDOWCHANGES)
  53. {
  54. dwFlags &= ~DDSCL_NOWINDOWCHANGES;
  55. LOGN(eDbgLevelError, "Removed NOWINDOWCHANGES flag");
  56. }
  57. return ORIGINAL_COM(IDirectDraw2, SetCooperativeLevel, pThis)(
  58. pThis,
  59. hWnd,
  60. dwFlags);
  61. }
  62. HRESULT
  63. COMHOOK(IDirectDraw4, SetCooperativeLevel)(
  64. PVOID pThis,
  65. HWND hWnd,
  66. DWORD dwFlags
  67. )
  68. {
  69. if (dwFlags & DDSCL_NOWINDOWCHANGES)
  70. {
  71. dwFlags &= ~DDSCL_NOWINDOWCHANGES;
  72. LOGN(eDbgLevelError, "Removed NOWINDOWCHANGES flag");
  73. }
  74. return ORIGINAL_COM(IDirectDraw4, SetCooperativeLevel, pThis)(
  75. pThis,
  76. hWnd,
  77. dwFlags);
  78. }
  79. HRESULT
  80. COMHOOK(IDirectDraw7, SetCooperativeLevel)(
  81. PVOID pThis,
  82. HWND hWnd,
  83. DWORD dwFlags
  84. )
  85. {
  86. if (dwFlags & DDSCL_NOWINDOWCHANGES)
  87. {
  88. dwFlags &= ~DDSCL_NOWINDOWCHANGES;
  89. LOGN(eDbgLevelError, "Removed NOWINDOWCHANGES flag");
  90. }
  91. return ORIGINAL_COM(IDirectDraw7, SetCooperativeLevel, pThis)(
  92. pThis,
  93. hWnd,
  94. dwFlags);
  95. }
  96. /*++
  97. Register hooked functions
  98. --*/
  99. HOOK_BEGIN
  100. APIHOOK_ENTRY_DIRECTX_COMSERVER()
  101. COMHOOK_ENTRY(DirectDraw, IDirectDraw, SetCooperativeLevel, 20)
  102. COMHOOK_ENTRY(DirectDraw, IDirectDraw2, SetCooperativeLevel, 20)
  103. COMHOOK_ENTRY(DirectDraw, IDirectDraw4, SetCooperativeLevel, 20)
  104. COMHOOK_ENTRY(DirectDraw, IDirectDraw7, SetCooperativeLevel, 20)
  105. HOOK_END
  106. IMPLEMENT_SHIM_END