Loading a Symbol Module

Debug Help Library

Loading a Symbol Module

If an application does not call the SymInitialize function with the fInvadeProcess parameter set to TRUE, it must load symbols for a module when they are required. To load a symbol module on demand, the application can call the SymLoadModuleEx function with a full path to a module name. When the module is loaded, the symbol handler will either load the symbols immediately or defer the load, depending on the options set using the SymSetOptions function.

The following code loads a symbol module. Note that it assumes you have initialized the symbol handler using the code in Initializing the Symbol Handler.

char  szImageName[MAX_PATH];
DWORD64 dwBaseAddr;

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

Note that szImageName can be a path to any executable module that has debugging information (.exe, .dll, .drv, .sys, .scr, .cpl, .com). Also, dwBaseAddr is the base address of the symbol module to be loaded. If this value is 0, the symbol handler will obtain the base address from the specified symbol module.

See Also

Unloading a Symbol Module

Send comments about this topic to Microsoft

Build date: 9/25/2007

© 2007 Microsoft Corporation. All rights reserved.