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.

119 lines
2.2 KiB

  1. /*++
  2. Copyright (c) 2000 Microsoft Corporation
  3. Module Name:
  4. ForceAVIWindow.cpp
  5. Abstract:
  6. Some apps that use MCI to play their AVIs send messages in an order that
  7. causes mciavi32 to continually re-open the window it's supposed to be
  8. playing to.
  9. The code in mciavi is different on win9x, so the exact reason for this shim
  10. is hidden in layers of user/avi code. Here we just filter the message that
  11. causes the avi stuff to not use the existing window it's been given.
  12. Notes:
  13. This is an app specific shim.
  14. History:
  15. 02/22/2000 linstev Created
  16. 09/27/2000 mnikkel Modified to destroy the MCI window on a command line input
  17. --*/
  18. #include "precomp.h"
  19. IMPLEMENT_SHIM_BEGIN(ForceAVIWindow)
  20. #include "ShimHookMacro.h"
  21. APIHOOK_ENUM_BEGIN
  22. APIHOOK_ENUM_ENTRY(PostMessageW)
  23. APIHOOK_ENUM_END
  24. BOOL g_bDestroyWindow= FALSE;
  25. /*++
  26. Filter AVIM_SHOWSTAGE
  27. --*/
  28. BOOL
  29. APIHOOK(PostMessageW)(
  30. HWND hWnd,
  31. UINT Msg,
  32. WPARAM wParam,
  33. LPARAM lParam
  34. )
  35. {
  36. #define AVIM_SHOWSTAGE (WM_USER+104)
  37. BOOL bRet;
  38. // Eat the AVIM_SHOWSTAGE message
  39. if (Msg != AVIM_SHOWSTAGE)
  40. {
  41. bRet = ORIGINAL_API(PostMessageW)(
  42. hWnd,
  43. Msg,
  44. wParam,
  45. lParam);
  46. }
  47. else
  48. {
  49. LOGN( eDbgLevelError,
  50. "[APIHook_PostMessageW] AVIM_SHOWSTAGE message discarded");
  51. // if command line specified to destroy the MCI window do so now.
  52. if (g_bDestroyWindow)
  53. {
  54. MCIWndDestroy(hWnd);
  55. }
  56. bRet = TRUE;
  57. }
  58. return bRet;
  59. }
  60. /*++
  61. Register hooked functions
  62. --*/
  63. BOOL
  64. NOTIFY_FUNCTION(
  65. DWORD fdwReason)
  66. {
  67. if (fdwReason == DLL_PROCESS_ATTACH)
  68. {
  69. CSTRING_TRY
  70. {
  71. CString csCl(COMMAND_LINE);
  72. g_bDestroyWindow = csCl.CompareNoCase(L"DestroyMCIWindow") == 0;
  73. }
  74. CSTRING_CATCH
  75. {
  76. return FALSE;
  77. }
  78. }
  79. return TRUE;
  80. }
  81. HOOK_BEGIN
  82. APIHOOK_ENTRY(USER32.DLL, PostMessageW)
  83. CALL_NOTIFY_FUNCTION
  84. HOOK_END
  85. IMPLEMENT_SHIM_END