Platform SDK: Debugging and Error Handling |
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 SymLoadModule 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.
char szImageName[MAX_PATH+1]; DWORD dwBaseAddr; if (SymLoadModule(hProcess, NULL, szImageName, NULL, dwBaseAddr, 0)) { // SymLoadModule returned success } else { // SymLoadModule failed error = GetLastError(); printf("SymLoadModule 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.