#pe #dll #bin #exe #file-format #load-file #mui

no-std bin+lib pelite

轻量级、内存安全、零分配的库,用于读取和遍历 PE 二进制文件

15 个版本 (9 个破坏性版本)

0.10.0 2022年11月4日
0.9.1 2022年6月18日
0.9.0 2020年9月5日
0.8.1 2020年4月15日
0.1.0 2016年2月23日

#278解析器实现

Download history 3411/week @ 2024-03-14 2928/week @ 2024-03-21 3584/week @ 2024-03-28 2718/week @ 2024-04-04 2132/week @ 2024-04-11 2474/week @ 2024-04-18 3119/week @ 2024-04-25 3515/week @ 2024-05-02 3103/week @ 2024-05-09 3171/week @ 2024-05-16 2949/week @ 2024-05-23 2669/week @ 2024-05-30 3143/week @ 2024-06-06 2572/week @ 2024-06-13 2800/week @ 2024-06-20 1692/week @ 2024-06-27

每月下载量10,774
用于 27 个包(19 个直接使用)

MIT 许可证

485KB
9K SLoC

包含 (Windows DLL,30KB) demo/Demo64.dll,(Windows DLL,28KB) demo/Demo.dll,(Windows exe,1KB) tests/tiny/tiny.128,(Windows exe,1KB) tests/tiny/tiny.168,(Windows exe,1KB) tests/tiny/tiny.296,(Windows exe,1KB) tests/tiny/tiny.356 等7个文件 更多信息

PeLite

MIT License crates.io docs.rs Changelog Build status Build Status

轻量级、内存安全、零分配的库,用于读取和遍历 PE 二进制文件。

设计

该库的目的是检查 PE 二进制文件(无论是在磁盘上还是已加载到内存中)。

由于以下两个原因,没有统一 32 位 (PE32) 和 64 位 (PE32+) 格式:

  • 存在一些微小但不可兼容的差异,这会导致即使源代码级别的匹配分支看起来相同,也需要进行恒等匹配,从而增加开销。

  • 通常你(在构建时)就知道你正在使用哪种格式。

这使得同时透明地处理这两种格式相当困难。

请注意,虽然正确的名称是 PE32+,但使用 PE64 作为名称,因为它是一个有效的标识符;它们在其他方面是同义的。

工具

包含一些演示库用途的 bin 文件,在演示中试用它们!

该库可在 crates.io 上找到。

文档可在 docs.rs 上找到。

在你的 Cargo.toml 中,添加以下内容:

[dependencies]
pelite = "0.8"

示例

尝试以下示例: cargo run --example readme

use pelite::FileMap;
use pelite::pe64::{Pe, PeFile};

fn main() {
	// Load the desired file into memory
	let file_map = FileMap::open("demo/Demo64.dll").unwrap();
	// Process the image file
	dll_deps(file_map.as_ref()).unwrap();
}

fn dll_deps(image: &[u8]) -> pelite::Result<()> {
	// Interpret the bytes as a PE32+ executable
	let file = PeFile::from_bytes(image)?;

	// Let's read the DLL dependencies
	let imports = file.imports()?;
	for desc in imports {
		// Get the DLL name being imported from
		let dll_name = desc.dll_name()?;
		// Get the number of imports for this dll
		let iat = desc.iat()?;
		println!("imported {} functions from {}", iat.len(), dll_name);
	}

	Ok(())
}

许可证

根据 MIT 许可证 许可,请参阅 license.txt

贡献

除非你明确表示,否则任何有意提交以包含在作品中并由你提交的贡献,都应按照上述许可证许可,不附加任何额外的条款或条件。

依赖关系