Windows Prefetch files, introduced in Windows XP, are designed to speed up the application startup process. Prefetch files contain the name of the executable, a Unicode list of DLLs used by that executable, a count of how many times the executable has been run, and a timestamp indicating the last time the program was run. Although Prefetch is present in Windows 2003, by default it is only enabled for boot prefetching. The feature is also found in Windows Vista, where it has been augmented with SuperFetch, ReadyBoot, and ReadyBoost. For SSD drives Prefetch is disabled by default .
Up to 128 Prefetch files are stored in the %SystemRoot%\Prefetch directory . Each file in that directory should contain the name of the application, a dash, and then an eight character hash of the location from which that application was run, and a .pf extension. The filenames should be all uppercase except for the extension. The format of hashes is not known. A sample filename for md5deep would look like: MD5DEEP.EXE-4F89AB0C.pf. If an application is run from two different locations on the drive (i.e. the user runs C:\md5deep.exe and then C:\Apps\Hashing\md5deep.exe), there will be two different prefetch files in the Prefetch folder.
- 1 File format
- 2 Prefetch hash
- 3 Timestamps
- 4 MetaData
- 5 Registry Keys
- 6 See Also
- 7 External Links
- 8 Tools
Each Prefetch file has a 4-byte signature (at offset 4) "SCCA" (or in hexadecimal notation 0x53 0x43 0x43 0x41). The signature is assumed to be preceded by a 4-byte format version indicator:
- 17 (0x00000011) for Windows XP and Windows 2003
- 23 (0x00000017) for Windows Vista, Windows 2008, Windows 7 and Windows 2012 (note Windows 2012 has not been confirmed)
- 26 (0x0000001a) for Windows 8.1 (note this could be Windows 8 as well but has not been confirmed)
For more information about the file format see: Windows Prefetch File Format
There are multiple known hashing functions to be used for prefetch file filename hashing, namely:
- SCCA XP hash function; used on Windows XP and Windows 2003
- SCCA Vista hash function; used on Windows Vista
- SCCA 2008 hash function; used on Windows 2008, Windows 7, (possibly: Windows 2012) and Windows 8 (including 8.1)
SCCA XP hash function
A Python implementation of the SCCA XP hash function:
def ssca_xp_hash_function(filename): hash_value = 0 for character in filename: hash_value = ((hash_value * 37) + ord(character)) % 0x100000000 hash_value = (hash_value * 314159269) % 0x100000000 if hash_value > 0x80000000: hash_value = 0x100000000 - hash_value return (abs(hash_value) % 1000000007) % 0x100000000
SCCA Vista hash function
A Python implementation of the SCCA Vista hash function:
def ssca_vista_hash_function(filename): hash_value = 314159 for character in filename: hash_value = ((hash_value * 37) + ord(character)) % 0x100000000 return hash_value
SCCA 2008 hash function
A Python implementation of the SCCA 2008 hash function:
def ssca_2008_hash_function(filename): hash_value = 314159 filename_index = 0 filename_length = len(filename) while filename_index + 8 < filename_length: character_value = ord(filename[filename_index + 1]) * 37 character_value += ord(filename[filename_index + 2]) character_value *= 37 character_value += ord(filename[filename_index + 3]) character_value *= 37 character_value += ord(filename[filename_index + 4]) character_value *= 37 character_value += ord(filename[filename_index + 5]) character_value *= 37 character_value += ord(filename[filename_index + 6]) character_value *= 37 character_value += ord(filename[filename_index]) * 442596621 character_value += ord(filename[filename_index + 7]) hash_value = ((character_value - (hash_value * 803794207)) % 0x100000000) filename_index += 8 while filename_index < filename_length: hash_value = (((37 * hash_value) + ord(filename[filename_index])) % 0x100000000) filename_index += 1 return hash_value
Both the NTFS timestamps for a Prefetch file and the timestamp embedded in each Prefetch file contain valuable information. The timestamp embedded within the Prefetch file is a 64-bit (QWORD) FILETIME object The creation date of the file indicates the first time the application was executed. Both the modification date of the file and the embedded timestamp indicate the last time the application was executed.
Windows will store timestamps according to a Windows file time.
The creation time does not have a static offset on any Windows platform. The location of the creation time can be found using the offset 0x8 + length of Volume path offset. See section Volume for more information.
Last Run Time
A timestamp of when the application was last ran is embedded into the Prefetch file. The offset from the beginning of the file to the "Last Run Time" is located:
- at offset 0x78 on Windows XP and Windows 2003.
- at offset 0x80 on Windows Vista, Windows 7, and Windows 8 (up to 8 entries for Windows 8).
In each Prefetch file, the size of the header is stored and can be found at offset 0x54 on Windows XP, Windows Vista, and Windows 7. The header size for Windows XP is 0x98 (152) and 0xf0 (240) on Windows Vista and Windows 7.
The Prefetch file will embed the executable's name, up to 29 characters, into the header at offset 0x10.
The run count, or number of times the application has been run, is a 4-byte (DWORD) value located at offset 0x90 from the beginning of the file on Windows XP. On Windows Vista and Windows 7, the run time can be found at 0x98.
Volume related information, volume path and volume serial number, are embedded into the Prefetch file. The precise offset for this information is the same for each Prefetch file and Windows operating system. In the header at offset 0x6c, the location of the volume path is stored. The location is a 4-bytes (DWORD) value.
At the location given from offset 0x6c, a 4-byte value is stored which is the number of bytes from current offset (location from offset 0x6c) to the beginning of the volume path string. The location from the offset 0x6c, for ease of reading, will be called the "volume path offset." The volume path is embedded as an UTF-16 encoded string.
The length of the volume path string is a 4-byte value is located at volume path offset + 0x4.
The volume serial number is a 4-byte value that identifies a media storage. A serial number does not have a consistent offset within a Prefetch between Windows operating systems. The 4-byte value can be found eight (8) bytes from the creation time location. The vol command on Windows can verify the volume serial number.
End of File
The end of file (EOF) for each Prefetch file is located at offset 0xc. The location of EOF also denotes the size of the Prefetch file.
Embedded within each Prefetch file are files and directories that were used doing the application's startup. The Prefetch file separates both filenames and directories into two different location in the file. Each string is encoded as a UTF-16 string. Windows operating system uses UTF-16 encoding.
The offset to the first set of filenames are at 0x64. The size of the first set of filenames can be found at offset 0x68. Both offsets are consistent between Windows XP, Windows Vista and Windows 7.
In the bottom section of the Prefetch file are UTF-16 strings of directories. At the time of this writing (7/2011), the precise offset and size of the directory listing is unknown. The distance between the end of the Volume Path string and the beginning of the directory strings is given. An approach to finding the offset to the beginning of the directories listing is to obtain the distance value and the offset when the Volume Path string ends (after the NULL bytes). The distance value is at volume path offset + 0x18 (24). The distance is a 4-byte (DWORD) value. The end of second set of strings will complete the Prefetch file. The size of the directory listing is calculated by subtracting the start position of the directory listing from the end of file position.
Key: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management\PrefetchParameters
The EnablePrefetcher Registry value can be used to disable prefetch.
- More detail from Microsoft
- Wikipedia Prefetcher
- MSDN: Disabling Prefetch
- Kernel Enhancements for Windows XP, by Microsoft, January 13, 2003 (Microsoft's description of Prefetch when Windows XP was introduced)
- Misinformation and the The Prefetch Flag, MSDN Blogs, May 25, 2005
- Prefetch file metadata, by Harlan Carvey, July 13, 2005
- Prefetch files, revisited, by Harlan Carvey, April 13, 2006
- Support and Q&A for Solid-State Drives, by Steven Sinofsky, May 5, 2009
- De-mystifying Defrag: Identifying When Defrag Has Been Used for Anti-Forensics (Part 1 - Windows XP), by Chad Tilbury, August 5, 2009
- Windows Prefetch File (old blog entry from 42 LLC), by Yogesh Khatri, April 14, 2010
- Decoding Prefetch Files for Forensic Purposes: Part 1, by Mark Wade, December 8, 2010
- Prefetch Files at Face Value, by Mark Wade, April 11, 2011
- Windows Logical Prefetcher, TTS blog, July 30, 2011 (article is in Russian)
- Prefetch i niedokładny licznik by Paweł Hałdrzyński, August 20, 2011 (article in Polish; uncertain about the year of publication)
- Prefetch Analysis, Revisited, by Harlan Carvey, March 8, 2012
- Prefetch Analysis, Revisited...Again..., by Harlan Carvey, March 15, 2012
- Prefetch Hash Calculator + a hash lookup table xp/vista/w7/w2k3/w2k8, Hexacorn blog, June 13, 2012
- Prefetch file names and UNC paths, Hexacorn blog, October 29, 2012
- NTOSBOOT Prefetch File, by Corey Harrell, December 5, 2012
- What's New in the Prefetch for Windows 8??, by Jared Atkinson, September 21, 2013
- Windows Prefetch (.PF) files, by Yogesh Khatri, October 21, 2013
Free - Non Open Source
- PrefetchForensics, PrefetchForensics is an application to extract information from Windows Prefetch files
- Prefetch-Parser, Parse the prefetch files and display information
- Windows File Analyzer - Parses Prefetch files, thumbnail databases, shortcuts, index.dat files, and the recycle bin
- Windows Prefetch Parser (pf), Free tool that can be run on Windows, Linux or Mac OS-X
- prefetch-tool, Script to extract information from windows prefetch folder