I am new to using IOKit and noticed that I think this is a sandbox, due to which it fails.
Here is the test I'm trying (in Pascal) that works fine outside of the sandbox, but when I turn it on, IOServiceOpen returns a kIORturnNotPermitted error every time.
Is IOKit safe in the sandbox for certain services? I tried to get some fan speeds / CPU temperatures, and I see that there are applications in the AppStore (sandbox), so I think this is possible. The only thing I could confirm seems to be the XPC service associated with the application as an assistant, so maybe the key to IOKit? I tried basically all the rights, and none of them seemed to help.
Thanks for any ideas you may have.
procedure TestIOKit;
var
err: kern_return_t;
masterPort: mach_port_t;
iterator: io_iterator_t;
device: io_object_t;
matchingDictionary: CFMutableDictionaryRef;
conn: io_connect_t;
begin
IOMasterPort(0, masterPort);
matchingDictionary := IOServiceMatching('AppleSMC');
err := IOServiceGetMatchingServices(masterPort, matchingDictionary, iterator);
if err <> kIOReturnSuccess then
writeln('IOServiceGetMatchingServices: ', err);
device := IOIteratorNext(iterator);
IOObjectRelease(iterator);
if device = 0 then
writeln('no smc found');
err := IOServiceOpen(device, mach_task_self_, 0, conn);
if err <> kIOReturnSuccess then
writeln('IOServiceOpen: ', err);
end;
source
share