@@ -45,9 +45,6 @@ EXTERN_C HANDLE WINAPI VmbusPipeClientTryOpenChannel(
45
45
46
46
namespace
47
47
{
48
- static std::string g_ServerHost = " 127.0.0.1" ;
49
- static std::string g_ServerPort = " 3389" ;
50
-
51
48
static SERVICE_STATUS_HANDLE volatile g_ServiceStatusHandle = nullptr ;
52
49
static bool volatile g_ServiceIsRunning = true ;
53
50
}
@@ -56,6 +53,43 @@ SOCKET SynthRdpConnectToServer()
56
53
{
57
54
SOCKET Result = INVALID_SOCKET;
58
55
56
+ std::string ServerHost = " 127.0.0.1" ;
57
+ {
58
+ std::wstring Buffer (32767 , L' \0 ' );
59
+ DWORD Length = static_cast <DWORD>(Buffer.size ());
60
+ if (ERROR_SUCCESS == ::RegGetValueW (
61
+ HKEY_LOCAL_MACHINE,
62
+ L" SYSTEM\\ CurrentControlSet\\ Services\\ "
63
+ L" SynthRdp\\ Configurations" ,
64
+ L" ServerHost" ,
65
+ RRF_RT_REG_SZ | RRF_SUBKEY_WOW6464KEY,
66
+ nullptr ,
67
+ const_cast <wchar_t *>(Buffer.c_str ()),
68
+ &Length))
69
+ {
70
+ Buffer.resize (std::wcslen (Buffer.c_str ()));
71
+ ServerHost = Mile::ToString (CP_UTF8, Buffer);
72
+ }
73
+ }
74
+
75
+ std::string ServerPort = " 3389" ;
76
+ {
77
+ DWORD Data = 0 ;
78
+ DWORD Length = sizeof (DWORD);
79
+ if (ERROR_SUCCESS == ::RegGetValueW (
80
+ HKEY_LOCAL_MACHINE,
81
+ L" SYSTEM\\ CurrentControlSet\\ Services\\ "
82
+ L" SynthRdp\\ Configurations" ,
83
+ L" ServerPort" ,
84
+ RRF_RT_REG_DWORD | RRF_SUBKEY_WOW6464KEY,
85
+ nullptr ,
86
+ &Data,
87
+ &Length))
88
+ {
89
+ ServerPort = Mile::FormatString (" %hu" , Data);
90
+ }
91
+ }
92
+
59
93
int LastError = 0 ;
60
94
61
95
addrinfo AddressHints = { 0 };
@@ -64,8 +98,8 @@ SOCKET SynthRdpConnectToServer()
64
98
AddressHints.ai_protocol = IPPROTO_TCP;
65
99
addrinfo* AddressInfo = nullptr ;
66
100
LastError = ::getaddrinfo (
67
- g_ServerHost .c_str (),
68
- g_ServerPort .c_str (),
101
+ ServerHost .c_str (),
102
+ ServerPort .c_str (),
69
103
&AddressHints,
70
104
&AddressInfo);
71
105
if (0 == LastError)
0 commit comments