Too many changes to list here! just see screenshot: http://img352.imageshack.us/my.php?image=socloseta2.png (not pictured: artifacts due to sometimes-broken handling of window region refreshing)

The graphics, mouse and keyboard are virtually done. Mouse wheel works. Still some bugs in the handling of binary raster operation codes, but less than before. Fixed polyline. Fixed all cursor issues. Fully supports text output. Fixed a resource leak where all clipping region were slowly leaked. Now closes cleanly on server disconnect

Moving on to more fun things!

Many thanks to filip & WaxDragon for the code of the previous Win32 port, it was misleading at times but very useful overall!

svn path=/trunk/; revision=23196
This commit is contained in:
Michele Cicciotti 2006-07-20 17:11:00 +00:00
parent 40a3a52a7b
commit 82aa6e1250
11 changed files with 868 additions and 165 deletions

View file

@ -61,7 +61,7 @@
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="kernel32.lib user32.lib gdi32.lib ws2_32.lib libeay32.lib advapi32.lib $(NoInherit)"
AdditionalDependencies="kernel32.lib user32.lib gdi32.lib ws2_32.lib libeay32.lib advapi32.lib msimg32.lib $(NoInherit)"
LinkIncremental="2"
AdditionalLibraryDirectories="&quot;C:\Documents and Settings\All Users\Documenti\openssl-0.9.8b\out32&quot;"
GenerateDebugInformation="true"
@ -137,7 +137,7 @@
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="kernel32.lib user32.lib gdi32.lib ws2_32.lib libeay32.lib advapi32.lib $(NoInherit)"
AdditionalDependencies="kernel32.lib user32.lib gdi32.lib ws2_32.lib libeay32.lib advapi32.lib msimg32.lib $(NoInherit)"
LinkIncremental="1"
AdditionalLibraryDirectories="&quot;C:\Documents and Settings\All Users\Documenti\openssl-0.9.8b\out32&quot;"
GenerateDebugInformation="true"

View file

@ -1,5 +1,10 @@
#pragma once
#define _CRT_SECURE_NO_DEPRECATE
#define _SCL_SECURE 0
#include <new>
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>

View file

@ -23,7 +23,7 @@
/* comment out #define BITMAP_SPEED_OVER_SIZE below for one slower function */
/* j@american-data.com */
#define BITMAP_SPEED_OVER_SIZE
//#define BITMAP_SPEED_OVER_SIZE
/* indent is confused by this file */
/* *INDENT-OFF* */
@ -73,14 +73,22 @@ static BOOL
bitmap_decompress1(uint8 * output, int width, int height, uint8 * input, int size)
{
uint8 *end = input + size;
uint8 *prevline = NULL, *line = NULL;
int opcode, count, offset, isfillormix, x = width;
uint8 *prevline = NULL;
int opcode, count, offset, isfillormix;
int lastopcode = -1, insertmix = False, bicolour = False;
uint8 code;
uint8 colour1 = 0, colour2 = 0;
uint8 mixmask, mask = 0;
uint8 mix = 0xff;
int fom_mask = 0;
#if 0
uint8 *line = NULL;
int x = width;
#else
uint8 *line = output;
int x = 0;
int y = 0;
#endif
while (input < end)
{
@ -167,12 +175,27 @@ bitmap_decompress1(uint8 * output, int width, int height, uint8 * input, int siz
{
if (x >= width)
{
#if 0
if (height <= 0)
#else
if (y >= height)
#endif
return False;
x = 0;
#if 0
height--;
#else
y ++;
#endif
prevline = line;
#if 0
line = output + height * width;
#else
line = output + y * width;
#endif
}
switch (opcode)
{
@ -271,14 +294,22 @@ static BOOL
bitmap_decompress2(uint8 * output, int width, int height, uint8 * input, int size)
{
uint8 *end = input + size;
uint16 *prevline = NULL, *line = NULL;
int opcode, count, offset, isfillormix, x = width;
uint16 *prevline = NULL;
int opcode, count, offset, isfillormix;
int lastopcode = -1, insertmix = False, bicolour = False;
uint8 code;
uint16 colour1 = 0, colour2 = 0;
uint8 mixmask, mask = 0;
uint16 mix = 0xffff;
int fom_mask = 0;
#if 0
uint8 *line = NULL;
int x = width;
#else
uint8 *line = output;
int x = 0;
int y = 0;
#endif
while (input < end)
{
@ -365,12 +396,27 @@ bitmap_decompress2(uint8 * output, int width, int height, uint8 * input, int siz
{
if (x >= width)
{
#if 0
if (height <= 0)
#else
if (y >= height)
#endif
return False;
x = 0;
#if 0
height--;
#else
y ++;
#endif
prevline = line;
#if 0
line = ((uint16 *) output) + height * width;
#else
line = ((uint16 *) output) + y * width;
#endif
}
switch (opcode)
{
@ -470,14 +516,22 @@ static BOOL
bitmap_decompress3(uint8 * output, int width, int height, uint8 * input, int size)
{
uint8 *end = input + size;
uint8 *prevline = NULL, *line = NULL;
int opcode, count, offset, isfillormix, x = width;
uint8 *prevline = NULL;
int opcode, count, offset, isfillormix;
int lastopcode = -1, insertmix = False, bicolour = False;
uint8 code;
uint8 colour1[3] = {0, 0, 0}, colour2[3] = {0, 0, 0};
uint8 mixmask, mask = 0;
uint8 mix[3] = {0xff, 0xff, 0xff};
int fom_mask = 0;
#if 0
uint8 *line = NULL;
int x = width;
#else
uint8 *line = output;
int x = 0;
int y = 0;
#endif
while (input < end)
{
@ -571,12 +625,27 @@ bitmap_decompress3(uint8 * output, int width, int height, uint8 * input, int siz
{
if (x >= width)
{
#if 0
if (height <= 0)
#else
if (y >= height)
#endif
return False;
x = 0;
#if 0
height--;
#else
y ++;
#endif
prevline = line;
#if 0
line = output + height * (width * 3);
#else
line = output + y * (width * 3);
#endif
}
switch (opcode)
{
@ -782,14 +851,22 @@ static BOOL
bitmap_decompressx(uint8 *output, int width, int height, uint8 *input, int size, int Bpp)
{
uint8 *end = input + size;
uint8 *prevline = NULL, *line = NULL;
int opcode, count, offset, isfillormix, x = width;
uint8 *prevline = NULL;
int opcode, count, offset, isfillormix;
int lastopcode = -1, insertmix = False, bicolour = False;
uint8 code;
uint32 colour1 = 0, colour2 = 0;
uint8 mixmask, mask = 0;
uint32 mix = 0xffffffff;
int fom_mask = 0;
#if 0
uint8 *line = NULL;
int x = width;
#else
uint8 *line = output;
int x = 0;
int y = 0;
#endif
while (input < end)
{
@ -885,14 +962,28 @@ bitmap_decompressx(uint8 *output, int width, int height, uint8 *input, int size,
{
if (x >= width)
{
#if 0
if (height <= 0)
#else
if (y >= height)
#endif
return False;
x = 0;
#if 0
height--;
#else
y ++;
#endif
prevline = line;
#if 0
line = output + height * width * Bpp;
#else
line = output + y * width * Bpp;
#endif
}
switch (opcode)

View file

@ -188,7 +188,11 @@ process_destblt(RDPCLIENT * This, STREAM s, DESTBLT_ORDER * os, uint32 present,
DEBUG(("DESTBLT(op=0x%x,x=%d,y=%d,cx=%d,cy=%d)\n",
os->opcode, os->x, os->y, os->cx, os->cy));
#if 0
ui_destblt(This, ROP2_S(os->opcode), os->x, os->y, os->cx, os->cy);
#else
ui_destblt(This, os->opcode, os->x, os->y, os->cx, os->cy);
#endif
}
/* Process a pattern blt order */
@ -221,8 +225,13 @@ process_patblt(RDPCLIENT * This, STREAM s, PATBLT_ORDER * os, uint32 present, BO
DEBUG(("PATBLT(op=0x%x,x=%d,y=%d,cx=%d,cy=%d,bs=%d,bg=0x%x,fg=0x%x)\n", os->opcode, os->x,
os->y, os->cx, os->cy, os->brush.style, os->bgcolour, os->fgcolour));
#if 0
ui_patblt(This, ROP2_P(os->opcode), os->x, os->y, os->cx, os->cy,
&os->brush, os->bgcolour, os->fgcolour);
#else
ui_patblt(This, os->opcode, os->x, os->y, os->cx, os->cy,
&os->brush, os->bgcolour, os->fgcolour);
#endif
}
/* Process a screen blt order */
@ -253,7 +262,11 @@ process_screenblt(RDPCLIENT * This, STREAM s, SCREENBLT_ORDER * os, uint32 prese
DEBUG(("SCREENBLT(op=0x%x,x=%d,y=%d,cx=%d,cy=%d,srcx=%d,srcy=%d)\n",
os->opcode, os->x, os->y, os->cx, os->cy, os->srcx, os->srcy));
#if 0
ui_screenblt(This, ROP2_S(os->opcode), os->x, os->y, os->cx, os->cy, os->srcx, os->srcy);
#else
ui_screenblt(This, os->opcode, os->x, os->y, os->cx, os->cy, os->srcx, os->srcy);
#endif
}
/* Process a line order */
@ -292,7 +305,11 @@ process_line(RDPCLIENT * This, STREAM s, LINE_ORDER * os, uint32 present, BOOL d
return;
}
#if 0
ui_line(This, os->opcode - 1, os->startx, os->starty, os->endx, os->endy, &os->pen);
#else
ui_line(This, os->opcode, os->startx, os->starty, os->endx, os->endy, &os->pen);
#endif
}
/* Process an opaque rectangle order */
@ -414,7 +431,11 @@ process_memblt(RDPCLIENT * This, STREAM s, MEMBLT_ORDER * os, uint32 present, BO
if (bitmap == NULL)
return;
#if 0
ui_memblt(This, ROP2_S(os->opcode), os->x, os->y, os->cx, os->cy, bitmap, os->srcx, os->srcy);
#else
ui_memblt(This, os->opcode, os->x, os->y, os->cx, os->cy, bitmap, os->srcx, os->srcy);
#endif
}
/* Process a 3-way blt order */
@ -547,8 +568,13 @@ process_polygon(RDPCLIENT * This, STREAM s, POLYGON_ORDER * os, uint32 present,
}
if (next - 1 == os->npoints)
#if 0
ui_polygon(This, os->opcode - 1, os->fillmode, points, os->npoints + 1, NULL, 0,
os->fgcolour);
#else
ui_polygon(This, os->opcode, os->fillmode, points, os->npoints + 1, NULL, 0,
os->fgcolour);
#endif
else
error("polygon parse error\n");
@ -632,8 +658,13 @@ process_polygon2(RDPCLIENT * This, STREAM s, POLYGON2_ORDER * os, uint32 present
}
if (next - 1 == os->npoints)
#if 0
ui_polygon(This, os->opcode - 1, os->fillmode, points, os->npoints + 1,
&os->brush, os->bgcolour, os->fgcolour);
#else
ui_polygon(This, os->opcode, os->fillmode, points, os->npoints + 1,
&os->brush, os->bgcolour, os->fgcolour);
#endif
else
error("polygon2 parse error\n");
@ -711,7 +742,11 @@ process_polyline(RDPCLIENT * This, STREAM s, POLYLINE_ORDER * os, uint32 present
}
if (next - 1 == os->lines)
#if 0
ui_polyline(This, os->opcode - 1, points, os->lines + 1, &pen);
#else
ui_polyline(This, os->opcode, points, os->lines + 1, &pen);
#endif
else
error("polyline parse error\n");
@ -746,8 +781,13 @@ process_ellipse(RDPCLIENT * This, STREAM s, ELLIPSE_ORDER * os, uint32 present,
DEBUG(("ELLIPSE(l=%d,t=%d,r=%d,b=%d,op=0x%x,fm=%d,fg=0x%x)\n", os->left, os->top,
os->right, os->bottom, os->opcode, os->fillmode, os->fgcolour));
#if 0
ui_ellipse(This, os->opcode - 1, os->fillmode, os->left, os->top, os->right - os->left,
os->bottom - os->top, NULL, 0, os->fgcolour);
#else
ui_ellipse(This, os->opcode, os->fillmode, os->left, os->top, os->right - os->left,
os->bottom - os->top, NULL, 0, os->fgcolour);
#endif
}
/* Process an ellipse2 order */
@ -784,8 +824,13 @@ process_ellipse2(RDPCLIENT * This, STREAM s, ELLIPSE2_ORDER * os, uint32 present
os->left, os->top, os->right, os->bottom, os->opcode, os->fillmode, os->brush.style,
os->bgcolour, os->fgcolour));
#if 0
ui_ellipse(This, os->opcode - 1, os->fillmode, os->left, os->top, os->right - os->left,
os->bottom - os->top, &os->brush, os->bgcolour, os->fgcolour);
#else
ui_ellipse(This, os->opcode, os->fillmode, os->left, os->top, os->right - os->left,
os->bottom - os->top, &os->brush, os->bgcolour, os->fgcolour);
#endif
}
/* Process a text order */
@ -859,11 +904,19 @@ process_text2(RDPCLIENT * This, STREAM s, TEXT2_ORDER * os, uint32 present, BOOL
DEBUG(("\n"));
#if 0
ui_draw_text(This, os->font, os->flags, os->opcode - 1, os->mixmode, os->x, os->y,
os->clipleft, os->cliptop, os->clipright - os->clipleft,
os->clipbottom - os->cliptop, os->boxleft, os->boxtop,
os->boxright - os->boxleft, os->boxbottom - os->boxtop,
&os->brush, os->bgcolour, os->fgcolour, os->text, os->length);
#else
ui_draw_text(This, os->font, os->flags, os->opcode, os->mixmode, os->x, os->y,
os->clipleft, os->cliptop, os->clipright - os->clipleft,
os->clipbottom - os->cliptop, os->boxleft, os->boxtop,
os->boxright - os->boxleft, os->boxbottom - os->boxtop,
&os->brush, os->bgcolour, os->fgcolour, os->text, os->length);
#endif
}
/* Process a raw bitmap cache order */
@ -887,15 +940,22 @@ process_raw_bmpcache(RDPCLIENT * This, STREAM s)
in_uint8p(s, data, bufsize);
DEBUG(("RAW_BMPCACHE(cx=%d,cy=%d,id=%d,idx=%d)\n", width, height, cache_id, cache_idx));
#if 0
inverted = (uint8 *) xmalloc(width * height * Bpp);
for (y = 0; y < height; y++)
{
memcpy(&inverted[(height - y - 1) * (width * Bpp)], &data[y * (width * Bpp)],
width * Bpp);
}
#endif
#if 0
bitmap = ui_create_bitmap(This, width, height, inverted);
xfree(inverted);
#else
bitmap = ui_create_bitmap(This, width, height, data);
#endif
cache_put_bitmap(This, cache_id, cache_idx, bitmap);
}
@ -1000,10 +1060,10 @@ process_bmpcache2(RDPCLIENT * This, STREAM s, uint16 flags, BOOL compressed)
DEBUG(("BMPCACHE2(compr=%d,flags=%x,cx=%d,cy=%d,id=%d,idx=%d,Bpp=%d,bs=%d)\n",
compressed, flags, width, height, cache_id, cache_idx, Bpp, bufsize));
bmpdata = (uint8 *) xmalloc(width * height * Bpp);
if (compressed)
{
bmpdata = (uint8 *) xmalloc(width * height * Bpp);
if (!bitmap_decompress(bmpdata, width, height, data, bufsize, Bpp))
{
DEBUG(("Failed to decompress bitmap data\n"));
@ -1013,9 +1073,13 @@ process_bmpcache2(RDPCLIENT * This, STREAM s, uint16 flags, BOOL compressed)
}
else
{
#if 0
for (y = 0; y < height; y++)
memcpy(&bmpdata[(height - y - 1) * (width * Bpp)],
&data[y * (width * Bpp)], width * Bpp);
#else
bmpdata = data;
#endif
}
bitmap = ui_create_bitmap(This, width, height, bmpdata);
@ -1032,7 +1096,8 @@ process_bmpcache2(RDPCLIENT * This, STREAM s, uint16 flags, BOOL compressed)
DEBUG(("process_bmpcache2: ui_create_bitmap failed\n"));
}
xfree(bmpdata);
if (compressed)
xfree(bmpdata);
}
/* Process a colourmap cache order */

View file

@ -110,9 +110,9 @@ BOOL pstcache_init(RDPCLIENT * This, uint8 cache_id);
/* rdesktop.c */
int main(int argc, char *argv[]);
void generate_random(uint8 * random);
void *xmalloc(int size);
void *xmalloc(size_t size);
char *xstrdup(const char *s);
void *xrealloc(void *oldmem, int size);
void *xrealloc(void *oldmem, size_t size);
void xfree(void *mem);
void error(char *format, ...);
void warning(char *format, ...);

View file

@ -39,7 +39,7 @@
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="&quot;C:\Documents and Settings\All Users\Documenti\openssl-0.9.8b\inc32&quot;"
PreprocessorDefinitions="WIN32;_DEBUG;_LIB;WITH_DEBUG;"
PreprocessorDefinitions="WIN32;_DEBUG;_LIB;_CRT_SECURE_NO_DEPRECATE;"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="3"
@ -100,7 +100,7 @@
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories="&quot;C:\Documents and Settings\All Users\Documenti\openssl-0.9.8b\inc32&quot;"
PreprocessorDefinitions="WIN32;NDEBUG;_LIB;"
PreprocessorDefinitions="WIN32;NDEBUG;_LIB;_CRT_SECURE_NO_DEPRECATE"
RuntimeLibrary="2"
UsePrecompiledHeader="0"
WarningLevel="3"

View file

@ -311,6 +311,7 @@ struct rdpclient
/* rdp.c */
struct rdp_
{
int ignore_;
#if WITH_DEBUG
uint32 packetno;
#endif

View file

@ -968,7 +968,7 @@ process_colour_pointer_pdu(RDPCLIENT * This, STREAM s)
in_uint8p(s, mask, masklen);
cursor = ui_create_cursor(This, x, y, width, height, mask, data);
ui_set_cursor(This, cursor);
// cache_put_cursor(This, cache_idx, cursor); // TODO
cache_put_cursor(This, cache_idx, cursor);
}
/* Process a cached pointer PDU */
@ -978,7 +978,7 @@ process_cached_pointer_pdu(RDPCLIENT * This, STREAM s)
uint16 cache_idx;
in_uint16_le(s, cache_idx);
ui_set_cursor(This, /*cache_get_cursor(This, cache_idx)*/ NULL); // TODO
ui_set_cursor(This, cache_get_cursor(This, cache_idx));
}
/* Process a system pointer PDU */
@ -1068,6 +1068,7 @@ process_bitmap_updates(RDPCLIENT * This, STREAM s)
if (!compress)
{
#if 0
int y;
bmpdata = (uint8 *) xmalloc(width * height * Bpp);
for (y = 0; y < height; y++)
@ -1077,6 +1078,10 @@ process_bitmap_updates(RDPCLIENT * This, STREAM s)
}
ui_paint_bitmap(This, left, top, cx, cy, width, height, bmpdata);
xfree(bmpdata);
#else
in_uint8p(s, bmpdata, width * height * Bpp);
ui_paint_bitmap(This, left, top, cx, cy, width, height, bmpdata);
#endif
continue;
}

View file

@ -333,8 +333,8 @@ sec_send_to_channel(RDPCLIENT * This, STREAM s, uint32 flags, uint16 channel)
datalen = s->end - s->p - 8;
#if WITH_DEBUG
DEBUG(("Sending encrypted packet:\n"));
hexdump(s->p + 8, datalen);
//DEBUG(("Sending encrypted packet:\n"));
//hexdump(s->p + 8, datalen);
#endif
sec_sign(s->p, 8, This->secure.sign_key, This->secure.rc4_key_len, s->p + 8, datalen);

View file

@ -92,7 +92,6 @@ typedef struct _PEN
}
PEN;
// TODO: nuke, use LOGBRUSH + pattern[8]
typedef struct _BRUSH
{
uint8 xorigin;