Exemplo n.º 1
0
static void SetupTrace( struct TDebugThread *obj )
{
    int update = FALSE;
    Tss tss;
    unsigned char ch = 0;

    obj->FDebug = FALSE;
    obj->FWasTrace = TRUE;

    RdosGetThreadTss( obj->ThreadID, &tss );

    RdosReadThreadMem( obj->ThreadID, tss.cs, tss.eip, (char *)&ch, 1 );

    if( ch == 0xCC ) {
        tss.eip++;
        update = TRUE;
    }

    if( ( tss.eflags & 0x100 ) == 0 ) {
        tss.eflags |= 0x100;
        update = TRUE;
    }

    if( update )
        RdosSetThreadTss( obj->ThreadID, &tss );
}
Exemplo n.º 2
0
static void ActivateBreaks( struct TDebugThread *obj, struct TDebugBreak *BreakList, struct TDebugWatch *WatchList )
{
    struct TDebugBreak  *b = BreakList;
    struct TDebugWatch  *w = WatchList;
    opcode_type         brk_opcode = BRKPOINT;
    int                 bnum = 0;

    while( w ) {
        if (bnum < 4) {
            RdosSetWriteDataBreak( obj->ThreadID, bnum, w->Sel, w->Offset, w->Size );
            bnum++;
        }
        w = w->Next;
    }

    while( b ) {
        if ((b->Sel & 0x3) == 0x3) {
            RdosReadThreadMem( obj->ThreadID, b->Sel, b->Offset, (char *)&brk_opcode, sizeof( brk_opcode ) );
            b->Instr = brk_opcode;
            RdosWriteThreadMem( obj->ThreadID, b->Sel, b->Offset, (char *)&brk_opcode, sizeof( brk_opcode ) );
        } else {
            if (bnum < 4) {
                RdosSetCodeBreak( obj->ThreadID, bnum, b->Sel, b->Offset );
                bnum++;
            }
        }
        b = b->Next;
    }
}
Exemplo n.º 3
0
static void SetupTrace( struct TDebugThread *obj )
{
    int         update = FALSE;
    Tss         tss;
    opcode_type brk_opcode = 0;

    obj->FDebug = FALSE;
    obj->FWasTrace = TRUE;

    RdosGetThreadTss( obj->ThreadID, &tss );

    RdosReadThreadMem( obj->ThreadID, tss.cs, tss.eip, (char *)&brk_opcode, sizeof( brk_opcode ) );

    if( brk_opcode == BRKPOINT ) {
        tss.eip++;
        update = TRUE;
    }

    if( ( tss.eflags & TRACE_BIT ) == 0 ) {
        tss.eflags |= TRACE_BIT;
        update = TRUE;
    }

    if( update ) {
        RdosSetThreadTss( obj->ThreadID, &tss );
    }
}
Exemplo n.º 4
0
static void ActivateBreaks( struct TDebugThread *obj, struct TDebugBreak *BreakList, struct TDebugWatch *WatchList )
{
    struct TDebugBreak *b = BreakList;
    struct TDebugWatch *w = WatchList;
    char brinstr = 0xCC;
    int bnum = 0;

    while( w ) {
        if (bnum < 4) {
            RdosSetWriteDataBreak( obj->ThreadID, bnum, w->Sel, w->Offset, w->Size );
            bnum++;
        }
        w = w->Next;
    }

    while( b ) {
        if ((b->Sel & 0x3) == 0x3) {
            RdosReadThreadMem( obj->ThreadID, b->Sel, b->Offset, &b->Instr, 1 );
            RdosWriteThreadMem( obj->ThreadID, b->Sel, b->Offset, &brinstr, 1 );
        } else {
            if (bnum < 4) {
                RdosSetCodeBreak( obj->ThreadID, bnum, b->Sel, b->Offset );
                bnum++;
            }
        }
        b = b->Next;
    }
}
Exemplo n.º 5
0
static void ActivateBreaks( struct TDebugThread *obj, struct TDebugBreak *BreakList )
{
    struct TDebugBreak *b = BreakList;
    char brinstr = 0xCC;

    while( b ) {
        RdosReadThreadMem( obj->ThreadID, b->Sel, b->Offset, &b->Instr, 1 );
        RdosWriteThreadMem( obj->ThreadID, b->Sel, b->Offset, &brinstr, 1 );

        b = b->Next;
    }
}
Exemplo n.º 6
0
int ReadMem( struct TDebugThread *obj, int Sel, long Offset, char *Buf, int Size )
{
    return RdosReadThreadMem( obj->ThreadID, Sel, Offset, Buf, Size );
}
Exemplo n.º 7
0
static void SetException( struct TDebugThread *obj, struct TExceptionEvent *event )
{
    Tss         tss;
    int         i;
    opcode_type brk_opcode = 0;

    obj->FHasBreak = FALSE;
    obj->FHasTrace = FALSE;
    obj->FHasException = FALSE;

    ReadThreadState( obj );
    RdosGetThreadTss( obj->ThreadID, &tss );

    obj->Cs = event->Cs;
    obj->Eip = event->Eip;

    RdosReadThreadMem( obj->ThreadID, obj->Cs, obj->Eip, (char *)&brk_opcode, sizeof( brk_opcode ) );
        
    if( brk_opcode == BRKPOINT )
        event->Code = 0x80000003;

    switch( event->Code ) {
        case 0x80000003:
            obj->FHasBreak = TRUE;
            break;

        case 0x80000004:
            obj->FHasTrace = TRUE;
            break;

        case 0xC0000005:
            obj->FaultText = "Access violation";
            obj->FHasException = TRUE;
            break;

        case 0xC0000017:
            obj->FaultText = "No memory";
            obj->FHasException = TRUE;
            break;

        case 0xC000001D:
            obj->FaultText = "Illegal instruction";
            obj->FHasException = TRUE;
            break;
            
        case 0xC0000025:
            obj->FaultText = "Noncontinuable exception";
            obj->FHasException = TRUE;
            break;

        case 0xC000008C:
            obj->FaultText = "Array bounds exceeded";
            obj->FHasException = TRUE;
            break;

        case 0xC0000094:
            obj->FaultText = "Integer divide by zero";
            obj->FHasException = TRUE;
            break;

        case 0xC0000095:
            obj->FaultText = "Integer overflow";
            obj->FHasException = TRUE;
            break;

        case 0xC0000096:
            obj->FaultText = "Priviliged instruction";
            obj->FHasException = TRUE;
            break;

        case 0xC00000FD:
            obj->FaultText = "Stack overflow";
            obj->FHasException = TRUE;
            break;

        case 0xC000013A:
            obj->FaultText = "Control-C exit";
            obj->FHasException = TRUE;
            break;

        case 0xC000008D:
            obj->FaultText = "Float denormal operand";
            obj->FHasException = TRUE;
            break;

        case 0xC000008E:
            obj->FaultText = "Float divide by zero";
            obj->FHasException = TRUE;
            break;

        case 0xC000008F:
            obj->FaultText = "Float inexact result";
            obj->FHasException = TRUE;
            break;

        case 0xC0000090:
            obj->FaultText = "Float invalid operation";
            obj->FHasException = TRUE;
            break;

        case 0xC0000091:
            obj->FaultText = "Float overflow";
            obj->FHasException = TRUE;
            break;

        case 0xC0000092:
            obj->FaultText = "Float stack check";
            obj->FHasException = TRUE;
            break;

        case 0xC0000093:
            obj->FaultText = "Float underflow";
            obj->FHasException = TRUE;
            break;

        default:
            obj->FaultText = "Protection fault";
            obj->FHasException = TRUE;
            break;
    }

    obj->Cr3 = tss.cr3;
    obj->Eflags = tss.eflags;
    obj->Eax = tss.eax;
    obj->Ecx = tss.ecx;
    obj->Edx = tss.edx;
    obj->Ebx = tss.ebx;
    obj->Esp = tss.esp;
    obj->Ebp = tss.ebp;
    obj->Esi = tss.esi;
    obj->Edi = tss.edi;
    obj->Es = tss.es;
    obj->Ss = tss.ss;
    obj->Ds = tss.ds;
    obj->Fs = tss.fs;
    obj->Gs = tss.gs;
    obj->Ldt = tss.ldt;

    for( i = 0; i < 4; i++ )
        obj->Dr[i] = tss.dr[i];

    obj->Dr7 = tss.dr7;
    obj->MathControl = tss.MathControl;
    obj->MathStatus = tss.MathStatus;
    obj->MathTag = tss.MathTag;
    obj->MathEip = tss.MathEip;
    obj->MathCs = tss.MathCs;
    obj->MathDataOffs = tss.MathDataOffs;
    obj->MathDataSel = tss.MathDataSel;

    for( i = 0; i < 8; i++ )
        obj->St[i] = tss.st[i];

    obj->FDebug = TRUE;
}