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.

158 lines
3.0 KiB

  1. /*++
  2. Copyright (c) 2000 Microsoft Corporation
  3. Module Name:
  4. ForceTemporaryModeChange.cpp
  5. Abstract:
  6. A hack for several apps that permanently change the display mode and fail
  7. to restore it correctly. Some of these apps do restore the resolution, but
  8. not the refresh rate. 1024x768 @ 60Hz looks really bad.
  9. Notes:
  10. This is a general purpose shim.
  11. History:
  12. 01/20/2000 linstev Created
  13. --*/
  14. #include "precomp.h"
  15. IMPLEMENT_SHIM_BEGIN(ForceTemporaryModeChange)
  16. #include "ShimHookMacro.h"
  17. APIHOOK_ENUM_BEGIN
  18. APIHOOK_ENUM_ENTRY(ChangeDisplaySettingsA)
  19. APIHOOK_ENUM_ENTRY(ChangeDisplaySettingsW)
  20. APIHOOK_ENUM_ENTRY(ChangeDisplaySettingsExA)
  21. APIHOOK_ENUM_ENTRY(ChangeDisplaySettingsExW)
  22. APIHOOK_ENUM_END
  23. /*++
  24. Force temporary change.
  25. --*/
  26. LONG
  27. APIHOOK(ChangeDisplaySettingsA)(
  28. LPDEVMODEA lpDevMode,
  29. DWORD dwFlags
  30. )
  31. {
  32. if (dwFlags != CDS_FULLSCREEN) {
  33. LOGN(
  34. eDbgLevelError,
  35. "[ChangeDisplaySettingsA] Changing flags to CDS_FULLSCREEN.");
  36. }
  37. return ORIGINAL_API(ChangeDisplaySettingsA)(
  38. lpDevMode,
  39. CDS_FULLSCREEN);
  40. }
  41. /*++
  42. Force temporary change.
  43. --*/
  44. LONG
  45. APIHOOK(ChangeDisplaySettingsW)(
  46. LPDEVMODEW lpDevMode,
  47. DWORD dwFlags
  48. )
  49. {
  50. if (dwFlags != CDS_FULLSCREEN) {
  51. LOGN(
  52. eDbgLevelError,
  53. "[ChangeDisplaySettingsW] Changing flags to CDS_FULLSCREEN.");
  54. }
  55. return ORIGINAL_API(ChangeDisplaySettingsW)(
  56. lpDevMode,
  57. CDS_FULLSCREEN);
  58. }
  59. /*++
  60. Force temporary change.
  61. --*/
  62. LONG
  63. APIHOOK(ChangeDisplaySettingsExA)(
  64. LPCSTR lpszDeviceName,
  65. LPDEVMODEA lpDevMode,
  66. HWND hwnd,
  67. DWORD dwflags,
  68. LPVOID lParam
  69. )
  70. {
  71. if (dwflags != CDS_FULLSCREEN) {
  72. LOGN(
  73. eDbgLevelError,
  74. "[ChangeDisplaySettingsExA] Changing flags to CDS_FULLSCREEN.");
  75. }
  76. return ORIGINAL_API(ChangeDisplaySettingsExA)(
  77. lpszDeviceName,
  78. lpDevMode,
  79. hwnd,
  80. CDS_FULLSCREEN,
  81. lParam);
  82. }
  83. /*++
  84. Force temporary change.
  85. --*/
  86. LONG
  87. APIHOOK(ChangeDisplaySettingsExW)(
  88. LPCWSTR lpszDeviceName,
  89. LPDEVMODEW lpDevMode,
  90. HWND hwnd,
  91. DWORD dwflags,
  92. LPVOID lParam
  93. )
  94. {
  95. if (dwflags != CDS_FULLSCREEN) {
  96. LOGN(
  97. eDbgLevelError,
  98. "[ChangeDisplaySettingsExW] Changing flags to CDS_FULLSCREEN.");
  99. }
  100. return ORIGINAL_API(ChangeDisplaySettingsExW)(
  101. lpszDeviceName,
  102. lpDevMode,
  103. hwnd,
  104. CDS_FULLSCREEN,
  105. lParam);
  106. }
  107. /*++
  108. Register hooked functions
  109. --*/
  110. HOOK_BEGIN
  111. APIHOOK_ENTRY(USER32.DLL, ChangeDisplaySettingsA)
  112. APIHOOK_ENTRY(USER32.DLL, ChangeDisplaySettingsW)
  113. APIHOOK_ENTRY(USER32.DLL, ChangeDisplaySettingsExA)
  114. APIHOOK_ENTRY(USER32.DLL, ChangeDisplaySettingsExW)
  115. HOOK_END
  116. IMPLEMENT_SHIM_END