Ejemplo n.º 1
0
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*) xzalloc(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);
		}
	}
}
Ejemplo n.º 2
0
void rdp_read_control_capability_set(STREAM* s, rdpSettings* settings)
{
	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) */
}
Ejemplo n.º 3
0
void rdp_read_window_activation_capability_set(STREAM* s, rdpSettings* settings)
{
	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) */
}
Ejemplo n.º 4
0
void rdp_read_order_capability_set(STREAM* s, rdpSettings* settings)
{
	int i;
	uint16 orderFlags;
	uint8 orderSupport[32];
	uint16 orderSupportExFlags;

	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_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) */

	for (i = 0; i < 32; i++)
	{
		if (orderSupport[i] == False)
			settings->order_support[i] = False;
	}
}
Ejemplo n.º 5
0
void rdp_read_glyph_cache_capability_set(STREAM* s, rdpSettings* settings)
{
	stream_seek(s, 40); /* glyphCache (40 bytes) */
	stream_seek_uint32(s); /* fragCache (4 bytes) */
	stream_seek_uint16(s); /* glyphSupportLevel (2 bytes) */
	stream_seek_uint16(s); /* pad2Octets (2 bytes) */
}
Ejemplo n.º 6
0
boolean rdp_recv_client_font_map_pdu(rdpRdp* rdp, STREAM* s)
{
	rdp->finalize_sc_pdus |= FINALIZE_SC_FONT_MAP_PDU;

	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;
}
Ejemplo n.º 7
0
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;
	}
	else
	{
		dstSize = bitmap_data->width * bitmap_data->height * bytesPerPixel;
	}

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

	bitmap_data->data = (uint8*) xzalloc(dstSize);

	//printf("bytesPerPixel:%d, width:%d, height:%d dstSize:%d flags:0x%04X\n",
	//		bytesPerPixel, bitmap_data->width, bitmap_data->height, dstSize, bitmap_data->flags);

	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\n");
}
Ejemplo n.º 8
0
void update_recv_orders(rdpUpdate* update, STREAM* s)
{
	uint16 numberOrders;

	stream_seek_uint16(s); /* pad2OctetsA (2 bytes) */
	stream_read_uint16(s, numberOrders); /* numberOrders (2 bytes) */
	stream_seek_uint16(s); /* pad2OctetsB (2 bytes) */

	while (numberOrders > 0)
	{
		update_recv_order(update, s);
		numberOrders--;
	}
}
Ejemplo n.º 9
0
static void cliprdr_process_clip_caps(cliprdrPlugin* cliprdr, STREAM* s, uint16 length, uint16 flags)
{
	int i;
	uint16 lengthCapability;
	uint16 cCapabilitiesSets;
	uint16 capabilitySetType;

	stream_read_uint16(s, cCapabilitiesSets); /* cCapabilitiesSets (2 bytes) */
	stream_seek_uint16(s); /* pad1 (2 bytes) */

	DEBUG_CLIPRDR("cCapabilitiesSets %d", cCapabilitiesSets);

	for (i = 0; i < cCapabilitiesSets; i++)
	{
		stream_read_uint16(s, capabilitySetType); /* capabilitySetType (2 bytes) */
		stream_read_uint16(s, lengthCapability); /* lengthCapability (2 bytes) */

		switch (capabilitySetType)
		{
			case CB_CAPSTYPE_GENERAL:
				cliprdr_process_general_capability(cliprdr, s);
				break;

			default:
				DEBUG_WARN("unknown cliprdr capability set: %d", capabilitySetType);
				break;
		}
	}
}
Ejemplo n.º 10
0
boolean rdp_recv_enhanced_security_redirection_packet(rdpRdp* rdp, STREAM* s)
{
	stream_seek_uint16(s); /* pad2Octets (2 bytes) */
	rdp_recv_server_redirection_pdu(rdp, s);
	stream_seek_uint8(s); /* pad2Octets (1 byte) */
	return true;
}
Ejemplo n.º 11
0
void rail_read_server_exec_result_order(STREAM* s, RAIL_EXEC_RESULT_ORDER* exec_result)
{
	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) */
	rail_read_unicode_string(s, &exec_result->exeOrFile); /* exeOrFile */
}
Ejemplo n.º 12
0
void rdp_read_bitmap_capability_set(STREAM* s, rdpSettings* settings)
{
	uint8 drawingFlags;
	uint16 desktopWidth;
	uint16 desktopHeight;
	uint16 desktopResizeFlag;
	uint16 preferredBitsPerPixel;

	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_read_uint16(s, desktopWidth); /* desktopWidth (2 bytes) */
	stream_read_uint16(s, desktopHeight); /* desktopHeight (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_uint8(s); /* highColorFlags (1 byte) */
	stream_read_uint8(s, drawingFlags); /* drawingFlags (1 byte) */
	stream_seek_uint16(s); /* multipleRectangleSupport (2 bytes) */
	stream_seek_uint16(s); /* pad2OctetsB (2 bytes) */

	if (desktopResizeFlag == False)
		settings->desktop_resize = False;
}
Ejemplo n.º 13
0
void rdp_read_sound_capability_set(STREAM* s, rdpSettings* settings)
{
	uint16 soundFlags;

	stream_read_uint16(s, soundFlags); /* soundFlags (2 bytes) */
	stream_seek_uint16(s); /* pad2OctetsA (2 bytes) */

	settings->sound_beeps = (soundFlags & SOUND_BEEPS_FLAG) ? True : False;
}
Ejemplo n.º 14
0
void update_read_synchronize(rdpUpdate* update, STREAM* s)
{
	stream_seek_uint16(s); /* pad2Octets (2 bytes) */

	/**
	 * The Synchronize Update is an artifact from the
	 * T.128 protocol and should be ignored.
	 */
}
Ejemplo n.º 15
0
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;
}
Ejemplo n.º 16
0
boolean rdp_recv_control_pdu(STREAM* s, uint16* action)
{
	if (stream_get_left(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) */

	return true;
}
Ejemplo n.º 17
0
void rdp_read_share_data_header(STREAM* s, uint16* length, uint8* type, uint32* share_id)
{
	/* Share Data Header */
	stream_read_uint32(s, *share_id); /* shareId (4 bytes) */
	stream_seek_uint8(s); /* pad1 (1 byte) */
	stream_seek_uint8(s); /* streamId (1 byte) */
	stream_read_uint16(s, *length); /* uncompressedLength (2 bytes) */
	stream_read_uint8(s, *type); /* pduType2, Data PDU Type (1 byte) */
	stream_seek_uint8(s); /* compressedType (1 byte) */
	stream_seek_uint16(s); /* compressedLength (2 bytes) */
}
Ejemplo n.º 18
0
void rdp_read_bitmap_cache_host_support_capability_set(STREAM* s, rdpSettings* settings)
{
	uint8 cacheVersion;

	stream_read_uint8(s, cacheVersion); /* cacheVersion (1 byte) */
	stream_seek_uint8(s); /* pad1 (1 byte) */
	stream_seek_uint16(s); /* pad2 (2 bytes) */

	if (cacheVersion & BITMAP_CACHE_V2)
		settings->persistent_bitmap_cache = True;
}
Ejemplo n.º 19
0
void rdp_read_bitmap_cache_v2_capability_set(STREAM* s, rdpSettings* settings)
{
	stream_seek_uint16(s); /* cacheFlags (2 bytes) */
	stream_seek_uint8(s); /* pad2 (1 byte) */
	stream_seek_uint8(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) */
}
Ejemplo n.º 20
0
void rdp_recv_logon_info_v2(rdpRdp* rdp, STREAM* s)
{
	uint32 cbDomain;
	uint32 cbUserName;

	stream_seek_uint16(s); /* version (2 bytes) */
	stream_seek_uint32(s); /* size (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, cbDomain); /* domain */
	stream_seek(s, cbUserName); /* userName */
}
Ejemplo n.º 21
0
void rdp_read_input_capability_set(STREAM* s, rdpSettings* settings)
{
	uint16 inputFlags;

	stream_read_uint16(s, inputFlags); /* inputFlags (2 bytes) */
	stream_seek_uint16(s); /* pad2OctetsA (2 bytes) */
	stream_read_uint32(s, settings->kbd_layout); /* keyboardLayout (4 bytes) */
	stream_read_uint32(s, settings->kbd_type); /* keyboardType (4 bytes) */
	stream_read_uint32(s, settings->kbd_subtype); /* keyboardSubType (4 bytes) */
	stream_read_uint32(s, settings->kbd_fn_keys); /* keyboardFunctionKeys (4 bytes) */
	stream_seek(s, 64); /* imeFileName (64 bytes) */

	if ((inputFlags & INPUT_FLAG_FASTPATH_INPUT) || (inputFlags & INPUT_FLAG_FASTPATH_INPUT2))
	{
		if (settings->fast_path_input != False)
			settings->fast_path_input = True;
	}
}
Ejemplo n.º 22
0
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;
}
Ejemplo n.º 23
0
void rdp_read_bitmap_cache_capability_set(STREAM* s, rdpSettings* settings)
{
	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) */
}
Ejemplo n.º 24
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;
}
Ejemplo n.º 25
0
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;
	}
}
Ejemplo n.º 26
0
void update_read_palette(rdpUpdate* update, STREAM* s, PALETTE_UPDATE* palette_update)
{
	int i;
	uint8 byte;
	uint32 color;

	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;

	/* paletteEntries */
	for (i = 0; i < (int) palette_update->number; i++)
	{
		stream_read_uint8(s, byte);
		color = byte;
		stream_read_uint8(s, byte);
		color |= (byte << 8);
		stream_read_uint8(s, byte);
		color |= (byte << 16);
		palette_update->entries[i] = color;
	}
}
Ejemplo n.º 27
0
/* 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);
	}
}
Ejemplo n.º 28
0
void rdp_read_color_cache_capability_set(STREAM* s, rdpSettings* settings)
{
	stream_seek_uint16(s); /* colorTableCacheSize (2 bytes) */
	stream_seek_uint16(s); /* pad2Octets (2 bytes) */
}
Ejemplo n.º 29
0
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;
}
Ejemplo n.º 30
0
void rdp_read_font_capability_set(STREAM* s, rdpSettings* settings)
{
	stream_seek_uint16(s); /* fontSupportFlags (2 bytes) */
	stream_seek_uint16(s); /* pad2Octets (2 bytes) */
}