PuTTY with Windows 7 jumplist support

Geplaatst door Daniel B. Roy op 29 January 2010

Tag(s): Hobbyprojecten, Artikel, Open Source

One of Windows 7's neater additions is the jumplist (my Mac Fanboy co-workers would actually call this a 'stolen UI idea'). This is a really handy thing for PuTTY, because it would allow you to start a saved session directly, without having to start PuTTY first and then double-clicking the session. You would then have a type of shortcut to saved sessions and as an added bonus save one valuable mouse-click in the process. Also, by pinning items in the jumplist, this offers a recent and favorite sessions functionality. Since PuTTY is open source, I decided to download the code and add this functionality myself. The resultant new version of PuTTY is downloadable below.

The jumplist is an application specific list, that can contain items defined by the application, for instance a list of recently opened documents or a list of favorites defined in the application. The list is persistent across application restarts and is accessed by right clicking the taskbar button of a running application or the icon of a pinned non-running application. For MS Word the jumplist looks like this:

With my changes added in, a saved session is added to the PuTTY jumplist when it is started by doubleclicking it in the config screen, or started from the command line with the "-load" parameter. Clicking a saved session in the jumplist will start it in PuTTY. The result can be seen below. As you can see, it is also possible to pin frequently used saved sessions in the jumplist as a kind of favorites.

I sent the changes to the PuTTY team and they have added them to the wishlist on their site. If you like them, please don't hesitate to petition the PuTTY maintainers to add this code to the actual program.

 

For those that are interested, I'll give some more details about the code. I used this excellent set of posts on the Microsoft site as a guide to the implementation, combined with the online MSDN library.

One thing to be aware of as a programmer is that the jumplist is write-only. You can't read what your jumplist currently looks like. Every time you want to change or update the jumplist, you have to rebuild it from scratch, not being able to access the old list. So, even if you're just adding one item to the top of the list you have to already know what all the other items that are staying in the list were, because from code you can't find out.

Obviously, this means that as a program you need to store the contents of your jumplist in your own persistent storage, so you know what your list looked like the last time you created it. I used the registry for this, adding an extra key to PuTTY's existing storage location.

Also, not being used to C programming, I spent quite some time mucking about with lowlevel string processing and calling COM functions from C code. COM being a technology that is built around OOP, quite some plumbing is required to connect the classless language C to the COM subsystem. The Windows 7 SDK header files do take a lot of that pain away though.

My general approach was as follows:

  1. Download the putty bleeding-edge source files from their SVN repository.
  2. Add Windows 7 header files to the project, using the Windows 7 SDK. Required for using the COM subsystem from C.
  3. Create functions to manipulate the internal registry list of jumplist entries. These functions add and remove items from the registry list.
  4. Create functions for manipulation of the jumplist. For instance: the function add_session_to_jumplist() first uses a function from 3 to update the registry list and then recreates the jumplist.
  5. Insert calls to functions from 4 in several places in the code. Specifically I had a session added to the jumplist when it is double clicked or opened with the commandline '-load' parameter.

The resultant sourcecode patch can be downloaded from the PuTTY site or below and contains extensive comments. I hope anyone else creating this type of thing finds them helpful.

Please beware that by downloading and using this adapted version of putty, you are implicitly saying that you trust me. If I am evil than I could have modified the file below to send your sensitive SSL keys and information directly to my mailbox. I didn't, of course, but you need to be aware of the possibility.

I hope this addition to one of my favorite programs is useful to you.

Download de bijbehorende bestanden:

Schrijf een reactie:

Naam:
E-mail*:
Bericht:
*optioneel, wordt niet getoond.