} // end ChangeEngineState() public int ChangeSymbolState(DEBUG_CSS Flags, ulong Argument) { try { if ((0 != (int)(Flags & (DEBUG_CSS.LOADS | DEBUG_CSS.UNLOADS)))) { // If we load symbols using DbgEng's Reload command, it will send // us back an Argument of 0, and we'll be forced to throw away everything. // But in at least some other cases it faithfully passes along the // base address - we still don't know which target it is for, but it is // at least for no more than one module. m_debugger.DiscardCachedModuleInfo(Argument); // TODO: BUGBUG: To do this right requires knowing the current // context, AND being able to get the dbghelp handle for it. When // we call into our DbgHelp wrapper to dump synthetic type info, // we want to be able to look it up by hProc (the pseudo handle to // the process) (which if we could call into dbgeng, we would get // by calling IDebugSystemObjects.GetCurrentProcessHandle, but // that's a no-no here). Instead we just dump synthetic type info // for all processes. m_debugger.BumpSymbolCookie(modBase: Argument); } // end if( we need to update module info ) if ((0 != (int)(Flags & DEBUG_CSS.SCOPE))) { // TODO: I don't really know what a change in symbol "scope" // means... but its one of the things that gets fired when I do // "Invoke-DbgEng '.reload /f msvcrt.dll'", so I guess I need to // refresh symbol info when that happens. Need to ask dbgsig about // the proper way to detect symbol reload. m_debugger.DiscardCachedModuleInfo(); } if ((0 != (int)(Flags & DEBUG_CSS.PATHS))) { m_debugger.m_sympath = null; } // Re: m_loadingImageHack: this is where the AV in dbgeng occurs. var eventArgs = new SymbolStateChangedEventArgs(m_debugger, Flags, Argument); int retVal = _RaiseEvent(m_debugger.SymbolStateChanged, eventArgs); if (_ShouldOutput(retVal, eventArgs)) { _PsPipe.WriteObject(eventArgs); } return(retVal); } catch (Exception e) { Util.FailFast("Unexpected exception during event callback.", e); return(0); } } // end ChangeSymbolState()
} // end ChangeEngineState() public int ChangeSymbolState(DEBUG_CSS Flags, ulong Argument) { try { if ((0 != (int)(Flags & (DEBUG_CSS.LOADS | DEBUG_CSS.UNLOADS)))) { // I have seen Arguments be 0 (on wow64, with no symbol server in // the symbol path), which caused a problem, although I don't // quite understand how. The symptom was that symbols appeared not // to be loaded, not only when doing "lm" (because refreshing the // module whose base address is 0 resulted in not refreshing any // module info), but also when trying to get some type information // from dbghelp--SymGetTypeInfo would return S_FALSE. I suspect // the reason for the latter might be related to lots of extra // ".reload /f" from _EnsureSymbolsLoaded, which happened because // we hadn't properly refreshed the module info. // I wish we could refresh just the info for the module specified // by Argument, but we don't know what target this event is for, // and we can't call into dbgeng to find out. m_debugger.DiscardCachedModuleInfo(); // TODO: BUGBUG: To do this right requires knowing the current // context, AND being able to get the dbghelp handle for it. When // we call into our DbgHelp wrapper to dump synthetic type info, // we want to be able to look it up by hProc (the pseudo handle to // the process) (which if we could call into dbgeng, we would get // by calling IDebugSystemObjects.GetCurrentProcessHandle, but // that's a no-no here). Instead we just dump synthetic type info // for all processes. m_debugger.BumpSymbolCookie(modBase: Argument); } // end if( we need to update module info ) if ((0 != (int)(Flags & DEBUG_CSS.SCOPE))) { // TODO: I don't really know what a change in symbol "scope" // means... but its one of the things that gets fired when I do // "Invoke-DbgEng '.reload /f msvcrt.dll'", so I guess I need to // refresh symbol info when that happens. Need to ask dbgsig about // the proper way to detect symbol reload. m_debugger.DiscardCachedModuleInfo(); } if ((0 != (int)(Flags & DEBUG_CSS.PATHS))) { m_debugger.m_sympath = null; } var eventArgs = new SymbolStateChangedEventArgs(m_debugger, Flags, Argument); int retVal = _RaiseEvent(m_debugger.SymbolStateChanged, eventArgs); if (_ShouldOutput(retVal, eventArgs)) { _PsPipe.WriteObject(eventArgs); } return(retVal); } catch (Exception e) { Util.FailFast("Unexpected exception during event callback.", e); return(0); } } // end ChangeSymbolState()