Exemplo n.º 1
0
an      BGStackValue( type_def *tipe )
/************************************/
{
    an                  addr;

    addr = RegName( StackReg(), tipe );
    return( addr );
}
Exemplo n.º 2
0
an      BGVarargsBasePtr( type_def *tipe )
/****************************************/
{
    an                  addr;

    addr = RegName( VarargsHomePtr(), tipe );
    return( addr );
}
Exemplo n.º 3
0
String Capstone::OperandText(int opindex) const
{
    if(opindex >= mInstr->detail->x86.op_count)
        return "";
    const auto & op = mInstr->detail->x86.operands[opindex];
    String result;
    char temp[32] = "";
    switch(op.type)
    {
    case X86_OP_REG:
    {
        result = RegName(x86_reg(op.reg));
    }
    break;

    case X86_OP_IMM:
    {
        if(InGroup(CS_GRP_JUMP) || InGroup(CS_GRP_CALL) || IsLoop())
            sprintf_s(temp, "%" fext "X", op.imm + mInstr->size);
        else
            sprintf_s(temp, "%" fext "X", op.imm);
        result = temp;
    }
    break;

    case X86_OP_MEM:
    {
        const auto & mem = op.mem;
        if(op.mem.base == X86_REG_RIP)  //rip-relative
        {
            sprintf_s(temp, "%" fext "X", mInstr->address + op.mem.disp + mInstr->size);
            result += temp;
        }
        else //normal
        {
            bool prependPlus = false;
            if(mem.base)
            {
                result += RegName(x86_reg(mem.base));
                prependPlus = true;
            }
            if(mem.index)
            {
                if(prependPlus)
                    result += "+";
                result += RegName(x86_reg(mem.index));
                sprintf_s(temp, "*%X", mem.scale);
                result += temp;
                prependPlus = true;
            }
            if(mem.disp)
            {
                char operatorText = '+';
                if(mem.disp < 0)
                {
                    operatorText = '-';
                    sprintf_s(temp, "%" fext "X", mem.disp * -1);
                }
                else
                    sprintf_s(temp, "%" fext "X", mem.disp);
                if(prependPlus)
                    result += operatorText;
                result += temp;
            }
        }
    }
    break;

    case X86_OP_FP:
    case X86_OP_INVALID:
    {
    }
    break;
    }
    return result;
}