线程context

线程切换的时候,要保存当前运行状态,以便后续切换回来

CONTEXT结构体保存的是一堆寄存器

两个函数

//You cannot get a valid context for a running thread. Use the SuspendThread function to suspend the thread before calling GetThreadContext.
//If you call GetThreadContext for the current thread, the function returns successfully; however, the context returned is not valid.
BOOL SetThreadContext(HANDLE hThread,const CONTEXT *lpContext);

//Do not try to set the context for a running thread; the results are unpredictable. 
//Use the SuspendThread function to suspend the thread before calling SetThreadContext.
BOOL GetThreadContext(HANDLE hThread,LPCONTEXT lpContext);

 

posted @ 2020-02-23 14:49  AGB  阅读(395)  评论(0编辑  收藏  举报