SymEnumSymbols function (dbghelp.h)

Enumerates all symbols in a process.

Syntax

BOOL IMAGEAPI SymEnumSymbols(
  [in]           HANDLE                         hProcess,
  [in]           ULONG64                        BaseOfDll,
  [in, optional] PCSTR                          Mask,
  [in]           PSYM_ENUMERATESYMBOLS_CALLBACK EnumSymbolsCallback,
  [in, optional] PVOID                          UserContext
);

Parameters

[in] hProcess

A handle to a process. This handle must have been previously passed to the SymInitialize function.

[in] BaseOfDll

The base address of the module. If this value is zero and Mask contains an exclamation point (!), the function looks across modules. If this value is zero and Mask does not contain an exclamation point, the function uses the scope established by the SymSetContext function.

[in, optional] Mask

A wildcard string that indicates the names of the symbols to be enumerated. The text can optionally contain the wildcards, "*" and "?".

To specify a specific module or set of modules, begin the text with a wildcard string specifying the module, followed by an exclamation point. When specifying a module, BaseOfDll is ignored.

Value Meaning
foo
If BaseOfDll is not zero, then SymEnumSymbols will look for a global symbol named "foo".

If BaseOfDll is zero, then SymEnumSymbols will look for a local symbol named "foo" within the scope established by the most recent call to the SymSetContext function.

foo?
If BaseOfDll is not zero, then SymEnumSymbols will look for a global symbol that starts with "foo" and contains one extra character afterwards, such as "fool" and "foot".

If BaseOfDll is zero, then SymEnumSymbols will look for a symbol that starts with "foo" and contains one extra character afterwards, such as "fool" and "foot". The search would be within the scope established by the most recent call to the SymSetContext function.

foo*!bar
SymEnumSymbols will look in every loaded module that starts with the text "foo" for a symbol called "bar". It could find matches such as these, "foot!bar", "footlocker!bar", and "fool!bar".
*!*
SymEnumSymbols will enumerate every symbol in every loaded module.

[in] EnumSymbolsCallback

A SymEnumSymbolsProc callback function that receives the symbol information.

[in, optional] UserContext

A user-defined value that is passed to the callback function, or NULL. This parameter is typically used by an application to pass a pointer to a data structure that provides context for the callback function.

Return value

If the function succeeds, the return value is TRUE.

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

Remarks

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.

To call the Unicode version of this function, define DBGHELP_TRANSLATE_TCHAR.

Examples

For an example, see Enumerating Symbols.

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

SymEnumSymbolsProc