访问 I/O 目录类对象

发布于 2024-07-13 00:13:41 字数 2299 浏览 4 评论 0原文

我正在开发一个 OS X 内核扩展 (kext),它将用作 I/O Kit 驱动程序。 然而,这个驱动程序将是严格的“虚拟”的; 它不会与任何硬件连接。

OS X 保留加载到内核中的所有驱动程序的目录(I/O 目录)。 它还保留一个注册表(I/O 注册表),其中包含与硬件设备匹配且当前正在控制硬件的 I/O 目录驱动程序。

由于我的驱动程序不依赖于硬件并且不“匹配”,因此它仅加载到I/O目录中并且不向I/O注册表注册。 这会导致一个问题,因为获取 I/O 驱动程序对象的 API 仅限于在 I/O 注册表中注册的驱动程序,而不能访问 I/O 目录中的对象。 我已经尝试过 使用推荐的 API 与我的驱动程序匹配,但是,正如我之前提到的,这些 API 不会公开 I/O 目录条目。

我的最终目标是获得对我的驱动程序的引用,以便 通过“setProperties”方法传入数据。 如果一切都失败了,我 可以使用 syscall、copyin 和 copyout 的组合来将数据传入和传出驱动程序,但我目前对该解决方案不感兴趣。

简而言之:是否有任何方法可以获得对 I/O 目录中但不在 I/O 注册表中的驱动程序的引用?

更新:要观察我的意思,请查看以下两个 IORegistryExplorer 的屏幕截图:

已注册可以轻松访问驱动程序 通过 API,但未注册驱动程序将无法使用 IOServiceGetMatchingServices(...) 进行匹配。 如何获取对未注册的已加载驱动程序的引用?

有关更多信息,请查看:

I'm developing an OS X kernel extension (kext) that will be used as an I/O Kit driver. This driver, however, will be strictly "virtual"; it will not interface with any hardware.

OS X keeps a catalog (I/O Catalog) of all the drivers that are loaded into the kernel. It also keeps a registry (I/O Registry) containing the I/O Catalog drivers that have matched with a hardware device and that are currently controlling the hardware.

Since my driver is not dependent on hardware and does not "match", it is only loaded into the I/O Catalog and not registered with the I/O Registry. This causes a problem, because the API to obtain I/O driver objects is limited to the drivers that are registered in the I/O Registry and does not access the objects in the I/O Catalog. I've tried matching to my driver using the recommended APIs, however, as I mentioned before, these APIs do not expose the I/O Catalog entries.

My ultimate goal is to obtain a reference to my driver in order to transfer in data with the "setProperties" method. If all else fails, I can use a combination of syscall, copyin and copyout to transfer the data in and out of the driver, but I'm not interested in that solution at the moment.

In short: Is there any way to obtain a reference to a driver that is in the I/O Catalog but not in the I/O Registry?

Update: To observe what I mean, look at the following two screen shots of IORegistryExplorer:

The registered driver is easily accessed through the API, but the unregistered driver will not match using IOServiceGetMatchingServices(...). How do I get a reference to a loaded driver that is not registered?

For more information, check out:

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

拧巴小姐 2024-07-20 00:13:41

您无需硬件即可加载驱动程序。 您可能想考虑针对“IOKit”或“IOBSD”执行“IOResourceMatching”之类的操作。 当这些资源可用时,这将导致驱动程序触发被动匹配。

You can get your driver to load without having a piece of hardware. You probably want to look into doing something like "IOResourceMatching" against "IOKit" or "IOBSD". That will cause passive matching to trigger on your driver when those resource become available.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文