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.

97 lines
2.1 KiB

  1. /*++
  2. Copyright (c) 2000 Microsoft Corporation
  3. Module Name:
  4. AfterDark.cpp
  5. Abstract:
  6. This shim hooks SystemParametersInfo and when SPI_SETSCREENSAVEACTIVE is
  7. passed in with FALSE as its argument, the shim only deletes the
  8. SCRNSAVE.EXE value which sets the "None" screen saver option instead of
  9. setting ScreenSaverActive to 0 as well, which completely disables
  10. screen savers (with no recovery UI).
  11. History:
  12. 08/07/2000 t-adams Created
  13. --*/
  14. #include "precomp.h"
  15. IMPLEMENT_SHIM_BEGIN(AfterDark)
  16. #include "ShimHookMacro.h"
  17. APIHOOK_ENUM_BEGIN
  18. APIHOOK_ENUM_ENTRY(SystemParametersInfoA)
  19. APIHOOK_ENUM_END
  20. /*++
  21. Abstract:
  22. This shim hooks SystemParametersInfoA and when SPI_SETSCREENSAVEACTIVE is
  23. passed in with FALSE as its argument, the shim only deletes the
  24. SCRNSAVE.EXE value which sets the "None" screen saver option instead of
  25. setting ScreenSaverActive to 0 as well, which completely disables
  26. screen savers (with no recovery UI).
  27. History:
  28. 08/07/2000 t-adams Created
  29. --*/
  30. BOOL
  31. APIHOOK(SystemParametersInfoA)(
  32. UINT uiAction,
  33. UINT uiParam,
  34. PVOID pvParam,
  35. UINT fWinIni
  36. )
  37. {
  38. HKEY hKey = 0;
  39. BOOL bRet = FALSE;
  40. if (SPI_SETSCREENSAVEACTIVE == uiAction && FALSE == uiParam)
  41. {
  42. LOGN( eDbgLevelError, "[APIHook_SystemParametersInfo] Attempt to disable screen savers - correcting");
  43. if (RegOpenKeyExW(HKEY_CURRENT_USER, L"Control Panel\\Desktop", 0, KEY_WRITE, &hKey)
  44. == ERROR_SUCCESS)
  45. {
  46. RegDeleteValueW(hKey, L"SCRNSAVE.EXE");
  47. RegCloseKey(hKey);
  48. bRet = TRUE;
  49. goto exit;
  50. }
  51. else
  52. {
  53. goto exit;
  54. }
  55. }
  56. else
  57. {
  58. bRet = ORIGINAL_API(SystemParametersInfoA)(uiAction, uiParam, pvParam, fWinIni);
  59. goto exit;
  60. }
  61. exit:
  62. return bRet;
  63. }
  64. /*++
  65. Register hooked functions
  66. --*/
  67. HOOK_BEGIN
  68. APIHOOK_ENTRY(USER32.DLL, SystemParametersInfoA)
  69. HOOK_END
  70. IMPLEMENT_SHIM_END