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.");
}