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.

Hooking.h 3.5KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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. #ifndef WINVNCCONF_HOOKING
  19. #define WINVNCCONF_HOOKING
  20. #include <rfb_win32/Registry.h>
  21. #include <rfb_win32/Dialog.h>
  22. #include <rfb_win32/SDisplay.h>
  23. #include <rfb_win32/WMPoller.h>
  24. #include <rfb/ServerCore.h>
  25. namespace rfb {
  26. namespace win32 {
  27. class HookingPage : public PropSheetPage {
  28. public:
  29. HookingPage(const RegKey& rk)
  30. : PropSheetPage(GetModuleHandle(0), MAKEINTRESOURCE(IDD_HOOKING)), regKey(rk) {}
  31. void initDialog() {
  32. setItemChecked(IDC_USEPOLLING, rfb::win32::SDisplay::updateMethod == 0);
  33. setItemChecked(IDC_USEHOOKS, (rfb::win32::SDisplay::updateMethod == 1) &&
  34. rfb::win32::SDisplay::areHooksAvailable());
  35. enableItem(IDC_USEHOOKS, rfb::win32::SDisplay::areHooksAvailable());
  36. setItemChecked(IDC_USEDRIVER, (rfb::win32::SDisplay::updateMethod == 2) &&
  37. rfb::win32::SDisplay::isDriverAvailable());
  38. enableItem(IDC_USEDRIVER, rfb::win32::SDisplay::isDriverAvailable());
  39. setItemChecked(IDC_POLLCONSOLES, rfb::win32::WMPoller::poll_console_windows);
  40. setItemChecked(IDC_CAPTUREBLT, osVersion.isPlatformNT &&
  41. rfb::win32::DeviceFrameBuffer::useCaptureBlt);
  42. enableItem(IDC_CAPTUREBLT, osVersion.isPlatformNT);
  43. onCommand(IDC_USEHOOKS, 0);
  44. }
  45. bool onCommand(int id, int cmd) {
  46. switch (id) {
  47. case IDC_USEPOLLING:
  48. case IDC_USEHOOKS:
  49. case IDC_USEDRIVER:
  50. case IDC_POLLCONSOLES:
  51. case IDC_CAPTUREBLT:
  52. setChanged(((rfb::win32::SDisplay::updateMethod == 0) != isItemChecked(IDC_USEPOLLING)) ||
  53. ((rfb::win32::SDisplay::updateMethod == 1) != isItemChecked(IDC_USEHOOKS)) ||
  54. ((rfb::win32::SDisplay::updateMethod == 2) != isItemChecked(IDC_USEDRIVER)) ||
  55. (rfb::win32::WMPoller::poll_console_windows != isItemChecked(IDC_POLLCONSOLES)) ||
  56. (rfb::win32::DeviceFrameBuffer::useCaptureBlt != isItemChecked(IDC_CAPTUREBLT)));
  57. enableItem(IDC_POLLCONSOLES, isItemChecked(IDC_USEHOOKS));
  58. break;
  59. }
  60. return false;
  61. }
  62. bool onOk() {
  63. if (isItemChecked(IDC_USEPOLLING))
  64. regKey.setInt(_T("UpdateMethod"), 0);
  65. if (isItemChecked(IDC_USEHOOKS))
  66. regKey.setInt(_T("UpdateMethod"), 1);
  67. if (isItemChecked(IDC_USEDRIVER))
  68. regKey.setInt(_T("UpdateMethod"), 2);
  69. regKey.setBool(_T("PollConsoleWindows"), isItemChecked(IDC_POLLCONSOLES));
  70. regKey.setBool(_T("UseCaptureBlt"), isItemChecked(IDC_CAPTUREBLT));
  71. // *** LEGACY compatibility ***
  72. regKey.setBool(_T("UseHooks"), isItemChecked(IDC_USEHOOKS));
  73. return true;
  74. }
  75. protected:
  76. RegKey regKey;
  77. };
  78. };
  79. };
  80. #endif