A minimal and fast zero-copy parser for the PE32+ file format.

Overview

peview

A minimal and fast zero-copy parser for the PE32+ file format.

Build status Docs.rs Crates.io

Goal

This project aims to offer a more light weight and easier to use alternative to fully featured binary parsing libraries when it comes to parsing the PE32+ file format. It does so by:

  • Taking a zero-copy approach. Everything is a reference to the original data
  • Parsing on demand. Basic parsing is done at the beginning, the rest is opt-in
  • Not focusing on endianness. The parsed buffer is assumed to be in LE
  • Strongly validating native structures according to the official specification
  • Having no external dependencies on top of being a no-std library

Usage

Example of printing the RVA's and names of imported symbols:

use peview::{dir::Import, file::PeView};
use std::{error::Error, fs::File, io::Read};

fn main() -> Result<(), Box<dyn Error>> {
    // Read file into buffer and parse it
    let mut buf = Vec::new();
    File::open("etc/ntoskrnl.exe")?.read_to_end(&mut buf)?;
    let pe = PeView::parse(&buf)?;

    // Iterate over modules in the import table
    for m in pe.imports()? {
        // Print the current modules name
        let module = m?;
        println!("{}", module.name()?);

        // Iterate over symbols within the module
        for i in module {
            // Check if the symbol is imported by name
            if let Import::Name(h, n) = i? {
                // Print out both the hint and its name
                println!("> {:#04x}: {}", h, n);
            }
        }
    }

    Ok(())
}

More usage examples can be found here.

Installation

Add the following line to your Cargo.toml file:

[dependencies]
# ...
peview = "0.2.0"

License

MIT

You might also like...
A pure-rust(with zero dependencies) fenwick tree, for the efficient computation of dynamic prefix sums.

indexset A pure-rust(with zero dependencies, no-std) fenwick tree, for the efficient computation of dynamic prefix sums. Background Did you ever have

A library for transcoding between bytes in Astro Notation Format and Native Rust data types.

Rust Astro Notation A library for transcoding between hexadecimal strings in Astro Notation Format and Native Rust data types. Usage In your Cargo.tom

A minimal `syn` syntax tree pretty-printer

prettyplease::unparse A minimal syn syntax tree pretty-printer. Overview This is a pretty-printer to turn a syn syntax tree into a String of well-form

A minimal, reloading SVG viewer a la feh

svgview Usage svgview path/to/some/file.svg Purpose I needed a tool to view SVGs while I work on them in other software. This tool should function sim

A minimal boilerplate for Astro / Vite with the Nannou creative framework (Rust → WASM). Supports multiple sketches + hot-reload.
A minimal boilerplate for Astro / Vite with the Nannou creative framework (Rust → WASM). Supports multiple sketches + hot-reload.

Astro x Nannou Starter astro-nannou-demo-1c.mov 🕹 Try it online! # 0a. Rust language tools open https://www.rust-lang.org/tools/install # 0b. wasm-p

A minimal version of 'grep' implemented in Rust. Exercise in the "The Rust Programming Language" book.

Minigrep - A simple grep-like tool implemented in Rust This simple CLI tool searches for a given pattern in a specified file and as a result, it print

An LR(1) parser generator and visualizer created for educational purposes.
An LR(1) parser generator and visualizer created for educational purposes.

.lr An LR(1) parser generator and visualizer created for educational purposes. Table of Contents What is an LR(1) parser? Why did you make this? How c

Texting Robots: A Rust native `robots.txt` parser with thorough unit testing

Texting Robots Crate texting_robots is a library for parsing robots.txt files. A key design goal of this crate is to have a thorough test suite tested

CSGO demo parser for Python

CSGO demo parser for Python Demo parser for Counter-Strike: Global Offensive. Parser is used to collect data from replay files (".dem" files). The goa

Owner
low level systems programmer
null
Rust library for concurrent data access, using memory-mapped files, zero-copy deserialization, and wait-free synchronization.

mmap-sync mmap-sync is a Rust crate designed to manage high-performance, concurrent data access between a single writer process and multiple reader pr

Cloudflare 97 Jun 26, 2023
A parser for the perf.data format

linux-perf-data This repo contains a parser for the perf.data format which is output by the Linux perf tool. It also contains a main.rs which acts sim

Markus Stange 8 Dec 29, 2022
Djotters is a Djot parser and translater written via parser combinators, in rust.

?? Djotters Turning your Djot (markdown) into lovely HTML! Djotters is here to let you draft up a document and watch it render in real time. If you wa

Anthony Alaribe 4 Mar 26, 2024
A parser for the .map file included in the aimware leak

a utility I wrote to parse the map file included with the recent aimware self-leak. there is also an IDAPython script to import the symbol information into IDA.

unknowntrojan 9 Feb 28, 2023
A personally annotated copy of the "The Rust Programming Language"

Rust Book This is a personally annotated copy of the "The Rust Programming Language"1. Why Rust For me, I've never really been exposed to low-level sy

Matan Lurey 3 Nov 1, 2022
Rust Vector for large amounts of data, that does not copy when growing, by using full `mmap`'d pages.

Large Vector Rust Vector for large amounts of data, that does not copy when growing, by using full mmap'd pages. Maturity I made ths to learn about mm

Wonko der Verständige 21 Apr 23, 2024
A turing-complete programming language using only zero-width unicode characters, inspired by brainfuck and whitespace.

Zero-Width A turing-complete programming language using only zero-width unicode characters, inspired by brainfuck and whitespace. Currently a (possibl

Gavin M 2 Jan 14, 2022
A set of Zero Knowledge modules, written in Rust and designed to be used in other system programming environments.

Zerokit A set of Zero Knowledge modules, written in Rust and designed to be used in other system programming environments. Initial scope Focus on RLN

vac 44 Dec 27, 2022
Code to follow along the "Zero To Production" book on API development in Rust.

Zero To Production / Code (Chapter 10 - Part 1) Zero To Production In Rust is an opinionated introduction to backend development using Rust. This repo

Luca Palmieri 2.8k Dec 31, 2022
Curdleproofs is a zero-knowledge shuffle argument

Curdleproofs Curdleproofs is a zero-knowledge shuffle argument inspired by BG12. Zero-knowledge shuffle arguments can have multiple use cases: Secret

George Kadianakis 43 Dec 10, 2022