From 13e52cfae29f402735110cabc8a4cb7664a64bd0 Mon Sep 17 00:00:00 2001 From: Richard Markiewicz Date: Fri, 21 Apr 2023 13:25:14 -0400 Subject: [PATCH] [channels,settings] add a setting to ignore invalid devices --- channels/rdpdr/client/irp.c | 2 +- channels/rdpdr/client/rdpdr_main.c | 4 +++- channels/rdpdr/client/rdpdr_main.h | 1 + include/freerdp/settings.h | 4 +++- libfreerdp/common/settings_getters.c | 7 +++++++ libfreerdp/common/settings_str.c | 1 + libfreerdp/core/test/settings_property_lists.h | 1 + 7 files changed, 17 insertions(+), 3 deletions(-) diff --git a/channels/rdpdr/client/irp.c b/channels/rdpdr/client/irp.c index c3ff325dd..8da260f11 100644 --- a/channels/rdpdr/client/irp.c +++ b/channels/rdpdr/client/irp.c @@ -107,7 +107,7 @@ IRP* irp_new(DEVMAN* devman, wStreamPool* pool, wStream* s, wLog* log, UINT* err if (!device) { if (error) - *error = ERROR_INVALID_PARAMETER; + *error = ERROR_DEV_NOT_EXIST; return NULL; } diff --git a/channels/rdpdr/client/rdpdr_main.c b/channels/rdpdr/client/rdpdr_main.c index 1b562f1f6..779adaeab 100644 --- a/channels/rdpdr/client/rdpdr_main.c +++ b/channels/rdpdr/client/rdpdr_main.c @@ -1067,6 +1067,8 @@ static UINT rdpdr_process_connect(rdpdrPlugin* rdpdr) settings = rdpdr->rdpcontext->settings; WINPR_ASSERT(settings); + rdpdr->ignoreInvalidDevices = settings->IgnoreInvalidDevices; + if (settings->ClientHostname) strncpy(rdpdr->computerName, settings->ClientHostname, sizeof(rdpdr->computerName) - 1); else @@ -1411,7 +1413,7 @@ static UINT rdpdr_process_irp(rdpdrPlugin* rdpdr, wStream* s) { WLog_Print(rdpdr->log, WLOG_ERROR, "irp_new failed with %" PRIu32 "!", error); - if (error == CHANNEL_RC_OK) + if (error == CHANNEL_RC_OK || (error == ERROR_DEV_NOT_EXIST && rdpdr->ignoreInvalidDevices)) { return dummy_irp_response(rdpdr, s); } diff --git a/channels/rdpdr/client/rdpdr_main.h b/channels/rdpdr/client/rdpdr_main.h index 06c666166..d2b290652 100644 --- a/channels/rdpdr/client/rdpdr_main.h +++ b/channels/rdpdr/client/rdpdr_main.h @@ -54,6 +54,7 @@ typedef struct wMessageQueue* queue; DEVMAN* devman; + BOOL ignoreInvalidDevices; UINT16 serverVersionMajor; UINT16 serverVersionMinor; diff --git a/include/freerdp/settings.h b/include/freerdp/settings.h index bcd7c2da0..5feabb0b6 100644 --- a/include/freerdp/settings.h +++ b/include/freerdp/settings.h @@ -875,6 +875,7 @@ typedef struct #define FreeRDP_DeviceCount (4161) #define FreeRDP_DeviceArraySize (4162) #define FreeRDP_DeviceArray (4163) +#define FreeRDP_IgnoreInvalidDevices (4164) #define FreeRDP_RedirectDrives (4288) #define FreeRDP_RedirectHomeDrive (4289) #define FreeRDP_DrivesToRedirect (4290) @@ -1569,7 +1570,8 @@ struct rdp_settings ALIGN64 UINT32 DeviceCount; /* 4161 */ ALIGN64 UINT32 DeviceArraySize; /* 4162 */ ALIGN64 RDPDR_DEVICE** DeviceArray; /* 4163 */ - UINT64 padding4288[4288 - 4164]; /* 4164 */ + ALIGN64 BOOL IgnoreInvalidDevices; /* 4164 */ + UINT64 padding4288[4288 - 4165]; /* 4165 */ /* Drive Redirection */ ALIGN64 BOOL RedirectDrives; /* 4288 */ diff --git a/libfreerdp/common/settings_getters.c b/libfreerdp/common/settings_getters.c index a17f2ad22..5194e9ce5 100644 --- a/libfreerdp/common/settings_getters.c +++ b/libfreerdp/common/settings_getters.c @@ -306,6 +306,9 @@ BOOL freerdp_settings_get_bool(const rdpSettings* settings, size_t id) case FreeRDP_IgnoreCertificate: return settings->IgnoreCertificate; + case FreeRDP_IgnoreInvalidDevices: + return settings->IgnoreInvalidDevices; + case FreeRDP_JpegCodec: return settings->JpegCodec; @@ -949,6 +952,10 @@ BOOL freerdp_settings_set_bool(rdpSettings* settings, size_t id, BOOL val) settings->IgnoreCertificate = cnv.c; break; + case FreeRDP_IgnoreInvalidDevices: + settings->IgnoreInvalidDevices = cnv.c; + break; + case FreeRDP_JpegCodec: settings->JpegCodec = cnv.c; break; diff --git a/libfreerdp/common/settings_str.c b/libfreerdp/common/settings_str.c index 1da97e31a..3d0421250 100644 --- a/libfreerdp/common/settings_str.c +++ b/libfreerdp/common/settings_str.c @@ -130,6 +130,7 @@ static const struct settings_str_entry settings_map[] = { { FreeRDP_HiDefRemoteApp, FREERDP_SETTINGS_TYPE_BOOL, "FreeRDP_HiDefRemoteApp" }, { FreeRDP_IPv6Enabled, FREERDP_SETTINGS_TYPE_BOOL, "FreeRDP_IPv6Enabled" }, { FreeRDP_IgnoreCertificate, FREERDP_SETTINGS_TYPE_BOOL, "FreeRDP_IgnoreCertificate" }, + { FreeRDP_IgnoreInvalidDevices, FREERDP_SETTINGS_TYPE_BOOL, "FreeRDP_IgnoreInvalidDevices" }, { FreeRDP_JpegCodec, FREERDP_SETTINGS_TYPE_BOOL, "FreeRDP_JpegCodec" }, { FreeRDP_KerberosRdgIsProxy, FREERDP_SETTINGS_TYPE_BOOL, "FreeRDP_KerberosRdgIsProxy" }, { FreeRDP_ListMonitors, FREERDP_SETTINGS_TYPE_BOOL, "FreeRDP_ListMonitors" }, diff --git a/libfreerdp/core/test/settings_property_lists.h b/libfreerdp/core/test/settings_property_lists.h index d5e1df279..43672c7ae 100644 --- a/libfreerdp/core/test/settings_property_lists.h +++ b/libfreerdp/core/test/settings_property_lists.h @@ -86,6 +86,7 @@ static const size_t bool_list_indices[] = { FreeRDP_HiDefRemoteApp, FreeRDP_IPv6Enabled, FreeRDP_IgnoreCertificate, + FreeRDP_IgnoreInvalidDevices, FreeRDP_JpegCodec, FreeRDP_KerberosRdgIsProxy, FreeRDP_ListMonitors,