-
Notifications
You must be signed in to change notification settings - Fork 953
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
Computation of section entropies for ELF, MACHO and PE (in progress) #501
Conversation
It seems that this branch is based on the branch for #440 (it contains the same commits). Shouldn't it be based on |
right, i'll fix that |
{ | ||
const auto overlaySize = getOverlaySize(); | ||
const auto declSize = getDeclaredFileLength(); | ||
const auto bytes = getBytes(); |
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.
Beware that storing the result of
const std::vector<unsigned char>& getBytes() const;
into
const auto bytes = getBytes();
causes the vector to be copied, i.e. the type of bytes
will be const std::vector<unsigned char>
. I believe what you want is
const auto &bytes = getBytes();
which will store a reference, i.e. the type of bytes
will be const std::vector<unsigned char> &
.
return; | ||
} | ||
|
||
auto data = reinterpret_cast<const uint8_t *>(bytes.data()); |
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 we need a reinterpret_cast
cast for this? Doesn't a static_cast
suffice?
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.
@@ -118,6 +119,10 @@ void MachODetector::getSections() | |||
fsec.setMemoryAlignment(pow(2, mSec->getAlignment())); | |||
fsec.setRelocationsOffset(mSec->getRelocationOffset()); | |||
fsec.setNumberOfRelocations(mSec->getNumberOfRelocations()); | |||
if(sec->getEntropy(entropy)) |
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 suggest defining double entropy;
right before if(sec->getEntropy(entropy))
, not 14 lines before. It is generally a good practice to define variables as close to their first use, especially when they are not initialized.
ac645c4
to
20a8e7a
Compare
#502
I've implemented extraction of section entropies for various file formats.
Tests are not implemented yet, thus the "in progress" status.