The Old New Thing
Practical development throughout the evolution of Windows.
Latest posts
How you might be loading a DLL during DLL_PROCESS_DETACH without even realizing it
As you are I'm sure aware, you shouldn't be doing much of anything in your function, but you have to watch out for cases where you end up doing them accidentally. Some time ago, I was investigating a failure which was traced back to loading a DLL inside . Wait, what kind of insane person loads a DLL as part of shutting down? Shouldn't you be cleaning up stuff, not creating new stuff? The following is not the actual code, but it captures the same spirit: There is some global variable that contains a pointer to memory that was allocated by . In this case, I made it a cache, but the details aren't important...
I could just use a picture of a regular-sized shopping cart from farther away
Internet retailer woot! went to CES 2010 and covered it on their blog. (CES category.) But they don't cover what the media elite cover, the big announcements, the hot products. Nope, they cover the weird stuff. They have uncrating photos of CES itself, they infiltrate the The Consumer Breakfast Buffet Show, and they take super secret spy pictures of a miniature shopping cart.
It rather involved being on the other side of this airtight hatchway: If they can inject code, then they can run code
One category of the dubious security vulnerability is designing an insecure system, putting together an exploit, and then blaming one of the components of the exploit rather than the insecure system in the first place. I have found a critical security vulnerability in the XYZ scripting object which permits modifying files on the Web server itself. To effect this exploit, write a script which instantiates the control and use the method to tell it to save its contents. The method does not attempt to block directory traversal, so you can pass any path to the method and overwrite any file on the server. To d...
News flash: Wearing clothing keeps you warm
Every so often, I'll run across a statement of the obvious disguised as news and post it to the News flash tag, but the ones I've found have nothing on this collection of the 11 Most Painfully Obvious Newspaper Articles Ever. Just click through and slap your forehead. Bonus News Flash: Mark McGwire used steroids. I can't wait to see what other breaking news stories we'll have in the coming days. "Pope's religion identified." "Bear feces found in forest."
Why does GetCommandLine give me a corrupted command line?
A customer had the following problem: We're calling to retrieve the command line, and the documentation says that it returns a single null-terminated string. However, when we call it in our application, we find that it is actually a double-null-terminated string. The buffer returned consists of a series of null-terminated strings, one string per word on the command line, all stored one after the other, and with two null terminators at the end. How do I get the original string? Recall that the command line is just a conveniently-initialized variable in a process and once it's set up, the kernel doesn't really...
But that's not all: The story of that cheesy Steve Ballmer Windows video
While it's true that the cheesy Steve Ballmer Windows video had bad music, bad hair, and bad acting, it's also true that all that cheese was intentional. That video was produced for and shown at the Company Meeting, back when a mainstay of the Company Meeting was spoofs of popular television advertisements—what today would be called "virally popular"—with Bill Gates and other senior executives taking the starring roles. The "Crazy Steve" video was a spoof of late-night television advertisements, the most direct influence being the popular-at-the-time Crazy Eddie commercials. So enjoy the "Crazy St...
Weight Gain 4000, the competition
Some years ago, one of my colleagues mentioned at the lunch table, "I went hiking this weekend, and man, my backpack was so heavy. I weighed it, and it was like 35 pounds. And then I realized, wait a second, I'm overweight by 35 pounds. I'm carrying this heavy backpack all the time!" Thus began a collective weight loss competition we called Weight Gain 4000, named after an episode of South Park which had aired recently. ("I'm not fat; I'm big-boned!") I set up a Web page where people could enter their current weight, and it charted everyone's pounds over target weight as a function of time. Oh, and the goal was...
Pros and cons of using a four-year-old as your language instructor
I have a niece who is a native speaker of Chinese. Playing with her is a free language lesson, and there are advantages and disadvantages. One advantage is that you will learn all the basic words, and you won't run the risk that your instructor will accidentally use some advanced vocabulary that will throw you off. (You also learn some words that are very important to young children like butt and fart.) Fortunately, my niece's pronunciation is very good, so it's not like I'm accidentally learning to speak with a lisp or a childhood speech impediment. One disadvantage is that you're learning kiddie-talk: My nie...
Why aren't compatibility workarounds disabled when a debugger is attached?
Ken Hagan wonders why compatibility workarounds aren't simply disabled when a debugger is attached. As I noted earlier, many compatibility workarounds are actually quicker than the code that detects whether the workaround would be needed. Now suppose you find a compatibility problem with some applications that expect the function to return exactly or . You then change the function to something like this: Now, we add code to enable the compatibility workaround only if the application is on the list of known applications which need this workaround: What was a simple flag test now includes a check to ...