/// <summary> /// Gets the context of a given thread. /// </summary> /// <param name="hThread">Handle to the thread for which the context will be returned.</param> /// <param name="ContextFlags">Determines which set(s) of registers will be returned.</param> /// <returns>Returns the context of the thread. If failure, sets CONTEXT.ContextFlags to zero.</returns> public static CONTEXT GetThreadContext(IntPtr hThread, uint ContextFlags) { CONTEXT ctx = new CONTEXT(); ctx.ContextFlags = ContextFlags; if (!Imports.GetThreadContext(hThread, ref ctx)) { ctx.ContextFlags = 0; } return(ctx); }