Exemple #1
0
/* If a MOV instruction is a sufficiently simple example of a
 * move between a register and memory (in either direction),
 * then find the register, the effective address and the size
 * of the instruction. The instruction is considered sufficiently
 * simple if it uses a single byte displacement, a base register,
 * and either no index or a (possibly scaled) register.
 */
static Bool DecodeSimpleMov(unsigned int *regnumReturn,
                            MRef *memReturn,
                            Size *inslenReturn,
                            MutatorFaultContext context,
                            Byte insvec[])
{
  unsigned int mod;
  unsigned int r;
  unsigned int m;

  DecodeModRM(&mod, &r, &m, insvec[1]);  /* .source.i486 Table 26-3 */
  if(1 == mod) {
    /* Only know about single byte displacements, .assume.want */
    Word base;
    Word idx;           /* can't shadow index(3) */
    Word disp;

    if(4 == m) {
      /* There is an index. */
      unsigned int s;
      unsigned int i;
      unsigned int b;

      DecodeSIB(&s, &i, &b, insvec[2]);  /* .source.i486 Table 26-3 */
      if(4 == i) {
        return FALSE; /* degenerate SIB form - unused by Dylan compiler */
      }
      disp = SignedInsElt(insvec, 3);
      base = RegValue(context, b);
      idx = RegValue(context, i) << s;
      *inslenReturn = 4;
    } else {
      /* MOV with reg1 & [reg2+byte] parameters */
      disp = SignedInsElt(insvec, 2);
      base = RegValue(context, m);
      idx = 0;
      *inslenReturn = 3;
    }
    *regnumReturn = r;
    *memReturn = (MRef)(base + idx + disp);  /* .assume.i3 */
    return TRUE;
  }

  return FALSE;
}
Exemple #2
0
static  void    RegModify( a_window *wnd, int row, int piece )
{
    int                     i;
    item_mach               value;
    reg_window              *reg = WndReg( wnd );
    bool                    ok;
    mad_radix               old_radix;
    reg_display_piece       disp;
    mad_type_info           tinfo;
    mad_modify_list const   *possible;
    int                     num_possible;

    if( row < 0 )
        return;
    piece >>= 1;
    i = GetRegIdx( reg, row, piece );
    if( i == -1 )
        return;
    if( !GetDisplayPiece( &disp, reg, DbgRegs, i ) )
        return;
    if( disp.reginfo == NULL )
        return;
    if( MADRegSetDisplayModify( reg->data, disp.reginfo, &possible, &num_possible ) != MS_OK )
        return;
    old_radix = NewCurrRadix( MADTypePreferredRadix( disp.disp_type ) );
    MADRegFullName( disp.reginfo, ".", TxtBuff, TXT_LEN );
    RegValue( &value, disp.reginfo, DbgRegs );
    if( num_possible == 1 ) {
        ok = DlgMadTypeExpr( TxtBuff, &value, disp.disp_type );
        if( ok ) {
            RegNewValue( disp.reginfo, &value, possible->type );
        }
    } else {
        for( i = 0; i < num_possible; ++i ) {
            MADTypeInfo( possible[i].type, &tinfo );
            if( memcmp( &value, possible[i].data, tinfo.b.bits / BITS_PER_BYTE ) == 0 ) {
                break;
            }
        }
        if( num_possible == 2 ) {
            if( i == 0 ) {
                i = 1;
            } else {
                i = 0;
            }
        } else {  //MJC const cast
            i = DlgPickWithRtn( TxtBuff, possible, i, RegValueName, num_possible );
        }
        if( i != -1 ) {
            RegNewValue( disp.reginfo, possible[i].data, possible[i].type );
        }
    }
    NewCurrRadix( old_radix );
}
Exemple #3
0
static  bool    RegGetLine( a_window *wnd, int row, int piece,
                            wnd_line_piece *line )
{
    int                 column;
    int                 i;
    reg_window          *reg = WndReg( wnd );
    size_t              max = TXT_LEN;
    mad_radix           old_radix, new_radix;
    item_mach           value;
    reg_display_piece   disp;

    column = piece >> 1;
    if( column >= reg->up )
        return( false );
    i = GetRegIdx( reg, row, column );
    if( i >= reg->count )
        return( false );
    if( i == -1 )
        return( false );
    if( !GetDisplayPiece( &disp, reg, DbgRegs, i ) )
        return( false );
    line->text = TxtBuff;
    if( piece & 1 ) {
        line->indent = reg->indents[column].value;
        if( reg->info[i].info == NULL ) {
            strcpy( TxtBuff, "   " );
        } else {
            new_radix = MADTypePreferredRadix( disp.disp_type );
            old_radix = NewCurrRadix( new_radix );
            RegValue( &value, reg->info[i].info, DbgRegs );
            max = reg->info[i].max_value + 1;
            MADTypeHandleToString( new_radix, disp.disp_type, &value, TxtBuff, &max );
            NewCurrRadix( old_radix );
            reg->info[i].standout = false;
            if( MADRegModified( reg->data, reg->info[i].info, &PrevRegs->mr, &DbgRegs->mr ) == MS_MODIFIED_SIGNIFICANTLY ) {
                reg->info[i].standout = true;
                line->attr = WND_STANDOUT;
            }
        }
    } else {
        line->indent = reg->indents[column].descript;
        strcpy( TxtBuff, disp.descript );
        if( TxtBuff[0] != NULLCHAR ) {
            strcat( TxtBuff, ":" );
        }
        line->tabstop = false;
    }
    return( true );
}
Exemple #4
0
walk_result MemReference( int opnd, mad_disasm_data *dd, MEMREF_WALKER *wk, const mad_registers *mr, void *d )
{
    mad_type_handle     th;
    address             addr;
    dis_operand         *op;
    mad_memref_kind     mmk;

    op = &dd->ins.op[opnd];
    switch( op->ref_type ) {
    case DRT_X86_DWORDF:
        th = X86T_FLOAT;
        break;
    case DRT_X86_DWORD:
        th = X86T_DWORD;
        break;
    case DRT_X86_QWORDF:
        th = X86T_DOUBLE;
        break;
    case DRT_X86_QWORD:
        th = X86T_QWORD;
        break;
    case DRT_X86_WORD:
        th = X86T_WORD;
        break;
    case DRT_X86_BYTE:
        th = X86T_BYTE;
        break;
    case DRT_X86_TBYTE:
        th = X86T_EXTENDED;
        break;
    case DRT_X86_FARPTR48:
        th = X86T_F32_PTR;
        break;
    case DRT_X86_FARPTR32:
        th = X86T_F16_PTR;
        break;
    default:
        th = X86T_BYTE;
        break;
    }
    addr.sect_id = 0;
    addr.indirect = 0;
    addr.mach.offset = op->value;
    if( op->base != DR_NONE ) {
        addr.mach.offset += RegValue( mr, op->base );
    }
    if( op->index != DR_NONE ) {
        addr.mach.offset += RegValue( mr, op->index ) * op->scale;
    }
    if( op->type & DO_NO_SEG_OVR ) {
        addr.mach.segment = RegValue( mr, DR_X86_es );
    } else {
        addr.mach.segment = RegValue( mr, GetSegRegOverride( dd, op ) );
    }
    if( dd->ins.flags.u.x86 & DIF_X86_ADDR_LONG ) {
        addr.mach.offset &= ~(dword)0;
    } else {
        addr.mach.offset &= ~(word)0;
    }
    mmk = MMK_READ;
    switch( dd->ins.type ) {
    case DI_X86_pop:
    case DI_X86_pop2:
    case DI_X86_pop3d:
    case DI_X86_pop3e:
    case DI_X86_pop3s:
    case DI_X86_pop4f:
    case DI_X86_pop4g:
    case DI_X86_ins:
    case DI_X86_stos:
        mmk = MMK_WRITE;
        break;
    case DI_X86_xchg:
    case DI_X86_xchg2:
    case DI_X86_inc:
    case DI_X86_inc2:
    case DI_X86_dec:
    case DI_X86_dec2:
        mmk |= MMK_WRITE;
        break;
    case DI_X86_cmps:
    case DI_X86_lods:
    case DI_X86_outs:
    case DI_X86_scas:
        break;
    case DI_X86_movzx:
    case DI_X86_movsx:
    case DI_X86_mov:
    case DI_X86_mov2:
    case DI_X86_mov3:
    case DI_X86_mov4:
    case DI_X86_mov5:
    case DI_X86_mov6:
    case DI_X86_mov7:
    case DI_X86_movs:
        if( opnd == OP_1 ) {
            mmk = MMK_WRITE;
        }
        break;
    default:
        if( dd->ins.num_ops >= 2 && opnd == OP_1 ) {
            mmk |= MMK_WRITE;
        }
        break;
    }
    return( wk( addr, th, mmk, d ) );
}
Exemple #5
0
mad_status DIGENTRY MIDisasmInsNext( mad_disasm_data *dd, const mad_registers *mr, address *next )
{
    mad_disasm_control  dc;

    *next = GetRegIP( mr );
    next->mach.offset += dd->ins.size;
    dc = DisasmControl( dd, mr );
    if( (dc & MDC_TAKEN_MASK) == MDC_TAKEN_NOT ) {
        return( MS_OK );
    }
    switch( dc & MDC_TYPE_MASK ) {
    case MDC_SYSCALL:
        return( MS_FAIL );
    case MDC_JUMP:
    case MDC_CALL:
        switch( dd->ins.op[ OP_1 ].type & DO_MASK ) {
        case DO_ABSOLUTE:
            next->mach.segment = dd->ins.op[ OP_1 ].extra;
            /* fall through */
        case DO_RELATIVE:
            next->mach.offset = dd->ins.op[ OP_1 ].value;
            break;
        case DO_REG:
            next->mach.offset = RegValue( mr, dd->ins.op[ OP_1 ].base );
            break;
        default:
            /* memory indirect jump/call */
            DoDisasmMemRefWalk( dd, FindCallTarget, mr, &DbgAddr );

            if( dd->ins.flags.u.x86 & DIF_X86_OPND_LONG ) {
                next->mach.offset = GetDataLong();
                if( dd->ins.op[ OP_1 ].ref_type == DRT_X86_FARPTR48 ) {
                    next->mach.segment = (unsigned_16)GetDataWord();
                }
            } else {
                next->mach.offset = (unsigned_16)GetDataWord();
                if( dd->ins.op[ OP_1 ].ref_type == DRT_X86_FARPTR32 ) {
                    next->mach.segment = (unsigned_16)GetDataWord();
                }
            }
            break;
        }
        break;
    case MDC_SYSRET:
    case MDC_RET:
        DbgAddr = GetRegSP( mr );
        if( dd->ins.flags.u.x86 & DIF_X86_OPND_LONG ) {
            next->mach.offset = GetDataLong();
        } else {
            next->mach.offset = (unsigned_16)GetDataWord();
        }
        switch( dd->ins.type ) {
        case DI_X86_retf:
        case DI_X86_retf2:
            next->mach.segment = (unsigned_16)GetDataWord();
            break;
        default:
            break;
        }
        break;
    }
    return( MS_OK );
}
void CTStatOutputView::OnNMClickListOutput(NMHDR *pNMHDR, LRESULT *pResult)
{
    LPNMITEMACTIVATE pNMItemActivate = reinterpret_cast<LPNMITEMACTIVATE>(pNMHDR);
    if (product_type==CS3000){
        return;
    }
    long lRow,lCol;
    m_output_list.Set_Edit(true);
    DWORD dwPos=GetMessagePos();//Get which line is click by user.Set the check box, when user enter Insert it will jump to program dialog
    CPoint point( LOWORD(dwPos), HIWORD(dwPos));
    m_output_list.ScreenToClient(&point);
    LVHITTESTINFO lvinfo;
    lvinfo.pt=point;
    lvinfo.flags=LVHT_ABOVE;
    int nItem=m_output_list.SubItemHitTest(&lvinfo);

    lRow = lvinfo.iItem;
    lCol = lvinfo.iSubItem;


    if(lRow>m_output_list.GetItemCount()) //如果点击区超过最大行号,则点击是无效的
        return;
    if(lRow<0)
        return;
    BOOL IS_SEND=FALSE;
    CString New_CString;
    CString temp_task_info;
    CString temp1;
    CStringArray temparray;
    New_CString =  m_output_list.GetItemText(lRow,lCol);
    //if (New_CString.CompareNoCase(NO_APPLICATION)==0)
    //{
    //    m_output_list.Set_Edit(false);
    //    IS_SEND=FALSE;
    //    return ;
    //}
    _MessageWriteOneInfo_List  *pwrite_info = new _MessageWriteOneInfo_List;
    pwrite_info->list_type=LIST_TYPE_OUTPUT_TSTAT;
    if(lCol == TStat_AM)
    {
        bitset<16> RegValue(m_tstat_output_data.at(lRow).AM.RegValue);

        if (m_tstat_output_data.at(lRow).AM.StrValue.CompareNoCase(Global_String_AUTO)==0)
        {
            pwrite_info->Changed_Name.Format(_T("%s,From %s to Manual"),m_tstat_output_data.at(lRow).OutputName.StrValue,m_tstat_output_data.at(lRow).AM.StrValue);
            pwrite_info->address=m_tstat_output_data.at(lRow).AM.regAddress;
            RegValue[lRow]=true;
            pwrite_info->new_value=RegValue.to_ulong();
        } 
        else
        {
            pwrite_info->Changed_Name.Format(_T("%s,From %s to Auto"),m_tstat_output_data.at(lRow).OutputName.StrValue,m_tstat_output_data.at(lRow).AM.StrValue);
            pwrite_info->address=m_tstat_output_data.at(lRow).AM.regAddress;
            RegValue[lRow]=false;
            pwrite_info->new_value=RegValue.to_ulong();
        }
        IS_SEND=TRUE;
    }



    if (lCol == TStat_Value)
    {
        if (m_tstat_output_data.at(lRow).AM.StrValue.CompareNoCase(Global_String_AUTO)==0)
        {
            m_output_list.Set_Edit(false);
            IS_SEND=FALSE;
            return ;
        }
        if (m_tstat_output_data.at(lRow).Range.RegValue==0)
        {
            m_output_list.Set_Edit(false);
        }
        if (m_tstat_output_data.at(lRow).Range.RegValue==0)//Manual+Range=on/off
        {
			if (lRow>4)
			{
				  
				if (m_tstat_output_data.at(lRow).Value.StrValue.CompareNoCase(Global_String_NO) == 0)//如果当前的值是 ON
				{
					pwrite_info->Changed_Name.Format(_T("%s,From %s to %s"), m_tstat_output_data.at(lRow).OutputName.StrValue, m_tstat_output_data.at(lRow).Value.StrValue, Global_String_OFF);
					pwrite_info->address = m_tstat_output_data.at(lRow).Value.regAddress;
					 
					pwrite_info->new_value = 0;
				}
				else
				{
					pwrite_info->Changed_Name.Format(_T("%s,From %s to %s"), m_tstat_output_data.at(lRow).OutputName.StrValue, m_tstat_output_data.at(lRow).Value.StrValue, Global_String_NO);
					pwrite_info->address = m_tstat_output_data.at(lRow).Value.regAddress;
					 
					pwrite_info->new_value = 1;
				}
				IS_SEND = TRUE;
			}
			else
			{
				bitset<16> RegValue(m_tstat_output_data.at(lRow).Value.RegValue);
				if (m_tstat_output_data.at(lRow).Value.StrValue.CompareNoCase(Global_String_NO) == 0)//如果当前的值是 ON
				{
					pwrite_info->Changed_Name.Format(_T("%s,From %s to %s"), m_tstat_output_data.at(lRow).OutputName.StrValue, m_tstat_output_data.at(lRow).Value.StrValue, Global_String_OFF);
					pwrite_info->address = m_tstat_output_data.at(lRow).Value.regAddress;
					RegValue[lRow] = false;
					pwrite_info->new_value = RegValue.to_ulong();
				}
				else
				{
					pwrite_info->Changed_Name.Format(_T("%s,From %s to %s"), m_tstat_output_data.at(lRow).OutputName.StrValue, m_tstat_output_data.at(lRow).Value.StrValue, Global_String_NO);
					pwrite_info->address = m_tstat_output_data.at(lRow).Value.regAddress;
					RegValue[lRow] = true;
					pwrite_info->new_value = RegValue.to_ulong();
				}
				IS_SEND = TRUE;
			}
            
        }

    }
    if (lCol == TStat_Signal_Type)
    {
        if (lRow<5)
        {
            m_output_list.Set_Edit(false);
            return ;
        }
        if (m_tstat_output_data.at(lRow).Function.RegValue!=4)
        {
            m_output_list.Set_Edit(false);
            return ;
        }
    } 




    if (IS_SEND)
    {	
        pwrite_info->device_id=g_tstat_id;
        pwrite_info->hwnd=g_hwnd_now;
        pwrite_info->mCol=lCol;
        pwrite_info->mRow=lRow;
        m_output_list.SetItemBkColor(lRow,lCol,LIST_ITEM_CHANGED_BKCOLOR);
        if(!PostThreadMessage(nThreadID,MY_WRITE_ONE_LIST,(WPARAM)pwrite_info,NULL))//post thread msg
        {
            return  ;
        }
        else
        {
            return  ;
        }
    }
    else{
        if (pwrite_info)
        {
            delete pwrite_info;
        }

    }
    *pResult = 0;
}