diff --git a/MdeModulePkg/Application/SmiHandlerProfileInfo/SmiHandlerProfileInfo.c b/MdeModulePkg/Application/SmiHandlerProfileInfo/SmiHandlerProfileInfo.c index 2419cd2959..338671374c 100644 --- a/MdeModulePkg/Application/SmiHandlerProfileInfo/SmiHandlerProfileInfo.c +++ b/MdeModulePkg/Application/SmiHandlerProfileInfo/SmiHandlerProfileInfo.c @@ -266,8 +266,8 @@ GetDriverNameString ( // // Method 1: Get the name string from image PDB // - if (ImageStruct->Header.Length > sizeof (SMM_CORE_IMAGE_DATABASE_STRUCTURE)) { - GetShortPdbFileName ((CHAR8 *) (ImageStruct + 1), mNameString); + if (ImageStruct->PdbStringOffset != 0) { + GetShortPdbFileName ((CHAR8 *) ((UINTN) ImageStruct + ImageStruct->PdbStringOffset), mNameString); return mNameString; } @@ -355,8 +355,10 @@ DumpSmmLoadedImage( Print(L" FvFile=\"%g\"", &ImageStruct->FileGuid); Print(L" RefId=\"0x%x\"", ImageStruct->ImageRef); Print(L">\n"); - PdbString = (CHAR8 *)((UINTN)ImageStruct + ImageStruct->PdbStringOffset); - Print(L" %a\n", PdbString); + if (ImageStruct->PdbStringOffset != 0) { + PdbString = (CHAR8 *)((UINTN)ImageStruct + ImageStruct->PdbStringOffset); + Print(L" %a\n", PdbString); + } Print(L" \n"); } diff --git a/MdeModulePkg/Core/PiSmmCore/SmiHandlerProfile.c b/MdeModulePkg/Core/PiSmmCore/SmiHandlerProfile.c index 63dcf6e3a1..49eba945fd 100644 --- a/MdeModulePkg/Core/PiSmmCore/SmiHandlerProfile.c +++ b/MdeModulePkg/Core/PiSmmCore/SmiHandlerProfile.c @@ -651,8 +651,12 @@ GetSmmImageDatabaseData ( ImageStruct->EntryPoint = mImageStruct[Index].EntryPoint; ImageStruct->ImageBase = mImageStruct[Index].ImageBase; ImageStruct->ImageSize = mImageStruct[Index].ImageSize; - ImageStruct->PdbStringOffset = sizeof(SMM_CORE_IMAGE_DATABASE_STRUCTURE); - CopyMem ((VOID *)((UINTN)ImageStruct + ImageStruct->PdbStringOffset), mImageStruct[Index].PdbString, mImageStruct[Index].PdbStringSize); + if (mImageStruct[Index].PdbStringSize != 0) { + ImageStruct->PdbStringOffset = sizeof(SMM_CORE_IMAGE_DATABASE_STRUCTURE); + CopyMem ((VOID *)((UINTN)ImageStruct + ImageStruct->PdbStringOffset), mImageStruct[Index].PdbString, mImageStruct[Index].PdbStringSize); + } else { + ImageStruct->PdbStringOffset = 0; + } ImageStruct = (SMM_CORE_IMAGE_DATABASE_STRUCTURE *)((UINTN)ImageStruct + ImageStruct->Header.Length); Size += sizeof(SMM_CORE_IMAGE_DATABASE_STRUCTURE) + mImageStruct[Index].PdbStringSize; }