I wish to manipulate data on a very low level.
Therefore I have a function that receives a virtual memory address as an integer and “does stuff” with this memory address. I interfaced this function from C, so it has the type (CUInt -> a).
The memory I want to link is a Word8 in a file. Sadly, I have no idea how to access the pointer value to that Word8.
To be clear, I do not need the value of the Word8, i need the value to the virtual memory address, which is the value of the pointer to it.
For the sake of a simple example, say you want to add an offset to the pointer.
Front matter:
Yes, you wrote that you don’t want the value of the
Word8, but I’ve retrieved it withpeekto demonstrate that the pointer is valid. You might be tempted toreturnthePtrfrom insidewithForeignPtr, but the documentation warns against that:The code is straightforward:
To approximate “a
Word8in a File” from your question, the main program memory-maps a file and uses that buffer to do stuff with memory addresses.Output: