|
7 | 7 | import subprocess |
8 | 8 | import plistlib |
9 | 9 | import hashlib |
10 | | - |
| 10 | +import re |
11 | 11 | from pathlib import Path |
12 | 12 | from dataclasses import dataclass, field |
13 | 13 | from typing import Any, ClassVar, Optional, Type, Union |
@@ -214,8 +214,26 @@ def populate_pci_path(self, original_entry: ioreg.io_registry_entry_t): |
214 | 214 | # Virtual PCI devices provide a botched IOService path (us.electronic.kext.vusb) |
215 | 215 | # We only care about physical devices, so skip them |
216 | 216 | try: |
217 | | - location = [hex(int(i, 16)) for i in ioreg.io_name_t_to_str(ioreg.IORegistryEntryGetLocationInPlane(entry, "IOService".encode(), None)[1]).split(",") + ["0"]] |
218 | | - paths.append(f"Pci({location[0]},{location[1]})") |
| 217 | + # Extract location string and handle possible non-numeric prefixes |
| 218 | + location_str = ioreg.io_name_t_to_str(ioreg.IORegistryEntryGetLocationInPlane(entry, "IOService".encode(), None)[1]) |
| 219 | + location_parts = location_str.split(",") |
| 220 | + location_hex = [] |
| 221 | + |
| 222 | + for i in location_parts + ["0"]: |
| 223 | + i_clean = i.strip() |
| 224 | + # Try to extract numeric part from end of string |
| 225 | + match = re.search(r'(\d+)$', i_clean) |
| 226 | + if match: |
| 227 | + # Use the numeric part found |
| 228 | + location_hex.append(hex(int(match.group(1)))) |
| 229 | + elif i_clean and i_clean.isdigit(): |
| 230 | + # Already a plain number |
| 231 | + location_hex.append(hex(int(i_clean))) |
| 232 | + else: |
| 233 | + # Cannot parse, use default 0 |
| 234 | + location_hex.append("0x0") |
| 235 | + |
| 236 | + paths.append(f"Pci({location_hex[0]},{location_hex[1]})") |
219 | 237 | except ValueError: |
220 | 238 | break |
221 | 239 | elif ioreg.IOObjectConformsTo(entry, "IOACPIPlatformDevice".encode()): |
|
0 commit comments