Mobile Development: a native remote desktop client (rdesktop port win32)

Print This Post Print This Post

The famous rdesktop running natively on windows ce and windows mobile

Intro and Background

Some times ago I found that message of Jay Sorg and retrieved a copy of his code for a native rdesktop win32 version. I played a little and got the code compile with Visual Studio 2005 with the Windows Mobile SDK.

I tried to implement windows clipboard support to enhance the transfer of texts between the client and server, but unfortunately I was not successful yet. Hopefully someone jumps in and helps enhancing the code and adds some features.

Rdesktop is open source and you can go with the wince implementation here, but if it does not work for you, you have either change the code yourself (and publish it) or find someone that is able to do for you.

There is a template uiports/xxxwin.c in the actual rdesktop source you can use as a starter to compile the actual rdesktop version for windows mobile if you manage to get all the dependencies to work. If you success, forget this post and go with this version (maybe you leave me a note?).

Why another Remote Desktop/Terminal Server Client?

The Windows Mobile Remote Desktop Client (or Remote Desktop Mobile, RDM) lacks some useful features available in the Windows CE version or the Desktop Windows version:

  • No automated login
  • No kiosk mode
  • Function keys are not sent to server

The first item is essential if you like to start a Terminal Server session without user intervention.

The second item is important for using RDM in a production environment.

The third item is useful to run applications on the Terminal Server (TS) that use Function keys.

Commercial RDM

There are some commercial remote desktop clients available for windows mobile:

  • Mochasoft RDP client
    “Windows 200x servers and terminal servers are not supported, as to a Microsoft patent license.”
  • zaDesktop
    This is currently in an early state.
  • RDP Finster
    Not really clear where this comes from.

I assume some of the commercials are either using mstscax or rdesktop code. Some time ago MS published the RDP documentation. Maybe the commercial apps did start from there. Going with the TSC COM library mststcax would be great, but who has the doc for this? For desktop PCs it is documented but not for windows mobile. If someone has a doc to this leave me a note. Then we can start to write a TSC around this library.

There are also some rewritten TSC for the desktop not using mstscax. One is called ProperJavaRDP and maybe a good starting point to rewrite a dotnet based native TSC for windows mobile.

Usage of the free opensource rdesktop-ce

You can start winrdesktop on windows mobile either with an ini file or with command line arguments:

Sample winrdesktop.ini

(place either in program dir or in root)

[main]
server=192.168.128.5
port=3389
username=YourUserName
password=YourPassword
bpp=16
geometry=1024x768
#fullscreen

server : provide the server IP or DNS host name
port : provide the port to use for RDP, usually 3389
username : provide the login user name for the terminal client session
password : provide the password of the user
bpp : define the bits per pixel to be used (number of colors per pixel)
geometry : define the size of the remote desktop window width x height An application to be used on windows mobile devices should match the screen size of the device. For example 240×320 (QVGA). Otherwise the user has to scroll the window to get access to all of the remote screen.
fullscreen : currently not supported


UPDATE 23. nov 2010:

fullscreen now supported. Fullscreen will switch rdesktop to not show a caption and no menu bar. If geometry matches the device’s screen size, there will also be no scrollbars.

This screenshot was taken of an app I wrote running on a Windows 2003 server of a QVGA device with following winrdesktop.ini:

[main]
server=192.168.128.5
port=3389
username=rdesktop
password=rdesktop
bpp=16
geometry=240x320
fullscreen

Rdesktop usage

Command line

WinRDesktop [-g widthxheight] [-t port] [-a bpp]
    [-f] [-u username] [-p password] [-d domain]
    [-s shell] [-c working directory] [-n host name]
    server-name-or-ip

options are the same as in winrdesktop.ini plus:

-d domain : specify the domain of the user login
-s shell : define a shell to use on TSC
-c working directory : define a working directory for the session
-n host name : specify the host name to use for the client (visible on TSC)

Restrictions of current code

See googlecode issues for a list of known restrictions.

Downloads

Windows Mobile Executable and INI sample file at googlecode
Source code: see googlecode

72 Comments

  1. bradh says:

    Hello,

    I was trying to connect to both Server 2003 and 2008 R2 with Security Layer: Negotiate; Encryption level: Client Compatible, and NLA unchecked. Connecting to either server returned “ERROR: modulus len 0x108″. Seems I’m not the only one, but I need a RDP client that supports function keys.

    Do some digging around and learn rdesktop-ce is based off rdesktop v1.4.0, so I go build all the major builds and do some testing in linux, figure out this bug was fixed in v1.5. Some searching and I find the correct reversion needed:

    http://svn.rot13.org/index.cgi/rdesktop/revision/?rev=1237

    Skip changes on lines 304-326, 552-558, 744-762

    Now I am able to successfully connect to both 2003 and 2008 without error as I was encountering before. Going to study the source code more and see what else I can maybe fix…

  2. josef says:

    See http://code.google.com/p/rdesktop-ce/wiki/Modulo108error

    rdesktop-ce as is only supports RDP4 and not RDP5 (as used by Win2008)

    If you can fix that, leave me a note

  3. bradh says:

    josef,

    The changes described in my post fix the error described in the wiki. The bug is caused by a key length calculation error (0x108 = 264bit key, should be 256bit)

    I am considering the benefits of updating the port to v1.7.1 but we will see what I come up with :)

  4. josef says:

    Hello Bradh

    sorry, I missed that:

    http://svn.rot13.org/index.cgi/rdesktop/revision/?rev=1237

    Skip changes on lines 304-326, 552-558, 744-762

    I will see if I can follow this. RDP5 support will be great!

    Thanks for your contribution

    Josef

  5. bradh says:

    Good news!! rdesktop-ce is getting a new lease on life! I have implemented RDP 5 and support for 2008R2 Servers with RD Session Host / Broker / Load Balancing.

    My build has the rdp-core code implemented from rdesktop 1.7.1, along with openssl as part of the build allowing RDP 5 to work. There is now 1 exe, 1 ini, 2 dlls.

    Load module: rdesktopce.exe
    Load module: libeay32.dll
    Load module: commctrl.dll.0409.mui
    Load module: commctrl.dll
    Load module: aygshell.dll
    Load module: ws2.dll
    Load module: coredll.dll.0409.mui
    Load module: ossvcs.dll
    Load module: ole32.dll
    Load module: coredll.dll
    g_num_channels is 0
    Load module: dtpt_nsp.dll
    Load module: nspm.dll
    Load module: ssllsp.dll
    Load module: AutoBind_lsp.dll
    Load module: dtpt_lsp.dll
    Load module: wspm.dll
    We’re going for the RDP5-style encryption
    CA Certificate length is 856
    Certificate length is 1131
    Generating client random
    rc_4_key_size == 2, 128-bit encryption enabled
    Sending CJRQ for channel #1004
    Sending CJRQ for channel #1003
    Sending RDP5-style Logon packet
    Called sec_init with packetlen 312

    #### Window size is (0/0)-(240/294)

    #### Window handle is 0x7c07bc30
    Could not create menubar!
    Load module: oleaut32.dll
    Load module: compime.dll
    Load module: shellres.dll
    Window Created!!DEMAND_ACTIVE(id=0x103ea)
    setting desktop size and depth to: 240x320x8
    PALETTE(c=256)
    PALETTE(c=256)
    BITMAP_UPDATE(l=0,t=0,r=15,b=0,w=16,h=1,Bpp=1,cmp=1025)
    BITMAP_UPDATE(l=0,t=0,r=239,b=132,w=240,h=133,Bpp=1,cmp=1025)
    BITMAP_UPDATE(l=0,t=133,r=239,b=265,w=240,h=133,Bpp=1,cmp=1025)
    BITMAP_UPDATE(l=0,t=266,r=239,b=319,w=240,h=54,Bpp=1,cmp=1025)
    PALETTE(c=256)

  6. Martin Franz says:

    Hi,
    is there a possibility to download a recent exe with the modulo bug fixed? The download section only shows quite old versions…
    Would be a great deal to get a running version, as the original rdb client from ms sucks.
    Best regards, Martin from Vienna

  7. Martin Franz says:

    Hi Josef,
    thanks a lot! Unfortunatelly my device (Intermec scanner) responds with “The file ‘rdesktioce’ cannot be opened. Either it is not signed with a trusted certificate or one of its components cannot be found. …
    Hmm. I copied the two .dll in the same directory where I have the exe..didn’t help.
    The “old” exe did start but gave the modulo error.
    Strange.I do not know this Windows CE too well, maybe I’m doing something very wrong :-)
    b.r.Martin

  8. Martin Franz says:

    Hi Josef,
    stupid me, I just downloaded the files the “wrong way”. Now I get a connection :-)
    Best regards, Martin

  9. Ralf says:

    Hi Josef,

    i tried this rdesktop Release: https://code.google.com/p/rdesktop-ce/source/browse/#svn%2Fbranches%2Frdesktopce_rdp5%2Fsource%2FWindows%20Mobile%205.0%20Pocket%20PC%20SDK%20%28ARMV4I%29%2FRelease
    I got a connection with my device (Intermek CK3). But when scanning barcodes I get no results. What can i do? Where can i find a running version with scanning functionality?

    Best regards
    Ralf

  10. josef says:

    By default the Intermec barcode scanner keyboard wedge will issue scanned barcodes as normal keystrokes. The wedge can be configured to use the clipboard instead and that is not supported by RDP. But configuration of the wedge is beyond the scope of this blog. Possibly you find a solution at community.intermec.com.

    This is a development related blog. You can compile a version with native intermec scanner support by just using a #define.

    regards

    Josef

  11. Ralf says:

    Hi Josef,

    sorry, but that is my problem. I’m not a developer and so i have not the knowledge and possibility of compiling a version for my requirements. I tried a former version of winrdesktop that nearly works as we want to (intermec scanner support included). But in that Version in some cases there is one character added after scanning a Barcode. It would be great, getting a running version of rdesktopce with all good features like function keys, RDP5 functionality AND intermec scanner support. And it would be even greater if you spend some of your precious time to create a exe Version for me (and certainly other intermec users) ;-)

    hopefully…

    with best regards

    Ralf

  12. josef says:

    Hello Ralf

    I am sorry, but I currently have no free resources to compile a version for you. Maybe next week or so.

    sorry

    ~Josef

  13. David Hut says:

    “There are also some posts in internet about “ERROR: modulus len 0×108″.” this is because the app is design with 64bit security and the server/computer you are connecting to has 256bit there and const in the code to change if you want to fix this. You’ll need EMBEDDED VISUAL c++ 4.0 to do so. I have got the code to work with windows 2008 R2.

  14. josef says:

    Hello David

    thanks a lot for the information and the background.

    ~josef

  15. jefsummers says:

    Hi Josef,

    Very nice work on rdesktop-ce!

    With a slight modification to the source and changing the subsystem to 4.20, I found it will also emulate QVGA on a VGA device. (Similar to what you showed with a subsystem mod to the built-in Remote Desktop Mobile client.)

    I noticed that you hadn’t included a Windows Mobile 6.5 target project. Is there something in the newer SDK that’s not compatible?

    When running geometry=240×320 and fullscreen, I do get a few “get bitmap” error dialogs when logging out. It’s fine on disconnect only occurs on log off. And it’s always this id:idx.

    get bitmap 2:23
    get bitmap 2:24

    Those errors they may repeat several times during the log off process.

    I can run a trace and sort out what’s going with the bitmap cache but was wondering if you had seen this?

    I’m testing against Windows XP Pro workstation.

    -Jef

  16. ekors says:

    Hello!
    Please help compile this project for Symbol MC9060 with Pocket PC 2003.
    In project set target platform: PocketPC 2003 (ARMV4).
    And have error linking.
    Intermec Libs not have ARMV4 library (only ARMV4i)

    Thanks for help!

  17. josef says:

    Hello ekors

    I am sorry, I have no compiled SSL libs for ArmV4 (I assume that this are the cause of the link errors you get). The SSL libs are not compiled by me, possibly you have success in compiling OpenSSL for ArmV4.

    :-( Josef

  18. ekors says:

    Write this error:
    ITCscan.lib(ITCSCAN.dll) : fatal error LNK1112: type module “THUMB” not for target module “ARM”
    Is i possible compile this project for Symbol MC9060 without ITCscan?

  19. josef says:

    hi ekors

    just recompile after commenting the #define line for USE_SCANNER

    ~josef

  20. Evgeny says:

    Hello.
    Tell me please, how can I using option
    -c working directory : define a working directory for the session ?..
    Write please example for winrdesktop.ini file.

    Thank You.

  21. josef says:

    @evgeny

    Windows CE based device do not know a drive letter nor a working dir. This option is only for Windows PC desktop clients.

    ~josef

Leave a Reply