IOKit.framework

I/O Kit is a low-level framework communicating with hardware or kernel services. Although it is a public framework, Apple discourages developers from using it, and any apps using it will be rejected from App Store.

IOService

Code using I/O Kit usually follows this pattern:

// Get the service named "AppleNANDFTL".
CFMutableDictionaryRef matching = IOServiceMatching("AppleNANDFTL");
io_service_t service = IOServiceGetMatchingService(kIOMasterPortDefault, matching);// Open a connection to the AppleNANDFTL service
io_connect_t connect;
kern_return_t errcode = IOServiceOpen(service, mach_task_self(),0,&connect);// Send some message to the service and get the result.// using one of the IOConnectCall*** methods.if(errcode ==0){
size_t infoSize;
size_t osize =sizeof(infoSize);
errcode = IOConnectCallStructMethod(
connect, 0xFE000200,// selectorNULL,0,// input&infoSize,&osize);// outputif(errcode ==0){void* info = malloc(infoSize);
IOConnectCallStructMethod(connect, 0xFE000100,NULL,0, info,&infoSize);// do_something_with(info);
free(info);}
IOServiceClose(connect);}
IOObjectRelease(service);