-
-
[求助]清除硬件断点没有效果
-
发表于:
2014-12-31 13:28
3719
-
我先给一个地址下了硬断dr0=addr1
然后在veh中捕获到该地址的异常时 将dr0指向了addr2 然后SetThreadContext
但是addr1还是会断下来
发现我SetThreadContext之后dr0还是指向addr1的,为什么第二次SetThreadContext设置的时候,明明返回成功了但是没有效果呢
操作的线程句柄都是主线程。
void SetOneHW(DWORD dwPoint)
{
SuspendThread(hMainThread);
CONTEXT ctx;
ctx.ContextFlags = CONTEXT_DEBUG_REGISTERS;
BOOL bRet = GetThreadContext(hMainThread,&ctx);
if (bRet)
{
char szOut[256] = {0};
wsprintfA(szOut,"dr0 :%08x set:%08x ",ctx.Dr0,dwPoint);
OutputDebugStringA(szOut);
}
else
{
char szOut[256] = {0};
wsprintfA(szOut,"get srror :%d ",GetLastError());
OutputDebugStringA(szOut);
}
ctx.Dr0 = dwPoint;
//ctx.Dr1 = dwMiniMap;
//ctx.Dr2 = dwShowHP1;
//ctx.Dr3 = dwShowHP2;
//http://blog.csdn.net/rancheice/article/details/8810777
ctx.Dr7 = 0x405;
//ctx.Dr7 = 0x455;
bRet = SetThreadContext(hMainThread, &ctx);
if (bRet)
{
char szOut[256] = {0};
wsprintfA(szOut,"----------------dr0 :%08x set:%08x ",ctx.Dr0,dwPoint);
OutputDebugStringA(szOut);
}
else
{
char szOut[256] = {0};
wsprintfA(szOut,"set srror :%d ",GetLastError());
OutputDebugStringA(szOut);
}
ResumeThread(hMainThread);
}
DWORD WINAPI ThreadSetHW(LPVOID p)
{
OutputDebugStringA("1111");
SetOneHW(0);//清空dr0,但是获取到的还是第一次设置的
return 1;
}
DWORD NTAPI ExceptionHandler(EXCEPTION_POINTERS * ExceptionInfo)
{
if ((DWORD)ExceptionInfo->ExceptionRecord->ExceptionAddress == dwFirstJmpAddr)
{
CreateThread(0,0,ThreadSetHW,0,0,0);//
Sleep(1000);
return EXCEPTION_CONTINUE_EXECUTION;
}
}
第一次设置
AddVectoredExceptionHandler(1, (PVECTORED_EXCEPTION_HANDLER)ExceptionHandler);
SetOneHW(dwFirstJmpAddr);
[注意]传递专业知识、拓宽行业人脉——看雪讲师团队等你加入!