diff options
author | Laxmikant Rashinkar <LK.Rashinkar@gmail.com> | 2014-02-10 18:47:22 -0800 |
---|---|---|
committer | Laxmikant Rashinkar <LK.Rashinkar@gmail.com> | 2014-02-10 18:47:22 -0800 |
commit | c5c8324d91277bdbddf7402453b0b8f56e698972 (patch) | |
tree | f39fa62e78e274d0792bfdbd0b0202e5be323977 | |
parent | e95edef44e1dd25cd40a650e61faff7c4977e689 (diff) | |
parent | 973d41bceb19fd2af275a1f262363cbe2db30792 (diff) | |
download | xrdp-proprietary-c5c8324d91277bdbddf7402453b0b8f56e698972.tar.gz xrdp-proprietary-c5c8324d91277bdbddf7402453b0b8f56e698972.zip |
Merge branch 'devel' of github.com:/neutrinolabs/xrdp into devel
-rw-r--r-- | common/os_calls.c | 43 | ||||
-rw-r--r-- | common/os_calls.h | 1 | ||||
-rw-r--r-- | tests/tcp_proxy/Makefile | 7 | ||||
-rw-r--r-- | tests/tcp_proxy/main.c | 405 | ||||
-rw-r--r-- | xorg/X11R7.6/rdp/rdpmain.c | 38 | ||||
-rw-r--r-- | xorg/server/module/rdpClientCon.h | 10 | ||||
-rw-r--r-- | xorg/server/module/rdpCursor.c | 255 | ||||
-rw-r--r-- | xorg/server/module/rdpReg.c | 19 | ||||
-rw-r--r-- | xorg/server/module/rdpReg.h | 2 | ||||
-rw-r--r-- | xrdp/xrdp.h | 4 | ||||
-rw-r--r-- | xrdp/xrdp_login_wnd.c | 4 | ||||
-rw-r--r-- | xrdp/xrdp_mm.c | 4 | ||||
-rw-r--r-- | xrdp/xrdp_wm.c | 13 | ||||
-rw-r--r-- | xup/xup.c | 884 |
14 files changed, 1422 insertions, 267 deletions
diff --git a/common/os_calls.c b/common/os_calls.c index bb26d246..80b2d235 100644 --- a/common/os_calls.c +++ b/common/os_calls.c @@ -1,7 +1,7 @@ /** * xrdp: A Remote Desktop Protocol server. * - * Copyright (C) Jay Sorg 2004-2013 + * Copyright (C) Jay Sorg 2004-2014 * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,6 +20,11 @@ * put all the os / arch define in here you want */ +/* To test for Windows (64 bit or 32 bit) use _WIN32 and _WIN64 in addition + for 64 bit windows. _WIN32 is defined for both. + To test for Linux use __linux__. + To test for BSD use BSD */ + #if defined(HAVE_CONFIG_H) #include "config_ac.h" #endif @@ -60,6 +65,13 @@ #include <stdio.h> #include <locale.h> +/* this is so we can use #ifdef BSD later */ +/* This is the recommended way of detecting BSD in the + FreeBSD Porter's Handbook. */ +#if (defined(__unix__) || defined(unix)) && !defined(USG) +#include <sys/param.h> +#endif + #include "os_calls.h" #include "arch.h" #include "log.h" @@ -596,10 +608,16 @@ g_tcp_local_socket(void) } /*****************************************************************************/ +/* returns error */ int APP_CC g_sck_get_peer_cred(int sck, int *pid, int *uid, int *gid) { +#if defined(SO_PEERCRED) +#if defined(_WIN32) int ucred_length; +#else + unsigned int ucred_length; +#endif struct myucred { pid_t pid; @@ -625,6 +643,9 @@ g_sck_get_peer_cred(int sck, int *pid, int *uid, int *gid) *gid = credentials.gid; } return 0; +#else + return 1; +#endif } /*****************************************************************************/ @@ -3122,15 +3143,33 @@ g_text2bool(const char *s) } /*****************************************************************************/ +/* returns pointer or nil on error */ void * APP_CC g_shmat(int shmid) { - return shmat(shmid, 0, 0); +#if defined(_WIN32) + return 0; +#else + return shmat(shmid, 0, 0); +#endif } /*****************************************************************************/ +/* returns -1 on error 0 on success */ int APP_CC g_shmdt(const void *shmaddr) { +#if defined(_WIN32) + return -1; +#else return shmdt(shmaddr); +#endif +} + +/*****************************************************************************/ +/* returns -1 on error 0 on success */ +int APP_CC +g_gethostname(char *name, int len) +{ + return gethostname(name, len); } diff --git a/common/os_calls.h b/common/os_calls.h index 2bee6077..06ce8494 100644 --- a/common/os_calls.h +++ b/common/os_calls.h @@ -163,5 +163,6 @@ int APP_CC g_time3(void); int APP_CC g_text2bool(const char *s); void * APP_CC g_shmat(int shmid); int APP_CC g_shmdt(const void *shmaddr); +int APP_CC g_gethostname(char *name, int len); #endif diff --git a/tests/tcp_proxy/Makefile b/tests/tcp_proxy/Makefile index d19b4818..8f5821d3 100644 --- a/tests/tcp_proxy/Makefile +++ b/tests/tcp_proxy/Makefile @@ -1,6 +1,7 @@ -CFLAGS = -O2 -Wall -I../../common -LDFLAGS = -Wl -OBJS = main.o ../../common/os_calls.o + +CFLAGS = -O2 -Wall +LDFLAGS = +OBJS = main.o LIBS = -ldl all: tcp_proxy diff --git a/tests/tcp_proxy/main.c b/tests/tcp_proxy/main.c index 53458a57..2d283ed9 100644 --- a/tests/tcp_proxy/main.c +++ b/tests/tcp_proxy/main.c @@ -1,7 +1,7 @@ /** * xrdp: A Remote Desktop Protocol server. * - * Copyright (C) Jay Sorg 2004-2013 + * Copyright (C) Jay Sorg 2004-2014 * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,7 +16,20 @@ * limitations under the License. */ -#include <os_calls.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <stdarg.h> +#include <unistd.h> +#include <fcntl.h> +#include <signal.h> +#include <errno.h> +#include <locale.h> +#include <netdb.h> +#include <sys/types.h> +#include <sys/socket.h> +#include <netinet/in.h> +#include <arpa/inet.h> int g_loc_io_count = 0; // bytes read from local port int g_rem_io_count = 0; // bytes read from remote port @@ -24,6 +37,394 @@ int g_rem_io_count = 0; // bytes read from remote port static int g_terminated = 0; static char g_buf[1024 * 32]; +#define DEFAULT_CC +#define APP_CC + +typedef unsigned short tui16; + +/*****************************************************************************/ +static void APP_CC +g_memset(void *ptr, int val, int size) +{ + memset(ptr, val, size); +} + +/*****************************************************************************/ +static void DEFAULT_CC +g_printf(const char *format, ...) +{ + va_list ap; + + va_start(ap, format); + vfprintf(stdout, format, ap); + va_end(ap); +} + +/*****************************************************************************/ +static void DEFAULT_CC +g_writeln(const char *format, ...) +{ + va_list ap; + + va_start(ap, format); + vfprintf(stdout, format, ap); + va_end(ap); + g_printf("\n"); +} + +/*****************************************************************************/ +static void APP_CC +g_hexdump(char *p, int len) +{ + unsigned char *line; + int i; + int thisline; + int offset; + + line = (unsigned char *)p; + offset = 0; + + while (offset < len) + { + g_printf("%04x ", offset); + thisline = len - offset; + + if (thisline > 16) + { + thisline = 16; + } + + for (i = 0; i < thisline; i++) + { + g_printf("%02x ", line[i]); + } + + for (; i < 16; i++) + { + g_printf(" "); + } + + for (i = 0; i < thisline; i++) + { + g_printf("%c", (line[i] >= 0x20 && line[i] < 0x7f) ? line[i] : '.'); + } + + g_writeln(""); + offset += thisline; + line += thisline; + } +} + +/*****************************************************************************/ +static int APP_CC +g_tcp_socket(void) +{ + int rv; + int option_value; + unsigned int option_len; + + rv = (int)socket(AF_INET, SOCK_STREAM, 0); + if (rv < 0) + { + return -1; + } + option_len = sizeof(option_value); + if (getsockopt(rv, SOL_SOCKET, SO_REUSEADDR, (char *)&option_value, + &option_len) == 0) + { + if (option_value == 0) + { + option_value = 1; + option_len = sizeof(option_value); + setsockopt(rv, SOL_SOCKET, SO_REUSEADDR, (char *)&option_value, + option_len); + } + } + + option_len = sizeof(option_value); + + if (getsockopt(rv, SOL_SOCKET, SO_SNDBUF, (char *)&option_value, + &option_len) == 0) + { + if (option_value < (1024 * 32)) + { + option_value = 1024 * 32; + option_len = sizeof(option_value); + setsockopt(rv, SOL_SOCKET, SO_SNDBUF, (char *)&option_value, + option_len); + } + } + + return rv; +} + +/*****************************************************************************/ +static int APP_CC +g_tcp_set_non_blocking(int sck) +{ + unsigned long i; + + i = fcntl(sck, F_GETFL); + i = i | O_NONBLOCK; + fcntl(sck, F_SETFL, i); + return 0; +} + +/*****************************************************************************/ +static int APP_CC +g_tcp_bind(int sck, const char* port) +{ + struct sockaddr_in s; + + memset(&s, 0, sizeof(struct sockaddr_in)); + s.sin_family = AF_INET; + s.sin_port = htons((tui16)atoi(port)); + s.sin_addr.s_addr = INADDR_ANY; + return bind(sck, (struct sockaddr*)&s, sizeof(struct sockaddr_in)); +} + +/*****************************************************************************/ +static int APP_CC +g_tcp_listen(int sck) +{ + return listen(sck, 2); +} + +/*****************************************************************************/ +static int APP_CC +g_tcp_select(int sck1, int sck2) +{ + fd_set rfds; + struct timeval time; + int max = 0; + int rv = 0; + + g_memset(&rfds, 0, sizeof(fd_set)); + g_memset(&time, 0, sizeof(struct timeval)); + + time.tv_sec = 0; + time.tv_usec = 0; + FD_ZERO(&rfds); + + if (sck1 > 0) + { + FD_SET(((unsigned int)sck1), &rfds); + } + + if (sck2 > 0) + { + FD_SET(((unsigned int)sck2), &rfds); + } + + max = sck1; + + if (sck2 > max) + { + max = sck2; + } + + rv = select(max + 1, &rfds, 0, 0, &time); + + if (rv > 0) + { + rv = 0; + + if (FD_ISSET(((unsigned int)sck1), &rfds)) + { + rv = rv | 1; + } + + if (FD_ISSET(((unsigned int)sck2), &rfds)) + { + rv = rv | 2; + } + } + else + { + rv = 0; + } + + return rv; +} + +/*****************************************************************************/ +static int APP_CC +g_tcp_recv(int sck, void *ptr, int len, int flags) +{ + return recv(sck, ptr, len, flags); +} + +/*****************************************************************************/ +static void APP_CC +g_tcp_close(int sck) +{ + if (sck == 0) + { + return; + } + close(sck); +} + +/*****************************************************************************/ +static int APP_CC +g_tcp_send(int sck, const void *ptr, int len, int flags) +{ + return send(sck, ptr, len, flags); +} + +/*****************************************************************************/ +void APP_CC +g_sleep(int msecs) +{ + usleep(msecs * 1000); +} + +/*****************************************************************************/ +static int APP_CC +g_tcp_last_error_would_block(int sck) +{ + return (errno == EWOULDBLOCK) || (errno == EAGAIN) || (errno == EINPROGRESS); +} + +/*****************************************************************************/ +static int APP_CC +g_tcp_accept(int sck) +{ + int ret ; + struct sockaddr_in s; + unsigned int i; + + i = sizeof(struct sockaddr_in); + memset(&s, 0, i); + ret = accept(sck, (struct sockaddr *)&s, &i); + return ret ; +} + +/*****************************************************************************/ +static int APP_CC +g_tcp_connect(int sck, const char* address, const char* port) +{ + struct sockaddr_in s; + struct hostent* h; + + g_memset(&s, 0, sizeof(struct sockaddr_in)); + s.sin_family = AF_INET; + s.sin_port = htons((tui16)atoi(port)); + s.sin_addr.s_addr = inet_addr(address); + if (s.sin_addr.s_addr == INADDR_NONE) + { + h = gethostbyname(address); + if (h != 0) + { + if (h->h_name != 0) + { + if (h->h_addr_list != 0) + { + if ((*(h->h_addr_list)) != 0) + { + s.sin_addr.s_addr = *((int*)(*(h->h_addr_list))); + } + } + } + } + } + return connect(sck, (struct sockaddr*)&s, sizeof(struct sockaddr_in)); +} + +/*****************************************************************************/ +static int APP_CC +g_tcp_socket_ok(int sck) +{ + int opt; + unsigned int opt_len; + + opt_len = sizeof(opt); + + if (getsockopt(sck, SOL_SOCKET, SO_ERROR, (char *)(&opt), &opt_len) == 0) + { + if (opt == 0) + { + return 1; + } + } + + return 0; +} + +/*****************************************************************************/ +static void APP_CC +g_init(const char *app_name) +{ + setlocale(LC_CTYPE, ""); +} + +/*****************************************************************************/ +static void APP_CC +g_deinit(void) +{ +} + +/*****************************************************************************/ +static int APP_CC +g_tcp_can_send(int sck, int millis) +{ + fd_set wfds; + struct timeval time; + int rv; + + time.tv_sec = millis / 1000; + time.tv_usec = (millis * 1000) % 1000000; + FD_ZERO(&wfds); + + if (sck > 0) + { + FD_SET(((unsigned int)sck), &wfds); + rv = select(sck + 1, 0, &wfds, 0, &time); + + if (rv > 0) + { + return g_tcp_socket_ok(sck); + } + } + + return 0; +} + +/*****************************************************************************/ +static void APP_CC +g_signal_user_interrupt(void (*func)(int)) +{ + signal(SIGINT, func); +} + +/*****************************************************************************/ +static void APP_CC +g_signal_kill(void (*func)(int)) +{ + signal(SIGKILL, func); +} + +/*****************************************************************************/ +static void APP_CC +g_signal_terminate(void (*func)(int)) +{ + signal(SIGTERM, func); +} + +/*****************************************************************************/ +static void APP_CC +g_signal_usr1(void (*func)(int)) +{ + signal(SIGUSR1, func); +} + +/*****************************************************************************/ +static int APP_CC +g_strcasecmp(const char *c1, const char *c2) +{ + return strcasecmp(c1, c2); +} + /*****************************************************************************/ static int main_loop(char *local_port, char *remote_ip, char *remote_port, int hexdump) diff --git a/xorg/X11R7.6/rdp/rdpmain.c b/xorg/X11R7.6/rdp/rdpmain.c index c68700fc..884b8a3a 100644 --- a/xorg/X11R7.6/rdp/rdpmain.c +++ b/xorg/X11R7.6/rdp/rdpmain.c @@ -32,6 +32,27 @@ Sets up the functions #define DEBUG_OUT(arg) ErrorF arg #endif +#ifndef XRDP_DISABLE_LINUX_ABSTRACT +#ifdef __linux__ +#define XRDP_DISABLE_LINUX_ABSTRACT 1 +#else +#define XRDP_DISABLE_LINUX_ABSTRACT 0 +#endif +#endif + +#if XRDP_DISABLE_LINUX_ABSTRACT +/* because including <X11/Xtrans/Xtransint.h> in problematic + * we dup a small struct + * we need to set flags to zero to turn off abstract sockets */ +struct _MyXtransport +{ + char *TransName; + int flags; +}; +/* in xtrans-1.2.6/Xtranssock.c */ +extern struct _MyXtransport _XSERVTransSocketLocalFuncs; +#endif + rdpScreenInfoRec g_rdpScreen; /* the one screen */ ScreenPtr g_pScreen = 0; @@ -234,6 +255,16 @@ rdpDestroyColormap(ColormapPtr pColormap) #endif /******************************************************************************/ +void +rdpSetUDSRights(void) +{ + char unixSocketName[128]; + + sprintf(unixSocketName, "/tmp/.X11-unix/X%s", display); + chmod(unixSocketName, 0700); +} + +/******************************************************************************/ /* returns boolean, true if everything is ok */ static Bool rdpScreenInit(int index, ScreenPtr pScreen, int argc, char **argv) @@ -548,6 +579,8 @@ rdpScreenInit(int index, ScreenPtr pScreen, int argc, char **argv) rdpGlyphInit(); //rdpXvInit(pScreen); + + rdpSetUDSRights(); ErrorF("rdpScreenInit: ret %d\n", ret); @@ -620,6 +653,11 @@ ddxProcessArgument(int argc, char **argv, int i) void OsVendorInit(void) { +#if XRDP_DISABLE_LINUX_ABSTRACT + /* turn off the Linux abstract unix doamin sockets TRANS_ABSTRACT */ + /* TRANS_NOLISTEN = 1 << 3 */ + _XSERVTransSocketLocalFuncs.flags = 0; +#endif } /******************************************************************************/ diff --git a/xorg/server/module/rdpClientCon.h b/xorg/server/module/rdpClientCon.h index 592e8d31..9cbe493a 100644 --- a/xorg/server/module/rdpClientCon.h +++ b/xorg/server/module/rdpClientCon.h @@ -143,9 +143,19 @@ rdpClientConAddDirtyScreenBox(rdpPtr dev, rdpClientCon *clientCon, int rdpClientConAddDirtyScreen(rdpPtr dev, rdpClientCon *clientCon, int x, int y, int cx, int cy); +void +rdpClientConGetScreenImageRect(rdpPtr dev, rdpClientCon *clientCon, + struct image_data *id); int rdpClientConAddAllReg(rdpPtr dev, RegionPtr reg, DrawablePtr pDrawable); int rdpClientConAddAllBox(rdpPtr dev, BoxPtr box, DrawablePtr pDrawable); +int +rdpClientConSetCursor(rdpPtr dev, rdpClientCon *clientCon, + short x, short y, char *cur_data, char *cur_mask); +int +rdpClientConSetCursorEx(rdpPtr dev, rdpClientCon *clientCon, + short x, short y, char *cur_data, + char *cur_mask, int bpp); #endif diff --git a/xorg/server/module/rdpCursor.c b/xorg/server/module/rdpCursor.c index 84a6cc81..3859e8e7 100644 --- a/xorg/server/module/rdpCursor.c +++ b/xorg/server/module/rdpCursor.c @@ -36,9 +36,50 @@ cursor #include <fb.h> #include <micmap.h> #include <mi.h> +#include <cursor.h> +#include <cursorstr.h> #include "rdp.h" #include "rdpMain.h" +#include "rdpDraw.h" +#include "rdpClientCon.h" + +/* Copied from Xvnc/lib/font/util/utilbitmap.c */ +static unsigned char g_reverse_byte[0x100] = +{ + 0x00, 0x80, 0x40, 0xc0, 0x20, 0xa0, 0x60, 0xe0, + 0x10, 0x90, 0x50, 0xd0, 0x30, 0xb0, 0x70, 0xf0, + 0x08, 0x88, 0x48, 0xc8, 0x28, 0xa8, 0x68, 0xe8, + 0x18, 0x98, 0x58, 0xd8, 0x38, 0xb8, 0x78, 0xf8, + 0x04, 0x84, 0x44, 0xc4, 0x24, 0xa4, 0x64, 0xe4, + 0x14, 0x94, 0x54, 0xd4, 0x34, 0xb4, 0x74, 0xf4, + 0x0c, 0x8c, 0x4c, 0xcc, 0x2c, 0xac, 0x6c, 0xec, + 0x1c, 0x9c, 0x5c, 0xdc, 0x3c, 0xbc, 0x7c, 0xfc, + 0x02, 0x82, 0x42, 0xc2, 0x22, 0xa2, 0x62, 0xe2, + 0x12, 0x92, 0x52, 0xd2, 0x32, 0xb2, 0x72, 0xf2, + 0x0a, 0x8a, 0x4a, 0xca, 0x2a, 0xaa, 0x6a, 0xea, + 0x1a, 0x9a, 0x5a, 0xda, 0x3a, 0xba, 0x7a, 0xfa, + 0x06, 0x86, 0x46, 0xc6, 0x26, 0xa6, 0x66, 0xe6, + 0x16, 0x96, 0x56, 0xd6, 0x36, 0xb6, 0x76, 0xf6, + 0x0e, 0x8e, 0x4e, 0xce, 0x2e, 0xae, 0x6e, 0xee, + 0x1e, 0x9e, 0x5e, 0xde, 0x3e, 0xbe, 0x7e, 0xfe, + 0x01, 0x81, 0x41, 0xc1, 0x21, 0xa1, 0x61, 0xe1, + 0x11, 0x91, 0x51, 0xd1, 0x31, 0xb1, 0x71, 0xf1, + 0x09, 0x89, 0x49, 0xc9, 0x29, 0xa9, 0x69, 0xe9, + 0x19, 0x99, 0x59, 0xd9, 0x39, 0xb9, 0x79, 0xf9, + 0x05, 0x85, 0x45, 0xc5, 0x25, 0xa5, 0x65, 0xe5, + 0x15, 0x95, 0x55, 0xd5, 0x35, 0xb5, 0x75, 0xf5, + 0x0d, 0x8d, 0x4d, 0xcd, 0x2d, 0xad, 0x6d, 0xed, + 0x1d, 0x9d, 0x5d, 0xdd, 0x3d, 0xbd, 0x7d, 0xfd, + 0x03, 0x83, 0x43, 0xc3, 0x23, 0xa3, 0x63, 0xe3, + 0x13, 0x93, 0x53, 0xd3, 0x33, 0xb3, 0x73, 0xf3, + 0x0b, 0x8b, 0x4b, 0xcb, 0x2b, 0xab, 0x6b, 0xeb, + 0x1b, 0x9b, 0x5b, 0xdb, 0x3b, 0xbb, 0x7b, 0xfb, + 0x07, 0x87, 0x47, 0xc7, 0x27, 0xa7, 0x67, 0xe7, + 0x17, 0x97, 0x57, 0xd7, 0x37, 0xb7, 0x77, 0xf7, + 0x0f, 0x8f, 0x4f, 0xcf, 0x2f, 0xaf, 0x6f, 0xef, + 0x1f, 0x9f, 0x5f, 0xdf, 0x3f, 0xbf, 0x7f, 0xff +}; /******************************************************************************/ #define LOG_LEVEL 1 @@ -62,11 +103,225 @@ rdpSpriteUnrealizeCursor(DeviceIntPtr pDev, ScreenPtr pScr, CursorPtr pCurs) } /******************************************************************************/ +static int +get_pixel_safe(char *data, int x, int y, int width, int height, int bpp) +{ + int start; + int shift; + int c; + unsigned int *src32; + + if (x < 0) + { + return 0; + } + + if (y < 0) + { + return 0; + } + + if (x >= width) + { + return 0; + } + + if (y >= height) + { + return 0; + } + + if (bpp == 1) + { + width = (width + 7) / 8; + start = (y * width) + x / 8; + shift = x % 8; + c = (unsigned char)(data[start]); +#if (X_BYTE_ORDER == X_LITTLE_ENDIAN) + return (g_reverse_byte[c] & (0x80 >> shift)) != 0; +#else + return (c & (0x80 >> shift)) != 0; +#endif + } + else if (bpp == 32) + { + src32 = (unsigned int*)data; + return src32[y * width + x]; + } + + return 0; +} + +/******************************************************************************/ +static void +set_pixel_safe(char *data, int x, int y, int width, int height, int bpp, + int pixel) +{ + int start; + int shift; + unsigned int *dst32; + + if (x < 0) + { + return; + } + + if (y < 0) + { + return; + } + + if (x >= width) + { + return; + } + + if (y >= height) + { + return; + } + + if (bpp == 1) + { + width = (width + 7) / 8; + start = (y * width) + x / 8; + shift = x % 8; + + if (pixel & 1) + { + data[start] = data[start] | (0x80 >> shift); + } + else + { + data[start] = data[start] & ~(0x80 >> shift); + } + } + else if (bpp == 24) + { + *(data + (3 * (y * width + x)) + 0) = pixel >> 0; + *(data + (3 * (y * width + x)) + 1) = pixel >> 8; + *(data + (3 * (y * width + x)) + 2) = pixel >> 16; + } + else if (bpp == 32) + { + dst32 = (unsigned int*)data; + dst32[y * width + x] = pixel; + } +} + +/******************************************************************************/ +void +rdpSpriteSetCursorCon(rdpClientCon *clientCon, + DeviceIntPtr pDev, ScreenPtr pScr, CursorPtr pCurs, + int x, int y) +{ + char cur_data[32 * (32 * 4)]; + char cur_mask[32 * (32 / 8)]; + char *mask; + char *data; + int i; + int j; + int w; + int h; + int p; + int xhot; + int yhot; + int paddedRowBytes; + int fgcolor; + int bgcolor; + int bpp; + + LLOGLN(10, ("rdpSpriteSetCursorCon:")); + + w = pCurs->bits->width; + h = pCurs->bits->height; + if ((pCurs->bits->argb != 0) && + (clientCon->client_info.pointer_flags & 1)) + { + bpp = 32; + paddedRowBytes = PixmapBytePad(w, 32); + xhot = pCurs->bits->xhot; + yhot = pCurs->bits->yhot; + data = (char *)(pCurs->bits->argb); + memset(cur_data, 0, sizeof(cur_data)); + memset(cur_mask, 0, sizeof(cur_mask)); + + for (j = 0; j < 32; j++) + { + for (i = 0; i < 32; i++) + { + p = get_pixel_safe(data, i, j, paddedRowBytes / 4, h, 32); + set_pixel_safe(cur_data, i, 31 - j, 32, 32, 32, p); + } + } + } + else + { + bpp = 0; + paddedRowBytes = PixmapBytePad(w, 1); + xhot = pCurs->bits->xhot; + yhot = pCurs->bits->yhot; + data = (char *)(pCurs->bits->source); + mask = (char *)(pCurs->bits->mask); + fgcolor = (((pCurs->foreRed >> 8) & 0xff) << 16) | + (((pCurs->foreGreen >> 8) & 0xff) << 8) | + ((pCurs->foreBlue >> 8) & 0xff); + bgcolor = (((pCurs->backRed >> 8) & 0xff) << 16) | + (((pCurs->backGreen >> 8) & 0xff) << 8) | + ((pCurs->backBlue >> 8) & 0xff); + memset(cur_data, 0, sizeof(cur_data)); + memset(cur_mask, 0, sizeof(cur_mask)); + + for (j = 0; j < 32; j++) + { + for (i = 0; i < 32; i++) + { + p = get_pixel_safe(mask, i, j, paddedRowBytes * 8, h, 1); + set_pixel_safe(cur_mask, i, 31 - j, 32, 32, 1, !p); + + if (p != 0) + { + p = get_pixel_safe(data, i, j, paddedRowBytes * 8, h, 1); + p = p ? fgcolor : bgcolor; + set_pixel_safe(cur_data, i, 31 - j, 32, 32, 24, p); + } + } + } + } + + rdpClientConBeginUpdate(clientCon->dev, clientCon); + rdpClientConSetCursorEx(clientCon->dev, clientCon, xhot, yhot, + cur_data, cur_mask, bpp); + rdpClientConEndUpdate(clientCon->dev, clientCon); + +} + +/******************************************************************************/ void rdpSpriteSetCursor(DeviceIntPtr pDev, ScreenPtr pScr, CursorPtr pCurs, int x, int y) { + rdpPtr dev; + rdpClientCon *clientCon; + LLOGLN(10, ("rdpSpriteSetCursor:")); + if (pCurs == 0) + { + return; + } + + if (pCurs->bits == 0) + { + return; + } + + dev = rdpGetDevFromScreen(pScr); + clientCon = dev->clientConHead; + while (clientCon != NULL) + { + rdpSpriteSetCursorCon(clientCon, pDev, pScr, pCurs, x, y); + clientCon = clientCon->next; + } } /******************************************************************************/ diff --git a/xorg/server/module/rdpReg.c b/xorg/server/module/rdpReg.c index 20600f66..8ff7d79d 100644 --- a/xorg/server/module/rdpReg.c +++ b/xorg/server/module/rdpReg.c @@ -244,3 +244,22 @@ rdpRegionUnionRect(RegionPtr pReg, BoxPtr prect) rdpRegionUnion(pReg, pReg, ®); rdpRegionUninit(®); } + +/*****************************************************************************/ +int +rdpRegionPixelCount(RegionPtr pReg) +{ + int index; + int count; + int rv; + BoxRec box; + + rv = 0; + count = REGION_NUM_RECTS(pReg); + for (index = 0; index < count; index++) + { + box = REGION_RECTS(pReg)[index]; + rv += (box.x2 - box.x1) * (box.y2 - box.y1); + } + return rv; +} diff --git a/xorg/server/module/rdpReg.h b/xorg/server/module/rdpReg.h index 38c4188a..a5cd73bf 100644 --- a/xorg/server/module/rdpReg.h +++ b/xorg/server/module/rdpReg.h @@ -58,5 +58,7 @@ Bool rdpRegionBreak(RegionPtr pReg); void rdpRegionUnionRect(RegionPtr pReg, BoxPtr prect); +int +rdpRegionPixelCount(RegionPtr pReg); #endif diff --git a/xrdp/xrdp.h b/xrdp/xrdp.h index 172d417a..e04dea5f 100644 --- a/xrdp/xrdp.h +++ b/xrdp/xrdp.h @@ -108,6 +108,8 @@ xrdp_wm_send_bitmap(struct xrdp_wm* self, struct xrdp_bitmap* bitmap, int x, int y, int cx, int cy); int APP_CC xrdp_wm_set_pointer(struct xrdp_wm* self, int cache_idx); +unsigned int APP_CC +xrdp_wm_htoi (const char *ptr); int APP_CC xrdp_wm_set_focused(struct xrdp_wm* self, struct xrdp_bitmap* wnd); int APP_CC @@ -349,6 +351,8 @@ get_keymaps(int keylayout, struct xrdp_keymap* keymap); /* xrdp_login_wnd.c */ int APP_CC xrdp_login_wnd_create(struct xrdp_wm* self); +int APP_CC +load_xrdp_config(struct xrdp_config *config); /* xrdp_bitmap_compress.c */ int APP_CC diff --git a/xrdp/xrdp_login_wnd.c b/xrdp/xrdp_login_wnd.c index 8011b468..bd63b0ec 100644 --- a/xrdp/xrdp_login_wnd.c +++ b/xrdp/xrdp_login_wnd.c @@ -559,7 +559,7 @@ xrdp_login_wnd_create(struct xrdp_wm *self) self->login_window->notify = xrdp_wm_login_notify; - gethostname(buf1, 256); + g_gethostname(buf1, 256); g_sprintf(buf, "Login to %s", buf1); set_string(&self->login_window->caption1, buf); @@ -642,7 +642,7 @@ xrdp_login_wnd_create(struct xrdp_wm *self) * * @return 0 on success, -1 on failure *****************************************************************************/ - +int APP_CC load_xrdp_config(struct xrdp_config *config) { struct xrdp_cfg_globals *globals; diff --git a/xrdp/xrdp_mm.c b/xrdp/xrdp_mm.c index e573efd9..6a1fd323 100644 --- a/xrdp/xrdp_mm.c +++ b/xrdp/xrdp_mm.c @@ -238,7 +238,7 @@ xrdp_mm_send_login(struct xrdp_mm *self) /*****************************************************************************/ /* returns error */ /* this goes through the login_names looking for one called 'aname' - then it copies the corisponding login_values item into 'dest' + then it copies the corresponding login_values item into 'dest' 'dest' must be at least 'dest_len' + 1 bytes in size */ static int APP_CC xrdp_mm_get_value(struct xrdp_mm *self, char *aname, char *dest, int dest_len) @@ -1511,7 +1511,7 @@ getPAMError(const int pamError, char *text, int text_bytes) case PAM_USER_UNKNOWN: return "User not known to the underlying authentication module"; case PAM_MAXTRIES: - return "Have exhasted maximum number of retries for service."; + return "Have exhausted maximum number of retries for service."; case PAM_NEW_AUTHTOK_REQD: return "Authentication token is no longer valid; new one required."; case PAM_ACCT_EXPIRED: diff --git a/xrdp/xrdp_wm.c b/xrdp/xrdp_wm.c index 0b1ca08a..e0657fac 100644 --- a/xrdp/xrdp_wm.c +++ b/xrdp/xrdp_wm.c @@ -323,7 +323,8 @@ xrdp_wm_set_pointer(struct xrdp_wm *self, int cache_idx) /*****************************************************************************/ /* convert hex string to int */ -unsigned int xrdp_wm_htoi (const char *ptr) +unsigned int APP_CC +xrdp_wm_htoi (const char *ptr) { unsigned int value = 0; char ch = *ptr; @@ -575,7 +576,7 @@ xrdp_wm_init(struct xrdp_wm *self) { if (autorun_name[0] == 0) { - /* if no doamin is passed, and no autorun in xrdp.ini, + /* if no domain is passed, and no autorun in xrdp.ini, use the first item in the xrdp.ini file thats not named 'globals' or 'Logging' or 'channels' */ @@ -1042,7 +1043,7 @@ xrdp_wm_mouse_move(struct xrdp_wm *self, int x, int y) b = xrdp_wm_at_pos(self->screen, x, y, 0); - if (b == 0) /* if b is null, the movment must be over the screen */ + if (b == 0) /* if b is null, the movement must be over the screen */ { if (self->screen->pointer != self->current_pointer) { @@ -1050,7 +1051,7 @@ xrdp_wm_mouse_move(struct xrdp_wm *self, int x, int y) self->current_pointer = self->screen->pointer; } - if (self->mm->mod != 0) /* if screen is mod controled */ + if (self->mm->mod != 0) /* if screen is mod controlled */ { if (self->mm->mod->mod_event != 0) { @@ -1189,7 +1190,7 @@ xrdp_wm_mouse_click(struct xrdp_wm *self, int x, int y, int but, int down) if (control == 0) { - if (self->mm->mod != 0) /* if screen is mod controled */ + if (self->mm->mod != 0) /* if screen is mod controlled */ { if (self->mm->mod->mod_event != 0) { @@ -1738,7 +1739,7 @@ xrdp_wm_login_mode_changed(struct xrdp_wm *self) } /*****************************************************************************/ -/* this is the log windows nofity function */ +/* this is the log windows notify function */ static int DEFAULT_CC xrdp_wm_log_wnd_notify(struct xrdp_bitmap *wnd, struct xrdp_bitmap *sender, @@ -435,6 +435,287 @@ lib_mod_event(struct mod *mod, int msg, tbus param1, tbus param2, /******************************************************************************/ /* return error */ static int APP_CC +process_server_fill_rect(struct mod *mod, struct stream *s) +{ + int rv; + int x; + int y; + int cx; + int cy; + + in_sint16_le(s, x); + in_sint16_le(s, y); + in_uint16_le(s, cx); + in_uint16_le(s, cy); + rv = mod->server_fill_rect(mod, x, y, cx, cy); + return rv; +} + +/******************************************************************************/ +/* return error */ +static int APP_CC +process_server_screen_blt(struct mod *mod, struct stream *s) +{ + int rv; + int x; + int y; + int cx; + int cy; + int srcx; + int srcy; + + in_sint16_le(s, x); + in_sint16_le(s, y); + in_uint16_le(s, cx); + in_uint16_le(s, cy); + in_sint16_le(s, srcx); + in_sint16_le(s, srcy); + rv = mod->server_screen_blt(mod, x, y, cx, cy, srcx, srcy); + return rv; +} + +/******************************************************************************/ +/* return error */ +static int APP_CC +process_server_paint_rect(struct mod *mod, struct stream *s) +{ + int rv; + int x; + int y; + int cx; + int cy; + int len_bmpdata; + char *bmpdata; + int width; + int height; + int srcx; + int srcy; + + in_sint16_le(s, x); + in_sint16_le(s, y); + in_uint16_le(s, cx); + in_uint16_le(s, cy); + in_uint32_le(s, len_bmpdata); + in_uint8p(s, bmpdata, len_bmpdata); + in_uint16_le(s, width); + in_uint16_le(s, height); + in_sint16_le(s, srcx); + in_sint16_le(s, srcy); + rv = mod->server_paint_rect(mod, x, y, cx, cy, + bmpdata, width, height, + srcx, srcy); + return rv; +} + +/******************************************************************************/ +/* return error */ +static int APP_CC +process_server_set_clip(struct mod *mod, struct stream *s) +{ + int rv; + int x; + int y; + int cx; + int cy; + + in_sint16_le(s, x); + in_sint16_le(s, y); + in_uint16_le(s, cx); + in_uint16_le(s, cy); + rv = mod->server_set_clip(mod, x, y, cx, cy); + return rv; +} + +/******************************************************************************/ +/* return error */ +static int APP_CC +process_server_reset_clip(struct mod *mod, struct stream *s) +{ + int rv; + + rv = mod->server_reset_clip(mod); + return rv; +} + +/******************************************************************************/ +/* return error */ +static int APP_CC +process_server_set_fgcolor(struct mod *mod, struct stream *s) +{ + int rv; + int fgcolor; + + in_uint32_le(s, fgcolor); + rv = mod->server_set_fgcolor(mod, fgcolor); + return rv; +} + +/******************************************************************************/ +/* return error */ +static int APP_CC +process_server_set_bgcolor(struct mod *mod, struct stream *s) +{ + int rv; + int bgcolor; + + in_uint32_le(s, bgcolor); + rv = mod->server_set_bgcolor(mod, bgcolor); + return rv; +} + +/******************************************************************************/ +/* return error */ +static int APP_CC +process_server_set_opcode(struct mod *mod, struct stream *s) +{ + int rv; + int opcode; + + in_uint16_le(s, opcode); + rv = mod->server_set_opcode(mod, opcode); + return rv; +} + +/******************************************************************************/ +/* return error */ +static int APP_CC +process_server_set_pen(struct mod *mod, struct stream *s) +{ + int rv; + int style; + int width; + + in_uint16_le(s, style); + in_uint16_le(s, width); + rv = mod->server_set_pen(mod, style, width); + return rv; +} + +/******************************************************************************/ +/* return error */ +static int APP_CC +process_server_draw_line(struct mod *mod, struct stream *s) +{ + int rv; + int x1; + int y1; + int x2; + int y2; + + in_sint16_le(s, x1); + in_sint16_le(s, y1); + in_sint16_le(s, x2); + in_sint16_le(s, y2); + rv = mod->server_draw_line(mod, x1, y1, x2, y2); + return rv; +} + +/******************************************************************************/ +/* return error */ +static int APP_CC +process_server_set_cursor(struct mod *mod, struct stream *s) +{ + int rv; + int x; + int y; + char cur_data[32 * (32 * 3)]; + char cur_mask[32 * (32 / 8)]; + + in_sint16_le(s, x); + in_sint16_le(s, y); + in_uint8a(s, cur_data, 32 * (32 * 3)); + in_uint8a(s, cur_mask, 32 * (32 / 8)); + rv = mod->server_set_cursor(mod, x, y, cur_data, cur_mask); + return rv; +} + +/******************************************************************************/ +/* return error */ +static int APP_CC +process_server_create_os_surface(struct mod *mod, struct stream *s) +{ + int rv; + int rdpid; + int width; + int height; + + in_uint32_le(s, rdpid); + in_uint16_le(s, width); + in_uint16_le(s, height); + rv = mod->server_create_os_surface(mod, rdpid, width, height); + return rv; +} + +/******************************************************************************/ +/* return error */ +static int APP_CC +process_server_switch_os_surface(struct mod *mod, struct stream *s) +{ + int rv; + int rdpid; + + in_uint32_le(s, rdpid); + rv = mod->server_switch_os_surface(mod, rdpid); + return rv; +} + +/******************************************************************************/ +/* return error */ +static int APP_CC +process_server_delete_os_surface(struct mod *mod, struct stream *s) +{ + int rv; + int rdpid; + + in_uint32_le(s, rdpid); + rv = mod->server_delete_os_surface(mod, rdpid); + return rv; +} + +/******************************************************************************/ +/* return error */ +static int APP_CC +process_server_paint_rect_os(struct mod *mod, struct stream *s) +{ + int rv; + int x; + int y; + int cx; + int cy; + int rdpid; + int srcx; + int srcy; + + in_sint16_le(s, x); + in_sint16_le(s, y); + in_uint16_le(s, cx); + in_uint16_le(s, cy); + in_uint32_le(s, rdpid); + in_sint16_le(s, srcx); + in_sint16_le(s, srcy); + rv = mod->server_paint_rect_os(mod, x, y, cx, cy, + rdpid, srcx, srcy); + return rv; +} + +/******************************************************************************/ +/* return error */ +static int APP_CC +process_server_set_hints(struct mod *mod, struct stream *s) +{ + int rv; + int hints; + int mask; + + in_uint32_le(s, hints); + in_uint32_le(s, mask); + rv = mod->server_set_hints(mod, hints, mask); + return rv; +} + +/******************************************************************************/ +/* return error */ +static int APP_CC process_server_window_new_update(struct mod *mod, struct stream *s) { int flags; @@ -518,6 +799,20 @@ process_server_window_new_update(struct mod *mod, struct stream *s) /******************************************************************************/ /* return error */ static int APP_CC +process_server_window_delete(struct mod *mod, struct stream *s) +{ + int window_id; + int rv; + + in_uint32_le(s, window_id); + mod->server_window_delete(mod, window_id); + rv = 0; + return rv; +} + +/******************************************************************************/ +/* return error */ +static int APP_CC process_server_window_show(struct mod* mod, struct stream* s) { int window_id; @@ -537,14 +832,209 @@ process_server_window_show(struct mod* mod, struct stream* s) /******************************************************************************/ /* return error */ static int APP_CC -process_server_window_delete(struct mod *mod, struct stream *s) +process_server_add_char(struct mod *mod, struct stream *s) { - int window_id; int rv; + int font; + int charactor; + int x; + int y; + int cx; + int cy; + int len_bmpdata; + char *bmpdata; - in_uint32_le(s, window_id); - mod->server_window_delete(mod, window_id); - rv = 0; + in_uint16_le(s, font); + in_uint16_le(s, charactor); + in_sint16_le(s, x); + in_sint16_le(s, y); + in_uint16_le(s, cx); + in_uint16_le(s, cy); + in_uint16_le(s, len_bmpdata); + in_uint8p(s, bmpdata, len_bmpdata); + rv = mod->server_add_char(mod, font, charactor, x, y, cx, cy, bmpdata); + return rv; +} + + +/******************************************************************************/ +/* return error */ +static int APP_CC +process_server_add_char_alpha(struct mod *mod, struct stream *s) +{ + int rv; + int font; + int charactor; + int x; + int y; + int cx; + int cy; + int len_bmpdata; + char *bmpdata; + + in_uint16_le(s, font); + in_uint16_le(s, charactor); + in_sint16_le(s, x); + in_sint16_le(s, y); + in_uint16_le(s, cx); + in_uint16_le(s, cy); + in_uint16_le(s, len_bmpdata); + in_uint8p(s, bmpdata, len_bmpdata); + rv = mod->server_add_char_alpha(mod, font, charactor, x, y, cx, cy, + bmpdata); + return rv; +} + +/******************************************************************************/ +/* return error */ +static int APP_CC +process_server_draw_text(struct mod *mod, struct stream *s) +{ + int rv; + int font; + int flags; + int mixmode; + int clip_left; + int clip_top; + int clip_right; + int clip_bottom; + int box_left; + int box_top; + int box_right; + int box_bottom; + int x; + int y; + int len_bmpdata; + char *bmpdata; + + in_uint16_le(s, font); + in_uint16_le(s, flags); + in_uint16_le(s, mixmode); + in_sint16_le(s, clip_left); + in_sint16_le(s, clip_top); + in_sint16_le(s, clip_right); + in_sint16_le(s, clip_bottom); + in_sint16_le(s, box_left); + in_sint16_le(s, box_top); + in_sint16_le(s, box_right); + in_sint16_le(s, box_bottom); + in_sint16_le(s, x); + in_sint16_le(s, y); + in_uint16_le(s, len_bmpdata); + in_uint8p(s, bmpdata, len_bmpdata); + rv = mod->server_draw_text(mod, font, flags, mixmode, clip_left, clip_top, + clip_right, clip_bottom, box_left, box_top, + box_right, box_bottom, x, y, bmpdata, len_bmpdata); + return rv; +} + +/******************************************************************************/ +/* return error */ +static int APP_CC +process_server_create_os_surface_bpp(struct mod *mod, struct stream *s) +{ + int rv; + int rdpid; + int width; + int height; + int bpp; + + in_uint32_le(s, rdpid); + in_uint16_le(s, width); + in_uint16_le(s, height); + in_uint8(s, bpp); + rv = mod->server_create_os_surface_bpp(mod, rdpid, width, height, bpp); + return rv; +} + + +/******************************************************************************/ +/* return error */ +static int APP_CC +process_server_paint_rect_bpp(struct mod *mod, struct stream *s) +{ + int rv; + int x; + int y; + int cx; + int cy; + int len_bmpdata; + char *bmpdata; + int width; + int height; + int srcx; + int srcy; + int bpp; + + in_sint16_le(s, x); + in_sint16_le(s, y); + in_uint16_le(s, cx); + in_uint16_le(s, cy); + in_uint32_le(s, len_bmpdata); + in_uint8p(s, bmpdata, len_bmpdata); + in_uint16_le(s, width); + in_uint16_le(s, height); + in_sint16_le(s, srcx); + in_sint16_le(s, srcy); + in_uint8(s, bpp); + rv = mod->server_paint_rect_bpp(mod, x, y, cx, cy, + bmpdata, width, height, + srcx, srcy, bpp); + return rv; +} + +/******************************************************************************/ +/* return error */ +static int APP_CC +process_server_composite(struct mod *mod, struct stream *s) +{ + int rv; + int srcidx; + int srcformat; + int srcwidth; + int srcrepeat; + int transform[10]; + int mskflags; + int mskidx; + int mskformat; + int mskwidth; + int mskrepeat; + int op; + int srcx; + int srcy; + int mskx; + int msky; + int dstx; + int dsty; + int width; + int height; + int dstformat; + + in_uint16_le(s, srcidx); + in_uint32_le(s, srcformat); + in_uint16_le(s, srcwidth); + in_uint8(s, srcrepeat); + g_memcpy(transform, s->p, 40); + in_uint8s(s, 40); + in_uint8(s, mskflags); + in_uint16_le(s, mskidx); + in_uint32_le(s, mskformat); + in_uint16_le(s, mskwidth); + in_uint8(s, mskrepeat); + in_uint8(s, op); + in_sint16_le(s, srcx); + in_sint16_le(s, srcy); + in_sint16_le(s, mskx); + in_sint16_le(s, msky); + in_sint16_le(s, dstx); + in_sint16_le(s, dsty); + in_uint16_le(s, width); + in_uint16_le(s, height); + in_uint32_le(s, dstformat); + rv = mod->server_composite(mod, srcidx, srcformat, srcwidth, srcrepeat, + transform, mskflags, mskidx, mskformat, + mskwidth, mskrepeat, op, srcx, srcy, mskx, msky, + dstx, dsty, width, height, dstformat); return rv; } @@ -602,67 +1092,124 @@ send_paint_rect_ack(struct mod *mod, int flags, int x, int y, int cx, int cy, /******************************************************************************/ /* return error */ static int APP_CC -lib_mod_process_orders(struct mod *mod, int type, struct stream *s) +process_server_paint_rect_shmem(struct mod *mod, struct stream *s) { int rv; int x; int y; int cx; int cy; - int srcx; - int srcy; - int mskx; - int msky; - int dstx; - int dsty; - int len_bmpdata; - int style; - int x1; - int y1; - int x2; - int y2; - int bpp; - int rdpid; - int hints; - int mask; + int flags; + int frame_id; + int shmem_id; + int shmem_offset; int width; int height; - int fgcolor; - int bgcolor; - int opcode; + int srcx; + int srcy; + char *bmpdata; + + in_sint16_le(s, x); + in_sint16_le(s, y); + in_uint16_le(s, cx); + in_uint16_le(s, cy); + in_uint32_le(s, flags); + in_uint32_le(s, frame_id); + in_uint32_le(s, shmem_id); + in_uint32_le(s, shmem_offset); + in_uint16_le(s, width); + in_uint16_le(s, height); + in_sint16_le(s, srcx); + in_sint16_le(s, srcy); + bmpdata = 0; + if (flags == 0) /* screen */ + { + if (mod->screen_shmem_id == 0) + { + mod->screen_shmem_id = shmem_id; + mod->screen_shmem_pixels = g_shmat(mod->screen_shmem_id); + } + if (mod->screen_shmem_pixels != 0) + { + bmpdata = mod->screen_shmem_pixels + shmem_offset; + } + } + if (bmpdata != 0) + { + rv = mod->server_paint_rect(mod, x, y, cx, cy, + bmpdata, width, height, + srcx, srcy); + } + else + { + rv = 1; + } + send_paint_rect_ack(mod, flags, x, y, cx, cy, frame_id); + return rv; +} + +/******************************************************************************/ +/* return error */ +static int APP_CC +send_paint_rect_ex_ack(struct mod *mod, int flags, int frame_id) +{ + int len; + struct stream *s; + + make_stream(s); + init_stream(s, 8192); + s_push_layer(s, iso_hdr, 4); + out_uint16_le(s, 106); + out_uint32_le(s, flags); + out_uint32_le(s, frame_id); + s_mark_end(s); + len = (int)(s->end - s->data); + s_pop_layer(s, iso_hdr); + out_uint32_le(s, len); + lib_send(mod, s->data, len); + free_stream(s); + return 0; +} + +/******************************************************************************/ +/* return error */ +static int APP_CC +process_server_paint_rect_shmem_ex(struct mod *mod, struct stream *s) +{ + int num_rects; int flags; + int frame_id; int shmem_id; int shmem_offset; - int frame_id; - int charactor; - int font; - int mixmode; - int clip_left; - int clip_top; - int clip_right; - int clip_bottom; - int box_left; - int box_top; - int box_right; - int box_bottom; - int srcrepeat; - int srcidx; - int srcformat; - int srcwidth; - int mskflags; - int mskidx; - int mskformat; - int mskwidth; - int mskrepeat; - int dstformat; - int op; - int transform[10]; - char *bmpdata; - char cur_data[32 * (32 * 3)]; - char cur_mask[32 * (32 / 8)]; + int width; + int height; - rv = 0; + in_uint16_le(s, num_rects); + in_uint8s(s, num_rects * 8); + in_uint16_le(s, num_rects); + in_uint8s(s, num_rects * 8); + in_uint32_le(s, flags); + in_uint32_le(s, frame_id); + in_uint32_le(s, shmem_id); + in_uint32_le(s, shmem_offset); + + in_uint16_le(s, width); + in_uint16_le(s, height); + + send_paint_rect_ex_ack(mod, flags, frame_id); + + return 0; +} + +/******************************************************************************/ +/* return error */ +static int APP_CC +lib_mod_process_orders(struct mod *mod, int type, struct stream *s) +{ + int rv; + + rv = 0; switch (type) { case 1: /* server_begin_update */ @@ -672,106 +1219,52 @@ lib_mod_process_orders(struct mod *mod, int type, struct stream *s) rv = mod->server_end_update(mod); break; case 3: /* server_fill_rect */ - in_sint16_le(s, x); - in_sint16_le(s, y); - in_uint16_le(s, cx); - in_uint16_le(s, cy); - rv = mod->server_fill_rect(mod, x, y, cx, cy); + rv = process_server_fill_rect(mod, s); break; case 4: /* server_screen_blt */ - in_sint16_le(s, x); - in_sint16_le(s, y); - in_uint16_le(s, cx); - in_uint16_le(s, cy); - in_sint16_le(s, srcx); - in_sint16_le(s, srcy); - rv = mod->server_screen_blt(mod, x, y, cx, cy, srcx, srcy); + rv = process_server_screen_blt(mod, s); break; case 5: /* server_paint_rect */ - in_sint16_le(s, x); - in_sint16_le(s, y); - in_uint16_le(s, cx); - in_uint16_le(s, cy); - in_uint32_le(s, len_bmpdata); - in_uint8p(s, bmpdata, len_bmpdata); - in_uint16_le(s, width); - in_uint16_le(s, height); - in_sint16_le(s, srcx); - in_sint16_le(s, srcy); - rv = mod->server_paint_rect(mod, x, y, cx, cy, - bmpdata, width, height, - srcx, srcy); + rv = process_server_paint_rect(mod, s); break; case 10: /* server_set_clip */ - in_sint16_le(s, x); - in_sint16_le(s, y); - in_uint16_le(s, cx); - in_uint16_le(s, cy); - rv = mod->server_set_clip(mod, x, y, cx, cy); + rv = process_server_set_clip(mod, s); break; case 11: /* server_reset_clip */ - rv = mod->server_reset_clip(mod); + rv = process_server_reset_clip(mod, s); break; case 12: /* server_set_fgcolor */ - in_uint32_le(s, fgcolor); - rv = mod->server_set_fgcolor(mod, fgcolor); + rv = process_server_set_fgcolor(mod, s); break; case 13: /* server_set_bgcolor */ - in_uint32_le(s, bgcolor); - rv = mod->server_set_bgcolor(mod, bgcolor); + rv = process_server_set_bgcolor(mod, s); break; - case 14: - in_uint16_le(s, opcode); - rv = mod->server_set_opcode(mod, opcode); + case 14: /* server_set_opcode */ + rv = process_server_set_opcode(mod, s); break; - case 17: - in_uint16_le(s, style); - in_uint16_le(s, width); - rv = mod->server_set_pen(mod, style, width); + case 17: /* server_set_pen */ + rv = process_server_set_pen(mod, s); break; - case 18: - in_sint16_le(s, x1); - in_sint16_le(s, y1); - in_sint16_le(s, x2); - in_sint16_le(s, y2); - rv = mod->server_draw_line(mod, x1, y1, x2, y2); + case 18: /* server_draw_line */ + rv = process_server_draw_line(mod, s); break; - case 19: - in_sint16_le(s, x); - in_sint16_le(s, y); - in_uint8a(s, cur_data, 32 * (32 * 3)); - in_uint8a(s, cur_mask, 32 * (32 / 8)); - rv = mod->server_set_cursor(mod, x, y, cur_data, cur_mask); + case 19: /* server_set_cursor */ + rv = process_server_set_cursor(mod, s); break; - case 20: - in_uint32_le(s, rdpid); - in_uint16_le(s, width); - in_uint16_le(s, height); - rv = mod->server_create_os_surface(mod, rdpid, width, height); + case 20: /* server_create_os_surface */ + rv = process_server_create_os_surface(mod, s); break; - case 21: - in_uint32_le(s, rdpid); - rv = mod->server_switch_os_surface(mod, rdpid); + case 21: /* server_switch_os_surface */ + rv = process_server_switch_os_surface(mod, s); break; - case 22: - in_uint32_le(s, rdpid); - rv = mod->server_delete_os_surface(mod, rdpid); + case 22: /* server_delete_os_surface */ + rv = process_server_delete_os_surface(mod, s); break; case 23: /* server_paint_rect_os */ - in_sint16_le(s, x); - in_sint16_le(s, y); - in_uint16_le(s, cx); - in_uint16_le(s, cy); - in_uint32_le(s, rdpid); - in_sint16_le(s, srcx); - in_sint16_le(s, srcy); - rv = mod->server_paint_rect_os(mod, x, y, cx, cy, - rdpid, srcx, srcy); + rv = process_server_paint_rect_os(mod, s); break; case 24: /* server_set_hints */ - in_uint32_le(s, hints); - in_uint32_le(s, mask); - rv = mod->server_set_hints(mod, hints, mask); + rv = process_server_set_hints(mod, s); break; case 25: /* server_window_new_update */ rv = process_server_window_new_update(mod, s); @@ -783,149 +1276,40 @@ lib_mod_process_orders(struct mod *mod, int type, struct stream *s) rv = process_server_window_show(mod, s); break; case 28: /* server_add_char */ - in_uint16_le(s, font); - in_uint16_le(s, charactor); - in_sint16_le(s, x); - in_sint16_le(s, y); - in_uint16_le(s, cx); - in_uint16_le(s, cy); - in_uint16_le(s, len_bmpdata); - in_uint8p(s, bmpdata, len_bmpdata); - rv = mod->server_add_char(mod, font, charactor, x, y, cx, cy, bmpdata); + rv = process_server_add_char(mod, s); break; case 29: /* server_add_char_alpha */ - in_uint16_le(s, font); - in_uint16_le(s, charactor); - in_sint16_le(s, x); - in_sint16_le(s, y); - in_uint16_le(s, cx); - in_uint16_le(s, cy); - in_uint16_le(s, len_bmpdata); - in_uint8p(s, bmpdata, len_bmpdata); - rv = mod->server_add_char_alpha(mod, font, charactor, x, y, cx, cy, bmpdata); + rv = process_server_add_char_alpha(mod, s); break; case 30: /* server_draw_text */ - in_uint16_le(s, font); - in_uint16_le(s, flags); - in_uint16_le(s, mixmode); - in_sint16_le(s, clip_left); - in_sint16_le(s, clip_top); - in_sint16_le(s, clip_right); - in_sint16_le(s, clip_bottom); - in_sint16_le(s, box_left); - in_sint16_le(s, box_top); - in_sint16_le(s, box_right); - in_sint16_le(s, box_bottom); - in_sint16_le(s, x); - in_sint16_le(s, y); - in_uint16_le(s, len_bmpdata); - in_uint8p(s, bmpdata, len_bmpdata); - rv = mod->server_draw_text(mod, font, flags, mixmode, clip_left, clip_top, - clip_right, clip_bottom, box_left, box_top, - box_right, box_bottom, x, y, bmpdata, len_bmpdata); + rv = process_server_draw_text(mod, s); break; case 31: /* server_create_os_surface_bpp */ - in_uint32_le(s, rdpid); - in_uint16_le(s, width); - in_uint16_le(s, height); - in_uint8(s, bpp); - rv = mod->server_create_os_surface_bpp(mod, rdpid, width, height, bpp); + rv = process_server_create_os_surface_bpp(mod, s); break; case 32: /* server_paint_rect_bpp */ - in_sint16_le(s, x); - in_sint16_le(s, y); - in_uint16_le(s, cx); - in_uint16_le(s, cy); - in_uint32_le(s, len_bmpdata); - in_uint8p(s, bmpdata, len_bmpdata); - in_uint16_le(s, width); - in_uint16_le(s, height); - in_sint16_le(s, srcx); - in_sint16_le(s, srcy); - in_uint8(s, bpp); - rv = mod->server_paint_rect_bpp(mod, x, y, cx, cy, - bmpdata, width, height, - srcx, srcy, bpp); + rv = process_server_paint_rect_bpp(mod, s); break; - case 33: - in_uint16_le(s, srcidx); - in_uint32_le(s, srcformat); - in_uint16_le(s, srcwidth); - in_uint8(s, srcrepeat); - g_memcpy(transform, s->p, 40); - in_uint8s(s, 40); - in_uint8(s, mskflags); - in_uint16_le(s, mskidx); - in_uint32_le(s, mskformat); - in_uint16_le(s, mskwidth); - in_uint8(s, mskrepeat); - in_uint8(s, op); - in_sint16_le(s, srcx); - in_sint16_le(s, srcy); - in_sint16_le(s, mskx); - in_sint16_le(s, msky); - in_sint16_le(s, dstx); - in_sint16_le(s, dsty); - in_uint16_le(s, width); - in_uint16_le(s, height); - in_uint32_le(s, dstformat); - rv = mod->server_composite(mod, srcidx, srcformat, srcwidth, srcrepeat, - transform, mskflags, mskidx, mskformat, - mskwidth, mskrepeat, op, srcx, srcy, mskx, msky, - dstx, dsty, width, height, dstformat); + case 33: /* server_composite */ + rv = process_server_composite(mod, s); break; case 51: /* server_set_pointer_ex */ rv = process_server_set_pointer_ex(mod, s); break; case 60: /* server_paint_rect_shmem */ - in_sint16_le(s, x); - in_sint16_le(s, y); - in_uint16_le(s, cx); - in_uint16_le(s, cy); - in_uint32_le(s, flags); - in_uint32_le(s, frame_id); - in_uint32_le(s, shmem_id); - in_uint32_le(s, shmem_offset); - in_uint16_le(s, width); - in_uint16_le(s, height); - in_sint16_le(s, srcx); - in_sint16_le(s, srcy); - bmpdata = 0; - if (flags == 0) /* screen */ - { - if (mod->screen_shmem_id == 0) - { - mod->screen_shmem_id = shmem_id; - mod->screen_shmem_pixels = g_shmat(mod->screen_shmem_id); - } - if (mod->screen_shmem_pixels != 0) - { - bmpdata = mod->screen_shmem_pixels + shmem_offset; - } - } - if (bmpdata != 0) - { - rv = mod->server_paint_rect(mod, x, y, cx, cy, - bmpdata, width, height, - srcx, srcy); - } - else - { - rv = 1; - } - send_paint_rect_ack(mod, flags, x, y, cx, cy, frame_id); + rv = process_server_paint_rect_shmem(mod, s); + break; + case 61: /* server_paint_rect_shmem_ex */ + rv = process_server_paint_rect_shmem_ex(mod, s); break; - default: g_writeln("lib_mod_process_orders: unknown order type %d", type); rv = 0; break; } - return rv; } - /******************************************************************************/ /* return error */ static int APP_CC |