freerdp: remove some deprecated stream utils
This commit is contained in:
parent
d1e4798372
commit
51715636a5
@ -101,7 +101,7 @@ static int audin_process_version(IWTSVirtualChannelCallback* pChannelCallback, w
|
||||
out = stream_new(5);
|
||||
stream_write_BYTE(out, MSG_SNDIN_VERSION);
|
||||
stream_write_UINT32(out, Version);
|
||||
error = callback->channel->Write(callback->channel, stream_get_length(s), stream_get_head(s), NULL);
|
||||
error = callback->channel->Write(callback->channel, Stream_GetPosition(s), stream_get_head(s), NULL);
|
||||
stream_free(out);
|
||||
|
||||
return error;
|
||||
@ -135,13 +135,13 @@ static int audin_process_formats(IWTSVirtualChannelCallback* pChannelCallback, w
|
||||
DEBUG_WARN("bad NumFormats %d", NumFormats);
|
||||
return 1;
|
||||
}
|
||||
stream_seek_UINT32(s); /* cbSizeFormatsPacket */
|
||||
Stream_Seek_UINT32(s); /* cbSizeFormatsPacket */
|
||||
|
||||
callback->formats = (audinFormat*) malloc(NumFormats * sizeof(audinFormat));
|
||||
ZeroMemory(callback->formats, NumFormats * sizeof(audinFormat));
|
||||
|
||||
out = stream_new(9);
|
||||
stream_seek(out, 9);
|
||||
Stream_Seek(out, 9);
|
||||
|
||||
/* SoundFormats (variable) */
|
||||
for (i = 0; i < NumFormats; i++)
|
||||
@ -150,12 +150,12 @@ static int audin_process_formats(IWTSVirtualChannelCallback* pChannelCallback, w
|
||||
stream_read_UINT16(s, format.wFormatTag);
|
||||
stream_read_UINT16(s, format.nChannels);
|
||||
stream_read_UINT32(s, format.nSamplesPerSec);
|
||||
stream_seek_UINT32(s); /* nAvgBytesPerSec */
|
||||
Stream_Seek_UINT32(s); /* nAvgBytesPerSec */
|
||||
stream_read_UINT16(s, format.nBlockAlign);
|
||||
stream_read_UINT16(s, format.wBitsPerSample);
|
||||
stream_read_UINT16(s, format.cbSize);
|
||||
format.data = stream_get_tail(s);
|
||||
stream_seek(s, format.cbSize);
|
||||
format.data = Stream_Pointer(s);
|
||||
Stream_Seek(s, format.cbSize);
|
||||
|
||||
DEBUG_DVC("wFormatTag=%d nChannels=%d nSamplesPerSec=%d "
|
||||
"nBlockAlign=%d wBitsPerSample=%d cbSize=%d",
|
||||
@ -182,8 +182,8 @@ static int audin_process_formats(IWTSVirtualChannelCallback* pChannelCallback, w
|
||||
|
||||
audin_send_incoming_data_pdu(pChannelCallback);
|
||||
|
||||
cbSizeFormatsPacket = stream_get_pos(out);
|
||||
stream_set_pos(out, 0);
|
||||
cbSizeFormatsPacket = Stream_GetPosition(out);
|
||||
Stream_SetPosition(out, 0);
|
||||
|
||||
stream_write_BYTE(out, MSG_SNDIN_FORMATS); /* Header (1 byte) */
|
||||
stream_write_UINT32(out, callback->formats_count); /* NumFormats (4 bytes) */
|
||||
@ -239,7 +239,7 @@ static BOOL audin_receive_wave_data(BYTE* data, int size, void* user_data)
|
||||
out = stream_new(size + 1);
|
||||
stream_write_BYTE(out, MSG_SNDIN_DATA);
|
||||
stream_write(out, data, size);
|
||||
error = callback->channel->Write(callback->channel, stream_get_length(out), stream_get_head(out), NULL);
|
||||
error = callback->channel->Write(callback->channel, Stream_GetPosition(out), stream_get_head(out), NULL);
|
||||
stream_free(out);
|
||||
|
||||
return (error == 0 ? TRUE : FALSE);
|
||||
|
@ -78,7 +78,7 @@ static void audin_server_send_version(audin_server* audin, wStream* s)
|
||||
{
|
||||
stream_write_BYTE(s, MSG_SNDIN_VERSION);
|
||||
stream_write_UINT32(s, 1); /* Version (4 bytes) */
|
||||
WTSVirtualChannelWrite(audin->audin_channel, stream_get_head(s), stream_get_length(s), NULL);
|
||||
WTSVirtualChannelWrite(audin->audin_channel, stream_get_head(s), Stream_GetPosition(s), NULL);
|
||||
}
|
||||
|
||||
static BOOL audin_server_recv_version(audin_server* audin, wStream* s, UINT32 length)
|
||||
@ -101,7 +101,7 @@ static void audin_server_send_formats(audin_server* audin, wStream* s)
|
||||
int i;
|
||||
UINT32 nAvgBytesPerSec;
|
||||
|
||||
stream_set_pos(s, 0);
|
||||
Stream_SetPosition(s, 0);
|
||||
stream_write_BYTE(s, MSG_SNDIN_FORMATS);
|
||||
stream_write_UINT32(s, audin->context.num_server_formats); /* NumFormats (4 bytes) */
|
||||
stream_write_UINT32(s, 0); /* cbSizeFormatsPacket (4 bytes), client-to-server only */
|
||||
@ -127,7 +127,7 @@ static void audin_server_send_formats(audin_server* audin, wStream* s)
|
||||
}
|
||||
}
|
||||
|
||||
WTSVirtualChannelWrite(audin->audin_channel, stream_get_head(s), stream_get_length(s), NULL);
|
||||
WTSVirtualChannelWrite(audin->audin_channel, stream_get_head(s), Stream_GetPosition(s), NULL);
|
||||
}
|
||||
|
||||
static BOOL audin_server_recv_formats(audin_server* audin, wStream* s, UINT32 length)
|
||||
@ -138,7 +138,7 @@ static BOOL audin_server_recv_formats(audin_server* audin, wStream* s, UINT32 le
|
||||
return FALSE;
|
||||
|
||||
stream_read_UINT32(s, audin->context.num_client_formats); /* NumFormats (4 bytes) */
|
||||
stream_seek_UINT32(s); /* cbSizeFormatsPacket (4 bytes) */
|
||||
Stream_Seek_UINT32(s); /* cbSizeFormatsPacket (4 bytes) */
|
||||
length -= 8;
|
||||
|
||||
if (audin->context.num_client_formats <= 0)
|
||||
@ -159,13 +159,13 @@ static BOOL audin_server_recv_formats(audin_server* audin, wStream* s, UINT32 le
|
||||
stream_read_UINT16(s, audin->context.client_formats[i].wFormatTag);
|
||||
stream_read_UINT16(s, audin->context.client_formats[i].nChannels);
|
||||
stream_read_UINT32(s, audin->context.client_formats[i].nSamplesPerSec);
|
||||
stream_seek_UINT32(s); /* nAvgBytesPerSec */
|
||||
Stream_Seek_UINT32(s); /* nAvgBytesPerSec */
|
||||
stream_read_UINT16(s, audin->context.client_formats[i].nBlockAlign);
|
||||
stream_read_UINT16(s, audin->context.client_formats[i].wBitsPerSample);
|
||||
stream_read_UINT16(s, audin->context.client_formats[i].cbSize);
|
||||
if (audin->context.client_formats[i].cbSize > 0)
|
||||
{
|
||||
stream_seek(s, audin->context.client_formats[i].cbSize);
|
||||
Stream_Seek(s, audin->context.client_formats[i].cbSize);
|
||||
}
|
||||
}
|
||||
|
||||
@ -181,7 +181,7 @@ static void audin_server_send_open(audin_server* audin, wStream* s)
|
||||
|
||||
audin->opened = TRUE;
|
||||
|
||||
stream_set_pos(s, 0);
|
||||
Stream_SetPosition(s, 0);
|
||||
stream_write_BYTE(s, MSG_SNDIN_OPEN);
|
||||
stream_write_UINT32(s, audin->context.frames_per_packet); /* FramesPerPacket (4 bytes) */
|
||||
stream_write_UINT32(s, audin->context.selected_client_format); /* initialFormat (4 bytes) */
|
||||
@ -198,7 +198,7 @@ static void audin_server_send_open(audin_server* audin, wStream* s)
|
||||
stream_write_UINT16(s, 16); /* wBitsPerSample */
|
||||
stream_write_UINT16(s, 0); /* cbSize */
|
||||
|
||||
WTSVirtualChannelWrite(audin->audin_channel, stream_get_head(s), stream_get_length(s), NULL);
|
||||
WTSVirtualChannelWrite(audin->audin_channel, stream_get_head(s), Stream_GetPosition(s), NULL);
|
||||
}
|
||||
|
||||
static BOOL audin_server_recv_open_reply(audin_server* audin, wStream* s, UINT32 length)
|
||||
@ -232,7 +232,7 @@ static BOOL audin_server_recv_data(audin_server* audin, wStream* s, UINT32 lengt
|
||||
if (format->wFormatTag == WAVE_FORMAT_ADPCM)
|
||||
{
|
||||
audin->dsp_context->decode_ms_adpcm(audin->dsp_context,
|
||||
stream_get_tail(s), length, format->nChannels, format->nBlockAlign);
|
||||
Stream_Pointer(s), length, format->nChannels, format->nBlockAlign);
|
||||
size = audin->dsp_context->adpcm_size;
|
||||
src = audin->dsp_context->adpcm_buffer;
|
||||
sbytes_per_sample = 2;
|
||||
@ -241,7 +241,7 @@ static BOOL audin_server_recv_data(audin_server* audin, wStream* s, UINT32 lengt
|
||||
else if (format->wFormatTag == WAVE_FORMAT_DVI_ADPCM)
|
||||
{
|
||||
audin->dsp_context->decode_ima_adpcm(audin->dsp_context,
|
||||
stream_get_tail(s), length, format->nChannels, format->nBlockAlign);
|
||||
Stream_Pointer(s), length, format->nChannels, format->nBlockAlign);
|
||||
size = audin->dsp_context->adpcm_size;
|
||||
src = audin->dsp_context->adpcm_buffer;
|
||||
sbytes_per_sample = 2;
|
||||
@ -250,7 +250,7 @@ static BOOL audin_server_recv_data(audin_server* audin, wStream* s, UINT32 lengt
|
||||
else
|
||||
{
|
||||
size = length;
|
||||
src = stream_get_tail(s);
|
||||
src = Stream_Pointer(s);
|
||||
sbytes_per_sample = format->wBitsPerSample / 8;
|
||||
sbytes_per_frame = format->nChannels * sbytes_per_sample;
|
||||
}
|
||||
@ -325,10 +325,10 @@ static void* audin_server_thread_func(void* arg)
|
||||
if (WaitForSingleObject(audin->stopEvent, 0) == WAIT_OBJECT_0)
|
||||
break;
|
||||
|
||||
stream_set_pos(s, 0);
|
||||
Stream_SetPosition(s, 0);
|
||||
|
||||
if (WTSVirtualChannelRead(audin->audin_channel, 0, stream_get_head(s),
|
||||
stream_get_size(s), &bytes_returned) == FALSE)
|
||||
Stream_Capacity(s), &bytes_returned) == FALSE)
|
||||
{
|
||||
if (bytes_returned == 0)
|
||||
break;
|
||||
@ -336,7 +336,7 @@ static void* audin_server_thread_func(void* arg)
|
||||
stream_check_size(s, (int) bytes_returned);
|
||||
|
||||
if (WTSVirtualChannelRead(audin->audin_channel, 0, stream_get_head(s),
|
||||
stream_get_size(s), &bytes_returned) == FALSE)
|
||||
Stream_Capacity(s), &bytes_returned) == FALSE)
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -87,14 +87,14 @@ void cliprdr_process_format_list_event(cliprdrPlugin* cliprdr, RDP_CB_FORMAT_LIS
|
||||
if (!cliprdr->use_long_format_names)
|
||||
name_length = 32;
|
||||
|
||||
stream_extend(body, stream_get_size(body) + 4 + name_length);
|
||||
stream_extend(body, Stream_Capacity(body) + 4 + name_length);
|
||||
|
||||
stream_write_UINT32(body, cb_event->formats[i]);
|
||||
stream_write(body, name, name_length);
|
||||
}
|
||||
|
||||
s = cliprdr_packet_new(CB_FORMAT_LIST, 0, stream_get_size(body));
|
||||
stream_write(s, stream_get_head(body), stream_get_size(body));
|
||||
s = cliprdr_packet_new(CB_FORMAT_LIST, 0, Stream_Capacity(body));
|
||||
stream_write(s, stream_get_head(body), Stream_Capacity(body));
|
||||
stream_free(body);
|
||||
}
|
||||
|
||||
@ -150,7 +150,7 @@ void cliprdr_process_short_format_names(cliprdrPlugin* cliprdr, wStream* s, UINT
|
||||
format_name->length = ConvertFromUnicode(CP_UTF8, 0, (WCHAR*) s->pointer, 32 / 2, &format_name->name, 0, NULL, NULL);
|
||||
}
|
||||
|
||||
stream_seek(s, 32);
|
||||
Stream_Seek(s, 32);
|
||||
}
|
||||
}
|
||||
|
||||
@ -166,7 +166,7 @@ void cliprdr_process_long_format_names(cliprdrPlugin* cliprdr, wStream* s, UINT3
|
||||
cliprdr->format_names = (CLIPRDR_FORMAT_NAME*) malloc(sizeof(CLIPRDR_FORMAT_NAME) * allocated_formats);
|
||||
cliprdr->num_format_names = 0;
|
||||
|
||||
while (stream_get_left(s) >= 6)
|
||||
while (Stream_GetRemainingLength(s) >= 6)
|
||||
{
|
||||
BYTE* p;
|
||||
int name_len;
|
||||
@ -184,15 +184,15 @@ void cliprdr_process_long_format_names(cliprdrPlugin* cliprdr, wStream* s, UINT3
|
||||
format_name->name = NULL;
|
||||
format_name->length = 0;
|
||||
|
||||
for (p = stream_get_tail(s), name_len = 0; p + 1 < end_mark; p += 2, name_len += 2)
|
||||
for (p = Stream_Pointer(s), name_len = 0; p + 1 < end_mark; p += 2, name_len += 2)
|
||||
{
|
||||
if (*((unsigned short*) p) == 0)
|
||||
break;
|
||||
}
|
||||
|
||||
format_name->length = ConvertFromUnicode(CP_UTF8, 0, (WCHAR*) stream_get_tail(s), name_len / 2, &format_name->name, 0, NULL, NULL);
|
||||
format_name->length = ConvertFromUnicode(CP_UTF8, 0, (WCHAR*) Stream_Pointer(s), name_len / 2, &format_name->name, 0, NULL, NULL);
|
||||
|
||||
stream_seek(s, name_len + 2);
|
||||
Stream_Seek(s, name_len + 2);
|
||||
}
|
||||
}
|
||||
|
||||
@ -210,7 +210,7 @@ void cliprdr_process_format_list(cliprdrPlugin* cliprdr, wStream* s, UINT32 data
|
||||
if (dataLen > 0)
|
||||
{
|
||||
cb_event->raw_format_data = (BYTE*) malloc(dataLen);
|
||||
memcpy(cb_event->raw_format_data, stream_get_tail(s), dataLen);
|
||||
memcpy(cb_event->raw_format_data, Stream_Pointer(s), dataLen);
|
||||
cb_event->raw_format_data_size = dataLen;
|
||||
}
|
||||
|
||||
@ -354,7 +354,7 @@ void cliprdr_process_format_data_response(cliprdrPlugin* cliprdr, wStream* s, UI
|
||||
{
|
||||
cb_event->size = dataLen;
|
||||
cb_event->data = (BYTE*) malloc(dataLen);
|
||||
CopyMemory(cb_event->data, stream_get_tail(s), dataLen);
|
||||
CopyMemory(cb_event->data, Stream_Pointer(s), dataLen);
|
||||
}
|
||||
|
||||
svc_plugin_send_event((rdpSvcPlugin*) cliprdr, (wMessage*) cb_event);
|
||||
|
@ -61,7 +61,7 @@ wStream* cliprdr_packet_new(UINT16 msgType, UINT16 msgFlags, UINT32 dataLen)
|
||||
stream_write_UINT16(s, msgType);
|
||||
stream_write_UINT16(s, msgFlags);
|
||||
/* Write actual length after the entire packet has been constructed. */
|
||||
stream_seek(s, 4);
|
||||
Stream_Seek(s, 4);
|
||||
|
||||
return s;
|
||||
}
|
||||
@ -71,11 +71,11 @@ void cliprdr_packet_send(cliprdrPlugin* cliprdr, wStream* s)
|
||||
int pos;
|
||||
UINT32 dataLen;
|
||||
|
||||
pos = stream_get_pos(s);
|
||||
pos = Stream_GetPosition(s);
|
||||
dataLen = pos - 8;
|
||||
stream_set_pos(s, 4);
|
||||
Stream_SetPosition(s, 4);
|
||||
stream_write_UINT32(s, dataLen);
|
||||
stream_set_pos(s, pos);
|
||||
Stream_SetPosition(s, pos);
|
||||
|
||||
svc_plugin_send((rdpSvcPlugin*) cliprdr, s);
|
||||
}
|
||||
@ -138,7 +138,7 @@ static void cliprdr_process_clip_caps(cliprdrPlugin* cliprdr, wStream* s, UINT16
|
||||
UINT16 capabilitySetType;
|
||||
|
||||
stream_read_UINT16(s, cCapabilitiesSets); /* cCapabilitiesSets (2 bytes) */
|
||||
stream_seek_UINT16(s); /* pad1 (2 bytes) */
|
||||
Stream_Seek_UINT16(s); /* pad1 (2 bytes) */
|
||||
|
||||
DEBUG_CLIPRDR("cCapabilitiesSets %d", cCapabilitiesSets);
|
||||
|
||||
|
@ -93,23 +93,23 @@ int drdynvc_write_data(drdynvcPlugin* drdynvc, UINT32 ChannelId, BYTE* data, UIN
|
||||
return 1;
|
||||
|
||||
data_out = stream_new(CHANNEL_CHUNK_LENGTH);
|
||||
stream_set_pos(data_out, 1);
|
||||
Stream_SetPosition(data_out, 1);
|
||||
cbChId = drdynvc_write_variable_uint(data_out, ChannelId);
|
||||
|
||||
if (data_size == 0)
|
||||
{
|
||||
pos = stream_get_pos(data_out);
|
||||
stream_set_pos(data_out, 0);
|
||||
pos = Stream_GetPosition(data_out);
|
||||
Stream_SetPosition(data_out, 0);
|
||||
stream_write_BYTE(data_out, 0x40 | cbChId);
|
||||
stream_set_pos(data_out, pos);
|
||||
Stream_SetPosition(data_out, pos);
|
||||
error = svc_plugin_send((rdpSvcPlugin*) drdynvc, data_out);
|
||||
}
|
||||
else if (data_size <= CHANNEL_CHUNK_LENGTH - pos)
|
||||
{
|
||||
pos = stream_get_pos(data_out);
|
||||
stream_set_pos(data_out, 0);
|
||||
pos = Stream_GetPosition(data_out);
|
||||
Stream_SetPosition(data_out, 0);
|
||||
stream_write_BYTE(data_out, 0x30 | cbChId);
|
||||
stream_set_pos(data_out, pos);
|
||||
Stream_SetPosition(data_out, pos);
|
||||
stream_write(data_out, data, data_size);
|
||||
error = svc_plugin_send((rdpSvcPlugin*) drdynvc, data_out);
|
||||
}
|
||||
@ -117,10 +117,10 @@ int drdynvc_write_data(drdynvcPlugin* drdynvc, UINT32 ChannelId, BYTE* data, UIN
|
||||
{
|
||||
/* Fragment the data */
|
||||
cbLen = drdynvc_write_variable_uint(data_out, data_size);
|
||||
pos = stream_get_pos(data_out);
|
||||
stream_set_pos(data_out, 0);
|
||||
pos = Stream_GetPosition(data_out);
|
||||
Stream_SetPosition(data_out, 0);
|
||||
stream_write_BYTE(data_out, 0x20 | cbChId | (cbLen << 2));
|
||||
stream_set_pos(data_out, pos);
|
||||
Stream_SetPosition(data_out, pos);
|
||||
chunk_len = CHANNEL_CHUNK_LENGTH - pos;
|
||||
stream_write(data_out, data, chunk_len);
|
||||
data += chunk_len;
|
||||
@ -130,13 +130,13 @@ int drdynvc_write_data(drdynvcPlugin* drdynvc, UINT32 ChannelId, BYTE* data, UIN
|
||||
while (error == CHANNEL_RC_OK && data_size > 0)
|
||||
{
|
||||
data_out = stream_new(CHANNEL_CHUNK_LENGTH);
|
||||
stream_set_pos(data_out, 1);
|
||||
Stream_SetPosition(data_out, 1);
|
||||
cbChId = drdynvc_write_variable_uint(data_out, ChannelId);
|
||||
|
||||
pos = stream_get_pos(data_out);
|
||||
stream_set_pos(data_out, 0);
|
||||
pos = Stream_GetPosition(data_out);
|
||||
Stream_SetPosition(data_out, 0);
|
||||
stream_write_BYTE(data_out, 0x30 | cbChId);
|
||||
stream_set_pos(data_out, pos);
|
||||
Stream_SetPosition(data_out, pos);
|
||||
|
||||
chunk_len = data_size;
|
||||
if (chunk_len > CHANNEL_CHUNK_LENGTH - pos)
|
||||
@ -179,7 +179,7 @@ static int drdynvc_process_capability_request(drdynvcPlugin* drdynvc, int Sp, in
|
||||
int error;
|
||||
|
||||
DEBUG_DVC("Sp=%d cbChId=%d", Sp, cbChId);
|
||||
stream_seek(s, 1); /* pad */
|
||||
Stream_Seek(s, 1); /* pad */
|
||||
stream_read_UINT16(s, drdynvc->version);
|
||||
|
||||
if (drdynvc->version == 2)
|
||||
@ -236,14 +236,14 @@ static int drdynvc_process_create_request(drdynvcPlugin* drdynvc, int Sp, int cb
|
||||
wStream* data_out;
|
||||
|
||||
ChannelId = drdynvc_read_variable_uint(s, cbChId);
|
||||
pos = stream_get_pos(s);
|
||||
DEBUG_DVC("ChannelId=%d ChannelName=%s", ChannelId, stream_get_tail(s));
|
||||
pos = Stream_GetPosition(s);
|
||||
DEBUG_DVC("ChannelId=%d ChannelName=%s", ChannelId, Stream_Pointer(s));
|
||||
|
||||
error = dvcman_create_channel(drdynvc->channel_mgr, ChannelId, (char*) stream_get_tail(s));
|
||||
error = dvcman_create_channel(drdynvc->channel_mgr, ChannelId, (char*) Stream_Pointer(s));
|
||||
|
||||
data_out = stream_new(pos + 4);
|
||||
stream_write_BYTE(data_out, 0x10 | cbChId);
|
||||
stream_set_pos(s, 1);
|
||||
Stream_SetPosition(s, 1);
|
||||
stream_copy(data_out, s, pos - 1);
|
||||
|
||||
if (error == 0)
|
||||
@ -284,7 +284,7 @@ static int drdynvc_process_data_first(drdynvcPlugin* drdynvc, int Sp, int cbChId
|
||||
return error;
|
||||
|
||||
return dvcman_receive_channel_data(drdynvc->channel_mgr, ChannelId,
|
||||
stream_get_tail(s), stream_get_left(s));
|
||||
Stream_Pointer(s), Stream_GetRemainingLength(s));
|
||||
}
|
||||
|
||||
static int drdynvc_process_data(drdynvcPlugin* drdynvc, int Sp, int cbChId, wStream* s)
|
||||
@ -295,7 +295,7 @@ static int drdynvc_process_data(drdynvcPlugin* drdynvc, int Sp, int cbChId, wStr
|
||||
DEBUG_DVC("ChannelId=%d", ChannelId);
|
||||
|
||||
return dvcman_receive_channel_data(drdynvc->channel_mgr, ChannelId,
|
||||
stream_get_tail(s), stream_get_left(s));
|
||||
Stream_Pointer(s), Stream_GetRemainingLength(s));
|
||||
}
|
||||
|
||||
static int drdynvc_process_close_request(drdynvcPlugin* drdynvc, int Sp, int cbChId, wStream* s)
|
||||
|
@ -445,7 +445,7 @@ int dvcman_receive_channel_data(IWTSVirtualChannelManager* pChannelMgr, UINT32 C
|
||||
if (channel->dvc_data)
|
||||
{
|
||||
/* Fragmented data */
|
||||
if (stream_get_length(channel->dvc_data) + data_size > (UINT32) stream_get_size(channel->dvc_data))
|
||||
if (Stream_GetPosition(channel->dvc_data) + data_size > (UINT32) Stream_Capacity(channel->dvc_data))
|
||||
{
|
||||
DEBUG_WARN("data exceeding declared length!");
|
||||
stream_free(channel->dvc_data);
|
||||
@ -455,10 +455,10 @@ int dvcman_receive_channel_data(IWTSVirtualChannelManager* pChannelMgr, UINT32 C
|
||||
|
||||
stream_write(channel->dvc_data, data, data_size);
|
||||
|
||||
if (stream_get_length(channel->dvc_data) >= stream_get_size(channel->dvc_data))
|
||||
if (Stream_GetPosition(channel->dvc_data) >= Stream_Capacity(channel->dvc_data))
|
||||
{
|
||||
error = channel->channel_callback->OnDataReceived(channel->channel_callback,
|
||||
stream_get_size(channel->dvc_data), stream_get_data(channel->dvc_data));
|
||||
Stream_Capacity(channel->dvc_data), Stream_Buffer(channel->dvc_data));
|
||||
stream_free(channel->dvc_data);
|
||||
channel->dvc_data = NULL;
|
||||
}
|
||||
|
@ -447,10 +447,10 @@ BOOL drive_file_set_information(DRIVE_FILE* file, UINT32 FsInformationClass, UIN
|
||||
{
|
||||
case FileBasicInformation:
|
||||
/* http://msdn.microsoft.com/en-us/library/cc232094.aspx */
|
||||
stream_seek_UINT64(input); /* CreationTime */
|
||||
stream_seek_UINT64(input); /* LastAccessTime */
|
||||
Stream_Seek_UINT64(input); /* CreationTime */
|
||||
Stream_Seek_UINT64(input); /* LastAccessTime */
|
||||
stream_read_UINT64(input, LastWriteTime);
|
||||
stream_seek_UINT64(input); /* ChangeTime */
|
||||
Stream_Seek_UINT64(input); /* ChangeTime */
|
||||
stream_read_UINT32(input, FileAttributes);
|
||||
|
||||
if (FSTAT(file->fd, &st) != 0)
|
||||
@ -501,11 +501,11 @@ BOOL drive_file_set_information(DRIVE_FILE* file, UINT32 FsInformationClass, UIN
|
||||
|
||||
case FileRenameInformation:
|
||||
/* http://msdn.microsoft.com/en-us/library/cc232085.aspx */
|
||||
stream_seek_BYTE(input); /* ReplaceIfExists */
|
||||
stream_seek_BYTE(input); /* RootDirectory */
|
||||
Stream_Seek_BYTE(input); /* ReplaceIfExists */
|
||||
Stream_Seek_BYTE(input); /* RootDirectory */
|
||||
stream_read_UINT32(input, FileNameLength);
|
||||
|
||||
status = ConvertFromUnicode(CP_UTF8, 0, (WCHAR*) stream_get_tail(input),
|
||||
status = ConvertFromUnicode(CP_UTF8, 0, (WCHAR*) Stream_Pointer(input),
|
||||
FileNameLength / 2, &s, 0, NULL, NULL);
|
||||
|
||||
if (status < 1)
|
||||
|
@ -128,12 +128,12 @@ static void drive_process_irp_create(DRIVE_DEVICE* disk, IRP* irp)
|
||||
UINT32 PathLength;
|
||||
|
||||
stream_read_UINT32(irp->input, DesiredAccess);
|
||||
stream_seek(irp->input, 16); /* AllocationSize(8), FileAttributes(4), SharedAccess(4) */
|
||||
Stream_Seek(irp->input, 16); /* AllocationSize(8), FileAttributes(4), SharedAccess(4) */
|
||||
stream_read_UINT32(irp->input, CreateDisposition);
|
||||
stream_read_UINT32(irp->input, CreateOptions);
|
||||
stream_read_UINT32(irp->input, PathLength);
|
||||
|
||||
status = ConvertFromUnicode(CP_UTF8, 0, (WCHAR*) stream_get_tail(irp->input),
|
||||
status = ConvertFromUnicode(CP_UTF8, 0, (WCHAR*) Stream_Pointer(irp->input),
|
||||
PathLength / 2, &path, 0, NULL, NULL);
|
||||
|
||||
if (status < 1)
|
||||
@ -284,7 +284,7 @@ static void drive_process_irp_write(DRIVE_DEVICE* disk, IRP* irp)
|
||||
|
||||
stream_read_UINT32(irp->input, Length);
|
||||
stream_read_UINT64(irp->input, Offset);
|
||||
stream_seek(irp->input, 20); /* Padding */
|
||||
Stream_Seek(irp->input, 20); /* Padding */
|
||||
|
||||
file = drive_get_file_by_id(disk, irp->FileId);
|
||||
|
||||
@ -302,7 +302,7 @@ static void drive_process_irp_write(DRIVE_DEVICE* disk, IRP* irp)
|
||||
|
||||
DEBUG_WARN("seek %s(%d) failed.", file->fullpath, file->id);
|
||||
}
|
||||
else if (!drive_file_write(file, stream_get_tail(irp->input), Length))
|
||||
else if (!drive_file_write(file, Stream_Pointer(irp->input), Length))
|
||||
{
|
||||
irp->IoStatus = STATUS_UNSUCCESSFUL;
|
||||
Length = 0;
|
||||
@ -357,7 +357,7 @@ static void drive_process_irp_set_information(DRIVE_DEVICE* disk, IRP* irp)
|
||||
|
||||
stream_read_UINT32(irp->input, FsInformationClass);
|
||||
stream_read_UINT32(irp->input, Length);
|
||||
stream_seek(irp->input, 24); /* Padding */
|
||||
Stream_Seek(irp->input, 24); /* Padding */
|
||||
|
||||
file = drive_get_file_by_id(disk, irp->FileId);
|
||||
|
||||
@ -504,9 +504,9 @@ static void drive_process_irp_query_directory(DRIVE_DEVICE* disk, IRP* irp)
|
||||
stream_read_UINT32(irp->input, FsInformationClass);
|
||||
stream_read_BYTE(irp->input, InitialQuery);
|
||||
stream_read_UINT32(irp->input, PathLength);
|
||||
stream_seek(irp->input, 23); /* Padding */
|
||||
Stream_Seek(irp->input, 23); /* Padding */
|
||||
|
||||
status = ConvertFromUnicode(CP_UTF8, 0, (WCHAR*) stream_get_tail(irp->input),
|
||||
status = ConvertFromUnicode(CP_UTF8, 0, (WCHAR*) Stream_Pointer(irp->input),
|
||||
PathLength / 2, &path, 0, NULL, NULL);
|
||||
|
||||
if (status < 1)
|
||||
|
@ -75,12 +75,12 @@ static void parallel_process_irp_create(PARALLEL_DEVICE* parallel, IRP* irp)
|
||||
int status;
|
||||
UINT32 PathLength;
|
||||
|
||||
stream_seek(irp->input, 28);
|
||||
Stream_Seek(irp->input, 28);
|
||||
/* DesiredAccess(4) AllocationSize(8), FileAttributes(4) */
|
||||
/* SharedAccess(4) CreateDisposition(4), CreateOptions(4) */
|
||||
stream_read_UINT32(irp->input, PathLength);
|
||||
|
||||
status = ConvertFromUnicode(CP_UTF8, 0, (WCHAR*) stream_get_tail(irp->input),
|
||||
status = ConvertFromUnicode(CP_UTF8, 0, (WCHAR*) Stream_Pointer(irp->input),
|
||||
PathLength / 2, &path, 0, NULL, NULL);
|
||||
|
||||
if (status < 1)
|
||||
@ -175,7 +175,7 @@ static void parallel_process_irp_write(PARALLEL_DEVICE* parallel, IRP* irp)
|
||||
|
||||
stream_read_UINT32(irp->input, Length);
|
||||
stream_read_UINT64(irp->input, Offset);
|
||||
stream_seek(irp->input, 20); /* Padding */
|
||||
Stream_Seek(irp->input, 20); /* Padding */
|
||||
|
||||
DEBUG_SVC("Length %u Offset %llu", Length, Offset);
|
||||
|
||||
@ -183,7 +183,7 @@ static void parallel_process_irp_write(PARALLEL_DEVICE* parallel, IRP* irp)
|
||||
|
||||
while (len > 0)
|
||||
{
|
||||
status = write(parallel->file, stream_get_tail(irp->input), len);
|
||||
status = write(parallel->file, Stream_Pointer(irp->input), len);
|
||||
|
||||
if (status < 0)
|
||||
{
|
||||
@ -194,7 +194,7 @@ static void parallel_process_irp_write(PARALLEL_DEVICE* parallel, IRP* irp)
|
||||
break;
|
||||
}
|
||||
|
||||
stream_seek(irp->input, status);
|
||||
Stream_Seek(irp->input, status);
|
||||
len -= status;
|
||||
}
|
||||
|
||||
|
@ -116,7 +116,7 @@ static void printer_process_irp_write(PRINTER_DEVICE* printer_dev, IRP* irp)
|
||||
|
||||
stream_read_UINT32(irp->input, Length);
|
||||
stream_read_UINT64(irp->input, Offset);
|
||||
stream_seek(irp->input, 20); /* Padding */
|
||||
Stream_Seek(irp->input, 20); /* Padding */
|
||||
|
||||
if (printer_dev->printer)
|
||||
printjob = printer_dev->printer->FindPrintJob(printer_dev->printer, irp->FileId);
|
||||
@ -130,7 +130,7 @@ static void printer_process_irp_write(PRINTER_DEVICE* printer_dev, IRP* irp)
|
||||
}
|
||||
else
|
||||
{
|
||||
printjob->Write(printjob, stream_get_tail(irp->input), Length);
|
||||
printjob->Write(printjob, Stream_Pointer(irp->input), Length);
|
||||
|
||||
DEBUG_SVC("printjob id %d written %d bytes.", irp->FileId, Length);
|
||||
}
|
||||
|
@ -90,7 +90,7 @@ void rail_string_to_unicode_string(rdpRailOrder* rail_order, char* string, RAIL_
|
||||
|
||||
BOOL rail_read_pdu_header(wStream* s, UINT16* orderType, UINT16* orderLength)
|
||||
{
|
||||
if (stream_get_left(s) < 4)
|
||||
if (Stream_GetRemainingLength(s) < 4)
|
||||
return FALSE;
|
||||
stream_read_UINT16(s, *orderType); /* orderType (2 bytes) */
|
||||
stream_read_UINT16(s, *orderLength); /* orderLength (2 bytes) */
|
||||
@ -107,7 +107,7 @@ wStream* rail_pdu_init(int length)
|
||||
{
|
||||
wStream* s;
|
||||
s = stream_new(length + RAIL_PDU_HEADER_LENGTH);
|
||||
stream_seek(s, RAIL_PDU_HEADER_LENGTH);
|
||||
Stream_Seek(s, RAIL_PDU_HEADER_LENGTH);
|
||||
return s;
|
||||
}
|
||||
|
||||
@ -115,11 +115,11 @@ void rail_send_pdu(rdpRailOrder* rail_order, wStream* s, UINT16 orderType)
|
||||
{
|
||||
UINT16 orderLength;
|
||||
|
||||
orderLength = stream_get_length(s);
|
||||
stream_set_pos(s, 0);
|
||||
orderLength = Stream_GetPosition(s);
|
||||
Stream_SetPosition(s, 0);
|
||||
|
||||
rail_write_pdu_header(s, orderType, orderLength);
|
||||
stream_set_pos(s, orderLength);
|
||||
Stream_SetPosition(s, orderLength);
|
||||
|
||||
/* send */
|
||||
DEBUG_RAIL("Sending %s PDU, length:%d",
|
||||
@ -138,7 +138,7 @@ void rail_write_high_contrast(wStream* s, HIGH_CONTRAST* high_contrast)
|
||||
|
||||
BOOL rail_read_handshake_order(wStream* s, RAIL_HANDSHAKE_ORDER* handshake)
|
||||
{
|
||||
if (stream_get_left(s) < 4)
|
||||
if (Stream_GetRemainingLength(s) < 4)
|
||||
return FALSE;
|
||||
stream_read_UINT32(s, handshake->buildNumber); /* buildNumber (4 bytes) */
|
||||
return TRUE;
|
||||
@ -146,12 +146,12 @@ BOOL rail_read_handshake_order(wStream* s, RAIL_HANDSHAKE_ORDER* handshake)
|
||||
|
||||
BOOL rail_read_server_exec_result_order(wStream* s, RAIL_EXEC_RESULT_ORDER* exec_result)
|
||||
{
|
||||
if (stream_get_left(s) < 8)
|
||||
if (Stream_GetRemainingLength(s) < 8)
|
||||
return FALSE;
|
||||
stream_read_UINT16(s, exec_result->flags); /* flags (2 bytes) */
|
||||
stream_read_UINT16(s, exec_result->execResult); /* execResult (2 bytes) */
|
||||
stream_read_UINT32(s, exec_result->rawResult); /* rawResult (4 bytes) */
|
||||
stream_seek_UINT16(s); /* padding (2 bytes) */
|
||||
Stream_Seek_UINT16(s); /* padding (2 bytes) */
|
||||
return rail_read_unicode_string(s, &exec_result->exeOrFile); /* exeOrFile */
|
||||
}
|
||||
|
||||
@ -159,7 +159,7 @@ BOOL rail_read_server_sysparam_order(wStream* s, RAIL_SYSPARAM_ORDER* sysparam)
|
||||
{
|
||||
BYTE body;
|
||||
|
||||
if (stream_get_left(s) < 5)
|
||||
if (Stream_GetRemainingLength(s) < 5)
|
||||
return FALSE;
|
||||
stream_read_UINT32(s, sysparam->param); /* systemParam (4 bytes) */
|
||||
stream_read_BYTE(s, body); /* body (1 byte) */
|
||||
@ -182,7 +182,7 @@ BOOL rail_read_server_sysparam_order(wStream* s, RAIL_SYSPARAM_ORDER* sysparam)
|
||||
|
||||
BOOL rail_read_server_minmaxinfo_order(wStream* s, RAIL_MINMAXINFO_ORDER* minmaxinfo)
|
||||
{
|
||||
if (stream_get_left(s) < 20)
|
||||
if (Stream_GetRemainingLength(s) < 20)
|
||||
return FALSE;
|
||||
stream_read_UINT32(s, minmaxinfo->windowId); /* windowId (4 bytes) */
|
||||
stream_read_UINT16(s, minmaxinfo->maxWidth); /* maxWidth (2 bytes) */
|
||||
@ -199,7 +199,7 @@ BOOL rail_read_server_minmaxinfo_order(wStream* s, RAIL_MINMAXINFO_ORDER* minmax
|
||||
BOOL rail_read_server_localmovesize_order(wStream* s, RAIL_LOCALMOVESIZE_ORDER* localmovesize)
|
||||
{
|
||||
UINT16 isMoveSizeStart;
|
||||
if (stream_get_left(s) < 12)
|
||||
if (Stream_GetRemainingLength(s) < 12)
|
||||
return FALSE;
|
||||
stream_read_UINT32(s, localmovesize->windowId); /* windowId (4 bytes) */
|
||||
|
||||
@ -214,7 +214,7 @@ BOOL rail_read_server_localmovesize_order(wStream* s, RAIL_LOCALMOVESIZE_ORDER*
|
||||
|
||||
BOOL rail_read_server_get_appid_resp_order(wStream* s, RAIL_GET_APPID_RESP_ORDER* get_appid_resp)
|
||||
{
|
||||
if (stream_get_left(s) < 516)
|
||||
if (Stream_GetRemainingLength(s) < 516)
|
||||
return FALSE;
|
||||
stream_read_UINT32(s, get_appid_resp->windowId); /* windowId (4 bytes) */
|
||||
stream_read(s, &get_appid_resp->applicationIdBuffer[0], 512); /* applicationId (256 UNICODE chars) */
|
||||
@ -226,7 +226,7 @@ BOOL rail_read_server_get_appid_resp_order(wStream* s, RAIL_GET_APPID_RESP_ORDER
|
||||
|
||||
BOOL rail_read_langbar_info_order(wStream* s, RAIL_LANGBAR_INFO_ORDER* langbar_info)
|
||||
{
|
||||
if (stream_get_left(s) < 4)
|
||||
if (Stream_GetRemainingLength(s) < 4)
|
||||
return FALSE;
|
||||
stream_read_UINT32(s, langbar_info->languageBarStatus); /* languageBarStatus (4 bytes) */
|
||||
return TRUE;
|
||||
|
@ -51,10 +51,10 @@ static void irp_complete(IRP* irp)
|
||||
|
||||
DEBUG_SVC("DeviceId %d FileId %d CompletionId %d", irp->device->id, irp->FileId, irp->CompletionId);
|
||||
|
||||
pos = stream_get_pos(irp->output);
|
||||
stream_set_pos(irp->output, 12);
|
||||
pos = Stream_GetPosition(irp->output);
|
||||
Stream_SetPosition(irp->output, 12);
|
||||
stream_write_UINT32(irp->output, irp->IoStatus);
|
||||
stream_set_pos(irp->output, pos);
|
||||
Stream_SetPosition(irp->output, pos);
|
||||
|
||||
svc_plugin_send(irp->devman->plugin, irp->output);
|
||||
irp->output = NULL;
|
||||
@ -93,7 +93,7 @@ IRP* irp_new(DEVMAN* devman, wStream* data_in)
|
||||
stream_write_UINT16(irp->output, PAKID_CORE_DEVICE_IOCOMPLETION);
|
||||
stream_write_UINT32(irp->output, DeviceId);
|
||||
stream_write_UINT32(irp->output, irp->CompletionId);
|
||||
stream_seek_UINT32(irp->output); /* IoStatus */
|
||||
Stream_Seek_UINT32(irp->output); /* IoStatus */
|
||||
|
||||
irp->Complete = irp_complete;
|
||||
irp->Discard = irp_free;
|
||||
|
@ -63,7 +63,7 @@ static void rdpdr_process_general_capset(rdpdrPlugin* rdpdr, wStream* data_in)
|
||||
UINT16 capabilityLength;
|
||||
|
||||
stream_read_UINT16(data_in, capabilityLength);
|
||||
stream_seek(data_in, capabilityLength - 4);
|
||||
Stream_Seek(data_in, capabilityLength - 4);
|
||||
}
|
||||
|
||||
/* Output printer direction capability set */
|
||||
@ -78,7 +78,7 @@ static void rdpdr_process_printer_capset(rdpdrPlugin* rdpdr, wStream* data_in)
|
||||
UINT16 capabilityLength;
|
||||
|
||||
stream_read_UINT16(data_in, capabilityLength);
|
||||
stream_seek(data_in, capabilityLength - 4);
|
||||
Stream_Seek(data_in, capabilityLength - 4);
|
||||
}
|
||||
|
||||
/* Output port redirection capability set */
|
||||
@ -93,7 +93,7 @@ static void rdpdr_process_port_capset(rdpdrPlugin* rdpdr, wStream* data_in)
|
||||
UINT16 capabilityLength;
|
||||
|
||||
stream_read_UINT16(data_in, capabilityLength);
|
||||
stream_seek(data_in, capabilityLength - 4);
|
||||
Stream_Seek(data_in, capabilityLength - 4);
|
||||
}
|
||||
|
||||
/* Output drive redirection capability set */
|
||||
@ -108,7 +108,7 @@ static void rdpdr_process_drive_capset(rdpdrPlugin* rdpdr, wStream* data_in)
|
||||
UINT16 capabilityLength;
|
||||
|
||||
stream_read_UINT16(data_in, capabilityLength);
|
||||
stream_seek(data_in, capabilityLength - 4);
|
||||
Stream_Seek(data_in, capabilityLength - 4);
|
||||
}
|
||||
|
||||
/* Output smart card redirection capability set */
|
||||
@ -123,7 +123,7 @@ static void rdpdr_process_smartcard_capset(rdpdrPlugin* rdpdr, wStream* data_in)
|
||||
UINT16 capabilityLength;
|
||||
|
||||
stream_read_UINT16(data_in, capabilityLength);
|
||||
stream_seek(data_in, capabilityLength - 4);
|
||||
Stream_Seek(data_in, capabilityLength - 4);
|
||||
}
|
||||
|
||||
void rdpdr_process_capability_request(rdpdrPlugin* rdpdr, wStream* data_in)
|
||||
@ -133,7 +133,7 @@ void rdpdr_process_capability_request(rdpdrPlugin* rdpdr, wStream* data_in)
|
||||
UINT16 capabilityType;
|
||||
|
||||
stream_read_UINT16(data_in, numCapabilities);
|
||||
stream_seek(data_in, 2); /* pad (2 bytes) */
|
||||
Stream_Seek(data_in, 2); /* pad (2 bytes) */
|
||||
|
||||
for(i = 0; i < numCapabilities; i++)
|
||||
{
|
||||
|
@ -157,9 +157,9 @@ static void rdpdr_send_device_list_announce_request(rdpdrPlugin* rdpdr, BOOL use
|
||||
stream_write_UINT16(data_out, RDPDR_CTYP_CORE);
|
||||
stream_write_UINT16(data_out, PAKID_CORE_DEVICELIST_ANNOUNCE);
|
||||
|
||||
count_pos = stream_get_pos(data_out);
|
||||
count_pos = Stream_GetPosition(data_out);
|
||||
count = 0;
|
||||
stream_seek_UINT32(data_out); /* deviceCount */
|
||||
Stream_Seek_UINT32(data_out); /* deviceCount */
|
||||
|
||||
for (item = rdpdr->devman->devices->head; item; item = item->next)
|
||||
{
|
||||
@ -175,12 +175,12 @@ static void rdpdr_send_device_list_announce_request(rdpdrPlugin* rdpdr, BOOL use
|
||||
if ((rdpdr->versionMinor == 0x0005) ||
|
||||
(device->type == RDPDR_DTYP_SMARTCARD) || user_loggedon)
|
||||
{
|
||||
data_len = (device->data == NULL ? 0 : stream_get_length(device->data));
|
||||
data_len = (device->data == NULL ? 0 : Stream_GetPosition(device->data));
|
||||
stream_check_size(data_out, 20 + data_len);
|
||||
|
||||
stream_write_UINT32(data_out, device->type); /* deviceType */
|
||||
stream_write_UINT32(data_out, device->id); /* deviceID */
|
||||
strncpy((char*) stream_get_tail(data_out), device->name, 8);
|
||||
strncpy((char*) Stream_Pointer(data_out), device->name, 8);
|
||||
|
||||
for (i = 0; i < 8; i++)
|
||||
{
|
||||
@ -189,13 +189,13 @@ static void rdpdr_send_device_list_announce_request(rdpdrPlugin* rdpdr, BOOL use
|
||||
if (c > 0x7F)
|
||||
stream_write_BYTE(data_out, '_');
|
||||
else
|
||||
stream_seek_BYTE(data_out);
|
||||
Stream_Seek_BYTE(data_out);
|
||||
}
|
||||
|
||||
stream_write_UINT32(data_out, data_len);
|
||||
|
||||
if (data_len > 0)
|
||||
stream_write(data_out, stream_get_data(device->data), data_len);
|
||||
stream_write(data_out, Stream_Buffer(device->data), data_len);
|
||||
|
||||
count++;
|
||||
|
||||
@ -204,11 +204,11 @@ static void rdpdr_send_device_list_announce_request(rdpdrPlugin* rdpdr, BOOL use
|
||||
}
|
||||
}
|
||||
|
||||
pos = stream_get_pos(data_out);
|
||||
stream_set_pos(data_out, count_pos);
|
||||
pos = Stream_GetPosition(data_out);
|
||||
Stream_SetPosition(data_out, count_pos);
|
||||
stream_write_UINT32(data_out, count);
|
||||
stream_set_pos(data_out, pos);
|
||||
stream_seal(data_out);
|
||||
Stream_SetPosition(data_out, pos);
|
||||
Stream_SealLength(data_out);
|
||||
|
||||
svc_plugin_send((rdpSvcPlugin*) rdpdr, data_out);
|
||||
}
|
||||
|
@ -262,14 +262,14 @@ void rdpsnd_recv_server_audio_formats_pdu(rdpsndPlugin* rdpsnd, wStream* s)
|
||||
rdpsnd->NumberOfServerFormats = 0;
|
||||
rdpsnd->ServerFormats = NULL;
|
||||
|
||||
stream_seek_UINT32(s); /* dwFlags */
|
||||
stream_seek_UINT32(s); /* dwVolume */
|
||||
stream_seek_UINT32(s); /* dwPitch */
|
||||
stream_seek_UINT16(s); /* wDGramPort */
|
||||
Stream_Seek_UINT32(s); /* dwFlags */
|
||||
Stream_Seek_UINT32(s); /* dwVolume */
|
||||
Stream_Seek_UINT32(s); /* dwPitch */
|
||||
Stream_Seek_UINT16(s); /* wDGramPort */
|
||||
stream_read_UINT16(s, wNumberOfFormats);
|
||||
stream_read_BYTE(s, rdpsnd->cBlockNo); /* cLastBlockConfirmed */
|
||||
stream_read_UINT16(s, wVersion); /* wVersion */
|
||||
stream_seek_BYTE(s); /* bPad */
|
||||
Stream_Seek_BYTE(s); /* bPad */
|
||||
|
||||
rdpsnd->NumberOfServerFormats = wNumberOfFormats;
|
||||
rdpsnd->ServerFormats = (AUDIO_FORMAT*) malloc(sizeof(AUDIO_FORMAT) * wNumberOfFormats);
|
||||
@ -333,7 +333,7 @@ static void rdpsnd_recv_wave_info_pdu(rdpsndPlugin* rdpsnd, wStream* s, UINT16 B
|
||||
stream_read_UINT16(s, rdpsnd->wTimeStamp);
|
||||
stream_read_UINT16(s, wFormatNo);
|
||||
stream_read_BYTE(s, rdpsnd->cBlockNo);
|
||||
stream_seek(s, 3); /* bPad */
|
||||
Stream_Seek(s, 3); /* bPad */
|
||||
stream_read(s, rdpsnd->waveData, 4);
|
||||
|
||||
rdpsnd->waveDataSize = BodySize - 8;
|
||||
@ -402,7 +402,7 @@ static void rdpsnd_recv_wave_pdu(rdpsndPlugin* rdpsnd, wStream* s)
|
||||
CopyMemory(stream_get_head(s), rdpsnd->waveData, 4);
|
||||
|
||||
data = stream_get_head(s);
|
||||
size = stream_get_size(s);
|
||||
size = Stream_Capacity(s);
|
||||
|
||||
wave = (RDPSND_WAVE*) malloc(sizeof(RDPSND_WAVE));
|
||||
|
||||
@ -481,7 +481,7 @@ static void rdpsnd_recv_pdu(rdpSvcPlugin* plugin, wStream* s)
|
||||
}
|
||||
|
||||
stream_read_BYTE(s, msgType); /* msgType */
|
||||
stream_seek_BYTE(s); /* bPad */
|
||||
Stream_Seek_BYTE(s); /* bPad */
|
||||
stream_read_UINT16(s, BodySize);
|
||||
|
||||
//fprintf(stderr, "msgType %d BodySize %d\n", msgType, BodySize);
|
||||
|
@ -63,7 +63,7 @@ static BOOL rdpsnd_server_send_formats(rdpsnd_server* rdpsnd, wStream* s)
|
||||
|
||||
stream_write_BYTE(s, SNDC_FORMATS);
|
||||
stream_write_BYTE(s, 0);
|
||||
stream_seek_UINT16(s);
|
||||
Stream_Seek_UINT16(s);
|
||||
|
||||
stream_write_UINT32(s, 0); /* dwFlags */
|
||||
stream_write_UINT32(s, 0); /* dwVolume */
|
||||
@ -94,12 +94,12 @@ static BOOL rdpsnd_server_send_formats(rdpsnd_server* rdpsnd, wStream* s)
|
||||
}
|
||||
}
|
||||
|
||||
pos = stream_get_pos(s);
|
||||
stream_set_pos(s, 2);
|
||||
pos = Stream_GetPosition(s);
|
||||
Stream_SetPosition(s, 2);
|
||||
stream_write_UINT16(s, pos - 4);
|
||||
stream_set_pos(s, pos);
|
||||
status = WTSVirtualChannelWrite(rdpsnd->rdpsnd_channel, stream_get_head(s), stream_get_length(s), NULL);
|
||||
stream_set_pos(s, 0);
|
||||
Stream_SetPosition(s, pos);
|
||||
status = WTSVirtualChannelWrite(rdpsnd->rdpsnd_channel, stream_get_head(s), Stream_GetPosition(s), NULL);
|
||||
Stream_SetPosition(s, 0);
|
||||
|
||||
return status;
|
||||
}
|
||||
@ -112,7 +112,7 @@ static void rdpsnd_server_recv_waveconfirm(rdpsnd_server* rdpsnd, wStream* s)
|
||||
BYTE confirmBlockNum = 0;
|
||||
stream_read_UINT16(s, timestamp);
|
||||
stream_read_BYTE(s, confirmBlockNum);
|
||||
stream_seek_BYTE(s); // padding
|
||||
Stream_Seek_BYTE(s); // padding
|
||||
}
|
||||
|
||||
static void rdpsnd_server_recv_quality_mode(rdpsnd_server* rdpsnd, wStream* s)
|
||||
@ -121,7 +121,7 @@ static void rdpsnd_server_recv_quality_mode(rdpsnd_server* rdpsnd, wStream* s)
|
||||
UINT16 quality;
|
||||
|
||||
stream_read_UINT16(s, quality);
|
||||
stream_seek_UINT16(s); // reserved
|
||||
Stream_Seek_UINT16(s); // reserved
|
||||
|
||||
fprintf(stderr, "Client requested sound quality: %#0X\n", quality);
|
||||
}
|
||||
@ -141,7 +141,7 @@ static BOOL rdpsnd_server_recv_formats(rdpsnd_server* rdpsnd, wStream* s)
|
||||
stream_read_UINT16(s, rdpsnd->context.num_client_formats); /* wNumberOfFormats */
|
||||
stream_read_BYTE(s, lastblock); /* cLastBlockConfirmed */
|
||||
stream_read_UINT16(s, version); /* wVersion */
|
||||
stream_seek_BYTE(s); /* bPad */
|
||||
Stream_Seek_BYTE(s); /* bPad */
|
||||
|
||||
if (rdpsnd->context.num_client_formats > 0)
|
||||
{
|
||||
@ -160,7 +160,7 @@ static BOOL rdpsnd_server_recv_formats(rdpsnd_server* rdpsnd, wStream* s)
|
||||
|
||||
if (rdpsnd->context.client_formats[i].cbSize > 0)
|
||||
{
|
||||
stream_seek(s, rdpsnd->context.client_formats[i].cbSize);
|
||||
Stream_Seek(s, rdpsnd->context.client_formats[i].cbSize);
|
||||
}
|
||||
|
||||
if (rdpsnd->context.client_formats[i].wFormatTag != 0)
|
||||
@ -216,10 +216,10 @@ static void* rdpsnd_server_thread_func(void* arg)
|
||||
break;
|
||||
}
|
||||
|
||||
stream_set_pos(s, 0);
|
||||
Stream_SetPosition(s, 0);
|
||||
|
||||
if (WTSVirtualChannelRead(rdpsnd->rdpsnd_channel, 0, stream_get_head(s),
|
||||
stream_get_size(s), &bytes_returned) == FALSE)
|
||||
Stream_Capacity(s), &bytes_returned) == FALSE)
|
||||
{
|
||||
if (bytes_returned == 0)
|
||||
break;
|
||||
@ -227,12 +227,12 @@ static void* rdpsnd_server_thread_func(void* arg)
|
||||
stream_check_size(s, (int) bytes_returned);
|
||||
|
||||
if (WTSVirtualChannelRead(rdpsnd->rdpsnd_channel, 0, stream_get_head(s),
|
||||
stream_get_size(s), &bytes_returned) == FALSE)
|
||||
Stream_Capacity(s), &bytes_returned) == FALSE)
|
||||
break;
|
||||
}
|
||||
|
||||
stream_read_BYTE(s, msgType);
|
||||
stream_seek_BYTE(s); /* bPad */
|
||||
Stream_Seek_BYTE(s); /* bPad */
|
||||
stream_read_UINT16(s, BodySize);
|
||||
|
||||
switch (msgType)
|
||||
@ -399,7 +399,7 @@ static BOOL rdpsnd_server_send_audio_pdu(rdpsnd_server* rdpsnd)
|
||||
}
|
||||
|
||||
/* WaveInfo PDU */
|
||||
stream_set_pos(s, 0);
|
||||
Stream_SetPosition(s, 0);
|
||||
stream_write_BYTE(s, SNDC_WAVE); /* msgType */
|
||||
stream_write_BYTE(s, 0); /* bPad */
|
||||
stream_write_UINT16(s, size + fill_size + 8); /* BodySize */
|
||||
@ -407,11 +407,11 @@ static BOOL rdpsnd_server_send_audio_pdu(rdpsnd_server* rdpsnd)
|
||||
stream_write_UINT16(s, 0); /* wTimeStamp */
|
||||
stream_write_UINT16(s, rdpsnd->context.selected_client_format); /* wFormatNo */
|
||||
stream_write_BYTE(s, rdpsnd->context.block_no); /* cBlockNo */
|
||||
stream_seek(s, 3); /* bPad */
|
||||
Stream_Seek(s, 3); /* bPad */
|
||||
stream_write(s, src, 4);
|
||||
|
||||
WTSVirtualChannelWrite(rdpsnd->rdpsnd_channel, stream_get_head(s), stream_get_length(s), NULL);
|
||||
stream_set_pos(s, 0);
|
||||
WTSVirtualChannelWrite(rdpsnd->rdpsnd_channel, stream_get_head(s), Stream_GetPosition(s), NULL);
|
||||
Stream_SetPosition(s, 0);
|
||||
|
||||
/* Wave PDU */
|
||||
stream_check_size(s, size + fill_size);
|
||||
@ -421,8 +421,8 @@ static BOOL rdpsnd_server_send_audio_pdu(rdpsnd_server* rdpsnd)
|
||||
if (fill_size > 0)
|
||||
stream_write_zero(s, fill_size);
|
||||
|
||||
status = WTSVirtualChannelWrite(rdpsnd->rdpsnd_channel, stream_get_head(s), stream_get_length(s), NULL);
|
||||
stream_set_pos(s, 0);
|
||||
status = WTSVirtualChannelWrite(rdpsnd->rdpsnd_channel, stream_get_head(s), Stream_GetPosition(s), NULL);
|
||||
Stream_SetPosition(s, 0);
|
||||
|
||||
rdpsnd->out_pending_frames = 0;
|
||||
|
||||
@ -467,17 +467,17 @@ static BOOL rdpsnd_server_set_volume(rdpsnd_server_context* context, int left, i
|
||||
|
||||
stream_write_BYTE(s, SNDC_SETVOLUME);
|
||||
stream_write_BYTE(s, 0);
|
||||
stream_seek_UINT16(s);
|
||||
Stream_Seek_UINT16(s);
|
||||
|
||||
stream_write_UINT16(s, left);
|
||||
stream_write_UINT16(s, right);
|
||||
|
||||
pos = stream_get_pos(s);
|
||||
stream_set_pos(s, 2);
|
||||
pos = Stream_GetPosition(s);
|
||||
Stream_SetPosition(s, 2);
|
||||
stream_write_UINT16(s, pos - 4);
|
||||
stream_set_pos(s, pos);
|
||||
status = WTSVirtualChannelWrite(rdpsnd->rdpsnd_channel, stream_get_head(s), stream_get_length(s), NULL);
|
||||
stream_set_pos(s, 0);
|
||||
Stream_SetPosition(s, pos);
|
||||
status = WTSVirtualChannelWrite(rdpsnd->rdpsnd_channel, stream_get_head(s), Stream_GetPosition(s), NULL);
|
||||
Stream_SetPosition(s, 0);
|
||||
|
||||
return status;
|
||||
}
|
||||
@ -502,14 +502,14 @@ static BOOL rdpsnd_server_close(rdpsnd_server_context* context)
|
||||
|
||||
stream_write_BYTE(s, SNDC_CLOSE);
|
||||
stream_write_BYTE(s, 0);
|
||||
stream_seek_UINT16(s);
|
||||
Stream_Seek_UINT16(s);
|
||||
|
||||
pos = stream_get_pos(s);
|
||||
stream_set_pos(s, 2);
|
||||
pos = Stream_GetPosition(s);
|
||||
Stream_SetPosition(s, 2);
|
||||
stream_write_UINT16(s, pos - 4);
|
||||
stream_set_pos(s, pos);
|
||||
status = WTSVirtualChannelWrite(rdpsnd->rdpsnd_channel, stream_get_head(s), stream_get_length(s), NULL);
|
||||
stream_set_pos(s, 0);
|
||||
Stream_SetPosition(s, pos);
|
||||
status = WTSVirtualChannelWrite(rdpsnd->rdpsnd_channel, stream_get_head(s), Stream_GetPosition(s), NULL);
|
||||
Stream_SetPosition(s, 0);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
@ -64,7 +64,7 @@ static void sample_process_receive(rdpSvcPlugin* plugin, wStream* data_in)
|
||||
/* process data in (from server) here */
|
||||
/* here we just send the same data back */
|
||||
|
||||
bytes = stream_get_size(data_in);
|
||||
bytes = Stream_Capacity(data_in);
|
||||
fprintf(stderr, "sample_process_receive: got bytes %d\n", bytes);
|
||||
|
||||
if (bytes > 0)
|
||||
@ -74,7 +74,7 @@ static void sample_process_receive(rdpSvcPlugin* plugin, wStream* data_in)
|
||||
/* svc_plugin_send takes ownership of data_out, that is why
|
||||
we do not free it */
|
||||
|
||||
bytes = stream_get_length(data_in);
|
||||
bytes = Stream_GetPosition(data_in);
|
||||
fprintf(stderr, "sample_process_receive: sending bytes %d\n", bytes);
|
||||
|
||||
svc_plugin_send(plugin, data_out);
|
||||
|
@ -90,11 +90,11 @@ static void serial_process_irp_create(SERIAL_DEVICE* serial, IRP* irp)
|
||||
UINT32 PathLength;
|
||||
UINT32 FileId;
|
||||
|
||||
stream_seek(irp->input, 28); /* DesiredAccess(4) AllocationSize(8), FileAttributes(4) */
|
||||
Stream_Seek(irp->input, 28); /* DesiredAccess(4) AllocationSize(8), FileAttributes(4) */
|
||||
/* SharedAccess(4) CreateDisposition(4), CreateOptions(4) */
|
||||
stream_read_UINT32(irp->input, PathLength);
|
||||
|
||||
status = ConvertFromUnicode(CP_UTF8, 0, (WCHAR*) stream_get_tail(irp->input),
|
||||
status = ConvertFromUnicode(CP_UTF8, 0, (WCHAR*) Stream_Pointer(irp->input),
|
||||
PathLength / 2, &path, 0, NULL, NULL);
|
||||
|
||||
if (status < 1)
|
||||
@ -210,7 +210,7 @@ static void serial_process_irp_write(SERIAL_DEVICE* serial, IRP* irp)
|
||||
|
||||
stream_read_UINT32(irp->input, Length);
|
||||
stream_read_UINT64(irp->input, Offset);
|
||||
stream_seek(irp->input, 20); /* Padding */
|
||||
Stream_Seek(irp->input, 20); /* Padding */
|
||||
|
||||
DEBUG_SVC("length %u offset %llu", Length, Offset);
|
||||
|
||||
@ -223,7 +223,7 @@ static void serial_process_irp_write(SERIAL_DEVICE* serial, IRP* irp)
|
||||
|
||||
DEBUG_WARN("tty not valid.");
|
||||
}
|
||||
else if (!serial_tty_write(tty, stream_get_tail(irp->input), Length))
|
||||
else if (!serial_tty_write(tty, Stream_Pointer(irp->input), Length))
|
||||
{
|
||||
irp->IoStatus = STATUS_UNSUCCESSFUL;
|
||||
Length = 0;
|
||||
@ -254,7 +254,7 @@ static void serial_process_irp_device_control(SERIAL_DEVICE* serial, IRP* irp)
|
||||
stream_read_UINT32(irp->input, InputBufferLength);
|
||||
stream_read_UINT32(irp->input, OutputBufferLength);
|
||||
stream_read_UINT32(irp->input, IoControlCode);
|
||||
stream_seek(irp->input, 20); /* Padding */
|
||||
Stream_Seek(irp->input, 20); /* Padding */
|
||||
|
||||
tty = serial->tty;
|
||||
|
||||
@ -478,9 +478,9 @@ void serial_get_timeouts(SERIAL_DEVICE* serial, IRP* irp, UINT32* timeout, UINT3
|
||||
UINT32 Length;
|
||||
UINT32 pos;
|
||||
|
||||
pos = stream_get_pos(irp->input);
|
||||
pos = Stream_GetPosition(irp->input);
|
||||
stream_read_UINT32(irp->input, Length);
|
||||
stream_set_pos(irp->input, pos);
|
||||
Stream_SetPosition(irp->input, pos);
|
||||
|
||||
DEBUG_SVC("length read %u", Length);
|
||||
|
||||
|
@ -90,7 +90,7 @@ UINT32 serial_tty_control(SERIAL_TTY* tty, UINT32 IoControlCode, wStream* input,
|
||||
|
||||
DEBUG_SVC("in");
|
||||
|
||||
stream_seek(output, sizeof(UINT32));
|
||||
Stream_Seek(output, sizeof(UINT32));
|
||||
|
||||
switch (IoControlCode)
|
||||
{
|
||||
@ -361,10 +361,10 @@ UINT32 serial_tty_control(SERIAL_TTY* tty, UINT32 IoControlCode, wStream* input,
|
||||
}
|
||||
|
||||
/* Write OutputBufferLength */
|
||||
pos = stream_get_pos(output);
|
||||
stream_set_pos(output, 16);
|
||||
pos = Stream_GetPosition(output);
|
||||
Stream_SetPosition(output, 16);
|
||||
stream_write_UINT32(output, length);
|
||||
stream_set_pos(output, pos);
|
||||
Stream_SetPosition(output, pos);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
@ -31,6 +31,7 @@
|
||||
|
||||
#include <winpr/crt.h>
|
||||
#include <winpr/synch.h>
|
||||
#include <winpr/stream.h>
|
||||
|
||||
#include "channels.h"
|
||||
|
||||
@ -133,19 +134,19 @@ static int wts_read_variable_uint(wStream* s, int cbLen, UINT32* val)
|
||||
switch (cbLen)
|
||||
{
|
||||
case 0:
|
||||
if (stream_get_left(s) < 1)
|
||||
if (Stream_GetRemainingLength(s) < 1)
|
||||
return 0;
|
||||
stream_read_BYTE(s, *val);
|
||||
return 1;
|
||||
|
||||
case 1:
|
||||
if (stream_get_left(s) < 2)
|
||||
if (Stream_GetRemainingLength(s) < 2)
|
||||
return 0;
|
||||
stream_read_UINT16(s, *val);
|
||||
return 2;
|
||||
|
||||
default:
|
||||
if (stream_get_left(s) < 4)
|
||||
if (Stream_GetRemainingLength(s) < 4)
|
||||
return 0;
|
||||
stream_read_UINT32(s, *val);
|
||||
return 4;
|
||||
@ -159,7 +160,7 @@ static void wts_read_drdynvc_capabilities_response(rdpPeerChannel* channel, UINT
|
||||
if (length < 3)
|
||||
return;
|
||||
|
||||
stream_seek_BYTE(channel->receive_data); /* Pad (1 byte) */
|
||||
Stream_Seek_BYTE(channel->receive_data); /* Pad (1 byte) */
|
||||
stream_read_UINT16(channel->receive_data, Version);
|
||||
|
||||
DEBUG_DVC("Version: %d", Version);
|
||||
@ -204,25 +205,25 @@ static void wts_read_drdynvc_data_first(rdpPeerChannel* channel, wStream* s, int
|
||||
if (length > channel->dvc_total_length)
|
||||
return;
|
||||
|
||||
stream_set_pos(channel->receive_data, 0);
|
||||
Stream_SetPosition(channel->receive_data, 0);
|
||||
stream_check_size(channel->receive_data, (int) channel->dvc_total_length);
|
||||
stream_write(channel->receive_data, stream_get_tail(s), length);
|
||||
stream_write(channel->receive_data, Stream_Pointer(s), length);
|
||||
}
|
||||
|
||||
static void wts_read_drdynvc_data(rdpPeerChannel* channel, wStream* s, UINT32 length)
|
||||
{
|
||||
if (channel->dvc_total_length > 0)
|
||||
{
|
||||
if (stream_get_length(channel->receive_data) + length > channel->dvc_total_length)
|
||||
if (Stream_GetPosition(channel->receive_data) + length > channel->dvc_total_length)
|
||||
{
|
||||
channel->dvc_total_length = 0;
|
||||
fprintf(stderr, "wts_read_drdynvc_data: incorrect fragment data, discarded.\n");
|
||||
return;
|
||||
}
|
||||
|
||||
stream_write(channel->receive_data, stream_get_tail(s), length);
|
||||
stream_write(channel->receive_data, Stream_Pointer(s), length);
|
||||
|
||||
if (stream_get_length(channel->receive_data) >= (int) channel->dvc_total_length)
|
||||
if (Stream_GetPosition(channel->receive_data) >= (int) channel->dvc_total_length)
|
||||
{
|
||||
wts_queue_receive_data(channel, stream_get_head(channel->receive_data), channel->dvc_total_length);
|
||||
channel->dvc_total_length = 0;
|
||||
@ -230,7 +231,7 @@ static void wts_read_drdynvc_data(rdpPeerChannel* channel, wStream* s, UINT32 le
|
||||
}
|
||||
else
|
||||
{
|
||||
wts_queue_receive_data(channel, stream_get_tail(s), length);
|
||||
wts_queue_receive_data(channel, Stream_Pointer(s), length);
|
||||
}
|
||||
}
|
||||
|
||||
@ -250,12 +251,12 @@ static void wts_read_drdynvc_pdu(rdpPeerChannel* channel)
|
||||
UINT32 ChannelId;
|
||||
rdpPeerChannel* dvc;
|
||||
|
||||
length = stream_get_pos(channel->receive_data);
|
||||
length = Stream_GetPosition(channel->receive_data);
|
||||
|
||||
if (length < 1)
|
||||
return;
|
||||
|
||||
stream_set_pos(channel->receive_data, 0);
|
||||
Stream_SetPosition(channel->receive_data, 0);
|
||||
stream_read_BYTE(channel->receive_data, value);
|
||||
|
||||
length--;
|
||||
@ -344,7 +345,7 @@ static void wts_write_drdynvc_header(wStream *s, BYTE Cmd, UINT32 ChannelId)
|
||||
int cbChId;
|
||||
|
||||
stream_get_mark(s, bm);
|
||||
stream_seek_BYTE(s);
|
||||
Stream_Seek_BYTE(s);
|
||||
cbChId = wts_write_variable_uint(s, ChannelId);
|
||||
*bm = ((Cmd & 0x0F) << 4) | cbChId;
|
||||
}
|
||||
@ -363,7 +364,7 @@ static void WTSProcessChannelData(rdpPeerChannel* channel, int channelId, BYTE*
|
||||
{
|
||||
if (flags & CHANNEL_FLAG_FIRST)
|
||||
{
|
||||
stream_set_pos(channel->receive_data, 0);
|
||||
Stream_SetPosition(channel->receive_data, 0);
|
||||
}
|
||||
|
||||
stream_check_size(channel->receive_data, size);
|
||||
@ -371,7 +372,7 @@ static void WTSProcessChannelData(rdpPeerChannel* channel, int channelId, BYTE*
|
||||
|
||||
if (flags & CHANNEL_FLAG_LAST)
|
||||
{
|
||||
if (stream_get_length(channel->receive_data) != total_size)
|
||||
if (Stream_GetPosition(channel->receive_data) != total_size)
|
||||
{
|
||||
fprintf(stderr, "WTSProcessChannelData: read error\n");
|
||||
}
|
||||
@ -381,9 +382,9 @@ static void WTSProcessChannelData(rdpPeerChannel* channel, int channelId, BYTE*
|
||||
}
|
||||
else
|
||||
{
|
||||
wts_queue_receive_data(channel, stream_get_head(channel->receive_data), stream_get_length(channel->receive_data));
|
||||
wts_queue_receive_data(channel, stream_get_head(channel->receive_data), Stream_GetPosition(channel->receive_data));
|
||||
}
|
||||
stream_set_pos(channel->receive_data, 0);
|
||||
Stream_SetPosition(channel->receive_data, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@ -575,7 +576,7 @@ void* WTSVirtualChannelOpenEx(
|
||||
|
||||
s = stream_new(64);
|
||||
wts_write_drdynvc_create_request(s, channel->channel_id, pVirtualName);
|
||||
WTSVirtualChannelWrite(vcm->drdynvc_channel, stream_get_head(s), stream_get_length(s), NULL);
|
||||
WTSVirtualChannelWrite(vcm->drdynvc_channel, stream_get_head(s), Stream_GetPosition(s), NULL);
|
||||
stream_free(s);
|
||||
|
||||
DEBUG_DVC("ChannelId %d.%s (total %d)", channel->channel_id, pVirtualName, list_size(vcm->dvc_channel_list));
|
||||
@ -783,10 +784,10 @@ BOOL WTSVirtualChannelWrite(
|
||||
item->buffer = malloc(channel->client->settings->VirtualChannelChunkSize);
|
||||
stream_attach(s, item->buffer, channel->client->settings->VirtualChannelChunkSize);
|
||||
|
||||
stream_seek_BYTE(s);
|
||||
Stream_Seek_BYTE(s);
|
||||
cbChId = wts_write_variable_uint(s, channel->channel_id);
|
||||
|
||||
if (first && (Length > (UINT32) stream_get_left(s)))
|
||||
if (first && (Length > (UINT32) Stream_GetRemainingLength(s)))
|
||||
{
|
||||
cbLen = wts_write_variable_uint(s, Length);
|
||||
item->buffer[0] = (DATA_FIRST_PDU << 4) | (cbLen << 2) | cbChId;
|
||||
@ -797,13 +798,13 @@ BOOL WTSVirtualChannelWrite(
|
||||
}
|
||||
|
||||
first = FALSE;
|
||||
written = stream_get_left(s);
|
||||
written = Stream_GetRemainingLength(s);
|
||||
|
||||
if (written > Length)
|
||||
written = Length;
|
||||
|
||||
stream_write(s, Buffer, written);
|
||||
item->length = stream_get_length(s);
|
||||
item->length = Stream_GetPosition(s);
|
||||
stream_detach(s);
|
||||
Length -= written;
|
||||
Buffer += written;
|
||||
@ -846,7 +847,7 @@ BOOL WTSVirtualChannelClose(
|
||||
{
|
||||
s = stream_new(8);
|
||||
wts_write_drdynvc_header(s, CLOSE_REQUEST_PDU, channel->channel_id);
|
||||
WTSVirtualChannelWrite(vcm->drdynvc_channel, stream_get_head(s), stream_get_length(s), NULL);
|
||||
WTSVirtualChannelWrite(vcm->drdynvc_channel, stream_get_head(s), Stream_GetPosition(s), NULL);
|
||||
stream_free(s);
|
||||
}
|
||||
}
|
||||
|
@ -220,10 +220,10 @@ static void smartcard_irp_complete(IRP* irp)
|
||||
|
||||
DEBUG_SVC("DeviceId %d FileId %d CompletionId %d", irp->device->id, irp->FileId, irp->CompletionId);
|
||||
|
||||
pos = stream_get_pos(irp->output);
|
||||
stream_set_pos(irp->output, 12);
|
||||
pos = Stream_GetPosition(irp->output);
|
||||
Stream_SetPosition(irp->output, 12);
|
||||
stream_write_UINT32(irp->output, irp->IoStatus);
|
||||
stream_set_pos(irp->output, pos);
|
||||
Stream_SetPosition(irp->output, pos);
|
||||
|
||||
/* Begin TS Client defect workaround. */
|
||||
WaitForSingleObject(smartcard->CompletionIdsMutex, INFINITE);
|
||||
|
@ -89,7 +89,7 @@ static UINT32 smartcard_output_string(IRP* irp, char* src, BOOL wide)
|
||||
BYTE* p;
|
||||
UINT32 len;
|
||||
|
||||
p = stream_get_tail(irp->output);
|
||||
p = Stream_Pointer(irp->output);
|
||||
len = strlen(src) + 1;
|
||||
|
||||
if (wide)
|
||||
@ -109,7 +109,7 @@ static UINT32 smartcard_output_string(IRP* irp, char* src, BOOL wide)
|
||||
memcpy(p, src, len);
|
||||
}
|
||||
|
||||
stream_seek(irp->output, len);
|
||||
Stream_Seek(irp->output, len);
|
||||
return len;
|
||||
}
|
||||
|
||||
@ -120,7 +120,7 @@ static void smartcard_output_alignment(IRP* irp, UINT32 seed)
|
||||
* CompletionID, and IoStatus
|
||||
* of Section 2.2.1.5.5 of MS-RDPEFS.
|
||||
*/
|
||||
UINT32 size = stream_get_length(irp->output) - field_lengths;
|
||||
UINT32 size = Stream_GetPosition(irp->output) - field_lengths;
|
||||
UINT32 add = (seed - (size % seed)) % seed;
|
||||
|
||||
if (add > 0)
|
||||
@ -212,14 +212,14 @@ static void smartcard_input_repos(IRP* irp, UINT32 read)
|
||||
UINT32 add = 4 - (read % 4);
|
||||
|
||||
if (add < 4 && add > 0)
|
||||
stream_seek(irp->input, add);
|
||||
Stream_Seek(irp->input, add);
|
||||
}
|
||||
|
||||
static void smartcard_input_reader_name(IRP* irp, char** dest, BOOL wide)
|
||||
{
|
||||
UINT32 dataLength;
|
||||
|
||||
stream_seek(irp->input, 8);
|
||||
Stream_Seek(irp->input, 8);
|
||||
stream_read_UINT32(irp->input, dataLength);
|
||||
|
||||
DEBUG_SCARD("datalength %d", dataLength);
|
||||
@ -233,7 +233,7 @@ static void smartcard_input_skip_linked(IRP* irp)
|
||||
|
||||
if (len > 0)
|
||||
{
|
||||
stream_seek(irp->input, len);
|
||||
Stream_Seek(irp->input, len);
|
||||
smartcard_input_repos(irp, len);
|
||||
}
|
||||
}
|
||||
@ -267,13 +267,13 @@ static UINT32 handle_EstablishContext(IRP* irp)
|
||||
UINT32 scope;
|
||||
SCARDCONTEXT hContext = -1;
|
||||
|
||||
stream_seek(irp->input, 8);
|
||||
Stream_Seek(irp->input, 8);
|
||||
stream_read_UINT32(irp->input, len);
|
||||
|
||||
if (len != 8)
|
||||
return SCARD_F_INTERNAL_ERROR;
|
||||
|
||||
stream_seek_UINT32(irp->input);
|
||||
Stream_Seek_UINT32(irp->input);
|
||||
stream_read_UINT32(irp->input, scope);
|
||||
|
||||
status = SCardEstablishContext(scope, NULL, NULL, &hContext);
|
||||
@ -295,10 +295,10 @@ static UINT32 handle_ReleaseContext(IRP* irp)
|
||||
UINT32 len, status;
|
||||
SCARDCONTEXT hContext = -1;
|
||||
|
||||
stream_seek(irp->input, 8);
|
||||
Stream_Seek(irp->input, 8);
|
||||
stream_read_UINT32(irp->input, len);
|
||||
|
||||
stream_seek(irp->input, 0x10);
|
||||
Stream_Seek(irp->input, 0x10);
|
||||
stream_read_UINT32(irp->input, hContext);
|
||||
|
||||
status = SCardReleaseContext(hContext);
|
||||
@ -318,7 +318,7 @@ static UINT32 handle_IsValidContext(IRP* irp)
|
||||
UINT32 status;
|
||||
SCARDCONTEXT hContext;
|
||||
|
||||
stream_seek(irp->input, 0x1C);
|
||||
Stream_Seek(irp->input, 0x1C);
|
||||
stream_read_UINT32(irp->input, hContext);
|
||||
|
||||
status = SCardIsValidContext(hContext);
|
||||
@ -342,10 +342,10 @@ static UINT32 handle_ListReaders(IRP* irp, BOOL wide)
|
||||
int elemLength, dataLength;
|
||||
int pos, poslen1, poslen2;
|
||||
|
||||
stream_seek(irp->input, 8);
|
||||
Stream_Seek(irp->input, 8);
|
||||
stream_read_UINT32(irp->input, len);
|
||||
|
||||
stream_seek(irp->input, 0x1c);
|
||||
Stream_Seek(irp->input, 0x1c);
|
||||
stream_read_UINT32(irp->input, len);
|
||||
|
||||
if (len != 4)
|
||||
@ -373,13 +373,13 @@ static UINT32 handle_ListReaders(IRP* irp, BOOL wide)
|
||||
|
||||
/* DEBUG_SCARD("Success 0x%08x %d %d", (unsigned) hContext, (unsigned) cchReaders, (int) strlen(readerList));*/
|
||||
|
||||
poslen1 = stream_get_pos(irp->output);
|
||||
stream_seek_UINT32(irp->output);
|
||||
poslen1 = Stream_GetPosition(irp->output);
|
||||
Stream_Seek_UINT32(irp->output);
|
||||
|
||||
stream_write_UINT32(irp->output, 0x01760650);
|
||||
|
||||
poslen2 = stream_get_pos(irp->output);
|
||||
stream_seek_UINT32(irp->output);
|
||||
poslen2 = Stream_GetPosition(irp->output);
|
||||
Stream_Seek_UINT32(irp->output);
|
||||
|
||||
walker = readerList;
|
||||
dataLength = 0;
|
||||
@ -397,14 +397,14 @@ static UINT32 handle_ListReaders(IRP* irp, BOOL wide)
|
||||
|
||||
dataLength += smartcard_output_string(irp, "\0", wide);
|
||||
|
||||
pos = stream_get_pos(irp->output);
|
||||
pos = Stream_GetPosition(irp->output);
|
||||
|
||||
stream_set_pos(irp->output, poslen1);
|
||||
Stream_SetPosition(irp->output, poslen1);
|
||||
stream_write_UINT32(irp->output, dataLength);
|
||||
stream_set_pos(irp->output, poslen2);
|
||||
Stream_SetPosition(irp->output, poslen2);
|
||||
stream_write_UINT32(irp->output, dataLength);
|
||||
|
||||
stream_set_pos(irp->output, pos);
|
||||
Stream_SetPosition(irp->output, pos);
|
||||
|
||||
smartcard_output_repos(irp, dataLength);
|
||||
smartcard_output_alignment(irp, 8);
|
||||
@ -427,15 +427,15 @@ static UINT32 handle_GetStatusChange(IRP* irp, BOOL wide)
|
||||
DWORD readerCount = 0;
|
||||
SCARD_READERSTATE *readerStates, *cur;
|
||||
|
||||
stream_seek(irp->input, 0x18);
|
||||
Stream_Seek(irp->input, 0x18);
|
||||
stream_read_UINT32(irp->input, dwTimeout);
|
||||
stream_read_UINT32(irp->input, readerCount);
|
||||
|
||||
stream_seek(irp->input, 8);
|
||||
Stream_Seek(irp->input, 8);
|
||||
|
||||
stream_read_UINT32(irp->input, hContext);
|
||||
|
||||
stream_seek(irp->input, 4);
|
||||
Stream_Seek(irp->input, 4);
|
||||
|
||||
DEBUG_SCARD("context: 0x%08x, timeout: 0x%08x, count: %d",
|
||||
(unsigned) hContext, (unsigned) dwTimeout, (int) readerCount);
|
||||
@ -452,7 +452,7 @@ static UINT32 handle_GetStatusChange(IRP* irp, BOOL wide)
|
||||
{
|
||||
cur = &readerStates[i];
|
||||
|
||||
stream_seek(irp->input, 4);
|
||||
Stream_Seek(irp->input, 4);
|
||||
|
||||
/*
|
||||
* TODO: on-wire is little endian; need to either
|
||||
@ -464,7 +464,7 @@ static UINT32 handle_GetStatusChange(IRP* irp, BOOL wide)
|
||||
stream_read_UINT32(irp->input, cur->cbAtr);
|
||||
stream_read(irp->input, cur->rgbAtr, 32);
|
||||
|
||||
stream_seek(irp->input, 4);
|
||||
Stream_Seek(irp->input, 4);
|
||||
|
||||
/* reset high bytes? */
|
||||
cur->dwCurrentState &= 0x0000FFFF;
|
||||
@ -476,7 +476,7 @@ static UINT32 handle_GetStatusChange(IRP* irp, BOOL wide)
|
||||
cur = &readerStates[i];
|
||||
UINT32 dataLength;
|
||||
|
||||
stream_seek(irp->input, 8);
|
||||
Stream_Seek(irp->input, 8);
|
||||
stream_read_UINT32(irp->input, dataLength);
|
||||
smartcard_input_repos(irp, smartcard_input_string(irp, (char **) &cur->szReader, dataLength, wide));
|
||||
|
||||
@ -536,7 +536,7 @@ static UINT32 handle_Cancel(IRP *irp)
|
||||
LONG status;
|
||||
SCARDCONTEXT hContext;
|
||||
|
||||
stream_seek(irp->input, 0x1C);
|
||||
Stream_Seek(irp->input, 0x1C);
|
||||
stream_read_UINT32(irp->input, hContext);
|
||||
|
||||
status = SCardCancel(hContext);
|
||||
@ -561,13 +561,13 @@ static UINT32 handle_Connect(IRP* irp, BOOL wide)
|
||||
DWORD dwActiveProtocol = 0;
|
||||
SCARDHANDLE hCard;
|
||||
|
||||
stream_seek(irp->input, 0x1c);
|
||||
Stream_Seek(irp->input, 0x1c);
|
||||
stream_read_UINT32(irp->input, dwShareMode);
|
||||
stream_read_UINT32(irp->input, dwPreferredProtocol);
|
||||
|
||||
smartcard_input_reader_name(irp, &readerName, wide);
|
||||
|
||||
stream_seek(irp->input, 4);
|
||||
Stream_Seek(irp->input, 4);
|
||||
stream_read_UINT32(irp->input, hContext);
|
||||
|
||||
DEBUG_SCARD("(context: 0x%08x, share: 0x%08x, proto: 0x%08x, reader: \"%s\")",
|
||||
@ -606,14 +606,14 @@ static UINT32 handle_Reconnect(IRP* irp)
|
||||
DWORD dwInitialization = 0;
|
||||
DWORD dwActiveProtocol = 0;
|
||||
|
||||
stream_seek(irp->input, 0x20);
|
||||
Stream_Seek(irp->input, 0x20);
|
||||
stream_read_UINT32(irp->input, dwShareMode);
|
||||
stream_read_UINT32(irp->input, dwPreferredProtocol);
|
||||
stream_read_UINT32(irp->input, dwInitialization);
|
||||
|
||||
stream_seek(irp->input, 0x4);
|
||||
Stream_Seek(irp->input, 0x4);
|
||||
stream_read_UINT32(irp->input, hContext);
|
||||
stream_seek(irp->input, 0x4);
|
||||
Stream_Seek(irp->input, 0x4);
|
||||
stream_read_UINT32(irp->input, hCard);
|
||||
|
||||
DEBUG_SCARD("(context: 0x%08x, hcard: 0x%08x, share: 0x%08x, proto: 0x%08x, init: 0x%08x)",
|
||||
@ -641,11 +641,11 @@ static UINT32 handle_Disconnect(IRP* irp)
|
||||
SCARDHANDLE hCard;
|
||||
DWORD dwDisposition = 0;
|
||||
|
||||
stream_seek(irp->input, 0x20);
|
||||
Stream_Seek(irp->input, 0x20);
|
||||
stream_read_UINT32(irp->input, dwDisposition);
|
||||
stream_seek(irp->input, 4);
|
||||
Stream_Seek(irp->input, 4);
|
||||
stream_read_UINT32(irp->input, hContext);
|
||||
stream_seek(irp->input, 4);
|
||||
Stream_Seek(irp->input, 4);
|
||||
stream_read_UINT32(irp->input, hCard);
|
||||
|
||||
DEBUG_SCARD("(context: 0x%08x, hcard: 0x%08x, disposition: 0x%08x)",
|
||||
@ -668,7 +668,7 @@ static UINT32 handle_BeginTransaction(IRP* irp)
|
||||
LONG status;
|
||||
SCARDCONTEXT hCard;
|
||||
|
||||
stream_seek(irp->input, 0x30);
|
||||
Stream_Seek(irp->input, 0x30);
|
||||
stream_read_UINT32(irp->input, hCard);
|
||||
|
||||
status = SCardBeginTransaction(hCard);
|
||||
@ -689,10 +689,10 @@ static UINT32 handle_EndTransaction(IRP* irp)
|
||||
SCARDCONTEXT hCard;
|
||||
DWORD dwDisposition = 0;
|
||||
|
||||
stream_seek(irp->input, 0x20);
|
||||
Stream_Seek(irp->input, 0x20);
|
||||
stream_read_UINT32(irp->input, dwDisposition);
|
||||
|
||||
stream_seek(irp->input, 0x0C);
|
||||
Stream_Seek(irp->input, 0x0C);
|
||||
stream_read_UINT32(irp->input, hCard);
|
||||
|
||||
status = SCardEndTransaction(hCard, dwDisposition);
|
||||
@ -721,12 +721,12 @@ static UINT32 handle_State(IRP* irp)
|
||||
int i;
|
||||
#endif
|
||||
|
||||
stream_seek(irp->input, 0x24);
|
||||
stream_seek_UINT32(irp->input); /* atrLen */
|
||||
Stream_Seek(irp->input, 0x24);
|
||||
Stream_Seek_UINT32(irp->input); /* atrLen */
|
||||
|
||||
stream_seek(irp->input, 0x0c);
|
||||
Stream_Seek(irp->input, 0x0c);
|
||||
stream_read_UINT32(irp->input, hCard);
|
||||
stream_seek(irp->input, 0x04);
|
||||
Stream_Seek(irp->input, 0x04);
|
||||
|
||||
#ifdef SCARD_AUTOALLOCATE
|
||||
readerLen = SCARD_AUTOALLOCATE;
|
||||
@ -792,12 +792,12 @@ static DWORD handle_Status(IRP *irp, BOOL wide)
|
||||
int i;
|
||||
#endif
|
||||
|
||||
stream_seek(irp->input, 0x24);
|
||||
Stream_Seek(irp->input, 0x24);
|
||||
stream_read_UINT32(irp->input, readerLen);
|
||||
stream_read_UINT32(irp->input, atrLen);
|
||||
stream_seek(irp->input, 0x0c);
|
||||
Stream_Seek(irp->input, 0x0c);
|
||||
stream_read_UINT32(irp->input, hCard);
|
||||
stream_seek(irp->input, 0x4);
|
||||
Stream_Seek(irp->input, 0x4);
|
||||
|
||||
atrLen = MAX_ATR_SIZE;
|
||||
|
||||
@ -830,7 +830,7 @@ static DWORD handle_Status(IRP *irp, BOOL wide)
|
||||
|
||||
state = smartcard_map_state(state);
|
||||
|
||||
poslen1 = stream_get_pos(irp->output);
|
||||
poslen1 = Stream_GetPosition(irp->output);
|
||||
stream_write_UINT32(irp->output, readerLen);
|
||||
stream_write_UINT32(irp->output, 0x00020000);
|
||||
stream_write_UINT32(irp->output, state);
|
||||
@ -841,19 +841,19 @@ static DWORD handle_Status(IRP *irp, BOOL wide)
|
||||
stream_write_zero(irp->output, 32 - atrLen);
|
||||
stream_write_UINT32(irp->output, atrLen);
|
||||
|
||||
poslen2 = stream_get_pos(irp->output);
|
||||
poslen2 = Stream_GetPosition(irp->output);
|
||||
stream_write_UINT32(irp->output, readerLen);
|
||||
|
||||
dataLength = smartcard_output_string(irp, readerName, wide);
|
||||
dataLength += smartcard_output_string(irp, "\0", wide);
|
||||
smartcard_output_repos(irp, dataLength);
|
||||
|
||||
pos = stream_get_pos(irp->output);
|
||||
stream_set_pos(irp->output, poslen1);
|
||||
pos = Stream_GetPosition(irp->output);
|
||||
Stream_SetPosition(irp->output, poslen1);
|
||||
stream_write_UINT32(irp->output,dataLength);
|
||||
stream_set_pos(irp->output, poslen2);
|
||||
Stream_SetPosition(irp->output, poslen2);
|
||||
stream_write_UINT32(irp->output,dataLength);
|
||||
stream_set_pos(irp->output, pos);
|
||||
Stream_SetPosition(irp->output, pos);
|
||||
|
||||
smartcard_output_alignment(irp, 8);
|
||||
|
||||
@ -876,9 +876,9 @@ static UINT32 handle_Transmit(IRP* irp)
|
||||
DWORD cbSendLength = 0, cbRecvLength = 0;
|
||||
BYTE *sendBuf = NULL, *recvBuf = NULL;
|
||||
|
||||
stream_seek(irp->input, 0x14);
|
||||
Stream_Seek(irp->input, 0x14);
|
||||
stream_read_UINT32(irp->input, map[0]);
|
||||
stream_seek(irp->input, 0x4);
|
||||
Stream_Seek(irp->input, 0x4);
|
||||
stream_read_UINT32(irp->input, map[1]);
|
||||
|
||||
stream_read_UINT32(irp->input, pioSendPci.dwProtocol);
|
||||
@ -894,7 +894,7 @@ static UINT32 handle_Transmit(IRP* irp)
|
||||
if (map[0] & SCARD_INPUT_LINKED)
|
||||
smartcard_input_skip_linked(irp);
|
||||
|
||||
stream_seek(irp->input, 4);
|
||||
Stream_Seek(irp->input, 4);
|
||||
stream_read_UINT32(irp->input, hCard);
|
||||
|
||||
if (map[2] & SCARD_INPUT_LINKED)
|
||||
@ -903,7 +903,7 @@ static UINT32 handle_Transmit(IRP* irp)
|
||||
stream_read_UINT32(irp->input, linkedLen);
|
||||
|
||||
stream_read_UINT32(irp->input, pioSendPci.dwProtocol);
|
||||
stream_seek(irp->input, linkedLen - 4);
|
||||
Stream_Seek(irp->input, linkedLen - 4);
|
||||
|
||||
smartcard_input_repos(irp, linkedLen);
|
||||
}
|
||||
@ -928,7 +928,7 @@ static UINT32 handle_Transmit(IRP* irp)
|
||||
stream_read_UINT32(irp->input, linkedLen);
|
||||
|
||||
stream_read_UINT32(irp->input, pioRecvPci.dwProtocol);
|
||||
stream_seek(irp->input, linkedLen - 4);
|
||||
Stream_Seek(irp->input, linkedLen - 4);
|
||||
|
||||
smartcard_input_repos(irp, linkedLen);
|
||||
|
||||
@ -937,7 +937,7 @@ static UINT32 handle_Transmit(IRP* irp)
|
||||
{
|
||||
/* not sure what this is */
|
||||
stream_read_UINT32(irp->input, linkedLen);
|
||||
stream_seek(irp->input, linkedLen);
|
||||
Stream_Seek(irp->input, linkedLen);
|
||||
|
||||
smartcard_input_repos(irp, linkedLen);
|
||||
}
|
||||
@ -993,18 +993,18 @@ static UINT32 handle_Control(IRP* irp)
|
||||
DWORD nBytesReturned;
|
||||
DWORD outBufferSize;
|
||||
|
||||
stream_seek(irp->input, 0x14);
|
||||
Stream_Seek(irp->input, 0x14);
|
||||
stream_read_UINT32(irp->input, map[0]);
|
||||
stream_seek(irp->input, 0x4);
|
||||
Stream_Seek(irp->input, 0x4);
|
||||
stream_read_UINT32(irp->input, map[1]);
|
||||
stream_read_UINT32(irp->input, controlCode);
|
||||
stream_read_UINT32(irp->input, recvLength);
|
||||
stream_read_UINT32(irp->input, map[2]);
|
||||
stream_seek(irp->input, 0x4);
|
||||
Stream_Seek(irp->input, 0x4);
|
||||
stream_read_UINT32(irp->input, outBufferSize);
|
||||
stream_seek(irp->input, 0x4);
|
||||
Stream_Seek(irp->input, 0x4);
|
||||
stream_read_UINT32(irp->input, hContext);
|
||||
stream_seek(irp->input, 0x4);
|
||||
Stream_Seek(irp->input, 0x4);
|
||||
stream_read_UINT32(irp->input, hCard);
|
||||
|
||||
/* Translate Windows SCARD_CTL_CODE's to corresponding local code */
|
||||
@ -1069,11 +1069,11 @@ static UINT32 handle_GetAttrib(IRP* irp)
|
||||
DWORD attrLen = 0;
|
||||
BYTE* pbAttr = NULL;
|
||||
|
||||
stream_seek(irp->input, 0x20);
|
||||
Stream_Seek(irp->input, 0x20);
|
||||
stream_read_UINT32(irp->input, dwAttrId);
|
||||
stream_seek(irp->input, 0x4);
|
||||
Stream_Seek(irp->input, 0x4);
|
||||
stream_read_UINT32(irp->input, dwAttrLen);
|
||||
stream_seek(irp->input, 0xC);
|
||||
Stream_Seek(irp->input, 0xC);
|
||||
stream_read_UINT32(irp->input, hCard);
|
||||
|
||||
DEBUG_SCARD("hcard: 0x%08x, attrib: 0x%08x (%d bytes)",
|
||||
@ -1182,7 +1182,7 @@ void scard_error(SMARTCARD_DEVICE* scard, IRP* irp, UINT32 ntstatus)
|
||||
/* [MS-RDPESC] 3.1.4.4 */
|
||||
fprintf(stderr, "scard processing error %x\n", ntstatus);
|
||||
|
||||
stream_set_pos(irp->output, 0); /* CHECKME */
|
||||
Stream_SetPosition(irp->output, 0); /* CHECKME */
|
||||
irp->IoStatus = ntstatus;
|
||||
irp->Complete(irp);
|
||||
}
|
||||
@ -1209,7 +1209,7 @@ static UINT32 handle_LocateCardsByATR(IRP* irp, BOOL wide)
|
||||
SERVER_SCARD_ATRMASK* curAtr = NULL;
|
||||
SERVER_SCARD_ATRMASK* pAtrMasks = NULL;
|
||||
|
||||
stream_seek(irp->input, 0x2C);
|
||||
Stream_Seek(irp->input, 0x2C);
|
||||
stream_read_UINT32(irp->input, hContext);
|
||||
stream_read_UINT32(irp->input, atrMaskCount);
|
||||
|
||||
@ -1237,7 +1237,7 @@ static UINT32 handle_LocateCardsByATR(IRP* irp, BOOL wide)
|
||||
{
|
||||
cur = &readerStates[i];
|
||||
|
||||
stream_seek(irp->input, 4);
|
||||
Stream_Seek(irp->input, 4);
|
||||
|
||||
/*
|
||||
* TODO: on-wire is little endian; need to either
|
||||
@ -1249,7 +1249,7 @@ static UINT32 handle_LocateCardsByATR(IRP* irp, BOOL wide)
|
||||
stream_read_UINT32(irp->input, cur->cbAtr);
|
||||
stream_read(irp->input, cur->rgbAtr, 32);
|
||||
|
||||
stream_seek(irp->input, 4);
|
||||
Stream_Seek(irp->input, 4);
|
||||
|
||||
/* reset high bytes? */
|
||||
cur->dwCurrentState &= 0x0000FFFF;
|
||||
@ -1262,7 +1262,7 @@ static UINT32 handle_LocateCardsByATR(IRP* irp, BOOL wide)
|
||||
cur = &readerStates[i];
|
||||
UINT32 dataLength;
|
||||
|
||||
stream_seek(irp->input, 8);
|
||||
Stream_Seek(irp->input, 8);
|
||||
stream_read_UINT32(irp->input, dataLength);
|
||||
smartcard_input_repos(irp, smartcard_input_string(irp, (char **) &cur->szReader, dataLength, wide));
|
||||
|
||||
@ -1334,9 +1334,9 @@ BOOL smartcard_async_op(IRP* irp)
|
||||
UINT32 ioctl_code;
|
||||
|
||||
/* peek ahead */
|
||||
stream_seek(irp->input, 8);
|
||||
Stream_Seek(irp->input, 8);
|
||||
stream_read_UINT32(irp->input, ioctl_code);
|
||||
stream_rewind(irp->input, 12);
|
||||
Stream_Rewind(irp->input, 12);
|
||||
|
||||
switch (ioctl_code)
|
||||
{
|
||||
@ -1388,16 +1388,16 @@ void smartcard_device_control(SMARTCARD_DEVICE* scard, IRP* irp)
|
||||
stream_read_UINT32(irp->input, input_len);
|
||||
stream_read_UINT32(irp->input, ioctl_code);
|
||||
|
||||
stream_seek(irp->input, 20); /* padding */
|
||||
Stream_Seek(irp->input, 20); /* padding */
|
||||
|
||||
// stream_seek(irp->input, 4); /* TODO: parse len, le, v1 */
|
||||
// stream_seek(irp->input, 4); /* 0xcccccccc */
|
||||
// stream_seek(irp->input, 4); /* rpce len */
|
||||
// Stream_Seek(irp->input, 4); /* TODO: parse len, le, v1 */
|
||||
// Stream_Seek(irp->input, 4); /* 0xcccccccc */
|
||||
// Stream_Seek(irp->input, 4); /* rpce len */
|
||||
|
||||
/* [MS-RDPESC] 3.2.5.1 Sending Outgoing Messages */
|
||||
stream_extend(irp->output, 2048);
|
||||
|
||||
irp_result_pos = stream_get_pos(irp->output);
|
||||
irp_result_pos = Stream_GetPosition(irp->output);
|
||||
|
||||
stream_write_UINT32(irp->output, 0x00000000); /* MS-RDPEFS
|
||||
* OutputBufferLength
|
||||
@ -1409,13 +1409,13 @@ void smartcard_device_control(SMARTCARD_DEVICE* scard, IRP* irp)
|
||||
stream_write_UINT32(irp->output, 0x00081001); /* len 8, LE, v1 */
|
||||
stream_write_UINT32(irp->output, 0xcccccccc); /* filler */
|
||||
|
||||
output_len_pos = stream_get_pos(irp->output);
|
||||
stream_seek(irp->output, 4); /* size */
|
||||
output_len_pos = Stream_GetPosition(irp->output);
|
||||
Stream_Seek(irp->output, 4); /* size */
|
||||
|
||||
stream_write_UINT32(irp->output, 0x0); /* filler */
|
||||
|
||||
result_pos = stream_get_pos(irp->output);
|
||||
stream_seek(irp->output, 4); /* result */
|
||||
result_pos = Stream_GetPosition(irp->output);
|
||||
Stream_Seek(irp->output, 4); /* result */
|
||||
|
||||
/* body */
|
||||
switch (ioctl_code)
|
||||
@ -1529,24 +1529,24 @@ void smartcard_device_control(SMARTCARD_DEVICE* scard, IRP* irp)
|
||||
result = 0x80100022;
|
||||
|
||||
/* handle response packet */
|
||||
pos = stream_get_pos(irp->output);
|
||||
pos = Stream_GetPosition(irp->output);
|
||||
stream_len = pos - irp_result_pos - 4; /* Value of OutputBufferLength */
|
||||
stream_set_pos(irp->output, irp_result_pos);
|
||||
Stream_SetPosition(irp->output, irp_result_pos);
|
||||
stream_write_UINT32(irp->output, stream_len);
|
||||
|
||||
stream_set_pos(irp->output, output_len_pos);
|
||||
Stream_SetPosition(irp->output, output_len_pos);
|
||||
/* Remove the effect of the MS-RPCE Common Type Header and Private
|
||||
* Header (Sections 2.2.6.1 and 2.2.6.2).
|
||||
*/
|
||||
stream_write_UINT32(irp->output, stream_len - header_lengths);
|
||||
|
||||
stream_set_pos(irp->output, result_pos);
|
||||
Stream_SetPosition(irp->output, result_pos);
|
||||
stream_write_UINT32(irp->output, result);
|
||||
|
||||
stream_set_pos(irp->output, pos);
|
||||
Stream_SetPosition(irp->output, pos);
|
||||
|
||||
#ifdef WITH_DEBUG_SCARD
|
||||
winpr_HexDump(stream_get_data(irp->output), stream_get_length(irp->output));
|
||||
winpr_HexDump(Stream_Buffer(irp->output), Stream_GetPosition(irp->output));
|
||||
#endif
|
||||
irp->IoStatus = 0;
|
||||
|
||||
|
@ -293,7 +293,7 @@ static UINT32 tsmf_codec_parse_BITMAPINFOHEADER(TS_AM_MEDIA_TYPE* mediatype, wSt
|
||||
stream_read_UINT32(s, biSize);
|
||||
stream_read_UINT32(s, biWidth);
|
||||
stream_read_UINT32(s, biHeight);
|
||||
stream_seek(s, 28);
|
||||
Stream_Seek(s, 28);
|
||||
|
||||
if (mediatype->Width == 0)
|
||||
mediatype->Width = biWidth;
|
||||
@ -302,7 +302,7 @@ static UINT32 tsmf_codec_parse_BITMAPINFOHEADER(TS_AM_MEDIA_TYPE* mediatype, wSt
|
||||
/* Assume there will be no color table for video? */
|
||||
|
||||
if (bypass && biSize > 40)
|
||||
stream_seek(s, biSize - 40);
|
||||
Stream_Seek(s, biSize - 40);
|
||||
|
||||
return (bypass ? biSize : 40);
|
||||
}
|
||||
@ -313,22 +313,22 @@ static UINT32 tsmf_codec_parse_VIDEOINFOHEADER2(TS_AM_MEDIA_TYPE* mediatype, wSt
|
||||
UINT64 AvgTimePerFrame;
|
||||
|
||||
/* VIDEOINFOHEADER2.rcSource, RECT(LONG left, LONG top, LONG right, LONG bottom) */
|
||||
stream_seek_UINT32(s);
|
||||
stream_seek_UINT32(s);
|
||||
Stream_Seek_UINT32(s);
|
||||
Stream_Seek_UINT32(s);
|
||||
stream_read_UINT32(s, mediatype->Width);
|
||||
stream_read_UINT32(s, mediatype->Height);
|
||||
/* VIDEOINFOHEADER2.rcTarget */
|
||||
stream_seek(s, 16);
|
||||
Stream_Seek(s, 16);
|
||||
/* VIDEOINFOHEADER2.dwBitRate */
|
||||
stream_read_UINT32(s, mediatype->BitRate);
|
||||
/* VIDEOINFOHEADER2.dwBitErrorRate */
|
||||
stream_seek_UINT32(s);
|
||||
Stream_Seek_UINT32(s);
|
||||
/* VIDEOINFOHEADER2.AvgTimePerFrame */
|
||||
stream_read_UINT64(s, AvgTimePerFrame);
|
||||
mediatype->SamplesPerSecond.Numerator = 1000000;
|
||||
mediatype->SamplesPerSecond.Denominator = (int)(AvgTimePerFrame / 10LL);
|
||||
/* Remaining fields before bmiHeader */
|
||||
stream_seek(s, 24);
|
||||
Stream_Seek(s, 24);
|
||||
|
||||
return 72;
|
||||
}
|
||||
@ -349,16 +349,16 @@ typedef struct tagVIDEOINFOHEADER {
|
||||
UINT64 AvgTimePerFrame;
|
||||
|
||||
/* VIDEOINFOHEADER.rcSource, RECT(LONG left, LONG top, LONG right, LONG bottom) */
|
||||
stream_seek_UINT32(s);
|
||||
stream_seek_UINT32(s);
|
||||
Stream_Seek_UINT32(s);
|
||||
Stream_Seek_UINT32(s);
|
||||
stream_read_UINT32(s, mediatype->Width);
|
||||
stream_read_UINT32(s, mediatype->Height);
|
||||
/* VIDEOINFOHEADER.rcTarget */
|
||||
stream_seek(s, 16);
|
||||
Stream_Seek(s, 16);
|
||||
/* VIDEOINFOHEADER.dwBitRate */
|
||||
stream_read_UINT32(s, mediatype->BitRate);
|
||||
/* VIDEOINFOHEADER.dwBitErrorRate */
|
||||
stream_seek_UINT32(s);
|
||||
Stream_Seek_UINT32(s);
|
||||
/* VIDEOINFOHEADER.AvgTimePerFrame */
|
||||
stream_read_UINT64(s, AvgTimePerFrame);
|
||||
mediatype->SamplesPerSecond.Numerator = 1000000;
|
||||
@ -377,55 +377,55 @@ BOOL tsmf_codec_parse_media_type(TS_AM_MEDIA_TYPE* mediatype, wStream* s)
|
||||
|
||||
/* MajorType */
|
||||
DEBUG_DVC("MajorType:");
|
||||
tsmf_print_guid(stream_get_tail(s));
|
||||
tsmf_print_guid(Stream_Pointer(s));
|
||||
for (i = 0; tsmf_major_type_map[i].type != TSMF_MAJOR_TYPE_UNKNOWN; i++)
|
||||
{
|
||||
if (memcmp(tsmf_major_type_map[i].guid, stream_get_tail(s), 16) == 0)
|
||||
if (memcmp(tsmf_major_type_map[i].guid, Stream_Pointer(s), 16) == 0)
|
||||
break;
|
||||
}
|
||||
mediatype->MajorType = tsmf_major_type_map[i].type;
|
||||
if (mediatype->MajorType == TSMF_MAJOR_TYPE_UNKNOWN)
|
||||
ret = FALSE;
|
||||
DEBUG_DVC("MajorType %s", tsmf_major_type_map[i].name);
|
||||
stream_seek(s, 16);
|
||||
Stream_Seek(s, 16);
|
||||
|
||||
/* SubType */
|
||||
DEBUG_DVC("SubType:");
|
||||
tsmf_print_guid(stream_get_tail(s));
|
||||
tsmf_print_guid(Stream_Pointer(s));
|
||||
for (i = 0; tsmf_sub_type_map[i].type != TSMF_SUB_TYPE_UNKNOWN; i++)
|
||||
{
|
||||
if (memcmp(tsmf_sub_type_map[i].guid, stream_get_tail(s), 16) == 0)
|
||||
if (memcmp(tsmf_sub_type_map[i].guid, Stream_Pointer(s), 16) == 0)
|
||||
break;
|
||||
}
|
||||
mediatype->SubType = tsmf_sub_type_map[i].type;
|
||||
if (mediatype->SubType == TSMF_SUB_TYPE_UNKNOWN)
|
||||
ret = FALSE;
|
||||
DEBUG_DVC("SubType %s", tsmf_sub_type_map[i].name);
|
||||
stream_seek(s, 16);
|
||||
Stream_Seek(s, 16);
|
||||
|
||||
/* bFixedSizeSamples, bTemporalCompression, SampleSize */
|
||||
stream_seek(s, 12);
|
||||
Stream_Seek(s, 12);
|
||||
|
||||
/* FormatType */
|
||||
DEBUG_DVC("FormatType:");
|
||||
tsmf_print_guid(stream_get_tail(s));
|
||||
tsmf_print_guid(Stream_Pointer(s));
|
||||
for (i = 0; tsmf_format_type_map[i].type != TSMF_FORMAT_TYPE_UNKNOWN; i++)
|
||||
{
|
||||
if (memcmp(tsmf_format_type_map[i].guid, stream_get_tail(s), 16) == 0)
|
||||
if (memcmp(tsmf_format_type_map[i].guid, Stream_Pointer(s), 16) == 0)
|
||||
break;
|
||||
}
|
||||
mediatype->FormatType = tsmf_format_type_map[i].type;
|
||||
if (mediatype->FormatType == TSMF_FORMAT_TYPE_UNKNOWN)
|
||||
ret = FALSE;
|
||||
DEBUG_DVC("FormatType %s", tsmf_format_type_map[i].name);
|
||||
stream_seek(s, 16);
|
||||
Stream_Seek(s, 16);
|
||||
|
||||
/* cbFormat */
|
||||
stream_read_UINT32(s, cbFormat);
|
||||
DEBUG_DVC("cbFormat %d", cbFormat);
|
||||
|
||||
#ifdef WITH_DEBUG_DVC
|
||||
winpr_HexDump(stream_get_tail(s), cbFormat);
|
||||
winpr_HexDump(Stream_Pointer(s), cbFormat);
|
||||
#endif
|
||||
|
||||
switch (mediatype->FormatType)
|
||||
@ -433,28 +433,28 @@ BOOL tsmf_codec_parse_media_type(TS_AM_MEDIA_TYPE* mediatype, wStream* s)
|
||||
case TSMF_FORMAT_TYPE_MFVIDEOFORMAT:
|
||||
/* http://msdn.microsoft.com/en-us/library/aa473808.aspx */
|
||||
|
||||
stream_seek(s, 8); /* dwSize and ? */
|
||||
Stream_Seek(s, 8); /* dwSize and ? */
|
||||
stream_read_UINT32(s, mediatype->Width); /* videoInfo.dwWidth */
|
||||
stream_read_UINT32(s, mediatype->Height); /* videoInfo.dwHeight */
|
||||
stream_seek(s, 32);
|
||||
Stream_Seek(s, 32);
|
||||
/* videoInfo.FramesPerSecond */
|
||||
stream_read_UINT32(s, mediatype->SamplesPerSecond.Numerator);
|
||||
stream_read_UINT32(s, mediatype->SamplesPerSecond.Denominator);
|
||||
stream_seek(s, 80);
|
||||
Stream_Seek(s, 80);
|
||||
stream_read_UINT32(s, mediatype->BitRate); /* compressedInfo.AvgBitrate */
|
||||
stream_seek(s, 36);
|
||||
Stream_Seek(s, 36);
|
||||
|
||||
if (cbFormat > 176)
|
||||
{
|
||||
mediatype->ExtraDataSize = cbFormat - 176;
|
||||
mediatype->ExtraData = stream_get_tail(s);
|
||||
mediatype->ExtraData = Stream_Pointer(s);
|
||||
}
|
||||
break;
|
||||
|
||||
case TSMF_FORMAT_TYPE_WAVEFORMATEX:
|
||||
/* http://msdn.microsoft.com/en-us/library/dd757720.aspx */
|
||||
|
||||
stream_seek_UINT16(s);
|
||||
Stream_Seek_UINT16(s);
|
||||
stream_read_UINT16(s, mediatype->Channels);
|
||||
stream_read_UINT32(s, mediatype->SamplesPerSecond.Numerator);
|
||||
mediatype->SamplesPerSecond.Denominator = 1;
|
||||
@ -464,7 +464,7 @@ BOOL tsmf_codec_parse_media_type(TS_AM_MEDIA_TYPE* mediatype, wStream* s)
|
||||
stream_read_UINT16(s, mediatype->BitsPerSample);
|
||||
stream_read_UINT16(s, mediatype->ExtraDataSize);
|
||||
if (mediatype->ExtraDataSize > 0)
|
||||
mediatype->ExtraData = stream_get_tail(s);
|
||||
mediatype->ExtraData = Stream_Pointer(s);
|
||||
|
||||
break;
|
||||
|
||||
@ -476,7 +476,7 @@ BOOL tsmf_codec_parse_media_type(TS_AM_MEDIA_TYPE* mediatype, wStream* s)
|
||||
if (cbFormat > i)
|
||||
{
|
||||
mediatype->ExtraDataSize = cbFormat - i;
|
||||
mediatype->ExtraData = stream_get_tail(s);
|
||||
mediatype->ExtraData = Stream_Pointer(s);
|
||||
}
|
||||
break;
|
||||
|
||||
@ -488,7 +488,7 @@ BOOL tsmf_codec_parse_media_type(TS_AM_MEDIA_TYPE* mediatype, wStream* s)
|
||||
if (cbFormat > i)
|
||||
{
|
||||
mediatype->ExtraDataSize = cbFormat - i;
|
||||
mediatype->ExtraData = stream_get_tail(s);
|
||||
mediatype->ExtraData = Stream_Pointer(s);
|
||||
}
|
||||
break;
|
||||
|
||||
@ -498,7 +498,7 @@ BOOL tsmf_codec_parse_media_type(TS_AM_MEDIA_TYPE* mediatype, wStream* s)
|
||||
if (cbFormat > i)
|
||||
{
|
||||
mediatype->ExtraDataSize = cbFormat - i;
|
||||
mediatype->ExtraData = stream_get_tail(s);
|
||||
mediatype->ExtraData = Stream_Pointer(s);
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -60,18 +60,18 @@ int tsmf_ifman_exchange_capability_request(TSMF_IFMAN* ifman)
|
||||
UINT32 cbCapabilityLength;
|
||||
UINT32 numHostCapabilities;
|
||||
|
||||
pos = stream_get_pos(ifman->output);
|
||||
pos = Stream_GetPosition(ifman->output);
|
||||
stream_check_size(ifman->output, ifman->input_size + 4);
|
||||
stream_copy(ifman->output, ifman->input, ifman->input_size);
|
||||
|
||||
stream_set_pos(ifman->output, pos);
|
||||
Stream_SetPosition(ifman->output, pos);
|
||||
stream_read_UINT32(ifman->output, numHostCapabilities);
|
||||
|
||||
for (i = 0; i < numHostCapabilities; i++)
|
||||
{
|
||||
stream_read_UINT32(ifman->output, CapabilityType);
|
||||
stream_read_UINT32(ifman->output, cbCapabilityLength);
|
||||
pos = stream_get_pos(ifman->output);
|
||||
pos = Stream_GetPosition(ifman->output);
|
||||
|
||||
switch (CapabilityType)
|
||||
{
|
||||
@ -90,7 +90,7 @@ int tsmf_ifman_exchange_capability_request(TSMF_IFMAN* ifman)
|
||||
DEBUG_WARN("unknown capability type %d", CapabilityType);
|
||||
break;
|
||||
}
|
||||
stream_set_pos(ifman->output, pos + cbCapabilityLength);
|
||||
Stream_SetPosition(ifman->output, pos + cbCapabilityLength);
|
||||
}
|
||||
stream_write_UINT32(ifman->output, 0); /* Result */
|
||||
|
||||
@ -106,7 +106,7 @@ int tsmf_ifman_check_format_support_request(TSMF_IFMAN* ifman)
|
||||
UINT32 FormatSupported = 1;
|
||||
|
||||
stream_read_UINT32(ifman->input, PlatformCookie);
|
||||
stream_seek_UINT32(ifman->input); /* NoRolloverFlags (4 bytes) */
|
||||
Stream_Seek_UINT32(ifman->input); /* NoRolloverFlags (4 bytes) */
|
||||
stream_read_UINT32(ifman->input, numMediaType);
|
||||
|
||||
DEBUG_DVC("PlatformCookie %d numMediaType %d", PlatformCookie, numMediaType);
|
||||
@ -143,7 +143,7 @@ int tsmf_ifman_on_new_presentation(TSMF_IFMAN* ifman)
|
||||
|
||||
}
|
||||
|
||||
presentation = tsmf_presentation_new(stream_get_tail(ifman->input), ifman->channel_callback);
|
||||
presentation = tsmf_presentation_new(Stream_Pointer(ifman->input), ifman->channel_callback);
|
||||
pexisted = presentation;
|
||||
|
||||
if (presentation == NULL)
|
||||
@ -165,8 +165,8 @@ int tsmf_ifman_add_stream(TSMF_IFMAN* ifman)
|
||||
|
||||
DEBUG_DVC("");
|
||||
|
||||
presentation = tsmf_presentation_find_by_id(stream_get_tail(ifman->input));
|
||||
stream_seek(ifman->input, 16);
|
||||
presentation = tsmf_presentation_find_by_id(Stream_Pointer(ifman->input));
|
||||
Stream_Seek(ifman->input, 16);
|
||||
|
||||
if (presentation == NULL)
|
||||
{
|
||||
@ -175,7 +175,7 @@ int tsmf_ifman_add_stream(TSMF_IFMAN* ifman)
|
||||
else
|
||||
{
|
||||
stream_read_UINT32(ifman->input, StreamId);
|
||||
stream_seek_UINT32(ifman->input); /* numMediaType */
|
||||
Stream_Seek_UINT32(ifman->input); /* numMediaType */
|
||||
stream = tsmf_stream_new(presentation, StreamId);
|
||||
|
||||
if (stream)
|
||||
@ -208,8 +208,8 @@ int tsmf_ifman_remove_stream(TSMF_IFMAN* ifman)
|
||||
|
||||
DEBUG_DVC("");
|
||||
|
||||
presentation = tsmf_presentation_find_by_id(stream_get_tail(ifman->input));
|
||||
stream_seek(ifman->input, 16);
|
||||
presentation = tsmf_presentation_find_by_id(Stream_Pointer(ifman->input));
|
||||
Stream_Seek(ifman->input, 16);
|
||||
|
||||
if (presentation == NULL)
|
||||
{
|
||||
@ -236,7 +236,7 @@ int tsmf_ifman_shutdown_presentation(TSMF_IFMAN* ifman)
|
||||
|
||||
DEBUG_DVC("");
|
||||
|
||||
presentation = tsmf_presentation_find_by_id(stream_get_tail(ifman->input));
|
||||
presentation = tsmf_presentation_find_by_id(Stream_Pointer(ifman->input));
|
||||
|
||||
if (presentation)
|
||||
tsmf_presentation_free(presentation);
|
||||
@ -256,14 +256,14 @@ int tsmf_ifman_on_stream_volume(TSMF_IFMAN* ifman)
|
||||
|
||||
DEBUG_DVC("on stream volume");
|
||||
|
||||
presentation = tsmf_presentation_find_by_id(stream_get_tail(ifman->input));
|
||||
presentation = tsmf_presentation_find_by_id(Stream_Pointer(ifman->input));
|
||||
|
||||
if (presentation)
|
||||
{
|
||||
UINT32 newVolume;
|
||||
UINT32 muted;
|
||||
|
||||
stream_seek(ifman->input, 16);
|
||||
Stream_Seek(ifman->input, 16);
|
||||
stream_read_UINT32(ifman->input, newVolume);
|
||||
DEBUG_DVC("on stream volume: new volume=[%d]", newVolume);
|
||||
stream_read_UINT32(ifman->input, muted);
|
||||
@ -286,14 +286,14 @@ int tsmf_ifman_on_channel_volume(TSMF_IFMAN* ifman)
|
||||
|
||||
DEBUG_DVC("on channel volume");
|
||||
|
||||
presentation = tsmf_presentation_find_by_id(stream_get_tail(ifman->input));
|
||||
presentation = tsmf_presentation_find_by_id(Stream_Pointer(ifman->input));
|
||||
|
||||
if (presentation)
|
||||
{
|
||||
UINT32 channelVolume;
|
||||
UINT32 changedChannel;
|
||||
|
||||
stream_seek(ifman->input, 16);
|
||||
Stream_Seek(ifman->input, 16);
|
||||
stream_read_UINT32(ifman->input, channelVolume);
|
||||
DEBUG_DVC("on channel volume: channel volume=[%d]", channelVolume);
|
||||
stream_read_UINT32(ifman->input, changedChannel);
|
||||
@ -327,19 +327,19 @@ int tsmf_ifman_update_geometry_info(TSMF_IFMAN* ifman)
|
||||
int i;
|
||||
int pos;
|
||||
|
||||
presentation = tsmf_presentation_find_by_id(stream_get_tail(ifman->input));
|
||||
stream_seek(ifman->input, 16);
|
||||
presentation = tsmf_presentation_find_by_id(Stream_Pointer(ifman->input));
|
||||
Stream_Seek(ifman->input, 16);
|
||||
|
||||
stream_read_UINT32(ifman->input, numGeometryInfo);
|
||||
pos = stream_get_pos(ifman->input);
|
||||
pos = Stream_GetPosition(ifman->input);
|
||||
|
||||
stream_seek(ifman->input, 12); /* VideoWindowId (8 bytes), VideoWindowState (4 bytes) */
|
||||
Stream_Seek(ifman->input, 12); /* VideoWindowId (8 bytes), VideoWindowState (4 bytes) */
|
||||
stream_read_UINT32(ifman->input, Width);
|
||||
stream_read_UINT32(ifman->input, Height);
|
||||
stream_read_UINT32(ifman->input, Left);
|
||||
stream_read_UINT32(ifman->input, Top);
|
||||
|
||||
stream_set_pos(ifman->input, pos + numGeometryInfo);
|
||||
Stream_SetPosition(ifman->input, pos + numGeometryInfo);
|
||||
stream_read_UINT32(ifman->input, cbVisibleRect);
|
||||
num_rects = cbVisibleRect / 16;
|
||||
|
||||
@ -360,13 +360,13 @@ int tsmf_ifman_update_geometry_info(TSMF_IFMAN* ifman)
|
||||
for (i = 0; i < num_rects; i++)
|
||||
{
|
||||
stream_read_UINT16(ifman->input, rects[i].y); /* Top */
|
||||
stream_seek_UINT16(ifman->input);
|
||||
Stream_Seek_UINT16(ifman->input);
|
||||
stream_read_UINT16(ifman->input, rects[i].x); /* Left */
|
||||
stream_seek_UINT16(ifman->input);
|
||||
Stream_Seek_UINT16(ifman->input);
|
||||
stream_read_UINT16(ifman->input, rects[i].height); /* Bottom */
|
||||
stream_seek_UINT16(ifman->input);
|
||||
Stream_Seek_UINT16(ifman->input);
|
||||
stream_read_UINT16(ifman->input, rects[i].width); /* Right */
|
||||
stream_seek_UINT16(ifman->input);
|
||||
Stream_Seek_UINT16(ifman->input);
|
||||
rects[i].width -= rects[i].x;
|
||||
rects[i].height -= rects[i].y;
|
||||
|
||||
@ -407,13 +407,13 @@ int tsmf_ifman_on_sample(TSMF_IFMAN* ifman)
|
||||
UINT32 SampleExtensions;
|
||||
UINT32 cbData;
|
||||
|
||||
stream_seek(ifman->input, 16);
|
||||
Stream_Seek(ifman->input, 16);
|
||||
stream_read_UINT32(ifman->input, StreamId);
|
||||
stream_seek_UINT32(ifman->input); /* numSample */
|
||||
Stream_Seek_UINT32(ifman->input); /* numSample */
|
||||
stream_read_UINT64(ifman->input, SampleStartTime);
|
||||
stream_read_UINT64(ifman->input, SampleEndTime);
|
||||
stream_read_UINT64(ifman->input, ThrottleDuration);
|
||||
stream_seek_UINT32(ifman->input); /* SampleFlags */
|
||||
Stream_Seek_UINT32(ifman->input); /* SampleFlags */
|
||||
stream_read_UINT32(ifman->input, SampleExtensions);
|
||||
stream_read_UINT32(ifman->input, cbData);
|
||||
|
||||
@ -440,7 +440,7 @@ int tsmf_ifman_on_sample(TSMF_IFMAN* ifman)
|
||||
|
||||
tsmf_stream_push_sample(stream, ifman->channel_callback,
|
||||
ifman->message_id, SampleStartTime, SampleEndTime, ThrottleDuration, SampleExtensions,
|
||||
cbData, stream_get_tail(ifman->input));
|
||||
cbData, Stream_Pointer(ifman->input));
|
||||
|
||||
ifman->output_pending = TRUE;
|
||||
|
||||
@ -452,7 +452,7 @@ int tsmf_ifman_on_flush(TSMF_IFMAN* ifman)
|
||||
UINT32 StreamId;
|
||||
TSMF_PRESENTATION* presentation;
|
||||
|
||||
stream_seek(ifman->input, 16);
|
||||
Stream_Seek(ifman->input, 16);
|
||||
stream_read_UINT32(ifman->input, StreamId);
|
||||
DEBUG_DVC("StreamId %d", StreamId);
|
||||
|
||||
@ -477,8 +477,8 @@ int tsmf_ifman_on_end_of_stream(TSMF_IFMAN* ifman)
|
||||
TSMF_STREAM* stream;
|
||||
TSMF_PRESENTATION* presentation;
|
||||
|
||||
presentation = tsmf_presentation_find_by_id(stream_get_tail(ifman->input));
|
||||
stream_seek(ifman->input, 16);
|
||||
presentation = tsmf_presentation_find_by_id(Stream_Pointer(ifman->input));
|
||||
Stream_Seek(ifman->input, 16);
|
||||
stream_read_UINT32(ifman->input, StreamId);
|
||||
|
||||
if (presentation)
|
||||
@ -505,7 +505,7 @@ int tsmf_ifman_on_playback_started(TSMF_IFMAN* ifman)
|
||||
|
||||
DEBUG_DVC("");
|
||||
|
||||
presentation = tsmf_presentation_find_by_id(stream_get_tail(ifman->input));
|
||||
presentation = tsmf_presentation_find_by_id(Stream_Pointer(ifman->input));
|
||||
|
||||
if (presentation)
|
||||
tsmf_presentation_start(presentation);
|
||||
@ -531,7 +531,7 @@ int tsmf_ifman_on_playback_paused(TSMF_IFMAN* ifman)
|
||||
|
||||
/* Added pause control so gstreamer pipeline can be paused accordingly */
|
||||
|
||||
presentation = tsmf_presentation_find_by_id(stream_get_tail(ifman->input));
|
||||
presentation = tsmf_presentation_find_by_id(Stream_Pointer(ifman->input));
|
||||
|
||||
if (presentation)
|
||||
tsmf_presentation_paused(presentation);
|
||||
@ -550,7 +550,7 @@ int tsmf_ifman_on_playback_restarted(TSMF_IFMAN* ifman)
|
||||
|
||||
/* Added restart control so gstreamer pipeline can be resumed accordingly */
|
||||
|
||||
presentation = tsmf_presentation_find_by_id(stream_get_tail(ifman->input));
|
||||
presentation = tsmf_presentation_find_by_id(Stream_Pointer(ifman->input));
|
||||
|
||||
if (presentation)
|
||||
tsmf_presentation_restarted(presentation);
|
||||
@ -566,7 +566,7 @@ int tsmf_ifman_on_playback_stopped(TSMF_IFMAN* ifman)
|
||||
|
||||
DEBUG_DVC("");
|
||||
|
||||
presentation = tsmf_presentation_find_by_id(stream_get_tail(ifman->input));
|
||||
presentation = tsmf_presentation_find_by_id(Stream_Pointer(ifman->input));
|
||||
|
||||
if (presentation)
|
||||
tsmf_presentation_stop(presentation);
|
||||
|
@ -89,8 +89,8 @@ void tsmf_playback_ack(IWTSVirtualChannelCallback* pChannelCallback,
|
||||
stream_write_UINT64(s, duration); /* DataDuration */
|
||||
stream_write_UINT64(s, data_size); /* cbData */
|
||||
|
||||
DEBUG_DVC("response size %d", (int) stream_get_length(s));
|
||||
status = callback->channel->Write(callback->channel, stream_get_length(s), stream_get_head(s), NULL);
|
||||
DEBUG_DVC("response size %d", (int) Stream_GetPosition(s));
|
||||
status = callback->channel->Write(callback->channel, Stream_GetPosition(s), stream_get_head(s), NULL);
|
||||
|
||||
if (status)
|
||||
{
|
||||
@ -139,7 +139,7 @@ static int tsmf_on_data_received(IWTSVirtualChannelCallback* pChannelCallback,
|
||||
input = stream_new(0);
|
||||
stream_attach(input, (BYTE*) pBuffer, cbSize);
|
||||
output = stream_new(256);
|
||||
stream_seek(output, 8);
|
||||
Stream_Seek(output, 8);
|
||||
|
||||
stream_read_UINT32(input, InterfaceId);
|
||||
stream_read_UINT32(input, MessageId);
|
||||
@ -181,8 +181,8 @@ static int tsmf_on_data_received(IWTSVirtualChannelCallback* pChannelCallback,
|
||||
switch (FunctionId)
|
||||
{
|
||||
case SET_CHANNEL_PARAMS:
|
||||
memcpy(callback->presentation_id, stream_get_tail(input), 16);
|
||||
stream_seek(input, 16);
|
||||
memcpy(callback->presentation_id, Stream_Pointer(input), 16);
|
||||
Stream_Seek(input, 16);
|
||||
stream_read_UINT32(input, callback->stream_id);
|
||||
DEBUG_DVC("SET_CHANNEL_PARAMS StreamId=%d", callback->stream_id);
|
||||
ifman.output_pending = TRUE;
|
||||
@ -317,8 +317,8 @@ static int tsmf_on_data_received(IWTSVirtualChannelCallback* pChannelCallback,
|
||||
if (status == 0 && !ifman.output_pending)
|
||||
{
|
||||
/* Response packet does not have FunctionId */
|
||||
length = stream_get_length(output);
|
||||
stream_set_pos(output, 0);
|
||||
length = Stream_GetPosition(output);
|
||||
Stream_SetPosition(output, 0);
|
||||
stream_write_UINT32(output, ifman.output_interface_id);
|
||||
stream_write_UINT32(output, MessageId);
|
||||
|
||||
|
@ -930,7 +930,7 @@ static void xf_cliprdr_process_dib(clipboardContext* cb, BYTE* data, int size)
|
||||
|
||||
s = stream_new(0);
|
||||
stream_attach(s, data, size);
|
||||
stream_seek(s, 14);
|
||||
Stream_Seek(s, 14);
|
||||
stream_read_UINT16(s, bpp);
|
||||
stream_read_UINT32(s, ncolors);
|
||||
offset = 14 + 40 + (bpp <= 8 ? (ncolors == 0 ? (1 << bpp) : ncolors) * 4 : 0);
|
||||
@ -948,7 +948,7 @@ static void xf_cliprdr_process_dib(clipboardContext* cb, BYTE* data, int size)
|
||||
stream_write(s, data, size);
|
||||
|
||||
cb->data = stream_get_head(s);
|
||||
cb->data_length = stream_get_length(s);
|
||||
cb->data_length = Stream_GetPosition(s);
|
||||
stream_detach(s);
|
||||
stream_free(s);
|
||||
}
|
||||
|
@ -70,7 +70,7 @@ void assert_stream(wStream* s, BYTE* data, int length, const char* func, int lin
|
||||
BYTE* actual_data;
|
||||
|
||||
actual_data = s->buffer;
|
||||
actual_length = stream_get_length(s);
|
||||
actual_length = Stream_GetPosition(s);
|
||||
|
||||
if (actual_length != length)
|
||||
{
|
||||
|
@ -363,11 +363,11 @@ void test_nsc_encode(void)
|
||||
|
||||
for (i = 0; i < 30000; i++)
|
||||
{
|
||||
stream_set_pos(enc_stream, 0);
|
||||
Stream_SetPosition(enc_stream, 0);
|
||||
nsc_compose_message(context, enc_stream, rgb_data, 64, 64, 64 * 3);
|
||||
}
|
||||
/*winpr_HexDump(stream_get_head(enc_stream), stream_get_length(enc_stream));*/
|
||||
nsc_process_message(context, 32, 64, 64, stream_get_head(enc_stream), stream_get_length(enc_stream));
|
||||
/*winpr_HexDump(stream_get_head(enc_stream), Stream_GetPosition(enc_stream));*/
|
||||
nsc_process_message(context, 32, 64, 64, stream_get_head(enc_stream), Stream_GetPosition(enc_stream));
|
||||
/*winpr_HexDump(context->bmpdata, 64 * 64 * 4);*/
|
||||
stream_free(enc_stream);
|
||||
|
||||
|
@ -91,7 +91,7 @@ void test_read_dstblt_order(void)
|
||||
CU_ASSERT(dstblt.nHeight == 311);
|
||||
CU_ASSERT(dstblt.bRop == 0);
|
||||
|
||||
CU_ASSERT(stream_get_length(s) == (sizeof(dstblt_order) - 1));
|
||||
CU_ASSERT(Stream_GetPosition(s) == (sizeof(dstblt_order) - 1));
|
||||
}
|
||||
|
||||
BYTE patblt_order[] = "\x1a\x00\xc3\x01\x0d\x00\x0d\x00\xf0\xff\xff\x00\x5b\xef\x00\x81";
|
||||
@ -121,7 +121,7 @@ void test_read_patblt_order(void)
|
||||
CU_ASSERT(patblt.brush.y == 0);
|
||||
CU_ASSERT(patblt.brush.style == (BMF_1BPP | CACHED_BRUSH));
|
||||
|
||||
CU_ASSERT(stream_get_length(s) == (sizeof(patblt_order) - 1));
|
||||
CU_ASSERT(Stream_GetPosition(s) == (sizeof(patblt_order) - 1));
|
||||
}
|
||||
|
||||
BYTE scrblt_order[] = "\x07\x00\xa1\x01\xf1\x00\xcc\x2f\x01\x8e\x00";
|
||||
@ -148,7 +148,7 @@ void test_read_scrblt_order(void)
|
||||
CU_ASSERT(scrblt.nXSrc == 303);
|
||||
CU_ASSERT(scrblt.nYSrc == 142);
|
||||
|
||||
CU_ASSERT(stream_get_length(s) == (sizeof(scrblt_order) - 1));
|
||||
CU_ASSERT(Stream_GetPosition(s) == (sizeof(scrblt_order) - 1));
|
||||
}
|
||||
|
||||
BYTE opaque_rect_order[] = "\x00\x04\x00\x03\x73\x02\x06";
|
||||
@ -173,7 +173,7 @@ void test_read_opaque_rect_order(void)
|
||||
CU_ASSERT(opaque_rect.nHeight == 768);
|
||||
CU_ASSERT(opaque_rect.color == 0x00060273);
|
||||
|
||||
CU_ASSERT(stream_get_length(s) == (sizeof(opaque_rect_order) - 1));
|
||||
CU_ASSERT(Stream_GetPosition(s) == (sizeof(opaque_rect_order) - 1));
|
||||
}
|
||||
|
||||
BYTE draw_nine_grid_order[] = "\xfb\xf9\x0d\x00";
|
||||
@ -202,7 +202,7 @@ void test_read_draw_nine_grid_order(void)
|
||||
CU_ASSERT(draw_nine_grid.srcBottom == 33);
|
||||
CU_ASSERT(draw_nine_grid.bitmapId == 13);
|
||||
|
||||
CU_ASSERT(stream_get_length(s) == (sizeof(draw_nine_grid_order) - 1));
|
||||
CU_ASSERT(Stream_GetPosition(s) == (sizeof(draw_nine_grid_order) - 1));
|
||||
}
|
||||
|
||||
|
||||
@ -253,7 +253,7 @@ void test_read_multi_opaque_rect_order(void)
|
||||
CU_ASSERT(multi_opaque_rect.rectangles[4].width == 241);
|
||||
CU_ASSERT(multi_opaque_rect.rectangles[4].height == 1);
|
||||
|
||||
CU_ASSERT(stream_get_length(s) == (sizeof(multi_opaque_rect_order) - 1));
|
||||
CU_ASSERT(Stream_GetPosition(s) == (sizeof(multi_opaque_rect_order) - 1));
|
||||
}
|
||||
|
||||
BYTE line_to_order[] = "\x03\xb1\x0e\xa6\x5b\xef\x00";
|
||||
@ -288,7 +288,7 @@ void test_read_line_to_order(void)
|
||||
CU_ASSERT(line_to.penWidth == 0);
|
||||
CU_ASSERT(line_to.penColor == 0x00EF5B);
|
||||
|
||||
CU_ASSERT(stream_get_length(s) == (sizeof(line_to_order) - 1));
|
||||
CU_ASSERT(Stream_GetPosition(s) == (sizeof(line_to_order) - 1));
|
||||
}
|
||||
|
||||
BYTE polyline_order[] =
|
||||
@ -357,7 +357,7 @@ void test_read_polyline_order(void)
|
||||
CU_ASSERT(polyline.points[31].x == -153);
|
||||
CU_ASSERT(polyline.points[32].x == 0);
|
||||
|
||||
CU_ASSERT(stream_get_length(s) == (sizeof(polyline_order) - 1));
|
||||
CU_ASSERT(Stream_GetPosition(s) == (sizeof(polyline_order) - 1));
|
||||
}
|
||||
|
||||
BYTE glyph_index_order_1[] =
|
||||
@ -387,7 +387,7 @@ void test_read_glyph_index_order(void)
|
||||
|
||||
CU_ASSERT(glyph_index.bkRight == 618);
|
||||
|
||||
CU_ASSERT(stream_get_length(s) == (sizeof(glyph_index_order_1) - 1));
|
||||
CU_ASSERT(Stream_GetPosition(s) == (sizeof(glyph_index_order_1) - 1));
|
||||
|
||||
s->pointer = s->buffer = glyph_index_order_2;
|
||||
|
||||
@ -412,7 +412,7 @@ void test_read_glyph_index_order(void)
|
||||
CU_ASSERT(glyph_index.x == 524);
|
||||
CU_ASSERT(glyph_index.y == 377);
|
||||
|
||||
CU_ASSERT(stream_get_length(s) == (sizeof(glyph_index_order_2) - 1));
|
||||
CU_ASSERT(Stream_GetPosition(s) == (sizeof(glyph_index_order_2) - 1));
|
||||
}
|
||||
|
||||
BYTE fast_index_order[] =
|
||||
@ -450,7 +450,7 @@ void test_read_fast_index_order(void)
|
||||
CU_ASSERT(fast_index.x == -32768);
|
||||
CU_ASSERT(fast_index.y == 124);
|
||||
|
||||
CU_ASSERT(stream_get_length(s) == (sizeof(fast_index_order) - 1));
|
||||
CU_ASSERT(Stream_GetPosition(s) == (sizeof(fast_index_order) - 1));
|
||||
}
|
||||
|
||||
BYTE fast_glyph_order[] =
|
||||
@ -486,7 +486,7 @@ void test_read_fast_glyph_order(void)
|
||||
CU_ASSERT(fast_glyph.x == -32768);
|
||||
CU_ASSERT(fast_glyph.y == 187);
|
||||
|
||||
CU_ASSERT(stream_get_length(s) == (sizeof(fast_glyph_order) - 1));
|
||||
CU_ASSERT(Stream_GetPosition(s) == (sizeof(fast_glyph_order) - 1));
|
||||
}
|
||||
|
||||
BYTE polygon_cb_order[] =
|
||||
@ -520,7 +520,7 @@ void test_read_polygon_cb_order(void)
|
||||
CU_ASSERT(polygon_cb.numPoints == 3);
|
||||
CU_ASSERT(polygon_cb.cbData == 5);
|
||||
|
||||
CU_ASSERT(stream_get_length(s) == (sizeof(polygon_cb_order) - 1));
|
||||
CU_ASSERT(Stream_GetPosition(s) == (sizeof(polygon_cb_order) - 1));
|
||||
}
|
||||
|
||||
BYTE cache_bitmap_order[] = "\x00\x00\x10\x01\x08\x01\x00\x00\x00\x10";
|
||||
@ -546,7 +546,7 @@ void test_read_cache_bitmap_order(void)
|
||||
CU_ASSERT(cache_bitmap.bitmapLength == 1);
|
||||
CU_ASSERT(cache_bitmap.cacheIndex == 0);
|
||||
|
||||
CU_ASSERT(stream_get_length(s) == (sizeof(cache_bitmap_order) - 1));
|
||||
CU_ASSERT(Stream_GetPosition(s) == (sizeof(cache_bitmap_order) - 1));
|
||||
}
|
||||
|
||||
BYTE cache_bitmap_v2_order[] =
|
||||
@ -588,7 +588,7 @@ void test_read_cache_bitmap_v2_order(void)
|
||||
CU_ASSERT(cache_bitmap_v2.bitmapLength == 220);
|
||||
CU_ASSERT(cache_bitmap_v2.cacheIndex == 32767);
|
||||
|
||||
CU_ASSERT(stream_get_length(s) == (sizeof(cache_bitmap_v2_order) - 1));
|
||||
CU_ASSERT(Stream_GetPosition(s) == (sizeof(cache_bitmap_v2_order) - 1));
|
||||
}
|
||||
|
||||
BYTE cache_bitmap_v3_order[] =
|
||||
@ -622,7 +622,7 @@ void test_read_cache_bitmap_v3_order(void)
|
||||
CU_ASSERT(cache_bitmap_v3.bitmapData.height == 2);
|
||||
CU_ASSERT(cache_bitmap_v3.bitmapData.length == 40);
|
||||
|
||||
CU_ASSERT(stream_get_length(s) == (sizeof(cache_bitmap_v3_order) - 1));
|
||||
CU_ASSERT(Stream_GetPosition(s) == (sizeof(cache_bitmap_v3_order) - 1));
|
||||
}
|
||||
|
||||
BYTE cache_brush_order[] = "\x00\x01\x08\x08\x81\x08\xaa\x55\xaa\x55\xaa\x55\xaa\x55";
|
||||
@ -646,7 +646,7 @@ void test_read_cache_brush_order(void)
|
||||
CU_ASSERT(cache_brush.style == 0x81);
|
||||
CU_ASSERT(cache_brush.length == 8);
|
||||
|
||||
CU_ASSERT(stream_get_length(s) == (sizeof(cache_brush_order) - 1));
|
||||
CU_ASSERT(Stream_GetPosition(s) == (sizeof(cache_brush_order) - 1));
|
||||
}
|
||||
|
||||
BYTE create_offscreen_bitmap_order[] = "\x00\x80\x60\x01\x10\x00\x01\x00\x02\x00";
|
||||
@ -674,7 +674,7 @@ void test_read_create_offscreen_bitmap_order(void)
|
||||
CU_ASSERT(create_offscreen_bitmap.cy == 16);
|
||||
CU_ASSERT(create_offscreen_bitmap.deleteList.cIndices == 1);
|
||||
|
||||
CU_ASSERT(stream_get_length(s) == (sizeof(create_offscreen_bitmap_order) - 1));
|
||||
CU_ASSERT(Stream_GetPosition(s) == (sizeof(create_offscreen_bitmap_order) - 1));
|
||||
}
|
||||
|
||||
BYTE switch_surface_order[] = "\xff\xff";
|
||||
@ -693,7 +693,7 @@ void test_read_switch_surface_order(void)
|
||||
|
||||
CU_ASSERT(switch_surface.bitmapId == 0xFFFF);
|
||||
|
||||
CU_ASSERT(stream_get_length(s) == (sizeof(switch_surface_order) - 1));
|
||||
CU_ASSERT(Stream_GetPosition(s) == (sizeof(switch_surface_order) - 1));
|
||||
}
|
||||
|
||||
int opaque_rect_count;
|
||||
|
@ -310,7 +310,7 @@ void test_decode(void)
|
||||
stream_write(s, y_data, sizeof(y_data));
|
||||
stream_write(s, cb_data, sizeof(cb_data));
|
||||
stream_write(s, cr_data, sizeof(cr_data));
|
||||
stream_set_pos(s, 0);
|
||||
Stream_SetPosition(s, 0);
|
||||
|
||||
context = rfx_context_new();
|
||||
context->mode = RLGR3;
|
||||
@ -358,7 +358,7 @@ void test_encode(void)
|
||||
printf("*** Cr ***\n");
|
||||
winpr_HexDump(stream_get_head(enc_stream) + y_size + cb_size, cr_size);*/
|
||||
|
||||
stream_set_pos(enc_stream, 0);
|
||||
Stream_SetPosition(enc_stream, 0);
|
||||
rfx_decode_rgb(context, enc_stream,
|
||||
y_size, test_quantization_values,
|
||||
cb_size, test_quantization_values,
|
||||
@ -398,9 +398,9 @@ void test_message(void)
|
||||
stream_clear(s);
|
||||
rfx_compose_message(context, s,
|
||||
&rect, 1, rgb_data, 100, 80, 100 * 3);
|
||||
stream_seal(s);
|
||||
Stream_SealLength(s);
|
||||
/*hexdump(buffer, size);*/
|
||||
stream_set_pos(s, 0);
|
||||
Stream_SetPosition(s, 0);
|
||||
message = rfx_process_message(context, s->pointer, s->capacity);
|
||||
if (i == 0)
|
||||
{
|
||||
|
@ -178,9 +178,9 @@ static void nsc_stream_initialize(NSC_CONTEXT* context, wStream* s)
|
||||
|
||||
stream_read_BYTE(s, context->nsc_stream.ColorLossLevel);
|
||||
stream_read_BYTE(s, context->nsc_stream.ChromaSubSamplingLevel);
|
||||
stream_seek(s, 2);
|
||||
Stream_Seek(s, 2);
|
||||
|
||||
context->nsc_stream.Planes = stream_get_tail(s);
|
||||
context->nsc_stream.Planes = Stream_Pointer(s);
|
||||
}
|
||||
|
||||
static void nsc_context_initialize(NSC_CONTEXT* context, wStream* s)
|
||||
|
@ -330,7 +330,7 @@ static BOOL rfx_process_message_sync(RFX_CONTEXT* context, wStream* s)
|
||||
UINT32 magic;
|
||||
|
||||
/* RFX_SYNC */
|
||||
if (stream_get_left(s) < 6)
|
||||
if (Stream_GetRemainingLength(s) < 6)
|
||||
{
|
||||
DEBUG_WARN("RfxSync packet too small");
|
||||
return FALSE;
|
||||
@ -359,7 +359,7 @@ static BOOL rfx_process_message_codec_versions(RFX_CONTEXT* context, wStream* s)
|
||||
{
|
||||
BYTE numCodecs;
|
||||
|
||||
if (stream_get_left(s) < 1)
|
||||
if (Stream_GetRemainingLength(s) < 1)
|
||||
{
|
||||
DEBUG_WARN("RfxCodecVersion packet too small");
|
||||
return FALSE;
|
||||
@ -372,7 +372,7 @@ static BOOL rfx_process_message_codec_versions(RFX_CONTEXT* context, wStream* s)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (stream_get_left(s) < 2 * numCodecs)
|
||||
if (Stream_GetRemainingLength(s) < 2 * numCodecs)
|
||||
{
|
||||
DEBUG_WARN("RfxCodecVersion packet too small for numCodecs=%d", numCodecs);
|
||||
return FALSE;
|
||||
@ -391,7 +391,7 @@ static BOOL rfx_process_message_channels(RFX_CONTEXT* context, wStream* s)
|
||||
BYTE channelId;
|
||||
BYTE numChannels;
|
||||
|
||||
if (stream_get_left(s) < 1)
|
||||
if (Stream_GetRemainingLength(s) < 1)
|
||||
{
|
||||
DEBUG_WARN("RfxMessageChannels packet too small");
|
||||
return FALSE;
|
||||
@ -408,7 +408,7 @@ static BOOL rfx_process_message_channels(RFX_CONTEXT* context, wStream* s)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if (stream_get_left(s) < numChannels * 5)
|
||||
if (Stream_GetRemainingLength(s) < numChannels * 5)
|
||||
{
|
||||
DEBUG_WARN("RfxMessageChannels packet too small for numChannels=%d", numChannels);
|
||||
return FALSE;
|
||||
@ -420,7 +420,7 @@ static BOOL rfx_process_message_channels(RFX_CONTEXT* context, wStream* s)
|
||||
stream_read_UINT16(s, context->height); /* height (2 bytes) */
|
||||
|
||||
/* Now, only the first monitor can be used, therefore the other channels will be ignored. */
|
||||
stream_seek(s, 5 * (numChannels - 1));
|
||||
Stream_Seek(s, 5 * (numChannels - 1));
|
||||
|
||||
DEBUG_RFX("numChannels %d id %d, %dx%d.",
|
||||
numChannels, channelId, context->width, context->height);
|
||||
@ -433,7 +433,7 @@ static BOOL rfx_process_message_context(RFX_CONTEXT* context, wStream* s)
|
||||
UINT16 tileSize;
|
||||
UINT16 properties;
|
||||
|
||||
if (stream_get_left(s) < 5)
|
||||
if (Stream_GetRemainingLength(s) < 5)
|
||||
{
|
||||
DEBUG_WARN("RfxMessageContext packet too small");
|
||||
return FALSE;
|
||||
@ -477,7 +477,7 @@ static BOOL rfx_process_message_frame_begin(RFX_CONTEXT* context, RFX_MESSAGE* m
|
||||
UINT32 frameIdx;
|
||||
UINT16 numRegions;
|
||||
|
||||
if (stream_get_left(s) < 6)
|
||||
if (Stream_GetRemainingLength(s) < 6)
|
||||
{
|
||||
DEBUG_WARN("RfxMessageFrameBegin packet too small");
|
||||
return FALSE;
|
||||
@ -498,13 +498,13 @@ static BOOL rfx_process_message_region(RFX_CONTEXT* context, RFX_MESSAGE* messag
|
||||
{
|
||||
int i;
|
||||
|
||||
if (stream_get_left(s) < 3)
|
||||
if (Stream_GetRemainingLength(s) < 3)
|
||||
{
|
||||
DEBUG_WARN("RfxMessageRegion packet too small");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
stream_seek_BYTE(s); /* regionFlags (1 byte) */
|
||||
Stream_Seek_BYTE(s); /* regionFlags (1 byte) */
|
||||
stream_read_UINT16(s, message->num_rects); /* numRects (2 bytes) */
|
||||
|
||||
if (message->num_rects < 1)
|
||||
@ -513,7 +513,7 @@ static BOOL rfx_process_message_region(RFX_CONTEXT* context, RFX_MESSAGE* messag
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if (stream_get_left(s) < 8 * message->num_rects)
|
||||
if (Stream_GetRemainingLength(s) < 8 * message->num_rects)
|
||||
{
|
||||
DEBUG_WARN("RfxMessageRegion packet too small for num_rects=%d", message->num_rects);
|
||||
return FALSE;
|
||||
@ -547,7 +547,7 @@ static BOOL rfx_process_message_tile(RFX_CONTEXT* context, RFX_TILE* tile, wStre
|
||||
UINT16 xIdx, yIdx;
|
||||
UINT16 YLen, CbLen, CrLen;
|
||||
|
||||
if (stream_get_left(s) < 13)
|
||||
if (Stream_GetRemainingLength(s) < 13)
|
||||
{
|
||||
DEBUG_WARN("RfxMessageTile packet too small");
|
||||
return FALSE;
|
||||
@ -603,7 +603,7 @@ static BOOL rfx_process_message_tileset(RFX_CONTEXT* context, RFX_MESSAGE* messa
|
||||
PTP_WORK* work_objects = NULL;
|
||||
RFX_TILE_WORK_PARAM* params = NULL;
|
||||
|
||||
if (stream_get_left(s) < 14)
|
||||
if (Stream_GetRemainingLength(s) < 14)
|
||||
{
|
||||
DEBUG_WARN("RfxMessageTileSet packet too small");
|
||||
return FALSE;
|
||||
@ -617,11 +617,11 @@ static BOOL rfx_process_message_tileset(RFX_CONTEXT* context, RFX_MESSAGE* messa
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
stream_seek_UINT16(s); /* idx (2 bytes), must be set to 0x0000 */
|
||||
stream_seek_UINT16(s); /* properties (2 bytes) */
|
||||
Stream_Seek_UINT16(s); /* idx (2 bytes), must be set to 0x0000 */
|
||||
Stream_Seek_UINT16(s); /* properties (2 bytes) */
|
||||
|
||||
stream_read_BYTE(s, context->num_quants); /* numQuant (1 byte) */
|
||||
stream_seek_BYTE(s); /* tileSize (1 byte), must be set to 0x40 */
|
||||
Stream_Seek_BYTE(s); /* tileSize (1 byte), must be set to 0x40 */
|
||||
|
||||
if (context->num_quants < 1)
|
||||
{
|
||||
@ -646,7 +646,7 @@ static BOOL rfx_process_message_tileset(RFX_CONTEXT* context, RFX_MESSAGE* messa
|
||||
quants = context->quants;
|
||||
|
||||
/* quantVals */
|
||||
if (stream_get_left(s) < context->num_quants * 5)
|
||||
if (Stream_GetRemainingLength(s) < context->num_quants * 5)
|
||||
{
|
||||
DEBUG_WARN("RfxMessageTileSet packet too small for num_quants=%d", context->num_quants);
|
||||
return FALSE;
|
||||
@ -692,7 +692,7 @@ static BOOL rfx_process_message_tileset(RFX_CONTEXT* context, RFX_MESSAGE* messa
|
||||
for (i = 0; i < message->num_tiles; i++)
|
||||
{
|
||||
/* RFX_TILE */
|
||||
if (stream_get_left(s) < 6)
|
||||
if (Stream_GetRemainingLength(s) < 6)
|
||||
{
|
||||
DEBUG_WARN("RfxMessageTileSet packet too small to read tile %d/%d", i, message->num_tiles);
|
||||
return FALSE;
|
||||
@ -701,13 +701,13 @@ static BOOL rfx_process_message_tileset(RFX_CONTEXT* context, RFX_MESSAGE* messa
|
||||
stream_read_UINT16(s, blockType); /* blockType (2 bytes), must be set to CBT_TILE (0xCAC3) */
|
||||
stream_read_UINT32(s, blockLen); /* blockLen (4 bytes) */
|
||||
|
||||
if (stream_get_left(s) < blockLen - 6)
|
||||
if (Stream_GetRemainingLength(s) < blockLen - 6)
|
||||
{
|
||||
DEBUG_WARN("RfxMessageTileSet not enough bytes to read tile %d/%d with blocklen=%d", i, message->num_tiles, blockLen);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
pos = stream_get_pos(s) - 6 + blockLen;
|
||||
pos = Stream_GetPosition(s) - 6 + blockLen;
|
||||
|
||||
if (blockType != CBT_TILE)
|
||||
{
|
||||
@ -733,7 +733,7 @@ static BOOL rfx_process_message_tileset(RFX_CONTEXT* context, RFX_MESSAGE* messa
|
||||
rfx_process_message_tile(context, message->tiles[i], s);
|
||||
}
|
||||
|
||||
stream_set_pos(s, pos);
|
||||
Stream_SetPosition(s, pos);
|
||||
}
|
||||
|
||||
if (context->priv->UseThreads)
|
||||
@ -761,7 +761,7 @@ RFX_MESSAGE* rfx_process_message(RFX_CONTEXT* context, BYTE* data, UINT32 length
|
||||
s = stream_new(0);
|
||||
stream_attach(s, data, length);
|
||||
|
||||
while (stream_get_left(s) > 6)
|
||||
while (Stream_GetRemainingLength(s) > 6)
|
||||
{
|
||||
/* RFX_BLOCKT */
|
||||
stream_read_UINT16(s, blockType); /* blockType (2 bytes) */
|
||||
@ -775,14 +775,14 @@ RFX_MESSAGE* rfx_process_message(RFX_CONTEXT* context, BYTE* data, UINT32 length
|
||||
break;
|
||||
}
|
||||
|
||||
if (stream_get_left(s) < blockLen - 6)
|
||||
if (Stream_GetRemainingLength(s) < blockLen - 6)
|
||||
{
|
||||
DEBUG_WARN("rfx_process_message: packet too small for blocklen=%d", blockLen);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
pos = stream_get_pos(s) - 6 + blockLen;
|
||||
pos = Stream_GetPosition(s) - 6 + blockLen;
|
||||
|
||||
if (blockType >= WBT_CONTEXT && blockType <= WBT_EXTENSION)
|
||||
{
|
||||
@ -835,7 +835,7 @@ RFX_MESSAGE* rfx_process_message(RFX_CONTEXT* context, BYTE* data, UINT32 length
|
||||
break;
|
||||
}
|
||||
|
||||
stream_set_pos(s, pos);
|
||||
Stream_SetPosition(s, pos);
|
||||
}
|
||||
|
||||
stream_detach(s);
|
||||
@ -1005,17 +1005,17 @@ static void rfx_compose_message_tile(RFX_CONTEXT* context, wStream* s,
|
||||
int start_pos, end_pos;
|
||||
|
||||
stream_check_size(s, 19);
|
||||
start_pos = stream_get_pos(s);
|
||||
start_pos = Stream_GetPosition(s);
|
||||
|
||||
stream_write_UINT16(s, CBT_TILE); /* BlockT.blockType */
|
||||
stream_seek_UINT32(s); /* set BlockT.blockLen later */
|
||||
Stream_Seek_UINT32(s); /* set BlockT.blockLen later */
|
||||
stream_write_BYTE(s, quantIdxY);
|
||||
stream_write_BYTE(s, quantIdxCb);
|
||||
stream_write_BYTE(s, quantIdxCr);
|
||||
stream_write_UINT16(s, xIdx);
|
||||
stream_write_UINT16(s, yIdx);
|
||||
|
||||
stream_seek(s, 6); /* YLen, CbLen, CrLen */
|
||||
Stream_Seek(s, 6); /* YLen, CbLen, CrLen */
|
||||
|
||||
rfx_encode_rgb(context, tile_data, tile_width, tile_height, rowstride,
|
||||
quantVals + quantIdxY * 10, quantVals + quantIdxCb * 10, quantVals + quantIdxCr * 10,
|
||||
@ -1024,16 +1024,16 @@ static void rfx_compose_message_tile(RFX_CONTEXT* context, wStream* s,
|
||||
DEBUG_RFX("xIdx=%d yIdx=%d width=%d height=%d YLen=%d CbLen=%d CrLen=%d",
|
||||
xIdx, yIdx, tile_width, tile_height, YLen, CbLen, CrLen);
|
||||
|
||||
end_pos = stream_get_pos(s);
|
||||
end_pos = Stream_GetPosition(s);
|
||||
|
||||
stream_set_pos(s, start_pos + 2);
|
||||
Stream_SetPosition(s, start_pos + 2);
|
||||
stream_write_UINT32(s, 19 + YLen + CbLen + CrLen); /* BlockT.blockLen */
|
||||
stream_set_pos(s, start_pos + 13);
|
||||
Stream_SetPosition(s, start_pos + 13);
|
||||
stream_write_UINT16(s, YLen);
|
||||
stream_write_UINT16(s, CbLen);
|
||||
stream_write_UINT16(s, CrLen);
|
||||
|
||||
stream_set_pos(s, end_pos);
|
||||
Stream_SetPosition(s, end_pos);
|
||||
}
|
||||
|
||||
static void rfx_compose_message_tileset(RFX_CONTEXT* context, wStream* s,
|
||||
@ -1078,10 +1078,10 @@ static void rfx_compose_message_tileset(RFX_CONTEXT* context, wStream* s,
|
||||
|
||||
size = 22 + numQuants * 5;
|
||||
stream_check_size(s, size);
|
||||
start_pos = stream_get_pos(s);
|
||||
start_pos = Stream_GetPosition(s);
|
||||
|
||||
stream_write_UINT16(s, WBT_EXTENSION); /* CodecChannelT.blockType */
|
||||
stream_seek_UINT32(s); /* set CodecChannelT.blockLen later */
|
||||
Stream_Seek_UINT32(s); /* set CodecChannelT.blockLen later */
|
||||
stream_write_BYTE(s, 1); /* CodecChannelT.codecId */
|
||||
stream_write_BYTE(s, 0); /* CodecChannelT.channelId */
|
||||
stream_write_UINT16(s, CBT_TILESET); /* subtype */
|
||||
@ -1090,7 +1090,7 @@ static void rfx_compose_message_tileset(RFX_CONTEXT* context, wStream* s,
|
||||
stream_write_BYTE(s, numQuants); /* numQuants */
|
||||
stream_write_BYTE(s, 0x40); /* tileSize */
|
||||
stream_write_UINT16(s, numTiles); /* numTiles */
|
||||
stream_seek_UINT32(s); /* set tilesDataSize later */
|
||||
Stream_Seek_UINT32(s); /* set tilesDataSize later */
|
||||
|
||||
quantValsPtr = quantVals;
|
||||
for (i = 0; i < numQuants * 5; i++)
|
||||
@ -1101,7 +1101,7 @@ static void rfx_compose_message_tileset(RFX_CONTEXT* context, wStream* s,
|
||||
|
||||
DEBUG_RFX("width:%d height:%d rowstride:%d", width, height, rowstride);
|
||||
|
||||
end_pos = stream_get_pos(s);
|
||||
end_pos = Stream_GetPosition(s);
|
||||
for (yIdx = 0; yIdx < numTilesY; yIdx++)
|
||||
{
|
||||
for (xIdx = 0; xIdx < numTilesX; xIdx++)
|
||||
@ -1113,16 +1113,16 @@ static void rfx_compose_message_tileset(RFX_CONTEXT* context, wStream* s,
|
||||
rowstride, quantVals, quantIdxY, quantIdxCb, quantIdxCr, xIdx, yIdx);
|
||||
}
|
||||
}
|
||||
tilesDataSize = stream_get_pos(s) - end_pos;
|
||||
tilesDataSize = Stream_GetPosition(s) - end_pos;
|
||||
size += tilesDataSize;
|
||||
end_pos = stream_get_pos(s);
|
||||
end_pos = Stream_GetPosition(s);
|
||||
|
||||
stream_set_pos(s, start_pos + 2);
|
||||
Stream_SetPosition(s, start_pos + 2);
|
||||
stream_write_UINT32(s, size); /* CodecChannelT.blockLen */
|
||||
stream_set_pos(s, start_pos + 18);
|
||||
Stream_SetPosition(s, start_pos + 18);
|
||||
stream_write_UINT32(s, tilesDataSize);
|
||||
|
||||
stream_set_pos(s, end_pos);
|
||||
Stream_SetPosition(s, end_pos);
|
||||
}
|
||||
|
||||
static void rfx_compose_message_frame_end(RFX_CONTEXT* context, wStream* s)
|
||||
|
@ -165,24 +165,24 @@ BOOL rfx_decode_rgb(RFX_CONTEXT* context, wStream* data_in,
|
||||
|
||||
params[0].context = context;
|
||||
params[0].quantization_values = y_quants;
|
||||
params[0].buffer = stream_get_tail(data_in);
|
||||
params[0].buffer = Stream_Pointer(data_in);
|
||||
params[0].capacity = y_size;
|
||||
params[0].buffer = pSrcDst[0];
|
||||
stream_seek(data_in, y_size);
|
||||
Stream_Seek(data_in, y_size);
|
||||
|
||||
params[1].context = context;
|
||||
params[1].quantization_values = cb_quants;
|
||||
params[1].buffer = stream_get_tail(data_in);
|
||||
params[1].buffer = Stream_Pointer(data_in);
|
||||
params[1].capacity = cb_size;
|
||||
params[1].buffer = pSrcDst[1];
|
||||
stream_seek(data_in, cb_size);
|
||||
Stream_Seek(data_in, cb_size);
|
||||
|
||||
params[2].context = context;
|
||||
params[2].quantization_values = cr_quants;
|
||||
params[2].buffer = stream_get_tail(data_in);
|
||||
params[2].buffer = Stream_Pointer(data_in);
|
||||
params[2].capacity = cr_size;
|
||||
params[2].buffer = pSrcDst[2];
|
||||
stream_seek(data_in, cr_size);
|
||||
Stream_Seek(data_in, cr_size);
|
||||
|
||||
work_objects[0] = CreateThreadpoolWork((PTP_WORK_CALLBACK) rfx_decode_component_work_callback,
|
||||
(void*) ¶ms[0], &context->priv->ThreadPoolEnv);
|
||||
@ -202,20 +202,20 @@ BOOL rfx_decode_rgb(RFX_CONTEXT* context, wStream* data_in,
|
||||
else
|
||||
#endif
|
||||
{
|
||||
if (stream_get_left(data_in) < y_size + cb_size + cr_size)
|
||||
if (Stream_GetRemainingLength(data_in) < y_size + cb_size + cr_size)
|
||||
{
|
||||
DEBUG_WARN("rfx_decode_rgb: packet too small for y_size+cb_size+cr_size");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
rfx_decode_component(context, y_quants, stream_get_tail(data_in), y_size, pSrcDst[0]); /* YData */
|
||||
stream_seek(data_in, y_size);
|
||||
rfx_decode_component(context, y_quants, Stream_Pointer(data_in), y_size, pSrcDst[0]); /* YData */
|
||||
Stream_Seek(data_in, y_size);
|
||||
|
||||
rfx_decode_component(context, cb_quants, stream_get_tail(data_in), cb_size, pSrcDst[1]); /* CbData */
|
||||
stream_seek(data_in, cb_size);
|
||||
rfx_decode_component(context, cb_quants, Stream_Pointer(data_in), cb_size, pSrcDst[1]); /* CbData */
|
||||
Stream_Seek(data_in, cb_size);
|
||||
|
||||
rfx_decode_component(context, cr_quants, stream_get_tail(data_in), cr_size, pSrcDst[2]); /* CrData */
|
||||
stream_seek(data_in, cr_size);
|
||||
rfx_decode_component(context, cr_quants, Stream_Pointer(data_in), cr_size, pSrcDst[2]); /* CrData */
|
||||
Stream_Seek(data_in, cr_size);
|
||||
}
|
||||
|
||||
prims->yCbCrToRGB_16s16s_P3P3((const INT16**) pSrcDst, 64 * sizeof(INT16),
|
||||
|
@ -245,18 +245,18 @@ void rfx_encode_rgb(RFX_CONTEXT* context, const BYTE* rgb_data, int width, int h
|
||||
stream_check_size(data_out, 4096);
|
||||
|
||||
rfx_encode_component(context, y_quants, pSrcDst[0],
|
||||
stream_get_tail(data_out), stream_get_left(data_out), y_size);
|
||||
stream_seek(data_out, *y_size);
|
||||
Stream_Pointer(data_out), Stream_GetRemainingLength(data_out), y_size);
|
||||
Stream_Seek(data_out, *y_size);
|
||||
|
||||
stream_check_size(data_out, 4096);
|
||||
rfx_encode_component(context, cb_quants, pSrcDst[1],
|
||||
stream_get_tail(data_out), stream_get_left(data_out), cb_size);
|
||||
stream_seek(data_out, *cb_size);
|
||||
Stream_Pointer(data_out), Stream_GetRemainingLength(data_out), cb_size);
|
||||
Stream_Seek(data_out, *cb_size);
|
||||
|
||||
stream_check_size(data_out, 4096);
|
||||
rfx_encode_component(context, cr_quants, pSrcDst[2],
|
||||
stream_get_tail(data_out), stream_get_left(data_out), cr_size);
|
||||
stream_seek(data_out, *cr_size);
|
||||
Stream_Pointer(data_out), Stream_GetRemainingLength(data_out), cr_size);
|
||||
Stream_Seek(data_out, *cr_size);
|
||||
|
||||
PROFILER_EXIT(context->priv->prof_rfx_encode_rgb);
|
||||
|
||||
|
@ -70,7 +70,7 @@ BOOL rdp_recv_client_synchronize_pdu(rdpRdp* rdp, wStream* s)
|
||||
|
||||
rdp->finalize_sc_pdus |= FINALIZE_SC_SYNCHRONIZE_PDU;
|
||||
|
||||
if (stream_get_left(s) < 4)
|
||||
if (Stream_GetRemainingLength(s) < 4)
|
||||
return FALSE;
|
||||
|
||||
stream_read_UINT16(s, messageType); /* messageType (2 bytes) */
|
||||
@ -79,7 +79,7 @@ BOOL rdp_recv_client_synchronize_pdu(rdpRdp* rdp, wStream* s)
|
||||
return FALSE;
|
||||
|
||||
/* targetUser (2 bytes) */
|
||||
stream_seek_UINT16(s);
|
||||
Stream_Seek_UINT16(s);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
@ -97,12 +97,12 @@ BOOL rdp_send_client_synchronize_pdu(rdpRdp* rdp)
|
||||
|
||||
BOOL rdp_recv_control_pdu(wStream* s, UINT16* action)
|
||||
{
|
||||
if (stream_get_left(s) < 8)
|
||||
if (Stream_GetRemainingLength(s) < 8)
|
||||
return FALSE;
|
||||
|
||||
stream_read_UINT16(s, *action); /* action (2 bytes) */
|
||||
stream_seek_UINT16(s); /* grantId (2 bytes) */
|
||||
stream_seek_UINT32(s); /* controlId (4 bytes) */
|
||||
Stream_Seek_UINT16(s); /* grantId (2 bytes) */
|
||||
Stream_Seek_UINT32(s); /* controlId (4 bytes) */
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
@ -208,7 +208,7 @@ BOOL rdp_send_client_persistent_key_list_pdu(rdpRdp* rdp)
|
||||
|
||||
BOOL rdp_recv_client_font_list_pdu(wStream* s)
|
||||
{
|
||||
if (stream_get_left(s) < 8)
|
||||
if (Stream_GetRemainingLength(s) < 8)
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
@ -249,12 +249,12 @@ BOOL rdp_recv_server_font_map_pdu(rdpRdp* rdp, wStream* s)
|
||||
BOOL rdp_recv_client_font_map_pdu(rdpRdp* rdp, wStream* s)
|
||||
{
|
||||
rdp->finalize_sc_pdus |= FINALIZE_SC_FONT_MAP_PDU;
|
||||
if(stream_get_left(s) >= 8)
|
||||
if(Stream_GetRemainingLength(s) >= 8)
|
||||
{
|
||||
stream_seek_UINT16(s); /* numberEntries (2 bytes) */
|
||||
stream_seek_UINT16(s); /* totalNumEntries (2 bytes) */
|
||||
stream_seek_UINT16(s); /* mapFlags (2 bytes) */
|
||||
stream_seek_UINT16(s); /* entrySize (2 bytes) */
|
||||
Stream_Seek_UINT16(s); /* numberEntries (2 bytes) */
|
||||
Stream_Seek_UINT16(s); /* totalNumEntries (2 bytes) */
|
||||
Stream_Seek_UINT16(s); /* mapFlags (2 bytes) */
|
||||
Stream_Seek_UINT16(s); /* entrySize (2 bytes) */
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
@ -282,18 +282,18 @@ BOOL rdp_recv_deactivate_all(rdpRdp* rdp, wStream* s)
|
||||
* Windows XP can send short DEACTIVATE_ALL PDU that doesn't contain
|
||||
* the following fields.
|
||||
*/
|
||||
if (stream_get_left(s) > 0)
|
||||
if (Stream_GetRemainingLength(s) > 0)
|
||||
{
|
||||
do {
|
||||
if(stream_get_left(s) < 4)
|
||||
if(Stream_GetRemainingLength(s) < 4)
|
||||
break;
|
||||
stream_read_UINT32(s, rdp->settings->ShareId); /* shareId (4 bytes) */
|
||||
if(stream_get_left(s) < 2)
|
||||
if(Stream_GetRemainingLength(s) < 2)
|
||||
break;
|
||||
stream_read_UINT16(s, lengthSourceDescriptor); /* lengthSourceDescriptor (2 bytes) */
|
||||
if(stream_get_left(s) < lengthSourceDescriptor)
|
||||
if(Stream_GetRemainingLength(s) < lengthSourceDescriptor)
|
||||
break;
|
||||
stream_seek(s, lengthSourceDescriptor); /* sourceDescriptor (should be 0x00) */
|
||||
Stream_Seek(s, lengthSourceDescriptor); /* sourceDescriptor (should be 0x00) */
|
||||
} while(0);
|
||||
}
|
||||
|
||||
|
@ -171,17 +171,17 @@ BOOL rdp_read_general_capability_set(wStream* s, UINT16 length, rdpSettings* set
|
||||
}
|
||||
else
|
||||
{
|
||||
stream_seek_UINT16(s); /* osMajorType (2 bytes) */
|
||||
stream_seek_UINT16(s); /* osMinorType (2 bytes) */
|
||||
Stream_Seek_UINT16(s); /* osMajorType (2 bytes) */
|
||||
Stream_Seek_UINT16(s); /* osMinorType (2 bytes) */
|
||||
}
|
||||
|
||||
stream_seek_UINT16(s); /* protocolVersion (2 bytes) */
|
||||
stream_seek_UINT16(s); /* pad2OctetsA (2 bytes) */
|
||||
stream_seek_UINT16(s); /* generalCompressionTypes (2 bytes) */
|
||||
Stream_Seek_UINT16(s); /* protocolVersion (2 bytes) */
|
||||
Stream_Seek_UINT16(s); /* pad2OctetsA (2 bytes) */
|
||||
Stream_Seek_UINT16(s); /* generalCompressionTypes (2 bytes) */
|
||||
stream_read_UINT16(s, extraFlags); /* extraFlags (2 bytes) */
|
||||
stream_seek_UINT16(s); /* updateCapabilityFlag (2 bytes) */
|
||||
stream_seek_UINT16(s); /* remoteUnshareFlag (2 bytes) */
|
||||
stream_seek_UINT16(s); /* generalCompressionLevel (2 bytes) */
|
||||
Stream_Seek_UINT16(s); /* updateCapabilityFlag (2 bytes) */
|
||||
Stream_Seek_UINT16(s); /* remoteUnshareFlag (2 bytes) */
|
||||
Stream_Seek_UINT16(s); /* generalCompressionLevel (2 bytes) */
|
||||
stream_read_BYTE(s, refreshRectSupport); /* refreshRectSupport (1 byte) */
|
||||
stream_read_BYTE(s, suppressOutputSupport); /* suppressOutputSupport (1 byte) */
|
||||
|
||||
@ -303,18 +303,18 @@ BOOL rdp_read_bitmap_capability_set(wStream* s, UINT16 length, rdpSettings* sett
|
||||
return FALSE;
|
||||
|
||||
stream_read_UINT16(s, preferredBitsPerPixel); /* preferredBitsPerPixel (2 bytes) */
|
||||
stream_seek_UINT16(s); /* receive1BitPerPixel (2 bytes) */
|
||||
stream_seek_UINT16(s); /* receive4BitsPerPixel (2 bytes) */
|
||||
stream_seek_UINT16(s); /* receive8BitsPerPixel (2 bytes) */
|
||||
Stream_Seek_UINT16(s); /* receive1BitPerPixel (2 bytes) */
|
||||
Stream_Seek_UINT16(s); /* receive4BitsPerPixel (2 bytes) */
|
||||
Stream_Seek_UINT16(s); /* receive8BitsPerPixel (2 bytes) */
|
||||
stream_read_UINT16(s, desktopWidth); /* desktopWidth (2 bytes) */
|
||||
stream_read_UINT16(s, desktopHeight); /* desktopHeight (2 bytes) */
|
||||
stream_seek_UINT16(s); /* pad2Octets (2 bytes) */
|
||||
Stream_Seek_UINT16(s); /* pad2Octets (2 bytes) */
|
||||
stream_read_UINT16(s, desktopResizeFlag); /* desktopResizeFlag (2 bytes) */
|
||||
stream_seek_UINT16(s); /* bitmapCompressionFlag (2 bytes) */
|
||||
stream_seek_BYTE(s); /* highColorFlags (1 byte) */
|
||||
Stream_Seek_UINT16(s); /* bitmapCompressionFlag (2 bytes) */
|
||||
Stream_Seek_BYTE(s); /* highColorFlags (1 byte) */
|
||||
stream_read_BYTE(s, drawingFlags); /* drawingFlags (1 byte) */
|
||||
stream_seek_UINT16(s); /* multipleRectangleSupport (2 bytes) */
|
||||
stream_seek_UINT16(s); /* pad2OctetsB (2 bytes) */
|
||||
Stream_Seek_UINT16(s); /* multipleRectangleSupport (2 bytes) */
|
||||
Stream_Seek_UINT16(s); /* pad2OctetsB (2 bytes) */
|
||||
|
||||
if (!settings->ServerMode && (preferredBitsPerPixel != settings->ColorDepth))
|
||||
{
|
||||
@ -448,23 +448,23 @@ BOOL rdp_read_order_capability_set(wStream* s, UINT16 length, rdpSettings* setti
|
||||
if (length < 88)
|
||||
return FALSE;
|
||||
|
||||
stream_seek(s, 16); /* terminalDescriptor (16 bytes) */
|
||||
stream_seek_UINT32(s); /* pad4OctetsA (4 bytes) */
|
||||
stream_seek_UINT16(s); /* desktopSaveXGranularity (2 bytes) */
|
||||
stream_seek_UINT16(s); /* desktopSaveYGranularity (2 bytes) */
|
||||
stream_seek_UINT16(s); /* pad2OctetsA (2 bytes) */
|
||||
stream_seek_UINT16(s); /* maximumOrderLevel (2 bytes) */
|
||||
stream_seek_UINT16(s); /* numberFonts (2 bytes) */
|
||||
Stream_Seek(s, 16); /* terminalDescriptor (16 bytes) */
|
||||
Stream_Seek_UINT32(s); /* pad4OctetsA (4 bytes) */
|
||||
Stream_Seek_UINT16(s); /* desktopSaveXGranularity (2 bytes) */
|
||||
Stream_Seek_UINT16(s); /* desktopSaveYGranularity (2 bytes) */
|
||||
Stream_Seek_UINT16(s); /* pad2OctetsA (2 bytes) */
|
||||
Stream_Seek_UINT16(s); /* maximumOrderLevel (2 bytes) */
|
||||
Stream_Seek_UINT16(s); /* numberFonts (2 bytes) */
|
||||
stream_read_UINT16(s, orderFlags); /* orderFlags (2 bytes) */
|
||||
stream_read(s, orderSupport, 32); /* orderSupport (32 bytes) */
|
||||
stream_seek_UINT16(s); /* textFlags (2 bytes) */
|
||||
Stream_Seek_UINT16(s); /* textFlags (2 bytes) */
|
||||
stream_read_UINT16(s, orderSupportExFlags); /* orderSupportExFlags (2 bytes) */
|
||||
stream_seek_UINT32(s); /* pad4OctetsB (4 bytes) */
|
||||
stream_seek_UINT32(s); /* desktopSaveSize (4 bytes) */
|
||||
stream_seek_UINT16(s); /* pad2OctetsC (2 bytes) */
|
||||
stream_seek_UINT16(s); /* pad2OctetsD (2 bytes) */
|
||||
stream_seek_UINT16(s); /* textANSICodePage (2 bytes) */
|
||||
stream_seek_UINT16(s); /* pad2OctetsE (2 bytes) */
|
||||
Stream_Seek_UINT32(s); /* pad4OctetsB (4 bytes) */
|
||||
Stream_Seek_UINT32(s); /* desktopSaveSize (4 bytes) */
|
||||
Stream_Seek_UINT16(s); /* pad2OctetsC (2 bytes) */
|
||||
Stream_Seek_UINT16(s); /* pad2OctetsD (2 bytes) */
|
||||
Stream_Seek_UINT16(s); /* textANSICodePage (2 bytes) */
|
||||
Stream_Seek_UINT16(s); /* pad2OctetsE (2 bytes) */
|
||||
|
||||
for (i = 0; i < 32; i++)
|
||||
{
|
||||
@ -640,18 +640,18 @@ BOOL rdp_read_bitmap_cache_capability_set(wStream* s, UINT16 length, rdpSettings
|
||||
if (length < 40)
|
||||
return FALSE;
|
||||
|
||||
stream_seek_UINT32(s); /* pad1 (4 bytes) */
|
||||
stream_seek_UINT32(s); /* pad2 (4 bytes) */
|
||||
stream_seek_UINT32(s); /* pad3 (4 bytes) */
|
||||
stream_seek_UINT32(s); /* pad4 (4 bytes) */
|
||||
stream_seek_UINT32(s); /* pad5 (4 bytes) */
|
||||
stream_seek_UINT32(s); /* pad6 (4 bytes) */
|
||||
stream_seek_UINT16(s); /* Cache0Entries (2 bytes) */
|
||||
stream_seek_UINT16(s); /* Cache0MaximumCellSize (2 bytes) */
|
||||
stream_seek_UINT16(s); /* Cache1Entries (2 bytes) */
|
||||
stream_seek_UINT16(s); /* Cache1MaximumCellSize (2 bytes) */
|
||||
stream_seek_UINT16(s); /* Cache2Entries (2 bytes) */
|
||||
stream_seek_UINT16(s); /* Cache2MaximumCellSize (2 bytes) */
|
||||
Stream_Seek_UINT32(s); /* pad1 (4 bytes) */
|
||||
Stream_Seek_UINT32(s); /* pad2 (4 bytes) */
|
||||
Stream_Seek_UINT32(s); /* pad3 (4 bytes) */
|
||||
Stream_Seek_UINT32(s); /* pad4 (4 bytes) */
|
||||
Stream_Seek_UINT32(s); /* pad5 (4 bytes) */
|
||||
Stream_Seek_UINT32(s); /* pad6 (4 bytes) */
|
||||
Stream_Seek_UINT16(s); /* Cache0Entries (2 bytes) */
|
||||
Stream_Seek_UINT16(s); /* Cache0MaximumCellSize (2 bytes) */
|
||||
Stream_Seek_UINT16(s); /* Cache1Entries (2 bytes) */
|
||||
Stream_Seek_UINT16(s); /* Cache1MaximumCellSize (2 bytes) */
|
||||
Stream_Seek_UINT16(s); /* Cache2Entries (2 bytes) */
|
||||
Stream_Seek_UINT16(s); /* Cache2MaximumCellSize (2 bytes) */
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
@ -753,10 +753,10 @@ BOOL rdp_read_control_capability_set(wStream* s, UINT16 length, rdpSettings* set
|
||||
if (length < 12)
|
||||
return FALSE;
|
||||
|
||||
stream_seek_UINT16(s); /* controlFlags (2 bytes) */
|
||||
stream_seek_UINT16(s); /* remoteDetachFlag (2 bytes) */
|
||||
stream_seek_UINT16(s); /* controlInterest (2 bytes) */
|
||||
stream_seek_UINT16(s); /* detachInterest (2 bytes) */
|
||||
Stream_Seek_UINT16(s); /* controlFlags (2 bytes) */
|
||||
Stream_Seek_UINT16(s); /* remoteDetachFlag (2 bytes) */
|
||||
Stream_Seek_UINT16(s); /* controlInterest (2 bytes) */
|
||||
Stream_Seek_UINT16(s); /* detachInterest (2 bytes) */
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
@ -820,10 +820,10 @@ BOOL rdp_read_window_activation_capability_set(wStream* s, UINT16 length, rdpSet
|
||||
if (length < 12)
|
||||
return FALSE;
|
||||
|
||||
stream_seek_UINT16(s); /* helpKeyFlag (2 bytes) */
|
||||
stream_seek_UINT16(s); /* helpKeyIndexFlag (2 bytes) */
|
||||
stream_seek_UINT16(s); /* helpExtendedKeyFlag (2 bytes) */
|
||||
stream_seek_UINT16(s); /* windowManagerKeyFlag (2 bytes) */
|
||||
Stream_Seek_UINT16(s); /* helpKeyFlag (2 bytes) */
|
||||
Stream_Seek_UINT16(s); /* helpKeyIndexFlag (2 bytes) */
|
||||
Stream_Seek_UINT16(s); /* helpExtendedKeyFlag (2 bytes) */
|
||||
Stream_Seek_UINT16(s); /* windowManagerKeyFlag (2 bytes) */
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
@ -967,8 +967,8 @@ BOOL rdp_read_share_capability_set(wStream* s, UINT16 length, rdpSettings* setti
|
||||
if (length < 8)
|
||||
return FALSE;
|
||||
|
||||
stream_seek_UINT16(s); /* nodeId (2 bytes) */
|
||||
stream_seek_UINT16(s); /* pad2Octets (2 bytes) */
|
||||
Stream_Seek_UINT16(s); /* nodeId (2 bytes) */
|
||||
Stream_Seek_UINT16(s); /* pad2Octets (2 bytes) */
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
@ -1027,8 +1027,8 @@ BOOL rdp_read_color_cache_capability_set(wStream* s, UINT16 length, rdpSettings*
|
||||
if (length < 8)
|
||||
return FALSE;
|
||||
|
||||
stream_seek_UINT16(s); /* colorTableCacheSize (2 bytes) */
|
||||
stream_seek_UINT16(s); /* pad2Octets (2 bytes) */
|
||||
Stream_Seek_UINT16(s); /* colorTableCacheSize (2 bytes) */
|
||||
Stream_Seek_UINT16(s); /* pad2Octets (2 bytes) */
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
@ -1087,7 +1087,7 @@ BOOL rdp_read_sound_capability_set(wStream* s, UINT16 length, rdpSettings* setti
|
||||
return FALSE;
|
||||
|
||||
stream_read_UINT16(s, soundFlags); /* soundFlags (2 bytes) */
|
||||
stream_seek_UINT16(s); /* pad2OctetsA (2 bytes) */
|
||||
Stream_Seek_UINT16(s); /* pad2OctetsA (2 bytes) */
|
||||
|
||||
settings->SoundBeepsEnabled = (soundFlags & SOUND_BEEPS_FLAG) ? TRUE : FALSE;
|
||||
|
||||
@ -1151,7 +1151,7 @@ BOOL rdp_read_input_capability_set(wStream* s, UINT16 length, rdpSettings* setti
|
||||
return FALSE;
|
||||
|
||||
stream_read_UINT16(s, inputFlags); /* inputFlags (2 bytes) */
|
||||
stream_seek_UINT16(s); /* pad2OctetsA (2 bytes) */
|
||||
Stream_Seek_UINT16(s); /* pad2OctetsA (2 bytes) */
|
||||
|
||||
if (settings->ServerMode)
|
||||
{
|
||||
@ -1162,13 +1162,13 @@ BOOL rdp_read_input_capability_set(wStream* s, UINT16 length, rdpSettings* setti
|
||||
}
|
||||
else
|
||||
{
|
||||
stream_seek_UINT32(s); /* keyboardLayout (4 bytes) */
|
||||
stream_seek_UINT32(s); /* keyboardType (4 bytes) */
|
||||
stream_seek_UINT32(s); /* keyboardSubType (4 bytes) */
|
||||
stream_seek_UINT32(s); /* keyboardFunctionKeys (4 bytes) */
|
||||
Stream_Seek_UINT32(s); /* keyboardLayout (4 bytes) */
|
||||
Stream_Seek_UINT32(s); /* keyboardType (4 bytes) */
|
||||
Stream_Seek_UINT32(s); /* keyboardSubType (4 bytes) */
|
||||
Stream_Seek_UINT32(s); /* keyboardFunctionKeys (4 bytes) */
|
||||
}
|
||||
|
||||
stream_seek(s, 64); /* imeFileName (64 bytes) */
|
||||
Stream_Seek(s, 64); /* imeFileName (64 bytes) */
|
||||
|
||||
if (settings->ServerMode != TRUE)
|
||||
{
|
||||
@ -1242,7 +1242,7 @@ BOOL rdp_print_input_capability_set(wStream* s, UINT16 length)
|
||||
stream_read_UINT32(s, keyboardType); /* keyboardType (4 bytes) */
|
||||
stream_read_UINT32(s, keyboardSubType); /* keyboardSubType (4 bytes) */
|
||||
stream_read_UINT32(s, keyboardFunctionKey); /* keyboardFunctionKeys (4 bytes) */
|
||||
stream_seek(s, 64); /* imeFileName (64 bytes) */
|
||||
Stream_Seek(s, 64); /* imeFileName (64 bytes) */
|
||||
|
||||
fprintf(stderr, "\tinputFlags: 0x%04X\n", inputFlags);
|
||||
fprintf(stderr, "\tpad2OctetsA: 0x%04X\n", pad2OctetsA);
|
||||
@ -1265,10 +1265,10 @@ BOOL rdp_print_input_capability_set(wStream* s, UINT16 length)
|
||||
BOOL rdp_read_font_capability_set(wStream* s, UINT16 length, rdpSettings* settings)
|
||||
{
|
||||
if (length > 4)
|
||||
stream_seek_UINT16(s); /* fontSupportFlags (2 bytes) */
|
||||
Stream_Seek_UINT16(s); /* fontSupportFlags (2 bytes) */
|
||||
|
||||
if (length > 6)
|
||||
stream_seek_UINT16(s); /* pad2Octets (2 bytes) */
|
||||
Stream_Seek_UINT16(s); /* pad2Octets (2 bytes) */
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
@ -1324,7 +1324,7 @@ BOOL rdp_read_brush_capability_set(wStream* s, UINT16 length, rdpSettings* setti
|
||||
if (length < 8)
|
||||
return FALSE;
|
||||
|
||||
stream_seek_UINT32(s); /* brushSupportLevel (4 bytes) */
|
||||
Stream_Seek_UINT32(s); /* brushSupportLevel (4 bytes) */
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
@ -1400,10 +1400,10 @@ BOOL rdp_read_glyph_cache_capability_set(wStream* s, UINT16 length, rdpSettings*
|
||||
if (length < 52)
|
||||
return FALSE;
|
||||
|
||||
stream_seek(s, 40); /* glyphCache (40 bytes) */
|
||||
stream_seek_UINT32(s); /* fragCache (4 bytes) */
|
||||
Stream_Seek(s, 40); /* glyphCache (40 bytes) */
|
||||
Stream_Seek_UINT32(s); /* fragCache (4 bytes) */
|
||||
stream_read_UINT16(s, glyphSupportLevel); /* glyphSupportLevel (2 bytes) */
|
||||
stream_seek_UINT16(s); /* pad2Octets (2 bytes) */
|
||||
Stream_Seek_UINT16(s); /* pad2Octets (2 bytes) */
|
||||
|
||||
settings->GlyphSupportLevel = glyphSupportLevel;
|
||||
|
||||
@ -1575,8 +1575,8 @@ BOOL rdp_read_bitmap_cache_host_support_capability_set(wStream* s, UINT16 length
|
||||
return FALSE;
|
||||
|
||||
stream_read_BYTE(s, cacheVersion); /* cacheVersion (1 byte) */
|
||||
stream_seek_BYTE(s); /* pad1 (1 byte) */
|
||||
stream_seek_UINT16(s); /* pad2 (2 bytes) */
|
||||
Stream_Seek_BYTE(s); /* pad1 (1 byte) */
|
||||
Stream_Seek_UINT16(s); /* pad2 (2 bytes) */
|
||||
|
||||
if (cacheVersion & BITMAP_CACHE_V2)
|
||||
settings->BitmapCachePersistEnabled = TRUE;
|
||||
@ -1667,15 +1667,15 @@ BOOL rdp_read_bitmap_cache_v2_capability_set(wStream* s, UINT16 length, rdpSetti
|
||||
if (length < 40)
|
||||
return FALSE;
|
||||
|
||||
stream_seek_UINT16(s); /* cacheFlags (2 bytes) */
|
||||
stream_seek_BYTE(s); /* pad2 (1 byte) */
|
||||
stream_seek_BYTE(s); /* numCellCaches (1 byte) */
|
||||
stream_seek(s, 4); /* bitmapCache0CellInfo (4 bytes) */
|
||||
stream_seek(s, 4); /* bitmapCache1CellInfo (4 bytes) */
|
||||
stream_seek(s, 4); /* bitmapCache2CellInfo (4 bytes) */
|
||||
stream_seek(s, 4); /* bitmapCache3CellInfo (4 bytes) */
|
||||
stream_seek(s, 4); /* bitmapCache4CellInfo (4 bytes) */
|
||||
stream_seek(s, 12); /* pad3 (12 bytes) */
|
||||
Stream_Seek_UINT16(s); /* cacheFlags (2 bytes) */
|
||||
Stream_Seek_BYTE(s); /* pad2 (1 byte) */
|
||||
Stream_Seek_BYTE(s); /* numCellCaches (1 byte) */
|
||||
Stream_Seek(s, 4); /* bitmapCache0CellInfo (4 bytes) */
|
||||
Stream_Seek(s, 4); /* bitmapCache1CellInfo (4 bytes) */
|
||||
Stream_Seek(s, 4); /* bitmapCache2CellInfo (4 bytes) */
|
||||
Stream_Seek(s, 4); /* bitmapCache3CellInfo (4 bytes) */
|
||||
Stream_Seek(s, 4); /* bitmapCache4CellInfo (4 bytes) */
|
||||
Stream_Seek(s, 12); /* pad3 (12 bytes) */
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
@ -1732,7 +1732,7 @@ BOOL rdp_print_bitmap_cache_v2_capability_set(wStream* s, UINT16 length)
|
||||
rdp_read_bitmap_cache_cell_info(s, &bitmapCacheV2CellInfo[2]); /* bitmapCache2CellInfo (4 bytes) */
|
||||
rdp_read_bitmap_cache_cell_info(s, &bitmapCacheV2CellInfo[3]); /* bitmapCache3CellInfo (4 bytes) */
|
||||
rdp_read_bitmap_cache_cell_info(s, &bitmapCacheV2CellInfo[4]); /* bitmapCache4CellInfo (4 bytes) */
|
||||
stream_seek(s, 12); /* pad3 (12 bytes) */
|
||||
Stream_Seek(s, 12); /* pad3 (12 bytes) */
|
||||
|
||||
fprintf(stderr, "\tcacheFlags: 0x%04X\n", cacheFlags);
|
||||
fprintf(stderr, "\tpad2: 0x%02X\n", pad2);
|
||||
@ -1928,11 +1928,11 @@ BOOL rdp_read_draw_gdiplus_cache_capability_set(wStream* s, UINT16 length, rdpSe
|
||||
return FALSE;
|
||||
|
||||
stream_read_UINT32(s, drawGDIPlusSupportLevel); /* drawGDIPlusSupportLevel (4 bytes) */
|
||||
stream_seek_UINT32(s); /* GdipVersion (4 bytes) */
|
||||
Stream_Seek_UINT32(s); /* GdipVersion (4 bytes) */
|
||||
stream_read_UINT32(s, drawGdiplusCacheLevel); /* drawGdiplusCacheLevel (4 bytes) */
|
||||
stream_seek(s, 10); /* GdipCacheEntries (10 bytes) */
|
||||
stream_seek(s, 8); /* GdipCacheChunkSize (8 bytes) */
|
||||
stream_seek(s, 6); /* GdipImageCacheProperties (6 bytes) */
|
||||
Stream_Seek(s, 10); /* GdipCacheEntries (10 bytes) */
|
||||
Stream_Seek(s, 8); /* GdipCacheChunkSize (8 bytes) */
|
||||
Stream_Seek(s, 6); /* GdipImageCacheProperties (6 bytes) */
|
||||
|
||||
if (drawGDIPlusSupportLevel & DRAW_GDIPLUS_SUPPORTED)
|
||||
settings->DrawGdiPlusEnabled = TRUE;
|
||||
@ -1985,9 +1985,9 @@ BOOL rdp_print_draw_gdiplus_cache_capability_set(wStream* s, UINT16 length)
|
||||
stream_read_UINT32(s, drawGdiPlusSupportLevel); /* drawGdiPlusSupportLevel (4 bytes) */
|
||||
stream_read_UINT32(s, GdipVersion); /* GdipVersion (4 bytes) */
|
||||
stream_read_UINT32(s, drawGdiplusCacheLevel); /* drawGdiPlusCacheLevel (4 bytes) */
|
||||
stream_seek(s, 10); /* GdipCacheEntries (10 bytes) */
|
||||
stream_seek(s, 8); /* GdipCacheChunkSize (8 bytes) */
|
||||
stream_seek(s, 6); /* GdipImageCacheProperties (6 bytes) */
|
||||
Stream_Seek(s, 10); /* GdipCacheEntries (10 bytes) */
|
||||
Stream_Seek(s, 8); /* GdipCacheChunkSize (8 bytes) */
|
||||
Stream_Seek(s, 6); /* GdipImageCacheProperties (6 bytes) */
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
@ -2073,9 +2073,9 @@ BOOL rdp_read_window_list_capability_set(wStream* s, UINT16 length, rdpSettings*
|
||||
if (length < 11)
|
||||
return FALSE;
|
||||
|
||||
stream_seek_UINT32(s); /* wndSupportLevel (4 bytes) */
|
||||
stream_seek_BYTE(s); /* numIconCaches (1 byte) */
|
||||
stream_seek_UINT16(s); /* numIconCacheEntries (2 bytes) */
|
||||
Stream_Seek_UINT32(s); /* wndSupportLevel (4 bytes) */
|
||||
Stream_Seek_BYTE(s); /* numIconCaches (1 byte) */
|
||||
Stream_Seek_UINT16(s); /* numIconCacheEntries (2 bytes) */
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
@ -2138,7 +2138,7 @@ BOOL rdp_read_desktop_composition_capability_set(wStream* s, UINT16 length, rdpS
|
||||
if (length < 6)
|
||||
return FALSE;
|
||||
|
||||
stream_seek_UINT16(s); /* compDeskSupportLevel (2 bytes) */
|
||||
Stream_Seek_UINT16(s); /* compDeskSupportLevel (2 bytes) */
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
@ -2191,10 +2191,12 @@ BOOL rdp_print_desktop_composition_capability_set(wStream* s, UINT16 length)
|
||||
BOOL rdp_read_multifragment_update_capability_set(wStream* s, UINT16 length, rdpSettings* settings)
|
||||
{
|
||||
UINT32 multifragMaxRequestSize;
|
||||
|
||||
if (length < 8)
|
||||
return FALSE;
|
||||
|
||||
stream_read_UINT32(s, multifragMaxRequestSize); /* MaxRequestSize (4 bytes) */
|
||||
|
||||
if (settings->MultifragMaxRequestSize < multifragMaxRequestSize)
|
||||
settings->MultifragMaxRequestSize = multifragMaxRequestSize;
|
||||
|
||||
@ -2248,7 +2250,7 @@ BOOL rdp_read_large_pointer_capability_set(wStream* s, UINT16 length, rdpSetting
|
||||
if (length < 6)
|
||||
return FALSE;
|
||||
|
||||
stream_seek_UINT16(s); /* largePointerSupportFlags (2 bytes) */
|
||||
Stream_Seek_UINT16(s); /* largePointerSupportFlags (2 bytes) */
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
@ -2303,8 +2305,8 @@ BOOL rdp_read_surface_commands_capability_set(wStream* s, UINT16 length, rdpSett
|
||||
if (length < 12)
|
||||
return FALSE;
|
||||
|
||||
stream_seek_UINT32(s); /* cmdFlags (4 bytes) */
|
||||
stream_seek_UINT32(s); /* reserved (4 bytes) */
|
||||
Stream_Seek_UINT32(s); /* cmdFlags (4 bytes) */
|
||||
Stream_Seek_UINT32(s); /* reserved (4 bytes) */
|
||||
|
||||
settings->SurfaceCommandsEnabled = TRUE;
|
||||
|
||||
@ -2473,12 +2475,12 @@ BOOL rdp_read_bitmap_codecs_capability_set(wStream* s, UINT16 length, rdpSetting
|
||||
}
|
||||
else
|
||||
{
|
||||
stream_seek_BYTE(s); /* codecID (1 byte) */
|
||||
Stream_Seek_BYTE(s); /* codecID (1 byte) */
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
stream_seek_BYTE(s); /* codecID (1 byte) */
|
||||
Stream_Seek_BYTE(s); /* codecID (1 byte) */
|
||||
}
|
||||
|
||||
stream_read_UINT16(s, codecPropertiesLength); /* codecPropertiesLength (2 bytes) */
|
||||
@ -2491,9 +2493,9 @@ BOOL rdp_read_bitmap_codecs_capability_set(wStream* s, UINT16 length, rdpSetting
|
||||
{
|
||||
if (UuidEqual(&codecGuid, &CODEC_GUID_REMOTEFX, &rpc_status))
|
||||
{
|
||||
stream_seek_UINT32(s); /* length */
|
||||
Stream_Seek_UINT32(s); /* length */
|
||||
stream_read_UINT32(s, settings->RemoteFxCaptureFlags); /* captureFlags */
|
||||
stream_rewind(s, 8);
|
||||
Stream_Rewind(s, 8);
|
||||
|
||||
if (settings->RemoteFxCaptureFlags & CARDP_CAPS_CAPTURE_NON_CAC)
|
||||
{
|
||||
@ -2502,7 +2504,7 @@ BOOL rdp_read_bitmap_codecs_capability_set(wStream* s, UINT16 length, rdpSetting
|
||||
}
|
||||
}
|
||||
|
||||
stream_seek(s, codecPropertiesLength); /* codecProperties */
|
||||
Stream_Seek(s, codecPropertiesLength); /* codecProperties */
|
||||
remainingLength -= codecPropertiesLength;
|
||||
|
||||
bitmapCodecCount--;
|
||||
@ -2747,7 +2749,7 @@ BOOL rdp_print_bitmap_codecs_capability_set(wStream* s, UINT16 length)
|
||||
if (remainingLength < codecPropertiesLength)
|
||||
return FALSE;
|
||||
|
||||
stream_seek(s, codecPropertiesLength); /* codecProperties */
|
||||
Stream_Seek(s, codecPropertiesLength); /* codecProperties */
|
||||
remainingLength -= codecPropertiesLength;
|
||||
|
||||
bitmapCodecCount--;
|
||||
@ -2774,7 +2776,7 @@ BOOL rdp_read_frame_acknowledge_capability_set(wStream* s, UINT16 length, rdpSet
|
||||
}
|
||||
else
|
||||
{
|
||||
stream_seek_UINT32(s); /* (4 bytes) */
|
||||
Stream_Seek_UINT32(s); /* (4 bytes) */
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
@ -2867,7 +2869,7 @@ BOOL rdp_print_capability_sets(wStream* s, UINT16 numberCapabilities, BOOL recei
|
||||
|
||||
em = bm + length;
|
||||
|
||||
if (stream_get_left(s) < length - 4)
|
||||
if (Stream_GetRemainingLength(s) < length - 4)
|
||||
{
|
||||
fprintf(stderr, "error processing stream\n");
|
||||
return FALSE;
|
||||
@ -3058,7 +3060,7 @@ BOOL rdp_read_capability_sets(wStream* s, rdpSettings* settings, UINT16 numberCa
|
||||
settings->ReceivedCapabilities[type] = TRUE;
|
||||
em = bm + length;
|
||||
|
||||
if (stream_get_left(s) < length - 4)
|
||||
if (Stream_GetRemainingLength(s) < length - 4)
|
||||
{
|
||||
fprintf(stderr, "error processing stream\n");
|
||||
return FALSE;
|
||||
@ -3302,18 +3304,18 @@ BOOL rdp_recv_demand_active(rdpRdp* rdp, wStream* s)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (stream_get_left(s) < 8)
|
||||
if (Stream_GetRemainingLength(s) < 8)
|
||||
return FALSE;
|
||||
|
||||
stream_read_UINT32(s, rdp->settings->ShareId); /* shareId (4 bytes) */
|
||||
stream_read_UINT16(s, lengthSourceDescriptor); /* lengthSourceDescriptor (2 bytes) */
|
||||
stream_read_UINT16(s, lengthCombinedCapabilities); /* lengthCombinedCapabilities (2 bytes) */
|
||||
|
||||
if (!stream_skip(s, lengthSourceDescriptor) || stream_get_left(s) < 4) /* sourceDescriptor */
|
||||
if (!stream_skip(s, lengthSourceDescriptor) || Stream_GetRemainingLength(s) < 4) /* sourceDescriptor */
|
||||
return FALSE;
|
||||
|
||||
stream_read_UINT16(s, numberCapabilities); /* numberCapabilities (2 bytes) */
|
||||
stream_seek(s, 2); /* pad2Octets (2 bytes) */
|
||||
Stream_Seek(s, 2); /* pad2Octets (2 bytes) */
|
||||
|
||||
/* capabilitySets */
|
||||
if (!rdp_read_capability_sets(s, rdp->settings, numberCapabilities))
|
||||
@ -3337,11 +3339,11 @@ void rdp_write_demand_active(wStream* s, rdpSettings* settings)
|
||||
stream_write_UINT16(s, 4); /* lengthSourceDescriptor (2 bytes) */
|
||||
|
||||
stream_get_mark(s, lm);
|
||||
stream_seek_UINT16(s); /* lengthCombinedCapabilities (2 bytes) */
|
||||
Stream_Seek_UINT16(s); /* lengthCombinedCapabilities (2 bytes) */
|
||||
stream_write(s, "RDP", 4); /* sourceDescriptor */
|
||||
|
||||
stream_get_mark(s, bm);
|
||||
stream_seek_UINT16(s); /* numberCapabilities (2 bytes) */
|
||||
Stream_Seek_UINT16(s); /* numberCapabilities (2 bytes) */
|
||||
stream_write_UINT16(s, 0); /* pad2Octets (2 bytes) */
|
||||
|
||||
numberCapabilities = 14;
|
||||
@ -3376,10 +3378,10 @@ void rdp_write_demand_active(wStream* s, rdpSettings* settings)
|
||||
stream_write_UINT16(s, numberCapabilities); /* numberCapabilities (2 bytes) */
|
||||
|
||||
#ifdef WITH_DEBUG_CAPABILITIES
|
||||
stream_seek_UINT16(s);
|
||||
Stream_Seek_UINT16(s);
|
||||
rdp_print_capability_sets(s, numberCapabilities, FALSE);
|
||||
stream_set_mark(s, bm);
|
||||
stream_seek_UINT16(s);
|
||||
Stream_Seek_UINT16(s);
|
||||
#endif
|
||||
|
||||
stream_set_mark(s, em);
|
||||
@ -3421,20 +3423,20 @@ BOOL rdp_recv_confirm_active(rdpRdp* rdp, wStream* s)
|
||||
if (pduType != PDU_TYPE_CONFIRM_ACTIVE)
|
||||
return FALSE;
|
||||
|
||||
if (stream_get_left(s) < 10)
|
||||
if (Stream_GetRemainingLength(s) < 10)
|
||||
return FALSE;
|
||||
|
||||
stream_seek_UINT32(s); /* shareId (4 bytes) */
|
||||
stream_seek_UINT16(s); /* originatorId (2 bytes) */
|
||||
Stream_Seek_UINT32(s); /* shareId (4 bytes) */
|
||||
Stream_Seek_UINT16(s); /* originatorId (2 bytes) */
|
||||
stream_read_UINT16(s, lengthSourceDescriptor); /* lengthSourceDescriptor (2 bytes) */
|
||||
stream_read_UINT16(s, lengthCombinedCapabilities); /* lengthCombinedCapabilities (2 bytes) */
|
||||
|
||||
if (stream_get_left(s) < lengthSourceDescriptor + 4)
|
||||
if (Stream_GetRemainingLength(s) < lengthSourceDescriptor + 4)
|
||||
return FALSE;
|
||||
|
||||
stream_seek(s, lengthSourceDescriptor); /* sourceDescriptor */
|
||||
Stream_Seek(s, lengthSourceDescriptor); /* sourceDescriptor */
|
||||
stream_read_UINT16(s, numberCapabilities); /* numberCapabilities (2 bytes) */
|
||||
stream_seek(s, 2); /* pad2Octets (2 bytes) */
|
||||
Stream_Seek(s, 2); /* pad2Octets (2 bytes) */
|
||||
|
||||
return rdp_read_capability_sets(s, rdp->settings, numberCapabilities);
|
||||
}
|
||||
@ -3453,11 +3455,11 @@ void rdp_write_confirm_active(wStream* s, rdpSettings* settings)
|
||||
stream_write_UINT16(s, lengthSourceDescriptor);/* lengthSourceDescriptor (2 bytes) */
|
||||
|
||||
stream_get_mark(s, lm);
|
||||
stream_seek_UINT16(s); /* lengthCombinedCapabilities (2 bytes) */
|
||||
Stream_Seek_UINT16(s); /* lengthCombinedCapabilities (2 bytes) */
|
||||
stream_write(s, SOURCE_DESCRIPTOR, lengthSourceDescriptor); /* sourceDescriptor */
|
||||
|
||||
stream_get_mark(s, bm);
|
||||
stream_seek_UINT16(s); /* numberCapabilities (2 bytes) */
|
||||
Stream_Seek_UINT16(s); /* numberCapabilities (2 bytes) */
|
||||
stream_write_UINT16(s, 0); /* pad2Octets (2 bytes) */
|
||||
|
||||
/* Capability Sets */
|
||||
@ -3561,10 +3563,10 @@ void rdp_write_confirm_active(wStream* s, rdpSettings* settings)
|
||||
stream_write_UINT16(s, numberCapabilities); /* numberCapabilities (2 bytes) */
|
||||
|
||||
#ifdef WITH_DEBUG_CAPABILITIES
|
||||
stream_seek_UINT16(s);
|
||||
Stream_Seek_UINT16(s);
|
||||
rdp_print_capability_sets(s, numberCapabilities, FALSE);
|
||||
stream_set_mark(s, bm);
|
||||
stream_seek_UINT16(s);
|
||||
Stream_Seek_UINT16(s);
|
||||
#endif
|
||||
|
||||
stream_set_mark(s, em);
|
||||
|
@ -232,7 +232,7 @@ BOOL certificate_read_x509_certificate(rdpCertBlob* cert, rdpCertInfo* info)
|
||||
/* skip zero padding, if any */
|
||||
do
|
||||
{
|
||||
if(stream_get_left(s) < 1)
|
||||
if(Stream_GetRemainingLength(s) < 1)
|
||||
goto error1;
|
||||
stream_peek_BYTE(s, padding);
|
||||
|
||||
@ -246,7 +246,7 @@ BOOL certificate_read_x509_certificate(rdpCertBlob* cert, rdpCertInfo* info)
|
||||
while (padding == 0);
|
||||
error++;
|
||||
|
||||
if(stream_get_left(s) < modulus_length)
|
||||
if(Stream_GetRemainingLength(s) < modulus_length)
|
||||
goto error1;
|
||||
info->ModulusLength = modulus_length;
|
||||
info->Modulus = (BYTE*) malloc(info->ModulusLength);
|
||||
@ -256,7 +256,7 @@ BOOL certificate_read_x509_certificate(rdpCertBlob* cert, rdpCertInfo* info)
|
||||
if(!ber_read_integer_length(s, &exponent_length)) /* publicExponent (INTEGER) */
|
||||
goto error2;
|
||||
error++;
|
||||
if(stream_get_left(s) < exponent_length || exponent_length > 4)
|
||||
if(Stream_GetRemainingLength(s) < exponent_length || exponent_length > 4)
|
||||
goto error2;
|
||||
stream_read(s, &info->exponent[4 - exponent_length], exponent_length);
|
||||
crypto_reverse(info->Modulus, info->ModulusLength);
|
||||
@ -325,7 +325,7 @@ static BOOL certificate_process_server_public_key(rdpCertificate* certificate, w
|
||||
UINT32 datalen;
|
||||
UINT32 modlen;
|
||||
|
||||
if(stream_get_left(s) < 20)
|
||||
if(Stream_GetRemainingLength(s) < 20)
|
||||
return FALSE;
|
||||
stream_read(s, magic, 4);
|
||||
|
||||
@ -341,13 +341,13 @@ static BOOL certificate_process_server_public_key(rdpCertificate* certificate, w
|
||||
stream_read(s, certificate->cert_info.exponent, 4);
|
||||
modlen = keylen - 8;
|
||||
|
||||
if(stream_get_left(s) < modlen + 8) // count padding
|
||||
if(Stream_GetRemainingLength(s) < modlen + 8) // count padding
|
||||
return FALSE;
|
||||
certificate->cert_info.ModulusLength = modlen;
|
||||
certificate->cert_info.Modulus = malloc(certificate->cert_info.ModulusLength);
|
||||
stream_read(s, certificate->cert_info.Modulus, certificate->cert_info.ModulusLength);
|
||||
/* 8 bytes of zero padding */
|
||||
stream_seek(s, 8);
|
||||
Stream_Seek(s, 8);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
@ -425,11 +425,11 @@ BOOL certificate_read_server_proprietary_certificate(rdpCertificate* certificate
|
||||
BYTE* sigdata;
|
||||
int sigdatalen;
|
||||
|
||||
if(stream_get_left(s) < 12)
|
||||
if(Stream_GetRemainingLength(s) < 12)
|
||||
return FALSE;
|
||||
|
||||
/* -4, because we need to include dwVersion */
|
||||
sigdata = stream_get_tail(s) - 4;
|
||||
sigdata = Stream_Pointer(s) - 4;
|
||||
stream_read_UINT32(s, dwSigAlgId);
|
||||
stream_read_UINT32(s, dwKeyAlgId);
|
||||
|
||||
@ -448,7 +448,7 @@ BOOL certificate_read_server_proprietary_certificate(rdpCertificate* certificate
|
||||
}
|
||||
|
||||
stream_read_UINT16(s, wPublicKeyBlobLen);
|
||||
if(stream_get_left(s) < wPublicKeyBlobLen)
|
||||
if(Stream_GetRemainingLength(s) < wPublicKeyBlobLen)
|
||||
return FALSE;
|
||||
|
||||
if (!certificate_process_server_public_key(certificate, s, wPublicKeyBlobLen))
|
||||
@ -457,10 +457,10 @@ BOOL certificate_read_server_proprietary_certificate(rdpCertificate* certificate
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if(stream_get_left(s) < 4)
|
||||
if(Stream_GetRemainingLength(s) < 4)
|
||||
return FALSE;
|
||||
|
||||
sigdatalen = stream_get_tail(s) - sigdata;
|
||||
sigdatalen = Stream_Pointer(s) - sigdata;
|
||||
stream_read_UINT16(s, wSignatureBlobType);
|
||||
|
||||
if (wSignatureBlobType != BB_RSA_SIGNATURE_BLOB)
|
||||
@ -470,7 +470,7 @@ BOOL certificate_read_server_proprietary_certificate(rdpCertificate* certificate
|
||||
}
|
||||
|
||||
stream_read_UINT16(s, wSignatureBlobLen);
|
||||
if(stream_get_left(s) < wSignatureBlobLen)
|
||||
if(Stream_GetRemainingLength(s) < wSignatureBlobLen)
|
||||
return FALSE;
|
||||
|
||||
if (wSignatureBlobLen != 72)
|
||||
@ -503,7 +503,7 @@ BOOL certificate_read_server_x509_certificate_chain(rdpCertificate* certificate,
|
||||
|
||||
DEBUG_CERTIFICATE("Server X.509 Certificate Chain");
|
||||
|
||||
if(stream_get_left(s) < 4)
|
||||
if(Stream_GetRemainingLength(s) < 4)
|
||||
return FALSE;
|
||||
stream_read_UINT32(s, numCertBlobs); /* numCertBlobs */
|
||||
|
||||
@ -511,10 +511,10 @@ BOOL certificate_read_server_x509_certificate_chain(rdpCertificate* certificate,
|
||||
|
||||
for (i = 0; i < (int) numCertBlobs; i++)
|
||||
{
|
||||
if(stream_get_left(s) < 4)
|
||||
if(Stream_GetRemainingLength(s) < 4)
|
||||
return FALSE;
|
||||
stream_read_UINT32(s, certLength);
|
||||
if(stream_get_left(s) < certLength)
|
||||
if(Stream_GetRemainingLength(s) < certLength)
|
||||
return FALSE;
|
||||
|
||||
DEBUG_CERTIFICATE("\nX.509 Certificate #%d, length:%d", i + 1, certLength);
|
||||
|
@ -99,15 +99,15 @@ BOOL freerdp_channel_process(freerdp* instance, wStream* s, UINT16 channel_id)
|
||||
UINT32 flags;
|
||||
int chunk_length;
|
||||
|
||||
if (stream_get_left(s) < 8)
|
||||
if (Stream_GetRemainingLength(s) < 8)
|
||||
return FALSE;
|
||||
|
||||
stream_read_UINT32(s, length);
|
||||
stream_read_UINT32(s, flags);
|
||||
chunk_length = stream_get_left(s);
|
||||
chunk_length = Stream_GetRemainingLength(s);
|
||||
|
||||
IFCALL(instance->ReceiveChannelData, instance,
|
||||
channel_id, stream_get_tail(s), chunk_length, flags, length);
|
||||
channel_id, Stream_Pointer(s), chunk_length, flags, length);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
@ -118,13 +118,13 @@ BOOL freerdp_channel_peer_process(freerdp_peer* client, wStream* s, UINT16 chann
|
||||
UINT32 flags;
|
||||
int chunk_length;
|
||||
|
||||
if(stream_get_left(s) < 8)
|
||||
if(Stream_GetRemainingLength(s) < 8)
|
||||
return FALSE;
|
||||
stream_read_UINT32(s, length);
|
||||
stream_read_UINT32(s, flags);
|
||||
chunk_length = stream_get_left(s);
|
||||
chunk_length = Stream_GetRemainingLength(s);
|
||||
|
||||
IFCALL(client->ReceiveChannelData, client,
|
||||
channel_id, stream_get_tail(s), chunk_length, flags, length);
|
||||
channel_id, Stream_Pointer(s), chunk_length, flags, length);
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -349,10 +349,10 @@ static BOOL rdp_server_establish_keys(rdpRdp* rdp, wStream* s)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if(stream_get_left(s) < 4)
|
||||
if(Stream_GetRemainingLength(s) < 4)
|
||||
return FALSE;
|
||||
stream_read_UINT32(s, rand_len);
|
||||
if(stream_get_left(s) < rand_len + 8) /* include 8 bytes of padding */
|
||||
if(Stream_GetRemainingLength(s) < rand_len + 8) /* include 8 bytes of padding */
|
||||
return FALSE;
|
||||
|
||||
key_len = rdp->settings->RdpServerRsaKey->ModulusLength;
|
||||
@ -366,7 +366,7 @@ static BOOL rdp_server_establish_keys(rdpRdp* rdp, wStream* s)
|
||||
memset(crypt_client_random, 0, sizeof(crypt_client_random));
|
||||
stream_read(s, crypt_client_random, rand_len);
|
||||
/* 8 zero bytes of padding */
|
||||
stream_seek(s, 8);
|
||||
Stream_Seek(s, 8);
|
||||
mod = rdp->settings->RdpServerRsaKey->Modulus;
|
||||
priv_exp = rdp->settings->RdpServerRsaKey->PrivateExponent;
|
||||
crypto_rsa_private_decrypt(crypt_client_random, rand_len - 8, key_len, mod, priv_exp, client_random);
|
||||
@ -535,7 +535,7 @@ BOOL rdp_client_connect_demand_active(rdpRdp* rdp, wStream* s)
|
||||
UINT16 channelId;
|
||||
stream_set_mark(s, mark);
|
||||
rdp_recv_get_active_header(rdp, s, &channelId);
|
||||
/* Was stream_seek(s, RDP_PACKET_HEADER_MAX_LENGTH);
|
||||
/* Was Stream_Seek(s, RDP_PACKET_HEADER_MAX_LENGTH);
|
||||
* but the headers aren't always that length,
|
||||
* so that could result in a bad offset.
|
||||
*/
|
||||
|
@ -76,9 +76,9 @@ UINT16 fastpath_header_length(wStream* s)
|
||||
{
|
||||
BYTE length1;
|
||||
|
||||
stream_seek_BYTE(s);
|
||||
Stream_Seek_BYTE(s);
|
||||
stream_read_BYTE(s, length1);
|
||||
stream_rewind(s, 2);
|
||||
Stream_Rewind(s, 2);
|
||||
|
||||
return ((length1 & 0x80) != 0 ? 3 : 2);
|
||||
}
|
||||
@ -142,7 +142,7 @@ BOOL fastpath_read_header_rdp(rdpFastPath* fastpath, wStream* s, UINT16 *length)
|
||||
if (!per_read_length(s, length))
|
||||
return FALSE;
|
||||
|
||||
*length = *length - stream_get_length(s);
|
||||
*length = *length - Stream_GetPosition(s);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@ -169,7 +169,7 @@ static BOOL fastpath_recv_update_common(rdpFastPath* fastpath, wStream* s)
|
||||
rdpUpdate* update = fastpath->rdp->update;
|
||||
rdpContext* context = update->context;
|
||||
|
||||
if (stream_get_left(s) < 2)
|
||||
if (Stream_GetRemainingLength(s) < 2)
|
||||
return FALSE;
|
||||
|
||||
stream_read_UINT16(s, updateType); /* updateType (2 bytes) */
|
||||
@ -305,10 +305,10 @@ static int fastpath_recv_update_data(rdpFastPath* fastpath, wStream* s)
|
||||
|
||||
stream_read_UINT16(s, size);
|
||||
|
||||
if (stream_get_left(s) < size)
|
||||
if (Stream_GetRemainingLength(s) < size)
|
||||
return -1;
|
||||
|
||||
next_pos = stream_get_pos(s) + size;
|
||||
next_pos = Stream_GetPosition(s) + size;
|
||||
comp_stream = s;
|
||||
|
||||
if (compressionFlags & PACKET_COMPRESSED)
|
||||
@ -324,7 +324,7 @@ static int fastpath_recv_update_data(rdpFastPath* fastpath, wStream* s)
|
||||
else
|
||||
{
|
||||
fprintf(stderr, "decompress_rdp() failed\n");
|
||||
stream_seek(s, size);
|
||||
Stream_Seek(s, size);
|
||||
}
|
||||
}
|
||||
|
||||
@ -338,12 +338,12 @@ static int fastpath_recv_update_data(rdpFastPath* fastpath, wStream* s)
|
||||
else
|
||||
{
|
||||
if (fragmentation == FASTPATH_FRAGMENT_FIRST)
|
||||
stream_set_pos(fastpath->updateData, 0);
|
||||
Stream_SetPosition(fastpath->updateData, 0);
|
||||
|
||||
stream_check_size(fastpath->updateData, size);
|
||||
stream_copy(fastpath->updateData, comp_stream, size);
|
||||
|
||||
if (stream_get_length(fastpath->updateData) > rdp->settings->MultifragMaxRequestSize)
|
||||
if (Stream_GetPosition(fastpath->updateData) > rdp->settings->MultifragMaxRequestSize)
|
||||
{
|
||||
fprintf(stderr, "fastpath PDU is bigger than MultifragMaxRequestSize\n");
|
||||
return -1;
|
||||
@ -352,8 +352,8 @@ static int fastpath_recv_update_data(rdpFastPath* fastpath, wStream* s)
|
||||
if (fragmentation == FASTPATH_FRAGMENT_LAST)
|
||||
{
|
||||
update_stream = fastpath->updateData;
|
||||
totalSize = stream_get_length(update_stream);
|
||||
stream_set_pos(update_stream, 0);
|
||||
totalSize = Stream_GetPosition(update_stream);
|
||||
Stream_SetPosition(update_stream, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@ -365,7 +365,7 @@ static int fastpath_recv_update_data(rdpFastPath* fastpath, wStream* s)
|
||||
return -1;
|
||||
}
|
||||
|
||||
stream_set_pos(s, next_pos);
|
||||
Stream_SetPosition(s, next_pos);
|
||||
|
||||
if (comp_stream != s)
|
||||
free(comp_stream);
|
||||
@ -380,7 +380,7 @@ int fastpath_recv_updates(rdpFastPath* fastpath, wStream* s)
|
||||
|
||||
IFCALL(update->BeginPaint, update->context);
|
||||
|
||||
while (stream_get_left(s) >= 3)
|
||||
while (Stream_GetRemainingLength(s) >= 3)
|
||||
{
|
||||
if (fastpath_recv_update_data(fastpath, s) < 0)
|
||||
return -1;
|
||||
@ -395,7 +395,7 @@ static BOOL fastpath_read_input_event_header(wStream* s, BYTE* eventFlags, BYTE*
|
||||
{
|
||||
BYTE eventHeader;
|
||||
|
||||
if (stream_get_left(s) < 1)
|
||||
if (Stream_GetRemainingLength(s) < 1)
|
||||
return FALSE;
|
||||
|
||||
stream_read_BYTE(s, eventHeader); /* eventHeader (1 byte) */
|
||||
@ -411,7 +411,7 @@ static BOOL fastpath_recv_input_event_scancode(rdpFastPath* fastpath, wStream* s
|
||||
UINT16 flags;
|
||||
UINT16 code;
|
||||
|
||||
if (stream_get_left(s) < 1)
|
||||
if (Stream_GetRemainingLength(s) < 1)
|
||||
return FALSE;
|
||||
|
||||
stream_read_BYTE(s, code); /* keyCode (1 byte) */
|
||||
@ -436,7 +436,7 @@ static BOOL fastpath_recv_input_event_mouse(rdpFastPath* fastpath, wStream* s, B
|
||||
UINT16 xPos;
|
||||
UINT16 yPos;
|
||||
|
||||
if (stream_get_left(s) < 6)
|
||||
if (Stream_GetRemainingLength(s) < 6)
|
||||
return FALSE;
|
||||
|
||||
stream_read_UINT16(s, pointerFlags); /* pointerFlags (2 bytes) */
|
||||
@ -454,7 +454,7 @@ static BOOL fastpath_recv_input_event_mousex(rdpFastPath* fastpath, wStream* s,
|
||||
UINT16 xPos;
|
||||
UINT16 yPos;
|
||||
|
||||
if (stream_get_left(s) < 6)
|
||||
if (Stream_GetRemainingLength(s) < 6)
|
||||
return FALSE;
|
||||
|
||||
stream_read_UINT16(s, pointerFlags); /* pointerFlags (2 bytes) */
|
||||
@ -478,7 +478,7 @@ static BOOL fastpath_recv_input_event_unicode(rdpFastPath* fastpath, wStream* s,
|
||||
UINT16 unicodeCode;
|
||||
UINT16 flags;
|
||||
|
||||
if (stream_get_left(s) < 2)
|
||||
if (Stream_GetRemainingLength(s) < 2)
|
||||
return FALSE;
|
||||
|
||||
stream_read_UINT16(s, unicodeCode); /* unicodeCode (2 bytes) */
|
||||
@ -548,7 +548,7 @@ int fastpath_recv_inputs(rdpFastPath* fastpath, wStream* s)
|
||||
* as one additional byte here.
|
||||
*/
|
||||
|
||||
if (stream_get_left(s) < 1)
|
||||
if (Stream_GetRemainingLength(s) < 1)
|
||||
return -1;
|
||||
|
||||
stream_read_BYTE(s, fastpath->numberEvents); /* eventHeader (1 byte) */
|
||||
@ -586,13 +586,13 @@ wStream* fastpath_input_pdu_init(rdpFastPath* fastpath, BYTE eventFlags, BYTE ev
|
||||
rdp = fastpath->rdp;
|
||||
|
||||
s = transport_send_stream_init(rdp->transport, 256);
|
||||
stream_seek(s, 3); /* fpInputHeader, length1 and length2 */
|
||||
Stream_Seek(s, 3); /* fpInputHeader, length1 and length2 */
|
||||
if (rdp->do_crypt) {
|
||||
rdp->sec_flags |= SEC_ENCRYPT;
|
||||
if (rdp->do_secure_checksum)
|
||||
rdp->sec_flags |= SEC_SECURE_CHECKSUM;
|
||||
}
|
||||
stream_seek(s, fastpath_get_sec_bytes(rdp));
|
||||
Stream_Seek(s, fastpath_get_sec_bytes(rdp));
|
||||
stream_write_BYTE(s, eventFlags | (eventCode << 5)); /* eventHeader (1 byte) */
|
||||
return s;
|
||||
}
|
||||
@ -606,7 +606,7 @@ BOOL fastpath_send_input_pdu(rdpFastPath* fastpath, wStream* s)
|
||||
|
||||
rdp = fastpath->rdp;
|
||||
|
||||
length = stream_get_length(s);
|
||||
length = Stream_GetPosition(s);
|
||||
if (length >= (2 << 14))
|
||||
{
|
||||
fprintf(stderr, "Maximum FastPath PDU length is 32767\n");
|
||||
@ -620,7 +620,7 @@ BOOL fastpath_send_input_pdu(rdpFastPath* fastpath, wStream* s)
|
||||
if (rdp->sec_flags & SEC_SECURE_CHECKSUM)
|
||||
eventHeader |= (FASTPATH_INPUT_SECURE_CHECKSUM << 6);
|
||||
|
||||
stream_set_pos(s, 0);
|
||||
Stream_SetPosition(s, 0);
|
||||
stream_write_BYTE(s, eventHeader);
|
||||
sec_bytes = fastpath_get_sec_bytes(fastpath->rdp);
|
||||
/*
|
||||
@ -636,18 +636,18 @@ BOOL fastpath_send_input_pdu(rdpFastPath* fastpath, wStream* s)
|
||||
BYTE* fpInputEvents;
|
||||
UINT16 fpInputEvents_length;
|
||||
|
||||
fpInputEvents = stream_get_tail(s) + sec_bytes;
|
||||
fpInputEvents = Stream_Pointer(s) + sec_bytes;
|
||||
fpInputEvents_length = length - 3 - sec_bytes;
|
||||
if (rdp->sec_flags & SEC_SECURE_CHECKSUM)
|
||||
security_salted_mac_signature(rdp, fpInputEvents, fpInputEvents_length, TRUE, stream_get_tail(s));
|
||||
security_salted_mac_signature(rdp, fpInputEvents, fpInputEvents_length, TRUE, Stream_Pointer(s));
|
||||
else
|
||||
security_mac_signature(rdp, fpInputEvents, fpInputEvents_length, stream_get_tail(s));
|
||||
security_mac_signature(rdp, fpInputEvents, fpInputEvents_length, Stream_Pointer(s));
|
||||
security_encrypt(fpInputEvents, fpInputEvents_length, rdp);
|
||||
}
|
||||
|
||||
rdp->sec_flags = 0;
|
||||
|
||||
stream_set_pos(s, length);
|
||||
Stream_SetPosition(s, length);
|
||||
if (transport_write(fastpath->rdp->transport, s) < 0)
|
||||
return FALSE;
|
||||
|
||||
@ -658,9 +658,9 @@ wStream* fastpath_update_pdu_init(rdpFastPath* fastpath)
|
||||
{
|
||||
wStream* s;
|
||||
s = transport_send_stream_init(fastpath->rdp->transport, FASTPATH_MAX_PACKET_SIZE);
|
||||
stream_seek(s, 3); /* fpOutputHeader, length1 and length2 */
|
||||
stream_seek(s, fastpath_get_sec_bytes(fastpath->rdp));
|
||||
stream_seek(s, 3); /* updateHeader, size */
|
||||
Stream_Seek(s, 3); /* fpOutputHeader, length1 and length2 */
|
||||
Stream_Seek(s, fastpath_get_sec_bytes(fastpath->rdp));
|
||||
Stream_Seek(s, 3); /* updateHeader, size */
|
||||
return s;
|
||||
}
|
||||
|
||||
@ -694,8 +694,8 @@ BOOL fastpath_send_update_pdu(rdpFastPath* fastpath, BYTE updateCode, wStream* s
|
||||
rdp = fastpath->rdp;
|
||||
sec_bytes = fastpath_get_sec_bytes(rdp);
|
||||
maxLength = FASTPATH_MAX_PACKET_SIZE - (6 + sec_bytes);
|
||||
totalLength = stream_get_length(s) - (6 + sec_bytes);
|
||||
stream_set_pos(s, 0);
|
||||
totalLength = Stream_GetPosition(s) - (6 + sec_bytes);
|
||||
Stream_SetPosition(s, 0);
|
||||
update = stream_new(0);
|
||||
try_comp = rdp->settings->CompressionEnabled;
|
||||
comp_update = stream_new(0);
|
||||
@ -745,7 +745,7 @@ BOOL fastpath_send_update_pdu(rdpFastPath* fastpath, BYTE updateCode, wStream* s
|
||||
stream_write_BYTE(ls, pduLength & 0xFF); /* length2 */
|
||||
|
||||
if (sec_bytes > 0)
|
||||
stream_seek(ls, sec_bytes);
|
||||
Stream_Seek(ls, sec_bytes);
|
||||
|
||||
fastpath_write_update_header(ls, updateCode, fragmentation, comp_flags);
|
||||
|
||||
@ -761,7 +761,7 @@ BOOL fastpath_send_update_pdu(rdpFastPath* fastpath, BYTE updateCode, wStream* s
|
||||
stream_write_UINT16(ls, pdu_data_bytes);
|
||||
|
||||
stream_attach(update, bm, pduLength);
|
||||
stream_seek(update, pduLength);
|
||||
Stream_Seek(update, pduLength);
|
||||
|
||||
if (sec_bytes > 0)
|
||||
{
|
||||
|
@ -140,7 +140,7 @@ BOOL freerdp_connect(freerdp* instance)
|
||||
s->capacity = record.length;
|
||||
|
||||
pcap_get_next_record_content(update->pcap_rfx, &record);
|
||||
stream_set_pos(s, 0);
|
||||
Stream_SetPosition(s, 0);
|
||||
|
||||
update->BeginPaint(update->context);
|
||||
update_recv_surfcmds(update, s->capacity, s);
|
||||
|
@ -249,7 +249,7 @@ wStream* http_request_write(HttpContext* http_context, HttpRequest* http_request
|
||||
|
||||
Stream_Write(s, "\0", 1); /* append null terminator */
|
||||
Stream_Rewind(s, 1); /* don't include null terminator in length */
|
||||
Stream_Length(s) = Stream_Position(s);
|
||||
Stream_Length(s) = Stream_GetPosition(s);
|
||||
|
||||
return s;
|
||||
}
|
||||
|
@ -105,7 +105,7 @@ int rpc_client_on_fragment_received_event(rdpRpc* rpc)
|
||||
|
||||
Stream_EnsureCapacity(rpc->client->pdu->s, Stream_Length(fragment));
|
||||
Stream_Write(rpc->client->pdu->s, buffer, Stream_Length(fragment));
|
||||
Stream_Length(rpc->client->pdu->s) = Stream_Position(rpc->client->pdu->s);
|
||||
Stream_Length(rpc->client->pdu->s) = Stream_GetPosition(rpc->client->pdu->s);
|
||||
|
||||
rpc_client_fragment_pool_return(rpc, fragment);
|
||||
|
||||
@ -195,7 +195,7 @@ int rpc_client_on_fragment_received_event(rdpRpc* rpc)
|
||||
rpc->client->pdu->Flags = RPC_PDU_FLAG_STUB;
|
||||
rpc->client->pdu->CallId = rpc->StubCallId;
|
||||
|
||||
Stream_Length(rpc->client->pdu->s) = Stream_Position(rpc->client->pdu->s);
|
||||
Stream_Length(rpc->client->pdu->s) = Stream_GetPosition(rpc->client->pdu->s);
|
||||
|
||||
rpc->StubFragCount = 0;
|
||||
rpc->StubCallId = 0;
|
||||
@ -219,12 +219,12 @@ int rpc_client_on_read_event(rdpRpc* rpc)
|
||||
if (!rpc->client->RecvFrag)
|
||||
rpc->client->RecvFrag = rpc_client_fragment_pool_take(rpc);
|
||||
|
||||
position = Stream_Position(rpc->client->RecvFrag);
|
||||
position = Stream_GetPosition(rpc->client->RecvFrag);
|
||||
|
||||
if (Stream_Position(rpc->client->RecvFrag) < RPC_COMMON_FIELDS_LENGTH)
|
||||
if (Stream_GetPosition(rpc->client->RecvFrag) < RPC_COMMON_FIELDS_LENGTH)
|
||||
{
|
||||
status = rpc_out_read(rpc, Stream_Pointer(rpc->client->RecvFrag),
|
||||
RPC_COMMON_FIELDS_LENGTH - Stream_Position(rpc->client->RecvFrag));
|
||||
RPC_COMMON_FIELDS_LENGTH - Stream_GetPosition(rpc->client->RecvFrag));
|
||||
|
||||
if (status < 0)
|
||||
{
|
||||
@ -235,7 +235,7 @@ int rpc_client_on_read_event(rdpRpc* rpc)
|
||||
Stream_Seek(rpc->client->RecvFrag, status);
|
||||
}
|
||||
|
||||
if (Stream_Position(rpc->client->RecvFrag) >= RPC_COMMON_FIELDS_LENGTH)
|
||||
if (Stream_GetPosition(rpc->client->RecvFrag) >= RPC_COMMON_FIELDS_LENGTH)
|
||||
{
|
||||
header = (rpcconn_common_hdr_t*) Stream_Buffer(rpc->client->RecvFrag);
|
||||
|
||||
@ -243,14 +243,14 @@ int rpc_client_on_read_event(rdpRpc* rpc)
|
||||
{
|
||||
fprintf(stderr, "rpc_client_frag_read: invalid fragment size: %d (max: %d)\n",
|
||||
header->frag_length, rpc->max_recv_frag);
|
||||
winpr_HexDump(Stream_Buffer(rpc->client->RecvFrag), Stream_Position(rpc->client->RecvFrag));
|
||||
winpr_HexDump(Stream_Buffer(rpc->client->RecvFrag), Stream_GetPosition(rpc->client->RecvFrag));
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (Stream_Position(rpc->client->RecvFrag) < header->frag_length)
|
||||
if (Stream_GetPosition(rpc->client->RecvFrag) < header->frag_length)
|
||||
{
|
||||
status = rpc_out_read(rpc, Stream_Pointer(rpc->client->RecvFrag),
|
||||
header->frag_length - Stream_Position(rpc->client->RecvFrag));
|
||||
header->frag_length - Stream_GetPosition(rpc->client->RecvFrag));
|
||||
|
||||
if (status < 0)
|
||||
{
|
||||
@ -269,13 +269,13 @@ int rpc_client_on_read_event(rdpRpc* rpc)
|
||||
if (status < 0)
|
||||
return -1;
|
||||
|
||||
status = Stream_Position(rpc->client->RecvFrag) - position;
|
||||
status = Stream_GetPosition(rpc->client->RecvFrag) - position;
|
||||
|
||||
if (Stream_Position(rpc->client->RecvFrag) >= header->frag_length)
|
||||
if (Stream_GetPosition(rpc->client->RecvFrag) >= header->frag_length)
|
||||
{
|
||||
/* complete fragment received */
|
||||
|
||||
Stream_Length(rpc->client->RecvFrag) = Stream_Position(rpc->client->RecvFrag);
|
||||
Stream_Length(rpc->client->RecvFrag) = Stream_GetPosition(rpc->client->RecvFrag);
|
||||
Stream_SetPosition(rpc->client->RecvFrag, 0);
|
||||
|
||||
Queue_Enqueue(rpc->client->FragmentQueue, rpc->client->RecvFrag);
|
||||
|
@ -121,7 +121,7 @@ DWORD TsProxySendToServer(handle_t IDL_handle, byte pRpcMessage[], UINT32 count,
|
||||
if (buffer3Length > 0)
|
||||
Stream_Write(s, buffer3, buffer3Length); /* buffer3 (variable) */
|
||||
|
||||
Stream_Length(s) = Stream_Position(s);
|
||||
Stream_Length(s) = Stream_GetPosition(s);
|
||||
|
||||
status = rpc_write(tsg->rpc, Stream_Buffer(s), Stream_Length(s), TsProxySendToServerOpnum);
|
||||
|
||||
|
@ -179,7 +179,7 @@ BOOL gcc_read_conference_create_request(wStream* s, rdpSettings* settings)
|
||||
/* userData::value (OCTET_STRING) */
|
||||
if (!per_read_length(s, &length))
|
||||
return FALSE;
|
||||
if (stream_get_left(s) < length)
|
||||
if (Stream_GetRemainingLength(s) < length)
|
||||
return FALSE;
|
||||
if (!gcc_read_client_data_blocks(s, settings, length))
|
||||
return FALSE;
|
||||
@ -201,7 +201,7 @@ void gcc_write_conference_create_request(wStream* s, wStream* user_data)
|
||||
per_write_object_identifier(s, t124_02_98_oid); /* ITU-T T.124 (02/98) OBJECT_IDENTIFIER */
|
||||
|
||||
/* ConnectData::connectPDU (OCTET_STRING) */
|
||||
per_write_length(s, stream_get_length(user_data) + 14); /* connectPDU length */
|
||||
per_write_length(s, Stream_GetPosition(user_data) + 14); /* connectPDU length */
|
||||
|
||||
/* ConnectGCCPDU */
|
||||
per_write_choice(s, 0); /* From ConnectGCCPDU select conferenceCreateRequest (0) of type ConferenceCreateRequest */
|
||||
@ -219,7 +219,7 @@ void gcc_write_conference_create_request(wStream* s, wStream* user_data)
|
||||
per_write_octet_string(s, h221_cs_key, 4, 4); /* h221NonStandard, client-to-server H.221 key, "Duca" */
|
||||
|
||||
/* userData::value (OCTET_STRING) */
|
||||
per_write_octet_string(s, user_data->buffer, stream_get_length(user_data), 0); /* array of client data blocks */
|
||||
per_write_octet_string(s, user_data->buffer, Stream_GetPosition(user_data), 0); /* array of client data blocks */
|
||||
}
|
||||
|
||||
BOOL gcc_read_conference_create_response(wStream* s, rdpSettings* settings)
|
||||
@ -278,7 +278,7 @@ void gcc_write_conference_create_response(wStream* s, wStream* user_data)
|
||||
per_write_object_identifier(s, t124_02_98_oid);
|
||||
|
||||
/* ConnectData::connectPDU (OCTET_STRING) */
|
||||
per_write_length(s, stream_get_length(user_data) + 2);
|
||||
per_write_length(s, Stream_GetPosition(user_data) + 2);
|
||||
|
||||
/* ConnectGCCPDU */
|
||||
per_write_choice(s, 0x14);
|
||||
@ -302,7 +302,7 @@ void gcc_write_conference_create_response(wStream* s, wStream* user_data)
|
||||
per_write_octet_string(s, h221_sc_key, 4, 4); /* h221NonStandard, server-to-client H.221 key, "McDn" */
|
||||
|
||||
/* userData (OCTET_STRING) */
|
||||
per_write_octet_string(s, user_data->buffer, stream_get_length(user_data), 0); /* array of server data blocks */
|
||||
per_write_octet_string(s, user_data->buffer, Stream_GetPosition(user_data), 0); /* array of server data blocks */
|
||||
}
|
||||
|
||||
BOOL gcc_read_client_data_blocks(wStream* s, rdpSettings* settings, int length)
|
||||
@ -313,7 +313,7 @@ BOOL gcc_read_client_data_blocks(wStream* s, rdpSettings* settings, int length)
|
||||
|
||||
while (length > 0)
|
||||
{
|
||||
pos = stream_get_pos(s);
|
||||
pos = Stream_GetPosition(s);
|
||||
if(!gcc_read_user_data_header(s, &type, &blockLength))
|
||||
return FALSE;
|
||||
|
||||
@ -349,7 +349,7 @@ BOOL gcc_read_client_data_blocks(wStream* s, rdpSettings* settings, int length)
|
||||
}
|
||||
|
||||
length -= blockLength;
|
||||
stream_set_pos(s, pos + blockLength);
|
||||
Stream_SetPosition(s, pos + blockLength);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
@ -453,13 +453,13 @@ void gcc_write_server_data_blocks(wStream* s, rdpSettings* settings)
|
||||
|
||||
BOOL gcc_read_user_data_header(wStream* s, UINT16* type, UINT16* length)
|
||||
{
|
||||
if (stream_get_left(s) < 4)
|
||||
if (Stream_GetRemainingLength(s) < 4)
|
||||
return FALSE;
|
||||
|
||||
stream_read_UINT16(s, *type); /* type */
|
||||
stream_read_UINT16(s, *length); /* length */
|
||||
|
||||
if (stream_get_left(s) < *length - 4)
|
||||
if (Stream_GetRemainingLength(s) < *length - 4)
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
@ -507,13 +507,13 @@ BOOL gcc_read_client_core_data(wStream* s, rdpSettings* settings, UINT16 blockLe
|
||||
stream_read_UINT16(s, settings->DesktopWidth); /* DesktopWidth */
|
||||
stream_read_UINT16(s, settings->DesktopHeight); /* DesktopHeight */
|
||||
stream_read_UINT16(s, colorDepth); /* ColorDepth */
|
||||
stream_seek_UINT16(s); /* SASSequence (Secure Access Sequence) */
|
||||
Stream_Seek_UINT16(s); /* SASSequence (Secure Access Sequence) */
|
||||
stream_read_UINT32(s, settings->KeyboardLayout); /* KeyboardLayout */
|
||||
stream_read_UINT32(s, settings->ClientBuild); /* ClientBuild */
|
||||
|
||||
/* clientName (32 bytes, null-terminated unicode, truncated to 15 characters) */
|
||||
ConvertFromUnicode(CP_UTF8, 0, (WCHAR*) stream_get_tail(s), 32 / 2, &str, 0, NULL, NULL);
|
||||
stream_seek(s, 32);
|
||||
ConvertFromUnicode(CP_UTF8, 0, (WCHAR*) Stream_Pointer(s), 32 / 2, &str, 0, NULL, NULL);
|
||||
Stream_Seek(s, 32);
|
||||
sprintf_s(settings->ClientHostname, 31, "%s", str);
|
||||
settings->ClientHostname[31] = 0;
|
||||
free(str);
|
||||
@ -523,7 +523,7 @@ BOOL gcc_read_client_core_data(wStream* s, rdpSettings* settings, UINT16 blockLe
|
||||
stream_read_UINT32(s, settings->KeyboardSubType); /* KeyboardSubType */
|
||||
stream_read_UINT32(s, settings->KeyboardFunctionKey); /* KeyboardFunctionKey */
|
||||
|
||||
stream_seek(s, 64); /* imeFileName */
|
||||
Stream_Seek(s, 64); /* imeFileName */
|
||||
|
||||
blockLength -= 128;
|
||||
|
||||
@ -543,12 +543,12 @@ BOOL gcc_read_client_core_data(wStream* s, rdpSettings* settings, UINT16 blockLe
|
||||
|
||||
if (blockLength < 2)
|
||||
break;
|
||||
stream_seek_UINT16(s); /* clientProductID */
|
||||
Stream_Seek_UINT16(s); /* clientProductID */
|
||||
blockLength -= 2;
|
||||
|
||||
if (blockLength < 4)
|
||||
break;
|
||||
stream_seek_UINT32(s); /* serialNumber */
|
||||
Stream_Seek_UINT32(s); /* serialNumber */
|
||||
blockLength -= 4;
|
||||
|
||||
if (blockLength < 2)
|
||||
@ -569,8 +569,8 @@ BOOL gcc_read_client_core_data(wStream* s, rdpSettings* settings, UINT16 blockLe
|
||||
if (blockLength < 64)
|
||||
break;
|
||||
|
||||
ConvertFromUnicode(CP_UTF8, 0, (WCHAR*) stream_get_tail(s), 64 / 2, &str, 0, NULL, NULL);
|
||||
stream_seek(s, 64);
|
||||
ConvertFromUnicode(CP_UTF8, 0, (WCHAR*) Stream_Pointer(s), 64 / 2, &str, 0, NULL, NULL);
|
||||
Stream_Seek(s, 64);
|
||||
sprintf_s(settings->ClientProductId, 32, "%s", str);
|
||||
free(str);
|
||||
blockLength -= 64;
|
||||
@ -582,7 +582,7 @@ BOOL gcc_read_client_core_data(wStream* s, rdpSettings* settings, UINT16 blockLe
|
||||
|
||||
if (blockLength < 1)
|
||||
break;
|
||||
stream_seek_BYTE(s); /* pad1octet */
|
||||
Stream_Seek_BYTE(s); /* pad1octet */
|
||||
blockLength -= 1;
|
||||
|
||||
if (blockLength < 4)
|
||||
@ -753,7 +753,7 @@ BOOL gcc_read_server_core_data(wStream* s, rdpSettings* settings)
|
||||
UINT32 version;
|
||||
UINT32 clientRequestedProtocols;
|
||||
|
||||
if(stream_get_left(s) < 8)
|
||||
if(Stream_GetRemainingLength(s) < 8)
|
||||
return FALSE;
|
||||
stream_read_UINT32(s, version); /* version */
|
||||
stream_read_UINT32(s, clientRequestedProtocols); /* clientRequestedProtocols */
|
||||
@ -794,7 +794,7 @@ BOOL gcc_read_client_security_data(wStream* s, rdpSettings* settings, UINT16 blo
|
||||
}
|
||||
else
|
||||
{
|
||||
stream_seek(s, 8);
|
||||
Stream_Seek(s, 8);
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
@ -828,7 +828,7 @@ BOOL gcc_read_server_security_data(wStream* s, rdpSettings* settings)
|
||||
BYTE* data;
|
||||
UINT32 length;
|
||||
|
||||
if (stream_get_left(s) < 8)
|
||||
if (Stream_GetRemainingLength(s) < 8)
|
||||
return FALSE;
|
||||
stream_read_UINT32(s, settings->EncryptionMethods); /* encryptionMethod */
|
||||
stream_read_UINT32(s, settings->EncryptionLevel); /* encryptionLevel */
|
||||
@ -842,12 +842,12 @@ BOOL gcc_read_server_security_data(wStream* s, rdpSettings* settings)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if (stream_get_left(s) < 8)
|
||||
if (Stream_GetRemainingLength(s) < 8)
|
||||
return FALSE;
|
||||
stream_read_UINT32(s, settings->ServerRandomLength); /* serverRandomLen */
|
||||
stream_read_UINT32(s, settings->ServerCertificateLength); /* serverCertLen */
|
||||
|
||||
if (stream_get_left(s) < settings->ServerRandomLength + settings->ServerCertificateLength)
|
||||
if (Stream_GetRemainingLength(s) < settings->ServerRandomLength + settings->ServerCertificateLength)
|
||||
return FALSE;
|
||||
|
||||
if (settings->ServerRandomLength > 0)
|
||||
@ -1016,7 +1016,7 @@ void gcc_write_server_security_data(wStream* s, rdpSettings* settings)
|
||||
crypto_nonce(settings->ServerRandom, serverRandomLen);
|
||||
stream_write(s, settings->ServerRandom, serverRandomLen);
|
||||
|
||||
sigData = stream_get_tail(s);
|
||||
sigData = Stream_Pointer(s);
|
||||
|
||||
stream_write_UINT32(s, CERT_CHAIN_VERSION_1); /* dwVersion (4 bytes) */
|
||||
stream_write_UINT32(s, SIGNATURE_ALG_RSA); /* dwSigAlgId */
|
||||
@ -1033,7 +1033,7 @@ void gcc_write_server_security_data(wStream* s, rdpSettings* settings)
|
||||
stream_write(s, settings->RdpServerRsaKey->Modulus, keyLen);
|
||||
stream_write_zero(s, 8);
|
||||
|
||||
sigDataLen = stream_get_tail(s) - sigData;
|
||||
sigDataLen = Stream_Pointer(s) - sigData;
|
||||
|
||||
stream_write_UINT16(s, BB_RSA_SIGNATURE_BLOB); /* wSignatureBlobType */
|
||||
stream_write_UINT16(s, keyLen + 8); /* wSignatureBlobLen */
|
||||
@ -1119,7 +1119,7 @@ BOOL gcc_read_server_network_data(wStream* s, rdpSettings* settings)
|
||||
UINT16 channelCount;
|
||||
UINT16 channelId;
|
||||
|
||||
if(stream_get_left(s) < 4)
|
||||
if(Stream_GetRemainingLength(s) < 4)
|
||||
return FALSE;
|
||||
stream_read_UINT16(s, MCSChannelId); /* MCSChannelId */
|
||||
stream_read_UINT16(s, channelCount); /* channelCount */
|
||||
@ -1130,7 +1130,7 @@ BOOL gcc_read_server_network_data(wStream* s, rdpSettings* settings)
|
||||
settings->ChannelCount, channelCount);
|
||||
}
|
||||
|
||||
if(stream_get_left(s) < channelCount * 2)
|
||||
if(Stream_GetRemainingLength(s) < channelCount * 2)
|
||||
return FALSE;
|
||||
|
||||
for (i = 0; i < channelCount; i++)
|
||||
|
@ -54,7 +54,7 @@ BOOL rdp_read_server_auto_reconnect_cookie(wStream* s, rdpSettings* settings)
|
||||
ARC_SC_PRIVATE_PACKET* autoReconnectCookie;
|
||||
autoReconnectCookie = settings->ServerAutoReconnectCookie;
|
||||
|
||||
if (stream_get_left(s) < 4+4+4+16)
|
||||
if (Stream_GetRemainingLength(s) < 4+4+4+16)
|
||||
return FALSE;
|
||||
stream_read_UINT32(s, autoReconnectCookie->cbLen); /* cbLen (4 bytes) */
|
||||
stream_read_UINT32(s, autoReconnectCookie->version); /* version (4 bytes) */
|
||||
@ -75,7 +75,7 @@ BOOL rdp_read_client_auto_reconnect_cookie(wStream* s, rdpSettings* settings)
|
||||
ARC_CS_PRIVATE_PACKET* autoReconnectCookie;
|
||||
autoReconnectCookie = settings->ClientAutoReconnectCookie;
|
||||
|
||||
if (stream_get_left(s) < 28)
|
||||
if (Stream_GetRemainingLength(s) < 28)
|
||||
return FALSE;
|
||||
|
||||
stream_read_UINT32(s, autoReconnectCookie->cbLen); /* cbLen (4 bytes) */
|
||||
@ -118,38 +118,38 @@ BOOL rdp_read_extended_info_packet(wStream* s, rdpSettings* settings)
|
||||
UINT16 cbClientDir;
|
||||
UINT16 cbAutoReconnectLen;
|
||||
|
||||
if (stream_get_left(s) < 4)
|
||||
if (Stream_GetRemainingLength(s) < 4)
|
||||
return FALSE;
|
||||
stream_read_UINT16(s, clientAddressFamily); /* clientAddressFamily */
|
||||
stream_read_UINT16(s, cbClientAddress); /* cbClientAddress */
|
||||
|
||||
settings->IPv6Enabled = (clientAddressFamily == ADDRESS_FAMILY_INET6 ? TRUE : FALSE);
|
||||
|
||||
if (stream_get_left(s) < cbClientAddress)
|
||||
if (Stream_GetRemainingLength(s) < cbClientAddress)
|
||||
return FALSE;
|
||||
|
||||
ConvertFromUnicode(CP_UTF8, 0, (WCHAR*) stream_get_tail(s), cbClientAddress / 2, &settings->ClientAddress, 0, NULL, NULL);
|
||||
stream_seek(s, cbClientAddress);
|
||||
ConvertFromUnicode(CP_UTF8, 0, (WCHAR*) Stream_Pointer(s), cbClientAddress / 2, &settings->ClientAddress, 0, NULL, NULL);
|
||||
Stream_Seek(s, cbClientAddress);
|
||||
|
||||
if (stream_get_left(s) < 2)
|
||||
if (Stream_GetRemainingLength(s) < 2)
|
||||
return FALSE;
|
||||
stream_read_UINT16(s, cbClientDir); /* cbClientDir */
|
||||
|
||||
if (stream_get_left(s) < cbClientDir)
|
||||
if (Stream_GetRemainingLength(s) < cbClientDir)
|
||||
return FALSE;
|
||||
|
||||
if (settings->ClientDir)
|
||||
free(settings->ClientDir);
|
||||
|
||||
ConvertFromUnicode(CP_UTF8, 0, (WCHAR*) stream_get_tail(s), cbClientDir / 2, &settings->ClientDir, 0, NULL, NULL);
|
||||
stream_seek(s, cbClientDir);
|
||||
ConvertFromUnicode(CP_UTF8, 0, (WCHAR*) Stream_Pointer(s), cbClientDir / 2, &settings->ClientDir, 0, NULL, NULL);
|
||||
Stream_Seek(s, cbClientDir);
|
||||
|
||||
if (!rdp_read_client_time_zone(s, settings))
|
||||
return FALSE;
|
||||
|
||||
if (stream_get_left(s) < 10)
|
||||
if (Stream_GetRemainingLength(s) < 10)
|
||||
return FALSE;
|
||||
stream_seek_UINT32(s); /* clientSessionId, should be set to 0 */
|
||||
Stream_Seek_UINT32(s); /* clientSessionId, should be set to 0 */
|
||||
stream_read_UINT32(s, settings->PerformanceFlags); /* performanceFlags */
|
||||
|
||||
stream_read_UINT16(s, cbAutoReconnectLen); /* cbAutoReconnectLen */
|
||||
@ -234,10 +234,10 @@ BOOL rdp_read_info_packet(wStream* s, rdpSettings* settings)
|
||||
UINT16 cbAlternateShell;
|
||||
UINT16 cbWorkingDir;
|
||||
|
||||
if (stream_get_left(s) < 18) // invalid packet
|
||||
if (Stream_GetRemainingLength(s) < 18) // invalid packet
|
||||
return FALSE;
|
||||
|
||||
stream_seek_UINT32(s); /* CodePage */
|
||||
Stream_Seek_UINT32(s); /* CodePage */
|
||||
stream_read_UINT32(s, flags); /* flags */
|
||||
|
||||
settings->AutoLogonEnabled = ((flags & INFO_AUTOLOGON) ? TRUE : FALSE);
|
||||
@ -251,55 +251,55 @@ BOOL rdp_read_info_packet(wStream* s, rdpSettings* settings)
|
||||
stream_read_UINT16(s, cbAlternateShell); /* cbAlternateShell */
|
||||
stream_read_UINT16(s, cbWorkingDir); /* cbWorkingDir */
|
||||
|
||||
if (stream_get_left(s) < cbDomain + 2)
|
||||
if (Stream_GetRemainingLength(s) < cbDomain + 2)
|
||||
return FALSE;
|
||||
|
||||
if (cbDomain > 0)
|
||||
{
|
||||
ConvertFromUnicode(CP_UTF8, 0, (WCHAR*) stream_get_tail(s), cbDomain / 2, &settings->Domain, 0, NULL, NULL);
|
||||
stream_seek(s, cbDomain);
|
||||
ConvertFromUnicode(CP_UTF8, 0, (WCHAR*) Stream_Pointer(s), cbDomain / 2, &settings->Domain, 0, NULL, NULL);
|
||||
Stream_Seek(s, cbDomain);
|
||||
}
|
||||
stream_seek(s, 2);
|
||||
Stream_Seek(s, 2);
|
||||
|
||||
if (stream_get_left(s) < cbUserName + 2)
|
||||
if (Stream_GetRemainingLength(s) < cbUserName + 2)
|
||||
return FALSE;
|
||||
|
||||
if (cbUserName > 0)
|
||||
{
|
||||
ConvertFromUnicode(CP_UTF8, 0, (WCHAR*) stream_get_tail(s), cbUserName / 2, &settings->Username, 0, NULL, NULL);
|
||||
stream_seek(s, cbUserName);
|
||||
ConvertFromUnicode(CP_UTF8, 0, (WCHAR*) Stream_Pointer(s), cbUserName / 2, &settings->Username, 0, NULL, NULL);
|
||||
Stream_Seek(s, cbUserName);
|
||||
}
|
||||
stream_seek(s, 2);
|
||||
Stream_Seek(s, 2);
|
||||
|
||||
if (stream_get_left(s) < cbPassword + 2)
|
||||
if (Stream_GetRemainingLength(s) < cbPassword + 2)
|
||||
return FALSE;
|
||||
|
||||
if (cbPassword > 0)
|
||||
{
|
||||
ConvertFromUnicode(CP_UTF8, 0, (WCHAR*) stream_get_tail(s), cbPassword / 2, &settings->Password, 0, NULL, NULL);
|
||||
stream_seek(s, cbPassword);
|
||||
ConvertFromUnicode(CP_UTF8, 0, (WCHAR*) Stream_Pointer(s), cbPassword / 2, &settings->Password, 0, NULL, NULL);
|
||||
Stream_Seek(s, cbPassword);
|
||||
}
|
||||
stream_seek(s, 2);
|
||||
Stream_Seek(s, 2);
|
||||
|
||||
if (stream_get_left(s) < cbAlternateShell + 2)
|
||||
if (Stream_GetRemainingLength(s) < cbAlternateShell + 2)
|
||||
return FALSE;
|
||||
|
||||
if (cbAlternateShell > 0)
|
||||
{
|
||||
ConvertFromUnicode(CP_UTF8, 0, (WCHAR*) stream_get_tail(s), cbAlternateShell / 2, &settings->AlternateShell, 0, NULL, NULL);
|
||||
stream_seek(s, cbAlternateShell);
|
||||
ConvertFromUnicode(CP_UTF8, 0, (WCHAR*) Stream_Pointer(s), cbAlternateShell / 2, &settings->AlternateShell, 0, NULL, NULL);
|
||||
Stream_Seek(s, cbAlternateShell);
|
||||
}
|
||||
stream_seek(s, 2);
|
||||
Stream_Seek(s, 2);
|
||||
|
||||
if (stream_get_left(s) < cbWorkingDir + 2)
|
||||
if (Stream_GetRemainingLength(s) < cbWorkingDir + 2)
|
||||
return FALSE;
|
||||
|
||||
if (cbWorkingDir > 0)
|
||||
{
|
||||
ConvertFromUnicode(CP_UTF8, 0, (WCHAR*) stream_get_tail(s), cbWorkingDir / 2, &settings->ShellWorkingDirectory, 0, NULL, NULL);
|
||||
stream_seek(s, cbWorkingDir);
|
||||
ConvertFromUnicode(CP_UTF8, 0, (WCHAR*) Stream_Pointer(s), cbWorkingDir / 2, &settings->ShellWorkingDirectory, 0, NULL, NULL);
|
||||
Stream_Seek(s, cbWorkingDir);
|
||||
}
|
||||
stream_seek(s, 2);
|
||||
Stream_Seek(s, 2);
|
||||
|
||||
if (settings->RdpVersion >= 5)
|
||||
return rdp_read_extended_info_packet(s, settings); /* extraInfo */
|
||||
@ -488,14 +488,14 @@ BOOL rdp_recv_logon_info_v1(rdpRdp* rdp, wStream* s)
|
||||
UINT32 cbDomain;
|
||||
UINT32 cbUserName;
|
||||
|
||||
if (stream_get_left(s) < (4 + 52 + 4 + 512 + 4))
|
||||
if (Stream_GetRemainingLength(s) < (4 + 52 + 4 + 512 + 4))
|
||||
return FALSE;
|
||||
|
||||
stream_read_UINT32(s, cbDomain); /* cbDomain (4 bytes) */
|
||||
stream_seek(s, 52); /* domain (52 bytes) */
|
||||
Stream_Seek(s, 52); /* domain (52 bytes) */
|
||||
stream_read_UINT32(s, cbUserName); /* cbUserName (4 bytes) */
|
||||
stream_seek(s, 512); /* userName (512 bytes) */
|
||||
stream_seek_UINT32(s); /* sessionId (4 bytes) */
|
||||
Stream_Seek(s, 512); /* userName (512 bytes) */
|
||||
Stream_Seek_UINT32(s); /* sessionId (4 bytes) */
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
@ -505,31 +505,31 @@ BOOL rdp_recv_logon_info_v2(rdpRdp* rdp, wStream* s)
|
||||
UINT32 cbDomain;
|
||||
UINT32 cbUserName;
|
||||
|
||||
if (stream_get_left(s) < (2 + 4 + 4 + 4 + 4 + 558))
|
||||
if (Stream_GetRemainingLength(s) < (2 + 4 + 4 + 4 + 4 + 558))
|
||||
return FALSE;
|
||||
|
||||
stream_seek_UINT16(s); /* version (2 bytes) */
|
||||
stream_seek_UINT32(s); /* size (4 bytes) */
|
||||
stream_seek_UINT32(s); /* sessionId (4 bytes) */
|
||||
Stream_Seek_UINT16(s); /* version (2 bytes) */
|
||||
Stream_Seek_UINT32(s); /* size (4 bytes) */
|
||||
Stream_Seek_UINT32(s); /* sessionId (4 bytes) */
|
||||
stream_read_UINT32(s, cbDomain); /* cbDomain (4 bytes) */
|
||||
stream_read_UINT32(s, cbUserName); /* cbUserName (4 bytes) */
|
||||
stream_seek(s, 558); /* pad */
|
||||
Stream_Seek(s, 558); /* pad */
|
||||
|
||||
if (stream_get_left(s) < cbDomain+cbUserName)
|
||||
if (Stream_GetRemainingLength(s) < cbDomain+cbUserName)
|
||||
return FALSE;
|
||||
|
||||
stream_seek(s, cbDomain); /* domain */
|
||||
stream_seek(s, cbUserName); /* userName */
|
||||
Stream_Seek(s, cbDomain); /* domain */
|
||||
Stream_Seek(s, cbUserName); /* userName */
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL rdp_recv_logon_plain_notify(rdpRdp* rdp, wStream* s)
|
||||
{
|
||||
if (stream_get_left(s) < 576)
|
||||
if (Stream_GetRemainingLength(s) < 576)
|
||||
return FALSE;
|
||||
|
||||
stream_seek(s, 576); /* pad */
|
||||
Stream_Seek(s, 576); /* pad */
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
@ -539,7 +539,7 @@ BOOL rdp_recv_logon_error_info(rdpRdp* rdp, wStream* s)
|
||||
UINT32 errorNotificationData;
|
||||
UINT32 errorNotificationType;
|
||||
|
||||
if (stream_get_left(s) < 4)
|
||||
if (Stream_GetRemainingLength(s) < 4)
|
||||
return FALSE;
|
||||
|
||||
stream_read_UINT32(s, errorNotificationData); /* errorNotificationData (4 bytes) */
|
||||
@ -556,7 +556,7 @@ BOOL rdp_recv_logon_info_extended(rdpRdp* rdp, wStream* s)
|
||||
UINT32 fieldsPresent;
|
||||
UINT16 Length;
|
||||
|
||||
if (stream_get_left(s) < 6)
|
||||
if (Stream_GetRemainingLength(s) < 6)
|
||||
return FALSE;
|
||||
|
||||
stream_read_UINT16(s, Length); /* The total size in bytes of this structure */
|
||||
@ -566,7 +566,7 @@ BOOL rdp_recv_logon_info_extended(rdpRdp* rdp, wStream* s)
|
||||
|
||||
if (fieldsPresent & LOGON_EX_AUTORECONNECTCOOKIE)
|
||||
{
|
||||
if (stream_get_left(s) < 4)
|
||||
if (Stream_GetRemainingLength(s) < 4)
|
||||
return FALSE;
|
||||
|
||||
stream_read_UINT32(s, cbFieldData); /* cbFieldData (4 bytes) */
|
||||
@ -577,7 +577,7 @@ BOOL rdp_recv_logon_info_extended(rdpRdp* rdp, wStream* s)
|
||||
|
||||
if (fieldsPresent & LOGON_EX_LOGONERRORS)
|
||||
{
|
||||
if (stream_get_left(s) < 4)
|
||||
if (Stream_GetRemainingLength(s) < 4)
|
||||
return FALSE;
|
||||
|
||||
stream_read_UINT32(s, cbFieldData); /* cbFieldData (4 bytes) */
|
||||
@ -586,10 +586,10 @@ BOOL rdp_recv_logon_info_extended(rdpRdp* rdp, wStream* s)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (stream_get_left(s) < 570)
|
||||
if (Stream_GetRemainingLength(s) < 570)
|
||||
return FALSE;
|
||||
|
||||
stream_seek(s, 570); /* pad */
|
||||
Stream_Seek(s, 570); /* pad */
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
@ -598,7 +598,7 @@ BOOL rdp_recv_save_session_info(rdpRdp* rdp, wStream* s)
|
||||
{
|
||||
UINT32 infoType;
|
||||
|
||||
if (stream_get_left(s) < 4)
|
||||
if (Stream_GetRemainingLength(s) < 4)
|
||||
return FALSE;
|
||||
stream_read_UINT32(s, infoType); /* infoType (4 bytes) */
|
||||
|
||||
|
@ -210,10 +210,10 @@ static BOOL input_recv_sync_event(rdpInput* input, wStream* s)
|
||||
{
|
||||
UINT32 toggleFlags;
|
||||
|
||||
if (stream_get_left(s) < 6)
|
||||
if (Stream_GetRemainingLength(s) < 6)
|
||||
return FALSE;
|
||||
|
||||
stream_seek(s, 2); /* pad2Octets (2 bytes) */
|
||||
Stream_Seek(s, 2); /* pad2Octets (2 bytes) */
|
||||
stream_read_UINT32(s, toggleFlags); /* toggleFlags (4 bytes) */
|
||||
|
||||
IFCALL(input->SynchronizeEvent, input, toggleFlags);
|
||||
@ -225,12 +225,12 @@ static BOOL input_recv_keyboard_event(rdpInput* input, wStream* s)
|
||||
{
|
||||
UINT16 keyboardFlags, keyCode;
|
||||
|
||||
if (stream_get_left(s) < 6)
|
||||
if (Stream_GetRemainingLength(s) < 6)
|
||||
return FALSE;
|
||||
|
||||
stream_read_UINT16(s, keyboardFlags); /* keyboardFlags (2 bytes) */
|
||||
stream_read_UINT16(s, keyCode); /* keyCode (2 bytes) */
|
||||
stream_seek(s, 2); /* pad2Octets (2 bytes) */
|
||||
Stream_Seek(s, 2); /* pad2Octets (2 bytes) */
|
||||
|
||||
IFCALL(input->KeyboardEvent, input, keyboardFlags, keyCode);
|
||||
|
||||
@ -241,12 +241,12 @@ static BOOL input_recv_unicode_keyboard_event(rdpInput* input, wStream* s)
|
||||
{
|
||||
UINT16 keyboardFlags, unicodeCode;
|
||||
|
||||
if (stream_get_left(s) < 6)
|
||||
if (Stream_GetRemainingLength(s) < 6)
|
||||
return FALSE;
|
||||
|
||||
stream_read_UINT16(s, keyboardFlags); /* keyboardFlags (2 bytes) */
|
||||
stream_read_UINT16(s, unicodeCode); /* unicodeCode (2 bytes) */
|
||||
stream_seek(s, 2); /* pad2Octets (2 bytes) */
|
||||
Stream_Seek(s, 2); /* pad2Octets (2 bytes) */
|
||||
|
||||
/*
|
||||
* According to the specification, the slow path Unicode Keyboard Event
|
||||
@ -270,7 +270,7 @@ static BOOL input_recv_mouse_event(rdpInput* input, wStream* s)
|
||||
{
|
||||
UINT16 pointerFlags, xPos, yPos;
|
||||
|
||||
if (stream_get_left(s) < 6)
|
||||
if (Stream_GetRemainingLength(s) < 6)
|
||||
return FALSE;
|
||||
|
||||
stream_read_UINT16(s, pointerFlags); /* pointerFlags (2 bytes) */
|
||||
@ -286,7 +286,7 @@ static BOOL input_recv_extended_mouse_event(rdpInput* input, wStream* s)
|
||||
{
|
||||
UINT16 pointerFlags, xPos, yPos;
|
||||
|
||||
if (stream_get_left(s) < 6)
|
||||
if (Stream_GetRemainingLength(s) < 6)
|
||||
return FALSE;
|
||||
|
||||
stream_read_UINT16(s, pointerFlags); /* pointerFlags (2 bytes) */
|
||||
@ -302,10 +302,10 @@ static BOOL input_recv_event(rdpInput* input, wStream* s)
|
||||
{
|
||||
UINT16 messageType;
|
||||
|
||||
if (stream_get_left(s) < 6)
|
||||
if (Stream_GetRemainingLength(s) < 6)
|
||||
return FALSE;
|
||||
|
||||
stream_seek(s, 4); /* eventTime (4 bytes), ignored by the server */
|
||||
Stream_Seek(s, 4); /* eventTime (4 bytes), ignored by the server */
|
||||
stream_read_UINT16(s, messageType); /* messageType (2 bytes) */
|
||||
|
||||
switch (messageType)
|
||||
@ -338,7 +338,7 @@ static BOOL input_recv_event(rdpInput* input, wStream* s)
|
||||
default:
|
||||
fprintf(stderr, "Unknown messageType %u\n", messageType);
|
||||
/* Each input event uses 6 bytes. */
|
||||
stream_seek(s, 6);
|
||||
Stream_Seek(s, 6);
|
||||
break;
|
||||
}
|
||||
|
||||
@ -349,14 +349,14 @@ BOOL input_recv(rdpInput* input, wStream* s)
|
||||
{
|
||||
UINT16 i, numberEvents;
|
||||
|
||||
if (stream_get_left(s) < 4)
|
||||
if (Stream_GetRemainingLength(s) < 4)
|
||||
return FALSE;
|
||||
|
||||
stream_read_UINT16(s, numberEvents); /* numberEvents (2 bytes) */
|
||||
stream_seek(s, 2); /* pad2Octets (2 bytes) */
|
||||
Stream_Seek(s, 2); /* pad2Octets (2 bytes) */
|
||||
|
||||
/* Each input event uses 6 exactly bytes. */
|
||||
if (stream_get_left(s) < 6 * numberEvents)
|
||||
if (Stream_GetRemainingLength(s) < 6 * numberEvents)
|
||||
return FALSE;
|
||||
|
||||
for (i = 0; i < numberEvents; i++)
|
||||
|
@ -126,7 +126,7 @@ void license_print_scope_list(SCOPE_LIST* scopeList)
|
||||
BOOL license_read_preamble(wStream* s, BYTE* bMsgType, BYTE* flags, UINT16* wMsgSize)
|
||||
{
|
||||
/* preamble (4 bytes) */
|
||||
if (stream_get_left(s) < 4)
|
||||
if (Stream_GetRemainingLength(s) < 4)
|
||||
return FALSE;
|
||||
|
||||
stream_read_BYTE(s, *bMsgType); /* bMsgType (1 byte) */
|
||||
@ -164,7 +164,7 @@ wStream* license_send_stream_init(rdpLicense* license)
|
||||
wStream* s;
|
||||
|
||||
s = transport_send_stream_init(license->rdp->transport, 4096);
|
||||
stream_seek(s, LICENSE_PACKET_HEADER_MAX_LENGTH);
|
||||
Stream_Seek(s, LICENSE_PACKET_HEADER_MAX_LENGTH);
|
||||
|
||||
return s;
|
||||
}
|
||||
@ -185,8 +185,8 @@ BOOL license_send(rdpLicense* license, wStream* s, BYTE type)
|
||||
|
||||
DEBUG_LICENSE("Sending %s Packet", LICENSE_MESSAGE_STRINGS[type & 0x1F]);
|
||||
|
||||
length = stream_get_length(s);
|
||||
stream_set_pos(s, 0);
|
||||
length = Stream_GetPosition(s);
|
||||
Stream_SetPosition(s, 0);
|
||||
|
||||
sec_flags = SEC_LICENSE_PKT;
|
||||
wMsgSize = length - LICENSE_PACKET_HEADER_MAX_LENGTH + 4;
|
||||
@ -206,7 +206,7 @@ BOOL license_send(rdpLicense* license, wStream* s, BYTE type)
|
||||
winpr_HexDump(s->pointer - 4, wMsgSize);
|
||||
#endif
|
||||
|
||||
stream_set_pos(s, length);
|
||||
Stream_SetPosition(s, length);
|
||||
|
||||
if (transport_write(license->rdp->transport, s) < 0)
|
||||
return FALSE;
|
||||
@ -252,7 +252,7 @@ BOOL license_recv(rdpLicense* license, wStream* s)
|
||||
if (!(securityFlags & SEC_LICENSE_PKT))
|
||||
{
|
||||
if (!(securityFlags & SEC_ENCRYPT))
|
||||
stream_rewind(s, RDP_SECURITY_HEADER_LENGTH);
|
||||
Stream_Rewind(s, RDP_SECURITY_HEADER_LENGTH);
|
||||
|
||||
if (rdp_recv_out_of_sequence_pdu(license->rdp, s) != TRUE)
|
||||
{
|
||||
@ -463,14 +463,14 @@ void license_decrypt_platform_challenge(rdpLicense* license)
|
||||
|
||||
BOOL license_read_product_info(wStream* s, PRODUCT_INFO* productInfo)
|
||||
{
|
||||
if (stream_get_left(s) < 8)
|
||||
if (Stream_GetRemainingLength(s) < 8)
|
||||
return FALSE;
|
||||
|
||||
stream_read_UINT32(s, productInfo->dwVersion); /* dwVersion (4 bytes) */
|
||||
|
||||
stream_read_UINT32(s, productInfo->cbCompanyName); /* cbCompanyName (4 bytes) */
|
||||
|
||||
if (stream_get_left(s) < productInfo->cbCompanyName + 4)
|
||||
if (Stream_GetRemainingLength(s) < productInfo->cbCompanyName + 4)
|
||||
return FALSE;
|
||||
|
||||
productInfo->pbCompanyName = (BYTE*) malloc(productInfo->cbCompanyName);
|
||||
@ -478,7 +478,7 @@ BOOL license_read_product_info(wStream* s, PRODUCT_INFO* productInfo)
|
||||
|
||||
stream_read_UINT32(s, productInfo->cbProductId); /* cbProductId (4 bytes) */
|
||||
|
||||
if (stream_get_left(s) < productInfo->cbProductId)
|
||||
if (Stream_GetRemainingLength(s) < productInfo->cbProductId)
|
||||
{
|
||||
free(productInfo->pbCompanyName);
|
||||
productInfo->pbCompanyName = NULL;
|
||||
@ -540,13 +540,13 @@ BOOL license_read_binary_blob(wStream* s, LICENSE_BLOB* blob)
|
||||
{
|
||||
UINT16 wBlobType;
|
||||
|
||||
if (stream_get_left(s) < 4)
|
||||
if (Stream_GetRemainingLength(s) < 4)
|
||||
return FALSE;
|
||||
|
||||
stream_read_UINT16(s, wBlobType); /* wBlobType (2 bytes) */
|
||||
stream_read_UINT16(s, blob->length); /* wBlobLen (2 bytes) */
|
||||
|
||||
if (stream_get_left(s) < blob->length)
|
||||
if (Stream_GetRemainingLength(s) < blob->length)
|
||||
return FALSE;
|
||||
|
||||
/*
|
||||
@ -649,7 +649,7 @@ BOOL license_read_scope_list(wStream* s, SCOPE_LIST* scopeList)
|
||||
UINT32 i;
|
||||
UINT32 scopeCount;
|
||||
|
||||
if (stream_get_left(s) < 4)
|
||||
if (Stream_GetRemainingLength(s) < 4)
|
||||
return FALSE;
|
||||
|
||||
stream_read_UINT32(s, scopeCount); /* ScopeCount (4 bytes) */
|
||||
@ -722,7 +722,7 @@ void license_free_scope_list(SCOPE_LIST* scopeList)
|
||||
BOOL license_read_license_request_packet(rdpLicense* license, wStream* s)
|
||||
{
|
||||
/* ServerRandom (32 bytes) */
|
||||
if (stream_get_left(s) < 32)
|
||||
if (Stream_GetRemainingLength(s) < 32)
|
||||
return FALSE;
|
||||
|
||||
stream_read(s, license->ServerRandom, 32);
|
||||
@ -781,7 +781,7 @@ BOOL license_read_platform_challenge_packet(rdpLicense* license, wStream* s)
|
||||
|
||||
DEBUG_LICENSE("Receiving Platform Challenge Packet");
|
||||
|
||||
if (stream_get_left(s) < 4)
|
||||
if (Stream_GetRemainingLength(s) < 4)
|
||||
return FALSE;
|
||||
|
||||
stream_read_UINT32(s, ConnectFlags); /* ConnectFlags, Reserved (4 bytes) */
|
||||
@ -791,7 +791,7 @@ BOOL license_read_platform_challenge_packet(rdpLicense* license, wStream* s)
|
||||
license_read_binary_blob(s, license->EncryptedPlatformChallenge);
|
||||
license->EncryptedPlatformChallenge->type = BB_ENCRYPTED_DATA_BLOB;
|
||||
|
||||
if (stream_get_left(s) < 16)
|
||||
if (Stream_GetRemainingLength(s) < 16)
|
||||
return FALSE;
|
||||
|
||||
stream_read(s, MacData, 16); /* MACData (16 bytes) */
|
||||
@ -856,7 +856,7 @@ BOOL license_read_error_alert_packet(rdpLicense* license, wStream* s)
|
||||
UINT32 dwErrorCode;
|
||||
UINT32 dwStateTransition;
|
||||
|
||||
if (stream_get_left(s) < 8)
|
||||
if (Stream_GetRemainingLength(s) < 8)
|
||||
return FALSE;
|
||||
|
||||
stream_read_UINT32(s, dwErrorCode); /* dwErrorCode (4 bytes) */
|
||||
|
@ -284,7 +284,7 @@ void mcs_write_domain_parameters(wStream* s, DomainParameters* domainParameters)
|
||||
int length;
|
||||
wStream* tmps;
|
||||
|
||||
tmps = stream_new(stream_get_size(s));
|
||||
tmps = stream_new(Stream_Capacity(s));
|
||||
ber_write_integer(tmps, domainParameters->maxChannelIds);
|
||||
ber_write_integer(tmps, domainParameters->maxUserIds);
|
||||
ber_write_integer(tmps, domainParameters->maxTokenIds);
|
||||
@ -294,7 +294,7 @@ void mcs_write_domain_parameters(wStream* s, DomainParameters* domainParameters)
|
||||
ber_write_integer(tmps, domainParameters->maxMCSPDUsize);
|
||||
ber_write_integer(tmps, domainParameters->protocolVersion);
|
||||
|
||||
length = stream_get_length(tmps);
|
||||
length = Stream_GetPosition(tmps);
|
||||
ber_write_sequence_tag(s, length);
|
||||
stream_write(s, stream_get_head(tmps), length);
|
||||
stream_free(tmps);
|
||||
@ -341,14 +341,14 @@ BOOL mcs_recv_connect_initial(rdpMcs* mcs, wStream* s)
|
||||
return FALSE;
|
||||
|
||||
/* callingDomainSelector (OCTET_STRING) */
|
||||
if (!ber_read_octet_string_tag(s, &length) || stream_get_left(s) < length)
|
||||
if (!ber_read_octet_string_tag(s, &length) || Stream_GetRemainingLength(s) < length)
|
||||
return FALSE;
|
||||
stream_seek(s, length);
|
||||
Stream_Seek(s, length);
|
||||
|
||||
/* calledDomainSelector (OCTET_STRING) */
|
||||
if (!ber_read_octet_string_tag(s, &length) || stream_get_left(s) < length)
|
||||
if (!ber_read_octet_string_tag(s, &length) || Stream_GetRemainingLength(s) < length)
|
||||
return FALSE;
|
||||
stream_seek(s, length);
|
||||
Stream_Seek(s, length);
|
||||
|
||||
/* upwardFlag (BOOLEAN) */
|
||||
if (!ber_read_BOOL(s, &upwardFlag))
|
||||
@ -366,7 +366,7 @@ BOOL mcs_recv_connect_initial(rdpMcs* mcs, wStream* s)
|
||||
if(!mcs_read_domain_parameters(s, &mcs->maximumParameters))
|
||||
return FALSE;
|
||||
|
||||
if (!ber_read_octet_string_tag(s, &length) || stream_get_left(s) < length)
|
||||
if (!ber_read_octet_string_tag(s, &length) || Stream_GetRemainingLength(s) < length)
|
||||
return FALSE;
|
||||
|
||||
if (!gcc_read_conference_create_request(s, mcs->transport->settings))
|
||||
@ -388,7 +388,7 @@ void mcs_write_connect_initial(wStream* s, rdpMcs* mcs, wStream* user_data)
|
||||
int length;
|
||||
wStream* tmps;
|
||||
|
||||
tmps = stream_new(stream_get_size(s));
|
||||
tmps = stream_new(Stream_Capacity(s));
|
||||
|
||||
/* callingDomainSelector (OCTET_STRING) */
|
||||
ber_write_octet_string(tmps, callingDomainSelector, sizeof(callingDomainSelector));
|
||||
@ -409,9 +409,9 @@ void mcs_write_connect_initial(wStream* s, rdpMcs* mcs, wStream* user_data)
|
||||
mcs_write_domain_parameters(tmps, &mcs->maximumParameters);
|
||||
|
||||
/* userData (OCTET_STRING) */
|
||||
ber_write_octet_string(tmps, user_data->buffer, stream_get_length(user_data));
|
||||
ber_write_octet_string(tmps, user_data->buffer, Stream_GetPosition(user_data));
|
||||
|
||||
length = stream_get_length(tmps);
|
||||
length = Stream_GetPosition(tmps);
|
||||
/* Connect-Initial (APPLICATION 101, IMPLICIT SEQUENCE) */
|
||||
ber_write_application_tag(s, MCS_TYPE_CONNECT_INITIAL, length);
|
||||
stream_write(s, stream_get_head(tmps), length);
|
||||
@ -431,15 +431,15 @@ void mcs_write_connect_response(wStream* s, rdpMcs* mcs, wStream* user_data)
|
||||
int length;
|
||||
wStream* tmps;
|
||||
|
||||
tmps = stream_new(stream_get_size(s));
|
||||
tmps = stream_new(Stream_Capacity(s));
|
||||
ber_write_enumerated(tmps, 0, MCS_Result_enum_length);
|
||||
ber_write_integer(tmps, 0); /* calledConnectId */
|
||||
mcs->domainParameters = mcs->targetParameters;
|
||||
mcs_write_domain_parameters(tmps, &(mcs->domainParameters));
|
||||
/* userData (OCTET_STRING) */
|
||||
ber_write_octet_string(tmps, user_data->buffer, stream_get_length(user_data));
|
||||
ber_write_octet_string(tmps, user_data->buffer, Stream_GetPosition(user_data));
|
||||
|
||||
length = stream_get_length(tmps);
|
||||
length = Stream_GetPosition(tmps);
|
||||
ber_write_application_tag(s, MCS_TYPE_CONNECT_RESPONSE, length);
|
||||
stream_write(s, stream_get_head(tmps), length);
|
||||
stream_free(tmps);
|
||||
@ -465,11 +465,11 @@ BOOL mcs_send_connect_initial(rdpMcs* mcs)
|
||||
|
||||
gcc_CCrq = stream_new(512);
|
||||
gcc_write_conference_create_request(gcc_CCrq, client_data);
|
||||
length = stream_get_length(gcc_CCrq) + 7;
|
||||
length = Stream_GetPosition(gcc_CCrq) + 7;
|
||||
|
||||
s = transport_send_stream_init(mcs->transport, 1024);
|
||||
stream_get_mark(s, bm);
|
||||
stream_seek(s, 7);
|
||||
Stream_Seek(s, 7);
|
||||
|
||||
mcs_write_connect_initial(s, mcs, gcc_CCrq);
|
||||
stream_get_mark(s, em);
|
||||
@ -544,11 +544,11 @@ BOOL mcs_send_connect_response(rdpMcs* mcs)
|
||||
|
||||
gcc_CCrsp = stream_new(512);
|
||||
gcc_write_conference_create_response(gcc_CCrsp, server_data);
|
||||
length = stream_get_length(gcc_CCrsp) + 7;
|
||||
length = Stream_GetPosition(gcc_CCrsp) + 7;
|
||||
|
||||
s = transport_send_stream_init(mcs->transport, 1024);
|
||||
stream_get_mark(s, bm);
|
||||
stream_seek(s, 7);
|
||||
Stream_Seek(s, 7);
|
||||
|
||||
mcs_write_connect_response(s, mcs, gcc_CCrsp);
|
||||
stream_get_mark(s, em);
|
||||
|
@ -567,16 +567,16 @@ BOOL nego_read_request(rdpNego* nego, wStream* s)
|
||||
if (!tpdu_read_connection_request(s, &li))
|
||||
return FALSE;
|
||||
|
||||
if (li != stream_get_left(s) + 6)
|
||||
if (li != Stream_GetRemainingLength(s) + 6)
|
||||
{
|
||||
fprintf(stderr, "Incorrect TPDU length indicator.\n");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (stream_get_left(s) > 8)
|
||||
if (Stream_GetRemainingLength(s) > 8)
|
||||
{
|
||||
/* Optional routingToken or cookie, ending with CR+LF */
|
||||
while (stream_get_left(s) > 0)
|
||||
while (Stream_GetRemainingLength(s) > 0)
|
||||
{
|
||||
stream_read_BYTE(s, c);
|
||||
|
||||
@ -588,12 +588,12 @@ BOOL nego_read_request(rdpNego* nego, wStream* s)
|
||||
if (c != '\x0A')
|
||||
continue;
|
||||
|
||||
stream_seek_BYTE(s);
|
||||
Stream_Seek_BYTE(s);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (stream_get_left(s) >= 8)
|
||||
if (Stream_GetRemainingLength(s) >= 8)
|
||||
{
|
||||
/* rdpNegData (optional) */
|
||||
|
||||
@ -647,7 +647,7 @@ BOOL nego_send_negotiation_request(rdpNego* nego)
|
||||
s = transport_send_stream_init(nego->transport, 256);
|
||||
length = TPDU_CONNECTION_REQUEST_LENGTH;
|
||||
stream_get_mark(s, bm);
|
||||
stream_seek(s, length);
|
||||
Stream_Seek(s, length);
|
||||
|
||||
if (nego->RoutingToken)
|
||||
{
|
||||
@ -728,7 +728,7 @@ void nego_process_negotiation_response(rdpNego* nego, wStream* s)
|
||||
|
||||
DEBUG_NEGO("RDP_NEG_RSP");
|
||||
|
||||
if (stream_get_left(s) < 7)
|
||||
if (Stream_GetRemainingLength(s) < 7)
|
||||
{
|
||||
DEBUG_NEGO("RDP_INVALID_NEG_RSP");
|
||||
nego->state = NEGO_STATE_FAIL;
|
||||
@ -811,7 +811,7 @@ BOOL nego_send_negotiation_response(rdpNego* nego)
|
||||
s = transport_send_stream_init(nego->transport, 256);
|
||||
length = TPDU_CONNECTION_CONFIRM_LENGTH;
|
||||
stream_get_mark(s, bm);
|
||||
stream_seek(s, length);
|
||||
Stream_Seek(s, length);
|
||||
|
||||
if (nego->selected_protocol > PROTOCOL_RDP)
|
||||
{
|
||||
|
@ -818,7 +818,7 @@ void credssp_read_ts_password_creds(rdpCredssp* credssp, wStream* s)
|
||||
credssp->identity.DomainLength = (UINT32) length;
|
||||
credssp->identity.Domain = (UINT16*) malloc(length);
|
||||
CopyMemory(credssp->identity.Domain, s->pointer, credssp->identity.DomainLength);
|
||||
stream_seek(s, credssp->identity.DomainLength);
|
||||
Stream_Seek(s, credssp->identity.DomainLength);
|
||||
credssp->identity.DomainLength /= 2;
|
||||
|
||||
/* [1] userName (OCTET STRING) */
|
||||
@ -827,7 +827,7 @@ void credssp_read_ts_password_creds(rdpCredssp* credssp, wStream* s)
|
||||
credssp->identity.UserLength = (UINT32) length;
|
||||
credssp->identity.User = (UINT16*) malloc(length);
|
||||
CopyMemory(credssp->identity.User, s->pointer, credssp->identity.UserLength);
|
||||
stream_seek(s, credssp->identity.UserLength);
|
||||
Stream_Seek(s, credssp->identity.UserLength);
|
||||
credssp->identity.UserLength /= 2;
|
||||
|
||||
/* [2] password (OCTET STRING) */
|
||||
@ -836,7 +836,7 @@ void credssp_read_ts_password_creds(rdpCredssp* credssp, wStream* s)
|
||||
credssp->identity.PasswordLength = (UINT32) length;
|
||||
credssp->identity.Password = (UINT16*) malloc(length);
|
||||
CopyMemory(credssp->identity.Password, s->pointer, credssp->identity.PasswordLength);
|
||||
stream_seek(s, credssp->identity.PasswordLength);
|
||||
Stream_Seek(s, credssp->identity.PasswordLength);
|
||||
credssp->identity.PasswordLength /= 2;
|
||||
|
||||
credssp->identity.Flags = SEC_WINNT_AUTH_IDENTITY_UNICODE;
|
||||
@ -1148,7 +1148,7 @@ int credssp_recv(rdpCredssp* credssp)
|
||||
s = stream_new(4096);
|
||||
|
||||
status = transport_read(credssp->transport, s);
|
||||
s->capacity = status;
|
||||
Stream_Length(s) = status;
|
||||
|
||||
if (status < 0)
|
||||
{
|
||||
@ -1170,7 +1170,7 @@ int credssp_recv(rdpCredssp* credssp)
|
||||
!ber_read_sequence_tag(s, &length) || /* NegoDataItem */
|
||||
!ber_read_contextual_tag(s, 0, &length, TRUE) || /* [0] negoToken */
|
||||
!ber_read_octet_string_tag(s, &length) || /* OCTET STRING */
|
||||
stream_get_left(s) < length)
|
||||
Stream_GetRemainingLength(s) < length)
|
||||
return -1;
|
||||
sspi_SecBufferAlloc(&credssp->negoToken, length);
|
||||
stream_read(s, credssp->negoToken.pvBuffer, length);
|
||||
@ -1181,7 +1181,7 @@ int credssp_recv(rdpCredssp* credssp)
|
||||
if (ber_read_contextual_tag(s, 2, &length, TRUE) != FALSE)
|
||||
{
|
||||
if(!ber_read_octet_string_tag(s, &length) || /* OCTET STRING */
|
||||
stream_get_left(s) < length)
|
||||
Stream_GetRemainingLength(s) < length)
|
||||
return -1;
|
||||
sspi_SecBufferAlloc(&credssp->authInfo, length);
|
||||
stream_read(s, credssp->authInfo.pvBuffer, length);
|
||||
@ -1192,7 +1192,7 @@ int credssp_recv(rdpCredssp* credssp)
|
||||
if (ber_read_contextual_tag(s, 3, &length, TRUE) != FALSE)
|
||||
{
|
||||
if(!ber_read_octet_string_tag(s, &length) || /* OCTET STRING */
|
||||
stream_get_left(s) < length)
|
||||
Stream_GetRemainingLength(s) < length)
|
||||
return -1;
|
||||
sspi_SecBufferAlloc(&credssp->pubKeyAuth, length);
|
||||
stream_read(s, credssp->pubKeyAuth.pvBuffer, length);
|
||||
|
@ -152,14 +152,14 @@ static INLINE BOOL update_read_coord(wStream* s, INT32* coord, BOOL delta)
|
||||
|
||||
if (delta)
|
||||
{
|
||||
if (stream_get_left(s) < 1)
|
||||
if (Stream_GetRemainingLength(s) < 1)
|
||||
return FALSE;
|
||||
stream_read_BYTE(s, lsi8);
|
||||
*coord += lsi8;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (stream_get_left(s) < 2)
|
||||
if (Stream_GetRemainingLength(s) < 2)
|
||||
return FALSE;
|
||||
stream_read_UINT16(s, lsi16);
|
||||
*coord = lsi16;
|
||||
@ -171,7 +171,7 @@ static INLINE BOOL update_read_color(wStream* s, UINT32* color)
|
||||
{
|
||||
BYTE byte;
|
||||
|
||||
if (stream_get_left(s) < 3)
|
||||
if (Stream_GetRemainingLength(s) < 3)
|
||||
return FALSE;
|
||||
stream_read_BYTE(s, byte);
|
||||
*color = byte;
|
||||
@ -192,7 +192,7 @@ static INLINE void update_read_colorref(wStream* s, UINT32* color)
|
||||
*color |= (byte << 8);
|
||||
stream_read_BYTE(s, byte);
|
||||
*color |= (byte << 16);
|
||||
stream_seek_BYTE(s);
|
||||
Stream_Seek_BYTE(s);
|
||||
}
|
||||
|
||||
static INLINE void update_read_color_quad(wStream* s, UINT32* color)
|
||||
@ -205,20 +205,20 @@ static INLINE void update_read_color_quad(wStream* s, UINT32* color)
|
||||
*color |= (byte << 8);
|
||||
stream_read_BYTE(s, byte);
|
||||
*color |= byte;
|
||||
stream_seek_BYTE(s);
|
||||
Stream_Seek_BYTE(s);
|
||||
}
|
||||
|
||||
static INLINE BOOL update_read_2byte_unsigned(wStream* s, UINT32* value)
|
||||
{
|
||||
BYTE byte;
|
||||
|
||||
if (stream_get_left(s) < 1)
|
||||
if (Stream_GetRemainingLength(s) < 1)
|
||||
return FALSE;
|
||||
stream_read_BYTE(s, byte);
|
||||
|
||||
if (byte & 0x80)
|
||||
{
|
||||
if (stream_get_left(s) < 1)
|
||||
if (Stream_GetRemainingLength(s) < 1)
|
||||
return FALSE;
|
||||
|
||||
*value = (byte & 0x7F) << 8;
|
||||
@ -237,7 +237,7 @@ static INLINE BOOL update_read_2byte_signed(wStream* s, INT32* value)
|
||||
BYTE byte;
|
||||
BOOL negative;
|
||||
|
||||
if (stream_get_left(s) < 1)
|
||||
if (Stream_GetRemainingLength(s) < 1)
|
||||
return FALSE;
|
||||
|
||||
stream_read_BYTE(s, byte);
|
||||
@ -248,7 +248,7 @@ static INLINE BOOL update_read_2byte_signed(wStream* s, INT32* value)
|
||||
|
||||
if (byte & 0x80)
|
||||
{
|
||||
if (stream_get_left(s) < 1)
|
||||
if (Stream_GetRemainingLength(s) < 1)
|
||||
return FALSE;
|
||||
stream_read_BYTE(s, byte);
|
||||
*value = (*value << 8) | byte;
|
||||
@ -264,12 +264,12 @@ static INLINE BOOL update_read_4byte_unsigned(wStream* s, UINT32* value)
|
||||
BYTE byte;
|
||||
BYTE count;
|
||||
|
||||
if (stream_get_left(s) < 1)
|
||||
if (Stream_GetRemainingLength(s) < 1)
|
||||
return FALSE;
|
||||
stream_read_BYTE(s, byte);
|
||||
|
||||
count = (byte & 0xC0) >> 6;
|
||||
if (stream_get_left(s) < count)
|
||||
if (Stream_GetRemainingLength(s) < count)
|
||||
return FALSE;
|
||||
|
||||
switch (count)
|
||||
@ -312,7 +312,7 @@ static INLINE BOOL update_read_delta(wStream* s, INT32* value)
|
||||
{
|
||||
BYTE byte;
|
||||
|
||||
if (stream_get_left(s) < 1)
|
||||
if (Stream_GetRemainingLength(s) < 1)
|
||||
return FALSE;
|
||||
stream_read_BYTE(s, byte);
|
||||
|
||||
@ -323,7 +323,7 @@ static INLINE BOOL update_read_delta(wStream* s, INT32* value)
|
||||
|
||||
if (byte & 0x80)
|
||||
{
|
||||
if (stream_get_left(s) < 1)
|
||||
if (Stream_GetRemainingLength(s) < 1)
|
||||
return FALSE;
|
||||
stream_read_BYTE(s, byte);
|
||||
*value = (*value << 8) | byte;
|
||||
@ -350,35 +350,35 @@ static INLINE void update_seek_glyph_delta(wStream* s)
|
||||
stream_read_BYTE(s, byte);
|
||||
|
||||
if (byte & 0x80)
|
||||
stream_seek_BYTE(s);
|
||||
Stream_Seek_BYTE(s);
|
||||
}
|
||||
|
||||
static INLINE BOOL update_read_brush(wStream* s, rdpBrush* brush, BYTE fieldFlags)
|
||||
{
|
||||
if (fieldFlags & ORDER_FIELD_01)
|
||||
{
|
||||
if (stream_get_left(s) < 1)
|
||||
if (Stream_GetRemainingLength(s) < 1)
|
||||
return FALSE;
|
||||
stream_read_BYTE(s, brush->x);
|
||||
}
|
||||
|
||||
if (fieldFlags & ORDER_FIELD_02)
|
||||
{
|
||||
if (stream_get_left(s) < 1)
|
||||
if (Stream_GetRemainingLength(s) < 1)
|
||||
return FALSE;
|
||||
stream_read_BYTE(s, brush->y);
|
||||
}
|
||||
|
||||
if (fieldFlags & ORDER_FIELD_03)
|
||||
{
|
||||
if (stream_get_left(s) < 1)
|
||||
if (Stream_GetRemainingLength(s) < 1)
|
||||
return FALSE;
|
||||
stream_read_BYTE(s, brush->style);
|
||||
}
|
||||
|
||||
if (fieldFlags & ORDER_FIELD_04)
|
||||
{
|
||||
if (stream_get_left(s) < 1)
|
||||
if (Stream_GetRemainingLength(s) < 1)
|
||||
return FALSE;
|
||||
stream_read_BYTE(s, brush->hatch);
|
||||
}
|
||||
@ -395,7 +395,7 @@ static INLINE BOOL update_read_brush(wStream* s, rdpBrush* brush, BYTE fieldFlag
|
||||
|
||||
if (fieldFlags & ORDER_FIELD_05)
|
||||
{
|
||||
if (stream_get_left(s) < 7)
|
||||
if (Stream_GetRemainingLength(s) < 7)
|
||||
return FALSE;
|
||||
brush->data = (BYTE*) brush->p8x8;
|
||||
stream_read_BYTE(s, brush->data[7]);
|
||||
@ -422,10 +422,10 @@ static INLINE BOOL update_read_delta_rects(wStream* s, DELTA_RECT* rectangles, i
|
||||
|
||||
zeroBitsSize = ((number + 1) / 2);
|
||||
|
||||
if (stream_get_left(s) < zeroBitsSize)
|
||||
if (Stream_GetRemainingLength(s) < zeroBitsSize)
|
||||
return FALSE;
|
||||
stream_get_mark(s, zeroBits);
|
||||
stream_seek(s, zeroBitsSize);
|
||||
Stream_Seek(s, zeroBitsSize);
|
||||
|
||||
memset(rectangles, 0, sizeof(DELTA_RECT) * (number + 1));
|
||||
|
||||
@ -473,10 +473,10 @@ static INLINE BOOL update_read_delta_points(wStream* s, DELTA_POINT* points, int
|
||||
|
||||
zeroBitsSize = ((number + 3) / 4);
|
||||
|
||||
if (stream_get_left(s) < zeroBitsSize)
|
||||
if (Stream_GetRemainingLength(s) < zeroBitsSize)
|
||||
return FALSE;
|
||||
stream_get_mark(s, zeroBits);
|
||||
stream_seek(s, zeroBitsSize);
|
||||
Stream_Seek(s, zeroBitsSize);
|
||||
|
||||
memset(points, 0, sizeof(DELTA_POINT) * number);
|
||||
|
||||
@ -501,7 +501,7 @@ static INLINE BOOL update_read_delta_points(wStream* s, DELTA_POINT* points, int
|
||||
do {\
|
||||
if (orderInfo->fieldFlags & (1 << (NO-1))) \
|
||||
{ \
|
||||
if (stream_get_left(s) < 1) {\
|
||||
if (Stream_GetRemainingLength(s) < 1) {\
|
||||
fprintf(stderr, "%s: error reading %s\n", __FUNCTION__, #TARGET); \
|
||||
return FALSE; \
|
||||
} \
|
||||
@ -513,7 +513,7 @@ static INLINE BOOL update_read_delta_points(wStream* s, DELTA_POINT* points, int
|
||||
do {\
|
||||
if (orderInfo->fieldFlags & (1 << (NO-1))) \
|
||||
{ \
|
||||
if (stream_get_left(s) < 2) { \
|
||||
if (Stream_GetRemainingLength(s) < 2) { \
|
||||
fprintf(stderr, "%s: error reading %s or %s\n", __FUNCTION__, #TARGET1, #TARGET2); \
|
||||
return FALSE; \
|
||||
} \
|
||||
@ -526,7 +526,7 @@ static INLINE BOOL update_read_delta_points(wStream* s, DELTA_POINT* points, int
|
||||
do {\
|
||||
if (orderInfo->fieldFlags & (1 << (NO-1))) \
|
||||
{ \
|
||||
if (stream_get_left(s) < 2) { \
|
||||
if (Stream_GetRemainingLength(s) < 2) { \
|
||||
fprintf(stderr, "%s: error reading %s\n", __FUNCTION__, #TARGET); \
|
||||
return FALSE; \
|
||||
} \
|
||||
@ -537,7 +537,7 @@ static INLINE BOOL update_read_delta_points(wStream* s, DELTA_POINT* points, int
|
||||
do {\
|
||||
if (orderInfo->fieldFlags & (1 << (NO-1))) \
|
||||
{ \
|
||||
if (stream_get_left(s) < 4) { \
|
||||
if (Stream_GetRemainingLength(s) < 4) { \
|
||||
fprintf(stderr, "%s: error reading %s\n", __FUNCTION__, #TARGET); \
|
||||
return FALSE; \
|
||||
} \
|
||||
@ -563,7 +563,7 @@ static INLINE BOOL update_read_delta_points(wStream* s, DELTA_POINT* points, int
|
||||
|
||||
#define FIELD_SKIP_BUFFER16(s, TARGET_LEN) \
|
||||
do { \
|
||||
if (stream_get_left(s) < 2) {\
|
||||
if (Stream_GetRemainingLength(s) < 2) {\
|
||||
fprintf(stderr, "%s: error reading length %s\n", __FUNCTION__, #TARGET_LEN); \
|
||||
return FALSE; \
|
||||
}\
|
||||
@ -621,21 +621,21 @@ BOOL update_read_opaque_rect_order(wStream* s, ORDER_INFO* orderInfo, OPAQUE_REC
|
||||
|
||||
if (orderInfo->fieldFlags & ORDER_FIELD_05)
|
||||
{
|
||||
if (stream_get_left(s) < 1)
|
||||
if (Stream_GetRemainingLength(s) < 1)
|
||||
return FALSE;
|
||||
stream_read_BYTE(s, byte);
|
||||
opaque_rect->color = (opaque_rect->color & 0xFFFFFF00) | byte;
|
||||
}
|
||||
|
||||
if (orderInfo->fieldFlags & ORDER_FIELD_06) {
|
||||
if (stream_get_left(s) < 1)
|
||||
if (Stream_GetRemainingLength(s) < 1)
|
||||
return FALSE;
|
||||
stream_read_BYTE(s, byte);
|
||||
opaque_rect->color = (opaque_rect->color & 0xFFFF00FF) | (byte << 8);
|
||||
}
|
||||
|
||||
if (orderInfo->fieldFlags & ORDER_FIELD_07) {
|
||||
if (stream_get_left(s) < 1)
|
||||
if (Stream_GetRemainingLength(s) < 1)
|
||||
return FALSE;
|
||||
stream_read_BYTE(s, byte);
|
||||
opaque_rect->color = (opaque_rect->color & 0xFF00FFFF) | (byte << 16);
|
||||
@ -664,7 +664,7 @@ BOOL update_read_multi_dstblt_order(wStream* s, ORDER_INFO* orderInfo, MULTI_DST
|
||||
|
||||
if (orderInfo->fieldFlags & ORDER_FIELD_07)
|
||||
{
|
||||
if (stream_get_left(s) < 2)
|
||||
if (Stream_GetRemainingLength(s) < 2)
|
||||
return FALSE;
|
||||
stream_read_UINT16(s, multi_dstblt->cbData);
|
||||
return update_read_delta_rects(s, multi_dstblt->rectangles, multi_dstblt->numRectangles);
|
||||
@ -689,7 +689,7 @@ BOOL update_read_multi_patblt_order(wStream* s, ORDER_INFO* orderInfo, MULTI_PAT
|
||||
|
||||
if (orderInfo->fieldFlags & ORDER_FIELD_14)
|
||||
{
|
||||
if (stream_get_left(s) < 2)
|
||||
if (Stream_GetRemainingLength(s) < 2)
|
||||
return FALSE;
|
||||
stream_read_UINT16(s, multi_patblt->cbData);
|
||||
if (!update_read_delta_rects(s, multi_patblt->rectangles, multi_patblt->numRectangles))
|
||||
@ -711,7 +711,7 @@ BOOL update_read_multi_scrblt_order(wStream* s, ORDER_INFO* orderInfo, MULTI_SCR
|
||||
|
||||
if (orderInfo->fieldFlags & ORDER_FIELD_09)
|
||||
{
|
||||
if (stream_get_left(s) < 2)
|
||||
if (Stream_GetRemainingLength(s) < 2)
|
||||
return FALSE;
|
||||
stream_read_UINT16(s, multi_scrblt->cbData);
|
||||
return update_read_delta_rects(s, multi_scrblt->rectangles, multi_scrblt->numRectangles);
|
||||
@ -729,7 +729,7 @@ BOOL update_read_multi_opaque_rect_order(wStream* s, ORDER_INFO* orderInfo, MULT
|
||||
|
||||
if (orderInfo->fieldFlags & ORDER_FIELD_05)
|
||||
{
|
||||
if (stream_get_left(s) < 1)
|
||||
if (Stream_GetRemainingLength(s) < 1)
|
||||
return FALSE;
|
||||
stream_read_BYTE(s, byte);
|
||||
multi_opaque_rect->color = (multi_opaque_rect->color & 0xFFFFFF00) | byte;
|
||||
@ -737,7 +737,7 @@ BOOL update_read_multi_opaque_rect_order(wStream* s, ORDER_INFO* orderInfo, MULT
|
||||
|
||||
if (orderInfo->fieldFlags & ORDER_FIELD_06)
|
||||
{
|
||||
if (stream_get_left(s) < 1)
|
||||
if (Stream_GetRemainingLength(s) < 1)
|
||||
return FALSE;
|
||||
stream_read_BYTE(s, byte);
|
||||
multi_opaque_rect->color = (multi_opaque_rect->color & 0xFFFF00FF) | (byte << 8);
|
||||
@ -745,7 +745,7 @@ BOOL update_read_multi_opaque_rect_order(wStream* s, ORDER_INFO* orderInfo, MULT
|
||||
|
||||
if (orderInfo->fieldFlags & ORDER_FIELD_07)
|
||||
{
|
||||
if (stream_get_left(s) < 1)
|
||||
if (Stream_GetRemainingLength(s) < 1)
|
||||
return FALSE;
|
||||
stream_read_BYTE(s, byte);
|
||||
multi_opaque_rect->color = (multi_opaque_rect->color & 0xFF00FFFF) | (byte << 16);
|
||||
@ -755,7 +755,7 @@ BOOL update_read_multi_opaque_rect_order(wStream* s, ORDER_INFO* orderInfo, MULT
|
||||
|
||||
if (orderInfo->fieldFlags & ORDER_FIELD_09)
|
||||
{
|
||||
if (stream_get_left(s) < 2)
|
||||
if (Stream_GetRemainingLength(s) < 2)
|
||||
return FALSE;
|
||||
stream_read_UINT16(s, multi_opaque_rect->cbData);
|
||||
return update_read_delta_rects(s, multi_opaque_rect->rectangles, multi_opaque_rect->numRectangles);
|
||||
@ -808,7 +808,7 @@ BOOL update_read_polyline_order(wStream* s, ORDER_INFO* orderInfo, POLYLINE_ORDE
|
||||
|
||||
if (orderInfo->fieldFlags & ORDER_FIELD_07)
|
||||
{
|
||||
if (stream_get_left(s) < 1)
|
||||
if (Stream_GetRemainingLength(s) < 1)
|
||||
return FALSE;
|
||||
stream_read_BYTE(s, polyline->cbData);
|
||||
|
||||
@ -897,14 +897,14 @@ BOOL update_read_glyph_index_order(wStream* s, ORDER_INFO* orderInfo, GLYPH_INDE
|
||||
|
||||
if (orderInfo->fieldFlags & ORDER_FIELD_22)
|
||||
{
|
||||
if (stream_get_left(s) < 1)
|
||||
if (Stream_GetRemainingLength(s) < 1)
|
||||
return FALSE;
|
||||
stream_read_BYTE(s, glyph_index->cbData);
|
||||
|
||||
if (stream_get_left(s) < glyph_index->cbData)
|
||||
if (Stream_GetRemainingLength(s) < glyph_index->cbData)
|
||||
return FALSE;
|
||||
memcpy(glyph_index->data, s->pointer, glyph_index->cbData);
|
||||
stream_seek(s, glyph_index->cbData);
|
||||
Stream_Seek(s, glyph_index->cbData);
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
@ -928,14 +928,14 @@ BOOL update_read_fast_index_order(wStream* s, ORDER_INFO* orderInfo, FAST_INDEX_
|
||||
|
||||
if (orderInfo->fieldFlags & ORDER_FIELD_15)
|
||||
{
|
||||
if (stream_get_left(s) < 1)
|
||||
if (Stream_GetRemainingLength(s) < 1)
|
||||
return FALSE;
|
||||
stream_read_BYTE(s, fast_index->cbData);
|
||||
|
||||
if (stream_get_left(s) < fast_index->cbData)
|
||||
if (Stream_GetRemainingLength(s) < fast_index->cbData)
|
||||
return FALSE;
|
||||
memcpy(fast_index->data, s->pointer, fast_index->cbData);
|
||||
stream_seek(s, fast_index->cbData);
|
||||
Stream_Seek(s, fast_index->cbData);
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
@ -962,12 +962,12 @@ BOOL update_read_fast_glyph_order(wStream* s, ORDER_INFO* orderInfo, FAST_GLYPH_
|
||||
|
||||
if (orderInfo->fieldFlags & ORDER_FIELD_15)
|
||||
{
|
||||
if (stream_get_left(s) < 1)
|
||||
if (Stream_GetRemainingLength(s) < 1)
|
||||
return FALSE;
|
||||
|
||||
stream_read_BYTE(s, fast_glyph->cbData);
|
||||
|
||||
if (stream_get_left(s) < fast_glyph->cbData)
|
||||
if (Stream_GetRemainingLength(s) < fast_glyph->cbData)
|
||||
return FALSE;
|
||||
|
||||
memcpy(fast_glyph->data, s->pointer, fast_glyph->cbData);
|
||||
@ -991,7 +991,7 @@ BOOL update_read_fast_glyph_order(wStream* s, ORDER_INFO* orderInfo, FAST_GLYPH_
|
||||
glyph->cb = ((glyph->cx + 7) / 8) * glyph->cy;
|
||||
glyph->cb += ((glyph->cb % 4) > 0) ? 4 - (glyph->cb % 4) : 0;
|
||||
|
||||
if (stream_get_left(s) < glyph->cb)
|
||||
if (Stream_GetRemainingLength(s) < glyph->cb)
|
||||
return FALSE;
|
||||
|
||||
glyph->aj = (BYTE*) malloc(glyph->cb);
|
||||
@ -1014,7 +1014,7 @@ BOOL update_read_polygon_sc_order(wStream* s, ORDER_INFO* orderInfo, POLYGON_SC_
|
||||
|
||||
if (orderInfo->fieldFlags & ORDER_FIELD_07)
|
||||
{
|
||||
if (stream_get_left(s) < 1)
|
||||
if (Stream_GetRemainingLength(s) < 1)
|
||||
return FALSE;
|
||||
stream_read_BYTE(s, polygon_sc->cbData);
|
||||
|
||||
@ -1044,7 +1044,7 @@ BOOL update_read_polygon_cb_order(wStream* s, ORDER_INFO* orderInfo, POLYGON_CB_
|
||||
|
||||
if (orderInfo->fieldFlags & ORDER_FIELD_13)
|
||||
{
|
||||
if (stream_get_left(s) < 1)
|
||||
if (Stream_GetRemainingLength(s) < 1)
|
||||
return FALSE;
|
||||
stream_read_BYTE(s, polygon_cb->cbData);
|
||||
|
||||
@ -1091,10 +1091,10 @@ BOOL update_read_ellipse_cb_order(wStream* s, ORDER_INFO* orderInfo, ELLIPSE_CB_
|
||||
|
||||
BOOL update_read_cache_bitmap_order(wStream* s, CACHE_BITMAP_ORDER* cache_bitmap_order, BOOL compressed, UINT16 flags)
|
||||
{
|
||||
if (stream_get_left(s) < 9)
|
||||
if (Stream_GetRemainingLength(s) < 9)
|
||||
return FALSE;
|
||||
stream_read_BYTE(s, cache_bitmap_order->cacheId); /* cacheId (1 byte) */
|
||||
stream_seek_BYTE(s); /* pad1Octet (1 byte) */
|
||||
Stream_Seek_BYTE(s); /* pad1Octet (1 byte) */
|
||||
stream_read_BYTE(s, cache_bitmap_order->bitmapWidth); /* bitmapWidth (1 byte) */
|
||||
stream_read_BYTE(s, cache_bitmap_order->bitmapHeight); /* bitmapHeight (1 byte) */
|
||||
stream_read_BYTE(s, cache_bitmap_order->bitmapBpp); /* bitmapBpp (1 byte) */
|
||||
@ -1106,25 +1106,25 @@ BOOL update_read_cache_bitmap_order(wStream* s, CACHE_BITMAP_ORDER* cache_bitmap
|
||||
if ((flags & NO_BITMAP_COMPRESSION_HDR) == 0)
|
||||
{
|
||||
BYTE* bitmapComprHdr = (BYTE*) &(cache_bitmap_order->bitmapComprHdr);
|
||||
if (stream_get_left(s) < 8)
|
||||
if (Stream_GetRemainingLength(s) < 8)
|
||||
return FALSE;
|
||||
stream_read(s, bitmapComprHdr, 8); /* bitmapComprHdr (8 bytes) */
|
||||
cache_bitmap_order->bitmapLength -= 8;
|
||||
}
|
||||
|
||||
if (stream_get_left(s) < cache_bitmap_order->bitmapLength)
|
||||
if (Stream_GetRemainingLength(s) < cache_bitmap_order->bitmapLength)
|
||||
return FALSE;
|
||||
|
||||
stream_get_mark(s, cache_bitmap_order->bitmapDataStream);
|
||||
stream_seek(s, cache_bitmap_order->bitmapLength);
|
||||
Stream_Seek(s, cache_bitmap_order->bitmapLength);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (stream_get_left(s) < cache_bitmap_order->bitmapLength)
|
||||
if (Stream_GetRemainingLength(s) < cache_bitmap_order->bitmapLength)
|
||||
return FALSE;
|
||||
|
||||
stream_get_mark(s, cache_bitmap_order->bitmapDataStream);
|
||||
stream_seek(s, cache_bitmap_order->bitmapLength); /* bitmapDataStream */
|
||||
Stream_Seek(s, cache_bitmap_order->bitmapLength); /* bitmapDataStream */
|
||||
}
|
||||
cache_bitmap_order->compressed = compressed;
|
||||
return TRUE;
|
||||
@ -1142,7 +1142,7 @@ BOOL update_read_cache_bitmap_v2_order(wStream* s, CACHE_BITMAP_V2_ORDER* cache_
|
||||
|
||||
if (cache_bitmap_v2_order->flags & CBR2_PERSISTENT_KEY_PRESENT)
|
||||
{
|
||||
if (stream_get_left(s) < 8)
|
||||
if (Stream_GetRemainingLength(s) < 8)
|
||||
return FALSE;
|
||||
stream_read_UINT32(s, cache_bitmap_v2_order->key1); /* key1 (4 bytes) */
|
||||
stream_read_UINT32(s, cache_bitmap_v2_order->key2); /* key2 (4 bytes) */
|
||||
@ -1172,7 +1172,7 @@ BOOL update_read_cache_bitmap_v2_order(wStream* s, CACHE_BITMAP_V2_ORDER* cache_
|
||||
{
|
||||
if (!(cache_bitmap_v2_order->flags & CBR2_NO_BITMAP_COMPRESSION_HDR))
|
||||
{
|
||||
if (stream_get_left(s) < 8)
|
||||
if (Stream_GetRemainingLength(s) < 8)
|
||||
return FALSE;
|
||||
|
||||
stream_read_UINT16(s, cache_bitmap_v2_order->cbCompFirstRowSize); /* cbCompFirstRowSize (2 bytes) */
|
||||
@ -1182,17 +1182,17 @@ BOOL update_read_cache_bitmap_v2_order(wStream* s, CACHE_BITMAP_V2_ORDER* cache_
|
||||
cache_bitmap_v2_order->bitmapLength = cache_bitmap_v2_order->cbCompMainBodySize;
|
||||
}
|
||||
|
||||
if (stream_get_left(s) < cache_bitmap_v2_order->bitmapLength)
|
||||
if (Stream_GetRemainingLength(s) < cache_bitmap_v2_order->bitmapLength)
|
||||
return FALSE;
|
||||
stream_get_mark(s, cache_bitmap_v2_order->bitmapDataStream);
|
||||
stream_seek(s, cache_bitmap_v2_order->bitmapLength);
|
||||
Stream_Seek(s, cache_bitmap_v2_order->bitmapLength);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (stream_get_left(s) < cache_bitmap_v2_order->bitmapLength)
|
||||
if (Stream_GetRemainingLength(s) < cache_bitmap_v2_order->bitmapLength)
|
||||
return FALSE;
|
||||
stream_get_mark(s, cache_bitmap_v2_order->bitmapDataStream);
|
||||
stream_seek(s, cache_bitmap_v2_order->bitmapLength);
|
||||
Stream_Seek(s, cache_bitmap_v2_order->bitmapLength);
|
||||
}
|
||||
cache_bitmap_v2_order->compressed = compressed;
|
||||
return TRUE;
|
||||
@ -1209,7 +1209,7 @@ BOOL update_read_cache_bitmap_v3_order(wStream* s, CACHE_BITMAP_V3_ORDER* cache_
|
||||
bitsPerPixelId = (flags & 0x00000078) >> 3;
|
||||
cache_bitmap_v3_order->bpp = CBR23_BPP[bitsPerPixelId];
|
||||
|
||||
if (stream_get_left(s) < 21)
|
||||
if (Stream_GetRemainingLength(s) < 21)
|
||||
return FALSE;
|
||||
stream_read_UINT16(s, cache_bitmap_v3_order->cacheIndex); /* cacheIndex (2 bytes) */
|
||||
stream_read_UINT32(s, cache_bitmap_v3_order->key1); /* key1 (4 bytes) */
|
||||
@ -1218,14 +1218,14 @@ BOOL update_read_cache_bitmap_v3_order(wStream* s, CACHE_BITMAP_V3_ORDER* cache_
|
||||
bitmapData = &cache_bitmap_v3_order->bitmapData;
|
||||
|
||||
stream_read_BYTE(s, bitmapData->bpp);
|
||||
stream_seek_BYTE(s); /* reserved1 (1 byte) */
|
||||
stream_seek_BYTE(s); /* reserved2 (1 byte) */
|
||||
Stream_Seek_BYTE(s); /* reserved1 (1 byte) */
|
||||
Stream_Seek_BYTE(s); /* reserved2 (1 byte) */
|
||||
stream_read_BYTE(s, bitmapData->codecID); /* codecID (1 byte) */
|
||||
stream_read_UINT16(s, bitmapData->width); /* width (2 bytes) */
|
||||
stream_read_UINT16(s, bitmapData->height); /* height (2 bytes) */
|
||||
stream_read_UINT32(s, bitmapData->length); /* length (4 bytes) */
|
||||
|
||||
if (stream_get_left(s) < bitmapData->length)
|
||||
if (Stream_GetRemainingLength(s) < bitmapData->length)
|
||||
return FALSE;
|
||||
if (bitmapData->data == NULL)
|
||||
bitmapData->data = (BYTE*) malloc(bitmapData->length);
|
||||
@ -1241,7 +1241,7 @@ BOOL update_read_cache_color_table_order(wStream* s, CACHE_COLOR_TABLE_ORDER* ca
|
||||
int i;
|
||||
UINT32* colorTable;
|
||||
|
||||
if (stream_get_left(s) < 3)
|
||||
if (Stream_GetRemainingLength(s) < 3)
|
||||
return FALSE;
|
||||
|
||||
stream_read_BYTE(s, cache_color_table_order->cacheIndex); /* cacheIndex (1 byte) */
|
||||
@ -1253,7 +1253,7 @@ BOOL update_read_cache_color_table_order(wStream* s, CACHE_COLOR_TABLE_ORDER* ca
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (stream_get_left(s) < cache_color_table_order->numberColors * 4)
|
||||
if (Stream_GetRemainingLength(s) < cache_color_table_order->numberColors * 4)
|
||||
return FALSE;
|
||||
|
||||
colorTable = (UINT32*) &cache_color_table_order->colorTable;
|
||||
@ -1272,7 +1272,7 @@ BOOL update_read_cache_glyph_order(wStream* s, CACHE_GLYPH_ORDER* cache_glyph_or
|
||||
INT16 lsi16;
|
||||
GLYPH_DATA* glyph;
|
||||
|
||||
if (stream_get_left(s) < 2)
|
||||
if (Stream_GetRemainingLength(s) < 2)
|
||||
return FALSE;
|
||||
|
||||
stream_read_BYTE(s, cache_glyph_order->cacheId); /* cacheId (1 byte) */
|
||||
@ -1282,7 +1282,7 @@ BOOL update_read_cache_glyph_order(wStream* s, CACHE_GLYPH_ORDER* cache_glyph_or
|
||||
{
|
||||
glyph = &cache_glyph_order->glyphData[i];
|
||||
|
||||
if (stream_get_left(s) < 10)
|
||||
if (Stream_GetRemainingLength(s) < 10)
|
||||
return FALSE;
|
||||
|
||||
stream_read_UINT16(s, glyph->cacheIndex);
|
||||
@ -1296,7 +1296,7 @@ BOOL update_read_cache_glyph_order(wStream* s, CACHE_GLYPH_ORDER* cache_glyph_or
|
||||
glyph->cb = ((glyph->cx + 7) / 8) * glyph->cy;
|
||||
glyph->cb += ((glyph->cb % 4) > 0) ? 4 - (glyph->cb % 4) : 0;
|
||||
|
||||
if (stream_get_left(s) < glyph->cb)
|
||||
if (Stream_GetRemainingLength(s) < glyph->cb)
|
||||
return FALSE;
|
||||
|
||||
glyph->aj = (BYTE*) malloc(glyph->cb);
|
||||
@ -1324,7 +1324,7 @@ BOOL update_read_cache_glyph_v2_order(wStream* s, CACHE_GLYPH_V2_ORDER* cache_gl
|
||||
{
|
||||
glyph = &cache_glyph_v2_order->glyphData[i];
|
||||
|
||||
if (stream_get_left(s) < 1)
|
||||
if (Stream_GetRemainingLength(s) < 1)
|
||||
return FALSE;
|
||||
|
||||
stream_read_BYTE(s, glyph->cacheIndex);
|
||||
@ -1340,7 +1340,7 @@ BOOL update_read_cache_glyph_v2_order(wStream* s, CACHE_GLYPH_V2_ORDER* cache_gl
|
||||
glyph->cb = ((glyph->cx + 7) / 8) * glyph->cy;
|
||||
glyph->cb += ((glyph->cb % 4) > 0) ? 4 - (glyph->cb % 4) : 0;
|
||||
|
||||
if (stream_get_left(s) < glyph->cb)
|
||||
if (Stream_GetRemainingLength(s) < glyph->cb)
|
||||
return FALSE;
|
||||
|
||||
glyph->aj = (BYTE*) malloc(glyph->cb);
|
||||
@ -1366,7 +1366,7 @@ BOOL update_decompress_brush(wStream* s, BYTE* output, BYTE bpp)
|
||||
palette = s->pointer + 16;
|
||||
bytesPerPixel = ((bpp + 1) / 8);
|
||||
|
||||
if (stream_get_left(s) < 16) // 64 / 4
|
||||
if (Stream_GetRemainingLength(s) < 16) // 64 / 4
|
||||
return FALSE;
|
||||
|
||||
for (y = 7; y >= 0; y--)
|
||||
@ -1394,7 +1394,7 @@ BOOL update_read_cache_brush_order(wStream* s, CACHE_BRUSH_ORDER* cache_brush_or
|
||||
BYTE iBitmapFormat;
|
||||
BOOL compressed = FALSE;
|
||||
|
||||
if (stream_get_left(s) < 6)
|
||||
if (Stream_GetRemainingLength(s) < 6)
|
||||
return FALSE;
|
||||
|
||||
stream_read_BYTE(s, cache_brush_order->index); /* cacheEntry (1 byte) */
|
||||
@ -1420,7 +1420,7 @@ BOOL update_read_cache_brush_order(wStream* s, CACHE_BRUSH_ORDER* cache_brush_or
|
||||
}
|
||||
|
||||
/* rows are encoded in reverse order */
|
||||
if (stream_get_left(s) < 8)
|
||||
if (Stream_GetRemainingLength(s) < 8)
|
||||
return FALSE;
|
||||
|
||||
for (i = 7; i >= 0; i--)
|
||||
@ -1448,7 +1448,7 @@ BOOL update_read_cache_brush_order(wStream* s, CACHE_BRUSH_ORDER* cache_brush_or
|
||||
/* uncompressed brush */
|
||||
int scanline = (cache_brush_order->bpp / 8) * 8;
|
||||
|
||||
if (stream_get_left(s) < scanline * 8)
|
||||
if (Stream_GetRemainingLength(s) < scanline * 8)
|
||||
return FALSE;
|
||||
|
||||
for (i = 7; i >= 0; i--)
|
||||
@ -1470,7 +1470,7 @@ BOOL update_read_create_offscreen_bitmap_order(wStream* s, CREATE_OFFSCREEN_BITM
|
||||
BOOL deleteListPresent;
|
||||
OFFSCREEN_DELETE_LIST* deleteList;
|
||||
|
||||
if (stream_get_left(s) < 6)
|
||||
if (Stream_GetRemainingLength(s) < 6)
|
||||
return FALSE;
|
||||
stream_read_UINT16(s, flags); /* flags (2 bytes) */
|
||||
create_offscreen_bitmap->id = flags & 0x7FFF;
|
||||
@ -1483,7 +1483,7 @@ BOOL update_read_create_offscreen_bitmap_order(wStream* s, CREATE_OFFSCREEN_BITM
|
||||
if (deleteListPresent)
|
||||
{
|
||||
int i;
|
||||
if (stream_get_left(s) < 2)
|
||||
if (Stream_GetRemainingLength(s) < 2)
|
||||
return FALSE;
|
||||
stream_read_UINT16(s, deleteList->cIndices);
|
||||
|
||||
@ -1493,7 +1493,7 @@ BOOL update_read_create_offscreen_bitmap_order(wStream* s, CREATE_OFFSCREEN_BITM
|
||||
deleteList->indices = realloc(deleteList->indices, deleteList->sIndices * 2);
|
||||
}
|
||||
|
||||
if (stream_get_left(s) < 2 * deleteList->cIndices)
|
||||
if (Stream_GetRemainingLength(s) < 2 * deleteList->cIndices)
|
||||
return FALSE;
|
||||
|
||||
for (i = 0; i < (int) deleteList->cIndices; i++)
|
||||
@ -1510,7 +1510,7 @@ BOOL update_read_create_offscreen_bitmap_order(wStream* s, CREATE_OFFSCREEN_BITM
|
||||
|
||||
BOOL update_read_switch_surface_order(wStream* s, SWITCH_SURFACE_ORDER* switch_surface)
|
||||
{
|
||||
if (stream_get_left(s) < 2)
|
||||
if (Stream_GetRemainingLength(s) < 2)
|
||||
return FALSE;
|
||||
stream_read_UINT16(s, switch_surface->bitmapId); /* bitmapId (2 bytes) */
|
||||
return TRUE;
|
||||
@ -1520,7 +1520,7 @@ BOOL update_read_create_nine_grid_bitmap_order(wStream* s, CREATE_NINE_GRID_BITM
|
||||
{
|
||||
NINE_GRID_BITMAP_INFO* nineGridInfo;
|
||||
|
||||
if (stream_get_left(s) < 19)
|
||||
if (Stream_GetRemainingLength(s) < 19)
|
||||
return FALSE;
|
||||
stream_read_BYTE(s, create_nine_grid_bitmap->bitmapBpp); /* bitmapBpp (1 byte) */
|
||||
stream_read_UINT16(s, create_nine_grid_bitmap->bitmapId); /* bitmapId (2 bytes) */
|
||||
@ -1537,7 +1537,7 @@ BOOL update_read_create_nine_grid_bitmap_order(wStream* s, CREATE_NINE_GRID_BITM
|
||||
|
||||
BOOL update_read_frame_marker_order(wStream* s, FRAME_MARKER_ORDER* frame_marker)
|
||||
{
|
||||
if (stream_get_left(s) < 4)
|
||||
if (Stream_GetRemainingLength(s) < 4)
|
||||
return FALSE;
|
||||
stream_read_UINT32(s, frame_marker->action); /* action (4 bytes) */
|
||||
return TRUE;
|
||||
@ -1545,7 +1545,7 @@ BOOL update_read_frame_marker_order(wStream* s, FRAME_MARKER_ORDER* frame_marker
|
||||
|
||||
BOOL update_read_stream_bitmap_first_order(wStream* s, STREAM_BITMAP_FIRST_ORDER* stream_bitmap_first)
|
||||
{
|
||||
if (stream_get_left(s) < 10) // 8 + 2 at least
|
||||
if (Stream_GetRemainingLength(s) < 10) // 8 + 2 at least
|
||||
return FALSE;
|
||||
stream_read_BYTE(s, stream_bitmap_first->bitmapFlags); /* bitmapFlags (1 byte) */
|
||||
stream_read_BYTE(s, stream_bitmap_first->bitmapBpp); /* bitmapBpp (1 byte) */
|
||||
@ -1554,11 +1554,11 @@ BOOL update_read_stream_bitmap_first_order(wStream* s, STREAM_BITMAP_FIRST_ORDER
|
||||
stream_read_UINT16(s, stream_bitmap_first->bitmapHeight); /* bitmapHeigth (2 bytes) */
|
||||
|
||||
if (stream_bitmap_first->bitmapFlags & STREAM_BITMAP_V2) {
|
||||
if (stream_get_left(s) < 4)
|
||||
if (Stream_GetRemainingLength(s) < 4)
|
||||
return FALSE;
|
||||
stream_read_UINT32(s, stream_bitmap_first->bitmapSize); /* bitmapSize (4 bytes) */
|
||||
} else {
|
||||
if (stream_get_left(s) < 2)
|
||||
if (Stream_GetRemainingLength(s) < 2)
|
||||
return FALSE;
|
||||
stream_read_UINT16(s, stream_bitmap_first->bitmapSize); /* bitmapSize (2 bytes) */
|
||||
}
|
||||
@ -1569,7 +1569,7 @@ BOOL update_read_stream_bitmap_first_order(wStream* s, STREAM_BITMAP_FIRST_ORDER
|
||||
|
||||
BOOL update_read_stream_bitmap_next_order(wStream* s, STREAM_BITMAP_NEXT_ORDER* stream_bitmap_next)
|
||||
{
|
||||
if (stream_get_left(s) < 5)
|
||||
if (Stream_GetRemainingLength(s) < 5)
|
||||
return FALSE;
|
||||
stream_read_BYTE(s, stream_bitmap_next->bitmapFlags); /* bitmapFlags (1 byte) */
|
||||
stream_read_UINT16(s, stream_bitmap_next->bitmapType); /* bitmapType (2 bytes) */
|
||||
@ -1579,9 +1579,9 @@ BOOL update_read_stream_bitmap_next_order(wStream* s, STREAM_BITMAP_NEXT_ORDER*
|
||||
|
||||
BOOL update_read_draw_gdiplus_first_order(wStream* s, DRAW_GDIPLUS_FIRST_ORDER* draw_gdiplus_first)
|
||||
{
|
||||
if (stream_get_left(s) < 11)
|
||||
if (Stream_GetRemainingLength(s) < 11)
|
||||
return FALSE;
|
||||
stream_seek_BYTE(s); /* pad1Octet (1 byte) */
|
||||
Stream_Seek_BYTE(s); /* pad1Octet (1 byte) */
|
||||
stream_read_UINT16(s, draw_gdiplus_first->cbSize); /* cbSize (2 bytes) */
|
||||
stream_read_UINT32(s, draw_gdiplus_first->cbTotalSize); /* cbTotalSize (4 bytes) */
|
||||
stream_read_UINT32(s, draw_gdiplus_first->cbTotalEmfSize); /* cbTotalEmfSize (4 bytes) */
|
||||
@ -1591,18 +1591,18 @@ BOOL update_read_draw_gdiplus_first_order(wStream* s, DRAW_GDIPLUS_FIRST_ORDER*
|
||||
|
||||
BOOL update_read_draw_gdiplus_next_order(wStream* s, DRAW_GDIPLUS_NEXT_ORDER* draw_gdiplus_next)
|
||||
{
|
||||
if (stream_get_left(s) < 3)
|
||||
if (Stream_GetRemainingLength(s) < 3)
|
||||
return FALSE;
|
||||
stream_seek_BYTE(s); /* pad1Octet (1 byte) */
|
||||
Stream_Seek_BYTE(s); /* pad1Octet (1 byte) */
|
||||
FIELD_SKIP_BUFFER16(s, draw_gdiplus_next->cbSize); /* cbSize(2 bytes) + emfRecords */
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL update_read_draw_gdiplus_end_order(wStream* s, DRAW_GDIPLUS_END_ORDER* draw_gdiplus_end)
|
||||
{
|
||||
if (stream_get_left(s) < 11)
|
||||
if (Stream_GetRemainingLength(s) < 11)
|
||||
return FALSE;
|
||||
stream_seek_BYTE(s); /* pad1Octet (1 byte) */
|
||||
Stream_Seek_BYTE(s); /* pad1Octet (1 byte) */
|
||||
stream_read_UINT16(s, draw_gdiplus_end->cbSize); /* cbSize (2 bytes) */
|
||||
stream_read_UINT32(s, draw_gdiplus_end->cbTotalSize); /* cbTotalSize (4 bytes) */
|
||||
stream_read_UINT32(s, draw_gdiplus_end->cbTotalEmfSize); /* cbTotalEmfSize (4 bytes) */
|
||||
@ -1612,7 +1612,7 @@ BOOL update_read_draw_gdiplus_end_order(wStream* s, DRAW_GDIPLUS_END_ORDER* draw
|
||||
|
||||
BOOL update_read_draw_gdiplus_cache_first_order(wStream* s, DRAW_GDIPLUS_CACHE_FIRST_ORDER* draw_gdiplus_cache_first)
|
||||
{
|
||||
if (stream_get_left(s) < 11)
|
||||
if (Stream_GetRemainingLength(s) < 11)
|
||||
return FALSE;
|
||||
stream_read_BYTE(s, draw_gdiplus_cache_first->flags); /* flags (1 byte) */
|
||||
stream_read_UINT16(s, draw_gdiplus_cache_first->cacheType); /* cacheType (2 bytes) */
|
||||
@ -1625,7 +1625,7 @@ BOOL update_read_draw_gdiplus_cache_first_order(wStream* s, DRAW_GDIPLUS_CACHE_F
|
||||
|
||||
BOOL update_read_draw_gdiplus_cache_next_order(wStream* s, DRAW_GDIPLUS_CACHE_NEXT_ORDER* draw_gdiplus_cache_next)
|
||||
{
|
||||
if (stream_get_left(s) < 7)
|
||||
if (Stream_GetRemainingLength(s) < 7)
|
||||
return FALSE;
|
||||
stream_read_BYTE(s, draw_gdiplus_cache_next->flags); /* flags (1 byte) */
|
||||
stream_read_UINT16(s, draw_gdiplus_cache_next->cacheType); /* cacheType (2 bytes) */
|
||||
@ -1637,7 +1637,7 @@ BOOL update_read_draw_gdiplus_cache_next_order(wStream* s, DRAW_GDIPLUS_CACHE_NE
|
||||
|
||||
BOOL update_read_draw_gdiplus_cache_end_order(wStream* s, DRAW_GDIPLUS_CACHE_END_ORDER* draw_gdiplus_cache_end)
|
||||
{
|
||||
if (stream_get_left(s) < 11)
|
||||
if (Stream_GetRemainingLength(s) < 11)
|
||||
return FALSE;
|
||||
stream_read_BYTE(s, draw_gdiplus_cache_end->flags); /* flags (1 byte) */
|
||||
stream_read_UINT16(s, draw_gdiplus_cache_end->cacheType); /* cacheType (2 bytes) */
|
||||
@ -1664,7 +1664,7 @@ BOOL update_read_field_flags(wStream* s, UINT32* fieldFlags, BYTE flags, BYTE fi
|
||||
fieldBytes = 0;
|
||||
}
|
||||
|
||||
if (stream_get_left(s) < fieldBytes)
|
||||
if (Stream_GetRemainingLength(s) < fieldBytes)
|
||||
return FALSE;
|
||||
|
||||
*fieldFlags = 0;
|
||||
@ -1680,7 +1680,7 @@ BOOL update_read_bounds(wStream* s, rdpBounds* bounds)
|
||||
{
|
||||
BYTE flags;
|
||||
|
||||
if (stream_get_left(s) < 1)
|
||||
if (Stream_GetRemainingLength(s) < 1)
|
||||
return FALSE;
|
||||
stream_read_BYTE(s, flags); /* field flags */
|
||||
|
||||
@ -1923,7 +1923,7 @@ BOOL update_recv_secondary_order(rdpUpdate* update, wStream* s, BYTE flags)
|
||||
rdpContext* context = update->context;
|
||||
rdpSecondaryUpdate* secondary = update->secondary;
|
||||
|
||||
if (stream_get_left(s) < 5)
|
||||
if (Stream_GetRemainingLength(s) < 5)
|
||||
return FALSE;
|
||||
stream_read_UINT16(s, orderLength); /* orderLength (2 bytes) */
|
||||
stream_read_UINT16(s, extraFlags); /* extraFlags (2 bytes) */
|
||||
@ -2111,7 +2111,7 @@ BOOL update_recv_order(rdpUpdate* update, wStream* s)
|
||||
{
|
||||
BYTE controlFlags;
|
||||
|
||||
if (stream_get_left(s) < 1)
|
||||
if (Stream_GetRemainingLength(s) < 1)
|
||||
return FALSE;
|
||||
|
||||
stream_read_BYTE(s, controlFlags); /* controlFlags (1 byte) */
|
||||
|
@ -135,7 +135,7 @@ static BOOL peer_recv_data_pdu(freerdp_peer* client, wStream* s)
|
||||
return FALSE;
|
||||
|
||||
case DATA_PDU_TYPE_FRAME_ACKNOWLEDGE:
|
||||
if(stream_get_left(s) < 4)
|
||||
if(Stream_GetRemainingLength(s) < 4)
|
||||
return FALSE;
|
||||
stream_read_UINT32(s, client->ack_frame_id);
|
||||
break;
|
||||
@ -232,7 +232,7 @@ static int peer_recv_fastpath_pdu(freerdp_peer* client, wStream* s)
|
||||
|
||||
fastpath_read_header_rdp(fastpath, s, &length);
|
||||
|
||||
if ((length == 0) || (length > stream_get_left(s)))
|
||||
if ((length == 0) || (length > Stream_GetRemainingLength(s)))
|
||||
{
|
||||
fprintf(stderr, "incorrect FastPath PDU header length %d\n", length);
|
||||
return -1;
|
||||
@ -326,7 +326,7 @@ static int peer_recv_callback(rdpTransport* transport, wStream* s, void* extra)
|
||||
* During reactivation sequence the client might sent some input or channel data
|
||||
* before receiving the Deactivate All PDU. We need to process them as usual.
|
||||
*/
|
||||
stream_set_pos(s, 0);
|
||||
Stream_SetPosition(s, 0);
|
||||
return peer_recv_pdu(client, s);
|
||||
}
|
||||
break;
|
||||
|
@ -80,10 +80,10 @@ static const char* const DATA_PDU_TYPE_STRINGS[] =
|
||||
BOOL rdp_read_security_header(wStream* s, UINT16* flags)
|
||||
{
|
||||
/* Basic Security Header */
|
||||
if(stream_get_left(s) < 4)
|
||||
if(Stream_GetRemainingLength(s) < 4)
|
||||
return FALSE;
|
||||
stream_read_UINT16(s, *flags); /* flags */
|
||||
stream_seek(s, 2); /* flagsHi (unused) */
|
||||
Stream_Seek(s, 2); /* flagsHi (unused) */
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@ -103,13 +103,13 @@ void rdp_write_security_header(wStream* s, UINT16 flags)
|
||||
|
||||
BOOL rdp_read_share_control_header(wStream* s, UINT16* length, UINT16* type, UINT16* channel_id)
|
||||
{
|
||||
if (stream_get_left(s) < 2)
|
||||
if (Stream_GetRemainingLength(s) < 2)
|
||||
return FALSE;
|
||||
|
||||
/* Share Control Header */
|
||||
stream_read_UINT16(s, *length); /* totalLength */
|
||||
|
||||
if (*length - 2 > stream_get_left(s))
|
||||
if (*length - 2 > Stream_GetRemainingLength(s))
|
||||
return FALSE;
|
||||
|
||||
stream_read_UINT16(s, *type); /* pduType */
|
||||
@ -136,13 +136,13 @@ void rdp_write_share_control_header(wStream* s, UINT16 length, UINT16 type, UINT
|
||||
BOOL rdp_read_share_data_header(wStream* s, UINT16* length, BYTE* type, UINT32* share_id,
|
||||
BYTE *compressed_type, UINT16 *compressed_len)
|
||||
{
|
||||
if (stream_get_left(s) < 12)
|
||||
if (Stream_GetRemainingLength(s) < 12)
|
||||
return FALSE;
|
||||
|
||||
/* Share Data Header */
|
||||
stream_read_UINT32(s, *share_id); /* shareId (4 bytes) */
|
||||
stream_seek_BYTE(s); /* pad1 (1 byte) */
|
||||
stream_seek_BYTE(s); /* streamId (1 byte) */
|
||||
Stream_Seek_BYTE(s); /* pad1 (1 byte) */
|
||||
Stream_Seek_BYTE(s); /* streamId (1 byte) */
|
||||
stream_read_UINT16(s, *length); /* uncompressedLength (2 bytes) */
|
||||
stream_read_BYTE(s, *type); /* pduType2, Data PDU Type (1 byte) */
|
||||
stream_read_BYTE(s, *compressed_type); /* compressedType (1 byte) */
|
||||
@ -170,10 +170,10 @@ static int rdp_security_stream_init(rdpRdp* rdp, wStream* s)
|
||||
{
|
||||
if (rdp->do_crypt)
|
||||
{
|
||||
stream_seek(s, 12);
|
||||
Stream_Seek(s, 12);
|
||||
|
||||
if (rdp->settings->EncryptionMethods == ENCRYPTION_METHOD_FIPS)
|
||||
stream_seek(s, 4);
|
||||
Stream_Seek(s, 4);
|
||||
|
||||
rdp->sec_flags |= SEC_ENCRYPT;
|
||||
|
||||
@ -182,7 +182,7 @@ static int rdp_security_stream_init(rdpRdp* rdp, wStream* s)
|
||||
}
|
||||
else if (rdp->sec_flags != 0)
|
||||
{
|
||||
stream_seek(s, 4);
|
||||
Stream_Seek(s, 4);
|
||||
}
|
||||
|
||||
return 0;
|
||||
@ -199,7 +199,7 @@ wStream* rdp_send_stream_init(rdpRdp* rdp)
|
||||
wStream* s;
|
||||
|
||||
s = transport_send_stream_init(rdp->transport, 2048);
|
||||
stream_seek(s, RDP_PACKET_HEADER_MAX_LENGTH);
|
||||
Stream_Seek(s, RDP_PACKET_HEADER_MAX_LENGTH);
|
||||
rdp_security_stream_init(rdp, s);
|
||||
|
||||
return s;
|
||||
@ -209,9 +209,9 @@ wStream* rdp_pdu_init(rdpRdp* rdp)
|
||||
{
|
||||
wStream* s;
|
||||
s = transport_send_stream_init(rdp->transport, 2048);
|
||||
stream_seek(s, RDP_PACKET_HEADER_MAX_LENGTH);
|
||||
Stream_Seek(s, RDP_PACKET_HEADER_MAX_LENGTH);
|
||||
rdp_security_stream_init(rdp, s);
|
||||
stream_seek(s, RDP_SHARE_CONTROL_HEADER_LENGTH);
|
||||
Stream_Seek(s, RDP_SHARE_CONTROL_HEADER_LENGTH);
|
||||
return s;
|
||||
}
|
||||
|
||||
@ -219,10 +219,10 @@ wStream* rdp_data_pdu_init(rdpRdp* rdp)
|
||||
{
|
||||
wStream* s;
|
||||
s = transport_send_stream_init(rdp->transport, 2048);
|
||||
stream_seek(s, RDP_PACKET_HEADER_MAX_LENGTH);
|
||||
Stream_Seek(s, RDP_PACKET_HEADER_MAX_LENGTH);
|
||||
rdp_security_stream_init(rdp, s);
|
||||
stream_seek(s, RDP_SHARE_CONTROL_HEADER_LENGTH);
|
||||
stream_seek(s, RDP_SHARE_DATA_HEADER_LENGTH);
|
||||
Stream_Seek(s, RDP_SHARE_CONTROL_HEADER_LENGTH);
|
||||
Stream_Seek(s, RDP_SHARE_DATA_HEADER_LENGTH);
|
||||
return s;
|
||||
}
|
||||
|
||||
@ -247,7 +247,7 @@ BOOL rdp_read_header(rdpRdp* rdp, wStream* s, UINT16* length, UINT16* channel_id
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (*length - 8 > stream_get_left(s))
|
||||
if (*length - 8 > Stream_GetRemainingLength(s))
|
||||
return FALSE;
|
||||
|
||||
if (MCSPDU == DomainMCSPDU_DisconnectProviderUltimatum)
|
||||
@ -262,15 +262,15 @@ BOOL rdp_read_header(rdpRdp* rdp, wStream* s, UINT16* length, UINT16* channel_id
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if(stream_get_left(s) < 5)
|
||||
if(Stream_GetRemainingLength(s) < 5)
|
||||
return FALSE;
|
||||
per_read_integer16(s, &initiator, MCS_BASE_CHANNEL_ID); /* initiator (UserId) */
|
||||
per_read_integer16(s, channel_id, 0); /* channelId */
|
||||
stream_seek(s, 1); /* dataPriority + Segmentation (0x70) */
|
||||
Stream_Seek(s, 1); /* dataPriority + Segmentation (0x70) */
|
||||
|
||||
if(!per_read_length(s, length)) /* userData (OCTET_STRING) */
|
||||
return FALSE;
|
||||
if (*length > stream_get_left(s))
|
||||
if (*length > Stream_GetRemainingLength(s))
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
@ -349,7 +349,7 @@ static UINT32 rdp_security_stream_out(rdpRdp* rdp, wStream* s, int length)
|
||||
stream_write_BYTE(s, pad);
|
||||
|
||||
security_hmac_signature(data, length, s->pointer, rdp);
|
||||
stream_seek(s, 8);
|
||||
Stream_Seek(s, 8);
|
||||
security_fips_encrypt(data, length + pad, rdp);
|
||||
}
|
||||
else
|
||||
@ -360,7 +360,7 @@ static UINT32 rdp_security_stream_out(rdpRdp* rdp, wStream* s, int length)
|
||||
security_salted_mac_signature(rdp, data, length, TRUE, s->pointer);
|
||||
else
|
||||
security_mac_signature(rdp, data, length, s->pointer);
|
||||
stream_seek(s, 8);
|
||||
Stream_Seek(s, 8);
|
||||
security_encrypt(s->pointer, length, rdp);
|
||||
}
|
||||
}
|
||||
@ -407,19 +407,19 @@ BOOL rdp_send(rdpRdp* rdp, wStream* s, UINT16 channel_id)
|
||||
UINT32 sec_bytes;
|
||||
BYTE* sec_hold;
|
||||
|
||||
length = stream_get_length(s);
|
||||
stream_set_pos(s, 0);
|
||||
length = Stream_GetPosition(s);
|
||||
Stream_SetPosition(s, 0);
|
||||
|
||||
rdp_write_header(rdp, s, length, channel_id);
|
||||
|
||||
sec_bytes = rdp_get_sec_bytes(rdp);
|
||||
sec_hold = s->pointer;
|
||||
stream_seek(s, sec_bytes);
|
||||
Stream_Seek(s, sec_bytes);
|
||||
|
||||
s->pointer = sec_hold;
|
||||
length += rdp_security_stream_out(rdp, s, length);
|
||||
|
||||
stream_set_pos(s, length);
|
||||
Stream_SetPosition(s, length);
|
||||
|
||||
if (transport_write(rdp->transport, s) < 0)
|
||||
return FALSE;
|
||||
@ -433,21 +433,21 @@ BOOL rdp_send_pdu(rdpRdp* rdp, wStream* s, UINT16 type, UINT16 channel_id)
|
||||
UINT32 sec_bytes;
|
||||
BYTE* sec_hold;
|
||||
|
||||
length = stream_get_length(s);
|
||||
stream_set_pos(s, 0);
|
||||
length = Stream_GetPosition(s);
|
||||
Stream_SetPosition(s, 0);
|
||||
|
||||
rdp_write_header(rdp, s, length, MCS_GLOBAL_CHANNEL_ID);
|
||||
|
||||
sec_bytes = rdp_get_sec_bytes(rdp);
|
||||
sec_hold = s->pointer;
|
||||
stream_seek(s, sec_bytes);
|
||||
Stream_Seek(s, sec_bytes);
|
||||
|
||||
rdp_write_share_control_header(s, length - sec_bytes, type, channel_id);
|
||||
|
||||
s->pointer = sec_hold;
|
||||
length += rdp_security_stream_out(rdp, s, length);
|
||||
|
||||
stream_set_pos(s, length);
|
||||
Stream_SetPosition(s, length);
|
||||
if (transport_write(rdp->transport, s) < 0)
|
||||
return FALSE;
|
||||
|
||||
@ -460,14 +460,14 @@ BOOL rdp_send_data_pdu(rdpRdp* rdp, wStream* s, BYTE type, UINT16 channel_id)
|
||||
UINT32 sec_bytes;
|
||||
BYTE* sec_hold;
|
||||
|
||||
length = stream_get_length(s);
|
||||
stream_set_pos(s, 0);
|
||||
length = Stream_GetPosition(s);
|
||||
Stream_SetPosition(s, 0);
|
||||
|
||||
rdp_write_header(rdp, s, length, MCS_GLOBAL_CHANNEL_ID);
|
||||
|
||||
sec_bytes = rdp_get_sec_bytes(rdp);
|
||||
sec_hold = s->pointer;
|
||||
stream_seek(s, sec_bytes);
|
||||
Stream_Seek(s, sec_bytes);
|
||||
|
||||
rdp_write_share_control_header(s, length - sec_bytes, PDU_TYPE_DATA, channel_id);
|
||||
rdp_write_share_data_header(s, length - sec_bytes, type, rdp->settings->ShareId);
|
||||
@ -475,7 +475,7 @@ BOOL rdp_send_data_pdu(rdpRdp* rdp, wStream* s, BYTE type, UINT16 channel_id)
|
||||
s->pointer = sec_hold;
|
||||
length += rdp_security_stream_out(rdp, s, length);
|
||||
|
||||
stream_set_pos(s, length);
|
||||
Stream_SetPosition(s, length);
|
||||
if (transport_write(rdp->transport, s) < 0)
|
||||
return FALSE;
|
||||
|
||||
@ -484,7 +484,7 @@ BOOL rdp_send_data_pdu(rdpRdp* rdp, wStream* s, BYTE type, UINT16 channel_id)
|
||||
|
||||
BOOL rdp_recv_set_error_info_data_pdu(rdpRdp* rdp, wStream* s)
|
||||
{
|
||||
if (stream_get_left(s) < 4)
|
||||
if (Stream_GetRemainingLength(s) < 4)
|
||||
return FALSE;
|
||||
|
||||
stream_read_UINT32(s, rdp->errorInfo); /* errorInfo (4 bytes) */
|
||||
@ -519,7 +519,7 @@ int rdp_recv_data_pdu(rdpRdp* rdp, wStream* s)
|
||||
|
||||
if (compressed_type & PACKET_COMPRESSED)
|
||||
{
|
||||
if (stream_get_left(s) < compressed_len - 18)
|
||||
if (Stream_GetRemainingLength(s) < compressed_len - 18)
|
||||
{
|
||||
fprintf(stderr, "decompress_rdp: not enough bytes for compressed_len=%d\n", compressed_len);
|
||||
return -1;
|
||||
@ -536,7 +536,7 @@ int rdp_recv_data_pdu(rdpRdp* rdp, wStream* s)
|
||||
fprintf(stderr, "decompress_rdp() failed\n");
|
||||
return -1;
|
||||
}
|
||||
stream_seek(s, compressed_len - 18);
|
||||
Stream_Seek(s, compressed_len - 18);
|
||||
}
|
||||
|
||||
#ifdef WITH_DEBUG_RDP
|
||||
@ -689,7 +689,7 @@ BOOL rdp_decrypt(rdpRdp* rdp, wStream* s, int length, UINT16 securityFlags)
|
||||
BYTE version, pad;
|
||||
BYTE* sig;
|
||||
|
||||
if (stream_get_left(s) < 12)
|
||||
if (Stream_GetRemainingLength(s) < 12)
|
||||
return FALSE;
|
||||
|
||||
stream_read_UINT16(s, len); /* 0x10 */
|
||||
@ -697,7 +697,7 @@ BOOL rdp_decrypt(rdpRdp* rdp, wStream* s, int length, UINT16 securityFlags)
|
||||
stream_read_BYTE(s, pad);
|
||||
|
||||
sig = s->pointer;
|
||||
stream_seek(s, 8); /* signature */
|
||||
Stream_Seek(s, 8); /* signature */
|
||||
|
||||
length -= 12;
|
||||
|
||||
@ -718,7 +718,7 @@ BOOL rdp_decrypt(rdpRdp* rdp, wStream* s, int length, UINT16 securityFlags)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if (stream_get_left(s) < 8)
|
||||
if (Stream_GetRemainingLength(s) < 8)
|
||||
return FALSE;
|
||||
|
||||
stream_read(s, wmac, sizeof(wmac));
|
||||
@ -802,7 +802,7 @@ static int rdp_recv_tpkt_pdu(rdpRdp* rdp, wStream* s)
|
||||
}
|
||||
else
|
||||
{
|
||||
while (stream_get_left(s) > 3)
|
||||
while (Stream_GetRemainingLength(s) > 3)
|
||||
{
|
||||
stream_get_mark(s, nextp);
|
||||
|
||||
@ -854,7 +854,7 @@ static int rdp_recv_fastpath_pdu(rdpRdp* rdp, wStream* s)
|
||||
if (!fastpath_read_header_rdp(fastpath, s, &length))
|
||||
return -1;
|
||||
|
||||
if ((length == 0) || (length > stream_get_left(s)))
|
||||
if ((length == 0) || (length > Stream_GetRemainingLength(s)))
|
||||
{
|
||||
fprintf(stderr, "incorrect FastPath PDU header length %d\n", length);
|
||||
return -1;
|
||||
|
@ -63,12 +63,12 @@ void rdp_print_redirection_flags(UINT32 flags)
|
||||
|
||||
BOOL rdp_string_read_length32(wStream* s, rdpString* string)
|
||||
{
|
||||
if(stream_get_left(s) < 4)
|
||||
if(Stream_GetRemainingLength(s) < 4)
|
||||
return FALSE;
|
||||
|
||||
stream_read_UINT32(s, string->length);
|
||||
|
||||
if(stream_get_left(s) < string->length)
|
||||
if(Stream_GetRemainingLength(s) < string->length)
|
||||
return FALSE;
|
||||
|
||||
string->unicode = (char*) malloc(string->length);
|
||||
@ -94,7 +94,7 @@ BOOL rdp_recv_server_redirection_pdu(rdpRdp* rdp, wStream* s)
|
||||
UINT16 length;
|
||||
rdpRedirection* redirection = rdp->redirection;
|
||||
|
||||
if (stream_get_left(s) < 12)
|
||||
if (Stream_GetRemainingLength(s) < 12)
|
||||
return FALSE;
|
||||
stream_read_UINT16(s, flags); /* flags (2 bytes) */
|
||||
stream_read_UINT16(s, length); /* length (2 bytes) */
|
||||
@ -116,10 +116,10 @@ BOOL rdp_recv_server_redirection_pdu(rdpRdp* rdp, wStream* s)
|
||||
|
||||
if (redirection->flags & LB_LOAD_BALANCE_INFO)
|
||||
{
|
||||
if (stream_get_left(s) < 4)
|
||||
if (Stream_GetRemainingLength(s) < 4)
|
||||
return FALSE;
|
||||
stream_read_UINT32(s, redirection->LoadBalanceInfoLength);
|
||||
if (stream_get_left(s) < redirection->LoadBalanceInfoLength)
|
||||
if (Stream_GetRemainingLength(s) < redirection->LoadBalanceInfoLength)
|
||||
return FALSE;
|
||||
|
||||
redirection->LoadBalanceInfo = (BYTE*) malloc(redirection->LoadBalanceInfoLength);
|
||||
@ -147,7 +147,7 @@ BOOL rdp_recv_server_redirection_pdu(rdpRdp* rdp, wStream* s)
|
||||
if (redirection->flags & LB_PASSWORD)
|
||||
{
|
||||
/* Note: length (hopefully) includes double zero termination */
|
||||
if (stream_get_left(s) < 4)
|
||||
if (Stream_GetRemainingLength(s) < 4)
|
||||
return FALSE;
|
||||
stream_read_UINT32(s, redirection->PasswordCookieLength);
|
||||
redirection->PasswordCookie = (BYTE*) malloc(redirection->PasswordCookieLength);
|
||||
@ -186,7 +186,7 @@ BOOL rdp_recv_server_redirection_pdu(rdpRdp* rdp, wStream* s)
|
||||
UINT32 count;
|
||||
UINT32 targetNetAddressesLength;
|
||||
|
||||
if (stream_get_left(s) < 8)
|
||||
if (Stream_GetRemainingLength(s) < 8)
|
||||
return FALSE;
|
||||
stream_read_UINT32(s, targetNetAddressesLength);
|
||||
|
||||
|
@ -30,7 +30,7 @@ static int update_recv_surfcmd_surface_bits(rdpUpdate* update, wStream* s, UINT3
|
||||
int pos;
|
||||
SURFACE_BITS_COMMAND* cmd = &update->surface_bits_command;
|
||||
|
||||
if (stream_get_left(s) < 20)
|
||||
if (Stream_GetRemainingLength(s) < 20)
|
||||
return -1;
|
||||
|
||||
stream_read_UINT16(s, cmd->destLeft);
|
||||
@ -38,19 +38,19 @@ static int update_recv_surfcmd_surface_bits(rdpUpdate* update, wStream* s, UINT3
|
||||
stream_read_UINT16(s, cmd->destRight);
|
||||
stream_read_UINT16(s, cmd->destBottom);
|
||||
stream_read_BYTE(s, cmd->bpp);
|
||||
stream_seek(s, 2); /* reserved1, reserved2 */
|
||||
Stream_Seek(s, 2); /* reserved1, reserved2 */
|
||||
stream_read_BYTE(s, cmd->codecID);
|
||||
stream_read_UINT16(s, cmd->width);
|
||||
stream_read_UINT16(s, cmd->height);
|
||||
stream_read_UINT32(s, cmd->bitmapDataLength);
|
||||
|
||||
if (stream_get_left(s) < cmd->bitmapDataLength)
|
||||
if (Stream_GetRemainingLength(s) < cmd->bitmapDataLength)
|
||||
return -1;
|
||||
|
||||
pos = stream_get_pos(s) + cmd->bitmapDataLength;
|
||||
cmd->bitmapData = stream_get_tail(s);
|
||||
pos = Stream_GetPosition(s) + cmd->bitmapDataLength;
|
||||
cmd->bitmapData = Stream_Pointer(s);
|
||||
|
||||
stream_set_pos(s, pos);
|
||||
Stream_SetPosition(s, pos);
|
||||
*length = 20 + cmd->bitmapDataLength;
|
||||
|
||||
IFCALL(update->SurfaceBits, update->context, cmd);
|
||||
@ -71,7 +71,7 @@ static int update_recv_surfcmd_frame_marker(rdpUpdate* update, wStream* s, UINT3
|
||||
{
|
||||
SURFACE_FRAME_MARKER* marker = &update->surface_frame_marker;
|
||||
|
||||
if (stream_get_left(s) < 6)
|
||||
if (Stream_GetRemainingLength(s) < 6)
|
||||
return -1;
|
||||
|
||||
stream_read_UINT16(s, marker->frameAction);
|
||||
|
@ -79,7 +79,7 @@ BOOL rdp_read_client_time_zone(wStream* s, rdpSettings* settings)
|
||||
char* str = NULL;
|
||||
TIME_ZONE_INFO* clientTimeZone;
|
||||
|
||||
if (stream_get_left(s) < 172)
|
||||
if (Stream_GetRemainingLength(s) < 172)
|
||||
return FALSE;
|
||||
|
||||
clientTimeZone = settings->ClientTimeZone;
|
||||
@ -87,8 +87,8 @@ BOOL rdp_read_client_time_zone(wStream* s, rdpSettings* settings)
|
||||
stream_read_UINT32(s, clientTimeZone->bias); /* Bias */
|
||||
|
||||
/* standardName (64 bytes) */
|
||||
ConvertFromUnicode(CP_UTF8, 0, (WCHAR*) stream_get_tail(s), 64 / 2, &str, 0, NULL, NULL);
|
||||
stream_seek(s, 64);
|
||||
ConvertFromUnicode(CP_UTF8, 0, (WCHAR*) Stream_Pointer(s), 64 / 2, &str, 0, NULL, NULL);
|
||||
Stream_Seek(s, 64);
|
||||
strncpy(clientTimeZone->standardName, str, sizeof(clientTimeZone->standardName));
|
||||
free(str);
|
||||
str = NULL;
|
||||
@ -97,8 +97,8 @@ BOOL rdp_read_client_time_zone(wStream* s, rdpSettings* settings)
|
||||
stream_read_UINT32(s, clientTimeZone->standardBias); /* StandardBias */
|
||||
|
||||
/* daylightName (64 bytes) */
|
||||
ConvertFromUnicode(CP_UTF8, 0, (WCHAR*) stream_get_tail(s), 64 / 2, &str, 0, NULL, NULL);
|
||||
stream_seek(s, 64);
|
||||
ConvertFromUnicode(CP_UTF8, 0, (WCHAR*) Stream_Pointer(s), 64 / 2, &str, 0, NULL, NULL);
|
||||
Stream_Seek(s, 64);
|
||||
strncpy(clientTimeZone->daylightName, str, sizeof(clientTimeZone->daylightName));
|
||||
free(str);
|
||||
|
||||
|
@ -68,7 +68,7 @@
|
||||
|
||||
BOOL tpdu_read_header(wStream* s, BYTE* code, BYTE *li)
|
||||
{
|
||||
if(stream_get_left(s) < 3)
|
||||
if(Stream_GetRemainingLength(s) < 3)
|
||||
return FALSE;
|
||||
|
||||
stream_read_BYTE(s, *li); /* LI */
|
||||
@ -77,7 +77,7 @@ BOOL tpdu_read_header(wStream* s, BYTE* code, BYTE *li)
|
||||
if (*code == X224_TPDU_DATA)
|
||||
{
|
||||
/* EOT (1 byte) */
|
||||
stream_seek(s, 1);
|
||||
Stream_Seek(s, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -165,7 +165,7 @@ BOOL tpdu_read_connection_confirm(wStream* s, BYTE *li)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return (stream_get_left(s) >= *li);
|
||||
return (Stream_GetRemainingLength(s) >= *li);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -90,7 +90,7 @@ UINT16 tpkt_read_header(wStream* s)
|
||||
|
||||
if (version == 3)
|
||||
{
|
||||
stream_seek(s, 2);
|
||||
Stream_Seek(s, 2);
|
||||
stream_read_UINT16_be(s, length);
|
||||
}
|
||||
else
|
||||
|
@ -54,7 +54,7 @@ wStream* transport_recv_stream_init(rdpTransport* transport, int size)
|
||||
{
|
||||
wStream* s = transport->ReceiveStream;
|
||||
stream_check_size(s, size);
|
||||
stream_set_pos(s, 0);
|
||||
Stream_SetPosition(s, 0);
|
||||
return s;
|
||||
}
|
||||
|
||||
@ -62,7 +62,7 @@ wStream* transport_send_stream_init(rdpTransport* transport, int size)
|
||||
{
|
||||
wStream* s = transport->SendStream;
|
||||
stream_check_size(s, size);
|
||||
stream_set_pos(s, 0);
|
||||
Stream_SetPosition(s, 0);
|
||||
return s;
|
||||
}
|
||||
|
||||
@ -322,13 +322,13 @@ UINT32 nla_read_header(wStream* s)
|
||||
{
|
||||
length = s->pointer[2];
|
||||
length += 3;
|
||||
stream_seek(s, 3);
|
||||
Stream_Seek(s, 3);
|
||||
}
|
||||
else if ((s->pointer[1] & ~(0x80)) == 2)
|
||||
{
|
||||
length = (s->pointer[2] << 8) | s->pointer[3];
|
||||
length += 4;
|
||||
stream_seek(s, 4);
|
||||
Stream_Seek(s, 4);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -339,7 +339,7 @@ UINT32 nla_read_header(wStream* s)
|
||||
{
|
||||
length = s->pointer[1];
|
||||
length += 2;
|
||||
stream_seek(s, 2);
|
||||
Stream_Seek(s, 2);
|
||||
}
|
||||
|
||||
return length;
|
||||
@ -414,7 +414,7 @@ int transport_read(rdpTransport* transport, wStream* s)
|
||||
transport_status = 0;
|
||||
|
||||
/* first check if we have header */
|
||||
stream_bytes = stream_get_length(s);
|
||||
stream_bytes = Stream_GetPosition(s);
|
||||
|
||||
if (stream_bytes < 4)
|
||||
{
|
||||
@ -504,7 +504,7 @@ static int transport_read_nonblocking(rdpTransport* transport)
|
||||
if (status <= 0)
|
||||
return status;
|
||||
|
||||
stream_seek(transport->ReceiveBuffer, status);
|
||||
Stream_Seek(transport->ReceiveBuffer, status);
|
||||
|
||||
return status;
|
||||
}
|
||||
@ -514,8 +514,8 @@ int transport_write(rdpTransport* transport, wStream* s)
|
||||
int status = -1;
|
||||
int length;
|
||||
|
||||
length = stream_get_length(s);
|
||||
stream_set_pos(s, 0);
|
||||
length = Stream_GetPosition(s);
|
||||
Stream_SetPosition(s, 0);
|
||||
|
||||
#ifdef WITH_DEBUG_TRANSPORT
|
||||
if (length > 0)
|
||||
@ -528,11 +528,11 @@ int transport_write(rdpTransport* transport, wStream* s)
|
||||
while (length > 0)
|
||||
{
|
||||
if (transport->layer == TRANSPORT_LAYER_TLS)
|
||||
status = tls_write(transport->TlsOut, stream_get_tail(s), length);
|
||||
status = tls_write(transport->TlsOut, Stream_Pointer(s), length);
|
||||
else if (transport->layer == TRANSPORT_LAYER_TCP)
|
||||
status = tcp_write(transport->TcpOut, stream_get_tail(s), length);
|
||||
status = tcp_write(transport->TcpOut, Stream_Pointer(s), length);
|
||||
else if (transport->layer == TRANSPORT_LAYER_TSG)
|
||||
status = tsg_write(transport->tsg, stream_get_tail(s), length);
|
||||
status = tsg_write(transport->tsg, Stream_Pointer(s), length);
|
||||
|
||||
if (status < 0)
|
||||
break; /* error occurred */
|
||||
@ -556,7 +556,7 @@ int transport_write(rdpTransport* transport, wStream* s)
|
||||
}
|
||||
|
||||
length -= status;
|
||||
stream_seek(s, status);
|
||||
Stream_Seek(s, status);
|
||||
}
|
||||
|
||||
if (status < 0)
|
||||
@ -631,16 +631,16 @@ int transport_check_fds(rdpTransport** ptransport)
|
||||
if (status < 0)
|
||||
return status;
|
||||
|
||||
while ((pos = stream_get_pos(transport->ReceiveBuffer)) > 0)
|
||||
while ((pos = Stream_GetPosition(transport->ReceiveBuffer)) > 0)
|
||||
{
|
||||
stream_set_pos(transport->ReceiveBuffer, 0);
|
||||
Stream_SetPosition(transport->ReceiveBuffer, 0);
|
||||
|
||||
if (tpkt_verify_header(transport->ReceiveBuffer)) /* TPKT */
|
||||
{
|
||||
/* Ensure the TPKT header is available. */
|
||||
if (pos <= 4)
|
||||
{
|
||||
stream_set_pos(transport->ReceiveBuffer, pos);
|
||||
Stream_SetPosition(transport->ReceiveBuffer, pos);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -653,7 +653,7 @@ int transport_check_fds(rdpTransport** ptransport)
|
||||
/* Ensure the TSRequest header is available. */
|
||||
if (pos <= 4)
|
||||
{
|
||||
stream_set_pos(transport->ReceiveBuffer, pos);
|
||||
Stream_SetPosition(transport->ReceiveBuffer, pos);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -662,7 +662,7 @@ int transport_check_fds(rdpTransport** ptransport)
|
||||
|
||||
if (pos < length)
|
||||
{
|
||||
stream_set_pos(transport->ReceiveBuffer, pos);
|
||||
Stream_SetPosition(transport->ReceiveBuffer, pos);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -673,7 +673,7 @@ int transport_check_fds(rdpTransport** ptransport)
|
||||
/* Ensure the Fast Path header is available. */
|
||||
if (pos <= 2)
|
||||
{
|
||||
stream_set_pos(transport->ReceiveBuffer, pos);
|
||||
Stream_SetPosition(transport->ReceiveBuffer, pos);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -682,7 +682,7 @@ int transport_check_fds(rdpTransport** ptransport)
|
||||
|
||||
if (pos < length)
|
||||
{
|
||||
stream_set_pos(transport->ReceiveBuffer, pos);
|
||||
Stream_SetPosition(transport->ReceiveBuffer, pos);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -698,16 +698,16 @@ int transport_check_fds(rdpTransport** ptransport)
|
||||
|
||||
if (pos < length)
|
||||
{
|
||||
stream_set_pos(transport->ReceiveBuffer, pos);
|
||||
Stream_SetPosition(transport->ReceiveBuffer, pos);
|
||||
return 0; /* Packet is not yet completely received. */
|
||||
}
|
||||
|
||||
received = transport->ReceiveBuffer;
|
||||
transport->ReceiveBuffer = StreamPool_Take(transport->ReceivePool, 0);
|
||||
|
||||
stream_set_pos(received, length);
|
||||
stream_seal(received);
|
||||
stream_set_pos(received, 0);
|
||||
Stream_SetPosition(received, length);
|
||||
Stream_SealLength(received);
|
||||
Stream_SetPosition(received, 0);
|
||||
|
||||
/**
|
||||
* ReceiveCallback return values:
|
||||
|
@ -46,12 +46,12 @@ BOOL update_recv_orders(rdpUpdate* update, wStream* s)
|
||||
{
|
||||
UINT16 numberOrders;
|
||||
|
||||
if (stream_get_left(s) < 6)
|
||||
if (Stream_GetRemainingLength(s) < 6)
|
||||
return FALSE;
|
||||
|
||||
stream_seek_UINT16(s); /* pad2OctetsA (2 bytes) */
|
||||
Stream_Seek_UINT16(s); /* pad2OctetsA (2 bytes) */
|
||||
stream_read_UINT16(s, numberOrders); /* numberOrders (2 bytes) */
|
||||
stream_seek_UINT16(s); /* pad2OctetsB (2 bytes) */
|
||||
Stream_Seek_UINT16(s); /* pad2OctetsB (2 bytes) */
|
||||
|
||||
while (numberOrders > 0)
|
||||
{
|
||||
@ -65,7 +65,7 @@ BOOL update_recv_orders(rdpUpdate* update, wStream* s)
|
||||
|
||||
BOOL update_read_bitmap_data(wStream* s, BITMAP_DATA* bitmap_data)
|
||||
{
|
||||
if (stream_get_left(s) < 18)
|
||||
if (Stream_GetRemainingLength(s) < 18)
|
||||
return FALSE;
|
||||
|
||||
stream_read_UINT16(s, bitmap_data->destLeft);
|
||||
@ -91,15 +91,15 @@ BOOL update_read_bitmap_data(wStream* s, BITMAP_DATA* bitmap_data)
|
||||
|
||||
bitmap_data->compressed = TRUE;
|
||||
stream_get_mark(s, bitmap_data->bitmapDataStream);
|
||||
stream_seek(s, bitmap_data->bitmapLength);
|
||||
Stream_Seek(s, bitmap_data->bitmapLength);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (stream_get_left(s) < bitmap_data->bitmapLength)
|
||||
if (Stream_GetRemainingLength(s) < bitmap_data->bitmapLength)
|
||||
return FALSE;
|
||||
bitmap_data->compressed = FALSE;
|
||||
stream_get_mark(s, bitmap_data->bitmapDataStream);
|
||||
stream_seek(s, bitmap_data->bitmapLength);
|
||||
Stream_Seek(s, bitmap_data->bitmapLength);
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
@ -108,7 +108,7 @@ BOOL update_read_bitmap(rdpUpdate* update, wStream* s, BITMAP_UPDATE* bitmap_upd
|
||||
{
|
||||
int i;
|
||||
|
||||
if (stream_get_left(s) < 2)
|
||||
if (Stream_GetRemainingLength(s) < 2)
|
||||
return FALSE;
|
||||
|
||||
stream_read_UINT16(s, bitmap_update->number); /* numberRectangles (2 bytes) */
|
||||
@ -142,16 +142,16 @@ BOOL update_read_palette(rdpUpdate* update, wStream* s, PALETTE_UPDATE* palette_
|
||||
int i;
|
||||
PALETTE_ENTRY* entry;
|
||||
|
||||
if (stream_get_left(s) < 6)
|
||||
if (Stream_GetRemainingLength(s) < 6)
|
||||
return FALSE;
|
||||
|
||||
stream_seek_UINT16(s); /* pad2Octets (2 bytes) */
|
||||
Stream_Seek_UINT16(s); /* pad2Octets (2 bytes) */
|
||||
stream_read_UINT32(s, palette_update->number); /* numberColors (4 bytes), must be set to 256 */
|
||||
|
||||
if (palette_update->number > 256)
|
||||
palette_update->number = 256;
|
||||
|
||||
if (stream_get_left(s) < palette_update->number * 3)
|
||||
if (Stream_GetRemainingLength(s) < palette_update->number * 3)
|
||||
return FALSE;
|
||||
|
||||
/* paletteEntries */
|
||||
@ -168,7 +168,7 @@ BOOL update_read_palette(rdpUpdate* update, wStream* s, PALETTE_UPDATE* palette_
|
||||
|
||||
void update_read_synchronize(rdpUpdate* update, wStream* s)
|
||||
{
|
||||
stream_seek_UINT16(s); /* pad2Octets (2 bytes) */
|
||||
Stream_Seek_UINT16(s); /* pad2Octets (2 bytes) */
|
||||
|
||||
/**
|
||||
* The Synchronize Update is an artifact from the
|
||||
@ -178,7 +178,7 @@ void update_read_synchronize(rdpUpdate* update, wStream* s)
|
||||
|
||||
BOOL update_read_play_sound(wStream* s, PLAY_SOUND_UPDATE* play_sound)
|
||||
{
|
||||
if (stream_get_left(s) < 8)
|
||||
if (Stream_GetRemainingLength(s) < 8)
|
||||
return FALSE;
|
||||
|
||||
stream_read_UINT32(s, play_sound->duration); /* duration (4 bytes) */
|
||||
@ -198,7 +198,7 @@ BOOL update_recv_play_sound(rdpUpdate* update, wStream* s)
|
||||
|
||||
BOOL update_read_pointer_position(wStream* s, POINTER_POSITION_UPDATE* pointer_position)
|
||||
{
|
||||
if (stream_get_left(s) < 4)
|
||||
if (Stream_GetRemainingLength(s) < 4)
|
||||
return FALSE;
|
||||
|
||||
stream_read_UINT16(s, pointer_position->xPos); /* xPos (2 bytes) */
|
||||
@ -208,7 +208,7 @@ BOOL update_read_pointer_position(wStream* s, POINTER_POSITION_UPDATE* pointer_p
|
||||
|
||||
BOOL update_read_pointer_system(wStream* s, POINTER_SYSTEM_UPDATE* pointer_system)
|
||||
{
|
||||
if (stream_get_left(s) < 4)
|
||||
if (Stream_GetRemainingLength(s) < 4)
|
||||
return FALSE;
|
||||
|
||||
stream_read_UINT32(s, pointer_system->type); /* systemPointerType (4 bytes) */
|
||||
@ -217,7 +217,7 @@ BOOL update_read_pointer_system(wStream* s, POINTER_SYSTEM_UPDATE* pointer_syste
|
||||
|
||||
BOOL update_read_pointer_color(wStream* s, POINTER_COLOR_UPDATE* pointer_color)
|
||||
{
|
||||
if (stream_get_left(s) < 14)
|
||||
if (Stream_GetRemainingLength(s) < 14)
|
||||
return FALSE;
|
||||
|
||||
stream_read_UINT16(s, pointer_color->cacheIndex); /* cacheIndex (2 bytes) */
|
||||
@ -241,7 +241,7 @@ BOOL update_read_pointer_color(wStream* s, POINTER_COLOR_UPDATE* pointer_color)
|
||||
|
||||
if (pointer_color->lengthXorMask > 0)
|
||||
{
|
||||
if (stream_get_left(s) < pointer_color->lengthXorMask)
|
||||
if (Stream_GetRemainingLength(s) < pointer_color->lengthXorMask)
|
||||
return FALSE;
|
||||
|
||||
if (!pointer_color->xorMaskData)
|
||||
@ -254,7 +254,7 @@ BOOL update_read_pointer_color(wStream* s, POINTER_COLOR_UPDATE* pointer_color)
|
||||
|
||||
if (pointer_color->lengthAndMask > 0)
|
||||
{
|
||||
if (stream_get_left(s) < pointer_color->lengthAndMask)
|
||||
if (Stream_GetRemainingLength(s) < pointer_color->lengthAndMask)
|
||||
return FALSE;
|
||||
|
||||
if (!pointer_color->andMaskData)
|
||||
@ -265,15 +265,15 @@ BOOL update_read_pointer_color(wStream* s, POINTER_COLOR_UPDATE* pointer_color)
|
||||
stream_read(s, pointer_color->andMaskData, pointer_color->lengthAndMask);
|
||||
}
|
||||
|
||||
if (stream_get_left(s) > 0)
|
||||
stream_seek_BYTE(s); /* pad (1 byte) */
|
||||
if (Stream_GetRemainingLength(s) > 0)
|
||||
Stream_Seek_BYTE(s); /* pad (1 byte) */
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL update_read_pointer_new(wStream* s, POINTER_NEW_UPDATE* pointer_new)
|
||||
{
|
||||
if (stream_get_left(s) < 2)
|
||||
if (Stream_GetRemainingLength(s) < 2)
|
||||
return FALSE;
|
||||
|
||||
stream_read_UINT16(s, pointer_new->xorBpp); /* xorBpp (2 bytes) */
|
||||
@ -282,7 +282,7 @@ BOOL update_read_pointer_new(wStream* s, POINTER_NEW_UPDATE* pointer_new)
|
||||
|
||||
BOOL update_read_pointer_cached(wStream* s, POINTER_CACHED_UPDATE* pointer_cached)
|
||||
{
|
||||
if (stream_get_left(s) < 2)
|
||||
if (Stream_GetRemainingLength(s) < 2)
|
||||
return FALSE;
|
||||
|
||||
stream_read_UINT16(s, pointer_cached->cacheIndex); /* cacheIndex (2 bytes) */
|
||||
@ -295,11 +295,11 @@ BOOL update_recv_pointer(rdpUpdate* update, wStream* s)
|
||||
rdpContext* context = update->context;
|
||||
rdpPointerUpdate* pointer = update->pointer;
|
||||
|
||||
if (stream_get_left(s) < 2 + 2)
|
||||
if (Stream_GetRemainingLength(s) < 2 + 2)
|
||||
return FALSE;
|
||||
|
||||
stream_read_UINT16(s, messageType); /* messageType (2 bytes) */
|
||||
stream_seek_UINT16(s); /* pad2Octets (2 bytes) */
|
||||
Stream_Seek_UINT16(s); /* pad2Octets (2 bytes) */
|
||||
|
||||
switch (messageType)
|
||||
{
|
||||
@ -344,7 +344,7 @@ BOOL update_recv(rdpUpdate* update, wStream* s)
|
||||
UINT16 updateType;
|
||||
rdpContext* context = update->context;
|
||||
|
||||
if (stream_get_left(s) < 2)
|
||||
if (Stream_GetRemainingLength(s) < 2)
|
||||
return FALSE;
|
||||
|
||||
stream_read_UINT16(s, updateType); /* updateType (2 bytes) */
|
||||
@ -452,7 +452,7 @@ static void update_write_refresh_rect(wStream* s, BYTE count, RECTANGLE_16* area
|
||||
int i;
|
||||
|
||||
stream_write_BYTE(s, count); /* numberOfAreas (1 byte) */
|
||||
stream_seek(s, 3); /* pad3Octets (3 bytes) */
|
||||
Stream_Seek(s, 3); /* pad3Octets (3 bytes) */
|
||||
|
||||
for (i = 0; i < count; i++)
|
||||
{
|
||||
@ -480,7 +480,7 @@ static void update_send_refresh_rect(rdpContext* context, BYTE count, RECTANGLE_
|
||||
static void update_write_suppress_output(wStream* s, BYTE allow, RECTANGLE_16* area)
|
||||
{
|
||||
stream_write_BYTE(s, allow); /* allowDisplayUpdates (1 byte) */
|
||||
stream_seek(s, 3); /* pad3Octets (3 bytes) */
|
||||
Stream_Seek(s, 3); /* pad3Octets (3 bytes) */
|
||||
|
||||
if (allow > 0)
|
||||
{
|
||||
@ -511,8 +511,8 @@ static void update_send_surface_command(rdpContext* context, wStream* s)
|
||||
rdpRdp* rdp = context->rdp;
|
||||
|
||||
update = fastpath_update_pdu_init(rdp->fastpath);
|
||||
stream_check_size(update, stream_get_length(s));
|
||||
stream_write(update, stream_get_head(s), stream_get_length(s));
|
||||
stream_check_size(update, Stream_GetPosition(s));
|
||||
stream_write(update, stream_get_head(s), Stream_GetPosition(s));
|
||||
fastpath_send_update_pdu(rdp->fastpath, FASTPATH_UPDATETYPE_SURFCMDS, update);
|
||||
}
|
||||
|
||||
@ -666,13 +666,13 @@ BOOL update_read_refresh_rect(rdpUpdate* update, wStream* s)
|
||||
BYTE numberOfAreas;
|
||||
RECTANGLE_16* areas;
|
||||
|
||||
if (stream_get_left(s) < 4)
|
||||
if (Stream_GetRemainingLength(s) < 4)
|
||||
return FALSE;
|
||||
|
||||
stream_read_BYTE(s, numberOfAreas);
|
||||
stream_seek(s, 3); /* pad3Octects */
|
||||
Stream_Seek(s, 3); /* pad3Octects */
|
||||
|
||||
if (stream_get_left(s) < numberOfAreas * 4 * 2)
|
||||
if (Stream_GetRemainingLength(s) < numberOfAreas * 4 * 2)
|
||||
return FALSE;
|
||||
areas = (RECTANGLE_16*) malloc(sizeof(RECTANGLE_16) * numberOfAreas);
|
||||
|
||||
@ -695,17 +695,17 @@ BOOL update_read_suppress_output(rdpUpdate* update, wStream* s)
|
||||
{
|
||||
BYTE allowDisplayUpdates;
|
||||
|
||||
if (stream_get_left(s) < 4)
|
||||
if (Stream_GetRemainingLength(s) < 4)
|
||||
return FALSE;
|
||||
|
||||
stream_read_BYTE(s, allowDisplayUpdates);
|
||||
stream_seek(s, 3); /* pad3Octects */
|
||||
Stream_Seek(s, 3); /* pad3Octects */
|
||||
|
||||
if (allowDisplayUpdates > 0 && stream_get_left(s) < 8)
|
||||
if (allowDisplayUpdates > 0 && Stream_GetRemainingLength(s) < 8)
|
||||
return FALSE;
|
||||
|
||||
IFCALL(update->SuppressOutput, update->context, allowDisplayUpdates,
|
||||
allowDisplayUpdates > 0 ? (RECTANGLE_16*) stream_get_tail(s) : NULL);
|
||||
allowDisplayUpdates > 0 ? (RECTANGLE_16*) Stream_Pointer(s) : NULL);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -30,7 +30,7 @@
|
||||
|
||||
BOOL update_read_icon_info(wStream* s, ICON_INFO* icon_info)
|
||||
{
|
||||
if(stream_get_left(s) < 8)
|
||||
if(Stream_GetRemainingLength(s) < 8)
|
||||
return FALSE;
|
||||
stream_read_UINT16(s, icon_info->cacheEntry); /* cacheEntry (2 bytes) */
|
||||
stream_read_BYTE(s, icon_info->cacheId); /* cacheId (1 byte) */
|
||||
@ -40,19 +40,19 @@ BOOL update_read_icon_info(wStream* s, ICON_INFO* icon_info)
|
||||
|
||||
/* cbColorTable is only present when bpp is 1, 2 or 4 */
|
||||
if (icon_info->bpp == 1 || icon_info->bpp == 2 || icon_info->bpp == 4) {
|
||||
if(stream_get_left(s) < 2)
|
||||
if(Stream_GetRemainingLength(s) < 2)
|
||||
return FALSE;
|
||||
stream_read_UINT16(s, icon_info->cbColorTable); /* cbColorTable (2 bytes) */
|
||||
} else {
|
||||
icon_info->cbColorTable = 0;
|
||||
}
|
||||
|
||||
if(stream_get_left(s) < 4)
|
||||
if(Stream_GetRemainingLength(s) < 4)
|
||||
return FALSE;
|
||||
stream_read_UINT16(s, icon_info->cbBitsMask); /* cbBitsMask (2 bytes) */
|
||||
stream_read_UINT16(s, icon_info->cbBitsColor); /* cbBitsColor (2 bytes) */
|
||||
|
||||
if(stream_get_left(s) < icon_info->cbBitsMask + icon_info->cbBitsColor)
|
||||
if(Stream_GetRemainingLength(s) < icon_info->cbBitsMask + icon_info->cbBitsColor)
|
||||
return FALSE;
|
||||
|
||||
/* bitsMask */
|
||||
@ -80,7 +80,7 @@ BOOL update_read_icon_info(wStream* s, ICON_INFO* icon_info)
|
||||
|
||||
BOOL update_read_cached_icon_info(wStream* s, CACHED_ICON_INFO* cached_icon_info)
|
||||
{
|
||||
if(stream_get_left(s) < 3)
|
||||
if(Stream_GetRemainingLength(s) < 3)
|
||||
return FALSE;
|
||||
stream_read_UINT16(s, cached_icon_info->cacheEntry); /* cacheEntry (2 bytes) */
|
||||
stream_read_BYTE(s, cached_icon_info->cacheId); /* cacheId (1 byte) */
|
||||
@ -89,7 +89,7 @@ BOOL update_read_cached_icon_info(wStream* s, CACHED_ICON_INFO* cached_icon_info
|
||||
|
||||
BOOL update_read_notify_icon_infotip(wStream* s, NOTIFY_ICON_INFOTIP* notify_icon_infotip)
|
||||
{
|
||||
if(stream_get_left(s) < 8)
|
||||
if(Stream_GetRemainingLength(s) < 8)
|
||||
return FALSE;
|
||||
stream_read_UINT32(s, notify_icon_infotip->timeout); /* timeout (4 bytes) */
|
||||
stream_read_UINT32(s, notify_icon_infotip->flags); /* infoFlags (4 bytes) */
|
||||
@ -103,21 +103,21 @@ BOOL update_read_window_state_order(wStream* s, WINDOW_ORDER_INFO* orderInfo, WI
|
||||
int size;
|
||||
|
||||
if (orderInfo->fieldFlags & WINDOW_ORDER_FIELD_OWNER) {
|
||||
if(stream_get_left(s) < 4)
|
||||
if(Stream_GetRemainingLength(s) < 4)
|
||||
return FALSE;
|
||||
stream_read_UINT32(s, window_state->ownerWindowId); /* ownerWindowId (4 bytes) */
|
||||
}
|
||||
|
||||
if (orderInfo->fieldFlags & WINDOW_ORDER_FIELD_STYLE)
|
||||
{
|
||||
if(stream_get_left(s) < 8)
|
||||
if(Stream_GetRemainingLength(s) < 8)
|
||||
return FALSE;
|
||||
stream_read_UINT32(s, window_state->style); /* style (4 bytes) */
|
||||
stream_read_UINT32(s, window_state->extendedStyle); /* extendedStyle (4 bytes) */
|
||||
}
|
||||
|
||||
if (orderInfo->fieldFlags & WINDOW_ORDER_FIELD_SHOW) {
|
||||
if(stream_get_left(s) < 1)
|
||||
if(Stream_GetRemainingLength(s) < 1)
|
||||
return FALSE;
|
||||
stream_read_BYTE(s, window_state->showState); /* showState (1 byte) */
|
||||
}
|
||||
@ -129,7 +129,7 @@ BOOL update_read_window_state_order(wStream* s, WINDOW_ORDER_INFO* orderInfo, WI
|
||||
|
||||
if (orderInfo->fieldFlags & WINDOW_ORDER_FIELD_CLIENT_AREA_OFFSET)
|
||||
{
|
||||
if(stream_get_left(s) < 4)
|
||||
if(Stream_GetRemainingLength(s) < 4)
|
||||
return FALSE;
|
||||
stream_read_UINT32(s, window_state->clientOffsetX); /* clientOffsetX (4 bytes) */
|
||||
stream_read_UINT32(s, window_state->clientOffsetY); /* clientOffsetY (4 bytes) */
|
||||
@ -137,27 +137,27 @@ BOOL update_read_window_state_order(wStream* s, WINDOW_ORDER_INFO* orderInfo, WI
|
||||
|
||||
if (orderInfo->fieldFlags & WINDOW_ORDER_FIELD_CLIENT_AREA_SIZE)
|
||||
{
|
||||
if(stream_get_left(s) < 4)
|
||||
if(Stream_GetRemainingLength(s) < 4)
|
||||
return FALSE;
|
||||
stream_read_UINT32(s, window_state->clientAreaWidth); /* clientAreaWidth (4 bytes) */
|
||||
stream_read_UINT32(s, window_state->clientAreaHeight); /* clientAreaHeight (4 bytes) */
|
||||
}
|
||||
|
||||
if (orderInfo->fieldFlags & WINDOW_ORDER_FIELD_RP_CONTENT) {
|
||||
if(stream_get_left(s) < 1)
|
||||
if(Stream_GetRemainingLength(s) < 1)
|
||||
return FALSE;
|
||||
stream_read_BYTE(s, window_state->RPContent); /* RPContent (1 byte) */
|
||||
}
|
||||
|
||||
if (orderInfo->fieldFlags & WINDOW_ORDER_FIELD_ROOT_PARENT) {
|
||||
if(stream_get_left(s) < 4)
|
||||
if(Stream_GetRemainingLength(s) < 4)
|
||||
return FALSE;
|
||||
stream_read_UINT32(s, window_state->rootParentHandle);/* rootParentHandle (4 bytes) */
|
||||
}
|
||||
|
||||
if (orderInfo->fieldFlags & WINDOW_ORDER_FIELD_WND_OFFSET)
|
||||
{
|
||||
if(stream_get_left(s) < 8)
|
||||
if(Stream_GetRemainingLength(s) < 8)
|
||||
return FALSE;
|
||||
stream_read_UINT32(s, window_state->windowOffsetX); /* windowOffsetX (4 bytes) */
|
||||
stream_read_UINT32(s, window_state->windowOffsetY); /* windowOffsetY (4 bytes) */
|
||||
@ -165,7 +165,7 @@ BOOL update_read_window_state_order(wStream* s, WINDOW_ORDER_INFO* orderInfo, WI
|
||||
|
||||
if (orderInfo->fieldFlags & WINDOW_ORDER_FIELD_WND_CLIENT_DELTA)
|
||||
{
|
||||
if(stream_get_left(s) < 8)
|
||||
if(Stream_GetRemainingLength(s) < 8)
|
||||
return FALSE;
|
||||
stream_read_UINT32(s, window_state->windowClientDeltaX); /* windowClientDeltaX (4 bytes) */
|
||||
stream_read_UINT32(s, window_state->windowClientDeltaY); /* windowClientDeltaY (4 bytes) */
|
||||
@ -173,7 +173,7 @@ BOOL update_read_window_state_order(wStream* s, WINDOW_ORDER_INFO* orderInfo, WI
|
||||
|
||||
if (orderInfo->fieldFlags & WINDOW_ORDER_FIELD_WND_SIZE)
|
||||
{
|
||||
if(stream_get_left(s) < 8)
|
||||
if(Stream_GetRemainingLength(s) < 8)
|
||||
return FALSE;
|
||||
stream_read_UINT32(s, window_state->windowWidth); /* windowWidth (4 bytes) */
|
||||
stream_read_UINT32(s, window_state->windowHeight); /* windowHeight (4 bytes) */
|
||||
@ -181,14 +181,14 @@ BOOL update_read_window_state_order(wStream* s, WINDOW_ORDER_INFO* orderInfo, WI
|
||||
|
||||
if (orderInfo->fieldFlags & WINDOW_ORDER_FIELD_WND_RECTS)
|
||||
{
|
||||
if(stream_get_left(s) < 2)
|
||||
if(Stream_GetRemainingLength(s) < 2)
|
||||
return FALSE;
|
||||
stream_read_UINT16(s, window_state->numWindowRects); /* numWindowRects (2 bytes) */
|
||||
|
||||
size = sizeof(RECTANGLE_16) * window_state->numWindowRects;
|
||||
window_state->windowRects = (RECTANGLE_16*) malloc(size);
|
||||
|
||||
if(stream_get_left(s) < 8 * window_state->numWindowRects)
|
||||
if(Stream_GetRemainingLength(s) < 8 * window_state->numWindowRects)
|
||||
return FALSE;
|
||||
|
||||
/* windowRects */
|
||||
@ -203,7 +203,7 @@ BOOL update_read_window_state_order(wStream* s, WINDOW_ORDER_INFO* orderInfo, WI
|
||||
|
||||
if (orderInfo->fieldFlags & WINDOW_ORDER_FIELD_VIS_OFFSET)
|
||||
{
|
||||
if(stream_get_left(s) < 4)
|
||||
if(Stream_GetRemainingLength(s) < 4)
|
||||
return FALSE;
|
||||
stream_read_UINT32(s, window_state->visibleOffsetX); /* visibleOffsetX (4 bytes) */
|
||||
stream_read_UINT32(s, window_state->visibleOffsetY); /* visibleOffsetY (4 bytes) */
|
||||
@ -211,14 +211,14 @@ BOOL update_read_window_state_order(wStream* s, WINDOW_ORDER_INFO* orderInfo, WI
|
||||
|
||||
if (orderInfo->fieldFlags & WINDOW_ORDER_FIELD_VISIBILITY)
|
||||
{
|
||||
if(stream_get_left(s) < 2)
|
||||
if(Stream_GetRemainingLength(s) < 2)
|
||||
return FALSE;
|
||||
stream_read_UINT16(s, window_state->numVisibilityRects); /* numVisibilityRects (2 bytes) */
|
||||
|
||||
size = sizeof(RECTANGLE_16) * window_state->numVisibilityRects;
|
||||
window_state->visibilityRects = (RECTANGLE_16*) malloc(size);
|
||||
|
||||
if(stream_get_left(s) < window_state->numVisibilityRects * 8)
|
||||
if(Stream_GetRemainingLength(s) < window_state->numVisibilityRects * 8)
|
||||
return FALSE;
|
||||
|
||||
/* visibilityRects */
|
||||
@ -256,7 +256,7 @@ BOOL update_recv_window_info_order(rdpUpdate* update, wStream* s, WINDOW_ORDER_I
|
||||
rdpContext* context = update->context;
|
||||
rdpWindowUpdate* window = update->window;
|
||||
|
||||
if(stream_get_left(s) < 4)
|
||||
if(Stream_GetRemainingLength(s) < 4)
|
||||
return FALSE;
|
||||
stream_read_UINT32(s, orderInfo->windowId); /* windowId (4 bytes) */
|
||||
|
||||
@ -297,7 +297,7 @@ BOOL update_recv_window_info_order(rdpUpdate* update, wStream* s, WINDOW_ORDER_I
|
||||
BOOL update_read_notification_icon_state_order(wStream* s, WINDOW_ORDER_INFO* orderInfo, NOTIFY_ICON_STATE_ORDER* notify_icon_state)
|
||||
{
|
||||
if (orderInfo->fieldFlags & WINDOW_ORDER_FIELD_NOTIFY_VERSION) {
|
||||
if(stream_get_left(s) < 4)
|
||||
if(Stream_GetRemainingLength(s) < 4)
|
||||
return FALSE;
|
||||
stream_read_UINT32(s, notify_icon_state->version); /* version (4 bytes) */
|
||||
}
|
||||
@ -313,7 +313,7 @@ BOOL update_read_notification_icon_state_order(wStream* s, WINDOW_ORDER_INFO* or
|
||||
}
|
||||
|
||||
if (orderInfo->fieldFlags & WINDOW_ORDER_FIELD_NOTIFY_STATE) {
|
||||
if(stream_get_left(s) < 4)
|
||||
if(Stream_GetRemainingLength(s) < 4)
|
||||
return FALSE;
|
||||
stream_read_UINT32(s, notify_icon_state->state); /* state (4 bytes) */
|
||||
}
|
||||
@ -340,7 +340,7 @@ BOOL update_recv_notification_icon_info_order(rdpUpdate* update, wStream* s, WIN
|
||||
rdpContext* context = update->context;
|
||||
rdpWindowUpdate* window = update->window;
|
||||
|
||||
if(stream_get_left(s) < 8)
|
||||
if(Stream_GetRemainingLength(s) < 8)
|
||||
return FALSE;
|
||||
stream_read_UINT32(s, orderInfo->windowId); /* windowId (4 bytes) */
|
||||
stream_read_UINT32(s, orderInfo->notifyIconId); /* notifyIconId (4 bytes) */
|
||||
@ -371,18 +371,18 @@ BOOL update_read_desktop_actively_monitored_order(wStream* s, WINDOW_ORDER_INFO*
|
||||
int size;
|
||||
|
||||
if (orderInfo->fieldFlags & WINDOW_ORDER_FIELD_DESKTOP_ACTIVE_WND) {
|
||||
if(stream_get_left(s) < 4)
|
||||
if(Stream_GetRemainingLength(s) < 4)
|
||||
return FALSE;
|
||||
stream_read_UINT32(s, monitored_desktop->activeWindowId); /* activeWindowId (4 bytes) */
|
||||
}
|
||||
|
||||
if (orderInfo->fieldFlags & WINDOW_ORDER_FIELD_DESKTOP_ZORDER)
|
||||
{
|
||||
if(stream_get_left(s) < 1)
|
||||
if(Stream_GetRemainingLength(s) < 1)
|
||||
return FALSE;
|
||||
stream_read_BYTE(s, monitored_desktop->numWindowIds); /* numWindowIds (1 byte) */
|
||||
|
||||
if(stream_get_left(s) < 4 * monitored_desktop->numWindowIds)
|
||||
if(Stream_GetRemainingLength(s) < 4 * monitored_desktop->numWindowIds)
|
||||
return FALSE;
|
||||
|
||||
size = sizeof(UINT32) * monitored_desktop->numWindowIds;
|
||||
@ -432,7 +432,7 @@ BOOL update_recv_altsec_window_order(rdpUpdate* update, wStream* s)
|
||||
UINT16 orderSize;
|
||||
rdpWindowUpdate* window = update->window;
|
||||
|
||||
if(stream_get_left(s) < 6)
|
||||
if(Stream_GetRemainingLength(s) < 6)
|
||||
return FALSE;
|
||||
stream_read_UINT16(s, orderSize); /* orderSize (2 bytes) */
|
||||
stream_read_UINT32(s, window->orderInfo.fieldFlags); /* FieldsPresentFlags (4 bytes) */
|
||||
|
@ -30,7 +30,7 @@ BOOL ber_read_length(wStream* s, int* length)
|
||||
{
|
||||
BYTE byte;
|
||||
|
||||
if(stream_get_left(s) < 1)
|
||||
if(Stream_GetRemainingLength(s) < 1)
|
||||
return FALSE;
|
||||
stream_read_BYTE(s, byte);
|
||||
|
||||
@ -38,7 +38,7 @@ BOOL ber_read_length(wStream* s, int* length)
|
||||
{
|
||||
byte &= ~(0x80);
|
||||
|
||||
if(stream_get_left(s) < byte)
|
||||
if(Stream_GetRemainingLength(s) < byte)
|
||||
return FALSE;
|
||||
|
||||
if (byte == 1)
|
||||
@ -103,7 +103,7 @@ BOOL ber_read_universal_tag(wStream* s, BYTE tag, BOOL pc)
|
||||
{
|
||||
BYTE byte;
|
||||
|
||||
if(stream_get_left(s) < 1)
|
||||
if(Stream_GetRemainingLength(s) < 1)
|
||||
return FALSE;
|
||||
stream_read_BYTE(s, byte);
|
||||
|
||||
@ -138,14 +138,14 @@ BOOL ber_read_application_tag(wStream* s, BYTE tag, int* length)
|
||||
|
||||
if (tag > 30)
|
||||
{
|
||||
if(stream_get_left(s) < 1)
|
||||
if(Stream_GetRemainingLength(s) < 1)
|
||||
return FALSE;
|
||||
stream_read_BYTE(s, byte);
|
||||
|
||||
if (byte != ((BER_CLASS_APPL | BER_CONSTRUCT) | BER_TAG_MASK))
|
||||
return FALSE;
|
||||
|
||||
if(stream_get_left(s) < 1)
|
||||
if(Stream_GetRemainingLength(s) < 1)
|
||||
return FALSE;
|
||||
stream_read_BYTE(s, byte);
|
||||
|
||||
@ -156,7 +156,7 @@ BOOL ber_read_application_tag(wStream* s, BYTE tag, int* length)
|
||||
}
|
||||
else
|
||||
{
|
||||
if(stream_get_left(s) < 1)
|
||||
if(Stream_GetRemainingLength(s) < 1)
|
||||
return FALSE;
|
||||
stream_read_BYTE(s, byte);
|
||||
|
||||
@ -195,13 +195,13 @@ BOOL ber_read_contextual_tag(wStream* s, BYTE tag, int* length, BOOL pc)
|
||||
{
|
||||
BYTE byte;
|
||||
|
||||
if(stream_get_left(s) < 1)
|
||||
if(Stream_GetRemainingLength(s) < 1)
|
||||
return FALSE;
|
||||
stream_read_BYTE(s, byte);
|
||||
|
||||
if (byte != ((BER_CLASS_CTXT | BER_PC(pc)) | (BER_TAG_MASK & tag)))
|
||||
{
|
||||
stream_rewind(s, 1);
|
||||
Stream_Rewind(s, 1);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@ -223,7 +223,7 @@ BOOL ber_read_sequence_tag(wStream* s, int* length)
|
||||
{
|
||||
BYTE byte;
|
||||
|
||||
if(stream_get_left(s) < 1)
|
||||
if(Stream_GetRemainingLength(s) < 1)
|
||||
return FALSE;
|
||||
stream_read_BYTE(s, byte);
|
||||
|
||||
@ -263,7 +263,7 @@ BOOL ber_read_enumerated(wStream* s, BYTE* enumerated, BYTE count)
|
||||
!ber_read_length(s, &length))
|
||||
return FALSE;
|
||||
|
||||
if (length != 1 || stream_get_left(s) < 1)
|
||||
if (length != 1 || Stream_GetRemainingLength(s) < 1)
|
||||
return FALSE;
|
||||
|
||||
stream_read_BYTE(s, *enumerated);
|
||||
@ -288,7 +288,7 @@ BOOL ber_read_bit_string(wStream* s, int* length, BYTE* padding)
|
||||
!ber_read_length(s, length))
|
||||
return FALSE;
|
||||
|
||||
if(stream_get_left(s) < 1)
|
||||
if(Stream_GetRemainingLength(s) < 1)
|
||||
return FALSE;
|
||||
stream_read_BYTE(s, *padding);
|
||||
return TRUE;
|
||||
@ -342,7 +342,7 @@ BOOL ber_read_BOOL(wStream* s, BOOL* value)
|
||||
!ber_read_length(s, &length))
|
||||
return FALSE;
|
||||
|
||||
if (length != 1 || stream_get_left(s) < 1)
|
||||
if (length != 1 || Stream_GetRemainingLength(s) < 1)
|
||||
return FALSE;
|
||||
|
||||
stream_read_BYTE(s, v);
|
||||
@ -369,7 +369,7 @@ BOOL ber_read_integer(wStream* s, UINT32* value)
|
||||
|
||||
if (!ber_read_universal_tag(s, BER_TAG_INTEGER, FALSE) ||
|
||||
!ber_read_length(s, &length) ||
|
||||
stream_get_left(s) < length)
|
||||
Stream_GetRemainingLength(s) < length)
|
||||
return FALSE;
|
||||
|
||||
if (value == NULL)
|
||||
|
@ -178,7 +178,7 @@ BOOL er_read_contextual_tag(wStream* s, BYTE tag, int* length, BOOL pc)
|
||||
|
||||
if (byte != ((ER_CLASS_CTXT | ER_PC(pc)) | (ER_TAG_MASK & tag)))
|
||||
{
|
||||
stream_rewind(s, 1);
|
||||
Stream_Rewind(s, 1);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@ -355,7 +355,7 @@ BOOL er_read_integer(wStream* s, UINT32* value)
|
||||
|
||||
if (value == NULL)
|
||||
{
|
||||
stream_seek(s, length);
|
||||
Stream_Seek(s, length);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
@ -34,14 +34,14 @@ BOOL per_read_length(wStream* s, UINT16* length)
|
||||
{
|
||||
BYTE byte;
|
||||
|
||||
if (stream_get_left(s) < 1)
|
||||
if (Stream_GetRemainingLength(s) < 1)
|
||||
return FALSE;
|
||||
|
||||
stream_read_BYTE(s, byte);
|
||||
|
||||
if (byte & 0x80)
|
||||
{
|
||||
if (stream_get_left(s) < 1)
|
||||
if (Stream_GetRemainingLength(s) < 1)
|
||||
return FALSE;
|
||||
|
||||
byte &= ~(0x80);
|
||||
@ -80,7 +80,7 @@ void per_write_length(wStream* s, int length)
|
||||
|
||||
BOOL per_read_choice(wStream* s, BYTE* choice)
|
||||
{
|
||||
if (stream_get_left(s) < 1)
|
||||
if (Stream_GetRemainingLength(s) < 1)
|
||||
return FALSE;
|
||||
|
||||
stream_read_BYTE(s, *choice);
|
||||
@ -107,7 +107,7 @@ void per_write_choice(wStream* s, BYTE choice)
|
||||
|
||||
BOOL per_read_selection(wStream* s, BYTE* selection)
|
||||
{
|
||||
if (stream_get_left(s) < 1)
|
||||
if (Stream_GetRemainingLength(s) < 1)
|
||||
return FALSE;
|
||||
|
||||
stream_read_BYTE(s, *selection);
|
||||
@ -134,7 +134,7 @@ void per_write_selection(wStream* s, BYTE selection)
|
||||
|
||||
BOOL per_read_number_of_sets(wStream* s, BYTE* number)
|
||||
{
|
||||
if (stream_get_left(s) < 1)
|
||||
if (Stream_GetRemainingLength(s) < 1)
|
||||
return FALSE;
|
||||
|
||||
stream_read_BYTE(s, *number);
|
||||
@ -160,10 +160,10 @@ void per_write_number_of_sets(wStream* s, BYTE number)
|
||||
|
||||
BOOL per_read_padding(wStream* s, int length)
|
||||
{
|
||||
if (stream_get_left(s) < length)
|
||||
if (Stream_GetRemainingLength(s) < length)
|
||||
return FALSE;
|
||||
|
||||
stream_seek(s, length);
|
||||
Stream_Seek(s, length);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@ -195,7 +195,7 @@ BOOL per_read_integer(wStream* s, UINT32* integer)
|
||||
if (!per_read_length(s, &length))
|
||||
return FALSE;
|
||||
|
||||
if (stream_get_left(s) < length)
|
||||
if (Stream_GetRemainingLength(s) < length)
|
||||
return FALSE;
|
||||
|
||||
if (length == 1)
|
||||
@ -243,7 +243,7 @@ void per_write_integer(wStream* s, UINT32 integer)
|
||||
|
||||
BOOL per_read_integer16(wStream* s, UINT16* integer, UINT16 min)
|
||||
{
|
||||
if (stream_get_left(s) < 2)
|
||||
if (Stream_GetRemainingLength(s) < 2)
|
||||
return FALSE;
|
||||
|
||||
stream_read_UINT16_be(s, *integer);
|
||||
@ -278,7 +278,7 @@ void per_write_integer16(wStream* s, UINT16 integer, UINT16 min)
|
||||
|
||||
BOOL per_read_enumerated(wStream* s, BYTE* enumerated, BYTE count)
|
||||
{
|
||||
if (stream_get_left(s) < 1)
|
||||
if (Stream_GetRemainingLength(s) < 1)
|
||||
return FALSE;
|
||||
|
||||
stream_read_BYTE(s, *enumerated);
|
||||
@ -322,7 +322,7 @@ BOOL per_read_object_identifier(wStream* s, BYTE oid[6])
|
||||
if (length != 5)
|
||||
return FALSE;
|
||||
|
||||
if (stream_get_left(s) < length)
|
||||
if (Stream_GetRemainingLength(s) < length)
|
||||
return FALSE;
|
||||
|
||||
stream_read_BYTE(s, t12); /* first two tuples */
|
||||
@ -399,11 +399,11 @@ BOOL per_read_octet_string(wStream* s, BYTE* oct_str, int length, int min)
|
||||
if (mlength + min != length)
|
||||
return FALSE;
|
||||
|
||||
if (stream_get_left(s) < length)
|
||||
if (Stream_GetRemainingLength(s) < length)
|
||||
return FALSE;
|
||||
|
||||
a_oct_str = s->pointer;
|
||||
stream_seek(s, length);
|
||||
Stream_Seek(s, length);
|
||||
|
||||
for (i = 0; i < length; i++)
|
||||
{
|
||||
@ -453,10 +453,10 @@ BOOL per_read_numeric_string(wStream* s, int min)
|
||||
|
||||
length = (mlength + min + 1) / 2;
|
||||
|
||||
if (stream_get_left(s) < length)
|
||||
if (Stream_GetRemainingLength(s) < length)
|
||||
return FALSE;
|
||||
|
||||
stream_seek(s, length);
|
||||
Stream_Seek(s, length);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
@ -48,12 +48,12 @@ void rail_unicode_string_free(RAIL_UNICODE_STRING* unicode_string)
|
||||
|
||||
BOOL rail_read_unicode_string(wStream* s, RAIL_UNICODE_STRING* unicode_string)
|
||||
{
|
||||
if (stream_get_left(s) < 2)
|
||||
if (Stream_GetRemainingLength(s) < 2)
|
||||
return FALSE;
|
||||
|
||||
stream_read_UINT16(s, unicode_string->length); /* cbString (2 bytes) */
|
||||
|
||||
if (stream_get_left(s) < unicode_string->length)
|
||||
if (Stream_GetRemainingLength(s) < unicode_string->length)
|
||||
return FALSE;
|
||||
|
||||
if (unicode_string->string == NULL)
|
||||
|
@ -127,13 +127,13 @@ static void svc_plugin_process_received(rdpSvcPlugin* plugin, void* pData, UINT3
|
||||
|
||||
if (dataFlags & CHANNEL_FLAG_LAST)
|
||||
{
|
||||
if (stream_get_size(data_in) != stream_get_length(data_in))
|
||||
if (Stream_Capacity(data_in) != Stream_GetPosition(data_in))
|
||||
{
|
||||
fprintf(stderr, "svc_plugin_process_received: read error\n");
|
||||
}
|
||||
|
||||
plugin->data_in = NULL;
|
||||
stream_set_pos(data_in, 0);
|
||||
Stream_SetPosition(data_in, 0);
|
||||
|
||||
MessageQueue_Post(plugin->MsgPipe->In, NULL, 0, (void*) data_in, NULL);
|
||||
}
|
||||
@ -305,13 +305,13 @@ int svc_plugin_send(rdpSvcPlugin* plugin, wStream* data_out)
|
||||
{
|
||||
UINT32 status = 0;
|
||||
|
||||
DEBUG_SVC("length %d", (int) stream_get_length(data_out));
|
||||
DEBUG_SVC("length %d", (int) Stream_GetPosition(data_out));
|
||||
|
||||
if (!plugin)
|
||||
status = CHANNEL_RC_BAD_INIT_HANDLE;
|
||||
else
|
||||
status = plugin->channel_entry_points.pVirtualChannelWrite(plugin->open_handle,
|
||||
stream_get_data(data_out), stream_get_length(data_out), data_out);
|
||||
Stream_Buffer(data_out), Stream_GetPosition(data_out), data_out);
|
||||
|
||||
if (status != CHANNEL_RC_OK)
|
||||
{
|
||||
|
@ -134,7 +134,7 @@ void mf_peer_rfx_update(freerdp_peer* client)
|
||||
|
||||
s = mfp->s;
|
||||
stream_clear(s);
|
||||
stream_set_pos(s, 0);
|
||||
Stream_SetPosition(s, 0);
|
||||
|
||||
UINT32 x = mfi->invalid.x / mfi->scale;
|
||||
UINT32 y = mfi->invalid.y / mfi->scale;
|
||||
@ -160,7 +160,7 @@ void mf_peer_rfx_update(freerdp_peer* client)
|
||||
cmd->codecID = 3;
|
||||
cmd->width = rect.width;
|
||||
cmd->height = rect.height;
|
||||
cmd->bitmapDataLength = stream_get_length(s);
|
||||
cmd->bitmapDataLength = Stream_GetPosition(s);
|
||||
cmd->bitmapData = stream_get_head(s);
|
||||
|
||||
//send
|
||||
|
@ -105,7 +105,7 @@ static void test_peer_init(freerdp_peer* client)
|
||||
static wStream* test_peer_stream_init(testPeerContext* context)
|
||||
{
|
||||
stream_clear(context->s);
|
||||
stream_set_pos(context->s, 0);
|
||||
Stream_SetPosition(context->s, 0);
|
||||
return context->s;
|
||||
}
|
||||
|
||||
@ -179,7 +179,7 @@ static void test_peer_draw_background(freerdp_peer* client)
|
||||
cmd->bpp = 32;
|
||||
cmd->width = rect.width;
|
||||
cmd->height = rect.height;
|
||||
cmd->bitmapDataLength = stream_get_length(s);
|
||||
cmd->bitmapDataLength = Stream_GetPosition(s);
|
||||
cmd->bitmapData = stream_get_head(s);
|
||||
update->SurfaceBits(update->context, cmd);
|
||||
|
||||
@ -278,7 +278,7 @@ static void test_peer_draw_icon(freerdp_peer* client, int x, int y)
|
||||
cmd->bpp = 32;
|
||||
cmd->width = context->icon_width;
|
||||
cmd->height = context->icon_height;
|
||||
cmd->bitmapDataLength = stream_get_length(s);
|
||||
cmd->bitmapDataLength = Stream_GetPosition(s);
|
||||
cmd->bitmapData = stream_get_head(s);
|
||||
update->SurfaceBits(update->context, cmd);
|
||||
}
|
||||
@ -305,7 +305,7 @@ static void test_peer_draw_icon(freerdp_peer* client, int x, int y)
|
||||
cmd->bpp = 32;
|
||||
cmd->width = context->icon_width;
|
||||
cmd->height = context->icon_height;
|
||||
cmd->bitmapDataLength = stream_get_length(s);
|
||||
cmd->bitmapDataLength = Stream_GetPosition(s);
|
||||
cmd->bitmapData = stream_get_head(s);
|
||||
update->SurfaceBits(update->context, cmd);
|
||||
|
||||
@ -417,10 +417,10 @@ static void* tf_debug_channel_thread_func(void* arg)
|
||||
if (WaitForSingleObject(context->stopEvent, 0) == WAIT_OBJECT_0)
|
||||
break;
|
||||
|
||||
stream_set_pos(s, 0);
|
||||
Stream_SetPosition(s, 0);
|
||||
|
||||
if (WTSVirtualChannelRead(context->debug_channel, 0, stream_get_head(s),
|
||||
stream_get_size(s), &bytes_returned) == FALSE)
|
||||
Stream_Capacity(s), &bytes_returned) == FALSE)
|
||||
{
|
||||
if (bytes_returned == 0)
|
||||
break;
|
||||
@ -428,14 +428,14 @@ static void* tf_debug_channel_thread_func(void* arg)
|
||||
stream_check_size(s, bytes_returned);
|
||||
|
||||
if (WTSVirtualChannelRead(context->debug_channel, 0, stream_get_head(s),
|
||||
stream_get_size(s), &bytes_returned) == FALSE)
|
||||
Stream_Capacity(s), &bytes_returned) == FALSE)
|
||||
{
|
||||
/* should not happen */
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
stream_set_pos(s, bytes_returned);
|
||||
Stream_SetPosition(s, bytes_returned);
|
||||
|
||||
printf("got %d bytes\n", bytes_returned);
|
||||
}
|
||||
|
@ -123,7 +123,7 @@ void wf_update_encode(wfInfo* wfi)
|
||||
|
||||
cmd = &wfi->cmd;
|
||||
|
||||
stream_set_pos(wfi->s, 0);
|
||||
Stream_SetPosition(wfi->s, 0);
|
||||
|
||||
wf_info_getScreenData(wfi, &width, &height, &pDataBits, &stride);
|
||||
|
||||
@ -149,7 +149,7 @@ void wf_update_encode(wfInfo* wfi)
|
||||
cmd->codecID = 3;
|
||||
cmd->width = width;
|
||||
cmd->height = height;
|
||||
cmd->bitmapDataLength = stream_get_length(wfi->s);
|
||||
cmd->bitmapDataLength = Stream_GetPosition(wfi->s);
|
||||
cmd->bitmapData = stream_get_head(wfi->s);
|
||||
}
|
||||
|
||||
|
@ -326,7 +326,7 @@ void xf_peer_init(freerdp_peer* client)
|
||||
wStream* xf_peer_stream_init(xfPeerContext* context)
|
||||
{
|
||||
stream_clear(context->s);
|
||||
stream_set_pos(context->s, 0);
|
||||
Stream_SetPosition(context->s, 0);
|
||||
return context->s;
|
||||
}
|
||||
|
||||
@ -408,7 +408,7 @@ void xf_peer_rfx_update(freerdp_peer* client, int x, int y, int width, int heigh
|
||||
cmd->codecID = client->settings->RemoteFxCodecId;
|
||||
cmd->width = width;
|
||||
cmd->height = height;
|
||||
cmd->bitmapDataLength = stream_get_length(s);
|
||||
cmd->bitmapDataLength = Stream_GetPosition(s);
|
||||
cmd->bitmapData = stream_get_head(s);
|
||||
|
||||
update->SurfaceBits(update->context, cmd);
|
||||
|
@ -190,10 +190,13 @@ WINPR_API void Stream_Free(wStream* s, BOOL bFreeBuffer);
|
||||
#define Stream_Buffer(_s) _s->buffer
|
||||
#define Stream_Length(_s) _s->length
|
||||
#define Stream_Capacity(_s) _s->capacity
|
||||
#define Stream_Position(_s) (_s->pointer - _s->buffer)
|
||||
|
||||
#define Stream_GetPosition(_s) (_s->pointer - _s->buffer)
|
||||
#define Stream_SetPosition(_s, _p) _s->pointer = _s->buffer + (_p)
|
||||
|
||||
#define Stream_SealLength(_s) _s->length = (_s->pointer - _s->buffer)
|
||||
#define Stream_GetRemainingLength(_s) (_s->length - (_s->pointer - _s->buffer))
|
||||
|
||||
/* Deprecated STREAM API */
|
||||
|
||||
WINPR_API wStream* stream_new(int size);
|
||||
@ -201,6 +204,7 @@ WINPR_API void stream_free(wStream* stream);
|
||||
|
||||
#define stream_attach(_s, _buf, _size) do { \
|
||||
_s->capacity = _size; \
|
||||
_s->length = _size; \
|
||||
_s->buffer = _buf; \
|
||||
_s->pointer = _buf; } while (0)
|
||||
#define stream_detach(_s) memset(_s, 0, sizeof(wStream))
|
||||
@ -211,19 +215,9 @@ WINPR_API void stream_extend(wStream* stream, int request_size);
|
||||
while (_s->pointer - _s->buffer + (_n) > _s->capacity) \
|
||||
stream_extend(_s, _n)
|
||||
|
||||
#define stream_get_pos(_s) (_s->pointer - _s->buffer)
|
||||
#define stream_set_pos(_s,_m) _s->pointer = _s->buffer + (_m)
|
||||
#define stream_seek(_s,_offset) _s->pointer += (_offset)
|
||||
#define stream_rewind(_s,_offset) _s->pointer -= (_offset)
|
||||
#define stream_seal(_s) _s->capacity = (_s->pointer - _s->buffer)
|
||||
#define stream_get_mark(_s,_mark) _mark = _s->pointer
|
||||
#define stream_set_mark(_s,_mark) _s->pointer = _mark
|
||||
#define stream_get_head(_s) _s->buffer
|
||||
#define stream_get_tail(_s) _s->pointer
|
||||
#define stream_get_length(_s) (_s->pointer - _s->buffer)
|
||||
#define stream_get_data(_s) (_s->buffer)
|
||||
#define stream_get_size(_s) (_s->capacity)
|
||||
#define stream_get_left(_s) (_s->capacity - (_s->pointer - _s->buffer))
|
||||
|
||||
#define stream_read_BYTE(_s, _v) do { _v = *_s->pointer++; } while (0)
|
||||
#define stream_read_UINT16(_s, _v) do { _v = \
|
||||
@ -305,10 +299,10 @@ WINPR_API void stream_extend(wStream* stream, int request_size);
|
||||
(((UINT64)(*(_s->pointer + 7))) << 56); \
|
||||
} while (0)
|
||||
|
||||
#define stream_seek_BYTE(_s) stream_seek(_s, 1)
|
||||
#define stream_seek_UINT16(_s) stream_seek(_s, 2)
|
||||
#define stream_seek_UINT32(_s) stream_seek(_s, 4)
|
||||
#define stream_seek_UINT64(_s) stream_seek(_s, 8)
|
||||
#define Stream_Seek_BYTE(_s) Stream_Seek(_s, 1)
|
||||
#define Stream_Seek_UINT16(_s) Stream_Seek(_s, 2)
|
||||
#define Stream_Seek_UINT32(_s) Stream_Seek(_s, 4)
|
||||
#define Stream_Seek_UINT64(_s) Stream_Seek(_s, 8)
|
||||
|
||||
#define stream_read_UINT16_be(_s, _v) do { _v = \
|
||||
(((UINT16)(*_s->pointer)) << 8) + \
|
||||
@ -336,9 +330,9 @@ WINPR_API void stream_extend(wStream* stream, int request_size);
|
||||
} while (0)
|
||||
|
||||
static INLINE BOOL stream_skip(wStream* s, size_t sz) {
|
||||
if (stream_get_left(s) < sz)
|
||||
if (Stream_GetRemainingLength(s) < sz)
|
||||
return FALSE;
|
||||
stream_seek(s, sz);
|
||||
Stream_Seek(s, sz);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
@ -119,7 +119,7 @@ void ntlm_read_ntlm_v2_client_challenge(wStream* s, NTLMv2_CLIENT_CHALLENGE* cha
|
||||
Stream_Read(s, challenge->ClientChallenge, 8);
|
||||
Stream_Read_UINT32(s, challenge->Reserved3);
|
||||
|
||||
size = Stream_Length(s) - Stream_Position(s);
|
||||
size = Stream_Length(s) - Stream_GetPosition(s);
|
||||
challenge->AvPairs = (NTLM_AV_PAIR*) malloc(size);
|
||||
Stream_Read(s, challenge->AvPairs, size);
|
||||
}
|
||||
|
@ -233,7 +233,7 @@ SECURITY_STATUS ntlm_read_NegotiateMessage(NTLM_CONTEXT* context, PSecBuffer buf
|
||||
if (message->NegotiateFlags & NTLMSSP_NEGOTIATE_VERSION)
|
||||
ntlm_read_version_info(s, &(message->Version)); /* Version (8 bytes) */
|
||||
|
||||
length = Stream_Position(s);
|
||||
length = Stream_GetPosition(s);
|
||||
buffer->cbBuffer = length;
|
||||
|
||||
sspi_SecBufferAlloc(&context->NegotiateMessage, length);
|
||||
@ -317,7 +317,7 @@ SECURITY_STATUS ntlm_write_NegotiateMessage(NTLM_CONTEXT* context, PSecBuffer bu
|
||||
if (message->NegotiateFlags & NTLMSSP_NEGOTIATE_VERSION)
|
||||
ntlm_write_version_info(s, &(message->Version));
|
||||
|
||||
length = Stream_Position(s);
|
||||
length = Stream_GetPosition(s);
|
||||
buffer->cbBuffer = length;
|
||||
|
||||
sspi_SecBufferAlloc(&context->NegotiateMessage, length);
|
||||
@ -606,7 +606,7 @@ SECURITY_STATUS ntlm_write_ChallengeMessage(NTLM_CONTEXT* context, PSecBuffer bu
|
||||
if (message->NegotiateFlags & NTLMSSP_NEGOTIATE_TARGET_INFO)
|
||||
ntlm_write_message_fields_buffer(s, &(message->TargetInfo));
|
||||
|
||||
length = Stream_Position(s);
|
||||
length = Stream_GetPosition(s);
|
||||
buffer->cbBuffer = length;
|
||||
|
||||
sspi_SecBufferAlloc(&context->ChallengeMessage, length);
|
||||
@ -682,7 +682,7 @@ SECURITY_STATUS ntlm_read_AuthenticateMessage(NTLM_CONTEXT* context, PSecBuffer
|
||||
if (message->NegotiateFlags & NTLMSSP_NEGOTIATE_VERSION)
|
||||
ntlm_read_version_info(s, &(message->Version)); /* Version (8 bytes) */
|
||||
|
||||
PayloadBufferOffset = Stream_Position(s);
|
||||
PayloadBufferOffset = Stream_GetPosition(s);
|
||||
|
||||
ntlm_read_message_fields_buffer(s, &(message->DomainName)); /* DomainName */
|
||||
|
||||
@ -718,7 +718,7 @@ SECURITY_STATUS ntlm_read_AuthenticateMessage(NTLM_CONTEXT* context, PSecBuffer
|
||||
ntlm_read_message_fields_buffer(s, &(message->EncryptedRandomSessionKey));
|
||||
CopyMemory(context->EncryptedRandomSessionKey, message->EncryptedRandomSessionKey.Buffer, 16);
|
||||
|
||||
length = Stream_Position(s);
|
||||
length = Stream_GetPosition(s);
|
||||
sspi_SecBufferAlloc(&context->AuthenticateMessage, length);
|
||||
CopyMemory(context->AuthenticateMessage.pvBuffer, s->buffer, length);
|
||||
buffer->cbBuffer = length;
|
||||
@ -727,7 +727,7 @@ SECURITY_STATUS ntlm_read_AuthenticateMessage(NTLM_CONTEXT* context, PSecBuffer
|
||||
|
||||
if (flags & MSV_AV_FLAGS_MESSAGE_INTEGRITY_CHECK)
|
||||
{
|
||||
MicOffset = Stream_Position(s);
|
||||
MicOffset = Stream_GetPosition(s);
|
||||
Stream_Read(s, message->MessageIntegrityCheck, 16);
|
||||
PayloadBufferOffset += 16;
|
||||
}
|
||||
@ -995,7 +995,7 @@ SECURITY_STATUS ntlm_write_AuthenticateMessage(NTLM_CONTEXT* context, PSecBuffer
|
||||
|
||||
if (context->UseMIC)
|
||||
{
|
||||
MicOffset = Stream_Position(s);
|
||||
MicOffset = Stream_GetPosition(s);
|
||||
Stream_Zero(s, 16); /* Message Integrity Check (16 bytes) */
|
||||
}
|
||||
|
||||
@ -1014,7 +1014,7 @@ SECURITY_STATUS ntlm_write_AuthenticateMessage(NTLM_CONTEXT* context, PSecBuffer
|
||||
if (message->NegotiateFlags & NTLMSSP_NEGOTIATE_KEY_EXCH)
|
||||
ntlm_write_message_fields_buffer(s, &(message->EncryptedRandomSessionKey)); /* EncryptedRandomSessionKey */
|
||||
|
||||
length = Stream_Position(s);
|
||||
length = Stream_GetPosition(s);
|
||||
sspi_SecBufferAlloc(&context->AuthenticateMessage, length);
|
||||
CopyMemory(context->AuthenticateMessage.pvBuffer, s->buffer, length);
|
||||
buffer->cbBuffer = length;
|
||||
|
@ -55,8 +55,6 @@ void StreamPool_ShiftUsed(wStreamPool* pool, int index, int count)
|
||||
|
||||
void StreamPool_AddUsed(wStreamPool* pool, wStream* s)
|
||||
{
|
||||
int index;
|
||||
|
||||
if ((pool->uSize + 1) >= pool->uCapacity)
|
||||
{
|
||||
pool->uCapacity *= 2;
|
||||
@ -88,32 +86,58 @@ void StreamPool_RemoveUsed(wStreamPool* pool, wStream* s)
|
||||
StreamPool_ShiftUsed(pool, index, -1);
|
||||
}
|
||||
|
||||
void StreamPool_ShiftAvailable(wStreamPool* pool, int index, int count)
|
||||
{
|
||||
if (count > 0)
|
||||
{
|
||||
if (pool->aSize + count > pool->aCapacity)
|
||||
{
|
||||
pool->aCapacity *= 2;
|
||||
pool->aArray = (wStream**) realloc(pool->aArray, sizeof(wStream*) * pool->aCapacity);
|
||||
}
|
||||
|
||||
MoveMemory(&pool->aArray[index + count], &pool->aArray[index], (pool->aSize - index) * sizeof(wStream*));
|
||||
pool->aSize += count;
|
||||
}
|
||||
else if (count < 0)
|
||||
{
|
||||
MoveMemory(&pool->aArray[index], &pool->aArray[index - count], (pool->aSize + count) * sizeof(wStream*));
|
||||
pool->aSize += count;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a stream from the pool.
|
||||
*/
|
||||
|
||||
wStream* StreamPool_Take(wStreamPool* pool, size_t size)
|
||||
{
|
||||
int index;
|
||||
wStream* s = NULL;
|
||||
BOOL found = FALSE;
|
||||
|
||||
if (pool->synchronized)
|
||||
WaitForSingleObject(pool->mutex, INFINITE);
|
||||
|
||||
if (pool->aSize > 0)
|
||||
s = pool->aArray[--(pool->aSize)];
|
||||
|
||||
if (size == 0)
|
||||
size = pool->defaultSize;
|
||||
|
||||
if (!s)
|
||||
for (index = 0; index < pool->aSize; index++)
|
||||
{
|
||||
s = pool->aArray[index];
|
||||
|
||||
if (s->capacity == size)
|
||||
{
|
||||
StreamPool_ShiftAvailable(pool, index, -1);
|
||||
found = TRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!found)
|
||||
s = Stream_New(NULL, size);
|
||||
}
|
||||
else
|
||||
{
|
||||
Stream_EnsureCapacity(s, size);
|
||||
Stream_Pointer(s) = Stream_Buffer(s);
|
||||
}
|
||||
|
||||
s->pool = pool;
|
||||
s->count = 1;
|
||||
|
@ -147,7 +147,7 @@ void stream_extend(wStream* stream, int request_size)
|
||||
int original_size;
|
||||
int increased_size;
|
||||
|
||||
pos = stream_get_pos(stream);
|
||||
pos = Stream_GetPosition(stream);
|
||||
original_size = stream->capacity;
|
||||
increased_size = (request_size > original_size ? request_size : original_size);
|
||||
stream->capacity += increased_size;
|
||||
@ -158,5 +158,5 @@ void stream_extend(wStream* stream, int request_size)
|
||||
stream->buffer = (BYTE*) realloc(stream->buffer, stream->capacity);
|
||||
|
||||
memset(stream->buffer + original_size, 0, increased_size);
|
||||
stream_set_pos(stream, pos);
|
||||
Stream_SetPosition(stream, pos);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user