Re: Kill debug for single module
"Mark Randall" <mark[__OKTHISISFAKE_]yr@REMOVETHISgoogle.ANDTHIScom> wrote
in message news:%23HLSnI5pGHA.3288@TK2MSFTNGP03.phx.gbl...
I am having a problem with a certain DLL (thats basically littered with
badly placed interupts / breakpoints) and I would like to disable the
debugger picking them up for just the one DLL.
Is this possible? if so would someone explain to me how to acomplish this
in Visual Studio 2005.
Consider this post as mostly thinking out loud ...
Well, first it is a process that actually is debugged and not a DLL. So, if
this DLL is loaded into multiple processes you'd have a lot to do.
Second, is the process that loads the DLL being debugged when this happens
or is it that DebugBreak() is activating just-in-time debugging?
If the former I don't think that there is a nice easy way out. Since it is
really an "int 3" that invokes the debugger you might be able to replace the
handler for that one interrupt. But even if you could do that, if you want
to be able to debug the good stuff then it seems to me that you would be
constantly toggling the address of the interrupt handler just before you
invoke a function in the DLL and toggling it back on exit. You might want to
post again in the kernel group.
If the latter, then all hope is not lost. You could disable DebugBreak()'s
ability to signal the debugger if you install a handler for the breakpoint
exception in advance of calling the functions in the DLL:
#include <windows.h>
#include <stdio.h>
LONG CALLBACK MyExceptionFilter(LPEXCEPTION_POINTERS p)
{
LONG dwCode;
dwCode = p->ExceptionRecord->ExceptionCode;
if ( dwCode != EXCEPTION_BREAKPOINT )
return EXCEPTION_CONTINUE_SEARCH;
p->ContextRecord->Eip = p->ContextRecord->Eip + 1;
return EXCEPTION_CONTINUE_EXECUTION;
}
int main()
{
__try
{
// Call your DLL function here - I just call DebugBreak() straight away as
a test
DebugBreak();
printf("I'm here\r\n");
}
__except ( MyExceptionFilter( GetExceptionInformation() ) )
{
}
return 0;
}
Finally, it should be possible to do what you want by becoming the debugger
for the process that ails you. You would then field the breakpoint
notifications and swallow the ones that shouldn't be there. Of course,
that's a boat-load and a half of work. If it's something that you'd consider
doing, I can post a link to a book by John Robbins wherein he discusses the
debug API.
Regards,
Will