/* * brkpt.c - Breakpoint functions of DBG DLL. * */ #include #pragma hdrstop BOOL bWantsTraceInteractive = FALSE; VDM_BREAKPOINT VdmBreakPoints[MAX_VDM_BREAKPOINTS] = {0}; #define X86_BP_OPCODE 0xCC void DbgSetTemporaryBP( WORD Seg, DWORD Offset, BOOL mode ) /* This routine writes a 'CC' to the specified location, and sets up the breakpoint structure so that we handle it correctly in DbgBPInt(). */ { PBYTE lpInst; if (VdmBreakPoints[VDM_TEMPBP].Flags & VDMBP_SET) { // remove previous bp lpInst = VdmMapFlat(VdmBreakPoints[VDM_TEMPBP].Seg, VdmBreakPoints[VDM_TEMPBP].Offset, ((VdmBreakPoints[VDM_TEMPBP].Flags & VDMBP_V86)==0) ? VDM_PM : VDM_V86 ); if (lpInst && (*lpInst == X86_BP_OPCODE)) { *lpInst = VdmBreakPoints[VDM_TEMPBP].Opcode; Sim32FlushVDMPointer( ((ULONG)VdmBreakPoints[VDM_TEMPBP].Seg << 16) + VdmBreakPoints[VDM_TEMPBP].Offset, 1, NULL, (BOOL)((VdmBreakPoints[VDM_TEMPBP].Flags & VDMBP_V86)==0) ); } } lpInst = VdmMapFlat(Seg, Offset, mode ? VDM_PM : VDM_V86); if (lpInst) { VdmBreakPoints[VDM_TEMPBP].Seg = Seg; VdmBreakPoints[VDM_TEMPBP].Offset = Offset; VdmBreakPoints[VDM_TEMPBP].Flags = VDMBP_SET | VDMBP_ENABLED; VdmBreakPoints[VDM_TEMPBP].Flags |= (mode ? 0 : VDMBP_V86); VdmBreakPoints[VDM_TEMPBP].Opcode = *lpInst; *lpInst = X86_BP_OPCODE; Sim32FlushVDMPointer(((ULONG)Seg << 16) + Offset, 1, NULL, mode); } else { VdmBreakPoints[VDM_TEMPBP].Flags = 0; } } BOOL xxxDbgBPInt( ) /* * DbgBPInt * * Handles an INT 3 * * Exit * Returns TRUE if the event was handled * FALSE if it should be reflected */ { BOOL bEventHandled = FALSE; ULONG vdmEip; int i; PBYTE lpInst; if ( fDebugged ) { DbgGetContext(); if ((getMSW() & MSW_PE) && SEGMENT_IS_BIG(vcContext.SegCs)) { vdmEip = vcContext.Eip; } else { vdmEip = (ULONG)LOWORD(vcContext.Eip); } for (i=0; i