views:

375

answers:

5

I'm having problems using madExcept + UPX on Delphi 2007. Whenever I open the compressed application, a Windows exception dialog appears code 0xc0000005. Anyone has the solution for this?

Thanks!

+2  A: 

That exception code usually means it's an unhandled external exception. What happens if you don't Use UPX? Does the exception go away?

It may not have anything to do with MadExcept, BTW. That exception code usually indicates that the exception happened before the VCL's exception handlers can be set up, and therefore it would probably be before MadExcept gets hooked in as well.

EDIT: From your comment, it sounds like UPX's compression technique may be interfering with MadExcept/Delphi's ability to hook up the Exception handler chain. Did you check the link Bruce provided?

Ken White
The program runs smoothly without UPX.
gmuller
A: 

I've successfully used madExcept with ASProtect, so I know it can be used with exe compression. However, there may be some specific problems with UPX.

Bruce McGee
+11  A: 

Stack tracing on exceptions etc. requires mapping in-memory code addresses to virtual addresses as stored in the executable, so that they can be correlated with either a .map file or debug info which indicates the function or source file and line. Normally, the mapping is straight-forward and relatively linear.

Executable compression mucks this up because it doesn't have a straight-forward mapping, particularly not one in line with the PE spec. This is because the executable compression replaces the initialization routine in the executable with one that extracts data from disk into memory (this also means that compressed executables don't share pages with other instances, and use more memory than uncompressed executables, since they need to page in everything all at once), before forwarding to the newly-expanded original initialization routine.

So, without quite clever relative-address storage of code locations in the stack tracing, it's unlikely that the two techniques will work together.

FWIW, I personally don't recommend using executable packers.

Barry Kelly
A: 

Try the following switch with upx:

--compress-exports=0

+3  A: 

It was already covered in MadShi's own forums:

Forum Article #1
Forum Article #2

There's a dozen of other topics around, but to sum a long story, MadExcept 3.* and after is known to work OK with UPX, below not.

Fabricio Araujo
Yes, I know that. I use UPX on several other apps, but there's a specific application that doesn't work.
gmuller