I’ve got some declares where I’m doing this kind of thing…
addressMB is a 4-byte MemoryBlock created for the sole purpose of holding the address of AnotherMemoryBlock.
addressMB.Ptr(0) = AnotherMemoryBlock
When I want to fiddle with bytes in the middle of AnotherMemoryBlock, I calculate the location for fiddling by adding an offset to the address stored in addressMB, like so,
location = addressMB.Long(0) + offset
and I pass that location as an Integer to some declares that are expecting a pointer to a C string or other memory structure.
All of which works fine. But I’m wondering about the 4-byte/Long(0) part and whether this should work fine.
I dusted this code off from several years ago, when my computer only had 2 GB of RAM, but now that I’m on a 64-bit Mac with 32 GB of RAM I’m wondering how the Long(0) which returns a 4-byte value from a 4-byte addressMB manages to work as a pointer to a memory address that could easily be larger than 4 bytes can hold.
Maybe it’s not working fine, at least some of the time. Maybe it only appears to be working fine, and my computer’s about to crash at any moment.
Do I need to change the way I’m doing these declares, and/or change the way I’m storing and accessing pointers to use, say, an 8-byte MemoryBlock and Int64Value(0) instead of Long(0)? And, if so, do I need to do some #If Target64Bit switching to do different things on, e.g., 32-bit Linux vs 64-bit OS X?
Can anyone enlighten me?
Confused, ignorant, and worried in Florida