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.7 KiB

  1. /*++
  2. Copyright (c) 2002 Microsoft Corporation
  3. Module Name:
  4. EmulateGetUIEffects.cpp
  5. Abstract:
  6. Force SPI_GETUIEFFECTS to FALSE if this is a remote (TS) session
  7. History:
  8. 08/07/2002 linstev Created
  9. 08/22/2002 robkenny Converted to a general shim
  10. --*/
  11. #include "precomp.h"
  12. IMPLEMENT_SHIM_BEGIN(EmulateGetUIEffects)
  13. #include "ShimHookMacro.h"
  14. APIHOOK_ENUM_BEGIN
  15. APIHOOK_ENUM_ENTRY(SystemParametersInfoA)
  16. APIHOOK_ENUM_ENTRY(SystemParametersInfoW)
  17. APIHOOK_ENUM_END
  18. BOOL bGetUIEffects = FALSE;
  19. /*++
  20. If the caller was after SPI_GETUIEFFECTS and this is a TS session
  21. force the value to the value specified on the command line.
  22. --*/
  23. VOID CorrectGetUIEffects(
  24. UINT uiAction, // system parameter to retrieve or set
  25. UINT uiParam, // depends on action to be taken
  26. PVOID pvParam, // depends on action to be taken
  27. UINT fWinIni // user profile update option
  28. )
  29. {
  30. if (pvParam && (uiAction == SPI_GETUIEFFECTS))
  31. {
  32. if (GetSystemMetrics(SM_REMOTESESSION))
  33. {
  34. BOOL * bUiEffect = (BOOL *)pvParam;
  35. // Only spew the message if we are actually changing the value
  36. if (*bUiEffect != bGetUIEffects)
  37. {
  38. LOGN(eDbgLevelWarning, "SystemParametersInfoA: Forcing SPI_GETUIEFFECTS to %s", bGetUIEffects ? "TRUE" : "FALSE");
  39. *bUiEffect = bGetUIEffects;
  40. }
  41. }
  42. }
  43. }
  44. /*++
  45. Force SPI_GETUIEFFECTS to bGetUIEffects (defaults to FALSE) if this is a remote (TS) session
  46. --*/
  47. BOOL
  48. APIHOOK(SystemParametersInfoA)(
  49. UINT uiAction, // system parameter to retrieve or set
  50. UINT uiParam, // depends on action to be taken
  51. PVOID pvParam, // depends on action to be taken
  52. UINT fWinIni // user profile update option
  53. )
  54. {
  55. BOOL bRet = ORIGINAL_API(SystemParametersInfoA)(uiAction, uiParam, pvParam, fWinIni);
  56. if (bRet)
  57. {
  58. CorrectGetUIEffects(uiAction, uiParam, pvParam, fWinIni);
  59. }
  60. return bRet;
  61. }
  62. BOOL
  63. APIHOOK(SystemParametersInfoW)(
  64. UINT uiAction, // system parameter to retrieve or set
  65. UINT uiParam, // depends on action to be taken
  66. PVOID pvParam, // depends on action to be taken
  67. UINT fWinIni // user profile update option
  68. )
  69. {
  70. BOOL bRet = ORIGINAL_API(SystemParametersInfoW)(uiAction, uiParam, pvParam, fWinIni);
  71. if (bRet)
  72. {
  73. CorrectGetUIEffects(uiAction, uiParam, pvParam, fWinIni);
  74. }
  75. return bRet;
  76. }
  77. BOOL
  78. NOTIFY_FUNCTION(
  79. DWORD fdwReason)
  80. {
  81. switch (fdwReason)
  82. {
  83. case DLL_PROCESS_ATTACH:
  84. {
  85. CSTRING_TRY
  86. {
  87. CString csCl(COMMAND_LINE);
  88. if (csCl.CompareNoCase(L"true") == 0)
  89. {
  90. DPFN(eDbgLevelSpew, "EmulateGetUIEffects command line forcing SPI_GETUIEFFECTS to TRUE");
  91. bGetUIEffects = TRUE;
  92. }
  93. else if (csCl.CompareNoCase(L"false") == 0)
  94. {
  95. DPFN(eDbgLevelSpew, "EmulateGetUIEffects command line forcing SPI_GETUIEFFECTS to FALSE");
  96. bGetUIEffects = FALSE;
  97. }
  98. }
  99. CSTRING_CATCH
  100. {
  101. return FALSE;
  102. }
  103. }
  104. break;
  105. default:
  106. break;
  107. }
  108. return TRUE;
  109. }
  110. /*++
  111. Register hooked functions
  112. --*/
  113. HOOK_BEGIN
  114. CALL_NOTIFY_FUNCTION
  115. APIHOOK_ENTRY(USER32.DLL, SystemParametersInfoA)
  116. APIHOOK_ENTRY(USER32.DLL, SystemParametersInfoW)
  117. HOOK_END
  118. IMPLEMENT_SHIM_END