January, 2007

  • The Old New Thing

    If you ask an author to sign a book, you have to tell him/her what to write

    • 17 Comments

    If you happen to catch me, say by stopping by my office if you happen to work at Microsoft, I'd be happy to sign your copy of my book. (There's no need to set up a formal book signing appearance in building 9; just stop by my office any time.) One of the things you don't realize as a fan waiting in line at a book signing is that when you get to the front of the line, you have to tell the author what to write.

    It's obvious once you think about it. The author doesn't know anything about you. You're just one person out of hundreds they're going to sign for today. How should they know what to write?

    So don't make the same mistake Michael Kaplan did. (I'm just teasing, Michael!) When you stop by to ask me to sign your copy of the book, give me some idea what you want me to write. I'm happy to do it, but you have to give me something to work with.

    In other book news: The publishers are working on getting the bonus chapters onto the book web site. Your patience is appreciated. And I'm seeing book reviews coming from all over, like this one from Tom Duff (who even posted the review to the book's Amazon page), and a surprise one from Martin Heller. (The surprise that Martin Heller wrote a review of my book at all, not that the review is full of surprises. I don't know if that makes sense.)

  • The Old New Thing

    Crackpots in computer security: A complete solution to computer security

    • 33 Comments

    Now that computer security grabs headlines, the crackpots are drawn to it. This means that the security folks are innundated with dubious vulnerability reports and revolutionary computer designs.

    Today's story is one of the "revolutionary computer designs" category.

    I have developed a complete solution to computer security.

    Construct one case but with two CPUs inside. Each CPU gets its own hard disk, keyboard port, monitor port, mouse port, etc. You also have a keyboard, mouse, and monitor with two cables, one that goes to the first CPU's I/O ports and another that goes to the second CPU's I/O ports.

    You then designate on of the CPUs the "fun" computer and let it connect to the Internet, play games, download software, all that fun reckless stuff. You designate the other CPU as the "safe" computer, which is where you do your personal finance and save your sensitive information.

    There you have it. A way people can surf the web without compromising their sensitive data. I'm willing to grant Microsoft a license to use this revolutionary new computer design.

    (The actual proposal was much longer and more convoluted.)

    Once you untangle the proposal, it just boils down to using a KVM switchbox to switch between two computers. The only "revolutionary" bit is that the two computers happen to share a single case.

  • The Old New Thing

    Unusual uses for a ball-point pen: Breaking into the debugger

    • 27 Comments

    Before PCI there was ISA. The pinout for ISA slots had one very convenient property: If you shorted the last two pins in an open ISA slot, you generated an NMI. (This trick is alluded to in passing in this discussion of generating crash dumps from hardware.)

    It so happened that the tip of a ball-point pen was the ideal shape for accomplishing this. You inserted the tip of the pen at the very end of an open slot (the end nearest the back of the computer) and slowly dragged it towards the front of the computer until it shorted the nearest pair of pins.

    O              
                 

    If you had the Windows 95 debugger connected to the system (known as WDEB386), it caught the NMI and broke into the debugger. Doesn't matter if interrupts were disabled; you got your debugger. NMI stands for "non-maskable interrupt" and it's the "non-maskable" part that is important here, for it means that there's nothing that will prevent it from happening¹. Very handy if a device driver got itself stuck in an infinite loop. You could tell the real device driver developers from the posers by seeing who carried a ball-point pen with them. (I'll talk more about NMI in a future entry.)

    I was reminded of this little hardware trivia by a colleague who pointed out that his first encounter with me was me trying to break into a machine that had wedged by asking him to perform this little maneuver. Over the phone. From 1600 miles away. He was convinced it was some sort of prank.

    Bonus ISA trivia: During the transition period from ISA to PCI, motherboards supported both buses. If you looked at a computer from this era, you saw eight ISA slots and eight PCI slots... and eight brackets in the cover for the cards to mount into. How did that work? Shouldn't there be sixteen mounting brackets?

    Those PCI folks were so clever. If you looked at an ISA card from above, with the back plate of the computer facing away from you, it looked like this:  The board itself formed the vertical stroke, and the little metal mounting bracket formed the horizontal stroke. The mounting bracket on the case therefore sat slightly to the right of the ISA slot. The PCI folks made their cards a mirror image of the ISA card: If you looked at a PCI card from above, it looked like this:  The mounting bracket on the case sat to the right of the PCI slot.

    In this way, you were able to accommodate eight ISA slots and eight PCI slots with only eight mounting brackets. Each mounting bracket supported the PCI slot to its left or the ISA slot to its right.

    ¹For pedants: Yes, you could actually get a machine so badly wedged that even the NMI had no effect, but you needed the help of poorly-behaving hardware devices.

  • The Old New Thing

    If vertical strips are better, why do toolbars use horizontal strips?

    • 12 Comments

    If vertical strips are better, why do toolbars use horizontal strips?

    An early version of the toolbar control first made its appearance in Windows 3.0, and in those days, screen resolutions were low and toolbar buttons were small. Horizontal or vertical didn't really matter. Ten bitmaps, each 16 × 16, at 4-bit color, comes out to one kilobyte, much less than even a single 4KB page. (And what's this paging nonsense anyway? We're talking 16-bit Windows here!)

    When this code was ported to 32-bit Windows for Windows 95, the existing bitmap format was preserved in order to retain compatibility with the 16-bit clients of the toolbar control. Windows 95 included both the 16-bit and 32-bit versions of the common controls library, and they both built out of the same sources, with a little #ifdef WIN32 action here and there to deal with the places where 16/32 source code compatibility didn't quite cover everything. The early prototypes of the Windows 95 shell were written in this mixed 16/32 model, so that the same program could be compiled either as a 16-bit program or a 32-bit program. The 16-bit version was used in the earlier builds because the 32-bit kernel, GDI, and USER were all being developed in parallel. The 16-bit version went out in the builds, and the 32-bit version was used by the development team as a proving ground for Windows 95's 32-bit computing environment. When the 32-bit environment was declared "good enough to self-host", the switch was thrown, and the 32-bit shell went into the builds instead of the 16-bit shell.

    All this is a long way of saying that source code compatibility between 16-bit code and 32-bit code was very important, not only within the Windows 95 shell team, but throughout the Windows 95 product, so that teams could port their 16-bit components to 32-bit in a gradual and evolutionary manner. If you were to introduce gratuitous subtle differences (like the orientation of bitmap strips in toolbars), you wouldn't make many friends. They would port their program to 32-bit Windows and the toolbars would all come out funny. "But it works fine when I compile it as 16-bit. Must be a bug in Windows 95. I'll wait for the next build and try again."

    With the introduction of version 4.70 of the common controls, the internal structure of the toolbars changed, and the bitmaps came to be stored as imagelists rather than as raw bitmaps. Imagelists store their images in a vertical strip, so once again all is well with the world.

    "Why not add a TB_ADDVERTICALBITMAP message?"

    Well, for one thing, you're looking for inefficiency at the wrong level. All that happens with the bitmap is that it gets stuffed into an imagelist. Nobody actually draws out of it, so there's no point in optimize it for drawing.

    And for another thing, you're looking for inefficiency at the wrong level. If this even shows up on your performance traces, it means that you're spending your time loading images into toolbars. Isn't that a bigger cause for concern, that you're spending so much of your time setting up toolbars? Shouldn't you be spending your time doing productive work?

    (Imagelists? Use your imagination.)

  • The Old New Thing

    The real underground (and subway)

    • 10 Comments

    London's Transport Museum commissioned a gorgeous interactive map called The Real Underground which lets you see two of the many versions of the world-famous London Underground Map, as well as a street map, and switch among them to see how the two schematics agree with actual geography. I wasted way too much time playing with the Real Underground. Now it's your turn. (Looking at the evolution of transit maps, you can see that it was Harry Beck's breakthrough map from 1933 that changed the face of tube maps forever.)

    There appears to be a similar effort to do the same to the New York Subway map, published by the brilliant folks at Urban Mapping. I visit New York only once every other year or so, but this map is so cool I'm tempted to get it anyway, even though I'll probably misplace it by the time I next travel there.

  • The Old New Thing

    The /MAXMEM switch doesn't set the maximum amount of memory Windows will use

    • 12 Comments

    The Windows boot.ini file has a /MAXMEM switch whose name would lead you to believe that it sets the maximum amount of memory that Windows will use. But that's not what it does; the name is misleading.

    What the /MAXMEM flag really does is set the maximum physical address that Windows will scan in search of RAM. If your physical memory map contains discontiguous chunks of RAM, such as the one at the 3.5GB boundary in the sample diagram I drew a few months ago, then the amount of RAM Windows finds will be less than the /MAXMEM value you specified. For example, if there were a gap between 128MB and 256MB (said gap used by some hardware device, say), then setting /MAXMEM to 512MB would only give you 384MB of RAM. You lost 128MB of physical address space to the gap.

    What's more, Knowledge Base article Q108393 says

    Microsoft has not committed to keeping the switch in any future releases of Windows.

    In fact, Windows Vista carries through that threat. The /MAXMEM switch has no effect in Windows Vista. To try to avoid the confusion surrounding the meaning of MAXMEM, the kernel folks changed its name to TRUNCATEMEMORY. (It also specifies the physical address limit in bytes rather than megabytes.) I'm not sure the name change will really help much to dispel the confusion, though, since it still says "memory". I think they should've called it something like MAXPHYSADDR.

  • The Old New Thing

    Not my finest hour: Where are my keys?

    • 44 Comments

    Tuesday was not my finest hour.

    Towards the end of the work day, I noticed that my coat was nowhere to be seen. I distinctly remember putting it on the back of my chair, but it's not there now. And where are my keys?

    After checking all the likely places (and several unlikely ones) in my office, I realized that we had gone out to lunch in my car, and it was a warm day, so I walked outside to my car and, yup, my coat is sitting there in the back seat. Now, my normal routine when locking the car is to hold my keys in one hand while locking the car with the other. Upon further consideration, I figured that I locked the car doors, slipped the key in my coat pocket, and then decided that since it was a warm day, I didn't need my coat, so I tossed the coat onto the seat before shutting the door.

    Fortunately, this was not the end of the world. I took the bus home (which includes a bit of walking since the bus stop is a twenty-minute walk from my front door), making a point to take an earlier run than I might normally, since I didn't want to get caught outdoors when the cold night set in. (I had a heavy sweater but no gloves.) I keep a spare house key in my wallet, so I was able to get inside. My plan was to bring my spare car keys with me when I rode my bicycle to work the following morning.

    Aha, an improvement to the plan. I made plans to have dinner with a friend at a restaurant near my house. My friend picked me up at my house and then dropped me off at work. Woo-hoo! Everything has been restored to balance! I used my spare car keys to get into my car and drive home. While waiting at a traffic light, I checked the pockets of the coat in the back seat. Empty. Rats.

    And then I realized, "Hey, where is the coat that I wore to the restaurant?" I must have left it at the restaurant. Well, I was headed in that direction anyway, so I took a slight detour to the restaurant and picked up my other coat. At least one problem was solved. But what about my keys?

    I concluded that my keys must still be in my office somewhere, so I drove back to work, set on finding the keys and resolving the last outstanding issue. Yes, this could have waited until the next morning, but I was determined by now. I went back to my table, checked the obvious locations again, and then moved on to less obvious locations. "Maybe they fell on the floor." I crawled under my table, and that's when I remembered.

    "Hey, wait a second, this isn't the first time today that I crawled under my table." Earlier in the day, I plugged my USB keychain drive into the back of a computer that hangs out under my table. I did this in order to call up a particular dialog box so I could take a screen shot. I crawled into an even more inconvenient spot under my table and, yup, there was my keychain, dangling off the back of one of my computers.

    When I start to think I'm a pretty clever guy, I just have to remember the day I lost my keys, and then lost my coat while looking for my keys.

  • The Old New Thing

    Where did the Windows Vista wallpaper images come from?

    • 49 Comments

    Windows Vista needed some new wallpapers. Where to get them? Historically, they were purchased from a professional service, which is expensive since Microsoft would need worldwide rights to reproduce (not just use) the image, and not just for a few months, but for decades. Besides, there are a lot of good amateur photographers at Microsoft who would be thrilled to have their work displayed on millions of computers all over the world.

    But why stop there? Creative Director Jenny Lam expanded the search to Flickr and contacted people who took really interesting pictures, asking them, "So, how would you like one of your photos included among the default wallpapers in Windows Vista?" The Flickr artists were excited to be a part of Windows Vista (one of them by an astonishing coincidence happened to be a beta tester), and after the lawyers had their say—because nothing is complete without lawyers getting involved—Microsoft sent the photographers on a commissioned photo shoot. Jenny tells me that these amateur photographers were great to work with. They don't have the ego problems that some professional photographers can have. (Another thing that I learned from Jenny is that photos which look great on paper do not always translate well to the screen.)

    Ultimately, Jenny studied over 50 gigabytes of low-resolution images. (Off the top of her head, she estimates that she evaluated over 10,000 images, but the math suggests it was a lot more.) About two thirds of the final wallpapers are licensed from various image libraries, with the rest split among amateur photographers recruited from Flickr, Microsoft employees who enjoy photography, and a professional photographer specifically hired for this purpose. Jenny confides that the ones from Flickr are her favorites.

    If you were wondering where those gorgeous pictures came from, the answer is many of them came from amateur photographers, regular people like you and me. (But with better taste.)

    [Update 9:15am: Long Zheng has a bit more on those wallpapers.]

  • The Old New Thing

    Walking through packed snow and ice with a little more confidence

    • 17 Comments

    :: Wendy :: invited several her friends to join her in some tea two weeks ago, and during the conversation, LaCroix recommended a product called Yaktrax. It's a lightweight little mesh that straps to the bottom of your shoe and acts like miniature tire chains, but for your shoes. Two of my friends acted on this tip immediately and had their pairs ready in time for our next snowstorm. I, on the other hand, was slow to act and was caught unprepared.

    It was a sight to behold. Not the storm but the effect of the storm on traffic. I had never before seen a traffic jam on Microsoft Way. (A friend of mine reported that it took somebody on his team forty-five minutes just to get from level 2 to level 1 of the parking garage!) One of my colleagues had an eye on the weather and left as soon as it started turning bad. We called his mobile phone two hours later to find out how the commute was. "Was? I'm still on the road!" It ultimately took three hours to travel what normally takes 30 minutes.

    Based on what was obviously a regional traffic standstill, several of us decided simply to wait it out. We grabbed dinner in the cafeteria (which was, not surprisingly, much busier than the cafeterias normally are in the evening), and returned to our offices, where we ran across one of our corridor-mates coming into the building.

    "Don't go out there. It took me a half hour just to get to Building Q."

    Building Q was the building right next door.

    I decided to walk home, and even at the late hour, traffic near Microsoft campus was still gridlocked. I found myself walking significantly faster than the cars were moving (or, more often, not moving). If only I had a walker, I could have shuffled down the sidewalk faster than the cars. That would really have showed them.

    Anyway, back to the Yaktrax. My friends loaned me a pair since I was walking to and from the bus stop because the roads in my neighborhood were covered in ice, and unlike some people, I had the presence of mind not to drive under such conditions. (For those who care, the bus stop is on a major road that remained navigable.)

    My review: Yaktrax worked great. Small, lightweight, somewhat of a struggle to put on (probably easier to do sitting down). It's not like walking with crampons; there are no spikes. You can wear them onto the bus without any qualms, and you can even walk on carpet without causing damage. I don't recommend walking on linoleum with them, however, because the coils don't grip onto the slick surface. Despite the ad copy, I wouldn't recommend running with them on ice. They enable you to walk on snow or on snow-covered ice at a normal pace, and they add enough grip to take what used to be "impossible to walk without slipping and falling on the ice" and turns it into "you can walk if you go carefully."

    You can get them on Amazon, of course, but I ordered mine from REI.

  • The Old New Thing

    The undeletable Outlook folder, episode 2

    • 11 Comments

    I had another undeletable Outlook folder, and all my tricks for cajoling Outlook into letting me delete it failed. I already deleted all the items in it, emptied it of offline items, deleted all the failures from my Sync Issues folder, but still I couldn't delete the folder.

    But I came up with a new trick.

    I moved the folder out of its normal location and made it a direct child of "Mailbox". As a result, it was no longer part of the list of synchronzized folders. I synchronized one more time, and then Outlook let me delete the folder.

    As I noted before, I don't know if this'll work for you, but it's another trick you can add to your bag.

    (And I still have three folders that I can't delete, despite trying both this trick and the previous one.)

Page 1 of 4 (35 items) 1234