Ask Your Question

What are the steps to register a key in the IORegistry and respond to its modification in the kext?

asked 2021-09-22 11:00:00 +0000

lalupa gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2021-06-26 19:00:00 +0000

qstack gravatar image
  1. Define the registry entry: Identify the IORegistry entry for your hardware device and determine its properties (e.g. vendor ID, product ID, etc.). Define the entry using the IORegistryExplorer tool or programatically in your kext.

  2. Register the registry entry: Once the registry entry is defined, register it using the IOServiceRegister function. This creates a matching dictionary that will be used to match the device to the kext.

  3. Implement the probe function: In your kext's probe function, use the matching dictionary to find the device and return an instance of your IOService subclass.

  4. Implement the start function: In your IOService subclass's start function, get a reference to the device's IOUSBInterface and register for notifications of key changes using the IOHIDDeviceRegisterInputValueCallback function.

  5. Handle the key change notification: When a key change notification is received, your IOHIDValueCallback function will be called. In this function, read the new key value and respond accordingly (e.g. update an internal state, send a message to the user space app, etc.).

  6. Unregister the callback: When your kext is unloaded or the device is disconnected, unregister the callback using the IOHIDDeviceUnregisterInputValueCallback function.

  7. Unregister the registry entry: Unregister the registry entry using the IOServiceUnregister function.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer

Question Tools


Asked: 2021-09-22 11:00:00 +0000

Seen: 1 times

Last updated: Jun 26 '21