EFI_IMAGE_DOS_HEADER BackupDosHdr;\r
ULONG Index;\r
ULONG Index1;\r
+ ULONG Index2;\r
+ ULONG Index3;\r
BOOLEAN TimeStampPresent;\r
UINTN AllignedRelocSize;\r
UINTN Delta;\r
EFI_IMAGE_SECTION_HEADER *SectionHeader;\r
UINT8 *FileBuffer;\r
UINTN FileLength;\r
+ RUNTIME_FUNCTION *RuntimeFunction;\r
+ UNWIND_INFO *UnwindInfo;\r
\r
SetUtilityName (UTILITY_NAME);\r
//\r
Optional32->SizeOfHeapReserve = 0;\r
Optional32->SizeOfHeapCommit = 0;\r
\r
- //\r
- // Zero the .pdata section if the machine type is X64 and the Debug Directoty entry is empty\r
- //\r
- if (PeHdr->FileHeader.Machine == 0x8664) { // X64\r
- if (Optional32->NumberOfRvaAndSizes >= 4) {\r
- if (Optional32->NumberOfRvaAndSizes < 7 || (Optional32->NumberOfRvaAndSizes >= 7 && Optional32->DataDirectory[6].Size == 0)) {\r
- SectionHeader = (EFI_IMAGE_SECTION_HEADER *)(FileBuffer + DosHdr->e_lfanew + sizeof(UINT32) + sizeof (EFI_IMAGE_FILE_HEADER) + PeHdr->FileHeader.SizeOfOptionalHeader);\r
- for (Index = 0; Index < PeHdr->FileHeader.NumberOfSections; Index++, SectionHeader++) {\r
- if (SectionHeader->VirtualAddress == Optional32->DataDirectory[3].VirtualAddress) {\r
- for (Index1 = 0; Index1 < Optional32->DataDirectory[3].Size; Index1++) {\r
- FileBuffer[SectionHeader->PointerToRawData + Index1] = 0;\r
- }\r
- }\r
- }\r
- Optional32->DataDirectory[3].Size = 0;\r
- Optional32->DataDirectory[3].VirtualAddress = 0;\r
- }\r
- }\r
- }\r
-\r
//\r
// Strip zero padding at the end of the .reloc section \r
//\r
SectionHeader = (EFI_IMAGE_SECTION_HEADER *)(FileBuffer + DosHdr->e_lfanew + sizeof(UINT32) + sizeof (EFI_IMAGE_FILE_HEADER) + PeHdr->FileHeader.SizeOfOptionalHeader);\r
for (Index = 0; Index < PeHdr->FileHeader.NumberOfSections; Index++, SectionHeader++) {\r
if (SectionHeader->VirtualAddress == Optional64->DataDirectory[3].VirtualAddress) {\r
- for (Index1 = 0; Index1 < Optional64->DataDirectory[3].Size; Index1++) {\r
- FileBuffer[SectionHeader->PointerToRawData + Index1] = 0;\r
+ RuntimeFunction = (RUNTIME_FUNCTION *)(FileBuffer + SectionHeader->PointerToRawData);\r
+ for (Index1 = 0; Index1 < Optional64->DataDirectory[3].Size / sizeof (RUNTIME_FUNCTION); Index1++, RuntimeFunction++) {\r
+ SectionHeader = (EFI_IMAGE_SECTION_HEADER *)(FileBuffer + DosHdr->e_lfanew + sizeof(UINT32) + sizeof (EFI_IMAGE_FILE_HEADER) + PeHdr->FileHeader.SizeOfOptionalHeader);\r
+ for (Index2 = 0; Index2 < PeHdr->FileHeader.NumberOfSections; Index2++, SectionHeader++) {\r
+ if (RuntimeFunction->UnwindInfoAddress > SectionHeader->VirtualAddress && RuntimeFunction->UnwindInfoAddress < (SectionHeader->VirtualAddress + SectionHeader->SizeOfRawData)) {\r
+ UnwindInfo = (UNWIND_INFO *)(FileBuffer + SectionHeader->PointerToRawData + (RuntimeFunction->UnwindInfoAddress - SectionHeader->VirtualAddress));\r
+ if (UnwindInfo->Version == 1) {\r
+ memset (UnwindInfo + 1, 0, UnwindInfo->CountOfUnwindCodes * sizeof (UINT16));\r
+ memset (UnwindInfo, 0, sizeof (UNWIND_INFO));\r
+ }\r
+ }\r
+ }\r
+ memset (RuntimeFunction, 0, sizeof (RUNTIME_FUNCTION));\r
}\r
}\r
}\r