diff --git a/CMakeLists.txt b/CMakeLists.txt index bcd102511..efb626912 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -397,7 +397,9 @@ if(ANDROID) set(PCSC_FEATURE_TYPE "DISABLED") endif() -find_feature(Wayland ${WAYLAND_FEATURE_TYPE} ${WAYLAND_FEATURE_PURPOSE} ${WAYLAND_FEATURE_DESCRIPTION}) +if(WITH_FREERDP_3x_DEPRECATED) + find_feature(Wayland ${WAYLAND_FEATURE_TYPE} ${WAYLAND_FEATURE_PURPOSE} ${WAYLAND_FEATURE_DESCRIPTION}) +endif() option(WITH_LIBRESSL "build with LibreSSL" OFF) if(WITH_LIBRESSL) @@ -527,9 +529,12 @@ include(CommonConfigOptions) if(FREERDP_UNIFIED_BUILD) add_subdirectory(winpr) - if(WITH_WAYLAND) - add_subdirectory(uwac) + if(WITH_FREERDP_3x_DEPRECATED) + if(WITH_WAYLAND) + add_subdirectory(uwac) + endif() endif() + if(WITH_SERVER) option(WITH_RDTK "build rdtk toolkit" ON) if(WITH_RDTK) diff --git a/channels/drive/client/drive_file.c b/channels/drive/client/drive_file.c index 319c86360..cac5682b0 100644 --- a/channels/drive/client/drive_file.c +++ b/channels/drive/client/drive_file.c @@ -503,6 +503,8 @@ static BOOL drive_file_query_from_handle_information(const DRIVE_FILE* file, default: /* Unhandled FsInformationClass */ + WLog_WARN(TAG, "Unhandled FSInformationClass %s [0x%08" PRIx32 "]", + FSInformationClass2Tag(FsInformationClass), FsInformationClass); return FALSE; } @@ -568,6 +570,8 @@ static BOOL drive_file_query_from_attributes(const DRIVE_FILE* file, default: /* Unhandled FsInformationClass */ + WLog_WARN(TAG, "Unhandled FSInformationClass %s [0x%08" PRIx32 "]", + FSInformationClass2Tag(FsInformationClass), FsInformationClass); return FALSE; } @@ -822,6 +826,8 @@ BOOL drive_file_set_information(DRIVE_FILE* file, UINT32 FsInformationClass, UIN break; default: + WLog_WARN(TAG, "Unhandled FSInformationClass %s [0x%08" PRIx32 "]", + FSInformationClass2Tag(FsInformationClass), FsInformationClass); return FALSE; } @@ -1003,7 +1009,8 @@ BOOL drive_file_query_directory(DRIVE_FILE* file, UINT32 FsInformationClass, BYT break; default: - WLog_ERR(TAG, "unhandled FsInformationClass %" PRIu32, FsInformationClass); + WLog_WARN(TAG, "Unhandled FSInformationClass %s [0x%08" PRIx32 "]", + FSInformationClass2Tag(FsInformationClass), FsInformationClass); /* Unhandled FsInformationClass */ goto out_fail; } diff --git a/channels/drive/client/drive_main.c b/channels/drive/client/drive_main.c index 817178248..57efd4b5c 100644 --- a/channels/drive/client/drive_main.c +++ b/channels/drive/client/drive_main.c @@ -153,13 +153,6 @@ static UINT drive_process_irp_create(DRIVE_DEVICE* drive, IRP* irp) UINT32 FileId = 0; DRIVE_FILE* file = NULL; BYTE Information = 0; - UINT32 FileAttributes = 0; - UINT32 SharedAccess = 0; - UINT32 DesiredAccess = 0; - UINT32 CreateDisposition = 0; - UINT32 CreateOptions = 0; - UINT32 PathLength = 0; - UINT64 allocationSize = 0; const WCHAR* path = NULL; if (!drive || !irp || !irp->devman || !irp->Complete) @@ -168,13 +161,13 @@ static UINT drive_process_irp_create(DRIVE_DEVICE* drive, IRP* irp) if (!Stream_CheckAndLogRequiredLength(TAG, irp->input, 6 * 4 + 8)) return ERROR_INVALID_DATA; - Stream_Read_UINT32(irp->input, DesiredAccess); - Stream_Read_UINT64(irp->input, allocationSize); - Stream_Read_UINT32(irp->input, FileAttributes); - Stream_Read_UINT32(irp->input, SharedAccess); - Stream_Read_UINT32(irp->input, CreateDisposition); - Stream_Read_UINT32(irp->input, CreateOptions); - Stream_Read_UINT32(irp->input, PathLength); + const uint32_t DesiredAccess = Stream_Get_UINT32(irp->input); + const uint64_t allocationSize = Stream_Get_UINT64(irp->input); + const uint32_t FileAttributes = Stream_Get_UINT32(irp->input); + const uint32_t SharedAccess = Stream_Get_UINT32(irp->input); + const uint32_t CreateDisposition = Stream_Get_UINT32(irp->input); + const uint32_t CreateOptions = Stream_Get_UINT32(irp->input); + const uint32_t PathLength = Stream_Get_UINT32(irp->input); if (!Stream_CheckAndLogRequiredLength(TAG, irp->input, PathLength)) return ERROR_INVALID_DATA; @@ -221,6 +214,15 @@ static UINT drive_process_irp_create(DRIVE_DEVICE* drive, IRP* irp) Information = 0; break; } + + if (allocationSize > 0) + { + const BYTE buffer[] = { '\0' }; + if (!drive_file_seek(file, allocationSize - sizeof(buffer))) + return ERROR_INTERNAL_ERROR; + if (!drive_file_write(file, buffer, sizeof(buffer))) + return ERROR_INTERNAL_ERROR; + } } Stream_Write_UINT32(irp->output, FileId); @@ -570,6 +572,8 @@ static UINT drive_process_irp_query_volume_information(DRIVE_DEVICE* drive, IRP* break; default: + WLog_WARN(TAG, "Unhandled FSInformationClass %s [0x%08" PRIx32 "]", + FSInformationClass2Tag(FsInformationClass), FsInformationClass); irp->IoStatus = STATUS_UNSUCCESSFUL; Stream_Write_UINT32(output, 0); /* Length */ break; @@ -587,15 +591,15 @@ static UINT drive_process_irp_query_volume_information(DRIVE_DEVICE* drive, IRP* */ static UINT drive_process_irp_silent_ignore(DRIVE_DEVICE* drive, IRP* irp) { - UINT32 FsInformationClass = 0; - if (!drive || !irp || !irp->output || !irp->Complete) return ERROR_INVALID_PARAMETER; if (!Stream_CheckAndLogRequiredLength(TAG, irp->input, 4)) return ERROR_INVALID_DATA; - Stream_Read_UINT32(irp->input, FsInformationClass); + const uint32_t FsInformationClass = Stream_Get_UINT32(irp->input); + WLog_VRB(TAG, "Silently ignore FSInformationClass %s [0x%08" PRIx32 "]", + FSInformationClass2Tag(FsInformationClass), FsInformationClass); Stream_Write_UINT32(irp->output, 0); /* Length */ return irp->Complete(irp); } diff --git a/channels/rdpdr/client/rdpdr_main.c b/channels/rdpdr/client/rdpdr_main.c index 6b73a563a..63010367f 100644 --- a/channels/rdpdr/client/rdpdr_main.c +++ b/channels/rdpdr/client/rdpdr_main.c @@ -1495,15 +1495,10 @@ UINT rdpdr_try_send_device_list_announce_request(rdpdrPlugin* rdpdr) static UINT dummy_irp_response(rdpdrPlugin* rdpdr, wStream* s) { - wStream* output = NULL; - UINT32 DeviceId = 0; - UINT32 FileId = 0; - UINT32 CompletionId = 0; - WINPR_ASSERT(rdpdr); WINPR_ASSERT(s); - output = StreamPool_Take(rdpdr->pool, 256); // RDPDR_DEVICE_IO_RESPONSE_LENGTH + wStream* output = StreamPool_Take(rdpdr->pool, 256); // RDPDR_DEVICE_IO_RESPONSE_LENGTH if (!output) { WLog_Print(rdpdr->log, WLOG_ERROR, "Stream_New failed!"); @@ -1512,10 +1507,14 @@ static UINT dummy_irp_response(rdpdrPlugin* rdpdr, wStream* s) Stream_SetPosition(s, 4); /* see "rdpdr_process_receive" */ - Stream_Read_UINT32(s, DeviceId); /* DeviceId (4 bytes) */ - Stream_Read_UINT32(s, FileId); /* FileId (4 bytes) */ - Stream_Read_UINT32(s, CompletionId); /* CompletionId (4 bytes) */ + const uint32_t DeviceId = Stream_Get_UINT32(s); /* DeviceId (4 bytes) */ + const uint32_t FileId = Stream_Get_UINT32(s); /* FileId (4 bytes) */ + const uint32_t CompletionId = Stream_Get_UINT32(s); /* CompletionId (4 bytes) */ + WLog_Print(rdpdr->log, WLOG_ERROR, + "Dummy response {DeviceId=%" PRIu32 ", FileId=%" PRIu32 ", CompletionId=%" PRIu32 + "}", + DeviceId, FileId, CompletionId); if (!rdpdr_write_iocompletion_header(output, DeviceId, CompletionId, STATUS_UNSUCCESSFUL)) return CHANNEL_RC_NO_MEMORY; diff --git a/channels/rdpdr/server/rdpdr_main.c b/channels/rdpdr/server/rdpdr_main.c index 9b8e8b208..48c3e486a 100644 --- a/channels/rdpdr/server/rdpdr_main.c +++ b/channels/rdpdr/server/rdpdr_main.c @@ -62,6 +62,44 @@ struct s_rdpdr_server_private wLog* log; }; +static const char* fileInformation2str(uint8_t val) +{ + switch (val) + { + case FILE_SUPERSEDED: + return "FILE_DOES_NOT_EXIST"; + case FILE_OPENED: + return "FILE_EXISTS"; + case FILE_CREATED: + return "FILE_OVERWRITTEN"; + case FILE_OVERWRITTEN: + return "FILE_CREATED"; + case FILE_EXISTS: + return "FILE_OPENED"; + case FILE_DOES_NOT_EXIST: + return "FILE_SUPERSEDED"; + default: + return "FILE_UNKNOWN"; + } +} + +static const char* DR_DRIVE_LOCK_REQ2str(uint32_t op) +{ + switch (op) + { + case RDP_LOWIO_OP_SHAREDLOCK: + return "RDP_LOWIO_OP_UNLOCK_MULTIPLE"; + case RDP_LOWIO_OP_EXCLUSIVELOCK: + return "RDP_LOWIO_OP_UNLOCK"; + case RDP_LOWIO_OP_UNLOCK: + return "RDP_LOWIO_OP_EXCLUSIVELOCK"; + case RDP_LOWIO_OP_UNLOCK_MULTIPLE: + return "RDP_LOWIO_OP_SHAREDLOCK"; + default: + return "RDP_LOWIO_OP_UNKNOWN"; + } +} + static void rdpdr_device_free(RdpdrDevice* device) { if (!device) @@ -1255,6 +1293,9 @@ static UINT rdpdr_server_receive_io_read_request(RdpdrServerContext* context, wS Stream_Read_UINT64(s, Offset); Stream_Seek(s, 20); /* Padding */ + WLog_Print(context->priv->log, WLOG_DEBUG, "Got Offset [0x%016" PRIx64 "], Length %" PRIu32, + Offset, Length); + WLog_Print(context->priv->log, WLOG_WARN, "[MS-RDPEFS] 2.2.1.4.3 Device Read Request (DR_READ_REQ) not implemented"); WLog_Print(context->priv->log, WLOG_WARN, "TODO"); @@ -1280,6 +1321,9 @@ static UINT rdpdr_server_receive_io_write_request(RdpdrServerContext* context, w Stream_Read_UINT64(s, Offset); Stream_Seek(s, 20); /* Padding */ + WLog_Print(context->priv->log, WLOG_DEBUG, "Got Offset [0x%016" PRIx64 "], Length %" PRIu32, + Offset, Length); + const BYTE* data = Stream_ConstPointer(s); if (!Stream_CheckAndLogRequiredLengthWLog(context->priv->log, s, Length)) return ERROR_INVALID_DATA; @@ -1319,7 +1363,9 @@ static UINT rdpdr_server_receive_io_device_control_request(RdpdrServerContext* c WLog_Print(context->priv->log, WLOG_WARN, "[MS-RDPEFS] 2.2.1.4.5 Device Control Request (DR_CONTROL_REQ) not implemented"); - WLog_Print(context->priv->log, WLOG_WARN, "TODO: parse %p", InputBuffer); + WLog_Print(context->priv->log, WLOG_WARN, + "TODO: parse %p [%" PRIu32 "], OutputBufferLength=%" PRIu32, InputBuffer, + InputBufferLength, OutputBufferLength); return CHANNEL_RC_OK; } @@ -1339,6 +1385,10 @@ static UINT rdpdr_server_receive_io_query_volume_information_request( Stream_Read_UINT32(s, Length); Stream_Seek(s, 24); /* Padding */ + WLog_Print(context->priv->log, WLOG_DEBUG, + "Got FSInformationClass %s [0x%08" PRIx32 "], Length %" PRIu32, + FSInformationClass2Tag(FsInformationClass), FsInformationClass, Length); + const BYTE* QueryVolumeBuffer = Stream_ConstPointer(s); if (!Stream_CheckAndLogRequiredLengthWLog(context->priv->log, s, Length)) return ERROR_INVALID_DATA; @@ -1369,6 +1419,10 @@ static UINT rdpdr_server_receive_io_set_volume_information_request( Stream_Read_UINT32(s, Length); Stream_Seek(s, 24); /* Padding */ + WLog_Print(context->priv->log, WLOG_DEBUG, + "Got FSInformationClass %s [0x%08" PRIx32 "], Length %" PRIu32, + FSInformationClass2Tag(FsInformationClass), FsInformationClass, Length); + const BYTE* SetVolumeBuffer = Stream_ConstPointer(s); if (!Stream_CheckAndLogRequiredLengthWLog(context->priv->log, s, Length)) return ERROR_INVALID_DATA; @@ -1401,6 +1455,10 @@ static UINT rdpdr_server_receive_io_query_information_request(RdpdrServerContext Stream_Read_UINT32(s, Length); Stream_Seek(s, 24); /* Padding */ + WLog_Print(context->priv->log, WLOG_DEBUG, + "Got FSInformationClass %s [0x%08" PRIx32 "], Length %" PRIu32, + FSInformationClass2Tag(FsInformationClass), FsInformationClass, Length); + const BYTE* QueryBuffer = Stream_ConstPointer(s); if (!Stream_CheckAndLogRequiredLengthWLog(context->priv->log, s, Length)) return ERROR_INVALID_DATA; @@ -1432,6 +1490,10 @@ static UINT rdpdr_server_receive_io_set_information_request(RdpdrServerContext* Stream_Read_UINT32(s, Length); Stream_Seek(s, 24); /* Padding */ + WLog_Print(context->priv->log, WLOG_DEBUG, + "Got FSInformationClass %s [0x%08" PRIx32 "], Length %" PRIu32, + FSInformationClass2Tag(FsInformationClass), FsInformationClass, Length); + const BYTE* SetBuffer = Stream_ConstPointer(s); if (!Stream_CheckAndLogRequiredLengthWLog(context->priv->log, s, Length)) return ERROR_INVALID_DATA; @@ -1453,7 +1515,6 @@ static UINT rdpdr_server_receive_io_query_directory_request(RdpdrServerContext* BYTE InitialQuery = 0; UINT32 FsInformationClass = 0; UINT32 PathLength = 0; - const WCHAR* Path = NULL; WINPR_ASSERT(context); WINPR_ASSERT(context->priv); @@ -1466,10 +1527,18 @@ static UINT rdpdr_server_receive_io_query_directory_request(RdpdrServerContext* Stream_Read_UINT32(s, PathLength); Stream_Seek(s, 23); /* Padding */ - Path = rdpdr_read_ustring(context->priv->log, s, PathLength); - if (!Path && (PathLength > 0)) + const WCHAR* wPath = rdpdr_read_ustring(context->priv->log, s, PathLength); + if (!wPath && (PathLength > 0)) return ERROR_INVALID_DATA; + char* Path = ConvertWCharNToUtf8Alloc(wPath, PathLength / sizeof(WCHAR), NULL); + WLog_Print(context->priv->log, WLOG_DEBUG, + "Got FSInformationClass %s [0x%08" PRIx32 "], InitialQuery [%" PRIu8 + "] Path[%" PRIu32 "] %s", + FSInformationClass2Tag(FsInformationClass), FsInformationClass, InitialQuery, + PathLength, Path); + free(Path); + WLog_Print(context->priv->log, WLOG_WARN, "[MS-RDPEFS] 2.2.3.3.10 Server Drive Query Directory Request " "(DR_DRIVE_QUERY_DIRECTORY_REQ) not implemented"); @@ -1535,22 +1604,22 @@ static UINT rdpdr_server_receive_io_lock_control_request(RdpdrServerContext* con WINPR_ATTR_UNUSED UINT32 FileId, WINPR_ATTR_UNUSED UINT32 CompletionId) { - UINT32 Operation = 0; - UINT32 Lock = 0; - UINT32 NumLocks = 0; - WINPR_ASSERT(context); WINPR_ASSERT(context->priv); if (!Stream_CheckAndLogRequiredLengthWLog(context->priv->log, s, 32)) return ERROR_INVALID_DATA; - Stream_Read_UINT32(s, Operation); - Stream_Read_UINT32(s, Lock); - Stream_Read_UINT32(s, NumLocks); + const uint32_t Operation = Stream_Get_UINT32(s); + uint32_t Lock = Stream_Get_UINT32(s); + const uint32_t NumLocks = Stream_Get_UINT32(s); Stream_Seek(s, 20); /* Padding */ - Lock &= 0x01; /* Only byte 0 is of importance */ + WLog_Print(context->priv->log, WLOG_DEBUG, + "IRP_MJ_LOCK_CONTROL, Operation=%s, Lock=0x%08" PRIx32 ", NumLocks=%" PRIu32, + DR_DRIVE_LOCK_REQ2str(Operation)); + + Lock &= 0x01; /* Only bit 0 is of importance */ for (UINT32 x = 0; x < NumLocks; x++) { @@ -1562,6 +1631,9 @@ static UINT rdpdr_server_receive_io_lock_control_request(RdpdrServerContext* con Stream_Read_UINT64(s, Length); Stream_Read_UINT64(s, Offset); + + WLog_Print(context->priv->log, WLOG_DEBUG, + "Locking at Offset=0x%08" PRIx64 " [Length %" PRIu64 "]", Offset, Length); } WLog_Print(context->priv->log, WLOG_WARN, @@ -2573,8 +2645,6 @@ static UINT rdpdr_server_drive_create_directory_callback1(RdpdrServerContext* co RDPDR_IRP* irp, UINT32 deviceId, UINT32 completionId, UINT32 ioStatus) { - UINT32 fileId = 0; - UINT8 information = 0; WINPR_ASSERT(context); WINPR_ASSERT(context->priv); WINPR_ASSERT(s); @@ -2596,8 +2666,11 @@ static UINT rdpdr_server_drive_create_directory_callback1(RdpdrServerContext* co if (!Stream_CheckAndLogRequiredLengthWLog(context->priv->log, s, 5)) return ERROR_INVALID_DATA; - Stream_Read_UINT32(s, fileId); /* FileId (4 bytes) */ - Stream_Read_UINT8(s, information); /* Information (1 byte) */ + const uint32_t fileId = Stream_Get_UINT32(s); /* FileId (4 bytes) */ + const uint8_t information = Stream_Get_UINT8(s); /* Information (1 byte) */ + WLog_Print(context->priv->log, WLOG_DEBUG, "fileId [0x%08" PRIx32 "], information %s", fileId, + fileInformation2str(information)); + /* Setup the IRP. */ irp->CompletionId = context->priv->NextCompletionId++; irp->Callback = rdpdr_server_drive_create_directory_callback2; @@ -2694,8 +2767,6 @@ static UINT rdpdr_server_drive_delete_directory_callback1(RdpdrServerContext* co RDPDR_IRP* irp, UINT32 deviceId, UINT32 completionId, UINT32 ioStatus) { - UINT32 fileId = 0; - UINT8 information = 0; WINPR_ASSERT(context); WINPR_ASSERT(context->priv); WINPR_ASSERT(irp); @@ -2716,8 +2787,11 @@ static UINT rdpdr_server_drive_delete_directory_callback1(RdpdrServerContext* co if (!Stream_CheckAndLogRequiredLengthWLog(context->priv->log, s, 5)) return ERROR_INVALID_DATA; - Stream_Read_UINT32(s, fileId); /* FileId (4 bytes) */ - Stream_Read_UINT8(s, information); /* Information (1 byte) */ + const uint32_t fileId = Stream_Get_UINT32(s); /* FileId (4 bytes) */ + const uint8_t information = Stream_Get_UINT8(s); /* Information (1 byte) */ + WLog_Print(context->priv->log, WLOG_DEBUG, "fileId [0x%08" PRIx32 "], information %s", fileId, + fileInformation2str(information)); + /* Setup the IRP. */ irp->CompletionId = context->priv->NextCompletionId++; irp->Callback = rdpdr_server_drive_delete_directory_callback2; @@ -2863,7 +2937,6 @@ static UINT rdpdr_server_drive_query_directory_callback1(RdpdrServerContext* con RDPDR_IRP* irp, UINT32 deviceId, UINT32 completionId, UINT32 ioStatus) { - UINT32 fileId = 0; WINPR_ASSERT(context); WINPR_ASSERT(context->priv); WINPR_ASSERT(irp); @@ -2884,7 +2957,7 @@ static UINT rdpdr_server_drive_query_directory_callback1(RdpdrServerContext* con if (!Stream_CheckAndLogRequiredLengthWLog(context->priv->log, s, 4)) return ERROR_INVALID_DATA; - Stream_Read_UINT32(s, fileId); + const uint32_t fileId = Stream_Get_UINT32(s); /* Setup the IRP. */ irp->CompletionId = context->priv->NextCompletionId++; irp->Callback = rdpdr_server_drive_query_directory_callback2; @@ -2956,8 +3029,6 @@ static UINT rdpdr_server_drive_open_file_callback(RdpdrServerContext* context, w RDPDR_IRP* irp, UINT32 deviceId, UINT32 completionId, UINT32 ioStatus) { - UINT32 fileId = 0; - UINT8 information = 0; WINPR_ASSERT(context); WINPR_ASSERT(context->priv); WINPR_ASSERT(irp); @@ -2969,8 +3040,11 @@ static UINT rdpdr_server_drive_open_file_callback(RdpdrServerContext* context, w if (!Stream_CheckAndLogRequiredLengthWLog(context->priv->log, s, 5)) return ERROR_INVALID_DATA; - Stream_Read_UINT32(s, fileId); /* FileId (4 bytes) */ - Stream_Read_UINT8(s, information); /* Information (1 byte) */ + const uint32_t fileId = Stream_Get_UINT32(s); /* FileId (4 bytes) */ + const uint8_t information = Stream_Get_UINT8(s); /* Information (1 byte) */ + WLog_Print(context->priv->log, WLOG_DEBUG, "fileId [0x%08" PRIx32 "], information %s", fileId, + fileInformation2str(information)); + /* Invoke the open file completion routine. */ context->OnDriveOpenFileComplete(context, irp->CallbackData, ioStatus, deviceId, fileId); /* Destroy the IRP. */ @@ -3289,8 +3363,6 @@ static UINT rdpdr_server_drive_delete_file_callback1(RdpdrServerContext* context RDPDR_IRP* irp, UINT32 deviceId, UINT32 completionId, UINT32 ioStatus) { - UINT32 fileId = 0; - UINT8 information = 0; WINPR_ASSERT(context); WINPR_ASSERT(context->priv); WINPR_ASSERT(irp); @@ -3311,8 +3383,11 @@ static UINT rdpdr_server_drive_delete_file_callback1(RdpdrServerContext* context if (!Stream_CheckAndLogRequiredLengthWLog(context->priv->log, s, 5)) return ERROR_INVALID_DATA; - Stream_Read_UINT32(s, fileId); /* FileId (4 bytes) */ - Stream_Read_UINT8(s, information); /* Information (1 byte) */ + const uint32_t fileId = Stream_Get_UINT32(s); /* FileId (4 bytes) */ + const uint8_t information = Stream_Get_UINT8(s); /* Information (1 byte) */ + + WLog_Print(context->priv->log, WLOG_DEBUG, "fileId [0x%08" PRIx32 "], information %s", fileId, + fileInformation2str(information)); /* Setup the IRP. */ irp->CompletionId = context->priv->NextCompletionId++; irp->Callback = rdpdr_server_drive_delete_file_callback2; @@ -3448,8 +3523,6 @@ static UINT rdpdr_server_drive_rename_file_callback1(RdpdrServerContext* context RDPDR_IRP* irp, UINT32 deviceId, UINT32 completionId, UINT32 ioStatus) { - UINT32 fileId = 0; - UINT8 information = 0; WINPR_ASSERT(context); WINPR_ASSERT(context->priv); WINPR_ASSERT(irp); @@ -3470,8 +3543,11 @@ static UINT rdpdr_server_drive_rename_file_callback1(RdpdrServerContext* context if (!Stream_CheckAndLogRequiredLengthWLog(context->priv->log, s, 5)) return ERROR_INVALID_DATA; - Stream_Read_UINT32(s, fileId); /* FileId (4 bytes) */ - Stream_Read_UINT8(s, information); /* Information (1 byte) */ + const uint32_t fileId = Stream_Get_UINT32(s); /* FileId (4 bytes) */ + const uint8_t information = Stream_Get_UINT8(s); /* Information (1 byte) */ + WLog_Print(context->priv->log, WLOG_DEBUG, "fileId [0x%08" PRIx32 "], information %s", fileId, + fileInformation2str(information)); + /* Setup the IRP. */ irp->CompletionId = context->priv->NextCompletionId++; irp->Callback = rdpdr_server_drive_rename_file_callback2; diff --git a/channels/urbdrc/client/data_transfer.c b/channels/urbdrc/client/data_transfer.c index e4c4c2a3a..1c57cfdf1 100644 --- a/channels/urbdrc/client/data_transfer.c +++ b/channels/urbdrc/client/data_transfer.c @@ -327,6 +327,9 @@ static UINT urbdrc_process_internal_io_control(IUDEVICE* pdev, GENERIC_CHANNEL_C if (!pdev || !callback || !s || !udevman) return ERROR_INVALID_PARAMETER; + URBDRC_PLUGIN* urbdrc = (URBDRC_PLUGIN*)callback->plugin; + WINPR_ASSERT(urbdrc); + if (!Stream_CheckAndLogRequiredLength(TAG, s, 8)) return ERROR_INVALID_DATA; @@ -343,6 +346,13 @@ static UINT urbdrc_process_internal_io_control(IUDEVICE* pdev, GENERIC_CHANNEL_C // TODO: Implement control code. /** Fixme: Currently this is a FALSE bustime... */ frames = GetTickCount(); + + if (4 > OutputBufferSize) + { + WLog_Print(urbdrc->log, WLOG_DEBUG, "out_size %" PRIu32 " > OutputBufferSize %" PRIu32, 4, + OutputBufferSize); + return ERROR_BAD_CONFIGURATION; + } out = urb_create_iocompletion(InterfaceId, MessageId, RequestId, 4); if (!out) @@ -593,6 +603,14 @@ static UINT urb_select_interface(IUDEVICE* pdev, GENERIC_CHANNEL_CALLBACK* callb MsInterface = MsConfig->MsInterfaces[InterfaceNumber]; interface_size = 16 + (MsInterface->NumberOfPipes * 20); out_size = 36 + interface_size; + if (out_size > OutputBufferSize) + { + WLog_Print(urbdrc->log, WLOG_DEBUG, "out_size %" PRIu32 " > OutputBufferSize %" PRIu32, + out_size, OutputBufferSize); + msusb_msconfig_free(MsConfig); + return ERROR_BAD_CONFIGURATION; + } + out = Stream_New(NULL, out_size); if (!out) @@ -1282,6 +1300,12 @@ static UINT urb_pipe_request(IUDEVICE* pdev, GENERIC_CHANNEL_CALLBACK* callback, /** send data */ out_size = 36; + if (out_size > OutputBufferSize) + { + WLog_Print(urbdrc->log, WLOG_DEBUG, "out_size %" PRIu32 " > OutputBufferSize %" PRIu32, + out_size, OutputBufferSize); + return ERROR_BAD_CONFIGURATION; + } out = Stream_New(NULL, out_size); if (!out) @@ -1327,6 +1351,14 @@ static UINT urb_get_current_frame_number(IUDEVICE* pdev, GENERIC_CHANNEL_CALLBAC /** Fixme: Need to fill actual frame number!!*/ dummy_frames = GetTickCount(); out_size = 40; + + if (out_size > OutputBufferSize) + { + WLog_Print(urbdrc->log, WLOG_DEBUG, "out_size %" PRIu32 " > OutputBufferSize %" PRIu32, + out_size, OutputBufferSize); + return ERROR_BAD_CONFIGURATION; + } + out = Stream_New(NULL, out_size); if (!out) diff --git a/channels/urbdrc/client/urbdrc_main.c b/channels/urbdrc/client/urbdrc_main.c index 3f83934e2..68451a01a 100644 --- a/channels/urbdrc/client/urbdrc_main.c +++ b/channels/urbdrc/client/urbdrc_main.c @@ -403,6 +403,15 @@ static UINT urbdrc_exchange_capabilities(GENERIC_CHANNEL_CALLBACK* callback, wSt switch (FunctionId) { case RIM_EXCHANGE_CAPABILITY_REQUEST: + if (InterfaceId != 0) + { + WLog_ERR( + TAG, + "[MS-RDPEUSB] 2.2.3.1 Interface Manipulation Exchange Capabilities Request " + "(RIM_EXCHANGE_CAPABILITY_REQUEST))::InterfaceId expected 0, got %" PRIu32, + InterfaceId); + return ERROR_INVALID_DATA; + } error = urbdrc_process_capability_request(callback, data, MessageId); break; diff --git a/client/CMakeLists.txt b/client/CMakeLists.txt index 761c6247f..ae384a795 100644 --- a/client/CMakeLists.txt +++ b/client/CMakeLists.txt @@ -47,9 +47,11 @@ if(FREERDP_VENDOR AND WITH_CLIENT) if(APPLE) if(IOS) - if(IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/iOS") - message(STATUS "Adding iOS client") - add_subdirectory(iOS) + if(WITH_FREERDP_3x_DEPRECATED) + if(IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/iOS") + message(STATUS "Adding iOS client") + add_subdirectory(iOS) + endif() endif() else() option(WITH_CLIENT_MAC "Build native mac client" ON) diff --git a/client/SDL/CMakeLists.txt b/client/SDL/CMakeLists.txt index 710cdf67d..0e8ace758 100644 --- a/client/SDL/CMakeLists.txt +++ b/client/SDL/CMakeLists.txt @@ -57,16 +57,18 @@ endif() include(CMakeDependentOption) -# Require 2.0.20 for ubuntu 22.04. -# older versions do not have the SDL2::SDL2 et al targets -find_package(SDL2 2.0.20) find_package(SDL3) cmake_dependent_option(WITH_CLIENT_SDL_VERSIONED "append sdl version to client binaries" OFF WITH_CLIENT_SDL OFF) -cmake_dependent_option( - WITH_CLIENT_SDL2 "[deprecated,experimental] build deprecated,experimental SDL2 client" ${SDL2_FOUND} WITH_CLIENT_SDL - OFF -) +if(WITH_FREERDP_3x_DEPRECATED) + # Require 2.0.20 for ubuntu 22.04. + # older versions do not have the SDL2::SDL2 et al targets + find_package(SDL2 2.0.20) + cmake_dependent_option( + WITH_CLIENT_SDL2 "[deprecated,experimental] build deprecated,experimental SDL2 client" ${SDL2_FOUND} + WITH_CLIENT_SDL OFF + ) +endif() cmake_dependent_option( WITH_CLIENT_SDL3 "[experimental] build experimental SDL3 client" ${SDL3_FOUND} WITH_CLIENT_SDL OFF ) @@ -85,11 +87,13 @@ if((WITH_CLIENT_SDL2 AND SDL2_FOUND) OR (WITH_CLIENT_SDL3 AND SDL3_FOUND)) include_directories(common) endif() -if(WITH_CLIENT_SDL2) - if(SDL2_FOUND) - add_subdirectory(SDL2) - else() - message(WARNING "SDL2 requested but not found, continuing build without SDL2 client") +if(WITH_FREERDP_3x_DEPRECATED) + if(WITH_CLIENT_SDL2) + if(SDL2_FOUND) + add_subdirectory(SDL2) + else() + message(WARNING "SDL2 requested but not found, continuing build without SDL2 client") + endif() endif() endif() diff --git a/client/X11/xf_keyboard.c b/client/X11/xf_keyboard.c index 6d0abc75e..e33043cdb 100644 --- a/client/X11/xf_keyboard.c +++ b/client/X11/xf_keyboard.c @@ -480,14 +480,14 @@ static int load_map_from_xkbfile(xfContext* xfc) char xkb_keyname[XkbKeyNameLength + 1] = { 42, 42, 42, 42, 0 }; /* end-of-string at index 5 */ - WLog_Print(xfc->log, WLOG_WARN, "XkbGetNames() == Success, min=%" PRIu8 ", max=%" PRIu8, + WLog_Print(xfc->log, WLOG_TRACE, "XkbGetNames() == Success, min=%" PRIu8 ", max=%" PRIu8, xkb->min_key_code, xkb->max_key_code); for (size_t i = xkb->min_key_code; i < xkb->max_key_code; i++) { BOOL found = FALSE; strncpy(xkb_keyname, xkb->names->keys[i].name, XkbKeyNameLength); - WLog_Print(xfc->log, WLOG_WARN, "KeyCode %" PRIuz " -> %s", i, xkb_keyname); + WLog_Print(xfc->log, WLOG_TRACE, "KeyCode %" PRIuz " -> %s", i, xkb_keyname); if (strnlen(xkb_keyname, ARRAYSIZE(xkb_keyname)) < 1) continue; diff --git a/libfreerdp/core/activation.c b/libfreerdp/core/activation.c index 92a585e21..503078eb8 100644 --- a/libfreerdp/core/activation.c +++ b/libfreerdp/core/activation.c @@ -751,19 +751,9 @@ BOOL rdp_server_accept_client_control_pdu(rdpRdp* rdp, wStream* s) BOOL rdp_server_accept_client_font_list_pdu(rdpRdp* rdp, wStream* s) { - rdpSettings* settings = NULL; - freerdp_peer* peer = NULL; - WINPR_ASSERT(rdp); WINPR_ASSERT(s); - settings = rdp->settings; - WINPR_ASSERT(settings); - - WINPR_ASSERT(rdp->context); - peer = rdp->context->peer; - WINPR_ASSERT(peer); - if (!rdp_recv_client_font_list_pdu(s)) return FALSE; rdp_finalize_set_flag(rdp, FINALIZE_CS_FONT_LIST_PDU); diff --git a/libfreerdp/core/server.c b/libfreerdp/core/server.c index 895a6d703..4a9e12e99 100644 --- a/libfreerdp/core/server.c +++ b/libfreerdp/core/server.c @@ -1678,12 +1678,8 @@ BOOL WINAPI FreeRDP_WTSVirtualChannelWrite(HANDLE hChannelHandle, PCHAR Buffer, } else { - rdpContext* context = NULL; - first = TRUE; - WINPR_ASSERT(channel->client); - context = channel->client->context; - WINPR_ASSERT(context); + while (Length > 0) { s = Stream_New(NULL, DVC_MAX_DATA_PDU_SIZE); diff --git a/server/Sample/sfreerdp.c b/server/Sample/sfreerdp.c index 582c7aee8..cf9afc472 100644 --- a/server/Sample/sfreerdp.c +++ b/server/Sample/sfreerdp.c @@ -559,12 +559,11 @@ static BOOL tf_peer_dump_rfx(freerdp_peer* client) rdpUpdate* update = NULL; rdpPcap* pcap_rfx = NULL; pcap_record record = { 0 }; - struct server_info* info = NULL; WINPR_ASSERT(client); WINPR_ASSERT(client->context); - info = client->ContextExtra; + struct server_info* info = client->ContextExtra; WINPR_ASSERT(info); s = Stream_New(NULL, 512); @@ -798,7 +797,6 @@ static BOOL tf_peer_post_connect(freerdp_peer* client) static BOOL tf_peer_activate(freerdp_peer* client) { testPeerContext* context = NULL; - struct server_info* info = NULL; rdpSettings* settings = NULL; WINPR_ASSERT(client); @@ -809,7 +807,7 @@ static BOOL tf_peer_activate(freerdp_peer* client) settings = client->context->settings; WINPR_ASSERT(settings); - info = client->ContextExtra; + struct server_info* info = client->ContextExtra; WINPR_ASSERT(info); context->activated = TRUE; @@ -1004,9 +1002,6 @@ static int hook_peer_write_pdu(rdpTransport* transport, wStream* s) UINT64 ts = 0; wStream* ls = NULL; UINT64 last_ts = 0; - const struct server_info* info = NULL; - freerdp_peer* client = NULL; - testPeerContext* peerCtx = NULL; size_t offset = 0; UINT32 flags = 0; rdpContext* context = transport_get_context(transport); @@ -1014,16 +1009,13 @@ static int hook_peer_write_pdu(rdpTransport* transport, wStream* s) WINPR_ASSERT(context); WINPR_ASSERT(s); - client = context->peer; + freerdp_peer* client = context->peer; WINPR_ASSERT(client); - peerCtx = (testPeerContext*)client->context; + testPeerContext* peerCtx = (testPeerContext*)client->context; WINPR_ASSERT(peerCtx); WINPR_ASSERT(peerCtx->io.WritePdu); - info = client->ContextExtra; - WINPR_ASSERT(info); - /* Let the client authenticate. * After that is done, we stop the normal operation and send * a previously recorded session PDU by PDU to the client. @@ -1031,7 +1023,6 @@ static int hook_peer_write_pdu(rdpTransport* transport, wStream* s) * This is fragile and the connecting client needs to use the same * configuration as the one that recorded the session! */ - WINPR_ASSERT(info); CONNECTION_STATE state = freerdp_get_state(context); if (state < CONNECTION_STATE_NEGO) return peerCtx->io.WritePdu(transport, s); @@ -1077,7 +1068,6 @@ static DWORD WINAPI test_peer_mainloop(LPVOID arg) DWORD count = 0; DWORD status = 0; testPeerContext* context = NULL; - struct server_info* info = NULL; rdpSettings* settings = NULL; rdpInput* input = NULL; rdpUpdate* update = NULL; @@ -1085,7 +1075,7 @@ static DWORD WINAPI test_peer_mainloop(LPVOID arg) WINPR_ASSERT(client); - info = client->ContextExtra; + struct server_info* info = client->ContextExtra; WINPR_ASSERT(info); if (!test_peer_init(client)) @@ -1273,14 +1263,13 @@ fail: static BOOL test_peer_accepted(freerdp_listener* instance, freerdp_peer* client) { HANDLE hThread = NULL; - struct server_info* info = NULL; WINPR_UNUSED(instance); WINPR_ASSERT(instance); WINPR_ASSERT(client); - info = instance->info; + struct server_info* info = instance->info; client->ContextExtra = info; if (!(hThread = CreateThread(NULL, 0, test_peer_mainloop, (void*)client, 0, NULL))) diff --git a/server/proxy/channels/pf_channel_smartcard.c b/server/proxy/channels/pf_channel_smartcard.c index 8cbccb177..7eccadb67 100644 --- a/server/proxy/channels/pf_channel_smartcard.c +++ b/server/proxy/channels/pf_channel_smartcard.c @@ -113,7 +113,8 @@ struct thread_arg static void queue_free(void* obj); static void* queue_copy(const void* obj); -static VOID irp_thread(PTP_CALLBACK_INSTANCE Instance, PVOID Context, PTP_WORK Work) +static VOID irp_thread(WINPR_ATTR_UNUSED PTP_CALLBACK_INSTANCE Instance, PVOID Context, + PTP_WORK Work) { struct thread_arg* arg = Context; pf_channel_client_context* scard = arg->scard; @@ -187,20 +188,17 @@ BOOL pf_channel_smartcard_client_handle(wLog* log, pClientContext* pc, wStream* return FALSE; else { - UINT32 DeviceId = 0; - UINT32 MajorFunction = 0; - UINT32 MinorFunction = 0; - - Stream_Read_UINT32(s, DeviceId); /* DeviceId (4 bytes) */ - Stream_Read_UINT32(s, FileId); /* FileId (4 bytes) */ - Stream_Read_UINT32(s, CompletionId); /* CompletionId (4 bytes) */ - Stream_Read_UINT32(s, MajorFunction); /* MajorFunction (4 bytes) */ - Stream_Read_UINT32(s, MinorFunction); /* MinorFunction (4 bytes) */ + const uint32_t DeviceId = Stream_Get_UINT32(s); /* DeviceId (4 bytes) */ + FileId = Stream_Get_UINT32(s); /* FileId (4 bytes) */ + CompletionId = Stream_Get_UINT32(s); /* CompletionId (4 bytes) */ + const uint32_t MajorFunction = Stream_Get_UINT32(s); /* MajorFunction (4 bytes) */ + const uint32_t MinorFunction = Stream_Get_UINT32(s); /* MinorFunction (4 bytes) */ if (MajorFunction != IRP_MJ_DEVICE_CONTROL) { - WLog_WARN(TAG, "[%s] Invalid IRP received, expected %s, got %2", SCARD_SVC_CHANNEL_NAME, - rdpdr_irp_string(IRP_MJ_DEVICE_CONTROL), rdpdr_irp_string(MajorFunction)); + WLog_WARN(TAG, "[%s] Invalid IRP received, expected %s, got %s [0x%08" PRIx32 "]", + SCARD_SVC_CHANNEL_NAME, rdpdr_irp_string(IRP_MJ_DEVICE_CONTROL), + rdpdr_irp_string(MajorFunction), MinorFunction); return FALSE; } e.op.completionID = CompletionId; @@ -259,7 +257,8 @@ fail: return rc; } -BOOL pf_channel_smartcard_server_handle(pServerContext* ps, wStream* s) +BOOL pf_channel_smartcard_server_handle(WINPR_ATTR_UNUSED pServerContext* ps, + WINPR_ATTR_UNUSED wStream* s) { WLog_ERR(TAG, "TODO: unimplemented"); return TRUE; diff --git a/server/proxy/pf_client.c b/server/proxy/pf_client.c index e92af3ba7..fc1746dbf 100644 --- a/server/proxy/pf_client.c +++ b/server/proxy/pf_client.c @@ -119,16 +119,9 @@ static void pf_client_on_activated(void* ctx, WINPR_ATTR_UNUSED const ActivatedE static BOOL pf_client_load_rdpsnd(pClientContext* pc) { rdpContext* context = (rdpContext*)pc; - pServerContext* ps = NULL; - const proxyConfig* config = NULL; WINPR_ASSERT(pc); WINPR_ASSERT(pc->pdata); - ps = pc->pdata->ps; - WINPR_ASSERT(ps); - config = pc->pdata->config; - WINPR_ASSERT(config); - /* * if AudioOutput is enabled in proxy and client connected with rdpsnd, use proxy as rdpsnd * backend. Otherwise, use sys:fake. @@ -540,27 +533,16 @@ static BOOL sendQueuedChannelData(pClientContext* pc) */ static BOOL pf_client_post_connect(freerdp* instance) { - rdpContext* context = NULL; - rdpSettings* settings = NULL; - rdpUpdate* update = NULL; - rdpContext* ps = NULL; - pClientContext* pc = NULL; - const proxyConfig* config = NULL; - WINPR_ASSERT(instance); - context = instance->context; + rdpContext* context = instance->context; WINPR_ASSERT(context); - settings = context->settings; - WINPR_ASSERT(settings); - update = context->update; + rdpUpdate* update = context->update; WINPR_ASSERT(update); - pc = (pClientContext*)context; + pClientContext* pc = (pClientContext*)context; WINPR_ASSERT(pc); WINPR_ASSERT(pc->pdata); - ps = (rdpContext*)pc->pdata->ps; + rdpContext* ps = (rdpContext*)pc->pdata->ps; WINPR_ASSERT(ps); - config = pc->pdata->config; - WINPR_ASSERT(config); if (!pf_modules_run_hook(pc->pdata->module, HOOK_TYPE_CLIENT_POST_CONNECT, pc->pdata, pc)) return FALSE; @@ -568,7 +550,7 @@ static BOOL pf_client_post_connect(freerdp* instance) if (!gdi_init(instance, PIXEL_FORMAT_BGRA32)) return FALSE; - WINPR_ASSERT(freerdp_settings_get_bool(settings, FreeRDP_SoftwareGdi)); + WINPR_ASSERT(freerdp_settings_get_bool(context->settings, FreeRDP_SoftwareGdi)); pf_client_register_update_callbacks(update); @@ -629,19 +611,14 @@ static void pf_client_post_disconnect(freerdp* instance) static BOOL pf_client_redirect(freerdp* instance) { - pClientContext* pc = NULL; - proxyData* pdata = NULL; - if (!instance) return FALSE; if (!instance->context) return FALSE; - pc = (pClientContext*)instance->context; + pClientContext* pc = (pClientContext*)instance->context; WINPR_ASSERT(pc); - pdata = pc->pdata; - WINPR_ASSERT(pdata); #if defined(WITH_PROXY_EMULATE_SMARTCARD) pf_channel_smartcard_client_reset(pc); diff --git a/server/proxy/pf_server.c b/server/proxy/pf_server.c index 0f86806a7..76a294878 100644 --- a/server/proxy/pf_server.c +++ b/server/proxy/pf_server.c @@ -403,24 +403,18 @@ static BOOL pf_server_receive_channel_data_hook(freerdp_peer* peer, UINT16 chann const BYTE* data, size_t size, UINT32 flags, size_t totalSize) { - pServerContext* ps = NULL; - pClientContext* pc = NULL; - proxyData* pdata = NULL; - const proxyConfig* config = NULL; - const pServerStaticChannelContext* channel = NULL; UINT64 channelId64 = channelId; WINPR_ASSERT(peer); - ps = (pServerContext*)peer->context; + pServerContext* ps = (pServerContext*)peer->context; WINPR_ASSERT(ps); - pdata = ps->pdata; + proxyData* pdata = ps->pdata; WINPR_ASSERT(pdata); - pc = pdata->pc; - config = pdata->config; - WINPR_ASSERT(config); + pClientContext* pc = pdata->pc; + /* * client side is not initialized yet, call original callback. * this is probably a drdynvc message between peer and proxy server, @@ -429,7 +423,8 @@ static BOOL pf_server_receive_channel_data_hook(freerdp_peer* peer, UINT16 chann if (!pc) goto original_cb; - channel = HashTable_GetItemValue(ps->channelsByFrontId, &channelId64); + const pServerStaticChannelContext* channel = + HashTable_GetItemValue(ps->channelsByFrontId, &channelId64); if (!channel) { PROXY_LOG_ERR(TAG, ps, "channel id=%" PRIu64 " not registered here, dropping", channelId64); diff --git a/server/shadow/shadow_client.c b/server/shadow/shadow_client.c index e0e36da44..06f6c4da2 100644 --- a/server/shadow/shadow_client.c +++ b/server/shadow/shadow_client.c @@ -701,17 +701,11 @@ static BOOL shadow_client_suppress_output(rdpContext* context, BYTE allow, const static BOOL shadow_client_activate(freerdp_peer* peer) { - rdpSettings* settings = NULL; - rdpShadowClient* client = NULL; - WINPR_ASSERT(peer); - client = (rdpShadowClient*)peer->context; + rdpShadowClient* client = (rdpShadowClient*)peer->context; WINPR_ASSERT(client); - settings = peer->context->settings; - WINPR_ASSERT(settings); - /* Resize client if necessary */ if (shadow_client_recalc_desktop_size(client)) return shadow_send_desktop_resize(client); @@ -1398,7 +1392,6 @@ static BOOL shadow_client_send_surface_gfx(rdpShadowClient* client, const BYTE* } else if (freerdp_settings_get_bool(settings, FreeRDP_GfxPlanar)) { - BOOL rc = 0; const UINT32 w = cmd.right - cmd.left; const UINT32 h = cmd.bottom - cmd.top; const BYTE* src = @@ -1409,8 +1402,10 @@ static BOOL shadow_client_send_surface_gfx(rdpShadowClient* client, const BYTE* return FALSE; } - rc = freerdp_bitmap_planar_context_reset(encoder->planar, w, h); - WINPR_ASSERT(rc); + const BOOL rc = freerdp_bitmap_planar_context_reset(encoder->planar, w, h); + if (!rc) + return FALSE; + freerdp_planar_topdown_image(encoder->planar, TRUE); cmd.data = freerdp_bitmap_compress_planar(encoder->planar, src, SrcFormat, w, h, nSrcStep, @@ -1430,17 +1425,21 @@ static BOOL shadow_client_send_surface_gfx(rdpShadowClient* client, const BYTE* } else { - BOOL rc = 0; const UINT32 w = cmd.right - cmd.left; const UINT32 h = cmd.bottom - cmd.top; const UINT32 length = w * 4 * h; + BYTE* data = malloc(length); + if (!data) + return FALSE; - WINPR_ASSERT(data); - - rc = freerdp_image_copy_no_overlap(data, PIXEL_FORMAT_BGRA32, 0, 0, 0, w, h, pSrcData, - SrcFormat, nSrcStep, cmd.left, cmd.top, NULL, 0); - WINPR_ASSERT(rc); + BOOL rc = freerdp_image_copy_no_overlap(data, PIXEL_FORMAT_BGRA32, 0, 0, 0, w, h, pSrcData, + SrcFormat, nSrcStep, cmd.left, cmd.top, NULL, 0); + if (!rc) + { + free(data); + return FALSE; + } cmd.data = data; cmd.length = length; diff --git a/winpr/include/winpr/bcrypt.h b/winpr/include/winpr/bcrypt.h index 06ed40952..bf97ac901 100644 --- a/winpr/include/winpr/bcrypt.h +++ b/winpr/include/winpr/bcrypt.h @@ -33,66 +33,100 @@ typedef PVOID BCRYPT_KEY_HANDLE; typedef PVOID BCRYPT_HASH_HANDLE; typedef PVOID BCRYPT_SECRET_HANDLE; -static const WCHAR BCRYPT_RSA_ALGORITHM[] = u"RSA"; -static const WCHAR BCRYPT_RSA_SIGN_ALGORITHM[] = u"RSA_SIGN"; -static const WCHAR BCRYPT_DH_ALGORITHM[] = u"DH"; -static const WCHAR BCRYPT_DSA_ALGORITHM[] = u"DSA"; -static const WCHAR BCRYPT_RC2_ALGORITHM[] = u"RC2"; -static const WCHAR BCRYPT_RC4_ALGORITHM[] = u"RC4"; -static const WCHAR BCRYPT_AES_ALGORITHM[] = u"AES"; -static const WCHAR BCRYPT_DES_ALGORITHM[] = u"DES"; -static const WCHAR BCRYPT_DESX_ALGORITHM[] = u"DESX"; -static const WCHAR BCRYPT_3DES_ALGORITHM[] = u"3DES"; -static const WCHAR BCRYPT_3DES_112_ALGORITHM[] = u"3DES_112"; -static const WCHAR BCRYPT_MD2_ALGORITHM[] = u"MD2"; -static const WCHAR BCRYPT_MD4_ALGORITHM[] = u"MD4"; -static const WCHAR BCRYPT_MD5_ALGORITHM[] = u"MD5"; -static const WCHAR BCRYPT_SHA1_ALGORITHM[] = u"SHA1"; -static const WCHAR BCRYPT_SHA256_ALGORITHM[] = u"SHA256"; -static const WCHAR BCRYPT_SHA384_ALGORITHM[] = u"SHA384"; -static const WCHAR BCRYPT_SHA512_ALGORITHM[] = u"SHA512"; -static const WCHAR BCRYPT_AES_GMAC_ALGORITHM[] = u"AES-GMAC"; -static const WCHAR BCRYPT_AES_CMAC_ALGORITHM[] = u"AES-CMAC"; -static const WCHAR BCRYPT_ECDSA_P256_ALGORITHM[] = u"ECDSA_P256"; -static const WCHAR BCRYPT_ECDSA_P384_ALGORITHM[] = u"ECDSA_P384"; -static const WCHAR BCRYPT_ECDSA_P521_ALGORITHM[] = u"ECDSA_P521"; -static const WCHAR BCRYPT_ECDH_P256_ALGORITHM[] = u"ECDSA_P256"; -static const WCHAR BCRYPT_ECDH_P384_ALGORITHM[] = u"ECDSA_P384"; -static const WCHAR BCRYPT_ECDH_P521_ALGORITHM[] = u"ECDSA_P521"; -static const WCHAR BCRYPT_RNG_ALGORITHM[] = u"RNG"; -static const WCHAR BCRYPT_RNG_FIPS186_DSA_ALGORITHM[] = u"FIPS186DSARNG"; -static const WCHAR BCRYPT_RNG_DUAL_EC_ALGORITHM[] = u"DUALECRNG"; +static const WCHAR BCRYPT_RSA_ALGORITHM[] = { 'R', 'S', 'A', '\0' }; +static const WCHAR BCRYPT_RSA_SIGN_ALGORITHM[] = { 'R', 'S', 'A', '_', 'S', 'I', 'G', 'N', '\0' }; +static const WCHAR BCRYPT_DH_ALGORITHM[] = { 'D', 'H', '\0' }; +static const WCHAR BCRYPT_DSA_ALGORITHM[] = { 'D', 'S', 'A', '\0' }; +static const WCHAR BCRYPT_RC2_ALGORITHM[] = { 'R', 'C', '2', '\0' }; +static const WCHAR BCRYPT_RC4_ALGORITHM[] = { 'R', 'C', '4', '\0' }; +static const WCHAR BCRYPT_AES_ALGORITHM[] = { 'A', 'E', 'S', '\0' }; +static const WCHAR BCRYPT_DES_ALGORITHM[] = { 'D', 'E', 'S', '\0' }; +static const WCHAR BCRYPT_DESX_ALGORITHM[] = { 'D', 'E', 'S', 'X', '\0' }; +static const WCHAR BCRYPT_3DES_ALGORITHM[] = { '3', 'D', 'E', 'S', '\0' }; +static const WCHAR BCRYPT_3DES_112_ALGORITHM[] = { '3', 'D', 'E', 'S', '_', '1', '1', '2', '\0' }; +static const WCHAR BCRYPT_MD2_ALGORITHM[] = { 'M', 'D', '2', '\0' }; +static const WCHAR BCRYPT_MD4_ALGORITHM[] = { 'M', 'D', '4', '\0' }; +static const WCHAR BCRYPT_MD5_ALGORITHM[] = { 'M', 'D', '5', '\0' }; +static const WCHAR BCRYPT_SHA1_ALGORITHM[] = { 'S', 'H', 'A', '1', '\0' }; +static const WCHAR BCRYPT_SHA256_ALGORITHM[] = { 'S', 'H', 'A', '2', '5', '6', '\0' }; +static const WCHAR BCRYPT_SHA384_ALGORITHM[] = { 'S', 'H', 'A', '3', '8', '4', '\0' }; +static const WCHAR BCRYPT_SHA512_ALGORITHM[] = { 'S', 'H', 'A', '5', '1', '2', '\0' }; +static const WCHAR BCRYPT_AES_GMAC_ALGORITHM[] = { 'A', 'E', 'S', '-', 'G', 'M', 'A', 'C', '\0' }; +static const WCHAR BCRYPT_AES_CMAC_ALGORITHM[] = { 'A', 'E', 'S', '-', 'C', 'M', 'A', 'C', '\0' }; +static const WCHAR BCRYPT_ECDSA_P256_ALGORITHM[] = { 'E', 'C', 'D', 'S', 'A', '_', + 'P', '2', '5', '6', '\0' }; +static const WCHAR BCRYPT_ECDSA_P384_ALGORITHM[] = { 'E', 'C', 'D', 'S', 'A', '_', + 'P', '3', '8', '4', '\0' }; +static const WCHAR BCRYPT_ECDSA_P521_ALGORITHM[] = { 'E', 'C', 'D', 'S', 'A', '_', + 'P', '5', '2', '1', '\0' }; +static const WCHAR BCRYPT_ECDH_P256_ALGORITHM[] = { 'E', 'C', 'D', 'S', 'A', '_', + 'P', '2', '5', '6', '\0' }; +static const WCHAR BCRYPT_ECDH_P384_ALGORITHM[] = { 'E', 'C', 'D', 'S', 'A', '_', + 'P', '3', '8', '4', '\0' }; +static const WCHAR BCRYPT_ECDH_P521_ALGORITHM[] = { 'E', 'C', 'D', 'S', 'A', '_', + 'P', '5', '2', '1', '\0' }; +static const WCHAR BCRYPT_RNG_ALGORITHM[] = { 'R', 'N', 'G', '\0' }; +static const WCHAR BCRYPT_RNG_FIPS186_DSA_ALGORITHM[] = { 'F', 'I', 'P', 'S', '1', '8', '6', + 'D', 'S', 'A', 'R', 'N', 'G', '\0' }; +static const WCHAR BCRYPT_RNG_DUAL_EC_ALGORITHM[] = { 'D', 'U', 'A', 'L', 'E', + 'C', 'R', 'N', 'G', '\0' }; -static const WCHAR BCRYPT_ECDSA_ALGORITHM[] = u"ECDSA"; -static const WCHAR BCRYPT_ECDH_ALGORITHM[] = u"ECDH"; -static const WCHAR BCRYPT_XTS_AES_ALGORITHM[] = u"XTS-AES"; +static const WCHAR BCRYPT_ECDSA_ALGORITHM[] = { 'E', 'C', 'D', 'S', 'A', '\0' }; +static const WCHAR BCRYPT_ECDH_ALGORITHM[] = { 'E', 'C', 'D', 'H', '\0' }; +static const WCHAR BCRYPT_XTS_AES_ALGORITHM[] = { 'X', 'T', 'S', '-', 'A', 'E', 'S', '\0' }; -static const WCHAR MS_PRIMITIVE_PROVIDER[] = u"Microsoft Primitive Provider"; -static const WCHAR MS_PLATFORM_CRYPTO_PROVIDER[] = u"Microsoft Platform Crypto Provider"; +static const WCHAR MS_PRIMITIVE_PROVIDER[] = { 'M', 'i', 'c', 'r', 'o', 's', 'o', 'f', 't', ' ', + 'P', 'r', 'i', 'm', 'i', 't', 'i', 'v', 'e', ' ', + 'P', 'r', 'o', 'v', 'i', 'd', 'e', 'r', '\0' }; +static const WCHAR MS_PLATFORM_CRYPTO_PROVIDER[] = { 'M', 'i', 'c', 'r', 'o', 's', 'o', 'f', 't', + ' ', 'P', 'l', 'a', 't', 'f', 'o', 'r', 'm', + ' ', 'C', 'r', 'y', 'p', 't', 'o', ' ', 'P', + 'r', 'o', 'v', 'i', 'd', 'e', 'r', '\0' }; #define BCRYPT_ALG_HANDLE_HMAC_FLAG 0x00000008 #define BCRYPT_PROV_DISPATCH 0x00000001 -static const WCHAR BCRYPT_OBJECT_LENGTH[] = u"ObjectLength"; -static const WCHAR BCRYPT_ALGORITHM_NAME[] = u"AlgorithmName"; -static const WCHAR BCRYPT_PROVIDER_HANDLE[] = u"ProviderHandle"; -static const WCHAR BCRYPT_CHAINING_MODE[] = u"ChainingMode"; -static const WCHAR BCRYPT_BLOCK_LENGTH[] = u"BlockLength"; -static const WCHAR BCRYPT_KEY_LENGTH[] = u"KeyLength"; -static const WCHAR BCRYPT_KEY_OBJECT_LENGTH[] = u"KeyObjectLength"; -static const WCHAR BCRYPT_KEY_STRENGTH[] = u"KeyStrength"; -static const WCHAR BCRYPT_KEY_LENGTHS[] = u"KeyLengths"; -static const WCHAR BCRYPT_BLOCK_SIZE_LIST[] = u"BlockSizeList"; -static const WCHAR BCRYPT_EFFECTIVE_KEY_LENGTH[] = u"EffectiveKeyLength"; -static const WCHAR BCRYPT_HASH_LENGTH[] = u"HashDigestLength"; -static const WCHAR BCRYPT_HASH_OID_LIST[] = u"HashOIDList"; -static const WCHAR BCRYPT_PADDING_SCHEMES[] = u"PaddingSchemes"; -static const WCHAR BCRYPT_SIGNATURE_LENGTH[] = u"SignatureLength"; -static const WCHAR BCRYPT_HASH_BLOCK_LENGTH[] = u"HashBlockLength"; -static const WCHAR BCRYPT_AUTH_TAG_LENGTH[] = u"AuthTagLength"; -static const WCHAR BCRYPT_PRIMITIVE_TYPE[] = u"PrimitiveType"; -static const WCHAR BCRYPT_IS_KEYED_HASH[] = u"IsKeyedHash"; -static const WCHAR BCRYPT_KEY_DATA_BLOB[] = u"KeyDataBlob"; +static const WCHAR BCRYPT_OBJECT_LENGTH[] = { 'O', 'b', 'j', 'e', 'c', 't', 'L', + 'e', 'n', 'g', 't', 'h', '\0' }; +static const WCHAR BCRYPT_ALGORITHM_NAME[] = { 'A', 'l', 'g', 'o', 'r', 'i', 't', + 'h', 'm', 'N', 'a', 'm', 'e', '\0' }; +static const WCHAR BCRYPT_PROVIDER_HANDLE[] = { 'P', 'r', 'o', 'v', 'i', 'd', 'e', 'r', + 'H', 'a', 'n', 'd', 'l', 'e', '\0' }; +static const WCHAR BCRYPT_CHAINING_MODE[] = { 'C', 'h', 'a', 'i', 'n', 'i', 'n', + 'g', 'M', 'o', 'd', 'e', '\0' }; +static const WCHAR BCRYPT_BLOCK_LENGTH[] = { 'B', 'l', 'o', 'c', 'k', 'L', + 'e', 'n', 'g', 't', 'h', '\0' }; +static const WCHAR BCRYPT_KEY_LENGTH[] = { 'K', 'e', 'y', 'L', 'e', 'n', 'g', 't', 'h', '\0' }; +static const WCHAR BCRYPT_KEY_OBJECT_LENGTH[] = { 'K', 'e', 'y', 'O', 'b', 'j', 'e', 'c', + 't', 'L', 'e', 'n', 'g', 't', 'h', '\0' }; +static const WCHAR BCRYPT_KEY_STRENGTH[] = { 'K', 'e', 'y', 'S', 't', 'r', + 'e', 'n', 'g', 't', 'h', '\0' }; +static const WCHAR BCRYPT_KEY_LENGTHS[] = { + 'K', 'e', 'y', 'L', 'e', 'n', 'g', 't', 'h', 's', '\0' +}; +static const WCHAR BCRYPT_BLOCK_SIZE_LIST[] = { 'B', 'l', 'o', 'c', 'k', 'S', 'i', + 'z', 'e', 'L', 'i', 's', 't', '\0' }; +static const WCHAR BCRYPT_EFFECTIVE_KEY_LENGTH[] = { 'E', 'f', 'f', 'e', 'c', 't', 'i', + 'v', 'e', 'K', 'e', 'y', 'L', 'e', + 'n', 'g', 't', 'h', '\0' }; +static const WCHAR BCRYPT_HASH_LENGTH[] = { 'H', 'a', 's', 'h', 'D', 'i', 'g', 'e', 's', + 't', 'L', 'e', 'n', 'g', 't', 'h', '\0' }; +static const WCHAR BCRYPT_HASH_OID_LIST[] = { 'H', 'a', 's', 'h', 'O', 'I', + 'D', 'L', 'i', 's', 't', '\0' }; +static const WCHAR BCRYPT_PADDING_SCHEMES[] = { 'P', 'a', 'd', 'd', 'i', 'n', 'g', 'S', + 'c', 'h', 'e', 'm', 'e', 's', '\0' }; +static const WCHAR BCRYPT_SIGNATURE_LENGTH[] = { 'S', 'i', 'g', 'n', 'a', 't', 'u', 'r', + 'e', 'L', 'e', 'n', 'g', 't', 'h', '\0' }; +static const WCHAR BCRYPT_HASH_BLOCK_LENGTH[] = { 'H', 'a', 's', 'h', 'B', 'l', 'o', 'c', + 'k', 'L', 'e', 'n', 'g', 't', 'h', '\0' }; +static const WCHAR BCRYPT_AUTH_TAG_LENGTH[] = { 'A', 'u', 't', 'h', 'T', 'a', 'g', + 'L', 'e', 'n', 'g', 't', 'h', '\0' }; +static const WCHAR BCRYPT_PRIMITIVE_TYPE[] = { 'P', 'r', 'i', 'm', 'i', 't', 'i', + 'v', 'e', 'T', 'y', 'p', 'e', '\0' }; +static const WCHAR BCRYPT_IS_KEYED_HASH[] = { 'I', 's', 'K', 'e', 'y', 'e', + 'd', 'H', 'a', 's', 'h', '\0' }; +static const WCHAR BCRYPT_KEY_DATA_BLOB[] = { 'K', 'e', 'y', 'D', 'a', 't', + 'a', 'B', 'l', 'o', 'b', '\0' }; #define BCRYPT_BLOCK_PADDING 0x00000001 diff --git a/winpr/include/winpr/nt.h b/winpr/include/winpr/nt.h index 672d2ee85..12667139e 100644 --- a/winpr/include/winpr/nt.h +++ b/winpr/include/winpr/nt.h @@ -1565,6 +1565,15 @@ extern "C" WINPR_API const char* NtStatus2Tag(NTSTATUS ntstatus); WINPR_API const char* Win32ErrorCode2Tag(UINT16 code); + /** @brief convert a \ref FILE_INFORMATION_CLASS to a string + * + * @param value The \ref FILE_INFORMATION_CLASS to convert + * + * @return A string representation of the value or "UNKNOWN" for invalid values + * @since version 3.13.0 + */ + WINPR_API const char* FSInformationClass2Tag(FILE_INFORMATION_CLASS value); + #ifdef __cplusplus } #endif diff --git a/winpr/libwinpr/nt/nt.c b/winpr/libwinpr/nt/nt.c index a863d2872..7b38c4659 100644 --- a/winpr/libwinpr/nt/nt.c +++ b/winpr/libwinpr/nt/nt.c @@ -62,3 +62,92 @@ PTEB NtCurrentTeb(void) return teb; } #endif + +const char* FSInformationClass2Tag(FILE_INFORMATION_CLASS value) +{ + switch (value) + { + case FileDirectoryInformation: + return "FileDirectoryInformation"; + case FileFullDirectoryInformation: + return "FileFullDirectoryInformation"; + case FileBothDirectoryInformation: + return "FileBothDirectoryInformation"; + case FileBasicInformation: + return "FileBasicInformation"; + case FileStandardInformation: + return "FileStandardInformation"; + case FileInternalInformation: + return "FileInternalInformation"; + case FileEaInformation: + return "FileEaInformation"; + case FileAccessInformation: + return "FileAccessInformation"; + case FileNameInformation: + return "FileNameInformation"; + case FileRenameInformation: + return "FileRenameInformation"; + case FileLinkInformation: + return "FileLinkInformation"; + case FileNamesInformation: + return "FileNamesInformation"; + case FileDispositionInformation: + return "FileDispositionInformation"; + case FilePositionInformation: + return "FilePositionInformation"; + case FileFullEaInformation: + return "FileFullEaInformation"; + case FileModeInformation: + return "FileModeInformation"; + case FileAlignmentInformation: + return "FileAlignmentInformation"; + case FileAllInformation: + return "FileAllInformation"; + case FileAllocationInformation: + return "FileAllocationInformation"; + case FileEndOfFileInformation: + return "FileEndOfFileInformation"; + case FileAlternateNameInformation: + return "FileAlternateNameInformation"; + case FileStreamInformation: + return "FileStreamInformation"; + case FilePipeInformation: + return "FilePipeInformation"; + case FilePipeLocalInformation: + return "FilePipeLocalInformation"; + case FilePipeRemoteInformation: + return "FilePipeRemoteInformation"; + case FileMailslotQueryInformation: + return "FileMailslotQueryInformation"; + case FileMailslotSetInformation: + return "FileMailslotSetInformation"; + case FileCompressionInformation: + return "FileCompressionInformation"; + case FileObjectIdInformation: + return "FileObjectIdInformation"; + case FileUnknownInformation1: + return "FileUnknownInformation1"; + case FileMoveClusterInformation: + return "FileMoveClusterInformation"; + case FileQuotaInformation: + return "FileQuotaInformation"; + case FileReparsePointInformation: + return "FileReparsePointInformation"; + case FileNetworkOpenInformation: + return "FileNetworkOpenInformation"; + case FileAttributeTagInformation: + return "FileAttributeTagInformation"; + case FileTrackingInformation: + return "FileTrackingInformation"; + case FileIdBothDirectoryInformation: + return "FileIdBothDirectoryInformation"; + case FileIdFullDirectoryInformation: + return "FileIdFullDirectoryInformation"; + case FileValidDataLengthInformation: + return "FileValidDataLengthInformation"; + case FileShortNameInformation: + return "FileShortNameInformation"; + default: + return "UNKNOWN"; + } +}