Changed indentation style (-psl).
git-svn-id: svn://svn.code.sf.net/p/rdesktop/code/trunk/rdesktop@24 423420c4-83ab-492f-b58f-81f9feb106b5
This commit is contained in:
parent
b9613445f9
commit
75717d8ab6
3
bitmap.c
3
bitmap.c
@ -26,7 +26,8 @@
|
|||||||
#define REPEAT(statement) { while ((count > 0) && (x < width)) { statement; count--; x++; } }
|
#define REPEAT(statement) { while ((count > 0) && (x < width)) { statement; count--; x++; } }
|
||||||
#define MASK_UPDATE() { mixmask <<= 1; if (mixmask == 0) { mask = CVAL(input); mixmask = 1; } }
|
#define MASK_UPDATE() { mixmask <<= 1; if (mixmask == 0) { mask = CVAL(input); mixmask = 1; } }
|
||||||
|
|
||||||
BOOL bitmap_decompress(unsigned char *output, int width, int height,
|
BOOL
|
||||||
|
bitmap_decompress(unsigned char *output, int width, int height,
|
||||||
unsigned char *input, int size)
|
unsigned char *input, int size)
|
||||||
{
|
{
|
||||||
unsigned char *end = input + size;
|
unsigned char *end = input + size;
|
||||||
|
28
cache.c
28
cache.c
@ -27,7 +27,8 @@
|
|||||||
static HBITMAP bmpcache[3][600];
|
static HBITMAP bmpcache[3][600];
|
||||||
|
|
||||||
/* Retrieve a bitmap from the cache */
|
/* Retrieve a bitmap from the cache */
|
||||||
HBITMAP cache_get_bitmap(uint8 cache_id, uint16 cache_idx)
|
HBITMAP
|
||||||
|
cache_get_bitmap(uint8 cache_id, uint16 cache_idx)
|
||||||
{
|
{
|
||||||
HBITMAP bitmap;
|
HBITMAP bitmap;
|
||||||
|
|
||||||
@ -44,7 +45,8 @@ HBITMAP cache_get_bitmap(uint8 cache_id, uint16 cache_idx)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Store a bitmap in the cache */
|
/* Store a bitmap in the cache */
|
||||||
void cache_put_bitmap(uint8 cache_id, uint16 cache_idx, HBITMAP bitmap)
|
void
|
||||||
|
cache_put_bitmap(uint8 cache_id, uint16 cache_idx, HBITMAP bitmap)
|
||||||
{
|
{
|
||||||
HBITMAP old;
|
HBITMAP old;
|
||||||
|
|
||||||
@ -68,7 +70,8 @@ void cache_put_bitmap(uint8 cache_id, uint16 cache_idx, HBITMAP bitmap)
|
|||||||
static FONTGLYPH fontcache[12][256];
|
static FONTGLYPH fontcache[12][256];
|
||||||
|
|
||||||
/* Retrieve a glyph from the font cache */
|
/* Retrieve a glyph from the font cache */
|
||||||
FONTGLYPH *cache_get_font(uint8 font, uint16 character)
|
FONTGLYPH *
|
||||||
|
cache_get_font(uint8 font, uint16 character)
|
||||||
{
|
{
|
||||||
FONTGLYPH *glyph;
|
FONTGLYPH *glyph;
|
||||||
|
|
||||||
@ -85,9 +88,9 @@ FONTGLYPH *cache_get_font(uint8 font, uint16 character)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Store a glyph in the font cache */
|
/* Store a glyph in the font cache */
|
||||||
void cache_put_font(uint8 font, uint16 character, uint16 offset,
|
void
|
||||||
uint16 baseline, uint16 width, uint16 height,
|
cache_put_font(uint8 font, uint16 character, uint16 offset,
|
||||||
HGLYPH pixmap)
|
uint16 baseline, uint16 width, uint16 height, HGLYPH pixmap)
|
||||||
{
|
{
|
||||||
FONTGLYPH *glyph;
|
FONTGLYPH *glyph;
|
||||||
|
|
||||||
@ -115,7 +118,8 @@ void cache_put_font(uint8 font, uint16 character, uint16 offset,
|
|||||||
static DATABLOB textcache[256];
|
static DATABLOB textcache[256];
|
||||||
|
|
||||||
/* Retrieve a text item from the cache */
|
/* Retrieve a text item from the cache */
|
||||||
DATABLOB *cache_get_text(uint8 cache_id)
|
DATABLOB *
|
||||||
|
cache_get_text(uint8 cache_id)
|
||||||
{
|
{
|
||||||
DATABLOB *text;
|
DATABLOB *text;
|
||||||
|
|
||||||
@ -131,7 +135,8 @@ DATABLOB *cache_get_text(uint8 cache_id)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Store a text item in the cache */
|
/* Store a text item in the cache */
|
||||||
void cache_put_text(uint8 cache_id, void *data, int length)
|
void
|
||||||
|
cache_put_text(uint8 cache_id, void *data, int length)
|
||||||
{
|
{
|
||||||
DATABLOB *text;
|
DATABLOB *text;
|
||||||
|
|
||||||
@ -156,7 +161,8 @@ void cache_put_text(uint8 cache_id, void *data, int length)
|
|||||||
static uint8 deskcache[0x38400];
|
static uint8 deskcache[0x38400];
|
||||||
|
|
||||||
/* Retrieve desktop data from the cache */
|
/* Retrieve desktop data from the cache */
|
||||||
uint8 *cache_get_desktop(uint32 offset, int cx, int cy)
|
uint8 *
|
||||||
|
cache_get_desktop(uint32 offset, int cx, int cy)
|
||||||
{
|
{
|
||||||
int length = cx * cy;
|
int length = cx * cy;
|
||||||
|
|
||||||
@ -170,8 +176,8 @@ uint8 *cache_get_desktop(uint32 offset, int cx, int cy)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Store desktop data in the cache */
|
/* Store desktop data in the cache */
|
||||||
void cache_put_desktop(uint32 offset, int cx, int cy, int scanline,
|
void
|
||||||
uint8 *data)
|
cache_put_desktop(uint32 offset, int cx, int cy, int scanline, uint8 *data)
|
||||||
{
|
{
|
||||||
int length = cx * cy;
|
int length = cx * cy;
|
||||||
|
|
||||||
|
21
iso.c
21
iso.c
@ -21,7 +21,8 @@
|
|||||||
#include "rdesktop.h"
|
#include "rdesktop.h"
|
||||||
|
|
||||||
/* Send a self-contained ISO PDU */
|
/* Send a self-contained ISO PDU */
|
||||||
static void iso_send_msg(uint8 code)
|
static void
|
||||||
|
iso_send_msg(uint8 code)
|
||||||
{
|
{
|
||||||
STREAM s;
|
STREAM s;
|
||||||
|
|
||||||
@ -42,7 +43,8 @@ static void iso_send_msg(uint8 code)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Receive a message on the ISO layer, return code */
|
/* Receive a message on the ISO layer, return code */
|
||||||
static STREAM iso_recv_msg(uint8 *code)
|
static STREAM
|
||||||
|
iso_recv_msg(uint8 *code)
|
||||||
{
|
{
|
||||||
STREAM s;
|
STREAM s;
|
||||||
uint16 length;
|
uint16 length;
|
||||||
@ -80,7 +82,8 @@ static STREAM iso_recv_msg(uint8 *code)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Initialise ISO transport data packet */
|
/* Initialise ISO transport data packet */
|
||||||
STREAM iso_init(int length)
|
STREAM
|
||||||
|
iso_init(int length)
|
||||||
{
|
{
|
||||||
STREAM s;
|
STREAM s;
|
||||||
|
|
||||||
@ -91,7 +94,8 @@ STREAM iso_init(int length)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Send an ISO data PDU */
|
/* Send an ISO data PDU */
|
||||||
void iso_send(STREAM s)
|
void
|
||||||
|
iso_send(STREAM s)
|
||||||
{
|
{
|
||||||
uint16 length;
|
uint16 length;
|
||||||
|
|
||||||
@ -110,7 +114,8 @@ void iso_send(STREAM s)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Receive ISO transport data packet */
|
/* Receive ISO transport data packet */
|
||||||
STREAM iso_recv()
|
STREAM
|
||||||
|
iso_recv()
|
||||||
{
|
{
|
||||||
STREAM s;
|
STREAM s;
|
||||||
uint8 code;
|
uint8 code;
|
||||||
@ -126,7 +131,8 @@ STREAM iso_recv()
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Establish a connection up to the ISO layer */
|
/* Establish a connection up to the ISO layer */
|
||||||
BOOL iso_connect(char *server)
|
BOOL
|
||||||
|
iso_connect(char *server)
|
||||||
{
|
{
|
||||||
uint8 code;
|
uint8 code;
|
||||||
|
|
||||||
@ -146,7 +152,8 @@ BOOL iso_connect(char *server)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Disconnect from the ISO layer */
|
/* Disconnect from the ISO layer */
|
||||||
void iso_disconnect()
|
void
|
||||||
|
iso_disconnect()
|
||||||
{
|
{
|
||||||
iso_send_msg(ISO_PDU_DR);
|
iso_send_msg(ISO_PDU_DR);
|
||||||
tcp_disconnect();
|
tcp_disconnect();
|
||||||
|
26
licence.c
26
licence.c
@ -29,8 +29,8 @@ static uint8 licence_key[16];
|
|||||||
static uint8 licence_sign_key[16];
|
static uint8 licence_sign_key[16];
|
||||||
|
|
||||||
/* Generate a session key and RC4 keys, given client and server randoms */
|
/* Generate a session key and RC4 keys, given client and server randoms */
|
||||||
void licence_generate_keys(uint8 *client_key, uint8 *server_key,
|
void
|
||||||
uint8 *client_rsa)
|
licence_generate_keys(uint8 *client_key, uint8 *server_key, uint8 *client_rsa)
|
||||||
{
|
{
|
||||||
uint8 session_key[48];
|
uint8 session_key[48];
|
||||||
uint8 temp_hash[48];
|
uint8 temp_hash[48];
|
||||||
@ -47,7 +47,8 @@ void licence_generate_keys(uint8 *client_key, uint8 *server_key,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Send a licence request packet */
|
/* Send a licence request packet */
|
||||||
static void licence_send_request(uint8 *client_random, uint8 *rsa_data,
|
static void
|
||||||
|
licence_send_request(uint8 *client_random, uint8 *rsa_data,
|
||||||
char *user, char *host)
|
char *user, char *host)
|
||||||
{
|
{
|
||||||
uint32 sec_flags = SEC_LICENCE_NEG;
|
uint32 sec_flags = SEC_LICENCE_NEG;
|
||||||
@ -83,7 +84,8 @@ static void licence_send_request(uint8 *client_random, uint8 *rsa_data,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Process a licence demand packet */
|
/* Process a licence demand packet */
|
||||||
static void licence_process_demand(STREAM s)
|
static void
|
||||||
|
licence_process_demand(STREAM s)
|
||||||
{
|
{
|
||||||
uint8 null_data[SEC_MODULUS_SIZE];
|
uint8 null_data[SEC_MODULUS_SIZE];
|
||||||
uint8 *server_random;
|
uint8 *server_random;
|
||||||
@ -101,8 +103,8 @@ static void licence_process_demand(STREAM s)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Send an authentication response packet */
|
/* Send an authentication response packet */
|
||||||
static void licence_send_authresp(uint8 *token, uint8 *crypt_hwid,
|
static void
|
||||||
uint8 *signature)
|
licence_send_authresp(uint8 *token, uint8 *crypt_hwid, uint8 *signature)
|
||||||
{
|
{
|
||||||
uint32 sec_flags = SEC_LICENCE_NEG;
|
uint32 sec_flags = SEC_LICENCE_NEG;
|
||||||
uint16 length = 58;
|
uint16 length = 58;
|
||||||
@ -128,7 +130,8 @@ static void licence_send_authresp(uint8 *token, uint8 *crypt_hwid,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Parse an authentication request packet */
|
/* Parse an authentication request packet */
|
||||||
static BOOL licence_parse_authreq(STREAM s, uint8 **token, uint8 **signature)
|
static BOOL
|
||||||
|
licence_parse_authreq(STREAM s, uint8 **token, uint8 **signature)
|
||||||
{
|
{
|
||||||
uint16 tokenlen;
|
uint16 tokenlen;
|
||||||
|
|
||||||
@ -148,7 +151,8 @@ static BOOL licence_parse_authreq(STREAM s, uint8 **token, uint8 **signature)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Process an authentication request packet */
|
/* Process an authentication request packet */
|
||||||
static void licence_process_authreq(STREAM s)
|
static void
|
||||||
|
licence_process_authreq(STREAM s)
|
||||||
{
|
{
|
||||||
uint8 *in_token, *in_sig;
|
uint8 *in_token, *in_sig;
|
||||||
uint8 out_token[LICENCE_TOKEN_SIZE],
|
uint8 out_token[LICENCE_TOKEN_SIZE],
|
||||||
@ -188,7 +192,8 @@ static void licence_process_authreq(STREAM s)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Process an licence issue packet */
|
/* Process an licence issue packet */
|
||||||
static void licence_process_issue(STREAM s)
|
static void
|
||||||
|
licence_process_issue(STREAM s)
|
||||||
{
|
{
|
||||||
RC4_KEY crypt_key;
|
RC4_KEY crypt_key;
|
||||||
uint32 length;
|
uint32 length;
|
||||||
@ -211,7 +216,8 @@ static void licence_process_issue(STREAM s)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Process a licence packet */
|
/* Process a licence packet */
|
||||||
void licence_process(STREAM s)
|
void
|
||||||
|
licence_process(STREAM s)
|
||||||
{
|
{
|
||||||
uint16 tag;
|
uint16 tag;
|
||||||
|
|
||||||
|
51
mcs.c
51
mcs.c
@ -23,7 +23,8 @@
|
|||||||
uint16 mcs_userid;
|
uint16 mcs_userid;
|
||||||
|
|
||||||
/* Parse an ASN.1 BER header */
|
/* Parse an ASN.1 BER header */
|
||||||
static BOOL ber_parse_header(STREAM s, int tagval, int *length)
|
static BOOL
|
||||||
|
ber_parse_header(STREAM s, int tagval, int *length)
|
||||||
{
|
{
|
||||||
int tag, len;
|
int tag, len;
|
||||||
|
|
||||||
@ -57,7 +58,8 @@ static BOOL ber_parse_header(STREAM s, int tagval, int *length)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Output an ASN.1 BER header */
|
/* Output an ASN.1 BER header */
|
||||||
static void ber_out_header(STREAM s, int tagval, int length)
|
static void
|
||||||
|
ber_out_header(STREAM s, int tagval, int length)
|
||||||
{
|
{
|
||||||
if (tagval > 0xff)
|
if (tagval > 0xff)
|
||||||
{
|
{
|
||||||
@ -78,14 +80,16 @@ static void ber_out_header(STREAM s, int tagval, int length)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Output an ASN.1 BER integer */
|
/* Output an ASN.1 BER integer */
|
||||||
static void ber_out_integer(STREAM s, int value)
|
static void
|
||||||
|
ber_out_integer(STREAM s, int value)
|
||||||
{
|
{
|
||||||
ber_out_header(s, BER_TAG_INTEGER, 2);
|
ber_out_header(s, BER_TAG_INTEGER, 2);
|
||||||
out_uint16_be(s, value);
|
out_uint16_be(s, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Output a DOMAIN_PARAMS structure (ASN.1 BER) */
|
/* Output a DOMAIN_PARAMS structure (ASN.1 BER) */
|
||||||
static void mcs_out_domain_params(STREAM s, int max_channels, int max_users,
|
static void
|
||||||
|
mcs_out_domain_params(STREAM s, int max_channels, int max_users,
|
||||||
int max_tokens, int max_pdusize)
|
int max_tokens, int max_pdusize)
|
||||||
{
|
{
|
||||||
ber_out_header(s, MCS_TAG_DOMAIN_PARAMS, 32);
|
ber_out_header(s, MCS_TAG_DOMAIN_PARAMS, 32);
|
||||||
@ -100,7 +104,8 @@ static void mcs_out_domain_params(STREAM s, int max_channels, int max_users,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Parse a DOMAIN_PARAMS structure (ASN.1 BER) */
|
/* Parse a DOMAIN_PARAMS structure (ASN.1 BER) */
|
||||||
static BOOL mcs_parse_domain_params(STREAM s)
|
static BOOL
|
||||||
|
mcs_parse_domain_params(STREAM s)
|
||||||
{
|
{
|
||||||
int length;
|
int length;
|
||||||
|
|
||||||
@ -111,7 +116,8 @@ static BOOL 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 mcs_send_connect_initial(STREAM mcs_data)
|
static void
|
||||||
|
mcs_send_connect_initial(STREAM mcs_data)
|
||||||
{
|
{
|
||||||
int datalen = mcs_data->end - mcs_data->data;
|
int datalen = mcs_data->end - mcs_data->data;
|
||||||
int length = 7 + 3 * 34 + 4 + datalen;
|
int length = 7 + 3 * 34 + 4 + datalen;
|
||||||
@ -138,7 +144,8 @@ static void 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 BOOL mcs_recv_connect_response(STREAM mcs_data)
|
static BOOL
|
||||||
|
mcs_recv_connect_response(STREAM mcs_data)
|
||||||
{
|
{
|
||||||
uint8 result;
|
uint8 result;
|
||||||
int length;
|
int length;
|
||||||
@ -177,7 +184,8 @@ static BOOL mcs_recv_connect_response(STREAM mcs_data)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Send an EDrq message (ASN.1 PER) */
|
/* Send an EDrq message (ASN.1 PER) */
|
||||||
static void mcs_send_edrq()
|
static void
|
||||||
|
mcs_send_edrq()
|
||||||
{
|
{
|
||||||
STREAM s;
|
STREAM s;
|
||||||
|
|
||||||
@ -192,7 +200,8 @@ static void mcs_send_edrq()
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Send an AUrq message (ASN.1 PER) */
|
/* Send an AUrq message (ASN.1 PER) */
|
||||||
static void mcs_send_aurq()
|
static void
|
||||||
|
mcs_send_aurq()
|
||||||
{
|
{
|
||||||
STREAM s;
|
STREAM s;
|
||||||
|
|
||||||
@ -205,7 +214,8 @@ static void mcs_send_aurq()
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Expect a AUcf message (ASN.1 PER) */
|
/* Expect a AUcf message (ASN.1 PER) */
|
||||||
static BOOL mcs_recv_aucf(uint16 *mcs_userid)
|
static BOOL
|
||||||
|
mcs_recv_aucf(uint16 *mcs_userid)
|
||||||
{
|
{
|
||||||
uint8 opcode, result;
|
uint8 opcode, result;
|
||||||
STREAM s;
|
STREAM s;
|
||||||
@ -235,7 +245,8 @@ static BOOL mcs_recv_aucf(uint16 *mcs_userid)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Send a CJrq message (ASN.1 PER) */
|
/* Send a CJrq message (ASN.1 PER) */
|
||||||
static void mcs_send_cjrq(uint16 chanid)
|
static void
|
||||||
|
mcs_send_cjrq(uint16 chanid)
|
||||||
{
|
{
|
||||||
STREAM s;
|
STREAM s;
|
||||||
|
|
||||||
@ -250,7 +261,8 @@ static void mcs_send_cjrq(uint16 chanid)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Expect a CJcf message (ASN.1 PER) */
|
/* Expect a CJcf message (ASN.1 PER) */
|
||||||
static BOOL mcs_recv_cjcf()
|
static BOOL
|
||||||
|
mcs_recv_cjcf()
|
||||||
{
|
{
|
||||||
uint8 opcode, result;
|
uint8 opcode, result;
|
||||||
STREAM s;
|
STREAM s;
|
||||||
@ -281,7 +293,8 @@ static BOOL mcs_recv_cjcf()
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Initialise an MCS transport data packet */
|
/* Initialise an MCS transport data packet */
|
||||||
STREAM mcs_init(int length)
|
STREAM
|
||||||
|
mcs_init(int length)
|
||||||
{
|
{
|
||||||
STREAM s;
|
STREAM s;
|
||||||
|
|
||||||
@ -292,7 +305,8 @@ STREAM mcs_init(int length)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Send an MCS transport data packet */
|
/* Send an MCS transport data packet */
|
||||||
void mcs_send(STREAM s)
|
void
|
||||||
|
mcs_send(STREAM s)
|
||||||
{
|
{
|
||||||
uint16 length;
|
uint16 length;
|
||||||
|
|
||||||
@ -310,7 +324,8 @@ void mcs_send(STREAM s)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Receive an MCS transport data packet */
|
/* Receive an MCS transport data packet */
|
||||||
STREAM mcs_recv()
|
STREAM
|
||||||
|
mcs_recv()
|
||||||
{
|
{
|
||||||
uint8 opcode, appid, length;
|
uint8 opcode, appid, length;
|
||||||
STREAM s;
|
STREAM s;
|
||||||
@ -339,7 +354,8 @@ STREAM mcs_recv()
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Establish a connection up to the MCS layer */
|
/* Establish a connection up to the MCS layer */
|
||||||
BOOL mcs_connect(char *server, STREAM mcs_data)
|
BOOL
|
||||||
|
mcs_connect(char *server, STREAM mcs_data)
|
||||||
{
|
{
|
||||||
if (!iso_connect(server))
|
if (!iso_connect(server))
|
||||||
return False;
|
return False;
|
||||||
@ -370,7 +386,8 @@ BOOL mcs_connect(char *server, STREAM mcs_data)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Disconnect from the MCS layer */
|
/* Disconnect from the MCS layer */
|
||||||
void mcs_disconnect()
|
void
|
||||||
|
mcs_disconnect()
|
||||||
{
|
{
|
||||||
iso_disconnect();
|
iso_disconnect();
|
||||||
}
|
}
|
||||||
|
80
orders.c
80
orders.c
@ -25,7 +25,8 @@ extern unsigned char *next_packet;
|
|||||||
static RDP_ORDER_STATE order_state;
|
static RDP_ORDER_STATE order_state;
|
||||||
|
|
||||||
/* Read field indicating which parameters are present */
|
/* Read field indicating which parameters are present */
|
||||||
static void rdp_in_present(STREAM s, uint32 *present, uint8 flags, int size)
|
static void
|
||||||
|
rdp_in_present(STREAM s, uint32 *present, uint8 flags, int size)
|
||||||
{
|
{
|
||||||
uint8 bits;
|
uint8 bits;
|
||||||
int i;
|
int i;
|
||||||
@ -52,7 +53,8 @@ static void 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 rdp_in_coord(STREAM s, uint16 *coord, BOOL delta)
|
static void
|
||||||
|
rdp_in_coord(STREAM s, uint16 *coord, BOOL delta)
|
||||||
{
|
{
|
||||||
uint8 change;
|
uint8 change;
|
||||||
|
|
||||||
@ -68,14 +70,16 @@ static void rdp_in_coord(STREAM s, uint16 *coord, BOOL delta)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Read a colour entry */
|
/* Read a colour entry */
|
||||||
static void rdp_in_colour(STREAM s, uint8 *colour)
|
static void
|
||||||
|
rdp_in_colour(STREAM s, uint8 *colour)
|
||||||
{
|
{
|
||||||
in_uint8(s, *colour);
|
in_uint8(s, *colour);
|
||||||
s->p += 2;
|
s->p += 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Parse bounds information */
|
/* Parse bounds information */
|
||||||
static BOOL rdp_parse_bounds(STREAM s, BOUNDS *bounds)
|
static BOOL
|
||||||
|
rdp_parse_bounds(STREAM s, BOUNDS *bounds)
|
||||||
{
|
{
|
||||||
uint8 present;
|
uint8 present;
|
||||||
|
|
||||||
@ -105,7 +109,8 @@ static BOOL rdp_parse_bounds(STREAM s, BOUNDS *bounds)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Parse a pen */
|
/* Parse a pen */
|
||||||
static BOOL rdp_parse_pen(STREAM s, PEN *pen, uint32 present)
|
static BOOL
|
||||||
|
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);
|
||||||
@ -120,7 +125,8 @@ static BOOL rdp_parse_pen(STREAM s, PEN *pen, uint32 present)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Parse a brush */
|
/* Parse a brush */
|
||||||
static BOOL rdp_parse_brush(STREAM s, BRUSH *brush, uint32 present)
|
static BOOL
|
||||||
|
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);
|
||||||
@ -141,8 +147,8 @@ static BOOL rdp_parse_brush(STREAM s, BRUSH *brush, uint32 present)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Process a destination blt order */
|
/* Process a destination blt order */
|
||||||
static void process_destblt(STREAM s, DESTBLT_ORDER *os,
|
static void
|
||||||
uint32 present, BOOL delta)
|
process_destblt(STREAM s, DESTBLT_ORDER *os, uint32 present, BOOL delta)
|
||||||
{
|
{
|
||||||
if (present & 0x01)
|
if (present & 0x01)
|
||||||
rdp_in_coord(s, &os->x, delta);
|
rdp_in_coord(s, &os->x, delta);
|
||||||
@ -166,8 +172,8 @@ static void process_destblt(STREAM s, DESTBLT_ORDER *os,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Process a pattern blt order */
|
/* Process a pattern blt order */
|
||||||
static void process_patblt(STREAM s, PATBLT_ORDER *os,
|
static void
|
||||||
uint32 present, BOOL delta)
|
process_patblt(STREAM s, PATBLT_ORDER *os, uint32 present, BOOL delta)
|
||||||
{
|
{
|
||||||
if (present & 0x0001)
|
if (present & 0x0001)
|
||||||
rdp_in_coord(s, &os->x, delta);
|
rdp_in_coord(s, &os->x, delta);
|
||||||
@ -201,8 +207,8 @@ static void process_patblt(STREAM s, PATBLT_ORDER *os,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Process a screen blt order */
|
/* Process a screen blt order */
|
||||||
static void process_screenblt(STREAM s, SCREENBLT_ORDER *os,
|
static void
|
||||||
uint32 present, BOOL delta)
|
process_screenblt(STREAM s, SCREENBLT_ORDER *os, uint32 present, BOOL delta)
|
||||||
{
|
{
|
||||||
if (present & 0x0001)
|
if (present & 0x0001)
|
||||||
rdp_in_coord(s, &os->x, delta);
|
rdp_in_coord(s, &os->x, delta);
|
||||||
@ -233,7 +239,8 @@ static void process_screenblt(STREAM s, SCREENBLT_ORDER *os,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Process a line order */
|
/* Process a line order */
|
||||||
static void process_line(STREAM s, LINE_ORDER *os, uint32 present, BOOL delta)
|
static void
|
||||||
|
process_line(STREAM s, LINE_ORDER *os, uint32 present, BOOL delta)
|
||||||
{
|
{
|
||||||
if (present & 0x0001)
|
if (present & 0x0001)
|
||||||
in_uint16_le(s, os->mixmode);
|
in_uint16_le(s, os->mixmode);
|
||||||
@ -273,7 +280,8 @@ static void process_line(STREAM s, LINE_ORDER *os, uint32 present, BOOL delta)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Process an opaque rectangle order */
|
/* Process an opaque rectangle order */
|
||||||
static void process_rect(STREAM s, RECT_ORDER *os, uint32 present, BOOL delta)
|
static void
|
||||||
|
process_rect(STREAM s, RECT_ORDER *os, uint32 present, BOOL delta)
|
||||||
{
|
{
|
||||||
if (present & 0x01)
|
if (present & 0x01)
|
||||||
rdp_in_coord(s, &os->x, delta);
|
rdp_in_coord(s, &os->x, delta);
|
||||||
@ -297,8 +305,8 @@ static void process_rect(STREAM s, RECT_ORDER *os, uint32 present, BOOL delta)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Process a desktop save order */
|
/* Process a desktop save order */
|
||||||
static void process_desksave(STREAM s, DESKSAVE_ORDER *os,
|
static void
|
||||||
uint32 present, BOOL delta)
|
process_desksave(STREAM s, DESKSAVE_ORDER *os, uint32 present, BOOL delta)
|
||||||
{
|
{
|
||||||
int width, height;
|
int width, height;
|
||||||
|
|
||||||
@ -335,8 +343,8 @@ static void process_desksave(STREAM s, DESKSAVE_ORDER *os,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Process a memory blt order */
|
/* Process a memory blt order */
|
||||||
static void process_memblt(STREAM s, MEMBLT_ORDER *os,
|
static void
|
||||||
uint32 present, BOOL delta)
|
process_memblt(STREAM s, MEMBLT_ORDER *os, uint32 present, BOOL delta)
|
||||||
{
|
{
|
||||||
HBITMAP bitmap;
|
HBITMAP bitmap;
|
||||||
|
|
||||||
@ -383,8 +391,8 @@ static void process_memblt(STREAM s, MEMBLT_ORDER *os,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Process a 3-way blt order */
|
/* Process a 3-way blt order */
|
||||||
static void process_triblt(STREAM s, TRIBLT_ORDER *os,
|
static void
|
||||||
uint32 present, BOOL delta)
|
process_triblt(STREAM s, TRIBLT_ORDER *os, uint32 present, BOOL delta)
|
||||||
{
|
{
|
||||||
HBITMAP bitmap;
|
HBITMAP bitmap;
|
||||||
|
|
||||||
@ -444,7 +452,8 @@ static void process_triblt(STREAM s, TRIBLT_ORDER *os,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Parse a delta co-ordinate in polyline order form */
|
/* Parse a delta co-ordinate in polyline order form */
|
||||||
static int parse_delta(uint8 *buffer, int *offset)
|
static int
|
||||||
|
parse_delta(uint8 *buffer, int *offset)
|
||||||
{
|
{
|
||||||
int value = buffer[(*offset)++];
|
int value = buffer[(*offset)++];
|
||||||
int two_byte = value & 0x80;
|
int two_byte = value & 0x80;
|
||||||
@ -461,8 +470,8 @@ static int parse_delta(uint8 *buffer, int *offset)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Process a polyline order */
|
/* Process a polyline order */
|
||||||
static void process_polyline(STREAM s, POLYLINE_ORDER *os,
|
static void
|
||||||
uint32 present, BOOL delta)
|
process_polyline(STREAM s, POLYLINE_ORDER *os, uint32 present, BOOL delta)
|
||||||
{
|
{
|
||||||
int index, line, data;
|
int index, line, data;
|
||||||
int x, y, xfrom, yfrom;
|
int x, y, xfrom, yfrom;
|
||||||
@ -531,8 +540,8 @@ static void process_polyline(STREAM s, POLYLINE_ORDER *os,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Process a text order */
|
/* Process a text order */
|
||||||
static void process_text2(STREAM s, TEXT2_ORDER *os, uint32 present,
|
static void
|
||||||
BOOL delta)
|
process_text2(STREAM s, TEXT2_ORDER *os, uint32 present, BOOL delta)
|
||||||
{
|
{
|
||||||
DATABLOB *entry;
|
DATABLOB *entry;
|
||||||
int i;
|
int i;
|
||||||
@ -634,7 +643,8 @@ static void process_text2(STREAM s, TEXT2_ORDER *os, uint32 present,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Process a raw bitmap cache order */
|
/* Process a raw bitmap cache order */
|
||||||
static void process_raw_bmpcache(STREAM s)
|
static void
|
||||||
|
process_raw_bmpcache(STREAM s)
|
||||||
{
|
{
|
||||||
HBITMAP bitmap;
|
HBITMAP bitmap;
|
||||||
uint16 cache_idx, bufsize;
|
uint16 cache_idx, bufsize;
|
||||||
@ -658,7 +668,8 @@ static void process_raw_bmpcache(STREAM s)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Process a bitmap cache order */
|
/* Process a bitmap cache order */
|
||||||
static void process_bmpcache(STREAM s)
|
static void
|
||||||
|
process_bmpcache(STREAM s)
|
||||||
{
|
{
|
||||||
HBITMAP bitmap;
|
HBITMAP bitmap;
|
||||||
uint16 cache_idx, size;
|
uint16 cache_idx, size;
|
||||||
@ -692,7 +703,8 @@ static void process_bmpcache(STREAM s)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Process a colourmap cache order */
|
/* Process a colourmap cache order */
|
||||||
static void process_colcache(STREAM s)
|
static void
|
||||||
|
process_colcache(STREAM s)
|
||||||
{
|
{
|
||||||
COLOURENTRY *entry;
|
COLOURENTRY *entry;
|
||||||
COLOURMAP map;
|
COLOURMAP map;
|
||||||
@ -723,7 +735,8 @@ static void process_colcache(STREAM s)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Process a font cache order */
|
/* Process a font cache order */
|
||||||
static void process_fontcache(STREAM s)
|
static void
|
||||||
|
process_fontcache(STREAM s)
|
||||||
{
|
{
|
||||||
HGLYPH bitmap;
|
HGLYPH bitmap;
|
||||||
uint8 font, nglyphs;
|
uint8 font, nglyphs;
|
||||||
@ -754,7 +767,8 @@ static void process_fontcache(STREAM s)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Process a secondary order */
|
/* Process a secondary order */
|
||||||
static void process_secondary_order(STREAM s)
|
static void
|
||||||
|
process_secondary_order(STREAM s)
|
||||||
{
|
{
|
||||||
uint16 length;
|
uint16 length;
|
||||||
uint8 type;
|
uint8 type;
|
||||||
@ -792,7 +806,8 @@ static void process_secondary_order(STREAM s)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Process an order PDU */
|
/* Process an order PDU */
|
||||||
void process_orders(STREAM s)
|
void
|
||||||
|
process_orders(STREAM s)
|
||||||
{
|
{
|
||||||
RDP_ORDER_STATE *os = &order_state;
|
RDP_ORDER_STATE *os = &order_state;
|
||||||
uint32 present;
|
uint32 present;
|
||||||
@ -929,7 +944,8 @@ void process_orders(STREAM s)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Reset order state */
|
/* Reset order state */
|
||||||
void reset_order_state()
|
void
|
||||||
|
reset_order_state()
|
||||||
{
|
{
|
||||||
memset(&order_state, 0, sizeof(order_state));
|
memset(&order_state, 0, sizeof(order_state));
|
||||||
}
|
}
|
||||||
|
21
rdesktop.c
21
rdesktop.c
@ -37,7 +37,8 @@ BOOL orders = True;
|
|||||||
BOOL licence = True;
|
BOOL licence = True;
|
||||||
|
|
||||||
/* Display usage information */
|
/* Display usage information */
|
||||||
static void usage(char *program)
|
static void
|
||||||
|
usage(char *program)
|
||||||
{
|
{
|
||||||
STATUS("Usage: %s [options] server\n", program);
|
STATUS("Usage: %s [options] server\n", program);
|
||||||
STATUS(" -u: user name\n");
|
STATUS(" -u: user name\n");
|
||||||
@ -55,7 +56,8 @@ static void usage(char *program)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Client program */
|
/* Client program */
|
||||||
int main(int argc, char *argv[])
|
int
|
||||||
|
main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
struct passwd *pw;
|
struct passwd *pw;
|
||||||
char *server;
|
char *server;
|
||||||
@ -183,7 +185,8 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Generate a 32-byte random for the secure transport code. */
|
/* Generate a 32-byte random for the secure transport code. */
|
||||||
void generate_random(uint8 *random)
|
void
|
||||||
|
generate_random(uint8 *random)
|
||||||
{
|
{
|
||||||
struct stat st;
|
struct stat st;
|
||||||
struct tms tmsbuf;
|
struct tms tmsbuf;
|
||||||
@ -210,7 +213,8 @@ void generate_random(uint8 *random)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* malloc; exit if out of memory */
|
/* malloc; exit if out of memory */
|
||||||
void *xmalloc(int size)
|
void *
|
||||||
|
xmalloc(int size)
|
||||||
{
|
{
|
||||||
void *mem = malloc(size);
|
void *mem = malloc(size);
|
||||||
if (mem == NULL)
|
if (mem == NULL)
|
||||||
@ -222,7 +226,8 @@ void *xmalloc(int size)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* realloc; exit if out of memory */
|
/* realloc; exit if out of memory */
|
||||||
void *xrealloc(void *oldmem, int size)
|
void *
|
||||||
|
xrealloc(void *oldmem, int size)
|
||||||
{
|
{
|
||||||
void *mem = realloc(oldmem, size);
|
void *mem = realloc(oldmem, size);
|
||||||
if (mem == NULL)
|
if (mem == NULL)
|
||||||
@ -234,13 +239,15 @@ void *xrealloc(void *oldmem, int size)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* free */
|
/* free */
|
||||||
void xfree(void *mem)
|
void
|
||||||
|
xfree(void *mem)
|
||||||
{
|
{
|
||||||
free(mem);
|
free(mem);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Produce a hex dump */
|
/* Produce a hex dump */
|
||||||
void hexdump(unsigned char *p, unsigned int len)
|
void
|
||||||
|
hexdump(unsigned char *p, unsigned int len)
|
||||||
{
|
{
|
||||||
unsigned char *line = p;
|
unsigned char *line = p;
|
||||||
unsigned int thisline, offset = 0;
|
unsigned int thisline, offset = 0;
|
||||||
|
96
rdp.c
96
rdp.c
@ -28,7 +28,8 @@ unsigned char *next_packet;
|
|||||||
uint32 rdp_shareid;
|
uint32 rdp_shareid;
|
||||||
|
|
||||||
/* Initialise an RDP packet */
|
/* Initialise an RDP packet */
|
||||||
static STREAM rdp_init(int maxlen)
|
static STREAM
|
||||||
|
rdp_init(int maxlen)
|
||||||
{
|
{
|
||||||
STREAM s;
|
STREAM s;
|
||||||
|
|
||||||
@ -39,7 +40,8 @@ static STREAM rdp_init(int maxlen)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Send an RDP packet */
|
/* Send an RDP packet */
|
||||||
static void rdp_send(STREAM s, uint8 pdu_type)
|
static void
|
||||||
|
rdp_send(STREAM s, uint8 pdu_type)
|
||||||
{
|
{
|
||||||
uint16 length;
|
uint16 length;
|
||||||
|
|
||||||
@ -54,7 +56,8 @@ static void rdp_send(STREAM s, uint8 pdu_type)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Receive an RDP packet */
|
/* Receive an RDP packet */
|
||||||
static STREAM rdp_recv(uint8 *type)
|
static STREAM
|
||||||
|
rdp_recv(uint8 *type)
|
||||||
{
|
{
|
||||||
static STREAM rdp_s;
|
static STREAM rdp_s;
|
||||||
uint16 length, pdu_type;
|
uint16 length, pdu_type;
|
||||||
@ -88,7 +91,8 @@ static STREAM rdp_recv(uint8 *type)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Initialise an RDP data packet */
|
/* Initialise an RDP data packet */
|
||||||
static STREAM rdp_init_data(int maxlen)
|
static STREAM
|
||||||
|
rdp_init_data(int maxlen)
|
||||||
{
|
{
|
||||||
STREAM s;
|
STREAM s;
|
||||||
|
|
||||||
@ -99,7 +103,8 @@ static STREAM rdp_init_data(int maxlen)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Send an RDP data packet */
|
/* Send an RDP data packet */
|
||||||
static void rdp_send_data(STREAM s, uint8 data_pdu_type)
|
static void
|
||||||
|
rdp_send_data(STREAM s, uint8 data_pdu_type)
|
||||||
{
|
{
|
||||||
uint16 length;
|
uint16 length;
|
||||||
|
|
||||||
@ -122,7 +127,8 @@ static void rdp_send_data(STREAM s, uint8 data_pdu_type)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Output a string in Unicode */
|
/* Output a string in Unicode */
|
||||||
void rdp_out_unistr(STREAM s, char *string, int len)
|
void
|
||||||
|
rdp_out_unistr(STREAM s, char *string, int len)
|
||||||
{
|
{
|
||||||
int i = 0, j = 0;
|
int i = 0, j = 0;
|
||||||
|
|
||||||
@ -138,9 +144,9 @@ void rdp_out_unistr(STREAM s, char *string, int len)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Parse a logon info packet */
|
/* Parse a logon info packet */
|
||||||
static void rdp_send_logon_info(uint32 flags, char *domain, char *user,
|
static void
|
||||||
char *password, char *program,
|
rdp_send_logon_info(uint32 flags, char *domain, char *user,
|
||||||
char *directory)
|
char *password, char *program, char *directory)
|
||||||
{
|
{
|
||||||
int len_domain = 2 * strlen(domain);
|
int len_domain = 2 * strlen(domain);
|
||||||
int len_user = 2 * strlen(user);
|
int len_user = 2 * strlen(user);
|
||||||
@ -171,7 +177,8 @@ static void rdp_send_logon_info(uint32 flags, char *domain, char *user,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Send a control PDU */
|
/* Send a control PDU */
|
||||||
static void rdp_send_control(uint16 action)
|
static void
|
||||||
|
rdp_send_control(uint16 action)
|
||||||
{
|
{
|
||||||
STREAM s;
|
STREAM s;
|
||||||
|
|
||||||
@ -186,7 +193,8 @@ static void rdp_send_control(uint16 action)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Send a synchronisation PDU */
|
/* Send a synchronisation PDU */
|
||||||
static void rdp_send_synchronise()
|
static void
|
||||||
|
rdp_send_synchronise()
|
||||||
{
|
{
|
||||||
STREAM s;
|
STREAM s;
|
||||||
|
|
||||||
@ -200,7 +208,8 @@ static void rdp_send_synchronise()
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Send a single input event */
|
/* Send a single input event */
|
||||||
void rdp_send_input(uint32 time, uint16 message_type, uint16 device_flags,
|
void
|
||||||
|
rdp_send_input(uint32 time, uint16 message_type, uint16 device_flags,
|
||||||
uint16 param1, uint16 param2)
|
uint16 param1, uint16 param2)
|
||||||
{
|
{
|
||||||
STREAM s;
|
STREAM s;
|
||||||
@ -221,7 +230,8 @@ void rdp_send_input(uint32 time, uint16 message_type, uint16 device_flags,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Send an (empty) font information PDU */
|
/* Send an (empty) font information PDU */
|
||||||
static void rdp_send_fonts(uint16 seq)
|
static void
|
||||||
|
rdp_send_fonts(uint16 seq)
|
||||||
{
|
{
|
||||||
STREAM s;
|
STREAM s;
|
||||||
|
|
||||||
@ -237,7 +247,8 @@ static void rdp_send_fonts(uint16 seq)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Output general capability set */
|
/* Output general capability set */
|
||||||
static void rdp_out_general_caps(STREAM s)
|
static void
|
||||||
|
rdp_out_general_caps(STREAM s)
|
||||||
{
|
{
|
||||||
out_uint16_le(s, RDP_CAPSET_GENERAL);
|
out_uint16_le(s, RDP_CAPSET_GENERAL);
|
||||||
out_uint16_le(s, RDP_CAPLEN_GENERAL);
|
out_uint16_le(s, RDP_CAPLEN_GENERAL);
|
||||||
@ -255,7 +266,8 @@ static void rdp_out_general_caps(STREAM s)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Output bitmap capability set */
|
/* Output bitmap capability set */
|
||||||
static void rdp_out_bitmap_caps(STREAM s)
|
static void
|
||||||
|
rdp_out_bitmap_caps(STREAM s)
|
||||||
{
|
{
|
||||||
out_uint16_le(s, RDP_CAPSET_BITMAP);
|
out_uint16_le(s, RDP_CAPSET_BITMAP);
|
||||||
out_uint16_le(s, RDP_CAPLEN_BITMAP);
|
out_uint16_le(s, RDP_CAPLEN_BITMAP);
|
||||||
@ -275,7 +287,8 @@ static void rdp_out_bitmap_caps(STREAM s)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Output order capability set */
|
/* Output order capability set */
|
||||||
static void rdp_out_order_caps(STREAM s)
|
static void
|
||||||
|
rdp_out_order_caps(STREAM s)
|
||||||
{
|
{
|
||||||
uint8 order_caps[32];
|
uint8 order_caps[32];
|
||||||
|
|
||||||
@ -300,7 +313,8 @@ static void rdp_out_order_caps(STREAM s)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Output bitmap cache capability set */
|
/* Output bitmap cache capability set */
|
||||||
static void rdp_out_bmpcache_caps(STREAM s)
|
static void
|
||||||
|
rdp_out_bmpcache_caps(STREAM s)
|
||||||
{
|
{
|
||||||
out_uint16_le(s, RDP_CAPSET_BMPCACHE);
|
out_uint16_le(s, RDP_CAPSET_BMPCACHE);
|
||||||
out_uint16_le(s, RDP_CAPLEN_BMPCACHE);
|
out_uint16_le(s, RDP_CAPLEN_BMPCACHE);
|
||||||
@ -315,7 +329,8 @@ static void rdp_out_bmpcache_caps(STREAM s)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Output control capability set */
|
/* Output control capability set */
|
||||||
static void rdp_out_control_caps(STREAM s)
|
static void
|
||||||
|
rdp_out_control_caps(STREAM s)
|
||||||
{
|
{
|
||||||
out_uint16_le(s, RDP_CAPSET_CONTROL);
|
out_uint16_le(s, RDP_CAPSET_CONTROL);
|
||||||
out_uint16_le(s, RDP_CAPLEN_CONTROL);
|
out_uint16_le(s, RDP_CAPLEN_CONTROL);
|
||||||
@ -327,7 +342,8 @@ static void rdp_out_control_caps(STREAM s)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Output activation capability set */
|
/* Output activation capability set */
|
||||||
static void rdp_out_activate_caps(STREAM s)
|
static void
|
||||||
|
rdp_out_activate_caps(STREAM s)
|
||||||
{
|
{
|
||||||
out_uint16_le(s, RDP_CAPSET_ACTIVATE);
|
out_uint16_le(s, RDP_CAPSET_ACTIVATE);
|
||||||
out_uint16_le(s, RDP_CAPLEN_ACTIVATE);
|
out_uint16_le(s, RDP_CAPLEN_ACTIVATE);
|
||||||
@ -339,7 +355,8 @@ static void rdp_out_activate_caps(STREAM s)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Output pointer capability set */
|
/* Output pointer capability set */
|
||||||
static void rdp_out_pointer_caps(STREAM s)
|
static void
|
||||||
|
rdp_out_pointer_caps(STREAM s)
|
||||||
{
|
{
|
||||||
out_uint16_le(s, RDP_CAPSET_POINTER);
|
out_uint16_le(s, RDP_CAPSET_POINTER);
|
||||||
out_uint16_le(s, RDP_CAPLEN_POINTER);
|
out_uint16_le(s, RDP_CAPLEN_POINTER);
|
||||||
@ -349,7 +366,8 @@ static void rdp_out_pointer_caps(STREAM s)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Output share capability set */
|
/* Output share capability set */
|
||||||
static void rdp_out_share_caps(STREAM s)
|
static void
|
||||||
|
rdp_out_share_caps(STREAM s)
|
||||||
{
|
{
|
||||||
out_uint16_le(s, RDP_CAPSET_SHARE);
|
out_uint16_le(s, RDP_CAPSET_SHARE);
|
||||||
out_uint16_le(s, RDP_CAPLEN_SHARE);
|
out_uint16_le(s, RDP_CAPLEN_SHARE);
|
||||||
@ -359,7 +377,8 @@ static void rdp_out_share_caps(STREAM s)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Output colour cache capability set */
|
/* Output colour cache capability set */
|
||||||
static void rdp_out_colcache_caps(STREAM s)
|
static void
|
||||||
|
rdp_out_colcache_caps(STREAM s)
|
||||||
{
|
{
|
||||||
out_uint16_le(s, RDP_CAPSET_COLCACHE);
|
out_uint16_le(s, RDP_CAPSET_COLCACHE);
|
||||||
out_uint16_le(s, RDP_CAPLEN_COLCACHE);
|
out_uint16_le(s, RDP_CAPLEN_COLCACHE);
|
||||||
@ -391,7 +410,8 @@ static uint8 canned_caps[] = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/* Output unknown capability set */
|
/* Output unknown capability set */
|
||||||
static void rdp_out_unknown_caps(STREAM s)
|
static void
|
||||||
|
rdp_out_unknown_caps(STREAM s)
|
||||||
{
|
{
|
||||||
out_uint16_le(s, RDP_CAPSET_UNKNOWN);
|
out_uint16_le(s, RDP_CAPSET_UNKNOWN);
|
||||||
out_uint16_le(s, 0x58);
|
out_uint16_le(s, 0x58);
|
||||||
@ -400,7 +420,8 @@ static void rdp_out_unknown_caps(STREAM s)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Send a confirm active PDU */
|
/* Send a confirm active PDU */
|
||||||
static void rdp_send_confirm_active()
|
static void
|
||||||
|
rdp_send_confirm_active()
|
||||||
{
|
{
|
||||||
STREAM s;
|
STREAM s;
|
||||||
uint16 caplen =
|
uint16 caplen =
|
||||||
@ -436,7 +457,8 @@ static void rdp_send_confirm_active()
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Respond to a demand active PDU */
|
/* Respond to a demand active PDU */
|
||||||
static void process_demand_active(STREAM s)
|
static void
|
||||||
|
process_demand_active(STREAM s)
|
||||||
{
|
{
|
||||||
uint8 type;
|
uint8 type;
|
||||||
|
|
||||||
@ -459,7 +481,8 @@ static void process_demand_active(STREAM s)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Process a pointer PDU */
|
/* Process a pointer PDU */
|
||||||
static void process_pointer_pdu(STREAM s)
|
static void
|
||||||
|
process_pointer_pdu(STREAM s)
|
||||||
{
|
{
|
||||||
uint16 message_type;
|
uint16 message_type;
|
||||||
uint16 x, y;
|
uint16 x, y;
|
||||||
@ -482,7 +505,8 @@ static void process_pointer_pdu(STREAM s)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Process bitmap updates */
|
/* Process bitmap updates */
|
||||||
static void process_bitmap_updates(STREAM s)
|
static void
|
||||||
|
process_bitmap_updates(STREAM s)
|
||||||
{
|
{
|
||||||
uint16 num_updates;
|
uint16 num_updates;
|
||||||
uint16 left, top, right, bottom, width, height;
|
uint16 left, top, right, bottom, width, height;
|
||||||
@ -535,7 +559,8 @@ static void process_bitmap_updates(STREAM s)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Process a palette update */
|
/* Process a palette update */
|
||||||
static void process_palette(STREAM s)
|
static void
|
||||||
|
process_palette(STREAM s)
|
||||||
{
|
{
|
||||||
HCOLOURMAP hmap;
|
HCOLOURMAP hmap;
|
||||||
COLOURMAP map;
|
COLOURMAP map;
|
||||||
@ -550,7 +575,8 @@ static void process_palette(STREAM s)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Process an update PDU */
|
/* Process an update PDU */
|
||||||
static void process_update_pdu(STREAM s)
|
static void
|
||||||
|
process_update_pdu(STREAM s)
|
||||||
{
|
{
|
||||||
uint16 update_type;
|
uint16 update_type;
|
||||||
|
|
||||||
@ -580,7 +606,8 @@ static void process_update_pdu(STREAM s)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Process data PDU */
|
/* Process data PDU */
|
||||||
static void process_data_pdu(STREAM s)
|
static void
|
||||||
|
process_data_pdu(STREAM s)
|
||||||
{
|
{
|
||||||
uint8 data_pdu_type;
|
uint8 data_pdu_type;
|
||||||
|
|
||||||
@ -612,7 +639,8 @@ static void process_data_pdu(STREAM s)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Process incoming packets */
|
/* Process incoming packets */
|
||||||
void rdp_main_loop()
|
void
|
||||||
|
rdp_main_loop()
|
||||||
{
|
{
|
||||||
uint8 type;
|
uint8 type;
|
||||||
STREAM s;
|
STREAM s;
|
||||||
@ -639,7 +667,8 @@ void rdp_main_loop()
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Establish a connection up to the RDP layer */
|
/* Establish a connection up to the RDP layer */
|
||||||
BOOL rdp_connect(char *server, uint32 flags, char *domain, char *password,
|
BOOL
|
||||||
|
rdp_connect(char *server, uint32 flags, char *domain, char *password,
|
||||||
char *command, char *directory)
|
char *command, char *directory)
|
||||||
{
|
{
|
||||||
if (!sec_connect(server))
|
if (!sec_connect(server))
|
||||||
@ -651,7 +680,8 @@ BOOL rdp_connect(char *server, uint32 flags, char *domain, char *password,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Disconnect from the RDP layer */
|
/* Disconnect from the RDP layer */
|
||||||
void rdp_disconnect()
|
void
|
||||||
|
rdp_disconnect()
|
||||||
{
|
{
|
||||||
sec_disconnect();
|
sec_disconnect();
|
||||||
}
|
}
|
||||||
|
74
secure.c
74
secure.c
@ -45,8 +45,8 @@ static uint8 sec_crypted_random[64];
|
|||||||
* a client and server salt) and a global salt value used for padding.
|
* a client and server salt) and a global salt value used for padding.
|
||||||
* Both SHA1 and MD5 algorithms are used.
|
* Both SHA1 and MD5 algorithms are used.
|
||||||
*/
|
*/
|
||||||
void sec_hash_48(uint8 *out, uint8 *in, uint8 *salt1, uint8 *salt2,
|
void
|
||||||
uint8 salt)
|
sec_hash_48(uint8 *out, uint8 *in, uint8 *salt1, uint8 *salt2, uint8 salt)
|
||||||
{
|
{
|
||||||
uint8 shasig[20];
|
uint8 shasig[20];
|
||||||
uint8 pad[4];
|
uint8 pad[4];
|
||||||
@ -76,7 +76,8 @@ void sec_hash_48(uint8 *out, uint8 *in, uint8 *salt1, uint8 *salt2,
|
|||||||
* Weaker 16-byte transformation, also using two 32-byte salts, but
|
* Weaker 16-byte transformation, also using two 32-byte salts, but
|
||||||
* only using a single round of MD5.
|
* only using a single round of MD5.
|
||||||
*/
|
*/
|
||||||
void sec_hash_16(uint8 *out, uint8 *in, uint8 *salt1, uint8 *salt2)
|
void
|
||||||
|
sec_hash_16(uint8 *out, uint8 *in, uint8 *salt1, uint8 *salt2)
|
||||||
{
|
{
|
||||||
MD5_CTX md5;
|
MD5_CTX md5;
|
||||||
|
|
||||||
@ -88,7 +89,8 @@ void sec_hash_16(uint8 *out, uint8 *in, uint8 *salt1, uint8 *salt2)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Reduce key entropy from 64 to 40 bits */
|
/* Reduce key entropy from 64 to 40 bits */
|
||||||
static void sec_make_40bit(uint8 *key)
|
static void
|
||||||
|
sec_make_40bit(uint8 *key)
|
||||||
{
|
{
|
||||||
key[0] = 0xd1;
|
key[0] = 0xd1;
|
||||||
key[1] = 0x26;
|
key[1] = 0x26;
|
||||||
@ -96,8 +98,8 @@ static void sec_make_40bit(uint8 *key)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* 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 sec_generate_keys(uint8 *client_key, uint8 *server_key,
|
static void
|
||||||
int rc4_key_size)
|
sec_generate_keys(uint8 *client_key, uint8 *server_key, int rc4_key_size)
|
||||||
{
|
{
|
||||||
uint8 session_key[48];
|
uint8 session_key[48];
|
||||||
uint8 temp_hash[48];
|
uint8 temp_hash[48];
|
||||||
@ -158,7 +160,8 @@ static uint8 pad_92[48] = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/* Output a uint32 into a buffer (little-endian) */
|
/* Output a uint32 into a buffer (little-endian) */
|
||||||
void buf_out_uint32(uint8 *buffer, uint32 value)
|
void
|
||||||
|
buf_out_uint32(uint8 *buffer, uint32 value)
|
||||||
{
|
{
|
||||||
buffer[0] = (value) & 0xff;
|
buffer[0] = (value) & 0xff;
|
||||||
buffer[1] = (value >> 8) & 0xff;
|
buffer[1] = (value >> 8) & 0xff;
|
||||||
@ -167,7 +170,8 @@ void buf_out_uint32(uint8 *buffer, uint32 value)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Generate a signature hash, using a combination of SHA1 and MD5 */
|
/* Generate a signature hash, using a combination of SHA1 and MD5 */
|
||||||
void sec_sign(uint8 *signature, uint8 *session_key, int length,
|
void
|
||||||
|
sec_sign(uint8 *signature, uint8 *session_key, int length,
|
||||||
uint8 *data, int datalen)
|
uint8 *data, int datalen)
|
||||||
{
|
{
|
||||||
uint8 shasig[20];
|
uint8 shasig[20];
|
||||||
@ -195,7 +199,8 @@ void sec_sign(uint8 *signature, uint8 *session_key, int length,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Update an encryption key - similar to the signing process */
|
/* Update an encryption key - similar to the signing process */
|
||||||
static void sec_update(uint8 *key, uint8 *update_key)
|
static void
|
||||||
|
sec_update(uint8 *key, uint8 *update_key)
|
||||||
{
|
{
|
||||||
uint8 shasig[20];
|
uint8 shasig[20];
|
||||||
SHA_CTX sha;
|
SHA_CTX sha;
|
||||||
@ -222,7 +227,8 @@ static void sec_update(uint8 *key, uint8 *update_key)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Encrypt data using RC4 */
|
/* Encrypt data using RC4 */
|
||||||
static void sec_encrypt(uint8 *data, int length)
|
static void
|
||||||
|
sec_encrypt(uint8 *data, int length)
|
||||||
{
|
{
|
||||||
static int use_count;
|
static int use_count;
|
||||||
|
|
||||||
@ -238,7 +244,8 @@ static void sec_encrypt(uint8 *data, int length)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Decrypt data using RC4 */
|
/* Decrypt data using RC4 */
|
||||||
static void sec_decrypt(uint8 *data, int length)
|
static void
|
||||||
|
sec_decrypt(uint8 *data, int length)
|
||||||
{
|
{
|
||||||
static int use_count;
|
static int use_count;
|
||||||
|
|
||||||
@ -254,7 +261,8 @@ static void sec_decrypt(uint8 *data, int length)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Read in a NUMBER from a buffer */
|
/* Read in a NUMBER from a buffer */
|
||||||
static void sec_read_number(NUMBER * num, uint8 *buffer, int len)
|
static void
|
||||||
|
sec_read_number(NUMBER * num, uint8 *buffer, int len)
|
||||||
{
|
{
|
||||||
INT *data = num->n_part;
|
INT *data = num->n_part;
|
||||||
int i, j;
|
int i, j;
|
||||||
@ -266,7 +274,8 @@ static void sec_read_number(NUMBER * num, uint8 *buffer, int len)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Write a NUMBER to a buffer */
|
/* Write a NUMBER to a buffer */
|
||||||
static void sec_write_number(NUMBER * num, uint8 *buffer, int len)
|
static void
|
||||||
|
sec_write_number(NUMBER * num, uint8 *buffer, int len)
|
||||||
{
|
{
|
||||||
INT *data = num->n_part;
|
INT *data = num->n_part;
|
||||||
int i, j;
|
int i, j;
|
||||||
@ -279,7 +288,8 @@ static void sec_write_number(NUMBER * num, uint8 *buffer, int len)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Perform an RSA public key encryption operation */
|
/* Perform an RSA public key encryption operation */
|
||||||
static void sec_rsa_encrypt(uint8 *out, uint8 *in, int len,
|
static void
|
||||||
|
sec_rsa_encrypt(uint8 *out, uint8 *in, int len,
|
||||||
uint8 *modulus, uint8 *exponent)
|
uint8 *modulus, uint8 *exponent)
|
||||||
{
|
{
|
||||||
NUMBER data, key;
|
NUMBER data, key;
|
||||||
@ -296,7 +306,8 @@ static void sec_rsa_encrypt(uint8 *out, uint8 *in, int len,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Initialise secure transport packet */
|
/* Initialise secure transport packet */
|
||||||
STREAM sec_init(uint32 flags, int maxlen)
|
STREAM
|
||||||
|
sec_init(uint32 flags, int maxlen)
|
||||||
{
|
{
|
||||||
int hdrlen;
|
int hdrlen;
|
||||||
STREAM s;
|
STREAM s;
|
||||||
@ -309,7 +320,8 @@ STREAM sec_init(uint32 flags, int maxlen)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Transmit secure transport packet */
|
/* Transmit secure transport packet */
|
||||||
void sec_send(STREAM s, uint32 flags)
|
void
|
||||||
|
sec_send(STREAM s, uint32 flags)
|
||||||
{
|
{
|
||||||
int datalen;
|
int datalen;
|
||||||
|
|
||||||
@ -334,7 +346,8 @@ void sec_send(STREAM s, uint32 flags)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Transfer the client random to the server */
|
/* Transfer the client random to the server */
|
||||||
static void sec_establish_key()
|
static void
|
||||||
|
sec_establish_key()
|
||||||
{
|
{
|
||||||
uint32 length = SEC_MODULUS_SIZE + SEC_PADDING_SIZE;
|
uint32 length = SEC_MODULUS_SIZE + SEC_PADDING_SIZE;
|
||||||
uint32 flags = SEC_CLIENT_RANDOM;
|
uint32 flags = SEC_CLIENT_RANDOM;
|
||||||
@ -351,7 +364,8 @@ static void sec_establish_key()
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Output connect initial data blob */
|
/* Output connect initial data blob */
|
||||||
static void sec_out_mcs_data(STREAM s)
|
static void
|
||||||
|
sec_out_mcs_data(STREAM s)
|
||||||
{
|
{
|
||||||
int hostlen = 2 * strlen(hostname);
|
int hostlen = 2 * strlen(hostname);
|
||||||
|
|
||||||
@ -403,7 +417,8 @@ static void sec_out_mcs_data(STREAM s)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Parse a public key structure */
|
/* Parse a public key structure */
|
||||||
static BOOL sec_parse_public_key(STREAM s, uint8 **modulus, uint8 **exponent)
|
static BOOL
|
||||||
|
sec_parse_public_key(STREAM s, uint8 **modulus, uint8 **exponent)
|
||||||
{
|
{
|
||||||
uint32 magic, modulus_len;
|
uint32 magic, modulus_len;
|
||||||
|
|
||||||
@ -430,9 +445,9 @@ static BOOL sec_parse_public_key(STREAM s, uint8 **modulus, uint8 **exponent)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Parse a crypto information structure */
|
/* Parse a crypto information structure */
|
||||||
static BOOL sec_parse_crypt_info(STREAM s, uint32 *rc4_key_size,
|
static BOOL
|
||||||
uint8 **server_random, uint8 **modulus,
|
sec_parse_crypt_info(STREAM s, uint32 *rc4_key_size,
|
||||||
uint8 **exponent)
|
uint8 **server_random, uint8 **modulus, uint8 **exponent)
|
||||||
{
|
{
|
||||||
uint32 crypt_level, random_len, rsa_info_len;
|
uint32 crypt_level, random_len, rsa_info_len;
|
||||||
uint16 tag, length;
|
uint16 tag, length;
|
||||||
@ -490,7 +505,8 @@ static BOOL sec_parse_crypt_info(STREAM s, uint32 *rc4_key_size,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Process crypto information blob */
|
/* Process crypto information blob */
|
||||||
static void sec_process_crypt_info(STREAM s)
|
static void
|
||||||
|
sec_process_crypt_info(STREAM s)
|
||||||
{
|
{
|
||||||
uint8 *server_random, *modulus, *exponent;
|
uint8 *server_random, *modulus, *exponent;
|
||||||
uint8 client_random[SEC_RANDOM_SIZE];
|
uint8 client_random[SEC_RANDOM_SIZE];
|
||||||
@ -508,7 +524,8 @@ static void sec_process_crypt_info(STREAM s)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Process connect response data blob */
|
/* Process connect response data blob */
|
||||||
static void sec_process_mcs_data(STREAM s)
|
static void
|
||||||
|
sec_process_mcs_data(STREAM s)
|
||||||
{
|
{
|
||||||
uint16 tag, length;
|
uint16 tag, length;
|
||||||
uint8 *next_tag;
|
uint8 *next_tag;
|
||||||
@ -544,7 +561,8 @@ static void sec_process_mcs_data(STREAM s)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Receive secure transport packet */
|
/* Receive secure transport packet */
|
||||||
STREAM sec_recv()
|
STREAM
|
||||||
|
sec_recv()
|
||||||
{
|
{
|
||||||
uint32 sec_flags;
|
uint32 sec_flags;
|
||||||
STREAM s;
|
STREAM s;
|
||||||
@ -572,7 +590,8 @@ STREAM sec_recv()
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Establish a secure connection */
|
/* Establish a secure connection */
|
||||||
BOOL sec_connect(char *server)
|
BOOL
|
||||||
|
sec_connect(char *server)
|
||||||
{
|
{
|
||||||
struct stream mcs_data;
|
struct stream mcs_data;
|
||||||
|
|
||||||
@ -590,7 +609,8 @@ BOOL sec_connect(char *server)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Disconnect a connection */
|
/* Disconnect a connection */
|
||||||
void sec_disconnect()
|
void
|
||||||
|
sec_disconnect()
|
||||||
{
|
{
|
||||||
mcs_disconnect();
|
mcs_disconnect();
|
||||||
}
|
}
|
||||||
|
15
tcp.c
15
tcp.c
@ -33,7 +33,8 @@ static struct stream in;
|
|||||||
static struct stream out;
|
static struct stream out;
|
||||||
|
|
||||||
/* Initialise TCP transport data packet */
|
/* Initialise TCP transport data packet */
|
||||||
STREAM tcp_init(int maxlen)
|
STREAM
|
||||||
|
tcp_init(int maxlen)
|
||||||
{
|
{
|
||||||
if (maxlen > out.size)
|
if (maxlen > out.size)
|
||||||
{
|
{
|
||||||
@ -47,7 +48,8 @@ STREAM tcp_init(int maxlen)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Send TCP transport data packet */
|
/* Send TCP transport data packet */
|
||||||
void tcp_send(STREAM s)
|
void
|
||||||
|
tcp_send(STREAM s)
|
||||||
{
|
{
|
||||||
int length = s->end - s->data;
|
int length = s->end - s->data;
|
||||||
int sent, total = 0;
|
int sent, total = 0;
|
||||||
@ -67,7 +69,8 @@ void tcp_send(STREAM s)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Receive a message on the TCP layer */
|
/* Receive a message on the TCP layer */
|
||||||
STREAM tcp_recv(int length)
|
STREAM
|
||||||
|
tcp_recv(int length)
|
||||||
{
|
{
|
||||||
int ret, rcvd = 0;
|
int ret, rcvd = 0;
|
||||||
struct timeval tv;
|
struct timeval tv;
|
||||||
@ -111,7 +114,8 @@ STREAM tcp_recv(int length)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Establish a connection on the TCP layer */
|
/* Establish a connection on the TCP layer */
|
||||||
BOOL tcp_connect(char *server)
|
BOOL
|
||||||
|
tcp_connect(char *server)
|
||||||
{
|
{
|
||||||
struct hostent *nslookup;
|
struct hostent *nslookup;
|
||||||
struct sockaddr_in servaddr;
|
struct sockaddr_in servaddr;
|
||||||
@ -159,7 +163,8 @@ BOOL tcp_connect(char *server)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Disconnect on the TCP layer */
|
/* Disconnect on the TCP layer */
|
||||||
void tcp_disconnect()
|
void
|
||||||
|
tcp_disconnect()
|
||||||
{
|
{
|
||||||
close(sock);
|
close(sock);
|
||||||
}
|
}
|
||||||
|
103
xwin.c
103
xwin.c
@ -32,7 +32,8 @@ static GC gc;
|
|||||||
static Visual *visual;
|
static Visual *visual;
|
||||||
static XIM IM;
|
static XIM IM;
|
||||||
|
|
||||||
BOOL ui_create_window(char *title)
|
BOOL
|
||||||
|
ui_create_window(char *title)
|
||||||
{
|
{
|
||||||
Screen *screen;
|
Screen *screen;
|
||||||
XSetWindowAttributes attribs;
|
XSetWindowAttributes attribs;
|
||||||
@ -83,7 +84,8 @@ BOOL ui_create_window(char *title)
|
|||||||
return True;
|
return True;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ui_destroy_window()
|
void
|
||||||
|
ui_destroy_window()
|
||||||
{
|
{
|
||||||
XCloseIM(IM);
|
XCloseIM(IM);
|
||||||
XFreeGC(display, gc);
|
XFreeGC(display, gc);
|
||||||
@ -91,7 +93,8 @@ void ui_destroy_window()
|
|||||||
XCloseDisplay(display);
|
XCloseDisplay(display);
|
||||||
}
|
}
|
||||||
|
|
||||||
static uint8 xwin_translate_key(unsigned long key)
|
static uint8
|
||||||
|
xwin_translate_key(unsigned long key)
|
||||||
{
|
{
|
||||||
DEBUG("KEY(code=0x%lx)\n", key);
|
DEBUG("KEY(code=0x%lx)\n", key);
|
||||||
|
|
||||||
@ -115,7 +118,8 @@ static uint8 xwin_translate_key(unsigned long key)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static uint16 xwin_translate_mouse(unsigned long button)
|
static uint16
|
||||||
|
xwin_translate_mouse(unsigned long button)
|
||||||
{
|
{
|
||||||
switch (button)
|
switch (button)
|
||||||
{
|
{
|
||||||
@ -130,7 +134,8 @@ static uint16 xwin_translate_mouse(unsigned long button)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ui_process_events()
|
void
|
||||||
|
ui_process_events()
|
||||||
{
|
{
|
||||||
XEvent event;
|
XEvent event;
|
||||||
uint8 scancode;
|
uint8 scancode;
|
||||||
@ -148,8 +153,8 @@ void ui_process_events()
|
|||||||
{
|
{
|
||||||
case KeyPress:
|
case KeyPress:
|
||||||
scancode =
|
scancode =
|
||||||
xwin_translate_key(event.xkey.
|
xwin_translate_key(event.
|
||||||
keycode);
|
xkey.keycode);
|
||||||
if (scancode == 0)
|
if (scancode == 0)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -159,8 +164,8 @@ void ui_process_events()
|
|||||||
|
|
||||||
case KeyRelease:
|
case KeyRelease:
|
||||||
scancode =
|
scancode =
|
||||||
xwin_translate_key(event.xkey.
|
xwin_translate_key(event.
|
||||||
keycode);
|
xkey.keycode);
|
||||||
if (scancode == 0)
|
if (scancode == 0)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -171,8 +176,8 @@ void ui_process_events()
|
|||||||
|
|
||||||
case ButtonPress:
|
case ButtonPress:
|
||||||
button =
|
button =
|
||||||
xwin_translate_mouse(event.xbutton.
|
xwin_translate_mouse(event.
|
||||||
button);
|
xbutton.button);
|
||||||
|
|
||||||
if (button == 0)
|
if (button == 0)
|
||||||
break;
|
break;
|
||||||
@ -185,8 +190,8 @@ void ui_process_events()
|
|||||||
|
|
||||||
case ButtonRelease:
|
case ButtonRelease:
|
||||||
button =
|
button =
|
||||||
xwin_translate_mouse(event.xbutton.
|
xwin_translate_mouse(event.
|
||||||
button);
|
xbutton.button);
|
||||||
if (button == 0)
|
if (button == 0)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -205,12 +210,14 @@ void ui_process_events()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ui_move_pointer(int x, int y)
|
void
|
||||||
|
ui_move_pointer(int x, int y)
|
||||||
{
|
{
|
||||||
XWarpPointer(display, wnd, wnd, 0, 0, 0, 0, x, y);
|
XWarpPointer(display, wnd, wnd, 0, 0, 0, 0, x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
HBITMAP ui_create_bitmap(int width, int height, uint8 *data)
|
HBITMAP
|
||||||
|
ui_create_bitmap(int width, int height, uint8 *data)
|
||||||
{
|
{
|
||||||
XImage *image;
|
XImage *image;
|
||||||
Pixmap bitmap;
|
Pixmap bitmap;
|
||||||
@ -226,7 +233,8 @@ HBITMAP ui_create_bitmap(int width, int height, uint8 *data)
|
|||||||
return (HBITMAP) bitmap;
|
return (HBITMAP) bitmap;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ui_paint_bitmap(int x, int y, int cx, int cy,
|
void
|
||||||
|
ui_paint_bitmap(int x, int y, int cx, int cy,
|
||||||
int width, int height, uint8 *data)
|
int width, int height, uint8 *data)
|
||||||
{
|
{
|
||||||
XImage *image;
|
XImage *image;
|
||||||
@ -238,12 +246,14 @@ void ui_paint_bitmap(int x, int y, int cx, int cy,
|
|||||||
XFree(image);
|
XFree(image);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ui_destroy_bitmap(HBITMAP bmp)
|
void
|
||||||
|
ui_destroy_bitmap(HBITMAP bmp)
|
||||||
{
|
{
|
||||||
XFreePixmap(display, (Pixmap) bmp);
|
XFreePixmap(display, (Pixmap) bmp);
|
||||||
}
|
}
|
||||||
|
|
||||||
HGLYPH ui_create_glyph(int width, int height, uint8 *data)
|
HGLYPH
|
||||||
|
ui_create_glyph(int width, int height, uint8 *data)
|
||||||
{
|
{
|
||||||
XImage *image;
|
XImage *image;
|
||||||
Pixmap bitmap;
|
Pixmap bitmap;
|
||||||
@ -269,12 +279,14 @@ HGLYPH ui_create_glyph(int width, int height, uint8 *data)
|
|||||||
return (HGLYPH) bitmap;
|
return (HGLYPH) bitmap;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ui_destroy_glyph(HGLYPH glyph)
|
void
|
||||||
|
ui_destroy_glyph(HGLYPH glyph)
|
||||||
{
|
{
|
||||||
XFreePixmap(display, (Pixmap) glyph);
|
XFreePixmap(display, (Pixmap) glyph);
|
||||||
}
|
}
|
||||||
|
|
||||||
HCOLOURMAP ui_create_colourmap(COLOURMAP *colours)
|
HCOLOURMAP
|
||||||
|
ui_create_colourmap(COLOURMAP *colours)
|
||||||
{
|
{
|
||||||
COLOURENTRY *entry;
|
COLOURENTRY *entry;
|
||||||
XColor *xcolours, *xentry;
|
XColor *xcolours, *xentry;
|
||||||
@ -301,17 +313,20 @@ HCOLOURMAP ui_create_colourmap(COLOURMAP *colours)
|
|||||||
return (HCOLOURMAP) map;
|
return (HCOLOURMAP) map;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ui_destroy_colourmap(HCOLOURMAP map)
|
void
|
||||||
|
ui_destroy_colourmap(HCOLOURMAP map)
|
||||||
{
|
{
|
||||||
XFreeColormap(display, (Colormap) map);
|
XFreeColormap(display, (Colormap) map);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ui_set_colourmap(HCOLOURMAP map)
|
void
|
||||||
|
ui_set_colourmap(HCOLOURMAP map)
|
||||||
{
|
{
|
||||||
XSetWindowColormap(display, wnd, (Colormap) map);
|
XSetWindowColormap(display, wnd, (Colormap) map);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ui_set_clip(int x, int y, int cx, int cy)
|
void
|
||||||
|
ui_set_clip(int x, int y, int cx, int cy)
|
||||||
{
|
{
|
||||||
XRectangle rect;
|
XRectangle rect;
|
||||||
|
|
||||||
@ -322,7 +337,8 @@ void ui_set_clip(int x, int y, int cx, int cy)
|
|||||||
XSetClipRectangles(display, gc, 0, 0, &rect, 1, YXBanded);
|
XSetClipRectangles(display, gc, 0, 0, &rect, 1, YXBanded);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ui_reset_clip()
|
void
|
||||||
|
ui_reset_clip()
|
||||||
{
|
{
|
||||||
XRectangle rect;
|
XRectangle rect;
|
||||||
|
|
||||||
@ -333,7 +349,8 @@ void ui_reset_clip()
|
|||||||
XSetClipRectangles(display, gc, 0, 0, &rect, 1, YXBanded);
|
XSetClipRectangles(display, gc, 0, 0, &rect, 1, YXBanded);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ui_bell()
|
void
|
||||||
|
ui_bell()
|
||||||
{
|
{
|
||||||
XBell(display, 0);
|
XBell(display, 0);
|
||||||
}
|
}
|
||||||
@ -357,12 +374,14 @@ static int rop2_map[] = {
|
|||||||
GXset /* 1 */
|
GXset /* 1 */
|
||||||
};
|
};
|
||||||
|
|
||||||
static void xwin_set_function(uint8 rop2)
|
static void
|
||||||
|
xwin_set_function(uint8 rop2)
|
||||||
{
|
{
|
||||||
XSetFunction(display, gc, rop2_map[rop2]);
|
XSetFunction(display, gc, rop2_map[rop2]);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ui_destblt(uint8 opcode,
|
void
|
||||||
|
ui_destblt(uint8 opcode,
|
||||||
/* dest */ int x, int y, int cx, int cy)
|
/* dest */ int x, int y, int cx, int cy)
|
||||||
{
|
{
|
||||||
xwin_set_function(opcode);
|
xwin_set_function(opcode);
|
||||||
@ -370,7 +389,8 @@ void ui_destblt(uint8 opcode,
|
|||||||
XFillRectangle(display, wnd, gc, x, y, cx, cy);
|
XFillRectangle(display, wnd, gc, x, y, cx, cy);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ui_patblt(uint8 opcode,
|
void
|
||||||
|
ui_patblt(uint8 opcode,
|
||||||
/* dest */ int x, int y, int cx, int cy,
|
/* dest */ int x, int y, int cx, int cy,
|
||||||
/* brush */ BRUSH *brush, int bgcolour, int fgcolour)
|
/* brush */ BRUSH *brush, int bgcolour, int fgcolour)
|
||||||
{
|
{
|
||||||
@ -405,7 +425,8 @@ void ui_patblt(uint8 opcode,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ui_screenblt(uint8 opcode,
|
void
|
||||||
|
ui_screenblt(uint8 opcode,
|
||||||
/* dest */ int x, int y, int cx, int cy,
|
/* dest */ int x, int y, int cx, int cy,
|
||||||
/* src */ int srcx, int srcy)
|
/* src */ int srcx, int srcy)
|
||||||
{
|
{
|
||||||
@ -414,7 +435,8 @@ void ui_screenblt(uint8 opcode,
|
|||||||
XCopyArea(display, wnd, wnd, gc, srcx, srcy, cx, cy, x, y);
|
XCopyArea(display, wnd, wnd, gc, srcx, srcy, cx, cy, x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ui_memblt(uint8 opcode,
|
void
|
||||||
|
ui_memblt(uint8 opcode,
|
||||||
/* dest */ int x, int y, int cx, int cy,
|
/* dest */ int x, int y, int cx, int cy,
|
||||||
/* src */ HBITMAP src, int srcx, int srcy)
|
/* src */ HBITMAP src, int srcx, int srcy)
|
||||||
{
|
{
|
||||||
@ -423,7 +445,8 @@ void ui_memblt(uint8 opcode,
|
|||||||
XCopyArea(display, (Pixmap) src, wnd, gc, srcx, srcy, cx, cy, x, y);
|
XCopyArea(display, (Pixmap) src, wnd, gc, srcx, srcy, cx, cy, x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ui_triblt(uint8 opcode,
|
void
|
||||||
|
ui_triblt(uint8 opcode,
|
||||||
/* dest */ int x, int y, int cx, int cy,
|
/* dest */ int x, int y, int cx, int cy,
|
||||||
/* src */ HBITMAP src, int srcx, int srcy,
|
/* src */ HBITMAP src, int srcx, int srcy,
|
||||||
/* brush */ BRUSH *brush, int bgcolour, int fgcolour)
|
/* brush */ BRUSH *brush, int bgcolour, int fgcolour)
|
||||||
@ -453,7 +476,8 @@ void ui_triblt(uint8 opcode,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ui_line(uint8 opcode,
|
void
|
||||||
|
ui_line(uint8 opcode,
|
||||||
/* dest */ int startx, int starty, int endx, int endy,
|
/* dest */ int startx, int starty, int endx, int endy,
|
||||||
/* pen */ PEN *pen)
|
/* pen */ PEN *pen)
|
||||||
{
|
{
|
||||||
@ -463,7 +487,8 @@ void ui_line(uint8 opcode,
|
|||||||
XDrawLine(display, wnd, gc, startx, starty, endx, endy);
|
XDrawLine(display, wnd, gc, startx, starty, endx, endy);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ui_rect(
|
void
|
||||||
|
ui_rect(
|
||||||
/* dest */ int x, int y, int cx, int cy,
|
/* dest */ int x, int y, int cx, int cy,
|
||||||
/* brush */ int colour)
|
/* brush */ int colour)
|
||||||
{
|
{
|
||||||
@ -473,7 +498,8 @@ void ui_rect(
|
|||||||
XFillRectangle(display, wnd, gc, x, y, cx, cy);
|
XFillRectangle(display, wnd, gc, x, y, cx, cy);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ui_draw_glyph(int mixmode,
|
void
|
||||||
|
ui_draw_glyph(int mixmode,
|
||||||
/* dest */ int x, int y, int cx, int cy,
|
/* dest */ int x, int y, int cx, int cy,
|
||||||
/* src */ HGLYPH glyph, int srcx, int srcy, int bgcolour,
|
/* src */ HGLYPH glyph, int srcx, int srcy, int bgcolour,
|
||||||
int fgcolour)
|
int fgcolour)
|
||||||
@ -505,7 +531,8 @@ void ui_draw_glyph(int mixmode,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ui_draw_text(uint8 font, uint8 flags, int mixmode, int x, int y,
|
void
|
||||||
|
ui_draw_text(uint8 font, uint8 flags, int mixmode, int x, int y,
|
||||||
int clipx, int clipy, int clipcx, int clipcy,
|
int clipx, int clipy, int clipcx, int clipcy,
|
||||||
int boxx, int boxy, int boxcx, int boxcy,
|
int boxx, int boxy, int boxcx, int boxcy,
|
||||||
int bgcolour, int fgcolour, uint8 *text, uint8 length)
|
int bgcolour, int fgcolour, uint8 *text, uint8 length)
|
||||||
@ -544,7 +571,8 @@ void ui_draw_text(uint8 font, uint8 flags, int mixmode, int x, int y,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ui_desktop_save(uint32 offset, int x, int y, int cx, int cy)
|
void
|
||||||
|
ui_desktop_save(uint32 offset, int x, int y, int cx, int cy)
|
||||||
{
|
{
|
||||||
XImage *image;
|
XImage *image;
|
||||||
|
|
||||||
@ -554,7 +582,8 @@ void ui_desktop_save(uint32 offset, int x, int y, int cx, int cy)
|
|||||||
XFree(image);
|
XFree(image);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ui_desktop_restore(uint32 offset, int x, int y, int cx, int cy)
|
void
|
||||||
|
ui_desktop_restore(uint32 offset, int x, int y, int cx, int cy)
|
||||||
{
|
{
|
||||||
XImage *image;
|
XImage *image;
|
||||||
uint8 *data;
|
uint8 *data;
|
||||||
|
Loading…
Reference in New Issue
Block a user