diff --git a/.clang-tidy b/.clang-tidy index f8a7209b6..e017b0ee7 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -48,6 +48,7 @@ Checks: > -llvm-else-after-return, -readability-else-after-return, -modernize-use-trailing-return-type, + -modernize-return-braced-init-list, -modernize-macro-to-enum, -readability-braces-around-statements, -readability-function-cognitive-complexity, diff --git a/channels/ainput/client/ainput_main.c b/channels/ainput/client/ainput_main.c index 1a2128dcc..51d912ad3 100644 --- a/channels/ainput/client/ainput_main.c +++ b/channels/ainput/client/ainput_main.c @@ -175,7 +175,7 @@ static const IWTSVirtualChannelCallback ainput_functions = { ainput_on_data_rece * * @return 0 on success, otherwise a Win32 error code */ -FREERDP_ENTRY_POINT(UINT ainput_DVCPluginEntry(IDRDYNVC_ENTRY_POINTS* pEntryPoints)) +FREERDP_ENTRY_POINT(UINT VCAPITYPE ainput_DVCPluginEntry(IDRDYNVC_ENTRY_POINTS* pEntryPoints)) { return freerdp_generic_DVCPluginEntry(pEntryPoints, TAG, AINPUT_DVC_CHANNEL_NAME, sizeof(AINPUT_PLUGIN), sizeof(GENERIC_CHANNEL_CALLBACK), diff --git a/channels/audin/client/alsa/audin_alsa.c b/channels/audin/client/alsa/audin_alsa.c index 47d5d5561..f666d6457 100644 --- a/channels/audin/client/alsa/audin_alsa.c +++ b/channels/audin/client/alsa/audin_alsa.c @@ -392,8 +392,8 @@ static UINT audin_alsa_parse_addin_args(AudinALSADevice* device, const ADDIN_ARG * * @return 0 on success, otherwise a Win32 error code */ -FREERDP_ENTRY_POINT( - UINT alsa_freerdp_audin_client_subsystem_entry(PFREERDP_AUDIN_DEVICE_ENTRY_POINTS pEntryPoints)) +FREERDP_ENTRY_POINT(UINT VCAPITYPE alsa_freerdp_audin_client_subsystem_entry( + PFREERDP_AUDIN_DEVICE_ENTRY_POINTS pEntryPoints)) { const ADDIN_ARGV* args = NULL; AudinALSADevice* alsa = NULL; diff --git a/channels/audin/client/audin_main.c b/channels/audin/client/audin_main.c index 1578d26ac..8f9002641 100644 --- a/channels/audin/client/audin_main.c +++ b/channels/audin/client/audin_main.c @@ -810,11 +810,15 @@ static UINT audin_load_device_plugin(AUDIN_PLUGIN* audin, const char* name, cons FREERDP_AUDIN_DEVICE_ENTRY_POINTS entryPoints = { 0 }; UINT error = ERROR_INTERNAL_ERROR; - const PFREERDP_AUDIN_DEVICE_ENTRY entry = - (const PFREERDP_AUDIN_DEVICE_ENTRY)freerdp_load_channel_addin_entry(AUDIN_CHANNEL_NAME, - name, NULL, 0); - if (entry == NULL) + union + { + PVIRTUALCHANNELENTRY pvce; + PFREERDP_AUDIN_DEVICE_ENTRY entry; + } cnv; + cnv.pvce = freerdp_load_channel_addin_entry(AUDIN_CHANNEL_NAME, name, NULL, 0); + + if (cnv.entry == NULL) { WLog_Print(audin->log, WLOG_ERROR, "freerdp_load_channel_addin_entry did not return any function pointers for %s ", @@ -827,7 +831,8 @@ static UINT audin_load_device_plugin(AUDIN_PLUGIN* audin, const char* name, cons entryPoints.args = args; entryPoints.rdpcontext = audin->rdpcontext; - if ((error = entry(&entryPoints))) + error = cnv.entry(&entryPoints); + if (error) { WLog_Print(audin->log, WLOG_ERROR, "%s entry returned error %" PRIu32 ".", name, error); return error; @@ -968,7 +973,7 @@ BOOL audin_process_addin_args(AUDIN_PLUGIN* audin, const ADDIN_ARGV* args) * * @return 0 on success, otherwise a Win32 error code */ -FREERDP_ENTRY_POINT(UINT audin_DVCPluginEntry(IDRDYNVC_ENTRY_POINTS* pEntryPoints)) +FREERDP_ENTRY_POINT(UINT VCAPITYPE audin_DVCPluginEntry(IDRDYNVC_ENTRY_POINTS* pEntryPoints)) { struct SubsystemEntry { diff --git a/channels/audin/client/ios/audin_ios.m b/channels/audin/client/ios/audin_ios.m index ae30aee71..30819858e 100644 --- a/channels/audin/client/ios/audin_ios.m +++ b/channels/audin/client/ios/audin_ios.m @@ -295,8 +295,8 @@ static UINT audin_ios_free(IAudinDevice *device) return CHANNEL_RC_OK; } -FREERDP_ENTRY_POINT( - UINT ios_freerdp_audin_client_subsystem_entry(PFREERDP_AUDIN_DEVICE_ENTRY_POINTS pEntryPoints)) +FREERDP_ENTRY_POINT(UINT VCAPITYPE ios_freerdp_audin_client_subsystem_entry( + PFREERDP_AUDIN_DEVICE_ENTRY_POINTS pEntryPoints)) { DWORD errCode; char errString[1024]; diff --git a/channels/audin/client/mac/audin_mac.m b/channels/audin/client/mac/audin_mac.m index 19749a966..346d85945 100644 --- a/channels/audin/client/mac/audin_mac.m +++ b/channels/audin/client/mac/audin_mac.m @@ -380,8 +380,8 @@ static UINT audin_mac_parse_addin_args(AudinMacDevice *device, const ADDIN_ARGV return CHANNEL_RC_OK; } -FREERDP_ENTRY_POINT( - UINT mac_freerdp_audin_client_subsystem_entry(PFREERDP_AUDIN_DEVICE_ENTRY_POINTS pEntryPoints)) +FREERDP_ENTRY_POINT(UINT VCAPITYPE mac_freerdp_audin_client_subsystem_entry( + PFREERDP_AUDIN_DEVICE_ENTRY_POINTS pEntryPoints)) { DWORD errCode; char errString[1024]; diff --git a/channels/audin/client/opensles/audin_opensl_es.c b/channels/audin/client/opensles/audin_opensl_es.c index a59fe0562..9885b033a 100644 --- a/channels/audin/client/opensles/audin_opensl_es.c +++ b/channels/audin/client/opensles/audin_opensl_es.c @@ -292,7 +292,7 @@ static UINT audin_opensles_parse_addin_args(AudinOpenSLESDevice* device, const A * * @return 0 on success, otherwise a Win32 error code */ -FREERDP_ENTRY_POINT(UINT opensles_freerdp_audin_client_subsystem_entry( +FREERDP_ENTRY_POINT(UINT VCAPITYPE opensles_freerdp_audin_client_subsystem_entry( PFREERDP_AUDIN_DEVICE_ENTRY_POINTS pEntryPoints)) { const ADDIN_ARGV* args; diff --git a/channels/audin/client/oss/audin_oss.c b/channels/audin/client/oss/audin_oss.c index fadff6c7d..ca14dd593 100644 --- a/channels/audin/client/oss/audin_oss.c +++ b/channels/audin/client/oss/audin_oss.c @@ -445,8 +445,8 @@ static UINT audin_oss_parse_addin_args(AudinOSSDevice* device, const ADDIN_ARGV* * * @return 0 on success, otherwise a Win32 error code */ -FREERDP_ENTRY_POINT( - UINT oss_freerdp_audin_client_subsystem_entry(PFREERDP_AUDIN_DEVICE_ENTRY_POINTS pEntryPoints)) +FREERDP_ENTRY_POINT(UINT VCAPITYPE oss_freerdp_audin_client_subsystem_entry( + PFREERDP_AUDIN_DEVICE_ENTRY_POINTS pEntryPoints)) { const ADDIN_ARGV* args = NULL; AudinOSSDevice* oss = NULL; diff --git a/channels/audin/client/pulse/audin_pulse.c b/channels/audin/client/pulse/audin_pulse.c index c2cb3fc7d..0f178f7fe 100644 --- a/channels/audin/client/pulse/audin_pulse.c +++ b/channels/audin/client/pulse/audin_pulse.c @@ -490,7 +490,7 @@ static UINT audin_pulse_parse_addin_args(AudinPulseDevice* device, const ADDIN_A * * @return 0 on success, otherwise a Win32 error code */ -FREERDP_ENTRY_POINT(UINT pulse_freerdp_audin_client_subsystem_entry( +FREERDP_ENTRY_POINT(UINT VCAPITYPE pulse_freerdp_audin_client_subsystem_entry( PFREERDP_AUDIN_DEVICE_ENTRY_POINTS pEntryPoints)) { const ADDIN_ARGV* args = NULL; diff --git a/channels/audin/client/sndio/audin_sndio.c b/channels/audin/client/sndio/audin_sndio.c index 92dac1385..f7c6a8a39 100644 --- a/channels/audin/client/sndio/audin_sndio.c +++ b/channels/audin/client/sndio/audin_sndio.c @@ -309,7 +309,7 @@ static UINT audin_sndio_parse_addin_args(AudinSndioDevice* device, ADDIN_ARGV* a * * @return 0 on success, otherwise a Win32 error code */ -FREERDP_ENTRY_POINT(UINT sndio_freerdp_audin_client_subsystem_entry( +FREERDP_ENTRY_POINT(UINT VCAPITYPE sndio_freerdp_audin_client_subsystem_entry( PFREERDP_AUDIN_DEVICE_ENTRY_POINTS pEntryPoints)) { ADDIN_ARGV* args; diff --git a/channels/audin/client/winmm/audin_winmm.c b/channels/audin/client/winmm/audin_winmm.c index b4172a516..82b19e51e 100644 --- a/channels/audin/client/winmm/audin_winmm.c +++ b/channels/audin/client/winmm/audin_winmm.c @@ -29,6 +29,7 @@ #include #include +#include #include #include #include @@ -491,7 +492,7 @@ static UINT audin_winmm_parse_addin_args(AudinWinmmDevice* device, const ADDIN_A * * @return 0 on success, otherwise a Win32 error code */ -FREERDP_ENTRY_POINT(UINT winmm_freerdp_audin_client_subsystem_entry( +FREERDP_ENTRY_POINT(UINT VCAPITYPE winmm_freerdp_audin_client_subsystem_entry( PFREERDP_AUDIN_DEVICE_ENTRY_POINTS pEntryPoints)) { const ADDIN_ARGV* args; diff --git a/channels/client/CMakeLists.txt b/channels/client/CMakeLists.txt index 923683ae3..1d02d8264 100644 --- a/channels/client/CMakeLists.txt +++ b/channels/client/CMakeLists.txt @@ -2,6 +2,8 @@ # FreeRDP cmake build script # # Copyright 2012 Marc-Andre Moreau +# Copyright 2024 Armin Novak +# Copyright 2024 Thincast Technologies GmbH # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -29,23 +31,13 @@ if(CHANNEL_STATIC_CLIENT_ENTRIES) list(REMOVE_DUPLICATES CHANNEL_STATIC_CLIENT_ENTRIES) endif() -set(CLIENT_STATIC_TYPEDEFS "#if __GNUC__\n") -set(CLIENT_STATIC_TYPEDEFS "${CLIENT_STATIC_TYPEDEFS}#pragma GCC diagnostic push\n") -set(CLIENT_STATIC_TYPEDEFS "${CLIENT_STATIC_TYPEDEFS}#pragma GCC diagnostic ignored \"-Wstrict-prototypes\"\n") -set(CLIENT_STATIC_TYPEDEFS "${CLIENT_STATIC_TYPEDEFS}#endif\n") -set(CLIENT_STATIC_TYPEDEFS "${CLIENT_STATIC_TYPEDEFS}typedef UINT (*static_entry_fkt)();\n") -set(CLIENT_STATIC_TYPEDEFS "${CLIENT_STATIC_TYPEDEFS}typedef UINT (*static_addin_fkt)();\n") -set(CLIENT_STATIC_TYPEDEFS "${CLIENT_STATIC_TYPEDEFS}#if __GNUC__\n") - set(CLIENT_STATIC_TYPEDEFS "${CLIENT_STATIC_TYPEDEFS}#pragma GCC diagnostic pop\n") - set(CLIENT_STATIC_TYPEDEFS "${CLIENT_STATIC_TYPEDEFS}#endif\n") - foreach(STATIC_ENTRY ${CHANNEL_STATIC_CLIENT_ENTRIES}) foreach(STATIC_MODULE ${CHANNEL_STATIC_CLIENT_MODULES}) foreach(ENTRY ${${STATIC_MODULE}_CLIENT_ENTRY}) if(${ENTRY} STREQUAL ${STATIC_ENTRY}) set(STATIC_MODULE_NAME ${${STATIC_MODULE}_CLIENT_NAME}) set(STATIC_MODULE_CHANNEL ${${STATIC_MODULE}_CLIENT_CHANNEL}) - set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} ${STATIC_MODULE_NAME}) + list(APPEND ${MODULE_PREFIX}_LIBS ${STATIC_MODULE_NAME}) set(ENTRY_POINT_NAME "${STATIC_MODULE_CHANNEL}_${ENTRY}") if(${ENTRY} STREQUAL "VirtualChannelEntry") @@ -53,14 +45,15 @@ foreach(STATIC_ENTRY ${CHANNEL_STATIC_CLIENT_ENTRIES}) elseif(${ENTRY} STREQUAL "VirtualChannelEntryEx") set(ENTRY_POINT_IMPORT "extern BOOL VCAPITYPE ${ENTRY_POINT_NAME}(PCHANNEL_ENTRY_POINTS,PVOID);") elseif(${ENTRY} MATCHES "DVCPluginEntry$") - set(ENTRY_POINT_IMPORT "extern UINT ${ENTRY_POINT_NAME}(IDRDYNVC_ENTRY_POINTS* pEntryPoints);") + set(ENTRY_POINT_IMPORT "extern UINT VCAPITYPE ${ENTRY_POINT_NAME}(IDRDYNVC_ENTRY_POINTS* pEntryPoints);") elseif(${ENTRY} MATCHES "DeviceServiceEntry$") - set(ENTRY_POINT_IMPORT "extern UINT ${ENTRY_POINT_NAME}(PDEVICE_SERVICE_ENTRY_POINTS pEntryPoints);") + set(ENTRY_POINT_IMPORT "extern UINT VCAPITYPE ${ENTRY_POINT_NAME}(PDEVICE_SERVICE_ENTRY_POINTS pEntryPoints);") else() - set(ENTRY_POINT_IMPORT "extern UINT ${ENTRY_POINT_NAME}(void);") + set(ENTRY_POINT_IMPORT "extern UINT VCAPITYPE ${ENTRY_POINT_NAME}(void);") endif() - set(${STATIC_ENTRY}_IMPORTS "${${STATIC_ENTRY}_IMPORTS}\n${ENTRY_POINT_IMPORT}") - set(${STATIC_ENTRY}_TABLE "${${STATIC_ENTRY}_TABLE}\n\t{ \"${STATIC_MODULE_CHANNEL}\", (static_entry_fkt)${ENTRY_POINT_NAME} },") + + string(APPEND ${STATIC_ENTRY}_IMPORTS "\n${ENTRY_POINT_IMPORT}") + string(APPEND ${STATIC_ENTRY}_TABLE "\n\t{ \"${STATIC_MODULE_CHANNEL}\", ${ENTRY_POINT_NAME} },") endif() endforeach() endforeach() @@ -105,14 +98,14 @@ foreach(STATIC_MODULE ${CHANNEL_STATIC_CLIENT_MODULES}) set(STATIC_SUBSYSTEM_ENTRY "${STATIC_SUBSYSTEM_NAME}_freerdp_${STATIC_MODULE_CHANNEL}_client_subsystem_entry") endif() set(SUBSYSTEM_TABLE "${SUBSYSTEM_TABLE}\n\t{ \"${STATIC_SUBSYSTEM_NAME}\", \"${STATIC_SUBSYSTEM_TYPE}\", ${STATIC_SUBSYSTEM_ENTRY} },") - set(SUBSYSTEM_IMPORT "extern UINT ${STATIC_SUBSYSTEM_ENTRY}(void*);") + set(SUBSYSTEM_IMPORT "extern UINT VCAPITYPE ${STATIC_SUBSYSTEM_ENTRY}(void*);") set(CLIENT_STATIC_SUBSYSTEM_IMPORTS "${CLIENT_STATIC_SUBSYSTEM_IMPORTS}\n${SUBSYSTEM_IMPORT}") endforeach() set(SUBSYSTEM_TABLE "${SUBSYSTEM_TABLE}\n\t{ NULL, NULL, NULL }\n};") set(CLIENT_STATIC_SUBSYSTEM_TABLES "${CLIENT_STATIC_SUBSYSTEM_TABLES}\n${SUBSYSTEM_TABLE}") foreach(ENTRY ${${STATIC_MODULE}_CLIENT_ENTRY}) set (ENTRY_POINT_NAME ${STATIC_MODULE_CHANNEL}_${ENTRY}) - set(CLIENT_STATIC_ADDIN_TABLE "${CLIENT_STATIC_ADDIN_TABLE}\n\t{ \"${STATIC_MODULE_CHANNEL}\", \"${ENTRY}\", (static_addin_fkt)${ENTRY_POINT_NAME}, ${SUBSYSTEM_TABLE_NAME} },") + set(CLIENT_STATIC_ADDIN_TABLE "${CLIENT_STATIC_ADDIN_TABLE}\n\t{ \"${STATIC_MODULE_CHANNEL}\", \"${ENTRY}\", ${ENTRY_POINT_NAME}, ${SUBSYSTEM_TABLE_NAME} },") endforeach() endforeach() set(CLIENT_STATIC_ADDIN_TABLE "${CLIENT_STATIC_ADDIN_TABLE}\n\t{ NULL, NULL, NULL, NULL }\n};") diff --git a/channels/client/addin.c b/channels/client/addin.c index 1b1d9d692..0c35a7d16 100644 --- a/channels/client/addin.c +++ b/channels/client/addin.c @@ -57,7 +57,7 @@ static void* freerdp_channels_find_static_entry_in_table(const STATIC_ENTRY_TABL union { void* pv; - UINT (*entry)(); + static_entry_fn_t entry; } cnv; cnv.entry = pEntry->entry; return cnv.pv; diff --git a/channels/client/tables.c.in b/channels/client/tables.c.in index a22621b32..2c34a30ee 100644 --- a/channels/client/tables.c.in +++ b/channels/client/tables.c.in @@ -25,9 +25,9 @@ ${CLIENT_STATIC_TYPEDEFS} ${CLIENT_STATIC_ENTRY_IMPORTS} +${CLIENT_STATIC_SUBSYSTEM_IMPORTS} ${CLIENT_STATIC_ENTRY_TABLES} ${CLIENT_STATIC_ENTRY_TABLES_LIST} -${CLIENT_STATIC_SUBSYSTEM_IMPORTS} ${CLIENT_STATIC_SUBSYSTEM_TABLES} ${CLIENT_STATIC_ADDIN_TABLE} diff --git a/channels/client/tables.h b/channels/client/tables.h index e67beb546..6f629fb05 100644 --- a/channels/client/tables.h +++ b/channels/client/tables.h @@ -18,16 +18,18 @@ */ #include +#include #include /* The 'entry' function pointers have variable arguments. */ WINPR_PRAGMA_DIAG_PUSH WINPR_PRAGMA_DIAG_IGNORED_STRICT_PROTOTYPES +typedef UINT(VCAPITYPE* static_entry_fn_t)(); typedef struct { const char* name; - UINT (*entry)(); + static_entry_fn_t entry; } STATIC_ENTRY; typedef struct @@ -36,18 +38,20 @@ typedef struct const STATIC_ENTRY* table; } STATIC_ENTRY_TABLE; +typedef UINT(VCAPITYPE* static_subsystem_entry_fn_t)(); typedef struct { const char* name; const char* type; - UINT (*entry)(); + static_subsystem_entry_fn_t entry; } STATIC_SUBSYSTEM_ENTRY; +typedef UINT(VCAPITYPE* static_addin_entry_fn_t)(); typedef struct { const char* name; const char* type; - UINT (*entry)(); + static_addin_entry_fn_t entry; const STATIC_SUBSYSTEM_ENTRY* table; } STATIC_ADDIN_TABLE; diff --git a/channels/disp/client/disp_main.c b/channels/disp/client/disp_main.c index f01824013..144927962 100644 --- a/channels/disp/client/disp_main.c +++ b/channels/disp/client/disp_main.c @@ -314,7 +314,7 @@ static const IWTSVirtualChannelCallback disp_callbacks = { disp_on_data_received * * @return 0 on success, otherwise a Win32 error code */ -FREERDP_ENTRY_POINT(UINT disp_DVCPluginEntry(IDRDYNVC_ENTRY_POINTS* pEntryPoints)) +FREERDP_ENTRY_POINT(UINT VCAPITYPE disp_DVCPluginEntry(IDRDYNVC_ENTRY_POINTS* pEntryPoints)) { return freerdp_generic_DVCPluginEntry(pEntryPoints, TAG, DISP_DVC_CHANNEL_NAME, sizeof(DISP_PLUGIN), sizeof(GENERIC_CHANNEL_CALLBACK), diff --git a/channels/drdynvc/client/drdynvc_main.c b/channels/drdynvc/client/drdynvc_main.c index e454e895d..16b15836d 100644 --- a/channels/drdynvc/client/drdynvc_main.c +++ b/channels/drdynvc/client/drdynvc_main.c @@ -352,18 +352,22 @@ fail: static UINT dvcman_load_addin(drdynvcPlugin* drdynvc, IWTSVirtualChannelManager* pChannelMgr, const ADDIN_ARGV* args, rdpContext* context) { - PDVC_PLUGIN_ENTRY pDVCPluginEntry = NULL; - WINPR_ASSERT(drdynvc); WINPR_ASSERT(pChannelMgr); WINPR_ASSERT(args); WINPR_ASSERT(context); WLog_Print(drdynvc->log, WLOG_INFO, "Loading Dynamic Virtual Channel %s", args->argv[0]); - pDVCPluginEntry = (PDVC_PLUGIN_ENTRY)freerdp_load_channel_addin_entry( - args->argv[0], NULL, NULL, FREERDP_ADDIN_CHANNEL_DYNAMIC); - if (pDVCPluginEntry) + union + { + PVIRTUALCHANNELENTRY pvce; + PDVC_PLUGIN_ENTRY pDVCPluginEntry; + } cnv; + cnv.pvce = + freerdp_load_channel_addin_entry(args->argv[0], NULL, NULL, FREERDP_ADDIN_CHANNEL_DYNAMIC); + + if (cnv.pDVCPluginEntry) { DVCMAN_ENTRY_POINTS entryPoints = { 0 }; @@ -375,7 +379,7 @@ static UINT dvcman_load_addin(drdynvcPlugin* drdynvc, IWTSVirtualChannelManager* entryPoints.dvcman = (DVCMAN*)pChannelMgr; entryPoints.args = args; entryPoints.context = context; - return pDVCPluginEntry(&entryPoints.iface); + return cnv.pDVCPluginEntry(&entryPoints.iface); } return ERROR_INVALID_FUNCTION; diff --git a/channels/drive/client/drive_main.c b/channels/drive/client/drive_main.c index 04f8d837f..089ea2cb7 100644 --- a/channels/drive/client/drive_main.c +++ b/channels/drive/client/drive_main.c @@ -1009,7 +1009,8 @@ out_error: * * @return 0 on success, otherwise a Win32 error code */ -FREERDP_ENTRY_POINT(UINT drive_DeviceServiceEntry(PDEVICE_SERVICE_ENTRY_POINTS pEntryPoints)) +FREERDP_ENTRY_POINT( + UINT VCAPITYPE drive_DeviceServiceEntry(PDEVICE_SERVICE_ENTRY_POINTS pEntryPoints)) { RDPDR_DRIVE* drive = NULL; UINT error = 0; diff --git a/channels/echo/client/echo_main.c b/channels/echo/client/echo_main.c index c4e1c226e..af6baafb5 100644 --- a/channels/echo/client/echo_main.c +++ b/channels/echo/client/echo_main.c @@ -84,7 +84,7 @@ static const IWTSVirtualChannelCallback echo_callbacks = { echo_on_data_received * * @return 0 on success, otherwise a Win32 error code */ -FREERDP_ENTRY_POINT(UINT echo_DVCPluginEntry(IDRDYNVC_ENTRY_POINTS* pEntryPoints)) +FREERDP_ENTRY_POINT(UINT VCAPITYPE echo_DVCPluginEntry(IDRDYNVC_ENTRY_POINTS* pEntryPoints)) { return freerdp_generic_DVCPluginEntry(pEntryPoints, TAG, ECHO_DVC_CHANNEL_NAME, sizeof(ECHO_PLUGIN), sizeof(GENERIC_CHANNEL_CALLBACK), diff --git a/channels/geometry/client/geometry_main.c b/channels/geometry/client/geometry_main.c index 5465fc9fe..d86007592 100644 --- a/channels/geometry/client/geometry_main.c +++ b/channels/geometry/client/geometry_main.c @@ -394,7 +394,7 @@ static void terminate_plugin_cb(GENERIC_DYNVC_PLUGIN* base) * * @return 0 on success, otherwise a Win32 error code */ -FREERDP_ENTRY_POINT(UINT geometry_DVCPluginEntry(IDRDYNVC_ENTRY_POINTS* pEntryPoints)) +FREERDP_ENTRY_POINT(UINT VCAPITYPE geometry_DVCPluginEntry(IDRDYNVC_ENTRY_POINTS* pEntryPoints)) { return freerdp_generic_DVCPluginEntry(pEntryPoints, TAG, GEOMETRY_DVC_CHANNEL_NAME, sizeof(GEOMETRY_PLUGIN), sizeof(GENERIC_CHANNEL_CALLBACK), diff --git a/channels/location/client/location_main.c b/channels/location/client/location_main.c index f84d7fc2e..516cc4131 100644 --- a/channels/location/client/location_main.c +++ b/channels/location/client/location_main.c @@ -465,7 +465,7 @@ static const IWTSVirtualChannelCallback location_callbacks = { location_on_data_ * * @return 0 on success, otherwise a Win32 error code */ -FREERDP_ENTRY_POINT(UINT location_DVCPluginEntry(IDRDYNVC_ENTRY_POINTS* pEntryPoints)) +FREERDP_ENTRY_POINT(UINT VCAPITYPE location_DVCPluginEntry(IDRDYNVC_ENTRY_POINTS* pEntryPoints)) { return freerdp_generic_DVCPluginEntry(pEntryPoints, TAG, LOCATION_DVC_CHANNEL_NAME, sizeof(LOCATION_PLUGIN), sizeof(LOCATION_CALLBACK), diff --git a/channels/parallel/client/parallel_main.c b/channels/parallel/client/parallel_main.c index 740fecf51..1eb2320f6 100644 --- a/channels/parallel/client/parallel_main.c +++ b/channels/parallel/client/parallel_main.c @@ -430,7 +430,8 @@ static void parallel_message_free(void* obj) * * @return 0 on success, otherwise a Win32 error code */ -FREERDP_ENTRY_POINT(UINT parallel_DeviceServiceEntry(PDEVICE_SERVICE_ENTRY_POINTS pEntryPoints)) +FREERDP_ENTRY_POINT( + UINT VCAPITYPE parallel_DeviceServiceEntry(PDEVICE_SERVICE_ENTRY_POINTS pEntryPoints)) { PARALLEL_DEVICE* parallel = NULL; UINT error = 0; diff --git a/channels/printer/client/cups/printer_cups.c b/channels/printer/client/cups/printer_cups.c index 6f996dd95..40464f1e2 100644 --- a/channels/printer/client/cups/printer_cups.c +++ b/channels/printer/client/cups/printer_cups.c @@ -366,7 +366,7 @@ static rdpPrinter** printer_cups_enum_printers(rdpPrinterDriver* driver) if (!printers) return NULL; - for (size_t i = 0; i < num_dests; i++) + for (size_t i = 0; i < (size_t)num_dests; i++) { const cups_dest_t* dest = &dests[i]; if (dest->instance == NULL) @@ -432,7 +432,7 @@ static void printer_cups_release_ref_driver(rdpPrinterDriver* driver) cups_driver->references--; } -FREERDP_ENTRY_POINT(UINT cups_freerdp_printer_client_subsystem_entry(void* arg)) +FREERDP_ENTRY_POINT(UINT VCAPITYPE cups_freerdp_printer_client_subsystem_entry(void* arg)) { rdpPrinterDriver** ppPrinter = (rdpPrinterDriver**)arg; if (!ppPrinter) diff --git a/channels/printer/client/printer_main.c b/channels/printer/client/printer_main.c index b89bf9b32..8408a8a4c 100644 --- a/channels/printer/client/printer_main.c +++ b/channels/printer/client/printer_main.c @@ -1072,7 +1072,8 @@ static rdpPrinterDriver* printer_load_backend(const char* backend) * * @return 0 on success, otherwise a Win32 error code */ -FREERDP_ENTRY_POINT(UINT printer_DeviceServiceEntry(PDEVICE_SERVICE_ENTRY_POINTS pEntryPoints)) +FREERDP_ENTRY_POINT( + UINT VCAPITYPE printer_DeviceServiceEntry(PDEVICE_SERVICE_ENTRY_POINTS pEntryPoints)) { char* name = NULL; char* driver_name = NULL; diff --git a/channels/printer/client/win/printer_win.c b/channels/printer/client/win/printer_win.c index 7c62b4011..c92b60249 100644 --- a/channels/printer/client/win/printer_win.c +++ b/channels/printer/client/win/printer_win.c @@ -23,6 +23,7 @@ #include #include +#include #include #include @@ -436,7 +437,7 @@ static void printer_win_release_ref_driver(rdpPrinterDriver* driver) win->references--; } -FREERDP_ENTRY_POINT(UINT win_freerdp_printer_client_subsystem_entry(void* arg)) +FREERDP_ENTRY_POINT(UINT VCAPITYPE win_freerdp_printer_client_subsystem_entry(void* arg)) { rdpPrinterDriver** ppPrinter = (rdpPrinterDriver**)arg; if (!ppPrinter) diff --git a/channels/rdpdr/client/devman.c b/channels/rdpdr/client/devman.c index 7c9e3ff61..ddff156ae 100644 --- a/channels/rdpdr/client/devman.c +++ b/channels/rdpdr/client/devman.c @@ -185,8 +185,12 @@ static const char PARALLEL_SERVICE_NAME[] = "parallel"; UINT devman_load_device_service(DEVMAN* devman, const RDPDR_DEVICE* device, rdpContext* rdpcontext) { const char* ServiceName = NULL; - DEVICE_SERVICE_ENTRY_POINTS ep; - PDEVICE_SERVICE_ENTRY entry = NULL; + DEVICE_SERVICE_ENTRY_POINTS ep = { 0 }; + union + { + PVIRTUALCHANNELENTRY pvce; + PDEVICE_SERVICE_ENTRY entry; + } cnv; union { const RDPDR_DEVICE* cdp; @@ -219,10 +223,9 @@ UINT devman_load_device_service(DEVMAN* devman, const RDPDR_DEVICE* device, rdpC else WLog_INFO(TAG, "Loading device service %s (static)", ServiceName); - entry = (PDEVICE_SERVICE_ENTRY)freerdp_load_channel_addin_entry(ServiceName, NULL, - "DeviceServiceEntry", 0); + cnv.pvce = freerdp_load_channel_addin_entry(ServiceName, NULL, "DeviceServiceEntry", 0); - if (!entry) + if (!cnv.entry) { WLog_INFO(TAG, "freerdp_load_channel_addin_entry failed!"); return ERROR_INTERNAL_ERROR; @@ -232,5 +235,5 @@ UINT devman_load_device_service(DEVMAN* devman, const RDPDR_DEVICE* device, rdpC ep.RegisterDevice = devman_register_device; ep.device = devconv.dp; ep.rdpcontext = rdpcontext; - return entry(&ep); + return cnv.entry(&ep); } diff --git a/channels/rdpecam/client/camera_device_enum_main.c b/channels/rdpecam/client/camera_device_enum_main.c index e191f8a41..d6da9e7aa 100644 --- a/channels/rdpecam/client/camera_device_enum_main.c +++ b/channels/rdpecam/client/camera_device_enum_main.c @@ -468,11 +468,14 @@ static UINT ecam_load_hal_plugin(CameraPlugin* ecam, const char* name, const ADD FREERDP_CAMERA_HAL_ENTRY_POINTS entryPoints = { 0 }; UINT error = ERROR_INTERNAL_ERROR; - const PFREERDP_CAMERA_HAL_ENTRY entry = - (const PFREERDP_CAMERA_HAL_ENTRY)freerdp_load_channel_addin_entry(RDPECAM_CHANNEL_NAME, - name, NULL, 0); + union + { + PVIRTUALCHANNELENTRY pvce; + const PFREERDP_CAMERA_HAL_ENTRY entry; + } cnv; + cnv.pvce = freerdp_load_channel_addin_entry(RDPECAM_CHANNEL_NAME, name, NULL, 0); - if (entry == NULL) + if (cnv.entry == NULL) { WLog_ERR(TAG, "freerdp_load_channel_addin_entry did not return any function pointers for %s ", @@ -485,7 +488,8 @@ static UINT ecam_load_hal_plugin(CameraPlugin* ecam, const char* name, const ADD entryPoints.args = args; entryPoints.ecam = ecam; - if ((error = entry(&entryPoints))) + error = cnv.entry(&entryPoints); + if (error) { WLog_ERR(TAG, "%s entry returned error %" PRIu32 ".", name, error); return error; @@ -500,7 +504,7 @@ static UINT ecam_load_hal_plugin(CameraPlugin* ecam, const char* name, const ADD * * @return 0 on success, otherwise a Win32 error code */ -FREERDP_ENTRY_POINT(UINT rdpecam_DVCPluginEntry(IDRDYNVC_ENTRY_POINTS* pEntryPoints)) +FREERDP_ENTRY_POINT(UINT VCAPITYPE rdpecam_DVCPluginEntry(IDRDYNVC_ENTRY_POINTS* pEntryPoints)) { UINT error = CHANNEL_RC_INITIALIZATION_ERROR; diff --git a/channels/rdpecam/client/v4l/camera_v4l.c b/channels/rdpecam/client/v4l/camera_v4l.c index ccb60d65b..8d5f4a628 100644 --- a/channels/rdpecam/client/v4l/camera_v4l.c +++ b/channels/rdpecam/client/v4l/camera_v4l.c @@ -734,8 +734,8 @@ static UINT cam_v4l_free(ICamHal* ihal) * * @return 0 on success, otherwise a Win32 error code */ -FREERDP_ENTRY_POINT( - UINT v4l_freerdp_rdpecam_client_subsystem_entry(PFREERDP_CAMERA_HAL_ENTRY_POINTS pEntryPoints)) +FREERDP_ENTRY_POINT(UINT VCAPITYPE v4l_freerdp_rdpecam_client_subsystem_entry( + PFREERDP_CAMERA_HAL_ENTRY_POINTS pEntryPoints)) { UINT ret = CHANNEL_RC_OK; WINPR_ASSERT(pEntryPoints); diff --git a/channels/rdpei/client/rdpei_main.c b/channels/rdpei/client/rdpei_main.c index cdb7759c1..78ed5e7fd 100644 --- a/channels/rdpei/client/rdpei_main.c +++ b/channels/rdpei/client/rdpei_main.c @@ -1466,7 +1466,7 @@ static const IWTSVirtualChannelCallback geometry_callbacks = { rdpei_on_data_rec * * @return 0 on success, otherwise a Win32 error code */ -FREERDP_ENTRY_POINT(UINT rdpei_DVCPluginEntry(IDRDYNVC_ENTRY_POINTS* pEntryPoints)) +FREERDP_ENTRY_POINT(UINT VCAPITYPE rdpei_DVCPluginEntry(IDRDYNVC_ENTRY_POINTS* pEntryPoints)) { return freerdp_generic_DVCPluginEntry(pEntryPoints, TAG, RDPEI_DVC_CHANNEL_NAME, sizeof(RDPEI_PLUGIN), sizeof(GENERIC_CHANNEL_CALLBACK), diff --git a/channels/rdpgfx/client/rdpgfx_main.c b/channels/rdpgfx/client/rdpgfx_main.c index b60739942..94de1d023 100644 --- a/channels/rdpgfx/client/rdpgfx_main.c +++ b/channels/rdpgfx/client/rdpgfx_main.c @@ -2424,7 +2424,7 @@ static const IWTSVirtualChannelCallback rdpgfx_callbacks = { rdpgfx_on_data_rece * * @return 0 on success, otherwise a Win32 error code */ -FREERDP_ENTRY_POINT(UINT rdpgfx_DVCPluginEntry(IDRDYNVC_ENTRY_POINTS* pEntryPoints)) +FREERDP_ENTRY_POINT(UINT VCAPITYPE rdpgfx_DVCPluginEntry(IDRDYNVC_ENTRY_POINTS* pEntryPoints)) { return freerdp_generic_DVCPluginEntry(pEntryPoints, TAG, RDPGFX_DVC_CHANNEL_NAME, sizeof(RDPGFX_PLUGIN), sizeof(GENERIC_CHANNEL_CALLBACK), diff --git a/channels/rdpsnd/client/alsa/rdpsnd_alsa.c b/channels/rdpsnd/client/alsa/rdpsnd_alsa.c index 43e812bee..93a39ee3b 100644 --- a/channels/rdpsnd/client/alsa/rdpsnd_alsa.c +++ b/channels/rdpsnd/client/alsa/rdpsnd_alsa.c @@ -511,7 +511,7 @@ static UINT rdpsnd_alsa_parse_addin_args(rdpsndDevicePlugin* device, const ADDIN * * @return 0 on success, otherwise a Win32 error code */ -FREERDP_ENTRY_POINT(UINT alsa_freerdp_rdpsnd_client_subsystem_entry( +FREERDP_ENTRY_POINT(UINT VCAPITYPE alsa_freerdp_rdpsnd_client_subsystem_entry( PFREERDP_RDPSND_DEVICE_ENTRY_POINTS pEntryPoints)) { const ADDIN_ARGV* args = NULL; diff --git a/channels/rdpsnd/client/fake/rdpsnd_fake.c b/channels/rdpsnd/client/fake/rdpsnd_fake.c index 35251d26c..9e06f4c11 100644 --- a/channels/rdpsnd/client/fake/rdpsnd_fake.c +++ b/channels/rdpsnd/client/fake/rdpsnd_fake.c @@ -109,7 +109,7 @@ static UINT rdpsnd_fake_parse_addin_args(rdpsndFakePlugin* fake, const ADDIN_ARG * * @return 0 on success, otherwise a Win32 error code */ -FREERDP_ENTRY_POINT(UINT fake_freerdp_rdpsnd_client_subsystem_entry( +FREERDP_ENTRY_POINT(UINT VCAPITYPE fake_freerdp_rdpsnd_client_subsystem_entry( PFREERDP_RDPSND_DEVICE_ENTRY_POINTS pEntryPoints)) { const ADDIN_ARGV* args = NULL; diff --git a/channels/rdpsnd/client/ios/rdpsnd_ios.c b/channels/rdpsnd/client/ios/rdpsnd_ios.c index 4aa8311ce..c3e17ece6 100644 --- a/channels/rdpsnd/client/ios/rdpsnd_ios.c +++ b/channels/rdpsnd/client/ios/rdpsnd_ios.c @@ -262,7 +262,7 @@ static void rdpsnd_ios_free(rdpsndDevicePlugin* device) * * @return 0 on success, otherwise a Win32 error code */ -FREERDP_ENTRY_POINT(UINT ios_freerdp_rdpsnd_client_subsystem_entry( +FREERDP_ENTRY_POINT(UINT VCAPITYPE ios_freerdp_rdpsnd_client_subsystem_entry( PFREERDP_RDPSND_DEVICE_ENTRY_POINTS pEntryPoints)) { rdpsndIOSPlugin* p = (rdpsndIOSPlugin*)calloc(1, sizeof(rdpsndIOSPlugin)); diff --git a/channels/rdpsnd/client/mac/rdpsnd_mac.m b/channels/rdpsnd/client/mac/rdpsnd_mac.m index 648ded4a9..89e02c2d5 100644 --- a/channels/rdpsnd/client/mac/rdpsnd_mac.m +++ b/channels/rdpsnd/client/mac/rdpsnd_mac.m @@ -382,7 +382,7 @@ static UINT rdpsnd_mac_play(rdpsndDevicePlugin *device, const BYTE *data, size_t * * @return 0 on success, otherwise a Win32 error code */ -FREERDP_ENTRY_POINT(UINT mac_freerdp_rdpsnd_client_subsystem_entry( +FREERDP_ENTRY_POINT(UINT VCAPITYPE mac_freerdp_rdpsnd_client_subsystem_entry( PFREERDP_RDPSND_DEVICE_ENTRY_POINTS pEntryPoints)) { rdpsndMacPlugin *mac; diff --git a/channels/rdpsnd/client/opensles/rdpsnd_opensles.c b/channels/rdpsnd/client/opensles/rdpsnd_opensles.c index c5679b623..1417899ef 100644 --- a/channels/rdpsnd/client/opensles/rdpsnd_opensles.c +++ b/channels/rdpsnd/client/opensles/rdpsnd_opensles.c @@ -332,7 +332,7 @@ static int rdpsnd_opensles_parse_addin_args(rdpsndDevicePlugin* device, ADDIN_AR * * @return 0 on success, otherwise a Win32 error code */ -FREERDP_ENTRY_POINT(UINT opensles_freerdp_rdpsnd_client_subsystem_entry( +FREERDP_ENTRY_POINT(UINT VCAPITYPE opensles_freerdp_rdpsnd_client_subsystem_entry( PFREERDP_RDPSND_DEVICE_ENTRY_POINTS pEntryPoints)) { ADDIN_ARGV* args; diff --git a/channels/rdpsnd/client/oss/rdpsnd_oss.c b/channels/rdpsnd/client/oss/rdpsnd_oss.c index 02bbf605d..a77da51a3 100644 --- a/channels/rdpsnd/client/oss/rdpsnd_oss.c +++ b/channels/rdpsnd/client/oss/rdpsnd_oss.c @@ -443,7 +443,7 @@ static int rdpsnd_oss_parse_addin_args(rdpsndDevicePlugin* device, const ADDIN_A * * @return 0 on success, otherwise a Win32 error code */ -FREERDP_ENTRY_POINT(UINT oss_freerdp_rdpsnd_client_subsystem_entry( +FREERDP_ENTRY_POINT(UINT VCAPITYPE oss_freerdp_rdpsnd_client_subsystem_entry( PFREERDP_RDPSND_DEVICE_ENTRY_POINTS pEntryPoints)) { const ADDIN_ARGV* args = NULL; diff --git a/channels/rdpsnd/client/pulse/rdpsnd_pulse.c b/channels/rdpsnd/client/pulse/rdpsnd_pulse.c index 843693bf9..311bbf906 100644 --- a/channels/rdpsnd/client/pulse/rdpsnd_pulse.c +++ b/channels/rdpsnd/client/pulse/rdpsnd_pulse.c @@ -704,7 +704,7 @@ static UINT rdpsnd_pulse_parse_addin_args(rdpsndDevicePlugin* device, const ADDI return CHANNEL_RC_OK; } -FREERDP_ENTRY_POINT(UINT pulse_freerdp_rdpsnd_client_subsystem_entry( +FREERDP_ENTRY_POINT(UINT VCAPITYPE pulse_freerdp_rdpsnd_client_subsystem_entry( PFREERDP_RDPSND_DEVICE_ENTRY_POINTS pEntryPoints)) { const ADDIN_ARGV* args = NULL; diff --git a/channels/rdpsnd/client/rdpsnd_main.c b/channels/rdpsnd/client/rdpsnd_main.c index a656802eb..b9f275aec 100644 --- a/channels/rdpsnd/client/rdpsnd_main.c +++ b/channels/rdpsnd/client/rdpsnd_main.c @@ -848,23 +848,28 @@ static void rdpsnd_register_device_plugin(rdpsndPlugin* rdpsnd, rdpsndDevicePlug static UINT rdpsnd_load_device_plugin(rdpsndPlugin* rdpsnd, const char* name, const ADDIN_ARGV* args) { - PFREERDP_RDPSND_DEVICE_ENTRY entry = NULL; - FREERDP_RDPSND_DEVICE_ENTRY_POINTS entryPoints; + union + { + PVIRTUALCHANNELENTRY pvce; + PFREERDP_RDPSND_DEVICE_ENTRY entry; + } cnv; + + FREERDP_RDPSND_DEVICE_ENTRY_POINTS entryPoints = { 0 }; UINT error = 0; DWORD flags = FREERDP_ADDIN_CHANNEL_STATIC | FREERDP_ADDIN_CHANNEL_ENTRYEX; if (rdpsnd->dynamic) flags = FREERDP_ADDIN_CHANNEL_DYNAMIC; - entry = (PFREERDP_RDPSND_DEVICE_ENTRY)freerdp_load_channel_addin_entry(RDPSND_CHANNEL_NAME, - name, NULL, flags); + cnv.pvce = freerdp_load_channel_addin_entry(RDPSND_CHANNEL_NAME, name, NULL, flags); - if (!entry) + if (!cnv.entry) return ERROR_INTERNAL_ERROR; entryPoints.rdpsnd = rdpsnd; entryPoints.pRegisterRdpsndDevice = rdpsnd_register_device_plugin; entryPoints.args = args; - if ((error = entry(&entryPoints))) + error = cnv.entry(&entryPoints); + if (error) WLog_ERR(TAG, "%s %s entry returns error %" PRIu32 "", rdpsnd_is_dyn_str(rdpsnd->dynamic), name, error); @@ -1795,7 +1800,7 @@ static UINT rdpsnd_plugin_terminated(IWTSPlugin* pPlugin) * * @return 0 on success, otherwise a Win32 error code */ -FREERDP_ENTRY_POINT(UINT rdpsnd_DVCPluginEntry(IDRDYNVC_ENTRY_POINTS* pEntryPoints)) +FREERDP_ENTRY_POINT(UINT VCAPITYPE rdpsnd_DVCPluginEntry(IDRDYNVC_ENTRY_POINTS* pEntryPoints)) { UINT error = CHANNEL_RC_OK; rdpsndPlugin* rdpsnd = NULL; diff --git a/channels/rdpsnd/client/sndio/rdpsnd_sndio.c b/channels/rdpsnd/client/sndio/rdpsnd_sndio.c index 4414653c6..541c6f7b5 100644 --- a/channels/rdpsnd/client/sndio/rdpsnd_sndio.c +++ b/channels/rdpsnd/client/sndio/rdpsnd_sndio.c @@ -179,7 +179,7 @@ static UINT rdpsnd_sndio_parse_addin_args(rdpsndDevicePlugin* device, ADDIN_ARGV * * @return 0 on success, otherwise a Win32 error code */ -FREERDP_ENTRY_POINT(UINT sndio_freerdp_rdpsnd_client_subsystem_entry( +FREERDP_ENTRY_POINT(UINT VCAPITYPE sndio_freerdp_rdpsnd_client_subsystem_entry( PFREERDP_RDPSND_DEVICE_ENTRY_POINTS pEntryPoints)) { ADDIN_ARGV* args; diff --git a/channels/rdpsnd/client/winmm/rdpsnd_winmm.c b/channels/rdpsnd/client/winmm/rdpsnd_winmm.c index 2ba065456..205a6cb2d 100644 --- a/channels/rdpsnd/client/winmm/rdpsnd_winmm.c +++ b/channels/rdpsnd/client/winmm/rdpsnd_winmm.c @@ -31,6 +31,7 @@ #include #include +#include #include #include @@ -313,7 +314,7 @@ static void rdpsnd_winmm_parse_addin_args(rdpsndDevicePlugin* device, const ADDI * * @return 0 on success, otherwise a Win32 error code */ -FREERDP_ENTRY_POINT(UINT winmm_freerdp_rdpsnd_client_subsystem_entry( +FREERDP_ENTRY_POINT(UINT VCAPITYPE winmm_freerdp_rdpsnd_client_subsystem_entry( PFREERDP_RDPSND_DEVICE_ENTRY_POINTS pEntryPoints)) { const ADDIN_ARGV* args; diff --git a/channels/serial/client/serial_main.c b/channels/serial/client/serial_main.c index 8ceb5f51b..34d3ee96d 100644 --- a/channels/serial/client/serial_main.c +++ b/channels/serial/client/serial_main.c @@ -837,7 +837,8 @@ static void irp_thread_close(void* arg) * * @return 0 on success, otherwise a Win32 error code */ -FREERDP_ENTRY_POINT(UINT serial_DeviceServiceEntry(PDEVICE_SERVICE_ENTRY_POINTS pEntryPoints)) +FREERDP_ENTRY_POINT( + UINT VCAPITYPE serial_DeviceServiceEntry(PDEVICE_SERVICE_ENTRY_POINTS pEntryPoints)) { size_t len = 0; SERIAL_DEVICE* serial = NULL; diff --git a/channels/smartcard/client/smartcard_main.c b/channels/smartcard/client/smartcard_main.c index 0037b4e6a..71951a6a5 100644 --- a/channels/smartcard/client/smartcard_main.c +++ b/channels/smartcard/client/smartcard_main.c @@ -625,8 +625,7 @@ static void smartcard_free_irp(void* obj) * * @return 0 on success, otherwise a Win32 error code */ -extern UINT DeviceServiceEntry(PDEVICE_SERVICE_ENTRY_POINTS pEntryPoints); -UINT DeviceServiceEntry(PDEVICE_SERVICE_ENTRY_POINTS pEntryPoints) +FREERDP_ENTRY_POINT(UINT VCAPITYPE DeviceServiceEntry(PDEVICE_SERVICE_ENTRY_POINTS pEntryPoints)) { SMARTCARD_DEVICE* smartcard = NULL; size_t length = 0; diff --git a/channels/sshagent/client/sshagent_main.c b/channels/sshagent/client/sshagent_main.c index 9ee5102cc..9a20944c1 100644 --- a/channels/sshagent/client/sshagent_main.c +++ b/channels/sshagent/client/sshagent_main.c @@ -345,7 +345,7 @@ static UINT sshagent_plugin_terminated(IWTSPlugin* pPlugin) * * @return 0 on success, otherwise a Win32 error code */ -FREERDP_ENTRY_POINT(UINT sshagent_DVCPluginEntry(IDRDYNVC_ENTRY_POINTS* pEntryPoints)) +FREERDP_ENTRY_POINT(UINT VCAPITYPE sshagent_DVCPluginEntry(IDRDYNVC_ENTRY_POINTS* pEntryPoints)) { UINT status = CHANNEL_RC_OK; SSHAGENT_PLUGIN* sshagent; diff --git a/channels/tsmf/client/alsa/tsmf_alsa.c b/channels/tsmf/client/alsa/tsmf_alsa.c index 6d8bf109e..c590be42b 100644 --- a/channels/tsmf/client/alsa/tsmf_alsa.c +++ b/channels/tsmf/client/alsa/tsmf_alsa.c @@ -221,7 +221,7 @@ static void tsmf_alsa_free(ITSMFAudioDevice* audio) free(alsa); } -FREERDP_ENTRY_POINT(UINT alsa_freerdp_tsmf_client_audio_subsystem_entry(void* ptr)) +FREERDP_ENTRY_POINT(UINT VCAPITYPE alsa_freerdp_tsmf_client_audio_subsystem_entry(void* ptr)) { ITSMFAudioDevice** sptr = (ITSMFAudioDevice**)ptr; WINPR_ASSERT(sptr); diff --git a/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c b/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c index ff72079a6..ce5bcd7c2 100644 --- a/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c +++ b/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c @@ -693,7 +693,7 @@ static BOOL CALLBACK InitializeAvCodecs(PINIT_ONCE once, PVOID param, PVOID* con return TRUE; } -FREERDP_ENTRY_POINT(UINT ffmpeg_freerdp_tsmf_client_decoder_subsystem_entry(void* ptr)) +FREERDP_ENTRY_POINT(UINT VCAPITYPE ffmpeg_freerdp_tsmf_client_decoder_subsystem_entry(void* ptr)) { ITSMFDecoder** sptr = (ITSMFDecoder**)ptr; WINPR_ASSERT(sptr); diff --git a/channels/tsmf/client/gstreamer/tsmf_gstreamer.c b/channels/tsmf/client/gstreamer/tsmf_gstreamer.c index bc1b837c4..c297a20cf 100644 --- a/channels/tsmf/client/gstreamer/tsmf_gstreamer.c +++ b/channels/tsmf/client/gstreamer/tsmf_gstreamer.c @@ -1003,7 +1003,7 @@ static BOOL tsmf_gstreamer_sync(ITSMFDecoder* decoder, void (*cb)(void*), void* return TRUE; } -FREERDP_ENTRY_POINT(UINT gstreamer_freerdp_tsmf_client_decoder_subsystem_entry(void* ptr)) +FREERDP_ENTRY_POINT(UINT VCAPITYPE gstreamer_freerdp_tsmf_client_decoder_subsystem_entry(void* ptr)) { ITSMFDecoder** sptr = (ITSMFDecoder**)ptr; WINPR_ASSERT(sptr); diff --git a/channels/tsmf/client/oss/tsmf_oss.c b/channels/tsmf/client/oss/tsmf_oss.c index 7d7b4db80..683c056aa 100644 --- a/channels/tsmf/client/oss/tsmf_oss.c +++ b/channels/tsmf/client/oss/tsmf_oss.c @@ -231,7 +231,7 @@ static void tsmf_oss_free(ITSMFAudioDevice* audio) free(oss); } -FREERDP_ENTRY_POINT(UINT oss_freerdp_tsmf_client_audio_subsystem_entry(void* ptr)) +FREERDP_ENTRY_POINT(UINT VCAPITYPE oss_freerdp_tsmf_client_audio_subsystem_entry(void* ptr)) { ITSMFAudioDevice** sptr = (ITSMFAudioDevice**)ptr; WINPR_ASSERT(sptr); diff --git a/channels/tsmf/client/pulse/tsmf_pulse.c b/channels/tsmf/client/pulse/tsmf_pulse.c index 084e88a4c..34a9fd55a 100644 --- a/channels/tsmf/client/pulse/tsmf_pulse.c +++ b/channels/tsmf/client/pulse/tsmf_pulse.c @@ -396,7 +396,7 @@ static void tsmf_pulse_free(ITSMFAudioDevice* audio) free(pulse); } -FREERDP_ENTRY_POINT(UINT pulse_freerdp_tsmf_client_audio_subsystem_entry(void* ptr)) +FREERDP_ENTRY_POINT(UINT VCAPITYPE pulse_freerdp_tsmf_client_audio_subsystem_entry(void* ptr)) { ITSMFAudioDevice** sptr = (ITSMFAudioDevice**)ptr; WINPR_ASSERT(sptr); diff --git a/channels/tsmf/client/tsmf_main.c b/channels/tsmf/client/tsmf_main.c index 877ef24f1..040c94e09 100644 --- a/channels/tsmf/client/tsmf_main.c +++ b/channels/tsmf/client/tsmf_main.c @@ -552,7 +552,7 @@ static UINT tsmf_process_addin_args(IWTSPlugin* pPlugin, const ADDIN_ARGV* args) * * @return 0 on success, otherwise a Win32 error code */ -FREERDP_ENTRY_POINT(UINT tsmf_DVCPluginEntry(IDRDYNVC_ENTRY_POINTS* pEntryPoints)) +FREERDP_ENTRY_POINT(UINT VCAPITYPE tsmf_DVCPluginEntry(IDRDYNVC_ENTRY_POINTS* pEntryPoints)) { UINT status = 0; TSMF_PLUGIN* tsmf = NULL; diff --git a/channels/urbdrc/client/libusb/libusb_udevice.c b/channels/urbdrc/client/libusb/libusb_udevice.c index a3939b126..5dfb43e90 100644 --- a/channels/urbdrc/client/libusb/libusb_udevice.c +++ b/channels/urbdrc/client/libusb/libusb_udevice.c @@ -864,7 +864,7 @@ static UINT32 libusb_udev_control_query_device_text(IUDEVICE* idev, UINT32 TextT msg, ret, devDescriptor->iProduct); len = MIN(sizeof(strDesc), inSize); - for (ssize_t i = 0; i < len; i++) + for (size_t i = 0; i < len; i++) text[i] = (WCHAR)strDesc[i]; *BufferSize = (BYTE)(len * 2); @@ -899,7 +899,7 @@ static UINT32 libusb_udev_control_query_device_text(IUDEVICE* idev, UINT32 TextT len = strnlen(deviceLocation, MIN(sizeof(deviceLocation), (inSize > 0) ? inSize - 1U : 0)); - for (ssize_t i = 0; i < len; i++) + for (size_t i = 0; i < len; i++) text[i] = (WCHAR)deviceLocation[i]; text[len++] = '\0'; *BufferSize = (UINT8)(len * sizeof(WCHAR)); diff --git a/channels/urbdrc/client/libusb/libusb_udevman.c b/channels/urbdrc/client/libusb/libusb_udevman.c index d8455622d..27f9644db 100644 --- a/channels/urbdrc/client/libusb/libusb_udevman.c +++ b/channels/urbdrc/client/libusb/libusb_udevman.c @@ -894,7 +894,7 @@ static DWORD WINAPI poll_thread(LPVOID lpThreadParameter) return 0; } -FREERDP_ENTRY_POINT(UINT libusb_freerdp_urbdrc_client_subsystem_entry( +FREERDP_ENTRY_POINT(UINT VCAPITYPE libusb_freerdp_urbdrc_client_subsystem_entry( PFREERDP_URBDRC_SERVICE_ENTRY_POINTS pEntryPoints)) { wObject* obj = NULL; diff --git a/channels/urbdrc/client/urbdrc_main.c b/channels/urbdrc/client/urbdrc_main.c index ca8ca375d..bf2044eaf 100644 --- a/channels/urbdrc/client/urbdrc_main.c +++ b/channels/urbdrc/client/urbdrc_main.c @@ -769,22 +769,26 @@ static BOOL urbdrc_register_udevman_addin(IWTSPlugin* pPlugin, IUDEVMAN* udevman static UINT urbdrc_load_udevman_addin(IWTSPlugin* pPlugin, LPCSTR name, const ADDIN_ARGV* args) { URBDRC_PLUGIN* urbdrc = (URBDRC_PLUGIN*)pPlugin; - PFREERDP_URBDRC_DEVICE_ENTRY entry = NULL; - FREERDP_URBDRC_SERVICE_ENTRY_POINTS entryPoints; - entry = (PFREERDP_URBDRC_DEVICE_ENTRY)freerdp_load_channel_addin_entry(URBDRC_CHANNEL_NAME, - name, NULL, 0); + FREERDP_URBDRC_SERVICE_ENTRY_POINTS entryPoints = { 0 }; + union + { + PVIRTUALCHANNELENTRY pvce; + PFREERDP_URBDRC_DEVICE_ENTRY entry; + } cnv; + cnv.pvce = freerdp_load_channel_addin_entry(URBDRC_CHANNEL_NAME, name, NULL, 0); - if (!entry) + if (!cnv.entry) return ERROR_INVALID_OPERATION; entryPoints.plugin = pPlugin; entryPoints.pRegisterUDEVMAN = urbdrc_register_udevman_addin; entryPoints.args = args; - if (entry(&entryPoints) != 0) + const UINT error = cnv.entry(&entryPoints); + if (error) { WLog_Print(urbdrc->log, WLOG_ERROR, "%s entry returns error.", name); - return ERROR_INVALID_OPERATION; + return error; } return CHANNEL_RC_OK; @@ -950,7 +954,7 @@ BOOL del_device(IUDEVMAN* idevman, UINT32 flags, BYTE busnum, BYTE devnum, UINT1 * * @return 0 on success, otherwise a Win32 error code */ -FREERDP_ENTRY_POINT(UINT urbdrc_DVCPluginEntry(IDRDYNVC_ENTRY_POINTS* pEntryPoints)) +FREERDP_ENTRY_POINT(UINT VCAPITYPE urbdrc_DVCPluginEntry(IDRDYNVC_ENTRY_POINTS* pEntryPoints)) { UINT status = 0; const ADDIN_ARGV* args = NULL; diff --git a/channels/video/client/video_main.c b/channels/video/client/video_main.c index ad5283593..7d3637a7e 100644 --- a/channels/video/client/video_main.c +++ b/channels/video/client/video_main.c @@ -1170,7 +1170,7 @@ static UINT video_plugin_terminated(IWTSPlugin* pPlugin) * * @return 0 on success, otherwise a Win32 error code */ -FREERDP_ENTRY_POINT(UINT video_DVCPluginEntry(IDRDYNVC_ENTRY_POINTS* pEntryPoints)) +FREERDP_ENTRY_POINT(UINT VCAPITYPE video_DVCPluginEntry(IDRDYNVC_ENTRY_POINTS* pEntryPoints)) { UINT error = CHANNEL_RC_OK; VIDEO_PLUGIN* videoPlugin = NULL; diff --git a/client/SDL/SDL2/dialogs/sdl_connection_dialog.cpp b/client/SDL/SDL2/dialogs/sdl_connection_dialog.cpp index 1cecc58a0..c63673f8f 100644 --- a/client/SDL/SDL2/dialogs/sdl_connection_dialog.cpp +++ b/client/SDL/SDL2/dialogs/sdl_connection_dialog.cpp @@ -458,7 +458,7 @@ std::string SDLConnectionDialog::print(const char* fmt, va_list ap) size = vsnprintf(res.data(), res.size(), fmt, copy); va_end(copy); - } while ((size > 0) && (size > res.size())); + } while ((size > 0) && (static_cast(size) > res.size())); return res; } diff --git a/client/SDL/SDL2/sdl_monitor.cpp b/client/SDL/SDL2/sdl_monitor.cpp index 5b0e38b05..ab6f2ca38 100644 --- a/client/SDL/SDL2/sdl_monitor.cpp +++ b/client/SDL/SDL2/sdl_monitor.cpp @@ -326,9 +326,13 @@ BOOL sdl_detect_monitors(SdlContext* sdl, UINT32* pMaxWidth, UINT32* pMaxHeight) const int numDisplays = SDL_GetNumVideoDisplays(); auto nr = freerdp_settings_get_uint32(settings, FreeRDP_NumMonitorIds); + if (numDisplays < 0) + return FALSE; + if (nr == 0) { - if (!freerdp_settings_set_pointer_len(settings, FreeRDP_MonitorIds, nullptr, numDisplays)) + if (!freerdp_settings_set_pointer_len(settings, FreeRDP_MonitorIds, nullptr, + static_cast(numDisplays))) return FALSE; for (size_t x = 0; x < numDisplays; x++) { @@ -340,7 +344,7 @@ BOOL sdl_detect_monitors(SdlContext* sdl, UINT32* pMaxWidth, UINT32* pMaxHeight) { /* There were more IDs supplied than there are monitors */ - if (nr > numDisplays) + if (nr > static_cast(numDisplays)) { WLog_ERR(TAG, "Found %" PRIu32 " monitor IDs, but only have %" PRIu32 " monitors connected", diff --git a/client/SDL/SDL3/dialogs/sdl_connection_dialog.cpp b/client/SDL/SDL3/dialogs/sdl_connection_dialog.cpp index 67b3363d2..a8abd01d0 100644 --- a/client/SDL/SDL3/dialogs/sdl_connection_dialog.cpp +++ b/client/SDL/SDL3/dialogs/sdl_connection_dialog.cpp @@ -456,7 +456,7 @@ std::string SDLConnectionDialog::print(const char* fmt, va_list ap) size = vsnprintf(res.data(), res.size(), fmt, copy); va_end(copy); - } while ((size > 0) && (size > res.size())); + } while ((size > 0) && (static_cast(size) > res.size())); return res; } diff --git a/client/SDL/SDL3/sdl_monitor.cpp b/client/SDL/SDL3/sdl_monitor.cpp index 3d7759de8..2d407f57d 100644 --- a/client/SDL/SDL3/sdl_monitor.cpp +++ b/client/SDL/SDL3/sdl_monitor.cpp @@ -323,8 +323,11 @@ BOOL sdl_detect_monitors(SdlContext* sdl, UINT32* pMaxWidth, UINT32* pMaxHeight) { int numDisplays = 0; auto sids = SDL_GetDisplays(&numDisplays); - ids = std::vector(sids, sids + numDisplays); + if (sids && (numDisplays > 0)) + ids = std::vector(sids, sids + numDisplays); SDL_free(sids); + if (numDisplays < 0) + return FALSE; } auto nr = freerdp_settings_get_uint32(settings, FreeRDP_NumMonitorIds); diff --git a/client/SDL/common/sdl_prefs.cpp b/client/SDL/common/sdl_prefs.cpp index b943946e3..d9ddf5bef 100644 --- a/client/SDL/common/sdl_prefs.cpp +++ b/client/SDL/common/sdl_prefs.cpp @@ -94,7 +94,7 @@ std::vector SdlPref::get_array(const std::string& key, return fallback; std::vector values; - for (int x = 0; x < WINPR_JSON_GetArraySize(item); x++) + for (size_t x = 0; x < WINPR_JSON_GetArraySize(item); x++) { auto cur = WINPR_JSON_GetArrayItem(item, x); values.push_back(item_to_str(cur)); diff --git a/client/X11/xf_monitor.c b/client/X11/xf_monitor.c index 96171de73..b7ba07e8f 100644 --- a/client/X11/xf_monitor.c +++ b/client/X11/xf_monitor.c @@ -186,15 +186,17 @@ BOOL xf_detect_monitors(xfContext* xfc, UINT32* pMaxWidth, UINT32* pMaxHeight) if (XRRQueryExtension(xfc->display, &major, &minor) && (XRRQueryVersion(xfc->display, &major, &minor) == True) && (major * 100 + minor >= 105)) { - rrmonitors = - XRRGetMonitors(xfc->display, DefaultRootWindow(xfc->display), 1, &vscreen->nmonitors); + int nmonitors = 0; + rrmonitors = XRRGetMonitors(xfc->display, DefaultRootWindow(xfc->display), 1, &nmonitors); - if (vscreen->nmonitors > 16) + if ((nmonitors < 0) || (nmonitors > 16)) vscreen->nmonitors = 0; + else + vscreen->nmonitors = (UINT32)nmonitors; if (vscreen->nmonitors) { - for (int i = 0; i < vscreen->nmonitors; i++) + for (UINT32 i = 0; i < vscreen->nmonitors; i++) { MONITOR_INFO* cur_vscreen = &vscreen->monitors[i]; const XRRMonitorInfo* cur_monitor = &rrmonitors[i]; @@ -213,14 +215,17 @@ BOOL xf_detect_monitors(xfContext* xfc, UINT32* pMaxWidth, UINT32* pMaxHeight) #ifdef WITH_XINERAMA if (XineramaQueryExtension(xfc->display, &major, &minor) && XineramaIsActive(xfc->display)) { - XineramaScreenInfo* screenInfo = XineramaQueryScreens(xfc->display, &vscreen->nmonitors); + int nmonitors = 0; + XineramaScreenInfo* screenInfo = XineramaQueryScreens(xfc->display, &nmonitors); - if (vscreen->nmonitors > 16) + if ((nmonitors < 0) || (nmonitors > 16)) vscreen->nmonitors = 0; + else + vscreen->nmonitors = (UINT32)nmonitors; if (vscreen->nmonitors) { - for (int i = 0; i < vscreen->nmonitors; i++) + for (UINT32 i = 0; i < vscreen->nmonitors; i++) { MONITOR_INFO* monitor = &vscreen->monitors[i]; monitor->area.left = screenInfo[i].x_org; @@ -240,7 +245,7 @@ BOOL xf_detect_monitors(xfContext* xfc, UINT32* pMaxWidth, UINT32* pMaxHeight) /* Determine which monitor that the mouse cursor is on */ if (vscreen->monitors) { - for (int i = 0; i < vscreen->nmonitors; i++) + for (UINT32 i = 0; i < vscreen->nmonitors; i++) { const MONITOR_INFO* monitor = &vscreen->monitors[i]; diff --git a/client/X11/xf_monitor.h b/client/X11/xf_monitor.h index c27c88f67..6597c1560 100644 --- a/client/X11/xf_monitor.h +++ b/client/X11/xf_monitor.h @@ -32,7 +32,7 @@ typedef struct typedef struct { - int nmonitors; + UINT32 nmonitors; RECTANGLE_16 area; RECTANGLE_16 workarea; MONITOR_INFO* monitors; diff --git a/client/common/client_cliprdr_file.c b/client/common/client_cliprdr_file.c index 00d676e90..79cdd4f64 100644 --- a/client/common/client_cliprdr_file.c +++ b/client/common/client_cliprdr_file.c @@ -320,7 +320,7 @@ static CliprdrFuseClipDataEntry* clip_data_entry_new(CliprdrFileContext* file_co } static BOOL should_remove_fuse_file(CliprdrFuseFile* fuse_file, BOOL all_files, - BOOL has_clip_data_id, BOOL clip_data_id) + BOOL has_clip_data_id, UINT32 clip_data_id) { if (all_files) return TRUE; @@ -329,7 +329,8 @@ static BOOL should_remove_fuse_file(CliprdrFuseFile* fuse_file, BOOL all_files, return FALSE; if (!fuse_file->has_clip_data_id && !has_clip_data_id) return TRUE; - if (fuse_file->has_clip_data_id && has_clip_data_id && fuse_file->clip_data_id == clip_data_id) + if (fuse_file->has_clip_data_id && has_clip_data_id && + (fuse_file->clip_data_id == clip_data_id)) return TRUE; return FALSE; @@ -972,7 +973,7 @@ static void cliprdr_file_fuse_read(fuse_req_t fuse_req, fuse_ino_t fuse_ino, siz fuse_reply_err(fuse_req, EISDIR); return; } - if (!fuse_file->has_size || offset > fuse_file->size) + if (!fuse_file->has_size || (offset < 0) || (offset > fuse_file->size)) { HashTable_Unlock(file_context->inode_table); fuse_reply_err(fuse_req, EINVAL); @@ -1051,7 +1052,7 @@ static void cliprdr_file_fuse_readdir(fuse_req_t fuse_req, fuse_ino_t fuse_ino, DEBUG_CLIPRDR(file_context->log, "Reading directory \"%s\" at offset %lu", fuse_file->filename_with_root, offset); - if (offset >= ArrayList_Count(fuse_file->children)) + if ((offset < 0) || ((size_t)offset >= ArrayList_Count(fuse_file->children))) { HashTable_Unlock(file_context->inode_table); fuse_reply_buf(fuse_req, NULL, 0); @@ -1100,7 +1101,7 @@ static void cliprdr_file_fuse_readdir(fuse_req_t fuse_req, fuse_ino_t fuse_ino, for (size_t j = 0, i = 2; j < ArrayList_Count(fuse_file->children); ++j, ++i) { - if (i < offset) + if (i < (size_t)offset) continue; child = ArrayList_GetItem(fuse_file->children, j); diff --git a/libfreerdp/codec/rfx_differential.h b/libfreerdp/codec/rfx_differential.h index 0633961a1..75d96c327 100644 --- a/libfreerdp/codec/rfx_differential.h +++ b/libfreerdp/codec/rfx_differential.h @@ -38,7 +38,7 @@ static INLINE void rfx_differential_decode(INT16* WINPR_RESTRICT buffer, size_t static INLINE void rfx_differential_encode(INT16* WINPR_RESTRICT buffer, size_t size) { INT16 n1 = buffer[0]; - for (int x = 0; x < size - 1; x++) + for (size_t x = 0; x < size - 1; x++) { INT16* dst = &buffer[x + 1]; const INT16 n2 = *dst; diff --git a/libfreerdp/codec/rfx_rlgr.c b/libfreerdp/codec/rfx_rlgr.c index 8b05e5682..68226006a 100644 --- a/libfreerdp/codec/rfx_rlgr.c +++ b/libfreerdp/codec/rfx_rlgr.c @@ -561,7 +561,7 @@ int rfx_rlgr_decode(RLGR_MODE mode, const BYTE* WINPR_RESTRICT pSrcData, UINT32 offset = (pOutput - pDstData); - if (offset != DstSize) + if ((DstSize < 0) || (offset != (size_t)DstSize)) return -1; return 1; diff --git a/libfreerdp/codec/xcrush.c b/libfreerdp/codec/xcrush.c index 9832de846..c1bbcacb5 100644 --- a/libfreerdp/codec/xcrush.c +++ b/libfreerdp/codec/xcrush.c @@ -334,7 +334,6 @@ static int xcrush_find_next_matching_chunk(XCRUSH_CONTEXT* WINPR_RESTRICT xcrush XCRUSH_CHUNK* WINPR_RESTRICT chunk, XCRUSH_CHUNK** WINPR_RESTRICT pNextChunk) { - UINT32 index = 0; XCRUSH_CHUNK* next = NULL; WINPR_ASSERT(xcrush); @@ -344,7 +343,7 @@ static int xcrush_find_next_matching_chunk(XCRUSH_CONTEXT* WINPR_RESTRICT xcrush if (chunk->next) { - index = (chunk - xcrush->Chunks) / sizeof(XCRUSH_CHUNK); + UINT32 index = (chunk - xcrush->Chunks) / sizeof(XCRUSH_CHUNK); if (index >= 65534) return -4002; /* error */ diff --git a/libfreerdp/common/assistance.c b/libfreerdp/common/assistance.c index d12d3eaba..ba5f9d6df 100644 --- a/libfreerdp/common/assistance.c +++ b/libfreerdp/common/assistance.c @@ -423,7 +423,7 @@ static BOOL freerdp_assistance_parse_attr(const char** opt, size_t* plength, con char bkey[128] = { 0 }; const int rc = _snprintf(bkey, sizeof(bkey), "%s=\"", key); WINPR_ASSERT(rc > 0); - WINPR_ASSERT(rc < sizeof(bkey)); + WINPR_ASSERT((size_t)rc < sizeof(bkey)); char* p = strstr(tag, bkey); if (!p) @@ -523,7 +523,7 @@ static char* freerdp_assistance_contains_element(char* input, size_t ilen, const char bkey[128] = { 0 }; const int rc = _snprintf(bkey, sizeof(bkey), "<%s", key); WINPR_ASSERT(rc > 0); - WINPR_ASSERT(rc < sizeof(bkey)); + WINPR_ASSERT((size_t)rc < sizeof(bkey)); char* tag = strstr(input, bkey); if (!tag || (tag > input + ilen)) @@ -562,7 +562,7 @@ static char* freerdp_assistance_contains_element(char* input, size_t ilen, const char ekey[128] = { 0 }; const int erc = _snprintf(ekey, sizeof(ekey), "", key); WINPR_ASSERT(erc > 0); - WINPR_ASSERT(erc < sizeof(ekey)); + WINPR_ASSERT((size_t)erc < sizeof(ekey)); const size_t offset = start - tag; dend = end = strrstr(start, ilen - offset, ekey); if (end) diff --git a/libfreerdp/core/childsession.c b/libfreerdp/core/childsession.c index 7c2f40d5a..6643c2f1b 100644 --- a/libfreerdp/core/childsession.c +++ b/libfreerdp/core/childsession.c @@ -211,10 +211,16 @@ static int transport_bio_named_read(BIO* bio, char* buf, int size) } } - int ret = MIN(size, ringbuffer_used(&ptr->readBuffer)); - if (ret) + SSIZE_T ret = -1; + if (size >= 0) { - DataChunk chunks[2]; + size_t rsize = ringbuffer_used(&ptr->readBuffer); + if (rsize <= SSIZE_MAX) + ret = MIN(size, (SSIZE_T)rsize); + } + if ((size >= 0) && ret) + { + DataChunk chunks[2] = { 0 }; int nchunks = ringbuffer_peek(&ptr->readBuffer, chunks, ret); for (int i = 0; i < nchunks; i++) { @@ -226,10 +232,6 @@ static int transport_bio_named_read(BIO* bio, char* buf, int size) WLog_VRB(TAG, "(%d)=%d nchunks=%d", size, ret, nchunks); } - else - { - ret = -1; - } if (!ringbuffer_used(&ptr->readBuffer)) { diff --git a/libfreerdp/core/client.c b/libfreerdp/core/client.c index 2e2bfeb25..d3b1f4ab5 100644 --- a/libfreerdp/core/client.c +++ b/libfreerdp/core/client.c @@ -511,7 +511,7 @@ BOOL freerdp_channels_data(freerdp* instance, UINT16 channelId, const BYTE* cdat return FALSE; } - for (int index = 0; index < mcs->channelCount; index++) + for (UINT32 index = 0; index < mcs->channelCount; index++) { rdpMcsChannel* cur = &mcs->channels[index]; diff --git a/libfreerdp/core/connection.c b/libfreerdp/core/connection.c index d09b2b892..a7005d1ae 100644 --- a/libfreerdp/core/connection.c +++ b/libfreerdp/core/connection.c @@ -758,8 +758,11 @@ static BOOL rdp_client_establish_keys(rdpRdp* rdp) crypto_rsa_public_encrypt(settings->ClientRandom, settings->ClientRandomLength, info, crypt_client_random, info->ModulusLength); /* send crypt client random to server */ - const size_t length = - RDP_PACKET_HEADER_MAX_LENGTH + RDP_SECURITY_HEADER_LENGTH + 4 + info->ModulusLength + 8; + const size_t length = RDP_PACKET_HEADER_MAX_LENGTH + RDP_SECURITY_HEADER_LENGTH + 4ULL + + info->ModulusLength + 8ULL; + if (length > UINT16_MAX) + return FALSE; + s = Stream_New(NULL, length); if (!s) diff --git a/libfreerdp/core/gateway/rdg.c b/libfreerdp/core/gateway/rdg.c index 895128eaa..2d276934d 100644 --- a/libfreerdp/core/gateway/rdg.c +++ b/libfreerdp/core/gateway/rdg.c @@ -1925,7 +1925,7 @@ static BOOL rdg_process_control_packet(rdpRdg* rdg, int type, size_t packetLengt static int rdg_read_data_packet(rdpRdg* rdg, BYTE* buffer, int size) { - RdgPacketHeader header; + RdgPacketHeader header = { 0 }; size_t readCount = 0; size_t readSize = 0; int status = 0; diff --git a/libfreerdp/core/rdp.c b/libfreerdp/core/rdp.c index 17e6c0f69..1e1dd3d8c 100644 --- a/libfreerdp/core/rdp.c +++ b/libfreerdp/core/rdp.c @@ -161,9 +161,9 @@ const char* data_pdu_type_to_string(UINT8 type) } static BOOL rdp_read_flow_control_pdu(rdpRdp* rdp, wStream* s, UINT16* type, UINT16* channel_id); -static BOOL rdp_write_share_control_header(rdpRdp* rdp, wStream* s, UINT16 length, UINT16 type, +static BOOL rdp_write_share_control_header(rdpRdp* rdp, wStream* s, size_t length, UINT16 type, UINT16 channel_id); -static BOOL rdp_write_share_data_header(rdpRdp* rdp, wStream* s, UINT16 length, BYTE type, +static BOOL rdp_write_share_data_header(rdpRdp* rdp, wStream* s, size_t length, BYTE type, UINT32 share_id); /** @@ -301,11 +301,13 @@ BOOL rdp_read_share_control_header(rdpRdp* rdp, wStream* s, UINT16* tpktLength, return Stream_CheckAndLogRequiredLengthWLog(rdp->log, s, remLen); } -BOOL rdp_write_share_control_header(rdpRdp* rdp, wStream* s, UINT16 length, UINT16 type, +BOOL rdp_write_share_control_header(rdpRdp* rdp, wStream* s, size_t length, UINT16 type, UINT16 channel_id) { WINPR_ASSERT(s); WINPR_ASSERT(rdp); + if (length > UINT16_MAX) + return FALSE; if (length < RDP_PACKET_HEADER_MAX_LENGTH) return FALSE; @@ -339,13 +341,15 @@ BOOL rdp_read_share_data_header(rdpRdp* rdp, wStream* s, UINT16* length, BYTE* t return TRUE; } -BOOL rdp_write_share_data_header(rdpRdp* rdp, wStream* s, UINT16 length, BYTE type, UINT32 share_id) +BOOL rdp_write_share_data_header(rdpRdp* rdp, wStream* s, size_t length, BYTE type, UINT32 share_id) { const size_t headerLen = RDP_PACKET_HEADER_MAX_LENGTH + RDP_SHARE_CONTROL_HEADER_LENGTH + RDP_SHARE_DATA_HEADER_LENGTH; WINPR_ASSERT(s); WINPR_ASSERT(rdp); + if (length > UINT16_MAX) + return FALSE; if (length < headerLen) return FALSE; @@ -647,12 +651,14 @@ BOOL rdp_read_header(rdpRdp* rdp, wStream* s, UINT16* length, UINT16* channelId) * @return \b TRUE for success, \b FALSE otherwise */ -BOOL rdp_write_header(rdpRdp* rdp, wStream* s, UINT16 length, UINT16 channelId) +BOOL rdp_write_header(rdpRdp* rdp, wStream* s, size_t length, UINT16 channelId) { WINPR_ASSERT(rdp); WINPR_ASSERT(rdp->settings); WINPR_ASSERT(s); WINPR_ASSERT(length >= RDP_PACKET_HEADER_MAX_LENGTH); + if (length > UINT16_MAX) + return FALSE; DomainMCSPDU MCSPDU = (rdp->settings->ServerMode) ? DomainMCSPDU_SendDataIndication : DomainMCSPDU_SendDataRequest; @@ -687,12 +693,13 @@ BOOL rdp_write_header(rdpRdp* rdp, wStream* s, UINT16 length, UINT16 channelId) return TRUE; } -static BOOL rdp_security_stream_out(rdpRdp* rdp, wStream* s, int length, UINT32 sec_flags, +static BOOL rdp_security_stream_out(rdpRdp* rdp, wStream* s, size_t length, UINT32 sec_flags, UINT32* pad) { BOOL status = 0; WINPR_ASSERT(rdp); - WINPR_ASSERT(length >= 0); + if (length > UINT16_MAX) + return FALSE; sec_flags |= rdp->sec_flags; *pad = 0; @@ -715,7 +722,7 @@ static BOOL rdp_security_stream_out(rdpRdp* rdp, wStream* s, int length, UINT32 if (size > length) goto unlock; - length -= (int)size; + length -= size; Stream_Write_UINT16(s, 0x10); /* length */ Stream_Write_UINT8(s, 0x1); /* TSFIPS_VERSION 1*/ @@ -742,7 +749,10 @@ static BOOL rdp_security_stream_out(rdpRdp* rdp, wStream* s, int length, UINT32 else { const BYTE* data = Stream_PointerAs(s, const BYTE) + 8; - length = length - (data - Stream_Buffer(s)); + const size_t diff = Stream_GetPosition(s) + 8ULL; + if (diff > length) + goto unlock; + length -= diff; if (!Stream_CheckAndLogRequiredCapacityWLog(rdp->log, s, 8)) goto unlock; @@ -811,7 +821,6 @@ BOOL rdp_send(rdpRdp* rdp, wStream* s, UINT16 channel_id) { BOOL rc = FALSE; UINT32 pad = 0; - UINT16 length = 0; if (!s) return FALSE; @@ -819,7 +828,7 @@ BOOL rdp_send(rdpRdp* rdp, wStream* s, UINT16 channel_id) if (!rdp) goto fail; - length = Stream_GetPosition(s); + size_t length = Stream_GetPosition(s); Stream_SetPosition(s, 0); if (!rdp_write_header(rdp, s, length, channel_id)) goto fail; @@ -842,7 +851,6 @@ fail: BOOL rdp_send_pdu(rdpRdp* rdp, wStream* s, UINT16 type, UINT16 channel_id) { - UINT16 length = 0; UINT32 sec_bytes = 0; size_t sec_hold = 0; UINT32 pad = 0; @@ -850,7 +858,7 @@ BOOL rdp_send_pdu(rdpRdp* rdp, wStream* s, UINT16 type, UINT16 channel_id) if (!rdp || !s) return FALSE; - length = Stream_GetPosition(s); + size_t length = Stream_GetPosition(s); Stream_SetPosition(s, 0); if (!rdp_write_header(rdp, s, length, MCS_GLOBAL_CHANNEL_ID)) return FALSE; @@ -877,7 +885,6 @@ BOOL rdp_send_pdu(rdpRdp* rdp, wStream* s, UINT16 type, UINT16 channel_id) BOOL rdp_send_data_pdu(rdpRdp* rdp, wStream* s, BYTE type, UINT16 channel_id) { BOOL rc = FALSE; - size_t length = 0; UINT32 sec_bytes = 0; size_t sec_hold = 0; UINT32 pad = 0; @@ -888,7 +895,7 @@ BOOL rdp_send_data_pdu(rdpRdp* rdp, wStream* s, BYTE type, UINT16 channel_id) if (!rdp) goto fail; - length = Stream_GetPosition(s); + size_t length = Stream_GetPosition(s); Stream_SetPosition(s, 0); if (!rdp_write_header(rdp, s, length, MCS_GLOBAL_CHANNEL_ID)) goto fail; @@ -924,13 +931,12 @@ fail: BOOL rdp_send_message_channel_pdu(rdpRdp* rdp, wStream* s, UINT16 sec_flags) { BOOL rc = FALSE; - UINT16 length = 0; UINT32 pad = 0; WINPR_ASSERT(rdp); WINPR_ASSERT(s); - length = Stream_GetPosition(s); + size_t length = Stream_GetPosition(s); Stream_SetPosition(s, 0); if (!rdp_write_header(rdp, s, length, rdp->mcs->messageChannelId)) goto fail; diff --git a/libfreerdp/core/rdp.h b/libfreerdp/core/rdp.h index a4eaf47f3..7f9bb3b14 100644 --- a/libfreerdp/core/rdp.h +++ b/libfreerdp/core/rdp.h @@ -223,7 +223,7 @@ FREERDP_LOCAL wStream* rdp_send_stream_init(rdpRdp* rdp); FREERDP_LOCAL wStream* rdp_send_stream_pdu_init(rdpRdp* rdp); FREERDP_LOCAL BOOL rdp_read_header(rdpRdp* rdp, wStream* s, UINT16* length, UINT16* channel_id); -FREERDP_LOCAL BOOL rdp_write_header(rdpRdp* rdp, wStream* s, UINT16 length, UINT16 channel_id); +FREERDP_LOCAL BOOL rdp_write_header(rdpRdp* rdp, wStream* s, size_t length, UINT16 channel_id); FREERDP_LOCAL BOOL rdp_send_pdu(rdpRdp* rdp, wStream* s, UINT16 type, UINT16 channel_id); diff --git a/libfreerdp/core/tpkt.c b/libfreerdp/core/tpkt.c index 2e84c661b..4796da9af 100644 --- a/libfreerdp/core/tpkt.c +++ b/libfreerdp/core/tpkt.c @@ -160,7 +160,7 @@ BOOL tpkt_ensure_stream_consumed_(wStream* s, size_t length, const char* fkt) * @return \b TRUE for success, \b FALSE otherwise */ -BOOL tpkt_write_header(wStream* s, UINT16 length) +BOOL tpkt_write_header(wStream* s, size_t length) { if (!Stream_CheckAndLogRequiredCapacity(TAG, (s), 4)) return FALSE; diff --git a/libfreerdp/core/tpkt.h b/libfreerdp/core/tpkt.h index 9bb278198..a24058dcd 100644 --- a/libfreerdp/core/tpkt.h +++ b/libfreerdp/core/tpkt.h @@ -30,7 +30,7 @@ FREERDP_LOCAL int tpkt_verify_header(wStream* s); FREERDP_LOCAL BOOL tpkt_read_header(wStream* s, UINT16* length); -FREERDP_LOCAL BOOL tpkt_write_header(wStream* s, UINT16 length); +FREERDP_LOCAL BOOL tpkt_write_header(wStream* s, size_t length); #define tpkt_ensure_stream_consumed(s, length) tpkt_ensure_stream_consumed_((s), (length), __func__) FREERDP_LOCAL BOOL tpkt_ensure_stream_consumed_(wStream* s, size_t length, const char* fkt); diff --git a/libfreerdp/core/window.c b/libfreerdp/core/window.c index 7abe0c067..fe4ff67d1 100644 --- a/libfreerdp/core/window.c +++ b/libfreerdp/core/window.c @@ -929,7 +929,7 @@ static BOOL update_read_desktop_actively_monitored_order(wStream* s, WINDOW_ORDE monitored_desktop->windowIds = newid; /* windowIds */ - for (UINT32 i = 0; i < (int)monitored_desktop->numWindowIds; i++) + for (UINT32 i = 0; i < monitored_desktop->numWindowIds; i++) { Stream_Read_UINT32(s, monitored_desktop->windowIds[i]); } diff --git a/server/shadow/shadow_client.c b/server/shadow/shadow_client.c index 1e2213198..1ce4a762f 100644 --- a/server/shadow/shadow_client.c +++ b/server/shadow/shadow_client.c @@ -1687,10 +1687,10 @@ static BOOL shadow_client_send_bitmap_update(rdpShadowClient* client, BYTE* pSrc bitmap->destLeft = nXSrc + (xIdx * 64); bitmap->destTop = nYSrc + (yIdx * 64); - if ((INT64)(bitmap->destLeft + bitmap->width) > (nXSrc + nWidth)) + if (((INT64)bitmap->destLeft + bitmap->width) > (nXSrc + nWidth)) bitmap->width = (UINT32)(nXSrc + nWidth) - bitmap->destLeft; - if ((INT64)(bitmap->destTop + bitmap->height) > (nYSrc + nHeight)) + if (((INT64)bitmap->destTop + bitmap->height) > (nYSrc + nHeight)) bitmap->height = (UINT32)(nYSrc + nHeight) - bitmap->destTop; bitmap->destRight = bitmap->destLeft + bitmap->width - 1; diff --git a/winpr/libwinpr/sspi/sspi_winpr.c b/winpr/libwinpr/sspi/sspi_winpr.c index cd18f362e..c3a5bd64a 100644 --- a/winpr/libwinpr/sspi/sspi_winpr.c +++ b/winpr/libwinpr/sspi/sspi_winpr.c @@ -987,7 +987,7 @@ void sspi_GlobalFinish(void) static const SecurityFunctionTableA* sspi_GetSecurityFunctionTableAByNameA(const SEC_CHAR* Name) { - size_t cPackages = sizeof(SecPkgInfoA_LIST) / sizeof(*(SecPkgInfoA_LIST)); + size_t cPackages = ARRAYSIZE(SecPkgInfoA_LIST); for (size_t index = 0; index < cPackages; index++) { @@ -1002,7 +1002,7 @@ static const SecurityFunctionTableA* sspi_GetSecurityFunctionTableAByNameA(const static const SecurityFunctionTableW* sspi_GetSecurityFunctionTableWByNameW(const SEC_WCHAR* Name) { - size_t cPackages = sizeof(SecPkgInfoW_LIST) / sizeof(*(SecPkgInfoW_LIST)); + size_t cPackages = ARRAYSIZE(SecPkgInfoW_LIST); for (size_t index = 0; index < cPackages; index++) { @@ -1073,12 +1073,10 @@ static void sspi_ContextBufferFree(void* contextBuffer) static SECURITY_STATUS SEC_ENTRY winpr_EnumerateSecurityPackagesW(ULONG* pcPackages, PSecPkgInfoW* ppPackageInfo) { - size_t size = 0; - UINT32 cPackages = 0; - SecPkgInfoW* pPackageInfo = NULL; - cPackages = sizeof(SecPkgInfoW_LIST) / sizeof(*(SecPkgInfoW_LIST)); - size = sizeof(SecPkgInfoW) * cPackages; - pPackageInfo = (SecPkgInfoW*)sspi_ContextBufferAlloc(EnumerateSecurityPackagesIndex, size); + size_t cPackages = ARRAYSIZE(SecPkgInfoW_LIST); + size_t size = sizeof(SecPkgInfoW) * cPackages; + SecPkgInfoW* pPackageInfo = + (SecPkgInfoW*)sspi_ContextBufferAlloc(EnumerateSecurityPackagesIndex, size); if (!pPackageInfo) return SEC_E_INSUFFICIENT_MEMORY; @@ -1101,12 +1099,10 @@ static SECURITY_STATUS SEC_ENTRY winpr_EnumerateSecurityPackagesW(ULONG* pcPacka static SECURITY_STATUS SEC_ENTRY winpr_EnumerateSecurityPackagesA(ULONG* pcPackages, PSecPkgInfoA* ppPackageInfo) { - size_t size = 0; - UINT32 cPackages = 0; - SecPkgInfoA* pPackageInfo = NULL; - cPackages = sizeof(SecPkgInfoA_LIST) / sizeof(*(SecPkgInfoA_LIST)); - size = sizeof(SecPkgInfoA) * cPackages; - pPackageInfo = (SecPkgInfoA*)sspi_ContextBufferAlloc(EnumerateSecurityPackagesIndex, size); + size_t cPackages = ARRAYSIZE(SecPkgInfoA_LIST); + size_t size = sizeof(SecPkgInfoA) * cPackages; + SecPkgInfoA* pPackageInfo = + (SecPkgInfoA*)sspi_ContextBufferAlloc(EnumerateSecurityPackagesIndex, size); if (!pPackageInfo) return SEC_E_INSUFFICIENT_MEMORY; @@ -1134,9 +1130,8 @@ static SECURITY_STATUS SEC_ENTRY winpr_EnumerateSecurityPackagesA(ULONG* pcPacka static void FreeContextBuffer_EnumerateSecurityPackages(void* contextBuffer) { - UINT32 cPackages = 0; SecPkgInfoA* pPackageInfo = (SecPkgInfoA*)contextBuffer; - cPackages = sizeof(SecPkgInfoA_LIST) / sizeof(*(SecPkgInfoA_LIST)); + size_t cPackages = ARRAYSIZE(SecPkgInfoA_LIST); if (!pPackageInfo) return; @@ -1163,16 +1158,14 @@ SecurityFunctionTableA* SEC_ENTRY winpr_InitSecurityInterfaceA(void) static SECURITY_STATUS SEC_ENTRY winpr_QuerySecurityPackageInfoW(SEC_WCHAR* pszPackageName, PSecPkgInfoW* ppPackageInfo) { - size_t size = 0; - SecPkgInfoW* pPackageInfo = NULL; - size_t cPackages = sizeof(SecPkgInfoW_LIST) / sizeof(*(SecPkgInfoW_LIST)); + size_t cPackages = ARRAYSIZE(SecPkgInfoW_LIST); for (size_t index = 0; index < cPackages; index++) { if (_wcscmp(pszPackageName, SecPkgInfoW_LIST[index]->Name) == 0) { - size = sizeof(SecPkgInfoW); - pPackageInfo = + size_t size = sizeof(SecPkgInfoW); + SecPkgInfoW* pPackageInfo = (SecPkgInfoW*)sspi_ContextBufferAlloc(QuerySecurityPackageInfoIndex, size); if (!pPackageInfo) @@ -1196,16 +1189,14 @@ static SECURITY_STATUS SEC_ENTRY winpr_QuerySecurityPackageInfoW(SEC_WCHAR* pszP static SECURITY_STATUS SEC_ENTRY winpr_QuerySecurityPackageInfoA(SEC_CHAR* pszPackageName, PSecPkgInfoA* ppPackageInfo) { - size_t size = 0; - SecPkgInfoA* pPackageInfo = NULL; - size_t cPackages = sizeof(SecPkgInfoA_LIST) / sizeof(*(SecPkgInfoA_LIST)); + size_t cPackages = ARRAYSIZE(SecPkgInfoA_LIST); for (size_t index = 0; index < cPackages; index++) { if (strcmp(pszPackageName, SecPkgInfoA_LIST[index]->Name) == 0) { - size = sizeof(SecPkgInfoA); - pPackageInfo = + size_t size = sizeof(SecPkgInfoA); + SecPkgInfoA* pPackageInfo = (SecPkgInfoA*)sspi_ContextBufferAlloc(QuerySecurityPackageInfoIndex, size); if (!pPackageInfo)