A [url=http://forums.thedailywtf.com/forums/p/7509/139904.aspx#139904]while[/url] ago I promised a story/rant about

Microsoft translators. Well, here it is. I'm not sure if the issue I describe is known stuff, or whether it is

appropriate to the forum, or if it's too long, so "AS IS", etc.

You probably know that Microsoft distributes a lot of localized Windows (and not just Windows, obviously) versions. Of course, it is nice to see the strings translated to your native tongue, especially if you don't know English at all. But sometimes, translators go too far. A relatively benign example is that they translate program names. Well, "Звукозапись" (or "Фонограф", as it was in Win95) is somewhat more intelligible that "Sound Recorder", but "Проигрыватель Windows Media"? Why didn't they translate "Internet Explorer" (since "Explorer" is "Проводник"), or, for that matter, "Windows"? Still, that's only mildly amusing, and I can live with it.

But sometimes the translators poke their noses where they really shouldn't. For example, the messages that were shown by Windows 98 bootloader if something went wrong were "localized". Well, the Cyrillic font obviously isn't loaded at this stage, so all that came out was the unintelligible mess of accented characters and symbols for the artist-formerly-known-as-Prince. And the Windows XP bluescreens (at least in SP1) made the same mistake. Yeah, I'm very happy that ïðîèçîøëà êðèòè÷åñêàÿ îøèáêà. Anyway, bluescreens don't happen very often, and I can live with it.

(That was just the foreword, the actual story follows. 8=])

Circa 1996, I had a computer (wow!). And it had the übercool OS installed on it — Windows 95! And it was really cool (I mean, I was just a kid back then). Well, besides such cool things as Paint and Wordpad, I had a certain [url=http://en.wikipedia.org/wiki/War_Gods_%28video_game%29]game[/url]. And it was (you guess it) cool. And that's about all about this period.

But circa 2001, an upgrade happened. And one of the consequences was that the trusty Windows 95 was replaced by Windows 98. Which was cool, but not so much. Months passed and I remembered The Game. Anticipating hours of fun gameplay, I installed it, but when I tried to launch it, it popped up a strange dialog: "To play War Gods you must close all other CD applications and insert the game CD. Retry/Cancel?"

I scratched my head and went on to verify that CD is, in fact, in the cupholder, and that no other applications are accessing it, or, for that matter, are running. After realizing the futility of repeatedly clicking the Retry button, I was reduced to watching the demo mode, which was entertaining, but not as entertaining (and cool), as, say, [i]playing[/i] the game. Afterwards, I uninstalled it and started exploring some other game. PowerPoint, probably.

The upgrade to Windows Me, which happened soon, didn't help the situation. The upgrade to Windows XP, which happened not-so-soon, didn't either.

Fast-forward to 2006. By this point I already had an Internet connection and my programming knowledge was growing exponentially. After I learned some x86 assembly, I suddenly thought: Hey! I'm a 1ee7 cr@xx0r now! I can look into the game disassembly and find the bug which prevents me from kicking ass! So I grabbed a [url=http://www.ollydbg.de/]debugger[/url] and plunged into the realm of teh machine codez. By setting a breakpoint on the MessageBox function call, I quickly located the CD binding code.

Here begins the interesting part. The game talked to Windows using MCI ([url=http://msdn2.microsoft.com/en-us/library/ms709461(VS.85).aspx]Media Control Interface[/url]). Basically, it sent a string and received a string in return. The first command issued was <font face="Courier New">status cdaudio ready</font>, and the response was <font face="Courier New">true</font>, since the drive was indeed ready. The game was happy with it and proceeded to request another bit of detail: <font face="Courier New">status cdaudio media present</font>. The response was identical and the game displayed curiosity again with <font face="Courier New">status cdaudio number of tracks</font>. To my surprise, the answer was <font face="Courier New">15</font>! After some head-scratching, I opened Windows Media Player and realized that the game data was on the first track, while the rest were music from the game. The game agreed that 15 tracks is just enough and then entered an interesting loop for <font face="Courier New">i</font> = 1 to 15. In each iteration the value of <font face="Courier New">i</font> was substituted into <font face="Courier New">status cdaudio type track %u</font>, and subsequently executed.

This command is [url=http://msdn2.microsoft.com/en-us/library/ms713277(VS.85).aspx]supposed[/url] to return either <font face="Courier New">audio</font> or <font face="Courier New">other</font>, depending on the track type. Imagine my surprise when it returned some garbage string instead! In the first iteration, this string was deemed unequal to "audio" and thus OK; however the garbage of the second iteration was expected be be equal to "audio", and thus the check for authencity failed.

Fine, I found the culprit, but what now? Windows is buggy? Since you've read the intro, you probably guessed the problem already, but I was flabbergasted. Not knowing what to do, I hacked together a simple VB program to experiment with MCI commands. Since I possess supreme C skillz now, I present you a C equivalent:

#include <stdio.h> #include <wchar.h> #include <locale.h> #define UNICODE #include <windows.h> #define BUFSIZE 1024 wchar_t inbuf[BUFSIZE], outbuf[BUFSIZE]; int main() { setlocale(LC_ALL, ""); while (fgetws(inbuf, BUFSIZE, stdin)) { MCIERROR err; size_t len = wcslen(inbuf); if (inbuf[len - 1] == L'

') inbuf[len - 1] = L'\0'; err = mciSendString(inbuf, outbuf, BUFSIZE, NULL); if (err == 0) fwprintf(stdout, L"%s

", outbuf); else if (mciGetErrorString(err, outbuf, BUFSIZE)) fwprintf(stdout, L"%s

", outbuf); else fputws(L"WTF?

", stderr); } return 0; }

I punched in the same commands as the game did:

status cdaudio ready true status cdaudio media present true status cdaudio number of tracks 15 status cdaudio type track 1 [b]другой[/b] status cdaudio type track 2 [b]аудио[/b]

[b]ZOMGWTFBBQROTFLMAOP&PIMP face'o'table!!1! [i]They translated the [u]MAGIC STRING[/u]?!?17!?!?!seventy one?!?!?!?[/i][/b]

When the stream of profanity run out, I opened the game executable and overwrote the magic string "audio" with the sorta-magic string "аудио", and the message box nagged me no more.