Skip to content

Commit aebe974

Browse files
hardeningakallabeth
authored andcommitted
[client,win32] Child session fixes
It seems like WaitFor[Single|Multiple]Object calls aren't reliable on pipes, especially on the pipe opened for childSession access. The object can be marked as signaled even if no data is available, making the connection laggy and unresponsive (nearly unusable in some cases). This patch works around that by using ReadFileEx() with overlapped instead of simple ReadFile() and use asynchronous reads.
1 parent 96c090f commit aebe974

File tree

5 files changed

+233
-30
lines changed

5 files changed

+233
-30
lines changed

client/Windows/wf_client.c

+4-2
Original file line numberDiff line numberDiff line change
@@ -1022,7 +1022,7 @@ static DWORD WINAPI wf_client_thread(LPVOID lpParam)
10221022
rdpSettings* settings = context->settings;
10231023
WINPR_ASSERT(settings);
10241024

1025-
while (1)
1025+
while (!freerdp_shall_disconnect_context(instance->context))
10261026
{
10271027
HANDLE handles[MAXIMUM_WAIT_OBJECTS] = { 0 };
10281028
DWORD nCount = 0;
@@ -1045,7 +1045,9 @@ static DWORD WINAPI wf_client_thread(LPVOID lpParam)
10451045
nCount += tmp;
10461046
}
10471047

1048-
if (MsgWaitForMultipleObjects(nCount, handles, FALSE, 1000, QS_ALLINPUT) == WAIT_FAILED)
1048+
DWORD status = MsgWaitForMultipleObjectsEx(nCount, handles, 5 * 1000, QS_ALLINPUT,
1049+
MWMO_ALERTABLE | MWMO_INPUTAVAILABLE);
1050+
if (status == WAIT_FAILED)
10491051
{
10501052
WLog_ERR(TAG, "wfreerdp_run: WaitForMultipleObjects failed: 0x%08lX", GetLastError());
10511053
break;

client/common/cmdline.c

+4-1
Original file line numberDiff line numberDiff line change
@@ -4753,11 +4753,14 @@ static int freerdp_client_settings_parse_command_line_arguments_int(
47534753
"vs-debug") ||
47544754
!freerdp_settings_set_string(settings, FreeRDP_ServerHostname, "localhost") ||
47554755
!freerdp_settings_set_string(settings, FreeRDP_AuthenticationPackageList, "ntlm") ||
4756+
!freerdp_settings_set_string(settings, FreeRDP_ClientAddress, "0.0.0.0") ||
47564757
!freerdp_settings_set_bool(settings, FreeRDP_NegotiateSecurityLayer, FALSE) ||
47574758
!freerdp_settings_set_bool(settings, FreeRDP_VmConnectMode, TRUE) ||
47584759
!freerdp_settings_set_bool(settings, FreeRDP_ConnectChildSession, TRUE) ||
47594760
!freerdp_settings_set_bool(settings, FreeRDP_NlaSecurity, TRUE) ||
4760-
!freerdp_settings_set_uint32(settings, FreeRDP_AuthenticationLevel, 0))
4761+
!freerdp_settings_set_uint32(settings, FreeRDP_AuthenticationLevel, 0) ||
4762+
!freerdp_settings_set_bool(settings, FreeRDP_NetworkAutoDetect, TRUE) ||
4763+
!freerdp_settings_set_uint32(settings, FreeRDP_ConnectionType, CONNECTION_TYPE_LAN))
47614764
return COMMAND_LINE_ERROR_MEMORY;
47624765
}
47634766
#endif

0 commit comments

Comments
 (0)