security.c
security.h
settings.c
+ orders.c
+ orders.h
capabilities.c
capabilities.h
certificate.c
tpkt.h
transport.c
transport.h
+ update.c
+ update.h
bitmap.c
)
--- /dev/null
+/**
+ * FreeRDP: A Remote Desktop Protocol Client
+ * Drawing Orders
+ *
+ * Copyright 2011 Marc-Andre Moreau <marcandre.moreau@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "orders.h"
+
+uint8 PRIMARY_DRAWING_ORDER_STRINGS[][20] =
+{
+ "DstBlt",
+ "PatBlt",
+ "ScrBlt",
+ "", "", "", "",
+ "DrawNineGrid",
+ "MultiDrawNineGrid",
+ "LineTo",
+ "OpaqueRect",
+ "SaveBitmap",
+ "MemBlt",
+ "Mem3Blt",
+ "MultiDstBlt",
+ "MultiPatBlt",
+ "MultiScrBlt",
+ "MultiOpaqueRect",
+ "FastIndex",
+ "PolygonSC",
+ "PolygonCB",
+ "Polyline",
+ "FastGlyph",
+ "EllipseSC",
+ "EllipseCB",
+ "GlyphIndex"
+};
+
+uint8 SECONDARY_DRAWING_ORDER_STRINGS[][32] =
+{
+ "Cache Bitmap",
+ "Cache Color Table",
+ "Cache Bitmap (Compressed)",
+ "Cache Glyph",
+ "Cache Bitmap V2",
+ "Cache Bitmap V2 (Compressed)",
+ "",
+ "Cache Brush",
+ "Cache Bitmap V3"
+};
+
+uint8 ALTSEC_DRAWING_ORDER_STRINGS[][32] =
+{
+ "Switch Surface",
+ "Create Offscreen Bitmap",
+ "Stream Bitmap First",
+ "Stream Bitmap Next",
+ "Create NineGrid Bitmap",
+ "Draw GDI+ First",
+ "Draw GDI+ Next",
+ "Draw GDI+ End",
+ "Draw GDI+ Cache First",
+ "Draw GDI+ Cache Next",
+ "Draw GDI+ Cache End",
+ "Windowing",
+ "Desktop Composition",
+ "Frame Marker"
+};
+
+void rdp_recv_primary_order(rdpRdp* rdp, STREAM* s, uint8 flags)
+{
+ uint8 orderType;
+
+ stream_read_uint8(s, orderType); /* orderType (1 byte) */
+
+ printf("%s Primary Drawing Order\n", PRIMARY_DRAWING_ORDER_STRINGS[orderType]);
+
+ switch (orderType)
+ {
+ case ORDER_TYPE_DSTBLT:
+ break;
+
+ case ORDER_TYPE_PATBLT:
+ break;
+
+ case ORDER_TYPE_SCRBLT:
+ break;
+
+ case ORDER_TYPE_DRAW_NINEGRID:
+ break;
+
+ case ORDER_TYPE_MULTI_DRAW_NINEGRID:
+ break;
+
+ case ORDER_TYPE_LINETO:
+ break;
+
+ case ORDER_TYPE_OPAQUE_RECT:
+ break;
+
+ case ORDER_TYPE_SAVE_BITMAP:
+ break;
+
+ case ORDER_TYPE_MEMBLT:
+ break;
+
+ case ORDER_TYPE_MEM3BLT:
+ break;
+
+ case ORDER_TYPE_MULTI_DSTBLT:
+ break;
+
+ case ORDER_TYPE_MULTI_PATBLT:
+ break;
+
+ case ORDER_TYPE_MULTI_SCRBLT:
+ break;
+
+ case ORDER_TYPE_MULTI_OPAQUE_RECT:
+ break;
+
+ case ORDER_TYPE_FAST_INDEX:
+ break;
+
+ case ORDER_TYPE_POLYGON_SC:
+ break;
+
+ case ORDER_TYPE_POLYGON_CB:
+ break;
+
+ case ORDER_TYPE_POLYLINE:
+ break;
+
+ case ORDER_TYPE_FAST_GLYPH:
+ break;
+
+ case ORDER_TYPE_ELLIPSE_SC:
+ break;
+
+ case ORDER_TYPE_ELLIPSE_CB:
+ break;
+
+ case ORDER_TYPE_INDEX_ORDER:
+ break;
+
+ default:
+ break;
+ }
+}
+
+void rdp_recv_secondary_order(rdpRdp* rdp, STREAM* s, uint8 flags)
+{
+ uint8 orderType;
+
+ stream_read_uint8(s, orderType); /* orderType (1 byte) */
+
+ printf("%s Secondary Drawing Order\n", SECONDARY_DRAWING_ORDER_STRINGS[orderType]);
+
+ switch (orderType)
+ {
+ case ORDER_TYPE_BITMAP_UNCOMPRESSED:
+ break;
+
+ case ORDER_TYPE_CACHE_COLOR_TABLE:
+ break;
+
+ case ORDER_TYPE_CACHE_BITMAP_COMPRESSED:
+ break;
+
+ case ORDER_TYPE_CACHE_GLYPH:
+ break;
+
+ case ORDER_TYPE_BITMAP_UNCOMPRESSED_V2:
+ break;
+
+ case ORDER_TYPE_BITMAP_COMPRESSED_V2:
+ break;
+
+ case ORDER_TYPE_CACHE_BRUSH:
+ break;
+
+ case ORDER_TYPE_BITMAP_COMPRESSED_V3:
+ break;
+
+ default:
+ break;
+ }
+}
+
+void rdp_recv_altsec_order(rdpRdp* rdp, STREAM* s, uint8 flags)
+{
+ uint8 orderType;
+
+ stream_read_uint8(s, orderType); /* orderType (1 byte) */
+
+ printf("%s Alternate Secondary Drawing Order\n", ALTSEC_DRAWING_ORDER_STRINGS[orderType]);
+
+ switch (orderType)
+ {
+ case ORDER_TYPE_SWITCH_SURFACE:
+ break;
+
+ case ORDER_TYPE_CREATE_OFFSCR_BITMAP:
+ break;
+
+ case ORDER_TYPE_STREAM_BITMAP_FIRST:
+ break;
+
+ case ORDER_TYPE_STREAM_BITMAP_NEXT:
+ break;
+
+ case ORDER_TYPE_CREATE_NINEGRID_BITMAP:
+ break;
+
+ case ORDER_TYPE_GDIPLUS_FIRST:
+ break;
+
+ case ORDER_TYPE_GDIPLUS_NEXT:
+ break;
+
+ case ORDER_TYPE_GDIPLUS_END:
+ break;
+
+ case ORDER_TYPE_GDIPLUS_CACHE_FIRST:
+ break;
+
+ case ORDER_TYPE_GDIPLUS_CACHE_NEXT:
+ break;
+
+ case ORDER_TYPE_GDIPLUS_CACHE_END:
+ break;
+
+ case ORDER_TYPE_WINDOW:
+ break;
+
+ case ORDER_TYPE_COMPDESK_FIRST:
+ break;
+
+ case ORDER_TYPE_FRAME_MARKER:
+ break;
+
+ default:
+ break;
+ }
+}
+
+void rdp_recv_order(rdpRdp* rdp, STREAM* s)
+{
+ uint8 controlFlags;
+
+ stream_read_uint8(s, controlFlags); /* controlFlags (1 byte) */
+
+ switch (controlFlags & ORDER_CLASS_MASK)
+ {
+ case ORDER_PRIMARY_CLASS:
+ rdp_recv_primary_order(rdp, s, controlFlags);
+ break;
+
+ case ORDER_SECONDARY_CLASS:
+ rdp_recv_secondary_order(rdp, s, controlFlags);
+ break;
+
+ case ORDER_ALTSEC_CLASS:
+ rdp_recv_altsec_order(rdp, s, controlFlags);
+ break;
+ }
+}
--- /dev/null
+/**
+ * FreeRDP: A Remote Desktop Protocol Client
+ * Drawing Orders
+ *
+ * Copyright 2011 Marc-Andre Moreau <marcandre.moreau@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __ORDERS_H
+#define __ORDERS_H
+
+#include "rdp.h"
+#include <freerdp/types.h>
+#include <freerdp/utils/stream.h>
+
+/* Order Control Flags */
+#define ORDER_STANDARD 0x01
+#define ORDER_SECONDARY 0x02
+#define ORDER_BOUNDS 0x04
+#define ORDER_TYPE_CHANGE 0x08
+#define ORDER_DELTA_COORDINATES 0x10
+#define ORDER_ZERO_BOUNDS_DELTAS 0x20
+#define ORDER_ZERO_FIELD_BYTE_BIT0 0x40
+#define ORDER_ZERO_FIELD_BYTE_BIT1 0x80
+
+/* Order Classes */
+#define ORDER_PRIMARY_CLASS 0x01
+#define ORDER_SECONDARY_CLASS 0x03
+#define ORDER_ALTSEC_CLASS 0x02
+#define ORDER_CLASS_MASK 0x03
+
+/* Primary Drawing Orders */
+#define ORDER_TYPE_DSTBLT 0x00
+#define ORDER_TYPE_PATBLT 0x01
+#define ORDER_TYPE_SCRBLT 0x02
+#define ORDER_TYPE_DRAW_NINEGRID 0x07
+#define ORDER_TYPE_MULTI_DRAW_NINEGRID 0x08
+#define ORDER_TYPE_LINETO 0x09
+#define ORDER_TYPE_OPAQUE_RECT 0x0A
+#define ORDER_TYPE_SAVE_BITMAP 0x0B
+#define ORDER_TYPE_MEMBLT 0x0D
+#define ORDER_TYPE_MEM3BLT 0x0E
+#define ORDER_TYPE_MULTI_DSTBLT 0x0F
+#define ORDER_TYPE_MULTI_PATBLT 0x10
+#define ORDER_TYPE_MULTI_SCRBLT 0x11
+#define ORDER_TYPE_MULTI_OPAQUE_RECT 0x12
+#define ORDER_TYPE_FAST_INDEX 0x13
+#define ORDER_TYPE_POLYGON_SC 0x14
+#define ORDER_TYPE_POLYGON_CB 0x15
+#define ORDER_TYPE_POLYLINE 0x16
+#define ORDER_TYPE_FAST_GLYPH 0x18
+#define ORDER_TYPE_ELLIPSE_SC 0x19
+#define ORDER_TYPE_ELLIPSE_CB 0x1A
+#define ORDER_TYPE_INDEX_ORDER 0x1B
+
+/* Secondary Drawing Orders */
+#define ORDER_TYPE_BITMAP_UNCOMPRESSED 0x00
+#define ORDER_TYPE_CACHE_COLOR_TABLE 0x01
+#define ORDER_TYPE_CACHE_BITMAP_COMPRESSED 0x02
+#define ORDER_TYPE_CACHE_GLYPH 0x03
+#define ORDER_TYPE_BITMAP_UNCOMPRESSED_V2 0x04
+#define ORDER_TYPE_BITMAP_COMPRESSED_V2 0x05
+#define ORDER_TYPE_CACHE_BRUSH 0x07
+#define ORDER_TYPE_BITMAP_COMPRESSED_V3 0x08
+
+/* Alternate Secondary Drawing Orders */
+#define ORDER_TYPE_SWITCH_SURFACE 0x00
+#define ORDER_TYPE_CREATE_OFFSCR_BITMAP 0x01
+#define ORDER_TYPE_STREAM_BITMAP_FIRST 0x02
+#define ORDER_TYPE_STREAM_BITMAP_NEXT 0x03
+#define ORDER_TYPE_CREATE_NINEGRID_BITMAP 0x04
+#define ORDER_TYPE_GDIPLUS_FIRST 0x05
+#define ORDER_TYPE_GDIPLUS_NEXT 0x06
+#define ORDER_TYPE_GDIPLUS_END 0x07
+#define ORDER_TYPE_GDIPLUS_CACHE_FIRST 0x08
+#define ORDER_TYPE_GDIPLUS_CACHE_NEXT 0x09
+#define ORDER_TYPE_GDIPLUS_CACHE_END 0x0A
+#define ORDER_TYPE_WINDOW 0x0B
+#define ORDER_TYPE_COMPDESK_FIRST 0x0C
+#define ORDER_TYPE_FRAME_MARKER 0x0D
+
+void rdp_recv_order(rdpRdp* rdp, STREAM* s);
+
+#endif /* __ORDERS_H */
printf("Error Info: 0x%08X\n", errorInfo);
}
-void rdp_recv_update_data_pdu(rdpRdp* rdp, STREAM* s)
-{
- uint16 updateType;
-
- stream_read_uint16(s, updateType); /* updateType (2 bytes) */
-
- switch (updateType)
- {
- case UPDATE_TYPE_ORDERS:
- printf("Orders Update\n");
- break;
-
- case UPDATE_TYPE_BITMAP:
- printf("Bitmap Update\n");
- break;
-
- case UPDATE_TYPE_PALETTE:
- printf("Palette Update\n");
- break;
-
- case UPDATE_TYPE_SYNCHRONIZE:
- printf("Synchronize Update\n");
- break;
- }
-}
-
void rdp_read_data_pdu(rdpRdp* rdp, STREAM* s)
{
uint8 type;
#include "tpkt.h"
#include "tpdu.h"
#include "nego.h"
+#include "update.h"
#include "license.h"
#include "security.h"
#include "registry.h"
#define DATA_PDU_TYPE_STATUS_INFO 0x36
#define DATA_PDU_TYPE_MONITOR_LAYOUT 0x37
-#define UPDATE_TYPE_ORDERS 0x0000
-#define UPDATE_TYPE_BITMAP 0x0001
-#define UPDATE_TYPE_PALETTE 0x0002
-#define UPDATE_TYPE_SYNCHRONIZE 0x0003
-
/* Compression Types */
#define PACKET_COMPRESSED 0x20
#define PACKET_AT_FRONT 0x40
--- /dev/null
+/**
+ * FreeRDP: A Remote Desktop Protocol Client
+ * Update Data PDUs
+ *
+ * Copyright 2011 Marc-Andre Moreau <marcandre.moreau@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "update.h"
+
+uint8 UPDATE_TYPE_STRINGS[][32] =
+{
+ "Orders",
+ "Bitmap",
+ "Palette",
+ "Synchronize"
+};
+
+void rdp_recv_orders_update(rdpRdp* rdp, STREAM* s)
+{
+ uint16 numberOrders;
+
+ stream_seek_uint16(s); /* pad2OctetsA (2 bytes) */
+ stream_read_uint16(s, numberOrders); /* numberOrders (2 bytes) */
+ stream_seek_uint16(s); /* pad2OctetsB (2 bytes) */
+}
+
+void rdp_read_bitmap_data(STREAM* s, BITMAP_DATA* bitmap_data)
+{
+ uint8* srcData;
+ uint16 dstSize;
+ uint16 bytesPerPixel;
+
+ stream_read_uint16(s, bitmap_data->left);
+ stream_read_uint16(s, bitmap_data->top);
+ stream_read_uint16(s, bitmap_data->right);
+ stream_read_uint16(s, bitmap_data->bottom);
+ stream_read_uint16(s, bitmap_data->width);
+ stream_read_uint16(s, bitmap_data->height);
+ stream_read_uint16(s, bitmap_data->bpp);
+ stream_read_uint16(s, bitmap_data->flags);
+ stream_read_uint16(s, bitmap_data->length);
+ stream_get_mark(s, srcData);
+ stream_seek(s, bitmap_data->length);
+
+ bytesPerPixel = (bitmap_data->bpp + 7) / 8;
+ dstSize = bitmap_data->width * bitmap_data->height * bytesPerPixel;
+
+ if (bitmap_data->data != NULL)
+ bitmap_data->data = (uint8*) xrealloc(bitmap_data->data, dstSize);
+ else
+ bitmap_data->data = (uint8*) xmalloc(dstSize);
+
+ /*printf("width:%d height:%d bitsPerPixel:%d bytesPerPixel:%d dstSize:%d\n",
+ bitmap_data->width, bitmap_data->height, bitmap_data->bpp, bytesPerPixel, dstSize);*/
+}
+
+void rdp_recv_bitmap_update(rdpRdp* rdp, STREAM* s)
+{
+ uint16 numberRectangles;
+ BITMAP_DATA bitmap_data;
+
+ bitmap_data.data = NULL;
+ stream_read_uint16(s, numberRectangles); /* numberRectangles (2 bytes) */
+
+ /* rectangles */
+ while (numberRectangles > 0)
+ {
+ rdp_read_bitmap_data(s, &bitmap_data);
+ numberRectangles--;
+ }
+
+ if (bitmap_data.data != NULL)
+ xfree(bitmap_data.data);
+}
+
+void rdp_recv_palette_update(rdpRdp* rdp, STREAM* s)
+{
+ stream_seek_uint16(s); /* pad2Octets (2 bytes) */
+ stream_seek_uint32(s); /* numberColors (4 bytes), must be set to 256 */
+
+ /* paletteEntries */
+}
+
+void rdp_recv_synchronize_update(rdpRdp* rdp, STREAM* s)
+{
+ stream_seek_uint16(s); /* pad2Octets (2 bytes) */
+
+ /**
+ * The Synchronize Update is an artifact from the
+ * T.128 protocol and should be ignored.
+ */
+}
+
+void rdp_recv_update_data_pdu(rdpRdp* rdp, STREAM* s)
+{
+ uint16 updateType;
+
+ stream_read_uint16(s, updateType); /* updateType (2 bytes) */
+
+ printf("%s Update Data PDU\n", UPDATE_TYPE_STRINGS[updateType]);
+
+ switch (updateType)
+ {
+ case UPDATE_TYPE_ORDERS:
+ rdp_recv_orders_update(rdp, s);
+ break;
+
+ case UPDATE_TYPE_BITMAP:
+ rdp_recv_bitmap_update(rdp, s);
+ break;
+
+ case UPDATE_TYPE_PALETTE:
+ rdp_recv_palette_update(rdp, s);
+ break;
+
+ case UPDATE_TYPE_SYNCHRONIZE:
+ rdp_recv_synchronize_update(rdp, s);
+ break;
+ }
+}
+
--- /dev/null
+/**
+ * FreeRDP: A Remote Desktop Protocol Client
+ * Update Data PDUs
+ *
+ * Copyright 2011 Marc-Andre Moreau <marcandre.moreau@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __UPDATE_H
+#define __UPDATE_H
+
+#include "rdp.h"
+#include "orders.h"
+#include <freerdp/types.h>
+#include <freerdp/utils/stream.h>
+
+#define UPDATE_TYPE_ORDERS 0x0000
+#define UPDATE_TYPE_BITMAP 0x0001
+#define UPDATE_TYPE_PALETTE 0x0002
+#define UPDATE_TYPE_SYNCHRONIZE 0x0003
+
+typedef struct
+{
+ uint16 left;
+ uint16 top;
+ uint16 right;
+ uint16 bottom;
+ uint16 width;
+ uint16 height;
+ uint16 bpp;
+ uint16 flags;
+ uint16 length;
+ uint8* data;
+} BITMAP_DATA;
+
+#define BITMAP_COMPRESSION 0x0001
+#define NO_BITMAP_COMPRESSION_HDR 0x0400
+
+void rdp_read_bitmap_data(STREAM* s, BITMAP_DATA* bitmap_data);
+void rdp_recv_bitmap_update(rdpRdp* rdp, STREAM* s);
+void rdp_recv_update_data_pdu(rdpRdp* rdp, STREAM* s);
+
+#endif /* __UPDATE_H */