| Crates.io | hwbp |
| lib.rs | hwbp |
| version | 0.1.2 |
| created_at | 2025-05-17 14:56:59.981001+00 |
| updated_at | 2025-05-22 18:30:48.210086+00 |
| description | A fully-featured Rust library for managing hardware breakpoints on Windows via x86 debug registers. |
| homepage | https://github.com/imunproductive/hwbp |
| repository | https://github.com/imunproductive/hwbp |
| max_upload_size | |
| id | 1677932 |
| size | 41,456 |
A fully-featured Rust library for managing hardware breakpoints on Windows via x86 debug registers.
HWBP provides a clean API to set, manage, and handle hardware breakpoints for watching memory execution, read & write access.
All of the following limitations are due to the hardware limitations of x86/AMD64 architecture.
First things first, you need to initialize the library:
hwbp::init();
This will initialize the exception handler. However, if you have one already, you can call dispatch_exception instead.
Now you need to obtain Context from current thread:
let mut ctx = Context::current().unwrap();
You can also obtain Context from a specific thread:
let mut ctx = Context::for_thread(42).unwrap();
Once you have a Context, you can create a new HWBP using Context::unused method:
let mut x = 0;
let hwbp = ctx
.unused()
.unwrap()
.watch_variable_write(&x, |_| {
println!("callback!")
})
.unwrap()
.with_enabled(true)
.build()
.unwrap();
You can also make up any HWBP you want:
let mut hwbp = ctx
.unused()
.unwrap()
.with_enabled(true)
.with_address(0x12345678)
.with_condition(Condition::ReadWrite)
.with_size(Size::EightBytes)
.with_callback(|_| {
println!("callback!")
})
.build_and_set()
.unwrap();
This will create a new HWBP and set it to context, however, not yet applied to the current thread.
ctx.apply_for_current_thread().expect("Failed to apply");
Voila!
For more examples, check out the examples directory!
To free the library you just call free:
hwbp::free();