Enumerating Symbols

Debug Help Library

Enumerating Symbols

The following code displays the name, address, and size of each loaded symbol in the specified module. The SymEnumSymbols function requires a callback function, which will be called once for each module loaded. In this example, EnumSymProc is an implementation of the callback function. The example assumes you have initialized the symbol handler using the code in Initializing the Symbol Handler.

#include <windows.h>
#include <stdio.h>
#include <dbghelp.h>

    PSYMBOL_INFO pSymInfo,   
    ULONG SymbolSize,      
    PVOID UserContext)
    printf("%08X %4u %s\n", 
           pSymInfo->Address, SymbolSize, pSymInfo->Name);
    return TRUE;

void main()
    HANDLE hProcess;
    DWORD64 BaseOfDll;
    char *Mask;

    // TODO: Initialize hProcess, BaseOfDll, and Mask.

    // TODO: Call SymInitialize.

    if (SymEnumSymbols(hProcess, BaseOfDll, Mask, EnumSymProc, NULL))
        // SymEnumSymbols succeeded
        // SymEnumSymbols failed
        printf("SymEnumSymbols failed: %d\n", GetLastError());

Send comments about this topic to Microsoft

Build date: 9/25/2007

© 2007 Microsoft Corporation. All rights reserved.