bool OnLoadModule(BreakpointConditionContext context) { var ctx = (DebugEventBreakpointConditionContext)context; var lmArgs = (LoadModuleDebugCallbackEventArgs)ctx.EventArgs; var mod = lmArgs.CorModule; if (!IsOurModule(mod)) { return(false); } debugger.RemoveBreakpoint(breakpoint); breakpoint = null; var serMod = mod.SerializedDnModule; if (type == BreakProcessType.ModuleCctorOrEntryPoint) { uint cctorToken = MetaDataUtils.GetGlobalStaticConstructor(mod.GetMetaDataInterface <IMetaDataImport>()); if (cctorToken != 0) { SetILBreakpoint(serMod, cctorToken); return(false); } } string otherModuleName; uint epToken = GetEntryPointToken(filename, out otherModuleName); if (epToken != 0) { if ((Table)(epToken >> 24) == Table.Method) { SetILBreakpoint(serMod, epToken); return(false); } if (otherModuleName != null) { Debug.Assert((Table)(epToken >> 24) == Table.File); otherModuleFullName = GetOtherModuleFullName(otherModuleName); if (otherModuleFullName != null) { thisAssembly = mod.Assembly; breakpoint = debugger.CreateBreakpoint(DebugEventBreakpointType.LoadModule, OnLoadOtherModule); return(false); } } } // Failed to set BP. Break to debugger. return(true); }
bool OnLoadModule(DebugEventBreakpointConditionContext ctx) { var lmArgs = (LoadModuleDebugCallbackEventArgs)ctx.EventArgs; var mod = lmArgs.CorModule; if (!IsOurModule(mod)) { return(false); } debugger.RemoveBreakpoint(breakpoint); breakpoint = null; Debug.Assert(!mod.IsDynamic && !mod.IsInMemory); // It's not a dyn/in-mem module so id isn't used var moduleId = mod.GetModuleId(uint.MaxValue); if (type == BreakProcessKind.ModuleCctorOrEntryPoint) { uint cctorToken = MetaDataUtils.GetGlobalStaticConstructor(mod.GetMetaDataInterface <IMetaDataImport>()); if (cctorToken != 0) { SetILBreakpoint(moduleId, cctorToken); return(false); } } uint epToken = GetEntryPointToken(filename, out string otherModuleName); if (epToken != 0) { if ((Table)(epToken >> 24) == Table.Method) { SetILBreakpoint(moduleId, epToken); return(false); } if (otherModuleName != null) { Debug.Assert((Table)(epToken >> 24) == Table.File); otherModuleFullName = GetOtherModuleFullName(otherModuleName); if (otherModuleFullName != null) { thisAssembly = mod.Assembly; breakpoint = debugger.CreateBreakpoint(DebugEventBreakpointKind.LoadModule, OnLoadOtherModule); return(false); } } } // Failed to set BP. Break to debugger. return(true); }