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.

99 lines
1.7 KiB

  1. /*++
  2. Copyright (c) 2000 Microsoft Corporation
  3. Module Name:
  4. MastersOfOrion2.cpp
  5. Abstract:
  6. This shim is designed to fix a synchronization issue which occurs when
  7. SendMessage is called on a different thread from the window proc. I've not
  8. confirmed this, but it looks as if SendMessage will relinquish control to
  9. the thread with the window proc on Win9x.
  10. The effect on an application can be varied. In Masters of Orion II, the
  11. mouse cursor stops moving.
  12. Notes:
  13. This is an app specific shim.
  14. History:
  15. 04/19/2000 linstev Created
  16. 06/06/2001 linstev Added fix for heap problems
  17. --*/
  18. #include "precomp.h"
  19. IMPLEMENT_SHIM_BEGIN(MastersOfOrion2)
  20. #include "ShimHookMacro.h"
  21. APIHOOK_ENUM_BEGIN
  22. APIHOOK_ENUM_ENTRY(SendMessageA)
  23. APIHOOK_ENUM_ENTRY(LocalAlloc)
  24. APIHOOK_ENUM_END
  25. /*++
  26. Make sure we switch threads after the SendMessage.
  27. --*/
  28. LRESULT
  29. APIHOOK(SendMessageA)(
  30. HWND hWnd,
  31. UINT Msg,
  32. WPARAM wParam,
  33. LPARAM lParam
  34. )
  35. {
  36. LRESULT lRet = ORIGINAL_API(SendMessageA)(
  37. hWnd,
  38. Msg,
  39. wParam,
  40. lParam);
  41. SwitchToThread();
  42. return lRet;
  43. }
  44. /*++
  45. Pad allocations for Ddraw surfaces so they don't trash Ddraw structures.
  46. --*/
  47. HLOCAL
  48. APIHOOK(LocalAlloc)(
  49. UINT uFlags,
  50. SIZE_T uBytes
  51. )
  52. {
  53. if (uBytes >= 640*480) {
  54. //
  55. // This is probably a screen size surface
  56. //
  57. uBytes += 4096;
  58. }
  59. return ORIGINAL_API(LocalAlloc)(uFlags, uBytes);
  60. }
  61. /*++
  62. Register hooked functions
  63. --*/
  64. HOOK_BEGIN
  65. APIHOOK_ENTRY(USER32.DLL, SendMessageA)
  66. APIHOOK_ENTRY(KERNEL32.DLL, LocalAlloc)
  67. HOOK_END
  68. IMPLEMENT_SHIM_END