c++ - getthreadcontext 返回值:87,请问如何解决
高洛峰
高洛峰 2017-04-17 14:48:18
0
2
777

在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了

高洛峰
高洛峰

拥有18年软件开发和IT教学经验。曾任多家上市公司技术总监、架构师、项目经理、高级软件工程师等职务。 网络人气名人讲师,...

reply all(2)
洪涛

Turn off domestic security software such as 360.

阿神

getThreadContextIf 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

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!