示例#1
0
static BYTE* xf_cliprdr_process_requested_unicodetext(BYTE* data, int* size)
{
	char* inbuf;
	WCHAR* outbuf;
	int out_size;

	inbuf = (char*) lf2crlf(data, size);
	out_size = freerdp_AsciiToUnicodeAlloc(inbuf, &outbuf, 0);
	free(inbuf);

	*size = (int) ((out_size + 1) * 2);

	return (BYTE*) outbuf;
}
示例#2
0
文件: nego.c 项目: LK2000/FreeRDP
BOOL nego_send_preconnection_pdu(rdpNego* nego)
{
	STREAM* s;
	UINT32 cbSize;
	UINT16 cchPCB = 0;
	WCHAR* wszPCB = NULL;

	if (!nego->send_preconnection_pdu)
		return TRUE;

	DEBUG_NEGO("Sending preconnection PDU");

	if (!nego_tcp_connect(nego))
		return FALSE;

	/* it's easier to always send the version 2 PDU, and it's just 2 bytes overhead */
	cbSize = PRECONNECTION_PDU_V2_MIN_SIZE;

	if (nego->preconnection_blob)
	{
		cchPCB = (UINT16) freerdp_AsciiToUnicodeAlloc(nego->preconnection_blob, &wszPCB, 0);
		cchPCB += 1; /* zero-termination */
		cbSize += cchPCB * 2;
	}

	s = transport_send_stream_init(nego->transport, cbSize);
	stream_write_UINT32(s, cbSize); /* cbSize */
	stream_write_UINT32(s, 0); /* Flags */
	stream_write_UINT32(s, PRECONNECTION_PDU_V2); /* Version */
	stream_write_UINT32(s, nego->preconnection_id); /* Id */
	stream_write_UINT16(s, cchPCB); /* cchPCB */

	if (wszPCB)
	{
		stream_write(s, wszPCB, cchPCB * 2); /* wszPCB */
		free(wszPCB);
	}

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

	return TRUE;
}
示例#3
0
void rail_string_to_unicode_string(rdpRailOrder* rail_order, char* string, RAIL_UNICODE_STRING* unicode_string)
{
	WCHAR* buffer;
	int length = 0;

	if (unicode_string->string != NULL)
		free(unicode_string->string);

	unicode_string->string = NULL;
	unicode_string->length = 0;

	if (string == NULL || strlen(string) < 1)
		return;

	length = freerdp_AsciiToUnicodeAlloc(string, &buffer, 0) * 2;

	unicode_string->string = (BYTE*) buffer;
	unicode_string->length = (UINT16) length;
}
示例#4
0
文件: gcc.c 项目: ArthurGodoy/FreeRDP
void gcc_write_client_core_data(STREAM* s, rdpSettings* settings)
{
	uint32 version;
	WCHAR* clientName;
	int clientNameLength;
	uint8 connectionType;
	uint16 highColorDepth;
	uint16 supportedColorDepths;
	uint16 earlyCapabilityFlags;
	WCHAR* clientDigProductId;
	int clientDigProductIdLength;

	gcc_write_user_data_header(s, CS_CORE, 216);

	version = settings->rdp_version >= 5 ? RDP_VERSION_5_PLUS : RDP_VERSION_4;

	clientNameLength = freerdp_AsciiToUnicodeAlloc(settings->client_hostname, &clientName, 0);
	clientDigProductIdLength = freerdp_AsciiToUnicodeAlloc(settings->client_product_id, &clientDigProductId, 0);

	stream_write_uint32(s, version); /* version */
	stream_write_uint16(s, settings->width); /* desktopWidth */
	stream_write_uint16(s, settings->height); /* desktopHeight */
	stream_write_uint16(s, RNS_UD_COLOR_8BPP); /* colorDepth, ignored because of postBeta2ColorDepth */
	stream_write_uint16(s, RNS_UD_SAS_DEL);	/* SASSequence (Secure Access Sequence) */
	stream_write_uint32(s, settings->kbd_layout); /* keyboardLayout */
	stream_write_uint32(s, settings->client_build); /* clientBuild */

	/* clientName (32 bytes, null-terminated unicode, truncated to 15 characters) */

	if (clientNameLength > 15)
	{
		clientNameLength = 15;
		clientName[clientNameLength] = 0;
	}

	stream_write(s, clientName, ((clientNameLength + 1) * 2));
	stream_write_zero(s, 32 - ((clientNameLength + 1) * 2));
	xfree(clientName);

	stream_write_uint32(s, settings->kbd_type); /* keyboardType */
	stream_write_uint32(s, settings->kbd_subtype); /* keyboardSubType */
	stream_write_uint32(s, settings->kbd_fn_keys); /* keyboardFunctionKey */

	stream_write_zero(s, 64); /* imeFileName */

	stream_write_uint16(s, RNS_UD_COLOR_8BPP); /* postBeta2ColorDepth */
	stream_write_uint16(s, 1); /* clientProductID */
	stream_write_uint32(s, 0); /* serialNumber (should be initialized to 0) */

	highColorDepth = MIN(settings->color_depth, 24);

	supportedColorDepths =
			RNS_UD_24BPP_SUPPORT |
			RNS_UD_16BPP_SUPPORT |
			RNS_UD_15BPP_SUPPORT;

	connectionType = settings->connection_type;
	earlyCapabilityFlags = RNS_UD_CS_SUPPORT_ERRINFO_PDU;

	if (settings->rfx_codec)
		connectionType = CONNECTION_TYPE_LAN;

	if (connectionType != 0)
		earlyCapabilityFlags |= RNS_UD_CS_VALID_CONNECTION_TYPE;

	if (settings->color_depth == 32)
	{
		supportedColorDepths |= RNS_UD_32BPP_SUPPORT;
		earlyCapabilityFlags |= RNS_UD_CS_WANT_32BPP_SESSION;
	}

	stream_write_uint16(s, highColorDepth); /* highColorDepth */
	stream_write_uint16(s, supportedColorDepths); /* supportedColorDepths */

	stream_write_uint16(s, earlyCapabilityFlags); /* earlyCapabilityFlags */

	/* clientDigProductId (64 bytes, null-terminated unicode, truncated to 30 characters) */
	if (clientDigProductIdLength > 62)
	{
		clientDigProductIdLength = 62;
		clientDigProductId[clientDigProductIdLength] = 0;
		clientDigProductId[clientDigProductIdLength + 1] = 0;
	}
	stream_write(s, clientDigProductId, clientDigProductIdLength + 2);
	stream_write_zero(s, 64 - clientDigProductIdLength - 2);
	xfree(clientDigProductId);

	stream_write_uint8(s, connectionType); /* connectionType */
	stream_write_uint8(s, 0); /* pad1octet */

	stream_write_uint32(s, settings->selected_protocol); /* serverSelectedProtocol */
}
示例#5
0
boolean disk_file_query_directory(DISK_FILE* file, uint32 FsInformationClass, uint8 InitialQuery,
	const char* path, STREAM* output)
{
	int length;
	boolean ret;
	WCHAR* ent_path;
	struct STAT st;
	struct dirent* ent;

	DEBUG_SVC("path %s FsInformationClass %d InitialQuery %d", path, FsInformationClass, InitialQuery);

	if (!file->dir)
	{
		stream_write_uint32(output, 0); /* Length */
		stream_write_uint8(output, 0); /* Padding */
		return false;
	}

	if (InitialQuery != 0)
	{
		rewinddir(file->dir);
		xfree(file->pattern);

		if (path[0])
			file->pattern = strdup(strrchr(path, '\\') + 1);
		else
			file->pattern = NULL;
	}

	if (file->pattern)
	{
		do
		{
			ent = readdir(file->dir);

			if (ent == NULL)
				continue;

			if (disk_file_wildcard_match(file->pattern, ent->d_name))
				break;
		} while (ent);
	}
	else
	{
		ent = readdir(file->dir);
	}

	if (ent == NULL)
	{
		DEBUG_SVC("  pattern %s not found.", file->pattern);
		stream_write_uint32(output, 0); /* Length */
		stream_write_uint8(output, 0); /* Padding */
		return false;
	}

	memset(&st, 0, sizeof(struct STAT));
	ent_path = (WCHAR*) malloc(strlen(file->fullpath) + strlen(ent->d_name) + 2);
	sprintf((char*) ent_path, "%s/%s", file->fullpath, ent->d_name);

	if (STAT((char*) ent_path, &st) != 0)
	{
		DEBUG_WARN("stat %s failed. errno = %d", (char*) ent_path, errno);
	}

	DEBUG_SVC("  pattern %s matched %s", file->pattern, ent_path);
	xfree(ent_path);

	length = freerdp_AsciiToUnicodeAlloc(ent->d_name, &ent_path, 0) * 2;

	ret = true;

	switch (FsInformationClass)
	{
		case FileDirectoryInformation:
			/* http://msdn.microsoft.com/en-us/library/cc232097.aspx */
			stream_write_uint32(output, 64 + length); /* Length */
			stream_check_size(output, 64 + length);
			stream_write_uint32(output, 0); /* NextEntryOffset */
			stream_write_uint32(output, 0); /* FileIndex */
			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_uint64(output, st.st_size); /* EndOfFile */
			stream_write_uint64(output, st.st_size); /* AllocationSize */
			stream_write_uint32(output, FILE_ATTR_SYSTEM_TO_RDP(file, st)); /* FileAttributes */
			stream_write_uint32(output, length); /* FileNameLength */
			stream_write(output, ent_path, length);
			break;

		case FileFullDirectoryInformation:
			/* http://msdn.microsoft.com/en-us/library/cc232068.aspx */
			stream_write_uint32(output, 68 + length); /* Length */
			stream_check_size(output, 68 + length);
			stream_write_uint32(output, 0); /* NextEntryOffset */
			stream_write_uint32(output, 0); /* FileIndex */
			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_uint64(output, st.st_size); /* EndOfFile */
			stream_write_uint64(output, st.st_size); /* AllocationSize */
			stream_write_uint32(output, FILE_ATTR_SYSTEM_TO_RDP(file, st)); /* FileAttributes */
			stream_write_uint32(output, length); /* FileNameLength */
			stream_write_uint32(output, 0); /* EaSize */
			stream_write(output, ent_path, length);
			break;

		case FileBothDirectoryInformation:
			/* http://msdn.microsoft.com/en-us/library/cc232095.aspx */
			stream_write_uint32(output, 93 + length); /* Length */
			stream_check_size(output, 93 + length);
			stream_write_uint32(output, 0); /* NextEntryOffset */
			stream_write_uint32(output, 0); /* FileIndex */
			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_uint64(output, st.st_size); /* EndOfFile */
			stream_write_uint64(output, st.st_size); /* AllocationSize */
			stream_write_uint32(output, FILE_ATTR_SYSTEM_TO_RDP(file, st)); /* FileAttributes */
			stream_write_uint32(output, length); /* FileNameLength */
			stream_write_uint32(output, 0); /* EaSize */
			stream_write_uint8(output, 0); /* ShortNameLength */
			/* Reserved(1), MUST NOT be added! */
			stream_write_zero(output, 24); /* ShortName */
			stream_write(output, ent_path, length);
			break;

		case FileNamesInformation:
			/* http://msdn.microsoft.com/en-us/library/cc232077.aspx */
			stream_write_uint32(output, 12 + length); /* Length */
			stream_check_size(output, 12 + length);
			stream_write_uint32(output, 0); /* NextEntryOffset */
			stream_write_uint32(output, 0); /* FileIndex */
			stream_write_uint32(output, length); /* FileNameLength */
			stream_write(output, ent_path, length);
			break;

		default:
			stream_write_uint32(output, 0); /* Length */
			stream_write_uint8(output, 0); /* Padding */
			DEBUG_WARN("invalid FsInformationClass %d", FsInformationClass);
			ret = false;
			break;
	}

	xfree(ent_path);

	return ret;
}