Thanks, Smith,
Thanks for your quick response. There are so few resource about DriverKit developing that I can find. So, thank you very much!
I follow your suggestion, add the code for NewUserClient
kern_return_t IMPL(testinfo, NewUserClient)
{
kern_return_t ret = kIOReturnSuccess;
IOService* client = nullptr;
Log("fredapp NewUserClient()");
ret = Create(this, "UserClientProperties", &client);
if (ret != kIOReturnSuccess)
{
Log("fredapp NewUserClient() - Failed to create UserClientProperties with error: 0x%08x.", ret);
goto Exit;
}
*userClient = OSDynamicCast(IOUserClient, client);
if (*userClient == NULL)
{
Log("fredapp NewUserClient() - Failed to cast new client.");
client->release();
ret = kIOReturnError;
goto Exit;
}
Log("fredapp NewUserClient() - Finished.");
Exit:
return ret;
}
And change the CppUserClient
ret = IOServiceGetMatchingServices(kIOMasterPortDefault, IOServiceNameMatching(dextIdentifier), &iterator);
But still got the message: Failed to match to device.
By the way, in CppUserClient.cpp
ret = IOServiceOpen(service, mach_task_self_, kIOHIDServerConnectType, &connection);
our dext is using the PCIDriverKit.framework, and include the headers
#include <DriverKit/IOUserServer.h>
#include <DriverKit/IOLib.h>
#include <PCIDriverKit/PCIDriverKit.h>
#include <DriverKit/IODMACommand.h>
#include <DriverKit/IODispatchSource.h>
#include <DriverKit/IOTimerDispatchSource.h>
#include <DriverKit/IOInterruptDispatchSource.h>
So I try to replace the kIOHIDServerConnectType to kIOPCIDeviceConnectType, but I do not know how to import the correct header file. I try to include
#include <IOKit/PCIDriverKit.h>
but Xcode report file not found.
What's the next step to try?
And I find a Github repository SamsungDS/MacVFN, in the file MacVFN/MacVFNUserClient.cpp,
#include <DriverKit/IOUserServer.h>
#include <DriverKit/IOLib.h>
#include <DriverKit/OSData.h>
#include <DriverKit/OSDictionary.h>
#include <DriverKit/OSNumber.h>
#include <PCIDriverKit/PCIDriverKit.h>
If it is workable (because I was failed to include PCIDriverKit/PCIDriverKit.h),
and I will try to download and inspect the code to find some information and try to figure out how to fix my problem.
Best Regards,
Charles
Topic:
App & System Services
SubTopic:
Drivers
Tags: