hmod

Crates.iohmod
lib.rshmod
version0.1.1
created_at2025-08-07 09:39:13.570987+00
updated_at2025-08-07 09:39:13.570987+00
descriptionReliably discovers the module handle of the current PE image
homepage
repositoryhttps://github.com/tim-weis/hmod
max_upload_size
id1784994
size29,077
Tim Weis (tim-weis)

documentation

README

crates.io docs.rs msrv repository platform support

hmod

Know 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.

Usage

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")) };
Commit count: 0

cargo fmt