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

handle PE delay import tables with VA pointers instead of RVA pointers #439

Merged
merged 11 commits into from Aug 25, 2021

Conversation

williballenthin
Copy link
Contributor

@williballenthin williballenthin commented Aug 19, 2021

closes #438

I'm sorry there's so much new code, but I've commented thoroughly so its clear what I'm doing and why. In theory, this code is only relevant for VS6 binaries (uncommon).

unrelated tweak to the parameter of parseImportTable to make it explicit which flavor of table is being parsed. i found is_import to be confusing: if its not an import table, what is the alternative? (ok, i know its delay import table but its not written out anywhere).

@williballenthin williballenthin marked this pull request as draft August 20, 2021 00:01
@williballenthin

This comment has been minimized.

- detect RVA vs VA in parseDelayImports
- make flavor="import table"/"delay import table" more clear
@williballenthin williballenthin marked this pull request as ready for review August 20, 2021 17:24
@williballenthin
Copy link
Contributor Author

ready for review @rakuy0. tests pass and no further pending changes.

Copy link
Contributor

@rakuy0 rakuy0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a few small questions. The only thing I think this is really missing is some kind of test.

Do you have a binary you can throw into https://github.com/vivisect/vivtestfiles so you or I could write a test for this?

entry_name = x.rvaDLLName
else:
raise ValueError("unexpected flavor: " + flavor)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since you have the check for the type above, are these additional checks necessary?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

when dealing with enum-style things in python i like to explicitly name each case and raise an exception otherwise. this helps catch bugs in the future if another enum member is added but the author forgets to update a switch/case. using a single if/else hides the bug and goes to the wrong logic block.

# more votes for RVA than for VA
return sum([1 for vote in votes if vote]) > sum([1 for vote in votes if not vote])

def parseImportTable(self, x, irva, flavor="import table", uses_rva=True):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is flavor ever going to expand beyond normal or delayed imports (I'm just curious about the change from a boolean to a string)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i dont know. gcc delay import table???

i found is_import to be confusing: if its not an import table, what is the alternative? using the flavor string makes it very clear to the reader what variety of thing is being parsed.

@williballenthin
Copy link
Contributor Author

Do you have a binary you can throw into https://github.com/vivisect/vivtestfiles so you or I could write a test for this?

#438 references a binary from VT. i'll add a test case with this sample.

@williballenthin
Copy link
Contributor Author

binary for testcase: vivisect/vivtestfiles#19

@williballenthin
Copy link
Contributor Author

test added. no further pending work.

@rakuy0 rakuy0 merged commit a910a9b into vivisect:master Aug 25, 2021
@williballenthin williballenthin deleted the fix-438 branch August 25, 2021 20:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

TypeError: a bytes-like object is required, not 'NoneType'
2 participants