def unload_modules(self):
    for handle in self.loaded_image_protocol_modules:
        struct_addr = self.dxe_context.protocols[handle][self.loaded_image_protocol_guid]
        loaded_image_protocol = EfiLoadedImageProtocol.EFI_LOADED_IMAGE_PROTOCOL.loadFrom(self.ql, struct_addr)
        unload_ptr = self.ql.unpack64(loaded_image_protocol.Unload)
        if (unload_ptr != 0):
            self.ql.log.info(f'Unloading module {handle:#x}, calling {unload_ptr:#x}')
            self.call_function(unload_ptr, [handle], self.end_of_execution_ptr)
            self.loaded_image_protocol_modules.remove(handle)
            return True
    return False
def unload_modules(self):
    for handle in self.loaded_image_protocol_modules:
        struct_addr = self.dxe_context.protocols[handle][self.loaded_image_protocol_guid]
        loaded_image_protocol = EfiLoadedImageProtocol.EFI_LOADED_IMAGE_PROTOCOL.loadFrom(self.ql, struct_addr)
        unload_ptr = self.ql.unpack64(loaded_image_protocol.Unload)
        if (unload_ptr != 0):
            self.ql.log.info(f'Unloading module {handle:#x}, calling {unload_ptr:#x}')
            self.call_function(unload_ptr, [handle], self.end_of_execution_ptr)
            self.loaded_image_protocol_modules.remove(handle)
            return True
    return False