Пример #1
0
void InterpreterDisAsmFrame::DoUpdate()
{
	wxCommandEvent ce;
	Show_PC(ce);
	WriteRegs();
	WriteCallStack();
}
Пример #2
0
trap_retval ReqWrite_regs( void )
{
    mad_registers           _WCUNALIGNED *mr;
    struct TDebug           *obj;
    struct TDebugThread     *thread;

    mr = GetInPtr( sizeof( write_regs_req ) );

    obj = GetCurrentDebug();
    if (obj) {
        thread = obj->CurrentThread;
        if( thread ) {
            thread->Eax = mr->x86.cpu.eax;
            thread->Ebx = mr->x86.cpu.ebx;
            thread->Ecx = mr->x86.cpu.ecx;
            thread->Edx = mr->x86.cpu.edx;
            thread->Esi = mr->x86.cpu.esi;
            thread->Edi = mr->x86.cpu.edi;
            thread->Esp = mr->x86.cpu.esp;
            thread->Ebp = mr->x86.cpu.ebp;
            thread->Eip = mr->x86.cpu.eip;
            thread->Eflags = mr->x86.cpu.efl;
            thread->Ds = mr->x86.cpu.ds;
            thread->Cs = mr->x86.cpu.cs;
            thread->Es = mr->x86.cpu.es;
            thread->Ss = mr->x86.cpu.ss;
            thread->Fs = mr->x86.cpu.fs;
            thread->Gs = mr->x86.cpu.gs;

            thread->MathControl = mr->x86.u.fpu.cw;
            thread->MathStatus = mr->x86.u.fpu.sw;
            thread->MathTag = mr->x86.u.fpu.tag;
            thread->MathEip = mr->x86.u.fpu.ip_err.p.offset;
            thread->MathCs = mr->x86.u.fpu.ip_err.p.segment;
            thread->MathDataOffs = mr->x86.u.fpu.op_err.p.offset;
            thread->MathDataSel = mr->x86.u.fpu.op_err.p.segment;
            memcpy( thread->St, mr->x86.u.fpu.reg, 8 * 10 );

            WriteRegs( thread );
        }
    }
    return( 0 );
}
Пример #3
0
void InterpreterDisAsmFrame::DoUpdate()
{
	Show_PC(wxCommandEvent());
	WriteRegs();
}
Пример #4
0
bool DebugExecute( uDB_t *buff, ULONG cmd, bool stop_on_module_load )
{
    EXCEPTIONREPORTRECORD       ex;
    ULONG                       value;
    ULONG                       stopvalue;
    ULONG                       notify = 0;
    BOOL                        got_second_notification;
    ULONG                       fcp;
    CONTEXTRECORD               fcr;

    buff->Cmd = cmd;
    value = buff->Value;
    if( cmd == DBG_C_Go ) {
        value = 0;
    }
    stopvalue = XCPT_CONTINUE_EXECUTION;
    got_second_notification = FALSE;
    if( cmd == DBG_C_Stop ) {
        stopvalue = XCPT_CONTINUE_STOP;
    }

    for( ;; ) {
        buff->Value = value;
        buff->Cmd = cmd;
        CallDosDebug( buff );

        value = stopvalue;
        cmd = DBG_C_Continue;

        /*
         * handle the preemptive notifications
         */
        switch( buff->Cmd ) {
        case DBG_N_ModuleLoad:
            RecordModHandle( buff->Value );
            if( stop_on_module_load )
                return( TRUE );
            break;
        case DBG_N_ModuleFree:
            break;
        case DBG_N_NewProc:
            break;
        case DBG_N_ProcTerm:
            value = XCPT_CONTINUE_STOP;         /* halt us */
            notify = DBG_N_ProcTerm;
            break;
        case DBG_N_ThreadCreate:
            break;
        case DBG_N_ThreadTerm:
            break;
        case DBG_N_AliasFree:
            break;
        case DBG_N_Exception:
            ExceptLinear = buff->Addr;
            if( buff->Value == DBG_X_STACK_INVALID ) {
                value = XCPT_CONTINUE_SEARCH;
                break;
            }
            fcp = buff->Len;
            if( buff->Value == DBG_X_PRE_FIRST_CHANCE ) {
                ExceptNum = buff->Buffer;
                if( ExceptNum == XCPT_BREAKPOINT ) {
                    notify = DBG_N_Breakpoint;
                    value = XCPT_CONTINUE_STOP;
                    break;
                } else if( ExceptNum == XCPT_SINGLE_STEP ) {
                    notify = DBG_N_SStep;
                    value = XCPT_CONTINUE_STOP;
                    break;
                }
            }
            //
            // NOTE: Going to second chance causes OS/2 to report the
            //       exception in the debugee.  However, if you report
            //       the fault at the first chance notification, the
            //       debugee's own fault handlers will not get invoked!
            //
            if( buff->Value == DBG_X_FIRST_CHANCE && !ExpectingAFault ) {
                if( stopOnSecond && !got_second_notification ) {
                    value = XCPT_CONTINUE_SEARCH;
                    break;
                }
            }
            notify = DBG_N_Exception;
            value = XCPT_CONTINUE_STOP;

            /*
             * Buffer contains the ptr to the exception block
             */
            buff->Cmd = DBG_C_ReadMemBuf;
            buff->Addr = buff->Buffer;
            buff->Buffer = (ULONG)&ex;
            buff->Len = sizeof( ex );
            CallDosDebug( buff );
            ExceptNum = ex.ExceptionNum;
            if( ExceptNum == XCPT_PROCESS_TERMINATE ||
                ExceptNum == XCPT_ASYNC_PROCESS_TERMINATE ||
                ExceptNum == XCPT_GUARD_PAGE_VIOLATION ||
                ( ExceptNum & XCPT_CUSTOMER_CODE ) ) {
                value = XCPT_CONTINUE_SEARCH;
                break;
            }

            /*
             * get the context record
             */
            buff->Cmd = DBG_C_ReadMemBuf;
            buff->Addr = fcp;
            buff->Buffer = (ULONG)&fcr;
            buff->Len = sizeof( fcr );
            CallDosDebug( buff );
            buff->EAX = fcr.ctx_RegEax;
            buff->EBX = fcr.ctx_RegEbx;
            buff->ECX = fcr.ctx_RegEcx;
            buff->EDX = fcr.ctx_RegEdx;
            buff->ESI = fcr.ctx_RegEsi;
            buff->EDI = fcr.ctx_RegEdi;
            buff->ESP = fcr.ctx_RegEsp;
            buff->EBP = fcr.ctx_RegEbp;
            buff->DS  = fcr.ctx_SegDs;
            buff->CS  = fcr.ctx_SegCs;
            buff->ES  = fcr.ctx_SegEs;
            buff->FS  = fcr.ctx_SegFs;
            buff->GS  = fcr.ctx_SegGs;
            buff->SS  = fcr.ctx_SegSs;
            buff->EIP = fcr.ctx_RegEip;
            buff->EFlags = fcr.ctx_EFlags;
            WriteRegs(buff);

            if( ExpectingAFault || got_second_notification ) {
                break;
            }
            if( stopOnSecond ) {
                value = XCPT_CONTINUE_EXECUTION;
                got_second_notification = TRUE;
            }
            break;
        default:
            if( notify != 0 ) {
                buff->Cmd = notify;
                // Check if we hit our splice DLL breakpoint
                if( (notify == DBG_N_Breakpoint) && splice_bp_set && (splice_bp_lin_addr == ExceptLinear) ) {
                    uDB_t       save;

                    // Remove breakpoint
                    WriteLinear( &saved_splice_bp, splice_bp_lin_addr, sizeof( byte ) );
                    splice_bp_set = FALSE;
                    splice_bp_lin_addr = 0;

                    // Attempt to load helper DLL
                    save.Pid = Pid;
                    save.Tid = 1;
                    ReadRegs( &save );
                    ExpectingAFault = TRUE;
                    // NB - the following will recursively call DebugExecute!
                    if( !CausePgmToLoadHelperDLL( ExceptLinear ) ) {
                        CanExecTask = FALSE;
                    } else {
                        CanExecTask = TRUE;
                    }
                    WriteRegs( &save );
                    break;
                }
            }
            return( FALSE );
        }
    }
//    return( FALSE );
}
Пример #5
0
bool CausePgmToLoadThisDLL( ULONG startLinear )
{

    char        savecode[LOAD_THIS_DLL_SIZE];
    USHORT      codesize;
    USHORT      len;
    loadstack_t far *loadstack;
    void        far *ptr;
    USHORT      dll_name_len;
    USHORT      size;
    char        this_dll[BUFF_SIZE];
    bool        rc;

    /*
     * save a chunk of the program's code, and put in LoadThisDLL instead
     */
    if( DosGetModName( ThisDLLModHandle, BUFF_SIZE, this_dll ) != 0 ) {
        return( FALSE );
    }
    codesize = (char *)EndLoadThisDLL - (char *)LoadThisDLL;
    if( codesize > LOAD_THIS_DLL_SIZE ) return( FALSE );
    ReadLinear( savecode, startLinear, codesize );
    if( Buff.Cmd != DBG_N_Success ) return( FALSE );
    WriteLinear( (byte far *)LoadThisDLL, startLinear, codesize );

    /*
     * set up the stack for the routine LoadThisDLL
     */
    dll_name_len = ( strlen( this_dll ) + 1 ) & ~1;
    size = sizeof( loadstack_t ) + dll_name_len;
    loadstack = Automagic( size );
    Buff.ESP -= size;
    strcpy( loadstack->load_name, this_dll );
    loadstack->fail_name = NULL;
    loadstack->fail_len = 0;
    ptr = MakeItSegmentedNumberOne( Buff.SS, Buff.ESP + offsetof( loadstack_t, load_name ) );
    loadstack->mod_name[0] = FP_OFF( ptr );
    loadstack->mod_name[1] = FP_SEG( ptr );
    ptr = MakeItSegmentedNumberOne( Buff.SS, Buff.ESP + offsetof( loadstack_t, hmod ) );
    loadstack->phmod[0] = FP_OFF( ptr );
    loadstack->phmod[1] = FP_SEG( ptr );
    len = WriteBuffer( (byte far *)loadstack, Buff.SS, Buff.ESP, size );
    if( len != size ) return( FALSE );

    /*
     * set up 16:16 CS:IP, SS:SP for execution
     */
    ptr = MakeSegmentedPointer( startLinear );
    Buff.CS = FP_SEG( ptr );
    Buff.EIP = FP_OFF( ptr );
    ptr = MakeItSegmentedNumberOne( Buff.SS, Buff.ESP );
    Buff.SS = FP_SEG( ptr );
    Buff.ESP = FP_OFF( ptr );

    /*
     * execute LoadThisDLL on behalf of the program
     */
    WriteRegs( &Buff );
    DebugExecute( &Buff, DBG_C_Go, FALSE );
    if( Buff.Cmd != DBG_N_Breakpoint ) {
        rc = FALSE;
    } else {
        rc = TRUE;
    }
    WriteLinear( savecode, startLinear, codesize );
    return( rc );
}