I can make an array using MakeArray.
Is there a function to get the size of the array I've created?
I've tried GetArrayId + GetLastIndex but it doesn't seem to work.
Reverse Engineering Stack Exchange is a question and answer site for researchers and developers who explore the principles of a system through analysis of its structure, function, and operation. It only takes a minute to sign up.Sign up to join this community
An array is an example of a data item. Like all items in IDA (the other item type is instruction), it has a starting address (head) and size. You can retrieve the whole item's size using the function
get_item_size() (legacy name
To figure out the number of items in an array, you can divide the whole array's size by the size of one element. But how to know the size of element? For this you need to inspect the flags of the item (attached to the head byte) using
get_flags() function. Base item type is encoded in the bits defined by the
DT_TYPE bits (top 4 bits of the flags) and takes values such as
FF_DWORD and so on. But instead of checking the bits manually, you can use the function
get_data_elsize() which return the size in bytes from the flags.
For more info check the
bytes.hpp header in the SDK.