public static MethodDefinitionHandle FindMethod(this PEFile file, string typeName, string methodName) { var type = file.FindType(typeName); var metadata = file.Metadata; var typeDefinition = metadata.GetTypeDefinition(type); foreach (var handle in typeDefinition.GetMethods()) { var definition = metadata.GetMethodDefinition(handle); if (metadata.GetString(definition.Name) == methodName) { return(handle); } } throw new($"Could not find `{typeName}.{methodName}` in `{file.FileName}`"); }
public static PropertyDefinitionHandle FindProperty(this PEFile file, string typeName, string propertyName) { var type = file.FindType(typeName); var metadata = file.Metadata; var typeDefinition = metadata.GetTypeDefinition(type); foreach (var handle in typeDefinition.GetProperties()) { var definition = metadata.GetPropertyDefinition(handle); var s = metadata.GetString(definition.Name); if (s == propertyName) { return(handle); } } throw new Exception($"Could not find `{typeName}.{propertyName}` in `{file.FileName}`"); }
public TypeToDisassemble(PEFile file, string typeName) { this.file = file; type = file.FindType(typeName); }