Sucking up to Raymond Chen finally pays off

I'd
enjoy hearing stories about sloppy/ugly code or strange workarounds or
code comments during the development of Windows 95 (I'm assuming there
are a few since it was a big jump from Windows 3.1), how they got there,
anything TheDailyWTF-worthy. The type of code that works surprisingly
well but makes you hate your life when you read it.

Re: Sucking up to Raymond Chen finally pays off

I just about fell out of my chair when the first word of his entry was my name. Totally made my day. And no offense to TDWTF editors, but Raymond's WTF was better than anything we've had here in a long time, with the possible exception of today's make-the-new-guy-hold-the-power-button story.

Re: Sucking up to Raymond Chen finally pays off

If you're still interested in strange or WTF code in Windows 95, try to find a copy of the book "Unauthorized Windows 95" by Andrew Shulman. You can sometimes find a used copy on Amazon. I used to have a copy and it was pretty interesting. There was one section I still remember because it struck me as pretty wierd.

Schulman was stepping thru some code and came to a place where the code jumped to a wierd address -- the address was located in his computers BIOS, specifically the copyright string. The address contained the value 43h, the ASCII code for the letter "c". It turns out that 43h is also the opcode for an extremely obscure x86 instruction called ARPL. What ARPL does is irrelevant. What was important was ARPL is an illegal instruction in protected mode.

Win95 spent a lot of time switching back and forth between real mode and protected mode, so at startup Win95 would scan your computer's BIOS for the value 43h and save that address. Then, whenever it needed to switch from protected mode to real mode it would jump to that address, which is an illegal instruction, which caused an error, which invoked an error handler and eventually you ended up back in real mode.*

* I'm doing this from memory so you'll have to read the book for a better explanation.