From d6dd9ea2a31bda9e6d6613945883e2f88cdcef5d Mon Sep 17 00:00:00 2001
From: Slava Pestov <slava@slava-pestovs-macbook-pro.local>
Date: Mon, 17 Nov 2008 21:21:57 -0600
Subject: [PATCH] Add workaround for Windows bttray.exe issue

---
 vm/os-windows-nt.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/vm/os-windows-nt.c b/vm/os-windows-nt.c
index 54afd1c147..e22ea1446b 100755
--- a/vm/os-windows-nt.c
+++ b/vm/os-windows-nt.c
@@ -29,7 +29,13 @@ long exception_handler(PEXCEPTION_POINTERS pe)
 		signal_number = ERROR_DIVIDE_BY_ZERO;
 		c->EIP = (CELL)divide_by_zero_signal_handler_impl;
 	}
-	else
+	/* If the Widcomm bluetooth stack is installed, the BTTray.exe process
+	injects code into running programs. For some reason this results in
+	random SEH exceptions with this (undocumented) exception code being
+	raised. The workaround seems to be ignoring this altogether, since that
+	is what happens if SEH is not enabled. Don't really have any idea what
+	this exception means. */
+	else if(e->ExceptionCode != 0x40010006)
 	{
 		signal_number = 11;
 		c->EIP = (CELL)misc_signal_handler_impl;