lundi 29 juin 2015

C equivalent of IOMemoryDescriptor class


I'm writing some C code using IOKit, and need to use IOMemoryDescriptor methods. Unfortunately, I can only compile pure C sources, and that is a C++ class. So, I'm asking if there is some C interface that lets me perform the same operations.

Specifically, I want a function that does pretty much this, but that can be compiled as C:

#include <IOKit/IOMemoryDescriptor.h>
extern "C" void CopyOut(mach_vm_address_t src, void *dst, size_t size)
{
    IOMemoryDescriptor *memDesc;
    memDesc = IOMemoryDescriptor::withAddressRange(src, size, kIODirectionOut, current_task());
    // Error checking removed for brevity
    memDesc->prepare();
    memDesc->readBytes(0, dst, size);
    memDesc->complete();
    memDesc->release();
}


Aucun commentaire:

Enregistrer un commentaire