Skip to content

SET_CONCRETE_MEMORY_VALUE callback invoked when performing symbolic memory read in MEMORY_ARRAY mode #1352

@0x9047

Description

@0x9047
import triton


def test_concrete_memory_handler_not_called_in_symbolic_rw():
    def handler(ctx, memory_access, *args):
        assert not memory_access.getLeaAst().isSymbolized()

    ctx = triton.TritonContext(triton.ARCH.AARCH64)
    ctx.setMode(triton.MODE.MEMORY_ARRAY, True)
    ctx.symbolizeRegister(ctx.registers.sp)
    ctx.setMode(triton.MODE.SYMBOLIZE_LOAD, True)
    ctx.setMode(triton.MODE.SYMBOLIZE_STORE, True)
    ctx.addCallback(triton.CALLBACK.GET_CONCRETE_MEMORY_VALUE, handler)
    ctx.addCallback(triton.CALLBACK.SET_CONCRETE_MEMORY_VALUE, handler)

    inst = triton.Instruction(0, bytes.fromhex("E00300F9"))  # str x0, [sp, #0]
    ctx.processing(inst)

Output

ctx = <TritonContext object at 0x10214b570>, memory_access = [@0x0]:64 bv[63..0], args = (0,), @py_assert1 = <built-in method getLeaAst of MemoryAccess object at 0x1024e59d0>
@py_assert3 = (bvadd (bvadd ref!0 (bvmul (_ bv0 64) (_ bv0 64))) (_ bv0 64)), @py_assert5 = <built-in method isSymbolized of AstNode object at 0x1024e5a10>

    def handler(ctx, memory_access, *args):
>       assert not memory_access.getLeaAst().isSymbolized()
E       assert not True
E        +  where True = <built-in method isSymbolized of AstNode object at 0x1024e5a10>()
E        +    where <built-in method isSymbolized of AstNode object at 0x1024e5a10> = (bvadd (bvadd ref!0 (bvmul (_ bv0 64) (_ bv0 64))) (_ bv0 64)).isSymbolized
E        +      where (bvadd (bvadd ref!0 (bvmul (_ bv0 64) (_ bv0 64))) (_ bv0 64)) = <built-in method getLeaAst of MemoryAccess object at 0x1024e59d0>()
E        +        where <built-in method getLeaAst of MemoryAccess object at 0x1024e59d0> = [@0x0]:64 bv[63..0].getLeaAst`

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions