Platform SDK: Debugging and Error Handling

SymGetSymFromName

The SymGetSymFromName function locates a symbol for the specified name.

This function is implemented as a wrapper that calls SymGetSymFromName64. For more information, see New 64-bit Functions.

BOOL SymGetSymFromName(
  HANDLE hProcess,          
  PSTR Name,               
  PIMAGEHLP_SYMBOL Symbol  
);

For SymGetSymFromName64, the parameter list is as follows.

BOOL SymGetSymFromName64(
  HANDLE hProcess,          
  PSTR Name,               
  PIMAGEHLP_SYMBOL64 Symbol  
);

Parameters

hProcess
[in] Handle to the process that was originally passed to the SymInitialize function.
Name
[in] Pointer to a null-terminated string that specifies the symbol name for which a symbol is to be located.
Symbol
[out] Pointer to an IMAGEHLP_SYMBOL structure.

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

The SymGetSymFromName function is used to locate a symbol for a specified name. The name can contain a module prefix that isolates the symbol search to a single module's symbol table.

The module prefix is in the form of "module!". The "!" character is the delimiter between the module name and the symbol name. If there is no module prefix, then the search is performed on each module's symbol table in a linear manner, beginning with the first module that is loaded.

Using the module prefix is preferable for two reasons. First, the symbol search occurs much faster. Second, when deferred symbol loading is turned on, the search causes symbols to be loaded for each module that is searched. When the symbol is found, the symbol information is copied into the Symbol buffer provided by the caller. The caller must allocate the Symbol buffer properly and fill in the required parameters in the IMAGEHLP_SYMBOL structure before calling SymGetSymFromName.

Requirements

  Windows NT/2000: Requires Windows NT 4.0 or later.
  Windows 95/98: Requires Windows 95 or later. Available as a redistributable for Windows 95.
  Header: Declared in Dbghelp.h.
  Library: Use Dbghelp.lib.

See Also

Debug Help Library Overview, DbgHelp Functions, IMAGEHLP_SYMBOL, SymInitialize