diff options
author | alexeypa@chromium.org <alexeypa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-06-26 22:53:03 +0000 |
---|---|---|
committer | alexeypa@chromium.org <alexeypa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-06-26 22:53:03 +0000 |
commit | 02ec42242fff81b3d8e1b2b963b002eace10a5dd (patch) | |
tree | 74d8a8168881ca39ca3943dcc843f138ba463b29 /remoting | |
parent | bd3631532ef4234a4983d010f42bf7742d722035 (diff) | |
download | chromium_src-02ec42242fff81b3d8e1b2b963b002eace10a5dd.zip chromium_src-02ec42242fff81b3d8e1b2b963b002eace10a5dd.tar.gz chromium_src-02ec42242fff81b3d8e1b2b963b002eace10a5dd.tar.bz2 |
Emulate Secure Attention Sequence on XP by injecting Ctrl-Alt-Delete as a hot key on Winlogon desktop.
BUG=121496
Review URL: https://chromiumcodereview.appspot.com/10636059
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@144310 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'remoting')
-rw-r--r-- | remoting/host/desktop_win.cc | 15 | ||||
-rw-r--r-- | remoting/host/desktop_win.h | 3 | ||||
-rw-r--r-- | remoting/host/session_event_executor_win.cc | 36 |
3 files changed, 52 insertions, 2 deletions
diff --git a/remoting/host/desktop_win.cc b/remoting/host/desktop_win.cc index 63762a7..a208e18 100644 --- a/remoting/host/desktop_win.cc +++ b/remoting/host/desktop_win.cc @@ -65,6 +65,21 @@ bool DesktopWin::SetThreadDesktop() const { return true; } +scoped_ptr<DesktopWin> DesktopWin::GetDesktop(const wchar_t* desktop_name) { + ACCESS_MASK desired_access = + DESKTOP_CREATEMENU | DESKTOP_CREATEWINDOW | DESKTOP_ENUMERATE | + DESKTOP_HOOKCONTROL | DESKTOP_WRITEOBJECTS | DESKTOP_READOBJECTS | + DESKTOP_SWITCHDESKTOP | GENERIC_WRITE; + HDESK desktop = OpenDesktop(desktop_name, 0, FALSE, desired_access); + if (desktop == NULL) { + LOG_GETLASTERROR(ERROR) + << "Failed to open the desktop '" << desktop_name << "'"; + return scoped_ptr<DesktopWin>(); + } + + return scoped_ptr<DesktopWin>(new DesktopWin(desktop, true)); +} + scoped_ptr<DesktopWin> DesktopWin::GetInputDesktop() { HDESK desktop = OpenInputDesktop( 0, FALSE, GENERIC_READ | GENERIC_WRITE | GENERIC_EXECUTE); diff --git a/remoting/host/desktop_win.h b/remoting/host/desktop_win.h index 9bbfaef..04db4d0 100644 --- a/remoting/host/desktop_win.h +++ b/remoting/host/desktop_win.h @@ -30,6 +30,9 @@ class DesktopWin { // failed for any reason. bool SetThreadDesktop() const; + // Returns the desktop by its name or NULL if an error occurs. + static scoped_ptr<DesktopWin> GetDesktop(const wchar_t* desktop_name); + // Returns the desktop currently receiving user input or NULL if an error // occurs. static scoped_ptr<DesktopWin> GetInputDesktop(); diff --git a/remoting/host/session_event_executor_win.cc b/remoting/host/session_event_executor_win.cc index d68664c..8168ccc 100644 --- a/remoting/host/session_event_executor_win.cc +++ b/remoting/host/session_event_executor_win.cc @@ -10,12 +10,13 @@ #include "base/command_line.h" #include "base/compiler_specific.h" #include "base/message_loop.h" +#include "base/win/windows_version.h" #include "ipc/ipc_channel.h" #include "ipc/ipc_channel_proxy.h" #include "remoting/proto/event.pb.h" - #include "remoting/host/chromoting_messages.h" #include "remoting/host/desktop_win.h" +#include "remoting/host/scoped_thread_desktop_win.h" namespace { @@ -37,6 +38,33 @@ bool areCtrlAndAltPressed(const std::set<uint32>& pressed_keys) { (ctrl_keys + alt_keys == pressed_keys.size()); } +// Emulates Secure Attention Sequence (Ctrl+Alt+Del) by switching to +// the Winlogon desktop and injecting Ctrl+Alt+Del as a hot key. +// N.B. Windows XP/W2K3 only. +void emulateSecureAttentionSequence() { + const wchar_t kWinlogonDesktopName[] = L"Winlogon"; + const wchar_t kSasWindowClassName[] = L"SAS window class"; + const wchar_t kSasWindowTitle[] = L"SAS window"; + + scoped_ptr<remoting::DesktopWin> winlogon_desktop( + remoting::DesktopWin::GetDesktop(kWinlogonDesktopName)); + if (!winlogon_desktop.get()) + return; + + remoting::ScopedThreadDesktopWin desktop; + if (!desktop.SetThreadDesktop(winlogon_desktop.Pass())) + return; + + HWND window = FindWindow(kSasWindowClassName, kSasWindowTitle); + if (!window) + return; + + PostMessage(window, + WM_HOTKEY, + 0, + MAKELONG(MOD_ALT | MOD_CONTROL, VK_DELETE)); +} + } // namespace namespace remoting { @@ -132,8 +160,12 @@ void SessionEventExecutorWin::InjectKeyEvent(const KeyEvent& event) { if (event.usb_keycode() == kUsbDelete && areCtrlAndAltPressed(pressed_keys_)) { VLOG(3) << "Sending Secure Attention Sequence to console"; - if (chromoting_channel_.get()) + + if (base::win::GetVersion() == base::win::VERSION_XP) { + emulateSecureAttentionSequence(); + } else if (chromoting_channel_.get()) { chromoting_channel_->Send(new ChromotingHostMsg_SendSasToConsole()); + } } pressed_keys_.insert(event.usb_keycode()); |