ModuleInfoο
A single module β executable or shared library β loaded in a process.
from PyMemoryEditor import ModuleInfo
ModuleInfo is a @dataclass(frozen=True) returned by process.get_modules().
Each entry corresponds to a file mapped into the address space β the main
executable plus every shared library it loaded (.dll on Windows, .so on
Linux, .dylib on macOS).
Fieldsο
- class ModuleInfo(name, path, base_address, size=0, raw=None)ο
- name: strο
File name of the module (e.g.
"game.exe","libc.so.6"). May be an empty string on macOS for an image whose path canβt be resolved (seepath).
- path: strο
Full path of the backing file on disk. On Windows it falls back to
namewhen only the name is available. On macOSnameis derived frompath, so when the path canβt be read bothpathandnameare empty strings (no fallback is possible).
- base_address: intο
Address where the module is loaded for this run. Combine it with a static offset (
base_address + offset) to reach a known location despite ASLR β the natural feed intoresolve_pointer_chain().
- size: intο
Size of the module in memory, in bytes.
0when the backend cannot determine it. The meaning is platform-specific:Windows β full module image (
modBaseSize).Linux β mapped span (covers
.data/.bss).macOS β
__TEXTsegment size; a single whole-module size is ill-defined for dyld-shared-cache dylibs.
- raw: Anyο
Underlying platform handle/key used to look up the module β the
MODULEENTRY32.hModuleon Windows, the mapped path on Linux, the Mach-O load address on macOS. Useful for advanced callers that need to make follow-up OS-specific calls.
Examplesο
Listing every moduleο
with OpenProcess(process_name="game.exe") as process:
for module in process.get_modules():
print(f"{module.name:32} 0x{module.base_address:016X} {module.size:>12}")
Finding the main executableο
main = next(m for m in process.get_modules() if m.name.endswith(".exe"))
print(f"{main.name} loaded at 0x{main.base_address:X}")
Using base_address as a pointer-chain rootο
module = next(m for m in process.get_modules() if m.name == "game.exe")
hp_addr = process.resolve_pointer_chain(
module.base_address + 0x10F4F4, [0x0, 0x158],
)
See also