Mar 132017
 

puTTY logoAnyone who has logged in to a UNIX or Linux machine remotely coming from a Windows box probably knows puTTY, which is practically “the” SSH and telnet client for Windows. In conjunction with a small X11 server like Xming you can even do Remote X. To my surprise, a new version has been released just last month, as a colleague told me! So there is version 0.68 now, and it comes in both a 32-bit and a 64-bit flavor.

Of course I had to try the 64-bit version on XP x64, and it did fail to execute:

64-bit puTTY failure on XP x64

A classic: 64-bit puTTY failure on XP x64, because it’s “not a valid Win32 application”

Out of curiosity, I fetched the puTTY source code from [here], because I thought I could just compile & link it myself. Building for 32-bit proved to be relatively easy; Just load the corresponding solution file into Microsoft Visual Studio 2010, build the whole project, done. But I wanted 64-bit! So I created a x64 build target and gave it a shot, but it couldn’t find the _addcarry_u64 intrinsic.

After a bit of searching on the web, it became clear that the intrinsics header of Visual Studio didn’t provide it. It’s too old, you need Visual Studio 2013 or newer for that. Funny part is, puTTY only comes with project files for 2010 and 2012, how are they building their x64 version? No idea. Maybe they’re linking against a different library version or something.

One attempt that I was going to make (build it with VS2013, linking against an older platform SDK) isn’t done yet, because I need to prepare my Windows 7 VM for it. I did manage to compile and run puTTY as 64-bit code on XP x64 by hacking up their program though! In the unpacked source tree, open sshbn.h and take a look at line #70:

expand/collapse source code
  1. #elif defined _MSC_VER && defined _M_AMD64
  2.  
  3.   /*
  4.    * 64-bit BignumInt, using Visual Studio x86-64 compiler intrinsics.
  5.    *
  6.    * 64-bit Visual Studio doesn't provide very much in the way of help
  7.    * here: there's no int128 type, and also no inline assembler giving
  8.    * us direct access to the x86-64 MUL or ADC instructions. However,
  9.    * there are compiler intrinsics giving us that access, so we can
  10.    * use those - though it turns out we have to be a little careful,
  11.    * since they seem to generate wrong code if their pointer-typed
  12.    * output parameters alias their inputs. Hence all the internal temp
  13.    * variables inside the macros.
  14.    */
  15.  
  16.   #include 
  17.   typedef unsigned char BignumCarry; /* the type _addcarry_u64 likes to use */
  18.   typedef unsigned __int64 BignumInt;
  19.   #define BIGNUM_INT_BITS 64
  20.   #define BignumADC(ret, retc, a, b, c) do                \
  21.       {                                                   \
  22.           BignumInt ADC_tmp;                              \
  23.           (retc) = _addcarry_u64(c, a, b, &ADC_tmp);      \
  24.           (ret) = ADC_tmp;                                \
  25.       } while (0)
  26.   #define BignumMUL(rh, rl, a, b) do              \
  27.       {                                           \
  28.           BignumInt MULADD_hi;                    \
  29.           (rl) = _umul128(a, b, &MULADD_hi);      \
  30.           (rh) = MULADD_hi;                       \
  31.       } while (0)
  32.   #define BignumMULADD(rh, rl, a, b, addend) do                           \
  33.       {                                                                   \
  34.           BignumInt MULADD_lo, MULADD_hi;                                 \
  35.           MULADD_lo = _umul128(a, b, &MULADD_hi);                         \
  36.           MULADD_hi += _addcarry_u64(0, MULADD_lo, (addend), &(rl));     \
  37.           (rh) = MULADD_hi;                                               \
  38.       } while (0)
  39.   #define BignumMULADD2(rh, rl, a, b, addend1, addend2) do                \
  40.       {                                                                   \
  41.           BignumInt MULADD_lo1, MULADD_lo2, MULADD_hi;                    \
  42.           MULADD_lo1 = _umul128(a, b, &MULADD_hi);                        \
  43.           MULADD_hi += _addcarry_u64(0, MULADD_lo1, (addend1), &MULADD_lo2); \
  44.           MULADD_hi += _addcarry_u64(0, MULADD_lo2, (addend2), &(rl));    \
  45.           (rh) = MULADD_hi;                                               \
  46.       } while (0)

I just commented out the entire codeblock using that modern _addcarry_u64 intrinsic, and replaced it with the code being used for the 32-bit version:

  1. #elif defined _MSC_VER && defined _M_AMD64
  2.  
  3.   /* 32-bit BignumInt, using Visual Studio __int64 as BignumDblInt 
  4.    * This is compatible with VS2010 & VS2012 for building a x86_64
  5.    * version of puTTY (no __int128 with those compilers).
  6.    */
  7.  
  8.   typedef unsigned int BignumInt;
  9.   #define BIGNUM_INT_BITS  32
  10.   #define DEFINE_BIGNUMDBLINT typedef unsigned __int64 BignumDblInt

I built that and it works, even though I keep thinking I should be using a wide 128-bit data type here (just like the original x64 code), but then we don’t have __int128 in MSVC before 2013, and I’m on 2010. And I don’t know how to use SSE registers in that context with things like __m128, which is why I left it alone. Looking good anyway:

puTTY 64-bit XP x64 version logged in to Windows 2000

puTTY 64-bit XP x64 version logged in to Windows 2000 using a modern SSH server (click to enlarge)

And:

puTTY 64-bit XP x64 version logged in to FreeBSD 10.3 UNIX

puTTY 64-bit XP x64 version logged in to FreeBSD 10.3 UNIX (click to enlarge)

In any case, here is a complete 64-bit build of puTTY that works on NT5.2 operating systems like Windows XP Professional x64 Edition or Windows Server 2003 x64:

  • [puTTY 0.68][1] (x64 version for NT5.2, portable without installer)

Maybe I’ll try to build a version with VS2013 on Windows 7 for the same platform target, we’ll see. But at least this works!

Oh and… No, I don’t really think anyone actually needs a 64-bit version of puTTY ;). Plus the 32-bit one works just fine on XP x64 / Server 2003 out-of-the-box anyway. But hey… You know… :roll:

[1] puTTY is © 1997-2017 Simon Tatham and is licensed under the MIT license

Apr 082014
 

Windows XP dark age logoSince I love exaggerated drama, I’d like to tell you a little story today. One that repeats itself every now and then, but sometimes it just stirs up shit more than usually. Ok? Here goes: One day, in a relatively nice world (or at least some inhabitants would’ve called it that), there was a young maiden growing up. She was not alone though, but a member of a large family with lots of older relatives, and her name was Windows XP. Having Windows Me and Windows 2000 as her parents (although some voices claim the real father was a guy named “Neptune”, but nobody can prove anything) made her a nice young lass. Since she was the youngest of the family, everybody loved her! Ok, not everybody liked her modern looks, but luckily, mommy 2000’s GDI clothes fit her soon enough, so she was able to dress up more seriously when requested. While their world wasn’t the only one even back then, the family chose to largely ignore or shut out other worlds around them, and Windows XP couldn’t care less. Growing massively in popularity she was soon the hottest thing in her own world, much to her satisfaction of course.

Windows XP on the rise

Windows XP on the rise

Childhood inevitably coming to an end slowly, she grew up to become a 64-Bit operating system even, and being the only one of the family with that feature at the time made her mighty proud. She went a bit international even, and worked on both the x86 and IA-64 Itanium continents, albeit the latter sunk to the ground of the ocean a few years ago, but oh well. At least she could now offer some serious new things like GPT or StorPort drivers, having matured from NT 5.1 to NT 5.2.

XP grows up, all x64 now

XP grows up, all x64 now

When her first sister was born, a young fugly wench named Vista, all that Windows XP had to spare for her was a smirk. With Vista not able to reach XPs and XP x64s glory, she thought herself invincible and walked through her world head high, all peaches and cream! Those other worlds’ people, like Linux, BSD UNIX or even MacOS X she just belittled rather than anything else, so great was her popularity at home by now. By that time Windows XP had grown relatively mature though, and little would she know that the true danger did not come from other worlds really, but from within her own freaking house!

The then-new brat

The then-new brat

Her over-confident smile froze to ice quickly after the birth of her then-youngest sister, named 7. Windows 7 was prettier, had new stuff XP didn’t and nobody really cared about that IA-64 Itanium continent having been flooded anyway. All you hear about that is cynical laughter, as only fools like Hewlett Packard had built their expensive houses there to begin with. Sure, Windows 7 having an even more perfect body than XP she couldn’t wear those nice old GDI clothes that well anymore (they just somehow don’t fit quite so well), but who was to be in opposition to that these days? All older relatives and parents were long gone, and Windows XP stood alone, and it was then when she realized that the end was coming for her, far sooner than she expected, having ignored all the signs…

By all means, she just couldn’t do those fancy new Direct3D 10/11 tricks that 7 could seemingly just pull out of the hat without much effort while even looking good doing so. As fast as the rise came, as long as her reign was, from that point on, there was only one way. Down. Indeed, the grim reaper was coming for her. And well…

For most citizens of the Microsoft world, he paid her the one and final visit today.

Or at least, so they would believe… and indeed, the dusk *is* here, night *is* falling, and for her, there will be no real sunrise ever again. And so, as she stumbles across the graveyard of her ancestors, in tears of despair, suddenly they are calling her down into the icy depths with a wild roar and a cold grip!

The icy depths are calling her

Come down here, where you belong, bitch! Die, just like all of us died before you! (True story guys!!!11 This happened today, on the 8th of April in 2014, no shit! Oh and: Original drawing by [Ian Strandberg].)

So, will she escape from that perilous graveyard? And if so, what for? To live on confused, in a world she can no longer see clearly, whose inhabitants she partially can’t even talk to anymore, a world that had abandoned her? Some legends say, that certain operating systems may carry on forever, despite all odds. Surely she heard those weird stories of ancients from other worlds such as Xenix (a very, very distant relative that shared next to nothing with her) or even OpenVMS. Maybe she too can trick death one last time as she did before already, and find her a place that does not despise her. Could be that that place is right here on this very machine I am typing this on, who knows? ;) And there might be others, who do not fear her being the outcast that she now is.

As she crawls over the mossy walls of that cemetery gravely wounded, suddenly, a bitter grin flits across her face as an evil thought found its way into her mind. She hears herself laugh out load, hysterically even, at the joy of that very thought!

For just recently, a new sister was born. And her name was 8. And some say, she be pretty damn good looking too. Maybe one day, her old rival Windows 7 will join her in her eternal exile, sharing the same bitterness, as she will have seen her own new rival force her out of her own house. Now if that day ever comes, that grin’d go from ear to ear, that much’s for sure!

Two old ladies, detached from the modern world, smiling bitterly at their fate. Somehow, a comforting thought she pondered.

PS.: I have started to write this and do that graveyard picture with a fever at nice 38°C/100°F. As I have now finished this weirdo crap about good old Windows XP, the thermometer is sitting at 38.5°C/102°F and it’s getting seriously hard to concentrate and maintain focus. So parts of this “article” might be unusually strange (ahem) or contain errors. If so, my apologies. I think I can no longer focus on it now, I’ll have to go to bed. I just had to finish this trash first somehow, as the 8th of April 2014, the end of all Microsoft support for Windows XP and XP x64 only comes once! ;) Long live XP x64, against all odds (or just emigrate to Linux or BSD UNIX, probably better anyway)!

Jun 282013
 

Search logoAnyone remembers the search function of Windows 2000? That clean, smooth and tidy user interface, no stupid dog assistant or anything else? Pure, simple, fast and when working on indexed file systems even more so. The nice and important tool [xp-AntiSpy] can give you that one back on XP in case you don’t wanna apply the hack manually in the systems registry hive.

However, even though most people think I’m against all modern technology, that ain’t true. A content-sensitive desktop search for instance, as known originally from MacOS X and later Windows 7 can be extremely helpful, especially if you want to search in different document formats like let’s say *.docx or *.pdf. I’m currently thinking about digitizing all my documents using OCR (optical character recognition), so I can have a large library of pdf files that can be searched for their content. On Windows 7 that’s easy, just let your scanner do the OCR, and the Windows 7 search will do the rest.

So, what you can do on XP / XP x64 is to install the Microsoft Desktop Search 4.0. That will give you a neat little search field in the task bar, and from there you can do content-sensitive searches. Also, Adobes own [pdf iFilter] supports this configuration, replacing the standard Microsoft search filter for PDF. There is only one problem: I’d like to keep the simple and smooth regular Windows 2000 search in Windows Explorer, that Desktop Search 4.0 also replaces, while I still want to be able to invoke Desktop Search 4.0 from the start menu or the neat search field in the task bar. Is it possible? Yes!

It does require some registry tweaking though, see the following code (just save the parts between the === === lines in a *.reg file, and then double-click it as a user with administrative privileges to insert it into your systems registry):

===Begin .reg file===
Windows Registry Editor Version 5.00

 [-HKEY_CLASSES_ROOT\CLSID\{FFAC7A18-EDF9-40DE-BA3F-49FC2269855E}\TreatAs]

 [HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer]
 "WebFindBandHook"="{68F2D3FC-8366-4a46-8224-58EFA2749425}"
 "FileFindBandHook"="{FFAC7A18-EDF9-40de-BA3F-49FC2269855E}"

===End .reg File===

Thanks fly out to the user [jgstanley] at [windowssecrets] for providing that fix! As soon as it’s applied, you may combine the simplicity and performance of the classic Windows 2000 search with the content sensitivity features of a more modern search engine, see here on a XP x64 test installation:

The power of old and new combined

The power of old and new combined

So, as you can see, the classic file search on the upper left and the modern Desktop Search 4.0 from the search bar on the lower right are working together nicely. In the Desktop Search field I have searched for some content present in the pdf file that is being found, in the classic search I have naturally just searched for file names. Working perfectly fine! So you can actually get the best of both worlds here!

Edit: Fixed a bug in the Registry hack source.