Improve Fast-Path code readability
Using constants and field definitions from MS-RDPBCGR.
This commit is contained in:
parent
3abeca252b
commit
eec94365c4
21
constants.h
21
constants.h
@ -23,6 +23,27 @@
|
|||||||
#define DEFAULT_CODEPAGE "UTF-8"
|
#define DEFAULT_CODEPAGE "UTF-8"
|
||||||
#define WINDOWS_CODEPAGE "UTF-16LE"
|
#define WINDOWS_CODEPAGE "UTF-16LE"
|
||||||
|
|
||||||
|
/* [MS-RDPBCGR] 2.2.9.1.2.1 */
|
||||||
|
/* adjusted for position in updateHeader */
|
||||||
|
#define FASTPATH_UPDATETYPE_ORDERS 0x0
|
||||||
|
#define FASTPATH_UPDATETYPE_BITMAP 0x1
|
||||||
|
#define FASTPATH_UPDATETYPE_PALETTE 0x2
|
||||||
|
#define FASTPATH_UPDATETYPE_SYNCHRONIZE 0x3
|
||||||
|
#define FASTPATH_UPDATETYPE_SURFCMDS 0x4
|
||||||
|
#define FASTPATH_UPDATETYPE_PTR_NULL 0x5
|
||||||
|
#define FASTPATH_UPDATETYPE_PTR_DEFAULT 0x6
|
||||||
|
#define FASTPATH_UPDATETYPE_PTR_POSITION 0x8
|
||||||
|
#define FASTPATH_UPDATETYPE_COLOR 0x9
|
||||||
|
#define FASTPATH_UPDATETYPE_CACHED 0xA
|
||||||
|
#define FASTPATH_UPDATETYPE_POINTER 0xB
|
||||||
|
|
||||||
|
#define FASTPATH_FRAGMENT_SINGLE (0x0 << 4)
|
||||||
|
#define FASTPATH_FRAGMENT_LAST (0x1 << 4)
|
||||||
|
#define FASTPATH_FRAGMENT_FIRST (0x2 << 4)
|
||||||
|
#define FASTPATH_FRAGMENT_NEXT (0x3 << 4)
|
||||||
|
|
||||||
|
#define FASTPATH_OUTPUT_COMPRESSION_USED (0x2 << 6)
|
||||||
|
|
||||||
/* ISO PDU codes */
|
/* ISO PDU codes */
|
||||||
enum ISO_PDU_CODE
|
enum ISO_PDU_CODE
|
||||||
{
|
{
|
||||||
|
2
proto.h
2
proto.h
@ -144,7 +144,7 @@ int rd_write_file(int fd, void *ptr, int len);
|
|||||||
int rd_lseek_file(int fd, int offset);
|
int rd_lseek_file(int fd, int offset);
|
||||||
RD_BOOL rd_lock_file(int fd, int start, int len);
|
RD_BOOL rd_lock_file(int fd, int start, int len);
|
||||||
/* rdp5.c */
|
/* rdp5.c */
|
||||||
void rdp5_process(STREAM s);
|
void process_ts_fp_updates(STREAM s);
|
||||||
/* rdp.c */
|
/* rdp.c */
|
||||||
void rdp_in_unistr(STREAM s, int in_len, char **string, uint32 * str_size);
|
void rdp_in_unistr(STREAM s, int in_len, char **string, uint32 * str_size);
|
||||||
void rdp_send_input(uint32 time, uint16 message_type, uint16 device_flags, uint16 param1,
|
void rdp_send_input(uint32 time, uint16 message_type, uint16 device_flags, uint16 param1,
|
||||||
|
4
rdp.c
4
rdp.c
@ -104,8 +104,8 @@ rdp_recv(uint8 * type)
|
|||||||
}
|
}
|
||||||
else if (rdpver != 3)
|
else if (rdpver != 3)
|
||||||
{
|
{
|
||||||
/* rdp5_process should move g_next_packet ok */
|
/* process_ts_fp_updates moves g_next_packet */
|
||||||
rdp5_process(rdp_s);
|
process_ts_fp_updates(rdp_s);
|
||||||
*type = 0;
|
*type = 0;
|
||||||
return rdp_s;
|
return rdp_s;
|
||||||
}
|
}
|
||||||
|
57
rdp5.c
57
rdp5.c
@ -1,6 +1,6 @@
|
|||||||
/* -*- c-basic-offset: 8 -*-
|
/* -*- c-basic-offset: 8 -*-
|
||||||
rdesktop: A Remote Desktop Protocol client.
|
rdesktop: A Remote Desktop Protocol client.
|
||||||
Protocol services - RDP5 short form PDU processing
|
Protocol services - RDP Fast-Path PDU processing
|
||||||
Copyright (C) Matthew Chapman <matthewc.unsw.edu.au> 1999-2008
|
Copyright (C) Matthew Chapman <matthewc.unsw.edu.au> 1999-2008
|
||||||
Copyright 2003-2008 Erik Forsberg <forsberg@cendio.se> for Cendio AB
|
Copyright 2003-2008 Erik Forsberg <forsberg@cendio.se> for Cendio AB
|
||||||
Copyright 2017 Karl Mikaelsson <derfian@cendio.se> for Cendio AB
|
Copyright 2017 Karl Mikaelsson <derfian@cendio.se> for Cendio AB
|
||||||
@ -26,10 +26,10 @@ extern uint8 *g_next_packet;
|
|||||||
extern RDPCOMP g_mppc_dict;
|
extern RDPCOMP g_mppc_dict;
|
||||||
|
|
||||||
void
|
void
|
||||||
rdp5_process(STREAM s)
|
process_ts_fp_updates(STREAM s)
|
||||||
{
|
{
|
||||||
uint16 length, count, x, y;
|
uint16 length, count, x, y;
|
||||||
uint8 type, ctype;
|
uint8 hdr, code, frag, comp, ctype = 0;
|
||||||
uint8 *next;
|
uint8 *next;
|
||||||
|
|
||||||
uint32 roff, rlen;
|
uint32 roff, rlen;
|
||||||
@ -39,25 +39,24 @@ rdp5_process(STREAM s)
|
|||||||
ui_begin_update();
|
ui_begin_update();
|
||||||
while (s->p < s->end)
|
while (s->p < s->end)
|
||||||
{
|
{
|
||||||
in_uint8(s, type);
|
/* Reading a number of TS_FP_UPDATE structures from the stream here.. */
|
||||||
if (type & RDP5_COMPRESSED)
|
in_uint8(s, hdr); /* updateHeader */
|
||||||
{
|
code = hdr & 0x0F; /* |- updateCode */
|
||||||
in_uint8(s, ctype);
|
frag = hdr & 0x30; /* |- fragmentation */
|
||||||
in_uint16_le(s, length);
|
comp = hdr & 0xC0; /* `- compression */
|
||||||
type ^= RDP5_COMPRESSED;
|
|
||||||
}
|
if (comp & FASTPATH_OUTPUT_COMPRESSION_USED)
|
||||||
else
|
in_uint8(s, ctype); /* compressionFlags */
|
||||||
{
|
|
||||||
ctype = 0;
|
in_uint16_le(s, length); /* length */
|
||||||
in_uint16_le(s, length);
|
|
||||||
}
|
|
||||||
g_next_packet = next = s->p + length;
|
g_next_packet = next = s->p + length;
|
||||||
|
|
||||||
if (ctype & RDP_MPPC_COMPRESSED)
|
if (ctype & RDP_MPPC_COMPRESSED)
|
||||||
{
|
{
|
||||||
if (mppc_expand(s->p, length, ctype, &roff, &rlen) == -1)
|
if (mppc_expand(s->p, length, ctype, &roff, &rlen) == -1)
|
||||||
logger(Protocol, Error,
|
logger(Protocol, Error,
|
||||||
"rdp5_process(), error while decompressing packet");
|
"process_ts_fp_update_pdu(), error while decompressing packet");
|
||||||
|
|
||||||
/* allocate memory and copy the uncompressed data into the temporary stream */
|
/* allocate memory and copy the uncompressed data into the temporary stream */
|
||||||
ns->data = (uint8 *) xrealloc(ns->data, rlen);
|
ns->data = (uint8 *) xrealloc(ns->data, rlen);
|
||||||
@ -74,46 +73,46 @@ rdp5_process(STREAM s)
|
|||||||
else
|
else
|
||||||
ts = s;
|
ts = s;
|
||||||
|
|
||||||
switch (type)
|
switch (code)
|
||||||
{
|
{
|
||||||
case 0: /* update orders */
|
case FASTPATH_UPDATETYPE_ORDERS:
|
||||||
in_uint16_le(ts, count);
|
in_uint16_le(ts, count);
|
||||||
process_orders(ts, count);
|
process_orders(ts, count);
|
||||||
break;
|
break;
|
||||||
case 1: /* update bitmap */
|
case FASTPATH_UPDATETYPE_BITMAP:
|
||||||
in_uint8s(ts, 2); /* part length */
|
in_uint8s(ts, 2); /* part length */
|
||||||
process_bitmap_updates(ts);
|
process_bitmap_updates(ts);
|
||||||
break;
|
break;
|
||||||
case 2: /* update palette */
|
case FASTPATH_UPDATETYPE_PALETTE:
|
||||||
in_uint8s(ts, 2); /* uint16 = 2 */
|
in_uint8s(ts, 2); /* uint16 = 2 */
|
||||||
process_palette(ts);
|
process_palette(ts);
|
||||||
break;
|
break;
|
||||||
case 3: /* update synchronize */
|
case FASTPATH_UPDATETYPE_SYNCHRONIZE:
|
||||||
break;
|
break;
|
||||||
case 5: /* null pointer */
|
case FASTPATH_UPDATETYPE_PTR_NULL:
|
||||||
ui_set_null_cursor();
|
ui_set_null_cursor();
|
||||||
break;
|
break;
|
||||||
case 6: /* default pointer */
|
case FASTPATH_UPDATETYPE_PTR_DEFAULT:
|
||||||
set_system_pointer(SYSPTR_DEFAULT);
|
set_system_pointer(SYSPTR_DEFAULT);
|
||||||
break;
|
break;
|
||||||
case 8: /* pointer position */
|
case FASTPATH_UPDATETYPE_PTR_POSITION:
|
||||||
in_uint16_le(ts, x);
|
in_uint16_le(ts, x);
|
||||||
in_uint16_le(ts, y);
|
in_uint16_le(ts, y);
|
||||||
if (s_check(ts))
|
if (s_check(ts))
|
||||||
ui_move_pointer(x, y);
|
ui_move_pointer(x, y);
|
||||||
break;
|
break;
|
||||||
case 9: /* color pointer */
|
case FASTPATH_UPDATETYPE_COLOR:
|
||||||
process_colour_pointer_pdu(ts);
|
process_colour_pointer_pdu(ts);
|
||||||
break;
|
break;
|
||||||
case 10: /* cached pointer */
|
case FASTPATH_UPDATETYPE_CACHED:
|
||||||
process_cached_pointer_pdu(ts);
|
process_cached_pointer_pdu(ts);
|
||||||
break;
|
break;
|
||||||
case 11:
|
case FASTPATH_UPDATETYPE_POINTER:
|
||||||
process_new_pointer_pdu(ts);
|
process_new_pointer_pdu(ts);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
logger(Protocol, Warning, "rdp5_process(), unhandled opcode %d",
|
logger(Protocol, Warning, "process_ts_fp_updates(), unhandled opcode %d",
|
||||||
type);
|
code);
|
||||||
}
|
}
|
||||||
|
|
||||||
s->p = next;
|
s->p = next;
|
||||||
|
Loading…
Reference in New Issue
Block a user