Author: hbelusca Date: Thu Dec 17 23:10:56 2015 New Revision: 70390
URL: http://svn.reactos.org/svn/reactos?rev=70390&view=rev Log: [DBGHELP][RTL] Fix usage of VirtualSize wrt. SizeOfRawData. CORE-10523 CORE-9548 #comment Please retest with revision >= 70390
Modified: trunk/reactos/dll/win32/dbghelp/compat.c trunk/reactos/lib/rtl/image.c
Modified: trunk/reactos/dll/win32/dbghelp/compat.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/dbghelp/compat.c?... ============================================================================== --- trunk/reactos/dll/win32/dbghelp/compat.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/dbghelp/compat.c [iso-8859-1] Thu Dec 17 23:10:56 2015 @@ -61,11 +61,11 @@ while (Count--) { Va = SWAPD(Section->VirtualAddress); - if ((Va <= Rva) && - (Rva < Va + SWAPD(Section->Misc.VirtualSize))) + if ((Va <= Rva) && (Rva < Va + SWAPD(Section->SizeOfRawData))) return Section; Section++; } + return NULL; }
@@ -83,9 +83,9 @@
if ((Section == NULL) || (Rva < SWAPD(Section->VirtualAddress)) || - (Rva >= SWAPD(Section->VirtualAddress) + SWAPD(Section->Misc.VirtualSize))) - { - Section = RtlImageRvaToSection (NtHeader, BaseAddress, Rva); + (Rva >= SWAPD(Section->VirtualAddress) + SWAPD(Section->SizeOfRawData))) + { + Section = RtlImageRvaToSection(NtHeader, BaseAddress, Rva); if (Section == NULL) return NULL;
@@ -93,9 +93,8 @@ *SectionHeader = Section; }
- return (PVOID)((ULONG_PTR)BaseAddress + - Rva + - SWAPD(Section->PointerToRawData) - + return (PVOID)((ULONG_PTR)BaseAddress + Rva + + (ULONG_PTR)SWAPD(Section->PointerToRawData) - (ULONG_PTR)SWAPD(Section->VirtualAddress)); }
@@ -132,7 +131,7 @@ if (MappedAsImage || Va < SWAPD(NtHeader->OptionalHeader.SizeOfHeaders)) return (PVOID)((ULONG_PTR)BaseAddress + Va);
- /* image mapped as ordinary file, we must find raw pointer */ + /* Image mapped as ordinary file, we must find raw pointer */ return RtlImageRvaToVa(NtHeader, BaseAddress, Va, NULL); }
Modified: trunk/reactos/lib/rtl/image.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/lib/rtl/image.c?rev=70390&a... ============================================================================== --- trunk/reactos/lib/rtl/image.c [iso-8859-1] (original) +++ trunk/reactos/lib/rtl/image.c [iso-8859-1] Thu Dec 17 23:10:56 2015 @@ -301,10 +301,9 @@ if (MappedAsImage || Va < SWAPD(NtHeader->OptionalHeader.SizeOfHeaders)) return (PVOID)((ULONG_PTR)BaseAddress + Va);
- /* image mapped as ordinary file, we must find raw pointer */ + /* Image mapped as ordinary file, we must find raw pointer */ return RtlImageRvaToVa(NtHeader, BaseAddress, Va, NULL); } -
/* * @implemented @@ -326,14 +325,13 @@ while (Count--) { Va = SWAPD(Section->VirtualAddress); - if ((Va <= Rva) && - (Rva < Va + SWAPD(Section->Misc.VirtualSize))) + if ((Va <= Rva) && (Rva < Va + SWAPD(Section->SizeOfRawData))) return Section; Section++; } + return NULL; } -
/* * @implemented @@ -353,9 +351,9 @@
if ((Section == NULL) || (Rva < SWAPD(Section->VirtualAddress)) || - (Rva >= SWAPD(Section->VirtualAddress) + SWAPD(Section->Misc.VirtualSize))) - { - Section = RtlImageRvaToSection (NtHeader, BaseAddress, Rva); + (Rva >= SWAPD(Section->VirtualAddress) + SWAPD(Section->SizeOfRawData))) + { + Section = RtlImageRvaToSection(NtHeader, BaseAddress, Rva); if (Section == NULL) return NULL;
@@ -363,9 +361,8 @@ *SectionHeader = Section; }
- return (PVOID)((ULONG_PTR)BaseAddress + - Rva + - SWAPD(Section->PointerToRawData) - + return (PVOID)((ULONG_PTR)BaseAddress + Rva + + (ULONG_PTR)SWAPD(Section->PointerToRawData) - (ULONG_PTR)SWAPD(Section->VirtualAddress)); }