Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions include/retdec/pelib/PeHeader.h
Original file line number Diff line number Diff line change
Expand Up @@ -1094,6 +1094,16 @@ namespace PeLib
ibBuffer >> ishCurr.NumberOfRelocations;
ibBuffer >> ishCurr.NumberOfLinenumbers;
ibBuffer >> ishCurr.Characteristics;

// PointerToRawData is aligned down to 0x200 by the Windows loader.
// This is because the section is mapped to memory based on file sectors.
// This behavior is independent of the FileAlignment value
// and only happens when SectionAlignment is greater or equal to page size
if(header.OptionalHeader.SectionAlignment >= PELIB_PAGE_SIZE)
{
ishCurr.PointerToRawData = ishCurr.PointerToRawData & ~(PELIB_SECTOR_SIZE - 1);
}

vIshdCurr.push_back(ishCurr);

uiOffset += PELIB_IMAGE_SECTION_HEADER::size();
Expand Down
2 changes: 2 additions & 0 deletions include/retdec/pelib/PeLibAux.h
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,8 @@ namespace PeLib
const dword PELIB_MAX_IMPORTED_FUNCTIONS = 0x1000; // Maximum number of exported functions (per DLL) that we support
const dword PELIB_MAX_EXPORTED_FUNCTIONS = 0x1000; // Maximum number of exported functions that we support

const dword PELIB_SECTOR_SIZE = 0x200;

template<int bits>
struct PELIB_IMAGE_ORDINAL_FLAGS;

Expand Down
1 change: 1 addition & 0 deletions src/fileinfo/fileinfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -525,3 +525,4 @@ int main(int argc, char* argv[])
delete fileDetector;
return isFatalError(res) ? static_cast<int>(res) : static_cast<int>(ReturnCode::OK);
}