How to use the reil.x86.arithmetic function in reil

To help you get started, we’ve selected a few reil examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github c01db33f / reil / x86 / memory.py View on Github external
b = r(ctx.accumulator.name, size)
    value = ctx.tmp(size)
    result = ctx.tmp(size * 2)
    address = ctx.tmp(a.size)

    if i.mnemonic.startswith('rep'):
        rep_prologue(ctx, i)

    ctx.emit(  str_  (a, address))

    # read the value
    ctx.emit(  ldm_  (address, value))

    # do the comparison and set flags
    ctx.emit(  sub_  (value, b, result))
    arithmetic._sub_set_flags(ctx, a, b, result)

    # do the increment/decrement
    ctx.emit(  jcc_  (r('df', 8), 'decrement'))
    ctx.emit('increment')
    ctx.emit(  add_  (address, imm(value.size // 8, ctx.word_size), address))
    ctx.emit(  jcc_  (imm(1, 8), 'set'))
    ctx.emit('decrement')
    ctx.emit(  sub_  (address, imm(value.size // 8, ctx.word_size), address))
    ctx.emit('set')
    ctx.emit(  str_  (address, ctx.destination))

    if i.mnemonic.startswith('rep'):
        rep_epilogue(ctx, i)
github c01db33f / reil / x86 / memory.py View on Github external
value2 = ctx.tmp(size)
    address2 = ctx.tmp(src.size)

    if i.mnemonic.startswith('rep'):
        rep_prologue(ctx, i)

    # read the values
    ctx.emit(  str_  (src, address1))
    ctx.emit(  ldm_  (address1, value1))

    ctx.emit(  str_  (dst, address2))
    ctx.emit(  ldm_  (address2, value2))

    # do the comparison and set flags
    ctx.emit(  sub_  (value1, value2, result))
    arithmetic._sub_set_flags(ctx, value1, value2, result)

    # do the increment/decrement
    ctx.emit(  jcc_  (r('df', 8), 'decrement'))
    ctx.emit('increment')
    ctx.emit(  add_  (address1, imm(size // 8, ctx.word_size), address1))
    ctx.emit(  add_  (address2, imm(size // 8, ctx.word_size), address2))
    ctx.emit(  jcc_  (imm(1, 8), 'set'))
    ctx.emit('decrement')
    ctx.emit(  sub_  (address1, imm(size // 8, ctx.word_size), address1))
    ctx.emit(  sub_  (address2, imm(size // 8, ctx.word_size), address2))
    ctx.emit('set')
    ctx.emit(  str_  (address1, ctx.source))
    ctx.emit(  str_  (address2, ctx.destination))

    if i.mnemonic.startswith('rep'):
        rep_epilogue(ctx, i)
github c01db33f / reil / x86 / translator.py View on Github external
import reil.x86.arithmetic as arithmetic
import reil.x86.bitwise as bitwise
import reil.x86.control_flow as control_flow
import reil.x86.logic as logic
import reil.x86.memory as memory
import reil.x86.misc as misc
import reil.x86.sse as sse
import reil.x86.unsupported as unsupported

opcode_handlers = {

    capstone.x86.X86_INS_AAA:               ascii.x86_aaa,
    capstone.x86.X86_INS_AAD:               ascii.x86_aad,
    capstone.x86.X86_INS_AAM:               ascii.x86_aam,
    capstone.x86.X86_INS_AAS:               ascii.x86_aas,
    capstone.x86.X86_INS_ADC:               arithmetic.x86_adc,
    capstone.x86.X86_INS_ADCX:              arithmetic.x86_adcx,
    capstone.x86.X86_INS_ADD:               arithmetic.x86_add,
    capstone.x86.X86_INS_ADDPD:             unsupported.floating_point,
    capstone.x86.X86_INS_ADDPS:             unsupported.floating_point,
    capstone.x86.X86_INS_ADDSD:             unsupported.floating_point,
    capstone.x86.X86_INS_ADDSS:             unsupported.floating_point,
    capstone.x86.X86_INS_ADDSUBPD:          unsupported.floating_point,
    capstone.x86.X86_INS_ADDSUBPS:          unsupported.floating_point,
    capstone.x86.X86_INS_ADOX:              arithmetic.x86_adox,
    capstone.x86.X86_INS_AESDEC:            unsupported.complicated,
    capstone.x86.X86_INS_AESDECLAST:        unsupported.complicated,
    capstone.x86.X86_INS_AESENC:            unsupported.complicated,
    capstone.x86.X86_INS_AESENCLAST:        unsupported.complicated,
    capstone.x86.X86_INS_AESIMC:            unsupported.complicated,
    capstone.x86.X86_INS_AESKEYGENASSIST:   unsupported.complicated,
    capstone.x86.X86_INS_AND:               logic.x86_and,
github c01db33f / reil / x86 / translator.py View on Github external
capstone.x86.X86_INS_FXAM:              unsupported.floating_point,
    capstone.x86.X86_INS_FXCH:              unsupported.floating_point,
    capstone.x86.X86_INS_FXRSTOR:           unsupported.floating_point,
    capstone.x86.X86_INS_FXSAVE:            unsupported.floating_point,
    capstone.x86.X86_INS_FXTRACT:           unsupported.floating_point,
    capstone.x86.X86_INS_FYL2X:             unsupported.floating_point,
    capstone.x86.X86_INS_FYL2XP1:           unsupported.floating_point,

    capstone.x86.X86_INS_HADDPD:            unsupported.floating_point,
    capstone.x86.X86_INS_HADDPS:            unsupported.floating_point,
    capstone.x86.X86_INS_HLT:               unsupported.privileged,
    capstone.x86.X86_INS_HSUBPD:            unsupported.floating_point,
    capstone.x86.X86_INS_HSUBPS:            unsupported.floating_point,

    capstone.x86.X86_INS_IDIV:              arithmetic.x86_idiv,
    capstone.x86.X86_INS_IMUL:              arithmetic.x86_imul,
    capstone.x86.X86_INS_IN:                unsupported.privileged,
    capstone.x86.X86_INS_INC:               arithmetic.x86_inc,
    capstone.x86.X86_INS_INSB:              unsupported.privileged,
    capstone.x86.X86_INS_INSD:              unsupported.privileged,
    capstone.x86.X86_INS_INSW:              unsupported.privileged,
    capstone.x86.X86_INS_INT:               misc.x86_int,
    capstone.x86.X86_INS_INT1:              misc.x86_int1,
    capstone.x86.X86_INS_INT3:              misc.x86_int3,
    capstone.x86.X86_INS_INTO:              misc.x86_into,
    capstone.x86.X86_INS_INVD:              unsupported.privileged,
    capstone.x86.X86_INS_INVLPG:            unsupported.privileged,

    capstone.x86.X86_INS_JA:                control_flow.x86_ja,
    capstone.x86.X86_INS_JAE:               control_flow.x86_jae,
    capstone.x86.X86_INS_JB:                control_flow.x86_jb,
    capstone.x86.X86_INS_JBE:               control_flow.x86_jbe,