Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Re-worked structure.member_t.refs() to also return structure operands that reference a defined global #34

Merged
merged 3 commits into from
Nov 10, 2019

Conversation

arizvisa
Copy link
Owner

So, the idaapi.get_opinfo does not return operand types where the operand is pointing to a defined structure. Because of this, the structure.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 the member_t.refs() method could be used to identify any structure that is referenced by said member.

Closes issue #33.

…y references to structure members instead of both members and addresses.
… reference a member directly instead of just the particular field.
@arizvisa arizvisa self-assigned this Nov 10, 2019
@arizvisa arizvisa added the bug label Nov 10, 2019
@arizvisa
Copy link
Owner Author

Wow, that was a huge fucking pain...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant