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 (see path).

path: str

Full path of the backing file on disk. On Windows it falls back to name when only the name is available. On macOS name is derived from path, so when the path can’t be read both path and name are 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 into resolve_pointer_chain().

size: int

Size of the module in memory, in bytes. 0 when the backend cannot determine it. The meaning is platform-specific:

  • Windows β€” full module image (modBaseSize).

  • Linux β€” mapped span (covers .data / .bss).

  • macOS β€” __TEXT segment 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.hModule on 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],
)