Skip to content

Commit 1cf1e34

Browse files
committed
2 parents 8b47c4f + 9cf1931 commit 1cf1e34

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

Resources/device_probe.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ def populate_pci_path(self, original_entry: ioreg.io_registry_entry_t):
8181
location = [hex(int(i, 16)) for i in ioreg.io_name_t_to_str(ioreg.IORegistryEntryGetLocationInPlane(entry, "IOService".encode(), None)[1]).split(",") + ["0"]]
8282
paths.append(f"Pci({location[0]},{location[1]})")
8383
elif ioreg.IOObjectConformsTo(entry, "IOACPIPlatformDevice".encode()):
84-
paths.append(f"PciRoot({hex(int(ioreg.IORegistryEntryCreateCFProperty(entry, '_UID', ioreg.kCFAllocatorDefault, ioreg.kNilOptions) or 0))})") # type: ignore
84+
paths.append(f"PciRoot({hex(int(ioreg.corefoundation_to_native(ioreg.IORegistryEntryCreateCFProperty(entry, '_UID', ioreg.kCFAllocatorDefault, ioreg.kNilOptions)) or 0))})") # type: ignore
8585
break
8686
elif ioreg.IOObjectConformsTo(entry, "IOPCIBridge".encode()):
8787
pass
@@ -127,7 +127,7 @@ def from_ioregistry(cls, entry: ioreg.io_registry_entry_t, anti_spoof=True):
127127

128128
interface = next(ioreg.ioiterator_to_list(ioreg.IOServiceGetMatchingServices(ioreg.kIOMasterPortDefault, matching_dict, None)[1]), None)
129129
if interface:
130-
device.country_code = ioreg.IORegistryEntryCreateCFProperty(interface, "IO80211CountryCode", ioreg.kCFAllocatorDefault, ioreg.kNilOptions) # type: ignore # If not present, will be None anyways
130+
device.country_code = ioreg.corefoundation_to_native(ioreg.IORegistryEntryCreateCFProperty(interface, "IO80211CountryCode", ioreg.kCFAllocatorDefault, ioreg.kNilOptions)) # type: ignore # If not present, will be None anyways
131131
else:
132132
device.country_code = None # type: ignore
133133

@@ -378,7 +378,7 @@ def storage_probe(self):
378378
parent = ioreg.IORegistryEntryGetParentEntry(device, "IOService".encode(), None)[1]
379379
ioreg.IOObjectRelease(device)
380380

381-
aspm: Union[int, bytes] = ioreg.IORegistryEntryCreateCFProperty(parent, "pci-aspm-default", ioreg.kCFAllocatorDefault, ioreg.kNilOptions) or 0 # type: ignore
381+
aspm: Union[int, bytes] = ioreg.corefoundation_to_native(ioreg.IORegistryEntryCreateCFProperty(parent, "pci-aspm-default", ioreg.kCFAllocatorDefault, ioreg.kNilOptions)) or 0 # type: ignore
382382
if isinstance(aspm, bytes):
383383
aspm = int.from_bytes(aspm, byteorder="little")
384384

Resources/ioreg.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,8 @@ def ioiterator_to_list(iterator: io_iterator_t):
218218

219219

220220
def corefoundation_to_native(collection):
221+
if collection is None: # nullptr
222+
return None
221223
native = Conversion.pythonCollectionFromPropertyList(collection)
222224
CFRelease(collection)
223225
return native

0 commit comments

Comments
 (0)