-
Notifications
You must be signed in to change notification settings - Fork 31
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 rebuild support for VersionInfo related structures #34
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.
Would this require users to call rebuild()
before write()
so they get the write length? What would that improve?
* | ||
* @return the updated length of this structure in bytes (might include padding) | ||
*/ | ||
int rebuild(); |
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.
Do any of the implementations actually rebuild anything? At least in this diff it seems to only calculate the length and not modify the structure itself.
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.
You are right, in the current PR, there are only length calculations. The next PR will tackle the resources tree, where this method will layout the directories and entries, and updating all pointers between them.
|
||
import java.io.IOException; | ||
|
||
public interface ModifiableStructure { |
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.
What about the interface makes it modifiable? I feel like I'm missing something with the naming of this.
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.
Good point, all of the structure classes are modifiable already now. I would propose to rename it to RebuildableStructure, so it better reflects its main method (rebuild).
I will also add a JavaDoc to make it clearer.
The idea behind splitting |
I updated the PR with a suggestion. I would squash the commits, once the PR is OK for you. Just let me know before merging it... |
So is that length that researches may want to change in the PE header or the physical length? How do we plan on giving them this control? Right now the
I always squash merge. No need to work extra to force push on your side. It's nice when the PR has a full history too. |
I'm not sure, I'm getting your point... The original author created all structure classes as simple POJOs having getter and setter methods, so all fields can be controlled from the outside (including all Regarding squash merges, I usually prefer keeping all commits if they are well done (what I try to do): Separate commits for separate sub tasks, put refactorings in dedicated commits, do NOT use it as diary ("first I did this, than that, then changed my mind") etc. When having this information in git, it makes investigations easier than having to browse the corresponding PRs to get these details. Github handles force pushes well and shows the diffs without any problems. Why not keeping the discussions and review iterations in the PR page on Github and push a clean, understandable, non-aggregated history to the git tree? |
So If that's the case, I think just the name needs to change to something like Or maybe something like the following would be easier for the user. Each structure can calculate its own length, but also has an optional override length. So
Sounds like we agree on this one. Pushes to main branch should be clean. I usually take the PR description for the commit message of the squashed commit, not the aggregated thing GitHub auto-generates. |
Correct, the old code just wrote the values as they are.
Yes, the next PR will tackle the resources tree, where this method will layout the directories and entries, and updating all pointers between them. So I had a look at how other libraries handle this topic. LIEF, for example, also requires the user to explicitly call an additional method - see https://lief-project.github.io/doc/stable/tutorials/02_pe_from_scratch.html at the bottom: "By default the import table is not rebuilt so we have to configure the builder to rebuild it".
Well, I actually wanted to provide arguments against squashing. If you look at the squashed PR 31 commit, you see in the commit message that 5 tasks have been done (Java update, refactoring, new functionality, add tests etc.), but the information which of these changes affected (let's say) the |
OK, so is this PR ready to merge as-is? Or do you want to make any changes based on this discussion? I can normal merge it. |
da2ba1e
to
54db1fb
Compare
The branch is now ready to be merged. I still think, |
I introduced a new interface to mark structures that can be updated and written back to a byte stream: ModifiableStructure. All VersionInfo related structures implement it now.
In addition, I removed some fields containing padding information as this should not be stored but recalculated.