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.

121 lines
2.3 KiB

  1. /*++
  2. Copyright (c) 2001 Microsoft Corporation
  3. Module Name:
  4. CorelAppsRegistration.cpp
  5. Abstract:
  6. Notes:
  7. This is an app specific shim.
  8. History:
  9. 11/13/2001 prashkud Created
  10. --*/
  11. #include "precomp.h"
  12. IMPLEMENT_SHIM_BEGIN(CorelAppsRegistration)
  13. #include "ShimHookMacro.h"
  14. APIHOOK_ENUM_BEGIN
  15. APIHOOK_ENUM_ENTRY(ShowWindow)
  16. APIHOOK_ENUM_ENTRY(CreateWindowExA)
  17. APIHOOK_ENUM_END
  18. /*++
  19. Calls SetForegroundWindow directly after a ShowWindow call with SW_SHOW as
  20. the operation. The mouse_event call allows the SetForegroundWindow call to
  21. succeed. This is a hack borrowed from the DirectX sources.
  22. --*/
  23. BOOL
  24. APIHOOK(ShowWindow)(
  25. HWND hWnd,
  26. INT nCmdShow
  27. )
  28. {
  29. BOOL bReturn;
  30. bReturn = ORIGINAL_API(ShowWindow)(hWnd, nCmdShow | SW_SHOW);
  31. mouse_event(MOUSEEVENTF_WHEEL, 0, 0, 0, 0);
  32. SetForegroundWindow(hWnd);
  33. LOGN( eDbgLevelWarning,
  34. "Forcing to foreground.");
  35. return bReturn;
  36. }
  37. /*++
  38. Calls SetForegroundWindow directly after a CreateWindowEx call with
  39. WS_VISIBLE as a style. The mouse_event call allows the
  40. SetForegroundWindow call to succeed. This is a hack borrowed from
  41. the DirectX sources.
  42. --*/
  43. HWND
  44. APIHOOK(CreateWindowExA)(
  45. DWORD dwExStyle,
  46. LPCSTR lpClassName,
  47. LPCSTR lpWindowName,
  48. DWORD dwStyle,
  49. int x,
  50. int y,
  51. int nWidth,
  52. int nHeight,
  53. HWND hWndParent,
  54. HMENU hMenu,
  55. HINSTANCE hInstance,
  56. LPVOID lpParam
  57. )
  58. {
  59. HWND hReturn;
  60. dwStyle |= WS_VISIBLE;
  61. hReturn = ORIGINAL_API(CreateWindowExA)(
  62. dwExStyle,
  63. lpClassName,
  64. lpWindowName,
  65. dwStyle,
  66. x,
  67. y,
  68. nWidth,
  69. nHeight,
  70. hWndParent,
  71. hMenu,
  72. hInstance,
  73. lpParam);
  74. mouse_event(MOUSEEVENTF_WHEEL, 0, 0, 0, 0);
  75. SetForegroundWindow(hReturn);
  76. LOGN( eDbgLevelWarning,
  77. "Forcing to foreground.");
  78. return hReturn;
  79. }
  80. /*++
  81. Register hooked functions
  82. --*/
  83. HOOK_BEGIN
  84. APIHOOK_ENTRY(USER32.DLL, ShowWindow)
  85. APIHOOK_ENTRY(USER32.DLL, CreateWindowExA)
  86. HOOK_END
  87. IMPLEMENT_SHIM_END