diff options
author | alexeypa@chromium.org <alexeypa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-05-16 03:03:03 +0000 |
---|---|---|
committer | alexeypa@chromium.org <alexeypa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-05-16 03:03:03 +0000 |
commit | 264513d9881a9e5599c67a9dded5020d06872dbd (patch) | |
tree | 329eefb494c8abd1c3d1b3df99fd03f5f1f75903 /remoting | |
parent | c867e42ff22987bb117ac5e3c90ccaf2a4e83251 (diff) | |
download | chromium_src-264513d9881a9e5599c67a9dded5020d06872dbd.zip chromium_src-264513d9881a9e5599c67a9dded5020d06872dbd.tar.gz chromium_src-264513d9881a9e5599c67a9dded5020d06872dbd.tar.bz2 |
Read the port number used by RDP from the registry.
BUG=241214
Review URL: https://chromiumcodereview.appspot.com/14896007
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@200424 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'remoting')
-rw-r--r-- | remoting/host/win/rdp_client.cc | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/remoting/host/win/rdp_client.cc b/remoting/host/win/rdp_client.cc index a154816..8838398 100644 --- a/remoting/host/win/rdp_client.cc +++ b/remoting/host/win/rdp_client.cc @@ -13,6 +13,7 @@ #include "base/logging.h" #include "base/rand_util.h" #include "base/single_thread_task_runner.h" +#include "base/win/registry.h" #include "net/base/ip_endpoint.h" #include "net/base/net_util.h" #include "remoting/base/typed_buffer.h" @@ -28,7 +29,12 @@ namespace { const int kMinLoopbackAddress = 0x7f000002; const int kMaxLoopbackAddress = 0x7ffffffe; -const int kRdpPort = 3389; +const int kDefaultRdpPort = 3389; + +// The port number used by RDP is stored in the registry. +const wchar_t kRdpPortKeyName[] = L"SYSTEM\\CurrentControlSet\\Control\\" + L"Terminal Server\\WinStations\\RDP-Tcp"; +const wchar_t kRdpPortValueName[] = L"PortNumber"; } // namespace @@ -155,10 +161,18 @@ void RdpClient::Core::Connect(const SkISize& screen_size) { GetProcAddress(iphlpapi_handle, "GetExtendedTcpTable")); CHECK(get_extended_tcp_table_); + // Read the port number used by RDP. + DWORD port; + base::win::RegKey key(HKEY_LOCAL_MACHINE, kRdpPortKeyName, KEY_READ); + if (!key.Valid() || + (key.ReadValueDW(kRdpPortValueName, &port) != ERROR_SUCCESS)) { + port = kDefaultRdpPort; + } + // Generate a random loopback address to connect to. memset(&server_address_, 0, sizeof(server_address_)); server_address_.sin_family = AF_INET; - server_address_.sin_port = htons(kRdpPort); + server_address_.sin_port = htons(port); server_address_.sin_addr.S_un.S_addr = htonl( base::RandInt(kMinLoopbackAddress, kMaxLoopbackAddress)); |