Uploaded image for project: 'Core ReactOS'
  1. Core ReactOS
  2. CORE-5760

PE section load alignment is not consistent with Windows and Linux

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • Major
    • None
    • NTCore
    • None
    • Operating System: ReactOS
      Platform: x86 Hardware

    Description

      When PE executable has non standard section alignment ReactOS loader behaviour differs from Windows and Linux loader.

      If the value of sect->PointerToRawData is not aligned on FileAlign then Windows (tested with 98,XP,Vista) and Linux loader all use the following algorithm to load the section:

      sectEnd = sect->PointerToRawData + sect->SizeOfRawData;
      fileOffset = sect->PointerToRawData & 0xFFFFFF80;
      sectSize = sectEnd - fileOffset;

      readData(fileHandle, fileOffset, sectSize);

      ReactOS loader, however, uses direct values to read data in:

      readData(fileHandle, sect->PointerToRawData , sect->SizeOfRawData);

      To test this behavior just use binary editor to edit any executable file and put anything in the last nibble of the PointerToRawData of the code section. It should still load correctly on Windows and Linux/Wine, but will fail on ReactOS (tested with 0.3.13)

      For the properly linked files this is not a problem, but if Linux has reasons to follow exact Windows behavior ReactOS should as well.

      Attachments

        Activity

          People

            admin admin
            technik3k technik3k
            Votes:
            2 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated: