brstoker/pe-version-reader 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

brstoker/pe-version-reader

Composer 安装命令:

composer require 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.

README 文档

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-zip
  • ext-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

统计信息

  • 总下载量: 0
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 6
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-03-31

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固