diff --git a/rdp/rdp_orders.c b/rdp/rdp_orders.c index 88f34fa6..2c5e8987 100644 --- a/rdp/rdp_orders.c +++ b/rdp/rdp_orders.c @@ -213,10 +213,9 @@ rdp_orders_process_raw_bmpcache(struct rdp_orders* self, struct stream* s, int height; int bpp; int Bpp; + int x; int y; - char* data; char* inverted; - char* src; char* dst; struct rdp_bitmap* bitmap; struct stream* rec_s; @@ -229,13 +228,24 @@ rdp_orders_process_raw_bmpcache(struct rdp_orders* self, struct stream* s, Bpp = (bpp + 7) / 8; in_uint16_le(s, bufsize); in_uint16_le(s, cache_idx); - in_uint8p(s, data, bufsize); inverted = (char*)g_malloc(width * height * Bpp, 0); for (y = 0; y < height; y++) { - src = data + (y * (width * Bpp)); dst = inverted + (((height - y) - 1) * (width * Bpp)); - g_memcpy(dst, src, width * Bpp); + if (Bpp == 1) + { + for (x = 0; x < width; x++) + { + in_uint8(s, dst[x]); + } + } + else if (Bpp == 2) + { + for (x = 0; x < width; x++) + { + in_uint16_le(s, ((unsigned short*)dst)[x]); + } + } } bitmap = (struct rdp_bitmap*)g_malloc(sizeof(struct rdp_bitmap), 0); bitmap->width = width; diff --git a/rdp/rdp_rdp.c b/rdp/rdp_rdp.c index 2b1c6791..00b8fa57 100644 --- a/rdp/rdp_rdp.c +++ b/rdp/rdp_rdp.c @@ -505,6 +505,7 @@ rdp_rdp_process_bitmap_updates(struct rdp_rdp* self, struct stream* s) int bufsize; int size; int i; + int x; int y; char* data; char* bmpdata0; @@ -546,12 +547,25 @@ rdp_rdp_process_bitmap_updates(struct rdp_rdp* self, struct stream* s) self->mod->server_paint_rect(self->mod, left, top, cx, cy, bmpdata1, width, height, 0, 0); } - else + else /* not compressed */ { for (y = 0; y < height; y++) { data = bmpdata0 + ((height - y) - 1) * (width * Bpp); - in_uint8a(s, data, width * Bpp); + if (Bpp == 1) + { + for (x = 0; x < width; x++) + { + in_uint8(s, data[x]); + } + } + else if (Bpp == 2) + { + for (x = 0; x < width; x++) + { + in_uint16_le(s, ((unsigned short*)data)[x]); + } + } } bmpdata1 = rdp_orders_convert_bitmap(bpp, self->mod->xrdp_bpp, bmpdata0, width, height,