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