Home

HMODULE

HMODULE is a Windows API type that represents a handle to a loaded module within a process. A module refers to a PE file that has been loaded into the process address space, typically a Dynamic Link Library (DLL) or an executable (EXE). The handle is obtained when a module is loaded via LoadLibrary, LoadLibraryEx, or retrieved with GetModuleHandle or GetModuleHandleEx, and it is used to perform various module-related operations.

Key uses of an HMODULE include retrieving exported symbols and module information. GetProcAddress takes an HMODULE

Lifetime and reference counting are important for HMODULE. Modules are kept loaded while their reference count

Notes: GetModuleHandle(NULL) returns a handle to the executable module of the calling process. HMODULE is an

and
the
name
of
an
exported
function
or
variable
to
return
its
address.
GetModuleFileName
can
be
used
with
an
HMODULE
to
obtain
the
full
path
to
the
module
file.
GetModuleInformation
and
related
APIs
can
report
base
address,
size,
and
other
attributes
of
the
loaded
module.
HMODULE
can
serve
as
a
base
address
for
certain
address
calculations
related
to
the
module.
is
non-zero.
LoadLibrary
increments
the
count,
and
FreeLibrary
decrements
it.
When
the
count
reaches
zero,
the
module
is
unloaded.
After
unloading,
the
HMODULE
becomes
invalid;
it
should
not
be
used
unless
reobtained.
opaque,
pointer-sized
handle
and
is
compatible
across
32-
and
64-bit
applications.
It
is
distinct
from
raw
pointers
to
code
and
should
be
treated
as
a
reference
to
a
loaded
module
rather
than
as
a
direct
memory
address.