У меня есть связанный список, подобный этому:
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, но, думаю, мне нужно реальное смещение. Но как я могу получить и следующее смещение (в зависимости от размера предыдущего)?
Надеюсь, это было понятно, но я могу уточнить, если нужно. Спасибо.