/[rdesktop]/sourceforge.net/trunk/rdesktop/rdp.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/rdp.c

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

revision 25 by matty, Sat Jan 6 03:47:04 2001 UTC revision 28 by matty, Wed Jun 20 13:54:48 2001 UTC
# Line 22  Line 22 
22    
23  extern uint16 mcs_userid;  extern uint16 mcs_userid;
24  extern char username[16];  extern char username[16];
25    extern BOOL bitmap_compression;
26  extern BOOL orders;  extern BOOL orders;
27    extern BOOL use_encryption;
28    extern BOOL desktop_save;
29    
30  unsigned char *next_packet;  uint8 *next_packet;
31  uint32 rdp_shareid;  uint32 rdp_shareid;
32    
33  /* Initialise an RDP packet */  /* Initialise an RDP packet */
# Line 33  rdp_init(int maxlen) Line 36  rdp_init(int maxlen)
36  {  {
37          STREAM s;          STREAM s;
38    
39          s = sec_init(SEC_ENCRYPT, maxlen + 6);          s = sec_init(use_encryption ? SEC_ENCRYPT : 0, maxlen + 6);
40          s_push_layer(s, rdp_hdr, 6);          s_push_layer(s, rdp_hdr, 6);
41    
42          return s;          return s;
# Line 52  rdp_send(STREAM s, uint8 pdu_type) Line 55  rdp_send(STREAM s, uint8 pdu_type)
55          out_uint16_le(s, (pdu_type | 0x10));    /* Version 1 */          out_uint16_le(s, (pdu_type | 0x10));    /* Version 1 */
56          out_uint16_le(s, (mcs_userid + 1001));          out_uint16_le(s, (mcs_userid + 1001));
57    
58          sec_send(s, SEC_ENCRYPT);          sec_send(s, use_encryption ? SEC_ENCRYPT : 0);
59  }  }
60    
61  /* Receive an RDP packet */  /* Receive an RDP packet */
# Line 78  rdp_recv(uint8 *type) Line 81  rdp_recv(uint8 *type)
81          in_uint16_le(rdp_s, length);          in_uint16_le(rdp_s, length);
82          in_uint16_le(rdp_s, pdu_type);          in_uint16_le(rdp_s, pdu_type);
83          in_uint8s(rdp_s, 2);    /* userid */          in_uint8s(rdp_s, 2);    /* userid */
   
         next_packet += length;  
84          *type = pdu_type & 0xf;          *type = pdu_type & 0xf;
85    
86  #if RDP_DEBUG  #if RDP_DEBUG
87          DEBUG("RDP packet (type %x):\n", *type);          DEBUG("RDP packet (type %x):\n", *type);
88          hexdump(rdp_s->p, length);          hexdump(next_packet, length);
89  #endif  #endif /*  */
90    
91            next_packet += length;
92          return rdp_s;          return rdp_s;
93  }  }
94    
# Line 96  rdp_init_data(int maxlen) Line 98  rdp_init_data(int maxlen)
98  {  {
99          STREAM s;          STREAM s;
100    
101          s = sec_init(SEC_ENCRYPT, maxlen + 18);          s = sec_init(use_encryption ? SEC_ENCRYPT : 0, maxlen + 18);
102          s_push_layer(s, rdp_hdr, 18);          s_push_layer(s, rdp_hdr, 18);
103    
104          return s;          return s;
# Line 123  rdp_send_data(STREAM s, uint8 data_pdu_t Line 125  rdp_send_data(STREAM s, uint8 data_pdu_t
125          out_uint8(s, 0);        /* compress_type */          out_uint8(s, 0);        /* compress_type */
126          out_uint16(s, 0);       /* compress_len */          out_uint16(s, 0);       /* compress_len */
127    
128          sec_send(s, SEC_ENCRYPT);          sec_send(s, use_encryption ? SEC_ENCRYPT : 0);
129  }  }
130    
131  /* Output a string in Unicode */  /* Output a string in Unicode */
# Line 153  rdp_send_logon_info(uint32 flags, char * Line 155  rdp_send_logon_info(uint32 flags, char *
155          int len_password = 2 * strlen(password);          int len_password = 2 * strlen(password);
156          int len_program = 2 * strlen(program);          int len_program = 2 * strlen(program);
157          int len_directory = 2 * strlen(directory);          int len_directory = 2 * strlen(directory);
158          uint32 sec_flags = SEC_LOGON_INFO | SEC_ENCRYPT;          uint32 sec_flags = use_encryption ? (SEC_LOGON_INFO | SEC_ENCRYPT)
159                                    : SEC_LOGON_INFO;
160          STREAM s;          STREAM s;
161    
162          s = sec_init(sec_flags, 18 + len_domain + len_user + len_password          s = sec_init(sec_flags, 18 + len_domain + len_user + len_password
# Line 280  rdp_out_bitmap_caps(STREAM s) Line 283  rdp_out_bitmap_caps(STREAM s)
283          out_uint16_le(s, 600);  /* Desktop height */          out_uint16_le(s, 600);  /* Desktop height */
284          out_uint16(s, 0);       /* Pad */          out_uint16(s, 0);       /* Pad */
285          out_uint16(s, 0);       /* Allow resize */          out_uint16(s, 0);       /* Allow resize */
286          out_uint16_le(s, 1);    /* Support compression */          out_uint16_le(s, bitmap_compression ? 1 : 0);   /* Support compression */
287          out_uint16(s, 0);       /* Unknown */          out_uint16(s, 0);       /* Unknown */
288          out_uint16_le(s, 1);    /* Unknown */          out_uint16_le(s, 1);    /* Unknown */
289          out_uint16(s, 0);       /* Pad */          out_uint16(s, 0);       /* Pad */
# Line 292  rdp_out_order_caps(STREAM s) Line 295  rdp_out_order_caps(STREAM s)
295  {  {
296          uint8 order_caps[32];          uint8 order_caps[32];
297    
         memset(order_caps, orders, 32);  
298    
299            memset(order_caps, 0, 32);
300            order_caps[0] = 1;      /* dest blt */
301            order_caps[1] = 1;      /* pat blt */
302            order_caps[2] = 1;      /* screen blt */
303            order_caps[8] = 1;      /* line */
304            order_caps[9] = 1;      /* line */
305            order_caps[10] = 1;     /* rect */
306            order_caps[11] = (desktop_save == False ? 0 : 1);       /* desksave */
307            order_caps[13] = 1;     /* memblt */
308            order_caps[14] = 1;     /* triblt */
309            order_caps[22] = 1;     /* polyline */
310            order_caps[27] = 1;     /* text2 */
311          out_uint16_le(s, RDP_CAPSET_ORDER);          out_uint16_le(s, RDP_CAPSET_ORDER);
312          out_uint16_le(s, RDP_CAPLEN_ORDER);          out_uint16_le(s, RDP_CAPLEN_ORDER);
313    
# Line 307  rdp_out_order_caps(STREAM s) Line 321  rdp_out_order_caps(STREAM s)
321          out_uint8p(s, order_caps, 32);  /* Orders supported */          out_uint8p(s, order_caps, 32);  /* Orders supported */
322          out_uint16_le(s, 0x6a1);        /* Text capability flags */          out_uint16_le(s, 0x6a1);        /* Text capability flags */
323          out_uint8s(s, 6);       /* Pad */          out_uint8s(s, 6);       /* Pad */
324          out_uint32(s, 0x38400); /* Desktop cache size */          out_uint32(s, desktop_save == False ? 0 : 0x38400);     /* Desktop cache size */
325          out_uint32(s, 0);       /* Unknown */          out_uint32(s, 0);       /* Unknown */
326          out_uint32(s, 0x4e4);   /* Unknown */          out_uint32(s, 0x4e4);   /* Unknown */
327  }  }
# Line 428  rdp_send_confirm_active() Line 442  rdp_send_confirm_active()
442                  RDP_CAPLEN_GENERAL + RDP_CAPLEN_BITMAP + RDP_CAPLEN_ORDER +                  RDP_CAPLEN_GENERAL + RDP_CAPLEN_BITMAP + RDP_CAPLEN_ORDER +
443                  RDP_CAPLEN_BMPCACHE + RDP_CAPLEN_COLCACHE +                  RDP_CAPLEN_BMPCACHE + RDP_CAPLEN_COLCACHE +
444                  RDP_CAPLEN_ACTIVATE + RDP_CAPLEN_CONTROL +                  RDP_CAPLEN_ACTIVATE + RDP_CAPLEN_CONTROL +
445                  RDP_CAPLEN_POINTER + RDP_CAPLEN_SHARE + RDP_CAPLEN_UNKNOWN;                  RDP_CAPLEN_POINTER + RDP_CAPLEN_SHARE + RDP_CAPLEN_UNKNOWN
446                            + 4 /* w2k fix, why? */;
447    
448          s = rdp_init(14 + caplen + sizeof(RDP_SOURCE));          s = rdp_init(14 + caplen + sizeof(RDP_SOURCE));
449    
# Line 470  process_demand_active(STREAM s) Line 485  process_demand_active(STREAM s)
485          rdp_send_synchronise();          rdp_send_synchronise();
486          rdp_send_control(RDP_CTL_COOPERATE);          rdp_send_control(RDP_CTL_COOPERATE);
487          rdp_send_control(RDP_CTL_REQUEST_CONTROL);          rdp_send_control(RDP_CTL_REQUEST_CONTROL);
488          rdp_recv(&type);        // RDP_PDU_SYNCHRONIZE          rdp_recv(&type);        /* RDP_PDU_SYNCHRONIZE */
489          rdp_recv(&type);        // RDP_CTL_COOPERATE          rdp_recv(&type);        /* RDP_CTL_COOPERATE */
490          rdp_recv(&type);        // RDP_CTL_GRANT_CONTROL          rdp_recv(&type);        /* RDP_CTL_GRANT_CONTROL */
491          rdp_send_input(0, RDP_INPUT_SYNCHRONIZE, 0, 0, 0);          rdp_send_input(0, RDP_INPUT_SYNCHRONIZE, 0, 0, 0);
492          rdp_send_fonts(1);          rdp_send_fonts(1);
493          rdp_send_fonts(2);          rdp_send_fonts(2);
494          rdp_recv(&type);        // RDP_PDU_UNKNOWN 0x28          rdp_recv(&type);        /* RDP_PDU_UNKNOWN 0x28 */
495          reset_order_state();          reset_order_state();
496  }  }
497    
# Line 485  static void Line 500  static void
500  process_pointer_pdu(STREAM s)  process_pointer_pdu(STREAM s)
501  {  {
502          uint16 message_type;          uint16 message_type;
503          uint16 x, y;          uint16 x, y, width, height, cache_idx, masklen, datalen;
504            uint8 *mask, *data;
505            HCURSOR cursor;
506    
507          in_uint16_le(s, message_type);          in_uint16_le(s, message_type);
508          in_uint8s(s, 2);        /* pad */          in_uint8s(s, 2);        /* pad */
# Line 499  process_pointer_pdu(STREAM s) Line 516  process_pointer_pdu(STREAM s)
516                                  ui_move_pointer(x, y);                                  ui_move_pointer(x, y);
517                          break;                          break;
518    
519                    case RDP_POINTER_COLOR:
520                            in_uint16_le(s, cache_idx);
521                            in_uint16_le(s, x);
522                            in_uint16_le(s, y);
523                            in_uint16_le(s, width);
524                            in_uint16_le(s, height);
525                            in_uint16_le(s, masklen);
526                            in_uint16_le(s, datalen);
527                            in_uint8p(s, data, datalen);
528                            in_uint8p(s, mask, masklen);
529                            cursor = ui_create_cursor(x, y, width, height, mask,
530                                                      data);
531                            ui_set_cursor(cursor);
532                            cache_put_cursor(cache_idx, cursor);
533                            break;
534    
535                    case RDP_POINTER_CACHED:
536                            in_uint16_le(s, cache_idx);
537                            ui_set_cursor(cache_get_cursor(cache_idx));
538                            break;
539    
540                  default:                  default:
541                          DEBUG("Pointer message 0x%x\n", message_type);                          DEBUG("Pointer message 0x%x\n", message_type);
542          }          }
# Line 511  process_bitmap_updates(STREAM s) Line 549  process_bitmap_updates(STREAM s)
549          uint16 num_updates;          uint16 num_updates;
550          uint16 left, top, right, bottom, width, height;          uint16 left, top, right, bottom, width, height;
551          uint16 cx, cy, bpp, compress, bufsize, size;          uint16 cx, cy, bpp, compress, bufsize, size;
552          uint8 *data, *rawdata;          uint8 *data, *bmpdata;
553          int i;          int i;
554    
555          in_uint16_le(s, num_updates);          in_uint16_le(s, num_updates);
# Line 536  process_bitmap_updates(STREAM s) Line 574  process_bitmap_updates(STREAM s)
574    
575                  if (!compress)                  if (!compress)
576                  {                  {
577                          in_uint8p(s, data, bufsize);                          int y;
578                            bmpdata = xmalloc(width * height);
579                            for (y = 0; y < height; y++)
580                            {
581                                    in_uint8a(s,
582                                              &bmpdata[(height - y - 1) * width],
583                                              width);
584                            }
585                          ui_paint_bitmap(left, top, cx, cy, width, height,                          ui_paint_bitmap(left, top, cx, cy, width, height,
586                                          data);                                          bmpdata);
587                          return;                          xfree(bmpdata);
588                            continue;
589                  }                  }
590    
591                  in_uint8s(s, 2);        /* pad */                  in_uint8s(s, 2);        /* pad */
# Line 547  process_bitmap_updates(STREAM s) Line 593  process_bitmap_updates(STREAM s)
593                  in_uint8s(s, 4);        /* line_size, final_size */                  in_uint8s(s, 4);        /* line_size, final_size */
594                  in_uint8p(s, data, size);                  in_uint8p(s, data, size);
595    
596                  rawdata = xmalloc(width * height);                  bmpdata = xmalloc(width * height);
597                  if (bitmap_decompress(rawdata, width, height, data, size))                  if (bitmap_decompress(bmpdata, width, height, data, size))
598                  {                  {
599                          ui_paint_bitmap(left, top, cx, cy, width, height,                          ui_paint_bitmap(left, top, cx, cy, width, height,
600                                          rawdata);                                          bmpdata);
601                  }                  }
602    
603                  xfree(rawdata);                  xfree(bmpdata);
604          }          }
605  }  }
606    

Legend:
Removed from v.25  
changed lines
  Added in v.28

  ViewVC Help
Powered by ViewVC 1.1.26