Merge branch 'devel' of github.com:/neutrinolabs/xrdp into devel

ulab-next
Laxmikant Rashinkar 11 years ago
commit c5c8324d91

@ -1,7 +1,7 @@
/** /**
* xrdp: A Remote Desktop Protocol server. * 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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with 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 * 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) #if defined(HAVE_CONFIG_H)
#include "config_ac.h" #include "config_ac.h"
#endif #endif
@ -60,6 +65,13 @@
#include <stdio.h> #include <stdio.h>
#include <locale.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 "os_calls.h"
#include "arch.h" #include "arch.h"
#include "log.h" #include "log.h"
@ -596,10 +608,16 @@ g_tcp_local_socket(void)
} }
/*****************************************************************************/ /*****************************************************************************/
/* returns error */
int APP_CC int APP_CC
g_sck_get_peer_cred(int sck, int *pid, int *uid, int *gid) g_sck_get_peer_cred(int sck, int *pid, int *uid, int *gid)
{ {
#if defined(SO_PEERCRED)
#if defined(_WIN32)
int ucred_length; int ucred_length;
#else
unsigned int ucred_length;
#endif
struct myucred struct myucred
{ {
pid_t pid; pid_t pid;
@ -625,6 +643,9 @@ g_sck_get_peer_cred(int sck, int *pid, int *uid, int *gid)
*gid = credentials.gid; *gid = credentials.gid;
} }
return 0; return 0;
#else
return 1;
#endif
} }
/*****************************************************************************/ /*****************************************************************************/
@ -3122,15 +3143,33 @@ g_text2bool(const char *s)
} }
/*****************************************************************************/ /*****************************************************************************/
/* returns pointer or nil on error */
void * APP_CC void * APP_CC
g_shmat(int shmid) 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 int APP_CC
g_shmdt(const void *shmaddr) g_shmdt(const void *shmaddr)
{ {
#if defined(_WIN32)
return -1;
#else
return shmdt(shmaddr); return shmdt(shmaddr);
#endif
}
/*****************************************************************************/
/* returns -1 on error 0 on success */
int APP_CC
g_gethostname(char *name, int len)
{
return gethostname(name, len);
} }

@ -163,5 +163,6 @@ int APP_CC g_time3(void);
int APP_CC g_text2bool(const char *s); int APP_CC g_text2bool(const char *s);
void * APP_CC g_shmat(int shmid); void * APP_CC g_shmat(int shmid);
int APP_CC g_shmdt(const void *shmaddr); int APP_CC g_shmdt(const void *shmaddr);
int APP_CC g_gethostname(char *name, int len);
#endif #endif

@ -1,6 +1,7 @@
CFLAGS = -O2 -Wall -I../../common
LDFLAGS = -Wl CFLAGS = -O2 -Wall
OBJS = main.o ../../common/os_calls.o LDFLAGS =
OBJS = main.o
LIBS = -ldl LIBS = -ldl
all: tcp_proxy all: tcp_proxy

@ -1,7 +1,7 @@
/** /**
* xrdp: A Remote Desktop Protocol server. * 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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -16,7 +16,20 @@
* limitations under the License. * 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_loc_io_count = 0; // bytes read from local port
int g_rem_io_count = 0; // bytes read from remote 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 int g_terminated = 0;
static char g_buf[1024 * 32]; 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 static int
main_loop(char *local_port, char *remote_ip, char *remote_port, int hexdump) main_loop(char *local_port, char *remote_ip, char *remote_port, int hexdump)

@ -32,6 +32,27 @@ Sets up the functions
#define DEBUG_OUT(arg) ErrorF arg #define DEBUG_OUT(arg) ErrorF arg
#endif #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 */ rdpScreenInfoRec g_rdpScreen; /* the one screen */
ScreenPtr g_pScreen = 0; ScreenPtr g_pScreen = 0;
@ -233,6 +254,16 @@ rdpDestroyColormap(ColormapPtr pColormap)
} }
#endif #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 */ /* returns boolean, true if everything is ok */
static Bool static Bool
@ -549,6 +580,8 @@ rdpScreenInit(int index, ScreenPtr pScreen, int argc, char **argv)
//rdpXvInit(pScreen); //rdpXvInit(pScreen);
rdpSetUDSRights();
ErrorF("rdpScreenInit: ret %d\n", ret); ErrorF("rdpScreenInit: ret %d\n", ret);
return ret; return ret;
@ -620,6 +653,11 @@ ddxProcessArgument(int argc, char **argv, int i)
void void
OsVendorInit(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
} }
/******************************************************************************/ /******************************************************************************/

@ -143,9 +143,19 @@ rdpClientConAddDirtyScreenBox(rdpPtr dev, rdpClientCon *clientCon,
int int
rdpClientConAddDirtyScreen(rdpPtr dev, rdpClientCon *clientCon, rdpClientConAddDirtyScreen(rdpPtr dev, rdpClientCon *clientCon,
int x, int y, int cx, int cy); int x, int y, int cx, int cy);
void
rdpClientConGetScreenImageRect(rdpPtr dev, rdpClientCon *clientCon,
struct image_data *id);
int int
rdpClientConAddAllReg(rdpPtr dev, RegionPtr reg, DrawablePtr pDrawable); rdpClientConAddAllReg(rdpPtr dev, RegionPtr reg, DrawablePtr pDrawable);
int int
rdpClientConAddAllBox(rdpPtr dev, BoxPtr box, DrawablePtr pDrawable); 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 #endif

@ -36,9 +36,50 @@ cursor
#include <fb.h> #include <fb.h>
#include <micmap.h> #include <micmap.h>
#include <mi.h> #include <mi.h>
#include <cursor.h>
#include <cursorstr.h>
#include "rdp.h" #include "rdp.h"
#include "rdpMain.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 #define LOG_LEVEL 1
@ -61,12 +102,226 @@ rdpSpriteUnrealizeCursor(DeviceIntPtr pDev, ScreenPtr pScr, CursorPtr pCurs)
return TRUE; return TRUE;
} }
/******************************************************************************/
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 void
rdpSpriteSetCursor(DeviceIntPtr pDev, ScreenPtr pScr, CursorPtr pCurs, rdpSpriteSetCursor(DeviceIntPtr pDev, ScreenPtr pScr, CursorPtr pCurs,
int x, int y) int x, int y)
{ {
rdpPtr dev;
rdpClientCon *clientCon;
LLOGLN(10, ("rdpSpriteSetCursor:")); 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;
}
} }
/******************************************************************************/ /******************************************************************************/

@ -244,3 +244,22 @@ rdpRegionUnionRect(RegionPtr pReg, BoxPtr prect)
rdpRegionUnion(pReg, pReg, &reg); rdpRegionUnion(pReg, pReg, &reg);
rdpRegionUninit(&reg); rdpRegionUninit(&reg);
} }
/*****************************************************************************/
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;
}

@ -58,5 +58,7 @@ Bool
rdpRegionBreak(RegionPtr pReg); rdpRegionBreak(RegionPtr pReg);
void void
rdpRegionUnionRect(RegionPtr pReg, BoxPtr prect); rdpRegionUnionRect(RegionPtr pReg, BoxPtr prect);
int
rdpRegionPixelCount(RegionPtr pReg);
#endif #endif

@ -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 x, int y, int cx, int cy);
int APP_CC int APP_CC
xrdp_wm_set_pointer(struct xrdp_wm* self, int cache_idx); xrdp_wm_set_pointer(struct xrdp_wm* self, int cache_idx);
unsigned int APP_CC
xrdp_wm_htoi (const char *ptr);
int APP_CC int APP_CC
xrdp_wm_set_focused(struct xrdp_wm* self, struct xrdp_bitmap* wnd); xrdp_wm_set_focused(struct xrdp_wm* self, struct xrdp_bitmap* wnd);
int APP_CC int APP_CC
@ -349,6 +351,8 @@ get_keymaps(int keylayout, struct xrdp_keymap* keymap);
/* xrdp_login_wnd.c */ /* xrdp_login_wnd.c */
int APP_CC int APP_CC
xrdp_login_wnd_create(struct xrdp_wm* self); xrdp_login_wnd_create(struct xrdp_wm* self);
int APP_CC
load_xrdp_config(struct xrdp_config *config);
/* xrdp_bitmap_compress.c */ /* xrdp_bitmap_compress.c */
int APP_CC int APP_CC

@ -559,7 +559,7 @@ xrdp_login_wnd_create(struct xrdp_wm *self)
self->login_window->notify = xrdp_wm_login_notify; self->login_window->notify = xrdp_wm_login_notify;
gethostname(buf1, 256); g_gethostname(buf1, 256);
g_sprintf(buf, "Login to %s", buf1); g_sprintf(buf, "Login to %s", buf1);
set_string(&self->login_window->caption1, buf); 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 * @return 0 on success, -1 on failure
*****************************************************************************/ *****************************************************************************/
int APP_CC
load_xrdp_config(struct xrdp_config *config) load_xrdp_config(struct xrdp_config *config)
{ {
struct xrdp_cfg_globals *globals; struct xrdp_cfg_globals *globals;

@ -238,7 +238,7 @@ xrdp_mm_send_login(struct xrdp_mm *self)
/*****************************************************************************/ /*****************************************************************************/
/* returns error */ /* returns error */
/* this goes through the login_names looking for one called 'aname' /* 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 */ 'dest' must be at least 'dest_len' + 1 bytes in size */
static int APP_CC static int APP_CC
xrdp_mm_get_value(struct xrdp_mm *self, char *aname, char *dest, int dest_len) 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: case PAM_USER_UNKNOWN:
return "User not known to the underlying authentication module"; return "User not known to the underlying authentication module";
case PAM_MAXTRIES: 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: case PAM_NEW_AUTHTOK_REQD:
return "Authentication token is no longer valid; new one required."; return "Authentication token is no longer valid; new one required.";
case PAM_ACCT_EXPIRED: case PAM_ACCT_EXPIRED:

@ -323,7 +323,8 @@ xrdp_wm_set_pointer(struct xrdp_wm *self, int cache_idx)
/*****************************************************************************/ /*****************************************************************************/
/* convert hex string to int */ /* 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; unsigned int value = 0;
char ch = *ptr; char ch = *ptr;
@ -575,7 +576,7 @@ xrdp_wm_init(struct xrdp_wm *self)
{ {
if (autorun_name[0] == 0) 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 use the first item in the xrdp.ini
file thats not named file thats not named
'globals' or 'Logging' or 'channels' */ '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); 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) 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; 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) 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 (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) 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 static int DEFAULT_CC
xrdp_wm_log_wnd_notify(struct xrdp_bitmap *wnd, xrdp_wm_log_wnd_notify(struct xrdp_bitmap *wnd,
struct xrdp_bitmap *sender, struct xrdp_bitmap *sender,

@ -432,6 +432,287 @@ lib_mod_event(struct mod *mod, int msg, tbus param1, tbus param2,
return rv; return rv;
} }
/******************************************************************************/
/* 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 */ /* return error */
static int APP_CC static int APP_CC
@ -515,6 +796,20 @@ process_server_window_new_update(struct mod *mod, struct stream *s)
return rv; return rv;
} }
/******************************************************************************/
/* 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 */ /* return error */
static int APP_CC static int APP_CC
@ -537,14 +832,209 @@ process_server_window_show(struct mod* mod, struct stream* s)
/******************************************************************************/ /******************************************************************************/
/* return error */ /* return error */
static int APP_CC 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 rv;
int font;
int charactor;
int x;
int y;
int cx;
int cy;
int len_bmpdata;
char *bmpdata;
in_uint32_le(s, window_id); in_uint16_le(s, font);
mod->server_window_delete(mod, window_id); in_uint16_le(s, charactor);
rv = 0; 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; 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 */ /* return error */
static int APP_CC 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 rv;
int x; int x;
int y; int y;
int cx; int cx;
int cy; int cy;
int srcx; int flags;
int srcy; int frame_id;
int mskx; int shmem_id;
int msky; int shmem_offset;
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 width; int width;
int height; int height;
int fgcolor; int srcx;
int bgcolor; int srcy;
int opcode; 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 flags;
int frame_id;
int shmem_id; int shmem_id;
int shmem_offset; int shmem_offset;
int frame_id; int width;
int charactor; int height;
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)];
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) switch (type)
{ {
case 1: /* server_begin_update */ 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); rv = mod->server_end_update(mod);
break; break;
case 3: /* server_fill_rect */ case 3: /* server_fill_rect */
in_sint16_le(s, x); rv = process_server_fill_rect(mod, s);
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);
break; break;
case 4: /* server_screen_blt */ case 4: /* server_screen_blt */
in_sint16_le(s, x); rv = process_server_screen_blt(mod, s);
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);
break; break;
case 5: /* server_paint_rect */ case 5: /* server_paint_rect */
in_sint16_le(s, x); rv = process_server_paint_rect(mod, s);
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);
break; break;
case 10: /* server_set_clip */ case 10: /* server_set_clip */
in_sint16_le(s, x); rv = process_server_set_clip(mod, s);
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);
break; break;
case 11: /* server_reset_clip */ case 11: /* server_reset_clip */
rv = mod->server_reset_clip(mod); rv = process_server_reset_clip(mod, s);
break; break;
case 12: /* server_set_fgcolor */ case 12: /* server_set_fgcolor */
in_uint32_le(s, fgcolor); rv = process_server_set_fgcolor(mod, s);
rv = mod->server_set_fgcolor(mod, fgcolor);
break; break;
case 13: /* server_set_bgcolor */ case 13: /* server_set_bgcolor */
in_uint32_le(s, bgcolor); rv = process_server_set_bgcolor(mod, s);
rv = mod->server_set_bgcolor(mod, bgcolor);
break; break;
case 14: case 14: /* server_set_opcode */
in_uint16_le(s, opcode); rv = process_server_set_opcode(mod, s);
rv = mod->server_set_opcode(mod, opcode);
break; break;
case 17: case 17: /* server_set_pen */
in_uint16_le(s, style); rv = process_server_set_pen(mod, s);
in_uint16_le(s, width);
rv = mod->server_set_pen(mod, style, width);
break; break;
case 18: case 18: /* server_draw_line */
in_sint16_le(s, x1); rv = process_server_draw_line(mod, s);
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);
break; break;
case 19: case 19: /* server_set_cursor */
in_sint16_le(s, x); rv = process_server_set_cursor(mod, s);
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);
break; break;
case 20: case 20: /* server_create_os_surface */
in_uint32_le(s, rdpid); rv = process_server_create_os_surface(mod, s);
in_uint16_le(s, width);
in_uint16_le(s, height);
rv = mod->server_create_os_surface(mod, rdpid, width, height);
break; break;
case 21: case 21: /* server_switch_os_surface */
in_uint32_le(s, rdpid); rv = process_server_switch_os_surface(mod, s);
rv = mod->server_switch_os_surface(mod, rdpid);
break; break;
case 22: case 22: /* server_delete_os_surface */
in_uint32_le(s, rdpid); rv = process_server_delete_os_surface(mod, s);
rv = mod->server_delete_os_surface(mod, rdpid);
break; break;
case 23: /* server_paint_rect_os */ case 23: /* server_paint_rect_os */
in_sint16_le(s, x); rv = process_server_paint_rect_os(mod, s);
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);
break; break;
case 24: /* server_set_hints */ case 24: /* server_set_hints */
in_uint32_le(s, hints); rv = process_server_set_hints(mod, s);
in_uint32_le(s, mask);
rv = mod->server_set_hints(mod, hints, mask);
break; break;
case 25: /* server_window_new_update */ case 25: /* server_window_new_update */
rv = process_server_window_new_update(mod, s); 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); rv = process_server_window_show(mod, s);
break; break;
case 28: /* server_add_char */ case 28: /* server_add_char */
in_uint16_le(s, font); rv = process_server_add_char(mod, s);
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);
break; break;
case 29: /* server_add_char_alpha */ case 29: /* server_add_char_alpha */
in_uint16_le(s, font); rv = process_server_add_char_alpha(mod, s);
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);
break; break;
case 30: /* server_draw_text */ case 30: /* server_draw_text */
in_uint16_le(s, font); rv = process_server_draw_text(mod, s);
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);
break; break;
case 31: /* server_create_os_surface_bpp */ case 31: /* server_create_os_surface_bpp */
in_uint32_le(s, rdpid); rv = process_server_create_os_surface_bpp(mod, s);
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);
break; break;
case 32: /* server_paint_rect_bpp */ case 32: /* server_paint_rect_bpp */
in_sint16_le(s, x); rv = process_server_paint_rect_bpp(mod, s);
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);
break; break;
case 33: case 33: /* server_composite */
in_uint16_le(s, srcidx); rv = process_server_composite(mod, s);
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);
break; break;
case 51: /* server_set_pointer_ex */ case 51: /* server_set_pointer_ex */
rv = process_server_set_pointer_ex(mod, s); rv = process_server_set_pointer_ex(mod, s);
break; break;
case 60: /* server_paint_rect_shmem */ case 60: /* server_paint_rect_shmem */
in_sint16_le(s, x); rv = process_server_paint_rect_shmem(mod, s);
in_sint16_le(s, y); break;
in_uint16_le(s, cx); case 61: /* server_paint_rect_shmem_ex */
in_uint16_le(s, cy); rv = process_server_paint_rect_shmem_ex(mod, s);
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);
break; break;
default: default:
g_writeln("lib_mod_process_orders: unknown order type %d", type); g_writeln("lib_mod_process_orders: unknown order type %d", type);
rv = 0; rv = 0;
break; break;
} }
return rv; return rv;
} }
/******************************************************************************/ /******************************************************************************/
/* return error */ /* return error */
static int APP_CC static int APP_CC

Loading…
Cancel
Save