Re-worked structure.member_t.refs() to also return structure operands that reference a defined global #34
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
So, the
idaapi.get_opinfo
does not return operand types where the operand is pointing to a defined structure. Because of this, thestructure.member_t.refs()
method does not act like one would expect. Until this PR was written, this method would only return references where the field was explicitly applied to an instruction's operand.To accomplish this, another case was added to the
member_t.refs()
which walks through all the operands for each instruction, checks to see if any have an offset that can be calculated statically, and then tries to find the structure id at that given address. If so, then it is compared against a list of all possible structure ids that the particular member might point to. As a structure can be referenced inside other structures, this had to be manually collected in order to perform the comparison.Additionally, in order to calculate the offset that the instruction operand is pointing to, the immediates from the operand need to be identified. As this can vary between the different operand decoders for each processor, the
interface.namedtypedtuple
class was modified so that accessing attributes is case-insensitive. This way only two attributes ("offset" and "address") need to be checked for existence in order to distinguish whether it is possible to calculate their target address statically.The
structure.structure_t.refs()
method was also updated so that it would return any members that are referencing the structure. This was necessary so that themember_t.refs()
method could be used to identify any structure that is referenced by said member.Closes issue #33.