+ /*
+ * Ignore C++ exceptions
+ *
+ * http://support.microsoft.com/kb/185294
+ * http://blogs.msdn.com/b/oldnewthing/archive/2010/07/30/10044061.aspx
+ */
+ if (pExceptionRecord->ExceptionCode == 0xe06d7363) {
+ return EXCEPTION_CONTINUE_SEARCH;
+ }
+
+ /*
+ * Ignore thread naming exception.
+ *
+ * http://msdn.microsoft.com/en-us/library/xcb2z8hs.aspx
+ */
+ if (pExceptionRecord->ExceptionCode == 0x406d1388) {
+ return EXCEPTION_CONTINUE_SEARCH;
+ }
+
+ // Clear direction flag
+#ifdef _MSC_VER
+#ifndef _WIN64
+ __asm {
+ cld
+ };
+#endif
+#else
+ asm("cld");
+#endif
+
+ log("apitrace: warning: caught exception 0x%08lx\n", pExceptionRecord->ExceptionCode);
+
+ static int recursion_count = 0;
+ if (recursion_count) {
+ fprintf(stderr, "apitrace: warning: recursion handling exception\n");