Minidump File Parser

0.0.24 · active · verified Fri Apr 17

minidump is a Python library designed for parsing Windows minidump (.dmp) files. It allows developers and security researchers to programmatically extract information such as modules, threads, handles, and exception data from crash dumps. Currently at version 0.0.24, the library receives updates primarily for bug fixes and feature enhancements related to parsing accuracy and additional stream support.

Common errors

Warnings

Install

Imports

Quickstart

This example demonstrates how to parse a minidump file and access its basic streams like modules, threads, and exception records. It assumes a file named 'example.dmp' exists in the same directory. Note that for actual parsing, 'example.dmp' must be a valid Windows minidump file.

from minidump.minidumpfile import MinidumpFile
import os

# For this example, ensure 'example.dmp' exists in the current directory
# and is a valid Windows minidump file.
# You can create a dummy file for testing, but real parsing requires a valid minidump.
minidump_path = os.path.join(os.path.dirname(__file__), 'example.dmp')

# Create a dummy file if it doesn't exist, though it won't be a valid minidump
# This is just to make the example runnable without crashing on FileNotFoundError
if not os.path.exists(minidump_path):
    with open(minidump_path, 'w') as f:
        f.write('DUMMY MINIDUMP CONTENT - REPLACE WITH REAL .dmp FILE')
    print(f"Warning: '{minidump_path}' created as a dummy. Replace with a real minidump for actual parsing.")

try:
    with open(minidump_path, 'rb') as f:
        md = MinidumpFile.parse(f)
        print(f"Successfully parsed minidump: {minidump_path}")
        
        # Accessing common streams
        if md.modules:
            print(f"\nModules found: {len(md.modules)}")
            for module in md.modules[:5]: # Print first 5 modules
                print(f"  - {module.name} (Base: {hex(module.baseofdll)})")
        
        if md.threads:
            print(f"\nThreads found: {len(md.threads)}")
            for thread in md.threads[:5]: # Print first 5 threads
                print(f"  - TID: {thread.threadid}, EIP: {hex(thread.stack.stackptr)}")

        if md.exceptions:
            print(f"\nException Record found: {md.exceptions.exceptionrecord.exceptioncode}")
            
except FileNotFoundError:
    print(f"Error: Minidump file not found at '{minidump_path}'. Please ensure it exists.")
except Exception as e:
    print(f"An error occurred during parsing: {e}")

# Clean up dummy file if it was created and is still dummy content
if os.path.exists(minidump_path) and os.path.getsize(minidump_path) > 0:
    with open(minidump_path, 'r') as f:
        content = f.read(100) # Read first 100 chars
        if 'DUMMY MINIDUMP CONTENT' in content:
            os.remove(minidump_path)
            print(f"Cleaned up dummy file: '{minidump_path}'.")

view raw JSON →