我有一个类似的链接列表:
class MemoryCell
{
protected:
unsigned char* _address; // the address offset (in another process)
unsigned int _size; // the size of this memory block
unsigned char* _buffer; // the data
MemoryCell* _next; // points to next memory cell to form linked list
};
然后我有一个MemoryMapper
班级将负责。我想把所有的记忆单元都放进去。
// void MemoryMapper::MapAllCells(unsigned int procId)//
unsigned int offset = 0x0;
while (true)
{
long memoryData = ptrace(PTRACE_PEEKDATA, procId, offset);
if (memoryData == -1) break; // need to check for errno(3) too
// add new MemoryCell w/ data to head of linked list
// how to get next offset based on what was returned?
它在地址 0 处立即中断。我认为该过程可能从 0x0 开始,但我想我需要真正的偏移量。但是我怎样才能得到下一个偏移量(基于前一个的大小)?
希望很清楚,但如果需要我可以澄清谢谢