What will you do if you encounter a crash in an application before it reaches the entry point ok EXE, i.e., the crash happens before the control reaches the WinMain
. In such cases, the crash might have happened in the DLL loaded by the EXE. To be more specific, say in the DllMain()
of DLLs. In most cases, we will not be having the source code of all DLLs so that we can put some breakpoint in the DllMain()
and debug. So how to track which DLL is causing the problem...
The windows loader provides an option to break the debugee while loading DLLs. For this, we have to set appropriate values under "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options" key.
Suppose I have an application which has dependency with "Foo.dll" and I want the bebugger to break just before loading "Foo.dll". To do so, create a key under the "Image File Execution Options" like:
"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\Foo.dll".
Add a DWORD
value under this key with name "BreakOnDllLoad
" and set its value as one.
Now if you start the application from the debugger. The debugger will report a breakpoint hit during startup. This break point will be just above the call to DLL entry point of foo.dll. (The entry point is _DllMainCRTStartup
if the DLL is written using VC++. This function later calls DllMain()
).

This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.