public static extern bool SetThreadContext(IntPtr hThread, ref CONTEXT lpContext);
/// <summary> /// Sets the context of a given thread. /// </summary> /// <param name="hThread">Handle to the thread for which the context will be set.</param> /// <param name="ctx">CONTEXT structure to which the thread's context will be set.</param> /// <returns>Returns true on success, false on failure.</returns> public static bool SetThreadContext(IntPtr hThread, CONTEXT ctx) { return Imports.SetThreadContext(hThread, ref ctx); }
/// <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; }