From 4b05e736a191c3a86f73bbd0eccc0c800d4d8389 Mon Sep 17 00:00:00 2001 From: Sean Heelan Date: Sun, 30 Aug 2015 22:50:47 +0700 Subject: [PATCH] Use asserts instead of print statements on the correct paths to avoid confusing people as to what the success indicator is here. --- regress/jmp_ebx_hang.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/regress/jmp_ebx_hang.py b/regress/jmp_ebx_hang.py index 21b057d2..1b78d89c 100755 --- a/regress/jmp_ebx_hang.py +++ b/regress/jmp_ebx_hang.py @@ -8,21 +8,26 @@ CODE = b'\xff\xe3' mu = unicorn.Uc(unicorn.UC_ARCH_X86, unicorn.UC_MODE_32) mu.mem_map(CODE_ADDR, 1024 * 4) mu.mem_write(CODE_ADDR, CODE) +# If EBX is zero then an exception is raised, as expected mu.reg_write(unicorn.x86_const.UC_X86_REG_EBX, 0x0) -print "jmp ebx, with ebx == 0" try: mu.emu_start(CODE_ADDR, CODE_ADDR + 2, count=1) except unicorn.UcError as e: - print "Error: %s" % e + assert(e.errno == unicorn.UC_ERR_CODE_INVALID) +else: + assert(False) mu = unicorn.Uc(unicorn.UC_ARCH_X86, unicorn.UC_MODE_32) mu.mem_map(CODE_ADDR, 1024 * 4) # If we write this address to EBX then the emulator hangs on emu_start mu.reg_write(unicorn.x86_const.UC_X86_REG_EBX, 0xaa96a47f) mu.mem_write(CODE_ADDR, CODE) -print "jmp ebx, with ebx == 0xaa96a47f" try: mu.emu_start(CODE_ADDR, CODE_ADDR + 2, count=1) except unicorn.UcError as e: - print "Error: %s" % e + assert(e.errno == unicorn.UC_ERR_CODE_INVALID) +else: + assert(False) + +print "Success"