Example #1
0
        bool OnLoadModule(DebugEventBreakpointConditionContext ctx)
        {
            var lmArgs = (LoadModuleDebugCallbackEventArgs)ctx.EventArgs;
            var mod    = lmArgs.CorModule;

            if (mod is null || mod.IsDynamic || mod.IsInMemory)
            {
                return(false);
            }
            var  filename = mod.Name;
            uint epToken  = GetEntryPointToken(filename);

            if ((Table)(epToken >> 24) != Table.Method || (epToken & 0x00FFFFFF) == 0)
            {
                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);

            SetILBreakpoint(moduleId, epToken);
            return(false);
        }
Example #2
0
        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);
        }
Example #3
0
        bool OnLoadOtherModule(DebugEventBreakpointConditionContext ctx)
        {
            var lmArgs = (LoadModuleDebugCallbackEventArgs)ctx.EventArgs;
            var mod    = lmArgs.CorModule;

            if (!IsModule(mod, otherModuleFullName) || mod.Assembly != thisAssembly)
            {
                return(false);
            }
            debugger.RemoveBreakpoint(breakpoint);
            breakpoint = null;

            string otherModuleName;
            uint   epToken = GetEntryPointToken(otherModuleFullName, out otherModuleName);

            if (epToken != 0 && (Table)(epToken >> 24) == Table.Method)
            {
                SetILBreakpoint(mod.SerializedDnModule, epToken);
                return(false);
            }

            return(true);
        }
Example #4
0
        bool OnLoadModule(DebugEventBreakpointConditionContext ctx)
        {
            var lmArgs = (LoadModuleDebugCallbackEventArgs)ctx.EventArgs;
            var mod    = lmArgs.CorModule;

            if (mod is null || mod.IsDynamic || mod.IsInMemory)
            {
                return(false);
            }

            uint memberToken = 0;

            if (type == BreakProcessKind.ModuleCctorOrEntryPoint)
            {
                memberToken = GetGlobalStaticConstructor(mod.GetMetaDataInterface <IMetaDataImport>());
            }

            if (memberToken == 0)
            {
                var  filename = mod.Name;
                uint epToken  = GetEntryPointToken(filename);
                if ((Table)(epToken >> 24) != Table.Method || (epToken & 0x00FFFFFF) == 0)
                {
                    return(false);
                }
                memberToken = epToken;
            }

            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);

            SetILBreakpoint(moduleId, memberToken);
            return(false);
        }
Example #5
0
        bool OnLoadOtherModule(DebugEventBreakpointConditionContext ctx)
        {
            var lmArgs = (LoadModuleDebugCallbackEventArgs)ctx.EventArgs;
            var mod    = lmArgs.CorModule;

            if (!IsModule(mod, otherModuleFullName) || mod.Assembly != thisAssembly)
            {
                return(false);
            }
            debugger.RemoveBreakpoint(breakpoint);
            breakpoint = null;

            uint epToken = GetEntryPointToken(otherModuleFullName, out string otherModuleName);

            if (epToken != 0 && (Table)(epToken >> 24) == Table.Method)
            {
                Debug.Assert(!mod.IsDynamic && !mod.IsInMemory);
                // It's not a dyn/in-mem module so id isn't used
                SetILBreakpoint(mod.GetModuleId(uint.MaxValue), epToken);
                return(false);
            }

            return(true);
        }
Example #6
0
		bool OnLoadOtherModule(DebugEventBreakpointConditionContext ctx) {
			var lmArgs = (LoadModuleDebugCallbackEventArgs)ctx.EventArgs;
			var mod = lmArgs.CorModule;
			if (!IsModule(mod, otherModuleFullName) || mod.Assembly != thisAssembly)
				return false;
			debugger.RemoveBreakpoint(breakpoint);
			breakpoint = null;

			string otherModuleName;
			uint epToken = GetEntryPointToken(otherModuleFullName, out otherModuleName);
			if (epToken != 0 && (Table)(epToken >> 24) == Table.Method) {
				SetILBreakpoint(mod.SerializedDnModule, epToken);
				return false;
			}

			return true;
		}
Example #7
0
		bool OnLoadModule(DebugEventBreakpointConditionContext ctx) {
			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 == BreakProcessKind.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(DebugEventBreakpointKind.LoadModule, OnLoadOtherModule);
						return false;
					}
				}
			}

			// Failed to set BP. Break to debugger.
			return true;
		}
Example #8
0
		bool HitHandler(DebugEventBreakpointConditionContext ctx) {
			if (cond == null)
				return true;

			Debug.Assert(ctx.DebugEventBreakpoint == dbgBreakpoint);

			var dectx = ctx.EventArgs.TryCreateDebugEventContext(debugger);
			if (dectx == null)
				return false;
			return cond(this, dectx);
		}