brstoker / pe-version-reader
Extract version info from Windows PE files (.exe, .dll, .sys) and archives (.zip, .tar.gz) on any OS. No WinAPI required.
Requires
- php: ^8.1
- ext-phar: *
- ext-zip: *
- illuminate/support: ^10.0|^11.0|^12.0
This package is auto-updated.
Last update: 2026-05-01 00:08:48 UTC
README
A cross-platform Laravel package for extracting version information from Windows PE files (.exe, .dll, .sys) and archives (.zip, .tar.gz, .rar, .7z). Works on Linux, macOS, and Windows without WinAPI.
Requirements
- PHP 8.1+
- Laravel 10, 11, or 12
ext-zipext-phar
Optional (for archive formats)
| Format | Requirement |
|---|---|
.zip |
ext-zip (included in PHP by default) |
.tar.gz |
ext-phar (included in PHP by default) |
.rar |
unrar binary |
.7z |
7z / 7za binary |
Installing binaries
Linux (Debian/Ubuntu)
apt install unrar p7zip-full
macOS
brew install rar p7zip
Windows
Download and install WinRAR and 7-Zip. Make sure their directories are added to PATH, or the package will attempt to find them at their default installation paths automatically.
Installation
composer require vendor/pe-version-reader
Laravel will auto-discover the service provider via package auto-discovery.
If auto-discovery is disabled, register the provider manually in bootstrap/providers.php:
Brstoker\PeVersionReader\PeVersionReaderServiceProvider::class,
Usage
Basic — auto-detect file type
use Brstoker\PeVersionReader\PeVersionReader; $reader = app(PeVersionReader::class); $info = $reader->read('/path/to/filename.zip'); $info = $reader->read('/path/to/filename.exe'); $info = $reader->read('/path/to/library.dll'); $info = $reader->read('/path/to/driver.sys');
Explicit methods
// PE file directly $info = $reader->readExe('/path/to/filename.exe'); // Archive — looks for a PE file matching the archive name in the archive root $info = $reader->readZip('/path/to/filename.zip');
Working with the result
$info = $reader->read('/path/to/filename.zip'); if ($info === null) { // PE file with matching name was not found inside the archive } // Version strings echo $info->fileVersion; // "1.0.39.0" echo $info->productVersion; // "1.0.39" // Version parts echo $info->fileMajor; // 1 echo $info->fileMinor; // 0 echo $info->fileBuild; // 39 echo $info->filePatch; // 0 echo $info->productMajor; // 1 echo $info->productMinor; // 0 echo $info->productBuild; // 39 echo $info->productPatch; // 0 // Metadata echo $info->companyName; // "Acme Corp" echo $info->productName; // "filename" echo $info->fileDescription; // "filename updater" echo $info->originalFilename; // "filename.exe" echo $info->internalName; // "filename" echo $info->legalCopyright; // "Copyright (C) 2026" echo $info->comments; // null // Full array $info->toArray();
toArray() returns:
[
'file_version' => '1.0.39.0',
'product_version' => '1.0.39',
'file_version_parts' => [
'major' => 1,
'minor' => 0,
'build' => 39,
'patch' => 0,
],
'product_version_parts' => [
'major' => 1,
'minor' => 0,
'build' => 39,
'patch' => 0,
],
'company_name' => 'Acme Corp',
'product_name' => 'filename',
'file_description' => 'filename updater',
'original_filename' => 'filename.exe',
'internal_name' => 'filename',
'legal_copyright' => 'Copyright (C) 2026',
'comments' => null,
]
How it works
PE files (.exe, .dll, .sys)
The package reads the binary file directly and locates the VS_VERSION_INFO resource embedded in the PE format. Version numbers are extracted from the VS_FIXEDFILEINFO structure, and string fields (company name, product name, etc.) are parsed from the StringFileInfo block. No WinAPI calls are made — the parser works entirely in pure PHP on any OS.
Archives (.zip, .tar.gz)
The package looks for a PE file in the root of the archive whose name (without extension) matches the archive name. For example, filename.zip must contain filename.exe, filename.dll, or filename.sys at the root level. Matching is case-insensitive. Once found, the file is extracted to a temporary directory, parsed, and the temp directory is cleaned up automatically.
Archives (.rar, .7z)
Same name-matching logic applies. Extraction is handled by shelling out to unrar (for .rar) or 7z / 7za (for .7z). The package auto-detects the binary location, including default installation paths on Windows (C:\Program Files\WinRAR\, C:\Program Files\7-Zip\).
| Exception | When |
|---|---|
InvalidArgumentException |
Unsupported file extension passed to read() |
FileNotFoundException |
File does not exist at the given path |
RuntimeException |
Archive cannot be opened or extraction failed |
UnsupportedFormatException |
Required binary not found (unrar, 7z) |
Supported formats summary
| Format | Driver | External dependency |
|---|---|---|
.exe .dll .sys |
Pure PHP PE parser | None |
.zip |
ext-zip |
None |
.tar.gz |
ext-phar |
None |
.rar |
unrar shell |
unrar binary |
.7z |
7z shell |
7z / 7za binary |
License
MIT