1 |
/* |
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 |
enum RDP_PDU_TYPE |
22 |
{ |
23 |
RDP_PDU_DEMAND_ACTIVE = 1, |
24 |
RDP_PDU_CONFIRM_ACTIVE = 3, |
25 |
RDP_PDU_DATA = 7 |
26 |
}; |
27 |
|
28 |
enum RDP_DATA_PDU_TYPE |
29 |
{ |
30 |
RDP_DATA_PDU_UPDATE = 2, |
31 |
RDP_DATA_PDU_CONTROL = 20, |
32 |
RDP_DATA_PDU_POINTER = 27, |
33 |
RDP_DATA_PDU_INPUT = 28, |
34 |
RDP_DATA_PDU_SYNCHRONIZE = 31, |
35 |
RDP_DATA_PDU_FONT2 = 39 |
36 |
}; |
37 |
|
38 |
typedef struct _RDP_HEADER |
39 |
{ |
40 |
uint16 length; |
41 |
uint16 pdu_type; |
42 |
uint16 userid; |
43 |
|
44 |
} RDP_HEADER; |
45 |
|
46 |
typedef struct _RDP_DATA_HEADER |
47 |
{ |
48 |
uint32 shareid; |
49 |
uint8 pad; |
50 |
uint8 streamid; |
51 |
uint16 length; |
52 |
uint8 data_pdu_type; |
53 |
uint8 compress_type; |
54 |
uint16 compress_len; |
55 |
|
56 |
} RDP_DATA_HEADER; |
57 |
|
58 |
#define RDP_CAPSET_GENERAL 1 |
59 |
#define RDP_CAPLEN_GENERAL 0x18 |
60 |
#define OS_MAJOR_TYPE_UNIX 4 |
61 |
#define OS_MINOR_TYPE_XSERVER 7 |
62 |
|
63 |
typedef struct _RDP_GENERAL_CAPS |
64 |
{ |
65 |
uint16 os_major_type; |
66 |
uint16 os_minor_type; |
67 |
uint16 ver_protocol; |
68 |
uint16 pad1; |
69 |
uint16 compress_types; |
70 |
uint16 pad2; |
71 |
uint16 cap_update; |
72 |
uint16 remote_unshare; |
73 |
uint16 compress_level; |
74 |
uint16 pad3; |
75 |
|
76 |
} RDP_GENERAL_CAPS; |
77 |
|
78 |
#define RDP_CAPSET_BITMAP 2 |
79 |
#define RDP_CAPLEN_BITMAP 0x1C |
80 |
|
81 |
typedef struct _RDP_BITMAP_CAPS |
82 |
{ |
83 |
uint16 preferred_bpp; |
84 |
uint16 receive1bpp; |
85 |
uint16 receive4bpp; |
86 |
uint16 receive8bpp; |
87 |
uint16 width; |
88 |
uint16 height; |
89 |
uint16 pad1; |
90 |
uint16 allow_resize; |
91 |
uint16 compression; |
92 |
uint16 unknown1; |
93 |
uint16 unknown2; |
94 |
uint16 pad2; |
95 |
|
96 |
} RDP_BITMAP_CAPS; |
97 |
|
98 |
#define RDP_CAPSET_ORDER 3 |
99 |
#define RDP_CAPLEN_ORDER 0x58 |
100 |
#define ORDER_CAP_NEGOTIATE 2 |
101 |
#define ORDER_CAP_NOSUPPORT 4 |
102 |
|
103 |
typedef struct _RDP_ORDER_CAPS |
104 |
{ |
105 |
uint8 terminal_desc[16]; |
106 |
uint32 pad1; |
107 |
uint16 xgranularity; // 1 |
108 |
uint16 ygranularity; // 20 |
109 |
uint16 pad2; |
110 |
uint16 max_order_level; |
111 |
uint16 num_fonts; // 0x2C |
112 |
uint16 cap_flags; // 0x22 |
113 |
uint8 support[32]; |
114 |
uint16 text_cap_flags; // 0x6A1 |
115 |
uint16 pad3; |
116 |
uint32 pad4; |
117 |
uint32 desk_save_size; |
118 |
uint32 unknown1; // 1 from server, 0 from client |
119 |
uint32 unknown2; // 0x4E4 from client |
120 |
|
121 |
} RDP_ORDER_CAPS; |
122 |
|
123 |
#define RDP_CAPSET_BMPCACHE 4 |
124 |
#define RDP_CAPLEN_BMPCACHE 0x28 |
125 |
|
126 |
typedef struct _RDP_BMPCACHE_INFO |
127 |
{ |
128 |
uint16 entries; |
129 |
uint16 max_cell_size; |
130 |
|
131 |
} RDP_BMPCACHE_INFO; |
132 |
|
133 |
typedef struct _RDP_BMPCACHE_CAPS |
134 |
{ |
135 |
uint32 unused[6]; |
136 |
RDP_BMPCACHE_INFO caches[3]; |
137 |
|
138 |
} RDP_BMPCACHE_CAPS; |
139 |
|
140 |
#define RDP_CAPSET_CONTROL 5 |
141 |
#define RDP_CAPLEN_CONTROL 0x0C |
142 |
|
143 |
typedef struct _RDP_CONTROL_CAPS |
144 |
{ |
145 |
uint16 control_caps; |
146 |
uint16 remote_detach; |
147 |
uint16 control_interest; |
148 |
uint16 detach_interest; |
149 |
|
150 |
} RDP_CONTROL_CAPS; |
151 |
|
152 |
#define RDP_CAPSET_ACTIVATE 7 |
153 |
#define RDP_CAPLEN_ACTIVATE 0x0C |
154 |
|
155 |
typedef struct _RDP_ACTIVATE_CAPS |
156 |
{ |
157 |
uint16 help_key; |
158 |
uint16 help_index_key; |
159 |
uint16 help_extended_key; |
160 |
uint16 window_activate; |
161 |
|
162 |
} RDP_ACTIVATE_CAPS; |
163 |
|
164 |
#define RDP_CAPSET_POINTER 8 |
165 |
#define RDP_CAPLEN_POINTER 0x08 |
166 |
|
167 |
typedef struct _RDP_POINTER_CAPS |
168 |
{ |
169 |
uint16 colour_pointer; |
170 |
uint16 cache_size; |
171 |
|
172 |
} RDP_POINTER_CAPS; |
173 |
|
174 |
#define RDP_CAPSET_SHARE 9 |
175 |
#define RDP_CAPLEN_SHARE 0x08 |
176 |
|
177 |
typedef struct _RDP_SHARE_CAPS |
178 |
{ |
179 |
uint16 userid; |
180 |
uint16 pad; |
181 |
|
182 |
} RDP_SHARE_CAPS; |
183 |
|
184 |
#define RDP_CAPSET_COLCACHE 10 |
185 |
#define RDP_CAPLEN_COLCACHE 0x08 |
186 |
|
187 |
typedef struct _RDP_COLCACHE_CAPS |
188 |
{ |
189 |
uint16 cache_size; |
190 |
uint16 pad; |
191 |
|
192 |
} RDP_COLCACHE_CAPS; |
193 |
|
194 |
#define RDP_CAPSET_UNKNOWN 13 |
195 |
#define RDP_CAPLEN_UNKNOWN 0x9C |
196 |
|
197 |
#define RDP_SOURCE "MSTSC" |
198 |
|
199 |
typedef struct _RDP_ACTIVE_PDU |
200 |
{ |
201 |
uint32 shareid; |
202 |
uint16 userid; // RDP_PDU_CONFIRM_ACTIVE only |
203 |
uint16 source_len; |
204 |
uint16 caps_len; |
205 |
uint8 source[48]; |
206 |
uint16 num_caps; |
207 |
uint16 pad; |
208 |
|
209 |
RDP_GENERAL_CAPS general_caps; |
210 |
RDP_BITMAP_CAPS bitmap_caps; |
211 |
RDP_ORDER_CAPS order_caps; |
212 |
RDP_BMPCACHE_CAPS bmpcache_caps; |
213 |
RDP_ACTIVATE_CAPS activate_caps; |
214 |
RDP_CONTROL_CAPS control_caps; |
215 |
RDP_POINTER_CAPS pointer_caps; |
216 |
RDP_SHARE_CAPS share_caps; |
217 |
RDP_COLCACHE_CAPS colcache_caps; |
218 |
|
219 |
} RDP_ACTIVE_PDU; |
220 |
|
221 |
typedef struct _RDP_SYNCHRONIZE_PDU |
222 |
{ |
223 |
uint16 type; // 1 |
224 |
uint16 userid; |
225 |
|
226 |
} RDP_SYNCHRONIZE_PDU; |
227 |
|
228 |
#define RDP_CTL_REQUEST_CONTROL 1 |
229 |
#define RDP_CTL_GRANT_CONTROL 2 |
230 |
#define RDP_CTL_DETACH 3 |
231 |
#define RDP_CTL_COOPERATE 4 |
232 |
|
233 |
typedef struct _RDP_CONTROL_PDU |
234 |
{ |
235 |
uint16 action; // see above |
236 |
uint16 userid; |
237 |
uint32 controlid; |
238 |
|
239 |
} RDP_CONTROL_PDU; |
240 |
|
241 |
#define RDP_INPUT_SYNCHRONIZE 0 |
242 |
#define RDP_INPUT_CODEPOINT 1 |
243 |
#define RDP_INPUT_VIRTKEY 2 |
244 |
#define RDP_INPUT_UNKNOWN 4 |
245 |
#define RDP_INPUT_MOUSE 0x8001 |
246 |
|
247 |
#define KBD_FLAG_RIGHT 0x0001 |
248 |
#define KBD_FLAG_QUIET 0x1000 |
249 |
#define KBD_FLAG_DOWN 0x4000 |
250 |
#define KBD_FLAG_RELEASE 0x8000 |
251 |
|
252 |
#define MOUSE_FLAG_MOVE 0x0800 |
253 |
#define MOUSE_FLAG_BUTTON1 0x1000 |
254 |
#define MOUSE_FLAG_BUTTON2 0x2000 |
255 |
#define MOUSE_FLAG_BUTTON3 0x4000 |
256 |
#define MOUSE_FLAG_DOWN 0x8000 |
257 |
|
258 |
#define RDP_MAX_EVENTS 50 |
259 |
|
260 |
typedef struct _RDP_INPUT_EVENT |
261 |
{ |
262 |
uint32 event_time; |
263 |
uint16 message_type; |
264 |
uint16 device_flags; |
265 |
|
266 |
uint16 kbd_keycode; |
267 |
|
268 |
uint16 mouse_x; |
269 |
uint16 mouse_y; |
270 |
|
271 |
} RDP_INPUT_EVENT; |
272 |
|
273 |
typedef struct _RDP_INPUT_PDU |
274 |
{ |
275 |
uint16 num_events; |
276 |
uint16 pad; |
277 |
RDP_INPUT_EVENT event[RDP_MAX_EVENTS]; |
278 |
|
279 |
} RDP_INPUT_PDU; |
280 |
|
281 |
#define RDP_FONT_INFO_SIZE 0x32 |
282 |
#define RDP_MAX_FONTS 100 |
283 |
|
284 |
typedef struct _RDP_FONT_INFO |
285 |
{ |
286 |
uint8 name[32]; |
287 |
uint16 flags; |
288 |
uint16 width; |
289 |
uint16 height; |
290 |
uint16 xaspect; |
291 |
uint16 yaspect; |
292 |
uint32 signature; |
293 |
uint16 codepage; |
294 |
uint16 ascent; |
295 |
|
296 |
} RDP_FONT_INFO; |
297 |
|
298 |
typedef struct _RDP_FONT_PDU |
299 |
{ |
300 |
uint16 num_fonts; |
301 |
uint16 unknown1; // 0x3e |
302 |
uint16 unknown2; // series number? |
303 |
uint16 entry_size; |
304 |
RDP_FONT_INFO font[RDP_MAX_FONTS]; |
305 |
|
306 |
} RDP_FONT_PDU; |
307 |
|
308 |
#define RDP_UPDATE_ORDERS 0 |
309 |
#define RDP_UPDATE_PALETTE 2 |
310 |
#define RDP_UPDATE_SYNCHRONIZE 3 |
311 |
|
312 |
typedef struct _OPAQUE_RECT_ORDER |
313 |
{ |
314 |
uint16 x; |
315 |
uint16 y; |
316 |
uint16 cx; |
317 |
uint16 cy; |
318 |
uint8 colour; |
319 |
|
320 |
} OPAQUE_RECT_ORDER; |
321 |
|
322 |
typedef struct _MEMBLT_ORDER |
323 |
{ |
324 |
uint8 cache_id; |
325 |
uint16 x; |
326 |
uint16 y; |
327 |
uint16 cx; |
328 |
uint16 cy; |
329 |
uint8 opcode; |
330 |
uint16 cache_idx; |
331 |
|
332 |
} MEMBLT_ORDER; |
333 |
|
334 |
typedef struct _RDP_ORDER_STATE |
335 |
{ |
336 |
uint8 order_type; |
337 |
|
338 |
OPAQUE_RECT_ORDER opaque_rect; |
339 |
MEMBLT_ORDER memblt; |
340 |
|
341 |
} RDP_ORDER_STATE; |
342 |
|
343 |
typedef struct _RDP_UPDATE_PDU |
344 |
{ |
345 |
uint16 update_type; |
346 |
uint16 pad; |
347 |
|
348 |
} RDP_UPDATE_PDU; |
349 |
|
350 |
#define RDP_ORDER_STANDARD 1 |
351 |
#define RDP_ORDER_SECONDARY 2 |
352 |
#define RDP_ORDER_BOUNDS 4 |
353 |
#define RDP_ORDER_CHANGE 8 |
354 |
#define RDP_ORDER_DELTA 16 |
355 |
#define RDP_ORDER_REPEAT 64 |
356 |
|
357 |
enum RDP_ORDER_TYPE |
358 |
{ |
359 |
RDP_ORDER_OPAQUE_RECT = 10, |
360 |
RDP_ORDER_MEMBLT = 13 |
361 |
}; |
362 |
|
363 |
enum RDP_SECONDARY_ORDER_TYPE |
364 |
{ |
365 |
RDP_ORDER_BMPCACHE = 2 |
366 |
}; |
367 |
|
368 |
typedef struct _RDP_SECONDARY_ORDER |
369 |
{ |
370 |
uint16 length; |
371 |
uint16 flags; |
372 |
uint8 type; |
373 |
|
374 |
} RDP_SECONDARY_ORDER; |
375 |
|
376 |
typedef struct _RDP_BITMAP_HEADER |
377 |
{ |
378 |
uint8 cache_id; |
379 |
uint8 pad1; |
380 |
uint8 width; |
381 |
uint8 height; |
382 |
uint8 bpp; |
383 |
uint16 bufsize; |
384 |
uint16 cache_idx; |
385 |
uint16 pad2; |
386 |
uint16 size; |
387 |
uint16 row_size; |
388 |
uint16 final_size; |
389 |
|
390 |
} RDP_BITMAP_HEADER; |
391 |
|
392 |
#define RDP_POINTER_MOVE 3 |
393 |
|
394 |
typedef struct _RDP_POINTER |
395 |
{ |
396 |
uint16 message; |
397 |
uint16 pad; |
398 |
uint16 x; |
399 |
uint16 y; |
400 |
|
401 |
} RDP_POINTER; |
402 |
|