kernel32: Check for a 32-bit NT header before getting module address range in MODULE_GetBinaryType.
This commit is contained in:
parent
5e4f0cf5ca
commit
4a59ac76f1
@ -282,7 +282,7 @@ DWORD MODULE_GetBinaryType( HANDLE hfile, void **res_start, void **res_end )
|
||||
union
|
||||
{
|
||||
IMAGE_OS2_HEADER os2;
|
||||
IMAGE_NT_HEADERS nt;
|
||||
IMAGE_NT_HEADERS32 nt;
|
||||
} ext_header;
|
||||
|
||||
/* We do have a DOS image so we will now try to seek into
|
||||
@ -309,9 +309,20 @@ DWORD MODULE_GetBinaryType( HANDLE hfile, void **res_start, void **res_end )
|
||||
if (len < sizeof(ext_header.nt)) /* clear remaining part of header if missing */
|
||||
memset( (char *)&ext_header.nt + len, 0, sizeof(ext_header.nt) - len );
|
||||
if (res_start) *res_start = (void *)ext_header.nt.OptionalHeader.ImageBase;
|
||||
if (res_end) *res_end = (void *)(ext_header.nt.OptionalHeader.ImageBase +
|
||||
ext_header.nt.OptionalHeader.SizeOfImage);
|
||||
switch (ext_header.nt.OptionalHeader.Magic)
|
||||
{
|
||||
case IMAGE_NT_OPTIONAL_HDR32_MAGIC:
|
||||
if (res_start) *res_start = (void *)ext_header.nt.OptionalHeader.ImageBase;
|
||||
if (res_end) *res_end = (void *)(ext_header.nt.OptionalHeader.ImageBase +
|
||||
ext_header.nt.OptionalHeader.SizeOfImage);
|
||||
return ret;
|
||||
case IMAGE_NT_OPTIONAL_HDR64_MAGIC:
|
||||
if (res_start) *res_start = NULL;
|
||||
if (res_end) *res_end = NULL;
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
return BINARY_DOS;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user