#binding #com-interface #api-bindings #windows #dbgeng #rust

dbg-rs

Safe Rust bindings for the COM interfaces of the Windows debugging engine

2 releases

0.1.1 Jan 28, 2025
0.1.0 Jan 28, 2025

#52 in Windows APIs

Download history 183/week @ 2025-01-26 44/week @ 2025-02-02

227 downloads per month

MIT license

29KB
309 lines

dbg-rs 🦀

Rust crate docs Forks Stars License

Safe Rust bindings for the COM interfaces of the Windows debugging engine.

Table of Contents

Features

  • ✅ Safe Rust bindings for Windows debugging interfaces.
  • ✅ Easy-to-use macros for logging to the debugger.
  • ✅ Abstractions for managing symbols, memory, and CPU registers.
  • ✅ Works seamlessly with the Windows COM-based debugging system.

Installation

Add dbg to your project by updating your Cargo.toml:

cargo add dbg-rs

Or manually add the dependency:

[dependencies]
dbg-rs = "<version>"

Usage

The dbg-rs library provides utilities to interact with the Windows debugging engine, such as executing commands, logging messages, and inspecting debug symbols. Below are some common use cases:

Logging to the Debugger

Use the dprintln! macro to send formatted messages to the debugger output:

use dbg_rs::dprintln;

// Example usage
dprintln!(dbg, "Hello, {}!", "Debugger");
dprintln!(dbg, "Number: {}", 42);

Executing Commands

Running commands in the debugger:

use dbg_rs::Dbg;

dbg.exec(".echo Hello, Debugger!")?;

Reading Virtual Memory

Access specific regions of the debugged process's memory:

use dbg_rs::Dbg;

let mut buffer = vec![0u8; 128];
dbg.read_vaddr(0x7FFEBEEF0000, &mut buffer)?;
println!("Read memory: {:?}", &buffer[..16]); // Print first 16 bytes

For more examples, including a WinDbg extension that lists loaded modules, see the examples folder in this repository. 📂

Contributing to dbg-rs

To contribute to dbg-rs, follow these steps:

  1. Fork this repository.
  2. Create a branch: git checkout -b <branch_name>.
  3. Make your changes and commit them: git commit -m '<commit_message>'.
  4. Push your changes to your branch: git push origin <branch_name>.
  5. Create a pull request.

Alternatively, consult the GitHub documentation on how to create a pull request.

License

This project is licensed under the MIT License. See the LICENSE file for details.

Dependencies

~126MB
~2M SLoC