在windows7 x64平台,调用getthreadcontext 返回值:87, 请问如何解决,windbg调试该内核API吗?
关键代码:
CONTEXT cxt;
SuspendThread(hThread);
ZeroMemory(&cxt, sizeof(cxt));
cxt.ContextFlags = CONTEXT_FULL;
if (!GetThreadContext(hThread, &cxt)) {
printf("GetThreadContext getlasterror: %d", GetLastError());
goto finish;
}
//hThread是有效的句柄,vs2015可以跟踪代码执行到printf出错的位置,然后就返回87了
Turn off domestic security software such as 360.
getThreadContext
If an error occurs, 0 is returned. Here printf prints the error code.Regarding the error code, the relevant meaning is here https://msdn.microsoft.com/en-us/library/ms681382(v=vs.85).aspx.aspx)
The cause of error code 87 (that is, 0x57) is
参数错误
.You did not check whether
SuspendThread
suspending the thread was successful. You can check it now.And when you open the thread, do you have query permission (
THREAD_GET_CONTEXT
/WOW64THREAD_QUERY_INFORMATION
)If you are compiling a 64-bit program, should you use
Wow64SuspendThread
/Wow64GetThreadContext