2011-07-12 02:46:36 +04:00
|
|
|
/**
|
2012-10-09 07:02:04 +04:00
|
|
|
* FreeRDP: A Remote Desktop Protocol Implementation
|
2011-07-12 02:46:36 +04:00
|
|
|
* RDP Client Info
|
|
|
|
*
|
|
|
|
* Copyright 2011 Marc-Andre Moreau <marcandre.moreau@gmail.com>
|
2015-05-29 14:46:50 +03:00
|
|
|
* Copyright 2015 Thincast Technologies GmbH
|
|
|
|
* Copyright 2015 DI (FH) Martin Haimberger <martin.haimberger@thincast.com>
|
2011-07-12 02:46:36 +04:00
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
|
2012-08-15 01:09:01 +04:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
|
|
|
|
2012-12-17 08:34:07 +04:00
|
|
|
#include <winpr/crt.h>
|
2013-10-22 19:14:29 +04:00
|
|
|
#include <freerdp/crypto/crypto.h>
|
2014-09-12 16:36:29 +04:00
|
|
|
#include <freerdp/log.h>
|
2016-02-18 16:19:36 +03:00
|
|
|
#include <freerdp/session.h>
|
2013-10-22 19:14:29 +04:00
|
|
|
#include <stdio.h>
|
2012-12-17 08:34:07 +04:00
|
|
|
|
2012-02-16 10:53:58 +04:00
|
|
|
#include "timezone.h"
|
|
|
|
|
2011-07-12 02:46:36 +04:00
|
|
|
#include "info.h"
|
|
|
|
|
2015-02-06 23:44:29 +03:00
|
|
|
#define TAG FREERDP_TAG("core.info")
|
2014-09-12 16:36:29 +04:00
|
|
|
|
2015-02-06 23:44:29 +03:00
|
|
|
static const char* const INFO_TYPE_LOGON_STRINGS[4] =
|
2011-07-25 21:42:14 +04:00
|
|
|
{
|
|
|
|
"Logon Info V1",
|
|
|
|
"Logon Info V2",
|
|
|
|
"Logon Plain Notify",
|
|
|
|
"Logon Extended Info"
|
|
|
|
};
|
|
|
|
|
2015-02-07 00:55:21 +03:00
|
|
|
BOOL rdp_compute_client_auto_reconnect_cookie(rdpRdp* rdp)
|
|
|
|
{
|
|
|
|
BYTE ClientRandom[32];
|
|
|
|
BYTE AutoReconnectRandom[32];
|
|
|
|
ARC_SC_PRIVATE_PACKET* serverCookie;
|
|
|
|
ARC_CS_PRIVATE_PACKET* clientCookie;
|
|
|
|
rdpSettings* settings = rdp->settings;
|
|
|
|
|
|
|
|
serverCookie = settings->ServerAutoReconnectCookie;
|
|
|
|
clientCookie = settings->ClientAutoReconnectCookie;
|
|
|
|
|
|
|
|
clientCookie->cbLen = 28;
|
|
|
|
clientCookie->version = serverCookie->version;
|
|
|
|
clientCookie->logonId = serverCookie->logonId;
|
|
|
|
ZeroMemory(clientCookie->securityVerifier, 16);
|
|
|
|
|
|
|
|
ZeroMemory(AutoReconnectRandom, sizeof(AutoReconnectRandom));
|
|
|
|
CopyMemory(AutoReconnectRandom, serverCookie->arcRandomBits, 16);
|
|
|
|
|
|
|
|
ZeroMemory(ClientRandom, sizeof(ClientRandom));
|
|
|
|
|
|
|
|
if (settings->SelectedProtocol == PROTOCOL_RDP)
|
|
|
|
CopyMemory(ClientRandom, settings->ClientRandom, settings->ClientRandomLength);
|
|
|
|
|
|
|
|
/* SecurityVerifier = HMAC_MD5(AutoReconnectRandom, ClientRandom) */
|
|
|
|
|
2016-11-24 16:53:19 +03:00
|
|
|
if (!winpr_HMAC(WINPR_MD_MD5, AutoReconnectRandom, 16, ClientRandom, 32, clientCookie->securityVerifier, 16))
|
2015-04-01 12:11:37 +03:00
|
|
|
return FALSE;
|
2015-02-07 00:55:21 +03:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2011-07-12 02:46:36 +04:00
|
|
|
/**
|
2011-07-25 21:42:14 +04:00
|
|
|
* Read Server Auto Reconnect Cookie (ARC_SC_PRIVATE_PACKET).\n
|
|
|
|
* @msdn{cc240540}
|
|
|
|
* @param s stream
|
|
|
|
* @param settings settings
|
|
|
|
*/
|
|
|
|
|
2016-02-18 16:19:36 +03:00
|
|
|
BOOL rdp_read_server_auto_reconnect_cookie(rdpRdp* rdp, wStream* s, logon_info_ex *info)
|
2011-07-25 21:42:14 +04:00
|
|
|
{
|
2015-02-06 23:44:29 +03:00
|
|
|
BYTE* p;
|
2011-07-25 21:42:14 +04:00
|
|
|
ARC_SC_PRIVATE_PACKET* autoReconnectCookie;
|
2015-02-07 00:55:21 +03:00
|
|
|
rdpSettings* settings = rdp->settings;
|
2015-02-06 22:21:26 +03:00
|
|
|
|
2012-11-08 00:13:14 +04:00
|
|
|
autoReconnectCookie = settings->ServerAutoReconnectCookie;
|
2011-07-25 21:42:14 +04:00
|
|
|
|
2015-02-06 22:21:26 +03:00
|
|
|
if (Stream_GetRemainingLength(s) < 28)
|
2013-01-11 04:18:11 +04:00
|
|
|
return FALSE;
|
2015-02-06 22:21:26 +03:00
|
|
|
|
2013-05-09 00:09:16 +04:00
|
|
|
Stream_Read_UINT32(s, autoReconnectCookie->cbLen); /* cbLen (4 bytes) */
|
2015-02-06 23:44:29 +03:00
|
|
|
if (autoReconnectCookie->cbLen != 28)
|
|
|
|
{
|
|
|
|
WLog_ERR(TAG, "ServerAutoReconnectCookie.cbLen != 28");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2016-02-18 16:19:36 +03:00
|
|
|
Stream_Read_UINT32(s, autoReconnectCookie->version); /* Version (4 bytes) */
|
|
|
|
Stream_Read_UINT32(s, autoReconnectCookie->logonId); /* LogonId (4 bytes) */
|
|
|
|
Stream_Read(s, autoReconnectCookie->arcRandomBits, 16); /* ArcRandomBits (16 bytes) */
|
|
|
|
|
2015-02-06 23:44:29 +03:00
|
|
|
p = autoReconnectCookie->arcRandomBits;
|
|
|
|
|
2016-12-14 00:47:08 +03:00
|
|
|
WLog_DBG(TAG, "ServerAutoReconnectCookie: Version: %"PRIu32" LogonId: %"PRIu32" SecurityVerifier: "
|
|
|
|
"%02"PRIX8"%02"PRIX8"%02"PRIX8"%02"PRIX8"%02"PRIX8"%02"PRIX8"%02"PRIX8"%02"PRIX8""
|
|
|
|
"%02"PRIX8"%02"PRIX8"%02"PRIX8"%02"PRIX8"%02"PRIX8"%02"PRIX8"%02"PRIX8"%02"PRIX8"",
|
2015-02-06 23:44:29 +03:00
|
|
|
autoReconnectCookie->version, autoReconnectCookie->logonId,
|
2016-12-14 00:47:08 +03:00
|
|
|
p[0], p[1], p[2], p[3], p[4], p[5], p[6], p[7],
|
2015-02-06 23:44:29 +03:00
|
|
|
p[8], p[9], p[10], p[11], p[12], p[13], p[14], p[15]);
|
2015-02-06 22:21:26 +03:00
|
|
|
|
2016-02-18 16:19:36 +03:00
|
|
|
info->LogonId = autoReconnectCookie->logonId;
|
|
|
|
CopyMemory(info->ArcRandomBits, p, 16);
|
|
|
|
|
2013-10-22 19:14:29 +04:00
|
|
|
if ((settings->PrintReconnectCookie) && (autoReconnectCookie->cbLen > 0))
|
|
|
|
{
|
2015-02-06 22:21:26 +03:00
|
|
|
char* base64;
|
|
|
|
base64 = crypto_base64_encode((BYTE*) autoReconnectCookie, sizeof(ARC_SC_PRIVATE_PACKET));
|
|
|
|
WLog_INFO(TAG, "Reconnect-cookie: %s", base64);
|
2013-10-22 19:14:29 +04:00
|
|
|
free(base64);
|
|
|
|
}
|
2015-02-06 22:21:26 +03:00
|
|
|
|
2013-01-11 04:18:11 +04:00
|
|
|
return TRUE;
|
2011-07-25 21:42:14 +04:00
|
|
|
}
|
|
|
|
|
2011-08-20 14:22:14 +04:00
|
|
|
/**
|
|
|
|
* Read Client Auto Reconnect Cookie (ARC_CS_PRIVATE_PACKET).\n
|
|
|
|
* @msdn{cc240541}
|
|
|
|
* @param s stream
|
|
|
|
* @param settings settings
|
|
|
|
*/
|
|
|
|
|
2015-02-07 00:55:21 +03:00
|
|
|
BOOL rdp_read_client_auto_reconnect_cookie(rdpRdp* rdp, wStream* s)
|
2011-08-20 14:22:14 +04:00
|
|
|
{
|
|
|
|
ARC_CS_PRIVATE_PACKET* autoReconnectCookie;
|
2015-02-07 00:55:21 +03:00
|
|
|
rdpSettings* settings = rdp->settings;
|
|
|
|
|
2012-11-08 00:13:14 +04:00
|
|
|
autoReconnectCookie = settings->ClientAutoReconnectCookie;
|
2011-08-20 14:22:14 +04:00
|
|
|
|
2013-04-30 06:35:15 +04:00
|
|
|
if (Stream_GetRemainingLength(s) < 28)
|
2012-10-09 10:31:28 +04:00
|
|
|
return FALSE;
|
2011-08-20 14:22:14 +04:00
|
|
|
|
2013-05-09 00:09:16 +04:00
|
|
|
Stream_Read_UINT32(s, autoReconnectCookie->cbLen); /* cbLen (4 bytes) */
|
|
|
|
Stream_Read_UINT32(s, autoReconnectCookie->version); /* version (4 bytes) */
|
|
|
|
Stream_Read_UINT32(s, autoReconnectCookie->logonId); /* LogonId (4 bytes) */
|
|
|
|
Stream_Read(s, autoReconnectCookie->securityVerifier, 16); /* SecurityVerifier */
|
2011-08-20 14:22:14 +04:00
|
|
|
|
2012-10-09 10:31:28 +04:00
|
|
|
return TRUE;
|
2011-08-20 14:22:14 +04:00
|
|
|
}
|
|
|
|
|
2011-07-25 21:42:14 +04:00
|
|
|
/**
|
|
|
|
* Write Client Auto Reconnect Cookie (ARC_CS_PRIVATE_PACKET).\n
|
2011-07-12 02:46:36 +04:00
|
|
|
* @msdn{cc240541}
|
|
|
|
* @param s stream
|
|
|
|
* @param settings settings
|
|
|
|
*/
|
|
|
|
|
2015-02-07 00:55:21 +03:00
|
|
|
void rdp_write_client_auto_reconnect_cookie(rdpRdp* rdp, wStream* s)
|
2011-07-12 02:46:36 +04:00
|
|
|
{
|
2015-02-06 23:44:29 +03:00
|
|
|
BYTE* p;
|
2011-07-12 02:46:36 +04:00
|
|
|
ARC_CS_PRIVATE_PACKET* autoReconnectCookie;
|
2015-02-07 00:55:21 +03:00
|
|
|
rdpSettings* settings = rdp->settings;
|
2014-08-11 19:23:23 +04:00
|
|
|
|
2015-02-07 00:37:28 +03:00
|
|
|
autoReconnectCookie = settings->ClientAutoReconnectCookie;
|
2014-08-11 19:23:23 +04:00
|
|
|
|
2015-02-07 00:37:28 +03:00
|
|
|
p = autoReconnectCookie->securityVerifier;
|
2015-02-06 23:44:29 +03:00
|
|
|
|
2016-12-14 00:47:08 +03:00
|
|
|
WLog_DBG(TAG, "ClientAutoReconnectCookie: Version: %"PRIu32" LogonId: %"PRIu32" ArcRandomBits: "
|
|
|
|
"%02"PRIX8"%02"PRIX8"%02"PRIX8"%02"PRIX8"%02"PRIX8"%02"PRIX8"%02"PRIX8"%02"PRIX8""
|
|
|
|
"%02"PRIX8"%02"PRIX8"%02"PRIX8"%02"PRIX8"%02"PRIX8"%02"PRIX8"%02"PRIX8"%02"PRIX8"",
|
2015-02-06 23:44:29 +03:00
|
|
|
autoReconnectCookie->version, autoReconnectCookie->logonId,
|
2016-12-14 00:47:08 +03:00
|
|
|
p[0], p[1], p[2], p[3], p[4], p[5], p[6], p[7],
|
2015-02-06 23:44:29 +03:00
|
|
|
p[8], p[9], p[10], p[11], p[12], p[13], p[14], p[15]);
|
|
|
|
|
2013-05-09 00:09:16 +04:00
|
|
|
Stream_Write_UINT32(s, autoReconnectCookie->cbLen); /* cbLen (4 bytes) */
|
|
|
|
Stream_Write_UINT32(s, autoReconnectCookie->version); /* version (4 bytes) */
|
|
|
|
Stream_Write_UINT32(s, autoReconnectCookie->logonId); /* LogonId (4 bytes) */
|
2015-02-07 00:37:28 +03:00
|
|
|
Stream_Write(s, autoReconnectCookie->securityVerifier, 16); /* SecurityVerifier (16 bytes) */
|
2011-07-12 02:46:36 +04:00
|
|
|
}
|
|
|
|
|
2011-08-20 14:22:14 +04:00
|
|
|
/**
|
|
|
|
* Read Extended Info Packet (TS_EXTENDED_INFO_PACKET).\n
|
|
|
|
* @msdn{cc240476}
|
|
|
|
* @param s stream
|
|
|
|
* @param settings settings
|
|
|
|
*/
|
|
|
|
|
2015-02-07 00:55:21 +03:00
|
|
|
BOOL rdp_read_extended_info_packet(rdpRdp* rdp, wStream* s)
|
2011-08-20 14:22:14 +04:00
|
|
|
{
|
2012-10-09 11:01:37 +04:00
|
|
|
UINT16 clientAddressFamily;
|
|
|
|
UINT16 cbClientAddress;
|
|
|
|
UINT16 cbClientDir;
|
|
|
|
UINT16 cbAutoReconnectLen;
|
2015-02-07 00:55:21 +03:00
|
|
|
rdpSettings* settings = rdp->settings;
|
2016-03-03 18:21:12 +03:00
|
|
|
WCHAR* wstr;
|
2011-08-20 14:22:14 +04:00
|
|
|
|
2013-04-30 06:35:15 +04:00
|
|
|
if (Stream_GetRemainingLength(s) < 4)
|
2013-01-11 04:18:11 +04:00
|
|
|
return FALSE;
|
2013-09-06 02:53:55 +04:00
|
|
|
|
2015-02-07 00:55:21 +03:00
|
|
|
Stream_Read_UINT16(s, clientAddressFamily); /* clientAddressFamily (2 bytes) */
|
|
|
|
Stream_Read_UINT16(s, cbClientAddress); /* cbClientAddress (2 bytes) */
|
2011-08-20 14:22:14 +04:00
|
|
|
|
2016-03-03 18:21:12 +03:00
|
|
|
/* cbClientAddress is the size in bytes of the character data in the clientAddress field.
|
|
|
|
* This size includes the length of the mandatory null terminator.
|
|
|
|
* The maximum allowed value is 80 bytes
|
2016-04-19 15:09:58 +03:00
|
|
|
* Note: Although according to [MS-RDPBCGR 2.2.1.11.1.1.1] the null terminator
|
|
|
|
* is mandatory, connections via Microsoft's TS Gateway set cbClientAddress to 0.
|
2016-03-03 18:21:12 +03:00
|
|
|
*/
|
|
|
|
|
2016-04-19 15:09:58 +03:00
|
|
|
if ((cbClientAddress % 2) || cbClientAddress > 80)
|
2016-03-03 18:21:12 +03:00
|
|
|
{
|
2016-12-14 00:47:08 +03:00
|
|
|
WLog_ERR(TAG, "protocol error: invalid cbClientAddress value: %"PRIu16"", cbClientAddress);
|
2016-03-03 18:21:12 +03:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2012-11-08 03:23:25 +04:00
|
|
|
settings->IPv6Enabled = (clientAddressFamily == ADDRESS_FAMILY_INET6 ? TRUE : FALSE);
|
2012-09-24 04:11:50 +04:00
|
|
|
|
2013-04-30 06:35:15 +04:00
|
|
|
if (Stream_GetRemainingLength(s) < cbClientAddress)
|
2012-10-09 10:31:28 +04:00
|
|
|
return FALSE;
|
2012-09-24 04:11:50 +04:00
|
|
|
|
2013-11-01 07:35:24 +04:00
|
|
|
if (settings->ClientAddress)
|
|
|
|
{
|
|
|
|
free(settings->ClientAddress);
|
|
|
|
settings->ClientAddress = NULL;
|
|
|
|
}
|
|
|
|
|
2016-04-19 15:09:58 +03:00
|
|
|
if (cbClientAddress)
|
2016-03-03 18:21:12 +03:00
|
|
|
{
|
2016-04-19 15:09:58 +03:00
|
|
|
wstr = (WCHAR*) Stream_Pointer(s);
|
|
|
|
if (wstr[cbClientAddress / 2 - 1])
|
|
|
|
{
|
|
|
|
WLog_ERR(TAG, "protocol error: clientAddress must be null terminated");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
if (ConvertFromUnicode(CP_UTF8, 0, wstr, -1, &settings->ClientAddress, 0, NULL, NULL) < 1)
|
|
|
|
{
|
|
|
|
WLog_ERR(TAG, "failed to convert client address");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
Stream_Seek(s, cbClientAddress);
|
|
|
|
WLog_DBG(TAG, "rdp client address: [%s]", settings->ClientAddress);
|
2016-03-03 18:21:12 +03:00
|
|
|
}
|
2011-08-20 14:22:14 +04:00
|
|
|
|
2013-04-30 06:35:15 +04:00
|
|
|
if (Stream_GetRemainingLength(s) < 2)
|
2013-01-11 04:18:11 +04:00
|
|
|
return FALSE;
|
2013-11-01 07:35:24 +04:00
|
|
|
|
2015-02-07 00:55:21 +03:00
|
|
|
Stream_Read_UINT16(s, cbClientDir); /* cbClientDir (2 bytes) */
|
2012-09-24 04:11:50 +04:00
|
|
|
|
2016-03-03 18:21:12 +03:00
|
|
|
/* cbClientDir is the size in bytes of the character data in the clientDir field.
|
|
|
|
* This size includes the length of the mandatory null terminator.
|
2016-04-11 11:50:27 +03:00
|
|
|
* The maximum allowed value is 512 bytes.
|
|
|
|
* Note: Although according to [MS-RDPBCGR 2.2.1.11.1.1.1] the null terminator
|
|
|
|
* is mandatory the Microsoft Android client (starting with version 8.1.31.44)
|
|
|
|
* sets cbClientDir to 0.
|
2016-03-03 18:21:12 +03:00
|
|
|
*/
|
|
|
|
|
2016-04-11 11:50:27 +03:00
|
|
|
if ((cbClientDir % 2) || cbClientDir > 512)
|
2016-03-03 18:21:12 +03:00
|
|
|
{
|
2016-12-14 00:47:08 +03:00
|
|
|
WLog_ERR(TAG, "protocol error: invalid cbClientDir value: %"PRIu16"", cbClientDir);
|
2016-03-03 18:21:12 +03:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2013-04-30 06:35:15 +04:00
|
|
|
if (Stream_GetRemainingLength(s) < cbClientDir)
|
2012-10-09 10:31:28 +04:00
|
|
|
return FALSE;
|
2012-09-24 04:11:50 +04:00
|
|
|
|
2012-11-08 03:23:25 +04:00
|
|
|
if (settings->ClientDir)
|
2013-11-01 07:35:24 +04:00
|
|
|
{
|
2012-11-08 03:23:25 +04:00
|
|
|
free(settings->ClientDir);
|
2013-11-01 07:35:24 +04:00
|
|
|
settings->ClientDir = NULL;
|
|
|
|
}
|
2012-09-24 04:11:50 +04:00
|
|
|
|
2016-04-11 11:50:27 +03:00
|
|
|
if (cbClientDir)
|
2016-03-03 18:21:12 +03:00
|
|
|
{
|
2016-04-11 11:50:27 +03:00
|
|
|
wstr = (WCHAR*) Stream_Pointer(s);
|
|
|
|
if (wstr[cbClientDir / 2 - 1])
|
|
|
|
{
|
|
|
|
WLog_ERR(TAG, "protocol error: clientDir must be null terminated");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
if (ConvertFromUnicode(CP_UTF8, 0, (WCHAR*) Stream_Pointer(s), -1, &settings->ClientDir, 0, NULL, NULL) < 1)
|
|
|
|
{
|
|
|
|
WLog_ERR(TAG, "failed to convert client directory");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
Stream_Seek(s, cbClientDir);
|
|
|
|
WLog_DBG(TAG, "rdp client dir: [%s]", settings->ClientDir);
|
2016-03-03 18:21:12 +03:00
|
|
|
}
|
2011-08-20 14:22:14 +04:00
|
|
|
|
2016-06-27 11:56:40 +03:00
|
|
|
/**
|
|
|
|
* down below all fields are optional but if one field is not present,
|
|
|
|
* then all of the subsequent fields also MUST NOT be present.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* optional: clientTimeZone (172 bytes) */
|
|
|
|
if (Stream_GetRemainingLength(s) == 0)
|
|
|
|
return TRUE;
|
2011-08-20 14:22:14 +04:00
|
|
|
if (!rdp_read_client_time_zone(s, settings))
|
2012-10-09 10:31:28 +04:00
|
|
|
return FALSE;
|
2011-08-20 14:22:14 +04:00
|
|
|
|
2016-06-27 11:56:40 +03:00
|
|
|
/* optional: clientSessionId (4 bytes), should be set to 0 */
|
|
|
|
if (Stream_GetRemainingLength(s) == 0)
|
|
|
|
return TRUE;
|
|
|
|
if (Stream_GetRemainingLength(s) < 4)
|
2013-01-11 04:18:11 +04:00
|
|
|
return FALSE;
|
2016-06-27 11:56:40 +03:00
|
|
|
Stream_Seek_UINT32(s);
|
2013-09-06 02:53:55 +04:00
|
|
|
|
2016-06-27 11:56:40 +03:00
|
|
|
/* optional: performanceFlags (4 bytes) */
|
|
|
|
if (Stream_GetRemainingLength(s) == 0)
|
|
|
|
return TRUE;
|
|
|
|
if (Stream_GetRemainingLength(s) < 4)
|
|
|
|
return FALSE;
|
|
|
|
Stream_Read_UINT32(s, settings->PerformanceFlags);
|
2013-09-17 22:56:23 +04:00
|
|
|
freerdp_performance_flags_split(settings);
|
2011-08-20 14:22:14 +04:00
|
|
|
|
2016-06-27 11:56:40 +03:00
|
|
|
/* optional: cbAutoReconnectLen (2 bytes) */
|
|
|
|
if (Stream_GetRemainingLength(s) == 0)
|
|
|
|
return TRUE;
|
|
|
|
if (Stream_GetRemainingLength(s) < 2)
|
|
|
|
return FALSE;
|
|
|
|
Stream_Read_UINT16(s, cbAutoReconnectLen);
|
2011-08-20 14:22:14 +04:00
|
|
|
|
2016-06-27 11:56:40 +03:00
|
|
|
/* optional: autoReconnectCookie (28 bytes) */
|
|
|
|
/* must be present if cbAutoReconnectLen is > 0 */
|
2011-08-20 14:22:14 +04:00
|
|
|
if (cbAutoReconnectLen > 0)
|
2016-06-27 11:56:40 +03:00
|
|
|
return rdp_read_client_auto_reconnect_cookie(rdp, s);
|
|
|
|
|
|
|
|
/* TODO */
|
2011-08-20 14:22:14 +04:00
|
|
|
|
|
|
|
/* reserved1 (2 bytes) */
|
|
|
|
/* reserved2 (2 bytes) */
|
2016-06-27 11:56:40 +03:00
|
|
|
/* cbDynamicDSTTimeZoneKeyName (2 bytes) */
|
|
|
|
/* dynamicDSTTimeZoneKeyName (variable) */
|
|
|
|
/* dynamicDaylightTimeDisabled (2 bytes) */
|
2011-08-20 14:22:14 +04:00
|
|
|
|
2012-10-09 10:31:28 +04:00
|
|
|
return TRUE;
|
2011-08-20 14:22:14 +04:00
|
|
|
}
|
|
|
|
|
2011-07-12 02:46:36 +04:00
|
|
|
/**
|
|
|
|
* Write Extended Info Packet (TS_EXTENDED_INFO_PACKET).\n
|
|
|
|
* @msdn{cc240476}
|
|
|
|
* @param s stream
|
|
|
|
* @param settings settings
|
|
|
|
*/
|
|
|
|
|
2015-02-07 00:55:21 +03:00
|
|
|
void rdp_write_extended_info_packet(rdpRdp* rdp, wStream* s)
|
2011-07-12 02:46:36 +04:00
|
|
|
{
|
2012-09-24 03:49:13 +04:00
|
|
|
int clientAddressFamily;
|
2013-01-11 00:30:32 +04:00
|
|
|
WCHAR* clientAddress = NULL;
|
2012-09-24 03:49:13 +04:00
|
|
|
int cbClientAddress;
|
2013-01-11 00:30:32 +04:00
|
|
|
WCHAR* clientDir = NULL;
|
2012-09-24 03:49:13 +04:00
|
|
|
int cbClientDir;
|
2015-02-07 00:37:28 +03:00
|
|
|
int cbAutoReconnectCookie;
|
2015-02-07 00:55:21 +03:00
|
|
|
rdpSettings* settings = rdp->settings;
|
2011-07-12 02:46:36 +04:00
|
|
|
|
2012-11-08 03:23:25 +04:00
|
|
|
clientAddressFamily = settings->IPv6Enabled ? ADDRESS_FAMILY_INET6 : ADDRESS_FAMILY_INET;
|
2011-07-12 02:46:36 +04:00
|
|
|
|
2012-12-17 19:20:25 +04:00
|
|
|
cbClientAddress = ConvertToUnicode(CP_UTF8, 0, settings->ClientAddress, -1, &clientAddress, 0) * 2;
|
2011-07-12 02:46:36 +04:00
|
|
|
|
2012-12-17 19:20:25 +04:00
|
|
|
cbClientDir = ConvertToUnicode(CP_UTF8, 0, settings->ClientDir, -1, &clientDir, 0) * 2;
|
2011-07-12 02:46:36 +04:00
|
|
|
|
2015-02-07 00:37:28 +03:00
|
|
|
cbAutoReconnectCookie = (int) settings->ServerAutoReconnectCookie->cbLen;
|
2011-07-12 02:46:36 +04:00
|
|
|
|
2015-02-06 22:21:26 +03:00
|
|
|
Stream_Write_UINT16(s, clientAddressFamily); /* clientAddressFamily (2 bytes) */
|
2011-07-12 02:46:36 +04:00
|
|
|
|
2015-02-06 22:21:26 +03:00
|
|
|
Stream_Write_UINT16(s, cbClientAddress + 2); /* cbClientAddress (2 bytes) */
|
2011-07-12 02:46:36 +04:00
|
|
|
|
|
|
|
if (cbClientAddress > 0)
|
2013-05-09 00:09:16 +04:00
|
|
|
Stream_Write(s, clientAddress, cbClientAddress); /* clientAddress */
|
|
|
|
Stream_Write_UINT16(s, 0);
|
2011-07-12 02:46:36 +04:00
|
|
|
|
2015-02-06 22:21:26 +03:00
|
|
|
Stream_Write_UINT16(s, cbClientDir + 2); /* cbClientDir (2 bytes) */
|
2011-07-12 02:46:36 +04:00
|
|
|
|
|
|
|
if (cbClientDir > 0)
|
2013-05-09 00:09:16 +04:00
|
|
|
Stream_Write(s, clientDir, cbClientDir); /* clientDir */
|
|
|
|
Stream_Write_UINT16(s, 0);
|
2011-07-12 02:46:36 +04:00
|
|
|
|
2015-02-06 22:21:26 +03:00
|
|
|
rdp_write_client_time_zone(s, settings); /* clientTimeZone (172 bytes) */
|
2011-07-12 02:46:36 +04:00
|
|
|
|
2015-02-06 22:21:26 +03:00
|
|
|
Stream_Write_UINT32(s, 0); /* clientSessionId (4 bytes), should be set to 0 */
|
2013-09-17 22:56:23 +04:00
|
|
|
|
|
|
|
freerdp_performance_flags_make(settings);
|
2015-02-06 22:21:26 +03:00
|
|
|
Stream_Write_UINT32(s, settings->PerformanceFlags); /* performanceFlags (4 bytes) */
|
2011-07-12 02:46:36 +04:00
|
|
|
|
2015-02-07 00:37:28 +03:00
|
|
|
Stream_Write_UINT16(s, cbAutoReconnectCookie); /* cbAutoReconnectCookie (2 bytes) */
|
2011-07-12 02:46:36 +04:00
|
|
|
|
2015-02-07 00:37:28 +03:00
|
|
|
if (cbAutoReconnectCookie > 0)
|
2013-10-22 19:14:29 +04:00
|
|
|
{
|
2015-02-07 00:55:21 +03:00
|
|
|
rdp_compute_client_auto_reconnect_cookie(rdp);
|
2015-02-06 22:21:26 +03:00
|
|
|
|
2015-02-07 00:55:21 +03:00
|
|
|
rdp_write_client_auto_reconnect_cookie(rdp, s); /* autoReconnectCookie */
|
2015-02-06 22:21:26 +03:00
|
|
|
|
|
|
|
Stream_Write_UINT16(s, 0); /* reserved1 (2 bytes) */
|
|
|
|
Stream_Write_UINT16(s, 0); /* reserved2 (2 bytes) */
|
2013-10-22 19:14:29 +04:00
|
|
|
}
|
2011-07-12 02:46:36 +04:00
|
|
|
|
2012-10-09 07:21:26 +04:00
|
|
|
free(clientAddress);
|
|
|
|
free(clientDir);
|
2011-07-12 02:46:36 +04:00
|
|
|
}
|
|
|
|
|
2011-08-20 14:22:14 +04:00
|
|
|
/**
|
|
|
|
* Read Info Packet (TS_INFO_PACKET).\n
|
|
|
|
* @msdn{cc240475}
|
|
|
|
* @param s stream
|
|
|
|
* @param settings settings
|
|
|
|
*/
|
|
|
|
|
2015-02-07 00:55:21 +03:00
|
|
|
BOOL rdp_read_info_packet(rdpRdp* rdp, wStream* s)
|
2011-08-20 14:22:14 +04:00
|
|
|
{
|
2012-10-09 11:26:39 +04:00
|
|
|
UINT32 flags;
|
2012-10-09 11:01:37 +04:00
|
|
|
UINT16 cbDomain;
|
|
|
|
UINT16 cbUserName;
|
|
|
|
UINT16 cbPassword;
|
|
|
|
UINT16 cbAlternateShell;
|
|
|
|
UINT16 cbWorkingDir;
|
2014-03-10 19:16:36 +04:00
|
|
|
UINT32 CompressionLevel;
|
2015-02-07 00:55:21 +03:00
|
|
|
rdpSettings* settings = rdp->settings;
|
2016-03-03 18:21:12 +03:00
|
|
|
WCHAR* wstr;
|
2011-08-20 14:22:14 +04:00
|
|
|
|
2014-03-10 19:16:36 +04:00
|
|
|
if (Stream_GetRemainingLength(s) < 18)
|
2013-01-11 04:18:11 +04:00
|
|
|
return FALSE;
|
|
|
|
|
2015-02-07 00:55:21 +03:00
|
|
|
Stream_Seek_UINT32(s); /* CodePage (4 bytes ) */
|
|
|
|
Stream_Read_UINT32(s, flags); /* flags (4 bytes) */
|
2011-08-20 14:22:14 +04:00
|
|
|
|
2013-10-10 06:38:26 +04:00
|
|
|
settings->AudioCapture = ((flags & INFO_AUDIOCAPTURE) ? TRUE : FALSE);
|
2013-05-24 00:35:24 +04:00
|
|
|
settings->AudioPlayback = ((flags & INFO_NOAUDIOPLAYBACK) ? FALSE : TRUE);
|
2012-11-08 03:23:25 +04:00
|
|
|
settings->AutoLogonEnabled = ((flags & INFO_AUTOLOGON) ? TRUE : FALSE);
|
2012-11-08 00:13:14 +04:00
|
|
|
settings->RemoteApplicationMode = ((flags & INFO_RAIL) ? TRUE : FALSE);
|
2012-11-08 03:23:25 +04:00
|
|
|
settings->RemoteConsoleAudio = ((flags & INFO_REMOTECONSOLEAUDIO) ? TRUE : FALSE);
|
|
|
|
settings->CompressionEnabled = ((flags & INFO_COMPRESSION) ? TRUE : FALSE);
|
2011-08-20 14:22:14 +04:00
|
|
|
|
2014-03-10 19:16:36 +04:00
|
|
|
if (flags & INFO_COMPRESSION)
|
|
|
|
{
|
|
|
|
CompressionLevel = ((flags & 0x00001E00) >> 9);
|
|
|
|
settings->CompressionLevel = CompressionLevel;
|
|
|
|
}
|
|
|
|
|
2016-03-03 18:21:12 +03:00
|
|
|
if (!(flags & INFO_UNICODE))
|
|
|
|
{
|
|
|
|
WLog_ERR(TAG, "Client without INFO_UNICODE flag: this is currently not supported");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2015-02-07 00:37:28 +03:00
|
|
|
Stream_Read_UINT16(s, cbDomain); /* cbDomain (2 bytes) */
|
|
|
|
Stream_Read_UINT16(s, cbUserName); /* cbUserName (2 bytes) */
|
|
|
|
Stream_Read_UINT16(s, cbPassword); /* cbPassword (2 bytes) */
|
|
|
|
Stream_Read_UINT16(s, cbAlternateShell); /* cbAlternateShell (2 bytes) */
|
|
|
|
Stream_Read_UINT16(s, cbWorkingDir); /* cbWorkingDir (2 bytes) */
|
2011-08-20 14:22:14 +04:00
|
|
|
|
2014-02-11 07:12:13 +04:00
|
|
|
if (Stream_GetRemainingLength(s) < (size_t) (cbDomain + 2))
|
2012-10-09 10:31:28 +04:00
|
|
|
return FALSE;
|
2012-09-24 04:11:50 +04:00
|
|
|
|
2011-08-20 14:22:14 +04:00
|
|
|
if (cbDomain > 0)
|
|
|
|
{
|
2016-03-03 18:21:12 +03:00
|
|
|
/* cbDomain is the size in bytes of the character data in the Domain field.
|
|
|
|
* This size excludes (!) the length of the mandatory null terminator.
|
|
|
|
* Maximum value including the mandatory null terminator: 512
|
|
|
|
*/
|
|
|
|
if ((cbDomain % 2) || cbDomain > 512)
|
|
|
|
{
|
2016-12-14 00:47:08 +03:00
|
|
|
WLog_ERR(TAG, "protocol error: invalid cbDomain value: %"PRIu16"", cbDomain);
|
2016-03-03 18:21:12 +03:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
wstr = (WCHAR*) Stream_Pointer(s);
|
|
|
|
if (wstr[cbDomain / 2])
|
|
|
|
{
|
|
|
|
WLog_ERR(TAG, "protocol error: Domain must be null terminated");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
if (ConvertFromUnicode(CP_UTF8, 0, wstr, -1, &settings->Domain, 0, NULL, NULL) < 1)
|
|
|
|
{
|
|
|
|
WLog_ERR(TAG, "failed to convert Domain string");
|
|
|
|
return FALSE;
|
|
|
|
}
|
2013-04-30 06:35:15 +04:00
|
|
|
Stream_Seek(s, cbDomain);
|
2011-08-20 14:22:14 +04:00
|
|
|
}
|
2013-04-30 06:35:15 +04:00
|
|
|
Stream_Seek(s, 2);
|
2011-08-20 14:22:14 +04:00
|
|
|
|
2014-02-11 07:12:13 +04:00
|
|
|
if (Stream_GetRemainingLength(s) < (size_t) (cbUserName + 2))
|
2012-10-09 10:31:28 +04:00
|
|
|
return FALSE;
|
2012-09-24 04:11:50 +04:00
|
|
|
|
2011-08-20 14:22:14 +04:00
|
|
|
if (cbUserName > 0)
|
|
|
|
{
|
2016-03-03 18:21:12 +03:00
|
|
|
/* cbUserName is the size in bytes of the character data in the UserName field.
|
|
|
|
* This size excludes (!) the length of the mandatory null terminator.
|
|
|
|
* Maximum value including the mandatory null terminator: 512
|
|
|
|
*/
|
|
|
|
if ((cbUserName % 2) || cbUserName > 512)
|
|
|
|
{
|
2016-12-14 00:47:08 +03:00
|
|
|
WLog_ERR(TAG, "protocol error: invalid cbUserName value: %"PRIu16"", cbUserName);
|
2016-03-03 18:21:12 +03:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
wstr = (WCHAR*) Stream_Pointer(s);
|
|
|
|
if (wstr[cbUserName / 2])
|
|
|
|
{
|
|
|
|
WLog_ERR(TAG, "protocol error: UserName must be null terminated");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
if (ConvertFromUnicode(CP_UTF8, 0, wstr, -1, &settings->Username, 0, NULL, NULL) < 1)
|
|
|
|
{
|
|
|
|
WLog_ERR(TAG, "failed to convert UserName string");
|
|
|
|
return FALSE;
|
|
|
|
}
|
2013-04-30 06:35:15 +04:00
|
|
|
Stream_Seek(s, cbUserName);
|
2011-08-20 14:22:14 +04:00
|
|
|
}
|
2013-04-30 06:35:15 +04:00
|
|
|
Stream_Seek(s, 2);
|
2011-08-20 14:22:14 +04:00
|
|
|
|
2014-02-11 07:12:13 +04:00
|
|
|
if (Stream_GetRemainingLength(s) < (size_t) (cbPassword + 2))
|
2012-10-09 10:31:28 +04:00
|
|
|
return FALSE;
|
2012-09-24 04:11:50 +04:00
|
|
|
|
2011-08-20 14:22:14 +04:00
|
|
|
if (cbPassword > 0)
|
|
|
|
{
|
2016-03-03 18:21:12 +03:00
|
|
|
/* cbPassword is the size in bytes of the character data in the Password field.
|
|
|
|
* This size excludes (!) the length of the mandatory null terminator.
|
|
|
|
* Maximum value including the mandatory null terminator: 512
|
|
|
|
*/
|
|
|
|
if ((cbPassword % 2) || cbPassword > 512)
|
|
|
|
{
|
2016-12-14 00:47:08 +03:00
|
|
|
WLog_ERR(TAG, "protocol error: invalid cbPassword value: %"PRIu16"", cbPassword);
|
2016-03-03 18:21:12 +03:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
wstr = (WCHAR*) Stream_Pointer(s);
|
|
|
|
if (wstr[cbPassword / 2])
|
|
|
|
{
|
|
|
|
WLog_ERR(TAG, "protocol error: Password must be null terminated");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
if (ConvertFromUnicode(CP_UTF8, 0, wstr, -1, &settings->Password, 0, NULL, NULL) < 1)
|
|
|
|
{
|
|
|
|
WLog_ERR(TAG, "failed to convert Password string");
|
|
|
|
return FALSE;
|
|
|
|
}
|
2013-04-30 06:35:15 +04:00
|
|
|
Stream_Seek(s, cbPassword);
|
2011-08-20 14:22:14 +04:00
|
|
|
}
|
2013-04-30 06:35:15 +04:00
|
|
|
Stream_Seek(s, 2);
|
2011-08-20 14:22:14 +04:00
|
|
|
|
2014-02-11 07:12:13 +04:00
|
|
|
if (Stream_GetRemainingLength(s) < (size_t) (cbAlternateShell + 2))
|
2012-10-09 10:31:28 +04:00
|
|
|
return FALSE;
|
2012-09-24 04:11:50 +04:00
|
|
|
|
2011-08-20 14:22:14 +04:00
|
|
|
if (cbAlternateShell > 0)
|
|
|
|
{
|
2016-03-03 18:21:12 +03:00
|
|
|
/* cbAlternateShell is the size in bytes of the character data in the AlternateShell field.
|
|
|
|
* This size excludes (!) the length of the mandatory null terminator.
|
|
|
|
* Maximum value including the mandatory null terminator: 512
|
|
|
|
*/
|
|
|
|
if ((cbAlternateShell % 2) || cbAlternateShell > 512)
|
|
|
|
{
|
2016-12-14 00:47:08 +03:00
|
|
|
WLog_ERR(TAG, "protocol error: invalid cbAlternateShell value: %"PRIu16"", cbAlternateShell);
|
2016-03-03 18:21:12 +03:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
wstr = (WCHAR*) Stream_Pointer(s);
|
|
|
|
if (wstr[cbAlternateShell / 2])
|
|
|
|
{
|
|
|
|
WLog_ERR(TAG, "protocol error: AlternateShell must be null terminated");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
if (ConvertFromUnicode(CP_UTF8, 0, wstr, -1, &settings->AlternateShell, 0, NULL, NULL) < 1)
|
|
|
|
{
|
|
|
|
WLog_ERR(TAG, "failed to convert AlternateShell string");
|
|
|
|
return FALSE;
|
|
|
|
}
|
2013-04-30 06:35:15 +04:00
|
|
|
Stream_Seek(s, cbAlternateShell);
|
2011-08-20 14:22:14 +04:00
|
|
|
}
|
2013-04-30 06:35:15 +04:00
|
|
|
Stream_Seek(s, 2);
|
2011-08-20 14:22:14 +04:00
|
|
|
|
2014-02-11 07:12:13 +04:00
|
|
|
if (Stream_GetRemainingLength(s) < (size_t) (cbWorkingDir + 2))
|
2012-10-09 10:31:28 +04:00
|
|
|
return FALSE;
|
2012-09-24 04:11:50 +04:00
|
|
|
|
2011-08-20 14:22:14 +04:00
|
|
|
if (cbWorkingDir > 0)
|
|
|
|
{
|
2016-03-03 18:21:12 +03:00
|
|
|
/* cbWorkingDir is the size in bytes of the character data in the WorkingDir field.
|
|
|
|
* This size excludes (!) the length of the mandatory null terminator.
|
|
|
|
* Maximum value including the mandatory null terminator: 512
|
|
|
|
*/
|
|
|
|
if ((cbWorkingDir % 2) || cbWorkingDir > 512)
|
|
|
|
{
|
2016-12-14 00:47:08 +03:00
|
|
|
WLog_ERR(TAG, "protocol error: invalid cbWorkingDir value: %"PRIu16"", cbWorkingDir);
|
2016-03-03 18:21:12 +03:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
wstr = (WCHAR*) Stream_Pointer(s);
|
|
|
|
if (wstr[cbWorkingDir / 2])
|
|
|
|
{
|
|
|
|
WLog_ERR(TAG, "protocol error: WorkingDir must be null terminated");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
if (ConvertFromUnicode(CP_UTF8, 0, wstr, -1, &settings->ShellWorkingDirectory, 0, NULL, NULL) < 1)
|
|
|
|
{
|
|
|
|
WLog_ERR(TAG, "failed to convert AlternateShell string");
|
|
|
|
return FALSE;
|
|
|
|
}
|
2013-04-30 06:35:15 +04:00
|
|
|
Stream_Seek(s, cbWorkingDir);
|
2011-08-20 14:22:14 +04:00
|
|
|
}
|
2013-04-30 06:35:15 +04:00
|
|
|
Stream_Seek(s, 2);
|
2011-08-20 14:22:14 +04:00
|
|
|
|
2012-11-07 19:33:06 +04:00
|
|
|
if (settings->RdpVersion >= 5)
|
2015-02-07 00:55:21 +03:00
|
|
|
return rdp_read_extended_info_packet(rdp, s); /* extraInfo */
|
2011-08-20 14:22:14 +04:00
|
|
|
|
2012-10-09 10:31:28 +04:00
|
|
|
return TRUE;
|
2011-08-20 14:22:14 +04:00
|
|
|
}
|
|
|
|
|
2011-07-12 02:46:36 +04:00
|
|
|
/**
|
|
|
|
* Write Info Packet (TS_INFO_PACKET).\n
|
|
|
|
* @msdn{cc240475}
|
|
|
|
* @param s stream
|
|
|
|
* @param settings settings
|
|
|
|
*/
|
|
|
|
|
2015-02-07 00:55:21 +03:00
|
|
|
void rdp_write_info_packet(rdpRdp* rdp, wStream* s)
|
2011-07-12 02:46:36 +04:00
|
|
|
{
|
2012-10-09 11:26:39 +04:00
|
|
|
UINT32 flags;
|
2014-06-29 02:33:46 +04:00
|
|
|
WCHAR* domainW = NULL;
|
2012-12-17 19:20:25 +04:00
|
|
|
int cbDomain = 0;
|
2014-06-29 02:33:46 +04:00
|
|
|
WCHAR* userNameW = NULL;
|
2012-12-17 19:20:25 +04:00
|
|
|
int cbUserName = 0;
|
2014-06-29 02:33:46 +04:00
|
|
|
WCHAR* passwordW = NULL;
|
2012-12-17 19:20:25 +04:00
|
|
|
int cbPassword = 0;
|
2014-06-29 02:33:46 +04:00
|
|
|
WCHAR* alternateShellW = NULL;
|
2012-12-17 19:20:25 +04:00
|
|
|
int cbAlternateShell = 0;
|
2014-06-29 02:33:46 +04:00
|
|
|
WCHAR* workingDirW = NULL;
|
2012-12-17 19:20:25 +04:00
|
|
|
int cbWorkingDir = 0;
|
2012-10-09 10:38:39 +04:00
|
|
|
BOOL usedPasswordCookie = FALSE;
|
2015-02-07 00:55:21 +03:00
|
|
|
rdpSettings* settings = rdp->settings;
|
2011-07-12 02:46:36 +04:00
|
|
|
|
|
|
|
flags = INFO_MOUSE |
|
|
|
|
INFO_UNICODE |
|
|
|
|
INFO_LOGONERRORS |
|
|
|
|
INFO_LOGONNOTIFY |
|
|
|
|
INFO_MAXIMIZESHELL |
|
|
|
|
INFO_ENABLEWINDOWSKEY |
|
2012-03-13 13:05:14 +04:00
|
|
|
INFO_DISABLECTRLALTDEL;
|
|
|
|
|
2012-11-08 00:13:14 +04:00
|
|
|
if (settings->AudioCapture)
|
2013-10-10 06:38:26 +04:00
|
|
|
flags |= INFO_AUDIOCAPTURE;
|
2012-03-13 13:05:14 +04:00
|
|
|
|
2012-11-08 00:13:14 +04:00
|
|
|
if (!settings->AudioPlayback)
|
2012-03-13 13:05:14 +04:00
|
|
|
flags |= INFO_NOAUDIOPLAYBACK;
|
2011-07-12 02:46:36 +04:00
|
|
|
|
2013-10-10 06:38:26 +04:00
|
|
|
if (settings->VideoDisable)
|
|
|
|
flags |= INFO_VIDEO_DISABLE;
|
|
|
|
|
2012-11-08 03:23:25 +04:00
|
|
|
if (settings->AutoLogonEnabled)
|
2011-07-12 02:46:36 +04:00
|
|
|
flags |= INFO_AUTOLOGON;
|
|
|
|
|
2012-11-08 00:13:14 +04:00
|
|
|
if (settings->RemoteApplicationMode)
|
2011-08-08 23:06:07 +04:00
|
|
|
flags |= INFO_RAIL;
|
|
|
|
|
2012-11-08 03:23:25 +04:00
|
|
|
if (settings->RemoteConsoleAudio)
|
2011-07-12 02:46:36 +04:00
|
|
|
flags |= INFO_REMOTECONSOLEAUDIO;
|
|
|
|
|
2014-07-29 00:47:42 +04:00
|
|
|
if (settings->HiDefRemoteApp)
|
|
|
|
flags |= INFO_HIDEF_RAIL_SUPPORTED;
|
|
|
|
|
2012-11-08 03:23:25 +04:00
|
|
|
if (settings->CompressionEnabled)
|
2014-03-10 19:16:36 +04:00
|
|
|
{
|
|
|
|
flags |= INFO_COMPRESSION;
|
|
|
|
flags |= ((settings->CompressionLevel << 9) & 0x00001E00);
|
|
|
|
}
|
2011-07-12 02:46:36 +04:00
|
|
|
|
2012-11-08 00:13:14 +04:00
|
|
|
if (settings->Domain)
|
2012-09-24 03:49:13 +04:00
|
|
|
{
|
2014-06-29 02:33:46 +04:00
|
|
|
cbDomain = ConvertToUnicode(CP_UTF8, 0, settings->Domain, -1, &domainW, 0) * 2;
|
2012-09-24 03:49:13 +04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2014-06-29 02:33:46 +04:00
|
|
|
domainW = NULL;
|
2012-09-24 03:49:13 +04:00
|
|
|
cbDomain = 0;
|
|
|
|
}
|
2011-07-12 02:46:36 +04:00
|
|
|
|
2014-06-29 02:33:46 +04:00
|
|
|
if (!settings->RemoteAssistanceMode)
|
|
|
|
{
|
|
|
|
cbUserName = ConvertToUnicode(CP_UTF8, 0, settings->Username, -1, &userNameW, 0) * 2;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* user name provided by the expert for connecting to the novice computer */
|
|
|
|
cbUserName = ConvertToUnicode(CP_UTF8, 0, settings->Username, -1, &userNameW, 0) * 2;
|
|
|
|
}
|
2011-07-12 02:46:36 +04:00
|
|
|
|
2014-06-29 02:33:46 +04:00
|
|
|
if (!settings->RemoteAssistanceMode)
|
2012-01-31 05:54:46 +04:00
|
|
|
{
|
2014-06-29 02:33:46 +04:00
|
|
|
if (settings->RedirectionPassword && settings->RedirectionPasswordLength > 0)
|
|
|
|
{
|
|
|
|
usedPasswordCookie = TRUE;
|
|
|
|
passwordW = (WCHAR*) settings->RedirectionPassword;
|
|
|
|
cbPassword = settings->RedirectionPasswordLength - 2; /* Strip double zero termination */
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
cbPassword = ConvertToUnicode(CP_UTF8, 0, settings->Password, -1, &passwordW, 0) * 2;
|
|
|
|
}
|
2012-01-31 05:54:46 +04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2014-06-29 02:33:46 +04:00
|
|
|
/* This field MUST be filled with "*" */
|
|
|
|
cbPassword = ConvertToUnicode(CP_UTF8, 0, "*", -1, &passwordW, 0) * 2;
|
2012-01-31 05:54:46 +04:00
|
|
|
}
|
2011-07-12 02:46:36 +04:00
|
|
|
|
2014-06-29 02:33:46 +04:00
|
|
|
if (!settings->RemoteAssistanceMode)
|
|
|
|
{
|
|
|
|
cbAlternateShell = ConvertToUnicode(CP_UTF8, 0, settings->AlternateShell, -1, &alternateShellW, 0) * 2;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2014-08-15 22:15:53 +04:00
|
|
|
if (settings->RemoteAssistancePassStub)
|
|
|
|
{
|
|
|
|
/* This field MUST be filled with "*" */
|
|
|
|
cbAlternateShell = ConvertToUnicode(CP_UTF8, 0, "*", -1, &alternateShellW, 0) * 2;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* This field must contain the remote assistance password */
|
|
|
|
cbAlternateShell = ConvertToUnicode(CP_UTF8, 0, settings->RemoteAssistancePassword, -1, &alternateShellW, 0) * 2;
|
|
|
|
}
|
2014-06-29 02:33:46 +04:00
|
|
|
}
|
2011-07-12 02:46:36 +04:00
|
|
|
|
2014-06-29 02:33:46 +04:00
|
|
|
if (!settings->RemoteAssistanceMode)
|
|
|
|
{
|
|
|
|
cbWorkingDir = ConvertToUnicode(CP_UTF8, 0, settings->ShellWorkingDirectory, -1, &workingDirW, 0) * 2;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* Remote Assistance Session Id */
|
|
|
|
cbWorkingDir = ConvertToUnicode(CP_UTF8, 0, settings->RemoteAssistanceSessionId, -1, &workingDirW, 0) * 2;
|
|
|
|
}
|
2011-07-12 02:46:36 +04:00
|
|
|
|
2015-02-06 22:21:26 +03:00
|
|
|
Stream_Write_UINT32(s, 0); /* CodePage (4 bytes) */
|
|
|
|
Stream_Write_UINT32(s, flags); /* flags (4 bytes) */
|
2011-07-12 02:46:36 +04:00
|
|
|
|
2015-02-06 22:21:26 +03:00
|
|
|
Stream_Write_UINT16(s, cbDomain); /* cbDomain (2 bytes) */
|
|
|
|
Stream_Write_UINT16(s, cbUserName); /* cbUserName (2 bytes) */
|
|
|
|
Stream_Write_UINT16(s, cbPassword); /* cbPassword (2 bytes) */
|
|
|
|
Stream_Write_UINT16(s, cbAlternateShell); /* cbAlternateShell (2 bytes) */
|
|
|
|
Stream_Write_UINT16(s, cbWorkingDir); /* cbWorkingDir (2 bytes) */
|
2011-07-12 02:46:36 +04:00
|
|
|
|
|
|
|
if (cbDomain > 0)
|
2014-06-29 02:33:46 +04:00
|
|
|
Stream_Write(s, domainW, cbDomain);
|
2013-05-09 00:09:16 +04:00
|
|
|
Stream_Write_UINT16(s, 0);
|
2011-07-12 02:46:36 +04:00
|
|
|
|
|
|
|
if (cbUserName > 0)
|
2014-06-29 02:33:46 +04:00
|
|
|
Stream_Write(s, userNameW, cbUserName);
|
2013-05-09 00:09:16 +04:00
|
|
|
Stream_Write_UINT16(s, 0);
|
2011-07-12 02:46:36 +04:00
|
|
|
|
|
|
|
if (cbPassword > 0)
|
2014-06-29 02:33:46 +04:00
|
|
|
Stream_Write(s, passwordW, cbPassword);
|
2013-05-09 00:09:16 +04:00
|
|
|
Stream_Write_UINT16(s, 0);
|
2011-07-12 02:46:36 +04:00
|
|
|
|
|
|
|
if (cbAlternateShell > 0)
|
2014-06-29 02:33:46 +04:00
|
|
|
Stream_Write(s, alternateShellW, cbAlternateShell);
|
2013-05-09 00:09:16 +04:00
|
|
|
Stream_Write_UINT16(s, 0);
|
2011-07-12 02:46:36 +04:00
|
|
|
|
|
|
|
if (cbWorkingDir > 0)
|
2014-06-29 02:33:46 +04:00
|
|
|
Stream_Write(s, workingDirW, cbWorkingDir);
|
2013-05-09 00:09:16 +04:00
|
|
|
Stream_Write_UINT16(s, 0);
|
2011-07-12 02:46:36 +04:00
|
|
|
|
2014-06-29 02:33:46 +04:00
|
|
|
free(domainW);
|
|
|
|
free(userNameW);
|
|
|
|
free(alternateShellW);
|
|
|
|
free(workingDirW);
|
2011-07-12 02:46:36 +04:00
|
|
|
|
2012-02-01 20:58:06 +04:00
|
|
|
if (!usedPasswordCookie)
|
2014-06-29 02:33:46 +04:00
|
|
|
free(passwordW);
|
2012-02-01 20:58:06 +04:00
|
|
|
|
2012-11-07 19:33:06 +04:00
|
|
|
if (settings->RdpVersion >= 5)
|
2015-02-07 00:55:21 +03:00
|
|
|
rdp_write_extended_info_packet(rdp, s); /* extraInfo */
|
2011-07-12 02:46:36 +04:00
|
|
|
}
|
|
|
|
|
2011-08-20 14:22:14 +04:00
|
|
|
/**
|
|
|
|
* Read Client Info PDU (CLIENT_INFO_PDU).\n
|
|
|
|
* @msdn{cc240474}
|
|
|
|
* @param rdp RDP module
|
|
|
|
* @param s stream
|
|
|
|
*/
|
|
|
|
|
2013-03-21 23:19:33 +04:00
|
|
|
BOOL rdp_recv_client_info(rdpRdp* rdp, wStream* s)
|
2011-08-20 14:22:14 +04:00
|
|
|
{
|
2012-10-09 11:01:37 +04:00
|
|
|
UINT16 length;
|
|
|
|
UINT16 channelId;
|
2016-12-02 12:46:43 +03:00
|
|
|
UINT16 securityFlags = 0;
|
2011-08-20 14:22:14 +04:00
|
|
|
|
|
|
|
if (!rdp_read_header(rdp, s, &length, &channelId))
|
2012-10-09 10:31:28 +04:00
|
|
|
return FALSE;
|
2011-08-20 14:22:14 +04:00
|
|
|
|
2013-01-15 02:40:34 +04:00
|
|
|
if (!rdp_read_security_header(s, &securityFlags))
|
|
|
|
return FALSE;
|
|
|
|
|
2012-01-25 19:30:54 +04:00
|
|
|
if ((securityFlags & SEC_INFO_PKT) == 0)
|
2012-10-09 10:31:28 +04:00
|
|
|
return FALSE;
|
2011-08-20 14:22:14 +04:00
|
|
|
|
Standard RDP Security Layer Levels/Method Overhaul
[MS-RDPBCGR] Section 5.3 describes the encryption level and method values for
standard RDP security.
Looking at the current usage of these values in the FreeRDP code gives me
reason to believe that there is a certain lack of understanding of how these
values should be handled.
The encryption level is only configured on the server side in the "Encryption
Level" setting found in the Remote Desktop Session Host Configuration RDP-Tcp
properties dialog and this value is never transferred from the client to the
server over the wire.
The possible options are "None", "Low", "Client Compatible", "High" and
"FIPS Compliant". The client receices this value in the Server Security Data
block (TS_UD_SC_SEC1), probably only for informational purposes and maybe to
give the client the possibility to verify if the server's decision for the
encryption method confirms to the server's encryption level.
The possible encryption methods are "NONE", "40BIT", "56BIT", "128BIT" and
"FIPS" and the RDP client advertises the ones it supports to the server in the
Client Security Data block (TS_UD_CS_SEC).
The server's configured encryption level value restricts the possible final
encryption method.
Something that I was not able to find in the documentation is the priority
level of the individual encryption methods based on which the server makes its
final method decision if there are several options.
My analysis with Windows Servers reveiled that the order is 128, 56, 40, FIPS.
The server only chooses FIPS if the level is "FIPS Comliant" or if it is the
only method advertised by the client.
Bottom line:
* FreeRDP's client side does not need to set settings->EncryptionLevel
(which was done quite frequently).
* FreeRDP's server side does not have to set the supported encryption methods
list in settings->EncryptionMethods
Changes in this commit:
Removed unnecessary/confusing changes of EncryptionLevel/Methods settings
Refactor settings->DisableEncryption
* This value actually means "Advanced RDP Encryption (NLA/TLS) is NOT used"
* The old name caused lots of confusion among developers
* Renamed it to "UseRdpSecurityLayer" (the compare logic stays untouched)
Any client's setting of settings->EncryptionMethods were annihilated
* All clients "want" to set all supported methods
* Some clients forgot 56bit because 56bit was not supported at the time the
code was written
* settings->EncryptionMethods was overwritten anyways in nego_connect()
* Removed all client side settings of settings->EncryptionMethods
The default is "None" (0)
* Changed nego_connect() to advertise all supported methods if
settings->EncryptionMethods is 0 (None)
* Added a commandline option /encryption-methods:comma separated list of the
values "40", "56", "128", "FIPS". E.g. /encryption-methods:56,128
* Print warning if server chooses non-advertised method
Verify received level and method in client's gcc_read_server_security_data
* Only accept valid/known encryption methods
* Verify encryption level/method combinations according to MS-RDPBCGR 5.3.2
Server implementations can now set settings->EncryptionLevel
* The default for settings->EncryptionLevel is 0 (None)
* nego_send_negotiation_response() changes it to ClientCompatible in that case
* default to ClientCompatible if the server implementation set an invalid level
Fix server's gcc_write_server_security_data
* Verify server encryption level value set by server implementations
* Choose rdp encryption method based on level and supported client methods
* Moved FIPS to the lowest priority (only used if other methods are possible)
Updated sample server
* Support RDP Security (RdpKeyFile was not set)
* Added commented sample code for setting the security level
2014-12-12 04:17:12 +03:00
|
|
|
if (rdp->settings->UseRdpSecurityLayer)
|
2012-01-25 19:30:54 +04:00
|
|
|
{
|
|
|
|
if (securityFlags & SEC_REDIRECTION_PKT)
|
|
|
|
{
|
2015-02-06 22:21:26 +03:00
|
|
|
WLog_ERR(TAG, "Error: SEC_REDIRECTION_PKT unsupported");
|
2012-10-09 10:31:28 +04:00
|
|
|
return FALSE;
|
2012-01-25 19:30:54 +04:00
|
|
|
}
|
2013-03-29 06:26:28 +04:00
|
|
|
|
2012-01-25 19:30:54 +04:00
|
|
|
if (securityFlags & SEC_ENCRYPT)
|
|
|
|
{
|
|
|
|
if (!rdp_decrypt(rdp, s, length - 4, securityFlags))
|
|
|
|
{
|
2015-02-06 22:21:26 +03:00
|
|
|
WLog_ERR(TAG, "rdp_decrypt failed");
|
2012-10-09 10:31:28 +04:00
|
|
|
return FALSE;
|
2012-01-25 19:30:54 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-02-07 00:55:21 +03:00
|
|
|
return rdp_read_info_packet(rdp, s);
|
2011-08-20 14:22:14 +04:00
|
|
|
}
|
|
|
|
|
2011-07-12 02:46:36 +04:00
|
|
|
/**
|
|
|
|
* Send Client Info PDU (CLIENT_INFO_PDU).\n
|
|
|
|
* @msdn{cc240474}
|
|
|
|
* @param rdp RDP module
|
|
|
|
*/
|
|
|
|
|
2012-10-09 10:38:39 +04:00
|
|
|
BOOL rdp_send_client_info(rdpRdp* rdp)
|
2011-07-12 02:46:36 +04:00
|
|
|
{
|
2013-03-21 23:19:33 +04:00
|
|
|
wStream* s;
|
2013-05-15 23:54:33 +04:00
|
|
|
BOOL status;
|
2011-07-12 02:46:36 +04:00
|
|
|
|
2011-09-13 10:40:27 +04:00
|
|
|
rdp->sec_flags |= SEC_INFO_PKT;
|
2013-05-15 23:54:33 +04:00
|
|
|
|
|
|
|
s = Stream_New(NULL, 2048);
|
2015-05-29 14:46:50 +03:00
|
|
|
|
|
|
|
if (!s)
|
|
|
|
{
|
|
|
|
WLog_ERR(TAG, "Stream_New failed!");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2013-05-15 23:54:33 +04:00
|
|
|
rdp_init_stream(rdp, s);
|
|
|
|
|
2015-02-07 00:55:21 +03:00
|
|
|
rdp_write_info_packet(rdp, s);
|
2013-05-15 23:54:33 +04:00
|
|
|
|
|
|
|
status = rdp_send(rdp, s, MCS_GLOBAL_CHANNEL_ID);
|
|
|
|
|
|
|
|
Stream_Free(s, TRUE);
|
|
|
|
|
|
|
|
return status;
|
2011-07-12 02:46:36 +04:00
|
|
|
}
|
|
|
|
|
2016-02-18 16:19:36 +03:00
|
|
|
BOOL rdp_recv_logon_info_v1(rdpRdp* rdp, wStream* s, logon_info *info)
|
2011-07-25 21:42:14 +04:00
|
|
|
{
|
2012-10-09 11:26:39 +04:00
|
|
|
UINT32 cbDomain;
|
|
|
|
UINT32 cbUserName;
|
2016-03-03 18:21:12 +03:00
|
|
|
WCHAR* wstr;
|
2011-07-25 21:42:14 +04:00
|
|
|
|
2016-03-03 13:45:12 +03:00
|
|
|
ZeroMemory(info, sizeof(*info));
|
|
|
|
|
2015-02-06 23:44:29 +03:00
|
|
|
if (Stream_GetRemainingLength(s) < 576)
|
2013-01-11 04:18:11 +04:00
|
|
|
return FALSE;
|
2013-03-29 06:26:28 +04:00
|
|
|
|
2013-05-09 00:09:16 +04:00
|
|
|
Stream_Read_UINT32(s, cbDomain); /* cbDomain (4 bytes) */
|
2016-03-03 18:21:12 +03:00
|
|
|
|
|
|
|
/* cbDomain is the size of the Unicode character data (including the mandatory
|
|
|
|
* null terminator) in bytes present in the fixed-length (52 bytes) Domain field
|
|
|
|
*/
|
2016-03-04 02:45:26 +03:00
|
|
|
if (cbDomain)
|
2016-03-03 13:45:12 +03:00
|
|
|
{
|
2016-03-04 02:45:26 +03:00
|
|
|
if ((cbDomain % 2) || cbDomain > 52)
|
|
|
|
{
|
2016-12-14 00:47:08 +03:00
|
|
|
WLog_ERR(TAG, "protocol error: invalid cbDomain value: %"PRIu32"", cbDomain);
|
2016-03-04 02:45:26 +03:00
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
wstr = (WCHAR*) Stream_Pointer(s);
|
|
|
|
if (wstr[cbDomain / 2 - 1])
|
|
|
|
{
|
|
|
|
WLog_ERR(TAG, "protocol error: Domain must be null terminated");
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
if (ConvertFromUnicode(CP_UTF8, 0, wstr, -1, &info->domain, 0, NULL, FALSE) < 1)
|
|
|
|
{
|
|
|
|
WLog_ERR(TAG, "failed to convert the Domain string");
|
|
|
|
goto fail;
|
|
|
|
}
|
2016-03-03 13:45:12 +03:00
|
|
|
}
|
2013-04-30 06:35:15 +04:00
|
|
|
Stream_Seek(s, 52); /* domain (52 bytes) */
|
2016-02-18 16:19:36 +03:00
|
|
|
|
2016-03-03 18:21:12 +03:00
|
|
|
|
2013-05-09 00:09:16 +04:00
|
|
|
Stream_Read_UINT32(s, cbUserName); /* cbUserName (4 bytes) */
|
2016-03-03 18:21:12 +03:00
|
|
|
|
|
|
|
/* cbUserName is the size of the Unicode character data (including the mandatory
|
|
|
|
* null terminator) in bytes present in the fixed-length (512 bytes) UserName field.
|
|
|
|
*/
|
2016-03-04 02:45:26 +03:00
|
|
|
if (cbUserName)
|
2016-03-03 18:21:12 +03:00
|
|
|
{
|
2016-03-04 02:45:26 +03:00
|
|
|
if ((cbUserName % 2) || cbUserName > 512)
|
|
|
|
{
|
2016-12-14 00:47:08 +03:00
|
|
|
WLog_ERR(TAG, "protocol error: invalid cbUserName value: %"PRIu32"", cbUserName);
|
2016-03-04 02:45:26 +03:00
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
wstr = (WCHAR*) Stream_Pointer(s);
|
|
|
|
if (wstr[cbUserName / 2 - 1])
|
|
|
|
{
|
|
|
|
WLog_ERR(TAG, "protocol error: UserName must be null terminated");
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
if (ConvertFromUnicode(CP_UTF8, 0, wstr, -1, &info->username, 0, NULL, FALSE) < 1)
|
|
|
|
{
|
|
|
|
WLog_ERR(TAG, "failed to convert the UserName string");
|
|
|
|
goto fail;
|
|
|
|
}
|
2016-03-03 13:45:12 +03:00
|
|
|
}
|
2013-04-30 06:35:15 +04:00
|
|
|
Stream_Seek(s, 512); /* userName (512 bytes) */
|
2015-02-06 23:44:29 +03:00
|
|
|
|
2016-02-18 16:19:36 +03:00
|
|
|
Stream_Read_UINT32(s, info->sessionId); /* SessionId (4 bytes) */
|
|
|
|
|
2016-12-14 00:47:08 +03:00
|
|
|
WLog_DBG(TAG, "LogonInfoV1: SessionId: 0x%08"PRIX32" UserName: [%s] Domain: [%s]",
|
2016-03-03 18:21:12 +03:00
|
|
|
info->sessionId, info->username, info->domain);
|
2013-03-29 06:26:28 +04:00
|
|
|
|
2013-01-11 04:18:11 +04:00
|
|
|
return TRUE;
|
2016-02-18 16:19:36 +03:00
|
|
|
|
2016-03-03 18:21:12 +03:00
|
|
|
fail:
|
|
|
|
free(info->username);
|
|
|
|
info->username = NULL;
|
2016-02-18 16:19:36 +03:00
|
|
|
free(info->domain);
|
|
|
|
info->domain = NULL;
|
|
|
|
return FALSE;
|
2011-07-25 21:42:14 +04:00
|
|
|
}
|
|
|
|
|
2016-02-18 16:19:36 +03:00
|
|
|
BOOL rdp_recv_logon_info_v2(rdpRdp* rdp, wStream* s, logon_info *info)
|
2011-07-25 21:42:14 +04:00
|
|
|
{
|
2015-02-06 23:44:29 +03:00
|
|
|
UINT16 Version;
|
|
|
|
UINT32 Size;
|
2012-10-09 11:26:39 +04:00
|
|
|
UINT32 cbDomain;
|
|
|
|
UINT32 cbUserName;
|
2016-03-03 18:21:12 +03:00
|
|
|
WCHAR* wstr;
|
2011-07-25 21:42:14 +04:00
|
|
|
|
2016-03-03 13:45:12 +03:00
|
|
|
ZeroMemory(info, sizeof(*info));
|
|
|
|
|
2015-02-06 23:44:29 +03:00
|
|
|
if (Stream_GetRemainingLength(s) < 576)
|
2013-01-11 04:18:11 +04:00
|
|
|
return FALSE;
|
2013-03-29 06:26:28 +04:00
|
|
|
|
2015-02-06 23:44:29 +03:00
|
|
|
Stream_Read_UINT16(s, Version); /* Version (2 bytes) */
|
|
|
|
Stream_Read_UINT32(s, Size); /* Size (4 bytes) */
|
2016-02-18 16:19:36 +03:00
|
|
|
Stream_Read_UINT32(s, info->sessionId); /* SessionId (4 bytes) */
|
2013-05-09 00:09:16 +04:00
|
|
|
Stream_Read_UINT32(s, cbDomain); /* cbDomain (4 bytes) */
|
|
|
|
Stream_Read_UINT32(s, cbUserName); /* cbUserName (4 bytes) */
|
2015-02-06 23:44:29 +03:00
|
|
|
Stream_Seek(s, 558); /* pad (558 bytes) */
|
2013-01-11 04:18:11 +04:00
|
|
|
|
2013-03-29 06:26:28 +04:00
|
|
|
|
2016-03-03 18:21:12 +03:00
|
|
|
/* cbDomain is the size in bytes of the Unicode character data in the Domain field.
|
|
|
|
* The size of the mandatory null terminator is include in this value.
|
|
|
|
* Note: Since MS-RDPBCGR 2.2.10.1.1.2 does not mention any size limits we assume
|
|
|
|
* that the maximum value is 52 bytes, according to the fixed size of the
|
|
|
|
* Domain field in the Logon Info Version 1 (TS_LOGON_INFO) structure.
|
|
|
|
*/
|
2016-03-04 02:45:26 +03:00
|
|
|
if (cbDomain)
|
2016-03-03 18:21:12 +03:00
|
|
|
{
|
2016-03-04 02:45:26 +03:00
|
|
|
if ((cbDomain % 2) || cbDomain > 52)
|
|
|
|
{
|
2016-12-14 00:47:08 +03:00
|
|
|
WLog_ERR(TAG, "protocol error: invalid cbDomain value: %"PRIu32"", cbDomain);
|
2016-03-04 02:45:26 +03:00
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
if (Stream_GetRemainingLength(s) < (size_t) cbDomain)
|
|
|
|
{
|
|
|
|
WLog_ERR(TAG, "insufficient remaining stream length");
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
wstr = (WCHAR*) Stream_Pointer(s);
|
|
|
|
if (wstr[cbDomain / 2 - 1])
|
|
|
|
{
|
|
|
|
WLog_ERR(TAG, "protocol error: Domain field must be null terminated");
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
if (ConvertFromUnicode(CP_UTF8, 0, wstr, -1, &info->domain, 0, NULL, FALSE) < 1)
|
|
|
|
{
|
|
|
|
WLog_ERR(TAG, "failed to convert the Domain string");
|
|
|
|
goto fail;
|
|
|
|
}
|
2016-03-03 18:21:12 +03:00
|
|
|
}
|
|
|
|
Stream_Seek(s, cbDomain); /* domain */
|
|
|
|
|
|
|
|
/* cbUserName is the size in bytes of the Unicode character data in the UserName field.
|
|
|
|
* The size of the mandatory null terminator is include in this value.
|
|
|
|
* Note: Since MS-RDPBCGR 2.2.10.1.1.2 does not mention any size limits we assume
|
|
|
|
* that the maximum value is 512 bytes, according to the fixed size of the
|
|
|
|
* Username field in the Logon Info Version 1 (TS_LOGON_INFO) structure.
|
|
|
|
*/
|
2016-03-04 02:45:26 +03:00
|
|
|
if (cbUserName)
|
2016-03-03 18:21:12 +03:00
|
|
|
{
|
2016-03-04 02:45:26 +03:00
|
|
|
if ((cbUserName % 2) || cbUserName < 2 || cbUserName > 512)
|
|
|
|
{
|
2016-12-14 00:47:08 +03:00
|
|
|
WLog_ERR(TAG, "protocol error: invalid cbUserName value: %"PRIu32"", cbUserName);
|
2016-03-04 02:45:26 +03:00
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
if (Stream_GetRemainingLength(s) < (size_t) cbUserName)
|
|
|
|
{
|
|
|
|
WLog_ERR(TAG, "insufficient remaining stream length");
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
wstr = (WCHAR*) Stream_Pointer(s);
|
|
|
|
if (wstr[cbUserName / 2 - 1])
|
|
|
|
{
|
|
|
|
WLog_ERR(TAG, "protocol error: UserName field must be null terminated");
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
if (ConvertFromUnicode(CP_UTF8, 0, wstr, -1, &info->username, 0, NULL, FALSE) < 1)
|
|
|
|
{
|
|
|
|
WLog_ERR(TAG, "failed to convert the Domain string");
|
|
|
|
goto fail;
|
|
|
|
}
|
2016-03-03 18:21:12 +03:00
|
|
|
}
|
|
|
|
Stream_Seek(s, cbUserName); /* userName */
|
|
|
|
|
2016-12-14 00:47:08 +03:00
|
|
|
WLog_DBG(TAG, "LogonInfoV2: SessionId: 0x%08"PRIX32" UserName: [%s] Domain: [%s]",
|
2016-03-03 18:21:12 +03:00
|
|
|
info->sessionId, info->username, info->domain);
|
2015-02-06 23:44:29 +03:00
|
|
|
|
2013-01-11 04:18:11 +04:00
|
|
|
return TRUE;
|
2016-03-03 18:21:12 +03:00
|
|
|
|
|
|
|
fail:
|
|
|
|
free(info->username);
|
|
|
|
info->username = NULL;
|
|
|
|
free(info->domain);
|
|
|
|
info->domain = NULL;
|
|
|
|
return FALSE;
|
2011-07-25 21:42:14 +04:00
|
|
|
}
|
|
|
|
|
2013-03-21 23:19:33 +04:00
|
|
|
BOOL rdp_recv_logon_plain_notify(rdpRdp* rdp, wStream* s)
|
2011-07-25 21:42:14 +04:00
|
|
|
{
|
2013-04-30 06:35:15 +04:00
|
|
|
if (Stream_GetRemainingLength(s) < 576)
|
2013-01-11 04:18:11 +04:00
|
|
|
return FALSE;
|
2013-03-29 06:26:28 +04:00
|
|
|
|
2015-02-06 23:44:29 +03:00
|
|
|
Stream_Seek(s, 576); /* pad (576 bytes) */
|
|
|
|
|
|
|
|
WLog_DBG(TAG, "LogonPlainNotify");
|
2013-03-29 06:26:28 +04:00
|
|
|
|
2013-01-11 04:18:11 +04:00
|
|
|
return TRUE;
|
2011-07-25 21:42:14 +04:00
|
|
|
}
|
|
|
|
|
2016-02-18 16:19:36 +03:00
|
|
|
BOOL rdp_recv_logon_error_info(rdpRdp* rdp, wStream* s, logon_info_ex *info)
|
2011-07-25 21:42:14 +04:00
|
|
|
{
|
2013-03-29 06:26:28 +04:00
|
|
|
UINT32 errorNotificationType;
|
2015-10-20 17:05:09 +03:00
|
|
|
UINT32 errorNotificationData;
|
2011-07-25 21:42:14 +04:00
|
|
|
|
2015-06-29 19:43:18 +03:00
|
|
|
if (Stream_GetRemainingLength(s) < 8)
|
2013-01-11 04:18:11 +04:00
|
|
|
return FALSE;
|
2013-03-29 06:26:28 +04:00
|
|
|
|
2013-05-09 00:09:16 +04:00
|
|
|
Stream_Read_UINT32(s, errorNotificationType); /* errorNotificationType (4 bytes) */
|
2015-10-20 17:05:09 +03:00
|
|
|
Stream_Read_UINT32(s, errorNotificationData); /* errorNotificationData (4 bytes) */
|
2013-03-29 06:26:28 +04:00
|
|
|
|
2016-12-14 00:47:08 +03:00
|
|
|
WLog_DBG(TAG, "LogonErrorInfo: Data: 0x%08"PRIX32" Type: 0x%08"PRIX32"",
|
2015-02-06 23:44:29 +03:00
|
|
|
errorNotificationData, errorNotificationType);
|
|
|
|
|
2013-03-29 06:26:28 +04:00
|
|
|
IFCALL(rdp->instance->LogonErrorInfo, rdp->instance, errorNotificationData, errorNotificationType);
|
|
|
|
|
2016-02-18 16:19:36 +03:00
|
|
|
info->ErrorNotificationType = errorNotificationType;
|
|
|
|
info->ErrorNotificationData = errorNotificationData;
|
2013-01-11 04:18:11 +04:00
|
|
|
return TRUE;
|
2011-07-25 21:42:14 +04:00
|
|
|
}
|
|
|
|
|
2016-02-18 16:19:36 +03:00
|
|
|
BOOL rdp_recv_logon_info_extended(rdpRdp* rdp, wStream* s, logon_info_ex *info)
|
2011-07-25 21:42:14 +04:00
|
|
|
{
|
2012-10-09 11:26:39 +04:00
|
|
|
UINT32 cbFieldData;
|
|
|
|
UINT32 fieldsPresent;
|
2012-10-09 11:01:37 +04:00
|
|
|
UINT16 Length;
|
2011-07-25 21:42:14 +04:00
|
|
|
|
2013-04-30 06:35:15 +04:00
|
|
|
if (Stream_GetRemainingLength(s) < 6)
|
2013-01-11 04:18:11 +04:00
|
|
|
return FALSE;
|
|
|
|
|
2015-02-06 23:44:29 +03:00
|
|
|
Stream_Read_UINT16(s, Length); /* Length (2 bytes) */
|
2013-05-09 00:09:16 +04:00
|
|
|
Stream_Read_UINT32(s, fieldsPresent); /* fieldsPresent (4 bytes) */
|
2011-07-25 21:42:14 +04:00
|
|
|
|
2016-02-18 16:19:36 +03:00
|
|
|
if ((Length < 6) || (Stream_GetRemainingLength(s) < (Length - 6)))
|
2015-02-06 23:44:29 +03:00
|
|
|
return FALSE;
|
|
|
|
|
2016-12-14 00:47:08 +03:00
|
|
|
WLog_DBG(TAG, "LogonInfoExtended: fieldsPresent: 0x%08"PRIX32"", fieldsPresent);
|
2015-02-06 23:44:29 +03:00
|
|
|
|
2011-07-25 21:42:14 +04:00
|
|
|
/* logonFields */
|
|
|
|
|
|
|
|
if (fieldsPresent & LOGON_EX_AUTORECONNECTCOOKIE)
|
|
|
|
{
|
2013-04-30 06:35:15 +04:00
|
|
|
if (Stream_GetRemainingLength(s) < 4)
|
2013-01-11 04:18:11 +04:00
|
|
|
return FALSE;
|
2013-03-29 06:26:28 +04:00
|
|
|
|
2016-02-18 16:19:36 +03:00
|
|
|
info->haveCookie = TRUE;
|
2013-05-09 00:09:16 +04:00
|
|
|
Stream_Read_UINT32(s, cbFieldData); /* cbFieldData (4 bytes) */
|
2013-03-29 06:26:28 +04:00
|
|
|
|
2016-02-18 16:19:36 +03:00
|
|
|
if (Stream_GetRemainingLength(s) < cbFieldData)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
if (!rdp_read_server_auto_reconnect_cookie(rdp, s, info))
|
2013-01-11 04:18:11 +04:00
|
|
|
return FALSE;
|
2011-07-25 21:42:14 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (fieldsPresent & LOGON_EX_LOGONERRORS)
|
|
|
|
{
|
2016-02-18 16:19:36 +03:00
|
|
|
info->haveErrorInfo = TRUE;
|
2013-04-30 06:35:15 +04:00
|
|
|
if (Stream_GetRemainingLength(s) < 4)
|
2013-01-11 04:18:11 +04:00
|
|
|
return FALSE;
|
2013-03-29 06:26:28 +04:00
|
|
|
|
2013-05-09 00:09:16 +04:00
|
|
|
Stream_Read_UINT32(s, cbFieldData); /* cbFieldData (4 bytes) */
|
2013-03-29 06:26:28 +04:00
|
|
|
|
2016-02-18 16:19:36 +03:00
|
|
|
if (Stream_GetRemainingLength(s) < cbFieldData)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
if (!rdp_recv_logon_error_info(rdp, s, info))
|
2013-01-11 04:18:11 +04:00
|
|
|
return FALSE;
|
2011-07-25 21:42:14 +04:00
|
|
|
}
|
|
|
|
|
2013-04-30 06:35:15 +04:00
|
|
|
if (Stream_GetRemainingLength(s) < 570)
|
2013-01-11 04:18:11 +04:00
|
|
|
return FALSE;
|
2013-03-29 06:26:28 +04:00
|
|
|
|
2015-02-06 23:44:29 +03:00
|
|
|
Stream_Seek(s, 570); /* pad (570 bytes) */
|
2013-03-29 06:26:28 +04:00
|
|
|
|
2013-01-11 04:18:11 +04:00
|
|
|
return TRUE;
|
2011-07-25 21:42:14 +04:00
|
|
|
}
|
|
|
|
|
2013-03-21 23:19:33 +04:00
|
|
|
BOOL rdp_recv_save_session_info(rdpRdp* rdp, wStream* s)
|
2011-07-25 21:42:14 +04:00
|
|
|
{
|
2012-10-09 11:26:39 +04:00
|
|
|
UINT32 infoType;
|
2016-02-18 16:19:36 +03:00
|
|
|
BOOL status;
|
|
|
|
logon_info logonInfo;
|
|
|
|
logon_info_ex logonInfoEx;
|
|
|
|
rdpContext *context = rdp->context;
|
|
|
|
rdpUpdate *update = rdp->context->update;
|
2011-07-25 21:42:14 +04:00
|
|
|
|
2013-04-30 06:35:15 +04:00
|
|
|
if (Stream_GetRemainingLength(s) < 4)
|
2013-01-11 04:18:11 +04:00
|
|
|
return FALSE;
|
2011-07-25 21:42:14 +04:00
|
|
|
|
2015-02-06 23:44:29 +03:00
|
|
|
Stream_Read_UINT32(s, infoType); /* infoType (4 bytes) */
|
2011-07-25 21:42:14 +04:00
|
|
|
|
|
|
|
switch (infoType)
|
|
|
|
{
|
|
|
|
case INFO_TYPE_LOGON:
|
2016-02-18 16:19:36 +03:00
|
|
|
ZeroMemory(&logonInfo, sizeof(logonInfo));
|
|
|
|
status = rdp_recv_logon_info_v1(rdp, s, &logonInfo);
|
|
|
|
if (status && update->SaveSessionInfo)
|
|
|
|
status = update->SaveSessionInfo(context, infoType, &logonInfo);
|
|
|
|
free(logonInfo.domain);
|
|
|
|
free(logonInfo.username);
|
2015-02-06 23:44:29 +03:00
|
|
|
break;
|
2011-07-25 21:42:14 +04:00
|
|
|
|
|
|
|
case INFO_TYPE_LOGON_LONG:
|
2016-02-18 16:19:36 +03:00
|
|
|
ZeroMemory(&logonInfo, sizeof(logonInfo));
|
|
|
|
status = rdp_recv_logon_info_v2(rdp, s, &logonInfo);
|
|
|
|
if (status && update->SaveSessionInfo)
|
|
|
|
status = update->SaveSessionInfo(context, infoType, &logonInfo);
|
|
|
|
free(logonInfo.domain);
|
|
|
|
free(logonInfo.username);
|
2015-02-06 23:44:29 +03:00
|
|
|
break;
|
2011-07-25 21:42:14 +04:00
|
|
|
|
|
|
|
case INFO_TYPE_LOGON_PLAIN_NOTIFY:
|
2015-02-06 23:44:29 +03:00
|
|
|
status = rdp_recv_logon_plain_notify(rdp, s);
|
2016-02-18 16:19:36 +03:00
|
|
|
if (status && update->SaveSessionInfo)
|
|
|
|
status = update->SaveSessionInfo(context, infoType, NULL);
|
2015-02-06 23:44:29 +03:00
|
|
|
break;
|
2011-07-25 21:42:14 +04:00
|
|
|
|
|
|
|
case INFO_TYPE_LOGON_EXTENDED_INF:
|
2016-02-18 16:19:36 +03:00
|
|
|
ZeroMemory(&logonInfoEx, sizeof(logonInfoEx));
|
|
|
|
status = rdp_recv_logon_info_extended(rdp, s, &logonInfoEx);
|
|
|
|
if (status && update->SaveSessionInfo)
|
|
|
|
status = update->SaveSessionInfo(context, infoType, &logonInfoEx);
|
2015-02-06 23:44:29 +03:00
|
|
|
break;
|
2011-07-25 21:42:14 +04:00
|
|
|
|
|
|
|
default:
|
2016-12-14 00:47:08 +03:00
|
|
|
WLog_ERR(TAG, "Unhandled saveSessionInfo type 0x%"PRIx32"", infoType);
|
2016-02-18 16:19:36 +03:00
|
|
|
status = TRUE;
|
2011-07-25 21:42:14 +04:00
|
|
|
break;
|
|
|
|
}
|
2011-08-22 13:49:39 +04:00
|
|
|
|
2015-02-06 23:44:29 +03:00
|
|
|
if (!status)
|
|
|
|
{
|
2016-12-14 00:47:08 +03:00
|
|
|
WLog_DBG(TAG, "SaveSessionInfo error: infoType: %s (%"PRIu32")",
|
2015-02-06 23:44:29 +03:00
|
|
|
infoType < 4 ? INFO_TYPE_LOGON_STRINGS[infoType % 4] : "Unknown", infoType);
|
|
|
|
}
|
|
|
|
|
|
|
|
return status;
|
2011-07-25 21:42:14 +04:00
|
|
|
}
|
|
|
|
|
2016-02-18 16:19:36 +03:00
|
|
|
static BOOL rdp_write_logon_info_v1(wStream *s, logon_info *info)
|
|
|
|
{
|
|
|
|
int sz = 4 + 52 + 4 + 512 + 4;
|
|
|
|
int len;
|
|
|
|
WCHAR *wString = NULL;
|
|
|
|
|
|
|
|
if (!Stream_EnsureRemainingCapacity(s, sz))
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
/* domain */
|
|
|
|
len = ConvertToUnicode(CP_UTF8, 0, info->domain, -1, &wString, 0);
|
|
|
|
if (len < 0)
|
|
|
|
return FALSE;
|
|
|
|
len *= 2;
|
|
|
|
if (len > 52)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
Stream_Write_UINT32(s, len);
|
|
|
|
Stream_Write(s, wString, len);
|
|
|
|
Stream_Seek(s, 52 - len);
|
|
|
|
free(wString);
|
|
|
|
|
|
|
|
/* username */
|
|
|
|
len = ConvertToUnicode(CP_UTF8, 0, info->username, -1, &wString, 0);
|
|
|
|
if (len < 0)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
len *= 2;
|
|
|
|
if (len > 512)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
Stream_Write_UINT32(s, len);
|
|
|
|
Stream_Write(s, wString, len);
|
|
|
|
Stream_Seek(s, 512 - len);
|
|
|
|
free(wString);
|
|
|
|
|
|
|
|
/* sessionId */
|
|
|
|
Stream_Write_UINT32(s, info->sessionId);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static BOOL rdp_write_logon_info_v2(wStream *s, logon_info *info)
|
|
|
|
{
|
|
|
|
int Size = 2 + 4 + 4 + 4 + 4 + 558;
|
|
|
|
int domainLen, usernameLen, len;
|
|
|
|
WCHAR *wString;
|
|
|
|
|
|
|
|
if (!Stream_EnsureRemainingCapacity(s, Size))
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
Stream_Write_UINT16(s, SAVE_SESSION_PDU_VERSION_ONE);
|
|
|
|
Stream_Write_UINT32(s, Size);
|
|
|
|
Stream_Write_UINT32(s, info->sessionId);
|
|
|
|
|
|
|
|
domainLen = strlen(info->domain);
|
|
|
|
Stream_Write_UINT32(s, (domainLen + 1) * 2);
|
|
|
|
|
|
|
|
usernameLen = strlen(info->username);
|
|
|
|
Stream_Write_UINT32(s, (usernameLen + 1) * 2);
|
|
|
|
|
|
|
|
Stream_Seek(s, 558);
|
|
|
|
|
|
|
|
len = ConvertToUnicode(CP_UTF8, 0, info->domain, -1, &wString, 0);
|
|
|
|
if (len < 0)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
Stream_Write(s, wString, len * 2);
|
|
|
|
free(wString);
|
|
|
|
|
|
|
|
len = ConvertToUnicode(CP_UTF8, 0, info->username, -1, &wString, 0);
|
|
|
|
if (len < 0)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
Stream_Write(s, wString, len * 2);
|
|
|
|
free(wString);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static BOOL rdp_write_logon_info_plain(wStream *s)
|
|
|
|
{
|
|
|
|
if (!Stream_EnsureRemainingCapacity(s, 576))
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
Stream_Seek(s, 576);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static BOOL rdp_write_logon_info_ex(wStream *s, logon_info_ex *info)
|
|
|
|
{
|
|
|
|
UINT32 FieldsPresent = 0;
|
|
|
|
UINT16 Size = 2 + 4 + 570;
|
|
|
|
|
|
|
|
if (info->haveCookie)
|
|
|
|
{
|
|
|
|
FieldsPresent |= LOGON_EX_AUTORECONNECTCOOKIE;
|
|
|
|
Size += 28;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (info->haveErrorInfo)
|
|
|
|
{
|
|
|
|
FieldsPresent |= LOGON_EX_LOGONERRORS;
|
|
|
|
Size += 8;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!Stream_EnsureRemainingCapacity(s, Size))
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
Stream_Write_UINT16(s, Size);
|
|
|
|
Stream_Write_UINT32(s, FieldsPresent);
|
|
|
|
|
|
|
|
if (info->haveCookie)
|
|
|
|
{
|
|
|
|
Stream_Write_UINT32(s, 28); /* cbFieldData (4 bytes) */
|
|
|
|
|
|
|
|
Stream_Write_UINT32(s, 28); /* cbLen (4 bytes) */
|
|
|
|
Stream_Write_UINT32(s, AUTO_RECONNECT_VERSION_1); /* Version (4 bytes) */
|
|
|
|
Stream_Write_UINT32(s, info->LogonId); /* LogonId (4 bytes) */
|
|
|
|
Stream_Write(s, info->ArcRandomBits, 16); /* ArcRandomBits (16 bytes) */
|
|
|
|
}
|
|
|
|
|
|
|
|
if (info->haveErrorInfo)
|
|
|
|
{
|
|
|
|
Stream_Write_UINT32(s, 8); /* cbFieldData (4 bytes) */
|
|
|
|
|
|
|
|
Stream_Write_UINT32(s, info->ErrorNotificationType); /* ErrorNotificationType (4 bytes) */
|
|
|
|
Stream_Write_UINT32(s, info->ErrorNotificationData); /* ErrorNotificationData (4 bytes) */
|
|
|
|
}
|
|
|
|
|
|
|
|
Stream_Seek(s, 570);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOL rdp_send_save_session_info(rdpContext *context, UINT32 type, void *data)
|
|
|
|
{
|
|
|
|
wStream *s;
|
|
|
|
BOOL status;
|
|
|
|
rdpRdp *rdp = context->rdp;
|
|
|
|
|
|
|
|
s = rdp_data_pdu_init(rdp);
|
|
|
|
if (!s)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
Stream_Write_UINT32(s, type);
|
|
|
|
|
|
|
|
switch (type)
|
|
|
|
{
|
|
|
|
case INFO_TYPE_LOGON:
|
|
|
|
status = rdp_write_logon_info_v1(s, (logon_info *)data);
|
|
|
|
break;
|
|
|
|
case INFO_TYPE_LOGON_LONG:
|
|
|
|
status = rdp_write_logon_info_v2(s, (logon_info *)data);
|
|
|
|
break;
|
|
|
|
case INFO_TYPE_LOGON_PLAIN_NOTIFY:
|
|
|
|
status = rdp_write_logon_info_plain(s);
|
|
|
|
break;
|
|
|
|
case INFO_TYPE_LOGON_EXTENDED_INF:
|
|
|
|
status = rdp_write_logon_info_ex(s, (logon_info_ex *)data);
|
|
|
|
break;
|
|
|
|
default:
|
2016-12-14 00:47:08 +03:00
|
|
|
WLog_ERR(TAG, "saveSessionInfo type 0x%"PRIx32" not handled", type);
|
2016-02-18 16:19:36 +03:00
|
|
|
status = FALSE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (status)
|
|
|
|
status = rdp_send_data_pdu(rdp, s, DATA_PDU_TYPE_SAVE_SESSION_INFO, rdp->mcs->userId);
|
|
|
|
else
|
|
|
|
Stream_Free(s, TRUE);
|
|
|
|
return status;
|
|
|
|
}
|