pefile is a Python module for parsing and working with Portable Executable (PE) files, commonly found on Windows systems. It allows security analysts and developers to inspect various aspects of PE files, such as sections, imports, exports, resources, and header information. The library is actively maintained, with a recent release (2024.8.26) and frequent updates addressing bugs and adding features, primarily focusing on Python 3.
pip install pefileVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to initialize a `pefile.PE` object from a file, access its headers and sections, and iterate through basic structures like imports. It includes error handling for non-PE files.
Migrate your codebase to Python 3. `pefile` is now Python 3-only, with `future` dependency also removed in v2023.2.7.
Upgrade to `pefile` version 2024.8.26 or newer to ensure correct `PE.get_data()` behavior. If you relied on older behavior, review changes.
Prefer using `pefile`'s public API methods (e.g., `get_data()`) rather than directly manipulating internal attributes like `__data__`. Upgrade to v2024.8.26 to benefit from internal stability fixes.
Always wrap `pefile.PE()` instantiation in a `try...except pefile.PEFormatError` block, and consider a broader `Exception` catch for unexpected issues, as shown in the quickstart.
No dependency data recorded yet.