Index: /trunk/source/lisp-kernel/thread_manager.c
===================================================================
--- /trunk/source/lisp-kernel/thread_manager.c	(revision 15130)
+++ /trunk/source/lisp-kernel/thread_manager.c	(revision 15131)
@@ -87,5 +87,5 @@
   /* What if the suspend count is > 1 at this point ?  I don't think
      that that matters, but I'm not sure */
-  pcontext->ContextFlags = CONTEXT_ALL;
+  pcontext->ContextFlags = CONTEXT_FULL;
   rc = GetThreadContext(hthread, pcontext);
   if (rc == 0) {
@@ -788,5 +788,5 @@
   TCR_AUX(next)->prev = prev;
   TCR_AUX(tcr)->prev = TCR_AUX(tcr)->next = NULL;
-#ifdef X8664
+#ifdef X86
   tcr->linear = NULL;
 #endif
@@ -1900,5 +1900,5 @@
   TCR *current = current_tcr;
 #elif defined(WIN_32)
-  TCR *current = (TCR *)((char *)NtCurrentTeb() + TCR_BIAS);
+  TCR *current = ((TCR *)((char *)NtCurrentTeb() + TCR_BIAS))->linear;
 #else
   void *tsd = (void *)tsd_get(lisp_global(TCR_KEY));
@@ -2020,5 +2020,5 @@
       return false;
     }
-    pcontext->ContextFlags = CONTEXT_ALL;
+    pcontext->ContextFlags = CONTEXT_FULL;
     rc = GetThreadContext(hthread, pcontext);
     if (rc == 0) {
@@ -2027,4 +2027,9 @@
     where = (pc)(xpPC(pcontext));
 
+    if ((where >= restore_windows_context_start) &&
+        (where < restore_windows_context_end) &&
+        (tcr->valence != TCR_STATE_LISP)) {
+      Bug(NULL, "Forgot about this case ...");
+    }
     if (tcr->valence == TCR_STATE_LISP) {
       if ((where >= restore_windows_context_start) &&
@@ -2061,11 +2066,5 @@
           ResumeThread(hthread);
           SEM_WAIT_FOREVER(TCR_AUX(tcr)->suspend);
-          SuspendThread(hthread);
-          /* The thread is either waiting for its resume semaphore to
-             be signaled or is about to wait.  Signal it now, while
-             the thread's suspended. */
-          SEM_RAISE(TCR_AUX(tcr)->resume);
-          pcontext->ContextFlags = CONTEXT_ALL;
-          GetThreadContext(hthread, pcontext);
+          pcontext = NULL;
         }
       }
@@ -2194,13 +2193,22 @@
     HANDLE hthread = (HANDLE)(TCR_AUX(tcr)->osid);
 
+
+    TCR_AUX(tcr)->suspend_context = NULL;
     if (context) {
-      context->ContextFlags = CONTEXT_ALL;
-      TCR_AUX(tcr)->suspend_context = NULL;
-      SetThreadContext(hthread,context);
+      if (tcr->valence == TCR_STATE_LISP) {
+        rc = SetThreadContext(hthread,context);
+        if (! rc) {
+          Bug(NULL,"SetThreadContext");
+          return false;
+        }
+      }
       rc = ResumeThread(hthread);
       if (rc == -1) {
-        wperror("ResumeThread");
+        Bug(NULL,"ResumeThread");
         return false;
       }
+      return true;
+    } else {
+      SEM_RAISE(TCR_AUX(tcr)->resume);
       return true;
     }
