Ring3: Added IsUserImage field into LOADED_IMAGE_PRIVATE_DATA structure.

This commit is contained in:
Mikhail Krichanov 2024-01-15 10:53:36 +03:00
parent cf83eed077
commit f2a28c5a55
4 changed files with 20 additions and 10 deletions

View File

@ -223,7 +223,8 @@ typedef struct {
/// Status returned by LoadImage() service. /// Status returned by LoadImage() service.
EFI_STATUS LoadImageStatus; EFI_STATUS LoadImageStatus;
VOID *HiiData; VOID *HiiData;
BOOLEAN IsUserImage;
} LOADED_IMAGE_PRIVATE_DATA; } LOADED_IMAGE_PRIVATE_DATA;
#define LOADED_IMAGE_PRIVATE_DATA_FROM_THIS(a) \ #define LOADED_IMAGE_PRIVATE_DATA_FROM_THIS(a) \
@ -2727,12 +2728,14 @@ RemoveImageRecord (
@param[in] LoadedImage The loaded image protocol @param[in] LoadedImage The loaded image protocol
@param[in] ImageOrigin Where File comes from. @param[in] ImageOrigin Where File comes from.
@param[in] LoadedImageDevicePath The loaded image device path protocol @param[in] LoadedImageDevicePath The loaded image device path protocol
@param[out] IsUserImage Whether the loaded image is in user space.
**/ **/
VOID VOID
ProtectUefiImage ( ProtectUefiImage (
IN EFI_LOADED_IMAGE_PROTOCOL *LoadedImage, IN EFI_LOADED_IMAGE_PROTOCOL *LoadedImage,
IN UINT8 ImageOrigin, IN UINT8 ImageOrigin,
UEFI_IMAGE_LOADER_IMAGE_CONTEXT *ImageContext IN UEFI_IMAGE_LOADER_IMAGE_CONTEXT *ImageContext,
OUT BOOLEAN *IsUserImage
); );
/** /**

View File

@ -324,7 +324,7 @@ DxeMain (
CoreInitializeMemoryProtection (); CoreInitializeMemoryProtection ();
ProtectUefiImage (&mCurrentImage->Info, UefiImageOriginFv, &ImageContext); ProtectUefiImage (&mCurrentImage->Info, UefiImageOriginFv, &ImageContext, &mCurrentImage->IsUserImage);
// //
// Call constructor for all libraries // Call constructor for all libraries

View File

@ -64,7 +64,10 @@ LOADED_IMAGE_PRIVATE_DATA mCorePrivateImage = {
0, // Machine 0, // Machine
NULL, // PeCoffEmu NULL, // PeCoffEmu
NULL, // RuntimeData NULL, // RuntimeData
NULL // LoadedImageDevicePath NULL, // LoadedImageDevicePath
EFI_SUCCESS, // LoadImageStatus
NULL, // HiiData
FALSE // IsUserImage
}; };
// //
// The field is define for Loading modules at fixed address feature to tracker the PEI code // The field is define for Loading modules at fixed address feature to tracker the PEI code
@ -1435,7 +1438,7 @@ CoreLoadImageCommon (
} }
Status = EFI_SUCCESS; Status = EFI_SUCCESS;
ProtectUefiImage (&Image->Info, ImageOrigin, &ImageContext); ProtectUefiImage (&Image->Info, ImageOrigin, &ImageContext, &Image->IsUserImage);
RegisterMemoryProfileImage ( RegisterMemoryProfileImage (
Image->LoadedImageDevicePath, Image->LoadedImageDevicePath,

View File

@ -168,12 +168,14 @@ IsMemoryProtectionSectionAligned (
@param[in] LoadedImage The loaded image protocol @param[in] LoadedImage The loaded image protocol
@param[in] ImageOrigin Where File comes from. @param[in] ImageOrigin Where File comes from.
@param[in] LoadedImageDevicePath The loaded image device path protocol @param[in] LoadedImageDevicePath The loaded image device path protocol
@param[out] IsUserImage Whether the loaded image is in user space.
**/ **/
VOID VOID
ProtectUefiImage ( ProtectUefiImage (
IN EFI_LOADED_IMAGE_PROTOCOL *LoadedImage, IN EFI_LOADED_IMAGE_PROTOCOL *LoadedImage,
IN UINT8 ImageOrigin, IN UINT8 ImageOrigin,
UEFI_IMAGE_LOADER_IMAGE_CONTEXT *ImageContext IN UEFI_IMAGE_LOADER_IMAGE_CONTEXT *ImageContext,
OUT BOOLEAN *IsUserImage
) )
{ {
RETURN_STATUS PdbStatus; RETURN_STATUS PdbStatus;
@ -234,8 +236,10 @@ ProtectUefiImage (
// //
if (AsciiStrStr (PdbPointer, "Ntfs") != NULL) { if (AsciiStrStr (PdbPointer, "Ntfs") != NULL) {
SetUefiImageProtectionAttributes (ImageRecord, TRUE); SetUefiImageProtectionAttributes (ImageRecord, TRUE);
*IsUserImage = TRUE;
} else { } else {
SetUefiImageProtectionAttributes (ImageRecord, FALSE); SetUefiImageProtectionAttributes (ImageRecord, FALSE);
*IsUserImage = FALSE;
} }
} }