Skip to content

Commit

Permalink
[BUGFIX] If section Virtual Size is not filled, use Raw Size as Virtual
Browse files Browse the repository at this point in the history
  • Loading branch information
hasherezade committed Feb 20, 2024
1 parent 06e63d4 commit bdae8c5
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion parser/pe/SectHdrsWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,9 @@ bufsize_t SectionHdrWrapper::getMappedRawSize()
return 0; // no changes
}
bufsize_t virtualSize = getContentDeclaredSize(Executable::RVA);
if (virtualSize == 0) { // if virtual size is not filled, use the raw size as virtual
virtualSize = getContentDeclaredSize(Executable::RAW);
}
if (virtualSize < rawSize) {
// if Virtual Size is smaller than the raw size, it means not full raw size will be mapped
rawSize = virtualSize;
Expand Down Expand Up @@ -305,7 +308,10 @@ bufsize_t SectionHdrWrapper::getMappedVirtualSize()
return 0; //invalid addr, nothing is mapped
}

bufsize_t dVirtualSize = getContentDeclaredSize(aType);
bufsize_t dVirtualSize = getContentDeclaredSize(aType);
if (dVirtualSize == 0) {
dVirtualSize = getContentDeclaredSize(Executable::RAW);
}
bufsize_t mRawSize = getMappedRawSize();

bufsize_t mVirtualSize = (dVirtualSize > mRawSize) ? dVirtualSize : mRawSize;
Expand Down

0 comments on commit bdae8c5

Please sign in to comment.