-
Notifications
You must be signed in to change notification settings - Fork 160
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
Exposing the raw COFF section table to the user #239
base: master
Are you sure you want to change the base?
Conversation
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.
Cool Thank you for this PR! Just a doc comment would be nice on the new public field; I don't know much about section_tables are they optional? What do they contain? Might be good for minor summary of this in the doc comment?
Also just curious, what are you using the section tables for ? :)
…the section_table field
Microsofts CodeView debug format (aka PDB) contains a copy of the raw section headers. I'm currently working on generating those for already existing binaries to make reverse engineering them easier.
I figured that wasn't necessary considering that goblin is already parsing them and fails if they're not present or corrupted. |
So I guess what I’m asking is there other structure we need to pull out of the section tables or is &[u8] the best we can do / depends on other information ? |
I’m asking specifically because I’m wondering if it’s the best public api to expose because if it isn’t and it needs to change then it’s a breaking change. (And it’s very well possible it is the best, in which case, great !) |
Oh this definitely isn't the best way to achieve what I'm trying to do. The structure behind that is IMAGE_SECTION_HEADER which is already being parsed into a struct Line 33 in aff5da4
The issue with that being that it copies the raw data into a custom struct goblin/src/pe/section_table.rs Lines 6 to 20 in aff5da4
that isn't 1:1 what's in the binary so I can't pass it to LLVM. I'm definitely duplicating behaviour here. A better (read: cleaner) solution would be to rewrite the section header parsing to produce the correct structure or even better, pass references to the original buffer back. I avoided doing that because that'd definitely be a breaking change. |
@not-wlan sorry I got busy and didn't notice your follow up; it's too bad, just released a new (breaking 0.3). So if i understood your proposal correctly, you want the section table we already parse to be 1:1 binary compatible so you can pass that back to llvm? Could you highlight what needs to change right now in the |
Alternatively, I think I'm ok with merging a version of this PR which tucks away the raw bytes in the struct as a private field (which e.g., mach-o does), and then we add a function like |
ping @not-wlan re my last comment, and in general, are you still interested in this feature? I'll leave it open for now, let me know whenever you find the time, no rush, thanks and thanks again for the PR and discussion! |
I'm interested into getting this PR back in shape if needed. :) |
I'm working on something that requires raw access to the section table and figured I might as well add this to the library so others may make use of this.
I tried building upon the existing code but I didn't want to break the signature of
header.coff_header.sections
either.This shouldn't break anything and should also add some validation for broken PEs.