简体   繁体   English

在OS X上从IOKit KEXT发布信息

[英]Publishing information from IOKit KEXT on OS X

I have an IOKit-based kernel extension on Mac OS X, a subclass of IOService. 我在Mac OS X上有一个基于IOKit的内核扩展,它是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 making some specific IOUserClient requests. 当这个服务加载时,我需要从它发布额外的特定运行时信息,我需要它可以从用户空间访问而不需要一些特定的IOUserClient请求。 The information in question is basically field\\value pairs and it's format is shared between the KEXT and it's user-space wrapper library. 有问题的信息基本上是字段\\值对,它的格式在KEXT和它的用户空间包装器库之间共享。 The contents will change over time on some specific events inside the service when it is active. 当服务处于活动状态时,内容将随服务内部的某些特定事件而变化。

On Linux i would have accomplished this with a file in the /proc file system. 在Linux上,我可以使用/ proc文件系统中的文件完成此操作。 Can you advise a similar strategy on OS X? 你能在OS X上建议一个类似的策略吗? Maybe something related to IORegistry? 也许与IORegistry相关的东西?

Thank you. 谢谢。

Well this turned out to be pretty easy. 结果证明这很简单。 Your IOKit service is (eventially) inherited from IOService class, which in turn is inherited from IORegistryEntry, which represents an instance of your service's entry in IORegistry and provides a family of setProperty\\getProperty methods to add\\change\\remove your own fields in IORegistry entry for your service. 您的IOKit服务(甚至)继承自IOService类,而IOService类继承自IORegistryEntry,它代表了IORegistry中服务条目的实例,并提供了一系列setProperty \\ getProperty方法,以便在IORegistry中添加\\ change \\ remove您自己的字段进入您的服务。

The IORegistry in an in-memory database that is of course programmatically accessible from user space where you search it for you service's entry and read information published by it. IORegistry位于内存数据库中,当然可以从用户空间以编程方式访问,您可以在其中搜索服务的条目并读取它发布的信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM