-
Notifications
You must be signed in to change notification settings - Fork 156
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
Add helper for walking the resource directory inside a PE file #425
Conversation
fda29ca
to
a636481
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for working on this!
src/pe.rs
Outdated
} | ||
|
||
pub const IMAGE_RESOURCE_NAME_IS_STRING: u32 = 0x8000_0000; | ||
pub const IMAGE_RESOURCE_DATA_IS_DIRECTORY: u32 = 0x8000_0000; | ||
pub const IMAGE_RESOURCE_NAME_OFFSET_MASK: u32 = 0x7FFF_FFFF; | ||
pub const IMAGE_RESOURCE_NAME_ID_MASK: u32 = 0x0000_FFFF; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know the comment below says that IDs are 16-bit, but the Microsoft PE Format documentation says they are 32-bit.
Ghidra parses them as 16-bit, so I'm not sure what is correct here.
a636481
to
d2f0f06
Compare
It looks like the changes I made in Is there a special setup I should follow for running those tests ? |
You'll need to run |
I never made PRs with submodule. |
No, you don't need to change the submodule, you just need to ensure git has checked it out so that you have a copy of https://github.com/gimli-rs/object-testfiles/blob/8392ac7ffa09cd31f24aa0f3ef77e08034cbca41/pe/base-gnu.exe, and then update the |
Add helpers for navigating a PE file resource directory
d2f0f06
to
6cc16ab
Compare
Done
The test sources are in one place and the test expected outputs in an other, makes sense. Them having the same folder name confused me a little bit. |
Add helpers for navigating a PE file resource directory
Add new API to allow walking the resource directory inside a PE file.
The entry point is
PeFile::resource_directory_table(&self) -> Result<ResourceDirectoryTable<'data>>
, from there it offers an iterator to visit every entries in the directory (ResourceDirectoryTable::iter(&self) -> impl Iterator<Item = ResourceDirectoryEntry<'data>>
).The API is mostly lazy, only reading data as needed (doesn't read entries and sub-directories data unless visited).
Also add a small binary
perscdump
as an example which print the resource data tree.