ReactOS 0.4.15-dev-7907-g95bf896
rdp.c
Go to the documentation of this file.
1/* -*- c-basic-offset: 8 -*-
2 rdesktop: A Remote Desktop Protocol client.
3 Protocol services - RDP layer
4 Copyright (C) Matthew Chapman 1999-2005
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License along
17 with this program; if not, write to the Free Software Foundation, Inc.,
18 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19*/
20
21#include <time.h>
22#include <errno.h>
23//#include <unistd.h>
24#include "rdesktop.h"
25
26#ifdef HAVE_ICONV
27#ifdef HAVE_ICONV_H
28#include <iconv.h>
29#endif
30
31#ifndef ICONV_CONST
32#define ICONV_CONST ""
33#endif
34#endif
35
36/* Receive an RDP packet */
37static STREAM
39{
40 static STREAM rdp_s; // FIXME HORROR
41 uint16 length, pdu_type;
42 uint8 rdpver;
43
44 if ((rdp_s == NULL) || (This->next_packet >= rdp_s->end) || (This->next_packet == NULL))
45 {
46 rdp_s = sec_recv(This, &rdpver);
47 if (rdp_s == NULL)
48 return NULL;
49 if (rdpver == 0xff)
50 {
51 This->next_packet = rdp_s->end;
52 *type = 0;
53 return rdp_s;
54 }
55 else if (rdpver != 3)
56 {
57 /* rdp5_process should move This->next_packet ok */
58 if(!rdp5_process(This, rdp_s))
59 return NULL;
60 *type = 0;
61 return rdp_s;
62 }
63
64 This->next_packet = rdp_s->p;
65 }
66 else
67 {
68 rdp_s->p = This->next_packet;
69 }
70
71 in_uint16_le(rdp_s, length);
72 /* 32k packets are really 8, keepalive fix */
73 if (length == 0x8000)
74 {
75 This->next_packet += 8;
76 *type = 0;
77 return rdp_s;
78 }
79 in_uint16_le(rdp_s, pdu_type);
80 in_uint8s(rdp_s, 2); /* userid */
81 *type = pdu_type & 0xf;
82
83#if WITH_DEBUG
84 DEBUG(("RDP packet #%d, (type %x)\n", ++This->rdp.packetno, *type));
85 hexdump(This->next_packet, length);
86#endif /* */
87
88 This->next_packet += length;
89 return rdp_s;
90}
91
92/* Initialise an RDP data packet */
93static STREAM
95{
96 STREAM s;
97
98 s = sec_init(This, This->encryption ? SEC_ENCRYPT : 0, maxlen + 18);
99
100 if(s == NULL)
101 return NULL;
102
103 s_push_layer(s, rdp_hdr, 18);
104
105 return s;
106}
107
108/* Send an RDP data packet */
109static BOOL
111{
113
114 s_pop_layer(s, rdp_hdr);
115 length = (uint16)(s->end - s->p);
116
118 out_uint16_le(s, (RDP_PDU_DATA | 0x10));
119 out_uint16_le(s, (This->mcs_userid + 1001));
120
121 out_uint32_le(s, This->rdp_shareid);
122 out_uint8(s, 0); /* pad */
123 out_uint8(s, 1); /* streamid */
124 out_uint16_le(s, (length - 14));
125 out_uint8(s, data_pdu_type);
126 out_uint8(s, 0); /* compress_type */
127 out_uint16(s, 0); /* compress_len */
128
129 return sec_send(This, s, This->encryption ? SEC_ENCRYPT : 0);
130}
131
132/* Output a string in Unicode */
133void
134rdp_out_unistr(RDPCLIENT * This, STREAM s, wchar_t *string, int len)
135{
136#ifdef HAVE_ICONV
137 size_t ibl = strlen(string), obl = len + 2;
138 static iconv_t iconv_h = (iconv_t) - 1;
139 char *pin = string, *pout = (char *) s->p;
140
141 memset(pout, 0, len + 4);
142
143 if (This->rdp.iconv_works)
144 {
145 if (iconv_h == (iconv_t) - 1)
146 {
147 size_t i = 1, o = 4;
148 if ((iconv_h = iconv_open(WINDOWS_CODEPAGE, This->codepage)) == (iconv_t) - 1)
149 {
150 warning("rdp_out_unistr: iconv_open[%s -> %s] fail %d\n",
151 This->codepage, WINDOWS_CODEPAGE, (int) iconv_h);
152
153 This->rdp.iconv_works = False;
154 rdp_out_unistr(This, s, string, len);
155 return;
156 }
157 if (iconv(iconv_h, (ICONV_CONST char **) &pin, &i, &pout, &o) ==
158 (size_t) - 1)
159 {
160 iconv_close(iconv_h);
161 iconv_h = (iconv_t) - 1;
162 warning("rdp_out_unistr: iconv(1) fail, errno %d\n", errno);
163
164 This->rdp.iconv_works = False;
165 rdp_out_unistr(This, s, string, len);
166 return;
167 }
168 pin = string;
169 pout = (char *) s->p;
170 }
171
172 if (iconv(iconv_h, (ICONV_CONST char **) &pin, &ibl, &pout, &obl) == (size_t) - 1)
173 {
174 iconv_close(iconv_h);
175 iconv_h = (iconv_t) - 1;
176 warning("rdp_out_unistr: iconv(2) fail, errno %d\n", errno);
177
178 This->rdp.iconv_works = False;
179 rdp_out_unistr(This, s, string, len);
180 return;
181 }
182
183 s->p += len + 2;
184
185 }
186 else
187#endif
188 // TODO
189 {
190 int i = 0, j = 0;
191
192 len += 2;
193
194 while (i < len)
195 {
196 int c = string[j++];
197 s->p[i++] = (c >> 0) & 0xFF;
198 s->p[i++] = (c >> 8) & 0xFF;
199 }
200
201 s->p += len;
202 }
203}
204
205/* Input a string in Unicode
206 *
207 * Returns str_len of string
208 */
209int
210rdp_in_unistr(RDPCLIENT * This, STREAM s, wchar_t *string, int uni_len)
211{
212#ifdef HAVE_ICONV
213 size_t ibl = uni_len, obl = uni_len;
214 char *pin = (char *) s->p, *pout = string;
215 static iconv_t iconv_h = (iconv_t) - 1;
216
217 if (This->rdp.iconv_works)
218 {
219 if (iconv_h == (iconv_t) - 1)
220 {
221 if ((iconv_h = iconv_open(This->codepage, WINDOWS_CODEPAGE)) == (iconv_t) - 1)
222 {
223 warning("rdp_in_unistr: iconv_open[%s -> %s] fail %d\n",
224 WINDOWS_CODEPAGE, This->codepage, (int) iconv_h);
225
226 This->rdp.iconv_works = False;
227 return rdp_in_unistr(This, s, string, uni_len);
228 }
229 }
230
231 if (iconv(iconv_h, (ICONV_CONST char **) &pin, &ibl, &pout, &obl) == (size_t) - 1)
232 {
233 iconv_close(iconv_h);
234 iconv_h = (iconv_t) - 1;
235 warning("rdp_in_unistr: iconv fail, errno %d\n", errno);
236
237 This->rdp.iconv_works = False;
238 return rdp_in_unistr(This, s, string, uni_len);
239 }
240
241 /* we must update the location of the current STREAM for future reads of s->p */
242 s->p += uni_len;
243
244 return pout - string;
245 }
246 else
247#endif
248 // TODO
249 {
250 int i = 0;
251
252 while (i < uni_len / 2)
253 {
254 in_uint8a(s, &string[i++], 1);
255 in_uint8s(s, 1);
256 }
257
258 return i - 1;
259 }
260}
261
262
263/* Parse a logon info packet */
264static BOOL
266 wchar_t *password, wchar_t *program, wchar_t *directory)
267{
268 wchar_t *ipaddr = tcp_get_address(This);
269 int len_domain = 2 * (int)wcslen(domain);
270 int len_user = 2 * (int)wcslen(user);
271 int len_password = 2 * (int)wcslen(password);
272 int len_program = 2 * (int)wcslen(program);
273 int len_directory = 2 * (int)wcslen(directory);
274 int len_ip = 2 * (int)wcslen(ipaddr);
275 int len_dll = 2 * (int)wcslen(L"C:\\WINNT\\System32\\mstscax.dll");
276 int packetlen = 0;
277 uint32 sec_flags = This->encryption ? (SEC_LOGON_INFO | SEC_ENCRYPT) : SEC_LOGON_INFO;
278 STREAM s;
279 time_t t = time(NULL);
280 time_t tzone;
281
282 if (!This->use_rdp5 || 1 == This->server_rdp_version)
283 {
284 DEBUG_RDP5(("Sending RDP4-style Logon packet\n"));
285
286 s = sec_init(This, sec_flags, 18 + len_domain + len_user + len_password
287 + len_program + len_directory + 10);
288
289 if(s == NULL)
290 return False;
291
292 out_uint32(s, 0);
294 out_uint16_le(s, len_domain);
295 out_uint16_le(s, len_user);
296 out_uint16_le(s, len_password);
297 out_uint16_le(s, len_program);
298 out_uint16_le(s, len_directory);
299 rdp_out_unistr(This, s, domain, len_domain);
300 rdp_out_unistr(This, s, user, len_user);
301 rdp_out_unistr(This, s, password, len_password);
302 rdp_out_unistr(This, s, program, len_program);
303 rdp_out_unistr(This, s, directory, len_directory);
304 }
305 else
306 {
307
309 DEBUG_RDP5(("Sending RDP5-style Logon packet\n"));
310 packetlen = 4 + /* Unknown uint32 */
311 4 + /* flags */
312 2 + /* len_domain */
313 2 + /* len_user */
314 (flags & RDP_LOGON_AUTO ? 2 : 0) + /* len_password */
315 (flags & RDP_LOGON_BLOB ? 2 : 0) + /* Length of BLOB */
316 2 + /* len_program */
317 2 + /* len_directory */
318 (0 < len_domain ? len_domain : 2) + /* domain */
319 len_user + (flags & RDP_LOGON_AUTO ? len_password : 0) + 0 + /* We have no 512 byte BLOB. Perhaps we must? */
320 (flags & RDP_LOGON_BLOB && !(flags & RDP_LOGON_AUTO) ? 2 : 0) + /* After the BLOB is a unknown int16. If there is a BLOB, that is. */
321 (0 < len_program ? len_program : 2) + (0 < len_directory ? len_directory : 2) + 2 + /* Unknown (2) */
322 2 + /* Client ip length */
323 len_ip + /* Client ip */
324 2 + /* DLL string length */
325 len_dll + /* DLL string */
326 2 + /* Unknown */
327 2 + /* Unknown */
328 64 + /* Time zone #0 */
329 2 + /* Unknown */
330 64 + /* Time zone #1 */
331 32; /* Unknown */
332
333 s = sec_init(This, sec_flags, packetlen);
334 DEBUG_RDP5(("Called sec_init with packetlen %d\n", packetlen));
335
336 if(s == NULL)
337 return False;
338
339 out_uint32(s, 0); /* Unknown */
341 out_uint16_le(s, len_domain);
342 out_uint16_le(s, len_user);
343 if (flags & RDP_LOGON_AUTO)
344 {
345 out_uint16_le(s, len_password);
346
347 }
349 {
350 out_uint16_le(s, 0);
351 }
352 out_uint16_le(s, len_program);
353 out_uint16_le(s, len_directory);
354 if (0 < len_domain)
355 rdp_out_unistr(This, s, domain, len_domain);
356 else
357 out_uint16_le(s, 0);
358 rdp_out_unistr(This, s, user, len_user);
359 if (flags & RDP_LOGON_AUTO)
360 {
361 rdp_out_unistr(This, s, password, len_password);
362 }
364 {
365 out_uint16_le(s, 0);
366 }
367 if (0 < len_program)
368 {
369 rdp_out_unistr(This, s, program, len_program);
370
371 }
372 else
373 {
374 out_uint16_le(s, 0);
375 }
376 if (0 < len_directory)
377 {
378 rdp_out_unistr(This, s, directory, len_directory);
379 }
380 else
381 {
382 out_uint16_le(s, 0);
383 }
384 out_uint16_le(s, 2);
385 out_uint16_le(s, len_ip + 2); /* Length of client ip */
386 rdp_out_unistr(This, s, ipaddr, len_ip);
387 out_uint16_le(s, len_dll + 2);
388 rdp_out_unistr(This, s, L"C:\\WINNT\\System32\\mstscax.dll", len_dll);
389
390 tzone = (mktime(gmtime(&t)) - mktime(localtime(&t))) / 60;
391 out_uint32_le(s, (uint32)tzone);
392
393 rdp_out_unistr(This, s, L"GTB, normaltid", 2 * (int)wcslen(L"GTB, normaltid"));
394 out_uint8s(s, 62 - 2 * wcslen(L"GTB, normaltid"));
395
396 out_uint32_le(s, 0x0a0000);
397 out_uint32_le(s, 0x050000);
398 out_uint32_le(s, 3);
399 out_uint32_le(s, 0);
400 out_uint32_le(s, 0);
401
402 rdp_out_unistr(This, s, L"GTB, sommartid", 2 * (int)wcslen(L"GTB, sommartid"));
403 out_uint8s(s, 62 - 2 * wcslen(L"GTB, sommartid"));
404
405 out_uint32_le(s, 0x30000);
406 out_uint32_le(s, 0x050000);
407 out_uint32_le(s, 2);
408 out_uint32(s, 0);
409 out_uint32_le(s, 0xffffffc4);
410 out_uint32_le(s, 0xfffffffe);
411 out_uint32_le(s, This->rdp5_performanceflags);
412 out_uint32(s, 0);
413
414
415 }
416 s_mark_end(s);
417 return sec_send(This, s, sec_flags);
418}
419
420/* Send a control PDU */
421static BOOL
423{
424 STREAM s;
425
426 s = rdp_init_data(This, 8);
427
428 if(s == NULL)
429 return False;
430
432 out_uint16(s, 0); /* userid */
433 out_uint32(s, 0); /* control id */
434
435 s_mark_end(s);
437}
438
439/* Send a synchronisation PDU */
440static BOOL
442{
443 STREAM s;
444
445 s = rdp_init_data(This, 4);
446
447 if(s == NULL)
448 return False;
449
450 out_uint16_le(s, 1); /* type */
451 out_uint16_le(s, 1002);
452
453 s_mark_end(s);
455}
456
457/* Send a single input event */
458BOOL
459rdp_send_input(RDPCLIENT * This, uint32 time, uint16 message_type, uint16 device_flags, uint16 param1, uint16 param2)
460{
461 STREAM s;
462
463 s = rdp_init_data(This, 16);
464
465 if(s == NULL)
466 return False;
467
468 out_uint16_le(s, 1); /* number of events */
469 out_uint16(s, 0); /* pad */
470
472 out_uint16_le(s, message_type);
473 out_uint16_le(s, device_flags);
474 out_uint16_le(s, param1);
475 out_uint16_le(s, param2);
476
477 s_mark_end(s);
479}
480
481/* Send a client window information PDU */
482BOOL
484{
485 STREAM s;
486
487 if (This->rdp.current_status == status)
488 return True;
489
490 s = rdp_init_data(This, 12);
491
492 if(s == NULL)
493 return False;
494
496
497 switch (status)
498 {
499 case 0: /* shut the server up */
500 break;
501
502 case 1: /* receive data again */
503 out_uint32_le(s, 0); /* unknown */
504 out_uint16_le(s, This->width);
505 out_uint16_le(s, This->height);
506 break;
507 }
508
509 s_mark_end(s);
510 This->rdp.current_status = status;
512}
513
514/* Send persistent bitmap cache enumeration PDU's */
515static BOOL
517{
518 STREAM s;
520 uint32 num_keys, offset, count, flags;
521
522 offset = 0;
523 num_keys = pstcache_enumerate(This, 2, keylist);
524
525 while (offset < num_keys)
526 {
527 count = MIN(num_keys - offset, 169);
528
529 s = rdp_init_data(This, 24 + count * sizeof(HASH_KEY));
530
531 if(s == NULL)
532 return False;
533
534 flags = 0;
535 if (offset == 0)
537 if (num_keys - offset <= 169)
539
540 /* header */
541 out_uint32_le(s, 0);
543 out_uint16_le(s, 0);
544 out_uint16_le(s, 0);
545 out_uint16_le(s, 0);
546 out_uint16_le(s, 0);
547 out_uint16_le(s, num_keys);
548 out_uint32_le(s, 0);
550
551 /* list */
552 out_uint8a(s, keylist[offset], count * sizeof(HASH_KEY));
553
554 s_mark_end(s);
555 if(!rdp_send_data(This, s, 0x2b))
556 return False;
557
558 offset += 169;
559 }
560
561 return True;
562}
563
564/* Send an (empty) font information PDU */
565static BOOL
567{
568 STREAM s;
569
570 s = rdp_init_data(This, 8);
571
572 if(s == NULL)
573 return False;
574
575 out_uint16(s, 0); /* number of fonts */
576 out_uint16_le(s, 0); /* pad? */
577 out_uint16_le(s, seq); /* unknown */
578 out_uint16_le(s, 0x32); /* entry size */
579
580 s_mark_end(s);
582}
583
584/* Output general capability set */
585static void
587{
590
591 out_uint16_le(s, 1); /* OS major type */
592 out_uint16_le(s, 3); /* OS minor type */
593 out_uint16_le(s, 0x200); /* Protocol version */
594 out_uint16(s, 0); /* Pad */
595 out_uint16(s, 0); /* Compression types */
596 out_uint16_le(s, This->use_rdp5 ? 0x40d : 0);
597 /* Pad, according to T.128. 0x40d seems to
598 trigger
599 the server to start sending RDP5 packets.
600 However, the value is 0x1d04 with W2KTSK and
601 NT4MS. Hmm.. Anyway, thankyou, Microsoft,
602 for sending such information in a padding
603 field.. */
604 out_uint16(s, 0); /* Update capability */
605 out_uint16(s, 0); /* Remote unshare capability */
606 out_uint16(s, 0); /* Compression level */
607 out_uint16(s, 0); /* Pad */
608}
609
610/* Output bitmap capability set */
611static void
613{
616
617 out_uint16_le(s, This->server_depth); /* Preferred colour depth */
618 out_uint16_le(s, 1); /* Receive 1 BPP */
619 out_uint16_le(s, 1); /* Receive 4 BPP */
620 out_uint16_le(s, 1); /* Receive 8 BPP */
621 out_uint16_le(s, 800); /* Desktop width */
622 out_uint16_le(s, 600); /* Desktop height */
623 out_uint16(s, 0); /* Pad */
624 out_uint16(s, 1); /* Allow resize */
625 out_uint16_le(s, This->bitmap_compression ? 1 : 0); /* Support compression */
626 out_uint16(s, 0); /* Unknown */
627 out_uint16_le(s, 1); /* Unknown */
628 out_uint16(s, 0); /* Pad */
629}
630
631/* Output order capability set */
632static void
634{
635 uint8 order_caps[32];
636
637 memset(order_caps, 0, 32);
638 order_caps[0] = 1; /* dest blt */
639 order_caps[1] = 1; /* pat blt */
640 order_caps[2] = 1; /* screen blt */
641 order_caps[3] = (This->bitmap_cache ? 1 : 0); /* memblt */
642 order_caps[4] = 0; /* triblt */
643 order_caps[8] = 1; /* line */
644 order_caps[9] = 1; /* line */
645 order_caps[10] = 1; /* rect */
646 order_caps[11] = (This->desktop_save ? 1 : 0); /* desksave */
647 order_caps[13] = 1; /* memblt */
648 order_caps[14] = 1; /* triblt */
649 order_caps[20] = (This->polygon_ellipse_orders ? 1 : 0); /* polygon */
650 order_caps[21] = (This->polygon_ellipse_orders ? 1 : 0); /* polygon2 */
651 order_caps[22] = 1; /* polyline */
652 order_caps[25] = (This->polygon_ellipse_orders ? 1 : 0); /* ellipse */
653 order_caps[26] = (This->polygon_ellipse_orders ? 1 : 0); /* ellipse2 */
654 order_caps[27] = 1; /* text2 */
657
658 out_uint8s(s, 20); /* Terminal desc, pad */
659 out_uint16_le(s, 1); /* Cache X granularity */
660 out_uint16_le(s, 20); /* Cache Y granularity */
661 out_uint16(s, 0); /* Pad */
662 out_uint16_le(s, 1); /* Max order level */
663 out_uint16_le(s, 0x147); /* Number of fonts */
664 out_uint16_le(s, 0x2a); /* Capability flags */
665 out_uint8p(s, order_caps, 32); /* Orders supported */
666 out_uint16_le(s, 0x6a1); /* Text capability flags */
667 out_uint8s(s, 6); /* Pad */
668 out_uint32_le(s, This->desktop_save == False ? 0 : 0x38400); /* Desktop cache size */
669 out_uint32(s, 0); /* Unknown */
670 out_uint32_le(s, 0x4e4); /* Unknown */
671}
672
673/* Output bitmap cache capability set */
674static void
676{
677 int Bpp;
680
681 Bpp = (This->server_depth + 7) / 8; /* bytes per pixel */
682 out_uint8s(s, 24); /* unused */
683 out_uint16_le(s, 0x258); /* entries */
684 out_uint16_le(s, 0x100 * Bpp); /* max cell size */
685 out_uint16_le(s, 0x12c); /* entries */
686 out_uint16_le(s, 0x400 * Bpp); /* max cell size */
687 out_uint16_le(s, 0x106); /* entries */
688 out_uint16_le(s, 0x1000 * Bpp); /* max cell size */
689}
690
691/* Output bitmap cache v2 capability set */
692static void
694{
697
698 out_uint16_le(s, This->bitmap_cache_persist_enable ? 2 : 0); /* version */
699
700 out_uint16_be(s, 3); /* number of caches in this set */
701
702 /* max cell size for cache 0 is 16x16, 1 = 32x32, 2 = 64x64, etc */
705 if (pstcache_init(This, 2))
706 {
708 }
709 else
710 {
712 }
713 out_uint8s(s, 20); /* other bitmap caches not used */
714}
715
716/* Output control capability set */
717static void
719{
722
723 out_uint16(s, 0); /* Control capabilities */
724 out_uint16(s, 0); /* Remote detach */
725 out_uint16_le(s, 2); /* Control interest */
726 out_uint16_le(s, 2); /* Detach interest */
727}
728
729/* Output activation capability set */
730static void
732{
735
736 out_uint16(s, 0); /* Help key */
737 out_uint16(s, 0); /* Help index key */
738 out_uint16(s, 0); /* Extended help key */
739 out_uint16(s, 0); /* Window activate */
740}
741
742/* Output pointer capability set */
743static void
745{
748
749 out_uint16(s, 0); /* Colour pointer */
750 out_uint16_le(s, 20); /* Cache size */
751}
752
753/* Output share capability set */
754static void
756{
759
760 out_uint16(s, 0); /* userid */
761 out_uint16(s, 0); /* pad */
762}
763
764/* Output colour cache capability set */
765static void
767{
770
771 out_uint16_le(s, 6); /* cache size */
772 out_uint16(s, 0); /* pad */
773}
774
775static const uint8 caps_0x0d[] = {
776 0x01, 0x00, 0x00, 0x00, 0x09, 0x04, 0x00, 0x00,
777 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
778 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
779 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
780 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
781 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
782 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
783 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
784 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
785 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
786 0x00, 0x00, 0x00, 0x00
787};
788
789static const uint8 caps_0x0c[] = { 0x01, 0x00, 0x00, 0x00 };
790
791static const uint8 caps_0x0e[] = { 0x01, 0x00, 0x00, 0x00 };
792
793static const uint8 caps_0x10[] = {
794 0xFE, 0x00, 0x04, 0x00, 0xFE, 0x00, 0x04, 0x00,
795 0xFE, 0x00, 0x08, 0x00, 0xFE, 0x00, 0x08, 0x00,
796 0xFE, 0x00, 0x10, 0x00, 0xFE, 0x00, 0x20, 0x00,
797 0xFE, 0x00, 0x40, 0x00, 0xFE, 0x00, 0x80, 0x00,
798 0xFE, 0x00, 0x00, 0x01, 0x40, 0x00, 0x00, 0x08,
799 0x00, 0x01, 0x00, 0x01, 0x02, 0x00, 0x00, 0x00
800};
801
802/* Output unknown capability sets */
803static void
805{
806 out_uint16_le(s, id);
808
809 out_uint8p(s, caps, length - 4);
810}
811
812#define RDP5_FLAG 0x0030
813/* Send a confirm active PDU */
814static BOOL
816{
817 STREAM s;
818 uint32 sec_flags = This->encryption ? (RDP5_FLAG | SEC_ENCRYPT) : RDP5_FLAG;
819 uint16 caplen =
824 0x58 + 0x08 + 0x08 + 0x34 /* unknown caps */ +
825 4 /* w2k fix, why? */ ;
826
827 s = sec_init(This, sec_flags, 6 + 14 + caplen + sizeof(RDP_SOURCE));
828
829 if(s == NULL)
830 return False;
831
832 out_uint16_le(s, 2 + 14 + caplen + sizeof(RDP_SOURCE));
833 out_uint16_le(s, (RDP_PDU_CONFIRM_ACTIVE | 0x10)); /* Version 1 */
834 out_uint16_le(s, (This->mcs_userid + 1001));
835
836 out_uint32_le(s, This->rdp_shareid);
837 out_uint16_le(s, 0x3ea); /* userid */
838 out_uint16_le(s, sizeof(RDP_SOURCE));
839 out_uint16_le(s, caplen);
840
842 out_uint16_le(s, 0xd); /* num_caps */
843 out_uint8s(s, 2); /* pad */
844
854
855 rdp_out_unknown_caps(s, 0x0d, 0x58, caps_0x0d); /* international? */
856 rdp_out_unknown_caps(s, 0x0c, 0x08, caps_0x0c);
857 rdp_out_unknown_caps(s, 0x0e, 0x08, caps_0x0e);
858 rdp_out_unknown_caps(s, 0x10, 0x34, caps_0x10); /* glyph cache? */
859
860 s_mark_end(s);
861 return sec_send(This, s, sec_flags);
862}
863
864/* Process a general capability set */
865static void
867{
868 uint16 pad2octetsB; /* rdp5 flags? */
869
870 in_uint8s(s, 10);
871 in_uint16_le(s, pad2octetsB);
872
873 if (!pad2octetsB)
874 This->use_rdp5 = False;
875}
876
877/* Process a bitmap capability set */
878static void
880{
882
884 in_uint8s(s, 6);
885
888
889 DEBUG(("setting desktop size and depth to: %dx%dx%d\n", width, height, depth));
890
891 /*
892 * The server may limit depth and change the size of the desktop (for
893 * example when shadowing another session).
894 */
895 if (This->server_depth != depth)
896 {
897 warning("Remote desktop does not support colour depth %d; falling back to %d\n",
898 This->server_depth, depth);
899 This->server_depth = depth;
900 }
901 if (This->width != width || This->height != height)
902 {
903 warning("Remote desktop changed from %dx%d to %dx%d.\n", This->width, This->height,
904 width, height);
905 This->width = width;
906 This->height = height;
908 }
909}
910
911/* Process server capabilities */
912static void
914{
915 int n;
916 uint8 *next, *start;
917 uint16 ncapsets, capset_type, capset_length;
918
919 start = s->p;
920
921 in_uint16_le(s, ncapsets);
922 in_uint8s(s, 2); /* pad */
923
924 for (n = 0; n < ncapsets; n++)
925 {
926 if (s->p > start + length)
927 return;
928
929 in_uint16_le(s, capset_type);
930 in_uint16_le(s, capset_length);
931
932 next = s->p + capset_length - 4;
933
934 switch (capset_type)
935 {
938 break;
939
942 break;
943 }
944
945 s->p = next;
946 }
947}
948
949/* Respond to a demand active PDU */
950static BOOL
952{
953 uint8 type;
954 uint16 len_src_descriptor, len_combined_caps;
955
956 in_uint32_le(s, This->rdp_shareid);
957 in_uint16_le(s, len_src_descriptor);
958 in_uint16_le(s, len_combined_caps);
959 in_uint8s(s, len_src_descriptor);
960
961 DEBUG(("DEMAND_ACTIVE(id=0x%x)\n", This->rdp_shareid));
962 rdp_process_server_caps(This, s, len_combined_caps);
963
964 if
965 (
970 !rdp_recv(This, &type) || /* RDP_PDU_SYNCHRONIZE */
971 !rdp_recv(This, &type) || /* RDP_CTL_COOPERATE */
972 !rdp_recv(This, &type) || /* RDP_CTL_GRANT_CONTROL */
974 /*This->numlock_sync ? ui_get_numlock_state(This, read_keyboard_state(This)) :*/ 0, 0) // TODO: keyboard mess
975 )
976 return False;
977
978 if (This->use_rdp5)
979 {
981 return False;
982 }
983 else
984 {
985 if(!rdp_send_fonts(This, 1) || !rdp_send_fonts(This, 2))
986 return False;
987 }
988
989 if(!rdp_recv(This, &type)) /* RDP_PDU_UNKNOWN 0x28 (Fonts?) */
990 return False;
991
993 return True;
994}
995
996/* Process a colour pointer PDU */
997void
999{
1000 uint16 x, y, width, height, cache_idx, masklen, datalen;
1001 uint8 *mask, *data;
1003
1004 in_uint16_le(s, cache_idx);
1005 in_uint16_le(s, x);
1006 in_uint16_le(s, y);
1009 in_uint16_le(s, masklen);
1012 in_uint8p(s, mask, masklen);
1015 cache_put_cursor(This, cache_idx, cursor);
1016}
1017
1018/* Process a cached pointer PDU */
1019void
1021{
1022 uint16 cache_idx;
1023
1024 in_uint16_le(s, cache_idx);
1026}
1027
1028/* Process a system pointer PDU */
1029void
1031{
1032 uint16 system_pointer_type;
1033
1034 in_uint16(s, system_pointer_type);
1035 switch (system_pointer_type)
1036 {
1037 case RDP_NULL_POINTER:
1039 break;
1040
1041 default:
1042 unimpl("System pointer message 0x%x\n", system_pointer_type);
1043 }
1044}
1045
1046/* Process a pointer PDU */
1047static void
1049{
1050 uint16 message_type;
1051 uint16 x, y;
1052
1053 in_uint16_le(s, message_type);
1054 in_uint8s(s, 2); /* pad */
1055
1056 switch (message_type)
1057 {
1058 case RDP_POINTER_MOVE:
1059 in_uint16_le(s, x);
1060 in_uint16_le(s, y);
1061 if (s_check(s))
1063 break;
1064
1065 case RDP_POINTER_COLOR:
1067 break;
1068
1069 case RDP_POINTER_CACHED:
1071 break;
1072
1073 case RDP_POINTER_SYSTEM:
1075 break;
1076
1077 default:
1078 unimpl("Pointer message 0x%x\n", message_type);
1079 }
1080}
1081
1082/* Process bitmap updates */
1083void
1085{
1086 uint16 num_updates;
1088 uint16 cx, cy, bpp, Bpp, compress, bufsize, size;
1089 uint8 *data, *bmpdata;
1090 int i;
1091
1092 in_uint16_le(s, num_updates);
1093
1094 for (i = 0; i < num_updates; i++)
1095 {
1097 in_uint16_le(s, top);
1102 in_uint16_le(s, bpp);
1103 Bpp = (bpp + 7) / 8;
1106
1107 cx = right - left + 1;
1108 cy = bottom - top + 1;
1109
1110 DEBUG(("BITMAP_UPDATE(l=%d,t=%d,r=%d,b=%d,w=%d,h=%d,Bpp=%d,cmp=%d)\n",
1111 left, top, right, bottom, width, height, Bpp, compress));
1112
1113 if (!compress)
1114 {
1115#if 0
1116 int y;
1117 bmpdata = (uint8 *) xmalloc(width * height * Bpp);
1118 for (y = 0; y < height; y++)
1119 {
1120 in_uint8a(s, &bmpdata[(height - y - 1) * (width * Bpp)],
1121 width * Bpp);
1122 }
1123 ui_paint_bitmap(This, left, top, cx, cy, width, height, bmpdata);
1124 xfree(bmpdata);
1125#else
1126 in_uint8p(s, bmpdata, width * height * Bpp);
1127 ui_paint_bitmap(This, left, top, cx, cy, width, height, bmpdata);
1128#endif
1129 continue;
1130 }
1131
1132
1133 if (compress & 0x400)
1134 {
1135 size = bufsize;
1136 }
1137 else
1138 {
1139 in_uint8s(s, 2); /* pad */
1141 in_uint8s(s, 4); /* line_size, final_size */
1142 }
1143 in_uint8p(s, data, size);
1144 bmpdata = (uint8 *) malloc(width * height * Bpp);
1145
1146 if(bmpdata == NULL)
1147 return;
1148
1149 if (bitmap_decompress(bmpdata, width, height, data, size, Bpp))
1150 {
1151 ui_paint_bitmap(This, left, top, cx, cy, width, height, bmpdata);
1152 }
1153 else
1154 {
1155 DEBUG_RDP5(("Failed to decompress data\n"));
1156 }
1157
1158 free(bmpdata);
1159 }
1160}
1161
1162/* Process a palette update */
1163void
1165{
1167 COLOURMAP map;
1168 HCOLOURMAP hmap;
1169 int i;
1170
1171 in_uint8s(s, 2); /* pad */
1172 in_uint16_le(s, map.ncolours);
1173 in_uint8s(s, 2); /* pad */
1174
1175 map.colours = (COLOURENTRY *) malloc(sizeof(COLOURENTRY) * map.ncolours);
1176
1177 if(map.colours == NULL)
1178 {
1179 in_uint8s(s, sizeof(*entry) * map.ncolours);
1180 return;
1181 }
1182
1183 DEBUG(("PALETTE(c=%d)\n", map.ncolours));
1184
1185 for (i = 0; i < map.ncolours; i++)
1186 {
1187 entry = &map.colours[i];
1188 in_uint8(s, entry->red);
1189 in_uint8(s, entry->green);
1190 in_uint8(s, entry->blue);
1191 }
1192
1193 hmap = ui_create_colourmap(This, &map);
1194 ui_set_colourmap(This, hmap);
1195
1196 free(map.colours);
1197}
1198
1199/* Process an update PDU */
1200static void
1202{
1203 uint16 update_type, count;
1204
1205 in_uint16_le(s, update_type);
1206
1208 switch (update_type)
1209 {
1210 case RDP_UPDATE_ORDERS:
1211 in_uint8s(s, 2); /* pad */
1213 in_uint8s(s, 2); /* pad */
1215 break;
1216
1217 case RDP_UPDATE_BITMAP:
1219 break;
1220
1221 case RDP_UPDATE_PALETTE:
1223 break;
1224
1226 break;
1227
1228 default:
1229 unimpl("update %d\n", update_type);
1230 }
1232}
1233
1234/* Process a disconnect PDU */
1235void
1237{
1239
1240 DEBUG(("Received disconnect PDU\n"));
1241}
1242
1243/* Process data PDU */
1244static BOOL
1246{
1247 uint8 data_pdu_type;
1248 uint8 ctype;
1249 uint16 clen;
1250 uint32 len;
1251
1252 uint32 roff, rlen;
1253
1254 struct stream *ns = &(This->mppc_dict.ns);
1255
1256 in_uint8s(s, 6); /* shareid, pad, streamid */
1257 in_uint16(s, len);
1258 in_uint8(s, data_pdu_type);
1259 in_uint8(s, ctype);
1260 in_uint16(s, clen);
1261 clen -= 18;
1262
1264 {
1265 void * p;
1266
1267 if (len > RDP_MPPC_DICT_SIZE)
1268 error("error decompressed packet size exceeds max\n");
1269 if (mppc_expand(This, s->p, clen, ctype, &roff, &rlen) == -1)
1270 error("error while decompressing packet\n");
1271
1272 /* len -= 18; */
1273
1274 /* allocate memory and copy the uncompressed data into the temporary stream */
1275 p = realloc(ns->data, rlen);
1276
1277 if(p == NULL)
1278 {
1279 This->disconnect_reason = 262;
1280 return True;
1281 }
1282
1283 ns->data = (uint8 *) p;
1284
1285 memcpy((ns->data), (unsigned char *) (This->mppc_dict.hist + roff), rlen);
1286
1287 ns->size = rlen;
1288 ns->end = (ns->data + ns->size);
1289 ns->p = ns->data;
1290 ns->rdp_hdr = ns->p;
1291
1292 s = ns;
1293 }
1294
1295 switch (data_pdu_type)
1296 {
1299 break;
1300
1302 DEBUG(("Received Control PDU\n"));
1303 break;
1304
1306 DEBUG(("Received Sync PDU\n"));
1307 break;
1308
1311 break;
1312
1313 case RDP_DATA_PDU_BELL:
1314 ui_bell(This);
1315 break;
1316
1317 case RDP_DATA_PDU_LOGON:
1318 DEBUG(("Received Logon PDU\n"));
1320 /* User logged on */
1321 break;
1322
1325
1326 /* We used to return true and disconnect immediately here, but
1327 * Windows Vista sends a disconnect PDU with reason 0 when
1328 * reconnecting to a disconnected session, and MSTSC doesn't
1329 * drop the connection. I think we should just save the status.
1330 */
1331 break;
1332
1333 default:
1334 unimpl("data PDU %d\n", data_pdu_type);
1335 }
1336 return False;
1337}
1338
1339/* Process redirect PDU from Session Directory */
1340static BOOL
1341process_redirect_pdu(RDPCLIENT * This, STREAM s /*, uint32 * ext_disc_reason */ )
1342{
1343 uint32 flags;
1344
1345 uint32 server_len;
1346 wchar_t * server;
1347
1348 uint32 cookie_len;
1349 char * cookie;
1350
1351 uint32 username_len;
1352 wchar_t * username;
1353
1354 uint32 domain_len;
1355 wchar_t * domain;
1356
1357 uint32 password_len;
1358 wchar_t * password;
1359
1360 /* these 2 bytes are unknown, seem to be zeros */
1361 in_uint8s(s, 2);
1362
1363 /* read connection flags */
1365
1366 /* read length of ip string */
1367 in_uint32_le(s, server_len);
1368
1369 /* read ip string */
1370 server = (wchar_t *)s->p;
1371 in_uint8s(s, server_len);
1372
1373 /* read length of cookie string */
1374 in_uint32_le(s, cookie_len);
1375
1376 /* read cookie string (plain ASCII) */
1377 cookie = (char *)s->p;
1378 in_uint8s(s, cookie_len);
1379
1380 /* read length of username string */
1381 in_uint32_le(s, username_len);
1382
1383 /* read username string */
1384 username = (wchar_t *)s->p;
1385 in_uint8s(s, username_len);
1386
1387 /* read length of domain string */
1388 in_uint32_le(s, domain_len);
1389
1390 /* read domain string */
1391 domain = (wchar_t *)s->p;
1392 in_uint8s(s, domain_len);
1393
1394 /* read length of password string */
1395 in_uint32_le(s, password_len);
1396
1397 /* read password string */
1398 password = (wchar_t *)s->p;
1399 in_uint8s(s, password_len);
1400
1401 This->redirect = True;
1402
1403 return event_redirect
1404 (
1405 This,
1406 flags,
1407 server_len,
1408 server,
1409 cookie_len,
1410 cookie,
1411 username_len,
1412 username,
1413 domain_len,
1414 domain,
1415 password_len,
1416 password
1417 );
1418}
1419
1420/* Process incoming packets */
1421/* nevers gets out of here till app is done */
1422void
1424{
1426 ;
1427}
1428
1429/* used in uiports and rdp_main_loop, processes the rdp packets waiting */
1430BOOL
1432{
1433 uint8 type;
1434 BOOL disc = False; /* True when a disconnect PDU was received */
1435 BOOL cont = True;
1436 STREAM s;
1437
1438 while (cont)
1439 {
1440 s = rdp_recv(This, &type);
1441 if (s == NULL)
1442 return False;
1443 switch (type)
1444 {
1447 return False;
1448 *deactivated = False;
1449 break;
1450 case RDP_PDU_DEACTIVATE:
1451 DEBUG(("RDP_PDU_DEACTIVATE\n"));
1452 *deactivated = True;
1453 break;
1454 case RDP_PDU_REDIRECT:
1455 return process_redirect_pdu(This, s);
1456 break;
1457 case RDP_PDU_DATA:
1459 break;
1460 case 0:
1461 break;
1462 default:
1463 unimpl("PDU %d\n", type);
1464 }
1465 if (disc)
1466 return False;
1467 cont = This->next_packet < s->end;
1468 }
1469 return True;
1470}
1471
1472/* Establish a connection up to the RDP layer */
1473BOOL
1474rdp_connect(RDPCLIENT * This, char *server, uint32 flags, wchar_t *username, wchar_t *domain, wchar_t *password,
1475 wchar_t *command, wchar_t *directory, wchar_t *hostname, char *cookie)
1476{
1478 return False;
1479
1481 return True;
1482}
1483
1484/* Establish a reconnection up to the RDP layer */
1485BOOL
1486rdp_reconnect(RDPCLIENT * This, char *server, uint32 flags, wchar_t *username, wchar_t *domain, wchar_t *password,
1487 wchar_t *command, wchar_t *directory, wchar_t *hostname, char *cookie)
1488{
1490 return False;
1491
1493 return True;
1494}
1495
1496/* Called during redirection to reset the state to support redirection */
1497void
1499{
1500 This->next_packet = NULL; /* reset the packet information */
1501 This->rdp_shareid = 0;
1503}
1504
1505/* Disconnect from the RDP layer */
1506void
1508{
1510}
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
BOOL event_redirect(RDPCLIENT *This, uint32 flags, uint32 server_len, wchar_t *server, uint32 cookie_len, char *cookie, uint32 username_len, wchar_t *username, uint32 domain_len, wchar_t *domain, uint32 password_len, wchar_t *password)
Definition: activex.cpp:5913
void event_logon(RDPCLIENT *This)
Definition: activex.cpp:5908
RD_BOOL bitmap_decompress(uint8 *output, int width, int height, uint8 *input, int size, int Bpp)
Definition: bitmap.c:884
RD_HCURSOR cache_get_cursor(uint16 cache_idx)
Definition: cache.c:400
void cache_put_cursor(uint16 cache_idx, RD_HCURSOR cursor)
Definition: cache.c:417
#define RDP_CAPLEN_SHARE
Definition: constants.h:318
@ RDP_UPDATE_PALETTE
Definition: constants.h:210
@ RDP_UPDATE_BITMAP
Definition: constants.h:209
@ RDP_UPDATE_SYNCHRONIZE
Definition: constants.h:211
@ RDP_UPDATE_ORDERS
Definition: constants.h:208
#define RDP_CAPSET_ORDER
Definition: constants.h:299
#define RDP_CAPSET_BMPCACHE2
Definition: constants.h:326
#define BMPCACHE2_FLAG_PERSIST
Definition: constants.h:328
#define RDP_CAPSET_BITMAP
Definition: constants.h:296
#define RDP_CAPLEN_BITMAP
Definition: constants.h:297
#define PDU_FLAG_FIRST
Definition: constants.h:287
#define BMPCACHE2_NUM_PSTCELLS
Definition: constants.h:285
#define RDP_CAPLEN_CONTROL
Definition: constants.h:308
#define RDP_CAPLEN_COLCACHE
Definition: constants.h:321
#define RDP_CAPSET_ACTIVATE
Definition: constants.h:310
#define RDP_CAPSET_CONTROL
Definition: constants.h:307
#define RDP_CAPLEN_BMPCACHE2
Definition: constants.h:327
#define RDP_MPPC_DICT_SIZE
Definition: constants.h:358
#define WINDOWS_CODEPAGE
Definition: constants.h:24
#define RDP_MPPC_COMPRESSED
Definition: constants.h:355
#define RDP_CAPSET_COLCACHE
Definition: constants.h:320
@ RDP_NULL_POINTER
Definition: constants.h:225
#define BMPCACHE2_C0_CELLS
Definition: constants.h:282
#define RDP_CAPLEN_POINTER
Definition: constants.h:314
@ RDP_CTL_COOPERATE
Definition: constants.h:203
@ RDP_CTL_REQUEST_CONTROL
Definition: constants.h:200
#define PDU_FLAG_LAST
Definition: constants.h:288
#define RDP_CAPLEN_GENERAL
Definition: constants.h:292
#define SEC_ENCRYPT
Definition: constants.h:101
#define RDP_CAPLEN_ACTIVATE
Definition: constants.h:311
#define RDP_CAPSET_BMPCACHE
Definition: constants.h:304
#define BMPCACHE2_C1_CELLS
Definition: constants.h:283
#define RDP_SOURCE
Definition: constants.h:330
@ RDP_INPUT_SYNCHRONIZE
Definition: constants.h:231
@ RDP_POINTER_MOVE
Definition: constants.h:217
@ RDP_POINTER_CACHED
Definition: constants.h:219
@ RDP_POINTER_COLOR
Definition: constants.h:218
@ RDP_POINTER_SYSTEM
Definition: constants.h:216
#define RDP_CAPLEN_BMPCACHE
Definition: constants.h:305
@ RDP_DATA_PDU_CLIENT_WINDOW_STATUS
Definition: constants.h:176
@ RDP_DATA_PDU_FONT2
Definition: constants.h:178
@ RDP_DATA_PDU_POINTER
Definition: constants.h:172
@ RDP_DATA_PDU_INPUT
Definition: constants.h:173
@ RDP_DATA_PDU_BELL
Definition: constants.h:175
@ RDP_DATA_PDU_CONTROL
Definition: constants.h:171
@ RDP_DATA_PDU_SYNCHRONISE
Definition: constants.h:174
@ RDP_DATA_PDU_LOGON
Definition: constants.h:177
@ RDP_DATA_PDU_DISCONNECT
Definition: constants.h:180
@ RDP_DATA_PDU_UPDATE
Definition: constants.h:170
#define RDP_CAPSET_SHARE
Definition: constants.h:317
#define RDP_CAPLEN_ORDER
Definition: constants.h:300
#define RDP_CAPSET_POINTER
Definition: constants.h:313
@ RDP_PDU_DEMAND_ACTIVE
Definition: constants.h:160
@ RDP_PDU_DEACTIVATE
Definition: constants.h:163
@ RDP_PDU_CONFIRM_ACTIVE
Definition: constants.h:161
@ RDP_PDU_REDIRECT
Definition: constants.h:162
@ RDP_PDU_DATA
Definition: constants.h:164
#define RDP_CAPSET_GENERAL
Definition: constants.h:291
#define BMPCACHE2_C2_CELLS
Definition: constants.h:284
int mppc_expand(uint8 *data, uint32 clen, uint8 ctype, uint32 *roff, uint32 *rlen)
Definition: mppc.c:58
void process_orders(STREAM s, uint16 num_orders)
Definition: orders.c:1311
void reset_order_state(void)
Definition: orders.c:1454
#define s_mark_end(s)
Definition: parse.h:41
#define out_uint32_le(s, v)
Definition: parse.h:59
#define s_check(s)
Definition: parse.h:42
#define s_pop_layer(s, h)
Definition: parse.h:40
#define out_uint8(s, v)
Definition: parse.h:92
#define s_push_layer(s, h, n)
Definition: parse.h:39
#define in_uint16_le(s, v)
Definition: parse.h:55
#define out_uint16_be(s, v)
Definition: parse.h:77
#define in_uint8p(s, v, n)
Definition: parse.h:89
#define in_uint8a(s, v, n)
Definition: parse.h:90
#define in_uint8s(s, n)
Definition: parse.h:91
#define out_uint8s(s, n)
Definition: parse.h:95
#define in_uint8(s, v)
Definition: parse.h:88
#define out_uint16_le(s, v)
Definition: parse.h:58
#define out_uint8p(s, v, n)
Definition: parse.h:93
#define out_uint32(s, v)
Definition: parse.h:85
#define in_uint32_le(s, v)
Definition: parse.h:56
#define in_uint16(s, v)
Definition: parse.h:82
#define out_uint8a(s, v, n)
Definition: parse.h:94
#define out_uint16(s, v)
Definition: parse.h:84
RD_BOOL pstcache_init(uint8 cache_id)
Definition: pstcache.c:163
void ui_set_cursor(RD_HCURSOR cursor)
void ui_bell(void)
Definition: uimain.c:158
void xfree(void *mem)
Definition: uimain.c:758
RD_HCURSOR ui_create_cursor(unsigned int x, unsigned int y, int width, int height, uint8 *andmask, uint8 *xormask, int bpp)
Definition: uimain.c:175
char * tcp_get_address(void)
Definition: tcp.c:866
void rdp5_process(STREAM s)
Definition: rdp5.c:28
void ui_set_null_cursor(void)
Definition: uimain.c:227
void ui_paint_bitmap(int x, int y, int cx, int cy, int width, int height, uint8 *data)
Definition: uimain.c:307
void sec_send(STREAM s, uint32 flags)
Definition: secure.c:472
void ui_set_colourmap(RD_HCOLOURMAP map)
Definition: qtewin.cpp:1527
RD_BOOL sec_connect(char *server, char *username, char *domain, char *password, RD_BOOL reconnect)
Definition: secure.c:1005
void unimpl(char *format,...)
Definition: uimain.c:801
void sec_reset_state(void)
Definition: secure.c:1039
void ui_resize_window(void)
Definition: uimain.c:651
void sec_disconnect(void)
Definition: secure.c:1032
void hexdump(unsigned char *p, unsigned int len)
Definition: shimdbg.c:234
void ui_begin_update(void)
Definition: uimain.c:657
STREAM sec_recv(uint8 *rdpver)
Definition: secure.c:903
void ui_move_pointer(int x, int y)
Definition: uimain.c:616
STREAM sec_init(uint32 flags, int maxlen)
Definition: secure.c:419
void * xmalloc(int size)
Definition: uimain.c:747
int pstcache_enumerate(uint8 id, HASH_KEY *keylist)
Definition: pstcache.c:107
RD_HCOLOURMAP ui_create_colourmap(COLOURMAP *colours)
Definition: uimain.c:336
void ui_end_update(void)
Definition: uimain.c:664
#define DEBUG_RDP5(args)
Definition: rdesktop.h:141
#define DEBUG(args)
Definition: rdesktop.h:129
#define MIN(x, y)
Definition: rdesktop.h:171
static uint8 caps_0x0e[]
Definition: rdp.c:890
static void rdp_out_bmpcache_caps(STREAM s)
Definition: rdp.c:753
static void rdp_send_control(uint16 action)
Definition: rdp.c:520
void process_bitmap_updates(STREAM s)
Definition: rdp.c:1224
static void rdp_process_bitmap_caps(STREAM s)
Definition: rdp.c:995
static void process_demand_active(STREAM s)
Definition: rdp.c:1067
static void rdp_send_logon_info(uint32 flags, char *domain, char *user, char *password, char *program, char *directory)
Definition: rdp.c:343
static void rdp_out_unknown_caps(STREAM s, uint16 id, uint16 length, uint8 *caps)
Definition: rdp.c:903
void process_cached_pointer_pdu(STREAM s)
Definition: rdp.c:1156
void rdp_disconnect(void)
Definition: rdp.c:1779
static void rdp_out_activate_caps(STREAM s)
Definition: rdp.c:809
static void rdp_enum_bmpcache2(void)
Definition: rdp.c:603
static void rdp_out_bitmap_caps(STREAM s)
Definition: rdp.c:690
static STREAM rdp_init_data(int maxlen)
Definition: rdp.c:140
static void rdp_out_order_caps(STREAM s)
Definition: rdp.c:711
void rdp_send_client_window_status(int status)
Definition: rdp.c:572
void process_palette(STREAM s)
Definition: rdp.c:1295
void rdp_send_input(uint32 time, uint16 message_type, uint16 device_flags, uint16 param1, uint16 param2)
Definition: rdp.c:551
void process_system_pointer_pdu(STREAM s)
Definition: rdp.c:1166
RD_BOOL rdp_connect(char *server, uint32 flags, char *domain, char *password, char *command, char *directory, RD_BOOL reconnect)
Definition: rdp.c:1742
static void process_update_pdu(STREAM s)
Definition: rdp.c:1326
static void rdp_out_control_caps(STREAM s)
Definition: rdp.c:796
void process_disconnect_pdu(STREAM s, uint32 *ext_disc_reason)
Definition: rdp.c:1407
static void rdp_out_general_caps(STREAM s)
Definition: rdp.c:664
static void rdp_send_fonts(uint16 seq)
Definition: rdp.c:647
static void rdp_send_confirm_active(void)
Definition: rdp.c:914
void rdp_in_unistr(STREAM s, int in_len, char **string, uint32 *str_size)
Definition: rdp.c:265
static uint8 caps_0x0c[]
Definition: rdp.c:888
static void rdp_out_pointer_caps(STREAM s)
Definition: rdp.c:822
static void rdp_out_share_caps(STREAM s)
Definition: rdp.c:845
RD_BOOL rdp_loop(RD_BOOL *deactivated, uint32 *ext_disc_reason)
Definition: rdp.c:1695
static STREAM rdp_recv(uint8 *type)
Definition: rdp.c:85
static void rdp_out_bmpcache2_caps(STREAM s)
Definition: rdp.c:771
void rdp_reset_state(void)
Definition: rdp.c:1770
void process_colour_pointer_pdu(STREAM s)
Definition: rdp.c:1139
static RD_BOOL process_data_pdu(STREAM s, uint32 *ext_disc_reason)
Definition: rdp.c:1416
void rdp_out_unistr(STREAM s, char *string, int len)
Definition: rdp.c:188
static void rdp_process_general_caps(STREAM s)
Definition: rdp.c:982
static void rdp_process_server_caps(STREAM s, uint16 length)
Definition: rdp.c:1029
static void rdp_send_synchronise(void)
Definition: rdp.c:536
static uint8 caps_0x10[]
Definition: rdp.c:892
#define RDP5_FLAG
Definition: rdp.c:911
void rdp_main_loop(RD_BOOL *deactivated, uint32 *ext_disc_reason)
Definition: rdp.c:1682
static RD_BOOL process_redirect_pdu(STREAM s, RD_BOOL enhanced_redirect)
Definition: rdp.c:1506
static void rdp_out_colcache_caps(STREAM s)
Definition: rdp.c:856
static void process_pointer_pdu(STREAM s)
Definition: rdp.c:1184
static uint8 caps_0x0d[]
Definition: rdp.c:874
static void rdp_send_data(STREAM s, uint8 data_pdu_type)
Definition: rdp.c:152
unsigned short uint16
Definition: types.h:30
unsigned int uint32
Definition: types.h:32
#define False
Definition: types.h:25
uint8 HASH_KEY[8]
Definition: types.h:161
#define True
Definition: types.h:24
unsigned char uint8
Definition: types.h:28
void user(int argc, const char *argv[])
Definition: cmds.c:1350
char * hostname
Definition: ftp.c:88
Definition: _ctype.h:58
Definition: _map.h:48
#define realloc
Definition: debug_ros.c:6
#define free
Definition: debug_ros.c:5
#define malloc
Definition: debug_ros.c:4
#define NULL
Definition: types.h:112
DWORD bpp
Definition: surface.c:185
const WCHAR * action
Definition: action.c:7479
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31
__kernel_size_t size_t
Definition: linux.h:237
__kernel_time_t time_t
Definition: linux.h:252
unsigned int BOOL
Definition: ntddk_ex.h:94
GLuint start
Definition: gl.h:1545
GLint GLint GLsizei GLsizei GLsizei depth
Definition: gl.h:1546
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
GLdouble s
Definition: gl.h:2039
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
GLuint GLuint GLsizei count
Definition: gl.h:1545
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
GLint GLint GLsizei GLsizei height
Definition: gl.h:1546
GLdouble GLdouble t
Definition: gl.h:2047
GLint GLint GLsizei width
Definition: gl.h:1546
GLsizeiptr size
Definition: glext.h:5919
GLdouble n
Definition: glext.h:7729
const GLubyte * c
Definition: glext.h:8905
GLenum GLint GLuint mask
Definition: glext.h:6028
GLdouble GLdouble GLdouble GLdouble top
Definition: glext.h:10859
GLuint program
Definition: glext.h:6723
GLdouble GLdouble right
Definition: glext.h:10859
GLint left
Definition: glext.h:7726
GLbitfield flags
Definition: glext.h:7161
GLuint GLsizei GLsizei * length
Definition: glext.h:6040
GLint GLint bottom
Definition: glext.h:7726
GLfloat GLfloat p
Definition: glext.h:8902
GLenum GLuint GLsizei bufsize
Definition: glext.h:7473
GLenum GLsizei len
Definition: glext.h:6722
GLintptr offset
Definition: glext.h:5920
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
Definition: glfuncs.h:250
const char cursor[]
Definition: icontest.c:13
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
uint32_t entry
Definition: isohybrid.c:63
int const JOCTET unsigned int datalen
Definition: jpeglib.h:1031
int iconv_close(iconv_t cd)
Definition: win_iconv.c:756
iconv_t iconv_open(const char *tocode, const char *fromcode)
Definition: win_iconv.c:730
size_t iconv(iconv_t cd, const char **inbuf, size_t *inbytesleft, char **outbuf, size_t *outbytesleft)
Definition: win_iconv.c:771
__u16 time
Definition: mkdosfs.c:8
#define error(str)
Definition: mkdosfs.c:1605
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
char string[160]
Definition: util.h:11
#define RDP_LOGON_AUTO
Definition: constants.h:261
#define RDP_LOGON_BLOB
Definition: constants.h:264
#define SEC_LOGON_INFO
Definition: constants.h:71
BOOL sec_reconnect(RDPCLIENT *This, char *server, wchar_t *hostname, char *cookie)
Definition: secure.c:933
BOOL rdp_reconnect(RDPCLIENT *This, char *server, uint32 flags, wchar_t *username, wchar_t *domain, wchar_t *password, wchar_t *command, wchar_t *directory, wchar_t *hostname, char *cookie)
Definition: rdp.c:1486
static WCHAR password[]
Definition: url.c:33
static WCHAR username[]
Definition: url.c:32
#define L(x)
Definition: ntvdm.h:50
_Out_opt_ int _Out_opt_ int * cy
Definition: commctrl.h:586
_Out_opt_ int * cx
Definition: commctrl.h:585
static unsigned __int64 next
Definition: rand_nt.c:6
#define errno
Definition: errno.h:18
_CRTIMP struct tm *__cdecl gmtime(const time_t *_Time)
Definition: time.h:415
_CRTIMP time_t __cdecl mktime(struct tm *_Tm)
Definition: time.h:418
_CRTIMP struct tm *__cdecl localtime(const time_t *_Time)
Definition: time.h:416
#define warning(s)
Definition: debug.h:83
int ZEXPORT compress(Bytef *dest, uLongf *destLen, const Bytef *source, uLong sourceLen)
Definition: compress.c:68
#define memset(x, y, z)
Definition: compat.h:39
Definition: cookie.c:34
Definition: cookie.c:42
Definition: path.c:35
Definition: mxnamespace.c:45
Definition: regsvr.c:104
Definition: ps.c:97
Definition: parse.h:23
unsigned char * end
Definition: parse.h:25
unsigned char * p
Definition: parse.h:24
int deactivated
Definition: svgawin.c:63
uint32 ext_disc_reason
Definition: svgawin.c:64
#define iconv_t
Definition: iconv.h:68
static rfbScreenInfoPtr server
Definition: vnc.c:74
HICON HCURSOR
Definition: windef.h:299