20#define PREVIOUS_MEMORY_DESCRIPTOR(MemoryDescriptor, Size) \
21 ((EFI_MEMORY_DESCRIPTOR *)((UINT8 *)(MemoryDescriptor) - (Size)))
23#define NEXT_MEMORY_DESCRIPTOR(MemoryDescriptor, Size) \
24 ((EFI_MEMORY_DESCRIPTOR *)((UINT8 *)(MemoryDescriptor) + (Size)))
60 return RShiftU64 (Size, EFI_PAGE_SHIFT) + ((((
UINTN)Size) & EFI_PAGE_MASK) ? 1 : 0);
79 if (ImageRecord ==
NULL) {
83 CodeSegmentListHead = &ImageRecord->CodeSegmentList;
85 ImageRecordCodeSection =
CR (
86 CodeSegmentListHead->ForwardLink,
89 IMAGE_PROPERTIES_RECORD_CODE_SECTION_SIGNATURE
117 MemoryMapEntry = MemoryMap;
118 NextMemoryMapEntry = NEXT_MEMORY_DESCRIPTOR (MemoryMapEntry, DescriptorSize);
120 while (MemoryMapEntry < MemoryMapEnd) {
121 while (NextMemoryMapEntry < MemoryMapEnd) {
128 NextMemoryMapEntry = NEXT_MEMORY_DESCRIPTOR (NextMemoryMapEntry, DescriptorSize);
131 MemoryMapEntry = NEXT_MEMORY_DESCRIPTOR (MemoryMapEntry, DescriptorSize);
132 NextMemoryMapEntry = NEXT_MEMORY_DESCRIPTOR (MemoryMapEntry, DescriptorSize);
159 for (ImageRecordLink = ImageRecordList->ForwardLink;
160 ImageRecordLink != ImageRecordList;
161 ImageRecordLink = ImageRecordLink->ForwardLink)
167 IMAGE_PROPERTIES_RECORD_SIGNATURE
170 if ((Buffer <= ImageRecord->ImageBase) &&
171 (Buffer + Length >= ImageRecord->ImageBase + ImageRecord->ImageSize))
209 UINTN NewRecordCount;
217 ImageRecordCodeSectionList = &ImageRecord->CodeSegmentList;
219 ImageRecordCodeSectionLink = ImageRecordCodeSectionList->ForwardLink;
220 ImageRecordCodeSectionEndLink = ImageRecordCodeSectionList;
221 while (ImageRecordCodeSectionLink != ImageRecordCodeSectionEndLink) {
222 ImageRecordCodeSection =
CR (
223 ImageRecordCodeSectionLink,
226 IMAGE_PROPERTIES_RECORD_CODE_SECTION_SIGNATURE
228 ImageRecordCodeSectionLink = ImageRecordCodeSectionLink->ForwardLink;
230 if (TempRecord.
PhysicalStart <= ImageRecordCodeSection->CodeSegmentBase) {
234 NewRecord->Type = TempRecord.
Type;
236 NewRecord->VirtualStart = 0;
237 NewRecord->NumberOfPages =
EfiSizeToPages (ImageRecordCodeSection->CodeSegmentBase - NewRecord->PhysicalStart);
238 NewRecord->Attribute = TempRecord.
Attribute | EFI_MEMORY_XP;
239 if (NewRecord->NumberOfPages != 0) {
240 NewRecord = NEXT_MEMORY_DESCRIPTOR (NewRecord, DescriptorSize);
247 NewRecord->Type = TempRecord.
Type;
248 NewRecord->PhysicalStart = ImageRecordCodeSection->CodeSegmentBase;
249 NewRecord->VirtualStart = 0;
250 NewRecord->NumberOfPages =
EfiSizeToPages (ImageRecordCodeSection->CodeSegmentSize);
251 NewRecord->Attribute = (TempRecord.
Attribute & (~EFI_MEMORY_XP)) | EFI_MEMORY_RO;
252 if (NewRecord->NumberOfPages != 0) {
253 NewRecord = NEXT_MEMORY_DESCRIPTOR (NewRecord, DescriptorSize);
265 ImageEnd = ImageRecord->ImageBase + ImageRecord->ImageSize;
271 NewRecord->Type = TempRecord.
Type;
273 NewRecord->VirtualStart = 0;
275 NewRecord->Attribute = TempRecord.
Attribute | EFI_MEMORY_XP;
279 return NewRecordCount;
302 UINTN SplitRecordCount;
303 UINT64 PhysicalStart;
306 SplitRecordCount = 0;
307 PhysicalStart = OldRecord->PhysicalStart;
308 PhysicalEnd = OldRecord->PhysicalStart +
EfiPagesToSize (OldRecord->NumberOfPages);
312 if (ImageRecord ==
NULL) {
316 SplitRecordCount += (2 * ImageRecord->CodeSegmentCount + 3);
317 PhysicalStart = ImageRecord->ImageBase + ImageRecord->ImageSize;
318 }
while ((ImageRecord !=
NULL) && (PhysicalStart < PhysicalEnd));
320 if (SplitRecordCount != 0) {
324 return SplitRecordCount;
356 UINT64 PhysicalStart;
358 UINTN NewRecordCount;
359 UINTN TotalNewRecordCount;
361 if (MaxSplitRecordCount == 0) {
362 CopyMem (NewRecord, OldRecord, DescriptorSize);
366 TotalNewRecordCount = 0;
378 if (NewImageRecord ==
NULL) {
383 if (PhysicalEnd > PhysicalStart) {
384 NewRecord->Type = TempRecord.
Type;
385 NewRecord->PhysicalStart = PhysicalStart;
386 NewRecord->VirtualStart = 0;
387 NewRecord->NumberOfPages =
EfiSizeToPages (PhysicalEnd - PhysicalStart);
388 NewRecord->Attribute = TempRecord.
Attribute;
389 TotalNewRecordCount++;
395 ImageRecord = NewImageRecord;
401 NewRecord->Type = TempRecord.
Type;
403 NewRecord->VirtualStart = 0;
405 NewRecord->Attribute = TempRecord.
Attribute;
406 TotalNewRecordCount++;
408 PhysicalStart = ImageRecord->ImageBase;
418 NewRecordCount =
SetNewRecord (ImageRecord, NewRecord, &TempRecord, DescriptorSize);
419 TotalNewRecordCount += NewRecordCount;
425 PhysicalStart = ImageRecord->ImageBase + ImageRecord->ImageSize;
428 }
while ((ImageRecord !=
NULL) && (PhysicalStart < PhysicalEnd));
434 ASSERT (TotalNewRecordCount != 0);
435 return TotalNewRecordCount - 1;
486 IN UINTN NumberOfAdditionalDescriptors
491 INTN IndexNewStarting;
492 UINTN MaxSplitRecordCount;
493 UINTN RealSplitRecordCount;
494 UINTN TotalSkippedRecords;
496 if ((MemoryMapSize ==
NULL) || (MemoryMap ==
NULL) || (ImageRecordList ==
NULL)) {
497 return EFI_INVALID_PARAMETER;
500 TotalSkippedRecords = 0;
504 IndexOld = ((*MemoryMapSize) / DescriptorSize) - 1;
508 IndexNew = ((*MemoryMapSize) / DescriptorSize) - 1 + NumberOfAdditionalDescriptors;
509 IndexNewStarting = IndexNew;
510 for ( ; IndexOld >= 0; IndexOld--) {
515 IndexNew -= MaxSplitRecordCount;
526 for ( ; RealSplitRecordCount < MaxSplitRecordCount; RealSplitRecordCount++) {
528 TotalSkippedRecords++;
539 (UINT8 *)MemoryMap + ((IndexNew + 1) * DescriptorSize),
540 (IndexNewStarting - IndexNew) * DescriptorSize
546 SortMemoryMap (MemoryMap, (IndexNewStarting - IndexNew) * DescriptorSize, DescriptorSize);
548 *MemoryMapSize = (IndexNewStarting - IndexNew - TotalSkippedRecords) * DescriptorSize;
571 if ((FirstImageRecordCodeSection ==
NULL) || (SecondImageRecordCodeSection ==
NULL)) {
572 return EFI_INVALID_PARAMETER;
575 TempImageRecordCodeSection.CodeSegmentBase = FirstImageRecordCodeSection->CodeSegmentBase;
576 TempImageRecordCodeSection.CodeSegmentSize = FirstImageRecordCodeSection->CodeSegmentSize;
578 FirstImageRecordCodeSection->CodeSegmentBase = SecondImageRecordCodeSection->CodeSegmentBase;
579 FirstImageRecordCodeSection->CodeSegmentSize = SecondImageRecordCodeSection->CodeSegmentSize;
581 SecondImageRecordCodeSection->CodeSegmentBase = TempImageRecordCodeSection.CodeSegmentBase;
582 SecondImageRecordCodeSection->CodeSegmentSize = TempImageRecordCodeSection.CodeSegmentSize;
610 if (ImageRecord ==
NULL) {
611 return EFI_INVALID_PARAMETER;
614 ImageRecordCodeSectionList = &ImageRecord->CodeSegmentList;
616 ImageRecordCodeSectionLink = ImageRecordCodeSectionList->ForwardLink;
617 NextImageRecordCodeSectionLink = ImageRecordCodeSectionLink->ForwardLink;
618 ImageRecordCodeSectionEndLink = ImageRecordCodeSectionList;
619 while (ImageRecordCodeSectionLink != ImageRecordCodeSectionEndLink) {
620 ImageRecordCodeSection =
CR (
621 ImageRecordCodeSectionLink,
624 IMAGE_PROPERTIES_RECORD_CODE_SECTION_SIGNATURE
626 while (NextImageRecordCodeSectionLink != ImageRecordCodeSectionEndLink) {
627 NextImageRecordCodeSection =
CR (
628 NextImageRecordCodeSectionLink,
631 IMAGE_PROPERTIES_RECORD_CODE_SECTION_SIGNATURE
633 if (ImageRecordCodeSection->CodeSegmentBase > NextImageRecordCodeSection->CodeSegmentBase) {
635 if (EFI_ERROR (Status)) {
641 NextImageRecordCodeSectionLink = NextImageRecordCodeSectionLink->ForwardLink;
644 ImageRecordCodeSectionLink = ImageRecordCodeSectionLink->ForwardLink;
645 NextImageRecordCodeSectionLink = ImageRecordCodeSectionLink->ForwardLink;
674 if (ImageRecord ==
NULL) {
678 DEBUG ((DEBUG_VERBOSE,
"ImageCode SegmentCount - 0x%x\n", ImageRecord->CodeSegmentCount));
680 ImageRecordCodeSectionList = &ImageRecord->CodeSegmentList;
682 ImageRecordCodeSectionLink = ImageRecordCodeSectionList->ForwardLink;
683 ImageRecordCodeSectionEndLink = ImageRecordCodeSectionList;
684 LastImageRecordCodeSection =
NULL;
685 while (ImageRecordCodeSectionLink != ImageRecordCodeSectionEndLink) {
686 ImageRecordCodeSection =
CR (
687 ImageRecordCodeSectionLink,
690 IMAGE_PROPERTIES_RECORD_CODE_SECTION_SIGNATURE
692 if (ImageRecordCodeSection->CodeSegmentSize == 0) {
696 if (ImageRecordCodeSection->CodeSegmentBase < ImageRecord->ImageBase) {
700 if (ImageRecordCodeSection->CodeSegmentBase >=
MAX_ADDRESS - ImageRecordCodeSection->CodeSegmentSize) {
704 if ((ImageRecordCodeSection->CodeSegmentBase + ImageRecordCodeSection->CodeSegmentSize) > (ImageRecord->ImageBase + ImageRecord->ImageSize)) {
708 if (LastImageRecordCodeSection !=
NULL) {
709 if ((LastImageRecordCodeSection->CodeSegmentBase + LastImageRecordCodeSection->CodeSegmentSize) > ImageRecordCodeSection->CodeSegmentBase) {
714 LastImageRecordCodeSection = ImageRecordCodeSection;
715 ImageRecordCodeSectionLink = ImageRecordCodeSectionLink->ForwardLink;
739 if ((FirstImageRecord ==
NULL) || (SecondImageRecord ==
NULL)) {
740 return EFI_INVALID_PARAMETER;
743 TempImageRecord.ImageBase = FirstImageRecord->ImageBase;
744 TempImageRecord.ImageSize = FirstImageRecord->ImageSize;
745 TempImageRecord.CodeSegmentCount = FirstImageRecord->CodeSegmentCount;
747 FirstImageRecord->ImageBase = SecondImageRecord->ImageBase;
748 FirstImageRecord->ImageSize = SecondImageRecord->ImageSize;
749 FirstImageRecord->CodeSegmentCount = SecondImageRecord->CodeSegmentCount;
751 SecondImageRecord->ImageBase = TempImageRecord.ImageBase;
752 SecondImageRecord->ImageSize = TempImageRecord.ImageSize;
753 SecondImageRecord->CodeSegmentCount = TempImageRecord.CodeSegmentCount;
755 SwapListEntries (&FirstImageRecord->CodeSegmentList, &SecondImageRecord->CodeSegmentList);
781 if (ImageRecordList ==
NULL) {
782 return EFI_INVALID_PARAMETER;
785 ImageRecordLink = ImageRecordList->ForwardLink;
786 NextImageRecordLink = ImageRecordLink->ForwardLink;
787 ImageRecordEndLink = ImageRecordList;
788 while (ImageRecordLink != ImageRecordEndLink) {
793 IMAGE_PROPERTIES_RECORD_SIGNATURE
795 while (NextImageRecordLink != ImageRecordEndLink) {
796 NextImageRecord =
CR (
800 IMAGE_PROPERTIES_RECORD_SIGNATURE
803 if (ImageRecord->ImageBase > NextImageRecord->ImageBase) {
805 if (EFI_ERROR (Status)) {
811 NextImageRecordLink = NextImageRecordLink->ForwardLink;
814 ImageRecordLink = ImageRecordLink->ForwardLink;
815 NextImageRecordLink = ImageRecordLink->ForwardLink;
831 IN CHAR8 *PdbPointer,
832 OUT CHAR8 *EfiFileName,
839 if ((PdbPointer ==
NULL) || (EfiFileNameSize < 5)) {
845 for (Index = 0; PdbPointer[Index] != 0; Index++) {
846 if ((PdbPointer[Index] ==
'\\') || (PdbPointer[Index] ==
'/')) {
847 StartIndex = Index + 1;
852 for (Index = 0; Index < EfiFileNameSize - 4; Index++) {
853 EfiFileName[Index] = PdbPointer[Index + StartIndex];
854 if (EfiFileName[Index] == 0) {
855 EfiFileName[Index] =
'.';
858 if (EfiFileName[Index] ==
'.') {
859 EfiFileName[Index + 1] =
'e';
860 EfiFileName[Index + 2] =
'f';
861 EfiFileName[Index + 3] =
'i';
862 EfiFileName[Index + 4] = 0;
867 if (Index ==
sizeof (EfiFileName) - 4) {
868 EfiFileName[Index] = 0;
888 CHAR8 EfiFileName[256];
890 if (ImageRecordList ==
NULL) {
894 ImageRecordLink = ImageRecordList->ForwardLink;
896 while (ImageRecordLink != ImageRecordList) {
897 CurrentImageRecord =
CR (
901 IMAGE_PROPERTIES_RECORD_SIGNATURE
904 PdbPointer = PeCoffLoaderGetPdbPointer ((VOID *)(
UINTN)CurrentImageRecord->ImageBase);
905 if (PdbPointer !=
NULL) {
906 GetFilename (PdbPointer, EfiFileName,
sizeof (EfiFileName));
909 "%a: 0x%llx - 0x%llx\n",
911 CurrentImageRecord->ImageBase,
912 CurrentImageRecord->ImageBase + CurrentImageRecord->ImageSize
917 "Unknown Image: 0x%llx - 0x%llx\n",
918 CurrentImageRecord->ImageBase,
919 CurrentImageRecord->ImageBase + CurrentImageRecord->ImageSize
923 CodeSectionLink = CurrentImageRecord->CodeSegmentList.ForwardLink;
925 while (CodeSectionLink != &CurrentImageRecord->CodeSegmentList) {
926 CurrentCodeSection =
CR (
930 IMAGE_PROPERTIES_RECORD_CODE_SECTION_SIGNATURE
935 " Code Section: 0x%llx - 0x%llx\n",
936 CurrentCodeSection->CodeSegmentBase,
937 CurrentCodeSection->CodeSegmentBase + CurrentCodeSection->CodeSegmentSize
940 CodeSectionLink = CodeSectionLink->ForwardLink;
943 ImageRecordLink = ImageRecordLink->ForwardLink;
969 if (ImageRecordList ==
NULL) {
973 for (ImageRecordLink = ImageRecordList->ForwardLink;
974 ImageRecordLink != ImageRecordList;
975 ImageRecordLink = ImageRecordLink->ForwardLink)
981 IMAGE_PROPERTIES_RECORD_SIGNATURE
984 if ((ImageBase == ImageRecord->ImageBase) &&
985 (ImageSize == ImageRecord->ImageSize))
1016 IN CONST UINT32 *RequiredAlignment OPTIONAL,
1027 UINT32 SectionAlignment;
1028 UINT32 PeCoffHeaderOffset;
1031 if ((ImageRecord ==
NULL) || (ImageBase ==
NULL)) {
1032 return EFI_INVALID_PARAMETER;
1037 "Creating Image Properties Record: 0x%016lx - 0x%016lx\n",
1046 ImageRecord->Signature = IMAGE_PROPERTIES_RECORD_SIGNATURE;
1048 ImageRecord->ImageSize = ImageSize;
1049 ImageRecord->CodeSegmentCount = 0;
1053 PdbPointer = PeCoffLoaderGetPdbPointer ((VOID *)(
UINTN)ImageBase);
1054 if (PdbPointer !=
NULL) {
1055 DEBUG ((DEBUG_VERBOSE,
" Image - %a\n", PdbPointer));
1060 PeCoffHeaderOffset = 0;
1061 if (DosHdr->
e_magic == EFI_IMAGE_DOS_SIGNATURE) {
1062 PeCoffHeaderOffset = DosHdr->
e_lfanew;
1066 if (Hdr.Pe32->Signature != EFI_IMAGE_NT_SIGNATURE) {
1067 DEBUG ((DEBUG_VERBOSE,
"Hdr.Pe32->Signature invalid - 0x%x\n", Hdr.Pe32->Signature));
1068 return EFI_INVALID_PARAMETER;
1073 SectionAlignment = Hdr.Pe32->OptionalHeader.SectionAlignment;
1075 SectionAlignment = Hdr.Pe32Plus->OptionalHeader.SectionAlignment;
1079 if ((RequiredAlignment !=
NULL) && ((SectionAlignment & (*RequiredAlignment - 1)) != 0)) {
1082 "!!!!!!!! Image Section Alignment(0x%x) does not match Required Alignment (0x%x) !!!!!!!!\n",
1091 (UINT8 *)(
UINTN)ImageBase +
1092 PeCoffHeaderOffset +
1095 Hdr.Pe32->FileHeader.SizeOfOptionalHeader
1097 for (Index = 0; Index < Hdr.Pe32->FileHeader.NumberOfSections; Index++) {
1098 Name = Section[Index].Name;
1101 " Section - '%c%c%c%c%c%c%c%c'\n",
1113 DEBUG ((DEBUG_VERBOSE,
" VirtualSize - 0x%08x\n", Section[Index].Misc.VirtualSize));
1114 DEBUG ((DEBUG_VERBOSE,
" VirtualAddress - 0x%08x\n", Section[Index].VirtualAddress));
1115 DEBUG ((DEBUG_VERBOSE,
" SizeOfRawData - 0x%08x\n", Section[Index].SizeOfRawData));
1116 DEBUG ((DEBUG_VERBOSE,
" PointerToRawData - 0x%08x\n", Section[Index].PointerToRawData));
1117 DEBUG ((DEBUG_VERBOSE,
" PointerToRelocations - 0x%08x\n", Section[Index].PointerToRelocations));
1118 DEBUG ((DEBUG_VERBOSE,
" PointerToLinenumbers - 0x%08x\n", Section[Index].PointerToLinenumbers));
1119 DEBUG ((DEBUG_VERBOSE,
" NumberOfRelocations - 0x%08x\n", Section[Index].NumberOfRelocations));
1120 DEBUG ((DEBUG_VERBOSE,
" NumberOfLinenumbers - 0x%08x\n", Section[Index].NumberOfLinenumbers));
1121 DEBUG ((DEBUG_VERBOSE,
" Characteristics - 0x%08x\n", Section[Index].Characteristics));
1124 ImageRecordCodeSection =
AllocatePool (
sizeof (*ImageRecordCodeSection));
1125 if (ImageRecordCodeSection ==
NULL) {
1126 Status = EFI_OUT_OF_RESOURCES;
1127 goto CreateImagePropertiesRecordEnd;
1130 ImageRecordCodeSection->Signature = IMAGE_PROPERTIES_RECORD_CODE_SECTION_SIGNATURE;
1132 ImageRecordCodeSection->CodeSegmentBase = (
UINTN)ImageBase + Section[Index].VirtualAddress;
1135 ImageRecordCodeSection->CodeSegmentSize =
ALIGN_VALUE (Section[Index].Misc.VirtualSize, SectionAlignment);
1137 InsertTailList (&ImageRecord->CodeSegmentList, &ImageRecordCodeSection->Link);
1138 ImageRecord->CodeSegmentCount++;
1142 if (ImageRecord->CodeSegmentCount > 0) {
1150 DEBUG ((DEBUG_ERROR,
"IsImageRecordCodeSectionValid - FAIL\n"));
1151 Status = EFI_INVALID_PARAMETER;
1152 goto CreateImagePropertiesRecordEnd;
1159 ImageRecord->ImageSize =
ALIGN_VALUE (ImageRecord->ImageSize, EFI_PAGE_SIZE);
1161CreateImagePropertiesRecordEnd:
1162 if (EFI_ERROR (Status)) {
BOOLEAN EFIAPI IsListEmpty(IN CONST LIST_ENTRY *ListHead)
LIST_ENTRY *EFIAPI SwapListEntries(IN OUT LIST_ENTRY *FirstEntry, IN OUT LIST_ENTRY *SecondEntry)
LIST_ENTRY *EFIAPI RemoveEntryList(IN CONST LIST_ENTRY *Entry)
UINT64 EFIAPI RShiftU64(IN UINT64 Operand, IN UINTN Count)
LIST_ENTRY *EFIAPI InitializeListHead(IN OUT LIST_ENTRY *ListHead)
UINT64 EFIAPI LShiftU64(IN UINT64 Operand, IN UINTN Count)
LIST_ENTRY *EFIAPI InsertTailList(IN OUT LIST_ENTRY *ListHead, IN OUT LIST_ENTRY *Entry)
VOID *EFIAPI CopyMem(OUT VOID *DestinationBuffer, IN CONST VOID *SourceBuffer, IN UINTN Length)
VOID EFIAPI FreePool(IN VOID *Buffer)
EFI_STATUS EFIAPI SwapImageRecord(IN IMAGE_PROPERTIES_RECORD *FirstImageRecord, IN IMAGE_PROPERTIES_RECORD *SecondImageRecord)
STATIC UINTN GetMaxSplitRecordCount(IN EFI_MEMORY_DESCRIPTOR *OldRecord, IN LIST_ENTRY *ImageRecordList)
EFI_STATUS EFIAPI SplitTable(IN OUT UINTN *MemoryMapSize, IN OUT EFI_MEMORY_DESCRIPTOR *MemoryMap, IN UINTN DescriptorSize, IN LIST_ENTRY *ImageRecordList, IN UINTN NumberOfAdditionalDescriptors)
STATIC VOID FreeImageRecordCodeSections(IMAGE_PROPERTIES_RECORD *ImageRecord)
VOID EFIAPI DeleteImagePropertiesRecord(IN IMAGE_PROPERTIES_RECORD *ImageRecord)
EFI_STATUS EFIAPI CreateImagePropertiesRecord(IN CONST VOID *ImageBase, IN CONST UINT64 ImageSize, IN CONST UINT32 *RequiredAlignment OPTIONAL, OUT IMAGE_PROPERTIES_RECORD *ImageRecord)
EFI_STATUS EFIAPI SwapImageRecordCodeSection(IN IMAGE_PROPERTIES_RECORD_CODE_SECTION *FirstImageRecordCodeSection, IN IMAGE_PROPERTIES_RECORD_CODE_SECTION *SecondImageRecordCodeSection)
STATIC IMAGE_PROPERTIES_RECORD * GetImageRecordByAddress(IN EFI_PHYSICAL_ADDRESS Buffer, IN UINT64 Length, IN LIST_ENTRY *ImageRecordList)
STATIC UINT64 EfiPagesToSize(IN UINT64 Pages)
BOOLEAN EFIAPI IsImageRecordCodeSectionValid(IN IMAGE_PROPERTIES_RECORD *ImageRecord)
STATIC UINTN SplitRecord(IN EFI_MEMORY_DESCRIPTOR *OldRecord, IN OUT EFI_MEMORY_DESCRIPTOR *NewRecord, IN UINTN MaxSplitRecordCount, IN UINTN DescriptorSize, IN LIST_ENTRY *ImageRecordList)
IMAGE_PROPERTIES_RECORD *EFIAPI FindImageRecord(IN EFI_PHYSICAL_ADDRESS ImageBase, IN UINT64 ImageSize, IN LIST_ENTRY *ImageRecordList)
STATIC UINTN SetNewRecord(IN IMAGE_PROPERTIES_RECORD *ImageRecord, IN OUT EFI_MEMORY_DESCRIPTOR *NewRecord, IN EFI_MEMORY_DESCRIPTOR *OldRecord, IN UINTN DescriptorSize)
STATIC VOID GetFilename(IN CHAR8 *PdbPointer, OUT CHAR8 *EfiFileName, IN UINTN EfiFileNameSize)
VOID EFIAPI DumpImageRecords(IN LIST_ENTRY *ImageRecordList)
STATIC UINT64 EfiSizeToPages(IN UINT64 Size)
STATIC VOID SortMemoryMap(IN OUT EFI_MEMORY_DESCRIPTOR *MemoryMap, IN UINTN MemoryMapSize, IN UINTN DescriptorSize)
EFI_STATUS EFIAPI SortImageRecord(IN LIST_ENTRY *ImageRecordList)
EFI_STATUS EFIAPI SortImageRecordCodeSection(IN IMAGE_PROPERTIES_RECORD *ImageRecord)
#define ALIGN_VALUE(Value, Alignment)
#define ASSERT_EFI_ERROR(StatusParameter)
#define DEBUG(Expression)
#define CR(Record, TYPE, Field, TestSignature)
#define EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC
#define EFI_IMAGE_SCN_CNT_CODE
0x00000020
VOID *EFIAPI AllocatePool(IN UINTN AllocationSize)
UINT64 EFI_PHYSICAL_ADDRESS
UINT32 e_lfanew
File address of new exe header.
UINT16 e_magic
Magic number.
EFI_PHYSICAL_ADDRESS PhysicalStart