sensepost / objection

📱 objection - runtime mobile exploration
GNU General Public License v3.0
7.42k stars 852 forks source link

Fix mem dump #520

Closed CDuPlooy closed 2 years ago

CDuPlooy commented 2 years ago

This PR adds chunking to the memory dump functions. The core logic is here:

# I changed this so that the BLOCK_SIZE is a parameter instead of a constant
def _get_chunks(addr: int, size: int) -> List:
  if size > BLOCK_SIZE:
    block_count = size // BLOCK_SIZE
    extra_block = size % BLOCK_SIZE
    ranges = []
    current_address = addr
    for i in range(block_count):
      ranges.append((current_address, BLOCK_SIZE))
      current_address += BLOCK_SIZE
    if extra_block != 0:
      ranges.append((current_address, extra_block))
    return ranges
  else:
    return [(addr, size)]

The tuple list that's returned is the offset to start dumping from and the size for that block, thus avoiding the 128MiB limit in glib. This hopefully closes #516.

GetCode747 commented 2 years ago

I appreciate your helping me.You were right. I solved my problem.