GetThreadContext

GetThreadContext

GetThreadContext是一個WindowsAPI函式,功能是取暫存器信息,返回值是GetLastError,另外不能用GetThreadContext(GetCurrentThread(), &ct)這種直接獲取當前執行緒的方式。

基本介紹

  • 中文名:取暫存器信息
  • 外文名:GetThreadContext
  • 定義:BOOL GetThreadContext
  • 參數:hThread
  • 返回值:GetLastError
定義,參數,說明,

定義

BOOL GetThreadContext(HANDLE hThread, LPCONTEXT lpContext);

參數

hThread
獲取信息目標進程的執行緒句柄。(用OpenThread獲取)
lpContext
一個用於接收信息的CONTEXT結構指針
返回值
如果成功,返回值不為零.
如果不成功,返回值為零,若想看其他的錯誤信息,參考GetLastError
CONTEXT結構定義
typedef struct _CONTEXT{
DWORD ContextFlags;
DWORD Dr0;
DWORD Dr1;
DWORD Dr2;
DWORD Dr3;
DWORD Dr6;
DWORD Dr7;
FLOATING_SAVE_AREA FloatSave;
DWORD SegGs;
DWORD SegFs;
DWORD SegEs;
DWORD SegDs;
DWORD Edi;
DWORD Esi;
DWORD Ebx;
DWORD Edx;
DWORD Ecx;
DWORD Eax;
DWORD Ebp;
DWORD Eip;
DWORD SegCs;
DWORD EFlags;
DWORD Esp;
DWORD SegSs;
} CONTEXT;
使用此api前需要用SuspendThread暫停目標執行緒,另外不能用GetThreadContext(GetCurrentThread(), &ct)這種直接獲取當前執行緒的方式。

說明

The GetThreadContext function is used to retrieve the context of the specified thread. The function allows a selective context to be retrieved based on the value of the ContextFlags member of the CONTEXT structure. The thread handle identified by the hThread parameter is typically being debugged, but the function can also operate when it is not being debugged.
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.
系統要求
Client: Requires Windows XP, Windows 2000 Professional, Windows NT Workstation, Windows Me, Windows 98, or Windows 95.
Server: Requires Windows Server 2003, Windows 2000 Server, or Windows NT Server.
Header: Declared in Winbase.h; include Windows.h.
Library: Link to Kernel32.lib.
DLL: Requires Kernel32.dll.

相關詞條

熱門詞條

聯絡我們