Post · 1 min read· p. 164

ANSI Escape Codes for Windows 7 RC

Two days ago j00ru informed me that my cmd.exe add-on (the one that adds the ultra important feature - colors!) does not work on Windows 7 RC - so I decided to have a look, and so version 0.004d came into being!

If one is interested about what add-on am I referring to, and how does it work - please read this post. In the current post I'll focus only one the minor differences, between Vista's cmd.exe and W7RC cmd.exe, that were the direct cause of version 0.004c malfunction.

To tell you the truth, there was only one difference - function LoadLibraryA was missing in the IAT of cmd.exe - and I used IAT entry in the cmd.exe entry loader (that was executed before OEP and loaded AnsiSupport.dll). In addition to that, I had a bug in my patcher - an uninitialized variable - that prevented the patcher from printing the correct error message that would instantly tell me what is wrong. Instead of that, the patcher inserted a "random" address into the patch, and behaved as if everything was OK - and this caused of course the patched cmd.exe to crash.

The solution was simple - I have written a variation of the patch that uses LoadLibraryW (which is present in IAT of cmd.exe from W7RC), and made the patcher choose which patch to apply, depending on the presence of either LoadLibraryW or LoadLibraryA in the IAT.

A download link as a final word:

cmd_ansihack_004d.zip (31kb, SRC+BIN)

And thats it!