diff --git a/channels/ainput/common/ainput_common.h b/channels/ainput/common/ainput_common.h index 9176692f4..a7357fe5c 100644 --- a/channels/ainput/common/ainput_common.h +++ b/channels/ainput/common/ainput_common.h @@ -25,6 +25,7 @@ #include +WINPR_ATTR_NODISCARD static inline const char* ainput_flags_to_string(UINT64 flags, char* buffer, size_t size) { char number[32] = { 0 }; diff --git a/channels/audin/client/opensles/opensl_io.h b/channels/audin/client/opensles/opensl_io.h index e99522cfe..4f9b2db4f 100644 --- a/channels/audin/client/opensles/opensl_io.h +++ b/channels/audin/client/opensles/opensl_io.h @@ -46,18 +46,20 @@ extern "C" typedef void (*opensl_receive_t)(void* context, const void* data, size_t size); - /* - Open the audio device with a given sampling rate (sr), input and output channels and IO buffer - size in frames. Returns a handle to the OpenSL stream - */ - FREERDP_LOCAL OPENSL_STREAM* android_OpenRecDevice(void* context, opensl_receive_t receive, - int sr, int inchannels, int bufferframes, - int bits_per_sample); /* Close the audio device */ FREERDP_LOCAL void android_CloseRecDevice(OPENSL_STREAM* p); + /* + Open the audio device with a given sampling rate (sr), input and output channels and IO buffer + size in frames. Returns a handle to the OpenSL stream + */ + WINPR_ATTR_MALLOC(android_CloseRecDevice, 1) + WINPR_ATTR_NODISCARD + FREERDP_LOCAL OPENSL_STREAM* android_OpenRecDevice(void* context, opensl_receive_t receive, + int sr, int inchannels, int bufferframes, + int bits_per_sample); #ifdef __cplusplus }; #endif diff --git a/channels/client/addin.h b/channels/client/addin.h index 1b794e737..ecb6b3dfb 100644 --- a/channels/client/addin.h +++ b/channels/client/addin.h @@ -16,13 +16,21 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +#pragma once + +#include +#include + +#include typedef UINT (*MsgHandler)(LPVOID userdata, wStream* data); +WINPR_ATTR_NODISCARD FREERDP_API void* channel_client_create_handler(rdpContext* ctx, LPVOID userdata, MsgHandler handler, const char* channel_name); -UINT channel_client_post_message(void* MsgsHandle, LPVOID pData, UINT32 dataLength, - UINT32 totalLength, UINT32 dataFlags); +WINPR_ATTR_NODISCARD +FREERDP_LOCAL UINT channel_client_post_message(void* MsgsHandle, LPVOID pData, UINT32 dataLength, + UINT32 totalLength, UINT32 dataFlags); -UINT channel_client_quit_handler(void* MsgsHandle); +FREERDP_LOCAL UINT channel_client_quit_handler(void* MsgsHandle); diff --git a/channels/cliprdr/client/cliprdr_format.h b/channels/cliprdr/client/cliprdr_format.h index a3ba1ed1b..80c10841f 100644 --- a/channels/cliprdr/client/cliprdr_format.h +++ b/channels/cliprdr/client/cliprdr_format.h @@ -23,14 +23,30 @@ #ifndef FREERDP_CHANNEL_CLIPRDR_CLIENT_FORMAT_H #define FREERDP_CHANNEL_CLIPRDR_CLIENT_FORMAT_H +#include + +WINPR_ATTR_NODISCARD +FREERDP_LOCAL UINT cliprdr_process_format_list(cliprdrPlugin* cliprdr, wStream* s, UINT32 dataLen, UINT16 msgFlags); + +WINPR_ATTR_NODISCARD +FREERDP_LOCAL UINT cliprdr_process_format_list_response(cliprdrPlugin* cliprdr, wStream* s, UINT32 dataLen, UINT16 msgFlags); + +WINPR_ATTR_NODISCARD +FREERDP_LOCAL UINT cliprdr_process_format_data_request(cliprdrPlugin* cliprdr, wStream* s, UINT32 dataLen, UINT16 msgFlags); + +WINPR_ATTR_NODISCARD +FREERDP_LOCAL UINT cliprdr_process_format_data_response(cliprdrPlugin* cliprdr, wStream* s, UINT32 dataLen, UINT16 msgFlags); + +WINPR_ATTR_NODISCARD +FREERDP_LOCAL CLIPRDR_FORMAT_LIST cliprdr_filter_format_list(const CLIPRDR_FORMAT_LIST* list, const UINT32 mask, const UINT32 checkMask); diff --git a/channels/cliprdr/client/cliprdr_main.h b/channels/cliprdr/client/cliprdr_main.h index d7b60c15e..42b6b5926 100644 --- a/channels/cliprdr/client/cliprdr_main.h +++ b/channels/cliprdr/client/cliprdr_main.h @@ -50,10 +50,14 @@ typedef struct BOOL initialFormatListSent; } cliprdrPlugin; -CliprdrClientContext* cliprdr_get_client_interface(cliprdrPlugin* cliprdr); -UINT cliprdr_send_error_response(cliprdrPlugin* cliprdr, UINT16 type); +WINPR_ATTR_NODISCARD +FREERDP_LOCAL CliprdrClientContext* cliprdr_get_client_interface(cliprdrPlugin* cliprdr); -extern const char type_FileGroupDescriptorW[]; -extern const char type_FileContents[]; +WINPR_ATTR_NODISCARD +FREERDP_LOCAL UINT cliprdr_send_error_response(cliprdrPlugin* cliprdr, UINT16 type); + +FREERDP_LOCAL extern const char type_FileGroupDescriptorW[]; + +FREERDP_LOCAL extern const char type_FileContents[]; #endif /* FREERDP_CHANNEL_CLIPRDR_CLIENT_MAIN_H */ diff --git a/channels/cliprdr/cliprdr_common.h b/channels/cliprdr/cliprdr_common.h index e848405d9..94b142683 100644 --- a/channels/cliprdr/cliprdr_common.h +++ b/channels/cliprdr/cliprdr_common.h @@ -29,33 +29,66 @@ #include #include +WINPR_ATTR_NODISCARD FREERDP_LOCAL const char* CB_MSG_TYPE_STRING(UINT16 type, char* buffer, size_t size); + +WINPR_ATTR_NODISCARD FREERDP_LOCAL const char* CB_MSG_FLAGS_STRING(UINT16 msgFlags, char* buffer, size_t size); +WINPR_ATTR_MALLOC(Stream_Free, 1) +WINPR_ATTR_NODISCARD FREERDP_LOCAL wStream* cliprdr_packet_new(UINT16 msgType, UINT16 msgFlags, size_t dataLen); + +WINPR_ATTR_MALLOC(Stream_Free, 1) +WINPR_ATTR_NODISCARD FREERDP_LOCAL wStream* cliprdr_packet_lock_clipdata_new(const CLIPRDR_LOCK_CLIPBOARD_DATA* lockClipboardData); + +WINPR_ATTR_MALLOC(Stream_Free, 1) +WINPR_ATTR_NODISCARD FREERDP_LOCAL wStream* cliprdr_packet_unlock_clipdata_new(const CLIPRDR_UNLOCK_CLIPBOARD_DATA* unlockClipboardData); + +WINPR_ATTR_MALLOC(Stream_Free, 1) +WINPR_ATTR_NODISCARD FREERDP_LOCAL wStream* cliprdr_packet_file_contents_request_new(const CLIPRDR_FILE_CONTENTS_REQUEST* request); + +WINPR_ATTR_MALLOC(Stream_Free, 1) +WINPR_ATTR_NODISCARD FREERDP_LOCAL wStream* cliprdr_packet_file_contents_response_new(const CLIPRDR_FILE_CONTENTS_RESPONSE* response); + +WINPR_ATTR_MALLOC(Stream_Free, 1) +WINPR_ATTR_NODISCARD FREERDP_LOCAL wStream* cliprdr_packet_format_list_new(const CLIPRDR_FORMAT_LIST* formatList, BOOL useLongFormatNames, BOOL useAsciiNames); +WINPR_ATTR_NODISCARD FREERDP_LOCAL UINT cliprdr_read_lock_clipdata(wStream* s, CLIPRDR_LOCK_CLIPBOARD_DATA* lockClipboardData); + +WINPR_ATTR_NODISCARD FREERDP_LOCAL UINT cliprdr_read_unlock_clipdata(wStream* s, CLIPRDR_UNLOCK_CLIPBOARD_DATA* unlockClipboardData); + +WINPR_ATTR_NODISCARD FREERDP_LOCAL UINT cliprdr_read_format_data_request(wStream* s, CLIPRDR_FORMAT_DATA_REQUEST* formatDataRequest); + +WINPR_ATTR_NODISCARD FREERDP_LOCAL UINT cliprdr_read_format_data_response(wStream* s, CLIPRDR_FORMAT_DATA_RESPONSE* response); + +WINPR_ATTR_NODISCARD FREERDP_LOCAL UINT cliprdr_read_file_contents_request(wStream* s, CLIPRDR_FILE_CONTENTS_REQUEST* fileContentsRequest); + +WINPR_ATTR_NODISCARD FREERDP_LOCAL UINT cliprdr_read_file_contents_response(wStream* s, CLIPRDR_FILE_CONTENTS_RESPONSE* response); + +WINPR_ATTR_NODISCARD FREERDP_LOCAL UINT cliprdr_read_format_list(wLog* log, wStream* s, CLIPRDR_FORMAT_LIST* formatList, BOOL useLongFormatNames); diff --git a/channels/disp/disp_common.h b/channels/disp/disp_common.h index 386b8b39d..d13f4f839 100644 --- a/channels/disp/disp_common.h +++ b/channels/disp/disp_common.h @@ -26,7 +26,10 @@ #include #include +WINPR_ATTR_NODISCARD FREERDP_LOCAL UINT disp_read_header(wStream* s, DISPLAY_CONTROL_HEADER* header); + +WINPR_ATTR_NODISCARD FREERDP_LOCAL UINT disp_write_header(wStream* s, const DISPLAY_CONTROL_HEADER* header); #endif /* FREERDP_CHANNEL_DISP_COMMON_H */ diff --git a/channels/drive/client/drive_file.h b/channels/drive/client/drive_file.h index 761295b65..9c5c8f161 100644 --- a/channels/drive/client/drive_file.h +++ b/channels/drive/client/drive_file.h @@ -28,6 +28,8 @@ #include #include + +#include #include #define TAG CHANNELS_TAG("drive.client") @@ -49,19 +51,34 @@ typedef struct UINT32 CreateOptions; } DRIVE_FILE; -DRIVE_FILE* drive_file_new(const WCHAR* base_path, const WCHAR* path, UINT32 PathWCharLength, - UINT32 id, UINT32 DesiredAccess, UINT32 CreateDisposition, - UINT32 CreateOptions, UINT32 FileAttributes, UINT32 SharedAccess); -BOOL drive_file_free(DRIVE_FILE* file); +FREERDP_LOCAL BOOL drive_file_free(DRIVE_FILE* file); -BOOL drive_file_open(DRIVE_FILE* file); -BOOL drive_file_seek(DRIVE_FILE* file, UINT64 Offset); -BOOL drive_file_read(DRIVE_FILE* file, BYTE* buffer, UINT32* Length); -BOOL drive_file_write(DRIVE_FILE* file, const BYTE* buffer, UINT32 Length); -BOOL drive_file_query_information(DRIVE_FILE* file, UINT32 FsInformationClass, wStream* output); -BOOL drive_file_set_information(DRIVE_FILE* file, UINT32 FsInformationClass, UINT32 Length, - wStream* input); -BOOL drive_file_query_directory(DRIVE_FILE* file, UINT32 FsInformationClass, BYTE InitialQuery, - const WCHAR* path, UINT32 PathWCharLength, wStream* output); +WINPR_ATTR_MALLOC(drive_file_free, 1) +WINPR_ATTR_NODISCARD FREERDP_LOCAL DRIVE_FILE* +drive_file_new(const WCHAR* base_path, const WCHAR* path, UINT32 PathWCharLength, UINT32 id, + UINT32 DesiredAccess, UINT32 CreateDisposition, UINT32 CreateOptions, + UINT32 FileAttributes, UINT32 SharedAccess); + +WINPR_ATTR_NODISCARD FREERDP_LOCAL BOOL drive_file_open(DRIVE_FILE* file); + +WINPR_ATTR_NODISCARD FREERDP_LOCAL BOOL drive_file_seek(DRIVE_FILE* file, UINT64 Offset); + +WINPR_ATTR_NODISCARD FREERDP_LOCAL BOOL drive_file_read(DRIVE_FILE* file, BYTE* buffer, + UINT32* Length); + +WINPR_ATTR_NODISCARD FREERDP_LOCAL BOOL drive_file_write(DRIVE_FILE* file, const BYTE* buffer, + UINT32 Length); + +WINPR_ATTR_NODISCARD FREERDP_LOCAL BOOL drive_file_query_information(DRIVE_FILE* file, + UINT32 FsInformationClass, + wStream* output); + +WINPR_ATTR_NODISCARD FREERDP_LOCAL BOOL drive_file_set_information(DRIVE_FILE* file, + UINT32 FsInformationClass, + UINT32 Length, wStream* input); + +WINPR_ATTR_NODISCARD FREERDP_LOCAL BOOL +drive_file_query_directory(DRIVE_FILE* file, UINT32 FsInformationClass, BYTE InitialQuery, + const WCHAR* path, UINT32 PathWCharLength, wStream* output); #endif /* FREERDP_CHANNEL_DRIVE_FILE_H */ diff --git a/channels/gfxredir/common/gfxredir_common.h b/channels/gfxredir/common/gfxredir_common.h index 18710a9ab..506172f97 100644 --- a/channels/gfxredir/common/gfxredir_common.h +++ b/channels/gfxredir/common/gfxredir_common.h @@ -26,7 +26,10 @@ #include #include +WINPR_ATTR_NODISCARD FREERDP_LOCAL UINT gfxredir_read_header(wStream* s, GFXREDIR_HEADER* header); + +WINPR_ATTR_NODISCARD FREERDP_LOCAL UINT gfxredir_write_header(wStream* s, const GFXREDIR_HEADER* header); #endif /* FREERDP_CHANNEL_GFXREDIR_COMMON_H */ diff --git a/channels/rail/client/rail_main.h b/channels/rail/client/rail_main.h index 2cbc6c155..7c2a93ef5 100644 --- a/channels/rail/client/rail_main.h +++ b/channels/rail/client/rail_main.h @@ -54,7 +54,8 @@ typedef struct BOOL sendHandshake; } railPlugin; -RailClientContext* rail_get_client_interface(railPlugin* rail); -UINT rail_send_channel_data(railPlugin* rail, wStream* s); +WINPR_ATTR_NODISCARD FREERDP_LOCAL RailClientContext* rail_get_client_interface(railPlugin* rail); + +WINPR_ATTR_NODISCARD FREERDP_LOCAL UINT rail_send_channel_data(railPlugin* rail, wStream* s); #endif /* FREERDP_CHANNEL_RAIL_CLIENT_MAIN_H */ diff --git a/channels/rail/client/rail_orders.h b/channels/rail/client/rail_orders.h index 6817fa1d5..8f887dc2a 100644 --- a/channels/rail/client/rail_orders.h +++ b/channels/rail/client/rail_orders.h @@ -29,34 +29,61 @@ #define TAG CHANNELS_TAG("rail.client") -UINT rail_order_recv(LPVOID userdata, wStream* s); -UINT rail_send_pdu(railPlugin* rail, wStream* s, UINT16 orderType); +WINPR_ATTR_NODISCARD FREERDP_LOCAL UINT rail_order_recv(LPVOID userdata, wStream* s); -UINT rail_send_handshake_order(railPlugin* rail, const RAIL_HANDSHAKE_ORDER* handshake); -UINT rail_send_handshake_ex_order(railPlugin* rail, const RAIL_HANDSHAKE_EX_ORDER* handshakeEx); -UINT rail_send_client_status_order(railPlugin* rail, const RAIL_CLIENT_STATUS_ORDER* clientStatus); -UINT rail_send_client_exec_order(railPlugin* rail, UINT16 flags, - const RAIL_UNICODE_STRING* exeOrFile, - const RAIL_UNICODE_STRING* workingDir, - const RAIL_UNICODE_STRING* arguments); -UINT rail_send_client_activate_order(railPlugin* rail, const RAIL_ACTIVATE_ORDER* activate); -UINT rail_send_client_sysmenu_order(railPlugin* rail, const RAIL_SYSMENU_ORDER* sysmenu); -UINT rail_send_client_syscommand_order(railPlugin* rail, const RAIL_SYSCOMMAND_ORDER* syscommand); +WINPR_ATTR_NODISCARD FREERDP_LOCAL UINT rail_send_pdu(railPlugin* rail, wStream* s, + UINT16 orderType); -UINT rail_send_client_notify_event_order(railPlugin* rail, - const RAIL_NOTIFY_EVENT_ORDER* notifyEvent); -UINT rail_send_client_window_move_order(railPlugin* rail, const RAIL_WINDOW_MOVE_ORDER* windowMove); -UINT rail_send_client_get_appid_req_order(railPlugin* rail, - const RAIL_GET_APPID_REQ_ORDER* getAppIdReq); -UINT rail_send_client_langbar_info_order(railPlugin* rail, - const RAIL_LANGBAR_INFO_ORDER* langBarInfo); -UINT rail_send_client_languageime_info_order(railPlugin* rail, - const RAIL_LANGUAGEIME_INFO_ORDER* langImeInfo); -UINT rail_send_client_cloak_order(railPlugin* rail, const RAIL_CLOAK* cloak); -UINT rail_send_client_snap_arrange_order(railPlugin* rail, const RAIL_SNAP_ARRANGE* snap); -UINT rail_send_client_compartment_info_order(railPlugin* rail, - const RAIL_COMPARTMENT_INFO_ORDER* compartmentInfo); -UINT rail_send_client_text_scale_order(railPlugin* rail, UINT32 textScale); -UINT rail_send_client_caret_blink_rate_order(railPlugin* rail, UINT32 rate); +WINPR_ATTR_NODISCARD FREERDP_LOCAL UINT +rail_send_handshake_order(railPlugin* rail, const RAIL_HANDSHAKE_ORDER* handshake); + +WINPR_ATTR_NODISCARD FREERDP_LOCAL UINT +rail_send_handshake_ex_order(railPlugin* rail, const RAIL_HANDSHAKE_EX_ORDER* handshakeEx); + +WINPR_ATTR_NODISCARD FREERDP_LOCAL UINT +rail_send_client_status_order(railPlugin* rail, const RAIL_CLIENT_STATUS_ORDER* clientStatus); + +WINPR_ATTR_NODISCARD FREERDP_LOCAL UINT rail_send_client_exec_order( + railPlugin* rail, UINT16 flags, const RAIL_UNICODE_STRING* exeOrFile, + const RAIL_UNICODE_STRING* workingDir, const RAIL_UNICODE_STRING* arguments); + +WINPR_ATTR_NODISCARD FREERDP_LOCAL UINT +rail_send_client_activate_order(railPlugin* rail, const RAIL_ACTIVATE_ORDER* activate); + +WINPR_ATTR_NODISCARD FREERDP_LOCAL UINT +rail_send_client_sysmenu_order(railPlugin* rail, const RAIL_SYSMENU_ORDER* sysmenu); + +WINPR_ATTR_NODISCARD FREERDP_LOCAL UINT +rail_send_client_syscommand_order(railPlugin* rail, const RAIL_SYSCOMMAND_ORDER* syscommand); + +WINPR_ATTR_NODISCARD FREERDP_LOCAL UINT +rail_send_client_notify_event_order(railPlugin* rail, const RAIL_NOTIFY_EVENT_ORDER* notifyEvent); + +WINPR_ATTR_NODISCARD FREERDP_LOCAL UINT +rail_send_client_window_move_order(railPlugin* rail, const RAIL_WINDOW_MOVE_ORDER* windowMove); + +WINPR_ATTR_NODISCARD FREERDP_LOCAL UINT +rail_send_client_get_appid_req_order(railPlugin* rail, const RAIL_GET_APPID_REQ_ORDER* getAppIdReq); + +WINPR_ATTR_NODISCARD FREERDP_LOCAL UINT +rail_send_client_langbar_info_order(railPlugin* rail, const RAIL_LANGBAR_INFO_ORDER* langBarInfo); + +WINPR_ATTR_NODISCARD FREERDP_LOCAL UINT rail_send_client_languageime_info_order( + railPlugin* rail, const RAIL_LANGUAGEIME_INFO_ORDER* langImeInfo); + +WINPR_ATTR_NODISCARD FREERDP_LOCAL UINT rail_send_client_cloak_order(railPlugin* rail, + const RAIL_CLOAK* cloak); + +WINPR_ATTR_NODISCARD FREERDP_LOCAL UINT +rail_send_client_snap_arrange_order(railPlugin* rail, const RAIL_SNAP_ARRANGE* snap); + +WINPR_ATTR_NODISCARD FREERDP_LOCAL UINT rail_send_client_compartment_info_order( + railPlugin* rail, const RAIL_COMPARTMENT_INFO_ORDER* compartmentInfo); + +WINPR_ATTR_NODISCARD FREERDP_LOCAL UINT rail_send_client_text_scale_order(railPlugin* rail, + UINT32 textScale); + +WINPR_ATTR_NODISCARD FREERDP_LOCAL UINT rail_send_client_caret_blink_rate_order(railPlugin* rail, + UINT32 rate); #endif /* FREERDP_CHANNEL_RAIL_CLIENT_ORDERS_H */ diff --git a/channels/rail/rail_common.h b/channels/rail/rail_common.h index 4233a8985..df6106f63 100644 --- a/channels/rail/rail_common.h +++ b/channels/rail/rail_common.h @@ -54,23 +54,45 @@ #define RAIL_GET_APPID_RESP_ORDER_LENGTH 524 /* fixed */ #define RAIL_GET_APPID_RESP_EX_ORDER_LENGTH 1048 /* fixed */ -UINT rail_read_handshake_order(wStream* s, RAIL_HANDSHAKE_ORDER* handshake); +WINPR_ATTR_NODISCARD FREERDP_LOCAL UINT rail_read_handshake_order(wStream* s, + RAIL_HANDSHAKE_ORDER* handshake); + +FREERDP_LOCAL void rail_write_handshake_order(wStream* s, const RAIL_HANDSHAKE_ORDER* handshake); -UINT rail_read_handshake_ex_order(wStream* s, RAIL_HANDSHAKE_EX_ORDER* handshakeEx); + +WINPR_ATTR_NODISCARD FREERDP_LOCAL UINT +rail_read_handshake_ex_order(wStream* s, RAIL_HANDSHAKE_EX_ORDER* handshakeEx); + +FREERDP_LOCAL void rail_write_handshake_ex_order(wStream* s, const RAIL_HANDSHAKE_EX_ORDER* handshakeEx); -wStream* rail_pdu_init(size_t length); -UINT rail_read_pdu_header(wStream* s, UINT16* orderType, UINT16* orderLength); +WINPR_ATTR_MALLOC(Stream_Free, 1) +WINPR_ATTR_NODISCARD FREERDP_LOCAL wStream* rail_pdu_init(size_t length); + +WINPR_ATTR_NODISCARD FREERDP_LOCAL UINT rail_read_pdu_header(wStream* s, UINT16* orderType, + UINT16* orderLength); + +FREERDP_LOCAL void rail_write_pdu_header(wStream* s, UINT16 orderType, UINT16 orderLength); -UINT rail_write_unicode_string(wStream* s, const RAIL_UNICODE_STRING* unicode_string); -UINT rail_write_unicode_string_value(wStream* s, const RAIL_UNICODE_STRING* unicode_string); +WINPR_ATTR_NODISCARD FREERDP_LOCAL UINT +rail_write_unicode_string(wStream* s, const RAIL_UNICODE_STRING* unicode_string); -UINT rail_read_sysparam_order(wStream* s, RAIL_SYSPARAM_ORDER* sysparam, BOOL extendedSpiSupported); -UINT rail_write_sysparam_order(wStream* s, const RAIL_SYSPARAM_ORDER* sysparam, - BOOL extendedSpiSupported); -BOOL rail_is_extended_spi_supported(UINT32 channelFlags); -const char* rail_get_order_type_string(UINT16 orderType); -const char* rail_get_order_type_string_full(UINT16 orderType, char* buffer, size_t length); +WINPR_ATTR_NODISCARD FREERDP_LOCAL UINT +rail_write_unicode_string_value(wStream* s, const RAIL_UNICODE_STRING* unicode_string); + +WINPR_ATTR_NODISCARD FREERDP_LOCAL UINT rail_read_sysparam_order(wStream* s, + RAIL_SYSPARAM_ORDER* sysparam, + BOOL extendedSpiSupported); + +WINPR_ATTR_NODISCARD FREERDP_LOCAL UINT rail_write_sysparam_order( + wStream* s, const RAIL_SYSPARAM_ORDER* sysparam, BOOL extendedSpiSupported); + +WINPR_ATTR_NODISCARD FREERDP_LOCAL BOOL rail_is_extended_spi_supported(UINT32 channelFlags); + +WINPR_ATTR_NODISCARD FREERDP_LOCAL const char* rail_get_order_type_string(UINT16 orderType); + +WINPR_ATTR_NODISCARD FREERDP_LOCAL const char* +rail_get_order_type_string_full(UINT16 orderType, char* buffer, size_t length); #endif /* FREERDP_CHANNEL_RAIL_COMMON_H */ diff --git a/channels/rail/server/rail_main.c b/channels/rail/server/rail_main.c index fb336a122..b0c985d7d 100644 --- a/channels/rail/server/rail_main.c +++ b/channels/rail/server/rail_main.c @@ -345,8 +345,9 @@ static UINT rail_send_server_sysparam(RailServerContext* context, return CHANNEL_RC_NO_MEMORY; } - rail_write_sysparam_order(s, sysparam, extendedSpiSupported); - error = rail_server_send_pdu(context, s, TS_RAIL_ORDER_SYSPARAM); + error = rail_write_sysparam_order(s, sysparam, extendedSpiSupported); + if (error == CHANNEL_RC_OK) + error = rail_server_send_pdu(context, s, TS_RAIL_ORDER_SYSPARAM); Stream_Free(s, TRUE); return error; } diff --git a/channels/rdpdr/client/devman.h b/channels/rdpdr/client/devman.h index 060038c9b..7cd66bc67 100644 --- a/channels/rdpdr/client/devman.h +++ b/channels/rdpdr/client/devman.h @@ -23,14 +23,25 @@ #ifndef FREERDP_CHANNEL_RDPDR_CLIENT_DEVMAN_H #define FREERDP_CHANNEL_RDPDR_CLIENT_DEVMAN_H +#include + #include "rdpdr_main.h" -void devman_unregister_device(DEVMAN* devman, void* key); -UINT devman_load_device_service(DEVMAN* devman, RDPDR_DEVICE* device, rdpContext* rdpcontext); -DEVICE* devman_get_device_by_id(DEVMAN* devman, UINT32 id); -DEVICE* devman_get_device_by_type(DEVMAN* devman, UINT32 type); +FREERDP_LOCAL void devman_unregister_device(DEVMAN* devman, void* key); +FREERDP_LOCAL void devman_free(DEVMAN* devman); -DEVMAN* devman_new(rdpdrPlugin* rdpdr); -void devman_free(DEVMAN* devman); +WINPR_ATTR_NODISCARD +FREERDP_LOCAL UINT devman_load_device_service(DEVMAN* devman, RDPDR_DEVICE* device, + rdpContext* rdpcontext); + +WINPR_ATTR_NODISCARD +FREERDP_LOCAL DEVICE* devman_get_device_by_id(DEVMAN* devman, UINT32 id); + +WINPR_ATTR_NODISCARD +FREERDP_LOCAL DEVICE* devman_get_device_by_type(DEVMAN* devman, UINT32 type); + +WINPR_ATTR_MALLOC(devman_free, 1) +WINPR_ATTR_NODISCARD +FREERDP_LOCAL DEVMAN* devman_new(rdpdrPlugin* rdpdr); #endif /* FREERDP_CHANNEL_RDPDR_CLIENT_DEVMAN_H */ diff --git a/channels/rdpdr/client/irp.h b/channels/rdpdr/client/irp.h index 053829502..4fee61465 100644 --- a/channels/rdpdr/client/irp.h +++ b/channels/rdpdr/client/irp.h @@ -21,9 +21,11 @@ #ifndef FREERDP_CHANNEL_RDPDR_CLIENT_IRP_H #define FREERDP_CHANNEL_RDPDR_CLIENT_IRP_H +#include #include #include "rdpdr_main.h" -IRP* irp_new(DEVMAN* devman, wStreamPool* pool, wStream* s, wLog* log, UINT* error); +WINPR_ATTR_NODISCARD +FREERDP_LOCAL IRP* irp_new(DEVMAN* devman, wStreamPool* pool, wStream* s, wLog* log, UINT* error); #endif /* FREERDP_CHANNEL_RDPDR_CLIENT_IRP_H */ diff --git a/channels/rdpdr/client/rdpdr_capabilities.c b/channels/rdpdr/client/rdpdr_capabilities.c index 64a847b5a..145719816 100644 --- a/channels/rdpdr/client/rdpdr_capabilities.c +++ b/channels/rdpdr/client/rdpdr_capabilities.c @@ -189,7 +189,8 @@ UINT rdpdr_process_capability_request(rdpdrPlugin* rdpdr, wStream* s) if (!rdpdr || !s) return CHANNEL_RC_NULL_DATA; - rdpdr_state_advance(rdpdr, RDPDR_CHANNEL_STATE_CLIENT_CAPS); + if (!rdpdr_state_advance(rdpdr, RDPDR_CHANNEL_STATE_CLIENT_CAPS)) + return ERROR_INVALID_STATE; if (!Stream_CheckAndLogRequiredLengthWLog(rdpdr->log, s, 4)) return ERROR_INVALID_DATA; diff --git a/channels/rdpdr/client/rdpdr_capabilities.h b/channels/rdpdr/client/rdpdr_capabilities.h index d4e1ecb27..ca3b361c6 100644 --- a/channels/rdpdr/client/rdpdr_capabilities.h +++ b/channels/rdpdr/client/rdpdr_capabilities.h @@ -23,9 +23,14 @@ #ifndef FREERDP_CHANNEL_RDPDR_CLIENT_CAPABILITIES_H #define FREERDP_CHANNEL_RDPDR_CLIENT_CAPABILITIES_H +#include + #include "rdpdr_main.h" -UINT rdpdr_process_capability_request(rdpdrPlugin* rdpdr, wStream* s); -UINT rdpdr_send_capability_response(rdpdrPlugin* rdpdr); +WINPR_ATTR_NODISCARD +FREERDP_LOCAL UINT rdpdr_process_capability_request(rdpdrPlugin* rdpdr, wStream* s); + +WINPR_ATTR_NODISCARD +FREERDP_LOCAL UINT rdpdr_send_capability_response(rdpdrPlugin* rdpdr); #endif /* FREERDP_CHANNEL_RDPDR_CLIENT_CAPABILITIES_H */ diff --git a/channels/rdpdr/client/rdpdr_main.c b/channels/rdpdr/client/rdpdr_main.c index 7f4eef096..6082776c5 100644 --- a/channels/rdpdr/client/rdpdr_main.c +++ b/channels/rdpdr/client/rdpdr_main.c @@ -1268,13 +1268,12 @@ static UINT rdpdr_process_server_announce_request(rdpdrPlugin* rdpdr, wStream* s */ static UINT rdpdr_send_client_announce_reply(rdpdrPlugin* rdpdr) { - wStream* s = NULL; - WINPR_ASSERT(rdpdr); WINPR_ASSERT(rdpdr->state == RDPDR_CHANNEL_STATE_ANNOUNCE); - rdpdr_state_advance(rdpdr, RDPDR_CHANNEL_STATE_ANNOUNCE_REPLY); + if (!rdpdr_state_advance(rdpdr, RDPDR_CHANNEL_STATE_ANNOUNCE_REPLY)) + return ERROR_INVALID_STATE; - s = StreamPool_Take(rdpdr->pool, 12); + wStream* s = StreamPool_Take(rdpdr->pool, 12); if (!s) { @@ -1303,7 +1302,8 @@ static UINT rdpdr_send_client_name_request(rdpdrPlugin* rdpdr) WINPR_ASSERT(rdpdr); WINPR_ASSERT(rdpdr->state == RDPDR_CHANNEL_STATE_ANNOUNCE_REPLY); - rdpdr_state_advance(rdpdr, RDPDR_CHANNEL_STATE_NAME_REQUEST); + if (!rdpdr_state_advance(rdpdr, RDPDR_CHANNEL_STATE_NAME_REQUEST)) + return ERROR_INVALID_STATE; const size_t len = strnlen(rdpdr->computerName, sizeof(rdpdr->computerName)); if (len == 0) @@ -1677,7 +1677,8 @@ static BOOL rdpdr_state_check(rdpdrPlugin* rdpdr, UINT16 packetid, enum RDPDR_CH "channel [RDPDR] received %s, expected states [%s] but have state %s, aborting.", rdpdr_packetid_string(packetid), buffer, strstate); - rdpdr_state_advance(rdpdr, RDPDR_CHANNEL_STATE_INITIAL); + if (!rdpdr_state_advance(rdpdr, RDPDR_CHANNEL_STATE_INITIAL)) + return FALSE; return FALSE; } return rdpdr_state_advance(rdpdr, next); @@ -1694,7 +1695,8 @@ static BOOL rdpdr_check_channel_state(rdpdrPlugin* rdpdr, UINT16 packetid) * it seems related to session login (e.g. first initialization for RDP/TLS style login, * then reinitialize the channel after login successful */ - rdpdr_state_advance(rdpdr, RDPDR_CHANNEL_STATE_INITIAL); + if (!rdpdr_state_advance(rdpdr, RDPDR_CHANNEL_STATE_INITIAL)) + return ERROR_INVALID_STATE; return rdpdr_state_check(rdpdr, packetid, RDPDR_CHANNEL_STATE_ANNOUNCE, 1, RDPDR_CHANNEL_STATE_INITIAL); case PAKID_CORE_SERVER_CAPABILITY: diff --git a/channels/rdpdr/client/rdpdr_main.h b/channels/rdpdr/client/rdpdr_main.h index c0c7bdca3..58d58d2ba 100644 --- a/channels/rdpdr/client/rdpdr_main.h +++ b/channels/rdpdr/client/rdpdr_main.h @@ -118,7 +118,10 @@ typedef struct RdpdrClientContext context; } rdpdrPlugin; -BOOL rdpdr_state_advance(rdpdrPlugin* rdpdr, enum RDPDR_CHANNEL_STATE next); -UINT rdpdr_send(rdpdrPlugin* rdpdr, wStream* s); +WINPR_ATTR_NODISCARD +FREERDP_LOCAL BOOL rdpdr_state_advance(rdpdrPlugin* rdpdr, enum RDPDR_CHANNEL_STATE next); + +WINPR_ATTR_NODISCARD +FREERDP_LOCAL UINT rdpdr_send(rdpdrPlugin* rdpdr, wStream* s); #endif /* FREERDP_CHANNEL_RDPDR_CLIENT_MAIN_H */ diff --git a/channels/rdpear/common/rdpear-common/ndr.h b/channels/rdpear/common/rdpear-common/ndr.h index dcc1ecabc..6f630c290 100644 --- a/channels/rdpear/common/rdpear-common/ndr.h +++ b/channels/rdpear/common/rdpear-common/ndr.h @@ -25,27 +25,35 @@ #define NDR_PTR_NULL (0UL) -#define NDR_SIMPLE_TYPE_DECL(LOWER, UPPER) \ - BOOL ndr_read_##LOWER(NdrContext* context, wStream* s, UPPER* v); \ - BOOL ndr_read_##LOWER##_(NdrContext* context, wStream* s, const void* hints, void* v); \ - BOOL ndr_write_##LOWER(NdrContext* context, wStream* s, UPPER v); \ - BOOL ndr_write_##LOWER##_(NdrContext* context, wStream* s, const void* hints, const void* v); \ - extern const NdrMessageDescr ndr_##LOWER##_descr_s; \ - NdrMessageType ndr_##LOWER##_descr(void) +#define NDR_SIMPLE_TYPE_DECL(LOWER, UPPER) \ + WINPR_ATTR_NODISCARD FREERDP_LOCAL BOOL ndr_read_##LOWER(NdrContext* context, wStream* s, \ + UPPER* v); \ + WINPR_ATTR_NODISCARD FREERDP_LOCAL BOOL ndr_read_##LOWER##_(NdrContext* context, wStream* s, \ + const void* hints, void* v); \ + WINPR_ATTR_NODISCARD FREERDP_LOCAL BOOL ndr_write_##LOWER(NdrContext* context, wStream* s, \ + UPPER v); \ + WINPR_ATTR_NODISCARD FREERDP_LOCAL BOOL ndr_write_##LOWER##_( \ + NdrContext* context, wStream* s, const void* hints, const void* v); \ + FREERDP_LOCAL \ + extern const NdrMessageDescr ndr_##LOWER##_descr_s; \ + WINPR_ATTR_NODISCARD FREERDP_LOCAL NdrMessageType ndr_##LOWER##_descr(void) -#define NDR_ARRAY_OF_TYPE_DECL(TYPE, UPPERTYPE) \ - BOOL ndr_read_##TYPE##Array(NdrContext* context, wStream* s, const void* hints, void* v); \ - BOOL ndr_write_##TYPE##Array(NdrContext* context, wStream* s, const void* hints, \ - const void* v); \ - void ndr_destroy_##TYPE##Array(NdrContext* context, const void* hints, void* obj); \ - extern const NdrMessageDescr ndr_##TYPE##Array_descr_s; \ - NdrMessageType ndr_##TYPE##Array_descr(void); \ - \ - BOOL ndr_read_##TYPE##VaryingArray(NdrContext* context, wStream* s, const void* hints, \ - void* v); \ - BOOL ndr_write_##TYPE##VaryingArray(NdrContext* context, wStream* s, const void* hints, \ - const void* v); \ - extern const NdrMessageDescr ndr_##TYPE##VaryingArray_descr_s; \ +#define NDR_ARRAY_OF_TYPE_DECL(TYPE, UPPERTYPE) \ + WINPR_ATTR_NODISCARD FREERDP_LOCAL BOOL ndr_read_##TYPE##Array( \ + NdrContext* context, wStream* s, const void* hints, void* v); \ + WINPR_ATTR_NODISCARD FREERDP_LOCAL BOOL ndr_write_##TYPE##Array( \ + NdrContext* context, wStream* s, const void* hints, const void* v); \ + FREERDP_LOCAL \ + void ndr_destroy_##TYPE##Array(NdrContext* context, const void* hints, void* obj); \ + FREERDP_LOCAL \ + extern const NdrMessageDescr ndr_##TYPE##Array_descr_s; \ + WINPR_ATTR_NODISCARD FREERDP_LOCAL NdrMessageType ndr_##TYPE##Array_descr(void); \ + \ + WINPR_ATTR_NODISCARD FREERDP_LOCAL BOOL ndr_read_##TYPE##VaryingArray( \ + NdrContext* context, wStream* s, const void* hints, void* v); \ + WINPR_ATTR_NODISCARD FREERDP_LOCAL BOOL ndr_write_##TYPE##VaryingArray( \ + NdrContext* context, wStream* s, const void* hints, const void* v); \ + extern const NdrMessageDescr ndr_##TYPE##VaryingArray_descr_s; \ NdrMessageType ndr_##TYPE##VaryingArray_descr(void) #ifdef __cplusplus @@ -120,7 +128,7 @@ extern "C" NdrMessageType msg; } NdrDeferredEntry; - void ndr_context_free(NdrContext* context); + FREERDP_LOCAL void ndr_context_free(NdrContext* context); static inline void ndr_context_destroy(NdrContext** pcontext) { @@ -131,19 +139,19 @@ extern "C" WINPR_ATTR_MALLOC(ndr_context_free, 1) WINPR_ATTR_NODISCARD - NdrContext* ndr_context_new(BOOL bigEndianDrep, BYTE version); + FREERDP_LOCAL NdrContext* ndr_context_new(BOOL bigEndianDrep, BYTE version); - void ndr_context_reset(NdrContext* context); + FREERDP_LOCAL void ndr_context_reset(NdrContext* context); WINPR_ATTR_MALLOC(ndr_context_free, 1) WINPR_ATTR_NODISCARD - NdrContext* ndr_context_copy(const NdrContext* src); + FREERDP_LOCAL NdrContext* ndr_context_copy(const NdrContext* src); WINPR_ATTR_MALLOC(ndr_context_free, 1) WINPR_ATTR_NODISCARD - NdrContext* ndr_read_header(wStream* s); + FREERDP_LOCAL NdrContext* ndr_read_header(wStream* s); - BOOL ndr_write_header(NdrContext* context, wStream* s); + WINPR_ATTR_NODISCARD FREERDP_LOCAL BOOL ndr_write_header(NdrContext* context, wStream* s); NDR_SIMPLE_TYPE_DECL(uint8, UINT8); NDR_SIMPLE_TYPE_DECL(uint16, UINT16); @@ -153,21 +161,34 @@ extern "C" NDR_ARRAY_OF_TYPE_DECL(uint8, BYTE); NDR_ARRAY_OF_TYPE_DECL(uint16, UINT16); - BOOL ndr_skip_bytes(NdrContext* context, wStream* s, size_t nbytes); - BOOL ndr_read_align(NdrContext* context, wStream* s, size_t sz); - BOOL ndr_write_align(NdrContext* context, wStream* s, size_t sz); - BOOL ndr_write_data(NdrContext* context, wStream* s, const void* data, size_t sz); + WINPR_ATTR_NODISCARD FREERDP_LOCAL BOOL ndr_skip_bytes(NdrContext* context, wStream* s, + size_t nbytes); - BOOL ndr_read_pickle(NdrContext* context, wStream* s); - BOOL ndr_write_pickle(NdrContext* context, wStream* s); + WINPR_ATTR_NODISCARD FREERDP_LOCAL BOOL ndr_read_align(NdrContext* context, wStream* s, + size_t sz); - BOOL ndr_read_constructed(NdrContext* context, wStream* s, wStream* target); - BOOL ndr_write_constructed(NdrContext* context, wStream* s, wStream* payload); + WINPR_ATTR_NODISCARD FREERDP_LOCAL BOOL ndr_write_align(NdrContext* context, wStream* s, + size_t sz); - BOOL ndr_start_constructed(NdrContext* context, wStream* s); - BOOL ndr_end_constructed(NdrContext* context, wStream* s); + WINPR_ATTR_NODISCARD FREERDP_LOCAL BOOL ndr_write_data(NdrContext* context, wStream* s, + const void* data, size_t sz); - BOOL ndr_read_wchar(NdrContext* context, wStream* s, WCHAR* ptr); + WINPR_ATTR_NODISCARD FREERDP_LOCAL BOOL ndr_read_pickle(NdrContext* context, wStream* s); + + WINPR_ATTR_NODISCARD FREERDP_LOCAL BOOL ndr_write_pickle(NdrContext* context, wStream* s); + + WINPR_ATTR_NODISCARD FREERDP_LOCAL BOOL ndr_read_constructed(NdrContext* context, wStream* s, + wStream* target); + + WINPR_ATTR_NODISCARD FREERDP_LOCAL BOOL ndr_write_constructed(NdrContext* context, wStream* s, + wStream* payload); + + WINPR_ATTR_NODISCARD FREERDP_LOCAL BOOL ndr_start_constructed(NdrContext* context, wStream* s); + + WINPR_ATTR_NODISCARD FREERDP_LOCAL BOOL ndr_end_constructed(NdrContext* context, wStream* s); + + WINPR_ATTR_NODISCARD FREERDP_LOCAL BOOL ndr_read_wchar(NdrContext* context, wStream* s, + WCHAR* ptr); /** @brief hints for a varying conformant array */ typedef struct @@ -176,12 +197,13 @@ extern "C" UINT32 maxLength; } NdrVaryingArrayHints; - BOOL ndr_read_uconformant_varying_array(NdrContext* context, wStream* s, - const NdrVaryingArrayHints* hints, - NdrMessageType itemType, void* ptarget); - BOOL ndr_write_uconformant_varying_array(NdrContext* context, wStream* s, - const NdrVaryingArrayHints* hints, - NdrMessageType itemType, const void* src); + WINPR_ATTR_NODISCARD FREERDP_LOCAL BOOL ndr_read_uconformant_varying_array( + NdrContext* context, wStream* s, const NdrVaryingArrayHints* hints, NdrMessageType itemType, + void* ptarget); + + WINPR_ATTR_NODISCARD FREERDP_LOCAL BOOL ndr_write_uconformant_varying_array( + NdrContext* context, wStream* s, const NdrVaryingArrayHints* hints, NdrMessageType itemType, + const void* src); /** @brief hints for a conformant array */ typedef struct @@ -189,30 +211,55 @@ extern "C" UINT32 count; } NdrArrayHints; - BOOL ndr_read_uconformant_array(NdrContext* context, wStream* s, const NdrArrayHints* hints, - NdrMessageType itemType, void* vtarget); - BOOL ndr_write_uconformant_array(NdrContext* context, wStream* s, UINT32 len, - NdrMessageType itemType, const BYTE* ptr); + WINPR_ATTR_NODISCARD FREERDP_LOCAL BOOL ndr_read_uconformant_array(NdrContext* context, + wStream* s, + const NdrArrayHints* hints, + NdrMessageType itemType, + void* vtarget); - BOOL ndr_struct_read_fromDescr(NdrContext* context, wStream* s, const NdrStructDescr* descr, - void* target); - BOOL ndr_struct_write_fromDescr(NdrContext* context, wStream* s, const NdrStructDescr* descr, - const void* src); + WINPR_ATTR_NODISCARD FREERDP_LOCAL BOOL ndr_write_uconformant_array(NdrContext* context, + wStream* s, UINT32 len, + NdrMessageType itemType, + const BYTE* ptr); + + WINPR_ATTR_NODISCARD FREERDP_LOCAL BOOL ndr_struct_read_fromDescr(NdrContext* context, + wStream* s, + const NdrStructDescr* descr, + void* target); + WINPR_ATTR_NODISCARD FREERDP_LOCAL BOOL ndr_struct_write_fromDescr(NdrContext* context, + wStream* s, + const NdrStructDescr* descr, + const void* src); + FREERDP_LOCAL void ndr_struct_dump_fromDescr(wLog* logger, UINT32 lvl, size_t identLevel, const NdrStructDescr* descr, const void* obj); + FREERDP_LOCAL void ndr_struct_destroy(NdrContext* context, const NdrStructDescr* descr, void* pptr); - ndr_refid ndr_pointer_refid(const void* ptr); - BOOL ndr_read_refpointer(NdrContext* context, wStream* s, UINT32* refId); - BOOL ndr_context_allocatePtr(NdrContext* context, const void* ptr, ndr_refid* prefId, - BOOL* pnewPtr); + WINPR_ATTR_NODISCARD FREERDP_LOCAL ndr_refid ndr_pointer_refid(const void* ptr); - BOOL ndr_read_pointedMessageEx(NdrContext* context, wStream* s, ndr_refid ptrId, - NdrMessageType descr, void* hints, void** target); + WINPR_ATTR_NODISCARD FREERDP_LOCAL BOOL ndr_read_refpointer(NdrContext* context, wStream* s, + UINT32* refId); - BOOL ndr_push_deferreds(NdrContext* context, NdrDeferredEntry* deferreds, size_t ndeferred); - BOOL ndr_treat_deferred_read(NdrContext* context, wStream* s); - BOOL ndr_treat_deferred_write(NdrContext* context, wStream* s); + WINPR_ATTR_NODISCARD FREERDP_LOCAL BOOL ndr_context_allocatePtr(NdrContext* context, + const void* ptr, + ndr_refid* prefId, + BOOL* pnewPtr); + + WINPR_ATTR_NODISCARD FREERDP_LOCAL BOOL ndr_read_pointedMessageEx(NdrContext* context, + wStream* s, ndr_refid ptrId, + NdrMessageType descr, + void* hints, void** target); + + WINPR_ATTR_NODISCARD FREERDP_LOCAL BOOL ndr_push_deferreds(NdrContext* context, + NdrDeferredEntry* deferreds, + size_t ndeferred); + + WINPR_ATTR_NODISCARD FREERDP_LOCAL BOOL ndr_treat_deferred_read(NdrContext* context, + wStream* s); + + WINPR_ATTR_NODISCARD FREERDP_LOCAL BOOL ndr_treat_deferred_write(NdrContext* context, + wStream* s); #ifdef __cplusplus } diff --git a/channels/rdpear/common/rdpear-common/rdpear_asn1.h b/channels/rdpear/common/rdpear-common/rdpear_asn1.h index 9b865fdcf..9cdb7bb3b 100644 --- a/channels/rdpear/common/rdpear-common/rdpear_asn1.h +++ b/channels/rdpear/common/rdpear-common/rdpear_asn1.h @@ -23,9 +23,14 @@ #include #include +#include -wStream* rdpear_enc_Checksum(UINT32 cksumtype, krb5_checksum* csum); +WINPR_ATTR_MALLOC(Stream_Free, 1) +WINPR_ATTR_NODISCARD FREERDP_LOCAL wStream* rdpear_enc_Checksum(UINT32 cksumtype, + krb5_checksum* csum); -wStream* rdpear_enc_EncryptedData(UINT32 encType, krb5_data* payload); +WINPR_ATTR_MALLOC(Stream_Free, 1) +WINPR_ATTR_NODISCARD FREERDP_LOCAL wStream* rdpear_enc_EncryptedData(UINT32 encType, + krb5_data* payload); #endif /* RPDEAR_RDPEAR_ASN1_H__ */ diff --git a/channels/rdpear/common/rdpear-common/rdpear_common.h b/channels/rdpear/common/rdpear-common/rdpear_common.h index e3a6a102a..af83e3fb6 100644 --- a/channels/rdpear/common/rdpear-common/rdpear_common.h +++ b/channels/rdpear/common/rdpear-common/rdpear_common.h @@ -79,17 +79,22 @@ typedef enum // End NTLM remote calls } RemoteGuardCallId; +WINPR_ATTR_NODISCARD FREERDP_LOCAL RdpEarPackageType rdpear_packageType_from_name(const WinPrAsn1_OctetString* package); + WINPR_ATTR_MALLOC(Stream_Free, 1) WINPR_ATTR_NODISCARD FREERDP_LOCAL wStream* rdpear_encodePayload(BOOL isKerb, wStream* payload); #define RDPEAR_COMMON_MESSAGE_DECL(V) \ + WINPR_ATTR_NODISCARD \ FREERDP_LOCAL BOOL ndr_read_##V(NdrContext* context, wStream* s, const void* hints, V* obj); \ + WINPR_ATTR_NODISCARD \ FREERDP_LOCAL BOOL ndr_write_##V(NdrContext* context, wStream* s, const void* hints, \ const V* obj); \ FREERDP_LOCAL void ndr_destroy_##V(NdrContext* context, const void* hints, V* obj); \ FREERDP_LOCAL void ndr_dump_##V(wLog* logger, UINT32 lvl, size_t indentLevel, const V* obj); \ + WINPR_ATTR_NODISCARD \ FREERDP_LOCAL NdrMessageType ndr_##V##_descr(void) /** @brief 2.2.1.2.2 KERB_RPC_OCTET_STRING */ diff --git a/channels/rdpecam/client/camera.h b/channels/rdpecam/client/camera.h index ce0be4e40..a9bb76ec5 100644 --- a/channels/rdpecam/client/camera.h +++ b/channels/rdpecam/client/camera.h @@ -127,10 +127,13 @@ typedef struct } CameraDeviceStream; +WINPR_ATTR_NODISCARD static inline CAM_MEDIA_FORMAT streamInputFormat(CameraDeviceStream* stream) { return stream->formats.inputFormat; } + +WINPR_ATTR_NODISCARD static inline CAM_MEDIA_FORMAT streamOutputFormat(CameraDeviceStream* stream) { return stream->formats.outputFormat; @@ -259,25 +262,35 @@ typedef WINPR_ATTR_NODISCARD UINT(VCAPITYPE* PFREERDP_CAMERA_HAL_ENTRY)(PFREERDP_CAMERA_HAL_ENTRY_POINTS pEntryPoints); /* common functions */ -UINT ecam_channel_send_generic_msg(CameraPlugin* ecam, GENERIC_CHANNEL_CALLBACK* hchannel, - CAM_MSG_ID msg); -UINT ecam_channel_send_error_response(CameraPlugin* ecam, GENERIC_CHANNEL_CALLBACK* hchannel, - CAM_ERROR_CODE code); -UINT ecam_channel_write(CameraPlugin* ecam, GENERIC_CHANNEL_CALLBACK* hchannel, CAM_MSG_ID msg, - wStream* out, BOOL freeStream); +WINPR_ATTR_NODISCARD FREERDP_LOCAL UINT ecam_channel_send_generic_msg( + CameraPlugin* ecam, GENERIC_CHANNEL_CALLBACK* hchannel, CAM_MSG_ID msg); + +FREERDP_LOCAL UINT ecam_channel_send_error_response(CameraPlugin* ecam, + GENERIC_CHANNEL_CALLBACK* hchannel, + CAM_ERROR_CODE code); + +WINPR_ATTR_NODISCARD FREERDP_LOCAL UINT ecam_channel_write(CameraPlugin* ecam, + GENERIC_CHANNEL_CALLBACK* hchannel, + CAM_MSG_ID msg, wStream* out, + BOOL freeStream); /* ecam device interface */ -void ecam_dev_destroy(CameraDevice* dev); +FREERDP_LOCAL void ecam_dev_destroy(CameraDevice* dev); WINPR_ATTR_MALLOC(ecam_dev_destroy, 1) WINPR_ATTR_NODISCARD -CameraDevice* ecam_dev_create(CameraPlugin* ecam, const char* deviceId, const char* deviceName); +FREERDP_LOCAL CameraDevice* ecam_dev_create(CameraPlugin* ecam, const char* deviceId, + const char* deviceName); /* video encoding interface */ -BOOL ecam_encoder_context_init(CameraDeviceStream* stream); -BOOL ecam_encoder_context_free(CameraDeviceStream* stream); -BOOL ecam_encoder_compress(CameraDeviceStream* stream, const BYTE* srcData, size_t srcSize, - BYTE** ppDstData, size_t* pDstSize); -UINT32 h264_get_max_bitrate(UINT32 height); +WINPR_ATTR_NODISCARD FREERDP_LOCAL BOOL ecam_encoder_context_init(CameraDeviceStream* stream); + +FREERDP_LOCAL BOOL ecam_encoder_context_free(CameraDeviceStream* stream); + +WINPR_ATTR_NODISCARD FREERDP_LOCAL BOOL ecam_encoder_compress(CameraDeviceStream* stream, + const BYTE* srcData, size_t srcSize, + BYTE** ppDstData, size_t* pDstSize); + +WINPR_ATTR_NODISCARD FREERDP_LOCAL UINT32 h264_get_max_bitrate(UINT32 height); #endif /* FREERDP_CLIENT_CAMERA_H */ diff --git a/channels/rdpecam/client/v4l/camera_v4l.c b/channels/rdpecam/client/v4l/camera_v4l.c index de5c5f454..d4faac078 100644 --- a/channels/rdpecam/client/v4l/camera_v4l.c +++ b/channels/rdpecam/client/v4l/camera_v4l.c @@ -487,8 +487,11 @@ static DWORD WINAPI cam_v4l_stream_capture_thread(LPVOID param) /* dequeue buffers until empty */ while (ioctl(fd, VIDIOC_DQBUF, &buf) != -1) { - stream->sampleCallback(stream->dev, stream->streamIndex, - stream->buffers[buf.index].start, buf.bytesused); + const UINT error = + stream->sampleCallback(stream->dev, stream->streamIndex, + stream->buffers[buf.index].start, buf.bytesused); + if (error != CHANNEL_RC_OK) + WLog_ERR(TAG, "Failure in sampleCallback: %" PRIu32, error); /* enqueue buffer back */ if (ioctl(fd, VIDIOC_QBUF, &buf) == -1) diff --git a/channels/rdpecam/client/v4l/camera_v4l.h b/channels/rdpecam/client/v4l/camera_v4l.h index 370154b5b..5d5de271a 100644 --- a/channels/rdpecam/client/v4l/camera_v4l.h +++ b/channels/rdpecam/client/v4l/camera_v4l.h @@ -39,7 +39,7 @@ typedef struct /* members used to call the callback */ CameraDevice* dev; size_t streamIndex; - ICamHalSampleCapturedCallback sampleCallback; + WINPR_ATTR_NODISCARD ICamHalSampleCapturedCallback sampleCallback; BOOL streaming; int fd; diff --git a/channels/rdpecam/client/v4l/uvc_h264.h b/channels/rdpecam/client/v4l/uvc_h264.h index c8a4e3ce4..b599e8230 100644 --- a/channels/rdpecam/client/v4l/uvc_h264.h +++ b/channels/rdpecam/client/v4l/uvc_h264.h @@ -163,7 +163,11 @@ typedef struct #define WINPR_PACK_POP #include -uint8_t get_uvc_h624_unit_id(const char* deviceId); -BOOL set_h264_muxed_format(CamV4lStream* stream, const CAM_MEDIA_TYPE_DESCRIPTION* mediaType); +WINPR_ATTR_NODISCARD +FREERDP_LOCAL uint8_t get_uvc_h624_unit_id(const char* deviceId); + +WINPR_ATTR_NODISCARD +FREERDP_LOCAL BOOL set_h264_muxed_format(CamV4lStream* stream, + const CAM_MEDIA_TYPE_DESCRIPTION* mediaType); #endif /* UVC_H264_H */ diff --git a/channels/rdpecam/common/rdpecam-utils.h b/channels/rdpecam/common/rdpecam-utils.h index 080cb0527..6e650ab63 100644 --- a/channels/rdpecam/common/rdpecam-utils.h +++ b/channels/rdpecam/common/rdpecam-utils.h @@ -53,6 +53,7 @@ static inline void rdpecam_PrintWarning(wLog* log, const char* file, const char* */ #define rdpecam_valid_messageId(id) \ rdpecam_valid_messageId_((id), WLog_Get(TAG), __FILE__, __func__, __LINE__) +WINPR_ATTR_NODISCARD static inline bool rdpecam_valid_messageId_(UINT8 id, wLog* log, const char* file, const char* fkt, size_t line) { @@ -102,6 +103,7 @@ static inline bool rdpecam_valid_messageId_(UINT8 id, wLog* log, const char* fil */ #define rdpecam_valid_CamErrorCode(code) \ rdpecam_valid_CamErrorCode_((code), WLog_Get(TAG), __FILE__, __func__, __LINE__) +WINPR_ATTR_NODISCARD static inline bool rdpecam_valid_CamErrorCode_(UINT32 code, wLog* log, const char* file, const char* fkt, size_t line) { @@ -137,6 +139,7 @@ static inline bool rdpecam_valid_CamErrorCode_(UINT32 code, wLog* log, const cha */ #define rdpecam_valid_CamStreamFrameSourceType(val) \ rdpecam_valid_CamStreamFrameSourceType_((val), WLog_Get(TAG), __FILE__, __func__, __LINE__) +WINPR_ATTR_NODISCARD static inline bool rdpecam_valid_CamStreamFrameSourceType_(UINT16 val, wLog* log, const char* file, const char* fkt, size_t line) { @@ -166,6 +169,7 @@ static inline bool rdpecam_valid_CamStreamFrameSourceType_(UINT16 val, wLog* log */ #define rdpecam_valid_CamStreamCategory(val) \ rdpecam_valid_CamStreamCategory_((val), WLog_Get(TAG), __FILE__, __func__, __LINE__) +WINPR_ATTR_NODISCARD static inline bool rdpecam_valid_CamStreamCategory_(UINT8 val, wLog* log, const char* file, const char* fkt, size_t line) { @@ -192,6 +196,7 @@ static inline bool rdpecam_valid_CamStreamCategory_(UINT8 val, wLog* log, const */ #define rdpecam_valid_CamMediaFormat(val) \ rdpecam_valid_CamMediaFormat_((val), WLog_Get(TAG), __FILE__, __func__, __LINE__) +WINPR_ATTR_NODISCARD static inline bool rdpecam_valid_CamMediaFormat_(UINT8 val, wLog* log, const char* file, const char* fkt, size_t line) { @@ -225,6 +230,7 @@ static inline bool rdpecam_valid_CamMediaFormat_(UINT8 val, wLog* log, const cha */ #define rdpecam_valid_MediaTypeDescriptionFlags(val) \ rdpecam_valid_MediaTypeDescriptionFlags_((val), WLog_Get(TAG), __FILE__, __func__, __LINE__) +WINPR_ATTR_NODISCARD static inline bool rdpecam_valid_MediaTypeDescriptionFlags_(UINT8 val, wLog* log, const char* file, const char* fkt, size_t line) { @@ -280,6 +286,7 @@ static inline bool rdpecam_valid_CamPropertyMode_(UINT8 val, wLog* log, const ch */ #define rdpecam_valid_CamPropertySet(val) \ rdpecam_valid_CamPropertySet_((val), WLog_Get(TAG), __FILE__, __func__, __LINE__) +WINPR_ATTR_NODISCARD static inline bool rdpecam_valid_CamPropertySet_(UINT8 val, wLog* log, const char* file, const char* fkt, size_t line) { @@ -307,6 +314,7 @@ static inline bool rdpecam_valid_CamPropertySet_(UINT8 val, wLog* log, const cha */ #define rdpecam_valid_CamPropertyCapabilities(val) \ rdpecam_valid_CamPropertyCapabilities_((val), WLog_Get(TAG), __FILE__, __func__, __LINE__) +WINPR_ATTR_NODISCARD static inline bool rdpecam_valid_CamPropertyCapabilities_(UINT32 val, wLog* log, const char* file, const char* fkt, size_t line) { diff --git a/channels/rdpei/client/rdpei_main.c b/channels/rdpei/client/rdpei_main.c index fc5477b87..b973af10f 100644 --- a/channels/rdpei/client/rdpei_main.c +++ b/channels/rdpei/client/rdpei_main.c @@ -300,6 +300,7 @@ static UINT rdpei_write_pen_frame(wStream* s, const RDPINPUT_PEN_FRAME* frame) static UINT rdpei_send_pen_event_pdu(GENERIC_CHANNEL_CALLBACK* callback, size_t frameOffset, const RDPINPUT_PEN_FRAME* frames, size_t count) { + UINT status = ERROR_OUTOFMEMORY; WINPR_ASSERT(callback); if (frameOffset > UINT32_MAX) @@ -327,24 +328,26 @@ static UINT rdpei_send_pen_event_pdu(GENERIC_CHANNEL_CALLBACK* callback, size_t * the time that has elapsed (in milliseconds) from when the oldest touch frame * was generated to when it was encoded for transmission by the client. */ - rdpei_write_4byte_unsigned(s, - (UINT32)frameOffset); /* encodeTime (FOUR_BYTE_UNSIGNED_INTEGER) */ - rdpei_write_2byte_unsigned(s, (UINT16)count); /* (frameCount) TWO_BYTE_UNSIGNED_INTEGER */ + if (!rdpei_write_4byte_unsigned( + s, (UINT32)frameOffset)) /* encodeTime (FOUR_BYTE_UNSIGNED_INTEGER) */ + goto fail; + if (!rdpei_write_2byte_unsigned(s, (UINT16)count)) /* (frameCount) TWO_BYTE_UNSIGNED_INTEGER */ + goto fail; for (size_t x = 0; x < count; x++) { - const UINT status = rdpei_write_pen_frame(s, &frames[x]); + status = rdpei_write_pen_frame(s, &frames[x]); if (status) { WLog_Print(rdpei->base.log, WLOG_ERROR, "rdpei_write_pen_frame failed with error %" PRIu32 "!", status); - Stream_Free(s, TRUE); - return status; + goto fail; } } Stream_SealLength(s); - const UINT status = rdpei_send_pdu(callback, s, EVENTID_PEN, Stream_Length(s)); + status = rdpei_send_pdu(callback, s, EVENTID_PEN, Stream_Length(s)); +fail: Stream_Free(s, TRUE); return status; } @@ -614,14 +617,16 @@ static UINT rdpei_write_touch_frame(wLog* log, wStream* s, RDPINPUT_TOUCH_FRAME* WLog_Print(log, WLOG_DEBUG, "contactCount: %" PRIu32 "", frame->contactCount); WLog_Print(log, WLOG_DEBUG, "frameOffset: 0x%016" PRIX64 "", frame->frameOffset); #endif - rdpei_write_2byte_unsigned(s, - frame->contactCount); /* contactCount (TWO_BYTE_UNSIGNED_INTEGER) */ + if (!rdpei_write_2byte_unsigned( + s, frame->contactCount)) /* contactCount (TWO_BYTE_UNSIGNED_INTEGER) */ + return ERROR_OUTOFMEMORY; /** * the time offset from the previous frame (in microseconds). * If this is the first frame being transmitted then this field MUST be set to zero. */ - rdpei_write_8byte_unsigned(s, frame->frameOffset * - 1000); /* frameOffset (EIGHT_BYTE_UNSIGNED_INTEGER) */ + if (!rdpei_write_8byte_unsigned(s, frame->frameOffset * + 1000)) /* frameOffset (EIGHT_BYTE_UNSIGNED_INTEGER) */ + return ERROR_OUTOFMEMORY; if (!Stream_EnsureRemainingCapacity(s, (size_t)frame->contactCount * 64)) { @@ -652,34 +657,44 @@ static UINT rdpei_write_touch_frame(wLog* log, wStream* s, RDPINPUT_TOUCH_FRAME* Stream_Write_UINT8( s, WINPR_ASSERTING_INT_CAST(uint8_t, contact->contactId)); /* contactId (1 byte) */ /* fieldsPresent (TWO_BYTE_UNSIGNED_INTEGER) */ - rdpei_write_2byte_unsigned(s, contact->fieldsPresent); - rdpei_write_4byte_signed(s, contact->x); /* x (FOUR_BYTE_SIGNED_INTEGER) */ - rdpei_write_4byte_signed(s, contact->y); /* y (FOUR_BYTE_SIGNED_INTEGER) */ + if (!rdpei_write_2byte_unsigned(s, contact->fieldsPresent)) + return ERROR_OUTOFMEMORY; + if (!rdpei_write_4byte_signed(s, contact->x)) /* x (FOUR_BYTE_SIGNED_INTEGER) */ + return ERROR_OUTOFMEMORY; + if (!rdpei_write_4byte_signed(s, contact->y)) /* y (FOUR_BYTE_SIGNED_INTEGER) */ + return ERROR_OUTOFMEMORY; /* contactFlags (FOUR_BYTE_UNSIGNED_INTEGER) */ - rdpei_write_4byte_unsigned(s, contact->contactFlags); + if (!rdpei_write_4byte_unsigned(s, contact->contactFlags)) + return ERROR_OUTOFMEMORY; if (contact->fieldsPresent & CONTACT_DATA_CONTACTRECT_PRESENT) { /* contactRectLeft (TWO_BYTE_SIGNED_INTEGER) */ - rdpei_write_2byte_signed(s, contact->contactRectLeft); + if (!rdpei_write_2byte_signed(s, contact->contactRectLeft)) + return ERROR_OUTOFMEMORY; /* contactRectTop (TWO_BYTE_SIGNED_INTEGER) */ - rdpei_write_2byte_signed(s, contact->contactRectTop); + if (!rdpei_write_2byte_signed(s, contact->contactRectTop)) + return ERROR_OUTOFMEMORY; /* contactRectRight (TWO_BYTE_SIGNED_INTEGER) */ - rdpei_write_2byte_signed(s, contact->contactRectRight); + if (!rdpei_write_2byte_signed(s, contact->contactRectRight)) + return ERROR_OUTOFMEMORY; /* contactRectBottom (TWO_BYTE_SIGNED_INTEGER) */ - rdpei_write_2byte_signed(s, contact->contactRectBottom); + if (!rdpei_write_2byte_signed(s, contact->contactRectBottom)) + return ERROR_OUTOFMEMORY; } if (contact->fieldsPresent & CONTACT_DATA_ORIENTATION_PRESENT) { /* orientation (FOUR_BYTE_UNSIGNED_INTEGER) */ - rdpei_write_4byte_unsigned(s, contact->orientation); + if (!rdpei_write_4byte_unsigned(s, contact->orientation)) + return ERROR_OUTOFMEMORY; } if (contact->fieldsPresent & CONTACT_DATA_PRESSURE_PRESENT) { /* pressure (FOUR_BYTE_UNSIGNED_INTEGER) */ - rdpei_write_4byte_unsigned(s, contact->pressure); + if (!rdpei_write_4byte_unsigned(s, contact->pressure)) + return ERROR_OUTOFMEMORY; } } @@ -694,6 +709,7 @@ static UINT rdpei_write_touch_frame(wLog* log, wStream* s, RDPINPUT_TOUCH_FRAME* static UINT rdpei_send_touch_event_pdu(GENERIC_CHANNEL_CALLBACK* callback, RDPINPUT_TOUCH_FRAME* frame) { + UINT status = ERROR_OUTOFMEMORY; WINPR_ASSERT(callback); RDPEI_PLUGIN* rdpei = (RDPEI_PLUGIN*)callback->plugin; @@ -714,27 +730,31 @@ static UINT rdpei_send_touch_event_pdu(GENERIC_CHANNEL_CALLBACK* callback, return CHANNEL_RC_NO_MEMORY; } - Stream_Seek(s, RDPINPUT_HEADER_LENGTH); + if (!Stream_SafeSeek(s, RDPINPUT_HEADER_LENGTH)) + goto fail; /** * the time that has elapsed (in milliseconds) from when the oldest touch frame * was generated to when it was encoded for transmission by the client. */ - rdpei_write_4byte_unsigned( - s, (UINT32)frame->frameOffset); /* encodeTime (FOUR_BYTE_UNSIGNED_INTEGER) */ - rdpei_write_2byte_unsigned(s, 1); /* (frameCount) TWO_BYTE_UNSIGNED_INTEGER */ + if (!rdpei_write_4byte_unsigned( + s, (UINT32)frame->frameOffset)) /* encodeTime (FOUR_BYTE_UNSIGNED_INTEGER) */ + goto fail; + if (!rdpei_write_2byte_unsigned(s, 1)) /* (frameCount) TWO_BYTE_UNSIGNED_INTEGER */ + goto fail; const UINT rc = rdpei_write_touch_frame(rdpei->base.log, s, frame); if (rc) { WLog_Print(rdpei->base.log, WLOG_ERROR, "rdpei_write_touch_frame failed with error %" PRIu32 "!", rc); - Stream_Free(s, TRUE); - return rc; + status = rc; + goto fail; } Stream_SealLength(s); - const UINT status = rdpei_send_pdu(callback, s, EVENTID_TOUCH, Stream_Length(s)); + status = rdpei_send_pdu(callback, s, EVENTID_TOUCH, Stream_Length(s)); +fail: Stream_Free(s, TRUE); return status; } diff --git a/channels/rdpei/rdpei_common.h b/channels/rdpei/rdpei_common.h index 3a5362f73..f9d8511ba 100644 --- a/channels/rdpei/rdpei_common.h +++ b/channels/rdpei/rdpei_common.h @@ -23,6 +23,8 @@ #include #include + +#include #include /** @brief input event ids */ @@ -37,21 +39,36 @@ enum EVENTID_PEN = 0x0008 }; -BOOL rdpei_read_2byte_unsigned(wStream* s, UINT16* value); -BOOL rdpei_write_2byte_unsigned(wStream* s, UINT16 value); -BOOL rdpei_read_2byte_signed(wStream* s, INT16* value); -BOOL rdpei_write_2byte_signed(wStream* s, INT16 value); -BOOL rdpei_read_4byte_unsigned(wStream* s, UINT32* value); -BOOL rdpei_write_4byte_unsigned(wStream* s, UINT32 value); -BOOL rdpei_read_4byte_signed(wStream* s, INT32* value); -BOOL rdpei_write_4byte_signed(wStream* s, INT32 value); -BOOL rdpei_read_8byte_unsigned(wStream* s, UINT64* value); -BOOL rdpei_write_8byte_unsigned(wStream* s, UINT64 value); +WINPR_ATTR_NODISCARD FREERDP_LOCAL BOOL rdpei_read_2byte_unsigned(wStream* s, UINT16* value); +WINPR_ATTR_NODISCARD FREERDP_LOCAL BOOL rdpei_write_2byte_unsigned(wStream* s, UINT16 value); + +WINPR_ATTR_NODISCARD FREERDP_LOCAL BOOL rdpei_read_2byte_signed(wStream* s, INT16* value); + +WINPR_ATTR_NODISCARD FREERDP_LOCAL BOOL rdpei_write_2byte_signed(wStream* s, INT16 value); + +WINPR_ATTR_NODISCARD FREERDP_LOCAL BOOL rdpei_read_4byte_unsigned(wStream* s, UINT32* value); + +WINPR_ATTR_NODISCARD FREERDP_LOCAL BOOL rdpei_write_4byte_unsigned(wStream* s, UINT32 value); + +WINPR_ATTR_NODISCARD FREERDP_LOCAL BOOL rdpei_read_4byte_signed(wStream* s, INT32* value); + +WINPR_ATTR_NODISCARD FREERDP_LOCAL BOOL rdpei_write_4byte_signed(wStream* s, INT32 value); + +WINPR_ATTR_NODISCARD FREERDP_LOCAL BOOL rdpei_read_8byte_unsigned(wStream* s, UINT64* value); + +WINPR_ATTR_NODISCARD FREERDP_LOCAL BOOL rdpei_write_8byte_unsigned(wStream* s, UINT64 value); + +FREERDP_LOCAL void touch_event_reset(RDPINPUT_TOUCH_EVENT* event); + +FREERDP_LOCAL void touch_frame_reset(RDPINPUT_TOUCH_FRAME* frame); +FREERDP_LOCAL void pen_event_reset(RDPINPUT_PEN_EVENT* event); + +FREERDP_LOCAL void pen_frame_reset(RDPINPUT_PEN_FRAME* frame); #endif /* FREERDP_CHANNEL_RDPEI_COMMON_H */ diff --git a/channels/rdpgfx/client/rdpgfx_codec.h b/channels/rdpgfx/client/rdpgfx_codec.h index 03d1bac99..ef519edae 100644 --- a/channels/rdpgfx/client/rdpgfx_codec.h +++ b/channels/rdpgfx/client/rdpgfx_codec.h @@ -30,6 +30,7 @@ #include "rdpgfx_main.h" +FREERDP_LOCAL FREERDP_LOCAL UINT rdpgfx_decode(RDPGFX_PLUGIN* gfx, RDPGFX_SURFACE_COMMAND* cmd); #endif /* FREERDP_CHANNEL_RDPGFX_CLIENT_CODEC_H */ diff --git a/channels/rdpgfx/rdpgfx_common.h b/channels/rdpgfx/rdpgfx_common.h index 246b6aee7..5074b0453 100644 --- a/channels/rdpgfx/rdpgfx_common.h +++ b/channels/rdpgfx/rdpgfx_common.h @@ -30,16 +30,28 @@ #include #include +WINPR_ATTR_NODISCARD FREERDP_LOCAL UINT rdpgfx_read_header(wStream* s, RDPGFX_HEADER* header); + +WINPR_ATTR_NODISCARD FREERDP_LOCAL UINT rdpgfx_write_header(wStream* s, const RDPGFX_HEADER* header); +WINPR_ATTR_NODISCARD FREERDP_LOCAL UINT rdpgfx_read_point16(wStream* s, RDPGFX_POINT16* pt16); + +WINPR_ATTR_NODISCARD FREERDP_LOCAL UINT rdpgfx_write_point16(wStream* s, const RDPGFX_POINT16* point16); +WINPR_ATTR_NODISCARD FREERDP_LOCAL UINT rdpgfx_read_rect16(wStream* s, RECTANGLE_16* rect16); + +WINPR_ATTR_NODISCARD FREERDP_LOCAL UINT rdpgfx_write_rect16(wStream* s, const RECTANGLE_16* rect16); +WINPR_ATTR_NODISCARD FREERDP_LOCAL UINT rdpgfx_read_color32(wStream* s, RDPGFX_COLOR32* color32); + +WINPR_ATTR_NODISCARD FREERDP_LOCAL UINT rdpgfx_write_color32(wStream* s, const RDPGFX_COLOR32* color32); #ifdef WITH_DEBUG_RDPGFX diff --git a/channels/remdesk/common/remdesk_common.h b/channels/remdesk/common/remdesk_common.h index 98bd26b8a..b7198cbb3 100644 --- a/channels/remdesk/common/remdesk_common.h +++ b/channels/remdesk/common/remdesk_common.h @@ -25,8 +25,15 @@ #include +WINPR_ATTR_NODISCARD FREERDP_LOCAL UINT remdesk_write_channel_header(wStream* s, const REMDESK_CHANNEL_HEADER* header); + +WINPR_ATTR_NODISCARD FREERDP_LOCAL UINT remdesk_write_ctl_header(wStream* s, const REMDESK_CTL_HEADER* ctlHeader); + +WINPR_ATTR_NODISCARD FREERDP_LOCAL UINT remdesk_read_channel_header(wStream* s, REMDESK_CHANNEL_HEADER* header); + +WINPR_ATTR_NODISCARD FREERDP_LOCAL UINT remdesk_prepare_ctl_header(REMDESK_CTL_HEADER* ctlHeader, UINT32 msgType, size_t msgSize); diff --git a/channels/tsmf/client/gstreamer/tsmf_platform.h b/channels/tsmf/client/gstreamer/tsmf_platform.h index 681095cf1..3a79b0c23 100644 --- a/channels/tsmf/client/gstreamer/tsmf_platform.h +++ b/channels/tsmf/client/gstreamer/tsmf_platform.h @@ -63,23 +63,43 @@ typedef struct } TSMFGstreamerDecoder; -const char* tsmf_platform_get_video_sink(void); -const char* tsmf_platform_get_audio_sink(void); +WINPR_ATTR_NODISCARD +FREERDP_LOCAL const char* tsmf_platform_get_video_sink(void); -int tsmf_platform_create(TSMFGstreamerDecoder* decoder); -int tsmf_platform_set_format(TSMFGstreamerDecoder* decoder); -int tsmf_platform_register_handler(TSMFGstreamerDecoder* decoder); -int tsmf_platform_free(TSMFGstreamerDecoder* decoder); +WINPR_ATTR_NODISCARD +FREERDP_LOCAL const char* tsmf_platform_get_audio_sink(void); -int tsmf_window_create(TSMFGstreamerDecoder* decoder); -int tsmf_window_resize(TSMFGstreamerDecoder* decoder, int x, int y, int width, int height, - int nr_rect, RDP_RECT* visible); -int tsmf_window_destroy(TSMFGstreamerDecoder* decoder); +WINPR_ATTR_NODISCARD +FREERDP_LOCAL int tsmf_platform_create(TSMFGstreamerDecoder* decoder); -int tsmf_window_map(TSMFGstreamerDecoder* decoder); -int tsmf_window_unmap(TSMFGstreamerDecoder* decoder); +WINPR_ATTR_NODISCARD +FREERDP_LOCAL int tsmf_platform_set_format(TSMFGstreamerDecoder* decoder); -BOOL tsmf_gstreamer_add_pad(TSMFGstreamerDecoder* mdecoder); -void tsmf_gstreamer_remove_pad(TSMFGstreamerDecoder* mdecoder); +WINPR_ATTR_NODISCARD +FREERDP_LOCAL int tsmf_platform_register_handler(TSMFGstreamerDecoder* decoder); + +WINPR_ATTR_NODISCARD +FREERDP_LOCAL int tsmf_platform_free(TSMFGstreamerDecoder* decoder); + +WINPR_ATTR_NODISCARD +FREERDP_LOCAL int tsmf_window_create(TSMFGstreamerDecoder* decoder); + +WINPR_ATTR_NODISCARD +FREERDP_LOCAL int tsmf_window_resize(TSMFGstreamerDecoder* decoder, int x, int y, int width, + int height, int nr_rect, RDP_RECT* visible); + +WINPR_ATTR_NODISCARD +FREERDP_LOCAL int tsmf_window_destroy(TSMFGstreamerDecoder* decoder); + +WINPR_ATTR_NODISCARD +FREERDP_LOCAL int tsmf_window_map(TSMFGstreamerDecoder* decoder); + +WINPR_ATTR_NODISCARD +FREERDP_LOCAL int tsmf_window_unmap(TSMFGstreamerDecoder* decoder); + +WINPR_ATTR_NODISCARD +FREERDP_LOCAL BOOL tsmf_gstreamer_add_pad(TSMFGstreamerDecoder* mdecoder); + +FREERDP_LOCAL void tsmf_gstreamer_remove_pad(TSMFGstreamerDecoder* mdecoder); #endif /* FREERDP_CHANNEL_TSMF_CLIENT_GST_PLATFORM_H */ diff --git a/channels/tsmf/client/tsmf_audio.h b/channels/tsmf/client/tsmf_audio.h index a5496c6d8..9df4ffba8 100644 --- a/channels/tsmf/client/tsmf_audio.h +++ b/channels/tsmf/client/tsmf_audio.h @@ -47,6 +47,7 @@ struct s_ITSMFAudioDevice #define TSMF_AUDIO_DEVICE_EXPORT_FUNC_NAME "TSMFAudioDeviceEntry" typedef UINT(VCAPITYPE* TSMF_AUDIO_DEVICE_ENTRY)(ITSMFAudioDevice** dev); -ITSMFAudioDevice* tsmf_load_audio_device(const char* name, const char* device); +WINPR_ATTR_NODISCARD FREERDP_LOCAL ITSMFAudioDevice* tsmf_load_audio_device(const char* name, + const char* device); #endif /* FREERDP_CHANNEL_TSMF_CLIENT_AUDIO_H */ diff --git a/channels/tsmf/client/tsmf_codec.h b/channels/tsmf/client/tsmf_codec.h index ab988991d..128c62879 100644 --- a/channels/tsmf/client/tsmf_codec.h +++ b/channels/tsmf/client/tsmf_codec.h @@ -22,7 +22,10 @@ #include "tsmf_types.h" -BOOL tsmf_codec_parse_media_type(TS_AM_MEDIA_TYPE* mediatype, wStream* s); -BOOL tsmf_codec_check_media_type(const char* decoder_name, wStream* s); +WINPR_ATTR_NODISCARD +FREERDP_LOCAL BOOL tsmf_codec_parse_media_type(TS_AM_MEDIA_TYPE* mediatype, wStream* s); + +WINPR_ATTR_NODISCARD +FREERDP_LOCAL BOOL tsmf_codec_check_media_type(const char* decoder_name, wStream* s); #endif /* FREERDP_CHANNEL_TSMF_CLIENT_CODEC_H */ diff --git a/channels/tsmf/client/tsmf_decoder.h b/channels/tsmf/client/tsmf_decoder.h index 457b745e1..26795d010 100644 --- a/channels/tsmf/client/tsmf_decoder.h +++ b/channels/tsmf/client/tsmf_decoder.h @@ -36,43 +36,52 @@ typedef struct s_ITSMFDecoder ITSMFDecoder; struct s_ITSMFDecoder { /* Set the decoder format. Return true if supported. */ - BOOL (*SetFormat)(ITSMFDecoder* decoder, TS_AM_MEDIA_TYPE* media_type); + WINPR_ATTR_NODISCARD BOOL (*SetFormat)(ITSMFDecoder* decoder, TS_AM_MEDIA_TYPE* media_type); /* Decode a sample. */ - BOOL (*Decode)(ITSMFDecoder* decoder, const BYTE* data, UINT32 data_size, UINT32 extensions); + WINPR_ATTR_NODISCARD BOOL (*Decode)(ITSMFDecoder* decoder, const BYTE* data, UINT32 data_size, + UINT32 extensions); /* Get the decoded data */ - BYTE* (*GetDecodedData)(ITSMFDecoder* decoder, UINT32* size); + WINPR_ATTR_NODISCARD BYTE* (*GetDecodedData)(ITSMFDecoder* decoder, UINT32* size); /* Get the pixel format of decoded video frame */ - UINT32 (*GetDecodedFormat)(ITSMFDecoder* decoder); + WINPR_ATTR_NODISCARD UINT32 (*GetDecodedFormat)(ITSMFDecoder* decoder); /* Get the width and height of decoded video frame */ - BOOL (*GetDecodedDimension)(ITSMFDecoder* decoder, UINT32* width, UINT32* height); + WINPR_ATTR_NODISCARD BOOL (*GetDecodedDimension)(ITSMFDecoder* decoder, UINT32* width, + UINT32* height); /* Free the decoder */ void (*Free)(ITSMFDecoder* decoder); /* Optional Control function */ - BOOL (*Control)(ITSMFDecoder* decoder, ITSMFControlMsg control_msg, UINT32* arg); + WINPR_ATTR_NODISCARD BOOL (*Control)(ITSMFDecoder* decoder, ITSMFControlMsg control_msg, + UINT32* arg); /* Decode a sample with extended interface. */ - BOOL(*DecodeEx) - (ITSMFDecoder* decoder, const BYTE* data, UINT32 data_size, UINT32 extensions, - UINT64 start_time, UINT64 end_time, UINT64 duration); + WINPR_ATTR_NODISCARD BOOL (*DecodeEx)(ITSMFDecoder* decoder, const BYTE* data, UINT32 data_size, + UINT32 extensions, UINT64 start_time, UINT64 end_time, + UINT64 duration); /* Get current play time */ - UINT64 (*GetRunningTime)(ITSMFDecoder* decoder); + WINPR_ATTR_NODISCARD UINT64 (*GetRunningTime)(ITSMFDecoder* decoder); /* Update Gstreamer Rendering Area */ - BOOL(*UpdateRenderingArea) - (ITSMFDecoder* decoder, UINT32 newX, UINT32 newY, UINT32 newWidth, UINT32 newHeight, - UINT32 numRectangles, const RECTANGLE_32* rectangles); + WINPR_ATTR_NODISCARD BOOL (*UpdateRenderingArea)(ITSMFDecoder* decoder, UINT32 newX, + UINT32 newY, UINT32 newWidth, UINT32 newHeight, + UINT32 numRectangles, + const RECTANGLE_32* rectangles); /* Change Gstreamer Audio Volume */ - BOOL (*ChangeVolume)(ITSMFDecoder* decoder, UINT32 newVolume, UINT32 muted); + WINPR_ATTR_NODISCARD BOOL (*ChangeVolume)(ITSMFDecoder* decoder, UINT32 newVolume, + UINT32 muted); /* Check buffer level */ - BOOL (*BufferLevel)(ITSMFDecoder* decoder); + WINPR_ATTR_NODISCARD BOOL (*BufferLevel)(ITSMFDecoder* decoder); /* Register a callback for frame ack. */ - BOOL (*SetAckFunc)(ITSMFDecoder* decoder, BOOL (*cb)(void*, BOOL), void* stream); + WINPR_ATTR_NODISCARD BOOL (*SetAckFunc)(ITSMFDecoder* decoder, BOOL (*cb)(void*, BOOL), + void* stream); /* Register a callback for stream seek detection. */ - BOOL (*SetSyncFunc)(ITSMFDecoder* decoder, void (*cb)(void*), void* stream); + WINPR_ATTR_NODISCARD BOOL (*SetSyncFunc)(ITSMFDecoder* decoder, void (*cb)(void*), + void* stream); }; #define TSMF_DECODER_EXPORT_FUNC_NAME "TSMFDecoderEntry" typedef UINT(VCAPITYPE* TSMF_DECODER_ENTRY)(ITSMFDecoder** decoder); -ITSMFDecoder* tsmf_load_decoder(const char* name, TS_AM_MEDIA_TYPE* media_type); -BOOL tsmf_check_decoder_available(const char* name); +WINPR_ATTR_NODISCARD FREERDP_LOCAL ITSMFDecoder* tsmf_load_decoder(const char* name, + TS_AM_MEDIA_TYPE* media_type); + +WINPR_ATTR_NODISCARD FREERDP_LOCAL BOOL tsmf_check_decoder_available(const char* name); #endif /* FREERDP_CHANNEL_TSMF_CLIENT_DECODER_H */ diff --git a/channels/tsmf/client/tsmf_ifman.h b/channels/tsmf/client/tsmf_ifman.h index 9547f6b08..363ddaa11 100644 --- a/channels/tsmf/client/tsmf_ifman.h +++ b/channels/tsmf/client/tsmf_ifman.h @@ -41,28 +41,52 @@ typedef struct UINT32 output_interface_id; } TSMF_IFMAN; -UINT tsmf_ifman_rim_exchange_capability_request(TSMF_IFMAN* ifman); -UINT tsmf_ifman_exchange_capability_request(TSMF_IFMAN* ifman); -UINT tsmf_ifman_check_format_support_request(TSMF_IFMAN* ifman); -UINT tsmf_ifman_on_new_presentation(TSMF_IFMAN* ifman); -UINT tsmf_ifman_add_stream(TSMF_IFMAN* ifman, rdpContext* rdpcontext); -UINT tsmf_ifman_set_topology_request(TSMF_IFMAN* ifman); -UINT tsmf_ifman_remove_stream(TSMF_IFMAN* ifman); -UINT tsmf_ifman_set_source_video_rect(TSMF_IFMAN* ifman); -UINT tsmf_ifman_shutdown_presentation(TSMF_IFMAN* ifman); -UINT tsmf_ifman_on_stream_volume(TSMF_IFMAN* ifman); -UINT tsmf_ifman_on_channel_volume(TSMF_IFMAN* ifman); -UINT tsmf_ifman_set_video_window(TSMF_IFMAN* ifman); -UINT tsmf_ifman_update_geometry_info(TSMF_IFMAN* ifman); -UINT tsmf_ifman_set_allocator(TSMF_IFMAN* ifman); -UINT tsmf_ifman_notify_preroll(TSMF_IFMAN* ifman); -UINT tsmf_ifman_on_sample(TSMF_IFMAN* ifman); -UINT tsmf_ifman_on_flush(TSMF_IFMAN* ifman); -UINT tsmf_ifman_on_end_of_stream(TSMF_IFMAN* ifman); -UINT tsmf_ifman_on_playback_started(TSMF_IFMAN* ifman); -UINT tsmf_ifman_on_playback_paused(TSMF_IFMAN* ifman); -UINT tsmf_ifman_on_playback_restarted(TSMF_IFMAN* ifman); -UINT tsmf_ifman_on_playback_stopped(TSMF_IFMAN* ifman); -UINT tsmf_ifman_on_playback_rate_changed(TSMF_IFMAN* ifman); +WINPR_ATTR_NODISCARD FREERDP_LOCAL UINT +tsmf_ifman_rim_exchange_capability_request(TSMF_IFMAN* ifman); + +WINPR_ATTR_NODISCARD FREERDP_LOCAL UINT tsmf_ifman_exchange_capability_request(TSMF_IFMAN* ifman); + +WINPR_ATTR_NODISCARD FREERDP_LOCAL UINT tsmf_ifman_check_format_support_request(TSMF_IFMAN* ifman); + +WINPR_ATTR_NODISCARD FREERDP_LOCAL UINT tsmf_ifman_on_new_presentation(TSMF_IFMAN* ifman); + +WINPR_ATTR_NODISCARD FREERDP_LOCAL UINT tsmf_ifman_add_stream(TSMF_IFMAN* ifman, + rdpContext* rdpcontext); + +WINPR_ATTR_NODISCARD FREERDP_LOCAL UINT tsmf_ifman_set_topology_request(TSMF_IFMAN* ifman); + +WINPR_ATTR_NODISCARD FREERDP_LOCAL UINT tsmf_ifman_remove_stream(TSMF_IFMAN* ifman); + +WINPR_ATTR_NODISCARD FREERDP_LOCAL UINT tsmf_ifman_set_source_video_rect(TSMF_IFMAN* ifman); + +WINPR_ATTR_NODISCARD FREERDP_LOCAL UINT tsmf_ifman_shutdown_presentation(TSMF_IFMAN* ifman); + +WINPR_ATTR_NODISCARD FREERDP_LOCAL UINT tsmf_ifman_on_stream_volume(TSMF_IFMAN* ifman); + +WINPR_ATTR_NODISCARD FREERDP_LOCAL UINT tsmf_ifman_on_channel_volume(TSMF_IFMAN* ifman); + +WINPR_ATTR_NODISCARD FREERDP_LOCAL UINT tsmf_ifman_set_video_window(TSMF_IFMAN* ifman); + +WINPR_ATTR_NODISCARD FREERDP_LOCAL UINT tsmf_ifman_update_geometry_info(TSMF_IFMAN* ifman); + +WINPR_ATTR_NODISCARD FREERDP_LOCAL UINT tsmf_ifman_set_allocator(TSMF_IFMAN* ifman); + +WINPR_ATTR_NODISCARD FREERDP_LOCAL UINT tsmf_ifman_notify_preroll(TSMF_IFMAN* ifman); + +WINPR_ATTR_NODISCARD FREERDP_LOCAL UINT tsmf_ifman_on_sample(TSMF_IFMAN* ifman); + +WINPR_ATTR_NODISCARD FREERDP_LOCAL UINT tsmf_ifman_on_flush(TSMF_IFMAN* ifman); + +WINPR_ATTR_NODISCARD FREERDP_LOCAL UINT tsmf_ifman_on_end_of_stream(TSMF_IFMAN* ifman); + +WINPR_ATTR_NODISCARD FREERDP_LOCAL UINT tsmf_ifman_on_playback_started(TSMF_IFMAN* ifman); + +WINPR_ATTR_NODISCARD FREERDP_LOCAL UINT tsmf_ifman_on_playback_paused(TSMF_IFMAN* ifman); + +WINPR_ATTR_NODISCARD FREERDP_LOCAL UINT tsmf_ifman_on_playback_restarted(TSMF_IFMAN* ifman); + +WINPR_ATTR_NODISCARD FREERDP_LOCAL UINT tsmf_ifman_on_playback_stopped(TSMF_IFMAN* ifman); + +WINPR_ATTR_NODISCARD FREERDP_LOCAL UINT tsmf_ifman_on_playback_rate_changed(TSMF_IFMAN* ifman); #endif /* FREERDP_CHANNEL_TSMF_CLIENT_IFMAN_H */ diff --git a/channels/tsmf/client/tsmf_main.h b/channels/tsmf/client/tsmf_main.h index fb783c180..730c8d727 100644 --- a/channels/tsmf/client/tsmf_main.h +++ b/channels/tsmf/client/tsmf_main.h @@ -58,8 +58,11 @@ typedef struct rdpContext* rdpcontext; } TSMF_PLUGIN; -BOOL tsmf_send_eos_response(IWTSVirtualChannelCallback* pChannelCallback, UINT32 message_id); -BOOL tsmf_playback_ack(IWTSVirtualChannelCallback* pChannelCallback, UINT32 message_id, - UINT64 duration, UINT32 data_size); +WINPR_ATTR_NODISCARD FREERDP_LOCAL BOOL +tsmf_send_eos_response(IWTSVirtualChannelCallback* pChannelCallback, UINT32 message_id); + +WINPR_ATTR_NODISCARD FREERDP_LOCAL BOOL +tsmf_playback_ack(IWTSVirtualChannelCallback* pChannelCallback, UINT32 message_id, UINT64 duration, + UINT32 data_size); #endif /* FREERDP_CHANNEL_TSMF_CLIENT_MAIN_H */ diff --git a/channels/tsmf/client/tsmf_media.h b/channels/tsmf/client/tsmf_media.h index eaa9cac88..bd0306fd5 100644 --- a/channels/tsmf/client/tsmf_media.h +++ b/channels/tsmf/client/tsmf_media.h @@ -36,37 +36,64 @@ typedef struct S_TSMF_STREAM TSMF_STREAM; typedef struct S_TSMF_SAMPLE TSMF_SAMPLE; -TSMF_PRESENTATION* tsmf_presentation_new(const BYTE* guid, - IWTSVirtualChannelCallback* pChannelCallback); -TSMF_PRESENTATION* tsmf_presentation_find_by_id(const BYTE* guid); -BOOL tsmf_presentation_start(TSMF_PRESENTATION* presentation); -BOOL tsmf_presentation_stop(TSMF_PRESENTATION* presentation); -UINT tsmf_presentation_sync(TSMF_PRESENTATION* presentation); -BOOL tsmf_presentation_paused(TSMF_PRESENTATION* presentation); -BOOL tsmf_presentation_restarted(TSMF_PRESENTATION* presentation); -BOOL tsmf_presentation_volume_changed(TSMF_PRESENTATION* presentation, UINT32 newVolume, - UINT32 muted); -BOOL tsmf_presentation_set_geometry_info(TSMF_PRESENTATION* presentation, UINT32 x, UINT32 y, - UINT32 width, UINT32 height, UINT32 num_rects, - const RECTANGLE_32* rects); +FREERDP_LOCAL void tsmf_presentation_free(TSMF_PRESENTATION* presentation); + +WINPR_ATTR_MALLOC(tsmf_presentation_free, 1) +WINPR_ATTR_NODISCARD FREERDP_LOCAL TSMF_PRESENTATION* +tsmf_presentation_new(const BYTE* guid, IWTSVirtualChannelCallback* pChannelCallback); + +WINPR_ATTR_NODISCARD FREERDP_LOCAL TSMF_PRESENTATION* +tsmf_presentation_find_by_id(const BYTE* guid); + +WINPR_ATTR_NODISCARD FREERDP_LOCAL BOOL tsmf_presentation_start(TSMF_PRESENTATION* presentation); + +WINPR_ATTR_NODISCARD FREERDP_LOCAL BOOL tsmf_presentation_stop(TSMF_PRESENTATION* presentation); + +WINPR_ATTR_NODISCARD FREERDP_LOCAL UINT tsmf_presentation_sync(TSMF_PRESENTATION* presentation); + +WINPR_ATTR_NODISCARD FREERDP_LOCAL BOOL tsmf_presentation_paused(TSMF_PRESENTATION* presentation); + +WINPR_ATTR_NODISCARD FREERDP_LOCAL BOOL +tsmf_presentation_restarted(TSMF_PRESENTATION* presentation); + +WINPR_ATTR_NODISCARD FREERDP_LOCAL BOOL +tsmf_presentation_volume_changed(TSMF_PRESENTATION* presentation, UINT32 newVolume, UINT32 muted); + +WINPR_ATTR_NODISCARD FREERDP_LOCAL BOOL tsmf_presentation_set_geometry_info( + TSMF_PRESENTATION* presentation, UINT32 x, UINT32 y, UINT32 width, UINT32 height, + UINT32 num_rects, const RECTANGLE_32* rects); + +FREERDP_LOCAL void tsmf_presentation_set_audio_device(TSMF_PRESENTATION* presentation, const char* name, const char* device); -void tsmf_presentation_free(TSMF_PRESENTATION* presentation); -TSMF_STREAM* tsmf_stream_new(TSMF_PRESENTATION* presentation, UINT32 stream_id, - rdpContext* rdpcontext); -TSMF_STREAM* tsmf_stream_find_by_id(TSMF_PRESENTATION* presentation, UINT32 stream_id); -BOOL tsmf_stream_set_format(TSMF_STREAM* stream, const char* name, wStream* s); +FREERDP_LOCAL +void tsmf_stream_free(TSMF_STREAM* stream); + +WINPR_ATTR_MALLOC(tsmf_stream_free, 1) +WINPR_ATTR_NODISCARD FREERDP_LOCAL TSMF_STREAM* +tsmf_stream_new(TSMF_PRESENTATION* presentation, UINT32 stream_id, rdpContext* rdpcontext); + +WINPR_ATTR_NODISCARD FREERDP_LOCAL TSMF_STREAM* +tsmf_stream_find_by_id(TSMF_PRESENTATION* presentation, UINT32 stream_id); + +WINPR_ATTR_NODISCARD FREERDP_LOCAL BOOL tsmf_stream_set_format(TSMF_STREAM* stream, + const char* name, wStream* s); + +FREERDP_LOCAL void tsmf_stream_end(TSMF_STREAM* stream, UINT32 message_id, IWTSVirtualChannelCallback* pChannelCallback); -void tsmf_stream_free(TSMF_STREAM* stream); -BOOL tsmf_stream_flush(TSMF_STREAM* stream); -BOOL tsmf_stream_push_sample(TSMF_STREAM* stream, IWTSVirtualChannelCallback* pChannelCallback, - UINT32 sample_id, UINT64 start_time, UINT64 end_time, UINT64 duration, - UINT32 extensions, UINT32 data_size, BYTE* data); +WINPR_ATTR_NODISCARD FREERDP_LOCAL BOOL tsmf_stream_flush(TSMF_STREAM* stream); -BOOL tsmf_media_init(void); +WINPR_ATTR_NODISCARD FREERDP_LOCAL BOOL +tsmf_stream_push_sample(TSMF_STREAM* stream, IWTSVirtualChannelCallback* pChannelCallback, + UINT32 sample_id, UINT64 start_time, UINT64 end_time, UINT64 duration, + UINT32 extensions, UINT32 data_size, BYTE* data); + +WINPR_ATTR_NODISCARD FREERDP_LOCAL BOOL tsmf_media_init(void); + +FREERDP_LOCAL void tsmf_stream_start_threads(TSMF_STREAM* stream); #endif /* FREERDP_CHANNEL_TSMF_CLIENT_MEDIA_H */ diff --git a/channels/urbdrc/client/data_transfer.c b/channels/urbdrc/client/data_transfer.c index 630d9e7b9..748e0e3a1 100644 --- a/channels/urbdrc/client/data_transfer.c +++ b/channels/urbdrc/client/data_transfer.c @@ -496,7 +496,10 @@ static UINT send_urb_select_configuration_result(GENERIC_CHANNEL_CALLBACK* callb /** TS_URB_SELECT_CONFIGURATION_RESULT */ if (MsConfig) - msusb_msconfig_write(MsConfig, out); + { + if (!msusb_msconfig_write(MsConfig, out)) + goto fail; + } else { Stream_Write_UINT32(out, 0); /** ConfigurationHandle */ @@ -887,7 +890,9 @@ static void urb_isoch_transfer_cb(WINPR_ATTR_UNUSED IUDEVICE* pdev, Stream_Write_UINT32(out, OutputBufferSize); /** OutputBufferSize */ Stream_Seek(out, OutputBufferSize); - stream_write_and_free(callback->plugin, callback->channel, out); + const UINT rc = stream_write_and_free(callback->plugin, callback->channel, out); + if (rc != CHANNEL_RC_OK) + WLog_WARN(TAG, "stream_write_and_free failed with %" PRIu32, rc); } } diff --git a/channels/urbdrc/client/data_transfer.h b/channels/urbdrc/client/data_transfer.h index 1d7126d2e..f10d59772 100644 --- a/channels/urbdrc/client/data_transfer.h +++ b/channels/urbdrc/client/data_transfer.h @@ -30,7 +30,9 @@ #define TRANSFER_CTX(transfer) (HANDLE_CTX((transfer)->dev_handle)) #define ITRANSFER_CTX(transfer) (TRANSFER_CTX(__USBI_TRANSFER_TO_LIBUSB_TRANSFER(transfer))) -UINT urbdrc_process_udev_data_transfer(GENERIC_CHANNEL_CALLBACK* callback, URBDRC_PLUGIN* urbdrc, - IUDEVMAN* udevman, wStream* data); +WINPR_ATTR_NODISCARD +FREERDP_LOCAL UINT urbdrc_process_udev_data_transfer(GENERIC_CHANNEL_CALLBACK* callback, + URBDRC_PLUGIN* urbdrc, IUDEVMAN* udevman, + wStream* data); #endif /* FREERDP_CHANNEL_URBDRC_CLIENT_DATA_TRANSFER_H */ diff --git a/channels/urbdrc/client/libusb/libusb_udevice.h b/channels/urbdrc/client/libusb/libusb_udevice.h index b08e2d9b5..8a7f0fab2 100644 --- a/channels/urbdrc/client/libusb/libusb_udevice.h +++ b/channels/urbdrc/client/libusb/libusb_udevice.h @@ -68,10 +68,15 @@ typedef struct } UDEVICE; typedef UDEVICE* PUDEVICE; -size_t udev_new_by_id(URBDRC_PLUGIN* urbdrc, libusb_context* ctx, UINT16 idVendor, UINT16 idProduct, - IUDEVICE*** devArray); -IUDEVICE* udev_new_by_addr(URBDRC_PLUGIN* urbdrc, libusb_context* context, BYTE bus_number, - BYTE dev_number); -const char* usb_interface_class_to_string(uint8_t c_class); +WINPR_ATTR_NODISCARD +FREERDP_LOCAL size_t udev_new_by_id(URBDRC_PLUGIN* urbdrc, libusb_context* ctx, UINT16 idVendor, + UINT16 idProduct, IUDEVICE*** devArray); + +WINPR_ATTR_NODISCARD +FREERDP_LOCAL IUDEVICE* udev_new_by_addr(URBDRC_PLUGIN* urbdrc, libusb_context* context, + BYTE bus_number, BYTE dev_number); + +WINPR_ATTR_NODISCARD +FREERDP_LOCAL const char* usb_interface_class_to_string(uint8_t c_class); #endif /* FREERDP_CHANNEL_URBDRC_CLIENT_LIBUSB_UDEVICE_H */ diff --git a/channels/urbdrc/client/urbdrc_main.h b/channels/urbdrc/client/urbdrc_main.h index 8629c8a34..a5791c9c9 100644 --- a/channels/urbdrc/client/urbdrc_main.h +++ b/channels/urbdrc/client/urbdrc_main.h @@ -220,11 +220,14 @@ struct S_IUDEVMAN (DEVICE_ADD_FLAG_BUS | DEVICE_ADD_FLAG_DEV | DEVICE_ADD_FLAG_VENDOR | \ DEVICE_ADD_FLAG_PRODUCT | DEVICE_ADD_FLAG_REGISTER) -FREERDP_API BOOL add_device(IUDEVMAN* idevman, UINT32 flags, BYTE busnum, BYTE devnum, - UINT16 idVendor, UINT16 idProduct); -FREERDP_API BOOL del_device(IUDEVMAN* idevman, UINT32 flags, BYTE busnum, BYTE devnum, - UINT16 idVendor, UINT16 idProduct); +FREERDP_LOCAL BOOL add_device(IUDEVMAN* idevman, UINT32 flags, BYTE busnum, BYTE devnum, + UINT16 idVendor, UINT16 idProduct); -UINT stream_write_and_free(IWTSPlugin* plugin, IWTSVirtualChannel* channel, wStream* out); +FREERDP_LOCAL BOOL del_device(IUDEVMAN* idevman, UINT32 flags, BYTE busnum, BYTE devnum, + UINT16 idVendor, UINT16 idProduct); + +WINPR_ATTR_NODISCARD +FREERDP_LOCAL UINT stream_write_and_free(IWTSPlugin* plugin, IWTSVirtualChannel* channel, + wStream* out); #endif /* FREERDP_CHANNEL_URBDRC_CLIENT_MAIN_H */ diff --git a/channels/urbdrc/common/msusb.c b/channels/urbdrc/common/msusb.c index 7f3c7780e..82fff5b8c 100644 --- a/channels/urbdrc/common/msusb.c +++ b/channels/urbdrc/common/msusb.c @@ -43,18 +43,17 @@ static void msusb_mspipes_free(MSUSB_PIPE_DESCRIPTOR** MsPipes, UINT32 NumberOfP } } -BOOL msusb_mspipes_replace(MSUSB_INTERFACE_DESCRIPTOR* MsInterface, +void msusb_mspipes_replace(MSUSB_INTERFACE_DESCRIPTOR* MsInterface, MSUSB_PIPE_DESCRIPTOR** NewMsPipes, UINT32 NewNumberOfPipes) { - if (!MsInterface || !NewMsPipes) - return FALSE; + WINPR_ASSERT(MsInterface); + WINPR_ASSERT(NewMsPipes || (NewNumberOfPipes == 0)); /* free original MsPipes */ msusb_mspipes_free(MsInterface->MsPipes, MsInterface->NumberOfPipes); /* And replace it */ MsInterface->MsPipes = NewMsPipes; MsInterface->NumberOfPipes = NewNumberOfPipes; - return TRUE; } static MSUSB_PIPE_DESCRIPTOR** msusb_mspipes_read(wStream* s, UINT32 NumberOfPipes) diff --git a/channels/urbdrc/common/msusb.h b/channels/urbdrc/common/msusb.h index 6f3868791..7cd4bfa63 100644 --- a/channels/urbdrc/common/msusb.h +++ b/channels/urbdrc/common/msusb.h @@ -68,34 +68,41 @@ extern "C" #endif /* MSUSB_CONFIG exported functions */ - FREERDP_API void msusb_msconfig_free(MSUSB_CONFIG_DESCRIPTOR* MsConfig); + FREERDP_LOCAL void msusb_msconfig_free(MSUSB_CONFIG_DESCRIPTOR* MsConfig); WINPR_ATTR_MALLOC(msusb_msconfig_free, 1) WINPR_ATTR_NODISCARD - FREERDP_API MSUSB_CONFIG_DESCRIPTOR* msusb_msconfig_new(void); + FREERDP_LOCAL MSUSB_CONFIG_DESCRIPTOR* msusb_msconfig_new(void); WINPR_ATTR_MALLOC(msusb_msconfig_free, 1) WINPR_ATTR_NODISCARD - FREERDP_API MSUSB_CONFIG_DESCRIPTOR* msusb_msconfig_read(wStream* s, UINT32 NumInterfaces); - FREERDP_API BOOL msusb_msconfig_write(const MSUSB_CONFIG_DESCRIPTOR* MsConfg, wStream* out); - FREERDP_API void msusb_msconfig_dump(const MSUSB_CONFIG_DESCRIPTOR* MsConfg); + FREERDP_LOCAL MSUSB_CONFIG_DESCRIPTOR* msusb_msconfig_read(wStream* s, UINT32 NumInterfaces); + + WINPR_ATTR_NODISCARD + FREERDP_LOCAL BOOL msusb_msconfig_write(const MSUSB_CONFIG_DESCRIPTOR* MsConfg, wStream* out); + + FREERDP_LOCAL void msusb_msconfig_dump(const MSUSB_CONFIG_DESCRIPTOR* MsConfg); /* MSUSB_PIPE exported functions */ - FREERDP_API BOOL msusb_mspipes_replace(MSUSB_INTERFACE_DESCRIPTOR* MsInterface, - MSUSB_PIPE_DESCRIPTOR** NewMsPipes, - UINT32 NewNumberOfPipes); + FREERDP_LOCAL void msusb_mspipes_replace(MSUSB_INTERFACE_DESCRIPTOR* MsInterface, + MSUSB_PIPE_DESCRIPTOR** NewMsPipes, + UINT32 NewNumberOfPipes); /* MSUSB_INTERFACE exported functions */ - FREERDP_API BOOL msusb_msinterface_replace(MSUSB_CONFIG_DESCRIPTOR* MsConfig, - BYTE InterfaceNumber, - MSUSB_INTERFACE_DESCRIPTOR* NewMsInterface); + WINPR_ATTR_NODISCARD + FREERDP_LOCAL BOOL msusb_msinterface_replace(MSUSB_CONFIG_DESCRIPTOR* MsConfig, + BYTE InterfaceNumber, + MSUSB_INTERFACE_DESCRIPTOR* NewMsInterface); - FREERDP_API void msusb_msinterface_free(MSUSB_INTERFACE_DESCRIPTOR* MsInterface); + FREERDP_LOCAL void msusb_msinterface_free(MSUSB_INTERFACE_DESCRIPTOR* MsInterface); WINPR_ATTR_MALLOC(msusb_msinterface_free, 1) - FREERDP_API MSUSB_INTERFACE_DESCRIPTOR* msusb_msinterface_read(wStream* out); - FREERDP_API BOOL msusb_msinterface_write(const MSUSB_INTERFACE_DESCRIPTOR* MsInterface, - wStream* out); + WINPR_ATTR_NODISCARD + FREERDP_LOCAL MSUSB_INTERFACE_DESCRIPTOR* msusb_msinterface_read(wStream* out); + + WINPR_ATTR_NODISCARD + FREERDP_LOCAL BOOL msusb_msinterface_write(const MSUSB_INTERFACE_DESCRIPTOR* MsInterface, + wStream* out); #ifdef __cplusplus } diff --git a/channels/urbdrc/common/urbdrc_helpers.c b/channels/urbdrc/common/urbdrc_helpers.c index 6620eb4ff..e623f85c6 100644 --- a/channels/urbdrc/common/urbdrc_helpers.c +++ b/channels/urbdrc/common/urbdrc_helpers.c @@ -445,6 +445,10 @@ wStream* create_shared_message_header_with_functionid(UINT32 InterfaceId, UINT32 wStream* out = Stream_New(NULL, 12ULL + OutputSize); if (!out) return NULL; - (void)write_shared_message_header_with_functionid(out, InterfaceId, MessageId, FunctionId); + if (!write_shared_message_header_with_functionid(out, InterfaceId, MessageId, FunctionId)) + { + Stream_Free(out, TRUE); + return NULL; + } return out; } diff --git a/channels/urbdrc/common/urbdrc_helpers.h b/channels/urbdrc/common/urbdrc_helpers.h index 80dfe886c..b4d9bea43 100644 --- a/channels/urbdrc/common/urbdrc_helpers.h +++ b/channels/urbdrc/common/urbdrc_helpers.h @@ -30,18 +30,27 @@ extern "C" #include #include +#include - const char* urb_function_string(UINT16 urb); - const char* mask_to_string(UINT32 mask); - const char* interface_to_string(UINT32 id); - const char* call_to_string(BOOL client, UINT32 interfaceNr, UINT32 functionId); + WINPR_ATTR_NODISCARD FREERDP_LOCAL const char* urb_function_string(UINT16 urb); + WINPR_ATTR_NODISCARD FREERDP_LOCAL const char* mask_to_string(UINT32 mask); + + WINPR_ATTR_NODISCARD FREERDP_LOCAL const char* interface_to_string(UINT32 id); + + WINPR_ATTR_NODISCARD FREERDP_LOCAL const char* call_to_string(BOOL client, UINT32 interfaceNr, + UINT32 functionId); + + FREERDP_LOCAL void urbdrc_dump_message(wLog* log, BOOL client, BOOL write, wStream* s); - wStream* create_shared_message_header_with_functionid(UINT32 InterfaceId, UINT32 MessageId, - UINT32 FunctionId, size_t OutputSize); - BOOL write_shared_message_header_with_functionid(wStream* s, UINT32 InterfaceId, - UINT32 MessageId, UINT32 FunctionId); + WINPR_ATTR_MALLOC(Stream_Free, 1) + WINPR_ATTR_NODISCARD FREERDP_LOCAL wStream* + create_shared_message_header_with_functionid(UINT32 InterfaceId, UINT32 MessageId, + UINT32 FunctionId, size_t OutputSize); + + WINPR_ATTR_NODISCARD FREERDP_LOCAL BOOL write_shared_message_header_with_functionid( + wStream* s, UINT32 InterfaceId, UINT32 MessageId, UINT32 FunctionId); #ifdef __cplusplus }