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

Error in mapping Raw Size to Virtual Size (when Virtual Size is smaller) #20

Closed
hasherezade opened this issue Mar 4, 2023 · 1 comment
Assignees
Labels

Comments

@hasherezade
Copy link
Owner

hasherezade commented Mar 4, 2023

Test cases:

1:
sample1

2:
sample2

Both samples have Virtual Size smaller than the Raw Size. It means not the whole Raw Size is going to be mapped.
However, Bearparser mistakenly uses the Raw Size as defined in the headers, over the Virtual Size. This leads to further errors in interpretation of the addresses.

What is really mapped in memory?

Example: cfccf5e157c00dc7104a750b2f9a8fc00fd323507277e8d616536c9084dc7586

This sample has Virtual Size defined as: 24B5 and Raw Size defined as 9400.
What is really mapped in memory is not exactly the Virtual Size, but the Virtual Size rounded up to File Alignment:

real_mapped

So, 24B5 rounded up to the File Alignment is 3000. We can make an experiment by appending a test string at the end of the section in the raw format:

sec_end1

And this is the end of the section in memory:

sec_end_virtual1

As we can see, indeed whole 3000 bytes from the file has been mapped in this section.

@hasherezade
Copy link
Owner Author

Fixed:

new_mapped1

new_mapped2

The real mapped sizes are displayed.
It fixes the problem with the interpretation of addresses, and the Entry Point is validly resolved.

@hasherezade hasherezade self-assigned this Mar 4, 2023
@hasherezade hasherezade added the bug label Mar 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant