Home

GetProcAddress

GetProcAddress is a Windows API function that retrieves the address of an exported function or variable from a specified dynamic-link library (DLL) module. It supports dynamic or late binding by allowing a program to resolve function addresses at runtime rather than at load time, enabling plugins, optional features, and runtime binding to DLLs.

The function is declared as FARPROC GetProcAddress(HMODULE hModule, LPCSTR lpProcName). The hModule parameter is a handle

Usage considerations include ensuring the DLL remains loaded for the duration of the call and any subsequent

to
a
loaded
module,
obtained
via
LoadLibrary
or
GetModuleHandle.
The
lpProcName
parameter
specifies
the
export
name
as
an
ANSI
string;
it
can
alternatively
indicate
an
ordinal
value
by
passing
MAKEINTRESOURCE
with
an
ordinal,
in
which
case
the
high-order
word
of
lpProcName
is
zero
and
the
low-order
word
is
the
ordinal.
The
return
value
is
a
pointer
to
the
requested
function
or
variable,
which
should
be
cast
to
the
appropriate
function
pointer
type
by
the
caller.
If
the
function
or
ordinal
is
not
found,
GetProcAddress
returns
NULL
and
the
caller
may
call
GetLastError
to
obtain
more
information,
though
some
implementations
do
not
reliably
set
an
error.
use
of
the
returned
pointer,
and
acknowledging
that
exported
names
are
case-sensitive
in
most
PE
implementations.
GetProcAddress
is
commonly
used
for
implementing
optional
features,
plugin
architectures,
and
compatibility
shims,
as
well
as
for
calling
functions
whose
availability
may
vary
across
Windows
versions
or
configurations.
It
is
used
in
conjunction
with
LoadLibrary
or
GetModuleHandle
and
FreeLibrary
as
part
of
dynamic
linking
practices.
See
also
LoadLibrary,
GetModuleHandle,
and
FreeLibrary.