• Stars
    star
    280
  • Rank 147,492 (Top 3 %)
  • Language
    Rust
  • License
    MIT License
  • Created over 7 years ago
  • Updated about 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Lightweight, memory-safe, zero-allocation library for reading and navigating PE binaries.

PeLite

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

Lightweight, memory-safe, zero-allocation library for reading and navigating PE binaries.

Design

The purpose of this library is inspecting PE binaries (whether on disk or already loaded in memory).

A trade-off was made to not unify the 32-bit (PE32) and 64-bit (PE32+) formats for two reasons:

  • There are small but incompatible differences, which would add overhead by requiring constant matching even if at source code level the match arms look identical.

  • Most of the time you know (at build time) what format you're working with anyway.

This makes it rather awkward to work with both formats together transparently.

Note that while the correct name is PE32+, the name PE64 is used as it is a valid identifier; they are otherwise synonymous.

Tools

Included are bins showing some uses for the library, try them out on the demos!

Library

This library is available on crates.io.

Documentation can be found on docs.rs.

In your Cargo.toml, put

[dependencies]
pelite = "0.8"

Examples

Try this example: 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(())
}

License

Licensed under MIT License, see license.txt.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, shall be licensed as above, without any additional terms or conditions.

More Repositories

1

apexdream

Apex Legends external cheat for UnKnoWnCheaTs in Rust
Rust
462
star
2

obfstr

Compiletime string literal obfuscation for Rust.
Rust
443
star
3

fmtools

Fast, minimal, feature-rich, extended formatting syntax for Rust!
Rust
68
star
4

external

Windows external process interaction, WIP
Rust
40
star
5

ProjectileSolverDemo

Hitting a moving target with a ballistic projectile
Rust
34
star
6

SourceProtect

Provides basic protection against malicious servers as well as prevents servers from being annoying.
25
star
7

LibEx

C++ Helper Library for myself
C++
24
star
8

lde

Length disassembler for x86 and x86_64 in Rust.
Rust
24
star
9

format_xml

Minimal compiletime templating for XML in Rust!
Rust
21
star
10

capcom0

Rust bindings to the infamous Capcom driver.
Rust
20
star
11

vigem-client

ViGEm client API in pure Rust.
Rust
17
star
12

struct_layout

Customize your struct layout with this one weird trick
Rust
14
star
13

bitset-core

Straightforward, no-std compatible, simd optimized, BitSet API.
Rust
12
star
14

pekit

PE viewer web application
Vue
12
star
15

OpenPlugin

client plugin for tf2/css doing various things
C++
10
star
16

ini_core

Streaming INI parser for no_std Rust
Rust
9
star
17

dataview

Safe transmute between types and byte arrays of the same size.
Rust
9
star
18

intptr

Rust
8
star
19

wineh

Windows SEH for Rust
Rust
8
star
20

cvar

Configuration Variables for Rust
Rust
6
star
21

named_constants

Makes enums behave like named constants in languages like C/C++ or C#.
Rust
5
star
22

websocket-protocol

WebSocket Protocol Library for Rust
Rust
5
star
23

com-rs

Windows COM for Rust
Rust
5
star
24

urandom

Produce and consume randomness, to convert them to useful types and distributions, and some randomness-related algorithms.
Rust
5
star
25

pupil-rs

Arithmetic expression evaluator in Rust
Rust
4
star
26

wbem-rs

COM Bindings for Web-Based Enterprise Management, I'm not even kidding.
Rust
3
star
27

PotatoClipEditor

Potato Clip Editor
JavaScript
3
star
28

UntitledDataFormat

UDF is a simple, self-describing, structured binary file format for storing arrays and their relationships.
Rust
3
star
29

q3mod

Quake3 external cheat
Rust
2
star
30

shade

Vector graphics API.
Rust
2
star
31

SourceServerQuery

C++ Library for querying Source game servers.
C++
2
star
32

vgcolors

Video game colors library
Rust
2
star
33

ringbuf

Rust
2
star
34

vision

Vision is a simple WebApp to draw a custom overlay.
Rust
2
star
35

adventofcode2018

My casual participation of https://adventofcode.com/2018
Rust
2
star
36

phantasm

Web client for the Phantasm project.
Vue
2
star
37

aurascope

A WebApp for live HTML visualization
Vue
2
star
38

ansi-gfx

ANSI Graphics Colors made easily printable
Rust
2
star
39

mphf

An exercise in implementing minimally perfect hash functions.
Rust
1
star
40

cvmath

Computer Graphics Math Library
Rust
1
star
41

Vue-Script

Vue Single File Components without the insanity that comes with the NPM ecosystem.
Rust
1
star
42

program-proxy

The program acts as a proxy for another program or script.
Rust
1
star
43

adventofcode2019

Advent of Code for 2019!
Rust
1
star
44

trigger

Manage variables transitioning between simple boolean states
Rust
1
star
45

pak-rs

Encrypted archive based on Quake's PAK format
Rust
1
star
46

PupilSharp

Pupil calculator in C#
C#
1
star
47

hexdump-rs

Hex dump utility.
Rust
1
star
48

pak

Encrypted archive based on Quake's PAK format
Rust
1
star
49

ExtPlugin

Extended Plugin for TF2
C++
1
star
50

programming-problems-rs

https://adriann.github.io/programming_problems.html in Rust
Rust
1
star
51

tetrs

Tetris clone written in Rust
Rust
1
star
52

Pupil

Arithmetic expression evaluator in C/C++
C++
1
star
53

align_data

Simply increase the alignment of any statics or include_bytes!
Rust
1
star