mirror of
https://github.com/idapython/src
synced 2026-06-08 14:47:00 +00:00
IDAPython for IDA 8.1
This commit is contained in:
+6
-2
@@ -31,6 +31,10 @@ ushort = uint16
|
||||
__EA64__ = ida_idaapi.BADADDR == 0xFFFFFFFFFFFFFFFF
|
||||
ea_t = uint64 if __EA64__ else uint32
|
||||
|
||||
# Dalvik indices are stored as uint32
|
||||
def to_uint32(v):
|
||||
return int.from_bytes(v, byteorder='little') & 0xFFFFFFFF
|
||||
|
||||
# parse a ctypes struct from byte data in str_ at 'off'
|
||||
def get_struct(str_, off, struct):
|
||||
s = struct()
|
||||
@@ -95,7 +99,7 @@ def unpack_dd(buf, off):
|
||||
def unpack_dq(buf, off):
|
||||
(xl, off) = unpack_dd(buf, off)
|
||||
(xh, off) = unpack_dd(buf, off)
|
||||
x = (long(xh) << 32) | xl
|
||||
x = (xh << 32) | xl
|
||||
if x > 0x8000000000000000:
|
||||
x = x - 0x10000000000000000
|
||||
return (x, off)
|
||||
@@ -286,7 +290,7 @@ class Dex(object):
|
||||
return Dex.as_string(raw)
|
||||
|
||||
def get_method_idx(self, ea):
|
||||
return self.nn_cmn.altval(ea, Dex.DEXCMN_METHOD_ID)
|
||||
return to_uint32(self.nn_cmn.supval_ea(ea, Dex.DEXCMN_METHOD_ID))
|
||||
|
||||
def get_method(self, from_ea, method_idx):
|
||||
nn_var = self.get_nn_var(from_ea)
|
||||
|
||||
+15
-4
@@ -4502,6 +4502,17 @@ def __l2m1(v):
|
||||
return v
|
||||
|
||||
|
||||
def __m1tol(v):
|
||||
"""
|
||||
Long -1 to BADNODE: If the 'v' appears to be the
|
||||
'signed long' version of -1, then return BADNODE.
|
||||
Otherwise, return 'v'.
|
||||
"""
|
||||
if v == -1:
|
||||
return ida_netnode.BADNODE
|
||||
else:
|
||||
return v
|
||||
|
||||
|
||||
AR_LONG = ida_netnode.atag
|
||||
"""Array of longs"""
|
||||
@@ -4749,9 +4760,9 @@ def get_next_index(tag, array_id, idx):
|
||||
node = __GetArrayById(array_id)
|
||||
try:
|
||||
if tag == AR_LONG:
|
||||
return __l2m1(node.altnext(idx, tag))
|
||||
return __l2m1(node.altnext(__m1tol(idx), tag))
|
||||
elif tag == AR_STR:
|
||||
return __l2m1(node.supnext(idx, tag))
|
||||
return __l2m1(node.supnext(__m1tol(idx), tag))
|
||||
else:
|
||||
return -1
|
||||
except OverflowError:
|
||||
@@ -4773,9 +4784,9 @@ def get_prev_index(tag, array_id, idx):
|
||||
node = __GetArrayById(array_id)
|
||||
try:
|
||||
if tag == AR_LONG:
|
||||
return __l2m1(node.altprev(idx, tag))
|
||||
return __l2m1(node.altprev(__m1tol(idx), tag))
|
||||
elif tag == AR_STR:
|
||||
return __l2m1(node.supprev(idx, tag))
|
||||
return __l2m1(node.supprev(__m1tol(idx), tag))
|
||||
else:
|
||||
return -1
|
||||
except OverflowError:
|
||||
|
||||
Reference in New Issue
Block a user