Fix returning the context of the current thread in NtGetContextThread
authorThomas Bluemel <thomas@reactsoft.com>
Fri, 20 Oct 2006 13:45:52 +0000 (13:45 +0000)
committerThomas Bluemel <thomas@reactsoft.com>
Fri, 20 Oct 2006 13:45:52 +0000 (13:45 +0000)
svn path=/trunk/; revision=24580

reactos/ntoskrnl/ps/debug.c

index 51488a7..e4fcd57 100644 (file)
@@ -174,8 +174,7 @@ PsGetContextThread(IN PETHREAD Thread,
         Size = sizeof(CONTEXT);
 
         /* Read the flags */
-        ProbeForReadUlong(&ThreadContext->ContextFlags);
-        Flags = ThreadContext->ContextFlags;
+        Flags = ProbeForReadUlong(&ThreadContext->ContextFlags);
 
         /* Check if the caller wanted extended registers */
         if ((Flags & CONTEXT_EXTENDED_REGISTERS) !=
@@ -256,10 +255,18 @@ PsGetContextThread(IN PETHREAD Thread,
                                            FALSE,
                                            NULL);
         }
+    }
 
+    _SEH_TRY
+    {
         /* Copy the context */
-        RtlMoveMemory(ThreadContext, &GetSetContext.Context, Size);
+        RtlCopyMemory(ThreadContext, &GetSetContext.Context, Size);
+    }
+    _SEH_HANDLE
+    {
+        Status = _SEH_GetExceptionCode();
     }
+    _SEH_END;
 
     /* Return status */
     return Status;
@@ -285,8 +292,7 @@ PsSetContextThread(IN PETHREAD Thread,
         Size = sizeof(CONTEXT);
 
         /* Read the flags */
-        ProbeForReadUlong(&ThreadContext->ContextFlags);
-        Flags = ThreadContext->ContextFlags;
+        Flags = ProbeForReadUlong(&ThreadContext->ContextFlags);
 
         /* Check if the caller wanted extended registers */
         if ((Flags & CONTEXT_EXTENDED_REGISTERS) !=
@@ -304,7 +310,7 @@ PsSetContextThread(IN PETHREAD Thread,
         }
 
         /* Copy the context */
-        RtlMoveMemory(&GetSetContext.Context, ThreadContext, Size);
+        RtlCopyMemory(&GetSetContext.Context, ThreadContext, Size);
     }
     _SEH_HANDLE
     {