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

How to determine the size when using get_content_from_virtual_address #2

Open
vegedreamgagnoa opened this issue Jun 30, 2022 · 2 comments

Comments

@vegedreamgagnoa
Copy link

Any help/hint how to determine the exact size of code/instruction/bytes we obtain from a virtual address?
I was a little bit confused on determining the exact size when trying to fetch the bytes using get_content_from_virtual_address

Thank you for assistance.

@vegedreamgagnoa
Copy link
Author

@codyd51

@codyd51
Copy link
Contributor

codyd51 commented Jul 25, 2022

Hi, thanks for your patience!

get_contents_from_virtual_address is a 'low-level' API, and doesn't automatically take into account the size of the underlying structure. If you know exactly what kind of structure you'd like to parse, you can use the read_struct API like so:

binary.read_struct(address, MachoSectionRawStruct, virtual=True)

That said, there are typically specific APIs to interact with the various structures in a Mach-O. For example, the above is better served by using the binary.sections API, which provides more information than parsing the structure by hand.

Please let me know if you have any other questions I can help with!

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

No branches or pull requests

2 participants