本文整理汇总了C#中Mono.Cecil.MethodReference.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# MethodReference.ToString方法的具体用法?C# MethodReference.ToString怎么用?C# MethodReference.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mono.Cecil.MethodReference
的用法示例。
在下文中一共展示了MethodReference.ToString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DoCheck
private void DoCheck(TypedInstruction call, MethodReference target, int nth)
{
int index = m_info.Tracker.GetStackIndex(call.Index, nth);
if (index >= 0)
{
LoadString load = m_info.Instructions[index] as LoadString;
if (load != null)
{
m_offset = call.Untyped.Offset;
m_bad = target.ToString();
Log.DebugLine(this, "bad call at {0:X2}", m_offset);
}
}
}
示例2: DoMatchProperty
private bool DoMatchProperty(MethodReference method)
{
if (method.Name.StartsWith("set_"))
{
if (method.Parameters.Count == 1)
{
if (method.Parameters[0].ParameterType.FullName == "System.String")
{
string name = method.ToString();
foreach (string pattern in m_properties)
{
if (name.Match(pattern))
return true;
}
}
}
}
return false;
}
示例3: GetNameO
string GetNameO(MethodReference mbr)
{
return ObfuscationHelper.GetNewName(mbr.ToString());
}
示例4: GetId
static string GetId(ModuleDefinition mod, MethodReference mtd)
{
char asmRef = (char)(mod.AssemblyReferences.IndexOf(mtd.DeclaringType.Scope as AssemblyNameReference) + 2);
return "\0" + asmRef + mtd.ToString();
}
示例5: DoCallsExternal
private bool DoCallsExternal(MethodReference method, Entry entry, CallGraph graph, List<string> chain, int depth, ref string name)
{
if (depth > 8) // this can't be too large or the rule takes a very long time to run
return false;
chain.Add(method.ToString());
if (entry.ExternalCalls.ContainsKey(method))
{
name = entry.ExternalCalls[method];
return true;
}
foreach (MethodReference candidate in graph.Calls(method))
{
if (DoCallsExternal(candidate, entry, graph, chain, depth + 1, ref name))
return true;
}
chain.RemoveAt(chain.Count - 1);
return false;
}
示例6: GetId
private static string GetId(ModuleDefinition mod, bool isVirt, MethodReference mtd)
{
string virt = isVirt ? "\r" : "\n";
char asmRef = (char)(mod.AssemblyReferences.IndexOf(mtd.DeclaringType.Scope as AssemblyNameReference) + 2);
return "\0" + asmRef + virt + mtd.ToString();
}
示例7: ImportMethodReference
public MethodReference ImportMethodReference(MethodReference mr, ImportContext context)
{
if (mr.DeclaringType.Module == m_module)
return mr;
ImportCache ();
if (mr is MethodSpecification)
return GetMethodSpec (mr, context);
MethodReference meth = m_memberRefCache [mr.ToString ()] as MethodReference;
if (meth != null)
return meth;
meth = new MethodReference (
mr.Name,
mr.HasThis,
mr.ExplicitThis,
mr.CallingConvention);
meth.DeclaringType = ImportTypeReference (mr.DeclaringType, context);
TypeReference contextType = meth.DeclaringType;
while (contextType is TypeSpecification)
contextType = (contextType as TypeSpecification).ElementType;
context.GenericContext.Method = meth;
context.GenericContext.Type = contextType;
foreach (GenericParameter gp in mr.GenericParameters)
meth.GenericParameters.Add (GenericParameter.Clone (gp, context));
meth.ReturnType.ReturnType = ImportTypeReference (mr.ReturnType.ReturnType, context);
foreach (ParameterDefinition param in mr.Parameters)
meth.Parameters.Add (new ParameterDefinition (
ImportTypeReference (param.ParameterType, context)));
m_module.MemberReferences.Add (meth);
m_memberRefCache [mr.ToString ()] = meth;
return meth;
}
示例8: GetMethodReference
MethodReference GetMethodReference (MethodReference source)
{
string name = source.ToString ();
MethodReference result;
if (!methodsrefs_cache.TryGetValue (name, out result)) {
TypeReference tr = GetTypeReference (source.DeclaringType, false);
if (source is GenericInstanceMethod) {
GenericInstanceMethod mr = source as GenericInstanceMethod;
mr.ElementMethod = GetMethodReference (mr.ElementMethod);
VisitParameterDefinitionCollection (mr.Parameters);
result = mr;
} else
result = GetMethodReferenceForType (tr, source);
methodsrefs_cache.Add (name, result);
}
return result;
}
示例9: DoFoundBadSetter
private bool DoFoundBadSetter(CallGraph graph, MethodReference method, List<string> chain)
{
if (m_visited.IndexOf(method) >= 0)
return false;
m_visited.Add(method);
bool found = false;
Log.DebugLine(this, "checking {0}", method);
if (m_unlocked.IndexOf(method) >= 0 && m_setters.IndexOf(method) >= 0)
{
Log.DebugLine(this, "it's a setter");
found = true;
}
else
{
foreach (MethodReference callee in graph.Calls(method))
{
Log.Indent();
if (DoFoundBadSetter(graph, callee, chain))
{
found = true;
Log.Unindent();
break;
}
Log.Unindent();
}
}
if (found)
chain.Insert(0, method.ToString());
return found;
}
示例10: method_5
private BfMethod method_5(BfMethod bfMethod_0, MethodReference methodReference_0)
{
GenericInstanceType genericInstanceType = (GenericInstanceType)methodReference_0.DeclaringType;
BfType bfType = this._cache.method_7(genericInstanceType.ElementType);
HashSet<string> hashSet = new HashSet<string>();
BfMethod result;
if (bfType == null)
{
result = null;
}
else
{
foreach (GenericParameter genericParameter in bfType.method_2().GenericParameters)
{
hashSet.Add(genericParameter.FullName);
}
MethodReference methodReference = null;
List<MethodReference> list = new List<MethodReference>();
list.AddRange(bfType.method_2().Constructors.Cast<MethodReference>());
list.AddRange(bfType.method_2().Methods.Cast<MethodReference>());
using (List<MethodReference>.Enumerator enumerator2 = list.GetEnumerator())
{
while (enumerator2.MoveNext())
{
MethodDefinition methodDefinition = (MethodDefinition)enumerator2.Current;
if (methodDefinition.Name == methodReference_0.Name && methodDefinition.Parameters.Count == methodReference_0.Parameters.Count)
{
bool flag = true;
for (int i = 0; i < methodDefinition.Parameters.Count; i++)
{
ParameterDefinition parameterDefinition = methodDefinition.Parameters[i];
ParameterDefinition parameterDefinition2 = methodReference_0.Parameters[i];
if (hashSet.Contains(BfCache.smethod_3(parameterDefinition.ParameterType).FullName))
{
if (!parameterDefinition2.ToString().StartsWith("A_"))
{
flag = false;
}
}
else if (!(Regex.Replace(parameterDefinition2.ParameterType.FullName, "<[^>]*>", "") == Regex.Replace(parameterDefinition.ParameterType.FullName, "<[^>]*>", "")))
{
flag = false;
}
}
if (flag)
{
methodReference = methodDefinition;
}
}
}
}
if (methodReference == null)
{
Logger.LogWarning("GetMethodRefFromGenericInstance", "Not good " + methodReference_0.ToString());
result = null;
}
else
{
BfMethod.smethod_0(methodReference);
result = this._cache.method_5(methodReference);
}
}
return result;
}
示例11: DoValidMethod
private bool DoValidMethod(MethodReference method)
{
string fullName = method.ToString();
if (fullName.Contains("Mono.Security.ASN1::Add"))
return false;
else if (fullName.Contains("System.Boolean System.Collections.Generic.HashSet`1<T>::Add"))
return false;
else if (fullName.Contains("System.Collections.ArrayList::Add"))
return false;
else if (fullName.Contains("System.Collections.IList::Add"))
return false;
else if (fullName.Contains("System.Collections.IList::Add"))
return false;
else if (fullName.Contains("System.Diagnostics.Process::Start()")) // note that people should generally use the result of the other overloads
return false;
else if (fullName.Contains("System.IO.Directory::CreateDirectory"))
return false;
else if (fullName.Contains("System.Diagnostics.TraceListenerCollection::Add"))
return false;
else if (fullName.Contains("System.IO.DirectoryInfo::CreateSubdirectory"))
return false;
else if (fullName.Contains("System.IO.FileStream::Seek"))
return false;
else if (fullName.Contains("System.IO.MemoryStream::Seek"))
return false;
else if (fullName.Contains("System.IO.Stream::Seek"))
return false;
else if (fullName.Contains("System.IO.UnmanagedMemoryStream::Seek"))
return false;
else if (fullName.Contains("System.Security.PermissionSet::AddPermission"))
return false;
else if (fullName.Contains("System.Security.PermissionSet::RemovePermission"))
return false;
else if (fullName.Contains("System.Security.PermissionSet::SetPermission"))
return false;
else if (fullName.Contains("System.Reflection.MethodBase::Invoke"))
return false;
else if (fullName.Contains("System.Runtime.InteropServices.Marshal::AddRef"))
return false;
else if (fullName.Contains("System.Runtime.InteropServices.Marshal::Release"))
return false;
else if (fullName.Contains("System.Runtime.Remoting.Lifetime.ILease::Renew"))
return false;
else if (fullName.Contains("System.Text.StringBuilder::Append"))
return false;
else if (fullName.Contains("System.Text.StringBuilder::Insert"))
return false;
else if (fullName.Contains("System.Text.StringBuilder::Remove"))
return false;
else if (fullName.Contains("System.Text.StringBuilder::Replace"))
return false;
else if (fullName.Contains("System.Threading.Interlocked::Add"))
return false;
else if (fullName.Contains("System.Threading.Interlocked::CompareExchange"))
return false;
else if (fullName.Contains("System.Threading.Interlocked::Decrement"))
return false;
else if (fullName.Contains("System.Threading.Interlocked::Exchange"))
return false;
else if (fullName.Contains("System.Threading.Interlocked::Increment"))
return false;
else if (fullName.Contains("System.Windows.Forms.ListBox/ObjectCollection::Add"))
return false;
else if (fullName.Contains("System.Windows.Forms.Menu/MenuItemCollection::Add"))
return false;
else if (fullName.Contains("System.Xml.Schema.XmlSchemaSet::Add"))
return false;
//.........这里部分代码省略.........
示例12: DoCallsLock
private bool DoCallsLock(MethodReference method, FieldReference field, Entry entry, CallGraph graph, List<string> chain, int depth)
{
if (depth > 8) // this can't be too large or the rule takes a very long time to run
return false;
chain.Add(method.ToString());
if (entry.Locked.ContainsKey(method) && entry.Locked[method].IndexOf(field) >= 0)
{
return true;
}
foreach (MethodReference candidate in graph.Calls(method))
{
if (DoCallsLock(candidate, field, entry, graph, chain, depth + 1))
return true;
}
chain.RemoveAt(chain.Count - 1);
return false;
}
示例13: GetNameO
string GetNameO(bool isVirt, MethodReference mbr)
{
return ObfuscationHelper.GetNewName((isVirt ? "V>." : "") + mbr.ToString());
}
示例14: DoMatchMethod
private bool DoMatchMethod(MethodReference method)
{
string name = method.ToString();
if (!method.Name.StartsWith("set_"))
{
foreach (string pattern in m_methods)
{
if (name.Match(pattern))
return true;
}
}
foreach (string custom in m_custom)
{
if (name.Contains(custom))
return true;
}
return false;
}
示例15: Print
public void Print(MethodReference mRef)
{
Console.WriteLine ("{0} {1}", mRef.DeclaringType.FullName, mRef.ToString());
}