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

  1. /*++
  2. Copyright (c) 2000 Microsoft Corporation
  3. Module Name:
  4. Worms2.cpp
  5. Abstract:
  6. Extremely lame hack because we don't properly support full-screen MCI
  7. playback on NT.
  8. Notes:
  9. This is an app specific shim.
  10. History:
  11. 12/04/2000 linstev Created
  12. --*/
  13. #include "precomp.h"
  14. #include <mmsystem.h>
  15. #include <digitalv.h>
  16. #include <mciavi.h>
  17. IMPLEMENT_SHIM_BEGIN(Worms2)
  18. #include "ShimHookMacro.h"
  19. APIHOOK_ENUM_BEGIN
  20. APIHOOK_ENUM_ENTRY(mciSendCommandA)
  21. APIHOOK_ENUM_END
  22. /*++
  23. Do lots of lame stuff.
  24. --*/
  25. MCIERROR
  26. APIHOOK(mciSendCommandA)(
  27. MCIDEVICEID IDDevice,
  28. UINT uMsg,
  29. DWORD fdwCommand,
  30. DWORD dwParam
  31. )
  32. {
  33. if ((uMsg == MCI_PLAY) &&
  34. (fdwCommand == (MCI_NOTIFY | MCI_WAIT | MCI_MCIAVI_PLAY_FULLSCREEN)))
  35. {
  36. DEVMODEA dm;
  37. dm.dmSize = sizeof(dm);
  38. dm.dmPelsWidth = 320;
  39. dm.dmPelsHeight = 200;
  40. dm.dmFields = DM_PELSWIDTH | DM_PELSHEIGHT;
  41. ChangeDisplaySettingsA(&dm, CDS_FULLSCREEN);
  42. #define szWndClass "WORMS2_HACK_WINDOW"
  43. WNDCLASSA cls;
  44. HMODULE hModule = GetModuleHandle(0);
  45. if (!GetClassInfoA(hModule, szWndClass, &cls))
  46. {
  47. cls.lpszClassName = szWndClass;
  48. cls.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH);
  49. cls.hInstance = hModule;
  50. cls.hIcon = NULL;
  51. cls.hCursor = NULL;
  52. cls.lpszMenuName = NULL;
  53. cls.style = CS_DBLCLKS;
  54. cls.lpfnWndProc = (WNDPROC)DefWindowProc;
  55. cls.cbWndExtra = sizeof(INT_PTR);
  56. cls.cbClsExtra = 0;
  57. if (RegisterClassA(&cls) == 0)
  58. {
  59. goto Fail;
  60. }
  61. }
  62. HWND hWnd = CreateWindowA(
  63. szWndClass,
  64. szWndClass,
  65. WS_OVERLAPPED|WS_POPUP|WS_VISIBLE,
  66. 0,
  67. 0,
  68. GetSystemMetrics(SM_CXSCREEN),
  69. GetSystemMetrics(SM_CYSCREEN),
  70. (HWND)NULL,
  71. NULL,
  72. hModule,
  73. (LPVOID)NULL);
  74. if (!hWnd)
  75. {
  76. goto Fail;
  77. }
  78. MCIERROR merr;
  79. MCI_DGV_WINDOW_PARMSA mciwnd;
  80. mciwnd.dwCallback = (DWORD) (WNDPROC) DefWindowProcA;
  81. mciwnd.hWnd = hWnd;
  82. mciwnd.lpstrText = 0;
  83. mciwnd.nCmdShow = 0;
  84. merr = mciSendCommandA(IDDevice, MCI_WINDOW, MCI_DGV_WINDOW_HWND, (DWORD)&mciwnd);
  85. if (merr != MMSYSERR_NOERROR)
  86. {
  87. DestroyWindow(hWnd);
  88. goto Fail;
  89. }
  90. ShowCursor(FALSE);
  91. MCI_PLAY_PARMS mciply;
  92. mciply.dwCallback = (DWORD)hWnd;
  93. mciply.dwFrom = 0x40000000;
  94. mciply.dwTo = 0;
  95. merr = mciSendCommandA(IDDevice, MCI_PLAY, MCI_NOTIFY | MCI_WAIT, (DWORD)&mciply);
  96. DestroyWindow(hWnd);
  97. ShowCursor(TRUE);
  98. if (merr != MMSYSERR_NOERROR)
  99. {
  100. goto Fail;
  101. }
  102. return 0;
  103. }
  104. Fail:
  105. return ORIGINAL_API(mciSendCommandA)(
  106. IDDevice,
  107. uMsg,
  108. fdwCommand,
  109. dwParam);
  110. }
  111. /*++
  112. Register hooked functions
  113. --*/
  114. HOOK_BEGIN
  115. APIHOOK_ENTRY(WINMM.DLL, mciSendCommandA)
  116. HOOK_END
  117. IMPLEMENT_SHIM_END