Fourth Batch: Update files using ChatGPT 4o
This commit is contained in:
parent
867c553378
commit
dbac3db7b7
22
iso.c
22
iso.c
@ -20,6 +20,8 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "rdesktop.h"
|
#include "rdesktop.h"
|
||||||
|
#include <string.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
extern RD_BOOL g_encryption;
|
extern RD_BOOL g_encryption;
|
||||||
extern RD_BOOL g_encryption_initial;
|
extern RD_BOOL g_encryption_initial;
|
||||||
@ -59,7 +61,7 @@ iso_send_msg(uint8 code)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
iso_send_connection_request(char *username, uint32 neg_proto)
|
iso_send_connection_request(const char *username, uint32 neg_proto)
|
||||||
{
|
{
|
||||||
STREAM s;
|
STREAM s;
|
||||||
int length = 30 + strlen(username);
|
int length = 30 + strlen(username);
|
||||||
@ -132,7 +134,7 @@ iso_recv_msg(uint8 * code, RD_BOOL * is_fastpath, uint8 * fastpath_hdr)
|
|||||||
{
|
{
|
||||||
/* length2 is only present if the most significant bit of length1 is set */
|
/* length2 is only present if the most significant bit of length1 is set */
|
||||||
length &= ~0x80;
|
length &= ~0x80;
|
||||||
next_be(s, length);
|
in_uint8(s, length); /* length2 */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -218,19 +220,19 @@ iso_recv(RD_BOOL * is_fastpath, uint8 * fastpath_hdr)
|
|||||||
/* try to setup a more helpful error message about TLS */
|
/* try to setup a more helpful error message about TLS */
|
||||||
char *get_credSSP_reason(uint32 neg_proto)
|
char *get_credSSP_reason(uint32 neg_proto)
|
||||||
{
|
{
|
||||||
static char msg[256];
|
static char msg[256] = "CredSSP required by server";
|
||||||
|
|
||||||
strcat(msg, "CredSSP required by server");
|
|
||||||
if ((neg_proto & PROTOCOL_SSL) &&
|
if ((neg_proto & PROTOCOL_SSL) &&
|
||||||
( (g_tls_version[0] == 0) ||
|
((g_tls_version[0] == 0) || (strcmp(g_tls_version, "1.2") < 0)))
|
||||||
(strcmp(g_tls_version, "1.2") < 0)))
|
{
|
||||||
strcat(msg, " (check if server has disabled old TLS versions, if yes use -V option)");
|
strcat(msg, " (check if server has disabled old TLS versions, if yes use -V option)");
|
||||||
|
}
|
||||||
return msg;
|
return msg;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Establish a connection up to the ISO layer */
|
/* Establish a connection up to the ISO layer */
|
||||||
RD_BOOL
|
RD_BOOL
|
||||||
iso_connect(char *server, char *username, char *domain, char *password,
|
iso_connect(const char *server, const char *username, const char *domain, const char *password,
|
||||||
RD_BOOL reconnect, uint32 * selected_protocol)
|
RD_BOOL reconnect, uint32 * selected_protocol)
|
||||||
{
|
{
|
||||||
UNUSED(reconnect);
|
UNUSED(reconnect);
|
||||||
@ -354,7 +356,7 @@ iso_connect(char *server, char *username, char *domain, char *password,
|
|||||||
{
|
{
|
||||||
if (!tcp_tls_connect())
|
if (!tcp_tls_connect())
|
||||||
{
|
{
|
||||||
/* failed to connect using cssp, let retry with plain TLS */
|
/* failed to connect using CredSSP, retry with plain TLS */
|
||||||
logger(Core, Verbose,
|
logger(Core, Verbose,
|
||||||
"Failed to connect using SSL, trying with plain RDP.");
|
"Failed to connect using SSL, trying with plain RDP.");
|
||||||
tcp_disconnect();
|
tcp_disconnect();
|
||||||
@ -370,7 +372,7 @@ iso_connect(char *server, char *username, char *domain, char *password,
|
|||||||
{
|
{
|
||||||
if (!cssp_connect(server, username, domain, password, s))
|
if (!cssp_connect(server, username, domain, password, s))
|
||||||
{
|
{
|
||||||
/* failed to connect using cssp, let retry with plain TLS */
|
/* failed to connect using CredSSP, retry with plain TLS */
|
||||||
logger(Core, Verbose,
|
logger(Core, Verbose,
|
||||||
"Failed to connect using NLA, trying with SSL");
|
"Failed to connect using NLA, trying with SSL");
|
||||||
tcp_disconnect();
|
tcp_disconnect();
|
||||||
@ -387,7 +389,7 @@ iso_connect(char *server, char *username, char *domain, char *password,
|
|||||||
{
|
{
|
||||||
logger(Core, Notice, "Connection established using plain RDP.");
|
logger(Core, Notice, "Connection established using plain RDP.");
|
||||||
}
|
}
|
||||||
else if (data != PROTOCOL_RDP)
|
else
|
||||||
{
|
{
|
||||||
tcp_disconnect();
|
tcp_disconnect();
|
||||||
logger(Protocol, Error,
|
logger(Protocol, Error,
|
||||||
|
35
licence.c
35
licence.c
@ -5,7 +5,6 @@
|
|||||||
Copyright (C) Thomas Uhle <thomas.uhle@mailbox.tu-dresden.de> 2011
|
Copyright (C) Thomas Uhle <thomas.uhle@mailbox.tu-dresden.de> 2011
|
||||||
Copyright (C) Henrik Andersson <henrik.andersson@cendio.com> 2014
|
Copyright (C) Henrik Andersson <henrik.andersson@cendio.com> 2014
|
||||||
|
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
This program is free software: you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU General Public License as published by
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
@ -22,6 +21,7 @@
|
|||||||
|
|
||||||
#include "rdesktop.h"
|
#include "rdesktop.h"
|
||||||
#include "ssl.h"
|
#include "ssl.h"
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
extern char *g_username;
|
extern char *g_username;
|
||||||
extern char g_hostname[16];
|
extern char g_hostname[16];
|
||||||
@ -35,7 +35,7 @@ RD_BOOL g_licence_error_result = False;
|
|||||||
|
|
||||||
/* Generate a session key and RC4 keys, given client and server randoms */
|
/* Generate a session key and RC4 keys, given client and server randoms */
|
||||||
static void
|
static void
|
||||||
licence_generate_keys(uint8 * client_random, uint8 * server_random, uint8 * pre_master_secret)
|
licence_generate_keys(const uint8 * client_random, const uint8 * server_random, const uint8 * pre_master_secret)
|
||||||
{
|
{
|
||||||
uint8 master_secret[48];
|
uint8 master_secret[48];
|
||||||
uint8 key_block[48];
|
uint8 key_block[48];
|
||||||
@ -60,12 +60,11 @@ licence_generate_hwid(uint8 * hwid)
|
|||||||
|
|
||||||
/* Send a licence info packet to server */
|
/* Send a licence info packet to server */
|
||||||
static void
|
static void
|
||||||
licence_info(uint8 * client_random, uint8 * rsa_data,
|
licence_info(const uint8 * client_random, const uint8 * rsa_data,
|
||||||
uint8 * licence_data, int licence_size, uint8 * hwid, uint8 * signature)
|
const uint8 * licence_data, int licence_size, const uint8 * hwid, const uint8 * signature)
|
||||||
{
|
{
|
||||||
uint32 sec_flags = SEC_LICENSE_PKT;
|
uint32 sec_flags = SEC_LICENSE_PKT;
|
||||||
uint16 length =
|
uint16 length = 24 + SEC_RANDOM_SIZE + SEC_MODULUS_SIZE + SEC_PADDING_SIZE +
|
||||||
24 + SEC_RANDOM_SIZE + SEC_MODULUS_SIZE + SEC_PADDING_SIZE +
|
|
||||||
licence_size + LICENCE_HWID_SIZE + LICENCE_SIGNATURE_SIZE;
|
licence_size + LICENCE_HWID_SIZE + LICENCE_SIGNATURE_SIZE;
|
||||||
STREAM s;
|
STREAM s;
|
||||||
|
|
||||||
@ -102,13 +101,12 @@ licence_info(uint8 * client_random, uint8 * rsa_data,
|
|||||||
|
|
||||||
/* Send a new licence request packet */
|
/* Send a new licence request packet */
|
||||||
static void
|
static void
|
||||||
licence_send_new_licence_request(uint8 * client_random, uint8 * rsa_data, char *user, char *host)
|
licence_send_new_licence_request(const uint8 * client_random, const uint8 * rsa_data, const char *user, const char *host)
|
||||||
{
|
{
|
||||||
uint32 sec_flags = SEC_LICENSE_PKT;
|
uint32 sec_flags = SEC_LICENSE_PKT;
|
||||||
uint16 userlen = strlen(user) + 1;
|
uint16 userlen = strlen(user) + 1;
|
||||||
uint16 hostlen = strlen(host) + 1;
|
uint16 hostlen = strlen(host) + 1;
|
||||||
uint16 length =
|
uint16 length = 24 + SEC_RANDOM_SIZE + SEC_MODULUS_SIZE + SEC_PADDING_SIZE + userlen + hostlen;
|
||||||
24 + SEC_RANDOM_SIZE + SEC_MODULUS_SIZE + SEC_PADDING_SIZE + userlen + hostlen;
|
|
||||||
STREAM s;
|
STREAM s;
|
||||||
|
|
||||||
s = sec_init(sec_flags, length + 2);
|
s = sec_init(sec_flags, length + 2);
|
||||||
@ -146,7 +144,7 @@ licence_send_new_licence_request(uint8 * client_random, uint8 * rsa_data, char *
|
|||||||
static void
|
static void
|
||||||
licence_process_request(STREAM s)
|
licence_process_request(STREAM s)
|
||||||
{
|
{
|
||||||
uint8 null_data[SEC_MODULUS_SIZE];
|
uint8 null_data[SEC_MODULUS_SIZE] = {0};
|
||||||
uint8 *server_random;
|
uint8 *server_random;
|
||||||
uint8 signature[LICENCE_SIGNATURE_SIZE];
|
uint8 signature[LICENCE_SIGNATURE_SIZE];
|
||||||
uint8 hwid[LICENCE_HWID_SIZE];
|
uint8 hwid[LICENCE_HWID_SIZE];
|
||||||
@ -159,7 +157,6 @@ licence_process_request(STREAM s)
|
|||||||
|
|
||||||
/* We currently use null client keys. This is a bit naughty but, hey,
|
/* We currently use null client keys. This is a bit naughty but, hey,
|
||||||
the security of licence negotiation isn't exactly paramount. */
|
the security of licence negotiation isn't exactly paramount. */
|
||||||
memset(null_data, 0, sizeof(null_data));
|
|
||||||
licence_generate_keys(null_data, server_random, null_data);
|
licence_generate_keys(null_data, server_random, null_data);
|
||||||
|
|
||||||
licence_size = load_licence(&licence_data);
|
licence_size = load_licence(&licence_data);
|
||||||
@ -179,7 +176,7 @@ licence_process_request(STREAM s)
|
|||||||
|
|
||||||
licence_info(null_data, null_data, licence_data, licence_size, hwid, signature);
|
licence_info(null_data, null_data, licence_data, licence_size, hwid, signature);
|
||||||
|
|
||||||
xfree(licence_data);
|
free(licence_data);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -192,7 +189,7 @@ licence_process_request(STREAM s)
|
|||||||
|
|
||||||
/* Send a platform challenge response packet */
|
/* Send a platform challenge response packet */
|
||||||
static void
|
static void
|
||||||
licence_send_platform_challenge_response(uint8 * token, uint8 * crypt_hwid, uint8 * signature)
|
licence_send_platform_challenge_response(const uint8 * token, const uint8 * crypt_hwid, const uint8 * signature)
|
||||||
{
|
{
|
||||||
uint32 sec_flags = SEC_LICENSE_PKT;
|
uint32 sec_flags = SEC_LICENSE_PKT;
|
||||||
uint16 length = 58;
|
uint16 length = 58;
|
||||||
@ -219,7 +216,7 @@ licence_send_platform_challenge_response(uint8 * token, uint8 * crypt_hwid, uint
|
|||||||
s_free(s);
|
s_free(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Parse an platform challenge request packet */
|
/* Parse a platform challenge request packet */
|
||||||
static RD_BOOL
|
static RD_BOOL
|
||||||
licence_parse_platform_challenge(STREAM s, uint8 ** token, uint8 ** signature)
|
licence_parse_platform_challenge(STREAM s, uint8 ** token, uint8 ** signature)
|
||||||
{
|
{
|
||||||
@ -301,7 +298,6 @@ licence_process_new_license(STREAM s)
|
|||||||
|
|
||||||
/* Skip strings, Scope, CompanyName and ProductId to get
|
/* Skip strings, Scope, CompanyName and ProductId to get
|
||||||
to the LicenseInfo which we store in license blob. */
|
to the LicenseInfo which we store in license blob. */
|
||||||
length = 0;
|
|
||||||
for (i = 0; i < 4; i++)
|
for (i = 0; i < 4; i++)
|
||||||
{
|
{
|
||||||
in_uint8s(s, length);
|
in_uint8s(s, length);
|
||||||
@ -315,7 +311,7 @@ licence_process_new_license(STREAM s)
|
|||||||
save_licence(data, length);
|
save_licence(data, length);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* process a licence error alert packet */
|
/* Process a licence error alert packet */
|
||||||
void
|
void
|
||||||
licence_process_error_alert(STREAM s)
|
licence_process_error_alert(STREAM s)
|
||||||
{
|
{
|
||||||
@ -330,7 +326,7 @@ licence_process_error_alert(STREAM s)
|
|||||||
and the server is not sending a license to client, a "Server License Error PDU -
|
and the server is not sending a license to client, a "Server License Error PDU -
|
||||||
Valid Client" packet is sent which means, every thing is ok.
|
Valid Client" packet is sent which means, every thing is ok.
|
||||||
|
|
||||||
Therefor we should flag that everything is ok with license here.
|
Therefore we should flag that everything is ok with license here.
|
||||||
*/
|
*/
|
||||||
if (error_code == 0x07)
|
if (error_code == 0x07)
|
||||||
{
|
{
|
||||||
@ -338,7 +334,7 @@ licence_process_error_alert(STREAM s)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* handle error codes, for now, just report them */
|
/* Handle error codes, for now, just report them */
|
||||||
switch (error_code)
|
switch (error_code)
|
||||||
{
|
{
|
||||||
case 0x6: // ERR_NO_LICENSE_SERVER
|
case 0x6: // ERR_NO_LICENSE_SERVER
|
||||||
@ -362,7 +358,6 @@ licence_process_error_alert(STREAM s)
|
|||||||
g_licence_error_result = True;
|
g_licence_error_result = True;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Process a licence packet */
|
/* Process a licence packet */
|
||||||
void
|
void
|
||||||
licence_process(STREAM s)
|
licence_process(STREAM s)
|
||||||
@ -397,6 +392,6 @@ licence_process(STREAM s)
|
|||||||
|
|
||||||
default:
|
default:
|
||||||
logger(Protocol, Warning,
|
logger(Protocol, Warning,
|
||||||
"license_process(), unhandled license PDU tag 0x%02", tag);
|
"license_process(), unhandled license PDU tag 0x%02x", tag);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
39
lspci.c
39
lspci.c
@ -21,6 +21,7 @@
|
|||||||
#include "rdesktop.h"
|
#include "rdesktop.h"
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
static VCHANNEL *lspci_channel;
|
static VCHANNEL *lspci_channel;
|
||||||
|
|
||||||
@ -50,42 +51,40 @@ handle_child_line(const char *line, void *data)
|
|||||||
|
|
||||||
if (str_startswith(line, "Class:"))
|
if (str_startswith(line, "Class:"))
|
||||||
{
|
{
|
||||||
val = line + sizeof("Class:");
|
val = line + strlen("Class:");
|
||||||
/* Skip whitespace and second Class: occurrence */
|
val += strspn(val, " \t"); /* Skip whitespace */
|
||||||
val += strspn(val, " \t") + sizeof("Class");
|
|
||||||
current_device.klass = strtol(val, NULL, 16);
|
current_device.klass = strtol(val, NULL, 16);
|
||||||
}
|
}
|
||||||
else if (str_startswith(line, "Vendor:"))
|
else if (str_startswith(line, "Vendor:"))
|
||||||
{
|
{
|
||||||
val = line + sizeof("Vendor:");
|
val = line + strlen("Vendor:");
|
||||||
current_device.vendor = strtol(val, NULL, 16);
|
current_device.vendor = strtol(val, NULL, 16);
|
||||||
}
|
}
|
||||||
else if (str_startswith(line, "Device:"))
|
else if (str_startswith(line, "Device:"))
|
||||||
{
|
{
|
||||||
val = line + sizeof("Device:");
|
val = line + strlen("Device:");
|
||||||
/* Sigh, there are *two* lines tagged as Device:. We
|
/* Ignore the domain/bus/slot/func line */
|
||||||
are not interested in the domain/bus/slot/func */
|
|
||||||
if (!strchr(val, ':'))
|
if (!strchr(val, ':'))
|
||||||
current_device.device = strtol(val, NULL, 16);
|
current_device.device = strtol(val, NULL, 16);
|
||||||
}
|
}
|
||||||
else if (str_startswith(line, "SVendor:"))
|
else if (str_startswith(line, "SVendor:"))
|
||||||
{
|
{
|
||||||
val = line + sizeof("SVendor:");
|
val = line + strlen("SVendor:");
|
||||||
current_device.subvendor = strtol(val, NULL, 16);
|
current_device.subvendor = strtol(val, NULL, 16);
|
||||||
}
|
}
|
||||||
else if (str_startswith(line, "SDevice:"))
|
else if (str_startswith(line, "SDevice:"))
|
||||||
{
|
{
|
||||||
val = line + sizeof("SDevice:");
|
val = line + strlen("SDevice:");
|
||||||
current_device.subdevice = strtol(val, NULL, 16);
|
current_device.subdevice = strtol(val, NULL, 16);
|
||||||
}
|
}
|
||||||
else if (str_startswith(line, "Rev:"))
|
else if (str_startswith(line, "Rev:"))
|
||||||
{
|
{
|
||||||
val = line + sizeof("Rev:");
|
val = line + strlen("Rev:");
|
||||||
current_device.revision = strtol(val, NULL, 16);
|
current_device.revision = strtol(val, NULL, 16);
|
||||||
}
|
}
|
||||||
else if (str_startswith(line, "ProgIf:"))
|
else if (str_startswith(line, "ProgIf:"))
|
||||||
{
|
{
|
||||||
val = line + sizeof("ProgIf:");
|
val = line + strlen("ProgIf:");
|
||||||
current_device.progif = strtol(val, NULL, 16);
|
current_device.progif = strtol(val, NULL, 16);
|
||||||
}
|
}
|
||||||
else if (strspn(line, " \t") == strlen(line))
|
else if (strspn(line, " \t") == strlen(line))
|
||||||
@ -111,12 +110,12 @@ static RD_BOOL
|
|||||||
lspci_process_line(const char *line, void *data)
|
lspci_process_line(const char *line, void *data)
|
||||||
{
|
{
|
||||||
UNUSED(data);
|
UNUSED(data);
|
||||||
char *lspci_command[5] = { "lspci", "-m", "-n", "-v", NULL };
|
const char *lspci_command[] = { "lspci", "-m", "-n", "-v", NULL };
|
||||||
|
|
||||||
if (!strcmp(line, "LSPCI"))
|
if (strcmp(line, "LSPCI") == 0)
|
||||||
{
|
{
|
||||||
memset(¤t_device, 0, sizeof(current_device));
|
memset(¤t_device, 0, sizeof(current_device));
|
||||||
subprocess(lspci_command, handle_child_line, NULL);
|
subprocess((char **)lspci_command, handle_child_line, NULL);
|
||||||
/* Send single dot to indicate end of enumeration */
|
/* Send single dot to indicate end of enumeration */
|
||||||
lspci_send(".\n");
|
lspci_send(".\n");
|
||||||
}
|
}
|
||||||
@ -138,11 +137,16 @@ lspci_process(STREAM s)
|
|||||||
|
|
||||||
pkglen = s_remaining(s);
|
pkglen = s_remaining(s);
|
||||||
/* str_handle_lines requires null terminated strings */
|
/* str_handle_lines requires null terminated strings */
|
||||||
buf = xmalloc(pkglen + 1);
|
buf = (char *)malloc(pkglen + 1);
|
||||||
|
if (!buf)
|
||||||
|
{
|
||||||
|
logger(Core, Error, "lspci_process(), memory allocation failed");
|
||||||
|
return;
|
||||||
|
}
|
||||||
in_uint8a(s, buf, pkglen);
|
in_uint8a(s, buf, pkglen);
|
||||||
buf[pkglen] = '\0';
|
buf[pkglen] = '\0';
|
||||||
str_handle_lines(buf, &rest, lspci_process_line, NULL);
|
str_handle_lines(buf, &rest, lspci_process_line, NULL);
|
||||||
xfree(buf);
|
free(buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Initialize this module: Register the lspci channel */
|
/* Initialize this module: Register the lspci channel */
|
||||||
@ -164,7 +168,8 @@ lspci_send(const char *output)
|
|||||||
|
|
||||||
len = strlen(output);
|
len = strlen(output);
|
||||||
s = channel_init(lspci_channel, len);
|
s = channel_init(lspci_channel, len);
|
||||||
out_uint8a(s, output, len) s_mark_end(s);
|
out_uint8a(s, output, len);
|
||||||
|
s_mark_end(s);
|
||||||
channel_send(s, lspci_channel);
|
channel_send(s, lspci_channel);
|
||||||
s_free(s);
|
s_free(s);
|
||||||
}
|
}
|
||||||
|
68
mcs.c
68
mcs.c
@ -25,10 +25,8 @@ uint16 g_mcs_userid;
|
|||||||
extern VCHANNEL g_channels[];
|
extern VCHANNEL g_channels[];
|
||||||
extern unsigned int g_num_channels;
|
extern unsigned int g_num_channels;
|
||||||
|
|
||||||
|
|
||||||
/* Output a DOMAIN_PARAMS structure (ASN.1 BER) */
|
/* Output a DOMAIN_PARAMS structure (ASN.1 BER) */
|
||||||
static void
|
static void mcs_out_domain_params(STREAM s, int max_channels, int max_users, int max_tokens, int max_pdusize)
|
||||||
mcs_out_domain_params(STREAM s, int max_channels, int max_users, int max_tokens, int max_pdusize)
|
|
||||||
{
|
{
|
||||||
ber_out_header(s, MCS_TAG_DOMAIN_PARAMS, 32);
|
ber_out_header(s, MCS_TAG_DOMAIN_PARAMS, 32);
|
||||||
ber_out_integer(s, max_channels);
|
ber_out_integer(s, max_channels);
|
||||||
@ -42,8 +40,7 @@ mcs_out_domain_params(STREAM s, int max_channels, int max_users, int max_tokens,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Parse a DOMAIN_PARAMS structure (ASN.1 BER) */
|
/* Parse a DOMAIN_PARAMS structure (ASN.1 BER) */
|
||||||
static void
|
static void mcs_parse_domain_params(STREAM s)
|
||||||
mcs_parse_domain_params(STREAM s)
|
|
||||||
{
|
{
|
||||||
uint32 length;
|
uint32 length;
|
||||||
struct stream packet = *s;
|
struct stream packet = *s;
|
||||||
@ -59,12 +56,12 @@ mcs_parse_domain_params(STREAM s)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Send an MCS_CONNECT_INITIAL message (ASN.1 BER) */
|
/* Send an MCS_CONNECT_INITIAL message (ASN.1 BER) */
|
||||||
static void
|
static void mcs_send_connect_initial(STREAM mcs_data)
|
||||||
mcs_send_connect_initial(STREAM mcs_data)
|
|
||||||
{
|
{
|
||||||
int datalen = s_length(mcs_data);
|
int datalen = s_length(mcs_data);
|
||||||
int length = 9 + 3 * 34 + 4 + datalen;
|
int length = 9 + 3 * 34 + 4 + datalen;
|
||||||
STREAM s;
|
STREAM s;
|
||||||
|
|
||||||
logger(Protocol, Debug, "%s()", __func__);
|
logger(Protocol, Debug, "%s()", __func__);
|
||||||
s = iso_init(length + 5);
|
s = iso_init(length + 5);
|
||||||
|
|
||||||
@ -90,8 +87,7 @@ mcs_send_connect_initial(STREAM mcs_data)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Expect a MCS_CONNECT_RESPONSE message (ASN.1 BER) */
|
/* Expect a MCS_CONNECT_RESPONSE message (ASN.1 BER) */
|
||||||
static RD_BOOL
|
static RD_BOOL mcs_recv_connect_response(STREAM mcs_data)
|
||||||
mcs_recv_connect_response(STREAM mcs_data)
|
|
||||||
{
|
{
|
||||||
UNUSED(mcs_data);
|
UNUSED(mcs_data);
|
||||||
uint8 result;
|
uint8 result;
|
||||||
@ -132,24 +128,12 @@ mcs_recv_connect_response(STREAM mcs_data)
|
|||||||
ber_parse_header(s, BER_TAG_OCTET_STRING, &length);
|
ber_parse_header(s, BER_TAG_OCTET_STRING, &length);
|
||||||
|
|
||||||
sec_process_mcs_data(s);
|
sec_process_mcs_data(s);
|
||||||
/*
|
|
||||||
if (length > mcs_data->size)
|
|
||||||
{
|
|
||||||
logger(Protocol, Error, "mcs_recv_connect_response(), expected length=%d, got %d",length, mcs_data->size);
|
|
||||||
length = mcs_data->size;
|
|
||||||
}
|
|
||||||
|
|
||||||
s_reset(mcs_data);
|
|
||||||
in_uint8stream(s, mcs_data, length);
|
|
||||||
s_mark_end(mcs_data);
|
|
||||||
s_seek(mcs_data, 0);
|
|
||||||
*/
|
|
||||||
return s_check_end(s);
|
return s_check_end(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Send an EDrq message (ASN.1 PER) */
|
/* Send an EDrq message (ASN.1 PER) */
|
||||||
static void
|
static void mcs_send_edrq(void)
|
||||||
mcs_send_edrq(void)
|
|
||||||
{
|
{
|
||||||
STREAM s;
|
STREAM s;
|
||||||
logger(Protocol, Debug, "%s()", __func__);
|
logger(Protocol, Debug, "%s()", __func__);
|
||||||
@ -165,8 +149,7 @@ mcs_send_edrq(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Send an AUrq message (ASN.1 PER) */
|
/* Send an AUrq message (ASN.1 PER) */
|
||||||
static void
|
static void mcs_send_aurq(void)
|
||||||
mcs_send_aurq(void)
|
|
||||||
{
|
{
|
||||||
STREAM s;
|
STREAM s;
|
||||||
logger(Protocol, Debug, "%s()", __func__);
|
logger(Protocol, Debug, "%s()", __func__);
|
||||||
@ -180,8 +163,7 @@ mcs_send_aurq(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Expect a AUcf message (ASN.1 PER) */
|
/* Expect a AUcf message (ASN.1 PER) */
|
||||||
static RD_BOOL
|
static RD_BOOL mcs_recv_aucf(uint16 * mcs_userid)
|
||||||
mcs_recv_aucf(uint16 * mcs_userid)
|
|
||||||
{
|
{
|
||||||
RD_BOOL is_fastpath;
|
RD_BOOL is_fastpath;
|
||||||
uint8 fastpath_hdr;
|
uint8 fastpath_hdr;
|
||||||
@ -215,8 +197,7 @@ mcs_recv_aucf(uint16 * mcs_userid)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Send a CJrq message (ASN.1 PER) */
|
/* Send a CJrq message (ASN.1 PER) */
|
||||||
static void
|
static void mcs_send_cjrq(uint16 chanid)
|
||||||
mcs_send_cjrq(uint16 chanid)
|
|
||||||
{
|
{
|
||||||
STREAM s;
|
STREAM s;
|
||||||
|
|
||||||
@ -234,8 +215,7 @@ mcs_send_cjrq(uint16 chanid)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Expect a CJcf message (ASN.1 PER) */
|
/* Expect a CJcf message (ASN.1 PER) */
|
||||||
static RD_BOOL
|
static RD_BOOL mcs_recv_cjcf(void)
|
||||||
mcs_recv_cjcf(void)
|
|
||||||
{
|
{
|
||||||
RD_BOOL is_fastpath;
|
RD_BOOL is_fastpath;
|
||||||
uint8 fastpath_hdr;
|
uint8 fastpath_hdr;
|
||||||
@ -269,10 +249,8 @@ mcs_recv_cjcf(void)
|
|||||||
return s_check_end(s);
|
return s_check_end(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Send MCS Disconnect provider ultimatum PDU */
|
/* Send MCS Disconnect provider ultimatum PDU */
|
||||||
void
|
void mcs_send_dpu(unsigned short reason)
|
||||||
mcs_send_dpu(unsigned short reason)
|
|
||||||
{
|
{
|
||||||
STREAM s, contents;
|
STREAM s, contents;
|
||||||
|
|
||||||
@ -294,8 +272,7 @@ mcs_send_dpu(unsigned short reason)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Initialise an MCS transport data packet */
|
/* Initialise an MCS transport data packet */
|
||||||
STREAM
|
STREAM mcs_init(int length)
|
||||||
mcs_init(int length)
|
|
||||||
{
|
{
|
||||||
STREAM s;
|
STREAM s;
|
||||||
|
|
||||||
@ -306,8 +283,7 @@ mcs_init(int length)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Send an MCS transport data packet to a specific channel */
|
/* Send an MCS transport data packet to a specific channel */
|
||||||
void
|
void mcs_send_to_channel(STREAM s, uint16 channel)
|
||||||
mcs_send_to_channel(STREAM s, uint16 channel)
|
|
||||||
{
|
{
|
||||||
uint16 length;
|
uint16 length;
|
||||||
|
|
||||||
@ -325,15 +301,13 @@ mcs_send_to_channel(STREAM s, uint16 channel)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Send an MCS transport data packet to the global channel */
|
/* Send an MCS transport data packet to the global channel */
|
||||||
void
|
void mcs_send(STREAM s)
|
||||||
mcs_send(STREAM s)
|
|
||||||
{
|
{
|
||||||
mcs_send_to_channel(s, MCS_GLOBAL_CHANNEL);
|
mcs_send_to_channel(s, MCS_GLOBAL_CHANNEL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Receive an MCS transport data packet */
|
/* Receive an MCS transport data packet */
|
||||||
STREAM
|
STREAM mcs_recv(uint16 * channel, RD_BOOL * is_fastpath, uint8 * fastpath_hdr)
|
||||||
mcs_recv(uint16 * channel, RD_BOOL * is_fastpath, uint8 * fastpath_hdr)
|
|
||||||
{
|
{
|
||||||
uint8 opcode, appid, length;
|
uint8 opcode, appid, length;
|
||||||
STREAM s;
|
STREAM s;
|
||||||
@ -364,16 +338,14 @@ mcs_recv(uint16 * channel, RD_BOOL * is_fastpath, uint8 * fastpath_hdr)
|
|||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
RD_BOOL
|
RD_BOOL mcs_connect_start(char *server, char *username, char *domain, char *password,
|
||||||
mcs_connect_start(char *server, char *username, char *domain, char *password,
|
|
||||||
RD_BOOL reconnect, uint32 * selected_protocol)
|
RD_BOOL reconnect, uint32 * selected_protocol)
|
||||||
{
|
{
|
||||||
logger(Protocol, Debug, "%s()", __func__);
|
logger(Protocol, Debug, "%s()", __func__);
|
||||||
return iso_connect(server, username, domain, password, reconnect, selected_protocol);
|
return iso_connect(server, username, domain, password, reconnect, selected_protocol);
|
||||||
}
|
}
|
||||||
|
|
||||||
RD_BOOL
|
RD_BOOL mcs_connect_finalize(STREAM mcs_data)
|
||||||
mcs_connect_finalize(STREAM mcs_data)
|
|
||||||
{
|
{
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
|
|
||||||
@ -411,16 +383,14 @@ mcs_connect_finalize(STREAM mcs_data)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Disconnect from the MCS layer */
|
/* Disconnect from the MCS layer */
|
||||||
void
|
void mcs_disconnect(int reason)
|
||||||
mcs_disconnect(int reason)
|
|
||||||
{
|
{
|
||||||
mcs_send_dpu(reason);
|
mcs_send_dpu(reason);
|
||||||
iso_disconnect();
|
iso_disconnect();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* reset the state of the mcs layer */
|
/* reset the state of the mcs layer */
|
||||||
void
|
void mcs_reset_state(void)
|
||||||
mcs_reset_state(void)
|
|
||||||
{
|
{
|
||||||
g_mcs_userid = 0;
|
g_mcs_userid = 0;
|
||||||
iso_reset_state();
|
iso_reset_state();
|
||||||
|
123
mppc.c
123
mppc.c
@ -22,40 +22,19 @@
|
|||||||
|
|
||||||
#include "rdesktop.h"
|
#include "rdesktop.h"
|
||||||
|
|
||||||
/* mppc decompression */
|
/* MPPC decompression based on RFC 2118 */
|
||||||
/* http://www.faqs.org/rfcs/rfc2118.html */
|
|
||||||
|
|
||||||
/* Contacts: */
|
|
||||||
|
|
||||||
/* hifn contact mentioned in the FAQ is */
|
|
||||||
/* Robert Friend rfriend at hifn dot com */
|
|
||||||
|
|
||||||
/* if you have questions regarding MPPC */
|
|
||||||
/* our contact is */
|
|
||||||
/* Guus Dhaeze GDhaeze at hifn dot com */
|
|
||||||
|
|
||||||
/* Licensing: */
|
/* Licensing: */
|
||||||
|
/* Decompression is allowed as long as we */
|
||||||
/* decompression is alright as long as we */
|
|
||||||
/* don't compress data */
|
/* don't compress data */
|
||||||
|
|
||||||
/* Algorithm: */
|
/* The algorithm is LZS and is patented for another couple of years. */
|
||||||
|
/* More information: */
|
||||||
/* as the RFC states the algorithm seems to */
|
|
||||||
/* be LZ77 with a sliding buffer */
|
|
||||||
/* that is empty at init. */
|
|
||||||
|
|
||||||
/* the algorithm is called LZS and is */
|
|
||||||
/* patented for another couple of years. */
|
|
||||||
|
|
||||||
/* more information is available in */
|
|
||||||
/* http://www.ietf.org/ietf/IPR/hifn-ipr-draft-friend-tls-lzs-compression.txt */
|
/* http://www.ietf.org/ietf/IPR/hifn-ipr-draft-friend-tls-lzs-compression.txt */
|
||||||
|
|
||||||
|
|
||||||
RDPCOMP g_mppc_dict;
|
RDPCOMP g_mppc_dict;
|
||||||
|
|
||||||
int
|
int mppc_expand(uint8 *data, uint32 clen, uint8 ctype, uint32 *roff, uint32 *rlen)
|
||||||
mppc_expand(uint8 * data, uint32 clen, uint8 ctype, uint32 * roff, uint32 * rlen)
|
|
||||||
{
|
{
|
||||||
int k, walker_len = 0, walker;
|
int k, walker_len = 0, walker;
|
||||||
uint32 i = 0;
|
uint32 i = 0;
|
||||||
@ -88,12 +67,13 @@ mppc_expand(uint8 * data, uint32 clen, uint8 ctype, uint32 * roff, uint32 * rlen
|
|||||||
*rlen = 0;
|
*rlen = 0;
|
||||||
|
|
||||||
walker = g_mppc_dict.roff;
|
walker = g_mppc_dict.roff;
|
||||||
|
|
||||||
next_offset = walker;
|
next_offset = walker;
|
||||||
old_offset = next_offset;
|
old_offset = next_offset;
|
||||||
*roff = old_offset;
|
*roff = old_offset;
|
||||||
|
|
||||||
if (clen == 0)
|
if (clen == 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
clen += i;
|
clen += i;
|
||||||
|
|
||||||
do
|
do
|
||||||
@ -120,13 +100,12 @@ mppc_expand(uint8 * data, uint32 clen, uint8 ctype, uint32 * roff, uint32 * rlen
|
|||||||
}
|
}
|
||||||
if (next_offset >= RDP_MPPC_DICT_SIZE)
|
if (next_offset >= RDP_MPPC_DICT_SIZE)
|
||||||
return -1;
|
return -1;
|
||||||
dict[next_offset++] = (((uint32) walker) >> ((uint32) 24));
|
dict[next_offset++] = (uint8)((uint32)walker >> 24);
|
||||||
walker <<= 8;
|
walker <<= 8;
|
||||||
walker_len -= 8;
|
walker_len -= 8;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
walker <<= 1;
|
walker <<= 1;
|
||||||
/* fetch next 8-bits */
|
|
||||||
if (--walker_len == 0)
|
if (--walker_len == 0)
|
||||||
{
|
{
|
||||||
if (i >= clen)
|
if (i >= clen)
|
||||||
@ -134,7 +113,6 @@ mppc_expand(uint8 * data, uint32 clen, uint8 ctype, uint32 * roff, uint32 * rlen
|
|||||||
walker = data[i++] << 24;
|
walker = data[i++] << 24;
|
||||||
walker_len = 8;
|
walker_len = 8;
|
||||||
}
|
}
|
||||||
/* literal decoding */
|
|
||||||
if (walker >= 0)
|
if (walker >= 0)
|
||||||
{
|
{
|
||||||
if (walker_len < 8)
|
if (walker_len < 8)
|
||||||
@ -152,8 +130,6 @@ mppc_expand(uint8 * data, uint32 clen, uint8 ctype, uint32 * roff, uint32 * rlen
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* decode offset */
|
|
||||||
/* length pair */
|
|
||||||
walker <<= 1;
|
walker <<= 1;
|
||||||
if (--walker_len < (big ? 3 : 2))
|
if (--walker_len < (big ? 3 : 2))
|
||||||
{
|
{
|
||||||
@ -165,15 +141,9 @@ mppc_expand(uint8 * data, uint32 clen, uint8 ctype, uint32 * roff, uint32 * rlen
|
|||||||
|
|
||||||
if (big)
|
if (big)
|
||||||
{
|
{
|
||||||
/* offset decoding where offset len is:
|
switch (((uint32)walker) >> 29)
|
||||||
-63: 11111 followed by the lower 6 bits of the value
|
|
||||||
64-319: 11110 followed by the lower 8 bits of the value ( value - 64 )
|
|
||||||
320-2367: 1110 followed by lower 11 bits of the value ( value - 320 )
|
|
||||||
2368-65535: 110 followed by lower 16 bits of the value ( value - 2368 )
|
|
||||||
*/
|
|
||||||
switch (((uint32) walker) >> ((uint32) 29))
|
|
||||||
{
|
{
|
||||||
case 7: /* - 63 */
|
case 7:
|
||||||
for (; walker_len < 9; walker_len += 8)
|
for (; walker_len < 9; walker_len += 8)
|
||||||
{
|
{
|
||||||
if (i >= clen)
|
if (i >= clen)
|
||||||
@ -181,50 +151,44 @@ mppc_expand(uint8 * data, uint32 clen, uint8 ctype, uint32 * roff, uint32 * rlen
|
|||||||
walker |= (data[i++] & 0xff) << (24 - walker_len);
|
walker |= (data[i++] & 0xff) << (24 - walker_len);
|
||||||
}
|
}
|
||||||
walker <<= 3;
|
walker <<= 3;
|
||||||
match_off = ((uint32) walker) >> ((uint32) 26);
|
match_off = ((uint32)walker) >> 26;
|
||||||
walker <<= 6;
|
walker <<= 6;
|
||||||
walker_len -= 9;
|
walker_len -= 9;
|
||||||
break;
|
break;
|
||||||
|
case 6:
|
||||||
case 6: /* 64 - 319 */
|
|
||||||
for (; walker_len < 11; walker_len += 8)
|
for (; walker_len < 11; walker_len += 8)
|
||||||
{
|
{
|
||||||
if (i >= clen)
|
if (i >= clen)
|
||||||
return -1;
|
return -1;
|
||||||
walker |= (data[i++] & 0xff) << (24 - walker_len);
|
walker |= (data[i++] & 0xff) << (24 - walker_len);
|
||||||
}
|
}
|
||||||
|
|
||||||
walker <<= 3;
|
walker <<= 3;
|
||||||
match_off = (((uint32) walker) >> ((uint32) 24)) + 64;
|
match_off = (((uint32)walker) >> 24) + 64;
|
||||||
walker <<= 8;
|
walker <<= 8;
|
||||||
walker_len -= 11;
|
walker_len -= 11;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 5:
|
case 5:
|
||||||
case 4: /* 320 - 2367 */
|
case 4:
|
||||||
for (; walker_len < 13; walker_len += 8)
|
for (; walker_len < 13; walker_len += 8)
|
||||||
{
|
{
|
||||||
if (i >= clen)
|
if (i >= clen)
|
||||||
return -1;
|
return -1;
|
||||||
walker |= (data[i++] & 0xff) << (24 - walker_len);
|
walker |= (data[i++] & 0xff) << (24 - walker_len);
|
||||||
}
|
}
|
||||||
|
|
||||||
walker <<= 2;
|
walker <<= 2;
|
||||||
match_off = (((uint32) walker) >> ((uint32) 21)) + 320;
|
match_off = (((uint32)walker) >> 21) + 320;
|
||||||
walker <<= 11;
|
walker <<= 11;
|
||||||
walker_len -= 13;
|
walker_len -= 13;
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
default: /* 2368 - 65535 */
|
|
||||||
for (; walker_len < 17; walker_len += 8)
|
for (; walker_len < 17; walker_len += 8)
|
||||||
{
|
{
|
||||||
if (i >= clen)
|
if (i >= clen)
|
||||||
return -1;
|
return -1;
|
||||||
walker |= (data[i++] & 0xff) << (24 - walker_len);
|
walker |= (data[i++] & 0xff) << (24 - walker_len);
|
||||||
}
|
}
|
||||||
|
|
||||||
walker <<= 1;
|
walker <<= 1;
|
||||||
match_off = (((uint32) walker) >> ((uint32) 16)) + 2368;
|
match_off = (((uint32)walker) >> 16) + 2368;
|
||||||
walker <<= 16;
|
walker <<= 16;
|
||||||
walker_len -= 17;
|
walker_len -= 17;
|
||||||
break;
|
break;
|
||||||
@ -232,14 +196,9 @@ mppc_expand(uint8 * data, uint32 clen, uint8 ctype, uint32 * roff, uint32 * rlen
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* offset decoding where offset len is:
|
switch (((uint32)walker) >> 30)
|
||||||
-63: 1111 followed by the lower 6 bits of the value
|
|
||||||
64-319: 1110 followed by the lower 8 bits of the value ( value - 64 )
|
|
||||||
320-8191: 110 followed by the lower 13 bits of the value ( value - 320 )
|
|
||||||
*/
|
|
||||||
switch (((uint32) walker) >> ((uint32) 30))
|
|
||||||
{
|
{
|
||||||
case 3: /* - 63 */
|
case 3:
|
||||||
if (walker_len < 8)
|
if (walker_len < 8)
|
||||||
{
|
{
|
||||||
if (i >= clen)
|
if (i >= clen)
|
||||||
@ -248,33 +207,29 @@ mppc_expand(uint8 * data, uint32 clen, uint8 ctype, uint32 * roff, uint32 * rlen
|
|||||||
walker_len += 8;
|
walker_len += 8;
|
||||||
}
|
}
|
||||||
walker <<= 2;
|
walker <<= 2;
|
||||||
match_off = ((uint32) walker) >> ((uint32) 26);
|
match_off = ((uint32)walker) >> 26;
|
||||||
walker <<= 6;
|
walker <<= 6;
|
||||||
walker_len -= 8;
|
walker_len -= 8;
|
||||||
break;
|
break;
|
||||||
|
case 2:
|
||||||
case 2: /* 64 - 319 */
|
|
||||||
for (; walker_len < 10; walker_len += 8)
|
for (; walker_len < 10; walker_len += 8)
|
||||||
{
|
{
|
||||||
if (i >= clen)
|
if (i >= clen)
|
||||||
return -1;
|
return -1;
|
||||||
walker |= (data[i++] & 0xff) << (24 - walker_len);
|
walker |= (data[i++] & 0xff) << (24 - walker_len);
|
||||||
}
|
}
|
||||||
|
|
||||||
walker <<= 2;
|
walker <<= 2;
|
||||||
match_off = (((uint32) walker) >> ((uint32) 24)) + 64;
|
match_off = (((uint32)walker) >> 24) + 64;
|
||||||
walker <<= 8;
|
walker <<= 8;
|
||||||
walker_len -= 10;
|
walker_len -= 10;
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
default: /* 320 - 8191 */
|
|
||||||
for (; walker_len < 14; walker_len += 8)
|
for (; walker_len < 14; walker_len += 8)
|
||||||
{
|
{
|
||||||
if (i >= clen)
|
if (i >= clen)
|
||||||
return -1;
|
return -1;
|
||||||
walker |= (data[i++] & 0xff) << (24 - walker_len);
|
walker |= (data[i++] & 0xff) << (24 - walker_len);
|
||||||
}
|
}
|
||||||
|
|
||||||
match_off = (walker >> 18) + 320;
|
match_off = (walker >> 18) + 320;
|
||||||
walker <<= 14;
|
walker <<= 14;
|
||||||
walker_len -= 14;
|
walker_len -= 14;
|
||||||
@ -289,33 +244,16 @@ mppc_expand(uint8 * data, uint32 clen, uint8 ctype, uint32 * roff, uint32 * rlen
|
|||||||
walker_len = 8;
|
walker_len = 8;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* decode length of match */
|
|
||||||
match_len = 0;
|
match_len = 0;
|
||||||
if (walker >= 0)
|
if (walker >= 0)
|
||||||
{ /* special case - length of 3 is in bit 0 */
|
{
|
||||||
match_len = 3;
|
match_len = 3;
|
||||||
walker <<= 1;
|
walker <<= 1;
|
||||||
walker_len--;
|
walker_len--;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* this is how it works len of:
|
match_bits = big ? 14 : 11;
|
||||||
4-7: 10 followed by 2 bits of the value
|
|
||||||
8-15: 110 followed by 3 bits of the value
|
|
||||||
16-31: 1110 followed by 4 bits of the value
|
|
||||||
32-63: .... and so forth
|
|
||||||
64-127:
|
|
||||||
128-255:
|
|
||||||
256-511:
|
|
||||||
512-1023:
|
|
||||||
1024-2047:
|
|
||||||
2048-4095:
|
|
||||||
4096-8191:
|
|
||||||
|
|
||||||
i.e. 4097 is encoded as: 111111111110 000000000001
|
|
||||||
meaning 4096 + 1...
|
|
||||||
*/
|
|
||||||
match_bits = big ? 14 : 11; /* 11 or 14 bits of value at most */
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
walker <<= 1;
|
walker <<= 1;
|
||||||
@ -332,8 +270,7 @@ mppc_expand(uint8 * data, uint32 clen, uint8 ctype, uint32 * roff, uint32 * rlen
|
|||||||
{
|
{
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
} while (1);
|
||||||
while (1);
|
|
||||||
match_len = (big ? 16 : 13) - match_bits;
|
match_len = (big ? 16 : 13) - match_bits;
|
||||||
walker <<= 1;
|
walker <<= 1;
|
||||||
if (--walker_len < match_len)
|
if (--walker_len < match_len)
|
||||||
@ -359,17 +296,13 @@ mppc_expand(uint8 * data, uint32 clen, uint8 ctype, uint32 * roff, uint32 * rlen
|
|||||||
{
|
{
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
/* memory areas can overlap - meaning we can't use memXXX functions */
|
|
||||||
k = (next_offset - match_off) & (big ? 65535 : 8191);
|
k = (next_offset - match_off) & (big ? 65535 : 8191);
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
dict[next_offset++] = dict[k++];
|
dict[next_offset++] = dict[k++];
|
||||||
}
|
} while (--match_len != 0);
|
||||||
while (--match_len != 0);
|
} while (1);
|
||||||
}
|
|
||||||
while (1);
|
|
||||||
|
|
||||||
/* store history offset */
|
|
||||||
g_mppc_dict.roff = next_offset;
|
g_mppc_dict.roff = next_offset;
|
||||||
|
|
||||||
*roff = old_offset;
|
*roff = old_offset;
|
||||||
|
113
orders.c
113
orders.c
@ -25,8 +25,7 @@ static RDP_ORDER_STATE g_order_state;
|
|||||||
extern RDP_VERSION g_rdp_version;
|
extern RDP_VERSION g_rdp_version;
|
||||||
|
|
||||||
/* Read field indicating which parameters are present */
|
/* Read field indicating which parameters are present */
|
||||||
static void
|
static void rdp_in_present(STREAM s, uint32 *present, uint8 flags, int size)
|
||||||
rdp_in_present(STREAM s, uint32 * present, uint8 flags, int size)
|
|
||||||
{
|
{
|
||||||
uint8 bits;
|
uint8 bits;
|
||||||
int i;
|
int i;
|
||||||
@ -53,8 +52,7 @@ rdp_in_present(STREAM s, uint32 * present, uint8 flags, int size)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Read a co-ordinate (16-bit, or 8-bit delta) */
|
/* Read a co-ordinate (16-bit, or 8-bit delta) */
|
||||||
static void
|
static void rdp_in_coord(STREAM s, sint16 *coord, RD_BOOL delta)
|
||||||
rdp_in_coord(STREAM s, sint16 * coord, RD_BOOL delta)
|
|
||||||
{
|
{
|
||||||
sint8 change;
|
sint8 change;
|
||||||
|
|
||||||
@ -70,8 +68,7 @@ rdp_in_coord(STREAM s, sint16 * coord, RD_BOOL delta)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Parse a delta co-ordinate in polyline/polygon order form */
|
/* Parse a delta co-ordinate in polyline/polygon order form */
|
||||||
static int
|
static int parse_delta(uint8 *buffer, int *offset)
|
||||||
parse_delta(uint8 * buffer, int *offset)
|
|
||||||
{
|
{
|
||||||
int value = buffer[(*offset)++];
|
int value = buffer[(*offset)++];
|
||||||
int two_byte = value & 0x80;
|
int two_byte = value & 0x80;
|
||||||
@ -88,8 +85,7 @@ parse_delta(uint8 * buffer, int *offset)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Read a colour entry */
|
/* Read a colour entry */
|
||||||
static void
|
static void rdp_in_colour(STREAM s, uint32 *colour)
|
||||||
rdp_in_colour(STREAM s, uint32 * colour)
|
|
||||||
{
|
{
|
||||||
uint32 i;
|
uint32 i;
|
||||||
in_uint8(s, i);
|
in_uint8(s, i);
|
||||||
@ -101,8 +97,7 @@ rdp_in_colour(STREAM s, uint32 * colour)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Parse bounds information */
|
/* Parse bounds information */
|
||||||
static void
|
static void rdp_parse_bounds(STREAM s, BOUNDS *bounds)
|
||||||
rdp_parse_bounds(STREAM s, BOUNDS * bounds)
|
|
||||||
{
|
{
|
||||||
uint8 present;
|
uint8 present;
|
||||||
|
|
||||||
@ -130,8 +125,7 @@ rdp_parse_bounds(STREAM s, BOUNDS * bounds)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Parse a pen */
|
/* Parse a pen */
|
||||||
static void
|
static void rdp_parse_pen(STREAM s, PEN *pen, uint32 present)
|
||||||
rdp_parse_pen(STREAM s, PEN * pen, uint32 present)
|
|
||||||
{
|
{
|
||||||
if (present & 1)
|
if (present & 1)
|
||||||
in_uint8(s, pen->style);
|
in_uint8(s, pen->style);
|
||||||
@ -143,8 +137,7 @@ rdp_parse_pen(STREAM s, PEN * pen, uint32 present)
|
|||||||
rdp_in_colour(s, &pen->colour);
|
rdp_in_colour(s, &pen->colour);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void setup_brush(BRUSH *out_brush, BRUSH *in_brush)
|
||||||
setup_brush(BRUSH * out_brush, BRUSH * in_brush)
|
|
||||||
{
|
{
|
||||||
BRUSHDATA *brush_data;
|
BRUSHDATA *brush_data;
|
||||||
uint8 cache_idx;
|
uint8 cache_idx;
|
||||||
@ -158,8 +151,7 @@ setup_brush(BRUSH * out_brush, BRUSH * in_brush)
|
|||||||
brush_data = cache_get_brush_data(colour_code, cache_idx);
|
brush_data = cache_get_brush_data(colour_code, cache_idx);
|
||||||
if ((brush_data == NULL) || (brush_data->data == NULL))
|
if ((brush_data == NULL) || (brush_data->data == NULL))
|
||||||
{
|
{
|
||||||
logger(Graphics, Error, "setup_brush(), error getting brush data, style %x",
|
logger(Graphics, Error, "setup_brush(), error getting brush data, style %x", out_brush->style);
|
||||||
out_brush->style);
|
|
||||||
out_brush->bd = NULL;
|
out_brush->bd = NULL;
|
||||||
memset(out_brush->pattern, 0, 8);
|
memset(out_brush->pattern, 0, 8);
|
||||||
}
|
}
|
||||||
@ -172,8 +164,7 @@ setup_brush(BRUSH * out_brush, BRUSH * in_brush)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Parse a brush */
|
/* Parse a brush */
|
||||||
static void
|
static void rdp_parse_brush(STREAM s, BRUSH *brush, uint32 present)
|
||||||
rdp_parse_brush(STREAM s, BRUSH * brush, uint32 present)
|
|
||||||
{
|
{
|
||||||
if (present & 1)
|
if (present & 1)
|
||||||
in_uint8(s, brush->xorigin);
|
in_uint8(s, brush->xorigin);
|
||||||
@ -192,8 +183,7 @@ rdp_parse_brush(STREAM s, BRUSH * brush, uint32 present)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Process a destination blt order */
|
/* Process a destination blt order */
|
||||||
static void
|
static void process_destblt(STREAM s, DESTBLT_ORDER *os, uint32 present, RD_BOOL delta)
|
||||||
process_destblt(STREAM s, DESTBLT_ORDER * os, uint32 present, RD_BOOL delta)
|
|
||||||
{
|
{
|
||||||
if (present & 0x01)
|
if (present & 0x01)
|
||||||
rdp_in_coord(s, &os->x, delta);
|
rdp_in_coord(s, &os->x, delta);
|
||||||
@ -217,8 +207,7 @@ process_destblt(STREAM s, DESTBLT_ORDER * os, uint32 present, RD_BOOL delta)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Process a pattern blt order */
|
/* Process a pattern blt order */
|
||||||
static void
|
static void process_patblt(STREAM s, PATBLT_ORDER *os, uint32 present, RD_BOOL delta)
|
||||||
process_patblt(STREAM s, PATBLT_ORDER * os, uint32 present, RD_BOOL delta)
|
|
||||||
{
|
{
|
||||||
BRUSH brush;
|
BRUSH brush;
|
||||||
|
|
||||||
@ -247,18 +236,15 @@ process_patblt(STREAM s, PATBLT_ORDER * os, uint32 present, RD_BOOL delta)
|
|||||||
|
|
||||||
logger(Graphics, Debug,
|
logger(Graphics, Debug,
|
||||||
"process_patblt(), op=0x%x, x=%d, y=%d, cx=%d, cy=%d, bs=%d, bg=0x%x, fg=0x%x)",
|
"process_patblt(), op=0x%x, x=%d, y=%d, cx=%d, cy=%d, bs=%d, bg=0x%x, fg=0x%x)",
|
||||||
os->opcode, os->x, os->y, os->cx, os->cy, os->brush.style, os->bgcolour,
|
os->opcode, os->x, os->y, os->cx, os->cy, os->brush.style, os->bgcolour, os->fgcolour);
|
||||||
os->fgcolour);
|
|
||||||
|
|
||||||
setup_brush(&brush, &os->brush);
|
setup_brush(&brush, &os->brush);
|
||||||
|
|
||||||
ui_patblt(ROP2_P(os->opcode), os->x, os->y, os->cx, os->cy,
|
ui_patblt(ROP2_P(os->opcode), os->x, os->y, os->cx, os->cy, &brush, os->bgcolour, os->fgcolour);
|
||||||
&brush, os->bgcolour, os->fgcolour);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Process a screen blt order */
|
/* Process a screen blt order */
|
||||||
static void
|
static void process_screenblt(STREAM s, SCREENBLT_ORDER *os, uint32 present, RD_BOOL delta)
|
||||||
process_screenblt(STREAM s, SCREENBLT_ORDER * os, uint32 present, RD_BOOL delta)
|
|
||||||
{
|
{
|
||||||
if (present & 0x0001)
|
if (present & 0x0001)
|
||||||
rdp_in_coord(s, &os->x, delta);
|
rdp_in_coord(s, &os->x, delta);
|
||||||
@ -289,8 +275,7 @@ process_screenblt(STREAM s, SCREENBLT_ORDER * os, uint32 present, RD_BOOL delta)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Process a line order */
|
/* Process a line order */
|
||||||
static void
|
static void process_line(STREAM s, LINE_ORDER *os, uint32 present, RD_BOOL delta)
|
||||||
process_line(STREAM s, LINE_ORDER * os, uint32 present, RD_BOOL delta)
|
|
||||||
{
|
{
|
||||||
if (present & 0x0001)
|
if (present & 0x0001)
|
||||||
in_uint16_le(s, os->mixmode);
|
in_uint16_le(s, os->mixmode);
|
||||||
@ -328,8 +313,7 @@ process_line(STREAM s, LINE_ORDER * os, uint32 present, RD_BOOL delta)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Process an opaque rectangle order */
|
/* Process an opaque rectangle order */
|
||||||
static void
|
static void process_rect(STREAM s, RECT_ORDER *os, uint32 present, RD_BOOL delta)
|
||||||
process_rect(STREAM s, RECT_ORDER * os, uint32 present, RD_BOOL delta)
|
|
||||||
{
|
{
|
||||||
uint32 i;
|
uint32 i;
|
||||||
if (present & 0x01)
|
if (present & 0x01)
|
||||||
@ -369,8 +353,7 @@ process_rect(STREAM s, RECT_ORDER * os, uint32 present, RD_BOOL delta)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Process a desktop save order */
|
/* Process a desktop save order */
|
||||||
static void
|
static void process_desksave(STREAM s, DESKSAVE_ORDER *os, uint32 present, RD_BOOL delta)
|
||||||
process_desksave(STREAM s, DESKSAVE_ORDER * os, uint32 present, RD_BOOL delta)
|
|
||||||
{
|
{
|
||||||
int width, height;
|
int width, height;
|
||||||
|
|
||||||
@ -405,8 +388,7 @@ process_desksave(STREAM s, DESKSAVE_ORDER * os, uint32 present, RD_BOOL delta)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Process a memory blt order */
|
/* Process a memory blt order */
|
||||||
static void
|
static void process_memblt(STREAM s, MEMBLT_ORDER *os, uint32 present, RD_BOOL delta)
|
||||||
process_memblt(STREAM s, MEMBLT_ORDER * os, uint32 present, RD_BOOL delta)
|
|
||||||
{
|
{
|
||||||
RD_HBITMAP bitmap;
|
RD_HBITMAP bitmap;
|
||||||
|
|
||||||
@ -452,8 +434,7 @@ process_memblt(STREAM s, MEMBLT_ORDER * os, uint32 present, RD_BOOL delta)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Process a 3-way blt order */
|
/* Process a 3-way blt order */
|
||||||
static void
|
static void process_triblt(STREAM s, TRIBLT_ORDER *os, uint32 present, RD_BOOL delta)
|
||||||
process_triblt(STREAM s, TRIBLT_ORDER * os, uint32 present, RD_BOOL delta)
|
|
||||||
{
|
{
|
||||||
RD_HBITMAP bitmap;
|
RD_HBITMAP bitmap;
|
||||||
BRUSH brush;
|
BRUSH brush;
|
||||||
@ -510,13 +491,11 @@ process_triblt(STREAM s, TRIBLT_ORDER * os, uint32 present, RD_BOOL delta)
|
|||||||
|
|
||||||
setup_brush(&brush, &os->brush);
|
setup_brush(&brush, &os->brush);
|
||||||
|
|
||||||
ui_triblt(os->opcode, os->x, os->y, os->cx, os->cy,
|
ui_triblt(os->opcode, os->x, os->y, os->cx, os->cy, bitmap, os->srcx, os->srcy, &brush, os->bgcolour, os->fgcolour);
|
||||||
bitmap, os->srcx, os->srcy, &brush, os->bgcolour, os->fgcolour);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Process a polygon order */
|
/* Process a polygon order */
|
||||||
static void
|
static void process_polygon(STREAM s, POLYGON_ORDER *os, uint32 present, RD_BOOL delta)
|
||||||
process_polygon(STREAM s, POLYGON_ORDER * os, uint32 present, RD_BOOL delta)
|
|
||||||
{
|
{
|
||||||
int index, data, next;
|
int index, data, next;
|
||||||
uint8 flags = 0;
|
uint8 flags = 0;
|
||||||
@ -588,8 +567,7 @@ process_polygon(STREAM s, POLYGON_ORDER * os, uint32 present, RD_BOOL delta)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Process a polygon2 order */
|
/* Process a polygon2 order */
|
||||||
static void
|
static void process_polygon2(STREAM s, POLYGON2_ORDER *os, uint32 present, RD_BOOL delta)
|
||||||
process_polygon2(STREAM s, POLYGON2_ORDER * os, uint32 present, RD_BOOL delta)
|
|
||||||
{
|
{
|
||||||
int index, data, next;
|
int index, data, next;
|
||||||
uint8 flags = 0;
|
uint8 flags = 0;
|
||||||
@ -670,8 +648,7 @@ process_polygon2(STREAM s, POLYGON2_ORDER * os, uint32 present, RD_BOOL delta)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Process a polyline order */
|
/* Process a polyline order */
|
||||||
static void
|
static void process_polyline(STREAM s, POLYLINE_ORDER *os, uint32 present, RD_BOOL delta)
|
||||||
process_polyline(STREAM s, POLYLINE_ORDER * os, uint32 present, RD_BOOL delta)
|
|
||||||
{
|
{
|
||||||
int index, next, data;
|
int index, next, data;
|
||||||
uint8 flags = 0;
|
uint8 flags = 0;
|
||||||
@ -741,8 +718,7 @@ process_polyline(STREAM s, POLYLINE_ORDER * os, uint32 present, RD_BOOL delta)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Process an ellipse order */
|
/* Process an ellipse order */
|
||||||
static void
|
static void process_ellipse(STREAM s, ELLIPSE_ORDER *os, uint32 present, RD_BOOL delta)
|
||||||
process_ellipse(STREAM s, ELLIPSE_ORDER * os, uint32 present, RD_BOOL delta)
|
|
||||||
{
|
{
|
||||||
if (present & 0x01)
|
if (present & 0x01)
|
||||||
rdp_in_coord(s, &os->left, delta);
|
rdp_in_coord(s, &os->left, delta);
|
||||||
@ -774,8 +750,7 @@ process_ellipse(STREAM s, ELLIPSE_ORDER * os, uint32 present, RD_BOOL delta)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Process an ellipse2 order */
|
/* Process an ellipse2 order */
|
||||||
static void
|
static void process_ellipse2(STREAM s, ELLIPSE2_ORDER *os, uint32 present, RD_BOOL delta)
|
||||||
process_ellipse2(STREAM s, ELLIPSE2_ORDER * os, uint32 present, RD_BOOL delta)
|
|
||||||
{
|
{
|
||||||
BRUSH brush;
|
BRUSH brush;
|
||||||
|
|
||||||
@ -817,8 +792,7 @@ process_ellipse2(STREAM s, ELLIPSE2_ORDER * os, uint32 present, RD_BOOL delta)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Process a text order */
|
/* Process a text order */
|
||||||
static void
|
static void process_text2(STREAM s, TEXT2_ORDER *os, uint32 present, RD_BOOL delta)
|
||||||
process_text2(STREAM s, TEXT2_ORDER * os, uint32 present, RD_BOOL delta)
|
|
||||||
{
|
{
|
||||||
UNUSED(delta);
|
UNUSED(delta);
|
||||||
BRUSH brush;
|
BRUSH brush;
|
||||||
@ -895,8 +869,7 @@ process_text2(STREAM s, TEXT2_ORDER * os, uint32 present, RD_BOOL delta)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Process a raw bitmap cache order */
|
/* Process a raw bitmap cache order */
|
||||||
static void
|
static void process_raw_bmpcache(STREAM s)
|
||||||
process_raw_bmpcache(STREAM s)
|
|
||||||
{
|
{
|
||||||
RD_HBITMAP bitmap;
|
RD_HBITMAP bitmap;
|
||||||
uint16 cache_idx, bufsize;
|
uint16 cache_idx, bufsize;
|
||||||
@ -929,8 +902,7 @@ process_raw_bmpcache(STREAM s)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Process a bitmap cache order */
|
/* Process a bitmap cache order */
|
||||||
static void
|
static void process_bmpcache(STREAM s)
|
||||||
process_bmpcache(STREAM s)
|
|
||||||
{
|
{
|
||||||
RD_HBITMAP bitmap;
|
RD_HBITMAP bitmap;
|
||||||
uint16 cache_idx, size;
|
uint16 cache_idx, size;
|
||||||
@ -963,7 +935,6 @@ process_bmpcache(STREAM s)
|
|||||||
/* in_uint8s(s, 4); *//* row_size, final_size */
|
/* in_uint8s(s, 4); *//* row_size, final_size */
|
||||||
in_uint16_le(s, row_size);
|
in_uint16_le(s, row_size);
|
||||||
in_uint16_le(s, final_size);
|
in_uint16_le(s, final_size);
|
||||||
|
|
||||||
}
|
}
|
||||||
in_uint8p(s, data, size);
|
in_uint8p(s, data, size);
|
||||||
logger(Graphics, Debug,
|
logger(Graphics, Debug,
|
||||||
@ -987,8 +958,7 @@ process_bmpcache(STREAM s)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Process a bitmap cache v2 order */
|
/* Process a bitmap cache v2 order */
|
||||||
static void
|
static void process_bmpcache2(STREAM s, uint16 flags, RD_BOOL compressed)
|
||||||
process_bmpcache2(STREAM s, uint16 flags, RD_BOOL compressed)
|
|
||||||
{
|
{
|
||||||
RD_HBITMAP bitmap;
|
RD_HBITMAP bitmap;
|
||||||
int y;
|
int y;
|
||||||
@ -1069,8 +1039,7 @@ process_bmpcache2(STREAM s, uint16 flags, RD_BOOL compressed)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Process a colourmap cache order */
|
/* Process a colourmap cache order */
|
||||||
static void
|
static void process_colcache(STREAM s)
|
||||||
process_colcache(STREAM s)
|
|
||||||
{
|
{
|
||||||
COLOURENTRY *entry;
|
COLOURENTRY *entry;
|
||||||
COLOURMAP map;
|
COLOURMAP map;
|
||||||
@ -1103,8 +1072,7 @@ process_colcache(STREAM s)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Process a font cache order */
|
/* Process a font cache order */
|
||||||
static void
|
static void process_fontcache(STREAM s)
|
||||||
process_fontcache(STREAM s)
|
|
||||||
{
|
{
|
||||||
RD_HGLYPH bitmap;
|
RD_HGLYPH bitmap;
|
||||||
uint8 font, nglyphs;
|
uint8 font, nglyphs;
|
||||||
@ -1133,8 +1101,7 @@ process_fontcache(STREAM s)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void process_compressed_8x8_brush_data(uint8 *in, uint8 *out, int Bpp)
|
||||||
process_compressed_8x8_brush_data(uint8 * in, uint8 * out, int Bpp)
|
|
||||||
{
|
{
|
||||||
int x, y, pal_index, in_index, shift, do2, i;
|
int x, y, pal_index, in_index, shift, do2, i;
|
||||||
uint8 *pal;
|
uint8 *pal;
|
||||||
@ -1167,8 +1134,7 @@ process_compressed_8x8_brush_data(uint8 * in, uint8 * out, int Bpp)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Process a brush cache order */
|
/* Process a brush cache order */
|
||||||
static void
|
static void process_brushcache(STREAM s, uint16 flags)
|
||||||
process_brushcache(STREAM s, uint16 flags)
|
|
||||||
{
|
{
|
||||||
UNUSED(flags);
|
UNUSED(flags);
|
||||||
BRUSHDATA brush_data;
|
BRUSHDATA brush_data;
|
||||||
@ -1243,8 +1209,7 @@ process_brushcache(STREAM s, uint16 flags)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Process a secondary order */
|
/* Process a secondary order */
|
||||||
static void
|
static void process_secondary_order(STREAM s)
|
||||||
process_secondary_order(STREAM s)
|
|
||||||
{
|
{
|
||||||
/* The length isn't calculated correctly by the server.
|
/* The length isn't calculated correctly by the server.
|
||||||
* For very compact orders the length becomes negative
|
* For very compact orders the length becomes negative
|
||||||
@ -1310,8 +1275,7 @@ process_secondary_order(STREAM s)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Process an order PDU */
|
/* Process an order PDU */
|
||||||
void
|
void process_orders(STREAM s, uint16 num_orders)
|
||||||
process_orders(STREAM s, uint16 num_orders)
|
|
||||||
{
|
{
|
||||||
RDP_ORDER_STATE *os = &g_order_state;
|
RDP_ORDER_STATE *os = &g_order_state;
|
||||||
uint32 present;
|
uint32 present;
|
||||||
@ -1368,8 +1332,7 @@ process_orders(STREAM s, uint16 num_orders)
|
|||||||
|
|
||||||
ui_set_clip(os->bounds.left,
|
ui_set_clip(os->bounds.left,
|
||||||
os->bounds.top,
|
os->bounds.top,
|
||||||
os->bounds.right -
|
os->bounds.right - os->bounds.left + 1,
|
||||||
os->bounds.left + 1,
|
|
||||||
os->bounds.bottom - os->bounds.top + 1);
|
os->bounds.bottom - os->bounds.top + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1452,12 +1415,10 @@ process_orders(STREAM s, uint16 num_orders)
|
|||||||
logger(Graphics, Error, "process_orders(), %d bytes remaining",
|
logger(Graphics, Error, "process_orders(), %d bytes remaining",
|
||||||
(int)(g_next_packet - s_tell(s)));
|
(int)(g_next_packet - s_tell(s)));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Reset order state */
|
/* Reset order state */
|
||||||
void
|
void reset_order_state(void)
|
||||||
reset_order_state(void)
|
|
||||||
{
|
{
|
||||||
memset(&g_order_state, 0, sizeof(g_order_state));
|
memset(&g_order_state, 0, sizeof(g_order_state));
|
||||||
g_order_state.order_type = RDP_ORDER_PATBLT;
|
g_order_state.order_type = RDP_ORDER_PATBLT;
|
||||||
|
173
orders.h
173
orders.h
@ -26,8 +26,8 @@
|
|||||||
#define RDP_ORDER_SMALL 0x40
|
#define RDP_ORDER_SMALL 0x40
|
||||||
#define RDP_ORDER_TINY 0x80
|
#define RDP_ORDER_TINY 0x80
|
||||||
|
|
||||||
enum RDP_ORDER_TYPE
|
/* Enumeration for RDP order types */
|
||||||
{
|
enum RDP_ORDER_TYPE {
|
||||||
RDP_ORDER_DESTBLT = 0,
|
RDP_ORDER_DESTBLT = 0,
|
||||||
RDP_ORDER_PATBLT = 1,
|
RDP_ORDER_PATBLT = 1,
|
||||||
RDP_ORDER_SCREENBLT = 2,
|
RDP_ORDER_SCREENBLT = 2,
|
||||||
@ -44,8 +44,8 @@ enum RDP_ORDER_TYPE
|
|||||||
RDP_ORDER_TEXT2 = 27
|
RDP_ORDER_TEXT2 = 27
|
||||||
};
|
};
|
||||||
|
|
||||||
enum RDP_SECONDARY_ORDER_TYPE
|
/* Enumeration for RDP secondary order types */
|
||||||
{
|
enum RDP_SECONDARY_ORDER_TYPE {
|
||||||
RDP_ORDER_RAW_BMPCACHE = 0,
|
RDP_ORDER_RAW_BMPCACHE = 0,
|
||||||
RDP_ORDER_COLCACHE = 1,
|
RDP_ORDER_COLCACHE = 1,
|
||||||
RDP_ORDER_BMPCACHE = 2,
|
RDP_ORDER_BMPCACHE = 2,
|
||||||
@ -55,19 +55,17 @@ enum RDP_SECONDARY_ORDER_TYPE
|
|||||||
RDP_ORDER_BRUSHCACHE = 7
|
RDP_ORDER_BRUSHCACHE = 7
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct _DESTBLT_ORDER
|
/* Structure for DESTBLT order */
|
||||||
{
|
typedef struct _DESTBLT_ORDER {
|
||||||
sint16 x;
|
sint16 x;
|
||||||
sint16 y;
|
sint16 y;
|
||||||
sint16 cx;
|
sint16 cx;
|
||||||
sint16 cy;
|
sint16 cy;
|
||||||
uint8 opcode;
|
uint8 opcode;
|
||||||
|
} DESTBLT_ORDER;
|
||||||
|
|
||||||
}
|
/* Structure for PATBLT order */
|
||||||
DESTBLT_ORDER;
|
typedef struct _PATBLT_ORDER {
|
||||||
|
|
||||||
typedef struct _PATBLT_ORDER
|
|
||||||
{
|
|
||||||
sint16 x;
|
sint16 x;
|
||||||
sint16 y;
|
sint16 y;
|
||||||
sint16 cx;
|
sint16 cx;
|
||||||
@ -76,12 +74,10 @@ typedef struct _PATBLT_ORDER
|
|||||||
uint32 bgcolour;
|
uint32 bgcolour;
|
||||||
uint32 fgcolour;
|
uint32 fgcolour;
|
||||||
BRUSH brush;
|
BRUSH brush;
|
||||||
|
} PATBLT_ORDER;
|
||||||
|
|
||||||
}
|
/* Structure for SCREENBLT order */
|
||||||
PATBLT_ORDER;
|
typedef struct _SCREENBLT_ORDER {
|
||||||
|
|
||||||
typedef struct _SCREENBLT_ORDER
|
|
||||||
{
|
|
||||||
sint16 x;
|
sint16 x;
|
||||||
sint16 y;
|
sint16 y;
|
||||||
sint16 cx;
|
sint16 cx;
|
||||||
@ -89,12 +85,10 @@ typedef struct _SCREENBLT_ORDER
|
|||||||
uint8 opcode;
|
uint8 opcode;
|
||||||
sint16 srcx;
|
sint16 srcx;
|
||||||
sint16 srcy;
|
sint16 srcy;
|
||||||
|
} SCREENBLT_ORDER;
|
||||||
|
|
||||||
}
|
/* Structure for LINE order */
|
||||||
SCREENBLT_ORDER;
|
typedef struct _LINE_ORDER {
|
||||||
|
|
||||||
typedef struct _LINE_ORDER
|
|
||||||
{
|
|
||||||
uint16 mixmode;
|
uint16 mixmode;
|
||||||
sint16 startx;
|
sint16 startx;
|
||||||
sint16 starty;
|
sint16 starty;
|
||||||
@ -103,35 +97,29 @@ typedef struct _LINE_ORDER
|
|||||||
uint32 bgcolour;
|
uint32 bgcolour;
|
||||||
uint8 opcode;
|
uint8 opcode;
|
||||||
PEN pen;
|
PEN pen;
|
||||||
|
} LINE_ORDER;
|
||||||
|
|
||||||
}
|
/* Structure for RECT order */
|
||||||
LINE_ORDER;
|
typedef struct _RECT_ORDER {
|
||||||
|
|
||||||
typedef struct _RECT_ORDER
|
|
||||||
{
|
|
||||||
sint16 x;
|
sint16 x;
|
||||||
sint16 y;
|
sint16 y;
|
||||||
sint16 cx;
|
sint16 cx;
|
||||||
sint16 cy;
|
sint16 cy;
|
||||||
uint32 colour;
|
uint32 colour;
|
||||||
|
} RECT_ORDER;
|
||||||
|
|
||||||
}
|
/* Structure for DESKSAVE order */
|
||||||
RECT_ORDER;
|
typedef struct _DESKSAVE_ORDER {
|
||||||
|
|
||||||
typedef struct _DESKSAVE_ORDER
|
|
||||||
{
|
|
||||||
uint32 offset;
|
uint32 offset;
|
||||||
sint16 left;
|
sint16 left;
|
||||||
sint16 top;
|
sint16 top;
|
||||||
sint16 right;
|
sint16 right;
|
||||||
sint16 bottom;
|
sint16 bottom;
|
||||||
uint8 action;
|
uint8 action;
|
||||||
|
} DESKSAVE_ORDER;
|
||||||
|
|
||||||
}
|
/* Structure for TRIBLT order */
|
||||||
DESKSAVE_ORDER;
|
typedef struct _TRIBLT_ORDER {
|
||||||
|
|
||||||
typedef struct _TRIBLT_ORDER
|
|
||||||
{
|
|
||||||
uint8 colour_table;
|
uint8 colour_table;
|
||||||
uint8 cache_id;
|
uint8 cache_id;
|
||||||
sint16 x;
|
sint16 x;
|
||||||
@ -146,12 +134,10 @@ typedef struct _TRIBLT_ORDER
|
|||||||
BRUSH brush;
|
BRUSH brush;
|
||||||
uint16 cache_idx;
|
uint16 cache_idx;
|
||||||
uint16 unknown;
|
uint16 unknown;
|
||||||
|
} TRIBLT_ORDER;
|
||||||
|
|
||||||
}
|
/* Structure for MEMBLT order */
|
||||||
TRIBLT_ORDER;
|
typedef struct _MEMBLT_ORDER {
|
||||||
|
|
||||||
typedef struct _MEMBLT_ORDER
|
|
||||||
{
|
|
||||||
uint8 colour_table;
|
uint8 colour_table;
|
||||||
uint8 cache_id;
|
uint8 cache_id;
|
||||||
sint16 x;
|
sint16 x;
|
||||||
@ -162,14 +148,12 @@ typedef struct _MEMBLT_ORDER
|
|||||||
sint16 srcx;
|
sint16 srcx;
|
||||||
sint16 srcy;
|
sint16 srcy;
|
||||||
uint16 cache_idx;
|
uint16 cache_idx;
|
||||||
|
} MEMBLT_ORDER;
|
||||||
}
|
|
||||||
MEMBLT_ORDER;
|
|
||||||
|
|
||||||
#define MAX_DATA 256
|
#define MAX_DATA 256
|
||||||
|
|
||||||
typedef struct _POLYGON_ORDER
|
/* Structure for POLYGON order */
|
||||||
{
|
typedef struct _POLYGON_ORDER {
|
||||||
sint16 x;
|
sint16 x;
|
||||||
sint16 y;
|
sint16 y;
|
||||||
uint8 opcode;
|
uint8 opcode;
|
||||||
@ -178,12 +162,10 @@ typedef struct _POLYGON_ORDER
|
|||||||
uint8 npoints;
|
uint8 npoints;
|
||||||
uint8 datasize;
|
uint8 datasize;
|
||||||
uint8 data[MAX_DATA];
|
uint8 data[MAX_DATA];
|
||||||
|
} POLYGON_ORDER;
|
||||||
|
|
||||||
}
|
/* Structure for POLYGON2 order */
|
||||||
POLYGON_ORDER;
|
typedef struct _POLYGON2_ORDER {
|
||||||
|
|
||||||
typedef struct _POLYGON2_ORDER
|
|
||||||
{
|
|
||||||
sint16 x;
|
sint16 x;
|
||||||
sint16 y;
|
sint16 y;
|
||||||
uint8 opcode;
|
uint8 opcode;
|
||||||
@ -194,12 +176,10 @@ typedef struct _POLYGON2_ORDER
|
|||||||
uint8 npoints;
|
uint8 npoints;
|
||||||
uint8 datasize;
|
uint8 datasize;
|
||||||
uint8 data[MAX_DATA];
|
uint8 data[MAX_DATA];
|
||||||
|
} POLYGON2_ORDER;
|
||||||
|
|
||||||
}
|
/* Structure for POLYLINE order */
|
||||||
POLYGON2_ORDER;
|
typedef struct _POLYLINE_ORDER {
|
||||||
|
|
||||||
typedef struct _POLYLINE_ORDER
|
|
||||||
{
|
|
||||||
sint16 x;
|
sint16 x;
|
||||||
sint16 y;
|
sint16 y;
|
||||||
uint8 opcode;
|
uint8 opcode;
|
||||||
@ -207,12 +187,10 @@ typedef struct _POLYLINE_ORDER
|
|||||||
uint8 lines;
|
uint8 lines;
|
||||||
uint8 datasize;
|
uint8 datasize;
|
||||||
uint8 data[MAX_DATA];
|
uint8 data[MAX_DATA];
|
||||||
|
} POLYLINE_ORDER;
|
||||||
|
|
||||||
}
|
/* Structure for ELLIPSE order */
|
||||||
POLYLINE_ORDER;
|
typedef struct _ELLIPSE_ORDER {
|
||||||
|
|
||||||
typedef struct _ELLIPSE_ORDER
|
|
||||||
{
|
|
||||||
sint16 left;
|
sint16 left;
|
||||||
sint16 top;
|
sint16 top;
|
||||||
sint16 right;
|
sint16 right;
|
||||||
@ -220,12 +198,10 @@ typedef struct _ELLIPSE_ORDER
|
|||||||
uint8 opcode;
|
uint8 opcode;
|
||||||
uint8 fillmode;
|
uint8 fillmode;
|
||||||
uint32 fgcolour;
|
uint32 fgcolour;
|
||||||
|
} ELLIPSE_ORDER;
|
||||||
|
|
||||||
}
|
/* Structure for ELLIPSE2 order */
|
||||||
ELLIPSE_ORDER;
|
typedef struct _ELLIPSE2_ORDER {
|
||||||
|
|
||||||
typedef struct _ELLIPSE2_ORDER
|
|
||||||
{
|
|
||||||
sint16 left;
|
sint16 left;
|
||||||
sint16 top;
|
sint16 top;
|
||||||
sint16 right;
|
sint16 right;
|
||||||
@ -235,14 +211,12 @@ typedef struct _ELLIPSE2_ORDER
|
|||||||
BRUSH brush;
|
BRUSH brush;
|
||||||
uint32 bgcolour;
|
uint32 bgcolour;
|
||||||
uint32 fgcolour;
|
uint32 fgcolour;
|
||||||
|
} ELLIPSE2_ORDER;
|
||||||
}
|
|
||||||
ELLIPSE2_ORDER;
|
|
||||||
|
|
||||||
#define MAX_TEXT 256
|
#define MAX_TEXT 256
|
||||||
|
|
||||||
typedef struct _TEXT2_ORDER
|
/* Structure for TEXT2 order */
|
||||||
{
|
typedef struct _TEXT2_ORDER {
|
||||||
uint8 font;
|
uint8 font;
|
||||||
uint8 flags;
|
uint8 flags;
|
||||||
uint8 opcode;
|
uint8 opcode;
|
||||||
@ -262,15 +236,12 @@ typedef struct _TEXT2_ORDER
|
|||||||
sint16 y;
|
sint16 y;
|
||||||
uint8 length;
|
uint8 length;
|
||||||
uint8 text[MAX_TEXT];
|
uint8 text[MAX_TEXT];
|
||||||
|
} TEXT2_ORDER;
|
||||||
|
|
||||||
}
|
/* Structure for RDP order state */
|
||||||
TEXT2_ORDER;
|
typedef struct _RDP_ORDER_STATE {
|
||||||
|
|
||||||
typedef struct _RDP_ORDER_STATE
|
|
||||||
{
|
|
||||||
uint8 order_type;
|
uint8 order_type;
|
||||||
BOUNDS bounds;
|
BOUNDS bounds;
|
||||||
|
|
||||||
DESTBLT_ORDER destblt;
|
DESTBLT_ORDER destblt;
|
||||||
PATBLT_ORDER patblt;
|
PATBLT_ORDER patblt;
|
||||||
SCREENBLT_ORDER screenblt;
|
SCREENBLT_ORDER screenblt;
|
||||||
@ -285,12 +256,10 @@ typedef struct _RDP_ORDER_STATE
|
|||||||
ELLIPSE_ORDER ellipse;
|
ELLIPSE_ORDER ellipse;
|
||||||
ELLIPSE2_ORDER ellipse2;
|
ELLIPSE2_ORDER ellipse2;
|
||||||
TEXT2_ORDER text2;
|
TEXT2_ORDER text2;
|
||||||
|
} RDP_ORDER_STATE;
|
||||||
|
|
||||||
}
|
/* Structure for RAW BMPCACHE order */
|
||||||
RDP_ORDER_STATE;
|
typedef struct _RDP_RAW_BMPCACHE_ORDER {
|
||||||
|
|
||||||
typedef struct _RDP_RAW_BMPCACHE_ORDER
|
|
||||||
{
|
|
||||||
uint8 cache_id;
|
uint8 cache_id;
|
||||||
uint8 pad1;
|
uint8 pad1;
|
||||||
uint8 width;
|
uint8 width;
|
||||||
@ -299,12 +268,10 @@ typedef struct _RDP_RAW_BMPCACHE_ORDER
|
|||||||
uint16 bufsize;
|
uint16 bufsize;
|
||||||
uint16 cache_idx;
|
uint16 cache_idx;
|
||||||
uint8 *data;
|
uint8 *data;
|
||||||
|
} RDP_RAW_BMPCACHE_ORDER;
|
||||||
|
|
||||||
}
|
/* Structure for BMPCACHE order */
|
||||||
RDP_RAW_BMPCACHE_ORDER;
|
typedef struct _RDP_BMPCACHE_ORDER {
|
||||||
|
|
||||||
typedef struct _RDP_BMPCACHE_ORDER
|
|
||||||
{
|
|
||||||
uint8 cache_id;
|
uint8 cache_id;
|
||||||
uint8 pad1;
|
uint8 pad1;
|
||||||
uint8 width;
|
uint8 width;
|
||||||
@ -317,51 +284,41 @@ typedef struct _RDP_BMPCACHE_ORDER
|
|||||||
uint16 row_size;
|
uint16 row_size;
|
||||||
uint16 final_size;
|
uint16 final_size;
|
||||||
uint8 *data;
|
uint8 *data;
|
||||||
|
} RDP_BMPCACHE_ORDER;
|
||||||
|
|
||||||
}
|
/* Constants for BMPCACHE2 order */
|
||||||
RDP_BMPCACHE_ORDER;
|
|
||||||
|
|
||||||
/* RDP_BMPCACHE2_ORDER */
|
|
||||||
#define ID_MASK 0x0007
|
#define ID_MASK 0x0007
|
||||||
#define MODE_MASK 0x0038
|
#define MODE_MASK 0x0038
|
||||||
#define SQUARE 0x0080
|
#define SQUARE 0x0080
|
||||||
#define PERSIST 0x0100
|
#define PERSIST 0x0100
|
||||||
#define FLAG_51_UNKNOWN 0x0800
|
#define FLAG_51_UNKNOWN 0x0800
|
||||||
|
|
||||||
#define MODE_SHIFT 3
|
#define MODE_SHIFT 3
|
||||||
|
|
||||||
#define LONG_FORMAT 0x80
|
#define LONG_FORMAT 0x80
|
||||||
#define BUFSIZE_MASK 0x3FFF /* or 0x1FFF? */
|
#define BUFSIZE_MASK 0x3FFF /* or 0x1FFF? */
|
||||||
|
|
||||||
#define MAX_GLYPH 32
|
#define MAX_GLYPH 32
|
||||||
|
|
||||||
typedef struct _RDP_FONT_GLYPH
|
/* Structure for font glyph */
|
||||||
{
|
typedef struct _RDP_FONT_GLYPH {
|
||||||
uint16 character;
|
uint16 character;
|
||||||
uint16 unknown;
|
uint16 unknown;
|
||||||
uint16 baseline;
|
uint16 baseline;
|
||||||
uint16 width;
|
uint16 width;
|
||||||
uint16 height;
|
uint16 height;
|
||||||
uint8 data[MAX_GLYPH];
|
uint8 data[MAX_GLYPH];
|
||||||
|
} RDP_FONT_GLYPH;
|
||||||
}
|
|
||||||
RDP_FONT_GLYPH;
|
|
||||||
|
|
||||||
#define MAX_GLYPHS 256
|
#define MAX_GLYPHS 256
|
||||||
|
|
||||||
typedef struct _RDP_FONTCACHE_ORDER
|
/* Structure for font cache order */
|
||||||
{
|
typedef struct _RDP_FONTCACHE_ORDER {
|
||||||
uint8 font;
|
uint8 font;
|
||||||
uint8 nglyphs;
|
uint8 nglyphs;
|
||||||
RDP_FONT_GLYPH glyphs[MAX_GLYPHS];
|
RDP_FONT_GLYPH glyphs[MAX_GLYPHS];
|
||||||
|
} RDP_FONTCACHE_ORDER;
|
||||||
|
|
||||||
}
|
/* Structure for colour cache order */
|
||||||
RDP_FONTCACHE_ORDER;
|
typedef struct _RDP_COLCACHE_ORDER {
|
||||||
|
|
||||||
typedef struct _RDP_COLCACHE_ORDER
|
|
||||||
{
|
|
||||||
uint8 cache_id;
|
uint8 cache_id;
|
||||||
COLOURMAP map;
|
COLOURMAP map;
|
||||||
|
} RDP_COLCACHE_ORDER;
|
||||||
}
|
|
||||||
RDP_COLCACHE_ORDER;
|
|
||||||
|
Loading…
Reference in New Issue
Block a user