# API Reference: Windows Prefetch Analysis Tools ## Prefetch File Format ### Location ``` C:\Windows\Prefetch\ ``` ### Filename Convention ``` EXECUTABLE_NAME-XXXXXXXX.pf ``` - `EXECUTABLE_NAME` - Uppercase name of the executed program - `XXXXXXXX` - Hash of the executable path (8 hex characters) - `.pf` - Prefetch file extension ### Version History | Version | Windows OS | Notes | |---------|-----------|-------| | 17 | XP | Basic format | | 23 | Vista, 7 | Added run count, timestamps | | 26 | 8, 8.1 | Extended timestamps (8 entries) | | 30 | 10, 11 | MAM compressed, 8 timestamps | ### Header Structure (Uncompressed) | Offset | Size | Field | |--------|------|-------| | 0 | 4 | Version | | 4 | 4 | Signature (SCCA) | | 12 | 4 | File size | | 16 | 60 | Executable name (UTF-16LE) | | 76 | 4 | Prefetch hash | ## PECmd (Eric Zimmerman) - Full Parser ### Syntax ```bash PECmd.exe -f # Single file PECmd.exe -d # Entire directory PECmd.exe -d --csv # Export to CSV PECmd.exe -d --json # Export to JSON PECmd.exe -f -q # Quiet mode ``` ### Output Fields | Field | Description | |-------|-------------| | `SourceFilename` | Original executable path | | `RunCount` | Number of times executed | | `LastRun` | Most recent execution timestamp | | `PreviousRun0-7` | Up to 8 previous run timestamps (Win8+) | | `FilesLoaded` | DLLs and files accessed during execution | | `Directories` | Directories accessed | | `VolumeSerialNumber` | Volume where executable resided | ## WinPrefetchView (NirSoft) ### GUI Features - Lists all prefetch files with execution details - Shows run count, timestamps, referenced files - Export to CSV, HTML, or text - Sort by any column for analysis ## Python Prefetch Parsing ### Structure Parsing ```python import struct with open("APP.EXE-HASH.pf", "rb") as f: data = f.read() version = struct.unpack_from(" prefetch_timeline.csv ```