Beispiel #1
0
void gcc_write_conference_create_response(STREAM* s, STREAM* user_data)
{
	/* ConnectData */
	per_write_choice(s, 0);
	per_write_object_identifier(s, t124_02_98_oid);

	/* ConnectData::connectPDU (OCTET_STRING) */
	per_write_length(s, stream_get_length(user_data) + 2);

	/* ConnectGCCPDU */
	per_write_choice(s, 0x14);

	/* ConferenceCreateResponse::nodeID (UserID) */
	per_write_integer16(s, 0x79F3, 1001);

	/* ConferenceCreateResponse::tag (INTEGER) */
	per_write_integer(s, 1);

	/* ConferenceCreateResponse::result (ENUMERATED) */
	per_write_enumerated(s, 0, MCS_Result_enum_length);

	/* number of UserData sets */
	per_write_number_of_sets(s, 1);

	/* UserData::value present + select h221NonStandard (1) */
	per_write_choice(s, 0xC0);

	/* h221NonStandard */
	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->data, stream_get_length(user_data), 0); /* array of server data blocks */
}
Beispiel #2
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);
	}
}
Beispiel #3
0
void gcc_write_conference_create_request(STREAM* s, STREAM* user_data)
{
	/* ConnectData */
	per_write_choice(s, 0); /* From Key select object (0) of type OBJECT_IDENTIFIER */
	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 */

	/* ConnectGCCPDU */
	per_write_choice(s, 0); /* From ConnectGCCPDU select conferenceCreateRequest (0) of type ConferenceCreateRequest */
	per_write_selection(s, 0x08); /* select optional userData from ConferenceCreateRequest */

	/* ConferenceCreateRequest::conferenceName */
	per_write_numeric_string(s, "1", 1, 1); /* ConferenceName::numeric */
	per_write_padding(s, 1); /* padding */

	/* UserData (SET OF SEQUENCE) */
	per_write_number_of_sets(s, 1); /* one set of UserData */
	per_write_choice(s, 0xC0); /* UserData::value present + select h221NonStandard (1) */

	/* h221NonStandard */
	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->data, stream_get_length(user_data), 0); /* array of client data blocks */
}
Beispiel #4
0
int credssp_client_authenticate(rdpCredssp* credssp)
{
	NTLMSSP* ntlmssp = credssp->ntlmssp;
	STREAM* s = stream_new(0);
	uint8* negoTokenBuffer = (uint8*) xmalloc(2048);

	if (credssp_ntlmssp_client_init(credssp) == 0)
		return 0;

	/* NTLMSSP NEGOTIATE MESSAGE */
	stream_attach(s, negoTokenBuffer, 2048);
	ntlmssp_send(ntlmssp, s);
	credssp->negoToken.data = stream_get_head(s);
	credssp->negoToken.length = stream_get_length(s);
	credssp_send(credssp, &credssp->negoToken, NULL, NULL);

	/* NTLMSSP CHALLENGE MESSAGE */
	if (credssp_recv(credssp, &credssp->negoToken, NULL, NULL) < 0)
		return -1;

	stream_attach(s, credssp->negoToken.data, credssp->negoToken.length);
	ntlmssp_recv(ntlmssp, s);

	freerdp_blob_free(&credssp->negoToken);

	/* NTLMSSP AUTHENTICATE MESSAGE */
	stream_attach(s, negoTokenBuffer, 2048);
	ntlmssp_send(ntlmssp, s);

	/* The last NTLMSSP message is sent with the encrypted public key */
	credssp->negoToken.data = stream_get_head(s);
	credssp->negoToken.length = stream_get_length(s);
	credssp_encrypt_public_key(credssp, &credssp->pubKeyAuth);
	credssp_send(credssp, &credssp->negoToken, NULL, &credssp->pubKeyAuth);
	freerdp_blob_free(&credssp->pubKeyAuth);

	/* Encrypted Public Key +1 */
	if (credssp_recv(credssp, &credssp->negoToken, NULL, &credssp->pubKeyAuth) < 0)
		return -1;

	if (credssp_verify_public_key(credssp, &credssp->pubKeyAuth) == 0)
	{
		/* Failed to verify server public key echo */
		return 0; /* DO NOT SEND CREDENTIALS! */
	}

	freerdp_blob_free(&credssp->negoToken);
	freerdp_blob_free(&credssp->pubKeyAuth);

	/* Send encrypted credentials */
	credssp_encode_ts_credentials(credssp);
	credssp_encrypt_ts_credentials(credssp, &credssp->authInfo);
	credssp_send(credssp, NULL, &credssp->authInfo, NULL);
	freerdp_blob_free(&credssp->authInfo);

	xfree(s);

	return 1;
}
Beispiel #5
0
static void test_peer_draw_icon(freerdp_peer* client, int x, int y)
{
	testPeerContext* context = (testPeerContext*) client->context;
	rdpUpdate* update = client->update;
	SURFACE_BITS_COMMAND* cmd = &update->surface_bits_command;
	RFX_RECT rect;
	STREAM* s;

	if (client->update->dump_rfx)
		return;
	if (!client->settings->rfx_codec || !context)
		return;
	if (context->icon_width < 1 || !context->activated)
		return;

	rect.x = 0;
	rect.y = 0;
	rect.width = context->icon_width;
	rect.height = context->icon_height;

	if (context->icon_x >= 0)
	{
		s = test_peer_stream_init(context);
		rfx_compose_message(context->rfx_context, s,
			&rect, 1, context->bg_data, rect.width, rect.height, rect.width * 3);

		cmd->destLeft = context->icon_x;
		cmd->destTop = context->icon_y;
		cmd->destRight = context->icon_x + context->icon_width;
		cmd->destBottom = context->icon_y + context->icon_height;
		cmd->bpp = 32;
		cmd->codecID = client->settings->rfx_codec_id;
		cmd->width = context->icon_width;
		cmd->height = context->icon_height;
		cmd->bitmapDataLength = stream_get_length(s);
		cmd->bitmapData = stream_get_head(s);
		update->SurfaceBits(update->context, cmd);
	}

	s = test_peer_stream_init(context);
	rfx_compose_message(context->rfx_context, s,
		&rect, 1, context->icon_data, rect.width, rect.height, rect.width * 3);

	cmd->destLeft = x;
	cmd->destTop = y;
	cmd->destRight = x + context->icon_width;
	cmd->destBottom = y + context->icon_height;
	cmd->bpp = 32;
	cmd->codecID = client->settings->rfx_codec_id;
	cmd->width = context->icon_width;
	cmd->height = context->icon_height;
	cmd->bitmapDataLength = stream_get_length(s);
	cmd->bitmapData = stream_get_head(s);
	update->SurfaceBits(update->context, cmd);

	context->icon_x = x;
	context->icon_y = y;
}
Beispiel #6
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);
}
Beispiel #7
0
int transport_write(rdpTransport* transport, STREAM* s)
{
    int status = -1;

    if (transport->layer == TRANSPORT_LAYER_TLS)
        status = tls_write(transport->tls, s->data, stream_get_length(s));
    else if (transport->layer == TRANSPORT_LAYER_TCP)
        status = tcp_write(transport->tcp, s->data, stream_get_length(s));

    return status;
}
Beispiel #8
0
int svc_plugin_send(rdpSvcPlugin* plugin, STREAM* data_out)
{
	uint32 error = 0;

	DEBUG_SVC("length %d", stream_get_length(data_out));

	error = plugin->channel_entry_points.pVirtualChannelWrite(plugin->priv->open_handle,
		stream_get_data(data_out), stream_get_length(data_out), data_out);
	if (error != CHANNEL_RC_OK)
		printf("svc_plugin_send: VirtualChannelWrite failed %d\n", error);

	return error;
}
Beispiel #9
0
void test_read_fast_index_order(void)
{
	STREAM _s, *s;
	FAST_INDEX_ORDER fast_index;

	s = &_s;
	s->p = s->data = fast_index_order;

	memset(orderInfo, 0, sizeof(ORDER_INFO));
	orderInfo->fieldFlags = 0x70FF;

	memset(&fast_index, 0, sizeof(FAST_INDEX_ORDER));
	update_read_fast_index_order(s, orderInfo, &fast_index);

	CU_ASSERT(fast_index.cacheId == 7);
	CU_ASSERT(fast_index.flAccel == 3);
	CU_ASSERT(fast_index.ulCharInc == 0);
	CU_ASSERT(fast_index.backColor == 0x0000FFFF);
	CU_ASSERT(fast_index.foreColor == 0x00003B74);
	CU_ASSERT(fast_index.bkLeft == 14);
	CU_ASSERT(fast_index.bkTop == 113);
	CU_ASSERT(fast_index.bkRight == 66);
	CU_ASSERT(fast_index.bkBottom == 126);
	CU_ASSERT(fast_index.opLeft == 0);
	CU_ASSERT(fast_index.opTop == 0);
	CU_ASSERT(fast_index.opRight == 0);
	CU_ASSERT(fast_index.opBottom == 0);
	CU_ASSERT(fast_index.x == -32768);
	CU_ASSERT(fast_index.y == 124);

	CU_ASSERT(stream_get_length(s) == (sizeof(fast_index_order) - 1));
}
Beispiel #10
0
boolean license_send(rdpLicense* license, STREAM* s, uint8 type)
{
	int length;
	uint8 flags;
	uint16 wMsgSize;
	uint16 sec_flags;

	DEBUG_LICENSE("Sending %s Packet", LICENSE_MESSAGE_STRINGS[type & 0x1F]);

	length = stream_get_length(s);
	stream_set_pos(s, 0);

	sec_flags = SEC_LICENSE_PKT;
	wMsgSize = length - LICENSE_PACKET_HEADER_MAX_LENGTH + 4;
	/**
	 * Using EXTENDED_ERROR_MSG_SUPPORTED here would cause mstsc to crash when
	 * running in server mode! This flag seems to be incorrectly documented.
	 */
	flags = PREAMBLE_VERSION_3_0;

	rdp_write_header(license->rdp, s, length, MCS_GLOBAL_CHANNEL_ID);
	rdp_write_security_header(s, sec_flags);
	license_write_preamble(s, type, flags, wMsgSize);

#ifdef WITH_DEBUG_LICENSE
	printf("Sending %s Packet, length %d\n", LICENSE_MESSAGE_STRINGS[type & 0x1F], wMsgSize);
	freerdp_hexdump(s->p - 4, wMsgSize);
#endif

	stream_set_pos(s, length);
	if (transport_write(license->rdp->transport, s) < 0)
		return false;

	return true;
}
Beispiel #11
0
void test_read_line_to_order(void)
{
	STREAM _s, *s;
	LINE_TO_ORDER line_to;

	s = &_s;
	s->p = s->data = line_to_order;

	memset(orderInfo, 0, sizeof(ORDER_INFO));
	orderInfo->fieldFlags = 0x021E;
	orderInfo->deltaCoordinates = true;

	memset(&line_to, 0, sizeof(LINE_TO_ORDER));
	line_to.nXStart = 826;
	line_to.nYStart = 350;
	line_to.nXEnd = 829;
	line_to.nYEnd = 347;

	update_read_line_to_order(s, orderInfo, &line_to);

	CU_ASSERT(line_to.nXStart == 829);
	CU_ASSERT(line_to.nYStart == 271);
	CU_ASSERT(line_to.nXEnd == 843);
	CU_ASSERT(line_to.nYEnd == 257);
	CU_ASSERT(line_to.backColor == 0);
	CU_ASSERT(line_to.bRop2 == 0);
	CU_ASSERT(line_to.penStyle == 0);
	CU_ASSERT(line_to.penWidth == 0);
	CU_ASSERT(line_to.penColor == 0x00EF5B);

	CU_ASSERT(stream_get_length(s) == (sizeof(line_to_order) - 1));
}
Beispiel #12
0
void test_read_draw_nine_grid_order(void)
{
	STREAM _s, *s;
	DRAW_NINE_GRID_ORDER draw_nine_grid;

	s = &_s;
	s->p = s->data = draw_nine_grid_order;

	memset(orderInfo, 0, sizeof(ORDER_INFO));
	orderInfo->fieldFlags = 0x1C;
	orderInfo->deltaCoordinates = true;

	memset(&draw_nine_grid, 0, sizeof(DRAW_NINE_GRID_ORDER));
	draw_nine_grid.srcRight = 38;
	draw_nine_grid.srcBottom = 40;

	update_read_draw_nine_grid_order(s, orderInfo, &draw_nine_grid);

	CU_ASSERT(draw_nine_grid.srcLeft == 0);
	CU_ASSERT(draw_nine_grid.srcTop == 0);
	CU_ASSERT(draw_nine_grid.srcRight == 33);
	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));
}
Beispiel #13
0
boolean rdp_send_data_pdu(rdpRdp* rdp, STREAM* s, uint8 type, uint16 channel_id)
{
	uint16 length;
	uint32 sec_bytes;
	uint8* sec_hold;

	length = stream_get_length(s);
	stream_set_pos(s, 0);

	rdp_write_header(rdp, s, length, MCS_GLOBAL_CHANNEL_ID);

	sec_bytes = rdp_get_sec_bytes(rdp);
	sec_hold = s->p;
	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->share_id);

	s->p = sec_hold;
	length += rdp_security_stream_out(rdp, s, length);

	stream_set_pos(s, length);
	if (transport_write(rdp->transport, s) < 0)
		return false;

	return true;
}
Beispiel #14
0
void test_read_cache_bitmap_v3_order(void)
{
	STREAM _s, *s;
	uint16 extraFlags;
	CACHE_BITMAP_V3_ORDER cache_bitmap_v3;

	s = &_s;
	extraFlags = 0x0C30;
	s->p = s->data = cache_bitmap_v3_order;

	memset(&cache_bitmap_v3, 0, sizeof(CACHE_BITMAP_V3_ORDER));

	update_read_cache_bitmap_v3_order(s, &cache_bitmap_v3, true, extraFlags);

	CU_ASSERT(cache_bitmap_v3.cacheIndex == 32767);
	CU_ASSERT(cache_bitmap_v3.key1 == 0xBCEC5035);
	CU_ASSERT(cache_bitmap_v3.key2 == 0xB7655274);
	CU_ASSERT(cache_bitmap_v3.bpp == 32);

	CU_ASSERT(cache_bitmap_v3.bitmapData.bpp == 32);
	CU_ASSERT(cache_bitmap_v3.bitmapData.codecID == 0);
	CU_ASSERT(cache_bitmap_v3.bitmapData.width == 5);
	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));
}
Beispiel #15
0
static void audin_server_send_open(audin_server* audin, STREAM* s)
{
	if (audin->context.selected_client_format < 0)
		return;

	audin->opened = TRUE;

	stream_set_pos(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) */
	/*
	 * [MS-RDPEAI] 3.2.5.1.6
	 * The second format specify the format that SHOULD be used to capture data from
	 * the actual audio input device.
	 */
	stream_write_UINT16(s, 1); /* wFormatTag = PCM */
	stream_write_UINT16(s, 2); /* nChannels */
	stream_write_UINT32(s, 44100); /* nSamplesPerSec */
	stream_write_UINT32(s, 44100 * 2 * 2); /* nAvgBytesPerSec */
	stream_write_UINT16(s, 4); /* nBlockAlign */
	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);
}
Beispiel #16
0
void test_read_patblt_order(void)
{
	STREAM _s, *s;
	PATBLT_ORDER patblt;

	s = &_s;
	s->p = s->data = patblt_order;

	memset(orderInfo, 0, sizeof(ORDER_INFO));
	orderInfo->fieldFlags = 0x027F;
	memset(&patblt, 0, sizeof(PATBLT_ORDER));

	update_read_patblt_order(s, orderInfo, &patblt);

	CU_ASSERT(patblt.nLeftRect == 26);
	CU_ASSERT(patblt.nTopRect == 451);
	CU_ASSERT(patblt.nWidth == 13);
	CU_ASSERT(patblt.nHeight == 13);
	CU_ASSERT(patblt.bRop == 240);
	CU_ASSERT(patblt.backColor == 0x00FFFF);
	CU_ASSERT(patblt.foreColor == 0x00EF5B);
	CU_ASSERT(patblt.brush.x == 0);
	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));
}
Beispiel #17
0
static void sample_process_receive(rdpSvcPlugin* plugin, STREAM* data_in)
{
	int bytes;
	STREAM* data_out;
	samplePlugin* sample = (samplePlugin*) plugin;

	printf("sample_process_receive:\n");

	if (!sample)
	{
		printf("sample_process_receive: sample is nil\n");
		return;
	}

	/* process data in (from server) here */
	/* here we just send the same data back */

	bytes = stream_get_size(data_in);
	printf("sample_process_receive: got bytes %d\n", bytes);

	if (bytes > 0)
	{
		data_out = stream_new(bytes);
		stream_copy(data_out, data_in, bytes);
		/* svc_plugin_send takes ownership of data_out, that is why
		   we do not free it */

		bytes = stream_get_length(data_in);
		printf("sample_process_receive: sending bytes %d\n", bytes);

		svc_plugin_send(plugin, data_out);
	}

	stream_free(data_in);
}
Beispiel #18
0
BOOL rdp_send_data_pdu(rdpRdp* rdp, STREAM* s, BYTE type, UINT16 channel_id)
{
	UINT16 length;
	UINT32 sec_bytes;
	BYTE* sec_hold;

	length = stream_get_length(s);
	stream_set_pos(s, 0);

	rdp_write_header(rdp, s, length, MCS_GLOBAL_CHANNEL_ID);

	sec_bytes = rdp_get_sec_bytes(rdp);
	sec_hold = s->p;
	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);

	s->p = sec_hold;
	length += rdp_security_stream_out(rdp, s, length);

	stream_set_pos(s, length);
	if (transport_write(rdp->transport, s) < 0)
		return FALSE;

	return TRUE;
}
Beispiel #19
0
BOOL rdp_send(rdpRdp* rdp, STREAM* s, UINT16 channel_id)
{
	UINT16 length;
	UINT32 sec_bytes;
	BYTE* sec_hold;

	length = stream_get_length(s);
	stream_set_pos(s, 0);

	rdp_write_header(rdp, s, length, channel_id);

	sec_bytes = rdp_get_sec_bytes(rdp);
	sec_hold = s->p;
	stream_seek(s, sec_bytes);

	s->p = sec_hold;
	length += rdp_security_stream_out(rdp, s, length);

	stream_set_pos(s, length);

	if (transport_write(rdp->transport, s) < 0)
		return FALSE;

	return TRUE;
}
Beispiel #20
0
void test_read_fast_glyph_order(void)
{
	STREAM _s, *s;
	FAST_GLYPH_ORDER fast_glyph;

	s = &_s;
	s->p = s->data = fast_glyph_order;

	memset(orderInfo, 0, sizeof(ORDER_INFO));
	orderInfo->fieldFlags = 0x7EFB;

	memset(&fast_glyph, 0, sizeof(FAST_GLYPH_ORDER));

	update_read_fast_glyph_order(s, orderInfo, &fast_glyph);

	CU_ASSERT(fast_glyph.backColor == 0);
	CU_ASSERT(fast_glyph.foreColor == 0x0000FFFF);
	CU_ASSERT(fast_glyph.bkLeft == 139);
	CU_ASSERT(fast_glyph.bkTop == 177);
	CU_ASSERT(fast_glyph.bkRight == 147);
	CU_ASSERT(fast_glyph.bkBottom == 190);
	CU_ASSERT(fast_glyph.opLeft == 0);
	CU_ASSERT(fast_glyph.opTop == 13);
	CU_ASSERT(fast_glyph.opRight == 32766);
	CU_ASSERT(fast_glyph.opBottom == -32768);
	CU_ASSERT(fast_glyph.x == -32768);
	CU_ASSERT(fast_glyph.y == 187);

	CU_ASSERT(stream_get_length(s) == (sizeof(fast_glyph_order) - 1));
}
Beispiel #21
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);
}
Beispiel #22
0
void test_read_polygon_cb_order(void)
{
	STREAM _s, *s;
	POLYGON_CB_ORDER polygon_cb;

	s = &_s;
	s->p = s->data = polygon_cb_order;

	memset(orderInfo, 0, sizeof(ORDER_INFO));
	orderInfo->fieldFlags = 0x1BEF;

	memset(&polygon_cb, 0, sizeof(POLYGON_CB_ORDER));

	update_read_polygon_cb_order(s, orderInfo, &polygon_cb);

	CU_ASSERT(polygon_cb.xStart == 234);
	CU_ASSERT(polygon_cb.yStart == 326);
	CU_ASSERT(polygon_cb.bRop2 == 0x0D);
	CU_ASSERT(polygon_cb.fillMode == 1);
	CU_ASSERT(polygon_cb.backColor == 0);
	CU_ASSERT(polygon_cb.foreColor == 0x00000008);
	CU_ASSERT(polygon_cb.brush.x == 4);
	CU_ASSERT(polygon_cb.brush.y == 3);
	CU_ASSERT(polygon_cb.brush.style == 0x81);
	CU_ASSERT(polygon_cb.numPoints == 3);
	CU_ASSERT(polygon_cb.cbData == 5);

	CU_ASSERT(stream_get_length(s) == (sizeof(polygon_cb_order) - 1));
}
Beispiel #23
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);
	}
}
Beispiel #24
0
void test_read_create_offscreen_bitmap_order(void)
{
	STREAM _s, *s;
	OFFSCREEN_DELETE_LIST* deleteList;
	CREATE_OFFSCREEN_BITMAP_ORDER create_offscreen_bitmap;

	s = &_s;
	s->p = s->data = create_offscreen_bitmap_order;

	memset(&create_offscreen_bitmap, 0, sizeof(CREATE_OFFSCREEN_BITMAP_ORDER));

	deleteList = &(create_offscreen_bitmap.deleteList);
	deleteList->cIndices = 0;
	deleteList->sIndices = 16;
	deleteList->indices = malloc(sizeof(uint16) * deleteList->sIndices);

	update_read_create_offscreen_bitmap_order(s, &create_offscreen_bitmap);

	CU_ASSERT(create_offscreen_bitmap.id == 0);
	CU_ASSERT(create_offscreen_bitmap.cx == 352);
	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));
}
Beispiel #25
0
void test_nsc_encode(void)
{
	int i;
	uint8* rgb_data;
	STREAM* enc_stream;
	NSC_CONTEXT* context;

	rgb_data = (uint8 *) malloc(64 * 64 * 3);
	for (i = 0; i < 64; i++)
		memcpy(rgb_data + i * 64 * 3, rgb_scanline_data, 64 * 3);

	context = nsc_context_new();
	nsc_context_set_cpu_opt(context, CPU_SSE2);
	nsc_context_set_pixel_format(context, RDP_PIXEL_FORMAT_R8G8B8);

	enc_stream = stream_new(65536);
	stream_clear(enc_stream);

	for (i = 0; i < 30000; i++)
	{
		stream_set_pos(enc_stream, 0);
		nsc_compose_message(context, enc_stream, rgb_data, 64, 64, 64 * 3);
	}
	/*freerdp_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));
	/*freerdp_hexdump(context->bmpdata, 64 * 64 * 4);*/
	stream_free(enc_stream);

	nsc_context_free(context);
}
Beispiel #26
0
void credssp_send(rdpCredssp* credssp)
{
	STREAM* s;
	int length;
	int ts_request_length;
	int nego_tokens_length;
	int pub_key_auth_length;
	int auth_info_length;

	nego_tokens_length = (credssp->negoToken.cbBuffer > 0) ? credssp_skip_nego_tokens(credssp->negoToken.cbBuffer) : 0;
	pub_key_auth_length = (credssp->pubKeyAuth.cbBuffer > 0) ? credssp_skip_pub_key_auth(credssp->pubKeyAuth.cbBuffer) : 0;
	auth_info_length = (credssp->authInfo.cbBuffer > 0) ? credssp_skip_auth_info(credssp->authInfo.cbBuffer) : 0;

	length = nego_tokens_length + pub_key_auth_length + auth_info_length;
	ts_request_length = credssp_skip_ts_request(length);

	s = stream_new(ts_request_length);

	/* TSRequest */
	length = der_get_content_length(ts_request_length);
	der_write_sequence_tag(s, length); /* SEQUENCE */

	/* [0] version */
	ber_write_contextual_tag(s, 0, 3, true);
	ber_write_integer(s, 2); /* INTEGER */

	/* [1] negoTokens (NegoData) */
	if (nego_tokens_length > 0)
	{
		length = der_get_content_length(nego_tokens_length);
		length -= der_write_contextual_tag(s, 1, length, true); /* NegoData */
		length -= der_write_sequence_tag(s, length); /* SEQUENCE OF NegoDataItem */
		length -= der_write_sequence_tag(s, length); /* NegoDataItem */
		length -= der_write_contextual_tag(s, 0, length, true); /* [0] negoToken */
		der_write_octet_string(s, (uint8*) credssp->negoToken.pvBuffer, length); /* OCTET STRING */
	}

	/* [2] authInfo (OCTET STRING) */
	if (auth_info_length > 0)
	{
		length = ber_get_content_length(auth_info_length);
		length -= ber_write_contextual_tag(s, 2, length, true);
		ber_write_octet_string(s, credssp->authInfo.pvBuffer, credssp->authInfo.cbBuffer);
	}

	/* [3] pubKeyAuth (OCTET STRING) */
	if (pub_key_auth_length > 0)
	{
		length = ber_get_content_length(pub_key_auth_length);
		length -= ber_write_contextual_tag(s, 3, length, true);
		ber_write_octet_string(s, credssp->pubKeyAuth.pvBuffer, length);
	}

	//printf("Sending TSRequest: (%d)\n", stream_get_length(s));
	//freerdp_hexdump(s->data, stream_get_length(s));

	tls_write(credssp->tls, s->data, stream_get_length(s));
	stream_free(s);
}
static void sc_output_alignment(IRP *irp, uint32 seed)
{
	uint32 size = stream_get_length(irp->output) - 20;
	uint32 add = (seed - (size % seed)) % seed;

	if (add > 0)
		stream_write_zero(irp->output, add);
}
Beispiel #28
0
void test_read_polyline_order(void)
{
	STREAM _s, *s;
	POLYLINE_ORDER polyline;

	s = &_s;
	s->p = s->data = polyline_order;

	memset(orderInfo, 0, sizeof(ORDER_INFO));
	orderInfo->fieldFlags = 0x73;

	memset(&polyline, 0, sizeof(POLYLINE_ORDER));

	update_read_polyline_order(s, orderInfo, &polyline);

	CU_ASSERT(polyline.xStart == 504);
	CU_ASSERT(polyline.yStart == 696);
	CU_ASSERT(polyline.bRop2 == 0);
	CU_ASSERT(polyline.penColor == 0x0000C000);
	CU_ASSERT(polyline.numPoints == 32);
	CU_ASSERT(polyline.cbData == 108);

	CU_ASSERT(polyline.points[0].x == -130);
	CU_ASSERT(polyline.points[1].x == -191);
	CU_ASSERT(polyline.points[2].x == -220);
	CU_ASSERT(polyline.points[3].x == -213);
	CU_ASSERT(polyline.points[4].x == -171);
	CU_ASSERT(polyline.points[5].x == -100);
	CU_ASSERT(polyline.points[6].x == -13);
	CU_ASSERT(polyline.points[7].x == 77);
	CU_ASSERT(polyline.points[8].x == 153);
	CU_ASSERT(polyline.points[9].x == 205);
	CU_ASSERT(polyline.points[10].x == 222);
	CU_ASSERT(polyline.points[11].x == 202);
	CU_ASSERT(polyline.points[12].x == 150);
	CU_ASSERT(polyline.points[13].x == 72);
	CU_ASSERT(polyline.points[14].x == -17);
	CU_ASSERT(polyline.points[15].x == -105);
	CU_ASSERT(polyline.points[16].x == -174);
	CU_ASSERT(polyline.points[17].x == -213);
	CU_ASSERT(polyline.points[18].x == -220);
	CU_ASSERT(polyline.points[19].x == -188);
	CU_ASSERT(polyline.points[20].x == -127);
	CU_ASSERT(polyline.points[21].x == -42);
	CU_ASSERT(polyline.points[22].x == 47);
	CU_ASSERT(polyline.points[23].x == 130);
	CU_ASSERT(polyline.points[24].x == 191);
	CU_ASSERT(polyline.points[25].x == 221);
	CU_ASSERT(polyline.points[26].x == 212);
	CU_ASSERT(polyline.points[27].x == 171);
	CU_ASSERT(polyline.points[28].x == 100);
	CU_ASSERT(polyline.points[29].x == 13);
	CU_ASSERT(polyline.points[30].x == -77);
	CU_ASSERT(polyline.points[31].x == -153);
	CU_ASSERT(polyline.points[32].x == 0);

	CU_ASSERT(stream_get_length(s) == (sizeof(polyline_order) - 1));
}
Beispiel #29
0
int transport_write(rdpTransport* transport, STREAM* s)
{
	int status = -1;
	int length;

	length = stream_get_length(s);
	stream_set_pos(s, 0);

#ifdef WITH_DEBUG_TRANSPORT
	if (length > 0)
	{
		printf("Local > Remote\n");
		winpr_HexDump(s->data, length);
	}
#endif

	while (length > 0)
	{
		if (transport->layer == TRANSPORT_LAYER_TLS)
			status = tls_write(transport->TlsOut, stream_get_tail(s), length);
		else if (transport->layer == TRANSPORT_LAYER_TCP)
			status = tcp_write(transport->TcpOut, stream_get_tail(s), length);
		else if (transport->layer == TRANSPORT_LAYER_TSG)
			status = tsg_write(transport->tsg, stream_get_tail(s), length);

		if (status < 0)
			break; /* error occurred */

		if (status == 0)
		{
			/* when sending is blocked in nonblocking mode, the receiving buffer should be checked */
			if (!transport->blocking)
			{
				/* and in case we do have buffered some data, we set the event so next loop will get it */
				if (transport_read_nonblocking(transport) > 0)
					SetEvent(transport->ReceiveEvent);
			}

			if (transport->layer == TRANSPORT_LAYER_TLS)
				tls_wait_write(transport->TlsOut);
			else if (transport->layer == TRANSPORT_LAYER_TCP)
				tcp_wait_write(transport->TcpOut);
			else
				USleep(transport->SleepInterval);
		}

		length -= status;
		stream_seek(s, status);
	}

	if (status < 0)
	{
		/* A write error indicates that the peer has dropped the connection */
		transport->layer = TRANSPORT_LAYER_CLOSED;
	}

	return status;
}
Beispiel #30
0
void test_read_glyph_index_order(void)
{
	STREAM _s, *s;
	GLYPH_INDEX_ORDER glyph_index;

	s = &_s;
	s->p = s->data = glyph_index_order_1;

	memset(orderInfo, 0, sizeof(ORDER_INFO));
	orderInfo->fieldFlags = 0x200100;
	orderInfo->deltaCoordinates = true;

	memset(&glyph_index, 0, sizeof(GLYPH_INDEX_ORDER));

	update_read_glyph_index_order(s, orderInfo, &glyph_index);

	CU_ASSERT(glyph_index.bkRight == 618);

	CU_ASSERT(stream_get_length(s) == (sizeof(glyph_index_order_1) - 1));

	s->p = s->data = glyph_index_order_2;

	memset(orderInfo, 0, sizeof(ORDER_INFO));
	orderInfo->fieldFlags = 0x383FE8;
	orderInfo->deltaCoordinates = true;

	memset(&glyph_index, 0, sizeof(GLYPH_INDEX_ORDER));

	update_read_glyph_index_order(s, orderInfo, &glyph_index);

	CU_ASSERT(glyph_index.fOpRedundant == 0);
	CU_ASSERT(glyph_index.foreColor == 0x00FFFFFF);
	CU_ASSERT(glyph_index.bkLeft == 524);
	CU_ASSERT(glyph_index.bkTop == 366);
	CU_ASSERT(glyph_index.bkRight == 589);
	CU_ASSERT(glyph_index.bkBottom == 379);
	CU_ASSERT(glyph_index.opLeft == 521);
	CU_ASSERT(glyph_index.opTop == 366);
	CU_ASSERT(glyph_index.opRight == 758);
	CU_ASSERT(glyph_index.opBottom == 379);
	CU_ASSERT(glyph_index.x == 524);
	CU_ASSERT(glyph_index.y == 377);

	CU_ASSERT(stream_get_length(s) == (sizeof(glyph_index_order_2) - 1));
}