[DBGHELP][RTL]

Fix usage of VirtualSize wrt. SizeOfRawData.
CORE-10523
CORE-9548 #comment Please retest with revision >= 70390

svn path=/trunk/; revision=70390
This commit is contained in:
Hermès Bélusca-Maïto 2015-12-17 23:10:56 +00:00
parent 382ea14238
commit 7e607b9fb8
2 changed files with 14 additions and 18 deletions

View file

@ -61,11 +61,11 @@ __RtlImageRvaToSection(
while (Count--) while (Count--)
{ {
Va = SWAPD(Section->VirtualAddress); Va = SWAPD(Section->VirtualAddress);
if ((Va <= Rva) && if ((Va <= Rva) && (Rva < Va + SWAPD(Section->SizeOfRawData)))
(Rva < Va + SWAPD(Section->Misc.VirtualSize)))
return Section; return Section;
Section++; Section++;
} }
return NULL; return NULL;
} }
@ -83,9 +83,9 @@ __RtlImageRvaToVa
if ((Section == NULL) || if ((Section == NULL) ||
(Rva < SWAPD(Section->VirtualAddress)) || (Rva < SWAPD(Section->VirtualAddress)) ||
(Rva >= SWAPD(Section->VirtualAddress) + SWAPD(Section->Misc.VirtualSize))) (Rva >= SWAPD(Section->VirtualAddress) + SWAPD(Section->SizeOfRawData)))
{ {
Section = RtlImageRvaToSection (NtHeader, BaseAddress, Rva); Section = RtlImageRvaToSection(NtHeader, BaseAddress, Rva);
if (Section == NULL) if (Section == NULL)
return NULL; return NULL;
@ -93,9 +93,8 @@ __RtlImageRvaToVa
*SectionHeader = Section; *SectionHeader = Section;
} }
return (PVOID)((ULONG_PTR)BaseAddress + return (PVOID)((ULONG_PTR)BaseAddress + Rva +
Rva + (ULONG_PTR)SWAPD(Section->PointerToRawData) -
SWAPD(Section->PointerToRawData) -
(ULONG_PTR)SWAPD(Section->VirtualAddress)); (ULONG_PTR)SWAPD(Section->VirtualAddress));
} }
@ -132,7 +131,7 @@ __RtlImageDirectoryEntryToData(
if (MappedAsImage || Va < SWAPD(NtHeader->OptionalHeader.SizeOfHeaders)) if (MappedAsImage || Va < SWAPD(NtHeader->OptionalHeader.SizeOfHeaders))
return (PVOID)((ULONG_PTR)BaseAddress + Va); 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); return RtlImageRvaToVa(NtHeader, BaseAddress, Va, NULL);
} }

View file

@ -301,11 +301,10 @@ RtlImageDirectoryEntryToData(
if (MappedAsImage || Va < SWAPD(NtHeader->OptionalHeader.SizeOfHeaders)) if (MappedAsImage || Va < SWAPD(NtHeader->OptionalHeader.SizeOfHeaders))
return (PVOID)((ULONG_PTR)BaseAddress + Va); 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); return RtlImageRvaToVa(NtHeader, BaseAddress, Va, NULL);
} }
/* /*
* @implemented * @implemented
*/ */
@ -326,15 +325,14 @@ RtlImageRvaToSection(
while (Count--) while (Count--)
{ {
Va = SWAPD(Section->VirtualAddress); Va = SWAPD(Section->VirtualAddress);
if ((Va <= Rva) && if ((Va <= Rva) && (Rva < Va + SWAPD(Section->SizeOfRawData)))
(Rva < Va + SWAPD(Section->Misc.VirtualSize)))
return Section; return Section;
Section++; Section++;
} }
return NULL; return NULL;
} }
/* /*
* @implemented * @implemented
*/ */
@ -353,9 +351,9 @@ RtlImageRvaToVa(
if ((Section == NULL) || if ((Section == NULL) ||
(Rva < SWAPD(Section->VirtualAddress)) || (Rva < SWAPD(Section->VirtualAddress)) ||
(Rva >= SWAPD(Section->VirtualAddress) + SWAPD(Section->Misc.VirtualSize))) (Rva >= SWAPD(Section->VirtualAddress) + SWAPD(Section->SizeOfRawData)))
{ {
Section = RtlImageRvaToSection (NtHeader, BaseAddress, Rva); Section = RtlImageRvaToSection(NtHeader, BaseAddress, Rva);
if (Section == NULL) if (Section == NULL)
return NULL; return NULL;
@ -363,9 +361,8 @@ RtlImageRvaToVa(
*SectionHeader = Section; *SectionHeader = Section;
} }
return (PVOID)((ULONG_PTR)BaseAddress + return (PVOID)((ULONG_PTR)BaseAddress + Rva +
Rva + (ULONG_PTR)SWAPD(Section->PointerToRawData) -
SWAPD(Section->PointerToRawData) -
(ULONG_PTR)SWAPD(Section->VirtualAddress)); (ULONG_PTR)SWAPD(Section->VirtualAddress));
} }