/[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

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

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

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

Legend:
Removed from v.435  
changed lines
  Added in v.895

  ViewVC Help
Powered by ViewVC 1.1.26