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

Annotation of /sourceforge.net/trunk/rdesktop/rdp.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 9 - (hide annotations)
Tue Jul 25 12:34:29 2000 UTC (23 years, 9 months ago) by matty
File MIME type: text/plain
File size: 44787 byte(s)
Committing some awesome progress I made while overseas - this commit
really embodies a huge number of changes. We are now able to talk quite
fluently to a French NT Terminal Server - in normal usage only minor
font issues remain (handling of TEXT2 order is not perfect).

The next major hurdle is encryption, and it will be quite a big hurdle
- there seems to be some quite nasty session key stuff.

1 matty 3 /*
2     rdesktop: A Remote Desktop Protocol client.
3     Protocol services - RDP layer
4     Copyright (C) Matthew Chapman 1999-2000
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
17     along with this program; if not, write to the Free Software
18     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19     */
20    
21     #include "includes.h"
22    
23     /* Establish a connection up to the RDP layer */
24 matty 9 HCONN rdp_connect(char *server, int width, int height)
25 matty 3 {
26     HCONN conn;
27    
28     if ((conn = mcs_connect(server)) == NULL)
29     return NULL;
30    
31     rdp_establish_key(conn);
32     mcs_recv(conn, False); /* Server's licensing certificate */
33     rdp_send_cert(conn);
34     mcs_recv(conn, False);
35 matty 9 mcs_recv(conn, False);
36 matty 3
37 matty 6 return conn;
38    
39 matty 3 }
40    
41     /* Work this out later. This is useless anyway when encryption is off. */
42     uint8 precanned_key_packet[] = {
43     0x48,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x33,0x00,0x00,0x00,0x00,0x00,
44     0x00,0x00,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x6c,0x86,
45     0xf7,0x99,0xef,0x60,0xc4,0x49,0x52,0xd0,0xd8,0xea,0xb5,0x4f,0x58,0x19,
46     0x52,0x2a,0x93,0x83,0x57,0x4f,0x4e,0x04,0xde,0x96,0x51,0xab,0x13,0x20,
47     0xd8,0xe5,0x00,0x00,0x00,0x00,0x00,0x00
48     };
49    
50 matty 9 uint8 precanned_key_packet_e1[] = {
51     0x01,0x00,0x00,0x00,0x48,0x00,0x00,0x00,0x7c,0xbd,0x8b,0x8f,0x16,0x2b,0xa1,0x00,
52     0xc6,0xfb,0x8a,0x39,0xf5,0x33,0xed,0x36,0x14,0x55,0x17,0x8c,0x3a,0xde,0x5e,0xdf,
53     0xcb,0x41,0x4c,0xc7,0x89,0x7d,0xe3,0xe9,0x34,0x08,0xda,0xdc,0x08,0x77,0x98,0xda,
54     0x65,0xae,0x27,0x74,0xf1,0x79,0xd0,0x28,0x54,0x64,0x86,0x7f,0x02,0xe0,0x71,0x51,
55     0x56,0x4e,0xca,0x72,0x94,0x62,0x49,0x27,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
56     };
57    
58     uint8 precanned_key_packet_e2[] = {
59     0x48,0x00,0x00,0x00,0x8a,0xe4,0x9f,0x8a,0xd5,0x04,0x02,0xfd,0x09,0x1f,0xff,0x53,
60     0xe0,0xb2,0x72,0x8b,0x19,0xba,0x22,0xe4,0x2a,0x7b,0xeb,0x79,0xa8,0x83,0x31,0x6f,
61     0x5c,0xcc,0x37,0x9c,0xe8,0x73,0x64,0x64,0xd3,0xab,0xaa,0x9f,0xbe,0x49,0x27,0xfc,
62     0x95,0xf3,0x6e,0xf8,0xb1,0x01,0x7c,0xba,0xa9,0xc5,0x35,0x9c,0x8f,0x74,0x3a,0x9f,
63     0xd4,0x26,0x4d,0x39,0x90,0xbe,0xf4,0xfb,0x72,0x9e,0x54,0x18
64     };
65    
66 matty 3 /* Create an RC4 key and transfer it to the server */
67     void rdp_establish_key(HCONN conn)
68     {
69     mcs_init_data(conn);
70     memcpy(conn->out.data + conn->out.offset, precanned_key_packet,
71     sizeof(precanned_key_packet));
72     conn->out.offset += sizeof(precanned_key_packet);
73     MARK_END(conn->out);
74     mcs_send_data(conn, MCS_GLOBAL_CHANNEL, True);
75     }
76    
77 matty 9 /* Create an RC4 key and transfer it to the server */
78     void rdp_establish_key_e1(HCONN conn)
79     {
80     mcs_init_data(conn);
81     memcpy(conn->out.data + conn->out.offset, precanned_key_packet_e1,
82     sizeof(precanned_key_packet_e1));
83     conn->out.offset += sizeof(precanned_key_packet_e1);
84     MARK_END(conn->out);
85     mcs_send_data(conn, MCS_GLOBAL_CHANNEL, True);
86     }
87    
88     /* Create an RC4 key and transfer it to the server */
89     void rdp_establish_key_e2(HCONN conn)
90     {
91     mcs_init_data(conn);
92     memcpy(conn->out.data + conn->out.offset, precanned_key_packet_e2,
93     sizeof(precanned_key_packet_e2));
94     conn->out.offset += sizeof(precanned_key_packet_e2);
95     MARK_END(conn->out);
96     mcs_send_data(conn, MCS_GLOBAL_CHANNEL, True);
97     }
98    
99 matty 3 /* Horrible horrible certificate stuff. Work out later. */
100 matty 9 uint8 precanned_cert_packet[] = { // 4c8
101 matty 3 0x80,0x00,0x00,0x00,0x12,0x02,0xb4,0x04,0x01,0x00,0x00,
102     0x00,0x00,0x00,0x01,0x02,0x9d,0xa3,0x7a,0x93,0x34,0x7b,0x28,0x37,0x24,0xa0,0x1f,
103     0x61,0x26,0xfd,0x96,0x3a,0x92,0x83,0xf3,0xe9,0x6a,0x2e,0x81,0x7c,0x2c,0xe4,0x72,//
104     0x01,0x18,0xe9,0xa1,0x0f,0x00,0x00,0x48,0x00,0x84,0x23,0x90,0xe6,0xd3,0xf8,0x20,
105     0xdb,0xa8,0x1b,0xb2,0xd0,0x78,0x2c,0x35,0xde,0xe3,0x0e,0x63,0x40,0xca,0xac,0x71,
106     0xc9,0x17,0x49,0x05,0x25,0xeb,0x9b,0xd0,0xa6,0x5c,0x90,0x3e,0x9d,0x4b,0x27,0x01,
107     0x79,0x1c,0x22,0xfb,0x3c,0x2c,0xb9,0x9f,0xf5,0x21,0xf3,0xee,0xd5,0x4d,0x47,0x1c,
108     0x85,0xbe,0x83,0x93,0xe8,0xed,0x8c,0x5c,0x82,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
109     0x00,0x01,0x00,0x10,0x04,0x30,0x82,0x04,0x0c,0x06,0x09,0x2a,0x86,0x48,0x86,0xf7,
110     0x0d,0x01,0x07,0x02,0xa0,0x82,0x03,0xfd,0x30,0x82,0x03,0xf9,0x02,0x01,0x01,0x31,
111     0x00,0x30,0x0b,0x06,0x09,0x2a,0x86,0x48,0x86,0xf7,0x0d,0x01,0x07,0x01,0xa0,0x82,
112     0x03,0xe1,0x30,0x82,0x01,0x77,0x30,0x82,0x01,0x25,0xa0,0x03,0x02,0x01,0x02,0x02,
113     0x08,0x01,0xbf,0x06,0x84,0x9d,0xdb,0x2d,0xe0,0x30,0x0d,0x06,0x09,0x2a,0x86,0x48,
114     0x86,0xf7,0x0d,0x01,0x01,0x01,0x05,0x00,0x30,0x38,0x31,0x36,0x30,0x11,0x06,0x03,
115     0x55,0x04,0x03,0x1e,0x0a,0x00,0x4e,0x00,0x54,0x00,0x54,0x00,0x53,0x00,0x45,0x30,
116     0x21,0x06,0x03,0x55,0x04,0x07,0x1e,0x1a,0x00,0x4d,0x00,0x69,0x00,0x63,0x00,0x72,
117     0x00,0x6f,0x00,0x73,0x00,0x6f,0x00,0x66,0x00,0x74,0x00,0x2e,0x00,0x63,0x00,0x6f,
118     0x00,0x6d,0x30,0x1e,0x17,0x0d,0x39,0x39,0x30,0x39,0x32,0x34,0x31,0x32,0x30,0x32,
119     0x30,0x34,0x5a,0x17,0x0d,0x34,0x39,0x30,0x39,0x32,0x34,0x31,0x32,0x30,0x32,0x30,
120     0x34,0x5a,0x30,0x38,0x31,0x36,0x30,0x11,0x06,0x03,0x55,0x04,0x03,0x1e,0x0a,0x00,
121     0x4e,0x00,0x54,0x00,0x54,0x00,0x53,0x00,0x45,0x30,0x21,0x06,0x03,0x55,0x04,0x07,
122     0x1e,0x1a,0x00,0x4d,0x00,0x69,0x00,0x63,0x00,0x72,0x00,0x6f,0x00,0x73,0x00,0x6f,
123     0x00,0x66,0x00,0x74,0x00,0x2e,0x00,0x63,0x00,0x6f,0x00,0x6d,0x30,0x5c,0x30,0x0d,
124     0x06,0x09,0x2a,0x86,0x48,0x86,0xf7,0x0d,0x01,0x01,0x01,0x05,0x00,0x03,0x4b,0x00,
125     0x30,0x48,0x02,0x41,0x00,0x91,0xb2,0x16,0x1c,0xae,0x4f,0x7f,0x7c,0xaf,0x57,0x2b,
126     0x23,0x4c,0x0c,0x25,0x3c,0x4f,0x66,0x9d,0x25,0xc3,0x4f,0x29,0xee,0x8b,0xda,0x4e,
127     0x95,0xe7,0x3b,0xaa,0xc0,0xa7,0xba,0xaf,0x99,0x8c,0x47,0x24,0x8b,0x09,0x77,0xbc,
128     0x2c,0xf4,0xe7,0x1a,0x07,0x58,0x7b,0x11,0x37,0x2a,0xa8,0x90,0xc3,0x50,0x92,0x80,
129     0x15,0xc5,0xda,0x51,0x8b,0x02,0x03,0x01,0x00,0x01,0xa3,0x13,0x30,0x11,0x30,0x0f,
130     0x06,0x03,0x55,0x1d,0x13,0x04,0x08,0x30,0x06,0x01,0x01,0xff,0x02,0x01,0x00,0x30,
131     0x09,0x06,0x05,0x2b,0x0e,0x03,0x02,0x1d,0x05,0x00,0x03,0x41,0x00,0x14,0x04,0x67,
132     0x28,0xc8,0xd3,0x1f,0x13,0x14,0x2e,0x2c,0x93,0x09,0x25,0xbb,0xbe,0x86,0x6a,0xd3,
133     0x47,0x6f,0x44,0x16,0x7b,0x94,0x8c,0xb2,0xa2,0xd5,0xf7,0x4f,0xb1,0x8f,0x7f,0xde,
134     0x0b,0x88,0x34,0x4a,0x1d,0xdc,0xa1,0xfd,0x26,0xbd,0x43,0xbb,0x38,0xf1,0x87,0x34,
135     0xbb,0xe9,0x3b,0xfa,0x7f,0x1e,0xff,0xe1,0x10,0x7e,0xee,0x6e,0xd8,0x30,0x82,0x02,
136     0x62,0x30,0x82,0x02,0x10,0xa0,0x03,0x02,0x01,0x02,0x02,0x05,0x01,0x00,0x00,0x00,
137     0x01,0x30,0x09,0x06,0x05,0x2b,0x0e,0x03,0x02,0x1d,0x05,0x00,0x30,0x38,0x31,0x36,
138     0x30,0x11,0x06,0x03,0x55,0x04,0x03,0x1e,0x0a,0x00,0x4e,0x00,0x54,0x00,0x54,0x00,
139     0x53,0x00,0x45,0x30,0x21,0x06,0x03,0x55,0x04,0x07,0x1e,0x1a,0x00,0x4d,0x00,0x69,
140     0x00,0x63,0x00,0x72,0x00,0x6f,0x00,0x73,0x00,0x6f,0x00,0x66,0x00,0x74,0x00,0x2e,
141     0x00,0x63,0x00,0x6f,0x00,0x6d,0x30,0x1e,0x17,0x0d,0x39,0x39,0x30,0x39,0x32,0x34,
142     0x30,0x30,0x30,0x30,0x30,0x30,0x5a,0x17,0x0d,0x34,0x39,0x30,0x39,0x32,0x34,0x30,
143     0x30,0x30,0x30,0x30,0x30,0x5a,0x30,0x79,0x31,0x77,0x30,0x17,0x06,0x03,0x55,0x04,
144     0x03,0x1e,0x10,0x00,0x52,0x00,0x45,0x00,0x53,0x00,0x37,0x00,0x2d,0x00,0x4e,0x00,
145     0x45,0x00,0x57,0x30,0x17,0x06,0x03,0x55,0x04,0x07,0x1e,0x10,0x00,0x7a,0x00,0x32,
146     0x00,0x32,0x00,0x33,0x00,0x32,0x00,0x32,0x00,0x30,0x00,0x33,0x30,0x43,0x06,0x03,
147     0x55,0x04,0x05,0x1e,0x3c,0x00,0x31,0x00,0x42,0x00,0x63,0x00,0x4b,0x00,0x65,0x00,
148     0x57,0x00,0x50,0x00,0x6c,0x00,0x37,0x00,0x58,0x00,0x47,0x00,0x61,0x00,0x73,0x00,
149     0x38,0x00,0x4a,0x00,0x79,0x00,0x50,0x00,0x34,0x00,0x30,0x00,0x7a,0x00,0x49,0x00,
150     0x6d,0x00,0x6e,0x00,0x6f,0x00,0x51,0x00,0x5a,0x00,0x59,0x00,0x3d,0x00,0x0d,0x00,
151     0x0a,0x30,0x5c,0x30,0x0d,0x06,0x09,0x2a,0x86,0x48,0x86,0xf7,0x0d,0x01,0x01,0x01,
152     0x05,0x00,0x03,0x4b,0x00,0x30,0x48,0x02,0x41,0x00,0x91,0xb2,0x16,0x1c,0xae,0x4f,
153     0x7f,0x7c,0xaf,0x57,0x2b,0x23,0x4c,0x0c,0x25,0x3c,0x4f,0x66,0x9d,0x25,0xc3,0x4f,
154     0x29,0xee,0x8b,0xda,0x4e,0x95,0xe7,0x3b,0xaa,0xc0,0xa7,0xba,0xaf,0x99,0x8c,0x47,
155     0x24,0x8b,0x09,0x77,0xbc,0x2c,0xf4,0xe7,0x1a,0x07,0x58,0x7b,0x11,0x37,0x2a,0xa8,
156     0x90,0xc3,0x50,0x92,0x80,0x15,0xc5,0xda,0x51,0x8b,0x02,0x03,0x01,0x00,0x01,0xa3,
157     0x81,0xc3,0x30,0x81,0xc0,0x30,0x14,0x06,0x09,0x2b,0x06,0x01,0x04,0x01,0x82,0x37,
158     0x12,0x04,0x01,0x01,0xff,0x04,0x04,0x01,0x00,0x01,0x00,0x30,0x3c,0x06,0x09,0x2b,
159     0x06,0x01,0x04,0x01,0x82,0x37,0x12,0x02,0x01,0x01,0xff,0x04,0x2c,0x4d,0x00,0x69,
160     0x00,0x63,0x00,0x72,0x00,0x6f,0x00,0x73,0x00,0x6f,0x00,0x66,0x00,0x74,0x00,0x20,
161     0x00,0x43,0x00,0x6f,0x00,0x72,0x00,0x70,0x00,0x6f,0x00,0x72,0x00,0x61,0x00,0x74,
162     0x00,0x69,0x00,0x6f,0x00,0x6e,0x00,0x00,0x00,0x30,0x4c,0x06,0x09,0x2b,0x06,0x01,
163     0x04,0x01,0x82,0x37,0x12,0x05,0x01,0x01,0xff,0x04,0x3c,0x00,0x10,0x00,0x00,0x01,
164     0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x09,0x04,0x00,0x00,0x18,0x00,0x18,0x00,0x30,
165     0x00,0x01,0x00,0x32,0x00,0x33,0x00,0x36,0x00,0x2d,0x00,0x34,0x00,0x2e,0x00,0x30,
166     0x00,0x30,0x00,0x2d,0x00,0x45,0x00,0x58,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x00,
167     0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x1c,0x06,0x03,0x55,0x1d,0x23,0x01,0x01,
168     0xff,0x04,0x12,0x30,0x10,0xa1,0x07,0x81,0x05,0x4e,0x54,0x54,0x53,0x45,0x82,0x05,
169     0x01,0x00,0x00,0x00,0x01,0x30,0x09,0x06,0x05,0x2b,0x0e,0x03,0x02,0x1d,0x05,0x00,
170     0x03,0x41,0x00,0x7b,0x1d,0xfd,0x24,0xea,0xf2,0xe8,0x17,0xdd,0x88,0x7e,0xfd,0xee,
171     0x28,0x61,0x7a,0x02,0xc3,0x73,0xcf,0x32,0x0f,0x7c,0x66,0x87,0x31,0xa7,0xbe,0x1b,
172     0x31,0xe2,0x20,0xa5,0x76,0x91,0x68,0x97,0x53,0x9e,0x80,0xcd,0x2b,0xd0,0x8e,0x8b,
173     0x7f,0x89,0x1b,0x62,0xa8,0xf8,0xee,0x5e,0x56,0xbd,0x9c,0x6b,0x80,0x06,0x54,0xd3,
174     0xf0,0xbf,0xb2,0x31,0x00,0x01,0x00,0x14,0x00,0xc7,0x32,0xf2,0x5b,0x98,0x0e,0x04,
175     0x49,0xa0,0x27,0x7e,0xf5,0xf6,0x0f,0xda,0x08,0x1d,0xe9,0x79,0xd1,0x31,0xc6,0x50,
176     0x90,0x4a,0xd3,0x1f,0x1d,0xf0,0x65,0x0d,0xb6,0x1f,0xaf,0xc9,0x1d
177     };
178    
179     /* Send license certificate and related data to the server */
180     void rdp_send_cert(HCONN conn)
181     {
182     mcs_init_data(conn);
183     prs_io_uint8s(&conn->out, precanned_cert_packet, sizeof(precanned_cert_packet));
184     MARK_END(conn->out);
185     mcs_send_data(conn, MCS_GLOBAL_CHANNEL, True);
186     }
187    
188     /* Initialise RDP transport packet */
189     void rdp_init(HCONN conn)
190     {
191     mcs_init_data(conn);
192     PUSH_LAYER(conn->out, rdp_offset, 6);
193     }
194    
195     /* Transmit RDP transport packet */
196     void rdp_send(HCONN conn, uint16 pdu_type)
197     {
198     RDP_HEADER hdr;
199     int length;
200    
201     POP_LAYER(conn->out, rdp_offset);
202     length = conn->out.end - conn->out.offset;
203     rdp_make_header(&hdr, length, pdu_type, conn->mcs_userid);
204     rdp_io_header(&conn->out, &hdr);
205     mcs_send_data(conn, MCS_GLOBAL_CHANNEL, True);
206     }
207    
208     /* Initialise RDP transport data packet */
209     void rdp_init_data(HCONN conn)
210     {
211     mcs_init_data(conn);
212     PUSH_LAYER(conn->out, rdp_offset, 18);
213     }
214    
215     /* Transmit RDP transport data packet */
216     void rdp_send_data(HCONN conn, uint16 data_pdu_type)
217     {
218     RDP_HEADER hdr;
219     RDP_DATA_HEADER datahdr;
220     int length = conn->out.end - conn->out.offset;
221    
222     POP_LAYER(conn->out, rdp_offset);
223     length = conn->out.end - conn->out.offset;
224     rdp_make_header(&hdr, length, RDP_PDU_DATA, conn->mcs_userid);
225     rdp_io_header(&conn->out, &hdr);
226     rdp_make_data_header(&datahdr, 0x103ea, length, data_pdu_type);
227     rdp_io_data_header(&conn->out, &datahdr);
228     mcs_send_data(conn, MCS_GLOBAL_CHANNEL, True);
229     }
230    
231 matty 9 void rdp_send_confirm_active(HCONN conn, uint32 shareid, int width, int height)
232 matty 3 {
233     RDP_ACTIVE_PDU active;
234    
235     rdp_init(conn);
236 matty 9 rdp_make_active_pdu(&active, shareid, conn->mcs_userid, width, height);
237 matty 3 rdp_io_active_pdu(&conn->out, &active, RDP_PDU_CONFIRM_ACTIVE);
238     MARK_END(conn->out);
239     rdp_send(conn, RDP_PDU_CONFIRM_ACTIVE);
240     }
241    
242     void rdp_send_synchronize(HCONN conn)
243     {
244 matty 9 RDP_SYNCHRONISE_PDU sync;
245 matty 3
246     rdp_init_data(conn);
247 matty 9 rdp_make_synchronise_pdu(&sync, 1002);
248     rdp_io_synchronise_pdu(&conn->out, &sync);
249 matty 3 MARK_END(conn->out);
250     rdp_send_data(conn, RDP_DATA_PDU_SYNCHRONIZE);
251     }
252    
253     void rdp_send_control(HCONN conn, uint16 action)
254     {
255     RDP_CONTROL_PDU control;
256    
257     rdp_init_data(conn);
258     rdp_make_control_pdu(&control, action);
259     rdp_io_control_pdu(&conn->out, &control);
260     MARK_END(conn->out);
261     rdp_send_data(conn, RDP_DATA_PDU_CONTROL);
262     }
263    
264     void rdp_send_fonts(HCONN conn, uint16 seqno)
265     {
266     RDP_FONT_PDU fonts;
267    
268     rdp_init_data(conn);
269     rdp_make_font_pdu(&fonts, seqno);
270     rdp_io_font_pdu(&conn->out, &fonts);
271     MARK_END(conn->out);
272     rdp_send_data(conn, RDP_DATA_PDU_FONT2);
273     }
274    
275 matty 9 void rdp_send_input(HCONN conn, uint16 message_type, uint16 device_flags,
276     uint16 param1, uint16 param2)
277 matty 3 {
278     RDP_INPUT_PDU input;
279    
280     rdp_init_data(conn);
281 matty 9 rdp_make_input_pdu(&input, message_type, device_flags, param1, param2);
282 matty 3 rdp_io_input_pdu(&conn->out, &input);
283     MARK_END(conn->out);
284     rdp_send_data(conn, RDP_DATA_PDU_INPUT);
285     }
286    
287     BOOL rdp_recv_pdu(HCONN conn, uint8 *type)
288     {
289     RDP_HEADER hdr;
290    
291 matty 7 conn->in.offset = conn->in.rdp_offset;
292    
293     if (conn->in.offset >= conn->in.end)
294     {
295     if (!mcs_recv(conn, False))
296     return False;
297     }
298    
299     if (!rdp_io_header(&conn->in, &hdr))
300 matty 3 return False;
301    
302 matty 7 conn->in.rdp_offset += hdr.length;
303 matty 3 *type = hdr.pdu_type & 0xf;
304 matty 7
305 matty 9 #if DUMP
306 matty 7 fprintf(stderr, "RDP packet (type %x):\n", *type);
307     dump_data(conn->in.data+conn->in.offset, conn->in.rdp_offset-conn->in.offset);
308     #endif
309    
310 matty 3 return True;
311     }
312    
313     /* Disconnect from the RDP layer */
314     void rdp_disconnect(HCONN conn)
315     {
316     mcs_disconnect(conn);
317     }
318    
319 matty 9 /* Construct an RDP header */
320 matty 3 void rdp_make_header(RDP_HEADER *hdr, uint16 length, uint16 pdu_type,
321     uint16 userid)
322     {
323     hdr->length = length;
324     hdr->pdu_type = pdu_type | 0x10; /* Version 1 */
325     hdr->userid = userid + 1001;
326     }
327    
328 matty 9 /* Parse an RDP header */
329     BOOL rdp_io_header(STREAM s, RDP_HEADER *hdr)
330     {
331     BOOL res = True;
332    
333     res = res ? lsb_io_uint16(s, &hdr->length ) : False;
334     res = res ? lsb_io_uint16(s, &hdr->pdu_type) : False;
335     if ((hdr->pdu_type & 0xf) != RDP_PDU_DEACTIVATE)
336     res = res ? lsb_io_uint16(s, &hdr->userid ) : False;
337    
338     return res;
339     }
340    
341     /* Construct a data header */
342 matty 3 void rdp_make_data_header(RDP_DATA_HEADER *hdr, uint32 shareid,
343     uint16 length, uint16 data_pdu_type)
344     {
345     hdr->shareid = shareid;
346     hdr->pad = 0;
347     hdr->streamid = 1;
348     hdr->length = length - 14;
349     hdr->data_pdu_type = data_pdu_type;
350     hdr->compress_type = 0;
351     hdr->compress_len = 0;
352     }
353    
354 matty 9 /* Parse a data header */
355     BOOL rdp_io_data_header(STREAM s, RDP_DATA_HEADER *hdr)
356 matty 3 {
357 matty 9 BOOL res = True;
358    
359     res = res ? lsb_io_uint32(s, &hdr->shareid ) : False;
360     res = res ? prs_io_uint8 (s, &hdr->pad ) : False;
361     res = res ? prs_io_uint8 (s, &hdr->streamid ) : False;
362     res = res ? lsb_io_uint16(s, &hdr->length ) : False;
363     res = res ? prs_io_uint8 (s, &hdr->data_pdu_type) : False;
364     res = res ? prs_io_uint8 (s, &hdr->compress_type) : False;
365     res = res ? lsb_io_uint16(s, &hdr->compress_len ) : False;
366    
367     return res;
368 matty 3 }
369    
370 matty 9 BOOL rdp_io_present(STREAM s, uint32 *present, uint8 flags, int size)
371 matty 3 {
372 matty 9 uint8 bits;
373     int i;
374    
375     if (flags & RDP_ORDER_SMALL)
376     {
377     size--;
378     }
379    
380     if (flags & RDP_ORDER_TINY)
381     {
382     if (size < 2)
383     return False;
384    
385     size -= 2;
386     }
387    
388     *present = 0;
389     for (i = 0; i < size; i++)
390     {
391     prs_io_uint8(s, &bits);
392     *present |= bits << (i * 8);
393     }
394    
395     return True;
396 matty 3 }
397    
398 matty 9 BOOL rdp_io_coord(STREAM s, uint16 *coord, BOOL delta)
399 matty 3 {
400 matty 9 uint8 change;
401     BOOL res;
402 matty 3
403 matty 9 if (delta)
404     {
405     res = prs_io_uint8(s, &change);
406     *coord += (char)change;
407     }
408     else
409     {
410     res = lsb_io_uint16(s, coord);
411     }
412 matty 3
413 matty 9 return res;
414 matty 3 }
415    
416 matty 9 BOOL rdp_io_colour(STREAM s, uint8 *colour)
417 matty 3 {
418 matty 9 BOOL res;
419    
420     res = prs_io_uint8(s, colour);
421     s->offset += 2;
422    
423     return res;
424 matty 3 }
425    
426 matty 9 BOOL rdp_io_colourmap(STREAM s, COLOURMAP *colours)
427 matty 3 {
428 matty 9 int datasize;
429    
430     lsb_io_uint16(s, &colours->ncolours);
431     datasize = colours->ncolours * 3;
432    
433     if (datasize > sizeof(colours->colours))
434     return False;
435    
436     memcpy(colours->colours, s->data + s->offset, datasize);
437     s->offset += datasize;
438     return True;
439 matty 3 }
440    
441 matty 9 BOOL rdp_io_bounds(STREAM s, BOUNDS *bounds)
442 matty 3 {
443 matty 9 uint8 present;
444    
445     prs_io_uint8(s, &present);
446    
447     if (present & 1)
448     rdp_io_coord(s, &bounds->left, False);
449     else if (present & 16)
450     rdp_io_coord(s, &bounds->left, True);
451    
452     if (present & 2)
453     rdp_io_coord(s, &bounds->top, False);
454     else if (present & 32)
455     rdp_io_coord(s, &bounds->top, True);
456    
457     if (present & 4)
458     rdp_io_coord(s, &bounds->right, False);
459     else if (present & 64)
460     rdp_io_coord(s, &bounds->right, True);
461    
462     if (present & 8)
463     rdp_io_coord(s, &bounds->bottom, False);
464     else if (present & 128)
465     rdp_io_coord(s, &bounds->bottom, True);
466    
467     return True;
468 matty 3 }
469    
470 matty 9 BOOL rdp_io_pen(STREAM s, PEN *pen, uint32 present)
471 matty 3 {
472 matty 9 BOOL res = True;
473    
474     if (present & 1)
475     res = res ? prs_io_uint8(s, &pen->style) : False;
476    
477     if (present & 2)
478     res = res ? prs_io_uint8(s, &pen->width) : False;
479    
480     if (present & 4)
481     res = res ? rdp_io_colour(s, &pen->colour) : False;
482    
483     return res;
484 matty 3 }
485    
486 matty 9 BOOL rdp_io_brush(STREAM s, BRUSH *brush, uint32 present)
487 matty 3 {
488 matty 9 BOOL res = True;
489 matty 3
490 matty 9 if (present & 1)
491     res = res ? prs_io_uint8(s, &brush->xorigin) : False;
492    
493     if (present & 2)
494     res = res ? prs_io_uint8(s, &brush->yorigin) : False;
495    
496     if (present & 4)
497     res = res ? prs_io_uint8(s, &brush->style) : False;
498    
499     if (present & 8)
500     res = res ? prs_io_uint8(s, &brush->pattern[0]) : False;
501    
502     if (present & 16)
503     res = res ? prs_io_uint8s(s, &brush->pattern[1], 7) : False;
504    
505     return res;
506 matty 3 }
507    
508 matty 9 /* Construct a confirm/demand active PDU */
509     void rdp_make_active_pdu(RDP_ACTIVE_PDU *pdu, uint32 shareid, uint16 userid,
510     int width, int height)
511 matty 3 {
512     memset(pdu, 0, sizeof(*pdu));
513     pdu->shareid = shareid;
514     pdu->userid = 1002;
515     pdu->source_len = sizeof(RDP_SOURCE);
516     memcpy(pdu->source, RDP_SOURCE, sizeof(RDP_SOURCE));
517    
518     pdu->caps_len = RDP_CAPLEN_GENERAL + RDP_CAPLEN_BITMAP + RDP_CAPLEN_ORDER
519     + RDP_CAPLEN_BMPCACHE + RDP_CAPLEN_COLCACHE + RDP_CAPLEN_ACTIVATE
520     + RDP_CAPLEN_CONTROL + RDP_CAPLEN_POINTER + RDP_CAPLEN_SHARE
521     + RDP_CAPLEN_UNKNOWN;
522     pdu->num_caps = 0xD;
523    
524     rdp_make_general_caps (&pdu->general_caps );
525 matty 9 rdp_make_bitmap_caps (&pdu->bitmap_caps, width, height);
526 matty 3 rdp_make_order_caps (&pdu->order_caps );
527     rdp_make_bmpcache_caps(&pdu->bmpcache_caps);
528     rdp_make_control_caps (&pdu->control_caps );
529     rdp_make_activate_caps(&pdu->activate_caps);
530     rdp_make_pointer_caps (&pdu->pointer_caps );
531     rdp_make_share_caps (&pdu->share_caps, userid);
532     rdp_make_colcache_caps(&pdu->colcache_caps);
533     }
534    
535 matty 9 /* Parse a confirm/demand active PDU */
536     BOOL rdp_io_active_pdu(STREAM s, RDP_ACTIVE_PDU *pdu, int pdutype)
537     {
538     uint16 capset;
539     uint16 length;
540     BOOL res;
541     int i;
542    
543     res = lsb_io_uint32(s, &pdu->shareid);
544    
545     if (pdutype == RDP_PDU_CONFIRM_ACTIVE)
546     res = res ? lsb_io_uint16(s, &pdu->userid ) : False;
547    
548     res = res ? lsb_io_uint16(s, &pdu->source_len) : False;
549     res = res ? lsb_io_uint16(s, &pdu->caps_len ) : False;
550    
551     if (pdu->source_len > 48)
552     {
553     ERROR("RDP source descriptor too long\n");
554     return False;
555     }
556    
557     res = res ? prs_io_uint8s(s, pdu->source, pdu->source_len) : False;
558     res = res ? lsb_io_uint16(s, &pdu->num_caps ) : False;
559     res = res ? lsb_io_uint16(s, &pdu->pad ) : False;
560    
561     if (s->marshall)
562     {
563     capset = RDP_CAPSET_GENERAL;
564     res = res ? lsb_io_uint16(s, &capset) : False;
565     res = res ? rdp_io_general_caps(s, &pdu->general_caps) : False;
566    
567     capset = RDP_CAPSET_BITMAP;
568     res = res ? lsb_io_uint16(s, &capset) : False;
569     res = res ? rdp_io_bitmap_caps (s, &pdu->bitmap_caps ) : False;
570    
571     capset = RDP_CAPSET_ORDER;
572     res = res ? lsb_io_uint16(s, &capset) : False;
573     res = res ? rdp_io_order_caps (s, &pdu->order_caps ) : False;
574    
575     capset = RDP_CAPSET_BMPCACHE;
576     res = res ? lsb_io_uint16(s, &capset) : False;
577     res = res ? rdp_io_bmpcache_caps(s, &pdu->bmpcache_caps) : False;
578    
579     capset = RDP_CAPSET_COLCACHE;
580     res = res ? lsb_io_uint16(s, &capset) : False;
581     res = res ? rdp_io_colcache_caps(s, &pdu->colcache_caps) : False;
582    
583     capset = RDP_CAPSET_ACTIVATE;
584     res = res ? lsb_io_uint16(s, &capset) : False;
585     res = res ? rdp_io_activate_caps(s, &pdu->activate_caps) : False;
586    
587     capset = RDP_CAPSET_CONTROL;
588     res = res ? lsb_io_uint16(s, &capset) : False;
589     res = res ? rdp_io_control_caps(s, &pdu->control_caps) : False;
590    
591     capset = RDP_CAPSET_POINTER;
592     res = res ? lsb_io_uint16(s, &capset) : False;
593     res = res ? rdp_io_pointer_caps(s, &pdu->pointer_caps) : False;
594    
595     capset = RDP_CAPSET_SHARE;
596     res = res ? lsb_io_uint16(s, &capset) : False;
597     res = res ? rdp_io_share_caps (s, &pdu->share_caps ) : False;
598    
599     capset = RDP_CAPSET_UNKNOWN;
600     res = res ? lsb_io_uint16(s, &capset) : False;
601     res = res ? rdp_io_unknown_caps(s, NULL) : False;
602     }
603     else
604     {
605     for (i = 0; i < pdu->num_caps; i++)
606     {
607     if (!res)
608     return False;
609    
610     if (!lsb_io_uint16(s, &capset))
611     return False;
612    
613     switch (capset)
614     {
615     case RDP_CAPSET_GENERAL:
616     res = rdp_io_general_caps (s, &pdu->general_caps );
617     break;
618     case RDP_CAPSET_BITMAP:
619     res = rdp_io_bitmap_caps (s, &pdu->bitmap_caps );
620     break;
621     case RDP_CAPSET_ORDER:
622     res = rdp_io_order_caps (s, &pdu->order_caps );
623     break;
624     case RDP_CAPSET_BMPCACHE:
625     res = rdp_io_bmpcache_caps(s, &pdu->bmpcache_caps);
626     break;
627     case RDP_CAPSET_CONTROL:
628     res = rdp_io_control_caps (s, &pdu->control_caps );
629     break;
630     case RDP_CAPSET_ACTIVATE:
631     res = rdp_io_activate_caps(s, &pdu->activate_caps);
632     break;
633     case RDP_CAPSET_POINTER:
634     res = rdp_io_pointer_caps (s, &pdu->pointer_caps );
635     break;
636     case RDP_CAPSET_SHARE:
637     res = rdp_io_share_caps (s, &pdu->share_caps );
638     break;
639     case RDP_CAPSET_COLCACHE:
640     res = rdp_io_colcache_caps(s, &pdu->colcache_caps);
641     break;
642     default:
643     NOTIMP("capset 0x%x\n", capset);
644    
645     if (!lsb_io_uint16(s, &length))
646     return False;
647    
648     s->offset += (length - 4);
649     }
650     }
651     }
652    
653     return res;
654     }
655    
656     /* Construct a control PDU */
657 matty 3 void rdp_make_control_pdu(RDP_CONTROL_PDU *pdu, uint16 action)
658     {
659     pdu->action = action;
660     pdu->userid = 0;
661     pdu->controlid = 0;
662     }
663    
664 matty 9 /* Parse a control PDU */
665     BOOL rdp_io_control_pdu(STREAM s, RDP_CONTROL_PDU *pdu)
666 matty 3 {
667 matty 9 BOOL res = True;
668    
669     res = res ? lsb_io_uint16(s, &pdu->action ) : False;
670     res = res ? lsb_io_uint16(s, &pdu->userid ) : False;
671     res = res ? lsb_io_uint32(s, &pdu->controlid) : False;
672    
673     return res;
674     }
675    
676     /* Construct a synchronisation PDU */
677     void rdp_make_synchronise_pdu(RDP_SYNCHRONISE_PDU *pdu, uint16 userid)
678     {
679 matty 3 pdu->type = 1;
680     pdu->userid = userid;
681     }
682    
683 matty 9 /* Parse a synchronisation PDU */
684     BOOL rdp_io_synchronise_pdu(STREAM s, RDP_SYNCHRONISE_PDU *pdu)
685     {
686     BOOL res = True;
687    
688     res = res ? lsb_io_uint16(s, &pdu->type ) : False;
689     res = res ? lsb_io_uint16(s, &pdu->userid) : False;
690    
691     return res;
692     }
693    
694     /* Parse a single input event */
695     BOOL rdp_io_input_event(STREAM s, RDP_INPUT_EVENT *evt)
696     {
697     BOOL res = True;
698    
699     res = res ? lsb_io_uint32(s, &evt->event_time) : False;
700     res = res ? lsb_io_uint16(s, &evt->message_type) : False;
701     res = res ? lsb_io_uint16(s, &evt->device_flags) : False;
702    
703     if (!res)
704     return False;
705    
706     switch (evt->message_type)
707     {
708     case RDP_INPUT_CODEPOINT:
709     case RDP_INPUT_VIRTKEY:
710     res = res ? lsb_io_uint16(s, &evt->param1) : False;
711     break;
712     case RDP_INPUT_SYNCHRONIZE:
713     case RDP_INPUT_SCANCODE:
714     case RDP_INPUT_MOUSE:
715     res = res ? lsb_io_uint16(s, &evt->param1) : False;
716     res = res ? lsb_io_uint16(s, &evt->param2) : False;
717     break;
718     default:
719     NOTIMP("input type %d\n", evt->message_type);
720     return False;
721     }
722    
723     return res;
724     }
725    
726     /* Construct an input PDU */
727     void rdp_make_input_pdu(RDP_INPUT_PDU *pdu, uint16 message_type,
728     uint16 device_flags, uint16 param1, uint16 param2)
729     {
730     uint32 now = time(NULL);
731    
732     pdu->num_events = 1;
733     pdu->pad = 0;
734    
735     pdu->event[0].event_time = now;
736     pdu->event[0].message_type = message_type;
737     pdu->event[0].device_flags = device_flags;
738     pdu->event[0].param1 = param1;
739     pdu->event[0].param2 = param2;
740     }
741    
742     /* Parse an input PDU */
743     BOOL rdp_io_input_pdu(STREAM s, RDP_INPUT_PDU *pdu)
744     {
745     BOOL res = True;
746     int i;
747    
748     res = res ? lsb_io_uint16(s, &pdu->num_events) : False;
749     res = res ? lsb_io_uint16(s, &pdu->pad ) : False;
750    
751     if (pdu->num_events > RDP_MAX_EVENTS)
752     {
753     ERROR("Too many events in one PDU\n");
754     return False;
755     }
756    
757     for (i = 0; i < pdu->num_events; i++)
758     {
759     res = res ? rdp_io_input_event(s, &pdu->event[i]) : False;
760     }
761    
762     return res;
763     }
764    
765     /* Construct a font information PDU */
766 matty 3 void rdp_make_font_pdu(RDP_FONT_PDU *pdu, uint16 seqno)
767     {
768     pdu->num_fonts = 0;
769     pdu->unknown1 = 0x3e;
770     pdu->unknown2 = seqno;
771     pdu->entry_size = RDP_FONT_INFO_SIZE;
772     }
773    
774 matty 9 /* Parse a font information structure */
775     BOOL rdp_io_font_info(STREAM s, RDP_FONT_INFO *font)
776 matty 3 {
777 matty 9 BOOL res = True;
778 matty 3
779 matty 9 res = res ? prs_io_uint8s(s, font->name, 32 ) : False;
780     res = res ? lsb_io_uint16(s, &font->flags ) : False;
781     res = res ? lsb_io_uint16(s, &font->width ) : False;
782     res = res ? lsb_io_uint16(s, &font->height ) : False;
783     res = res ? lsb_io_uint16(s, &font->xaspect ) : False;
784     res = res ? lsb_io_uint16(s, &font->yaspect ) : False;
785     res = res ? lsb_io_uint32(s, &font->signature) : False;
786     res = res ? lsb_io_uint16(s, &font->codepage ) : False;
787     res = res ? lsb_io_uint16(s, &font->ascent ) : False;
788 matty 3
789 matty 9 return res;
790     }
791 matty 3
792 matty 9 /* Parse a font information PDU */
793     BOOL rdp_io_font_pdu(STREAM s, RDP_FONT_PDU *pdu)
794     {
795     BOOL res = True;
796     int i;
797 matty 3
798 matty 9 res = res ? lsb_io_uint16(s, &pdu->num_fonts ) : False;
799     res = res ? lsb_io_uint16(s, &pdu->unknown1 ) : False;
800     res = res ? lsb_io_uint16(s, &pdu->unknown2 ) : False;
801     res = res ? lsb_io_uint16(s, &pdu->entry_size) : False;
802    
803     if (pdu->num_fonts > RDP_MAX_FONTS)
804     {
805     ERROR("Too many fonts in one PDU\n");
806     return False;
807     }
808    
809     for (i = 0; i < pdu->num_fonts; i++)
810     {
811     res = res ? rdp_io_font_info(s, &pdu->font[i]) : False;
812     }
813    
814     return res;
815 matty 3 }
816    
817 matty 9 /* Parse a pointer PDU */
818     BOOL rdp_io_pointer_pdu(STREAM s, RDP_POINTER_PDU *ptr)
819 matty 3 {
820     BOOL res = True;
821    
822 matty 9 res = res ? lsb_io_uint16(s, &ptr->message) : False;
823     res = res ? lsb_io_uint16(s, &ptr->pad ) : False;
824 matty 3
825 matty 9 switch (ptr->message)
826     {
827     case RDP_POINTER_MOVE:
828     res = res ? lsb_io_uint16(s, &ptr->x ) : False;
829     res = res ? lsb_io_uint16(s, &ptr->y ) : False;
830     break;
831     }
832    
833 matty 3 return res;
834     }
835    
836 matty 9 /* Parse an update PDU */
837     BOOL rdp_io_update_pdu(STREAM s, RDP_UPDATE_PDU *pdu)
838 matty 3 {
839     BOOL res = True;
840    
841 matty 9 res = res ? lsb_io_uint16(s, &pdu->update_type) : False;
842     res = res ? lsb_io_uint16(s, &pdu->pad ) : False;
843 matty 3
844     return res;
845     }
846    
847 matty 9
848     /* PRIMARY ORDERS */
849    
850     /* Parse an destination blt order */
851     BOOL rdp_io_destblt_order(STREAM s, DESTBLT_ORDER *os, uint32 present, BOOL delta)
852 matty 7 {
853 matty 9 if (present & 0x01)
854     rdp_io_coord(s, &os->x, delta);
855 matty 7
856 matty 9 if (present & 0x02)
857     rdp_io_coord(s, &os->y, delta);
858    
859     if (present & 0x04)
860     rdp_io_coord(s, &os->cx, delta);
861    
862     if (present & 0x08)
863     rdp_io_coord(s, &os->cy, delta);
864    
865     if (present & 0x10)
866     prs_io_uint8(s, &os->opcode);
867    
868     return PRS_ERROR(s);
869     }
870    
871     /* Parse an pattern blt order */
872     BOOL rdp_io_patblt_order(STREAM s, PATBLT_ORDER *os, uint32 present, BOOL delta)
873     {
874     if (present & 0x0001)
875     rdp_io_coord(s, &os->x, delta);
876    
877     if (present & 0x0002)
878     rdp_io_coord(s, &os->y, delta);
879    
880     if (present & 0x0004)
881     rdp_io_coord(s, &os->cx, delta);
882    
883     if (present & 0x0008)
884     rdp_io_coord(s, &os->cy, delta);
885    
886     if (present & 0x0010)
887     prs_io_uint8(s, &os->opcode);
888    
889     if (present & 0x0020)
890     rdp_io_colour(s, &os->bgcolour);
891    
892     if (present & 0x0040)
893     rdp_io_colour(s, &os->fgcolour);
894    
895     rdp_io_brush(s, &os->brush, present >> 7);
896    
897     return PRS_ERROR(s);
898     }
899    
900     /* Parse an screen blt order */
901     BOOL rdp_io_screenblt_order(STREAM s, SCREENBLT_ORDER *os, uint32 present, BOOL delta)
902     {
903     if (present & 0x0001)
904     rdp_io_coord(s, &os->x, delta);
905    
906     if (present & 0x0002)
907     rdp_io_coord(s, &os->y, delta);
908    
909     if (present & 0x0004)
910     rdp_io_coord(s, &os->cx, delta);
911    
912     if (present & 0x0008)
913     rdp_io_coord(s, &os->cy, delta);
914    
915     if (present & 0x0010)
916     prs_io_uint8(s, &os->opcode);
917    
918     if (present & 0x0020)
919     rdp_io_coord(s, &os->srcx, delta);
920    
921     if (present & 0x0040)
922     rdp_io_coord(s, &os->srcy, delta);
923    
924     return PRS_ERROR(s);
925     }
926    
927     /* Parse a line order */
928     BOOL rdp_io_line_order(STREAM s, LINE_ORDER *os, uint32 present, BOOL delta)
929     {
930     if (present & 0x0001)
931     lsb_io_uint16(s, &os->mixmode);
932    
933     if (present & 0x0002)
934     rdp_io_coord(s, &os->startx, delta);
935    
936     if (present & 0x0004)
937     rdp_io_coord(s, &os->starty, delta);
938    
939     if (present & 0x0008)
940     rdp_io_coord(s, &os->endx, delta);
941    
942     if (present & 0x0010)
943     rdp_io_coord(s, &os->endy, delta);
944    
945     if (present & 0x0020)
946     rdp_io_colour(s, &os->bgcolour);
947    
948     if (present & 0x0040)
949     prs_io_uint8(s, &os->opcode);
950    
951     rdp_io_pen(s, &os->pen, present >> 7);
952    
953     return PRS_ERROR(s);
954     }
955    
956     /* Parse an opaque rectangle order */
957     BOOL rdp_io_rect_order(STREAM s, RECT_ORDER *os, uint32 present, BOOL delta)
958     {
959     if (present & 0x01)
960     rdp_io_coord(s, &os->x, delta);
961    
962     if (present & 0x02)
963     rdp_io_coord(s, &os->y, delta);
964    
965     if (present & 0x04)
966     rdp_io_coord(s, &os->cx, delta);
967    
968     if (present & 0x08)
969     rdp_io_coord(s, &os->cy, delta);
970    
971     if (present & 0x10)
972     prs_io_uint8(s, &os->colour);
973    
974     return PRS_ERROR(s);
975     }
976    
977     /* Parse a desktop save order */
978     BOOL rdp_io_desksave_order(STREAM s, DESKSAVE_ORDER *os, uint32 present, BOOL delta)
979     {
980     if (present & 0x01)
981     lsb_io_uint32(s, &os->offset);
982    
983     if (present & 0x02)
984     rdp_io_coord(s, &os->left, delta);
985    
986     if (present & 0x04)
987     rdp_io_coord(s, &os->top, delta);
988    
989     if (present & 0x08)
990     rdp_io_coord(s, &os->right, delta);
991    
992     if (present & 0x10)
993     rdp_io_coord(s, &os->bottom, delta);
994    
995     if (present & 0x20)
996     prs_io_uint8(s, &os->action);
997    
998     return PRS_ERROR(s);
999     }
1000    
1001     /* Parse a memory blt order */
1002     BOOL rdp_io_memblt_order(STREAM s, MEMBLT_ORDER *os, uint32 present, BOOL delta)
1003     {
1004     if (present & 0x0001)
1005 matty 7 {
1006 matty 9 prs_io_uint8(s, &os->cache_id);
1007     prs_io_uint8(s, &os->colour_table);
1008 matty 7 }
1009 matty 9
1010     if (present & 0x0002)
1011     rdp_io_coord(s, &os->x, delta);
1012    
1013     if (present & 0x0004)
1014     rdp_io_coord(s, &os->y, delta);
1015    
1016     if (present & 0x0008)
1017     rdp_io_coord(s, &os->cx, delta);
1018    
1019     if (present & 0x0010)
1020     rdp_io_coord(s, &os->cy, delta);
1021    
1022     if (present & 0x0020)
1023     prs_io_uint8(s, &os->opcode);
1024    
1025     if (present & 0x0040)
1026     rdp_io_coord(s, &os->srcx, delta);
1027    
1028     if (present & 0x0080)
1029     rdp_io_coord(s, &os->srcy, delta);
1030    
1031     if (present & 0x0100)
1032     lsb_io_uint16(s, &os->cache_idx);
1033    
1034     return PRS_ERROR(s);
1035     }
1036    
1037     /* Parse a 3-way blt order */
1038     BOOL rdp_io_triblt_order(STREAM s, TRIBLT_ORDER *os, uint32 present, BOOL delta)
1039     {
1040     if (present & 0x000001)
1041 matty 7 {
1042 matty 9 prs_io_uint8(s, &os->cache_id);
1043     prs_io_uint8(s, &os->colour_table);
1044 matty 7 }
1045    
1046 matty 9 if (present & 0x000002)
1047     rdp_io_coord(s, &os->x, delta);
1048    
1049     if (present & 0x000004)
1050     rdp_io_coord(s, &os->y, delta);
1051    
1052     if (present & 0x000008)
1053     rdp_io_coord(s, &os->cx, delta);
1054    
1055     if (present & 0x000010)
1056     rdp_io_coord(s, &os->cy, delta);
1057    
1058     if (present & 0x000020)
1059     prs_io_uint8(s, &os->opcode);
1060    
1061     if (present & 0x000040)
1062     rdp_io_coord(s, &os->srcx, delta);
1063    
1064     if (present & 0x000080)
1065     rdp_io_coord(s, &os->srcy, delta);
1066    
1067     if (present & 0x000100)
1068     rdp_io_colour(s, &os->bgcolour);
1069    
1070     if (present & 0x000200)
1071     rdp_io_colour(s, &os->fgcolour);
1072    
1073     rdp_io_brush(s, &os->brush, present >> 10);
1074    
1075     if (present & 0x008000)
1076     lsb_io_uint16(s, &os->cache_idx);
1077    
1078     if (present & 0x010000)
1079     lsb_io_uint16(s, &os->unknown);
1080    
1081     return PRS_ERROR(s);
1082     }
1083    
1084     /* Parse a text order */
1085     BOOL rdp_io_text2_order(STREAM s, TEXT2_ORDER *os, uint32 present, BOOL delta)
1086     {
1087     if (present & 0x000001)
1088     prs_io_uint8(s, &os->font);
1089    
1090     if (present & 0x000002)
1091     prs_io_uint8(s, &os->flags);
1092    
1093     if (present & 0x000004)
1094     prs_io_uint8(s, &os->unknown);
1095    
1096     if (present & 0x000008)
1097     prs_io_uint8(s, &os->mixmode);
1098    
1099     if (present & 0x000010)
1100     rdp_io_colour(s, &os->fgcolour);
1101    
1102     if (present & 0x000020)
1103     rdp_io_colour(s, &os->bgcolour);
1104    
1105     if (present & 0x000040)
1106     lsb_io_uint16(s, &os->clipleft);
1107    
1108     if (present & 0x000080)
1109     lsb_io_uint16(s, &os->cliptop);
1110    
1111     if (present & 0x000100)
1112     lsb_io_uint16(s, &os->clipright);
1113    
1114     if (present & 0x000200)
1115     lsb_io_uint16(s, &os->clipbottom);
1116    
1117     if (present & 0x000400)
1118     lsb_io_uint16(s, &os->boxleft);
1119    
1120     if (present & 0x000800)
1121     lsb_io_uint16(s, &os->boxtop);
1122    
1123     if (present & 0x001000)
1124     lsb_io_uint16(s, &os->boxright);
1125    
1126     if (present & 0x002000)
1127     lsb_io_uint16(s, &os->boxbottom);
1128    
1129     if (present & 0x080000)
1130     lsb_io_uint16(s, &os->x);
1131    
1132     if (present & 0x100000)
1133     lsb_io_uint16(s, &os->y);
1134    
1135     if (present & 0x200000)
1136     {
1137     prs_io_uint8(s, &os->length);
1138     prs_io_uint8s(s, os->text, os->length);
1139     }
1140    
1141     return PRS_ERROR(s);
1142     }
1143    
1144    
1145     /* SECONDARY ORDERS */
1146    
1147     BOOL rdp_io_secondary_order(STREAM s, RDP_SECONDARY_ORDER *rso)
1148     {
1149     BOOL res = True;
1150    
1151     res = res ? lsb_io_uint16(s, &rso->length) : False;
1152     res = res ? lsb_io_uint16(s, &rso->flags ) : False;
1153     res = res ? prs_io_uint8 (s, &rso->type ) : False;
1154    
1155 matty 7 return res;
1156     }
1157    
1158 matty 9 BOOL rdp_io_raw_bmpcache_order(STREAM s, RDP_RAW_BMPCACHE_ORDER *rbo)
1159 matty 7 {
1160 matty 9 BOOL res = True;
1161 matty 7
1162 matty 9 res = res ? prs_io_uint8 (s, &rbo->cache_id ) : False;
1163     res = res ? prs_io_uint8 (s, &rbo->pad1 ) : False;
1164     res = res ? prs_io_uint8 (s, &rbo->width ) : False;
1165     res = res ? prs_io_uint8 (s, &rbo->height ) : False;
1166     res = res ? prs_io_uint8 (s, &rbo->bpp ) : False;
1167     res = res ? lsb_io_uint16(s, &rbo->bufsize ) : False;
1168     res = res ? lsb_io_uint16(s, &rbo->cache_idx ) : False;
1169 matty 7
1170 matty 9 rbo->data = s->data + s->offset;
1171     s->offset += rbo->bufsize;
1172 matty 7
1173 matty 9 return res;
1174     }
1175    
1176     BOOL rdp_io_bmpcache_order(STREAM s, RDP_BMPCACHE_ORDER *rbo)
1177     {
1178     BOOL res = True;
1179    
1180     res = res ? prs_io_uint8 (s, &rbo->cache_id ) : False;
1181     res = res ? prs_io_uint8 (s, &rbo->pad1 ) : False;
1182     res = res ? prs_io_uint8 (s, &rbo->width ) : False;
1183     res = res ? prs_io_uint8 (s, &rbo->height ) : False;
1184     res = res ? prs_io_uint8 (s, &rbo->bpp ) : False;
1185     res = res ? lsb_io_uint16(s, &rbo->bufsize ) : False;
1186     res = res ? lsb_io_uint16(s, &rbo->cache_idx ) : False;
1187     res = res ? lsb_io_uint16(s, &rbo->pad2 ) : False;
1188     res = res ? lsb_io_uint16(s, &rbo->size ) : False;
1189     res = res ? lsb_io_uint16(s, &rbo->row_size ) : False;
1190     res = res ? lsb_io_uint16(s, &rbo->final_size) : False;
1191    
1192     rbo->data = s->data + s->offset;
1193     s->offset += rbo->size;
1194    
1195     return res;
1196     }
1197    
1198     BOOL rdp_io_colcache_order(STREAM s, RDP_COLCACHE_ORDER *colours)
1199     {
1200     COLOURENTRY *entry;
1201     int i;
1202    
1203     prs_io_uint8(s, &colours->cache_id);
1204     lsb_io_uint16(s, &colours->map.ncolours);
1205    
1206     for (i = 0; i < colours->map.ncolours; i++)
1207     {
1208     entry = &colours->map.colours[i];
1209     prs_io_uint8(s, &entry->blue);
1210     prs_io_uint8(s, &entry->green);
1211     prs_io_uint8(s, &entry->red);
1212     s->offset++;
1213     }
1214    
1215 matty 7 return True;
1216     }
1217    
1218 matty 9 BOOL rdp_io_fontcache_order(STREAM s, RDP_FONTCACHE_ORDER *font)
1219     {
1220     RDP_FONT_GLYPH *glyph;
1221     BOOL res = True;
1222     int i, j, datasize;
1223     uint8 in, out;
1224    
1225     res = res ? prs_io_uint8(s, &font->font ) : False;
1226     res = res ? prs_io_uint8(s, &font->nglyphs) : False;
1227    
1228     for (i = 0; i < font->nglyphs; i++)
1229     {
1230     glyph = &font->glyphs[i];
1231     res = res ? lsb_io_uint16(s, &glyph->character) : False;
1232     res = res ? lsb_io_uint16(s, &glyph->unknown ) : False;
1233     res = res ? lsb_io_uint16(s, &glyph->baseline ) : False;
1234     res = res ? lsb_io_uint16(s, &glyph->width ) : False;
1235     res = res ? lsb_io_uint16(s, &glyph->height ) : False;
1236    
1237     datasize = (glyph->height * ((glyph->width + 7) / 8) + 3) & ~3;
1238     res = res ? prs_io_uint8s(s, glyph->data, datasize) : False;
1239     for (j = 0; j < datasize; j++)
1240     {
1241     in = glyph->data[j];
1242     out = 0;
1243     if (in & 1) out |= 128;
1244     if (in & 2) out |= 64;
1245     if (in & 4) out |= 32;
1246     if (in & 8) out |= 16;
1247     if (in & 16) out |= 8;
1248     if (in & 32) out |= 4;
1249     if (in & 64) out |= 2;
1250     if (in & 128) out |= 1;
1251     glyph->data[j] = out;
1252     }
1253     }
1254    
1255     return res;
1256     }
1257    
1258    
1259     /* CAPABILITIES */
1260    
1261     /* Construct a general capability set */
1262     void rdp_make_general_caps(RDP_GENERAL_CAPS *caps)
1263     {
1264     caps->os_major_type = 1;
1265     caps->os_minor_type = 3;
1266     caps->ver_protocol = 0x200;
1267     }
1268    
1269     /* Parse general capability set */
1270 matty 3 BOOL rdp_io_general_caps(STREAM s, RDP_GENERAL_CAPS *caps)
1271     {
1272     uint16 length = RDP_CAPLEN_GENERAL;
1273     uint16 pkt_length = length;
1274     BOOL res;
1275    
1276     res = lsb_io_uint16(s, &pkt_length);
1277     if (pkt_length != length)
1278     {
1279 matty 9 ERROR("Unrecognised capabilities size\n");
1280 matty 3 return False;
1281     }
1282    
1283     res = res ? lsb_io_uint16(s, &caps->os_major_type ) : False;
1284     res = res ? lsb_io_uint16(s, &caps->os_minor_type ) : False;
1285     res = res ? lsb_io_uint16(s, &caps->ver_protocol ) : False;
1286     res = res ? lsb_io_uint16(s, &caps->pad1 ) : False;
1287     res = res ? lsb_io_uint16(s, &caps->compress_types) : False;
1288     res = res ? lsb_io_uint16(s, &caps->pad2 ) : False;
1289     res = res ? lsb_io_uint16(s, &caps->cap_update ) : False;
1290     res = res ? lsb_io_uint16(s, &caps->remote_unshare) : False;
1291     res = res ? lsb_io_uint16(s, &caps->compress_level) : False;
1292     res = res ? lsb_io_uint16(s, &caps->pad3 ) : False;
1293    
1294     return res;
1295     }
1296    
1297 matty 9 /* Construct a bitmap capability set */
1298     void rdp_make_bitmap_caps(RDP_BITMAP_CAPS *caps, int width, int height)
1299     {
1300     caps->preferred_bpp = 8;
1301     caps->receive1bpp = 1;
1302     caps->receive4bpp = 1;
1303     caps->receive8bpp = 1;
1304     caps->width = width;
1305     caps->height = height;
1306     caps->compression = 1;
1307     caps->unknown2 = 1;
1308     }
1309    
1310     /* Parse bitmap capability set */
1311 matty 3 BOOL rdp_io_bitmap_caps(STREAM s, RDP_BITMAP_CAPS *caps)
1312     {
1313     uint16 length = RDP_CAPLEN_BITMAP;
1314     uint16 pkt_length = length;
1315     BOOL res;
1316    
1317     res = lsb_io_uint16(s, &pkt_length);
1318     if (pkt_length != length)
1319     {
1320 matty 9 ERROR("Unrecognised capabilities size\n");
1321 matty 3 return False;
1322     }
1323    
1324     res = res ? lsb_io_uint16(s, &caps->preferred_bpp) : False;
1325     res = res ? lsb_io_uint16(s, &caps->receive1bpp ) : False;
1326     res = res ? lsb_io_uint16(s, &caps->receive4bpp ) : False;
1327     res = res ? lsb_io_uint16(s, &caps->receive8bpp ) : False;
1328     res = res ? lsb_io_uint16(s, &caps->width ) : False;
1329     res = res ? lsb_io_uint16(s, &caps->height ) : False;
1330     res = res ? lsb_io_uint16(s, &caps->pad1 ) : False;
1331     res = res ? lsb_io_uint16(s, &caps->allow_resize ) : False;
1332     res = res ? lsb_io_uint16(s, &caps->compression ) : False;
1333     res = res ? lsb_io_uint16(s, &caps->unknown1 ) : False;
1334     res = res ? lsb_io_uint16(s, &caps->unknown2 ) : False;
1335     res = res ? lsb_io_uint16(s, &caps->pad2 ) : False;
1336    
1337     return res;
1338     }
1339    
1340 matty 9 /* Construct an order capability set */
1341     void rdp_make_order_caps(RDP_ORDER_CAPS *caps)
1342     {
1343     caps->xgranularity = 1;
1344     caps->ygranularity = 20;
1345     caps->max_order_level = 1;
1346     caps->num_fonts = 0x147;
1347     caps->cap_flags = 0x2A;
1348    
1349     // caps->cap_flags = ORDER_CAP_NEGOTIATE | ORDER_CAP_NOSUPPORT;
1350    
1351     caps->support[0] = caps->support[1] = caps->support[2]
1352     = caps->support[3] = caps->support[4] = caps->support[5]
1353     = caps->support[6] = caps->support[8] = caps->support[11]
1354     = caps->support[12] = caps->support[22] = caps->support[28]
1355     = caps->support[29] = caps->support[30] = 1;
1356     caps->text_cap_flags = 0x6A1;
1357     caps->desk_save_size = 0x38400;
1358     caps->unknown2 = 0x4E4;
1359     }
1360    
1361     /* Parse order capability set */
1362 matty 3 BOOL rdp_io_order_caps(STREAM s, RDP_ORDER_CAPS *caps)
1363     {
1364     uint16 length = RDP_CAPLEN_ORDER;
1365     uint16 pkt_length = length;
1366     BOOL res;
1367    
1368     res = lsb_io_uint16(s, &pkt_length);
1369     if (pkt_length != length)
1370     {
1371 matty 9 ERROR("Unrecognised capabilities size\n");
1372 matty 3 return False;
1373     }
1374    
1375     res = res ? prs_io_uint8s(s, caps->terminal_desc, 16) : False;
1376     res = res ? lsb_io_uint32(s, &caps->pad1 ) : False;
1377     res = res ? lsb_io_uint16(s, &caps->xgranularity ) : False;
1378     res = res ? lsb_io_uint16(s, &caps->ygranularity ) : False;
1379     res = res ? lsb_io_uint16(s, &caps->pad2 ) : False;
1380     res = res ? lsb_io_uint16(s, &caps->max_order_level ) : False;
1381     res = res ? lsb_io_uint16(s, &caps->num_fonts ) : False;
1382     res = res ? lsb_io_uint16(s, &caps->cap_flags ) : False;
1383     res = res ? prs_io_uint8s(s, caps->support , 32) : False;
1384     res = res ? lsb_io_uint16(s, &caps->text_cap_flags ) : False;
1385     res = res ? lsb_io_uint16(s, &caps->pad3 ) : False;
1386     res = res ? lsb_io_uint32(s, &caps->pad4 ) : False;
1387     res = res ? lsb_io_uint32(s, &caps->desk_save_size ) : False;
1388     res = res ? lsb_io_uint32(s, &caps->unknown1 ) : False;
1389     res = res ? lsb_io_uint32(s, &caps->unknown2 ) : False;
1390    
1391     return res;
1392     }
1393    
1394 matty 9 /* Construct a bitmap cache capability set */
1395     void rdp_make_bmpcache_caps(RDP_BMPCACHE_CAPS *caps)
1396     {
1397     caps->caches[0].entries = 0x258;
1398     caps->caches[0].max_cell_size = 0x100;
1399     caps->caches[1].entries = 0x12c;
1400     caps->caches[1].max_cell_size = 0x400;
1401     caps->caches[2].entries = 0x106;
1402     caps->caches[2].max_cell_size = 0x1000;
1403     }
1404    
1405     /* Parse single bitmap cache information structure */
1406 matty 3 BOOL rdp_io_bmpcache_info(STREAM s, RDP_BMPCACHE_INFO *info)
1407     {
1408     if (!lsb_io_uint16(s, &info->entries ))
1409     return False;
1410    
1411     if (!lsb_io_uint16(s, &info->max_cell_size))
1412     return False;
1413    
1414     return True;
1415     }
1416    
1417 matty 9 /* Parse bitmap cache capability set */
1418 matty 3 BOOL rdp_io_bmpcache_caps(STREAM s, RDP_BMPCACHE_CAPS *caps)
1419     {
1420     uint16 length = RDP_CAPLEN_BMPCACHE;
1421     uint16 pkt_length = length;
1422     BOOL res;
1423     int i;
1424    
1425     res = lsb_io_uint16(s, &pkt_length);
1426     if (pkt_length != length)
1427     {
1428 matty 9 ERROR("Unrecognised capabilities size\n");
1429 matty 3 return False;
1430     }
1431    
1432     for (i = 0; i < 6; i++)
1433     res = res ? lsb_io_uint32(s, &caps->unused[i]) : False;
1434    
1435     for (i = 0; i < 3; i++)
1436     res = res ? rdp_io_bmpcache_info(s, &caps->caches[i]) : False;
1437    
1438     return res;
1439     }
1440    
1441 matty 9 /* Construct a control capability set */
1442     void rdp_make_control_caps(RDP_CONTROL_CAPS *caps)
1443     {
1444     caps->control_interest = 2;
1445     caps->detach_interest = 2;
1446     }
1447    
1448     /* Parse control capability set */
1449 matty 3 BOOL rdp_io_control_caps(STREAM s, RDP_CONTROL_CAPS *caps)
1450     {
1451     uint16 length = RDP_CAPLEN_CONTROL;
1452     uint16 pkt_length = length;
1453     BOOL res;
1454    
1455     res = lsb_io_uint16(s, &pkt_length);
1456     if (pkt_length != length)
1457     {
1458 matty 9 ERROR("Unrecognised capabilities size\n");
1459 matty 3 return False;
1460     }
1461    
1462     res = res ? lsb_io_uint16(s, &caps->control_caps ) : False;
1463     res = res ? lsb_io_uint16(s, &caps->remote_detach ) : False;
1464     res = res ? lsb_io_uint16(s, &caps->control_interest) : False;
1465     res = res ? lsb_io_uint16(s, &caps->detach_interest ) : False;
1466    
1467     return res;
1468     }
1469    
1470 matty 9 /* Construct an activation capability set */
1471     void rdp_make_activate_caps(RDP_ACTIVATE_CAPS *caps)
1472     {
1473     }
1474    
1475     /* Parse activation capability set */
1476 matty 3 BOOL rdp_io_activate_caps(STREAM s, RDP_ACTIVATE_CAPS *caps)
1477     {
1478     uint16 length = RDP_CAPLEN_ACTIVATE;
1479     uint16 pkt_length = length;
1480     BOOL res;
1481    
1482     res = lsb_io_uint16(s, &pkt_length);
1483     if (pkt_length != length)
1484     {
1485 matty 9 ERROR("Unrecognised capabilities size\n");
1486 matty 3 return False;
1487     }
1488    
1489     res = res ? lsb_io_uint16(s, &caps->help_key ) : False;
1490     res = res ? lsb_io_uint16(s, &caps->help_index_key ) : False;
1491     res = res ? lsb_io_uint16(s, &caps->help_extended_key) : False;
1492     res = res ? lsb_io_uint16(s, &caps->window_activate ) : False;
1493    
1494     return res;
1495     }
1496    
1497 matty 9 /* Construct a pointer capability set */
1498     void rdp_make_pointer_caps(RDP_POINTER_CAPS *caps)
1499     {
1500     caps->colour_pointer = 0;
1501     caps->cache_size = 20;
1502     }
1503    
1504     /* Parse pointer capability set */
1505 matty 3 BOOL rdp_io_pointer_caps(STREAM s, RDP_POINTER_CAPS *caps)
1506     {
1507     uint16 length = RDP_CAPLEN_POINTER;
1508     uint16 pkt_length = length;
1509     BOOL res;
1510    
1511     res = lsb_io_uint16(s, &pkt_length);
1512     if (pkt_length != length)
1513     {
1514 matty 9 ERROR("Unrecognised capabilities size\n");
1515 matty 3 return False;
1516     }
1517    
1518     res = res ? lsb_io_uint16(s, &caps->colour_pointer) : False;
1519     res = res ? lsb_io_uint16(s, &caps->cache_size ) : False;
1520    
1521     return res;
1522     }
1523    
1524 matty 9 /* Construct a share capability set */
1525     void rdp_make_share_caps(RDP_SHARE_CAPS *caps, uint16 userid)
1526     {
1527     }
1528    
1529     /* Parse share capability set */
1530 matty 3 BOOL rdp_io_share_caps(STREAM s, RDP_SHARE_CAPS *caps)
1531     {
1532     uint16 length = RDP_CAPLEN_SHARE;
1533     uint16 pkt_length = length;
1534     BOOL res;
1535    
1536     res = lsb_io_uint16(s, &pkt_length);
1537     if (pkt_length != length)
1538     {
1539 matty 9 ERROR("Unrecognised capabilities size\n");
1540 matty 3 return False;
1541     }
1542    
1543     res = res ? lsb_io_uint16(s, &caps->userid) : False;
1544     res = res ? lsb_io_uint16(s, &caps->pad ) : False;
1545    
1546     return res;
1547     }
1548    
1549 matty 9 /* Construct a colour cache capability set */
1550     void rdp_make_colcache_caps(RDP_COLCACHE_CAPS *caps)
1551     {
1552     caps->cache_size = 6;
1553     }
1554    
1555     /* Parse colour cache capability set */
1556 matty 3 BOOL rdp_io_colcache_caps(STREAM s, RDP_COLCACHE_CAPS *caps)
1557     {
1558     uint16 length = RDP_CAPLEN_COLCACHE;
1559     uint16 pkt_length = length;
1560     BOOL res;
1561    
1562     res = lsb_io_uint16(s, &pkt_length);
1563     if (pkt_length != length)
1564     {
1565 matty 9 ERROR("Unrecognised capabilities size\n");
1566 matty 3 return False;
1567     }
1568    
1569     res = res ? lsb_io_uint16(s, &caps->cache_size) : False;
1570     res = res ? lsb_io_uint16(s, &caps->pad ) : False;
1571    
1572     return res;
1573     }
1574    
1575     uint8 canned_caps[] = {
1576     0x01,0x00,0x00,0x00,0x09,0x04,0x00,0x00,0x04,
1577     0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
1578     0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
1579     0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
1580     0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
1581     0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0C,0x00,0x08,0x00,0x01,
1582     0x00,0x00,0x00,0x0E,0x00,0x08,0x00,0x01,0x00,0x00,0x00,0x10,0x00,0x34,0x00,0xFE,
1583     0x00,0x04,0x00,0xFE,0x00,0x04,0x00,0xFE,0x00,0x08,0x00,0xFE,0x00,0x08,0x00,0xFE,
1584     0x00,0x10,0x00,0xFE,0x00,0x20,0x00,0xFE,0x00,0x40,0x00,0xFE,0x00,0x80,0x00,0xFE,
1585     0x00,0x00,0x01,0x40,0x00,0x00,0x08,0x00,0x01,0x00,0x01,0x02,0x00,0x00,0x00
1586     };
1587    
1588 matty 9 /* Insert canned capabilities */
1589 matty 3 BOOL rdp_io_unknown_caps(STREAM s, void *caps)
1590     {
1591     uint16 length = 0x58;
1592     uint16 pkt_length = length;
1593     BOOL res;
1594    
1595     res = lsb_io_uint16(s, &pkt_length);
1596     if (pkt_length != length)
1597     {
1598 matty 9 ERROR("Unrecognised capabilities size\n");
1599 matty 3 return False;
1600     }
1601    
1602     res = res ? prs_io_uint8s(s, canned_caps, RDP_CAPLEN_UNKNOWN-4) : False;
1603    
1604     return res;
1605     }

  ViewVC Help
Powered by ViewVC 1.1.26