1 /** 2 * FreeRDP: A Remote Desktop Protocol Implementation 3 * Update Interface API 4 * 5 * Copyright 2011 Marc-Andre Moreau <marcandre.moreau@gmail.com> 6 * 7 * Licensed under the Apache License, Version 2.0 (the "License"); 8 * you may not use this file except in compliance with the License. 9 * You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, software 14 * distributed under the License is distributed on an "AS IS" BASIS, 15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 * See the License for the specific language governing permissions and 17 * limitations under the License. 18 */ 19 20 #ifndef FREERDP_UPDATE_H 21 #define FREERDP_UPDATE_H 22 23 typedef struct rdp_update rdpUpdate; 24 25 #include <winpr/crt.h> 26 #include <winpr/wlog.h> 27 #include <winpr/synch.h> 28 #include <winpr/thread.h> 29 #include <winpr/stream.h> 30 #include <winpr/collections.h> 31 32 #include <freerdp/rail.h> 33 #include <freerdp/types.h> 34 #include <freerdp/freerdp.h> 35 #include <freerdp/graphics.h> 36 #include <freerdp/utils/pcap.h> 37 38 #include <freerdp/primary.h> 39 #include <freerdp/secondary.h> 40 #include <freerdp/altsec.h> 41 #include <freerdp/window.h> 42 #include <freerdp/pointer.h> 43 44 /* Bitmap Updates */ 45 #define EX_COMPRESSED_BITMAP_HEADER_PRESENT 0x01 46 47 struct _BITMAP_DATA 48 { 49 UINT32 destLeft; 50 UINT32 destTop; 51 UINT32 destRight; 52 UINT32 destBottom; 53 UINT32 width; 54 UINT32 height; 55 UINT32 bitsPerPixel; 56 UINT32 flags; 57 UINT32 bitmapLength; 58 UINT32 cbCompFirstRowSize; 59 UINT32 cbCompMainBodySize; 60 UINT32 cbScanWidth; 61 UINT32 cbUncompressedSize; 62 BYTE* bitmapDataStream; 63 BOOL compressed; 64 }; 65 typedef struct _BITMAP_DATA BITMAP_DATA; 66 67 struct _BITMAP_UPDATE 68 { 69 UINT32 count; 70 UINT32 number; 71 BITMAP_DATA* rectangles; 72 BOOL skipCompression; 73 }; 74 typedef struct _BITMAP_UPDATE BITMAP_UPDATE; 75 76 /* Palette Updates */ 77 78 struct _PALETTE_UPDATE 79 { 80 UINT32 number; 81 PALETTE_ENTRY entries[256]; 82 }; 83 typedef struct _PALETTE_UPDATE PALETTE_UPDATE; 84 85 /* Play Sound (System Beep) Updates */ 86 87 struct _PLAY_SOUND_UPDATE 88 { 89 UINT32 duration; 90 UINT32 frequency; 91 }; 92 typedef struct _PLAY_SOUND_UPDATE PLAY_SOUND_UPDATE; 93 94 /* Surface Command Updates */ 95 struct _TS_COMPRESSED_BITMAP_HEADER_EX 96 { 97 UINT32 highUniqueId; 98 UINT32 lowUniqueId; 99 UINT64 tmMilliseconds; 100 UINT64 tmSeconds; 101 }; 102 typedef struct _TS_COMPRESSED_BITMAP_HEADER_EX TS_COMPRESSED_BITMAP_HEADER_EX; 103 104 struct _TS_BITMAP_DATA_EX 105 { 106 BYTE bpp; 107 BYTE flags; 108 UINT16 codecID; 109 UINT16 width; 110 UINT16 height; 111 UINT32 bitmapDataLength; 112 TS_COMPRESSED_BITMAP_HEADER_EX exBitmapDataHeader; 113 BYTE* bitmapData; 114 }; 115 typedef struct _TS_BITMAP_DATA_EX TS_BITMAP_DATA_EX; 116 117 enum SURFCMD_CMDTYPE 118 { 119 CMDTYPE_SET_SURFACE_BITS = 0x0001, 120 CMDTYPE_FRAME_MARKER = 0x0004, 121 CMDTYPE_STREAM_SURFACE_BITS = 0x0006 122 }; 123 124 struct _SURFACE_BITS_COMMAND 125 { 126 UINT32 cmdType; 127 UINT32 destLeft; 128 UINT32 destTop; 129 UINT32 destRight; 130 UINT32 destBottom; 131 TS_BITMAP_DATA_EX bmp; 132 BOOL skipCompression; 133 }; 134 typedef struct _SURFACE_BITS_COMMAND SURFACE_BITS_COMMAND; 135 136 struct _SURFACE_FRAME_MARKER 137 { 138 UINT32 frameAction; 139 UINT32 frameId; 140 }; 141 typedef struct _SURFACE_FRAME_MARKER SURFACE_FRAME_MARKER; 142 143 enum SURFCMD_FRAMEACTION 144 { 145 SURFACECMD_FRAMEACTION_BEGIN = 0x0000, 146 SURFACECMD_FRAMEACTION_END = 0x0001 147 }; 148 149 /** @brief status code as in 2.2.5.2 Server Status Info PDU */ 150 enum 151 { 152 TS_STATUS_FINDING_DESTINATION = 0x00000401, 153 TS_STATUS_LOADING_DESTINATION = 0x00000402, 154 TS_STATUS_BRINGING_SESSION_ONLINE = 0x00000403, 155 TS_STATUS_REDIRECTING_TO_DESTINATION = 0x00000404, 156 TS_STATUS_VM_LOADING = 0x00000501, 157 TS_STATUS_VM_WAKING = 0x00000502, 158 TS_STATUS_VM_STARTING = 0x00000503, 159 TS_STATUS_VM_STARTING_MONITORING = 0x00000504, 160 TS_STATUS_VM_RETRYING_MONITORING = 0x00000505 161 }; 162 163 struct _SURFACE_FRAME 164 { 165 UINT32 frameId; 166 UINT32 commandCount; 167 SURFACE_BITS_COMMAND* commands; 168 }; 169 typedef struct _SURFACE_FRAME SURFACE_FRAME; 170 171 /* defined inside libfreerdp-core */ 172 typedef struct rdp_update_proxy rdpUpdateProxy; 173 174 /* Update Interface */ 175 176 typedef BOOL (*pBeginPaint)(rdpContext* context); 177 typedef BOOL (*pEndPaint)(rdpContext* context); 178 typedef BOOL (*pSetBounds)(rdpContext* context, const rdpBounds* bounds); 179 180 typedef BOOL (*pSynchronize)(rdpContext* context); 181 typedef BOOL (*pDesktopResize)(rdpContext* context); 182 typedef BOOL (*pBitmapUpdate)(rdpContext* context, const BITMAP_UPDATE* bitmap); 183 typedef BOOL (*pPalette)(rdpContext* context, const PALETTE_UPDATE* palette); 184 typedef BOOL (*pPlaySound)(rdpContext* context, const PLAY_SOUND_UPDATE* play_sound); 185 typedef BOOL (*pSetKeyboardIndicators)(rdpContext* context, UINT16 led_flags); 186 187 typedef BOOL (*pRefreshRect)(rdpContext* context, BYTE count, const RECTANGLE_16* areas); 188 typedef BOOL (*pSuppressOutput)(rdpContext* context, BYTE allow, const RECTANGLE_16* area); 189 typedef BOOL (*pRemoteMonitors)(rdpContext* context, UINT32 count, const MONITOR_DEF* monitors); 190 191 typedef BOOL (*pSurfaceCommand)(rdpContext* context, wStream* s); 192 typedef BOOL (*pSurfaceBits)(rdpContext* context, const SURFACE_BITS_COMMAND* surfaceBitsCommand); 193 typedef BOOL (*pSurfaceFrameMarker)(rdpContext* context, 194 const SURFACE_FRAME_MARKER* surfaceFrameMarker); 195 typedef BOOL (*pSurfaceFrameBits)(rdpContext* context, const SURFACE_BITS_COMMAND* cmd, BOOL first, 196 BOOL last, UINT32 frameId); 197 typedef BOOL (*pSurfaceFrameAcknowledge)(rdpContext* context, UINT32 frameId); 198 199 typedef BOOL (*pSaveSessionInfo)(rdpContext* context, UINT32 type, void* data); 200 typedef BOOL (*pSetKeyboardImeStatus)(rdpContext* context, UINT16 imeId, UINT32 imeState, 201 UINT32 imeConvMode); 202 typedef BOOL (*pServerStatusInfo)(rdpContext* context, UINT32 status); 203 204 struct rdp_update 205 { 206 rdpContext* context; /* 0 */ 207 UINT32 paddingA[16 - 1]; /* 1 */ 208 209 pBeginPaint BeginPaint; /* 16 */ 210 pEndPaint EndPaint; /* 17 */ 211 pSetBounds SetBounds; /* 18 */ 212 pSynchronize Synchronize; /* 19 */ 213 pDesktopResize DesktopResize; /* 20 */ 214 pBitmapUpdate BitmapUpdate; /* 21 */ 215 pPalette Palette; /* 22 */ 216 pPlaySound PlaySound; /* 23 */ 217 pSetKeyboardIndicators SetKeyboardIndicators; /* 24 */ 218 pSetKeyboardImeStatus SetKeyboardImeStatus; /* 25 */ 219 UINT32 paddingB[32 - 26]; /* 26 */ 220 221 rdpPointerUpdate* pointer; /* 32 */ 222 rdpPrimaryUpdate* primary; /* 33 */ 223 rdpSecondaryUpdate* secondary; /* 34 */ 224 rdpAltSecUpdate* altsec; /* 35 */ 225 rdpWindowUpdate* window; /* 36 */ 226 UINT32 paddingC[48 - 37]; /* 37 */ 227 228 pRefreshRect RefreshRect; /* 48 */ 229 pSuppressOutput SuppressOutput; /* 49 */ 230 pRemoteMonitors RemoteMonitors; /* 50 */ 231 UINT32 paddingD[64 - 51]; /* 51 */ 232 233 pSurfaceCommand SurfaceCommand; /* 64 */ 234 pSurfaceBits SurfaceBits; /* 65 */ 235 pSurfaceFrameMarker SurfaceFrameMarker; /* 66 */ 236 pSurfaceFrameBits SurfaceFrameBits; /* 67 */ 237 pSurfaceFrameAcknowledge SurfaceFrameAcknowledge; /* 68 */ 238 pSaveSessionInfo SaveSessionInfo; /* 69 */ 239 pServerStatusInfo ServerStatusInfo; /* 70 */ 240 UINT32 paddingE[80 - 71]; /* 71 */ 241 242 /* internal */ 243 244 wLog* log; 245 246 BOOL dump_rfx; 247 BOOL play_rfx; 248 rdpPcap* pcap_rfx; 249 BOOL initialState; 250 251 BOOL asynchronous; 252 rdpUpdateProxy* proxy; 253 wMessageQueue* queue; 254 255 wStream* us; 256 UINT16 numberOrders; 257 BOOL combineUpdates; 258 rdpBounds currentBounds; 259 rdpBounds previousBounds; 260 CRITICAL_SECTION mux; 261 262 /* if autoCalculateBitmapData is set to TRUE, the server automatically 263 * fills BITMAP_DATA struct members: flags, cbCompMainBodySize and cbCompFirstRowSize. 264 */ 265 BOOL autoCalculateBitmapData; 266 size_t offsetOrders; /* the offset to patch numberOrders in the stream */ 267 }; 268 269 #endif /* FREERDP_UPDATE_H */ 270