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.

WMHooks.h 2.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. /* Copyright (C) 2002-2005 RealVNC Ltd. All Rights Reserved.
  2. *
  3. * This is free software; you can redistribute it and/or modify
  4. * it under the terms of the GNU General Public License as published by
  5. * the Free Software Foundation; either version 2 of the License, or
  6. * (at your option) any later version.
  7. *
  8. * This software is distributed in the hope that it will be useful,
  9. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. * GNU General Public License for more details.
  12. *
  13. * You should have received a copy of the GNU General Public License
  14. * along with this software; if not, write to the Free Software
  15. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
  16. * USA.
  17. */
  18. // -=- WMHooks.h
  19. #ifndef __RFB_WIN32_WM_HOOKS_H__
  20. #define __RFB_WIN32_WM_HOOKS_H__
  21. #include <windows.h>
  22. #include <rfb/UpdateTracker.h>
  23. #include <rdr/Exception.h>
  24. #include <rfb_win32/Win32Util.h>
  25. namespace rfb {
  26. namespace win32 {
  27. // -=- WMHooks
  28. // Uses the wm_hooks DLL to intercept window messages, to get _hints_ as
  29. // to what may have changed on-screen. Updates are notified via a Win32
  30. // event, and retrieved using the getUpdates method, which is thread-safe.
  31. class WMHooks {
  32. public:
  33. WMHooks();
  34. ~WMHooks();
  35. // Specify the event object to notify. Starts the hook subsystem if it is
  36. // not already active, and returns false if the hooks fail to start.
  37. bool setEvent(HANDLE updateEvent);
  38. // Copies any new updates to the UpdateTracker. Returns true if new updates
  39. // were added, false otherwise.
  40. bool getUpdates(UpdateTracker* ut);
  41. #ifdef _DEBUG
  42. // Get notifications of any messages in the given range, to any hooked window
  43. void setDiagnosticRange(UINT min, UINT max);
  44. #endif
  45. // * INTERNAL NOTIFICATION FUNCTION *
  46. void NotifyHooksRegion(const Region& r);
  47. protected:
  48. HANDLE updateEvent;
  49. bool updatesReady;
  50. SimpleUpdateTracker updates;
  51. };
  52. // -=- Support for filtering out local input events while remote connections are
  53. // active. Implemented using SetWindowsHookEx for portability.
  54. class WMBlockInput {
  55. public:
  56. WMBlockInput();
  57. ~WMBlockInput();
  58. bool blockInputs(bool block);
  59. protected:
  60. bool active;
  61. };
  62. };
  63. };
  64. #endif // __RFB_WIN32_WM_HOOKS_H__