-
Notifications
You must be signed in to change notification settings - Fork 163
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
PE: Use OFTs for resolving imports without FTs #430
Merged
Merged
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -263,18 +263,29 @@ impl<'a> SyntheticImportDirectoryEntry<'a> { | |
} | ||
}; | ||
|
||
let import_address_table_offset = &mut utils::find_offset( | ||
import_directory_entry.import_address_table_rva as usize, | ||
sections, | ||
file_alignment, | ||
opts, | ||
) | ||
.ok_or_else(|| { | ||
error::Error::Malformed(format!( | ||
"Cannot map import_address_table_rva {:#x} into offset for {}", | ||
import_directory_entry.import_address_table_rva, name | ||
)) | ||
})?; | ||
let rva = match import_directory_entry.import_address_table_rva.is_zero() { | ||
true => import_directory_entry.import_lookup_table_rva, | ||
false => import_directory_entry.import_address_table_rva, | ||
}; | ||
Comment on lines
+266
to
+269
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. just fyi matching on true/false in this case is somewhat unidiomatic, generally |
||
|
||
let import_address_table_offset = | ||
&mut utils::find_offset(rva as usize, sections, file_alignment, opts).ok_or_else( | ||
|| { | ||
error::Error::Malformed( | ||
if import_directory_entry.import_address_table_rva.is_zero() { | ||
format!( | ||
"Cannot map import_lookup_table_rva {:#x} into offset for {}", | ||
rva, name | ||
) | ||
} else { | ||
format!( | ||
"Cannot map import_address_table_rva {:#x} into offset for {}", | ||
rva, name | ||
) | ||
}, | ||
) | ||
kkent030315 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
}, | ||
)?; | ||
let mut import_address_table = Vec::new(); | ||
loop { | ||
let import_address = bytes | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 am pretty sure I should check if
opts.resolve_rva
istrue
in match-false bracket (otherwise raises malformed as well as how it does before) in order to use address table which is replaced with absolute address of import address when the image is mapped.aka
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.
the second is somewhat harder to read at first, but i think I like it better :)
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.
when you say you're pretty sure, you mean that this PR needs that amendment? And are you worried about some kind of regression in doing this (i.e., less strict, problems further down the parsing pipeline or how come you didn't add it to this PR?)
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.
If I am correct that
resolve_rva
opt is meant to be solely used for the mapped image (i.e., raw memory dumps, minidumps etc):Yes, but what I am not sure is that we already make use of address table right now which is rewritten to the 64/32-bit absolute address when mapped into the memory. So If this is not to be the problem for this long in goblin, then I see no problems there to use lookup table.
I guess this is some kind of non-well implementation.. we should look for lookup tables rather than address tables.
call cs:__imp_MessageBoxA
are actually points to the FTs.I came to the conclusion that we do not need this optimization at this time.