memory ¤
Reading, writing, and describing memory.
Classes:
-
Page–Represents the address space and page permissions of at least
Functions:
-
round_down–round_down(address, align) -> int
-
round_up–round_up(address, align) -> int
-
format_address–Format the given address as a string.
-
page_align–page_align(address) -> int
-
page_size_align– -
page_offset–
Attributes:
-
PAGE_SIZE– -
PAGE_MASK– -
align_down– -
align_up–
Page ¤
Page(
start: int,
size: int,
flags: int,
offset: int,
arch_ptrsize: int,
objfile: str = "",
in_darwin_shared_cache: bool = False,
protection_key: int | None = None,
vm_flags: list[str] | None = None,
)
Represents the address space and page permissions of at least one page of memory.
Methods:
Attributes:
-
R_OK– -
W_OK– -
X_OK– -
vaddr– -
memsz– -
flags– -
offset– -
objfile–Possible non-empty values of
objfile: -
in_darwin_shared_cache(bool) –Whether this mapping is part of the Darwin Shared Cache.
-
arch_ptrsize– -
protection_key– -
vm_flags– -
start(int) –Mapping start address.
-
end(int) –Address beyond mapping. So the last effective address is self.end-1
-
is_stack(bool) – -
is_heap(bool) – -
is_memory_mapped_file(bool) –Whether this mapping is backed by a named file on disk.
-
read(bool) – -
write(bool) – -
execute(bool) – -
ro(bool) – -
rw(bool) – -
wx(bool) – -
rwx(bool) – -
is_guard(bool) – -
permstr(str) –
objfile class-attribute instance-attribute ¤
Possible non-empty values of objfile: - Contains square brackets "[]" if it's not a memory mapped file. Examples: [stack], [vsyscall], [heap], [vdso] - A path to a file, such as /usr/lib/libc.so.6
in_darwin_shared_cache instance-attribute ¤
Whether this mapping is part of the Darwin Shared Cache.
This is an interesting property to know, as these entries may not be useful to us at all times, and having an easy way to filter them out is helpful..
end property ¤
Address beyond mapping. So the last effective address is self.end-1 It is the same as displayed in /proc/
is_memory_mapped_file property ¤
Whether this mapping is backed by a named file on disk.
Returns True when objfile is a real filesystem path (e.g. /usr/lib/libc.so.6). Returns False for kernel-virtual regions whose names are wrapped in square brackets — [stack], [heap], [vdso], [anon_shmem], etc. — because those are not files that can be opened or parsed as ELF objects.
round_down ¤
round_down(address, align) -> int
Round down address to the nearest increment of align.
round_up ¤
round_up(address, align) -> int
Round up address to the nearest increment of align.
format_address ¤
format_address(
vaddr: int,
memsz: int,
permstr: str,
offset: int,
ptrsize: int,
objfile: str | None = None,
) -> str
Format the given address as a string.
page_align ¤
page_align(address) -> int
Round down address to the nearest page boundary.