• The Old New Thing

    Batman and Robin patrolling Whitley

    • 2 Comments

    Batman and Robin have been spotted in Whitley, providing valuable services like rescuing damsels in distress (pushing her car to the nearest petrol station), scaring away potential muggers, and even chasing streakers off a football pitch.

  • The Old New Thing

    Why did InterlockedIncrement/Decrement only return the sign of the result?

    • 16 Comments

    If you read the fine print of the InterlockedIncrement and InterlockedDecrement functions, you'll see that on Windows NT 3.51 and earlier and on Windows 95, the return value only matches the sign of the result of the increment or decrement. Why is that?

    The 80386 instruction set supports interlocked increment and decrement, but the result of the increment/decrement operation is not returned. Only the flags are updated by the operation. As a result, the only information you get back from the CPU about the result of the operation is whether it was zero, positive, or negative. (Okay, you also get some obscure information like whether there were an even or odd number of 1 bits in the result, but that's hardly useful nowadays.)

    Since those operating systems supported the 80386 processor, their implementations of the InterlockedIncrement and InterlockedDecrement functions were limited by the capabilities of the processor.

    The 80486 introduced the XADD instruction which returns the original value of the operand. With this additional information, it now becomes possible to return the result of the operation exactly.

    Windows NT 4 dropped support for the 80386 processor, requiring a minimum of an 80486, so it could take advantage of this instruction. Windows 98 still had to support the 80386, so it couldn't.

    So how did Windows 98 manage to implement an operation that was not supported by the CPU?

    Windows 98 detected whether you had a CPU that supported the new XADD instruction. If not, then it used an alternate mechanism which was mind-bogglingly slow: It called a driver whenever you wanted to increment or decrement a variable. The driver would then emulate the XADD instruction by disabling interrupts and performing the operation in locked memory. Since Windows 98 was a uniprocessor operating system, it didn't have to worry about a second processor changing the memory at the same time; all it needed to ensure was that the single processor didn't get interrupted while it was performing the "atomic" operation.

  • The Old New Thing

    Chris Pratley's history lesson

    • 9 Comments

    If you haven't read it yet, check out Chris Pratley's voluminous discourse on various aspects of the history of Word. It packs more history into one entry than I do all year.

    And that was a sequel! You can read the first half, too.

    In fact, the good stuff keeps on coming. just read it all.

  • The Old New Thing

    Scripting is a two-edged sword

    • 15 Comments

    A three line VB script will disable your firewall.

    The advantage of scripting is that you can control so many things with just a few lines of code.

    The disadvantage of scripting is that bad people can control so many things with just a few lines of code.

    I wonder how long it will be before there's a virus that disables the firewall.

  • The Old New Thing

    Broadcasting user-defined messages

    • 5 Comments

    When you broadcast a message (via HWND_BROADCAST) remember that the message you broadcast must have global meaning. I discussed earlier what the various message ranges mean. Notice that only the system-defined range (0..WM_USER-1) and the registered message range (MAXINTATOM .. MAXWORD) have global meaning. The other two ranges have class-specifc or application-specific meanings.

    In other words, you can't broadcast a message in the WM_USER range since that message has a different meaning for each window class. Similarly, a message in the WM_APP range has a different meaning for each application.

    We ran into this problem in Windows 95. There were programs that decided to broadcast private messages like WM_USER+0x0100, intending them to be delivered to other instances of that program. Of course, when those messages reached some other windows, they interpreted WM_USER+0x0100 as some other private message and either acted funny or crashed.

    On the other hand, the programs really wanted the message to reach the windows of other copies of itself, so we couldn't just block the broadcast of the programs would stop working. Progams were relying on the system not trying to stop them from crashing other programs!

    The solution was to split the difference. If you broadcast a message that was not safe to broadcast, Windows 95 would send it only to old-style programs. New-style programs (marked as version 4.0 or higher) would not receive the messages.

    That way, old programs continued to affect each other as they always did, but new programs followed the new rules.

    Moral of the story: When you broadcast a message, make sure it's one that every receiving window will be able to handle.

  • The Old New Thing

    Dead man running

    • 7 Comments

    The plight of the legally dead (but physically alive) in India has been taken up by - of course - a legally dead man. And now he's running for public office. Though apparently this isn't the first time.

    (People are usually declared dead by conniving relatives who want to claim their inheritance prematurely.)

    I wish him luck. If it works in Missouri it can work in India.

  • The Old New Thing

    Is open source the new monoculture?

    • 63 Comments

    Okay I know I'm going to get into a lot of trouble for even bringing up this topic...

    This past weekend, Ulf Harnhammar discovered two buffer overflow and two directory traversal vulnerabilities in LHA, a library of data compression functions.

    Since the code for this is public, it has been copied all over the place. At least one commercial archive management program and at least one commercial mail antivirus program are vulnerable. A denial of service attack is already under way against the mail antivirus program; all you have to do is attach a malformed LHA file to a message, causing the scanner to crash when it attempts to scan the attachment. When the administrator restarts the mail server, the scanner will resume where it left off... and crash again. (Somebody with more time on their hands could craft a more clever LHA file attack that takes over the mail server itself.)

    The fact that the code itself was public meant that everybody didn't have to write their own LHA functions. This is a good thing. However, it also means that everybody has the same security vulnerabilities. This is a bad thing.

    So we have one bug that can take down large numbers of machines, even though they're all running different software.

    How do you track all the versions? Is there a solution to this? Is it even a problem?

  • The Old New Thing

    Truckers block highway to protest high gas prices

    • 21 Comments

    To protest rising gasoline prices, a group of truckers abandoned their vehicles in the middle of the highway. It struck me as odd that a country that brims with anti-French rhetoric would adopt one of their protest techniques.

    Presumably they don't want French gasoline prices either.

  • The Old New Thing

    Why does my hard drive light flash every few second?

    • 22 Comments

    Back in Windows 95, people would notice that their hard drive light would blink every few seconds. What's that all about?

    Actually, it wasn't the hard drive light after all.

    Windows 95 was polling your CD-ROM drive to see whether you had inserted a new CD. Some computers wired up the "hard drive light" not to the hard drive but rather to the SCSI and/or IDE bus. So the light didn't indicate hard drive activity necessarily. It turned on for any bus activity.

    Fortunately, motherboard manufacturers discovered their mistake and nowadays you don't find any of them that miswire the hard drive access light.

    Or do you? I keep my computer under my desk so I never see the hard drive light anyway. I'm just surmising that in the past seven years, motherboard manufacturers have gotten their act together.

  • The Old New Thing

    Today is Swedish tax day

    • 16 Comments

    Of course, in Sweden, every day is tax day.

    By now, it's too late to fill out your tax form, which the Swedish tax agency permits you to file on paper, via Internet, over the phone, or even via SMS.

    They even have what I wish the US tax agency had: An online tax form calculator.

Page 415 of 451 (4,501 items) «413414415416417»