I'm trying to realize handling Windows exceptions with the help
of __try/__except block.
Problem is that the program never enters __except block - only exits incorrectly.
Workspace: OS: Windows 7 x64; Framework: Embarcadero XE5 C++ Builder; Application template type: console 64-bit application (for 32-bit works normally!)
Code:
void foo()
{
   __try
   {
     int *p = 0;
     fprintf(stderr, "before action");
     *p = 1;
   }
   __except(EXCEPTION_EXECUTE_HANDLER)
   {
    printf("in __except block\n");
    throw("");
   }
}
int _tmain(int argc, _TCHAR* argv[])
{
 try
 {
   foo();
 }
 catch(...)
 {
   printf("in catch block\n");
 }
 printf("end of main\n");
 return 0;
}
Output:
before action
then incorrect exit
In the second variant I added exception handler this way:
LONG WINAPI MyUnhandledExceptionFilter(PEXCEPTION_POINTERS p)
{
  printf("in excepiton filter\n");
  return EXCEPTION_EXECUTE_HANDLER;
}
int _tmain(int argc, _TCHAR* argv[])
{
  AddVectoredExceptionHandler(1, MyVectorExceptionFilter);
  // the same text
  // ...
}
After this I got this output:
Output:
before action
in excepiton filter
then incorrect exit
Why does not the program enters __except block?
Is there a way to continue working correctly after entering exception handler?
 
     
     
    