[](https://crates.io/crates/hmod)
[](https://docs.rs/hmod)

[](https://github.com/tim-weis/hmod) <!-- see https://www.designpieces.com/palette/github-color-palette-hex-and-rgb/ -->
 <!-- see https://www.color-hex.com/color-palette/1023458 -->
# `hmod`
Know your `HMODULE`!
This library provides a straightforward way to retrieve the [`HMODULE` (or `HINSTANCE`)](https://devblogs.microsoft.com/oldnewthing/20040614-00/?p=38903) identifying the module that contains the currently executing code. It reliably determines the module handle, whether linked into a DLL, an EXE, or an intermediate `rlib`.
## Usage
Display the main module's load address:
```rust
fn main() {
let load_addr = hmod::current();
println!("Load address: {load_addr:#?}");
}
```
Load a cursor from the module's resources section:
```rust
use windows_sys::{w, Win32::UI::WindowsAndMessaging::LoadCursorW};
let cursor = unsafe { LoadCursorW(hmod::current(), w!("unicorn")) };
```