Adding new menu item to PuTTY

1 minute read

This article has been migrated from my original post at

I came across a requirement to add a new easy access menu item to the putty terminal window for Windows. This article explains how I did it.


I collect a lot of debug logs for my Linux development boards while working with some new problem. While I have some environment constraints that force me to work with my Windows Box, I find it difficult to split the log files just before a particular scenario occurs (so that it will be easier to identify what went wrong)

The general approach I take is to go change the logging in putty re-configuration to none, apply it and then change it again back to “All Session Output”. But doing this every time was not fun.

So, I decided to include a new menu item that automatically does this.

The problem was, there are no architecture documentation available for PuTTY (at least none that I came across). So, I had to dig through the code and here is how I achieved my objective


I used the latest release source code for Windows available here

I used the express version of MS Visual Studio 2012 available for download here

The code changes I made are

  1. Define the SECURITY_WIN32 macro in putty.h to avoid compilation errors
#ifndef SECURITY_WIN32
#define SECURITY_WIN32

2) define the new SYSCOMMAND message in windows.c

#define IDM_RELOG    0x0080

3) Add the menu item in WinMain() of windows.c


4) Add the callback handle code to WndProc() of windows.c

	log_reconfig(logctx, &cfg);
	log_reconfig(logctx, &cfg);

Compile the code, and you now have a new menu item to restart the log file

Leave a comment