Inthook size types (Fixes #669) (#670)

* Make size_t and ssize_t the correct sizes, and actually use them for inthook. Fix for #669 along with other issues.

* elif, pointer size support message
pull/671/head
Stuart Nevans Locke 6 years ago committed by Disconnect3d
parent 7f5d8e7853
commit 068099c15e

@ -37,15 +37,15 @@ class xint(with_metaclass(IsAnInt, builtins.int)):
def __new__(cls, value, *a, **kw):
if isinstance(value, gdb.Value):
if pwndbg.typeinfo.is_pointer(value):
value = value.cast(pwndbg.typeinfo.ulong)
value = value.cast(pwndbg.typeinfo.size_t)
else:
value = value.cast(pwndbg.typeinfo.long)
value = value.cast(pwndbg.typeinfo.ssize_t)
elif isinstance(value, gdb.Symbol):
symbol = value
value = symbol.value()
if symbol.is_function:
value = value.cast(pwndbg.typeinfo.ulong)
value = value.cast(pwndbg.typeinfo.size_t)
elif not isinstance(value, (six.string_types, six.integer_types)) \
or isinstance(cls, enum.EnumMeta):

@ -65,18 +65,22 @@ def update():
module.int32 = lookup_types('int', 'i32', 'int32')
module.int64 = lookup_types('long long', 'long', 'i64', 'int64')
module.ssize_t = module.long
module.size_t = module.ulong
module.pvoid = void.pointer()
module.ppvoid = pvoid.pointer()
module.pchar = char.pointer()
module.ptrsize = pvoid.sizeof
if pvoid.sizeof == 4: module.ptrdiff = uint32
if pvoid.sizeof == 8: module.ptrdiff = uint64
if pvoid.sizeof == 4:
module.ptrdiff = module.uint32
module.size_t = module.uint32
module.ssize_t = module.int32
elif pvoid.sizeof == 8:
module.ptrdiff = module.uint64
module.size_t = module.uint64
module.ssize_t = module.int64
else:
raise Exception('Pointer size not supported')
module.null = gdb.Value(0).cast(void)
# Call it once so we load all of the types

Loading…
Cancel
Save