]> git.sesse.net Git - rdpsrv/commitdiff
Decode mouse events, try to send RDP4 bitmap updates back (?).
authorSteinar H. Gunderson <sesse@samfundet.no>
Sun, 6 Feb 2005 02:27:46 +0000 (02:27 +0000)
committerSteinar H. Gunderson <sesse@samfundet.no>
Sun, 6 Feb 2005 02:27:46 +0000 (02:27 +0000)
Makefile
iso.c
rdp5.c [new file with mode: 0644]
rdpsrv.c
secure.c

index c71c0a7eef31976193f5d3958e86ed0e37195a19..5d55b2b51922aa223161b1202bf37351cd7df1f8 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -3,7 +3,7 @@ CFLAGS=-g -Wall
 LIBS=-lssl
 
 all: rdpsrv protodiff
-OBJS=rdpsrv.o iso.o tcp.o util.o mcs.o secure.o channels.o rdp.o licence.o
+OBJS=rdpsrv.o iso.o tcp.o util.o mcs.o secure.o channels.o rdp.o licence.o rdp5.o
 OBJS_PROTODIFF=protodiff.o tcp.o util.o
 
 rdpsrv: $(OBJS)
diff --git a/iso.c b/iso.c
index b0bafa71863c4beff5fede42e1b79c4e63a825c2..a098ad5f50826b3e566cf3d849a62816a5488105 100644 (file)
--- a/iso.c
+++ b/iso.c
@@ -111,10 +111,8 @@ iso_recv_msg(uint8 * code)
 
        if ((version & 3) == 0)
        {
-               // FIXME :-)
-               //              rdp5_process(s, version & 0x80);
-               printf("rdp5_process()\n");
-               goto next_packet;
+               rdp5_process(s, version & 0x80);
+               return NULL;
        }
 
        in_uint8s(s, 1);        /* hdrlen */
diff --git a/rdp5.c b/rdp5.c
new file mode 100644 (file)
index 0000000..0ac3807
--- /dev/null
+++ b/rdp5.c
@@ -0,0 +1,86 @@
+/* -*- c-basic-offset: 8 -*-
+   rdesktop: A Remote Desktop Protocol client.
+   Protocol services - Multipoint Communications Service
+   Copyright (C) Matthew Chapman 1999-2002
+   Copyright (C) Erik Forsberg 2003
+   
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2 of the License, or
+   (at your option) any later version.
+   
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+   
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#include "rdesktop.h"
+
+extern uint8 *g_next_packet;
+extern int listen_on_vnc;
+
+void
+rdp5_process(STREAM s, BOOL encryption)
+{
+       uint16 length, count, x, y;
+       uint8 type;
+       uint8 *next;
+
+       if (encryption)
+       {
+               in_uint8s(s, 8);        /* signature */
+               sec_decrypt(s->p, s->end - s->p);
+       }
+
+#if 1
+       printf("RDP5 data:\n");
+       hexdump(s->p, s->end - s->p);
+#endif
+
+       while (s->p < s->end)
+       {
+               in_uint8(s, type);
+
+               switch (type)
+               {
+                       case 32: { // mouse
+                               listen_on_vnc = 1;
+                               uint16 device_flags, x, y;
+                               static int mouse1_down = 0, mouse2_down = 0;
+
+                               in_uint16_le(s, device_flags);
+                               in_uint16_le(s, x);
+                               in_uint16_le(s, y);
+                               
+                               printf("- Type: Mouse\n");
+                               printf("- Device flags: %x\n", device_flags);
+                               printf("- Position: (%u,%u)\n", x, y);
+
+                               if (device_flags & MOUSE_FLAG_BUTTON1)
+                                       mouse1_down = (device_flags & MOUSE_FLAG_DOWN) ? 0x01 : 0;
+                               if (device_flags & MOUSE_FLAG_BUTTON2)
+                                       mouse2_down = (device_flags & MOUSE_FLAG_DOWN) ? 0x02 : 0;
+
+                               printf("button mask = %x\n", mouse1_down | mouse2_down);
+
+                       /*      buf[0] = 5; // message type
+                               buf[1] = mouse1_down | mouse2_down; // button mask
+                               buf[2] = param1 >> 8;
+                               buf[3] = param1 & 0xff;
+                               buf[4] = param2 >> 8;
+                               buf[5] = param2 & 0xff;
+                               write(vnc_sock, buf, 6); */
+
+                               break;
+                       }
+                       default:
+                               printf("Unimplemented RDP5 opcode %d (len=%u)\n", type, length);
+                               return;
+               }
+       }
+}
index 91989872cf530955bd5cd274a21f858e9d09818a..c5cb1876fb397e6f608dc8fb9457ce8b8c3215b2 100644 (file)
--- a/rdpsrv.c
+++ b/rdpsrv.c
@@ -320,10 +320,11 @@ void handle_vnc_fbupdate(int vnc_sock)
        }
 }
 
+int listen_on_vnc = 0;
+
 int serve_client()
 {
        int vnc_sock = vnc_init();
-       int listen_on_vnc = 0;
        
        if (!mcs_recv_connect_initial())
                error("MCS_CONNECT_INITIAL recv failed");
@@ -363,6 +364,8 @@ int serve_client()
                        }
                }
 
+               printf("LISTEN_ON_VNC=%u\n", listen_on_vnc);
+               
                // activity on VNC socket?
                if (FD_ISSET(vnc_sock, &readfs) && listen_on_vnc) {
                        unsigned char buf[256];
index 62e59a526a8749e5354b6a6e4e64d66231b2ef27..56c8bef117fba0929c4d2c3e129adfaf8be2bc44 100644 (file)
--- a/secure.c
+++ b/secure.c
@@ -842,7 +842,7 @@ sec_recv(void)
        uint16 channel;
        STREAM s;
 
-       while ((s = mcs_recv(&channel)) != NULL)
+       if ((s = mcs_recv(&channel)) != NULL)
        {
                if (/*g_encryption || !g_licence_issued*/ 1)
                {
@@ -883,7 +883,7 @@ sec_recv(void)
                                        }
                                }
                                
-                               continue;
+                               return NULL;
                        }
 
                        if (sec_flags & SEC_LOGON_INFO) 
@@ -901,7 +901,7 @@ sec_recv(void)
                                        sec_send(s, SEC_LICENCE_NEG);
                                }
                                
-                               continue;
+                               return NULL;
                        }
 
                        if (sec_flags & SEC_CLIENT_RANDOM) {
@@ -934,7 +934,7 @@ sec_recv(void)
 
                                // now we can generate the keys
                                sec_generate_keys(inr + SEC_RANDOM_SIZE, cacert, 1);
-                               continue;
+                               return NULL;
                        }
                }
 
@@ -942,7 +942,7 @@ sec_recv(void)
                if (channel != MCS_GLOBAL_CHANNEL)
                {
                        channel_process(s, channel);
-                       continue;
+                       return NULL;
                }
 
                return s;