5

I know how to send data to DriverKit and get back some values, that is application calling IOConnectCallStructMethod() and driver fill the OSData in structureOutput from application.

In my Application it is using IOConnectCallAsyncScalarMethod() and the kext using sendAsyncResult64() to let the app know events coming in. However the method sendAsyncResult64() is not available in DriverKit.

I saw AsyncCompletion looks like solution but no idea to implement it. Anyone know how to do? Appreciate if any suggestion!

1
  • By the way in my app I use IOConnectCallStructMethod and prepares a buffer for driver, and in my driver use IOMemoryDescriptor::CreateMapping to fill related data let app get it. But I don't know how to use IOMemoryDescriptor::CreateMapping in successful way. Commented Aug 26, 2020 at 8:30

1 Answer 1

6

IOUserClient::AsyncCompletion is indeed the replacement for sendAsyncResult64().

To call it successfully, you need to retain the OSAction object supplied in the completion field of the IOUserClientMethodArguments supplied in your ExternalMethod dispatch function. Then, when you are ready to send an asynchronous result, call

userclient->AsyncCompletion(saved_osaction, result, async_arguments, num_async_arguments);

Don't forget to release the OSAction object once you no longer need it. The array of async arguments will be passed to the handler function in the user space application, same as with a kext calling sendAsyncResult64().

Note that you can't asynchronously fill "small" structureOutput fields (4096 bytes or less) as these must be returned in the ExternalMethod handler. Only if the buffer is large enough to be passed via structureOutputDescriptor can you retain that descriptor and fill it with data after the initial ExternalMethod returns. This is no different than for kexts, however.

Sign up to request clarification or add additional context in comments.

1 Comment

We solved this problem by you indication, thanks :) You're the top!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.