Initializing the Symbol Handler

Debug Help Library

Initializing the Symbol Handler

The following code demonstrates how to initialize the symbol handler. The SymSetOptions function defers symbol loading until symbol information is requested. The code loads the symbols for each module in the specified process by passing a value of TRUE for the bInvade parameter of the SymInitialize function. (This function calls the SymLoadModule64 function for each module the process has mapped into its address space.)

If the specified process is not the process that called SymInitialize, the code passes a process identifier as the first parameter of SymInitialize.

Specifying NULL as the second parameter of SymInitialize indicates that the symbol handler should use the default search path to locate symbol files. For detailed information on how the symbol handler locates symbol files or how an application can specify a symbol search path, see Symbol Paths.

DWORD  error;
HANDLE hProcess;
DWORD  processId;

SymSetOptions(SYMOPT_UNDNAME | SYMOPT_DEFERRED_LOADS);

hProcess = GetCurrentProcess();
// hProcess = (HANDLE)processId;

if (SymInitialize(hProcess, NULL, TRUE))
{
    // SymInitialize returned success
}
else
{
    // SymInitialize failed
    error = GetLastError();
    printf("SymInitialize returned error : %d\n", error);
}

Send comments about this topic to Microsoft

Build date: 9/25/2007

© 2007 Microsoft Corporation. All rights reserved.