阅读:1251回复:0
请教:关于硬件调试寄存器控制代码设置与中断的问题
通过DRx设置硬件指令断点
代码如下: void SetBreak() { DbgPrint("SetBreak"); unsigned long DebuggedAddress = 0; DebuggedAddress = Registers[0].dwAddress; DbgPrint("Set Process [%d] BreakPoint @ %X",DebuggedProcessID,DebuggedAddress); __asm { mov eax,DebuggedAddress mov dr0,eax } pDR_7->G0=(DebuggedAddress==0?0:1); pDR_7->L0=0;//(DebuggedAddress==0?0:1); pDR_7->LEN0=0; pDR_7->RW0=0; } ..... DebugRegister7 DR_7; SetBreak(&DR7); __asm { mov eax,DR_7; mov dr7,eax; } 通过DbgPrint输出,确认SetBreak(...)正常执行 DebuggedAddress也是测试应用层程序正常的代码地址 为什么不产生中断 应用层测试线程代码 unsigned long __stdcall TestThread(void *pParam) { _DebugSupport *pDebugSupport = (_DebugSupport *)pParam; while(!bStop) { __asm { Call DebugPoint; DebugPoint: pop eax; mov theDebugPoint,eax; } if(Inited) { Sleep(1000); continue; } __asm { call GoHere; GoHere: pop eax; mov theGoHere,eax; } if(OldStep != Step) { Sleep(1000); printf("%d\n",Step); OldStep = Step; } if(!Inited) { pDebugSupport->Registers[0].dwAddress = theDebugPoint; pDebugSupport->Registers[0].How = CHANGEEIP; pDebugSupport->Registers[0].newValue = theGoHere; pDebugSupport->dwProcessID = GetCurrentProcessId(); Inited = TRUE; } Step++; } return 0; } 在测试线程里面通过SetThreadContext设置过断点就可以中断 通过驱动设置全局断点断不下来 |
|