Install & Compatibility
Where this runs
tested against v1.2.6 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslpy 3.10–3.95 runs
installs and imports cleanly · install 0.0s · import 0.000s · 40.5MB
glibcpy 3.10–3.95 runs
installs and imports cleanly · install 3.0s · import 0.000s · 41MB
39MB installed
● package 39MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
dump_file
✓ import pcodedmp
✗ from pcodedmp import dump_file
This quickstart demonstrates how to use `pcodedmp` to disassemble VBA p-code from an Office document. It shows how to call the `dump_file` function and capture its output. Replace the placeholder `document_path` with an actual path to a `.docm`, `.xlsm`, or `.pptm` file containing VBA macros. The example gracefully handles `FileNotFoundError` and other exceptions.
import os
import io
import sys
from pcodedmp.pcodedmp import dump_file
# This library processes existing Office documents containing VBA macros.
# Replace 'path/to/your/document.docm' with the actual path to your target file.
# For example, create a simple .docm file with a basic macro (e.g., MsgBox 'Hello').
#
# If the file does not exist, the library will raise a FileNotFoundError.
# This example is designed to be runnable and show the expected output,
# whether it's successful disassembly or an error due to a missing file.
document_path = "path/to/your/document.docm" # Replace with a real path if you have one.
# Capture stdout to inspect the disassembly output without writing to console
original_stdout = sys.stdout
captured_output = io.StringIO()
sys.stdout = captured_output
try:
print(f"Attempting to disassemble VBA p-code from: {document_path}")
# The dump_file function writes output to sys.stdout by default.
# You can also specify an output file: dump_file(document_path, output_file=open('output.txt', 'w'))
dump_file(document_path)
# Get the captured output
output_lines = captured_output.getvalue().strip().split('\n')
print("\n--- Disassembly Attempt Result ---")
if output_lines and output_lines[0].startswith('VBA p-code disassembler'): # Check for actual content
print("\n".join(output_lines[:10])) # Print first 10 lines of actual disassembly
if len(output_lines) > 10:
print("...")
print(f"(Full output length: {len(output_lines)} lines)")
else:
# No relevant output from disassembly, likely an error message from the library itself
print("No relevant disassembly output. See error messages below if any.")
except FileNotFoundError:
print(f"\nERROR: Input file not found at '{document_path}'.")
print("Please replace 'path/to/your/document.docm' with a valid path to an Office document containing VBA.")
except Exception as e:
print(f"\nAn unexpected error occurred: {e}")
finally:
sys.stdout = original_stdout # Restore original stdout
print("\nQuickstart finished. Check the 'Disassembly Attempt Result' above.")
pcodedmp --version
Upgrade
Version history
1.2.6latest on PyPI · released Jul 30, 2019
Audit
Dependencies
olefilerequiredRequired for parsing OLE2 and Open XML file formats used by Microsoft Office documents.