1 |
forsberg |
343 |
/* -*- c-basic-offset: 8 -*- |
2 |
|
|
rdesktop: A Remote Desktop Protocol client. |
3 |
|
|
Protocol services - Multipoint Communications Service |
4 |
stargo |
828 |
Copyright (C) Matthew Chapman 1999-2005 |
5 |
forsberg |
343 |
Copyright (C) Erik Forsberg 2003 |
6 |
jsorg71 |
713 |
|
7 |
forsberg |
343 |
This program is free software; you can redistribute it and/or modify |
8 |
|
|
it under the terms of the GNU General Public License as published by |
9 |
|
|
the Free Software Foundation; either version 2 of the License, or |
10 |
|
|
(at your option) any later version. |
11 |
jsorg71 |
713 |
|
12 |
forsberg |
343 |
This program is distributed in the hope that it will be useful, |
13 |
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 |
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 |
|
|
GNU General Public License for more details. |
16 |
jsorg71 |
713 |
|
17 |
forsberg |
343 |
You should have received a copy of the GNU General Public License |
18 |
|
|
along with this program; if not, write to the Free Software |
19 |
|
|
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
20 |
|
|
*/ |
21 |
|
|
|
22 |
|
|
#include "rdesktop.h" |
23 |
|
|
|
24 |
jsorg71 |
438 |
extern uint8 *g_next_packet; |
25 |
forsberg |
343 |
|
26 |
n-ki |
687 |
extern RDPCOMP g_mppc_dict; |
27 |
|
|
|
28 |
forsberg |
343 |
void |
29 |
jsorg71 |
733 |
rdp5_process(STREAM s) |
30 |
forsberg |
343 |
{ |
31 |
forsberg |
428 |
uint16 length, count, x, y; |
32 |
n-ki |
687 |
uint8 type, ctype; |
33 |
forsberg |
343 |
uint8 *next; |
34 |
|
|
|
35 |
n-ki |
687 |
uint32 roff, rlen; |
36 |
|
|
struct stream *ns = &(g_mppc_dict.ns); |
37 |
|
|
struct stream *ts; |
38 |
|
|
|
39 |
forsberg |
343 |
#if 0 |
40 |
|
|
printf("RDP5 data:\n"); |
41 |
|
|
hexdump(s->p, s->end - s->p); |
42 |
|
|
#endif |
43 |
|
|
|
44 |
jsorg71 |
713 |
ui_begin_update(); |
45 |
forsberg |
343 |
while (s->p < s->end) |
46 |
|
|
{ |
47 |
|
|
in_uint8(s, type); |
48 |
n-ki |
687 |
if (type & RDP_COMPRESSION) |
49 |
|
|
{ |
50 |
|
|
in_uint8(s, ctype); |
51 |
|
|
in_uint16_le(s, length); |
52 |
|
|
type ^= RDP_COMPRESSION; |
53 |
|
|
} |
54 |
|
|
else |
55 |
|
|
{ |
56 |
|
|
ctype = 0; |
57 |
|
|
in_uint16_le(s, length); |
58 |
|
|
} |
59 |
jsorg71 |
438 |
g_next_packet = next = s->p + length; |
60 |
forsberg |
343 |
|
61 |
n-ki |
687 |
if (ctype & RDP_MPPC_COMPRESSED) |
62 |
|
|
{ |
63 |
jsorg71 |
773 |
if (length > RDP_MPPC_DICT_SIZE) |
64 |
astrand |
782 |
error("error decompressed packet size exceeds max\n"); |
65 |
n-ki |
687 |
if (mppc_expand(s->p, length, ctype, &roff, &rlen) == -1) |
66 |
|
|
error("error while decompressing packet\n"); |
67 |
|
|
|
68 |
|
|
/* allocate memory and copy the uncompressed data into the temporary stream */ |
69 |
jsorg71 |
711 |
ns->data = (uint8 *) xrealloc(ns->data, rlen); |
70 |
n-ki |
687 |
|
71 |
|
|
memcpy((ns->data), (unsigned char *) (g_mppc_dict.hist + roff), rlen); |
72 |
|
|
|
73 |
|
|
ns->size = rlen; |
74 |
|
|
ns->end = (ns->data + ns->size); |
75 |
|
|
ns->p = ns->data; |
76 |
|
|
ns->rdp_hdr = ns->p; |
77 |
|
|
|
78 |
|
|
ts = ns; |
79 |
|
|
} |
80 |
|
|
else |
81 |
|
|
ts = s; |
82 |
|
|
|
83 |
forsberg |
343 |
switch (type) |
84 |
|
|
{ |
85 |
astrand |
435 |
/* Thanks to Jeroen Meijer <jdmeijer at yahoo |
86 |
|
|
dot com> for finding out the meaning of |
87 |
|
|
most of the opcodes here. Especially opcode |
88 |
|
|
8! :) */ |
89 |
forsberg |
343 |
case 0: /* orders */ |
90 |
n-ki |
687 |
in_uint16_le(ts, count); |
91 |
|
|
process_orders(ts, count); |
92 |
forsberg |
343 |
break; |
93 |
|
|
case 1: /* bitmap update (???) */ |
94 |
n-ki |
687 |
in_uint8s(ts, 2); /* part length */ |
95 |
|
|
process_bitmap_updates(ts); |
96 |
forsberg |
343 |
break; |
97 |
|
|
case 2: /* palette */ |
98 |
n-ki |
687 |
in_uint8s(ts, 2); /* uint16 = 2 */ |
99 |
|
|
process_palette(ts); |
100 |
forsberg |
343 |
break; |
101 |
forsberg |
411 |
case 3: /* probably an palette with offset 3. Weird */ |
102 |
forsberg |
343 |
break; |
103 |
|
|
case 5: |
104 |
astrand |
508 |
ui_set_null_cursor(); |
105 |
forsberg |
343 |
break; |
106 |
stargo |
885 |
case 6: /* TODO: W2K3 SP1 sends this on connect */ |
107 |
|
|
break; |
108 |
astrand |
435 |
case 8: |
109 |
n-ki |
687 |
in_uint16_le(ts, x); |
110 |
|
|
in_uint16_le(ts, y); |
111 |
|
|
if (s_check(ts)) |
112 |
forsberg |
428 |
ui_move_pointer(x, y); |
113 |
|
|
break; |
114 |
forsberg |
343 |
case 9: |
115 |
n-ki |
687 |
process_colour_pointer_pdu(ts); |
116 |
forsberg |
343 |
break; |
117 |
|
|
case 10: |
118 |
n-ki |
687 |
process_cached_pointer_pdu(ts); |
119 |
forsberg |
343 |
break; |
120 |
|
|
default: |
121 |
|
|
unimpl("RDP5 opcode %d\n", type); |
122 |
|
|
} |
123 |
|
|
|
124 |
|
|
s->p = next; |
125 |
|
|
} |
126 |
jsorg71 |
713 |
ui_end_update(); |
127 |
forsberg |
343 |
} |