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.

76 lines
1.3 KiB

  1. /*++
  2. Copyright (c) 2000 Microsoft Corporation
  3. Module Name:
  4. UrbanChaos.cpp
  5. Abstract:
  6. The sound system (Miles) uses a very high-resolution timer: 32ms. The app
  7. has badly designed message loop code. Instead of running everything off the
  8. loop, they have their movie playing code interspersed with a call to
  9. empty the queue. Unfortunately for them, the queue on NT is almost always
  10. filled with these timer messages, so their code to keep track of how far
  11. along their movie is gets starved.
  12. To fix this we reduce the timer resolution.
  13. Notes:
  14. This is an app specific shim.
  15. History:
  16. 10/31/2000 linstev Created
  17. --*/
  18. #include "precomp.h"
  19. IMPLEMENT_SHIM_BEGIN(UrbanChaos)
  20. #include "ShimHookMacro.h"
  21. APIHOOK_ENUM_BEGIN
  22. APIHOOK_ENUM_ENTRY(SetTimer)
  23. APIHOOK_ENUM_END
  24. /*++
  25. Reduce the timer resolution to a managable level.
  26. --*/
  27. UINT_PTR
  28. APIHOOK(SetTimer)(
  29. HWND hWnd,
  30. UINT nIDEvent,
  31. UINT uElapse,
  32. TIMERPROC lpTimerFunc
  33. )
  34. {
  35. // Reduce timer resolution
  36. if (uElapse < 100)
  37. {
  38. uElapse = 500;
  39. }
  40. return ORIGINAL_API(SetTimer)(hWnd, nIDEvent, uElapse, lpTimerFunc);
  41. }
  42. /*++
  43. Register hooked functions
  44. --*/
  45. HOOK_BEGIN
  46. APIHOOK_ENTRY(USER32.DLL, SetTimer)
  47. HOOK_END
  48. IMPLEMENT_SHIM_END