I use PuTTY with screen, and I also use the hibernate function of Windows. The problem is that connections timeout, and I have after each resume to close/reopen/resize all of my PuTTY windows.

This patch is a very quick workaround. It handles the Windows Power Message (WM_POWERBROADCAST), and when resuming it duplicates the current session and terminates the old one (waiting for ‘reuse-windows’ item, see below). The attached file contains the piece of code to be inserted somewhere in main select of the WndProc.

PuTTY 0.58 with this patch. (Unofficial)
Patch against 0.58 (to be inserted in window.c / WndProc)
Source Code including this patch.

Patch Code (to be inserted in window.c / WndProc)

/** 
 * Reset the connection when suspending, and try to re-establish it when resuming.
 * This is designed to be used with screen (SSH Remote Command : 'screen -r || zsh || bash')
 *
 * Windows broadcasts these messages 
 * * when pushing the suspend button :
 *  - PBT_APMQUERYSUSPEND : Query if suspend is allowed => We do not do anything.
 *  - PBT_APMSUSPEND      : Tell the program Windows is suspending => Close the connection.
 * * when resuming :
 *  - PBT_APMRESUMESUSPEND : Tell the program Windows is resuming from suspend mode => Re-open the connection.
 *  - PBT_APMRESUMEAUTOMATICALLE : Tell the program that Windows has resumed from something. => Do nothing.
 */
case WM_POWERBROADCAST:
      switch(wParam)
      {
            case PBT_APMSUSPEND:
            {
                    logevent(NULL, "APM Suspend.");
                    break;
        }
            case PBT_APMRESUMESUSPEND:
            {
                    logevent(NULL, "APM Resume.");
                    // Restart the session
                    PostMessage(hwnd, WM_COMMAND, (WPARAM)IDM_RESTART, (LPARAM)NULL);
                    break;
            }
            default: break;
      }
      return TRUE;

What? – Version 0.53a

This patch is a very quick workaround. It handles the Windows Power Message (WM_POWERBROADCAST), and when resuming it duplicates the current session and terminates the old one (waiting for ‘reuse-windows’ item, see below). The attached file contains the piece of code to be inserted somewhere in main select of the WndProc.

Vote for wish ‘reuse-windows’

The ‘Ability to re-use dead session windows’ in on the wishlist of PuTTY. This would be really great (as with this patch, the screen would be restored within exactly the same window : no need to resize/move the window). So as stated in PuTTY’s page, do vote for this feature !

Patch Code (to be inserted in window.c / WndProc)

/** 
* Suspend - 2003 - Rémi Peyronnet <[email protected]> http://www.via.ecp.fr/~remi 
* 
* Reset the connection when suspending, and try to re-establish it when resuming.
* This is designed to be used with screen (SSH Remote Command : 'screen -r || zsh || bash')
*
* Windows broadcasts these messages 
* * when pushing the suspend button :
*  - PBT_APMQUERYSUSPEND : Query if suspend is allowed => We do not do anything.
*  - PBT_APMSUSPEND      : Tell the program Windows is suspending => Close the connection.
* * when resuming :
*  - PBT_APMRESUMESUSPEND : Tell the program Windows is resuming from suspend mode => Re-open the connection.
*  - PBT_APMRESUMEAUTOMATICALLE : Tell the program that Windows has resumed from something. => Do nothing.
*/
case WM_POWERBROADCAST:
      switch(wParam)
      {
            case PBT_APMSUSPEND:
            {
                    logevent("APM Suspend.");
                    break;
        }
            case PBT_APMRESUMESUSPEND:
            {
                    logevent("APM Resume.");
                    // Duplicate the session and close the current. 
                    // Knows Issue : As this is the wrong order (duplicate, then close), 
                    //  screen might not have been detached if the suspend time was too short.
                    //  This should only happen when testing suspend/resume quickly.
                    // It would obviously be neat to re-use the window, but my tries have been unsuccessful.
                    PostMessage(hwnd, WM_SYSCOMMAND, IDM_DUPSESS, NULL);
                    PostMessage(hwnd, WM_DESTROY, 0, NULL);
                    break;
            }
            default: break;
      }
      return TRUE;