Fix KiGetFpuState() - Thanks to Hartmut for finding this bug and testing the patch.
Modified: trunk/reactos/ntoskrnl/ke/i386/fpu.c

Modified: trunk/reactos/ntoskrnl/ke/i386/fpu.c
--- trunk/reactos/ntoskrnl/ke/i386/fpu.c	2005-10-06 20:07:24 UTC (rev 18299)
+++ trunk/reactos/ntoskrnl/ke/i386/fpu.c	2005-10-06 20:34:20 UTC (rev 18300)
@@ -326,6 +326,7 @@
 {
     PFX_SAVE_AREA FxSaveArea = NULL;
     KIRQL OldIrql;
+    ULONG Cr0;
 
     KeRaiseIrql(DISPATCH_LEVEL, &OldIrql);
     if (Thread->NpxState & NPX_STATE_VALID)
@@ -334,16 +335,19 @@
         if (Thread->NpxState & NPX_STATE_DIRTY)
         {
             ASSERT(KeGetCurrentPrcb()->NpxThread == Thread);
-            ASSERT((Ke386GetCr0() & X86_CR0_TS) == 0);
 
+            Cr0 = Ke386GetCr0();
+            asm volatile("clts");
             if (FxsrSupport)
                 asm volatile("fxsave %0" : : "m"(FxSaveArea->U.FxArea));
             else
             {
+                asm volatile("fnsave %0" : : "m"(FxSaveArea->U.FnArea));
+                /* FPU state has to be reloaded because fnsave changes it. */
+                Cr0 |= X86_CR0_TS;
                 KeGetCurrentPrcb()->NpxThread = NULL;
-                asm volatile("fnsave %0" : : "m"(FxSaveArea->U.FnArea));
-                Ke386SetCr0(Ke386GetCr0() | X86_CR0_TS); /* FPU state has to be reloaded because fnsave changes it. */
             }
+            Ke386SetCr0(Cr0);
             Thread->NpxState = NPX_STATE_VALID;
         }
     }