mirror of
https://github.com/reactos/reactos.git
synced 2025-08-06 06:02:56 +00:00
[RTL] Fix RtlImageDirectoryEntryToData to support both 32 and 64 bit images
This commit is contained in:
parent
cac7b003c0
commit
883ae6d93b
1 changed files with 29 additions and 8 deletions
|
@ -289,17 +289,38 @@ RtlImageDirectoryEntryToData(
|
||||||
if (NtHeader == NULL)
|
if (NtHeader == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (Directory >= SWAPD(NtHeader->OptionalHeader.NumberOfRvaAndSizes))
|
if (NtHeader->OptionalHeader.Magic == IMAGE_NT_OPTIONAL_HDR64_MAGIC)
|
||||||
|
{
|
||||||
|
PIMAGE_OPTIONAL_HEADER64 OptionalHeader = (PIMAGE_OPTIONAL_HEADER64)&NtHeader->OptionalHeader;
|
||||||
|
|
||||||
|
if (Directory >= SWAPD(OptionalHeader->NumberOfRvaAndSizes))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
Va = SWAPD(NtHeader->OptionalHeader.DataDirectory[Directory].VirtualAddress);
|
Va = SWAPD(OptionalHeader->DataDirectory[Directory].VirtualAddress);
|
||||||
if (Va == 0)
|
if (Va == 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
*Size = SWAPD(NtHeader->OptionalHeader.DataDirectory[Directory].Size);
|
*Size = SWAPD(OptionalHeader->DataDirectory[Directory].Size);
|
||||||
|
|
||||||
if (MappedAsImage || Va < SWAPD(NtHeader->OptionalHeader.SizeOfHeaders))
|
if (MappedAsImage || Va < SWAPD(OptionalHeader->SizeOfHeaders))
|
||||||
return (PVOID)((ULONG_PTR)BaseAddress + Va);
|
return (PVOID)((ULONG_PTR)BaseAddress + Va);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
PIMAGE_OPTIONAL_HEADER32 OptionalHeader = (PIMAGE_OPTIONAL_HEADER32)&NtHeader->OptionalHeader;
|
||||||
|
|
||||||
|
if (Directory >= SWAPD(OptionalHeader->NumberOfRvaAndSizes))
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
Va = SWAPD(OptionalHeader->DataDirectory[Directory].VirtualAddress);
|
||||||
|
if (Va == 0)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
*Size = SWAPD(OptionalHeader->DataDirectory[Directory].Size);
|
||||||
|
|
||||||
|
if (MappedAsImage || Va < SWAPD(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);
|
return RtlImageRvaToVa(NtHeader, BaseAddress, Va, NULL);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue