Skip to content

Base of immediate changes when sym_resolver is defined #538

Description

@ImpossibleOctopus

I've observed this in the Python version. If a sym_resolver is defined, all immediates will be interpreted as hex values.

# normal behavior
ks = Ks(KS_ARCH_X86,KS_MODE_64)
encoding, count = ks.asm('mov rax, 80',as_bytes=True)
md = Cs(CS_ARCH_X86,CS_MODE_64)
for ins in md.disasm(encoding,0):
    print(f'{ins.mnemonic} {ins.op_str}')

The above code will print mov rax, 0x50, with keystone correctly interpreting the immediate as a decimal.

# abnormal behavior
ks = Ks(KS_ARCH_X86,KS_MODE_64)
def sym_resolver(sym,val):
    return False
ks.sym_resolver = sym_resolver
encoding, count = ks.asm('mov rax, 80',as_bytes=True)
md = Cs(CS_ARCH_X86,CS_MODE_64)
for ins in md.disasm(encoding,0):
    print(f'{ins.mnemonic} {ins.op_str}')

The above code will print mov rax, 0x80, with keystone incorrectly interpreting the immediate as a hexadecimal.

I've also noticed other inconsistencies occur when the sym_resolver is defined, but I haven't been able to isolate any others yet like I have here. This issue might be related to issue #351

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions