SymGetModuleBase function (dbghelp.h)

Retrieves the base address of the module that contains the specified address.

Syntax

DWORD IMAGEAPI SymGetModuleBase(
  [in] HANDLE hProcess,
  [in] DWORD  dwAddr
);

Parameters

[in] hProcess

A handle to the process that was originally passed to the SymInitialize function.

[in] dwAddr

The virtual address that is contained in one of the modules loaded by the SymLoadModule64 function.

Return value

If the function succeeds, the return value is a nonzero virtual address. The value is the base address of the module containing the address specified by the dwAddr parameter.

If the function fails, the return value is zero. To retrieve extended error information, call GetLastError.

Remarks

The module table is searched for a module that contains dwAddr. The module is located based on the load address and size of each module.

All DbgHelp functions, such as this one, are single threaded. Therefore, calls from more than one thread to this function will likely result in unexpected behavior or memory corruption. To avoid this, you must synchronize all concurrent calls from more than one thread to this function.

This function supersedes the SymGetModuleBase function. For more information, see Updated Platform Support. SymGetModuleBase is defined as follows in DbgHelp.h.

#if !defined(_IMAGEHLP_SOURCE_) && defined(_IMAGEHLP64)
#define SymGetModuleBase SymGetModuleBase64
#else
DWORD
IMAGEAPI
SymGetModuleBase(
    __in HANDLE hProcess,
    __in DWORD dwAddr
    );
#endif

Requirements

Requirement Value
Target Platform Windows
Header dbghelp.h
Library Dbghelp.lib
DLL Dbghelp.dll
Redistributable DbgHelp.dll 5.1 or later

See also

DbgHelp Functions

SymInitialize

SymLoadModule64