1 | /*
|
---|
2 | rdesktop: A Remote Desktop Protocol client.
|
---|
3 | RDP order processing
|
---|
4 | Copyright (C) Matthew Chapman 1999-2007
|
---|
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 | /*
|
---|
22 | * Sun GPL Disclaimer: For the avoidance of doubt, except that if any license choice
|
---|
23 | * other than GPL or LGPL is available it will apply instead, Sun elects to use only
|
---|
24 | * the General Public License version 2 (GPLv2) at this time for any software where
|
---|
25 | * a choice of GPL license versions is made available with the language indicating
|
---|
26 | * that GPLv2 or any later version may be used, or where a choice of which version
|
---|
27 | * of the GPL is applied is otherwise unspecified.
|
---|
28 | */
|
---|
29 |
|
---|
30 | #define RDP_ORDER_STANDARD 0x01
|
---|
31 | #define RDP_ORDER_SECONDARY 0x02
|
---|
32 | #define RDP_ORDER_BOUNDS 0x04
|
---|
33 | #define RDP_ORDER_CHANGE 0x08
|
---|
34 | #define RDP_ORDER_DELTA 0x10
|
---|
35 | #define RDP_ORDER_LASTBOUNDS 0x20
|
---|
36 | #define RDP_ORDER_SMALL 0x40
|
---|
37 | #define RDP_ORDER_TINY 0x80
|
---|
38 |
|
---|
39 | enum RDP_ORDER_TYPE
|
---|
40 | {
|
---|
41 | RDP_ORDER_DESTBLT = 0,
|
---|
42 | RDP_ORDER_PATBLT = 1,
|
---|
43 | RDP_ORDER_SCREENBLT = 2,
|
---|
44 | RDP_ORDER_LINE = 9,
|
---|
45 | RDP_ORDER_RECT = 10,
|
---|
46 | RDP_ORDER_DESKSAVE = 11,
|
---|
47 | RDP_ORDER_MEMBLT = 13,
|
---|
48 | RDP_ORDER_TRIBLT = 14,
|
---|
49 | RDP_ORDER_POLYGON = 20,
|
---|
50 | RDP_ORDER_POLYGON2 = 21,
|
---|
51 | RDP_ORDER_POLYLINE = 22,
|
---|
52 | RDP_ORDER_ELLIPSE = 25,
|
---|
53 | RDP_ORDER_ELLIPSE2 = 26,
|
---|
54 | RDP_ORDER_TEXT2 = 27
|
---|
55 | };
|
---|
56 |
|
---|
57 | enum RDP_SECONDARY_ORDER_TYPE
|
---|
58 | {
|
---|
59 | RDP_ORDER_RAW_BMPCACHE = 0,
|
---|
60 | RDP_ORDER_COLCACHE = 1,
|
---|
61 | RDP_ORDER_BMPCACHE = 2,
|
---|
62 | RDP_ORDER_FONTCACHE = 3,
|
---|
63 | RDP_ORDER_RAW_BMPCACHE2 = 4,
|
---|
64 | RDP_ORDER_BMPCACHE2 = 5,
|
---|
65 | RDP_ORDER_BRUSHCACHE = 7
|
---|
66 | };
|
---|
67 |
|
---|
68 | typedef struct _DESTBLT_ORDER
|
---|
69 | {
|
---|
70 | sint16 x;
|
---|
71 | sint16 y;
|
---|
72 | sint16 cx;
|
---|
73 | sint16 cy;
|
---|
74 | uint8 opcode;
|
---|
75 |
|
---|
76 | }
|
---|
77 | DESTBLT_ORDER;
|
---|
78 |
|
---|
79 | typedef struct _PATBLT_ORDER
|
---|
80 | {
|
---|
81 | sint16 x;
|
---|
82 | sint16 y;
|
---|
83 | sint16 cx;
|
---|
84 | sint16 cy;
|
---|
85 | uint8 opcode;
|
---|
86 | uint32 bgcolour;
|
---|
87 | uint32 fgcolour;
|
---|
88 | BRUSH brush;
|
---|
89 |
|
---|
90 | }
|
---|
91 | PATBLT_ORDER;
|
---|
92 |
|
---|
93 | typedef struct _SCREENBLT_ORDER
|
---|
94 | {
|
---|
95 | sint16 x;
|
---|
96 | sint16 y;
|
---|
97 | sint16 cx;
|
---|
98 | sint16 cy;
|
---|
99 | uint8 opcode;
|
---|
100 | sint16 srcx;
|
---|
101 | sint16 srcy;
|
---|
102 |
|
---|
103 | }
|
---|
104 | SCREENBLT_ORDER;
|
---|
105 |
|
---|
106 | typedef struct _LINE_ORDER
|
---|
107 | {
|
---|
108 | uint16 mixmode;
|
---|
109 | sint16 startx;
|
---|
110 | sint16 starty;
|
---|
111 | sint16 endx;
|
---|
112 | sint16 endy;
|
---|
113 | uint32 bgcolour;
|
---|
114 | uint8 opcode;
|
---|
115 | PEN pen;
|
---|
116 |
|
---|
117 | }
|
---|
118 | LINE_ORDER;
|
---|
119 |
|
---|
120 | typedef struct _RECT_ORDER
|
---|
121 | {
|
---|
122 | sint16 x;
|
---|
123 | sint16 y;
|
---|
124 | sint16 cx;
|
---|
125 | sint16 cy;
|
---|
126 | uint32 colour;
|
---|
127 |
|
---|
128 | }
|
---|
129 | RECT_ORDER;
|
---|
130 |
|
---|
131 | typedef struct _DESKSAVE_ORDER
|
---|
132 | {
|
---|
133 | uint32 offset;
|
---|
134 | sint16 left;
|
---|
135 | sint16 top;
|
---|
136 | sint16 right;
|
---|
137 | sint16 bottom;
|
---|
138 | uint8 action;
|
---|
139 |
|
---|
140 | }
|
---|
141 | DESKSAVE_ORDER;
|
---|
142 |
|
---|
143 | typedef struct _TRIBLT_ORDER
|
---|
144 | {
|
---|
145 | uint8 colour_table;
|
---|
146 | uint8 cache_id;
|
---|
147 | sint16 x;
|
---|
148 | sint16 y;
|
---|
149 | sint16 cx;
|
---|
150 | sint16 cy;
|
---|
151 | uint8 opcode;
|
---|
152 | sint16 srcx;
|
---|
153 | sint16 srcy;
|
---|
154 | uint32 bgcolour;
|
---|
155 | uint32 fgcolour;
|
---|
156 | BRUSH brush;
|
---|
157 | uint16 cache_idx;
|
---|
158 | uint16 unknown;
|
---|
159 |
|
---|
160 | }
|
---|
161 | TRIBLT_ORDER;
|
---|
162 |
|
---|
163 | typedef struct _MEMBLT_ORDER
|
---|
164 | {
|
---|
165 | uint8 colour_table;
|
---|
166 | uint8 cache_id;
|
---|
167 | sint16 x;
|
---|
168 | sint16 y;
|
---|
169 | sint16 cx;
|
---|
170 | sint16 cy;
|
---|
171 | uint8 opcode;
|
---|
172 | sint16 srcx;
|
---|
173 | sint16 srcy;
|
---|
174 | uint16 cache_idx;
|
---|
175 |
|
---|
176 | }
|
---|
177 | MEMBLT_ORDER;
|
---|
178 |
|
---|
179 | #define MAX_DATA 256
|
---|
180 |
|
---|
181 | typedef struct _POLYGON_ORDER
|
---|
182 | {
|
---|
183 | sint16 x;
|
---|
184 | sint16 y;
|
---|
185 | uint8 opcode;
|
---|
186 | uint8 fillmode;
|
---|
187 | uint32 fgcolour;
|
---|
188 | uint8 npoints;
|
---|
189 | uint8 datasize;
|
---|
190 | uint8 data[MAX_DATA];
|
---|
191 |
|
---|
192 | }
|
---|
193 | POLYGON_ORDER;
|
---|
194 |
|
---|
195 | typedef struct _POLYGON2_ORDER
|
---|
196 | {
|
---|
197 | sint16 x;
|
---|
198 | sint16 y;
|
---|
199 | uint8 opcode;
|
---|
200 | uint8 fillmode;
|
---|
201 | uint32 bgcolour;
|
---|
202 | uint32 fgcolour;
|
---|
203 | BRUSH brush;
|
---|
204 | uint8 npoints;
|
---|
205 | uint8 datasize;
|
---|
206 | uint8 data[MAX_DATA];
|
---|
207 |
|
---|
208 | }
|
---|
209 | POLYGON2_ORDER;
|
---|
210 |
|
---|
211 | typedef struct _POLYLINE_ORDER
|
---|
212 | {
|
---|
213 | sint16 x;
|
---|
214 | sint16 y;
|
---|
215 | uint8 opcode;
|
---|
216 | uint32 fgcolour;
|
---|
217 | uint8 lines;
|
---|
218 | uint8 datasize;
|
---|
219 | uint8 data[MAX_DATA];
|
---|
220 |
|
---|
221 | }
|
---|
222 | POLYLINE_ORDER;
|
---|
223 |
|
---|
224 | typedef struct _ELLIPSE_ORDER
|
---|
225 | {
|
---|
226 | sint16 left;
|
---|
227 | sint16 top;
|
---|
228 | sint16 right;
|
---|
229 | sint16 bottom;
|
---|
230 | uint8 opcode;
|
---|
231 | uint8 fillmode;
|
---|
232 | uint32 fgcolour;
|
---|
233 |
|
---|
234 | }
|
---|
235 | ELLIPSE_ORDER;
|
---|
236 |
|
---|
237 | typedef struct _ELLIPSE2_ORDER
|
---|
238 | {
|
---|
239 | sint16 left;
|
---|
240 | sint16 top;
|
---|
241 | sint16 right;
|
---|
242 | sint16 bottom;
|
---|
243 | uint8 opcode;
|
---|
244 | uint8 fillmode;
|
---|
245 | BRUSH brush;
|
---|
246 | uint32 bgcolour;
|
---|
247 | uint32 fgcolour;
|
---|
248 |
|
---|
249 | }
|
---|
250 | ELLIPSE2_ORDER;
|
---|
251 |
|
---|
252 | #define MAX_TEXT 256
|
---|
253 |
|
---|
254 | typedef struct _TEXT2_ORDER
|
---|
255 | {
|
---|
256 | uint8 font;
|
---|
257 | uint8 flags;
|
---|
258 | uint8 opcode;
|
---|
259 | uint8 mixmode;
|
---|
260 | uint32 bgcolour;
|
---|
261 | uint32 fgcolour;
|
---|
262 | sint16 clipleft;
|
---|
263 | sint16 cliptop;
|
---|
264 | sint16 clipright;
|
---|
265 | sint16 clipbottom;
|
---|
266 | sint16 boxleft;
|
---|
267 | sint16 boxtop;
|
---|
268 | sint16 boxright;
|
---|
269 | sint16 boxbottom;
|
---|
270 | BRUSH brush;
|
---|
271 | sint16 x;
|
---|
272 | sint16 y;
|
---|
273 | uint8 length;
|
---|
274 | uint8 text[MAX_TEXT];
|
---|
275 |
|
---|
276 | }
|
---|
277 | TEXT2_ORDER;
|
---|
278 |
|
---|
279 | typedef struct _RDP_ORDER_STATE
|
---|
280 | {
|
---|
281 | uint8 order_type;
|
---|
282 | BOUNDS bounds;
|
---|
283 |
|
---|
284 | DESTBLT_ORDER destblt;
|
---|
285 | PATBLT_ORDER patblt;
|
---|
286 | SCREENBLT_ORDER screenblt;
|
---|
287 | LINE_ORDER line;
|
---|
288 | RECT_ORDER rect;
|
---|
289 | DESKSAVE_ORDER desksave;
|
---|
290 | MEMBLT_ORDER memblt;
|
---|
291 | TRIBLT_ORDER triblt;
|
---|
292 | POLYGON_ORDER polygon;
|
---|
293 | POLYGON2_ORDER polygon2;
|
---|
294 | POLYLINE_ORDER polyline;
|
---|
295 | ELLIPSE_ORDER ellipse;
|
---|
296 | ELLIPSE2_ORDER ellipse2;
|
---|
297 | TEXT2_ORDER text2;
|
---|
298 |
|
---|
299 | }
|
---|
300 | RDP_ORDER_STATE;
|
---|
301 |
|
---|
302 | typedef struct _RDP_RAW_BMPCACHE_ORDER
|
---|
303 | {
|
---|
304 | uint8 cache_id;
|
---|
305 | uint8 pad1;
|
---|
306 | uint8 width;
|
---|
307 | uint8 height;
|
---|
308 | uint8 bpp;
|
---|
309 | uint16 bufsize;
|
---|
310 | uint16 cache_idx;
|
---|
311 | uint8 *data;
|
---|
312 |
|
---|
313 | }
|
---|
314 | RDP_RAW_BMPCACHE_ORDER;
|
---|
315 |
|
---|
316 | typedef struct _RDP_BMPCACHE_ORDER
|
---|
317 | {
|
---|
318 | uint8 cache_id;
|
---|
319 | uint8 pad1;
|
---|
320 | uint8 width;
|
---|
321 | uint8 height;
|
---|
322 | uint8 bpp;
|
---|
323 | uint16 bufsize;
|
---|
324 | uint16 cache_idx;
|
---|
325 | uint16 pad2;
|
---|
326 | uint16 size;
|
---|
327 | uint16 row_size;
|
---|
328 | uint16 final_size;
|
---|
329 | uint8 *data;
|
---|
330 |
|
---|
331 | }
|
---|
332 | RDP_BMPCACHE_ORDER;
|
---|
333 |
|
---|
334 | /* RDP_BMPCACHE2_ORDER */
|
---|
335 | #define ID_MASK 0x0007
|
---|
336 | #define MODE_MASK 0x0038
|
---|
337 | #define SQUARE 0x0080
|
---|
338 | #define PERSIST 0x0100
|
---|
339 | #define FLAG_51_UNKNOWN 0x0800
|
---|
340 |
|
---|
341 | #define MODE_SHIFT 3
|
---|
342 |
|
---|
343 | #define LONG_FORMAT 0x80
|
---|
344 | #define BUFSIZE_MASK 0x3FFF /* or 0x1FFF? */
|
---|
345 |
|
---|
346 | #define MAX_GLYPH 32
|
---|
347 |
|
---|
348 | typedef struct _RDP_FONT_GLYPH
|
---|
349 | {
|
---|
350 | uint16 character;
|
---|
351 | uint16 unknown;
|
---|
352 | uint16 baseline;
|
---|
353 | uint16 width;
|
---|
354 | uint16 height;
|
---|
355 | uint8 data[MAX_GLYPH];
|
---|
356 |
|
---|
357 | }
|
---|
358 | RDP_FONT_GLYPH;
|
---|
359 |
|
---|
360 | #define MAX_GLYPHS 256
|
---|
361 |
|
---|
362 | typedef struct _RDP_FONTCACHE_ORDER
|
---|
363 | {
|
---|
364 | uint8 font;
|
---|
365 | uint8 nglyphs;
|
---|
366 | RDP_FONT_GLYPH glyphs[MAX_GLYPHS];
|
---|
367 |
|
---|
368 | }
|
---|
369 | RDP_FONTCACHE_ORDER;
|
---|
370 |
|
---|
371 | typedef struct _RDP_COLCACHE_ORDER
|
---|
372 | {
|
---|
373 | uint8 cache_id;
|
---|
374 | COLOURMAP map;
|
---|
375 |
|
---|
376 | }
|
---|
377 | RDP_COLCACHE_ORDER;
|
---|