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.

112 lines
1.8 KiB

  1. /*++
  2. Copyright (c) 2002 Microsoft Corporation
  3. Module Name:
  4. CreativeOnScreenDisplay.cpp
  5. Abstract:
  6. App crashes with low resolution display changes.
  7. Notes:
  8. This is an app specific shim.
  9. History:
  10. 06/25/2002 linstev Created
  11. --*/
  12. #include "precomp.h"
  13. IMPLEMENT_SHIM_BEGIN(CreativeOnScreenDisplay)
  14. #include "ShimHookMacro.h"
  15. APIHOOK_ENUM_BEGIN
  16. APIHOOK_ENUM_ENTRY(RegisterClassA)
  17. APIHOOK_ENUM_ENTRY(SetWindowLongA)
  18. APIHOOK_ENUM_END
  19. /*++
  20. Handle display change messages
  21. --*/
  22. LRESULT
  23. CALLBACK
  24. Creative_WindowProcHook(
  25. WNDPROC pfnOld,
  26. HWND hwnd,
  27. UINT uMsg,
  28. WPARAM wParam,
  29. LPARAM lParam
  30. )
  31. {
  32. if (uMsg == WM_DISPLAYCHANGE)
  33. {
  34. // Ignore this message if the resolution is too low
  35. if ((LOWORD(lParam) < 512) || (HIWORD(lParam) < 384))
  36. {
  37. LOGN(eDbgLevelError, "[WndProc] Hiding WM_DISPLAYCHANGE for low resolution mode");
  38. return 0;
  39. }
  40. }
  41. return (*pfnOld)(hwnd, uMsg, wParam, lParam);
  42. }
  43. /*++
  44. Hook the wndproc
  45. --*/
  46. ATOM
  47. APIHOOK(RegisterClassA)(
  48. CONST WNDCLASSA *lpWndClass
  49. )
  50. {
  51. WNDCLASSA wcNewWndClass = *lpWndClass;
  52. wcNewWndClass.lpfnWndProc =
  53. (WNDPROC) HookCallback(lpWndClass->lpfnWndProc, Creative_WindowProcHook);
  54. return ORIGINAL_API(RegisterClassA)(&wcNewWndClass);
  55. }
  56. LONG
  57. APIHOOK(SetWindowLongA)(
  58. HWND hWnd,
  59. int nIndex,
  60. LONG dwNewLong
  61. )
  62. {
  63. if (nIndex == GWL_WNDPROC)
  64. {
  65. dwNewLong = (LONG) HookCallback((PVOID)dwNewLong, Creative_WindowProcHook);
  66. }
  67. return ORIGINAL_API(SetWindowLongA)(
  68. hWnd,
  69. nIndex,
  70. dwNewLong);
  71. }
  72. /*++
  73. Register hooked functions
  74. --*/
  75. HOOK_BEGIN
  76. APIHOOK_ENTRY(USER32.DLL, RegisterClassA)
  77. APIHOOK_ENTRY(USER32.DLL, SetWindowLongA)
  78. HOOK_END
  79. IMPLEMENT_SHIM_END