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.

110 lines
2.8 KiB

  1. /*++
  2. Copyright (c) 2000-2001 Microsoft Corporation
  3. Module Name:
  4. Ppo3svrScr.cpp
  5. Abstract:
  6. Power Plus screensaver bundled with Lotus Super Office 2000 Japanese could not launch
  7. Configure dialog on Whistler. But it works on Win 2000.
  8. The desk.cpl behavior of launching screensaver is changed a bit on Whistler.
  9. This screensaver's ScreenSaverConfigureDialog ID is not DLG_SCRNSAVECONFIGURE (2003=MSDN must) and unusual.
  10. Assuming unusual screensaver.
  11. This shim is applied to screensaver and hacks GetCommandLineW/A return text to change from
  12. "D:\WINDOWS\System32\ppo3svr.scr /c:1769646"
  13. to
  14. "D:\WINDOWS\System32\ppo3svr.scr"
  15. so that configure dialog appears.
  16. More Info:
  17. From desk.cpl (rundll32.exe), Screen Saver operation and CreateProcessW lpCommandLine argument:
  18. (1) Initial selection of screensaver
  19. "D:\WINDOWS\System32\ppo3svr.scr /p 721330" -> preview only
  20. (2) Preview button
  21. 1st call "D:\WINDOWS\System32\ppo3svr.scr /s" -> screen saver
  22. 2nd call "D:\WINDOWS\System32\ppo3svr.scr /p 721330" -> return to preview
  23. (3) Settings button
  24. 1st call "D:\WINDOWS\System32\ppo3svr.scr /c:1769646" -> configure dialog (not working)
  25. 2nd call "D:\WINDOWS\System32\ppo3svr.scr /p 721330" -> return to preview
  26. History:
  27. 06/11/2001 hioh Created
  28. --*/
  29. #include "precomp.h"
  30. // Using only strstr to find lower ascii text for GetCommandLineW/A. Operation is same between W & A.
  31. #include "LegalStr.h"
  32. IMPLEMENT_SHIM_BEGIN(Ppo3svrScr)
  33. #include "ShimHookMacro.h"
  34. //
  35. // Add APIs that you wish to hook to this macro construction.
  36. //
  37. APIHOOK_ENUM_BEGIN
  38. APIHOOK_ENUM_ENTRY(GetCommandLineW)
  39. APIHOOK_ENUM_ENTRY(GetCommandLineA)
  40. APIHOOK_ENUM_END
  41. /*++
  42. Cut the /c:... string in CommandLine for ppo3svr.scr.
  43. --*/
  44. LPWSTR APIHOOK(GetCommandLineW)()
  45. {
  46. WCHAR szScreenSaverConfigure[] = L"ppo3svr.scr /c:";
  47. WCHAR szConfigure[] = L" /c:";
  48. LPWSTR lpCommandLine = ORIGINAL_API(GetCommandLineW)();
  49. LPWSTR pw = wcsstr(lpCommandLine, szScreenSaverConfigure);
  50. if (pw != NULL)
  51. {
  52. if (pw = wcsstr(pw, szConfigure))
  53. {
  54. *pw = 0; // cut from " /c:"
  55. }
  56. }
  57. return (lpCommandLine);
  58. }
  59. LPSTR APIHOOK(GetCommandLineA)()
  60. {
  61. CHAR szScreenSaverConfigure[] = "ppo3svr.scr /c:";
  62. CHAR szConfigure[] = " /c:";
  63. LPSTR lpCommandLine = ORIGINAL_API(GetCommandLineA)();
  64. LPSTR pc = strstr(lpCommandLine, szScreenSaverConfigure);
  65. if (pc != NULL)
  66. {
  67. if (pc = strstr(pc, szConfigure))
  68. {
  69. *pc = 0; // cut from " /c:"
  70. }
  71. }
  72. return (lpCommandLine);
  73. }
  74. /*++
  75. Register hooked functions
  76. --*/
  77. HOOK_BEGIN
  78. APIHOOK_ENTRY(KERNEL32.DLL, GetCommandLineW)
  79. APIHOOK_ENTRY(KERNEL32.DLL, GetCommandLineA)
  80. HOOK_END
  81. IMPLEMENT_SHIM_END