private bool DoCallsExternalCode(Call call, ref string name) { if (call.Target.Name == "Invoke" && call.Target.HasThis) { int i = call.GetThisIndex(m_info); Log.DebugLine(this, "found invoke call at {0:X2}", call.Untyped.Offset); if (i >= 0) { LoadField load = m_info.Instructions[i] as LoadField; if (load != null) { Log.DebugLine(this, " this pointer is at {0:X2}", load.Untyped.Offset); if (load.Field.FieldType.IsSameOrSubclassOf("System.Delegate", Cache)) { Log.DebugLine(this, " and is a delegate type"); name = load.Field.ToString(); return true; } } } } return false; }
private TypeReference DoGetThisType(Call call) { TypeReference self = null; if (call.Target.HasThis) { int index = call.GetThisIndex(m_info); if (index >= 0) { do { LoadArg arg = m_info.Instructions[index] as LoadArg; if (arg != null) { self = arg.Type; break; } LoadField field = m_info.Instructions[index] as LoadField; if (field != null) { self = field.Field.FieldType; break; } LoadStaticField sfield = m_info.Instructions[index] as LoadStaticField; if (sfield != null) { self = sfield.Field.FieldType; break; } LoadLocal local = m_info.Instructions[index] as LoadLocal; if (local != null) { self = local.Type; break; } } while (false); } } return self; }
public void VisitCall(Call call) { if (m_fields.Count > 0 && !m_info.Method.IsConstructor && call.Target.HasThis) { int index = call.GetThisIndex(m_info); if (index >= 0) { LoadStaticField load = m_info.Instructions[index] as LoadStaticField; if (load != null && m_fields.IndexOf(load.Field) >= 0) { Entry entry = m_table[load.Field]; if (m_adders[entry.Key].IndexOf(call.Target.Name) >= 0) { if (!DoIsNullSet(call.Index, call.Target.Name)) { if (!entry.FoundAdd) { Log.DebugLine(this, "found an add at {0:X2}", call.Untyped.Offset); entry.FoundAdd = true; } } else { if (!entry.FoundRemove) { Log.DebugLine(this, "found a null set at {0:X2}", call.Untyped.Offset); entry.FoundRemove = true; } } } if (!entry.FoundRemove) { if (m_removers[entry.Key].IndexOf(call.Target.Name) >= 0) { Log.DebugLine(this, "found a remove at {0:X2}", call.Untyped.Offset); entry.FoundRemove = true; } } } } } }
public void VisitCall(Call call) { if (m_needsCheck && m_offset < 0 && call.Target.HasThis) { int index = call.GetThisIndex(m_info); if (index >= 0) { Log.DebugLine(this, "found this arg at {0:X2}", m_info.Instructions[index].Untyped.Offset); LoadArg load = m_info.Instructions[index] as LoadArg; if (load != null) { bool found; if (m_table.TryGetValue(load.Name, out found)) { if (!found) { m_offset = call.Untyped.Offset; m_badArg = load.Name; Log.DebugLine(this, "bad call at {0:X2}", m_offset); } } } } } }
public void VisitCall(Call call) { if (m_needsCheck) { Log.Indent(); // See if an arg is being used as a this pointer, if (call.Target.HasThis) { int index = call.GetThisIndex(m_info); if (index >= 0) { LoadArg load = m_info.Instructions[index] as LoadArg; if (load != null && m_types[load.Arg] != null) { TypeReference tr = call.Target.GetDeclaredIn(Cache); TypeDefinition type = Cache.FindType(tr); if (type != null && type.ExternallyVisible(Cache)) { Log.DebugLine(this, "found type {0}", type.FullName); if (!type.Name.StartsWith("_")) // can get weird stuff like System.Runtime.InteropServices._Type otherwise { DoUseArg(load.Arg, call.Untyped.Offset, type); } else if ("_" + load.Type.Name != type.Name) { DoUseArg(load.Arg, call.Untyped.Offset, type); } } } } } // See if an arg is being used as an arg. for (int nth = 0; nth < call.Target.Parameters.Count; ++nth) { int index = m_info.Tracker.GetStackIndex(call.Index, nth); if (index >= 0) { LoadArg load = m_info.Instructions[index] as LoadArg; if (load != null && m_types[load.Arg] != null) { int argIndex = call.Target.Parameters.Count - nth - 1; TypeReference type = call.Target.Parameters[argIndex].ParameterType; DoUseArg(load.Arg, call.Untyped.Offset, type); } } } Log.Unindent(); } }