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

Fix "Offset" values in Optional Header metadata #2135

Merged
merged 1 commit into from
Aug 31, 2020

Conversation

srutzky
Copy link
Contributor

@srutzky srutzky commented Aug 31, 2020

Problem

Offset values in the "Optional Header" metadata section are missing the base offset and thus start at 00000000 instead of at something like 00000098. This concerns lines 65 - 94:

https://github.com/icsharpcode/ILSpy/blob/master/ILSpy/Metadata/OptionalHeaderTreeNode.cs#L65-L94

Solution

I applied the base offset, headers.PEHeaderStartOffset, in the same manner that it's being applied in CoffHeaderTreeNode.cs (lines 70 - 75):

https://github.com/icsharpcode/ILSpy/blob/master/ILSpy/Metadata/CoffHeaderTreeNode.cs#L70-L75

NOTE: I apologize that I have no ability to test this change. However, it should be very low-risk as no new lines are being added, it's an existing variable, and it's being handled consistently with the other metadata section that has a similar base offset. However, if a change needs to be made then please let me know.

Take care,
Solomon...
https://SqlQuantumLeap.com/

Offsets in this metadata section are missing the base offset and thus start at 00000000 instead of at something like 00000098. I applied the base offset in the same manner that it's being applied in CoffHeaderTreeNode.cs.
@siegfriedpammer siegfriedpammer merged commit 45d7e06 into icsharpcode:master Aug 31, 2020
@siegfriedpammer
Copy link
Member

Thank you for this contribution!

@srutzky
Copy link
Contributor Author

srutzky commented Aug 31, 2020

@siegfriedpammer You are welcome.

Also, there is one more change I would like to make but would appreciate your input first. I want to add the specific flag / bitmask values to each of the individual options for both the "Characteristics" list (in "COFF Header") and the "DLL Characteristics" list (in "Optional Header"). The end-result being that we would see:

☑️  | <0x0002> File is executable
🟦  | <0x0004> Line numbers stripped from file
🟦  | <0x0008> Local symbols stripped from file
...
🟦  | <0x0080> Bytes of machine words are reversed (Low)

Or, it could be:

☑️  | <0002> File is executable
🟦  | <0004> Line numbers stripped from file
🟦  | <0008> Local symbols stripped from file
...
🟦  | <0080> Bytes of machine words are reversed (Low)

Or, it could be something else entirely.

Do you have a preferred style? I'm using < and > to keep them visually separate from the existing parenthetical values used at the end of the line in a few places: (Low), (High), and (SEH).

@srutzky srutzky deleted the patch-1 branch August 31, 2020 13:55
@christophwille
Copy link
Member

@srutzky Please open an issue for this - discussion on a closed PR for something else isn't helping visibility.

@srutzky
Copy link
Contributor Author

srutzky commented Sep 2, 2020

@christophwille Sorry, I was thought I was making things easier. Issue has been created as requested: #2138

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.

3 participants