diff --git a/reactos/base/applications/tsclient/MissTosca.sln b/reactos/base/applications/tsclient/MissTosca.sln
new file mode 100644
index 00000000000..7c035a066dd
--- /dev/null
+++ b/reactos/base/applications/tsclient/MissTosca.sln
@@ -0,0 +1,38 @@
+
+Microsoft Visual Studio Solution File, Format Version 9.00
+# Visual C++ Express 2005
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "rdesktop-core", "rdesktop\rdesktop-core.vcproj", "{8620E9B2-9AF0-4F69-A5AF-C195D5F86372}"
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mstsc", "mstsc\mstsc.vcproj", "{1B415732-1F37-415F-957B-EA436301860D}"
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mstscax", "mstscax\mstscax.vcproj", "{2C217E9E-9D77-4D6A-9259-216FD56BA56F}"
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "rdesktop-core-tester", "porting-tools\rdesktop-core-tester\rdesktop-core-tester.vcproj", "{B172A623-E2BD-4E3F-86E6-620548FE255B}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Win32 = Debug|Win32
+ Release|Win32 = Release|Win32
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {8620E9B2-9AF0-4F69-A5AF-C195D5F86372}.Debug|Win32.ActiveCfg = Debug|Win32
+ {8620E9B2-9AF0-4F69-A5AF-C195D5F86372}.Debug|Win32.Build.0 = Debug|Win32
+ {8620E9B2-9AF0-4F69-A5AF-C195D5F86372}.Release|Win32.ActiveCfg = Release|Win32
+ {8620E9B2-9AF0-4F69-A5AF-C195D5F86372}.Release|Win32.Build.0 = Release|Win32
+ {1B415732-1F37-415F-957B-EA436301860D}.Debug|Win32.ActiveCfg = Debug|Win32
+ {1B415732-1F37-415F-957B-EA436301860D}.Debug|Win32.Build.0 = Debug|Win32
+ {1B415732-1F37-415F-957B-EA436301860D}.Release|Win32.ActiveCfg = Release|Win32
+ {1B415732-1F37-415F-957B-EA436301860D}.Release|Win32.Build.0 = Release|Win32
+ {2C217E9E-9D77-4D6A-9259-216FD56BA56F}.Debug|Win32.ActiveCfg = Debug|Win32
+ {2C217E9E-9D77-4D6A-9259-216FD56BA56F}.Debug|Win32.Build.0 = Debug|Win32
+ {2C217E9E-9D77-4D6A-9259-216FD56BA56F}.Release|Win32.ActiveCfg = Release|Win32
+ {2C217E9E-9D77-4D6A-9259-216FD56BA56F}.Release|Win32.Build.0 = Release|Win32
+ {B172A623-E2BD-4E3F-86E6-620548FE255B}.Debug|Win32.ActiveCfg = Debug|Win32
+ {B172A623-E2BD-4E3F-86E6-620548FE255B}.Debug|Win32.Build.0 = Debug|Win32
+ {B172A623-E2BD-4E3F-86E6-620548FE255B}.Release|Win32.ActiveCfg = Release|Win32
+ {B172A623-E2BD-4E3F-86E6-620548FE255B}.Release|Win32.Build.0 = Release|Win32
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+EndGlobal
diff --git a/reactos/base/applications/tsclient/mstsc/mstsc.cpp b/reactos/base/applications/tsclient/mstsc/mstsc.cpp
new file mode 100644
index 00000000000..91806ac5f3b
--- /dev/null
+++ b/reactos/base/applications/tsclient/mstsc/mstsc.cpp
@@ -0,0 +1,7 @@
+#include "stdafx.h"
+
+int _tmain(int argc, _TCHAR* argv[])
+{
+ return 0;
+}
+
diff --git a/reactos/base/applications/tsclient/mstsc/mstsc.vcproj b/reactos/base/applications/tsclient/mstsc/mstsc.vcproj
new file mode 100644
index 00000000000..a6d58a9cc1c
--- /dev/null
+++ b/reactos/base/applications/tsclient/mstsc/mstsc.vcproj
@@ -0,0 +1,223 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/reactos/base/applications/tsclient/mstsc/stdafx.cpp b/reactos/base/applications/tsclient/mstsc/stdafx.cpp
new file mode 100644
index 00000000000..cc6f8043102
--- /dev/null
+++ b/reactos/base/applications/tsclient/mstsc/stdafx.cpp
@@ -0,0 +1,8 @@
+// stdafx.cpp : source file that includes just the standard includes
+// mstsc.pch will be the pre-compiled header
+// stdafx.obj will contain the pre-compiled type information
+
+#include "stdafx.h"
+
+// TODO: reference any additional headers you need in STDAFX.H
+// and not in this file
diff --git a/reactos/base/applications/tsclient/mstsc/stdafx.h b/reactos/base/applications/tsclient/mstsc/stdafx.h
new file mode 100644
index 00000000000..83cd4a71993
--- /dev/null
+++ b/reactos/base/applications/tsclient/mstsc/stdafx.h
@@ -0,0 +1,15 @@
+// stdafx.h : include file for standard system include files,
+// or project specific include files that are used frequently, but
+// are changed infrequently
+//
+
+#pragma once
+
+
+#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
+#include
+#include
+
+
+
+// TODO: reference additional headers your program requires here
diff --git a/reactos/base/applications/tsclient/mstscax/mstscax.cpp b/reactos/base/applications/tsclient/mstscax/mstscax.cpp
new file mode 100644
index 00000000000..91806ac5f3b
--- /dev/null
+++ b/reactos/base/applications/tsclient/mstscax/mstscax.cpp
@@ -0,0 +1,7 @@
+#include "stdafx.h"
+
+int _tmain(int argc, _TCHAR* argv[])
+{
+ return 0;
+}
+
diff --git a/reactos/base/applications/tsclient/mstscax/mstscax.vcproj b/reactos/base/applications/tsclient/mstscax/mstscax.vcproj
new file mode 100644
index 00000000000..7b3b3b0144f
--- /dev/null
+++ b/reactos/base/applications/tsclient/mstscax/mstscax.vcproj
@@ -0,0 +1,223 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/reactos/base/applications/tsclient/mstscax/stdafx.cpp b/reactos/base/applications/tsclient/mstscax/stdafx.cpp
new file mode 100644
index 00000000000..166b44effc9
--- /dev/null
+++ b/reactos/base/applications/tsclient/mstscax/stdafx.cpp
@@ -0,0 +1,8 @@
+// stdafx.cpp : source file that includes just the standard includes
+// mstscax.pch will be the pre-compiled header
+// stdafx.obj will contain the pre-compiled type information
+
+#include "stdafx.h"
+
+// TODO: reference any additional headers you need in STDAFX.H
+// and not in this file
diff --git a/reactos/base/applications/tsclient/mstscax/stdafx.h b/reactos/base/applications/tsclient/mstscax/stdafx.h
new file mode 100644
index 00000000000..83cd4a71993
--- /dev/null
+++ b/reactos/base/applications/tsclient/mstscax/stdafx.h
@@ -0,0 +1,15 @@
+// stdafx.h : include file for standard system include files,
+// or project specific include files that are used frequently, but
+// are changed infrequently
+//
+
+#pragma once
+
+
+#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
+#include
+#include
+
+
+
+// TODO: reference additional headers your program requires here
diff --git a/reactos/base/applications/tsclient/porting-tools/rdesktop-core-tester/rdesktop-core-tester.cpp b/reactos/base/applications/tsclient/porting-tools/rdesktop-core-tester/rdesktop-core-tester.cpp
new file mode 100644
index 00000000000..a75b8009a19
--- /dev/null
+++ b/reactos/base/applications/tsclient/porting-tools/rdesktop-core-tester/rdesktop-core-tester.cpp
@@ -0,0 +1,998 @@
+#include "stdafx.h"
+
+#include "rdesktop/rdesktop.h"
+#include "rdesktop/proto.h"
+
+extern "C"
+{
+ /* ==== BEGIN POOP ==== */
+ // Temporary implementations of stuff we totally positively need to make the Real Thing happy
+ /* produce a hex dump */
+ void
+ hexdump(unsigned char *p, unsigned int len)
+ {
+ unsigned char *line = p;
+ int i, thisline;
+ unsigned int offset = 0;
+
+ while (offset < len)
+ {
+ printf("%04x ", offset);
+ thisline = len - offset;
+ if (thisline > 16)
+ thisline = 16;
+
+ for (i = 0; i < thisline; i++)
+ printf("%02x ", line[i]);
+
+ for (; i < 16; i++)
+ printf(" ");
+
+ for (i = 0; i < thisline; i++)
+ printf("%c", (line[i] >= 0x20 && line[i] < 0x7f) ? line[i] : '.');
+
+ printf("\n");
+ offset += thisline;
+ line += thisline;
+ }
+ }
+
+ void generate_random(uint8 * random)
+ {
+ memcpy(random, "12345678901234567890123456789012", 32);
+ }
+
+ /* report an error */
+ void
+ error(char *format, ...)
+ {
+ va_list ap;
+
+ fprintf(stderr, "ERROR: ");
+
+ va_start(ap, format);
+ vfprintf(stderr, format, ap);
+ va_end(ap);
+ }
+
+ /* report a warning */
+ void
+ warning(char *format, ...)
+ {
+ va_list ap;
+
+ fprintf(stderr, "WARNING: ");
+
+ va_start(ap, format);
+ vfprintf(stderr, format, ap);
+ va_end(ap);
+ }
+
+ /* report an unimplemented protocol feature */
+ void
+ unimpl(char *format, ...)
+ {
+ va_list ap;
+
+ fprintf(stderr, "NOT IMPLEMENTED: ");
+
+ va_start(ap, format);
+ vfprintf(stderr, format, ap);
+ va_end(ap);
+ }
+
+ /* malloc; exit if out of memory */
+ void *
+ xmalloc(int size)
+ {
+ void *mem = malloc(size);
+ if (mem == NULL)
+ {
+ error("xmalloc %d\n", size);
+ exit(1);
+ }
+ return mem;
+ }
+
+ /* strdup */
+ char *
+ xstrdup(const char *s)
+ {
+ char *mem = strdup(s);
+ if (mem == NULL)
+ {
+ perror("strdup");
+ exit(1);
+ }
+ return mem;
+ }
+
+ /* realloc; exit if out of memory */
+ void *
+ xrealloc(void *oldmem, int size)
+ {
+ void *mem;
+
+ if (size < 1)
+ size = 1;
+ mem = realloc(oldmem, size);
+ if (mem == NULL)
+ {
+ error("xrealloc %d\n", size);
+ exit(1);
+ }
+ return mem;
+ }
+
+ /* free */
+ void
+ xfree(void *mem)
+ {
+ free(mem);
+ }
+
+ /* Create the bitmap cache directory */
+ BOOL
+ rd_pstcache_mkdir(void)
+ {
+ char *home;
+ char bmpcache_dir[256];
+
+ home = getenv("HOME");
+
+ if (home == NULL)
+ return False;
+
+ sprintf(bmpcache_dir, "%s/%s", home, ".rdesktop");
+
+ if ((_mkdir(bmpcache_dir) == -1) && errno != EEXIST)
+ {
+ perror(bmpcache_dir);
+ return False;
+ }
+
+ sprintf(bmpcache_dir, "%s/%s", home, ".rdesktop/cache");
+
+ if ((_mkdir(bmpcache_dir) == -1) && errno != EEXIST)
+ {
+ perror(bmpcache_dir);
+ return False;
+ }
+
+ return True;
+ }
+
+ /* open a file in the .rdesktop directory */
+ int
+ rd_open_file(char *filename)
+ {
+ char *home;
+ char fn[256];
+ int fd;
+
+ home = getenv("HOME");
+ if (home == NULL)
+ return -1;
+ sprintf(fn, "%s/.rdesktop/%s", home, filename);
+ fd = _open(fn, _O_RDWR | _O_CREAT, 0);
+ if (fd == -1)
+ perror(fn);
+ return fd;
+ }
+
+ /* close file */
+ void
+ rd_close_file(int fd)
+ {
+ _close(fd);
+ }
+
+ /* read from file*/
+ int
+ rd_read_file(int fd, void *ptr, int len)
+ {
+ return _read(fd, ptr, len);
+ }
+
+ /* write to file */
+ int
+ rd_write_file(int fd, void *ptr, int len)
+ {
+ return _write(fd, ptr, len);
+ }
+
+ /* move file pointer */
+ int
+ rd_lseek_file(int fd, int offset)
+ {
+ return _lseek(fd, offset, SEEK_SET);
+ }
+
+ /* do a write lock on a file */
+ BOOL
+ rd_lock_file(int fd, int start, int len)
+ {
+ // TODOOO...
+ return False;
+ }
+
+ int
+ load_licence(RDPCLIENT * This, unsigned char **data)
+ {
+ char *home, *path;
+ struct stat st;
+ int fd, length;
+
+ home = getenv("HOME");
+ if (home == NULL)
+ return -1;
+
+ path = (char *) xmalloc(strlen(home) + strlen(This->hostname) + sizeof("/.rdesktop/licence."));
+ sprintf(path, "%s/.rdesktop/licence.%s", home, This->hostname);
+
+ fd = _open(path, O_RDONLY);
+ if (fd == -1)
+ return -1;
+
+ if (fstat(fd, &st))
+ return -1;
+
+ *data = (uint8 *) xmalloc(st.st_size);
+ length = _read(fd, *data, st.st_size);
+ _close(fd);
+ xfree(path);
+ return length;
+ }
+
+ void
+ save_licence(RDPCLIENT * This, unsigned char *data, int length)
+ {
+ char *home, *path, *tmppath;
+ int fd;
+
+ home = getenv("HOME");
+ if (home == NULL)
+ return;
+
+ path = (char *) xmalloc(strlen(home) + strlen(This->hostname) + sizeof("/.rdesktop/licence."));
+
+ sprintf(path, "%s/.rdesktop", home);
+ if ((_mkdir(path) == -1) && errno != EEXIST)
+ {
+ perror(path);
+ return;
+ }
+
+ /* write licence to licence.hostname.new, then atomically rename to licence.hostname */
+
+ sprintf(path, "%s/.rdesktop/licence.%s", home, This->hostname);
+ tmppath = (char *) xmalloc(strlen(path) + sizeof(".new"));
+ strcpy(tmppath, path);
+ strcat(tmppath, ".new");
+
+ fd = _open(tmppath, O_WRONLY | O_CREAT | O_TRUNC, 0600);
+ if (fd == -1)
+ {
+ perror(tmppath);
+ return;
+ }
+
+ if (_write(fd, data, length) != length)
+ {
+ perror(tmppath);
+ _unlink(tmppath);
+ }
+ else if (rename(tmppath, path) == -1)
+ {
+ perror(path);
+ _unlink(tmppath);
+ }
+
+ _close(fd);
+ xfree(tmppath);
+ xfree(path);
+ }
+
+ /* ==== END POOP ==== */
+
+ /* ==== UI ==== */
+ // Globals are totally teh evil, but cut me some slack here
+ HWND hwnd;
+ HBITMAP hbmBuffer;
+ HDC hdcBuffer;
+
+#if 0
+ // NOTE: we don't really need these with rdesktop.c out of the picture
+ BOOL
+ ui_init(RDPCLIENT * This)
+ {
+ return 0;
+ }
+
+ void
+ ui_deinit(RDPCLIENT * This)
+ {
+ }
+
+ BOOL
+ ui_create_window(RDPCLIENT * This)
+ {
+ return 0;
+ }
+#endif
+
+ void
+ ui_resize_window(RDPCLIENT * This)
+ {
+ // TODO
+ }
+
+#if 0
+ void
+ ui_destroy_window(RDPCLIENT * This)
+ {
+ }
+#endif
+
+ int
+ ui_select(RDPCLIENT * This, int rdp_socket)
+ {
+ return 1; // TODO: return 0 for user quit. Or just kill this silly function
+ }
+
+ void
+ ui_move_pointer(RDPCLIENT * This, int x, int y)
+ {
+ // TODO
+ }
+
+ HBITMAP
+ ui_create_bitmap(RDPCLIENT * This, int width, int height, uint8 * data)
+ {
+ void * pBits;
+
+ BITMAPINFOHEADER bmih;
+ BITMAPINFO bmi;
+
+ bmih.biSize = sizeof(bmih);
+ bmih.biWidth = width;
+ bmih.biHeight = - height;
+ bmih.biPlanes = 1;
+ bmih.biBitCount = This->server_depth;
+ bmih.biCompression = BI_RGB;
+ bmih.biSizeImage = 0;
+ bmih.biXPelsPerMeter = 0;
+ bmih.biYPelsPerMeter = 0;
+ bmih.biClrUsed = 0;
+ bmih.biClrImportant = 0;
+
+ bmi.bmiHeader = bmih;
+ memset(bmi.bmiColors, 0, sizeof(bmi.bmiColors));
+
+ return CreateDIBitmap(hdcBuffer, &bmih, CBM_INIT, data, &bmi, DIB_RGB_COLORS);
+ }
+
+ void
+ ui_destroy_bitmap(RDPCLIENT * This, HBITMAP bmp)
+ {
+ DeleteObject(bmp);
+ }
+
+ HGLYPH
+ ui_create_glyph(RDPCLIENT * This, int width, int height, const uint8 * data)
+ {
+ // TODO: create 2bpp mask
+ return 0;
+ }
+
+ void
+ ui_destroy_glyph(RDPCLIENT * This, HGLYPH glyph)
+ {
+ // TODO
+ }
+
+ HCURSOR
+ ui_create_cursor(RDPCLIENT * This, unsigned int x, unsigned int y, int width, int height,
+ uint8 * andmask, uint8 * xormask)
+ {
+ return CreateCursor(NULL, x, y, width, height, andmask, xormask);
+ }
+
+ void
+ ui_set_cursor(RDPCLIENT * This, HCURSOR cursor)
+ {
+ // TODO
+ }
+
+ void
+ ui_destroy_cursor(RDPCLIENT * This, HCURSOR cursor)
+ {
+ DestroyCursor(cursor);
+ }
+
+ void
+ ui_set_null_cursor(RDPCLIENT * This)
+ {
+ // TODO
+ }
+
+ HCOLOURMAP
+ ui_create_colourmap(RDPCLIENT * This, COLOURMAP * colours)
+ {
+ // TODO: kill HCOLOURMAP/COLOURMAP, use HPALETTE/LOGPALETTE
+ return 0;
+ }
+
+ void
+ ui_destroy_colourmap(RDPCLIENT * This, HCOLOURMAP map)
+ {
+ // TODO: see above
+ }
+
+ void
+ ui_set_colourmap(RDPCLIENT * This, HCOLOURMAP map)
+ {
+ // TODO
+ }
+
+ RECT rcClip; // TODO: initialize
+
+ void
+ ui_set_clip(RDPCLIENT * This, int x, int y, int cx, int cy)
+ {
+ rcClip.left = x;
+ rcClip.top = y;
+ rcClip.right = x + cx - 1;
+ rcClip.bottom = y + cy - 1;
+ SelectObject(hdcBuffer, CreateRectRgnIndirect(&rcClip));
+ }
+
+ void
+ ui_reset_clip(RDPCLIENT * This)
+ {
+ rcClip.left = 0;
+ rcClip.top = 0;
+ rcClip.right = This->width;
+ rcClip.bottom = This->height;
+ SelectObject(hdcBuffer, CreateRectRgnIndirect(&rcClip));
+ }
+
+ void
+ ui_bell(RDPCLIENT * This)
+ {
+ MessageBeep(MB_OK); // TODO? use Beep() on remote sessions?
+ }
+
+ static
+ void
+ win32_repaint_rect(RDPCLIENT * This, const RECT * lprc)
+ {
+ RECT rcDamage;
+ IntersectRect(&rcDamage, lprc, &rcClip);
+ InvalidateRect(hwnd, &rcDamage, FALSE);
+ //Sleep(100);
+ }
+
+ static
+ void
+ win32_repaint_area(RDPCLIENT * This, int x, int y, int cx, int cy)
+ {
+ RECT rcDamage;
+ rcDamage.left = x;
+ rcDamage.top = y;
+ rcDamage.right = x + cx;
+ rcDamage.bottom = y + cy;
+ win32_repaint_rect(This, &rcDamage);
+ }
+
+ static
+ void
+ win32_repaint_poly(RDPCLIENT * This, POINT * point, int npoints, int linewidth)
+ {
+ RECT rcDamage;
+
+ rcDamage.left = MAXLONG;
+ rcDamage.top = MAXLONG;
+ rcDamage.right = 0;
+ rcDamage.bottom = 0;
+
+ for(int i = 0; i < npoints; ++ i)
+ {
+ if(point[i].x < rcDamage.left)
+ rcDamage.left = point[i].x;
+
+ if(point[i].y < rcDamage.top)
+ rcDamage.top = point[i].y;
+
+ if(point[i].x > rcDamage.right)
+ rcDamage.right = point[i].x;
+
+ if(point[i].y > rcDamage.bottom)
+ rcDamage.bottom = point[i].y;
+ }
+
+ InflateRect(&rcDamage, linewidth, linewidth);
+ win32_repaint_rect(This, &rcDamage);
+ }
+
+ static
+ void
+ win32_repaint_whole(RDPCLIENT * This)
+ {
+ InvalidateRgn(hwnd, NULL, FALSE);
+ }
+
+ /*
+ TODO: all of the following could probably be implemented this way:
+ - perform operation on off-screen buffer
+ - invalidate affected region of the window
+ */
+ void
+ ui_paint_bitmap(RDPCLIENT * This, int x, int y, int cx, int cy, int width, int height, uint8 * data)
+ {
+ BITMAPINFO bmi;
+ ZeroMemory(&bmi, sizeof(bmi));
+
+ bmi.bmiHeader.biSize = sizeof(bmi.bmiHeader);
+ bmi.bmiHeader.biWidth = width;
+ bmi.bmiHeader.biHeight = - height;
+ bmi.bmiHeader.biPlanes = 1;
+ bmi.bmiHeader.biBitCount = This->server_depth;
+
+ StretchDIBits(hdcBuffer, x, y, cx, cy, 0, 0, width, height, data, &bmi, DIB_RGB_COLORS, SRCCOPY);
+
+ win32_repaint_area(This, x, y, cx, cy);
+ }
+
+ void
+ ui_destblt(RDPCLIENT * This, uint8 opcode,
+ /* dest */ int x, int y, int cx, int cy)
+ {
+ RECT rc;
+ rc.left = x;
+ rc.top = y;
+ rc.right = x + cx;
+ rc.bottom = y + cy;
+
+ int prev = SetROP2(hdcBuffer, MAKELONG(0, opcode | opcode << 4));
+
+ FillRect(hdcBuffer, &rc, (HBRUSH)GetStockObject(BLACK_BRUSH)); // use Rectangle instead?
+
+ SetROP2(hdcBuffer, prev);
+
+ win32_repaint_area(This, x, y, cx, cy);
+ }
+
+ void
+ ui_patblt(RDPCLIENT * This, uint8 opcode,
+ /* dest */ int x, int y, int cx, int cy,
+ /* brush */ BRUSH * brush, int bgcolour, int fgcolour)
+ {
+ // TODO
+ win32_repaint_area(This, x, y, cx, cy);
+ }
+
+ void
+ ui_screenblt(RDPCLIENT * This, uint8 opcode,
+ /* dest */ int x, int y, int cx, int cy,
+ /* src */ int srcx, int srcy)
+ {
+ BitBlt(hdcBuffer, x, y, cx, cy, hdcBuffer, srcx, srcy, MAKELONG(0, opcode | opcode << 4));
+ win32_repaint_area(This, x, y, cx, cy);
+ }
+
+ void
+ ui_memblt(RDPCLIENT * This, uint8 opcode,
+ /* dest */ int x, int y, int cx, int cy,
+ /* src */ HBITMAP src, int srcx, int srcy)
+ {
+ HDC hdcSrc = CreateCompatibleDC(hdcBuffer);
+ HGDIOBJ hOld = SelectObject(hdcSrc, src);
+
+ BitBlt(hdcBuffer, x, y, cx, cy, hdcSrc, srcx, srcy, MAKELONG(0, opcode | opcode << 4));
+
+ DeleteObject(hOld);
+ DeleteDC(hdcSrc);
+
+ win32_repaint_area(This, x, y, cx, cy);
+ }
+
+ void
+ ui_triblt(RDPCLIENT * This, uint8 opcode,
+ /* dest */ int x, int y, int cx, int cy,
+ /* src */ HBITMAP src, int srcx, int srcy,
+ /* brush */ BRUSH * brush, int bgcolour, int fgcolour)
+ {
+ // TODO
+ win32_repaint_area(This, x, y, cx, cy);
+ }
+
+ void
+ ui_line(RDPCLIENT * This, uint8 opcode,
+ /* dest */ int startx, int starty, int endx, int endy,
+ /* pen */ PEN * pen)
+ {
+ HPEN hpen = CreatePen(pen->style, pen->width, pen->colour);
+ HGDIOBJ hOld = SelectObject(hdcBuffer, hpen);
+
+ int prevROP = SetROP2(hdcBuffer, opcode);
+
+ POINT prevPos;
+ MoveToEx(hdcBuffer, startx, starty, &prevPos);
+
+ LineTo(hdcBuffer, endx, endy);
+
+ MoveToEx(hdcBuffer, prevPos.x, prevPos.y, NULL);
+
+ SetROP2(hdcBuffer, prevROP);
+
+ SelectObject(hdcBuffer, hOld);
+
+ RECT rcDamage;
+
+ if(startx < endx)
+ {
+ rcDamage.left = startx;
+ rcDamage.right = endx;
+ }
+ else
+ {
+ rcDamage.left = endx;
+ rcDamage.right = startx;
+ }
+
+ if(starty < endy)
+ {
+ rcDamage.top = starty;
+ rcDamage.bottom = endy;
+ }
+ else
+ {
+ rcDamage.top = endy;
+ rcDamage.bottom = starty;
+ }
+
+ InflateRect(&rcDamage, pen->width, pen->width);
+ win32_repaint_rect(This, &rcDamage);
+ }
+
+ void
+ ui_rect(RDPCLIENT * This,
+ /* dest */ int x, int y, int cx, int cy,
+ /* brush */ int colour)
+ {
+ RECT rc;
+ rc.left = x;
+ rc.top = y;
+ rc.right = x + cx;
+ rc.bottom = y + cy;
+
+ HBRUSH hbr = CreateSolidBrush(colour);
+ FillRect(hdcBuffer, &rc, hbr); // use Rectangle instead?
+ DeleteObject(hbr);
+
+ win32_repaint_rect(This, &rc);
+ }
+
+ void
+ ui_polygon(RDPCLIENT * This, uint8 opcode,
+ /* mode */ uint8 fillmode,
+ /* dest */ POINT * point, int npoints,
+ /* brush */ BRUSH * brush, int bgcolour, int fgcolour)
+ {
+ // TODO: create brush, set fg&bg
+
+ int oldRop = SetROP2(hdcBuffer, opcode);
+ int oldFillMode = SetPolyFillMode(hdcBuffer, fillmode);
+ Polygon(hdcBuffer, point, npoints);
+ SetPolyFillMode(hdcBuffer, oldFillMode);
+ SetROP2(hdcBuffer, oldRop);
+
+ win32_repaint_poly(This, point, npoints, 0);
+ }
+
+ void
+ ui_polyline(RDPCLIENT * This, uint8 opcode,
+ /* dest */ POINT * points, int npoints,
+ /* pen */ PEN * pen)
+ {
+ HPEN hpen = CreatePen(pen->style, pen->width, pen->colour);
+ HGDIOBJ hOld = SelectObject(hdcBuffer, hpen);
+ int oldRop = SetROP2(hdcBuffer, opcode);
+ Polyline(hdcBuffer, points, npoints);
+ SetROP2(hdcBuffer, oldRop);
+ SelectObject(hdcBuffer, hOld);
+
+ win32_repaint_poly(This, points, npoints, pen->width);
+ }
+
+ void
+ ui_ellipse(RDPCLIENT * This, uint8 opcode,
+ /* mode */ uint8 fillmode,
+ /* dest */ int x, int y, int cx, int cy,
+ /* brush */ BRUSH * brush, int bgcolour, int fgcolour)
+ {
+#if 0
+ switch(fillmode)
+ {
+ case 0: // outline // HOW? HOW? WITH WHAT PEN?
+ case 1: // filled // TODO
+ }
+#endif
+ win32_repaint_area(This, x, y, cx, cy);
+ }
+
+ void
+ ui_draw_glyph(RDPCLIENT * This, int mixmode,
+ /* dest */ int x, int y, int cx, int cy,
+ /* src */ HGLYPH glyph, int srcx, int srcy,
+ int bgcolour, int fgcolour)
+ {
+ // TODO!!!
+ }
+
+ void
+ ui_draw_text(RDPCLIENT * This, uint8 font, uint8 flags, uint8 opcode, int mixmode, int x, int y,
+ int clipx, int clipy, int clipcx, int clipcy,
+ int boxx, int boxy, int boxcx, int boxcy, BRUSH * brush,
+ int bgcolour, int fgcolour, uint8 * text, uint8 length)
+ {
+ // TODO!!!
+ }
+
+ void
+ ui_desktop_save(RDPCLIENT * This, uint32 offset, int x, int y, int cx, int cy)
+ {
+ // TODO (use GetDIBits)
+ }
+
+ void
+ ui_desktop_restore(RDPCLIENT * This, uint32 offset, int x, int y, int cx, int cy)
+ {
+ // TODO (use SetDIBitsToDevice)
+ win32_repaint_whole(This);
+ }
+
+ void
+ ui_begin_update(RDPCLIENT * This)
+ {
+ // TODO? use a mutex to arbitrate access to the off-screen buffer?
+ }
+
+ void
+ ui_end_update(RDPCLIENT * This)
+ {
+ // TODO? use a mutex to arbitrate access to the off-screen buffer?
+ }
+};
+
+static
+LRESULT
+CALLBACK
+mstsc_WndProc
+(
+ HWND hwnd,
+ UINT uMsg,
+ WPARAM wparam,
+ LPARAM lparam
+)
+{
+ // BUGBUG: LongToPtr & PtrToLong will break on Win64
+
+ RDPCLIENT * This = reinterpret_cast(LongToPtr(GetWindowLongPtr(hwnd, GWLP_USERDATA)));
+
+ switch(uMsg)
+ {
+ case WM_CREATE:
+ This = static_cast(reinterpret_cast(lparam)->lpCreateParams);
+ SetWindowLongPtr(hwnd, GWLP_USERDATA, PtrToLong(This));
+ break;
+
+ case WM_PAINT:
+ // Obscenely simple code for now...
+ {
+ PAINTSTRUCT ps;
+ HDC hdc = BeginPaint(hwnd, &ps);
+
+ BitBlt
+ (
+ hdc,
+ ps.rcPaint.left,
+ ps.rcPaint.top,
+ ps.rcPaint.right - ps.rcPaint.left,
+ ps.rcPaint.bottom - ps.rcPaint.top,
+ hdcBuffer,
+ ps.rcPaint.left,
+ ps.rcPaint.top,
+ SRCCOPY
+ );
+
+ EndPaint(hwnd, &ps);
+ }
+
+ break;
+
+ case WM_SYSKEYDOWN:
+ case WM_KEYDOWN:
+ rdp_send_input
+ (
+ This,
+ GetMessageTime(),
+ RDP_INPUT_SCANCODE,
+ RDP_KEYPRESS | (lparam & 0x1000000 ? KBD_FLAG_EXT : 0),
+ LOBYTE(HIWORD(lparam)),
+ 0
+ );
+
+ break;
+
+ case WM_SYSKEYUP:
+ case WM_KEYUP:
+ rdp_send_input
+ (
+ This,
+ GetMessageTime(),
+ RDP_INPUT_SCANCODE,
+ RDP_KEYRELEASE | (lparam & 0x1000000 ? KBD_FLAG_EXT : 0),
+ LOBYTE(HIWORD(lparam)),
+ 0
+ );
+
+ break;
+
+ default:
+ return DefWindowProc(hwnd, uMsg, wparam, lparam);
+ }
+
+ return 0;
+}
+
+static
+DWORD
+WINAPI
+mstsc_ProtocolIOThread
+(
+ LPVOID lpArgument
+)
+{
+ RDPCLIENT * This = static_cast(lpArgument);
+
+ strcpy(This->username, "Hyperion");
+
+ DWORD dw = sizeof(This->hostname);
+ GetComputerNameA(This->hostname, &dw);
+
+ uint32 flags = RDP_LOGON_NORMAL | RDP_LOGON_COMPRESSION | RDP_LOGON_COMPRESSION2;
+
+ rdp_connect(This, "10.0.0.3", flags, "", "", "", "");
+
+ hdcBuffer = CreateCompatibleDC(NULL);
+
+ BITMAPINFO bmi;
+ bmi.bmiHeader.biSize = sizeof(bmi.bmiHeader);
+ bmi.bmiHeader.biWidth = This->width;
+ bmi.bmiHeader.biHeight = This->height;
+ bmi.bmiHeader.biPlanes = 1;
+ bmi.bmiHeader.biBitCount = This->server_depth;
+ bmi.bmiHeader.biCompression = BI_RGB;
+ bmi.bmiHeader.biSizeImage = 0;
+ bmi.bmiHeader.biXPelsPerMeter = 0;
+ bmi.bmiHeader.biYPelsPerMeter = 0;
+ bmi.bmiHeader.biClrUsed = 0; // TODO! palette displays
+ bmi.bmiHeader.biClrImportant = 0; // TODO! palette displays
+
+ void * p;
+
+ hbmBuffer = CreateDIBSection(hdcBuffer, &bmi, DIB_RGB_COLORS, &p, NULL, 0);
+
+ SelectObject(hdcBuffer, hbmBuffer);
+
+ rcClip.left = 0;
+ rcClip.top = 0;
+ rcClip.right = This->width;
+ rcClip.bottom = This->height;
+
+ BOOL deactivated;
+ uint32 ext_disc_reason;
+
+ rdp_main_loop(This, &deactivated, &ext_disc_reason);
+
+ return 0;
+}
+
+int wmain()
+{
+ WSADATA wsd;
+ WSAStartup(MAKEWORD(2, 2), &wsd);
+
+ static RDPCLIENT This_; // NOTE: this is HUGE and would overflow the stack!
+ ZeroMemory(&This_, sizeof(This_));
+
+ RDPCLIENT * This = &This_;
+
+ /*
+ Threading model for MissTosca:
+ - main thread is the GUI thread. Message loop maintained by caller
+ - protocol I/O is handled in an I/O thread (or thread pool)
+ - extra threads maintained by virtual channel handlers. Virtual channel writes are thread-neutral
+
+ How we handle drawing: at the moment just an off-screen buffer we dump on-screen when asked to.
+ Still considering how to draw on-screen directly and *then* buffering off-screen (for example,
+ when running inside another remote session)
+ */
+
+ // FIXME: keyboard mess
+ This->keylayout = 0x409;
+ This->keyboard_type = 0x4;
+ This->keyboard_subtype = 0x0;
+ This->keyboard_functionkeys = 0xc;
+ This->width = 1024;
+ This->height = 768;
+ This->server_depth = 24;
+ This->bitmap_compression = True;
+ This->sendmotion = True;
+ This->bitmap_cache = True;
+ This->bitmap_cache_persist_enable = False;
+ This->bitmap_cache_precache = True;
+ This->encryption = True;
+ This->packet_encryption = True;
+ This->desktop_save = True;
+ This->polygon_ellipse_orders = True;
+ This->fullscreen = False;
+ This->grab_keyboard = True;
+ This->hide_decorations = False;
+ This->use_rdp5 = True;
+ This->rdpclip = True;
+ This->console_session = False;
+ This->numlock_sync = False;
+ This->seamless_rdp = False;
+ This->rdp5_performanceflags = RDP5_NO_WALLPAPER | RDP5_NO_FULLWINDOWDRAG | RDP5_NO_MENUANIMATIONS;
+ This->tcp_port_rdp = TCP_PORT_RDP;
+
+#define NOT_SET -1
+ This->cache.bmpcache_lru[0] = NOT_SET;
+ This->cache.bmpcache_lru[1] = NOT_SET;
+ This->cache.bmpcache_lru[2] = NOT_SET;
+ This->cache.bmpcache_mru[0] = NOT_SET;
+ This->cache.bmpcache_mru[1] = NOT_SET;
+ This->cache.bmpcache_mru[2] = NOT_SET;
+
+ WNDCLASS wc;
+ ZeroMemory(&wc, sizeof(wc));
+
+ wc.lpfnWndProc = mstsc_WndProc;
+ wc.hbrBackground = static_cast(GetStockObject(HOLLOW_BRUSH));
+ wc.lpszClassName = TEXT("MissTosca_Desktop");
+
+ ATOM a = RegisterClass(&wc);
+
+ hwnd = CreateWindow
+ (
+ MAKEINTATOM(a),
+ NULL,
+ WS_POPUP | WS_VISIBLE,
+ CW_USEDEFAULT,
+ CW_USEDEFAULT,
+ This->width,
+ This->height,
+ NULL,
+ NULL,
+ NULL,
+ This
+ );
+
+ // The righ time to start the protocol thread
+ DWORD dwThreadId;
+ HANDLE hThread = CreateThread(NULL, 0, mstsc_ProtocolIOThread, This, 0, &dwThreadId);
+
+ // Your standard, garden variety message loop
+ MSG msg;
+
+ while(GetMessage(&msg, NULL, 0, 0))
+ {
+ TranslateMessage(&msg);
+ DispatchMessage(&msg);
+ }
+}
+
+// EOF
diff --git a/reactos/base/applications/tsclient/porting-tools/rdesktop-core-tester/rdesktop-core-tester.vcproj b/reactos/base/applications/tsclient/porting-tools/rdesktop-core-tester/rdesktop-core-tester.vcproj
new file mode 100644
index 00000000000..44256e90d41
--- /dev/null
+++ b/reactos/base/applications/tsclient/porting-tools/rdesktop-core-tester/rdesktop-core-tester.vcproj
@@ -0,0 +1,231 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/reactos/base/applications/tsclient/porting-tools/rdesktop-core-tester/stdafx.cpp b/reactos/base/applications/tsclient/porting-tools/rdesktop-core-tester/stdafx.cpp
new file mode 100644
index 00000000000..ed86f05d826
--- /dev/null
+++ b/reactos/base/applications/tsclient/porting-tools/rdesktop-core-tester/stdafx.cpp
@@ -0,0 +1,8 @@
+// stdafx.cpp : source file that includes just the standard includes
+// rdesktop-core-tester.pch will be the pre-compiled header
+// stdafx.obj will contain the pre-compiled type information
+
+#include "stdafx.h"
+
+// TODO: reference any additional headers you need in STDAFX.H
+// and not in this file
diff --git a/reactos/base/applications/tsclient/porting-tools/rdesktop-core-tester/stdafx.h b/reactos/base/applications/tsclient/porting-tools/rdesktop-core-tester/stdafx.h
new file mode 100644
index 00000000000..cb4324781a4
--- /dev/null
+++ b/reactos/base/applications/tsclient/porting-tools/rdesktop-core-tester/stdafx.h
@@ -0,0 +1,18 @@
+#pragma once
+
+#include
+#include
+#include
+#include
+
+#include
+#include
+#include
+#include
+#include
+
+#define WIN32_LEAN_AND_MEAN
+#include
+#include
+
+// EOF
diff --git a/reactos/base/applications/tsclient/rdesktop/channels.c b/reactos/base/applications/tsclient/rdesktop/channels.c
index 1c138527ff1..bffb39c18ef 100644
--- a/reactos/base/applications/tsclient/rdesktop/channels.c
+++ b/reactos/base/applications/tsclient/rdesktop/channels.c
@@ -21,10 +21,13 @@
#include "rdesktop.h"
+// FIXME: header mess
+#if 0
#define CHANNEL_CHUNK_LENGTH 1600
#define CHANNEL_FLAG_FIRST 0x01
#define CHANNEL_FLAG_LAST 0x02
#define CHANNEL_FLAG_SHOW_PROTOCOL 0x10
+#endif
/* FIXME: We should use the information in TAG_SRV_CHANNELS to map RDP5
channels to MCS channels.
diff --git a/reactos/base/applications/tsclient/rdesktop/constants.h b/reactos/base/applications/tsclient/rdesktop/constants.h
index 703c823140e..462f9028fdf 100644
--- a/reactos/base/applications/tsclient/rdesktop/constants.h
+++ b/reactos/base/applications/tsclient/rdesktop/constants.h
@@ -2,7 +2,7 @@
rdesktop: A Remote Desktop Protocol client.
Miscellaneous protocol constants
Copyright (C) Matthew Chapman 1999-2005
-
+
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
@@ -311,9 +311,10 @@ enum RDP_INPUT_DEVICE
#define MASK_HAS_BITS(var, mask) ((var & mask)>0)
#define MASK_CHANGE_BIT(var, mask, active) (var = ((var & ~mask) | (active ? mask : 0)))
-/* Clipboard constants, "borrowed" from GCC system headers in
+/* Clipboard constants, "borrowed" from GCC system headers in
the w32 cross compiler */
+#if 0
#define CF_TEXT 1
#define CF_BITMAP 2
#define CF_METAFILEPICT 3
@@ -377,7 +378,6 @@ enum RDP_INPUT_DEVICE
#define STATUS_NOTIFY_ENUM_DIR 0xc000010c
#define STATUS_CANCELLED 0xc0000120
-
/* RDPDR constants */
#define RDPDR_MAX_DEVICES 0x10
#define DEVICE_TYPE_SERIAL 0x01
@@ -413,7 +413,9 @@ enum RDP_INPUT_DEVICE
#define exDiscReasonLicenseErrClientEncryption 0x0108
#define exDiscReasonLicenseCantUpgradeLicense 0x0109
#define exDiscReasonLicenseNoRemoteConnections 0x010a
+#endif
+#if 0
/* SeamlessRDP constants */
#define SEAMLESSRDP_NOTYETMAPPED -1
#define SEAMLESSRDP_NORMAL 0
@@ -425,3 +427,4 @@ enum RDP_INPUT_DEVICE
#define SEAMLESSRDP_HELLO_RECONNECT 0x0001
#define SEAMLESSRDP_HELLO_HIDDEN 0x0002
+#endif
diff --git a/reactos/base/applications/tsclient/rdesktop/licence.c b/reactos/base/applications/tsclient/rdesktop/licence.c
index 67b46079782..d60d45f3fbd 100644
--- a/reactos/base/applications/tsclient/rdesktop/licence.c
+++ b/reactos/base/applications/tsclient/rdesktop/licence.c
@@ -19,7 +19,7 @@
*/
#include "rdesktop.h"
-#include
+#include // TODO: remove dependency on OpenSSL
/* Generate a session key and RC4 keys, given client and server randoms */
static void
diff --git a/reactos/base/applications/tsclient/rdesktop/proto.h b/reactos/base/applications/tsclient/rdesktop/proto.h
index 4e229927117..bc1d94fa808 100644
--- a/reactos/base/applications/tsclient/rdesktop/proto.h
+++ b/reactos/base/applications/tsclient/rdesktop/proto.h
@@ -56,6 +56,7 @@ void cliprdr_send_data_request(RDPCLIENT * This, uint32 format);
void cliprdr_send_data(RDPCLIENT * This, uint8 * data, uint32 length);
void cliprdr_set_mode(RDPCLIENT * This, const char *optarg);
BOOL cliprdr_init(RDPCLIENT * This);
+#if 0
/* disk.c */
int disk_enum_devices(RDPCLIENT * This, uint32 * id, char *optarg);
NTSTATUS disk_query_information(RDPCLIENT * This, NTHANDLE handle, uint32 info_class, STREAM out);
@@ -64,6 +65,7 @@ NTSTATUS disk_check_notify(RDPCLIENT * This, NTHANDLE handle);
NTSTATUS disk_create_notify(RDPCLIENT * This, NTHANDLE handle, uint32 info_class);
NTSTATUS disk_query_volume_information(RDPCLIENT * This, NTHANDLE handle, uint32 info_class, STREAM out);
NTSTATUS disk_query_directory(RDPCLIENT * This, NTHANDLE handle, uint32 info_class, char *pattern, STREAM out);
+#endif
/* mppc.c */
int mppc_expand(RDPCLIENT * This, uint8 * data, uint32 clen, uint8 ctype, uint32 * roff, uint32 * rlen);
/* ewmhints.c */
@@ -153,6 +155,7 @@ BOOL rdp_reconnect(RDPCLIENT * This, char *server, uint32 flags, char *domain, c
char *directory, char *cookie);
void rdp_reset_state(RDPCLIENT * This);
void rdp_disconnect(RDPCLIENT * This);
+#if 0
/* rdpdr.c */
int get_device_index(RDPCLIENT * This, NTHANDLE handle);
void convert_to_unix_filename(char *filename);
@@ -162,6 +165,8 @@ struct async_iorequest *rdpdr_remove_iorequest(RDPCLIENT * This, struct async_io
struct async_iorequest *iorq);
void rdpdr_check_fds(RDPCLIENT * This, fd_set * rfds, fd_set * wfds, BOOL timed_out);
BOOL rdpdr_abort_io(RDPCLIENT * This, uint32 fd, uint32 major, NTSTATUS status);
+#endif
+#if 0
/* rdpsnd.c */
void rdpsnd_send_completion(RDPCLIENT * This, uint16 tick, uint8 packet_index);
BOOL rdpsnd_init(RDPCLIENT * This);
@@ -173,6 +178,7 @@ BOOL wave_out_set_format(WAVEFORMATEX * pwfx);
void wave_out_volume(uint16 left, uint16 right);
void wave_out_write(STREAM s, uint16 tick, uint8 index);
void wave_out_play(void);
+#endif
/* secure.c */
void sec_hash_48(uint8 * out, uint8 * in, uint8 * salt1, uint8 * salt2, uint8 salt);
void sec_hash_16(uint8 * out, uint8 * in, uint8 * salt1, uint8 * salt2);
@@ -189,10 +195,12 @@ BOOL sec_connect(RDPCLIENT * This, char *server, char *username);
BOOL sec_reconnect(RDPCLIENT * This, char *server);
void sec_disconnect(RDPCLIENT * This);
void sec_reset_state(RDPCLIENT * This);
+#if 0
/* serial.c */
int serial_enum_devices(RDPCLIENT * This, uint32 * id, char *optarg);
BOOL serial_get_event(RDPCLIENT * This, NTHANDLE handle, uint32 * result);
BOOL serial_get_timeout(RDPCLIENT * This, NTHANDLE handle, uint32 length, uint32 * timeout, uint32 * itv_timeout);
+#endif
/* tcp.c */
STREAM tcp_init(RDPCLIENT * This, uint32 maxlen);
void tcp_send(RDPCLIENT * This, STREAM s);
@@ -210,6 +218,7 @@ void ui_clip_sync(RDPCLIENT * This);
void ui_clip_set_mode(RDPCLIENT * This, const char *optarg);
void xclip_init(RDPCLIENT * This);
void xclip_deinit(RDPCLIENT * This);
+#if 0
/* xkeymap.c */
BOOL xkeymap_from_locale(RDPCLIENT * This, const char *locale);
FILE *xkeymap_open(const char *filename);
@@ -227,6 +236,7 @@ unsigned int read_keyboard_state(RDPCLIENT * This);
uint16 ui_get_numlock_state(RDPCLIENT * This, unsigned int state);
void reset_modifier_keys(RDPCLIENT * This);
void rdp_send_scancode(RDPCLIENT * This, uint32 time, uint16 flags, uint8 scancode);
+#endif
/* xwin.c */
BOOL get_key_state(RDPCLIENT * This, unsigned int state, uint32 keysym);
BOOL ui_init(RDPCLIENT * This);
diff --git a/reactos/base/applications/tsclient/rdesktop/rdesktop-core.vcproj b/reactos/base/applications/tsclient/rdesktop/rdesktop-core.vcproj
new file mode 100644
index 00000000000..4b9e1569b5b
--- /dev/null
+++ b/reactos/base/applications/tsclient/rdesktop/rdesktop-core.vcproj
@@ -0,0 +1,255 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/reactos/base/applications/tsclient/rdesktop/rdesktop.h b/reactos/base/applications/tsclient/rdesktop/rdesktop.h
index ca3f8327d47..378ade20b2f 100644
--- a/reactos/base/applications/tsclient/rdesktop/rdesktop.h
+++ b/reactos/base/applications/tsclient/rdesktop/rdesktop.h
@@ -18,6 +18,14 @@
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
+#ifndef WIN32_LEAN_AND_MEAN
+#define WIN32_LEAN_AND_MEAN
+#endif
+
+#include
+#include
+
+#if 0
#include
#include
#include
@@ -32,14 +40,18 @@
#include /* PATH_MAX */
/* FIXME FIXME */
+#include
+#include
+#include
+/* FIXME FIXME */
+#endif
+
+// TODO
#include
#include
#include
#include
#include
-#include
-#include
-/* FIXME FIXME */
#define VERSION "1.4.1"
@@ -128,6 +140,7 @@ typedef struct rdpclient RDPCLIENT;
#include "types.h"
#include "orders.h"
+#if 0
/* Used to store incoming io request, until they are ready to be completed */
/* using a linked list ensures that they are processed in the right order, */
/* if multiple ios are being done on the same fd */
@@ -141,6 +154,7 @@ struct async_iorequest
struct async_iorequest *next; /* next element in list */
};
+#endif
struct bmpcache_entry
{
@@ -149,6 +163,7 @@ struct bmpcache_entry
sint16 next;
};
+#if 0
typedef struct _seamless_group
{
Window wnd;
@@ -174,33 +189,25 @@ typedef struct _seamless_window
struct _seamless_window *next;
} seamless_window;
+#endif
/* holds the whole state of the RDP client */
struct rdpclient
{
- /* Public fields */
/* channels.c */
#define MAX_CHANNELS 6
VCHANNEL channels[MAX_CHANNELS];
unsigned int num_channels;
- /* disk.c */
-#define MAX_OPEN_FILES 0x100
- FILEINFO fileinfo[MAX_OPEN_FILES];
- BOOL notify_stamp;
-
- /* ewmhints.c */
- Atom net_wm_state_atom, net_wm_desktop_atom;
-
/* licence.c */
BOOL licence_issued;
- /* mppc.c */
- RDPCOMP mppc_dict;
-
/* mcs.c */
uint16 mcs_userid;
+ /* mppc.c */
+ RDPCOMP mppc_dict;
+
/* pstcache.c */
int pstcache_fd[8];
int pstcache_Bpp;
@@ -210,7 +217,7 @@ struct rdpclient
char title[64];
char username[64];
char hostname[16];
- char keymapname[PATH_MAX];
+ char keymapname[MAX_PATH];
unsigned int keylayout;
int keyboard_type;
int keyboard_subtype;
@@ -259,50 +266,16 @@ struct rdpclient
char redirect_cookie[128];
uint32 redirect_flags;
-#ifdef WITH_RDPSND
- BOOL rdpsnd_enabled;
-#endif
-
-#ifdef HAVE_ICONV
- char codepage[16];
-#endif
-
/* rdp.c */
uint8 *next_packet;
uint32 rdp_shareid;
- /* rdpdr.c */
- /* If select() times out, the request for the device with handle min_timeout_fd is aborted */
- NTHANDLE min_timeout_fd;
- uint32 num_devices;
-
- /* Table with information about rdpdr devices */
- RDPDR_DEVICE rdpdr_device[RDPDR_MAX_DEVICES];
- char *rdpdr_clientname;
-
- struct async_iorequest *iorequest;
-
- /* rdpsndXXX.c */
-#ifdef WITH_RDPSND
- int dsp_fd;
- BOOL dsp_busy;
-#endif
-
/* secure.c */
uint16 server_rdp_version;
/* tcp.c */
int tcp_port_rdp;
- /* xwin.c */
- Display *display;
- BOOL enable_compose;
- BOOL Unobscured; /* used for screenblt */
- Time last_gesturetime;
- Window wnd;
-
- /* Private fields */
- /* FIXME: it's not pretty to spill private fields this way. Use opaque pointers */
/* cache.c */
struct cache_
{
@@ -320,23 +293,6 @@ struct rdpclient
}
cache;
- /* cliprdr.c */
- struct cliprdr_
- {
- VCHANNEL *channel;
- uint8 *last_formats;
- uint32 last_formats_length;
- }
- cliprdr;
-
- struct ewmhints_
- {
- Atom state_maximized_vert_atom, state_maximized_horz_atom,
- state_hidden_atom, name_atom, utf8_string_atom,
- state_skip_taskbar_atom, state_skip_pager_atom, state_modal_atom;
- }
- ewmhints;
-
/* licence.c */
struct licence_
{
@@ -365,36 +321,6 @@ struct rdpclient
}
rdp;
- /* rdpdr.c */
- struct rdpdr_
- {
- VCHANNEL *channel;
- }
- rdpdr;
-
- /* rdpsnd.c */
- struct rdpsnd_
- {
- VCHANNEL *channel;
-
- BOOL device_open;
-
-#define MAX_FORMATS 10
- WAVEFORMATEX formats[MAX_FORMATS];
-
- unsigned int format_count;
- unsigned int current_format;
- }
- rdpsnd;
-
- /* seamless.c */
- struct seamless_
- {
- VCHANNEL *channel;
- unsigned int serial;
- }
- seamless;
-
/* secure.c */
struct secure_
{
@@ -426,6 +352,91 @@ struct rdpclient
}
tcp;
+#if 0
+ /* Public fields */
+ /* disk.c */
+#define MAX_OPEN_FILES 0x100
+ FILEINFO fileinfo[MAX_OPEN_FILES];
+ BOOL notify_stamp;
+
+ /* ewmhints.c */
+ Atom net_wm_state_atom, net_wm_desktop_atom;
+
+ /* rdpdr.c */
+ /* If select() times out, the request for the device with handle min_timeout_fd is aborted */
+ NTHANDLE min_timeout_fd;
+ uint32 num_devices;
+
+ /* Table with information about rdpdr devices */
+ RDPDR_DEVICE rdpdr_device[RDPDR_MAX_DEVICES];
+ char *rdpdr_clientname;
+
+ struct async_iorequest *iorequest;
+
+ /* rdpsndXXX.c */
+#ifdef WITH_RDPSND
+ int dsp_fd;
+ BOOL dsp_busy;
+#endif
+
+#if 0
+ /* xwin.c */
+ Display *display;
+ BOOL enable_compose;
+ BOOL Unobscured; /* used for screenblt */
+ Time last_gesturetime;
+ Window wnd;
+#endif
+
+ /* Private fields */
+ /* FIXME: it's not pretty to spill private fields this way. Use opaque pointers */
+ /* cliprdr.c */
+ struct cliprdr_
+ {
+ VCHANNEL *channel;
+ uint8 *last_formats;
+ uint32 last_formats_length;
+ }
+ cliprdr;
+
+ struct ewmhints_
+ {
+ Atom state_maximized_vert_atom, state_maximized_horz_atom,
+ state_hidden_atom, name_atom, utf8_string_atom,
+ state_skip_taskbar_atom, state_skip_pager_atom, state_modal_atom;
+ }
+ ewmhints;
+
+ /* rdpdr.c */
+ struct rdpdr_
+ {
+ VCHANNEL *channel;
+ }
+ rdpdr;
+
+ /* rdpsnd.c */
+ struct rdpsnd_
+ {
+ VCHANNEL *channel;
+
+ BOOL device_open;
+
+#define MAX_FORMATS 10
+ WAVEFORMATEX formats[MAX_FORMATS];
+
+ unsigned int format_count;
+ unsigned int current_format;
+ }
+ rdpsnd;
+
+ /* seamless.c */
+ struct seamless_
+ {
+ VCHANNEL *channel;
+ unsigned int serial;
+ }
+ seamless;
+
/* xclip.c */
struct xclip_
{
@@ -520,6 +531,7 @@ struct rdpclient
}
xkeymap;
+#if 0
/* xwin.c */
struct xwin_
{
@@ -565,9 +577,9 @@ struct rdpclient
binary format. If so, we can avoid an expensive translation.
Note that this can be true when compatible_arch is false,
e.g.:
-
+
RDP(LE) <-> host(BE) <-> X-Server(LE)
-
+
('host' is the machine running rdesktop; the host simply memcpy's
so its endianess doesn't matter)
*/
@@ -595,6 +607,8 @@ struct rdpclient
XErrorHandler old_error_handler;
}
xwin;
+#endif
+#endif
};
#ifndef MAKE_PROTO
diff --git a/reactos/base/applications/tsclient/rdesktop/rdp.c b/reactos/base/applications/tsclient/rdesktop/rdp.c
index 764021099e0..028dc91a8dc 100644
--- a/reactos/base/applications/tsclient/rdesktop/rdp.c
+++ b/reactos/base/applications/tsclient/rdesktop/rdp.c
@@ -20,7 +20,7 @@
#include
#include
-#include
+//#include
#include "rdesktop.h"
#ifdef HAVE_ICONV
@@ -932,7 +932,7 @@ process_demand_active(RDPCLIENT * This, STREAM s)
rdp_recv(This, &type); /* RDP_CTL_COOPERATE */
rdp_recv(This, &type); /* RDP_CTL_GRANT_CONTROL */
rdp_send_input(This, 0, RDP_INPUT_SYNCHRONIZE, 0,
- This->numlock_sync ? ui_get_numlock_state(This, read_keyboard_state(This)) : 0, 0);
+ /*This->numlock_sync ? ui_get_numlock_state(This, read_keyboard_state(This)) :*/ 0, 0); // TODO: keyboard mess
if (This->use_rdp5)
{
@@ -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);
+ // cache_put_cursor(This, cache_idx, cursor); // TODO
}
/* 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));
+ ui_set_cursor(This, /*cache_get_cursor(This, cache_idx)*/ NULL); // TODO
}
/* Process a system pointer PDU */
diff --git a/reactos/base/applications/tsclient/rdesktop/secure.c b/reactos/base/applications/tsclient/rdesktop/secure.c
index 47f28c79f83..8f90d72e4ed 100644
--- a/reactos/base/applications/tsclient/rdesktop/secure.c
+++ b/reactos/base/applications/tsclient/rdesktop/secure.c
@@ -19,7 +19,9 @@
*/
#include "rdesktop.h"
+#include
+// TODO: remove dependency on OpenSSL
#include
#include
#include
diff --git a/reactos/base/applications/tsclient/rdesktop/tcp.c b/reactos/base/applications/tsclient/rdesktop/tcp.c
index 173c227ee6c..8d03272f9d8 100644
--- a/reactos/base/applications/tsclient/rdesktop/tcp.c
+++ b/reactos/base/applications/tsclient/rdesktop/tcp.c
@@ -18,6 +18,7 @@
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
+#if 0 // FIXME: header mess
#include /* select read write close */
#include /* socket connect setsockopt */
#include /* timeval */
@@ -26,7 +27,12 @@
#include /* TCP_NODELAY */
#include /* inet_addr */
#include /* errno */
+#endif
+
#include "rdesktop.h"
+#include
+
+typedef int socklen_t;
#ifndef INADDR_NONE
#define INADDR_NONE ((unsigned long) -1)
@@ -59,7 +65,7 @@ tcp_send(RDPCLIENT * This, STREAM s)
sent = send(This->tcp.sock, s->data + total, length - total, 0);
if (sent <= 0)
{
- error("send: %s\n", strerror(errno));
+ // error("send: %s\n", strerror(errno)); // EOF
return;
}
@@ -109,7 +115,7 @@ tcp_recv(RDPCLIENT * This, STREAM s, uint32 length)
rcvd = recv(This->tcp.sock, s->end, length, 0);
if (rcvd < 0)
{
- error("recv: %s\n", strerror(errno));
+ // error("recv: %s\n", strerror(errno)); // EOF
return NULL;
}
else if (rcvd == 0)
@@ -188,7 +194,7 @@ tcp_connect(RDPCLIENT * This, char *server)
if ((This->tcp.sock = socket(AF_INET, SOCK_STREAM, 0)) < 0)
{
- error("socket: %s\n", strerror(errno));
+ // error("socket: %s\n", strerror(errno)); // EOF
return False;
}
@@ -197,7 +203,7 @@ tcp_connect(RDPCLIENT * This, char *server)
if (connect(This->tcp.sock, (struct sockaddr *) &servaddr, sizeof(struct sockaddr)) < 0)
{
- error("connect: %s\n", strerror(errno));
+ // error("connect: %s\n", strerror(errno)); // EOF
close(This->tcp.sock);
return False;
}
diff --git a/reactos/base/applications/tsclient/rdesktop/types.h b/reactos/base/applications/tsclient/rdesktop/types.h
index fc06233281d..705373f9f59 100644
--- a/reactos/base/applications/tsclient/rdesktop/types.h
+++ b/reactos/base/applications/tsclient/rdesktop/types.h
@@ -2,7 +2,7 @@
rdesktop: A Remote Desktop Protocol client.
Common data types
Copyright (C) Matthew Chapman 1999-2005
-
+
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
@@ -12,13 +12,15 @@
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
-
+
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
+#if 0
typedef int BOOL;
+#endif
#ifndef True
#define True (1)
@@ -32,17 +34,25 @@ typedef signed short sint16;
typedef unsigned int uint32;
typedef signed int sint32;
+// TODO: detect Win32, avoid this mess
+#if 0
typedef void *HBITMAP;
-typedef void *HGLYPH;
-typedef void *HCOLOURMAP;
typedef void *HCURSOR;
+#endif
+typedef void *HGLYPH;
+// TODO: nuke, use HPALETTE
+typedef void *HCOLOURMAP;
+
+#if 0
typedef struct _POINT
{
sint16 x, y;
}
POINT;
+#endif
+// TODO: nuke, use COLORREF
typedef struct _COLOURENTRY
{
uint8 red;
@@ -52,6 +62,7 @@ typedef struct _COLOURENTRY
}
COLOURENTRY;
+// TODO: nuke, use LOGPALETTE
typedef struct _COLOURMAP
{
uint16 ncolours;
@@ -60,6 +71,7 @@ typedef struct _COLOURMAP
}
COLOURMAP;
+// TODO: nuke, use RECT
typedef struct _BOUNDS
{
sint16 left;
@@ -70,7 +82,8 @@ typedef struct _BOUNDS
}
BOUNDS;
-typedef struct _PEN
+// TODO: nuke, use LOGPEN
+typedef struct _PEN
{
uint8 style;
uint8 width;
@@ -79,6 +92,7 @@ typedef struct _PEN
}
PEN;
+// TODO: nuke, use LOGBRUSH + pattern[8]
typedef struct _BRUSH
{
uint8 xorigin;
@@ -119,6 +133,7 @@ typedef struct _key_translation
}
key_translation;
+// TODO: semi-nuke, wrap CHANNEL_DEF
typedef struct _VCHANNEL
{
uint16 mcs_id;
@@ -145,6 +160,7 @@ CELLHEADER;
#define MAX_CBSIZE 256
/* RDPSND */
+#if 0
typedef struct
{
uint16 wFormatTag;
@@ -156,7 +172,7 @@ typedef struct
uint16 cbSize;
uint8 cb[MAX_CBSIZE];
} WAVEFORMATEX;
-
+#endif
typedef struct _RDPCOMP
{
uint32 roff;
@@ -165,6 +181,7 @@ typedef struct _RDPCOMP
}
RDPCOMP;
+#if 0
/* RDPDR */
typedef uint32 NTSTATUS;
typedef uint32 NTHANDLE;
@@ -264,5 +281,6 @@ typedef struct fileinfo
uint32 info_class;
}
FILEINFO;
+#endif
typedef BOOL(*str_handle_lines_t) (RDPCLIENT * This, const char *line, void *data);