Alternate function for IOMemoryDescriptor::withAddress ?

Hi ,
I am trying to write dext code for my existing Kext , i see "IOMemoryDescriptor::withAddress" being used , I dont find any alternatives in "DriverKit", Is there any others ways to achieve this,

Any input is appriciated ,

Thanks,
revan
Answered by in 669970022
Code Block C++
uint8_t data = { 1, 2, 3, 4 };
uint64_t dataSize = 4;
IOBufferMemoryDescriptor* buffer = nullptr;
uint8_t pipeMaxPacketSize = 0;
uint64_t addressValue = 0;
uint64_t length = 0;
ivars->interface->CreateIOBuffer(kIOMemoryDirectionInOut, pipeMaxPacketSize, &buffer);
(buffer)->Map(0, 0, 0, 0, &addressValue, &length);
memcpy((uint8_t*)addressValue, data, dataSize);

Accepted Answer
Code Block C++
uint8_t data = { 1, 2, 3, 4 };
uint64_t dataSize = 4;
IOBufferMemoryDescriptor* buffer = nullptr;
uint8_t pipeMaxPacketSize = 0;
uint64_t addressValue = 0;
uint64_t length = 0;
ivars->interface->CreateIOBuffer(kIOMemoryDirectionInOut, pipeMaxPacketSize, &buffer);
(buffer)->Map(0, 0, 0, 0, &addressValue, &length);
memcpy((uint8_t*)addressValue, data, dataSize);

I agree with the necessity of that function "IOMemoryDescriptor::withAddress" in DriverKit

Hi,

BufferMemoryDescriptorAME_Module = NULL;

IOMemoryMap *MemMap;

BufferMemoryDescriptorAME_Module= IOBufferMemoryDescriptor::inTaskWithPhysicalMask(

                                 // task to hold the memory

                                 kernel_task,

                                 // options

                                 kIOMemoryPhysicallyContiguous,

                                 // size

                                 Total_memory_size)

        BufferMemoryDescriptorAME_Module->prepare(kIODirectionInOut);

        MemMap = BufferMemoryDescriptorAME_Module->map(kIOMapInhibitCache);

        logicalAddressAME_Module = (UInt8 *) MemMap->getVirtualAddress();

        physicalAddressAME_Module = MemMap->getPhysicalAddress();

I am trying to write Dext code for my existing Kext,How to convert this code to be compatible with Dext?

Thanks,

Frederic

Hi,

`BufferMemoryDescriptorAME_Module = NULL;

IOMemoryMap *MemMap;

BufferMemoryDescriptorAME_Module= IOBufferMemoryDescriptor::inTaskWithPhysicalMask(

                                 // task to hold the memory



                                 kernel_task,



                                 // options



                                 kIOMemoryPhysicallyContiguous,



                                 // size



                                 Total_memory_size)



        BufferMemoryDescriptorAME_Module->prepare(kIODirectionInOut);



        MemMap = BufferMemoryDescriptorAME_Module->map(kIOMapInhibitCache);



        logicalAddressAME_Module = (UInt8 *) MemMap->getVirtualAddress();



        physicalAddressAME_Module = MemMap->getPhysicalAddress();

`

I am trying to write Dext code for my existing Kext,How to convert this code to be compatible with Dext?

Thanks,

Frederic

Alternate function for IOMemoryDescriptor::withAddress ?
 
 
Q