Beispiel #1
0
static void rfx_compose_message_context(RFX_CONTEXT* context, STREAM* s)
{
	UINT16 properties;

	stream_write_UINT16(s, WBT_CONTEXT); /* CodecChannelT.blockType */
	stream_write_UINT32(s, 13); /* CodecChannelT.blockLen */
	stream_write_BYTE(s, 1); /* CodecChannelT.codecId */
	stream_write_BYTE(s, 0); /* CodecChannelT.channelId */
	stream_write_BYTE(s, 0); /* ctxId */
	stream_write_UINT16(s, CT_TILE_64x64); /* tileSize */

	/* properties */
	properties = context->flags; /* flags */
	properties |= (COL_CONV_ICT << 3); /* cct */
	properties |= (CLW_XFORM_DWT_53_A << 5); /* xft */
	properties |= ((context->mode == RLGR1 ? CLW_ENTROPY_RLGR1 : CLW_ENTROPY_RLGR3) << 9); /* et */
	properties |= (SCALAR_QUANTIZATION << 13); /* qt */
	stream_write_UINT16(s, properties);

	/* properties in tilesets: note that this has different format from the one in TS_RFX_CONTEXT */
	properties = 1; /* lt */
	properties |= (context->flags << 1); /* flags */
	properties |= (COL_CONV_ICT << 4); /* cct */
	properties |= (CLW_XFORM_DWT_53_A << 6); /* xft */
	properties |= ((context->mode == RLGR1 ? CLW_ENTROPY_RLGR1 : CLW_ENTROPY_RLGR3) << 10); /* et */
	properties |= (SCALAR_QUANTIZATION << 14); /* qt */
	context->properties = properties;
}
Beispiel #2
0
static void rfx_compose_message_codec_versions(RFX_CONTEXT* context, STREAM* s)
{
	stream_write_UINT16(s, WBT_CODEC_VERSIONS); /* BlockT.blockType */
	stream_write_UINT32(s, 10); /* BlockT.blockLen */
	stream_write_BYTE(s, 1); /* numCodecs */
	stream_write_BYTE(s, 1); /* codecs.codecId */
	stream_write_UINT16(s, WF_VERSION_1_0); /* codecs.version */
}
Beispiel #3
0
static void rfx_compose_message_frame_end(RFX_CONTEXT* context, STREAM* s)
{
	stream_check_size(s, 8);

	stream_write_UINT16(s, WBT_FRAME_END); /* CodecChannelT.blockType */
	stream_write_UINT32(s, 8); /* CodecChannelT.blockLen */
	stream_write_BYTE(s, 1); /* CodecChannelT.codecId */
	stream_write_BYTE(s, 0); /* CodecChannelT.channelId */
}
Beispiel #4
0
static void rfx_compose_message_channels(RFX_CONTEXT* context, STREAM* s)
{
	stream_write_UINT16(s, WBT_CHANNELS); /* BlockT.blockType */
	stream_write_UINT32(s, 12); /* BlockT.blockLen */
	stream_write_BYTE(s, 1); /* numChannels */
	stream_write_BYTE(s, 0); /* Channel.channelId */
	stream_write_UINT16(s, context->width); /* Channel.width */
	stream_write_UINT16(s, context->height); /* Channel.height */
}
Beispiel #5
0
BOOL nego_send_negotiation_request(rdpNego* nego)
{
	STREAM* s;
	int length;
	BYTE *bm, *em;
	int cookie_length;

	s = transport_send_stream_init(nego->transport, 256);
	length = TPDU_CONNECTION_REQUEST_LENGTH;
	stream_get_mark(s, bm);
	stream_seek(s, length);

	if (nego->RoutingToken != NULL)
	{
		stream_write(s, nego->RoutingToken, nego->RoutingTokenLength);
		length += nego->RoutingTokenLength;
	}
	else if (nego->cookie != NULL)
	{
		cookie_length = strlen(nego->cookie);

		if (cookie_length > (int) nego->cookie_max_length)
			cookie_length = nego->cookie_max_length;

		stream_write(s, "Cookie: mstshash=", 17);
		stream_write(s, (BYTE*) nego->cookie, cookie_length);
		stream_write_BYTE(s, 0x0D); /* CR */
		stream_write_BYTE(s, 0x0A); /* LF */
		length += cookie_length + 19;
	}

	DEBUG_NEGO("requested_protocols: %d", nego->requested_protocols);

	if (nego->requested_protocols > PROTOCOL_RDP)
	{
		/* RDP_NEG_DATA must be present for TLS and NLA */
		stream_write_BYTE(s, TYPE_RDP_NEG_REQ);
		stream_write_BYTE(s, 0); /* flags, must be set to zero */
		stream_write_UINT16(s, 8); /* RDP_NEG_DATA length (8) */
		stream_write_UINT32(s, nego->requested_protocols); /* requestedProtocols */
		length += 8;
	}

	stream_get_mark(s, em);
	stream_set_mark(s, bm);
	tpkt_write_header(s, length);
	tpdu_write_connection_request(s, length - 5);
	stream_set_mark(s, em);

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

	return TRUE;
}
Beispiel #6
0
static UINT32 rdp_security_stream_out(rdpRdp* rdp, STREAM* s, int length)
{
	BYTE* data;
	UINT32 sec_flags;
	UINT32 pad = 0;

	sec_flags = rdp->sec_flags;

	if (sec_flags != 0)
	{
		rdp_write_security_header(s, sec_flags);

		if (sec_flags & SEC_ENCRYPT)
		{
			if (rdp->settings->EncryptionMethods == ENCRYPTION_METHOD_FIPS)
			{
				data = s->p + 12;

				length = length - (data - s->data);
				stream_write_UINT16(s, 0x10); /* length */
				stream_write_BYTE(s, 0x1); /* TSFIPS_VERSION 1*/

				/* handle padding */
				pad = 8 - (length % 8);

				if (pad == 8)
					pad = 0;
				if (pad)
					memset(data+length, 0, pad);

				stream_write_BYTE(s, pad);

				security_hmac_signature(data, length, s->p, rdp);
				stream_seek(s, 8);
				security_fips_encrypt(data, length + pad, rdp);
			}
			else
			{
				data = s->p + 8;
				length = length - (data - s->data);
				if (sec_flags & SEC_SECURE_CHECKSUM)
					security_salted_mac_signature(rdp, data, length, TRUE, s->p);
				else
					security_mac_signature(rdp, data, length, s->p);
				stream_seek(s, 8);
				security_encrypt(s->p, length, rdp);
			}
		}

		rdp->sec_flags = 0;
	}

	return pad;
}
Beispiel #7
0
void rail_write_client_sysparam_order(STREAM* s, RAIL_SYSPARAM_ORDER* sysparam)
{
	BYTE body;
	stream_write_UINT32(s, sysparam->param); /* systemParam (4 bytes) */

	switch (sysparam->param)
	{
		case SPI_SET_DRAG_FULL_WINDOWS:
			body = sysparam->dragFullWindows;
			stream_write_BYTE(s, body);
			break;

		case SPI_SET_KEYBOARD_CUES:
			body = sysparam->keyboardCues;
			stream_write_BYTE(s, body);
			break;

		case SPI_SET_KEYBOARD_PREF:
			body = sysparam->keyboardPref;
			stream_write_BYTE(s, body);
			break;

		case SPI_SET_MOUSE_BUTTON_SWAP:
			body = sysparam->mouseButtonSwap;
			stream_write_BYTE(s, body);
			break;

		case SPI_SET_WORK_AREA:
			stream_write_UINT16(s, sysparam->workArea.left); /* left (2 bytes) */
			stream_write_UINT16(s, sysparam->workArea.top); /* top (2 bytes) */
			stream_write_UINT16(s, sysparam->workArea.right); /* right (2 bytes) */
			stream_write_UINT16(s, sysparam->workArea.bottom); /* bottom (2 bytes) */
			break;

		case SPI_DISPLAY_CHANGE:
			stream_write_UINT16(s, sysparam->displayChange.left); /* left (2 bytes) */
			stream_write_UINT16(s, sysparam->displayChange.top); /* top (2 bytes) */
			stream_write_UINT16(s, sysparam->displayChange.right); /* right (2 bytes) */
			stream_write_UINT16(s, sysparam->displayChange.bottom); /* bottom (2 bytes) */
			break;

		case SPI_TASKBAR_POS:
			stream_write_UINT16(s, sysparam->taskbarPos.left); /* left (2 bytes) */
			stream_write_UINT16(s, sysparam->taskbarPos.top); /* top (2 bytes) */
			stream_write_UINT16(s, sysparam->taskbarPos.right); /* right (2 bytes) */
			stream_write_UINT16(s, sysparam->taskbarPos.bottom); /* bottom (2 bytes) */
			break;

		case SPI_SET_HIGH_CONTRAST:
			rail_write_high_contrast(s, &sysparam->highContrast);
			break;
	}
}
Beispiel #8
0
static void rfx_compose_message_frame_begin(RFX_CONTEXT* context, STREAM* s)
{
	stream_check_size(s, 14);

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

	context->frame_idx++;
}
Beispiel #9
0
BOOL drive_file_query_information(DRIVE_FILE* file, UINT32 FsInformationClass, STREAM* output)
{
	struct STAT st;

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

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

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

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

		default:
			stream_write_UINT32(output, 0); /* Length */
			DEBUG_WARN("invalid FsInformationClass %d", FsInformationClass);
			return FALSE;
	}
	return TRUE;
}
Beispiel #10
0
int ber_write_length(wStream* s, int length)
{
	if (length > 0x7F)
	{
		stream_write_BYTE(s, 0x82);
		stream_write_UINT16_be(s, length);
		return 3;
	}
	else
	{
		stream_write_BYTE(s, length);
		return 1;
	}
}
Beispiel #11
0
void ber_write_application_tag(wStream* s, BYTE tag, int length)
{
	if (tag > 30)
	{
		stream_write_BYTE(s, (BER_CLASS_APPL | BER_CONSTRUCT) | BER_TAG_MASK);
		stream_write_BYTE(s, tag);
		ber_write_length(s, length);
	}
	else
	{
		stream_write_BYTE(s, (BER_CLASS_APPL | BER_CONSTRUCT) | (BER_TAG_MASK & tag));
		ber_write_length(s, length);
	}
}
Beispiel #12
0
void rdp_write_share_data_header(STREAM* s, UINT16 length, BYTE type, UINT32 share_id)
{
	length -= RDP_PACKET_HEADER_MAX_LENGTH;
	length -= RDP_SHARE_CONTROL_HEADER_LENGTH;
	length -= RDP_SHARE_DATA_HEADER_LENGTH;

	/* Share Data Header */
	stream_write_UINT32(s, share_id); /* shareId (4 bytes) */
	stream_write_BYTE(s, 0); /* pad1 (1 byte) */
	stream_write_BYTE(s, STREAM_LOW); /* streamId (1 byte) */
	stream_write_UINT16(s, length); /* uncompressedLength (2 bytes) */
	stream_write_BYTE(s, type); /* pduType2, Data PDU Type (1 byte) */
	stream_write_BYTE(s, 0); /* compressedType (1 byte) */
	stream_write_UINT16(s, 0); /* compressedLength (2 bytes) */
}
Beispiel #13
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 #14
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 #15
0
static void printer_process_irp_write(PRINTER_DEVICE* printer_dev, IRP* irp)
{
    UINT32 Length;
    UINT64 Offset;
    rdpPrintJob* printjob = NULL;

    stream_read_UINT32(irp->input, Length);
    stream_read_UINT64(irp->input, Offset);
    stream_seek(irp->input, 20); /* Padding */

    if (printer_dev->printer != NULL)
        printjob = printer_dev->printer->FindPrintJob(printer_dev->printer, irp->FileId);

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

        DEBUG_WARN("printjob id %d not found.", irp->FileId);
    }
    else
    {
        printjob->Write(printjob, stream_get_tail(irp->input), Length);

        DEBUG_SVC("printjob id %d written %d bytes.", irp->FileId, Length);
    }

    stream_write_UINT32(irp->output, Length);
    stream_write_BYTE(irp->output, 0); /* Padding */

    irp->Complete(irp);
}
Beispiel #16
0
void rdp_write_header(rdpRdp* rdp, STREAM* s, UINT16 length, UINT16 channel_id)
{
	int body_length;
	enum DomainMCSPDU MCSPDU;

	MCSPDU = (rdp->settings->ServerMode) ? DomainMCSPDU_SendDataIndication : DomainMCSPDU_SendDataRequest;

	if ((rdp->sec_flags & SEC_ENCRYPT) && (rdp->settings->EncryptionMethods == ENCRYPTION_METHOD_FIPS))
	{
		int pad;

		body_length = length - RDP_PACKET_HEADER_MAX_LENGTH - 16;
		pad = 8 - (body_length % 8);

		if (pad != 8)
			length += pad;
	}

	mcs_write_domain_mcspdu_header(s, MCSPDU, length, 0);
	per_write_integer16(s, rdp->mcs->user_id, MCS_BASE_CHANNEL_ID); /* initiator */
	per_write_integer16(s, channel_id, 0); /* channelId */
	stream_write_BYTE(s, 0x70); /* dataPriority + segmentation */
	/*
	 * We always encode length in two bytes, eventhough we could use
	 * only one byte if length <= 0x7F. It is just easier that way,
	 * because we can leave room for fixed-length header, store all
	 * the data first and then store the header.
	 */
	length = (length - RDP_PACKET_HEADER_MAX_LENGTH) | 0x8000;
	stream_write_UINT16_be(s, length); /* userData (OCTET_STRING) */
}
Beispiel #17
0
void tpdu_write_header(STREAM* s, UINT16 length, BYTE code)
{
	stream_write_BYTE(s, length); /* LI */
	stream_write_BYTE(s, code); /* code */

	if (code == X224_TPDU_DATA)
	{
		stream_write_BYTE(s, 0x80); /* EOT */
	}
	else
	{
		stream_write_UINT16(s, 0); /* DST-REF */
		stream_write_UINT16(s, 0); /* SRC-REF */
		stream_write_BYTE(s, 0); /* Class 0 */
	}
}
Beispiel #18
0
void update_write_surfcmd_surface_bits_header(STREAM* s, SURFACE_BITS_COMMAND* cmd)
{
	stream_check_size(s, SURFCMD_SURFACE_BITS_HEADER_LENGTH);

	stream_write_UINT16(s, CMDTYPE_STREAM_SURFACE_BITS);

	stream_write_UINT16(s, cmd->destLeft);
	stream_write_UINT16(s, cmd->destTop);
	stream_write_UINT16(s, cmd->destRight);
	stream_write_UINT16(s, cmd->destBottom);
	stream_write_BYTE(s, cmd->bpp);
	stream_write_UINT16(s, 0); /* reserved1, reserved2 */
	stream_write_BYTE(s, cmd->codecID);
	stream_write_UINT16(s, cmd->width);
	stream_write_UINT16(s, cmd->height);
	stream_write_UINT32(s, cmd->bitmapDataLength);
}
Beispiel #19
0
void rail_write_client_activate_order(STREAM* s, RAIL_ACTIVATE_ORDER* activate)
{
	BYTE enabled;

	stream_write_UINT32(s, activate->windowId); /* windowId (4 bytes) */

	enabled = activate->enabled;
	stream_write_BYTE(s, enabled); /* enabled (1 byte) */
}
Beispiel #20
0
void rdp_write_client_persistent_key_list_pdu(STREAM* s, rdpSettings* settings)
{
	stream_write_UINT16(s, 0); /* numEntriesCache0 (2 bytes) */
	stream_write_UINT16(s, 0); /* numEntriesCache1 (2 bytes) */
	stream_write_UINT16(s, 0); /* numEntriesCache2 (2 bytes) */
	stream_write_UINT16(s, 0); /* numEntriesCache3 (2 bytes) */
	stream_write_UINT16(s, 0); /* numEntriesCache4 (2 bytes) */
	stream_write_UINT16(s, 0); /* totalEntriesCache0 (2 bytes) */
	stream_write_UINT16(s, 0); /* totalEntriesCache1 (2 bytes) */
	stream_write_UINT16(s, 0); /* totalEntriesCache2 (2 bytes) */
	stream_write_UINT16(s, 0); /* totalEntriesCache3 (2 bytes) */
	stream_write_UINT16(s, 0); /* totalEntriesCache4 (2 bytes) */
	stream_write_BYTE(s, PERSIST_FIRST_PDU | PERSIST_LAST_PDU); /* bBitMask (1 byte) */
	stream_write_BYTE(s, 0); /* pad1 (1 byte) */
	stream_write_UINT16(s, 0); /* pad3 (2 bytes) */

	/* entries */
}
Beispiel #21
0
int der_write_length(wStream* s, int length)
{
	if (length > 0x7F && length <= 0xFF)
	{
		stream_write_BYTE(s, 0x81);
		stream_write_BYTE(s, length);
		return 2;
	}
	else if (length > 0xFF)
	{
		stream_write_BYTE(s, 0x82);
		stream_write_UINT16_be(s, length);
		return 3;
	}
	else
	{
		stream_write_BYTE(s, length);
		return 1;
	}
}
Beispiel #22
0
static void rfx_compose_message_tile(RFX_CONTEXT* context, STREAM* s,
	BYTE* tile_data, int tile_width, int tile_height, int rowstride,
	const UINT32* quantVals, int quantIdxY, int quantIdxCb, int quantIdxCr,
	int xIdx, int yIdx)
{
	int YLen = 0;
	int CbLen = 0;
	int CrLen = 0;
	int start_pos, end_pos;

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

	stream_write_UINT16(s, CBT_TILE); /* BlockT.blockType */
	stream_seek_UINT32(s); /* set BlockT.blockLen later */
	stream_write_BYTE(s, quantIdxY);
	stream_write_BYTE(s, quantIdxCb);
	stream_write_BYTE(s, quantIdxCr);
	stream_write_UINT16(s, xIdx);
	stream_write_UINT16(s, yIdx);

	stream_seek(s, 6); /* YLen, CbLen, CrLen */

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

	DEBUG_RFX("xIdx=%d yIdx=%d width=%d height=%d YLen=%d CbLen=%d CrLen=%d",
		xIdx, yIdx, tile_width, tile_height, YLen, CbLen, CrLen);

	end_pos = stream_get_pos(s);

	stream_set_pos(s, start_pos + 2);
	stream_write_UINT32(s, 19 + YLen + CbLen + CrLen); /* BlockT.blockLen */
	stream_set_pos(s, start_pos + 13);
	stream_write_UINT16(s, YLen);
	stream_write_UINT16(s, CbLen);
	stream_write_UINT16(s, CrLen);

	stream_set_pos(s, end_pos);
}
Beispiel #23
0
void input_send_fastpath_keyboard_event(rdpInput* input, UINT16 flags, UINT16 code)
{
	STREAM* s;
	BYTE eventFlags = 0;
	rdpRdp* rdp = input->context->rdp;

	eventFlags |= (flags & KBD_FLAGS_RELEASE) ? FASTPATH_INPUT_KBDFLAGS_RELEASE : 0;
	eventFlags |= (flags & KBD_FLAGS_EXTENDED) ? FASTPATH_INPUT_KBDFLAGS_EXTENDED : 0;
	s = fastpath_input_pdu_init(rdp->fastpath, eventFlags, FASTPATH_INPUT_EVENT_SCANCODE);
	stream_write_BYTE(s, code); /* keyCode (1 byte) */
	fastpath_send_input_pdu(rdp->fastpath, s);
}
Beispiel #24
0
BOOL rdp_send_deactivate_all(rdpRdp* rdp)
{
	STREAM* s;

	s = rdp_pdu_init(rdp);

	stream_write_UINT32(s, rdp->settings->share_id); /* shareId (4 bytes) */
	stream_write_UINT16(s, 1); /* lengthSourceDescriptor (2 bytes) */
	stream_write_BYTE(s, 0); /* sourceDescriptor (should be 0x00) */

	return rdp_send_pdu(rdp, s, PDU_TYPE_DEACTIVATE_ALL, rdp->mcs->user_id);
}
Beispiel #25
0
static BOOL rdpsnd_server_send_formats(rdpsnd_server* rdpsnd, STREAM* s)
{
	UINT16 i;

	RDPSND_PDU_INIT(s, SNDC_FORMATS);

	stream_write_UINT32(s, 0); /* dwFlags */
	stream_write_UINT32(s, 0); /* dwVolume */
	stream_write_UINT32(s, 0); /* dwPitch */
	stream_write_UINT16(s, 0); /* wDGramPort */
	stream_write_UINT16(s, rdpsnd->context.num_server_formats); /* wNumberOfFormats */
	stream_write_BYTE(s, rdpsnd->context.block_no); /* cLastBlockConfirmed */
	stream_write_UINT16(s, 0x06); /* wVersion */
	stream_write_BYTE(s, 0); /* bPad */

	for (i = 0; i < rdpsnd->context.num_server_formats; i++)
	{
		stream_write_UINT16(s, rdpsnd->context.server_formats[i].wFormatTag); /* wFormatTag (WAVE_FORMAT_PCM) */
		stream_write_UINT16(s, rdpsnd->context.server_formats[i].nChannels); /* nChannels */
		stream_write_UINT32(s, rdpsnd->context.server_formats[i].nSamplesPerSec); /* nSamplesPerSec */

		stream_write_UINT32(s, rdpsnd->context.server_formats[i].nSamplesPerSec *
			rdpsnd->context.server_formats[i].nChannels *
			rdpsnd->context.server_formats[i].wBitsPerSample / 8); /* nAvgBytesPerSec */

		stream_write_UINT16(s, rdpsnd->context.server_formats[i].nBlockAlign); /* nBlockAlign */
		stream_write_UINT16(s, rdpsnd->context.server_formats[i].wBitsPerSample); /* wBitsPerSample */
		stream_write_UINT16(s, rdpsnd->context.server_formats[i].cbSize); /* cbSize */

		if (rdpsnd->context.server_formats[i].cbSize > 0)
		{
			stream_write(s, rdpsnd->context.server_formats[i].data, rdpsnd->context.server_formats[i].cbSize);
		}
	}

	RDPSND_PDU_FINISH(s);

	return TRUE;
}
Beispiel #26
0
static void update_write_suppress_output(STREAM* s, BYTE allow, RECTANGLE_16* area)
{
	stream_write_BYTE(s, allow); /* allowDisplayUpdates (1 byte) */
	stream_seek(s, 3); /* pad3Octets (3 bytes) */

	if (allow > 0)
	{
		stream_write_UINT16(s, area->left); /* left (2 bytes) */
		stream_write_UINT16(s, area->top); /* top (2 bytes) */
		stream_write_UINT16(s, area->right); /* right (2 bytes) */
		stream_write_UINT16(s, area->bottom); /* bottom (2 bytes) */
	}
}
Beispiel #27
0
static void update_send_scrblt(rdpContext* context, SCRBLT_ORDER* scrblt)
{
	STREAM* s;
	rdpRdp* rdp = context->rdp;

	s = fastpath_update_pdu_init(rdp->fastpath);

	stream_write_UINT16(s, 1); /* numberOrders (2 bytes) */
	stream_write_BYTE(s, ORDER_STANDARD | ORDER_TYPE_CHANGE); /* controlFlags (1 byte) */
	stream_write_BYTE(s, ORDER_TYPE_SCRBLT); /* orderType (1 byte) */
	stream_write_BYTE(s, 0x7F); /* fieldFlags (variable) */

	stream_write_UINT16(s, scrblt->nLeftRect);
	stream_write_UINT16(s, scrblt->nTopRect);
	stream_write_UINT16(s, scrblt->nWidth);
	stream_write_UINT16(s, scrblt->nHeight);
	stream_write_BYTE(s, scrblt->bRop);
	stream_write_UINT16(s, scrblt->nXSrc);
	stream_write_UINT16(s, scrblt->nYSrc);

	fastpath_send_update_pdu(rdp->fastpath, FASTPATH_UPDATETYPE_ORDERS, s);
}
Beispiel #28
0
static void xf_cliprdr_process_dib(clipboardContext* cb, BYTE* data, int size)
{
	STREAM* s;
	UINT16 bpp;
	UINT32 offset;
	UINT32 ncolors;

	/* size should be at least sizeof(BITMAPINFOHEADER) */
	if (size < 40)
	{
		DEBUG_X11_CLIPRDR("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_CLIPRDR("offset=%d bpp=%d ncolors=%d", offset, bpp, ncolors);

	s = stream_new(14 + size);
	stream_write_BYTE(s, 'B');
	stream_write_BYTE(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);
}
Beispiel #29
0
void drive_register_drive_path(PDEVICE_SERVICE_ENTRY_POINTS pEntryPoints, char* name, char* path)
{
	int i, length;
	DRIVE_DEVICE* disk;

#ifdef WIN32
	/*
	 * We cannot enter paths like c:\ because : is an arg separator
	 * thus, paths are entered as c+\ and the + is substituted here
	 */
	if ( path[1] == '+' )
	{
		if ( (path[0]>='a' && path[0]<='z') || (path[0]>='A' && path[0]<='Z') )
		{
			path[1] = ':';
		}
	}
#endif

	if (name[0] && path[0])
	{
		disk = (DRIVE_DEVICE*) malloc(sizeof(DRIVE_DEVICE));
		ZeroMemory(disk, sizeof(DRIVE_DEVICE));

		disk->device.type = RDPDR_DTYP_FILESYSTEM;
		disk->device.name = name;
		disk->device.IRPRequest = drive_irp_request;
		disk->device.Free = drive_free;

		length = strlen(name);
		disk->device.data = stream_new(length + 1);

		for (i = 0; i <= length; i++)
			stream_write_BYTE(disk->device.data, name[i] < 0 ? '_' : name[i]);

		disk->path = path;
		disk->files = list_new();

		disk->pIrpList = (PSLIST_HEADER) _aligned_malloc(sizeof(SLIST_HEADER), MEMORY_ALLOCATION_ALIGNMENT);
		InitializeSListHead(disk->pIrpList);

		disk->irpEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
		disk->stopEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
		disk->thread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE) drive_thread_func, disk, CREATE_SUSPENDED, NULL);

		pEntryPoints->RegisterDevice(pEntryPoints->devman, (DEVICE*) disk);

                ResumeThread(disk->thread);
	}
}
Beispiel #30
0
void rts_pdu_header_write(STREAM* s, RTS_PDU_HEADER* header)
{
	stream_write_BYTE(s, header->rpc_vers); /* rpc_vers (1 byte) */
	stream_write_BYTE(s, header->rpc_vers_minor); /* rpc_vers_minor (1 byte) */
	stream_write_BYTE(s, header->ptype); /* PTYPE (1 byte) */
	stream_write_BYTE(s, header->pfc_flags); /* pfc_flags (1 byte) */
	stream_write_BYTE(s, header->packed_drep[0]); /* packet_drep[0] (1 byte) */
	stream_write_BYTE(s, header->packed_drep[1]); /* packet_drep[1] (1 byte) */
	stream_write_BYTE(s, header->packed_drep[2]); /* packet_drep[2] (1 byte) */
	stream_write_BYTE(s, header->packed_drep[3]); /* packet_drep[3] (1 byte) */
	stream_write_UINT16(s, header->frag_length); /* frag_length (2 bytes) */
	stream_write_UINT16(s, header->auth_length); /* auth_length (2 bytes) */
	stream_write_UINT32(s, header->call_id); /* call_id (4 bytes) */
	stream_write_UINT16(s, header->flags); /* flags (2 bytes) */
	stream_write_UINT16(s, header->numberOfCommands); /* numberOfCommands (2 bytes) */
}