Esempio n. 1
0
	def notify_protocol(self, handle, protocol, interface, from_hook):
		for (event_id, event_dic) in self.ql.loader.events.items():
			if event_dic['Guid'] == protocol:
				if event_dic['CallbackArgs'] == None:
					# To support smm notification, we use None for CallbackArgs on SmmRegisterProtocolNotify 
					# and updare it here.
					guid = str_to_guid(protocol)
					guid_ptr = self.heap.alloc(guid.sizeof())
					guid.saveTo(self.ql, guid_ptr)
					event_dic['CallbackArgs'] = [guid_ptr, interface, handle]
				# The event was previously registered by 'RegisterProtocolNotify'.
				signal_event(self.ql, event_id)
		return execute_protocol_notifications(self.ql, from_hook)
Esempio n. 2
0
    def find(self, guid: str) -> Optional[int]:
        ptr = self.baseptr
        nitems = self.nitems
        efi_guid = utils.str_to_guid(guid)

        for _ in range(nitems):
            entry = EFI_CONFIGURATION_TABLE.loadFrom(self.ql, ptr)

            if utils.CompareGuid(entry.VendorGuid, efi_guid):
                return ptr

            ptr += EFI_CONFIGURATION_TABLE.sizeof()

        return None
Esempio n. 3
0
    def install(self, guid: str, table: int):
        ptr = self.find(guid)
        append = ptr is None

        if append:
            ptr = self.baseptr + self.nitems * EFI_CONFIGURATION_TABLE.sizeof()
            append = True

        instance = EFI_CONFIGURATION_TABLE()
        instance.VendorGuid = utils.str_to_guid(guid)
        instance.VendorTable = table
        instance.saveTo(self.ql, ptr)

        if append:
            self.nitems += 1
Esempio n. 4
0
	def install_configuration_table(self, guid: str, table: int):
		guid = guid.lower()
		confs = self.conf_table_array

		# find configuration table entry by guid. if found, idx would be set to the entry index
		# in the array. if not, idx would be set to one past end of array
		if guid not in confs:
			confs.append(guid)

		idx = confs.index(guid)
		ptr = self.conf_table_array_ptr + (idx * EFI_CONFIGURATION_TABLE.sizeof())

		instance = EFI_CONFIGURATION_TABLE()
		instance.VendorGuid = str_to_guid(guid)
		instance.VendorTable = table
		instance.saveTo(self.ql, ptr)
Esempio n. 5
0
def GetNextGuidHob(ql: Qiling, guid: str, hoblist: int) -> int:
    """Find next HOB with the specified GUID.
	"""

    hobguid = str_to_guid(guid)
    hobaddr = hoblist

    while True:
        hobaddr = GetNextHob(ql, EFI_HOB_TYPE_GUID_EXTENSION, hobaddr)

        if not hobaddr:
            return 0

        hob = EFI_HOB_GUID_TYPE.loadFrom(ql, hobaddr)

        if CompareGuid(hob.Name, hobguid):
            break

        hobaddr += hob.Header.HobLength

    return hobaddr