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