[channels] use Stream_BufferAs
For WTSVirtualChannelRead and WTSVirtualChannelWrite use Stream_BufferAs to cast to correct type.
This commit is contained in:
parent
55177e0e46
commit
11b7633dc0
@ -177,7 +177,7 @@ static UINT ainput_server_send_version(ainput_server* ainput)
|
||||
Stream_Write_UINT32(s, AINPUT_VERSION_MINOR); /* Version (4 bytes) */
|
||||
|
||||
WINPR_ASSERT(Stream_GetPosition(s) <= UINT32_MAX);
|
||||
if (!WTSVirtualChannelWrite(ainput->ainput_channel, (PCHAR)Stream_Buffer(s),
|
||||
if (!WTSVirtualChannelWrite(ainput->ainput_channel, Stream_BufferAs(s, char),
|
||||
(ULONG)Stream_GetPosition(s), &written))
|
||||
{
|
||||
WLog_ERR(TAG, "WTSVirtualChannelWrite failed!");
|
||||
@ -467,7 +467,7 @@ static UINT ainput_process_message(ainput_server* ainput)
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (WTSVirtualChannelRead(ainput->ainput_channel, 0, (PCHAR)Stream_Buffer(s),
|
||||
if (WTSVirtualChannelRead(ainput->ainput_channel, 0, Stream_BufferAs(s, char),
|
||||
(ULONG)Stream_Capacity(s), &ActualBytesReturned) == FALSE)
|
||||
{
|
||||
WLog_ERR(TAG, "WTSVirtualChannelRead failed!");
|
||||
|
@ -379,7 +379,7 @@ static DWORD WINAPI audin_server_thread_func(LPVOID arg)
|
||||
break;
|
||||
|
||||
WINPR_ASSERT(Stream_Capacity(s) <= UINT32_MAX);
|
||||
if (WTSVirtualChannelRead(audin->audin_channel, 0, (PCHAR)Stream_Buffer(s),
|
||||
if (WTSVirtualChannelRead(audin->audin_channel, 0, Stream_BufferAs(s, char),
|
||||
(ULONG)Stream_Capacity(s), &BytesReturned) == FALSE)
|
||||
{
|
||||
WLog_Print(audin->log, WLOG_ERROR, "WTSVirtualChannelRead failed!");
|
||||
@ -572,7 +572,7 @@ static UINT audin_server_packet_send(audin_server_context* context, wStream* s)
|
||||
if (pos > UINT32_MAX)
|
||||
return ERROR_INVALID_PARAMETER;
|
||||
|
||||
if (!WTSVirtualChannelWrite(audin->audin_channel, (PCHAR)Stream_Buffer(s), (UINT32)pos,
|
||||
if (!WTSVirtualChannelWrite(audin->audin_channel, Stream_BufferAs(s, char), (UINT32)pos,
|
||||
&written))
|
||||
{
|
||||
WLog_Print(audin->log, WLOG_ERROR, "WTSVirtualChannelWrite failed!");
|
||||
|
@ -78,24 +78,32 @@
|
||||
*/
|
||||
static UINT cliprdr_server_packet_send(CliprdrServerPrivate* cliprdr, wStream* s)
|
||||
{
|
||||
UINT rc = ERROR_INTERNAL_ERROR;
|
||||
UINT rc = 0;
|
||||
size_t pos = 0;
|
||||
BOOL status = 0;
|
||||
UINT32 dataLen = 0;
|
||||
ULONG written = 0;
|
||||
|
||||
WINPR_ASSERT(cliprdr);
|
||||
|
||||
const size_t pos = Stream_GetPosition(s);
|
||||
pos = Stream_GetPosition(s);
|
||||
if ((pos < 8) || (pos > UINT32_MAX))
|
||||
{
|
||||
rc = ERROR_NO_DATA;
|
||||
goto fail;
|
||||
}
|
||||
|
||||
const UINT32 dataLen = (UINT32)(pos - 8);
|
||||
dataLen = (UINT32)(pos - 8);
|
||||
Stream_SetPosition(s, 4);
|
||||
Stream_Write_UINT32(s, dataLen);
|
||||
if (pos > UINT32_MAX)
|
||||
{
|
||||
rc = ERROR_INVALID_DATA;
|
||||
goto fail;
|
||||
}
|
||||
|
||||
ULONG written = 0;
|
||||
const BOOL status = WTSVirtualChannelWrite(cliprdr->ChannelHandle, (PCHAR)Stream_Buffer(s),
|
||||
(UINT32)pos, &written);
|
||||
status = WTSVirtualChannelWrite(cliprdr->ChannelHandle, Stream_BufferAs(s, char), (UINT32)pos,
|
||||
&written);
|
||||
rc = status ? CHANNEL_RC_OK : ERROR_INTERNAL_ERROR;
|
||||
fail:
|
||||
Stream_Free(s, TRUE);
|
||||
|
@ -315,7 +315,7 @@ static UINT disp_server_handle_messages(DispServerContext* context)
|
||||
if (cap > UINT32_MAX)
|
||||
return CHANNEL_RC_NO_BUFFER;
|
||||
|
||||
if (WTSVirtualChannelRead(priv->disp_channel, 0, (PCHAR)Stream_Buffer(s), (ULONG)cap,
|
||||
if (WTSVirtualChannelRead(priv->disp_channel, 0, Stream_BufferAs(s, char), (ULONG)cap,
|
||||
&BytesReturned) == FALSE)
|
||||
{
|
||||
WLog_ERR(TAG, "WTSVirtualChannelRead failed!");
|
||||
@ -499,7 +499,7 @@ static UINT disp_server_packet_send(DispServerContext* context, wStream* s)
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (!WTSVirtualChannelWrite(context->priv->disp_channel, (PCHAR)Stream_Buffer(s), pos,
|
||||
if (!WTSVirtualChannelWrite(context->priv->disp_channel, Stream_BufferAs(s, char), pos,
|
||||
&written))
|
||||
{
|
||||
WLog_ERR(TAG, "WTSVirtualChannelWrite failed!");
|
||||
|
@ -256,7 +256,7 @@ static DWORD WINAPI echo_server_thread_func(LPVOID arg)
|
||||
break;
|
||||
}
|
||||
|
||||
if (WTSVirtualChannelRead(echo->echo_channel, 0, (PCHAR)Stream_Buffer(s),
|
||||
if (WTSVirtualChannelRead(echo->echo_channel, 0, Stream_BufferAs(s, char),
|
||||
(ULONG)Stream_Capacity(s), &BytesReturned) == FALSE)
|
||||
{
|
||||
WLog_ERR(TAG, "WTSVirtualChannelRead failed!");
|
||||
|
@ -251,7 +251,7 @@ static DWORD WINAPI encomsp_server_thread(LPVOID arg)
|
||||
|
||||
const size_t cap = Stream_Capacity(s);
|
||||
if ((cap > UINT32_MAX) ||
|
||||
!WTSVirtualChannelRead(context->priv->ChannelHandle, 0, (PCHAR)Stream_Buffer(s),
|
||||
!WTSVirtualChannelRead(context->priv->ChannelHandle, 0, Stream_BufferAs(s, char),
|
||||
(ULONG)cap, &BytesReturned))
|
||||
{
|
||||
WLog_ERR(TAG, "WTSVirtualChannelRead failed!");
|
||||
|
@ -296,7 +296,7 @@ static UINT location_process_message(location_server* location)
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (WTSVirtualChannelRead(location->location_channel, 0, (PCHAR)Stream_Buffer(s),
|
||||
if (WTSVirtualChannelRead(location->location_channel, 0, Stream_BufferAs(s, char),
|
||||
(ULONG)Stream_Capacity(s), &BytesReturned) == FALSE)
|
||||
{
|
||||
WLog_ERR(TAG, "WTSVirtualChannelRead failed!");
|
||||
@ -544,7 +544,7 @@ static UINT location_server_packet_send(LocationServerContext* context, wStream*
|
||||
const size_t pos = Stream_GetPosition(s);
|
||||
if (pos > UINT32_MAX)
|
||||
return ERROR_OUTOFMEMORY;
|
||||
if (!WTSVirtualChannelWrite(location->location_channel, (PCHAR)Stream_Buffer(s), (ULONG)pos,
|
||||
if (!WTSVirtualChannelWrite(location->location_channel, Stream_BufferAs(s, char), (ULONG)pos,
|
||||
&written))
|
||||
{
|
||||
WLog_ERR(TAG, "WTSVirtualChannelWrite failed!");
|
||||
|
@ -46,7 +46,7 @@ static UINT rail_send(RailServerContext* context, wStream* s, ULONG length)
|
||||
if (!context)
|
||||
return CHANNEL_RC_BAD_INIT_HANDLE;
|
||||
|
||||
if (!WTSVirtualChannelWrite(context->priv->rail_channel, (PCHAR)Stream_Buffer(s), length,
|
||||
if (!WTSVirtualChannelWrite(context->priv->rail_channel, Stream_BufferAs(s, char), length,
|
||||
&written))
|
||||
{
|
||||
WLog_ERR(TAG, "WTSVirtualChannelWrite failed!");
|
||||
|
@ -230,7 +230,7 @@ static UINT rdpdr_seal_send_free_request(RdpdrServerContext* context, wStream* s
|
||||
rdpdr_packetid_string(header.PacketId), header.PacketId);
|
||||
}
|
||||
winpr_HexLogDump(context->priv->log, WLOG_DEBUG, Stream_Buffer(s), Stream_Length(s));
|
||||
status = WTSVirtualChannelWrite(context->priv->ChannelHandle, (PCHAR)Stream_Buffer(s),
|
||||
status = WTSVirtualChannelWrite(context->priv->ChannelHandle, Stream_BufferAs(s, char),
|
||||
(ULONG)length, &written);
|
||||
Stream_Free(s, TRUE);
|
||||
return status ? CHANNEL_RC_OK : ERROR_INTERNAL_ERROR;
|
||||
@ -2078,7 +2078,7 @@ static DWORD WINAPI rdpdr_server_thread(LPVOID arg)
|
||||
}
|
||||
|
||||
capacity = MIN(Stream_Capacity(s), UINT32_MAX);
|
||||
if (!WTSVirtualChannelRead(context->priv->ChannelHandle, 0, (PCHAR)Stream_Buffer(s),
|
||||
if (!WTSVirtualChannelRead(context->priv->ChannelHandle, 0, Stream_BufferAs(s, char),
|
||||
(ULONG)capacity, &BytesReturned))
|
||||
{
|
||||
WLog_Print(context->priv->log, WLOG_ERROR, "WTSVirtualChannelRead failed!");
|
||||
|
@ -287,7 +287,7 @@ static UINT enumerator_process_message(enumerator_server* enumerator)
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (WTSVirtualChannelRead(enumerator->enumerator_channel, 0, (PCHAR)Stream_Buffer(s),
|
||||
if (WTSVirtualChannelRead(enumerator->enumerator_channel, 0, Stream_BufferAs(s, char),
|
||||
(ULONG)Stream_Capacity(s), &BytesReturned) == FALSE)
|
||||
{
|
||||
WLog_ERR(TAG, "WTSVirtualChannelRead failed!");
|
||||
@ -531,7 +531,7 @@ static UINT enumerator_server_packet_send(CamDevEnumServerContext* context, wStr
|
||||
UINT error = CHANNEL_RC_OK;
|
||||
ULONG written = 0;
|
||||
|
||||
if (!WTSVirtualChannelWrite(enumerator->enumerator_channel, (PCHAR)Stream_Buffer(s),
|
||||
if (!WTSVirtualChannelWrite(enumerator->enumerator_channel, Stream_BufferAs(s, char),
|
||||
Stream_GetPosition(s), &written))
|
||||
{
|
||||
WLog_ERR(TAG, "WTSVirtualChannelWrite failed!");
|
||||
|
@ -426,7 +426,7 @@ static UINT device_process_message(device_server* device)
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (WTSVirtualChannelRead(device->device_channel, 0, (PCHAR)Stream_Buffer(s),
|
||||
if (WTSVirtualChannelRead(device->device_channel, 0, Stream_BufferAs(s, char),
|
||||
(ULONG)Stream_Capacity(s), &BytesReturned) == FALSE)
|
||||
{
|
||||
WLog_ERR(TAG, "WTSVirtualChannelRead failed!");
|
||||
@ -704,7 +704,7 @@ static UINT device_server_packet_send(CameraDeviceServerContext* context, wStrea
|
||||
WINPR_ASSERT(context);
|
||||
WINPR_ASSERT(s);
|
||||
|
||||
if (!WTSVirtualChannelWrite(device->device_channel, (PCHAR)Stream_Buffer(s),
|
||||
if (!WTSVirtualChannelWrite(device->device_channel, Stream_BufferAs(s, char),
|
||||
Stream_GetPosition(s), &written))
|
||||
{
|
||||
WLog_ERR(TAG, "WTSVirtualChannelWrite failed!");
|
||||
|
@ -252,7 +252,7 @@ static UINT mouse_cursor_process_message(mouse_cursor_server* mouse_cursor)
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (WTSVirtualChannelRead(mouse_cursor->mouse_cursor_channel, 0, (PCHAR)Stream_Buffer(s),
|
||||
if (WTSVirtualChannelRead(mouse_cursor->mouse_cursor_channel, 0, Stream_BufferAs(s, char),
|
||||
(ULONG)Stream_Capacity(s), &BytesReturned) == FALSE)
|
||||
{
|
||||
WLog_ERR(TAG, "WTSVirtualChannelRead failed!");
|
||||
@ -514,7 +514,7 @@ static UINT mouse_cursor_server_packet_send(MouseCursorServerContext* context, w
|
||||
const size_t pos = Stream_GetPosition(s);
|
||||
if (pos > UINT32_MAX)
|
||||
return ERROR_OUTOFMEMORY;
|
||||
if (!WTSVirtualChannelWrite(mouse_cursor->mouse_cursor_channel, (PCHAR)Stream_Buffer(s),
|
||||
if (!WTSVirtualChannelWrite(mouse_cursor->mouse_cursor_channel, Stream_BufferAs(s, char),
|
||||
(ULONG)pos, &written))
|
||||
{
|
||||
WLog_ERR(TAG, "WTSVirtualChannelWrite failed!");
|
||||
|
@ -1836,7 +1836,7 @@ UINT rdpgfx_server_handle_messages(RdpgfxServerContext* context)
|
||||
return CHANNEL_RC_NO_MEMORY;
|
||||
}
|
||||
|
||||
if (WTSVirtualChannelRead(priv->rdpgfx_channel, 0, (PCHAR)Stream_Buffer(s),
|
||||
if (WTSVirtualChannelRead(priv->rdpgfx_channel, 0, Stream_BufferAs(s, char),
|
||||
Stream_Capacity(s), &BytesReturned) == FALSE)
|
||||
{
|
||||
WLog_Print(context->priv->log, WLOG_ERROR, "WTSVirtualChannelRead failed!");
|
||||
|
@ -87,7 +87,7 @@ static UINT rdpsnd_server_send_formats(RdpsndServerContext* context)
|
||||
Stream_SetPosition(s, pos);
|
||||
|
||||
WINPR_ASSERT(context->priv);
|
||||
status = WTSVirtualChannelWrite(context->priv->ChannelHandle, (PCHAR)Stream_Buffer(s),
|
||||
status = WTSVirtualChannelWrite(context->priv->ChannelHandle, Stream_BufferAs(s, char),
|
||||
Stream_GetPosition(s), &written);
|
||||
Stream_SetPosition(s, 0);
|
||||
fail:
|
||||
@ -456,7 +456,7 @@ static UINT rdpsnd_server_training(RdpsndServerContext* context, UINT16 timestam
|
||||
Stream_SetPosition(s, 2);
|
||||
Stream_Write_UINT16(s, end - 4);
|
||||
|
||||
status = WTSVirtualChannelWrite(context->priv->ChannelHandle, (PCHAR)Stream_Buffer(s), end,
|
||||
status = WTSVirtualChannelWrite(context->priv->ChannelHandle, Stream_BufferAs(s, char), end,
|
||||
&written);
|
||||
|
||||
Stream_SetPosition(s, 0);
|
||||
@ -537,7 +537,7 @@ static UINT rdpsnd_server_send_wave_pdu(RdpsndServerContext* context, UINT16 wTi
|
||||
Stream_Write_UINT16(s, end - start + 8);
|
||||
Stream_SetPosition(s, end);
|
||||
|
||||
if (!WTSVirtualChannelWrite(context->priv->ChannelHandle, (PCHAR)Stream_Buffer(s),
|
||||
if (!WTSVirtualChannelWrite(context->priv->ChannelHandle, Stream_BufferAs(s, char),
|
||||
start + 4, &written))
|
||||
{
|
||||
WLog_ERR(TAG, "WTSVirtualChannelWrite failed!");
|
||||
@ -637,7 +637,7 @@ static UINT rdpsnd_server_send_wave2_pdu(RdpsndServerContext* context, UINT16 fo
|
||||
Stream_SetPosition(s, 2);
|
||||
Stream_Write_UINT16(s, end - 4);
|
||||
|
||||
status = WTSVirtualChannelWrite(context->priv->ChannelHandle, (PCHAR)Stream_Buffer(s), end,
|
||||
status = WTSVirtualChannelWrite(context->priv->ChannelHandle, Stream_BufferAs(s, char), end,
|
||||
&written);
|
||||
|
||||
if (!status || (end != written))
|
||||
@ -776,7 +776,7 @@ static UINT rdpsnd_server_set_volume(RdpsndServerContext* context, UINT16 left,
|
||||
Stream_Write_UINT16(s, right);
|
||||
len = Stream_GetPosition(s);
|
||||
|
||||
status = WTSVirtualChannelWrite(context->priv->ChannelHandle, (PCHAR)Stream_Buffer(s),
|
||||
status = WTSVirtualChannelWrite(context->priv->ChannelHandle, Stream_BufferAs(s, char),
|
||||
(ULONG)len, &written);
|
||||
Stream_SetPosition(s, 0);
|
||||
return status ? CHANNEL_RC_OK : ERROR_INTERNAL_ERROR;
|
||||
@ -827,7 +827,7 @@ static UINT rdpsnd_server_close(RdpsndServerContext* context)
|
||||
Stream_SetPosition(s, 2);
|
||||
Stream_Write_UINT16(s, pos - 4);
|
||||
Stream_SetPosition(s, pos);
|
||||
status = WTSVirtualChannelWrite(context->priv->ChannelHandle, (PCHAR)Stream_Buffer(s),
|
||||
status = WTSVirtualChannelWrite(context->priv->ChannelHandle, Stream_BufferAs(s, char),
|
||||
Stream_GetPosition(s), &written);
|
||||
Stream_SetPosition(s, 0);
|
||||
return status ? CHANNEL_RC_OK : ERROR_INTERNAL_ERROR;
|
||||
|
@ -38,7 +38,7 @@ static UINT remdesk_virtual_channel_write(RemdeskServerContext* context, wStream
|
||||
{
|
||||
BOOL status = 0;
|
||||
ULONG BytesWritten = 0;
|
||||
status = WTSVirtualChannelWrite(context->priv->ChannelHandle, (PCHAR)Stream_Buffer(s),
|
||||
status = WTSVirtualChannelWrite(context->priv->ChannelHandle, Stream_BufferAs(s, char),
|
||||
Stream_Length(s), &BytesWritten);
|
||||
return (status) ? CHANNEL_RC_OK : ERROR_INTERNAL_ERROR;
|
||||
}
|
||||
@ -595,7 +595,7 @@ static DWORD WINAPI remdesk_server_thread(LPVOID arg)
|
||||
break;
|
||||
}
|
||||
|
||||
if (WTSVirtualChannelRead(context->priv->ChannelHandle, 0, (PCHAR)Stream_Buffer(s),
|
||||
if (WTSVirtualChannelRead(context->priv->ChannelHandle, 0, Stream_BufferAs(s, char),
|
||||
Stream_Capacity(s), &BytesReturned))
|
||||
{
|
||||
if (BytesReturned)
|
||||
|
@ -174,7 +174,7 @@ static UINT telemetry_process_message(telemetry_server* telemetry)
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (WTSVirtualChannelRead(telemetry->telemetry_channel, 0, (PCHAR)Stream_Buffer(s),
|
||||
if (WTSVirtualChannelRead(telemetry->telemetry_channel, 0, Stream_BufferAs(s, char),
|
||||
(ULONG)Stream_Capacity(s), &BytesReturned) == FALSE)
|
||||
{
|
||||
WLog_ERR(TAG, "WTSVirtualChannelRead failed!");
|
||||
|
@ -1411,7 +1411,7 @@ HANDLE WINAPI FreeRDP_WTSVirtualChannelOpenEx(DWORD SessionId, LPSTR pVirtualNam
|
||||
if (!wts_write_drdynvc_create_request(s, channel->channelId, pVirtualName))
|
||||
goto fail;
|
||||
|
||||
if (!WTSVirtualChannelWrite(vcm->drdynvc_channel, (PCHAR)Stream_Buffer(s),
|
||||
if (!WTSVirtualChannelWrite(vcm->drdynvc_channel, Stream_BufferAs(s, char),
|
||||
Stream_GetPosition(s), &written))
|
||||
goto fail;
|
||||
|
||||
@ -1469,7 +1469,7 @@ BOOL WINAPI FreeRDP_WTSVirtualChannelClose(HANDLE hChannelHandle)
|
||||
else
|
||||
{
|
||||
wts_write_drdynvc_header(s, CLOSE_REQUEST_PDU, channel->channelId);
|
||||
ret = WTSVirtualChannelWrite(vcm->drdynvc_channel, (PCHAR)Stream_Buffer(s),
|
||||
ret = WTSVirtualChannelWrite(vcm->drdynvc_channel, Stream_BufferAs(s, char),
|
||||
Stream_GetPosition(s), &written);
|
||||
Stream_Free(s, TRUE);
|
||||
}
|
||||
|
@ -653,7 +653,7 @@ static DWORD WINAPI tf_debug_channel_thread_func(LPVOID arg)
|
||||
|
||||
Stream_SetPosition(s, 0);
|
||||
|
||||
if (WTSVirtualChannelRead(context->debug_channel, 0, (PCHAR)Stream_Buffer(s),
|
||||
if (WTSVirtualChannelRead(context->debug_channel, 0, Stream_BufferAs(s, char),
|
||||
(ULONG)Stream_Capacity(s), &BytesReturned) == FALSE)
|
||||
{
|
||||
if (BytesReturned == 0)
|
||||
@ -662,7 +662,7 @@ static DWORD WINAPI tf_debug_channel_thread_func(LPVOID arg)
|
||||
if (!Stream_EnsureRemainingCapacity(s, BytesReturned))
|
||||
break;
|
||||
|
||||
if (WTSVirtualChannelRead(context->debug_channel, 0, (PCHAR)Stream_Buffer(s),
|
||||
if (WTSVirtualChannelRead(context->debug_channel, 0, Stream_BufferAs(s, char),
|
||||
(ULONG)Stream_Capacity(s), &BytesReturned) == FALSE)
|
||||
{
|
||||
/* should not happen */
|
||||
|
Loading…
Reference in New Issue
Block a user