Data Execution Protection & Rex Winn

Back in Dec 2005 Charles Cowan reported a problem where Surfulater would crash whenever it went to display one of its pop-up tip Windows. I’d had no other reports of this and was unable to reproduce it on any of our test PC’s. As any software developer will tell you these are the worst type of problems to have.

Over the course of a few days I created several special builds of Surfulater that I sent to Charles in an effort to isolate the precise cause of the problem. The results from this process made little sense at the time and I was unable to get to the bottom of it. Charles informed me that he was having problems with other programs as well and in the end we agreed it was likely a problem with his PC, and not Surfulater. I did suggest a work-around which enabled him to continue using Surfulater, but I was not particularly satisfied with the outcome.

Step forward to earlier this month when Rex Winn told me he was having a problem with Surfulater crashing when capturing new articles. Rex and I went back and forth on this and I concluded fairly quickly that it was the same problem Charles had reported. When a new article is created Surfulater pops up a tip window and there came the same crash. As it fortuitously happened Rex is also a software developer and after lengthy exchange of e-mails he was able to pin-point the cause. 

Surfulater was working fine on Rex’s PC until he did two things. First he changed his operating system from Windows XP to Windows 2003 Server and second he upgraded the BIOS on his Motherboard. At that point Surfulater would run ok until a pop-up tip was displayed. But then Rex needed to re-boot his PC and after that Surfulater wouldn’t start at all. Like Charles, Rex mentioned he was also having problems with some other programs and the only way to get these programs to work was to turn off Data Execution Protection.

I hadn’t heard of Data Execution Protection or DEP, so it was time to hit Google. The first thing I found was that DEP wasn’t enabled on my PC, so I quickly rectified that, started Surfulater and it worked perfectly. Next I discovered there are two aspects to DEP, Software DEP and Hardware DEP and I’d only enabled Software DEP. Hardware DEP is only available on newer PC’s, so I didn’t even know if my PC supported it. After some digging around in the BIOS I found the option that enabled Hardware DEP, turned it on, started Windows, then Surfulater and low and behold I was able to reproduce the problem Charles and Rex were having with the pop-up window. Everything else worked fine and the problem where Rex couldn’t even start Surfulater remained a real mystery.

So now it was time to start digging and find out precisely what was causing DEP to throw its hands up in horror and kill Surfulater. Before I do let me provide some information on DEP from Microsoft.

Data Execution Prevention (DEP) is a set of hardware and software technologies that perform additional checks on memory to help prevent malicious code from running on a system. In Microsoft Windows XP Service Pack 2 (SP2) and Microsoft Windows XP Tablet PC Edition 2005, DEP is enforced by hardware and by software.

The primary benefit of DEP is to help prevent code execution from data pages. Typically, code is not executed from the default heap and the stack. Hardware-enforced DEP detects code that is running from these locations and raises an exception when execution occurs. Software-enforced DEP can help prevent malicious code from taking advantage of exception-handling mechanisms in Windows.

The bottom line here is that DEP will help prevent Trojan and Virus programs from running on your PC, which is an admirable goal.

So back to Surfulater. It turned out that some third party code I use was causing the problem by trying to assemble and execute code in a data section. This has been something Windows programmers have been doing forever, but can no longer, at least on Windows XP SP2 and Windows 2003 SP1 with DEP enabled. The good news was that other folks using this same code were aware of the problem and several solutions had been presented. Kevin Hoffman’s code was a perfect fit and after a few hours reworking my code, Surfulater and DEP played happily together. I quickly sent a copy off to Rex to try who ecstatically reported his favourite program was working perfectly again.

To quote Rex:

The good news is that it *WORKED* YOU ROCK!!!

The bad news… THERE ISN’T ANY!!! SWEET!!! I’m back into SUL and
loving it!!! WOOOOHOOOO!!!

As I said at the start these are the worst sorts or problems to track down. Rex’s help was truly invaluable and for that I remain indebted.

A final word of advice for any programmer’s reading this. Ensure you thoroughly test you code with both Hardware and Software DEP enabled.

And to my Surfulater readers Version 1.97, Build 0.20 was released today with this updated code in place. Download here.

No related posts.

This entry was posted in Surfulater, Surfulater - Tech Info. Bookmark the permalink.

7 Responses to Data Execution Protection & Rex Winn

  1. Rex Winn says:

    It’s been working quite well I’m happy to report. It’s always very disappointing when you make some sort of a large scale system change and you break a program or product. I was very frustrated about not having SUL anymore and I just kind of figured that’s how it was going to be.

    I was extremely surprised at how motivated you were to identify the problem and code a solution. In fact I’ve just never had an experience as positive as that before.

    I’ll be a loyal Surf-U-Later user for a long time and Soft As It Gets will be one of the first vendors I consider for future product purchases.

    Thanks a ton Neville, I really appreciate your dedication to your products.

    Best Regards,

    Rex Winn

  2. nevf says:

    Hi Rex,
    Thanks for the kudos. One of the key differentiators that separates the wannabes from successful players is a commitment to delivering a quality product and great service and then following through. There is no doubt in my mind that this is one of the keys to my companies longevity in the crowded software market.

    The fact that you are a Surfulater zealot and were able to provide invaluable assistance also helped a great deal. Thanks again for that.

  3. Charles Cowan says:

    Neville: After our adventures in December it is great to get a solution to the problem. So far all seems fine, both the popup balloons and the icon selection.

    Good work and thank you for your persistance.

    Regards,
    Charles Cowan

  4. Hi Neville,

    Thanks for the heads up on this one. We use the same component (albeit the WTL version) within Visual Lint, and as luck would have it I was able to put together an updated version a day *before* the first bug report arrived from a potential customer. As a result, that person seems rather impressed with our response time at the moment!

    I’ve not checked out your product yet, but I have a feeling it’s about time I did…. ;)

    Cheers,

    Anna

  5. nevf says:

    Hi Anna,
    I’m really pleased my post over at CP was able to help a fellow developer. I don’t use shog’s code as is either, but a reusable chunk from within it.

    And yes it is about time you checked out Surfulater.

  6. Hi Neville,

    Great article!!! We just went through a few amazingly weird bugs last week, were some files were being converted to read-only status for no apparent reason and causing havoc in those rare cases. Not quite as hard to trace, but quite difficult nonetheless.

    What I really liked about your article though is that you articulated very well the difficulties of tracing and solving those brutal types of bugs!

    Regards,
    Stephane

  7. Pingback: FollowSteph.com » An Adventure in Solving a Difficult Software Bug