Details
-
Bug
-
Resolution: Incomplete
-
Major
-
None
-
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!