PIMAGE_DOS_HEADER DosHeader;
PIMAGE_NT_HEADERS NtHeaders;
PIMAGE_SECTION_HEADER SectionHeader;
- unsigned SectionIndex;
- char SectionName[IMAGE_SIZEOF_SHORT_NAME];
+ ULONG SectionIndex;
+ BOOLEAN RosSymSectionFound = FALSE;
+ CHAR SectionName[IMAGE_SIZEOF_SHORT_NAME];
/* Check if MZ header is valid */
DosHeader = (PIMAGE_DOS_HEADER) ImageStart;
{
if (0 == memcmp(SectionName, SectionHeader->Name, IMAGE_SIZEOF_SHORT_NAME))
{
+ RosSymSectionFound = TRUE;
break;
}
SectionHeader++;
}
- if (NtHeaders->FileHeader.NumberOfSections <= SectionIndex)
+
+ if (!RosSymSectionFound)
{
DPRINT("No %s section found\n", ROSSYM_SECTION_NAME);
return FALSE;
return FALSE;
}
+ if (SectionHeader->VirtualAddress + SectionHeader->Misc.VirtualSize > ImageSize)
+ {
+ DPRINT("Bad %s section virtual size!\n", ROSSYM_SECTION_NAME);
+ return FALSE;
+ }
+
/* Load it */
return RosSymCreateFromRaw((char *) ImageStart + SectionHeader->VirtualAddress,
SectionHeader->SizeOfRawData, RosSymInfo);