当我尝试为驱动程序打开服务(根据SimpleUserClient 示例使用用户客户端)时,IOServiceOpen 返回 0x10000003(MACH_SEND_INVALID_REQUEST
):
mach_port_t machPort = mach_task_self();
kern_return_t kernResult;
io_service_t service;
classesToMatch = IOServiceNameMatching(DRIVER_NAME);
kernResult = IOServiceGetMatchingServices(kIOMasterPortDefault, classesToMatch, &iterator);
while ((service = IOIteratorNext(iterator)) != IO_OBJECT_NULL){
kernResult = IOServiceOpen(service, machPort, 0, &connect);
if (kernResult != KERN_SUCCESS){
//0x10000003 = MACH_SEND_INVALID_DEST causes a return false here
fprintf(stderr, "IOServiceOpen returned 0x%08x - machPort is %lu\n"), kernResult, machPort);
return false;
}
}
因此,该服务永远不会打开。