-/**\r
- Find image record accroding to image base and size.\r
-\r
- @param[in] ImageBase Base of PE image\r
- @param[in] ImageSize Size of PE image\r
-\r
- @return image record\r
-**/\r
-STATIC\r
-IMAGE_PROPERTIES_RECORD *\r
-FindImageRecord (\r
- IN EFI_PHYSICAL_ADDRESS ImageBase,\r
- IN UINT64 ImageSize\r
- )\r
-{\r
- IMAGE_PROPERTIES_RECORD *ImageRecord;\r
- LIST_ENTRY *ImageRecordLink;\r
- LIST_ENTRY *ImageRecordList;\r
-\r
- ImageRecordList = &mImagePropertiesPrivateData.ImageRecordList;\r
-\r
- for (ImageRecordLink = ImageRecordList->ForwardLink;\r
- ImageRecordLink != ImageRecordList;\r
- ImageRecordLink = ImageRecordLink->ForwardLink) {\r
- ImageRecord = CR (\r
- ImageRecordLink,\r
- IMAGE_PROPERTIES_RECORD,\r
- Link,\r
- IMAGE_PROPERTIES_RECORD_SIGNATURE\r
- );\r
-\r
- if ((ImageBase == ImageRecord->ImageBase) &&\r
- (ImageSize == ImageRecord->ImageSize)) {\r
- return ImageRecord;\r
- }\r
- }\r
-\r
- return NULL;\r
-}\r
-\r
-/**\r
- Remove Image record.\r
-\r
- @param[in] DriverEntry Driver information\r
-**/\r
-VOID\r
-SmmRemoveImageRecord (\r
- IN EFI_SMM_DRIVER_ENTRY *DriverEntry\r
- )\r
-{\r
- IMAGE_PROPERTIES_RECORD *ImageRecord;\r
- LIST_ENTRY *CodeSegmentListHead;\r
- IMAGE_PROPERTIES_RECORD_CODE_SECTION *ImageRecordCodeSection;\r
-\r
- DEBUG ((DEBUG_VERBOSE, "SMM RemoveImageRecord - 0x%x\n", DriverEntry));\r
- DEBUG ((DEBUG_VERBOSE, "SMM RemoveImageRecord - 0x%016lx - 0x%016lx\n", DriverEntry->ImageBuffer, DriverEntry->NumberOfPage));\r
-\r
- ImageRecord = FindImageRecord (DriverEntry->ImageBuffer, EfiPagesToSize(DriverEntry->NumberOfPage));\r
- if (ImageRecord == NULL) {\r
- DEBUG ((DEBUG_ERROR, "SMM !!!!!!!! ImageRecord not found !!!!!!!!\n"));\r
- return ;\r
- }\r
-\r
- CodeSegmentListHead = &ImageRecord->CodeSegmentList;\r
- while (!IsListEmpty (CodeSegmentListHead)) {\r
- ImageRecordCodeSection = CR (\r
- CodeSegmentListHead->ForwardLink,\r
- IMAGE_PROPERTIES_RECORD_CODE_SECTION,\r
- Link,\r
- IMAGE_PROPERTIES_RECORD_CODE_SECTION_SIGNATURE\r
- );\r
- RemoveEntryList (&ImageRecordCodeSection->Link);\r
- FreePool (ImageRecordCodeSection);\r
- }\r
-\r
- RemoveEntryList (&ImageRecord->Link);\r
- FreePool (ImageRecord);\r
- mImagePropertiesPrivateData.ImageRecordCount--;\r
-}\r