/* $Id: //info.ravenbrook.com/project/mps/master/test/test/testlib/platform.c#6 $
*/

#include "testlib.h"
/* that includes platform.h, so we don't need to */

#ifdef MPS_OS_W3

LONG mySEHFilter(LPEXCEPTION_POINTERS info) {
 LPEXCEPTION_RECORD er;
 ULONG_PTR write, address;

 er = info->ExceptionRecord;

 if (er->ExceptionCode == EXCEPTION_ACCESS_VIOLATION) {
  write = er->ExceptionInformation[0];
  address = er->ExceptionInformation[1];
  report("memoryerror", "true");
  if (write == 1) {
   report("memoryop", "write");
  } else { /* write == 0 */
   report("memoryop", "read");
  }
  report("memoryaddr", "%ld", address);
  report("abort", "true");
  report("assert_or_abort", "true");
  myabort();
 }

 /* otherwise don't interfere */
 return EXCEPTION_CONTINUE_SEARCH;
}

#endif