Passing CFDictionary Using the IOKIt Command

I am looking for a universal method for setting parameters from the userpace agent to the kernel, since the Mac is not equivalent to the Windows registry, where the driver can directly access any key in this table with the command ZwQueryValueKey.

Therefore, I would like to pass a dynamic list of variables through CFDictionary.

There IOConnectCallMethodis a way to pass a pointer to input, but the question is whether I can pass CFDictionaryor CFDictionaryRefinstead of a simple structure.

I saw that there are some IOkit commands that allow you to pass CFDictionaryRef directly, for example IOServiceGetMatchingService, but they are not intended for the driver module, but for the entity that controls the drivers.

+4
source share
1 answer

You can use the I / O set properties mechanism to exchange plist-like data between user space and kernel space. To install them from user space, you want to use one or more of the following IOKitLib functions:

  • IORegistryEntrySetCFProperty
  • IORegistryEntrySetCFProperties
  • IOConnectSetCFProperty
  • IOConnectSetCFProperties

On the kernel side, your subclass of IOService or IOUserClient should override the function virtual IOReturn setProperties( OSObject * properties );. Remember to process any data received as potentially hostile, so make sure that you check nullptrs, use OSDynamicCast()while waiting for a specific OSData/ OSNumber/ OSString/ OSArray/ etc. objects and sanitize the data itself.

, setProperties() IORegistryEntry, this->setProperty() / .

Apple .

+1

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


All Articles