9 GetSystemTimeAsFileTime(&t);
10 return (((s64)t.dwLowDateTime | (s64)t.dwHighDateTime<<32)
14 FACTOR_STDCALL LONG exception_handler(PEXCEPTION_POINTERS pe)
16 PEXCEPTION_RECORD e = (PEXCEPTION_RECORD)pe->ExceptionRecord;
17 CONTEXT *c = (CONTEXT*)pe->ContextRecord;
19 if(in_code_heap_p(c->EIP))
20 signal_callstack_top = (stack_frame *)c->ESP;
22 signal_callstack_top = NULL;
24 if(e->ExceptionCode == EXCEPTION_ACCESS_VIOLATION)
26 signal_fault_addr = e->ExceptionInformation[1];
27 c->EIP = (cell)memory_signal_handler_impl;
29 /* If the Widcomm bluetooth stack is installed, the BTTray.exe process
30 injects code into running programs. For some reason this results in
31 random SEH exceptions with this (undocumented) exception code being
32 raised. The workaround seems to be ignoring this altogether, since that
33 is what happens if SEH is not enabled. Don't really have any idea what
34 this exception means. */
35 else if(e->ExceptionCode != 0x40010006)
37 signal_number = e->ExceptionCode;
38 c->EIP = (cell)misc_signal_handler_impl;
41 return EXCEPTION_CONTINUE_EXECUTION;
44 void c_to_factor_toplevel(cell quot)
46 if(!AddVectoredExceptionHandler(0, (PVECTORED_EXCEPTION_HANDLER)exception_handler))
47 fatal_error("AddVectoredExceptionHandler failed", 0);
49 RemoveVectoredExceptionHandler((void *)exception_handler);