TianoCore EDK2 master
Loading...
Searching...
No Matches
DefaultExceptionHandlerUefi.c
Go to the documentation of this file.
1
9#include <Uefi.h>
11#include <Library/UefiLib.h>
12
14
29CHAR8 *
31 IN UINTN FaultAddress,
32 OUT UINTN *ImageBase,
33 OUT UINTN *PeCoffSizeOfHeaders
34 )
35{
36 EFI_STATUS Status;
37 EFI_DEBUG_IMAGE_INFO_TABLE_HEADER *DebugTableHeader;
38 EFI_DEBUG_IMAGE_INFO *DebugTable;
39 UINTN Entry;
40 CHAR8 *Address;
41
42 Status = EfiGetSystemConfigurationTable (&gEfiDebugImageInfoTableGuid, (VOID **)&DebugTableHeader);
43 if (EFI_ERROR (Status)) {
44 return NULL;
45 }
46
47 DebugTable = DebugTableHeader->EfiDebugImageInfoTable;
48 if (DebugTable == NULL) {
49 return NULL;
50 }
51
52 Address = (CHAR8 *)(UINTN)FaultAddress;
53 for (Entry = 0; Entry < DebugTableHeader->TableSize; Entry++, DebugTable++) {
54 if (DebugTable->NormalImage != NULL) {
55 if ((DebugTable->NormalImage->ImageInfoType == EFI_DEBUG_IMAGE_INFO_TYPE_NORMAL) &&
56 (DebugTable->NormalImage->LoadedImageProtocolInstance != NULL))
57 {
58 if ((Address >= (CHAR8 *)DebugTable->NormalImage->LoadedImageProtocolInstance->ImageBase) &&
59 (Address <= ((CHAR8 *)DebugTable->NormalImage->LoadedImageProtocolInstance->ImageBase + DebugTable->NormalImage->LoadedImageProtocolInstance->ImageSize)))
60 {
61 *ImageBase = (UINTN)DebugTable->NormalImage->LoadedImageProtocolInstance->ImageBase;
62 *PeCoffSizeOfHeaders = PeCoffGetSizeOfHeaders ((VOID *)(UINTN)*ImageBase);
63 return PeCoffLoaderGetPdbPointer (DebugTable->NormalImage->LoadedImageProtocolInstance->ImageBase);
64 }
65 }
66 }
67 }
68
69 return NULL;
70}
UINT64 UINTN
CHAR8 * GetImageName(IN UINTN FaultAddress, OUT UINTN *ImageBase, OUT UINTN *PeCoffSizeOfHeaders)
#define NULL
Definition: Base.h:319
#define IN
Definition: Base.h:279
#define OUT
Definition: Base.h:284
RETURN_STATUS EFI_STATUS
Definition: UefiBaseType.h:29
EFI_STATUS EFIAPI EfiGetSystemConfigurationTable(IN EFI_GUID *TableGuid, OUT VOID **Table)
Definition: UefiLib.c:82
EFI_LOADED_IMAGE_PROTOCOL * LoadedImageProtocolInstance
EFI_DEBUG_IMAGE_INFO * EfiDebugImageInfoTable
UINT64 ImageSize
The size in bytes of the loaded image.
Definition: LoadedImage.h:68
VOID * ImageBase
The base address at which the image was loaded.
Definition: LoadedImage.h:67