diff --git a/Scripts/aida64.py b/Scripts/aida64.py deleted file mode 100644 index e265d3f..0000000 --- a/Scripts/aida64.py +++ /dev/null @@ -1,503 +0,0 @@ -from Scripts.datasets import pci_data -from Scripts import gpu_identifier -from Scripts import utils - -class AIDA64: - def __init__(self): - self.headers = {"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36"} - self.encodings = ["utf-8", "latin-1", "ISO-8859-1"] - self.gpu_identifier = gpu_identifier.GPUIdentifier() - self.utils = utils.Utils() - - def try_open(self, file_path): - for encoding in self.encodings: - try: - with open(file_path, "r", encoding=encoding) as file: - return file.read() - except UnicodeDecodeError: - continue - raise UnicodeDecodeError("Unable to decode file {} with given encodings".format(file_path)) - - def get_unique_key(self, base_key, dictionary): - if base_key not in dictionary: - return base_key - - counter = 1 - unique_key = f"{base_key}_#{counter}" - - while unique_key in dictionary: - counter += 1 - unique_key = f"{base_key}_#{counter}" - - return unique_key - - def parse_hardware_id(self, hardware_id): - if "VEN" in hardware_id: - return { - "Bus Type": hardware_id.split("\\")[0], - "Device ID": "{}-{}".format(hardware_id.split("VEN_")[-1].split("&")[0], hardware_id.split("DEV_")[-1].split("&")[0]), - "Subsystem ID": hardware_id.split("SUBSYS_")[-1].split("&")[0], - "Revision": hardware_id.split("REV_")[-1].split("\\")[0] - } - - if "VID" in hardware_id: - return { - "Bus Type": hardware_id.split("\\")[0], - "Device ID": "{}-{}".format(hardware_id.split("VID_")[-1].split("&")[0], hardware_id.split("PID_")[-1].split("&")[0]), - "Revision": hardware_id.split("REV_")[-1].split("&")[0].split("\\")[0] - } - - return { - "Bus Type": hardware_id.split("\\")[0], - "Device": hardware_id.split("\\")[-1] - } - - def motherboard(self, motherboard_props, dmi): - motherboard_info = {} - - motherboard_info["Motherboard Name"] = motherboard_props.get("Motherboard Name", "Unknown").split("(")[0].strip() - motherboard_info["Motherboard Chipset"] = motherboard_props.get("Motherboard Chipset", "Unknown").split(", ")[0] - - if "Unknown" in motherboard_info.get("Motherboard Name"): - motherboard_info["Motherboard Name"] = "Unknown" - merged_report = dmi.get("System", {}).copy() - merged_report.update(dmi.get("Motherboard", {})) - for device_key, device_value in merged_report.items(): - motherboard_name = "{} {}".format(device_value.get("Manufacturer", "O.E.M."), device_value.get("Product", "O.E.M.")) - if "O.E.M." not in motherboard_name and "System Product Name" not in motherboard_name and len(motherboard_name) > len(motherboard_info.get("Motherboard Name")): - motherboard_info["Motherboard Name"] = motherboard_name - - motherboard_info["Platform"] = dmi.get("Chassis", {}).get("Chassis Properties", {}).get("Chassis Type", "Unknown") - if any(word in motherboard_info["Platform"].lower() for word in ["convertible", "notebook", "laptop", "docking station", "portable"]): - motherboard_info["Platform"] = "Laptop" - elif any(word in motherboard_info["Platform"].lower() for word in ["desktop", "mini pc"]): - motherboard_info["Platform"] = "Desktop" - elif "NUC" in motherboard_info["Motherboard Name"]: - motherboard_info["Platform"] = "NUC" - - return motherboard_info - - def cpu(self, cpu_table): - cpu_info = {} - - cpu_info["CPU Manufacturer"] = cpu_table.get("CPU Manufacturer", {}).get("Company Name", "Unknown") - - cpu_props = cpu_table.get("CPU Properties", {}) - cpu_info["Processor Name"] = cpu_props.get("CPU Type", "Unknown").split(",")[0] - - if "Intel" in cpu_info["CPU Manufacturer"]: - cpu_info["CPU Manufacturer"] = "Intel" - elif "Advanced Micro Devices" in cpu_info["CPU Manufacturer"]: - cpu_info["CPU Manufacturer"] = "AMD" - elif cpu_info["CPU Manufacturer"] == "Unknown": - processor_name = cpu_table.get("Multi CPU", {}).get("CPU #1", "Unknown").split("with")[0].split(",")[0] - if "Intel" in processor_name: - cpu_info["CPU Manufacturer"] = "Intel" - elif "AMD" in processor_name: - cpu_info["CPU Manufacturer"] = "AMD" - cpu_info["Processor Name"] += cpu_info["CPU Manufacturer"] + processor_name.split(cpu_info["CPU Manufacturer"])[-1] - - cpu_info["CPU Codename"] = cpu_props.get("CPU Alias", "Unknown") - - cpu_info["CPU Cores"] = str(sum(1 for key in list(cpu_table.get("CPU Utilization", {}).keys()) if not "SMT Unit" in key or "SMT Unit #1" in key)).zfill(2) - - cpu_info["CPU Configuration"] = list(cpu_table.get("CPU Utilization", {}).keys())[-1].split(" / ")[0].split("#")[-1].zfill(2) - - cpu_info["Instruction Set"] = cpu_props.get("Instruction Set", "Unknown") - - return cpu_info - - def storage_controllers(self, ata_controllers, storage_controllers): - storage_controllers_info = {} - - storage_controllers.update(ata_controllers) - for controller_name, controller_props in storage_controllers.items(): - bus_type = controller_props.get("Bus Type", "Unknown") - if "PCI" in bus_type or "VID" in bus_type: - if " SD " in controller_name or "MMC" in controller_name: - continue - - storage_controllers_info[self.get_unique_key(controller_props.get("PCI Device", controller_name), storage_controllers_info)] = { - "Bus Type": controller_props.get("Bus Type", "Unknown"), - "Device ID": controller_props.get("Device ID", "Unknown") - } - - return storage_controllers_info - - def audio(self, windows_devices): - audio_devices_info = {} - audio_device_ids = [] - - for device_name, device_props in windows_devices.get("Audio inputs and outputs", {}).items(): - driver_description = device_props.get("Driver Description", "Unknown") - - if " (" not in driver_description: - continue - - audio_endpoint = driver_description.split(" (")[0] - audio_controller_name = driver_description.split(" (")[-1].strip(" )").split("- ")[-1] - - audio_controller_props = self.utils.search_dict_iter(windows_devices, audio_controller_name) - bus_type = audio_controller_props.get("Bus Type", "") - - if audio_controller_name not in audio_devices_info and (bus_type.endswith("AUDIO") or bus_type.endswith("USB") or bus_type.endswith("ACP")): - audio_devices_info[audio_controller_name] = { - "Bus Type": bus_type, - "{} ID".format("USB" if bus_type.endswith("USB") else "Codec"): audio_controller_props.get("Device ID", "Unknown"), - "Audio Endpoints": [audio_endpoint] - } - audio_device_ids.append(audio_controller_props.get("Device ID", "Unknown")) - elif audio_controller_name in audio_devices_info: - audio_devices_info[audio_controller_name]["Audio Endpoints"].append(audio_endpoint) - - detected_audio_devices = self.utils.search_dict_iter(windows_devices, "AUDIO", equal=False) - windows_audio_devices = self.utils.search_dict_iter(windows_devices, detected_audio_devices) - - for device_name, device_props in windows_audio_devices.items(): - bus_type = device_props.get("Bus Type", "") - if bus_type.endswith("AUDIO") or bus_type.endswith("USB"): - if device_props.get("Device ID", "Unknown") not in audio_device_ids: - audio_devices_info[self.get_unique_key(device_name, audio_devices_info)] = { - "Bus Type": bus_type, - "{} ID".format("USB" if bus_type.endswith("USB") else "Codec"): device_props.get("Device ID", "Unknown") - } - - return audio_devices_info - - def gpu(self, pci_devices, windows_devices): - gpu_info = {} - - display_adapters = windows_devices.get("Display adapters", windows_devices.get("Display adaptors", {})) - gpu_by_class = None - if not display_adapters: - gpu_by_class = self.utils.search_dict_iter(pci_devices, "VGA Display Controller", equal=False) - if gpu_by_class: - gpu_in_windows_devices = self.utils.search_dict_iter(windows_devices, gpu_by_class.get("Device ID")) - display_adapters = self.utils.search_dict_iter(windows_devices, gpu_in_windows_devices) - - for adapter_name, adapter_props in display_adapters.items(): - device_id = adapter_props.get("Device ID") - if not device_id: - continue - if gpu_by_class and self.utils.contains_any(["Video Controller", "Video Adapter", "Graphics Controller"], adapter_name + adapter_props.get("PCI Device", "")) is None: - continue - gpu_info[adapter_name] = self.gpu_identifier.classify_gpu(device_id) - - return self.utils.sort_dict_by_key(gpu_info, "Device Type") - - def input(self, human_interface_devices, keyboards, pointing_devices, usb_devices): - input_devices_info = {} - - combined_devices = human_interface_devices.copy() - combined_devices.update(keyboards) - combined_devices.update(pointing_devices) - - for device_name, device_props in combined_devices.items(): - bus_type = device_props.get("Bus Type", "Unknown") - device_id = device_props.get("Device ID", "Unknown") - - if "ACPI" in bus_type or "ROOT" in bus_type or "USB" in bus_type: - if "USB" in bus_type: - device_name = self.utils.search_dict_iter(usb_devices, device_props["Device ID"]).get("Device Description", device_name) - - input_devices_info[device_name] = { - "Bus Type": bus_type, - "Device ID": device_id - } - - return input_devices_info - - def usb_controllers(self, usb_controllers): - return { - controller_name: { - "Bus Type": controller_props.get("Bus Type", "Unknown"), - "Device ID": controller_props.get("Device ID", "Unknown") - } - for controller_name, controller_props in usb_controllers.items() - if controller_props.get("Bus Type", "Unknown").startswith("PCI") - } - - def usb_devices(self, usb_devices, windows_devices): - usb_devices_info = {} - - for device_name, device_data in usb_devices.items(): - device_props = device_data.get("Device Properties", {}) - manufacturer = device_props.get("Manufacturer", None) - product = device_props.get("Product", None) - device_description = "{} {}".format(manufacturer, product) if manufacturer and product else product if product else None - - if not device_description: - device_id = device_props.get("Device ID", None) - revision_id = device_props.get("Revision", None)[:-1] if device_props.get("Revision") else None - hardware_id = "USB\\VID_{}&PID_{}&REV_{}".format(device_id[:4], device_id[5:], revision_id[:-1]) if device_id and revision_id else None - - if hardware_id: - device_description = self.utils.search_dict_iter(windows_devices, hardware_id + "&MI_00").get("Driver Description", None) - if not device_description: - device_description = self.utils.search_dict_iter(windows_devices, hardware_id).get("Driver Description", device_name) - - device_description = self.get_unique_key(device_description, usb_devices_info) - - if "Hub" not in device_description and "Billboard" not in device_description and not "0000-0000" in device_props.get("Device ID"): - usb_devices_info[device_description] = { - "Device Description": device_description.split("_#")[0], - "Device Class": device_props.get("Device Class"), - "Device ID": device_props.get("Device ID"), - "Revision": device_props.get("Revision") - } - - return usb_devices_info - - def network(self, windows_devices, pci_devices): - network_info = {} - - for device_name, device_props in pci_devices.items(): - device_class = device_props.get("Device Properties", {}).get("Device Class", "Unknown")[6:-1] - - if self.utils.contains_any(["Network", "Ethernet", "WiFi", "Wi-Fi", "Wireless"], device_class + device_name): - device_id = device_props.get("Device Properties").get("Device ID") - - network_adapter = self.utils.search_dict_iter(windows_devices, device_id) - network_adapters = self.utils.search_dict_iter(windows_devices, network_adapter) - - for adapter_name, adapter_props in network_adapters.items(): - bus_type = adapter_props.get("Bus Type", "Unknown") - if bus_type.startswith("PCI") or bus_type.startswith("USB"): - device_key = adapter_props.get("PCI Device") if not " - " in adapter_props.get("PCI Device", " - ") else adapter_name - network_info[device_key.split(" [")[0]] = { - "Bus Type": bus_type, - "Device ID": adapter_props.get("Device ID", "Unknown") - } - - return network_info - - def sd_controller(self, pci_devices, usb_devices, hardware): - combined_devices = pci_devices.copy() - combined_devices.update(usb_devices) - - for device_name, device_data in combined_devices.items(): - device_props = device_data.get("Device Properties", device_data) - device_class = device_props.get("Device Class", "Unknown") - - if self.utils.contains_any(["SD Host Controller", "Card Reader", "SDHC", "SDXC", "SDUC", " SD ", "MMC"], device_name + " " + device_class): - hardware["SD Controller"] = { - "Device Description": device_name, - "Bus Type": "PCI" if device_props.get("Bus Type", "Unknown").startswith("PCI") else "USB", - "Device ID": device_props.get("Device ID", "Unknown") - } - - return hardware - - def intel_mei(self, cpu_codename, pci_devices, hardware): - if "Sandy Bridge" in cpu_codename or "Ivy Bridge" in cpu_codename: - intel_mei_data = self.utils.search_dict_iter(pci_devices, "HECI", equal=False) - - if not intel_mei_data: - intel_mei_data = self.utils.search_dict_iter(pci_devices, "Management Engine Interface", equal=False) - - if intel_mei_data: - intel_mei_props = intel_mei_data.get("Device Properties", {}) - hardware["Intel MEI"] = { - "Bus Type": intel_mei_props.get("Bus Type", "Unknown"), - "Device ID": intel_mei_props.get("Device ID", "Unknown") - } - - return hardware - - def bluetooth(self, bluetooth, usb_devices, hardware): - bluetooth_info = {} - - for device_name, device_props in bluetooth.items(): - bus_type = device_props.get("Bus Type", "Unknown") - - if bus_type.startswith("USB"): - bluetooth_info[device_name] = { - "Device ID": device_props.get("Device ID"), - "Revision": device_props.get("Revision") - } - - if not bluetooth_info: - for usb_device_name, usb_device_props in usb_devices.items(): - device_class = usb_device_props.get("Device Class", {}) - device_id = usb_device_props.get("Device ID", {}) - - if "bluetooth" in (usb_device_name + device_class).lower() or device_id in pci_data.BluetoothIDs: - bluetooth_info[usb_device_name] = usb_device_props - - if bluetooth_info: - hardware["Bluetooth"] = bluetooth_info - - return hardware - - def biometric(self, biometric_devices, usb_devices, hardware): - biometric_info = { - device_name: { - "Bus Type": device_props.get("Bus Type", "Unknown"), - "Device ID": device_props.get("Device ID", "Unknown") - } - for device_name, device_props in biometric_devices.items() - } - - if not biometric_info: - for device_name, device_data in usb_devices.items(): - if "fingerprint" in device_name.lower(): - device_props = device_data.get("Device Properties", {}) - - biometric_info[device_name] = { - "Bus Type": device_props.get("Bus Type", "Unknown"), - "Device ID": device_props.get("Device ID", "Unknown") - } - - if biometric_info: - hardware["Biometric"] = biometric_info - - return hardware - - def parse_dmi(self, dmi_data): - parsed_dmi = {} - - for full_key, item_value in dmi_data.items(): - occurrence_suffix = "" - category_name = None - - if "_#" in full_key: - suffix_idx = full_key.index("_#") - occurrence_suffix = full_key[suffix_idx:] - full_key = full_key[:suffix_idx] - - if " / " in full_key: - category_idx = full_key.index(" / ") - category_name = full_key[:category_idx] - device_name = full_key[category_idx + 3:] - - if not category_name: - parsed_dmi["{}{}".format(full_key, occurrence_suffix)] = item_value - else: - if category_name not in parsed_dmi: - parsed_dmi[category_name] = {} - parsed_dmi[category_name]["{}{}".format(device_name, occurrence_suffix)] = item_value - - return parsed_dmi - - def parse_windows_devices(self, windows_devices): - parsed_windows_devices = {} - - for full_key, item_value in windows_devices.items(): - device_props = item_value.get("Device Properties", {}) - - if "Hardware ID" in device_props: - device_props.update(self.parse_hardware_id(device_props.get("Hardware ID"))) - - category_name = full_key.split(" / ")[0] - - if category_name not in parsed_windows_devices: - parsed_windows_devices[category_name] = {} - - device_name = device_props.get("Driver Description") - - parsed_windows_devices[category_name][self.get_unique_key(device_name, parsed_windows_devices[category_name])] = device_props - - return parsed_windows_devices - - def get_inner_text(self, html_string): - text = "" - inside_tag = False - for char in html_string: - if char == "<": - inside_tag = True - elif char == ">": - inside_tag = False - elif not inside_tag: - text += char - return text.strip() - - def parse_html_to_json(self, html_content): - parsed_data = {} - table_titles = [ - "Summary", - "DMI", - "CPU", - "Windows Devices", - "PCI Devices", - "USB Devices" - ] - - try: - start_index = html_content.index("") + len("") - except: - raise Exception("Your AIDA64 report is missing some information. Please revise it according to the provided guidelines") - - for title in table_titles: - title_marker = f">{title}<" - if title_marker not in html_content[start_index:]: - raise Exception("Your AIDA64 report is missing some information. Please revise it according to the provided guidelines") - - title_index = html_content[start_index:].index(title_marker) - table_start_index = start_index + title_index + html_content[start_index+title_index:].index("\n") - table_end_index = table_start_index + 1 + html_content[table_start_index:].index("") + len("") - table_html = html_content[table_start_index:table_end_index].strip() - - parsed_data[title] = {} - stack = [(parsed_data[title], -1)] - - for line in table_html.splitlines(): - if line.startswith(""): - line = line.replace("", "") - - level = (len(line) - len(line.lstrip(""))) // 3 - 1 - if level < 1: - continue - - while line.startswith(""): - line = line[line.find(">") + 1:] - else: - continue - - line = line.replace("  ", "") - td_elements = line.split("") - key = self.get_inner_text(td_elements[0]) - value = None if len(td_elements) < 2 else self.get_inner_text(td_elements[-1]) - - key = key.rstrip(":").strip("[]").strip() - - while stack and stack[-1][1] >= level: - stack.pop() - - current_dict = stack[-1][0] - key = self.get_unique_key(key, current_dict) - - if value is None: - new_dict = {} - current_dict[key] = new_dict - stack.append((new_dict, level)) - else: - current_dict[key] = value - - start_index = table_end_index - - return parsed_data - - def dump(self, report_path): - html_content = self.try_open(report_path) - report_dict = self.parse_html_to_json(html_content) - - dmi = self.parse_dmi(report_dict.get("DMI", {})) - windows_devices = self.parse_windows_devices(report_dict.get("Windows Devices", {})) - - hardware = {} - hardware["Motherboard"] = self.motherboard(report_dict.get("Summary", {}).get("Motherboard", {}), dmi) - hardware["CPU"] = self.cpu(report_dict.get("CPU", {})) - hardware["GPU"] = self.gpu(report_dict.get("PCI Devices", {}), windows_devices) - hardware["Network"] = self.network(windows_devices, report_dict.get("PCI Devices", {})) - hardware["Storage Controllers"] = self.storage_controllers(windows_devices.get("IDE ATA/ATAPI controllers", {}), windows_devices.get("Storage controllers", {})) - hardware["Audio"] = self.audio(windows_devices) - hardware["USB Controllers"] = self.usb_controllers(windows_devices.get("Universal Serial Bus controllers", {})) - usb_devices = self.usb_devices(report_dict.get("USB Devices", {}), windows_devices) - hardware["Input"] = self.input(windows_devices.get("Human Interface Devices", {}), windows_devices.get("Keyboards", {}), windows_devices.get("Mice and other pointing devices", {}), usb_devices) - - hardware = self.biometric(windows_devices.get("Biometric devices", {}), usb_devices, hardware) - hardware = self.bluetooth(windows_devices.get("Bluetooth", {}), usb_devices, hardware) - hardware = self.sd_controller(report_dict.get("PCI Devices", {}), usb_devices, hardware) - hardware = self.intel_mei(hardware["CPU"].get("CPU Codename"), report_dict.get("PCI Devices", {}), hardware) - - return hardware \ No newline at end of file diff --git a/Scripts/device_locator.py b/Scripts/device_locator.py deleted file mode 100644 index e0c398e..0000000 --- a/Scripts/device_locator.py +++ /dev/null @@ -1,93 +0,0 @@ -import run -import os -import re - -class DeviceLocator: - def __init__(self): - self.run = run.Run().run - - def convert_pci_path(self, path): - components = path.split("#") - result = [] - - for component in components: - if component.startswith("PCIROOT"): - match = re.match(r"PCIROOT\((\d+)\)", component) - if match: - result.append("PciRoot(0x{:x})".format(int(match.group(1)))) - elif component.startswith("PCI"): - match = re.match(r"PCI\((\w+)\)", component) - if match: - values = match.group(1) - if len(values) == 4: - bus = int(values[:2], 16) - device = int(values[2:], 16) - result.append("Pci(0x{:x},0x{:x})".format(bus, device)) - else: - result.append("Pci(0x{:x})".format(int(values, 16))) - - return "/".join(result) - - def convert_acpi_path(self, path): - components = path.split("#") - result = [] - - for component in components: - match = re.match(r'ACPI\((\w+)\)', component) - if match: - if result: - result.append(match.group(1)) - else: - result.append("\\{}".format(match.group(1)[:-1])) - - return '.'.join(result) - - def get_device_location_paths(self, bus_type, pci_id, subsystem_id=None, revision_id=None): - if os.name != 'nt': - return None - - vendor_id = pci_id[:4] - device_id = pci_id[5:] - hardware_id = "{}\\VEN_{}&DEV_{}".format(bus_type, vendor_id, device_id) - if subsystem_id: - hardware_id += "&SUBSYS_{}".format(subsystem_id) - if revision_id: - hardware_id += "&REV_{}".format(revision_id) - - query_device_command = ''' - $searchPattern = "{}" - Get-PnpDevice | Where-Object {{ $_.InstanceId -like "$searchPattern*" }} | Select-Object InstanceId - ''' - - output = self.run({ - "args":["powershell", "-Command", query_device_command.format(hardware_id)] - }) - - if output[-1] != 0 or not output[0]: - return None - - lines = output[0].splitlines() - if len(lines) < 4: - return None - - device_instance_id_with_topology = lines[3].strip() - if not hardware_id in device_instance_id_with_topology: - return None - - get_location_paths_command = ( - 'Get-PnpDeviceProperty -InstanceId "{}" ' - '-KeyName DEVPKEY_Device_LocationPaths | Select-Object -ExpandProperty Data' - ) - - output = self.run({ - "args":["powershell", "-Command", get_location_paths_command.format(device_instance_id_with_topology)] - }) - - if output[-1] != 0 or not output[0]: - return None - - location_paths = output[0].strip().splitlines() - return { - "PCI Path": self.convert_pci_path(location_paths[0]), - "APCI Path": self.convert_acpi_path(location_paths[-1]) - } \ No newline at end of file diff --git a/Scripts/gpu_identifier.py b/Scripts/gpu_identifier.py deleted file mode 100644 index f69f7de..0000000 --- a/Scripts/gpu_identifier.py +++ /dev/null @@ -1,128 +0,0 @@ -class GPUIdentifier: - def identify_intel_graphics(self, hardware_id): - gpu_codename = "Unknown" - device_id = hardware_id[5:] - - if device_id.startswith("01"): - if device_id[-2] in ["5", "6"]: - gpu_codename = "Ivy Bridge" - else: - gpu_codename = "Sandy Bridge" - elif device_id.startswith(("04", "0A", "0C", "0D")): - gpu_codename = "Haswell" - elif device_id.startswith(("0B", "16")): - gpu_codename = "Broadwell" - elif device_id.startswith(("09", "19")): - gpu_codename = "Skylake" - elif device_id.startswith("59"): - if device_id.endswith("17"): - gpu_codename = "Kaby Lake-R" - else: - gpu_codename = "Kaby Lake" - elif device_id.startswith("87"): - gpu_codename = "Amber Lake" - elif device_id.startswith(("3E", "5A")): - if device_id.endswith(("A0", "A1")): - gpu_codename = "Whiskey Lake" - else: - gpu_codename = "Coffee Lake" - elif device_id.startswith("8A"): - gpu_codename = "Ice Lake" - elif device_id.startswith("9B"): - gpu_codename = "Comet Lake" - - return { - "Manufacturer": "Intel", - "GPU Codename": gpu_codename, - "Device ID": hardware_id, - "Device Type": "Unknown" if gpu_codename == "Unknown" else "Integrated GPU" - } - - def identify_amd_graphics(self, hardware_id): - gpu_codename = "Unknown" - device_id = hardware_id[5:] - - if device_id.startswith("15D8"): - gpu_codename = "Picasso" - elif device_id.startswith("15DD"): - gpu_codename = "Raven Ridge" - elif device_id.startswith("15E7"): - gpu_codename = "Barcelo" - elif device_id.startswith("1636"): - gpu_codename = "Renoir" - elif device_id.startswith("1638"): - gpu_codename = "Cezanne" - elif device_id.startswith("164C"): - gpu_codename = "Lucienne" - elif device_id.startswith(("67C", "67D")): - gpu_codename = "Ellesmere" - elif device_id.startswith(("67E", "67F")): - gpu_codename = "Baffin" - elif device_id.startswith("694"): - gpu_codename = "Polaris 22" - elif device_id.startswith(("698", "699")): - gpu_codename = "Lexa" - elif device_id.startswith("69A"): - gpu_codename = "Vega 12" - elif device_id.startswith("6FDF"): - gpu_codename = "Polaris 20" - elif device_id.startswith(("686", "687")): - gpu_codename = "Vega 10" - elif device_id.startswith("66A"): - gpu_codename = "Vega 20" - elif device_id.startswith("731"): - gpu_codename = "Navi 10" - elif device_id.startswith("734"): - gpu_codename = "Navi 14" - elif device_id.startswith("736"): - gpu_codename = "Navi 12" - elif device_id.startswith(("73A", "73B")): - gpu_codename = "Navi 21" - elif device_id.startswith(("73C", "73D")): - gpu_codename = "Navi 22" - elif device_id.startswith(("73E", "73FF")): - gpu_codename = "Navi 23" - - return { - "Manufacturer": "AMD", - "GPU Codename": gpu_codename, - "Device ID": hardware_id, - "Device Type": "Unknown" if gpu_codename == "Unknown" else "Integrated GPU" if device_id.startswith(("15", "16")) else "Discrete GPU" - } - - def identify_nvidia_graphics(self, hardware_id): - gpu_codename = "Unknown" - device_id = hardware_id[5:] - - if device_id.startswith(("0FC", "0FD", "0FE", "0FF", "100", "101", "102", "103", "11", "128", "129", "12A", "12B", "130")) and device_id != "1140": - gpu_codename = "Kepler" - elif device_id.startswith(("05E", "05F", "0A2", "0A3", "0A6", "0A7", "0C", "10C", "10D")): - gpu_codename = "Tesla" - elif device_id.startswith(("06C", "06D", "0DC", "0DD", "0DE", "0DF", "0E2", "0E3", "0F0", "104", "105", "107", "108", "109", "114", "120", "121", "124", "125")): - gpu_codename = "Fermi" - elif device_id.startswith(("13", "14", "16", "17")) and not device_id.startswith("172"): - gpu_codename = "Maxwell" - elif device_id.startswith(("15", "172", "1B", "1C", "1D0", "1D1", "1D3", "1D5")): - gpu_codename = "Pascal" - - return { - "Manufacturer": "NVIDIA", - "GPU Codename": gpu_codename, - "Device ID": hardware_id, - "Device Type": "Discrete GPU" - } - - def classify_gpu(self, hardware_id): - if hardware_id.startswith("8086"): - return self.identify_intel_graphics(hardware_id) - elif hardware_id.startswith("1002"): - return self.identify_amd_graphics(hardware_id) - elif hardware_id.startswith("10DE"): - return self.identify_nvidia_graphics(hardware_id) - else: - return { - "Manufacturer": "Unknown", - "GPU Codename": "Unknown", - "Device ID": hardware_id, - "Device Type": "Unknown" - } \ No newline at end of file