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

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)

OUTDATED: DO NOT USE, look for latest at github!

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

113 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

  22. Thomas Buhr says:

    Hello Josef,

    I am very impressed of the nice work you have done with rdesktop-ce!
    Currently I am testing rdesktop-ce on Windows 2008 32bit terminal server (using this edition for legacy application not working on 64 bit) with Motorola MC9090 (Windows Mobile 5) hand terminal.

    Everything works besides arrow keys when using numeric mode (normal keyboard mode) of the hand terminal. Selecting “alpha”-mode on the Motorola keyboard makes the arrow-keys work.
    Could it be that the translation of scan codes for the arrow-keys of the numeric keyboard are not included in the code? Also now writing this post im am not sure if the enter-key had the same issue. I dont think so. But I will check that.

    Regards
    Thomas

  23. Thomas Buhr says:

    Hi again,

    Sorry, just got a little confused after sending my last post.
    Have found a description of the mentioned “ALPHA”-mode button of the hand terminal:

    “The default keypad mode is the num-lock (number lock) mode. Press the orange ALPHA key to de-activate the num-lock mode and to access the alternate ALPHA characters.”

    The arrow keys are not working when in default mode – but only when ALPHA-mode is entered – which means num-lock is off.
    So now I am not sure what is missing.. I guess the best would be to test with your keytest3ak app? What do you think?

    Regards
    Thomas

  24. josef says:

    Hello Thomas

    please use keytest3ak to see what key codes are generated. RDP does only transfer PS/2 keyboard scancodes. If a key does not work, you may alter the rdesktopce key table.
    For some keys additional flags or keys have to be sent before. In example, if CapsLock is active, each key is sent with VK_SHIFT before and after.

    BTW: I am not the author of rdesktopce, I only ported it to Visual Studio. The original author is Jay. Therefor I can only adopt small changes.

    ~josef

  25. Thomas Buhr says:

    Hi again,

    now I have tested with keytest3ak.

    Using the arrow keys directly without ALPHA-key (NUMLOCK) gives me the following output:

    KEYDOWN VK_LEFT 0x25 7d0001

    KEYUP VK_LEFT 0x25 c07d0001

    KEYDOWN VK_UP 0x26 740001

    KEYUP VK_UP 0x26 c0740001

    KEYDOWN VK_DOWN 0x28 6c0001

    KEYUP VK_DOWN 0x28 c06c0001

    KEYDOWN VK_RIGHT 0x27 750001

    KEYUP VK_RIGHT 0x27 c0750001

    And having ALPHA-button (NUMLOCK) key activated gives me the same output:

    KEYDOWN VK_LEFT 0x25 7d0001

    KEYUP VK_LEFT 0x25 c07d0001

    KEYDOWN VK_UP 0x26 740001

    KEYUP VK_UP 0x26 c0740001

    KEYDOWN VK_DOWN 0x28 6c0001

    KEYUP VK_DOWN 0x28 c06c0001

    KEYDOWN VK_RIGHT 0x27 750001

    KEYUP VK_RIGHT 0x27 c0750001

    The strange thing is still that having ALPHA-key active the arrow keys works through RDP.
    Without ALPHA activated it does not. But the key codes sent seems to be the same?

    By the way when pressing the ALPHA-key the follow key codes are sent – but it does not seem to send an extra key code, when the arrowkeys are pressed:

    KEYDOWN VK_NUMLOCK 0x90 770001
    KEYUP VK_NUMLOCK 0x90 c0770001

    But it seems that the ALHPA-key is the NUMLOCK key…

  26. Thomas Buhr says:

    Hi Josef,

    Isn’t it strange that the same key codes sent from the device gives different results through RDP in my example?

    Regards
    Thomas

  27. Josef says:

    Hello Thomas

    as already said, there is another channel used to change keyboard flags. If, for example, NUM_LOCK or CAPS_LOCK is pressed on the client side or the host sees a change in there for another reason, then the same input will result in different output.

    RDP sends scan codes (PS/2) only. Do you see any keycode when you press your ‘ALPHA key’?

    ~josef

  28. Thomas Buhr says:

    Yes, when ALPHA is pressed the following keycode is sent:
    KEYDOWN VK_NUMLOCK 0x90 770001
    KEYUP VK_NUMLOCK 0x90 c0770001

  29. Thomas Buhr says:

    And by the way it behaves as numlock – ALPHA stays active (lights up) until pressed again.

  30. Felix says:

    Great job josef, the client works very well. Also the hardware function keys are working without any remaps.
    But there are two problems I couldn’t find a solution for.

    1.) on an Intermec CK3R there is no way to send a function key as preamble. {kx76} doesn’t work within a rdp session when I am using this client.
    2.) if there is a “z” in the Barcode there will be transmit a “y”. This must be a problem with the language settings. But I’m not sure on which site.

    Felix

  31. admin says:

    The default wedge settings on the CK3R/CK3X/Cx7x are a mess!
    They send WM_CHAR with no scancode and then a KEYUP without scancode. No KeyDown. As RDP only knows scancodes, this will not work.

    The latest rdesktopce_rdp5 works well for Function keys too, if the right vwConfig.ini (the one using EVENT transmission) is used and WedgeMode is “Adapt To Application”:
    [VWConfig]
    DumpConfig=”1″

    [DEFAULT_APPLICATION]
    GlobalXmitMethod=”EVENT”
    GlobalXmitType=”Table”

    If the client and host are not using the same keyboard layout you can change the layout on the host for the application only (install a second US keyboard layout) or create a special vwConfig.ini where you exchange y with z.

    ~josef

  32. Felix says:

    I don’t get it. I can just transmit the content of a barcode by using “barcodescanner” in the ini file.
    This will transmit all scanned characters to the rdp host. If I set the postamble to {kx76} the output on the rdp server will be barcodeContent{kx76}
    Also if I’m using the VWConfig.ini which you’ve posted above.
    What am I doing wrong?

    Is there a disadvantage of using this client and not the installed RDM Client?

    [main]
    server=xxxx
    port=3389
    domain=
    username=user
    password=user
    bpp=16
    geometry=240×320
    fullscreen
    barcodescanner

  33. Isidro says:

    Hello,

    First of all, thanks a lot for your work!
    I’m using your tool in a Motorla MC device.
    It worked perfectly against a Windows Terminal Server 2008 R2 until a few days ago.
    I guess it could be related with some MS update, but although I’ve tried all I have found (Uncheck resolution limit, lower security, etc.) there is
    no way to make it work again.

    It would be nice is you could tell me what should I do/check. Or if you have some kind of fix.
    Right now I’m stuck with this scanner.

    Thanks in advance for you help.

    Best regards,
    Isidro

  34. josef says:

    My crystal ball is for repair… πŸ˜‰

    Sorry

    Josef

  35. Isidro says:

    Now I’ve found the origin: MS KB3042058 update on my server.
    It’s related with default cipher suite priority order.
    I’ve tried your guide at http://www.hjgode.de/wp/2014/03/12/windows-server-2012-rds-and-windows-mobile-connection-error/
    But no luck with your tool. It works with the standard RDP client in my device, but is does not have as good visibility and performance as yours.
    Only uninstall the update do the trick.

    Maybe you can advice some solution… I like your program but if you have another good candidate for mobile 6.5 it would be welcome.

    Best regards,
    Isidro

  36. josef says:

    Hello Isidro

    I am sorry, but I am unable to change the protocol.

    and I do now know any alternatives to rdesktopce and MS Remote Desktop Mobile.

    ~josef

  37. Daniel Georg says:

    Hi,

    thanks for this perfect program!

    I am trying to use it with a Honeywel Dolphin 70e.
    The only thing is that the scanner is not working during the session.

    barcodescanner is set in the config file.

    Thanks a lot
    Daniel

  38. josef says:

    The native barcodescanner support is for Intermec devices only. You need to use the Dolphin Scanner DataWedge and disable the barcodescanner support in the ini file.

  39. Daniel Georg says:

    Thx. I tried that already but it is not working. Until I am in the Terminal Session the buttons for scanning are not working anymore. If I close the application the scanner works immediately.

  40. josef says:

    Hello Daniel

    I do not now how the datawedge is fired by a key. In a RDP session all local keys are sent to the host (except for F keys). On intermec devices the scanner is fired by a named event pair and the scanner button just fires the named events. So the latter does not conflict with RDP.

    Possibly you can assign the scan button to a key that is not forwarded to the host (ie the App1 to App6 key values).

    Josef

  41. Daniel Georg says:

    Hi again,
    I will try to change the keys.. Thanks for your support.

  42. Victor says:

    Hi I testing in two servers 2008 r2 without any problema but In one server 2008 r2 with terminal services license installed cannot connect (not login , not show desktop sesiΓ³n, close fast in the moment when rotating the icon , but the original remote desktop in Windows Mobile 6.5 connect,any idea because I cannot acces with the rdesktopce
    Victor

  43. josef says:

    Hello Victor and all others

    please ALWAYS use the latest version: binaries are at https://github.com/hjgode/rdesktopce_rdp5/tree/master/source/Windows%20Mobile%205.0%20Pocket%20PC%20SDK%20%28ARMV4I%29

    If that does not work for you, I can not help.

    Sorry

    Josef

  44. Roman says:

    Hello Josef

    I try to run rdesktop-ce on my mc9090 wm 6.1 for connection with the 2012 r2. What should I do besides copying 1 exe, ini 1 , 2 dlls?
    Sorry for my English I am from Ukraine

    thank you
    Sincerely Roman Davydov

  45. josef says:

    Hello Roman

    you do not need anything else. Place the exe, the two DLLs and the changed ini file in one new folder on the device and start the exe. That is all.

    ~Josef

  46. Roman says:

    Hello Josef
    thanks for the answer

    I wonder did so but when I run the .exe nothing happens even error does not return. Options in the .ini spelled correctly. Although the program does something, because when I run it without connection to the TCP of an error.

    Roman Davydov

  47. josef says:

    Hello Roman

    I am sorry, but I can not help with that, too less details. Possibly you downloaded the wrong build. Try https://github.com/hjgode/rdesktopce_rdp5/tree/master/source/Windows%20Mobile%205.0%20Pocket%20PC%20SDK%20(ARMV4I)/Debug and the DLLs at https://github.com/hjgode/rdesktopce_rdp5/tree/master/source/dll

    ~

  48. Roman says:

    Thank you for caring Josef
    I replaced all the files but the connection is not there, I run .ehe and see on the screen something happens (spinning cursor in the box) but this does not follow, is there a log which is a result of the program to see for which reason there is no connectivity?
    Thank you again for your concern
    Roman Davydov

  49. josef says:

    Roman

    does the Remote Desktop Mobile application run and connect? If not, you have an issue with the RDP connection at all (firewall, wrong IP, username, password).

    There is no log written by rdesktopce.
    ~

Leave a Reply