DrMinGW is a fancy crash detection program for MinGW programs. Details can be found here:

http://code.google.com/p/jrfonseca/wiki/DrMingw

One of the really cool features of DrMinGW is you can alternatively invoke a DLL from your program to catch your crashes, instead of requiring you or your testers to install DrMinGW.

The problem is the library and DLL aren’t available for download, and building it from sources requires SCONS, which I can’t seem to get to work with it. So, my solution is to build it manually. Unfortunately, building it requires knowledge of some of the secret defines set by SCONS.

After much digging, building the DLL should have been:

The samples can be built now as follows:

NOTE: “-gstabs3” symbols are required by DrMingW.

Now you can run test.exe or testcpp.exe and watch them crash. Be sure copy exchndl.dll alongside the executables. The way it works is: If there’s no DLL, then nothing happens; If there is a DLL, an RPT report file is written.

If you read the documentation for DrMinGW, what may not be entirely obvious with exchndl.dll is that it doesn’t pop up a box, but instead writes an RPT file relative your executable (myapp.exe -> myapp.RPT).

Relative the executable is alright for debugging, but once your game/app is installed by a user you no longer have permission to write relative your executable (unless you get elevated privileges). My solution is to write the report file somewhere safe instead. Below is a modified “OnStartup()” function that places the report in your roaming profile. Overwrite the original function found inside “exchndl.c” (#includes and all).

Now if you’re to browse to your roaming profile directory, you’ll find the report.

Phew!

Static libintl

When building the DLL, a static alternative to libintl (the -lintl part) can be found here:

http://sourceforge.net/projects/libintl-windows/

Be sure to link against “libintl.a” and “win_iconv.c”.

Stripping to cut down the size. Should be closer to 700K now instead of 5M.

NEW: Pidgen’s Modified DrMinGW

The folks behind the Pidgen chat client have provided an improved version of the original DrMinGW (exchndl.dll):

http://hg.pidgin.im/util/drmingw

It exists because of a discussion over here on how exploitable it could be:

https://developer.pidgin.im/ticket/15289

And more details on the exploit itself are here. A pretty blatant one that probably every application that loads dll’s is venerable to in some way.

One solution… maybe. MinGW lacks Softpub.h (and wintrust.lib), so this maybe a VC build only thing. I’m not sure though if MinGW’s DLL loader is the same as VC. Heh, getting very Windows meta here. 😀