Article ID: 106262
Article Last Modified on 10/2/2003
/* Compiler options needed: /D_X86_
*/
#include <windows.h>
#include <memory.h>
#include <string.h>
#include <stdio.h>
int handling = 0;
int do_cld = 0;
LONG MyFilter(LPEXCEPTION_POINTERS except_pointers)
{
EXCEPTION_RECORD* er = except_pointers->ExceptionRecord;
if (do_cld)
{
__asm cld
}
if (er->ExceptionCode==EXCEPTION_ACCESS_VIOLATION && handling==0)
{
handling = 1;
printf("We're in the filter now and printing out a long"
"string that's long enough to cause a problem\n");
handling = 0;
return EXCEPTION_EXECUTE_HANDLER;
}
else return EXCEPTION_CONTINUE_SEARCH;
}
int main(int argc,char** argv)
{
if ( argc==2 && ((strcmp(argv[1],"cld")==0) ||
(strcmp(argv[1],"CLD")==0)))
do_cld = 1;
__try
{
printf("Starting the test\n");
memcpy((void*)4,(void*)0,8);
printf("After exception");
}
__except (MyFilter(GetExceptionInformation()))
{
printf("In the handler now\n");
}
return 0;
}
Additional query words: 1.00 structured handling protection fault
Keywords: kbbug kbfix kbcrt KB106262