PDA

View Full Version : The problem with Windows XP SP2



PtP
11-08-2004, 12:22 PM
The DivX problem is going to be repeated on quite a few applications.

Anything that generates machine code into a memory buffer and then calls it will be hit, until the authors modify their software to tell Windows what they're doing. The calls for this have existed since the introduction of the Win32 API - it's just that until now, nothing went wrong if you didn't use them.

The technical details go like this. Since x86- compatible CPUs acquired memory protection, at the 386, it's been possible for operating systems to mark memory segments as readable or writable - much like filename permissions under UNIX/Linux. But until AMD introduced the NX bit, it hasn't been possible to control if segments were executable. If memory could be read, you could try to execute it.

Buffer overflow attacks work in just this way: upload a large packet, stuffed with machine code and with trickery to get the target computer to execute it. For more gory details, see Jon Erickson's Hacking: the art of exploitation, from No Starch Press, or doubtless any one of dozens of website. DEP marks stack and data memory as non-executable, so that if you try to execute it, you get an error.



DivX will be generating machine code into a buffer and calling it. This is a recognised trick for accessing screen memory extremely quickly: you generate code that implicitly knows about the screen memory layout, the logical operatings you want to do on the image, and so on. They you call it. It runs a load faster than code that's full of "if (24bitscreen) {} else {}" idioms, because all those questions were answered while it was geing generated.

To avoid DEP biting you when you do this, you need to allocate the memory that will hold the code with the correct flags. With a quick look in MSDN, it seems that VirtualAlloc with the appropriate flProtect option is what you need. Windows will set up a memory segment that's execute-enabled, and give you back a pointer to it. You do need to use VirtualAlloc: malloc() doesn't know a thing about this stuff.
As for why the DivX install is giving trouble, I don't know. I'd suspect an installer which generates machine code for its own operatings on the fly, or something like that. Other things that could easily get bitten by DEP include naive Java JITs and similar programs. Straight C or C++ code that doesn't try to get clever with the guts of the hardware doesn't seem to do this.

Like the DivX answer page says, you can turn off DEP for individual programs under XPsp2. My Computer=> Properties=>Advanced=>Performance.

PtP
11-08-2004, 12:23 PM
How to install DivX 5.2 under Windows XP Service Pack 2

<!-- Body -->Windows XP Service Pack 2 introduces new security features designed at improving the stability of your computer, and its resistance to various security exploits commonly exploited by hackers and malware. One of these features, called Data Execution Prevention, or DEP, can prevent DivX 5.2 from installing and operating correctly. This issue will arise if your system matches one of the following configurations:


Microsoft Windows XP Service Pack 2 running on an Intel Pentium 4 Prescott CPU or newer
Microsoft Windows XP Service Pack 2 running on an AMD Athlon 64 CPU or newer


If you install DivX 5.2 on such a system, installation may appear to proceed normally, however the DivX installer will be unable to correctly register various components with the operating system, and they will not function correctly.





Installing DivX 5.2


Before you run the DivX 5.2 installer, you must temporarily turn off the DEP feature in Service Pack 2. To do so, take the following steps:


Open the System Properties control panel
Select the Advanced tab
Click the Performance Settings button
Select the Data Execution Prevention tab from the Performance Settings window
Click Turn off DEP
Click OK
Install DivX
Re-enable DEP
You must have administrative privileges to perform this action. In consideration of your systems security, we strongly advise that you do not disable DEP on a permanent basis.

Using DivX 5.2


To use any component of DivX Pro 5.2, you must disable the DEP feature for any software that relies upon a DivX component. This includes:


Video editing applications
Media players
DivX EKG
To do this, you must add exclusions for each application on your system that you wish to work with DivX 5.2:


Open the System Properties control panel
Select the Advanced tab
Click the Performance Settings button
Select the Data Execution Prevention tab from the Performance Settings window
Add the desired applications to the DEP exclusion list by browsing to its installed location and selecting the main program file
You must have administrative privileges to perform this action. If you disable DEP for an application, you remove a layer of protection that targets, most specifically, network-based attacks. We strongly recommend that you do not disable DEP for web browsers.

</AS-HTML>