/[rdesktop]/sourceforge.net/trunk/rdesktop/rdp5.c
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Contents of /sourceforge.net/trunk/rdesktop/rdp5.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 687 - (show annotations)
Fri Apr 30 06:18:08 2004 UTC (20 years, 1 month ago) by n-ki
File MIME type: text/plain
File size: 3035 byte(s)
rdp5 decompression, but only <= 8-bit depth.

1 /* -*- c-basic-offset: 8 -*-
2 rdesktop: A Remote Desktop Protocol client.
3 Protocol services - Multipoint Communications Service
4 Copyright (C) Matthew Chapman 1999-2002
5 Copyright (C) Erik Forsberg 2003
6
7 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
12 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
17 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 extern uint8 *g_next_packet;
25
26 extern RDPCOMP g_mppc_dict;
27
28 void
29 rdp5_process(STREAM s, BOOL encryption)
30 {
31 uint16 length, count, x, y;
32 uint8 type, ctype;
33 uint8 *next;
34
35 uint32 roff, rlen;
36 struct stream *ns = &(g_mppc_dict.ns);
37 struct stream *ts;
38
39 if (encryption)
40 {
41 in_uint8s(s, 8); /* signature */
42 sec_decrypt(s->p, s->end - s->p);
43 }
44
45 #if 0
46 printf("RDP5 data:\n");
47 hexdump(s->p, s->end - s->p);
48 #endif
49
50 while (s->p < s->end)
51 {
52 in_uint8(s, type);
53 if (type & RDP_COMPRESSION)
54 {
55 in_uint8(s, ctype);
56 in_uint16_le(s, length);
57 type ^= RDP_COMPRESSION;
58 }
59 else
60 {
61 ctype = 0;
62 in_uint16_le(s, length);
63 }
64 g_next_packet = next = s->p + length;
65
66 if (ctype & RDP_MPPC_COMPRESSED)
67 {
68
69 if (mppc_expand(s->p, length, ctype, &roff, &rlen) == -1)
70 error("error while decompressing packet\n");
71
72 /* allocate memory and copy the uncompressed data into the temporary stream */
73 ns->data = xrealloc(ns->data, rlen);
74
75 memcpy((ns->data), (unsigned char *) (g_mppc_dict.hist + roff), rlen);
76
77 ns->size = rlen;
78 ns->end = (ns->data + ns->size);
79 ns->p = ns->data;
80 ns->rdp_hdr = ns->p;
81
82 ts = ns;
83 }
84 else
85 ts = s;
86
87 switch (type)
88 {
89 /* Thanks to Jeroen Meijer <jdmeijer at yahoo
90 dot com> for finding out the meaning of
91 most of the opcodes here. Especially opcode
92 8! :) */
93 case 0: /* orders */
94 in_uint16_le(ts, count);
95 process_orders(ts, count);
96 break;
97 case 1: /* bitmap update (???) */
98 in_uint8s(ts, 2); /* part length */
99 process_bitmap_updates(ts);
100 break;
101 case 2: /* palette */
102 in_uint8s(ts, 2); /* uint16 = 2 */
103 process_palette(ts);
104 break;
105 case 3: /* probably an palette with offset 3. Weird */
106 break;
107 case 5:
108 ui_set_null_cursor();
109 break;
110 case 8:
111 in_uint16_le(ts, x);
112 in_uint16_le(ts, y);
113 if (s_check(ts))
114 ui_move_pointer(x, y);
115 break;
116 case 9:
117 process_colour_pointer_pdu(ts);
118 break;
119 case 10:
120 process_cached_pointer_pdu(ts);
121 break;
122 default:
123 unimpl("RDP5 opcode %d\n", type);
124 }
125
126 s->p = next;
127 }
128 }

  ViewVC Help
Powered by ViewVC 1.1.26