Exemplo n.º 1
0
static void audin_server_send_formats(audin_server* audin, STREAM* s)
{
	int i;
	UINT32 nAvgBytesPerSec;

	stream_set_pos(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 */

	for (i = 0; i < audin->context.num_server_formats; i++)
	{
		nAvgBytesPerSec = audin->context.server_formats[i].nSamplesPerSec *
			audin->context.server_formats[i].nChannels *
			audin->context.server_formats[i].wBitsPerSample / 8;
		stream_check_size(s, 18);
		stream_write_UINT16(s, audin->context.server_formats[i].wFormatTag);
		stream_write_UINT16(s, audin->context.server_formats[i].nChannels);
		stream_write_UINT32(s, audin->context.server_formats[i].nSamplesPerSec);
		stream_write_UINT32(s, nAvgBytesPerSec);
		stream_write_UINT16(s, audin->context.server_formats[i].nBlockAlign);
		stream_write_UINT16(s, audin->context.server_formats[i].wBitsPerSample);
		stream_write_UINT16(s, audin->context.server_formats[i].cbSize);
		if (audin->context.server_formats[i].cbSize)
		{
			stream_check_size(s, audin->context.server_formats[i].cbSize);
			stream_write(s, audin->context.server_formats[i].data,
				audin->context.server_formats[i].cbSize);
		}
	}

	WTSVirtualChannelWrite(audin->audin_channel, stream_get_head(s), stream_get_length(s), NULL);
}
Exemplo n.º 2
0
BOOL drive_file_query_information(DRIVE_FILE* file, UINT32 FsInformationClass, STREAM* output)
{
	struct STAT st;

	if (STAT(file->fullpath, &st) != 0)
	{
		stream_write_UINT32(output, 0); /* Length */
		return FALSE;
	}

	switch (FsInformationClass)
	{
		case FileBasicInformation:
			/* http://msdn.microsoft.com/en-us/library/cc232094.aspx */
			stream_write_UINT32(output, 36); /* Length */
			stream_check_size(output, 36);
			stream_write_UINT64(output, FILE_TIME_SYSTEM_TO_RDP(st.st_mtime)); /* CreationTime */
			stream_write_UINT64(output, FILE_TIME_SYSTEM_TO_RDP(st.st_atime)); /* LastAccessTime */
			stream_write_UINT64(output, FILE_TIME_SYSTEM_TO_RDP(st.st_mtime)); /* LastWriteTime */
			stream_write_UINT64(output, FILE_TIME_SYSTEM_TO_RDP(st.st_ctime)); /* ChangeTime */
			stream_write_UINT32(output, FILE_ATTR_SYSTEM_TO_RDP(file, st)); /* FileAttributes */
			/* Reserved(4), MUST NOT be added! */
			break;

		case FileStandardInformation:
			/*  http://msdn.microsoft.com/en-us/library/cc232088.aspx */
			stream_write_UINT32(output, 22); /* Length */
			stream_check_size(output, 22);
			stream_write_UINT64(output, st.st_size); /* AllocationSize */
			stream_write_UINT64(output, st.st_size); /* EndOfFile */
			stream_write_UINT32(output, st.st_nlink); /* NumberOfLinks */
			stream_write_BYTE(output, file->delete_pending ? 1 : 0); /* DeletePending */
			stream_write_BYTE(output, file->is_dir ? 1 : 0); /* Directory */
			/* Reserved(2), MUST NOT be added! */
			break;

		case FileAttributeTagInformation:
			/* http://msdn.microsoft.com/en-us/library/cc232093.aspx */
			stream_write_UINT32(output, 8); /* Length */
			stream_check_size(output, 8);
			stream_write_UINT32(output, FILE_ATTR_SYSTEM_TO_RDP(file, st)); /* FileAttributes */
			stream_write_UINT32(output, 0); /* ReparseTag */
			break;

		default:
			stream_write_UINT32(output, 0); /* Length */
			DEBUG_WARN("invalid FsInformationClass %d", FsInformationClass);
			return FALSE;
	}
	return TRUE;
}
Exemplo n.º 3
0
void test_stream(void)
{
	STREAM * stream;
	int pos;
	uint32 n;
	uint64 n64;

	stream = stream_new(1);
	pos = stream_get_pos(stream);

	stream_write_uint8(stream, 0xFE);

	stream_check_size(stream, 14);
	stream_write_uint16(stream, 0x0102);
	stream_write_uint32(stream, 0x03040506);
	stream_write_uint64(stream, 0x0708091011121314LL);

	/* freerdp_hexdump(stream->buffer, 15); */

	stream_set_pos(stream, pos);
	stream_seek(stream, 3);
	stream_read_uint32(stream, n);
	stream_read_uint64(stream, n64);

	CU_ASSERT(n == 0x03040506);
	CU_ASSERT(n64 == 0x0708091011121314LL);

	stream_free(stream);
}
Exemplo n.º 4
0
STREAM* transport_recv_stream_init(rdpTransport* transport, int size)
{
	STREAM* s = transport->ReceiveStream;
	stream_check_size(s, size);
	stream_set_pos(s, 0);
	return s;
}
Exemplo n.º 5
0
STREAM* transport_send_stream_init(rdpTransport* transport, int size)
{
	STREAM* s = transport->send_stream;
	stream_check_size(s, size);
	stream_set_pos(s, 0);
	return s;
}
Exemplo n.º 6
0
static void WTSProcessChannelData(rdpPeerChannel* channel, int channelId, BYTE* data, int size, int flags, int total_size)
{
	if (flags & CHANNEL_FLAG_FIRST)
	{
		stream_set_pos(channel->receive_data, 0);
	}

	stream_check_size(channel->receive_data, size);
	stream_write(channel->receive_data, data, size);

	if (flags & CHANNEL_FLAG_LAST)
	{
		if (stream_get_length(channel->receive_data) != total_size)
		{
			fprintf(stderr, "WTSProcessChannelData: read error\n");
		}
		if (channel == channel->vcm->drdynvc_channel)
		{
			wts_read_drdynvc_pdu(channel);
		}
		else
		{
			wts_queue_receive_data(channel, stream_get_head(channel->receive_data), stream_get_length(channel->receive_data));
		}
		stream_set_pos(channel->receive_data, 0);
	}
}
Exemplo n.º 7
0
static void rfx_compose_message_region(RFX_CONTEXT* context, STREAM* s,
	const RFX_RECT* rects, int num_rects)
{
	int size;
	int i;

	size = 15 + num_rects * 8;
	stream_check_size(s, size);

	stream_write_UINT16(s, WBT_REGION); /* CodecChannelT.blockType */
	stream_write_UINT32(s, size); /* set CodecChannelT.blockLen later */
	stream_write_BYTE(s, 1); /* CodecChannelT.codecId */
	stream_write_BYTE(s, 0); /* CodecChannelT.channelId */
	stream_write_BYTE(s, 1); /* regionFlags */
	stream_write_UINT16(s, num_rects); /* numRects */

	for (i = 0; i < num_rects; i++)
	{
		stream_write_UINT16(s, rects[i].x);
		stream_write_UINT16(s, rects[i].y);
		stream_write_UINT16(s, rects[i].width);
		stream_write_UINT16(s, rects[i].height);
	}

	stream_write_UINT16(s, CBT_REGION); /* regionType */
	stream_write_UINT16(s, 1); /* numTilesets */
}
Exemplo n.º 8
0
static void svc_plugin_process_received(rdpSvcPlugin* plugin, void* pData, uint32 dataLength,
	uint32 totalLength, uint32 dataFlags)
{
	STREAM* data_in;

	if (dataFlags & CHANNEL_FLAG_FIRST)
	{
		if (plugin->priv->data_in != NULL)
			stream_free(plugin->priv->data_in);
		plugin->priv->data_in = stream_new(totalLength);
	}

	data_in = plugin->priv->data_in;
	stream_check_size(data_in, dataLength);
	stream_write(data_in, pData, dataLength);

	if (dataFlags & CHANNEL_FLAG_LAST)
	{
		if (stream_get_size(data_in) != stream_get_length(data_in))
		{
			printf("svc_plugin_process_received: read error\n");
		}
		/* the stream ownership is passed to the callback who is responsible for freeing it. */
		plugin->priv->data_in = NULL;
		stream_set_pos(data_in, 0);
		plugin->receive_callback(plugin, data_in);
	}
}
Exemplo n.º 9
0
void rail_write_unicode_string_value(wStream* s, RAIL_UNICODE_STRING* unicode_string)
{
	if (unicode_string->length > 0)
	{
		stream_check_size(s, unicode_string->length);
		stream_write(s, unicode_string->string, unicode_string->length); /* string */
	}
}
Exemplo n.º 10
0
BOOL freerdp_channel_send(rdpRdp* rdp, UINT16 channel_id, BYTE* data, int size)
{
	STREAM* s;
	UINT32 flags;
	int i, left;
	int chunk_size;
	rdpChannel* channel = NULL;

	for (i = 0; i < rdp->settings->ChannelCount; i++)
	{
		if (rdp->settings->ChannelDefArray[i].ChannelId == channel_id)
		{
			channel = &rdp->settings->ChannelDefArray[i];
			break;
		}
	}

	if (channel == NULL)
	{
		printf("freerdp_channel_send: unknown channel_id %d\n", channel_id);
		return FALSE;
	}

	flags = CHANNEL_FLAG_FIRST;
	left = size;
	while (left > 0)
	{
		s = rdp_send_stream_init(rdp);

		if (left > (int) rdp->settings->VirtualChannelChunkSize)
		{
			chunk_size = rdp->settings->VirtualChannelChunkSize;
		}
		else
		{
			chunk_size = left;
			flags |= CHANNEL_FLAG_LAST;
		}
		if ((channel->options & CHANNEL_OPTION_SHOW_PROTOCOL))
		{
			flags |= CHANNEL_FLAG_SHOW_PROTOCOL;
		}

		stream_write_UINT32(s, size);
		stream_write_UINT32(s, flags);
		stream_check_size(s, chunk_size);
		stream_write(s, data, chunk_size);

		rdp_send(rdp, s, channel_id);

		data += chunk_size;
		left -= chunk_size;
		flags = 0;
	}

	return TRUE;
}
Exemplo n.º 11
0
void update_write_surfcmd_frame_marker(STREAM* s, UINT16 frameAction, UINT32 frameId)
{
	stream_check_size(s, SURFCMD_FRAME_MARKER_LENGTH);

	stream_write_UINT16(s, CMDTYPE_FRAME_MARKER);

	stream_write_UINT16(s, frameAction);
	stream_write_UINT32(s, frameId);
}
Exemplo n.º 12
0
boolean vchan_send(rdpVchan* vchan, uint16 channel_id, uint8* data, int size)
{
	STREAM* s;
	uint32 flags;
	rdpChan* channel = NULL;
	int i;
	int chunk_size;
	int left;

	for (i = 0; i < vchan->instance->settings->num_channels; i++)
	{
		if (vchan->instance->settings->channels[i].chan_id == channel_id)
		{
			channel = &vchan->instance->settings->channels[i];
			break;
		}
	}
	if (channel == NULL)
	{
		printf("vchan_send: unknown channel_id %d\n", channel_id);
		return False;
	}

	flags = CHANNEL_FLAG_FIRST;
	left = size;
	while (left > 0)
	{
		s = rdp_send_stream_init(vchan->instance->rdp);

		if (left > (int) vchan->instance->settings->vc_chunk_size)
		{
			chunk_size = vchan->instance->settings->vc_chunk_size;
		}
		else
		{
			chunk_size = left;
			flags |= CHANNEL_FLAG_LAST;
		}
		if ((channel->options & CHANNEL_OPTION_SHOW_PROTOCOL))
		{
			flags |= CHANNEL_FLAG_SHOW_PROTOCOL;
		}

		stream_write_uint32(s, size);
		stream_write_uint32(s, flags);
		stream_check_size(s, chunk_size);
		stream_write(s, data, chunk_size);

		rdp_send(vchan->instance->rdp, s, channel_id);

		data += chunk_size;
		left -= chunk_size;
		flags = 0;
	}

	return True;
}
Exemplo n.º 13
0
boolean freerdp_channel_send(rdpRdp* rdp, uint16 channel_id, uint8* data, int size)
{
	STREAM* s;
	uint32 flags;
	int i, left;
	int chunk_size;
	rdpChannel* channel = NULL;

	for (i = 0; i < rdp->settings->num_channels; i++)
	{
		if (rdp->settings->channels[i].channel_id == channel_id)
		{
			channel = &rdp->settings->channels[i];
			break;
		}
	}

	if (channel == NULL)
	{
		printf("freerdp_channel_send: unknown channel_id %d\n", channel_id);
		return false;
	}

	flags = CHANNEL_FLAG_FIRST;
	left = size;
	while (left > 0)
	{
		s = rdp_send_stream_init(rdp);

		if (left > (int) rdp->settings->vc_chunk_size)
		{
			chunk_size = rdp->settings->vc_chunk_size;
		}
		else
		{
			chunk_size = left;
			flags |= CHANNEL_FLAG_LAST;
		}
		if ((channel->options & CHANNEL_OPTION_SHOW_PROTOCOL))
		{
			flags |= CHANNEL_FLAG_SHOW_PROTOCOL;
		}

		stream_write_uint32(s, size);
		stream_write_uint32(s, flags);
		stream_check_size(s, chunk_size);
		stream_write(s, data, chunk_size);

		rdp_send(rdp, s, channel_id);

		data += chunk_size;
		left -= chunk_size;
		flags = 0;
	}

	return true;
}
Exemplo n.º 14
0
static void rfx_compose_message_frame_end(RFX_CONTEXT* context, STREAM* s)
{
	stream_check_size(s, 8);

	stream_write_UINT16(s, WBT_FRAME_END); /* CodecChannelT.blockType */
	stream_write_UINT32(s, 8); /* CodecChannelT.blockLen */
	stream_write_BYTE(s, 1); /* CodecChannelT.codecId */
	stream_write_BYTE(s, 0); /* CodecChannelT.channelId */
}
Exemplo n.º 15
0
static void wts_write_drdynvc_create_request(wStream *s, UINT32 ChannelId, const char *ChannelName)
{
	UINT32 len;

	wts_write_drdynvc_header(s, CREATE_REQUEST_PDU, ChannelId);
	len = strlen(ChannelName) + 1;
	stream_check_size(s, (int) len);
	stream_write(s, ChannelName, len);
}
Exemplo n.º 16
0
static void drive_process_irp_read(DRIVE_DEVICE* disk, IRP* irp)
{
	DRIVE_FILE* file;
	UINT32 Length;
	UINT64 Offset;
	BYTE* buffer = NULL;

	stream_read_UINT32(irp->input, Length);
	stream_read_UINT64(irp->input, Offset);

	file = drive_get_file_by_id(disk, irp->FileId);

	if (file == NULL)
	{
		irp->IoStatus = STATUS_UNSUCCESSFUL;
		Length = 0;

		DEBUG_WARN("FileId %d not valid.", irp->FileId);
	}
	else if (!drive_file_seek(file, Offset))
	{
		irp->IoStatus = STATUS_UNSUCCESSFUL;
		Length = 0;

		DEBUG_WARN("seek %s(%d) failed.", file->fullpath, file->id);
	}
	else
	{
		buffer = (BYTE*) malloc(Length);
		if (!drive_file_read(file, buffer, &Length))
		{
			irp->IoStatus = STATUS_UNSUCCESSFUL;
			free(buffer);
			buffer = NULL;
			Length = 0;

			DEBUG_WARN("read %s(%d) failed.", file->fullpath, file->id);
		}
		else
		{
			DEBUG_SVC("read %llu-%llu from %s(%d).", Offset, Offset + Length, file->fullpath, file->id);
		}
	}

	stream_write_UINT32(irp->output, Length);

	if (Length > 0)
	{
		stream_check_size(irp->output, (int) Length);
		stream_write(irp->output, buffer, Length);
	}

	free(buffer);

	irp->Complete(irp);
}
Exemplo n.º 17
0
static void update_send_surface_command(rdpContext* context, STREAM* s)
{
	STREAM* update;
	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));
	fastpath_send_update_pdu(rdp->fastpath, FASTPATH_UPDATETYPE_SURFCMDS, update);
}
Exemplo n.º 18
0
static void* tf_debug_channel_thread_func(void* arg)
{
	void* fd;
	STREAM* s;
	void* buffer;
	UINT32 bytes_returned = 0;
	testPeerContext* context = (testPeerContext*) arg;
	freerdp_thread* thread = context->debug_channel_thread;

	if (WTSVirtualChannelQuery(context->debug_channel, WTSVirtualFileHandle, &buffer, &bytes_returned) == TRUE)
	{
		fd = *((void**) buffer);
		WTSFreeMemory(buffer);
		thread->signals[thread->num_signals++] = CreateFileDescriptorEvent(NULL, TRUE, FALSE, ((int) (long) fd));
	}

	s = stream_new(4096);

	WTSVirtualChannelWrite(context->debug_channel, (BYTE*) "test1", 5, NULL);

	while (1)
	{
		freerdp_thread_wait(thread);

		if (freerdp_thread_is_stopped(thread))
			break;

		stream_set_pos(s, 0);

		if (WTSVirtualChannelRead(context->debug_channel, 0, stream_get_head(s),
			stream_get_size(s), &bytes_returned) == FALSE)
		{
			if (bytes_returned == 0)
				break;

			stream_check_size(s, bytes_returned);

			if (WTSVirtualChannelRead(context->debug_channel, 0, stream_get_head(s),
				stream_get_size(s), &bytes_returned) == FALSE)
			{
				/* should not happen */
				break;
			}
		}

		stream_set_pos(s, bytes_returned);

		printf("got %d bytes\n", bytes_returned);
	}

	stream_free(s);
	freerdp_thread_quit(thread);

	return 0;
}
Exemplo n.º 19
0
void rfx_compose_message_header(RFX_CONTEXT* context, STREAM* s)
{
	stream_check_size(s, 12 + 10 + 12 + 13);

	rfx_compose_message_sync(context, s);
	rfx_compose_message_context(context, s);
	rfx_compose_message_codec_versions(context, s);
	rfx_compose_message_channels(context, s);

	context->header_processed = TRUE;
}
Exemplo n.º 20
0
static void update_send_surface_bits(rdpContext* context, SURFACE_BITS_COMMAND* surface_bits_command)
{
	STREAM* s;
	rdpRdp* rdp = context->rdp;

	s = fastpath_update_pdu_init(rdp->fastpath);
	stream_check_size(s, SURFCMD_SURFACE_BITS_HEADER_LENGTH + (int) surface_bits_command->bitmapDataLength);
	update_write_surfcmd_surface_bits_header(s, surface_bits_command);
	stream_write(s, surface_bits_command->bitmapData, surface_bits_command->bitmapDataLength);
	fastpath_send_update_pdu(rdp->fastpath, FASTPATH_UPDATETYPE_SURFCMDS, s);
}
Exemplo n.º 21
0
static void serial_process_irp_read(SERIAL_DEVICE* serial, IRP* irp)
{
	SERIAL_TTY* tty;
	UINT32 Length;
	UINT64 Offset;
	BYTE* buffer = NULL;

	stream_read_UINT32(irp->input, Length);
	stream_read_UINT64(irp->input, Offset);

	DEBUG_SVC("length %u offset %llu", Length, Offset);

	tty = serial->tty;

	if (tty == NULL)
	{
		irp->IoStatus = STATUS_UNSUCCESSFUL;
		Length = 0;

		DEBUG_WARN("tty not valid.");
	}
	else
	{
		buffer = (BYTE*) malloc(Length);

		if (!serial_tty_read(tty, buffer, &Length))
		{
			irp->IoStatus = STATUS_UNSUCCESSFUL;
			free(buffer);
			buffer = NULL;
			Length = 0;

			DEBUG_WARN("read %s(%d) failed.", serial->path, tty->id);
		}
		else
		{
			DEBUG_SVC("read %llu-%llu from %d", Offset, Offset + Length, tty->id);
		}
	}

	stream_write_UINT32(irp->output, Length);

	if (Length > 0)
	{
		stream_check_size(irp->output, Length);
		stream_write(irp->output, buffer, Length);
	}

	free(buffer);

	irp->Complete(irp);
}
Exemplo n.º 22
0
static void rfx_compose_message_frame_begin(RFX_CONTEXT* context, STREAM* s)
{
	stream_check_size(s, 14);

	stream_write_UINT16(s, WBT_FRAME_BEGIN); /* CodecChannelT.blockType */
	stream_write_UINT32(s, 14); /* CodecChannelT.blockLen */
	stream_write_BYTE(s, 1); /* CodecChannelT.codecId */
	stream_write_BYTE(s, 0); /* CodecChannelT.channelId */
	stream_write_UINT32(s, context->frame_idx); /* frameIdx */
	stream_write_UINT16(s, 1); /* numRegions */

	context->frame_idx++;
}
Exemplo n.º 23
0
static int transport_read_nonblocking(rdpTransport* transport)
{
	int status;

	stream_check_size(transport->recv_buffer, 4096);
	status = transport_read(transport, transport->recv_buffer);

	if (status <= 0)
		return status;

	stream_seek(transport->recv_buffer, status);

	return status;
}
Exemplo n.º 24
0
static void* tf_debug_channel_thread_func(void* arg)
{
	void* fd;
	STREAM* s;
	void* buffer;
	uint32 bytes_returned = 0;
	testPeerContext* context = (testPeerContext*) arg;
	freerdp_thread* thread = context->debug_channel_thread;

	if (WTSVirtualChannelQuery(context->debug_channel, WTSVirtualFileHandle, &buffer, &bytes_returned) == true)
	{
		fd = *((void**)buffer);
		WTSFreeMemory(buffer);
		thread->signals[thread->num_signals++] = wait_obj_new_with_fd(fd);
	}

	s = stream_new(4096);

	WTSVirtualChannelWrite(context->debug_channel, (uint8*) "test1", 5, NULL);

	while (1)
	{
		freerdp_thread_wait(thread);
		if (freerdp_thread_is_stopped(thread))
			break;

		stream_set_pos(s, 0);
		if (WTSVirtualChannelRead(context->debug_channel, 0, stream_get_head(s),
			stream_get_size(s), &bytes_returned) == false)
		{
			if (bytes_returned == 0)
				break;
			stream_check_size(s, bytes_returned);
			if (WTSVirtualChannelRead(context->debug_channel, 0, stream_get_head(s),
				stream_get_size(s), &bytes_returned) == false)
			{
				/* should not happen */
				break;
			}
		}
		stream_set_pos(s, bytes_returned);

		printf("got %d bytes\n", bytes_returned);
	}

	stream_free(s);
	freerdp_thread_quit(thread);

	return 0;
}
Exemplo n.º 25
0
static int transport_read_nonblocking(rdpTransport* transport)
{
	int status;

	stream_check_size(transport->ReceiveBuffer, 32 * 1024);
	status = transport_read(transport, transport->ReceiveBuffer);

	if (status <= 0)
		return status;

	stream_seek(transport->ReceiveBuffer, status);

	return status;
}
Exemplo n.º 26
0
static void wts_read_drdynvc_data_first(rdpPeerChannel* channel, STREAM* s, int cbLen, uint32 length)
{
	int value;

	value = wts_read_variable_uint(s, cbLen, &channel->dvc_total_length);
	if (value == 0)
		return;
	length -= value;
	if (length > channel->dvc_total_length)
		return;

	stream_set_pos(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);
}
Exemplo n.º 27
0
void update_write_surfcmd_surface_bits_header(STREAM* s, SURFACE_BITS_COMMAND* cmd)
{
	stream_check_size(s, SURFCMD_SURFACE_BITS_HEADER_LENGTH);

	stream_write_UINT16(s, CMDTYPE_STREAM_SURFACE_BITS);

	stream_write_UINT16(s, cmd->destLeft);
	stream_write_UINT16(s, cmd->destTop);
	stream_write_UINT16(s, cmd->destRight);
	stream_write_UINT16(s, cmd->destBottom);
	stream_write_BYTE(s, cmd->bpp);
	stream_write_UINT16(s, 0); /* reserved1, reserved2 */
	stream_write_BYTE(s, cmd->codecID);
	stream_write_UINT16(s, cmd->width);
	stream_write_UINT16(s, cmd->height);
	stream_write_UINT32(s, cmd->bitmapDataLength);
}
Exemplo n.º 28
0
static void svc_plugin_process_received(rdpSvcPlugin* plugin, void* pData, uint32 dataLength,
	uint32 totalLength, uint32 dataFlags)
{
	STREAM* data_in;
	svc_data_in_item* item;
	
	if ( (dataFlags & CHANNEL_FLAG_SUSPEND) || (dataFlags & CHANNEL_FLAG_RESUME))
	{
		/* According to MS-RDPBCGR 2.2.6.1, "All virtual channel traffic MUST be suspended.
		This flag is only valid in server-to-client virtual channel traffic. It MUST be
		ignored in client-to-server data." Thus it would be best practice to cease data
		transmission. However, simply returing here avoids a crash. */
		return;
	}

	if (dataFlags & CHANNEL_FLAG_FIRST)
	{
		if (plugin->priv->data_in != NULL)
			stream_free(plugin->priv->data_in);
		plugin->priv->data_in = stream_new(totalLength);
	}

	data_in = plugin->priv->data_in;
	stream_check_size(data_in, (int) dataLength);
	stream_write(data_in, pData, dataLength);

	if (dataFlags & CHANNEL_FLAG_LAST)
	{
		if (stream_get_size(data_in) != stream_get_length(data_in))
		{
			printf("svc_plugin_process_received: read error\n");
		}

		plugin->priv->data_in = NULL;
		stream_set_pos(data_in, 0);

		item = xnew(svc_data_in_item);
		item->data_in = data_in;

		freerdp_thread_lock(plugin->priv->thread);
		list_enqueue(plugin->priv->data_in_list, item);
		freerdp_thread_unlock(plugin->priv->thread);

		freerdp_thread_signal(plugin->priv->thread);
	}
}
Exemplo n.º 29
0
static void update_write_pointer_color(STREAM* s, POINTER_COLOR_UPDATE* pointer_color)
{
	stream_check_size(s, 15 + (int) pointer_color->lengthAndMask + (int) pointer_color->lengthXorMask);

	stream_write_UINT16(s, pointer_color->cacheIndex);
	stream_write_UINT16(s, pointer_color->xPos);
	stream_write_UINT16(s, pointer_color->yPos);
	stream_write_UINT16(s, pointer_color->width);
	stream_write_UINT16(s, pointer_color->height);
	stream_write_UINT16(s, pointer_color->lengthAndMask);
	stream_write_UINT16(s, pointer_color->lengthXorMask);

	if (pointer_color->lengthXorMask > 0)
		stream_write(s, pointer_color->xorMaskData, pointer_color->lengthXorMask);
	
	if (pointer_color->lengthAndMask > 0)
		stream_write(s, pointer_color->andMaskData, pointer_color->lengthAndMask);
	
	stream_write_BYTE(s, 0); /* pad (1 byte) */
}
Exemplo n.º 30
0
static void rfx_compose_message_tile(RFX_CONTEXT* context, STREAM* s,
	BYTE* tile_data, int tile_width, int tile_height, int rowstride,
	const UINT32* quantVals, int quantIdxY, int quantIdxCb, int quantIdxCr,
	int xIdx, int yIdx)
{
	int YLen = 0;
	int CbLen = 0;
	int CrLen = 0;
	int start_pos, end_pos;

	stream_check_size(s, 19);
	start_pos = stream_get_pos(s);

	stream_write_UINT16(s, CBT_TILE); /* BlockT.blockType */
	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 */

	rfx_encode_rgb(context, tile_data, tile_width, tile_height, rowstride,
		quantVals + quantIdxY * 10, quantVals + quantIdxCb * 10, quantVals + quantIdxCr * 10,
		s, &YLen, &CbLen, &CrLen);

	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);

	stream_set_pos(s, start_pos + 2);
	stream_write_UINT32(s, 19 + YLen + CbLen + CrLen); /* BlockT.blockLen */
	stream_set_pos(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);
}