Binarysharp.MemoryManagement.Threading.ThreadCore.GetThreadContext C# (CSharp) Method

GetThreadContext() public static method

Retrieves the context of the specified thread.
public static GetThreadContext ( SafeMemoryHandle threadHandle, ThreadContextFlags contextFlags = ThreadContextFlags.Full ) : ThreadContext
threadHandle Binarysharp.MemoryManagement.Native.SafeMemoryHandle A handle to the thread whose context is to be retrieved.
contextFlags ThreadContextFlags Determines which registers are returned or set.
return Binarysharp.MemoryManagement.Native.ThreadContext
        public static ThreadContext GetThreadContext(SafeMemoryHandle threadHandle, ThreadContextFlags contextFlags = ThreadContextFlags.Full)
        {
            // Check if the handle is valid
            HandleManipulator.ValidateAsArgument(threadHandle, "threadHandle");

            // Allocate a thread context structure
            var context = new ThreadContext {ContextFlags = contextFlags};

            // Set the context flag

            // Get the thread context
            if (NativeMethods.GetThreadContext(threadHandle, ref context))
                return context;

            // Else couldn't get the thread context, throws an exception
            throw new Win32Exception("Couldn't get the thread context.");
        }