Publish information from IOKit KEXT on OS X

I have an IOKit-based kernel extension on Mac OS X, a subclass of IOService. When this service loads, I need to publish additional specific runtime information from it, and I need it to be accessible from user space without any specific IOUserClient requests. The information in question is basically a \ value pair field, and this format is shared between KEXT and the user space cover library. The content will change over time for some specific events within the service when it is active.

On Linux, I would do this with a file in the / proc file system. Can you recommend a similar strategy for OS X? Maybe something has to do with IORegistry?

Thanks.

+4
source share
1 answer

Well, that turned out pretty easy. Your IOKit service is (in fact) inherited from the IOService class, which in turn inherits from IORegistryEntry, which represents an instance of your service record in IORegistry and provides the setProperty \ getProperty method family to add \ change \ delete your own fields in the IORegistry record for your service.

IORegistry in a database in memory, which, of course, is programmatically accessible from the user space, where you search to enter the service and read the information published by it.

+3
source

Source: https://habr.com/ru/post/1302009/


All Articles