28#include "../rdesktop.h"
95#define COLOR16TO32(color) \
97 ((((color >> 8) & 0xf8) | ((color >> 13) & 0x7)) << 0) | \
98 ((((color >> 3) & 0xfc) | ((color >> 9) & 0x3)) << 8) | \
99 ((((color << 3) & 0xf8) | ((color >> 2) & 0x7)) << 16) \
107 GR_MODE_COPYINVERTED,
129 case 0x1:
return ~(
src |
dst);
130 case 0x2:
return (~
src) &
dst;
131 case 0x3:
return ~src;
133 case 0x5:
return ~(
dst);
134 case 0x6:
return src ^
dst;
135 case 0x7:
return ~(
src &
dst);
136 case 0x8:
return src &
dst;
137 case 0x9:
return ~(
src) ^
dst;
138 case 0xa:
return dst;
139 case 0xb:
return (~
src) |
dst;
140 case 0xc:
return src;
142 case 0xe:
return src |
dst;
174 int * srcx,
int * srcy)
263 region = GrNewRegion();
264 GrUnionRectWithRegion(region, &
g_clip);
265 GrSetGCRegion(
g_gc, region);
273 GrSetGCRegion(
g_gc, 0);
367 return (
void *) pixmap;
373 GrDestroyWindow((GR_WINDOW_ID)
bmp);
377#define DO_GLYPH(ttext,idx) \
379 glyph = cache_get_font (font, ttext[idx]); \
380 if (!(flags & TEXT2_IMPLICIT_X)) \
382 xyoffset = ttext[++idx]; \
383 if ((xyoffset & 0x80)) \
385 if (flags & TEXT2_VERTICAL) \
387 y += ttext[idx+1] | (ttext[idx+2] << 8); \
391 x += ttext[idx+1] | (ttext[idx+2] << 8); \
397 if (flags & TEXT2_VERTICAL) \
409 x1 = x + glyph->offset; \
410 y1 = y + glyph->baseline; \
411 GrBitmap(g_wnd, g_gc, x1, y1, glyph->width, glyph->height, glyph->pixmap); \
412 if (flags & TEXT2_IMPLICIT_X) \
422 int clipx,
int clipy,
int clipcx,
int clipcy,
423 int boxx,
int boxy,
int boxcx,
int boxcy,
BRUSH * brush,
427 int i,
j, xyoffset,
x1,
y1;
430 GrSetGCMode(
g_gc, GR_MODE_COPY);
431 GrSetGCUseBackground(
g_gc, 0);
437 GrSetGCForeground(
g_gc, bgcolor);
444 GrFillRect(
g_wnd,
g_gc, boxx, boxy, boxcx, boxcy);
448 GrFillRect(
g_wnd,
g_gc, clipx, clipy, clipcx, clipcy);
450 GrSetGCForeground(
g_gc, fgcolor);
463 error(
"this shouldn't be happening\n");
528 if (opcode == 12 || opcode == 6)
537 GrLine(
g_wnd,
g_gc, startx, starty, endx, endy);
538 GrSetGCMode(
g_gc, GR_MODE_COPY);
542 unimpl(
"opcode %d in ui_line\n", opcode);
548 void *
src,
int srcx,
int srcy,
549 BRUSH * brush,
int bgcolor,
int fgcolor)
556 void *
src,
int srcx,
int srcy)
572 GrGetWindowInfo((GR_DRAW_ID)
src, &wi);
580 GrReadArea((GR_DRAW_ID)
src, 0, 0,
581 wi.width, wi.height, (GR_PIXELVAL*)
source);
582 for (
i = 0;
i <
cy;
i++)
584 for (
j = 0;
j <
cx;
j++)
591 pixmap = GrNewPixmap(
cx,
cy, 0);
592 GrArea(pixmap,
g_gc_clean, 0, 0,
cx,
cy,
final, MWPF_TRUECOLOR0888);
594 GrDestroyWindow(pixmap);
639 unimpl(
"opcode %d in ui_screenblt\n", opcode);
648 BRUSH * brush,
int bgcolor,
int fgcolor)
660 switch (brush->style)
663 if (opcode == 12 || opcode == 6)
667 GrSetGCForeground(
g_gc, fgcolor);
669 GrSetGCMode(
g_gc, GR_MODE_COPY);
673 unimpl(
"opcode %d in ui_patblt solid brush\n", opcode);
677 for (
i = 0;
i != 8;
i++)
679 ipattern[7 -
i] = brush->pattern[
i];
689 for (
i = 0;
i <
cy;
i++)
691 for (
j = 0;
j <
cx;
j++)
694 (
y +
i + brush->yorigin) % 8, 8, 1))
706 pixmap = GrNewPixmap(
cx,
cy, 0);
707 GrArea(pixmap,
g_gc_clean, 0, 0,
cx,
cy,
final, MWPF_TRUECOLOR0888);
709 GrDestroyWindow(pixmap);
723 GrSetGCForeground(
g_gc, 0);
726 else if (opcode == 5)
728 GrSetGCForeground(
g_gc, 0xffffffff);
731 else if (opcode == 15)
733 GrSetGCForeground(
g_gc, 0xffffffff);
736 if (opcode == 12 || opcode == 6)
741 GrSetGCMode(
g_gc, GR_MODE_COPY);
745 unimpl(
"opcode %d in ui_destblt\n", opcode);
792 return !((
r == 0) && (
g == 0) && (
b == 0));
852 GR_BITMAP * databitmap;
853 GR_BITMAP * maskbitmap;
855 int i1, i2, bon, mon;
863 for (i1 = 0; i1 <= 31; i1++)
865 for (i2 = 0; i2 <= 31; i2++)
867 mon =
is24on(xormask, i1, i2);
868 bon =
is1on(andmask, i1, i2);
887 cursor = GrNewCursor(32, 32,
x,
y, 0xffffff, 0, databitmap, maskbitmap);
896 GrDestroyCursor((GR_CURSOR_ID)
cursor);
928 BRUSH * brush,
int bgcolor,
int fgcolor)
942 for (
i = 1;
i < npoints;
i++)
955 int x,
int y,
int cx,
int cy,
956 BRUSH * brush,
int bgcolor,
int fgcolor)
1152 g_keys[0x1d].ch1 = 63533;
1153 g_keys[0x1d].ch2 = 63534;
1178 g_keys[0x2a].ch1 = 63531;
1199 g_keys[0x35].ch2 = 63509;
1201 g_keys[0x36].ch1 = 63532;
1203 g_keys[0x37].ch2 = 63510;
1204 g_keys[0x38].ch1 = 63535;
1205 g_keys[0x38].ch2 = 63536;
1208 g_keys[0x3b].ch1 = 63515;
1209 g_keys[0x3c].ch1 = 63516;
1210 g_keys[0x3d].ch1 = 63517;
1211 g_keys[0x3e].ch1 = 63518;
1212 g_keys[0x3f].ch1 = 63519;
1213 g_keys[0x40].ch1 = 63520;
1214 g_keys[0x41].ch1 = 63521;
1215 g_keys[0x42].ch1 = 63522;
1216 g_keys[0x43].ch1 = 63523;
1217 g_keys[0x44].ch1 = 63524;
1220 g_keys[0x47].ch1 = 63505;
1221 g_keys[0x47].ch2 = 63494;
1222 g_keys[0x48].ch1 = 63490;
1223 g_keys[0x48].ch2 = 63506;
1224 g_keys[0x49].ch1 = 63507;
1225 g_keys[0x49].ch2 = 63496;
1227 g_keys[0x4a].ch2 = 63511;
1228 g_keys[0x4b].ch1 = 63502;
1229 g_keys[0x4b].ch2 = 63488;
1230 g_keys[0x4c].ch1 = 63503;
1231 g_keys[0x4d].ch1 = 63504;
1232 g_keys[0x4d].ch2 = 63489;
1234 g_keys[0x4e].ch2 = 63512;
1235 g_keys[0x4f].ch1 = 63499;
1236 g_keys[0x4f].ch2 = 63495;
1237 g_keys[0x50].ch1 = 63500;
1238 g_keys[0x50].ch2 = 63491;
1239 g_keys[0x51].ch1 = 63501;
1240 g_keys[0x51].ch2 = 63497;
1241 g_keys[0x52].ch1 = 63498;
1242 g_keys[0x52].ch2 = 63492;
1243 g_keys[0x53].ch1 = 63508;
1244 g_keys[0x53].ch2 = 63493;
1245 g_keys[0x54].ch1 = 63525;
1246 g_keys[0x55].ch1 = 63527;
1251static int get_sc(GR_EVENT_KEYSTROKE * event_keystroke,
int * sc,
int * ec)
1258 for (
i = 0;
i < 256;
i++)
1260 if (event_keystroke->modifiers & 1)
1262 if (event_keystroke->ch ==
g_keys[
i].chs)
1268 if (event_keystroke->ch ==
g_keys[
i].ch1 ||
1269 event_keystroke->ch ==
g_keys[
i].ch2 ||
1270 event_keystroke->ch ==
g_keys[
i].ch3)
1291 if (
get_sc(event_keystroke, &sc, &ec) == 0)
1307 GR_EVENT_MOUSE * event_mouse;
1308 GR_EVENT_BUTTON * event_button;
1309 GR_EVENT_FDINPUT * event_fdinput;
1310 GR_EVENT_KEYSTROKE * event_keystroke;
1314 if (ev->type == GR_EVENT_TYPE_FDINPUT)
1316 event_fdinput = (GR_EVENT_FDINPUT *) ev;
1317 if (event_fdinput->fd ==
g_sck)
1321 fprintf(
stderr,
"rdp_loop in nanox_event exit codes %d %d\n",
1327 else if (ev->type == GR_EVENT_TYPE_BUTTON_DOWN)
1329 event_button = (GR_EVENT_BUTTON *) ev;
1330 if (event_button->changebuttons & 4)
1333 event_button->x, event_button->y);
1335 else if (event_button->changebuttons & 1)
1338 event_button->x, event_button->y);
1341 else if (ev->type == GR_EVENT_TYPE_BUTTON_UP)
1343 event_button = (GR_EVENT_BUTTON *) ev;
1344 if (event_button->changebuttons & 4)
1347 event_button->x, event_button->y);
1349 else if (event_button->changebuttons & 1)
1352 event_button->x, event_button->y);
1355 else if (ev->type == GR_EVENT_TYPE_MOUSE_MOTION)
1357 event_mouse = (GR_EVENT_MOUSE *) ev;
1359 event_mouse->x, event_mouse->y);
1361 else if (ev->type == GR_EVENT_TYPE_MOUSE_POSITION)
1365 else if (ev->type == GR_EVENT_TYPE_KEY_DOWN)
1367 event_keystroke = (GR_EVENT_KEYSTROKE *) ev;
1370 else if (ev->type == GR_EVENT_TYPE_KEY_UP)
1372 event_keystroke = (GR_EVENT_KEYSTROKE *) ev;
1375 else if (ev->type == GR_EVENT_TYPE_FOCUS_IN)
1378 else if (ev->type == GR_EVENT_TYPE_FOCUS_OUT)
1381 else if (ev->type == GR_EVENT_TYPE_UPDATE)
1384 GrCheckNextEvent(ev);
1385 }
while (ev->type != GR_EVENT_TYPE_NONE);
1391 char fullhostname[64];
1398 if (pw !=
NULL && pw->pw_name !=
NULL)
1402 if (
gethostname(fullhostname,
sizeof(fullhostname)) != -1)
1404 p =
strchr(fullhostname,
'.');
1415 fprintf(
stderr,
"rdesktop: A Remote Desktop Protocol client.\n");
1418 fprintf(
stderr,
"See http://www.rdesktop.org/ for more information.\n\n");
1439 for (
i = 1;
i < in_argc;
i++)
1442 if (
strcmp(in_argv[
i],
"-h") == 0)
1447 else if (
strcmp(in_argv[
i],
"-n") == 0)
1451 else if (
strcmp(in_argv[
i],
"-u") == 0)
1455 else if (
strcmp(in_argv[
i],
"-p") == 0)
1461 else if (
strcmp(in_argv[
i],
"-d") == 0)
1466 else if (
strcmp(in_argv[
i],
"-s") == 0)
1471 else if (
strcmp(in_argv[
i],
"-c") == 0)
1481int main(
int in_argc,
char ** in_argv)
1507 fprintf(
stderr,
"unsupported bpp, server = %d, client = %d\n",
1529 GrSetGCForeground(
g_gc, 0);
1534 GrSelectEvents(
g_wnd, -1);
1535 GrRegisterInput(
g_sck);
1543 GrDestroyWindow(
g_wnd);
int strcmp(const char *String1, const char *String2)
char * strcpy(char *DstString, const char *SrcString)
char * strchr(const char *String, int ch)
void cache_put_text(uint8 cache_id, void *data, int length)
DATABLOB * cache_get_text(uint8 cache_id)
#define MOUSE_FLAG_BUTTON1
#define MOUSE_FLAG_BUTTON2
void rdp_send_input(uint32 time, uint16 message_type, uint16 device_flags, uint16 param1, uint16 param2)
RD_BOOL rdp_connect(char *server, uint32 flags, char *domain, char *password, char *command, char *directory, RD_BOOL reconnect)
RD_BOOL rdp_loop(RD_BOOL *deactivated, uint32 *ext_disc_reason)
#define STRNCPY(dst, src, n)
INT WSAAPI gethostname(OUT char FAR *name, IN INT namelen)
GLint GLint GLint GLint GLint x
GLint GLint GLint GLint GLint GLint y
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
GLint GLint GLsizei GLsizei height
GLdouble GLdouble GLdouble r
GLint GLint GLsizei width
GLdouble GLdouble GLdouble GLdouble q
GLboolean GLboolean GLboolean b
GLuint GLsizei GLsizei * length
GLsizei const GLfloat * points
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
_CRTIMP void __cdecl perror(_In_opt_z_ const char *_ErrMsg)
_Check_return_opt_ _CRTIMP int __cdecl fprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format,...)
_Check_return_opt_ _CRTIMP int __cdecl vfprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format, va_list _ArgList)
#define memcpy(s1, s2, n)
#define RDP5_NO_MENUANIMATIONS
#define RDP5_NO_FULLWINDOWDRAG
#define RDP5_NO_WALLPAPER
char g_redirect_cookie[128]
static GR_CURSOR_ID g_null_cursor
static char g_directory[64]
static void process_keystroke(GR_EVENT_KEYSTROKE *event_keystroke, int down)
static void set1(uint8 *data, int x, int y)
void ui_patblt(uint8 opcode, int x, int y, int cx, int cy, BRUSH *brush, int bgcolor, int fgcolor)
void ui_memblt(uint8 opcode, int x, int y, int cx, int cy, void *src, int srcx, int srcy)
#define DO_GLYPH(ttext, idx)
void ui_triblt(uint8 opcode, int x, int y, int cx, int cy, void *src, int srcx, int srcy, BRUSH *brush, int bgcolor, int fgcolor)
void ui_ellipse(uint8 opcode, uint8 fillmode, int x, int y, int cx, int cy, BRUSH *brush, int bgcolor, int fgcolor)
void ui_destroy_bitmap(void *bmp)
static GR_GC_ID g_gc_clean
int rd_write_file(int fd, void *ptr, int len)
void nanox_event(GR_EVENT *ev)
void ui_draw_text(uint8 font, uint8 flags, uint8 opcode, int mixmode, int x, int y, int clipx, int clipy, int clipcx, int clipcy, int boxx, int boxy, int boxcx, int boxcy, BRUSH *brush, int bgcolor, int fgcolor, uint8 *text, uint8 length)
void ui_rect(int x, int y, int cx, int cy, int color)
void * ui_create_bitmap(int width, int height, uint8 *data)
char g_redirect_username[64]
void ui_destroy_cursor(void *cursor)
char * xstrdup(const char *s)
static void set_pixel32(uint8 *data, int x, int y, int width, int height, int pixel)
void ui_screenblt(uint8 opcode, int x, int y, int cx, int cy, int srcx, int srcy)
int rd_read_file(int fd, void *ptr, int len)
void ui_set_null_cursor(void)
void ui_paint_bitmap(int x, int y, int cx, int cy, int width, int height, uint8 *data)
void ui_desktop_save(uint32 offset, int x, int y, int cx, int cy)
void * xrealloc(void *in, int size)
static char g_password[64]
void ui_polyline(uint8 opcode, POINT *points, int npoints, PEN *pen)
char g_redirect_domain[16]
int g_keyboard_functionkeys
static int warp_coords(int *x, int *y, int *cx, int *cy, int *srcx, int *srcy)
static char g_servername[256]
int load_licence(uint8 **data)
void rd_close_file(int fd)
void ui_set_colourmap(void *map)
void ui_polygon(uint8 opcode, uint8 fillmode, POINT *point, int npoints, BRUSH *brush, int bgcolor, int fgcolor)
static int get_pixel32(uint8 *data, int x, int y, int width, int height)
static int is_pixel_on(uint8 *data, int x, int y, int width, int bpp)
void ui_set_cursor(void *cursor)
static GR_SCREEN_INFO g_screen_info
static int is24on(uint8 *data, int x, int y)
static void get_username_and_hostname(void)
void unimpl(char *format,...)
uint32 g_rdp5_performanceflags
uint16 ui_get_numlock_state(uint32 state)
void ui_line(uint8 opcode, int startx, int starty, int endx, int endy, PEN *pen)
static void flipover(uint8 *data)
static void out_params(void)
char g_redirect_password[64]
void ui_destblt(uint8 opcode, int x, int y, int cx, int cy)
void ui_desktop_restore(uint32 offset, int x, int y, int cx, int cy)
int rd_lock_file(int fd, int start, int len)
static int is1on(uint8 *data, int x, int y)
void ui_set_clip(int x, int y, int cx, int cy)
int rd_pstcache_mkdir(void)
static struct key g_keys[256]
void ui_resize_window(void)
static int g_ext_disc_reason
void * ui_create_glyph(int width, int height, uint8 *data)
void * ui_create_colourmap(COLOURMAP *colors)
void * ui_create_cursor(uint32 x, uint32 y, int width, int height, uint8 *andmask, uint8 *xormask)
int g_bitmap_cache_precache
int g_bitmap_cache_persist_enable
void save_licence(uint8 *data, int length)
void ui_begin_update(void)
static int parse_parameters(int in_argc, char **in_argv)
char g_redirect_server[64]
int rd_lseek_file(int fd, int offset)
uint32 read_keyboard_state(void)
int rd_open_file(char *filename)
void ui_move_pointer(int x, int y)
void generate_random(uint8 *random)
int g_polygon_ellipse_orders
static int rop(int rop, int src, int dst)
void ui_destroy_glyph(void *glyph)
#define COLOR16TO32(color)
static int get_sc(GR_EVENT_KEYSTROKE *event_keystroke, int *sc, int *ec)
static GR_WINDOW_ID g_wnd
static void init_keys(void)
_Out_opt_ int _Out_opt_ int * cy
_Check_return_ _CRTIMP char *__cdecl strdup(_In_opt_z_ const char *_Src)
_In_ CLIPOBJ _In_ BRUSHOBJ _In_ LONG _In_ LONG y1
_In_ CLIPOBJ _In_ BRUSHOBJ _In_ LONG x1
void int int ULONGLONG int va_list * ap