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

[PATCH] Error in PE Loader relocations (LdrPerformRelocations)

    XMLWordPrintable

Details

    • Bug
    • Resolution: Incomplete
    • Major
    • None
    • Win32SS
    • None
    • Operating System: ReactOS
      Platform: x86 Hardware

    Description

      In LdrPerformRelocations(), on line 01408, there's an error in calculating the Delta when performing relocations:

      Delta = (ULONG_PTR)ImageBase - NTHeaders->OptionalHeader.ImageBase;

      The problem is that the NTHeaders->OptionalHeader.ImageBase variable may be greater than the ImageBase variable, thus, if the smaller is subtracted from the larger, will create a negative number, resulting in incorrectly relocated code.

      The fix I thought up would end up looking something like this:

      Delta = max((ULONG_PTR)ImageBase, NTHeaders->OptionalHeader.ImageBase) - min((ULONG_PTR)ImageBase, NTHeaders->OptionalHeader.ImageBase);

      Thanks!

      Attachments

        Activity

          People

            fireball fireball
            dmags dmags
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: