Jordan72 said:
I was directed to kexts as a solution by a Unix guy, but he only knew the Intel way. So Mac gurus, I'm part way to my goal.
What's the next step? How do I get a pointer to my first address in memory so I can read and write any address on my hard drive?
Will addresses be different on different machines? I have an iBook G4. Will I run into a hardware address such as the keyboard I can't write to? Can someone give some idea where the memory is?
Walking up a disk is trivial. Find the
/dev/disk? "file" for the disk (where ? is an integer). Open that file and use
seek() to perform the walk. Ensure that you close the file when you are done.
Walking through memory is generally a very, very bad idea. But this should also be possible using /dev/mem in a similar way to the disk walk.
You should not try to write to any location on your disk since you are very likely to end up corrupting your filesystem.
In terms of finding the address at which each file starts, this depends on the file system in use. For HFS+ file systems then you can only do this by walking through the filesystem finding each file inode and reading out the address.
It sounds like you are trying to code up a disk data visualizer and/or editor. If so, then you will need to spend some time reading up on file systems. An important point to remember is that a entire file is not stored in a continuous block on the disk. The file is sliced up into fixed size blocks (I think 4096K by default) and then each of these blocks is stored whereever there is space.
Rather than walking the disk you can find the locations of all files by directly reading off the inode tables then traversing the inode graph. In this approach, you assume that the disk is empty except for blocks that are specifically referenced in the inode graph. You also need to remember that the first few sectors of the disk are occupied by the partition table.