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.

147 lines
2.9 KiB

  1. /*
  2. Copyright (c) 2000 Microsoft Corporation
  3. Module Name:
  4. WinStone99.cpp
  5. Bug: Whistler #185797
  6. Problem:
  7. Only for Winstone '99. Winstone uses scripts that hide the taskbar, and print stuff.
  8. PrintUI displays a balloon tip informing the user that the printing job is done (this is a
  9. new addition to Whistler).
  10. The balloon tip utilizes user tracking code, and is hence left stationary on the machine,
  11. till the user clicks on it, or there is 10 seconds of user activity on the machine.
  12. Winstone runs these automated tests, hence there is no user activity on the machine, when
  13. the balloon is up, so it stays up forever.
  14. Later, when Winstone tries to enumerate the application windows, the presence of the
  15. balloon tip throws it off track. Hence this apphack that disables the display of these
  16. balloons when Winstone is running.
  17. Winstone is a collection of Visual Test scripts, and zdbui32.exe is the only exe that runs
  18. throughout when Winstone is running. So disable user tracking when Winstone is running.
  19. Solution:
  20. Disable display of balloon tips when Winstone is running and enable it when Winstone is
  21. finished
  22. Details:
  23. Winstone sends a message to the tray that disables the balloon tip when it is running, and
  24. re-sends the message to the tray when it is done, so that the tray can enable the balloon
  25. tip
  26. History:
  27. 09/20/2000 ramkumar Created
  28. */
  29. #include "precomp.h"
  30. #include <shlapip.h>
  31. IMPLEMENT_SHIM_BEGIN(WinStone99)
  32. #include "ShimHookMacro.h"
  33. APIHOOK_ENUM_BEGIN
  34. APIHOOK_ENUM_ENTRY(GetCommandLineA)
  35. APIHOOK_ENUM_ENTRY(GetCommandLineW)
  36. APIHOOK_ENUM_END
  37. BOOL g_bInit = FALSE;
  38. HWND g_hwndTray;
  39. UINT g_uEnableBalloonMessage;
  40. /*++
  41. Initialize
  42. --*/
  43. VOID
  44. WinStone99_Initialize()
  45. {
  46. if (!g_bInit)
  47. {
  48. g_bInit = TRUE;
  49. g_uEnableBalloonMessage = RegisterWindowMessage(ENABLE_BALLOONTIP_MESSAGE);
  50. if (!g_uEnableBalloonMessage)
  51. {
  52. return;
  53. }
  54. g_hwndTray = FindWindowA(WNDCLASS_TRAYNOTIFY, NULL);
  55. if (g_hwndTray)
  56. {
  57. SendMessage(g_hwndTray, g_uEnableBalloonMessage, FALSE, 0);
  58. }
  59. }
  60. }
  61. /*++
  62. Initialize.
  63. --*/
  64. LPSTR
  65. APIHOOK(GetCommandLineA)()
  66. {
  67. WinStone99_Initialize();
  68. return ORIGINAL_API(GetCommandLineA)();
  69. }
  70. /*++
  71. Initialize.
  72. --*/
  73. LPWSTR
  74. APIHOOK(GetCommandLineW)()
  75. {
  76. WinStone99_Initialize();
  77. return ORIGINAL_API(GetCommandLineW)();
  78. }
  79. /*++
  80. Register hooked functions
  81. --*/
  82. BOOL
  83. NOTIFY_FUNCTION(
  84. DWORD fdwReason
  85. )
  86. {
  87. if (fdwReason == DLL_PROCESS_DETACH)
  88. {
  89. if (g_bInit)
  90. {
  91. if (g_hwndTray)
  92. {
  93. SendMessage(g_hwndTray, g_uEnableBalloonMessage, TRUE, 0);
  94. }
  95. }
  96. }
  97. return TRUE;
  98. }
  99. HOOK_BEGIN
  100. CALL_NOTIFY_FUNCTION
  101. APIHOOK_ENTRY(KERNEL32.DLL, GetCommandLineA)
  102. APIHOOK_ENTRY(KERNEL32.DLL, GetCommandLineW)
  103. HOOK_END
  104. IMPLEMENT_SHIM_END