for (Index1 = 0; Index1 < Index; Index1 ++) {\r
if ((DirectoryEntry->VirtualAddress >= SectionHeader[Index1].VirtualAddress) && \r
(DirectoryEntry->VirtualAddress < (SectionHeader[Index1].VirtualAddress + SectionHeader[Index1].Misc.VirtualSize))) {\r
+ DebugEntry = (EFI_IMAGE_DEBUG_DIRECTORY_ENTRY *)((UINTN) Hdr.Te +\r
+ DirectoryEntry->VirtualAddress - \r
+ SectionHeader [Index1].VirtualAddress + \r
+ SectionHeader [Index1].PointerToRawData + \r
+ TEImageAdjust);\r
break;\r
}\r
}\r
- DebugEntry = (EFI_IMAGE_DEBUG_DIRECTORY_ENTRY *)((UINTN) Hdr.Te +\r
- DirectoryEntry->VirtualAddress - SectionHeader [Index1].VirtualAddress + SectionHeader [Index1].PointerToRawData + \r
- TEImageAdjust);\r
}\r
} else if (EFI_IMAGE_NT_SIGNATURE == Hdr.Pe32->Signature) {\r
//\r
DirectoryEntry = (EFI_IMAGE_DATA_DIRECTORY *)&(Hdr.Pe32Plus->OptionalHeader.DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_DEBUG]);\r
}\r
\r
- if (NumberOfRvaAndSizes <= EFI_IMAGE_DIRECTORY_ENTRY_DEBUG) {\r
+ if (NumberOfRvaAndSizes <= EFI_IMAGE_DIRECTORY_ENTRY_DEBUG || DirectoryEntry->VirtualAddress == 0) {\r
DirectoryEntry = NULL;\r
DebugEntry = NULL;\r
} else {\r
for (Index1 = 0; Index1 < Index; Index1 ++) {\r
if ((DirectoryEntry->VirtualAddress >= SectionHeader[Index1].VirtualAddress) && \r
(DirectoryEntry->VirtualAddress < (SectionHeader[Index1].VirtualAddress + SectionHeader[Index1].Misc.VirtualSize))) {\r
+ DebugEntry = (EFI_IMAGE_DEBUG_DIRECTORY_ENTRY *) (\r
+ (UINTN) Pe32Data + \r
+ DirectoryEntry->VirtualAddress - \r
+ SectionHeader[Index1].VirtualAddress + \r
+ SectionHeader[Index1].PointerToRawData);\r
break;\r
}\r
}\r
- DebugEntry = (EFI_IMAGE_DEBUG_DIRECTORY_ENTRY *) ((UINTN) Pe32Data + DirectoryEntry->VirtualAddress - SectionHeader[Index1].VirtualAddress + SectionHeader[Index1].PointerToRawData);\r
}\r
} else {\r
return NULL;\r
for (Index1 = 0; Index1 < Index; Index1 ++) {\r
if ((DebugEntry->RVA >= SectionHeader[Index1].VirtualAddress) && \r
(DebugEntry->RVA < (SectionHeader[Index1].VirtualAddress + SectionHeader[Index1].Misc.VirtualSize))) {\r
+ CodeViewEntryPointer = (VOID *) (\r
+ ((UINTN)Pe32Data) + \r
+ (UINTN) DebugEntry->RVA - \r
+ SectionHeader[Index1].VirtualAddress + \r
+ SectionHeader[Index1].PointerToRawData + \r
+ (UINTN)TEImageAdjust);\r
break;\r
}\r
}\r
- CodeViewEntryPointer = (VOID *) (((UINTN)Pe32Data) + (UINTN) DebugEntry->RVA - SectionHeader[Index1].VirtualAddress + SectionHeader[Index1].PointerToRawData + (UINTN)TEImageAdjust);\r
+ if (Index1 >= Index) {\r
+ //\r
+ // Can't find CodeViewEntryPointer in raw PE/COFF image.\r
+ //\r
+ continue;\r
+ }\r
switch (* (UINT32 *) CodeViewEntryPointer) {\r
case CODEVIEW_SIGNATURE_NB10:\r
return (VOID *) ((CHAR8 *)CodeViewEntryPointer + sizeof (EFI_IMAGE_DEBUG_CODEVIEW_NB10_ENTRY));\r