コード例 #1
0
ファイル: activation.c プロジェクト: ArvidNorr/FreeRDP
boolean rdp_recv_client_synchronize_pdu(rdpRdp* rdp, STREAM* s)
{
	uint16 messageType;

	rdp->finalize_sc_pdus |= FINALIZE_SC_SYNCHRONIZE_PDU;

	if (stream_get_left(s) < 4)
		return false;

	stream_read_uint16(s, messageType); /* messageType (2 bytes) */

	if (messageType != SYNCMSGTYPE_SYNC)
		return false;

	/* targetUser (2 bytes) */
	stream_seek_uint16(s);

	return true;
}
コード例 #2
0
ファイル: rdpsnd_main.c プロジェクト: rafcabezas/FreeRDP
static void rdpsnd_process_receive(rdpSvcPlugin* plugin, STREAM* data_in)
{
	rdpsndPlugin* rdpsnd = (rdpsndPlugin*)plugin;
	uint8 msgType;
	uint16 BodySize;

	if (rdpsnd->expectingWave)
	{
		rdpsnd_process_message_wave(rdpsnd, data_in);
		stream_free(data_in);
		return;
	}

	stream_read_uint8(data_in, msgType); /* msgType */
	stream_seek_uint8(data_in); /* bPad */
	stream_read_uint16(data_in, BodySize);

	DEBUG_SVC("msgType %d BodySize %d", msgType, BodySize);

	switch (msgType)
	{
		case SNDC_FORMATS:
			rdpsnd_process_message_formats(rdpsnd, data_in);
			break;
		case SNDC_TRAINING:
			rdpsnd_process_message_training(rdpsnd, data_in);
			break;
		case SNDC_WAVE:
			rdpsnd_process_message_wave_info(rdpsnd, data_in, BodySize);
			break;
		case SNDC_CLOSE:
			rdpsnd_process_message_close(rdpsnd);
			break;
		case SNDC_SETVOLUME:
			rdpsnd_process_message_setvolume(rdpsnd, data_in);
			break;
		default:
			DEBUG_WARN("unknown msgType %d", msgType);
			break;
	}

	stream_free(data_in);
}
コード例 #3
0
ファイル: cliprdr_format.c プロジェクト: zzzhou/FreeRDP
void cliprdr_process_long_format_names(cliprdrPlugin* cliprdr, STREAM* s, uint32 length, uint16 flags)
{
	int num_formats;
	uint8* start_mark;
	uint8* end_mark;
	uint16 terminator;
	CLIPRDR_FORMAT_NAME* format_name;

	num_formats = 0;
	stream_get_mark(s, start_mark);
	stream_get_mark(s, end_mark);
	end_mark += length;

	while (s->p < end_mark)
	{
		stream_seek_uint32(s);

		do
		{
			stream_read_uint16(s, terminator);
		}
		while (terminator != 0x0000);

		num_formats++;
	}

	stream_set_mark(s, start_mark);

	cliprdr->format_names = (CLIPRDR_FORMAT_NAME*) xmalloc(sizeof(CLIPRDR_FORMAT_NAME) * num_formats);
	cliprdr->num_format_names = num_formats;
	format_name = cliprdr->format_names;

	while (s->p < end_mark)
	{
		stream_read_uint32(s, format_name->id);

		format_name->name = freerdp_uniconv_in(cliprdr->uniconv, s->p, 32);
		format_name->length = strlen(format_name->name);
		stream_seek(s, format_name->length);

		format_name++;
	}
}
コード例 #4
0
ファイル: rdp.c プロジェクト: ydal/FreeRDP
boolean rdp_decrypt(rdpRdp* rdp, STREAM* s, int length)
{
	int cryptlen;

	if (rdp->settings->encryption_method == ENCRYPTION_METHOD_FIPS)
	{
		uint16 len;
		uint8 version, pad;
		uint8 *sig;

		stream_read_uint16(s, len); /* 0x10 */
		stream_read_uint8(s, version); /* 0x1 */
		stream_read_uint8(s, pad);

		sig = s->p;
		stream_seek(s, 8);	/* signature */

		cryptlen = length - 12;

		if (!security_fips_decrypt(s->p, cryptlen, rdp))
		{
			printf("FATAL: cannot decrypt\n");
			return false; /* TODO */
		}

		if (!security_fips_check_signature(s->p, cryptlen-pad, sig, rdp))
		{
			printf("FATAL: invalid packet signature\n");
			return false; /* TODO */
		}

		/* is this what needs adjusting? */
		s->size -= pad;
		return true;
	}

	stream_seek(s, 8); /* signature */
	cryptlen = length - 8;
	security_decrypt(s->p, cryptlen, rdp);
	return true;
}
コード例 #5
0
ファイル: wtsvc.c プロジェクト: ArthurGodoy/FreeRDP
static int wts_read_variable_uint(STREAM* s, int cbLen, uint32 *val)
{
	switch (cbLen)
	{
		case 0:
			if (stream_get_left(s) < 1)
				return 0;
			stream_read_uint8(s, *val);
			return 1;
		case 1:
			if (stream_get_left(s) < 2)
				return 0;
			stream_read_uint16(s, *val);
			return 2;
		default:
			if (stream_get_left(s) < 4)
				return 0;
			stream_read_uint32(s, *val);
			return 4;
	}
}
コード例 #6
0
ファイル: input.c プロジェクト: EdWatts/FreeRDP
boolean input_recv(rdpInput* input, STREAM* s)
{
	uint16 i, numberEvents;

	if (stream_get_left(s) < 4)
		return false;

	stream_read_uint16(s, numberEvents); /* numberEvents (2 bytes) */
	stream_seek(s, 2); /* pad2Octets (2 bytes) */

	/* Each input event uses 6 exactly bytes. */
	if (stream_get_left(s) < 6 * numberEvents)
		return false;

	for (i = 0; i < numberEvents; i++)
	{
		if (!input_recv_event(input, s))
			return false;
	}

	return true;
}
コード例 #7
0
ファイル: xf_cliprdr.c プロジェクト: kidfolk/FreeRDP
static void xf_cliprdr_process_dib(clipboardContext* cb, uint8* data, int size)
{
	STREAM* s;
	uint16 bpp;
	uint32 offset;
	uint32 ncolors;

	/* size should be at least sizeof(BITMAPINFOHEADER) */
	if (size < 40)
	{
		DEBUG_X11("dib size %d too short", size);
		return;
	}

	s = stream_new(0);
	stream_attach(s, data, size);
	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);
	stream_detach(s);
	stream_free(s);

	DEBUG_X11("offset=%d bpp=%d ncolors=%d",
		offset, bpp, ncolors);

	s = stream_new(14 + size);
	stream_write_uint8(s, 'B');
	stream_write_uint8(s, 'M');
	stream_write_uint32(s, 14 + size);
	stream_write_uint32(s, 0);
	stream_write_uint32(s, offset);
	stream_write(s, data, size);

	cb->data = stream_get_head(s);
	cb->data_length = stream_get_length(s);
	stream_detach(s);
	stream_free(s);
}
コード例 #8
0
ファイル: surface.c プロジェクト: johnsonyes/FreeRDP
boolean update_recv_surfcmds(rdpUpdate* update, uint32 size, STREAM* s)
{
	uint8* mark;
	uint16 cmdType;
	uint32 cmdLength;

	while (size > 2)
	{
		stream_get_mark(s, mark);

		stream_read_uint16(s, cmdType);
		size -= 2;

		switch (cmdType)
		{
			case CMDTYPE_SET_SURFACE_BITS:
			case CMDTYPE_STREAM_SURFACE_BITS:
				cmdLength = update_recv_surfcmd_surface_bits(update, s);
				break;

			case CMDTYPE_FRAME_MARKER:
				cmdLength = update_recv_surfcmd_frame_marker(update, s);
				break;

			default:
				DEBUG_WARN("unknown cmdType 0x%X", cmdType);
				return false;
		}

		size -= cmdLength;

		if (update->dump_rfx)
		{
			pcap_add_record(update->pcap_rfx, mark, cmdLength + 2);
			pcap_flush(update->pcap_rfx);
		}
	}
	return true;
}
コード例 #9
0
ファイル: update.c プロジェクト: shlevy/FreeRDP
void update_recv_pointer(rdpUpdate* update, STREAM* s)
{
	uint16 messageType;

	stream_read_uint16(s, messageType); /* messageType (2 bytes) */
	stream_seek_uint16(s); /* pad2Octets (2 bytes) */

	switch (messageType)
	{
		case PTR_MSG_TYPE_POSITION:
			update_read_pointer_position(s, &update->pointer_position);
			IFCALL(update->PointerPosition, update, &update->pointer_position);
			break;

		case PTR_MSG_TYPE_SYSTEM:
			update_read_pointer_system(s, &update->pointer_system);
			IFCALL(update->PointerSystem, update, &update->pointer_system);
			break;

		case PTR_MSG_TYPE_COLOR:
			update_read_pointer_color(s, &update->pointer_color);
			IFCALL(update->PointerColor, update, &update->pointer_color);
			break;

		case PTR_MSG_TYPE_POINTER:
			update_read_pointer_new(s, &update->pointer_new);
			IFCALL(update->PointerNew, update, &update->pointer_new);
			break;

		case PTR_MSG_TYPE_CACHED:
			update_read_pointer_cached(s, &update->pointer_cached);
			IFCALL(update->PointerCached, update, &update->pointer_cached);
			break;

		default:
			break;
	}
}
コード例 #10
0
static void rfx_process_message_sync(RFX_CONTEXT* context, STREAM* s)
{
	uint32 magic;

	/* RFX_SYNC */
	stream_read_uint32(s, magic); /* magic (4 bytes), 0xCACCACCA */

	if (magic != WF_MAGIC)
	{
		DEBUG_WARN("invalid magic number 0x%X", magic);
		return;
	}

	stream_read_uint16(s, context->version); /* version (2 bytes), WF_VERSION_1_0 (0x0100) */

	if (context->version != WF_VERSION_1_0)
	{
		DEBUG_WARN("unknown version number 0x%X", context->version);
		return;
	}

	DEBUG_RFX("version 0x%X", context->version);
}
コード例 #11
0
ファイル: rdpsnd.c プロジェクト: felfert/FreeRDP
static boolean rdpsnd_server_recv_formats(rdpsnd_server* rdpsnd, STREAM* s)
{
	int i;

	if (stream_get_left(s) < 20)
		return false;

	stream_seek_uint32(s); /* dwFlags */
	stream_seek_uint32(s); /* dwVolume */
	stream_seek_uint32(s); /* dwPitch */
	stream_seek_uint16(s); /* wDGramPort */
	stream_read_uint16(s, rdpsnd->context.num_client_formats); /* wNumberOfFormats */
	stream_seek_uint8(s); /* cLastBlockConfirmed */
	stream_seek_uint16(s); /* wVersion */
	stream_seek_uint8(s); /* bPad */

	if (rdpsnd->context.num_client_formats > 0)
	{
		rdpsnd->context.client_formats = xzalloc(rdpsnd->context.num_client_formats * sizeof(rdpsndFormat));
		for (i = 0; i < rdpsnd->context.num_client_formats; i++)
		{
			if (stream_get_left(s) < 18)
			{
				xfree(rdpsnd->context.client_formats);
				rdpsnd->context.client_formats = NULL;
				return false;
			}

			stream_read_uint16(s, rdpsnd->context.client_formats[i].wFormatTag);
			stream_read_uint16(s, rdpsnd->context.client_formats[i].nChannels);
			stream_read_uint32(s, rdpsnd->context.client_formats[i].nSamplesPerSec);
			stream_seek_uint32(s); /* nAvgBytesPerSec */
			stream_read_uint16(s, rdpsnd->context.client_formats[i].nBlockAlign);
			stream_read_uint16(s, rdpsnd->context.client_formats[i].wBitsPerSample);
			stream_read_uint16(s, rdpsnd->context.client_formats[i].cbSize);
			if (rdpsnd->context.client_formats[i].cbSize > 0)
			{
				stream_seek(s, rdpsnd->context.client_formats[i].cbSize);
			}
		}
	}

	return true;
}
コード例 #12
0
ファイル: nego.c プロジェクト: ydal/FreeRDP
void nego_process_negotiation_failure(rdpNego* nego, STREAM* s)
{
    uint8 flags;
    uint16 length;
    uint32 failureCode;

    DEBUG_NEGO("RDP_NEG_FAILURE");

    stream_read_uint8(s, flags);
    stream_read_uint16(s, length);
    stream_read_uint32(s, failureCode);

    switch (failureCode)
    {
    case SSL_REQUIRED_BY_SERVER:
        DEBUG_NEGO("Error: SSL_REQUIRED_BY_SERVER");
        break;
    case SSL_NOT_ALLOWED_BY_SERVER:
        DEBUG_NEGO("Error: SSL_NOT_ALLOWED_BY_SERVER");
        break;
    case SSL_CERT_NOT_ON_SERVER:
        DEBUG_NEGO("Error: SSL_CERT_NOT_ON_SERVER");
        break;
    case INCONSISTENT_FLAGS:
        DEBUG_NEGO("Error: INCONSISTENT_FLAGS");
        break;
    case HYBRID_REQUIRED_BY_SERVER:
        DEBUG_NEGO("Error: HYBRID_REQUIRED_BY_SERVER");
        break;
    default:
        DEBUG_NEGO("Error: Unknown protocol security error %d", failureCode);
        break;
    }

    nego->state = NEGO_STATE_FAIL;
}
コード例 #13
0
ファイル: capabilities.c プロジェクト: roman-bb/FreeRDP-1.0
void rdp_read_general_capability_set(STREAM* s, rdpSettings* settings)
{
	uint16 extraFlags;
	uint8 refreshRectSupport;
	uint8 suppressOutputSupport;

	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_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_read_uint8(s, refreshRectSupport); /* refreshRectSupport (1 byte) */
	stream_read_uint8(s, suppressOutputSupport); /* suppressOutputSupport (1 byte) */

	if (refreshRectSupport == False)
		settings->refresh_rect = False;

	if (suppressOutputSupport == False)
		settings->suppress_output = False;
}
コード例 #14
0
ファイル: window.c プロジェクト: kidfolk/FreeRDP
void update_read_icon_info(STREAM* s, ICON_INFO* icon_info)
{
	stream_read_uint16(s, icon_info->cacheEntry); /* cacheEntry (2 bytes) */
	stream_read_uint8(s, icon_info->cacheId); /* cacheId (1 byte) */
	stream_read_uint8(s, icon_info->bpp); /* bpp (1 byte) */
	stream_read_uint16(s, icon_info->width); /* width (2 bytes) */
	stream_read_uint16(s, icon_info->height); /* height (2 bytes) */

	/* cbColorTable is only present when bpp is 1, 2 or 4 */
	if (icon_info->bpp == 1 || icon_info->bpp == 2 || icon_info->bpp == 4)
		stream_read_uint16(s, icon_info->cbColorTable); /* cbColorTable (2 bytes) */
	else
		icon_info->cbColorTable = 0;

	stream_read_uint16(s, icon_info->cbBitsMask); /* cbBitsMask (2 bytes) */
	stream_read_uint16(s, icon_info->cbBitsColor); /* cbBitsColor (2 bytes) */

	/* bitsMask */
	if (icon_info->bitsMask == NULL)
		icon_info->bitsMask = (uint8*) xmalloc(icon_info->cbBitsMask);
	else
		icon_info->bitsMask = (uint8*) xrealloc(icon_info->bitsMask, icon_info->cbBitsMask);
	stream_read(s, icon_info->bitsMask, icon_info->cbBitsMask);

	/* colorTable */
	if (icon_info->colorTable == NULL)
		icon_info->colorTable = (uint8*) xmalloc(icon_info->cbColorTable);
	else
		icon_info->colorTable = (uint8*) xrealloc(icon_info->colorTable, icon_info->cbColorTable);
	stream_read(s, icon_info->colorTable, icon_info->cbColorTable);

	/* bitsColor */
	if (icon_info->bitsColor == NULL)
		icon_info->bitsColor = (uint8*) xmalloc(icon_info->cbBitsColor);
	else
		icon_info->bitsColor = (uint8*) xrealloc(icon_info->bitsColor, icon_info->cbBitsColor);
	stream_read(s, icon_info->bitsColor, icon_info->cbBitsColor);
}
コード例 #15
0
ファイル: surface.c プロジェクト: johnsonyes/FreeRDP
static int update_recv_surfcmd_surface_bits(rdpUpdate* update, STREAM* s)
{
	int pos;
	SURFACE_BITS_COMMAND* cmd = &update->surface_bits_command;

	stream_read_uint16(s, cmd->destLeft);
	stream_read_uint16(s, cmd->destTop);
	stream_read_uint16(s, cmd->destRight);
	stream_read_uint16(s, cmd->destBottom);
	stream_read_uint8(s, cmd->bpp);
	stream_seek(s, 2); /* reserved1, reserved2 */
	stream_read_uint8(s, cmd->codecID);
	stream_read_uint16(s, cmd->width);
	stream_read_uint16(s, cmd->height);
	stream_read_uint32(s, cmd->bitmapDataLength);
	pos = stream_get_pos(s) + cmd->bitmapDataLength;
	cmd->bitmapData = stream_get_tail(s);

	IFCALL(update->SurfaceBits, update->context, cmd);

	stream_set_pos(s, pos);

	return 20 + cmd->bitmapDataLength;
}
コード例 #16
0
ファイル: rdpsnd_main.c プロジェクト: rafcabezas/FreeRDP
/* receives a list of server supported formats and returns a list
   of client supported formats */
static void rdpsnd_process_message_formats(rdpsndPlugin* rdpsnd, STREAM* data_in)
{
	uint16 wNumberOfFormats;
	uint16 nFormat;
	uint16 wVersion;
	STREAM* data_out;
	rdpsndFormat* out_formats;
	uint16 n_out_formats;
	rdpsndFormat* format;
	uint8* format_mark;
	uint8* data_mark;
	int pos;

	rdpsnd_free_supported_formats(rdpsnd);

	stream_seek_uint32(data_in); /* dwFlags */
	stream_seek_uint32(data_in); /* dwVolume */
	stream_seek_uint32(data_in); /* dwPitch */
	stream_seek_uint16(data_in); /* wDGramPort */
	stream_read_uint16(data_in, wNumberOfFormats);
	stream_read_uint8(data_in, rdpsnd->cBlockNo); /* cLastBlockConfirmed */
	stream_read_uint16(data_in, wVersion);
	stream_seek_uint8(data_in); /* bPad */

	DEBUG_SVC("wNumberOfFormats %d wVersion %d", wNumberOfFormats, wVersion);
	if (wNumberOfFormats < 1)
	{
		DEBUG_WARN("wNumberOfFormats is 0");
		return;
	}

	out_formats = (rdpsndFormat*)xzalloc(wNumberOfFormats * sizeof(rdpsndFormat));
	n_out_formats = 0;

	data_out = stream_new(24);
	stream_write_uint8(data_out, SNDC_FORMATS); /* msgType */
	stream_write_uint8(data_out, 0); /* bPad */
	stream_seek_uint16(data_out); /* BodySize */
	stream_write_uint32(data_out, TSSNDCAPS_ALIVE | TSSNDCAPS_VOLUME); /* dwFlags */
	stream_write_uint32(data_out, 0xFFFFFFFF); /* dwVolume */
	stream_write_uint32(data_out, 0); /* dwPitch */
	stream_write_uint16_be(data_out, 0); /* wDGramPort */
	stream_seek_uint16(data_out); /* wNumberOfFormats */
	stream_write_uint8(data_out, 0); /* cLastBlockConfirmed */
	stream_write_uint16(data_out, 6); /* wVersion */
	stream_write_uint8(data_out, 0); /* bPad */

	for (nFormat = 0; nFormat < wNumberOfFormats; nFormat++)
	{
		stream_get_mark(data_in, format_mark);
		format = &out_formats[n_out_formats];
		stream_read_uint16(data_in, format->wFormatTag);
		stream_read_uint16(data_in, format->nChannels);
		stream_read_uint32(data_in, format->nSamplesPerSec);
		stream_seek_uint32(data_in); /* nAvgBytesPerSec */
		stream_read_uint16(data_in, format->nBlockAlign);
		stream_read_uint16(data_in, format->wBitsPerSample);
		stream_read_uint16(data_in, format->cbSize);
		stream_get_mark(data_in, data_mark);
		stream_seek(data_in, format->cbSize);
		format->data = NULL;

		DEBUG_SVC("wFormatTag=%d nChannels=%d nSamplesPerSec=%d nBlockAlign=%d wBitsPerSample=%d",
			format->wFormatTag, format->nChannels, format->nSamplesPerSec,
			format->nBlockAlign, format->wBitsPerSample);

		if (rdpsnd->fixed_format > 0 && rdpsnd->fixed_format != format->wFormatTag)
			continue;
		if (rdpsnd->fixed_channel > 0 && rdpsnd->fixed_channel != format->nChannels)
			continue;
		if (rdpsnd->fixed_rate > 0 && rdpsnd->fixed_rate != format->nSamplesPerSec)
			continue;
		if (rdpsnd->device && rdpsnd->device->FormatSupported(rdpsnd->device, format))
		{
			DEBUG_SVC("format supported.");

			stream_check_size(data_out, 18 + format->cbSize);
			stream_write(data_out, format_mark, 18 + format->cbSize);
			if (format->cbSize > 0)
			{
				format->data = xmalloc(format->cbSize);
				memcpy(format->data, data_mark, format->cbSize);
			}
			n_out_formats++;
		}
	}

	rdpsnd->n_supported_formats = n_out_formats;
	if (n_out_formats > 0)
	{
		rdpsnd->supported_formats = out_formats;
	}
	else
	{
		xfree(out_formats);
		DEBUG_WARN("no formats supported");
	}

	pos = stream_get_pos(data_out);
	stream_set_pos(data_out, 2);
	stream_write_uint16(data_out, pos - 4);
	stream_set_pos(data_out, 18);
	stream_write_uint16(data_out, n_out_formats);
	stream_set_pos(data_out, pos);

	svc_plugin_send((rdpSvcPlugin*)rdpsnd, data_out);

	if (wVersion >= 6)
	{
		data_out = stream_new(8);
		stream_write_uint8(data_out, SNDC_QUALITYMODE); /* msgType */
		stream_write_uint8(data_out, 0); /* bPad */
		stream_write_uint16(data_out, 4); /* BodySize */
		stream_write_uint16(data_out, HIGH_QUALITY); /* wQualityMode */
		stream_write_uint16(data_out, 0); /* Reserved */

		svc_plugin_send((rdpSvcPlugin*)rdpsnd, data_out);
	}
}
コード例 #17
0
ファイル: update.c プロジェクト: shlevy/FreeRDP
void update_read_bitmap_data(STREAM* s, BITMAP_DATA* bitmap_data)
{
	uint8* srcData;
	uint16 dstSize;
	boolean status;
	uint16 bytesPerPixel;

	stream_read_uint16(s, bitmap_data->left);
	stream_read_uint16(s, bitmap_data->top);
	stream_read_uint16(s, bitmap_data->right);
	stream_read_uint16(s, bitmap_data->bottom);
	stream_read_uint16(s, bitmap_data->width);
	stream_read_uint16(s, bitmap_data->height);
	stream_read_uint16(s, bitmap_data->bpp);
	stream_read_uint16(s, bitmap_data->flags);
	stream_read_uint16(s, bitmap_data->length);

	bytesPerPixel = (bitmap_data->bpp + 7) / 8;

	if (bitmap_data->flags & BITMAP_COMPRESSION)
	{
		uint16 cbCompMainBodySize;
		uint16 cbUncompressedSize;

		stream_seek_uint16(s); /* cbCompFirstRowSize (2 bytes) */
		stream_read_uint16(s, cbCompMainBodySize); /* cbCompMainBodySize (2 bytes) */
		stream_seek_uint16(s); /* cbScanWidth (2 bytes) */
		stream_read_uint16(s, cbUncompressedSize); /* cbUncompressedSize (2 bytes) */

		dstSize = cbUncompressedSize;
		bitmap_data->length = cbCompMainBodySize;
		bitmap_data->data = (uint8*) xmalloc(dstSize);

		stream_get_mark(s, srcData);
		stream_seek(s, bitmap_data->length);

		status = bitmap_decompress(srcData, bitmap_data->data, bitmap_data->width, bitmap_data->height,
				bitmap_data->length, bitmap_data->bpp, bitmap_data->bpp);

		if (status != True)
			printf("bitmap decompression failed, bpp:%d\n", bitmap_data->bpp);
	}
	else
	{
		int y;
		int offset;
		int scanline;
		stream_get_mark(s, srcData);
		dstSize = bitmap_data->length;
		bitmap_data->data = (uint8*) xzalloc(dstSize);
		scanline = bitmap_data->width * (bitmap_data->bpp / 8);

		for (y = 0; y < bitmap_data->height; y++)
		{
			offset = (bitmap_data->height - y - 1) * scanline;
			stream_read(s, &bitmap_data->data[offset], scanline);
		}
	}
}
コード例 #18
0
ファイル: rail_orders.c プロジェクト: kidfolk/FreeRDP
void rail_read_pdu_header(STREAM* s, uint16* orderType, uint16* orderLength)
{
	stream_read_uint16(s, *orderType); /* orderType (2 bytes) */
	stream_read_uint16(s, *orderLength); /* orderLength (2 bytes) */
}
コード例 #19
0
ファイル: update.c プロジェクト: shlevy/FreeRDP
void update_read_pointer_cached(STREAM* s, POINTER_CACHED_UPDATE* pointer_cached)
{
	stream_read_uint16(s, pointer_cached->cacheIndex); /* cacheIndex (2 bytes) */
}
コード例 #20
0
ファイル: update.c プロジェクト: shlevy/FreeRDP
void update_read_pointer_new(STREAM* s, POINTER_NEW_UPDATE* pointer_new)
{
	stream_read_uint16(s, pointer_new->xorBpp); /* xorBpp (2 bytes) */
	update_read_pointer_color(s, &pointer_new->colorPtrAttr); /* colorPtrAttr */
}
コード例 #21
0
ファイル: gcc.c プロジェクト: tenchman/FreeRDP-1.0
void gcc_read_user_data_header(STREAM* s, uint16* type, uint16* length)
{
	stream_read_uint16(s, *type); /* type */
	stream_read_uint16(s, *length); /* length */
}
コード例 #22
0
ファイル: rdpdr_main.c プロジェクト: kidfolk/FreeRDP
static void rdpdr_process_receive(rdpSvcPlugin* plugin, STREAM* data_in)
{
	rdpdrPlugin* rdpdr = (rdpdrPlugin*)plugin;
	uint16 component;
	uint16 packetID;
	uint32 deviceID;
	uint32 status;

	stream_read_uint16(data_in, component);
	stream_read_uint16(data_in, packetID);

	if (component == RDPDR_CTYP_CORE)
	{
		switch (packetID)
		{
			case PAKID_CORE_SERVER_ANNOUNCE:
				DEBUG_SVC("RDPDR_CTYP_CORE / PAKID_CORE_SERVER_ANNOUNCE");
				rdpdr_process_server_announce_request(rdpdr, data_in);
				rdpdr_send_client_announce_reply(rdpdr);
				rdpdr_send_client_name_request(rdpdr);
				break;

			case PAKID_CORE_SERVER_CAPABILITY:
				DEBUG_SVC("RDPDR_CTYP_CORE / PAKID_CORE_SERVER_CAPABILITY");
				rdpdr_process_capability_request(rdpdr, data_in);
				rdpdr_send_capability_response(rdpdr);
				break;

			case PAKID_CORE_CLIENTID_CONFIRM:
				DEBUG_SVC("RDPDR_CTYP_CORE / PAKID_CORE_CLIENTID_CONFIRM");
				rdpdr_process_server_clientid_confirm(rdpdr, data_in);
				rdpdr_send_device_list_announce_request(rdpdr, False);
				break;

			case PAKID_CORE_USER_LOGGEDON:
				DEBUG_SVC("RDPDR_CTYP_CORE / PAKID_CORE_USER_LOGGEDON");
				rdpdr_send_device_list_announce_request(rdpdr, True);
				break;

			case PAKID_CORE_DEVICE_REPLY:
				/* connect to a specific resource */
				stream_read_uint32(data_in, deviceID);
				stream_read_uint32(data_in, status);
				DEBUG_SVC("RDPDR_CTYP_CORE / PAKID_CORE_DEVICE_REPLY (deviceID=%d status=0x%08X)", deviceID, status);
				break;

			case PAKID_CORE_DEVICE_IOREQUEST:
				DEBUG_SVC("RDPDR_CTYP_CORE / PAKID_CORE_DEVICE_IOREQUEST");
				if (rdpdr_process_irp(rdpdr, data_in))
					data_in = NULL;
				break;

			default:
				DEBUG_WARN("RDPDR_CTYP_CORE / unknown packetID: 0x%02X", packetID);
				break;

		}
	}
	else if (component == RDPDR_CTYP_PRN)
	{
		DEBUG_SVC("RDPDR_CTYP_PRN");
	}
	else
	{
		DEBUG_WARN("RDPDR component: 0x%02X packetID: 0x%02X\n", component, packetID);
	}

	stream_free(data_in);
}
コード例 #23
0
ファイル: capabilities.c プロジェクト: roman-bb/FreeRDP-1.0
void rdp_read_demand_active(STREAM* s, rdpSettings* settings)
{
	uint16 type;
	uint16 length;
	uint8 *bm, *em;
	uint16 numberCapabilities;
	uint16 lengthSourceDescriptor;
	uint16 lengthCombinedCapabilities;

	printf("Demand Active PDU\n");

	stream_read_uint32(s, settings->share_id); /* shareId (4 bytes) */
	stream_read_uint16(s, lengthSourceDescriptor); /* lengthSourceDescriptor (2 bytes) */
	stream_read_uint16(s, lengthCombinedCapabilities); /* lengthCombinedCapabilities (2 bytes) */
	stream_seek(s, lengthSourceDescriptor); /* sourceDescriptor */
	stream_read_uint16(s, numberCapabilities); /* numberCapabilities (2 bytes) */
	stream_seek(s, 2); /* pad2Octets (2 bytes) */

	/* capabilitySets */
	while (numberCapabilities > 0)
	{
		stream_get_mark(s, bm);

		rdp_read_capability_set_header(s, &length, &type);
		printf("%s Capability Set (0x%02X), length:%d\n", CAPSET_TYPE_STRINGS[type], type, length);
		settings->received_caps[type] = True;
		em = bm + length;

		switch (type)
		{
			case CAPSET_TYPE_GENERAL:
				rdp_read_general_capability_set(s, settings);
				break;

			case CAPSET_TYPE_BITMAP:
				rdp_read_bitmap_capability_set(s, settings);
				break;

			case CAPSET_TYPE_ORDER:
				rdp_read_order_capability_set(s, settings);
				break;

			case CAPSET_TYPE_BITMAP_CACHE:
				rdp_read_bitmap_cache_capability_set(s, settings);
				break;

			case CAPSET_TYPE_CONTROL:
				rdp_read_control_capability_set(s, settings);
				break;

			case CAPSET_TYPE_ACTIVATION:
				rdp_read_window_activation_capability_set(s, settings);
				break;

			case CAPSET_TYPE_POINTER:
				rdp_read_pointer_capability_set(s, settings);
				break;

			case CAPSET_TYPE_SHARE:
				rdp_read_share_capability_set(s, settings);
				break;

			case CAPSET_TYPE_COLOR_CACHE:
				rdp_read_color_cache_capability_set(s, settings);
				break;

			case CAPSET_TYPE_SOUND:
				rdp_read_sound_capability_set(s, settings);
				break;

			case CAPSET_TYPE_INPUT:
				rdp_read_input_capability_set(s, settings);
				break;

			case CAPSET_TYPE_FONT:
				rdp_read_font_capability_set(s, settings);
				break;

			case CAPSET_TYPE_BRUSH:
				rdp_read_brush_capability_set(s, settings);
				break;

			case CAPSET_TYPE_GLYPH_CACHE:
				rdp_read_glyph_cache_capability_set(s, settings);
				break;

			case CAPSET_TYPE_OFFSCREEN_CACHE:
				rdp_read_offscreen_bitmap_cache_capability_set(s, settings);
				break;

			case CAPSET_TYPE_BITMAP_CACHE_HOST_SUPPORT:
				rdp_read_bitmap_cache_host_support_capability_set(s, settings);
				break;

			case CAPSET_TYPE_BITMAP_CACHE_V2:
				rdp_read_bitmap_cache_v2_capability_set(s, settings);
				break;

			case CAPSET_TYPE_VIRTUAL_CHANNEL:
				rdp_read_virtual_channel_capability_set(s, settings);
				break;

			case CAPSET_TYPE_DRAW_NINE_GRID_CACHE:
				rdp_read_draw_nine_grid_cache_capability_set(s, settings);
				break;

			case CAPSET_TYPE_DRAW_GDI_PLUS:
				rdp_read_draw_gdiplus_cache_capability_set(s, settings);
				break;

			case CAPSET_TYPE_RAIL:
				rdp_read_remote_programs_capability_set(s, settings);
				break;

			case CAPSET_TYPE_WINDOW:
				rdp_read_window_list_capability_set(s, settings);
				break;

			case CAPSET_TYPE_COMP_DESK:
				rdp_read_desktop_composition_capability_set(s, settings);
				break;

			case CAPSET_TYPE_MULTI_FRAGMENT_UPDATE:
				rdp_read_multifragment_update_capability_set(s, settings);
				break;

			case CAPSET_TYPE_LARGE_POINTER:
				rdp_read_large_pointer_capability_set(s, settings);
				break;

			case CAPSET_TYPE_SURFACE_COMMANDS:
				rdp_read_surface_commands_capability_set(s, settings);
				break;

			case CAPSET_TYPE_BITMAP_CODECS:
				rdp_read_bitmap_codecs_capability_set(s, settings);
				break;

			case CAPSET_TYPE_FRAME_ACKNOWLEDGE:
				rdp_read_frame_acknowledge_capability_set(s, settings);
				break;

			default:
				break;
		}

		if (s->p != em)
			printf("incorrect offset, actual:%d expected:%d\n", (int) (s->p - bm), (int) (em - bm));

		stream_set_mark(s, em);
		numberCapabilities--;
	}
}
コード例 #24
0
ファイル: ntlm_av_pairs.c プロジェクト: ArvidNorr/FreeRDP
void ntlm_input_av_pairs(NTLM_CONTEXT* context, STREAM* s)
{
	AV_ID AvId;
	uint16 AvLen;
	uint8* value;
	AV_PAIRS* av_pairs = context->av_pairs;

#ifdef WITH_DEBUG_NTLM
	printf("AV_PAIRS = {\n");
#endif

	do
	{
		value = NULL;
		stream_read_uint16(s, AvId);
		stream_read_uint16(s, AvLen);

		if (AvLen > 0)
		{
			if (AvId != MsvAvFlags)
			{
				value = xmalloc(AvLen);
				stream_read(s, value, AvLen);
			}
			else
			{
				stream_read_uint32(s, av_pairs->Flags);
			}
		}

		switch (AvId)
		{
			case MsvAvNbComputerName:
				av_pairs->NbComputerName.length = AvLen;
				av_pairs->NbComputerName.value = value;
				break;

			case MsvAvNbDomainName:
				av_pairs->NbDomainName.length = AvLen;
				av_pairs->NbDomainName.value = value;
				break;

			case MsvAvDnsComputerName:
				av_pairs->DnsComputerName.length = AvLen;
				av_pairs->DnsComputerName.value = value;
				break;

			case MsvAvDnsDomainName:
				av_pairs->DnsDomainName.length = AvLen;
				av_pairs->DnsDomainName.value = value;
				break;

			case MsvAvDnsTreeName:
				av_pairs->DnsTreeName.length = AvLen;
				av_pairs->DnsTreeName.value = value;
				break;

			case MsvAvTimestamp:
				av_pairs->Timestamp.length = AvLen;
				av_pairs->Timestamp.value = value;
				break;

			case MsvAvRestrictions:
				av_pairs->Restrictions.length = AvLen;
				av_pairs->Restrictions.value = value;
				break;

			case MsvAvTargetName:
				av_pairs->TargetName.length = AvLen;
				av_pairs->TargetName.value = value;
				break;

			case MsvChannelBindings:
				av_pairs->ChannelBindings.length = AvLen;
				av_pairs->ChannelBindings.value = value;
				break;

			default:
				if (value != NULL)
					xfree(value);
				break;
		}

#ifdef WITH_DEBUG_NTLM
		if (AvId < 10)
			printf("\tAvId: %s, AvLen: %d\n", AV_PAIRS_STRINGS[AvId], AvLen);
		else
			printf("\tAvId: %s, AvLen: %d\n", "Unknown", AvLen);

		freerdp_hexdump(value, AvLen);
#endif
	}
	while (AvId != MsvAvEOL);

#ifdef WITH_DEBUG_NTLM
	printf("}\n");
#endif
}
コード例 #25
0
ファイル: capabilities.c プロジェクト: roman-bb/FreeRDP-1.0
void rdp_read_capability_set_header(STREAM* s, uint16* length, uint16* type)
{
	stream_read_uint16(s, *type); /* capabilitySetType */
	stream_read_uint16(s, *length); /* lengthCapability */
}
コード例 #26
0
ファイル: capabilities.c プロジェクト: roman-bb/FreeRDP-1.0
/**
 * Read cache definition (glyph).\n
 * @msdn{cc240566}
 * @param s stream
 */
void rdp_read_cache_definition(STREAM* s, uint16* numEntries, uint16* maxCellSize)
{
	stream_read_uint16(s, *numEntries); /* cacheEntries (2 bytes) */
	stream_read_uint16(s, *maxCellSize); /* cacheMaximumCellSize (2 bytes) */
}
コード例 #27
0
ファイル: rdp.c プロジェクト: CaledoniaProject/rdpscan
void rdp_read_security_header(STREAM* s, uint16* flags)
{
	/* Basic Security Header */
	stream_read_uint16(s, *flags); /* flags */
	stream_seek(s, 2); /* flagsHi (unused) */
}
コード例 #28
0
ファイル: update.c プロジェクト: shlevy/FreeRDP
void update_read_pointer_position(STREAM* s, POINTER_POSITION_UPDATE* pointer_position)
{
	stream_read_uint16(s, pointer_position->xPos); /* xPos (2 bytes) */
	stream_read_uint16(s, pointer_position->yPos); /* yPos (2 bytes) */
}
コード例 #29
0
ファイル: info.c プロジェクト: adambprotiviti/FreeRDP
boolean rdp_read_info_packet(STREAM* s, rdpSettings* settings)
{
	uint32 flags;
	uint16 cbDomain;
	uint16 cbUserName;
	uint16 cbPassword;
	uint16 cbAlternateShell;
	uint16 cbWorkingDir;

	stream_seek_uint32(s); /* CodePage */
	stream_read_uint32(s, flags); /* flags */

	settings->autologon = ((flags & INFO_AUTOLOGON) ? true : false);
	settings->remote_app = ((flags & INFO_RAIL) ? true : false);
	settings->console_audio = ((flags & INFO_REMOTECONSOLEAUDIO) ? true : false);
	settings->compression = ((flags & INFO_COMPRESSION) ? true : false);

	stream_read_uint16(s, cbDomain); /* cbDomain */
	stream_read_uint16(s, cbUserName); /* cbUserName */
	stream_read_uint16(s, cbPassword); /* cbPassword */
	stream_read_uint16(s, cbAlternateShell); /* cbAlternateShell */
	stream_read_uint16(s, cbWorkingDir); /* cbWorkingDir */

	if (stream_get_left(s) < cbDomain + 2)
		return false;
	if (cbDomain > 0)
	{
		settings->domain = freerdp_uniconv_in(settings->uniconv, stream_get_tail(s), cbDomain);
		stream_seek(s, cbDomain);
	}
	stream_seek(s, 2);

	if (stream_get_left(s) < cbUserName + 2)
		return false;
	if (cbUserName > 0)
	{
		settings->username = freerdp_uniconv_in(settings->uniconv, stream_get_tail(s), cbUserName);
		stream_seek(s, cbUserName);
	}
	stream_seek(s, 2);

	if (stream_get_left(s) < cbPassword + 2)
		return false;
	if (cbPassword > 0)
	{
		settings->password = freerdp_uniconv_in(settings->uniconv, stream_get_tail(s), cbPassword);
		stream_seek(s, cbPassword);
	}
	stream_seek(s, 2);

	if (stream_get_left(s) < cbAlternateShell + 2)
		return false;
	if (cbAlternateShell > 0)
	{
		settings->shell = freerdp_uniconv_in(settings->uniconv, stream_get_tail(s), cbAlternateShell);
		stream_seek(s, cbAlternateShell);
	}
	stream_seek(s, 2);

	if (stream_get_left(s) < cbWorkingDir + 2)
		return false;
	if (cbWorkingDir > 0)
	{
		settings->directory = freerdp_uniconv_in(settings->uniconv, stream_get_tail(s), cbWorkingDir);
		stream_seek(s, cbWorkingDir);
	}
	stream_seek(s, 2);

	if (settings->rdp_version >= 5)
		return rdp_read_extended_info_packet(s, settings); /* extraInfo */

	return true;
}
コード例 #30
0
ファイル: tsmf_codec.c プロジェクト: kidfolk/FreeRDP
boolean tsmf_codec_parse_media_type(TS_AM_MEDIA_TYPE* mediatype, STREAM* s)
{
	int i;
	uint32 cbFormat;
	boolean ret = True;

	memset(mediatype, 0, sizeof(TS_AM_MEDIA_TYPE));

	/* MajorType */
	DEBUG_DVC("MajorType:");
	tsmf_print_guid(stream_get_tail(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)
			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);

	/* SubType */
	DEBUG_DVC("SubType:");
	tsmf_print_guid(stream_get_tail(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)
			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);

	/* bFixedSizeSamples, bTemporalCompression, SampleSize */
	stream_seek(s, 12);

	/* FormatType */
	DEBUG_DVC("FormatType:");
	tsmf_print_guid(stream_get_tail(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)
			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);

	/* cbFormat */
	stream_read_uint32(s, cbFormat);
	DEBUG_DVC("cbFormat %d", cbFormat);

#ifdef WITH_DEBUG_DVC
	freerdp_hexdump(stream_get_tail(s), cbFormat);
#endif

	switch (mediatype->FormatType)
	{
		case TSMF_FORMAT_TYPE_MFVIDEOFORMAT:
			/* http://msdn.microsoft.com/en-us/library/aa473808.aspx */

			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);
			/* videoInfo.FramesPerSecond */
			stream_read_uint32(s, mediatype->SamplesPerSecond.Numerator);
			stream_read_uint32(s, mediatype->SamplesPerSecond.Denominator);
			stream_seek(s, 80);
			stream_read_uint32(s, mediatype->BitRate); /* compressedInfo.AvgBitrate */
			stream_seek(s, 36);

			if (cbFormat > 176)
			{
				mediatype->ExtraDataSize = cbFormat - 176;
				mediatype->ExtraData = stream_get_tail(s);
			}
			break;

		case TSMF_FORMAT_TYPE_WAVEFORMATEX:
			/* http://msdn.microsoft.com/en-us/library/dd757720.aspx */

			stream_seek_uint16(s);
			stream_read_uint16(s, mediatype->Channels);
			stream_read_uint32(s, mediatype->SamplesPerSecond.Numerator);
			mediatype->SamplesPerSecond.Denominator = 1;
			stream_read_uint32(s, mediatype->BitRate);
			mediatype->BitRate *= 8;
			stream_read_uint16(s, mediatype->BlockAlign);
			stream_read_uint16(s, mediatype->BitsPerSample);
			stream_read_uint16(s, mediatype->ExtraDataSize);
			if (mediatype->ExtraDataSize > 0)
				mediatype->ExtraData = stream_get_tail(s);
			
			break;

		case TSMF_FORMAT_TYPE_MPEG2VIDEOINFO:
			/* http://msdn.microsoft.com/en-us/library/dd390707.aspx */

			i = tsmf_codec_parse_VIDEOINFOHEADER2(mediatype, s);
			i += tsmf_codec_parse_BITMAPINFOHEADER(mediatype, s, True);
			if (cbFormat > i)
			{
				mediatype->ExtraDataSize = cbFormat - i;
				mediatype->ExtraData = stream_get_tail(s);
			}
			break;

		case TSMF_FORMAT_TYPE_VIDEOINFO2:
			i = tsmf_codec_parse_VIDEOINFOHEADER2(mediatype, s);
			i += tsmf_codec_parse_BITMAPINFOHEADER(mediatype, s, False);
			if (cbFormat > i)
			{
				mediatype->ExtraDataSize = cbFormat - i;
				mediatype->ExtraData = stream_get_tail(s);
			}
			break;

		default:
			break;
	}

	if (mediatype->SamplesPerSecond.Numerator == 0)
		mediatype->SamplesPerSecond.Numerator = 1;
	if (mediatype->SamplesPerSecond.Denominator == 0)
		mediatype->SamplesPerSecond.Denominator = 1;

	return ret;
}