Fix exception when we can't find the main exe at all

pull/86/head
Zach Riggle 10 years ago
parent 5e99cb09b8
commit a34a1b9d49

@ -49,7 +49,9 @@ def exe():
Return a loaded ELF header object pointing to the Ehdr of the Return a loaded ELF header object pointing to the Ehdr of the
main executable. main executable.
""" """
return load(entry()) e = entry()
if e:
return load(e)
@pwndbg.proc.OnlyWhenRunning @pwndbg.proc.OnlyWhenRunning
@pwndbg.memoize.reset_on_start @pwndbg.memoize.reset_on_start

@ -78,11 +78,17 @@ def available():
return True return True
def l2r(addr): def l2r(addr):
result = (addr - int(pwndbg.elf.exe().address) + base()) & pwndbg.arch.ptrmask exe = pwndbg.elf.exe()
if not exe:
raise Exception("Can't find EXE base")
result = (addr - int(exe.address) + base()) & pwndbg.arch.ptrmask
return result return result
def r2l(addr): def r2l(addr):
result = (addr - base() + int(pwndbg.elf.exe().address)) & pwndbg.arch.ptrmask exe = pwndbg.elf.exe()
if not exe:
raise Exception("Can't find EXE base")
result = (addr - base() + int(exe.address)) & pwndbg.arch.ptrmask
return result return result
@pwndbg.memoize.reset_on_objfile @pwndbg.memoize.reset_on_objfile

Loading…
Cancel
Save