I am working on a DriverKit project and the new class OSMappedFile sounds like something I am looking for, at least from what I understood from the description in the header file. https://developer.apple.com/documentation/driverkit/osmappedfile
I've tried different combinations, however the method OSMappedFile::createFromPath always returns an error 0xe00002bc (general error), which is not helpful at all.
Could you please provide more details about the class and how to use it? Is it possible to open an arbitrary file in an arbitrary location? Does the owner of the file matter? Does the entitlements have to be modified somehow?
Thanks for reply
I am testing it on Monterey 12.3.1, my driver is linking DriverKit 21.0, no provisioning profile, SIP is off.
Pulling the conversation from the comments back out to an answer for clarity. Instead of using OSMappedFile::createFromPath
, try getting the file from an OSBundle
like so:
OSMappedFile* myMappedFile = nullptr;
OSBundle* myBundle = OSBundle::mainBundle();
myBundle->loadResources("configfile.conf", 0, IOVMPageSize * sizeToFit, &myMappedFile);
This should work without requiring any additional entitlements, and without having to know any GUIDs.