| Crates.io | hmod |
| lib.rs | hmod |
| version | 0.1.1 |
| created_at | 2025-08-07 09:39:13.570987+00 |
| updated_at | 2025-08-07 09:39:13.570987+00 |
| description | Reliably discovers the module handle of the current PE image |
| homepage | |
| repository | https://github.com/tim-weis/hmod |
| max_upload_size | |
| id | 1784994 |
| size | 29,077 |
hmodKnow your HMODULE!
This library provides a straightforward way to retrieve the HMODULE (or HINSTANCE) 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.
Display the main module's load address:
fn main() {
let load_addr = hmod::current();
println!("Load address: {load_addr:#?}");
}
Load a cursor from the module's resources section:
use windows_sys::{w, Win32::UI::WindowsAndMessaging::LoadCursorW};
let cursor = unsafe { LoadCursorW(hmod::current(), w!("unicorn")) };