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.

84 lines
1.7 KiB

  1. /*++
  2. Copyright (c) 2001 Microsoft Corporation
  3. Module Name:
  4. Cossacks.cpp
  5. Abstract:
  6. This is a workaround for a problem created by SafeDisc 2.0. The application
  7. uses the WM_ACTIVATEAPP message to determine if it has focus or not. The
  8. Safedisc wrapper prevents this message from hitting their main window on
  9. NT, because it goes to the SafeDisc window before everything has been
  10. unwrapped. So the app never thinks it has focus.
  11. The fix is to send an activate message after the window has been created.
  12. Notes:
  13. This is an app specific shim.
  14. History:
  15. 06/16/2001 linstev Created
  16. --*/
  17. #include "precomp.h"
  18. #include <mmsystem.h>
  19. IMPLEMENT_SHIM_BEGIN(Cossacks)
  20. #include "ShimHookMacro.h"
  21. APIHOOK_ENUM_BEGIN
  22. APIHOOK_ENUM_ENTRY(mciSendCommandA)
  23. APIHOOK_ENUM_END
  24. /*++
  25. Hook mciSendCommand and try to find the window we need to activate.
  26. --*/
  27. BOOL g_bFirst = TRUE;
  28. MCIERROR
  29. APIHOOK(mciSendCommandA)(
  30. MCIDEVICEID IDDevice,
  31. UINT uMsg,
  32. DWORD fdwCommand,
  33. DWORD dwParam
  34. )
  35. {
  36. if (g_bFirst) {
  37. //
  38. // Only need to hit this code once
  39. //
  40. HWND hWnd = FindWindowW(L"Kernel", L"Game");
  41. if (hWnd) {
  42. //
  43. // We've found the window, send the message
  44. //
  45. g_bFirst = FALSE;
  46. LOGN(eDbgLevelError, "Sent a WM_ACTIVATEAPP to the window");
  47. SendMessageW(hWnd, WM_ACTIVATEAPP, 1, 0);
  48. }
  49. }
  50. return ORIGINAL_API(mciSendCommandA)(IDDevice, uMsg, fdwCommand, dwParam);
  51. }
  52. /*++
  53. Register hooked functions
  54. --*/
  55. HOOK_BEGIN
  56. APIHOOK_ENTRY(WINMM.DLL, mciSendCommandA)
  57. HOOK_END
  58. IMPLEMENT_SHIM_END