def toDictionary()

in UefiTestingPkg/AuditTests/PagingAudit/Windows/MemoryRangeObjects.py [0:0]


    def toDictionary(self):
        # Pre-process the Section Type
        # Set a reasonable default.
        section_type = "UNEXPECTED VALUE"
        # If there are no attributes, we're done.
        if not self.Attribute:
            section_type = "Not Tracked"
        else:
            attribute_names = MemoryRange.attributes_to_flags(self.Attribute)
            # If the attributes are both XP and RO, that's not good.
            if "EFI_MEMORY_XP" in attribute_names and "EFI_MEMORY_RO" in attribute_names:
                section_type = "ERROR"
            elif "EFI_MEMORY_XP" in attribute_names:
                section_type = "DATA"
            elif "EFI_MEMORY_RO" in attribute_names:
                section_type = "CODE"

        return {
            "Page Size" : self.getPageSizeStr(),
            "Read/Write" : "Enabled" if (self.ReadWrite == 1) else "Disabled",
            "Execute" : "Disabled" if (self.Nx == 1) else "Enabled",
            "Privilege" : "User" if (self.UserPrivilege == 1) else "Supervisor",
            "Start" : "0x{0:010X}".format(self.PhysicalStart),
            "End" : "0x{0:010X}".format(self.PhysicalEnd),
            "Number of Entries" : self.NumberOfEntries if (not self.PageSplit) else str(self.NumberOfEntries) + " (p)" ,
            "Memory Type" : self.GetMemoryTypeDescription(),
            "Section Type" : section_type,
            "System Memory": self.GetSystemMemoryType(),
            "Memory Contents" : self.ImageName,
            "Partial Page": self.PageSplit}