Exemplo n.º 1
0
 public ExportedType(string @namespace, string name, ModuleDefinition module, IMetadataScope scope)
 {
     this.@namespace = @namespace;
     this.name = name;
     this.scope = scope;
     this.module = module;
 }
 public static Collection<CustomAttribute> GetCustomAttributes(
     this ICustomAttributeProvider self,
     ref Collection<CustomAttribute> variable,
     ModuleDefinition module)
 {
     return module.HasImage()
         ? module.Read(ref variable, self, (provider, reader) => reader.ReadCustomAttributes(provider))
         : variable = new Collection<CustomAttribute>();
 }
        void CopyTo(CustomAttribute target, ModuleDefinition context)
        {
            foreach (var arg in ConstructorArguments)
                target.ConstructorArguments.Add(new CustomAttributeArgument(context.Import(arg.Type), arg.Value));

            foreach (var field in Fields)
                target.Fields.Add(new CustomAttributeNamedArgument(field.Name, new CustomAttributeArgument(context.Import(field.Argument.Type), field.Argument.Value)));

            foreach (var prop in Properties)
                target.Properties.Add(new CustomAttributeNamedArgument(prop.Name, new CustomAttributeArgument(context.Import(prop.Argument.Type), prop.Argument.Value)));
        }
Exemplo n.º 4
0
 public TypeReference(string @namespace, string name, ModuleDefinition module, IMetadataScope scope, bool valueType)
     : this(@namespace, name, module, scope)
 {
     value_type = valueType;
 }
 public static Collection<SecurityDeclaration> GetSecurityDeclarations(
     this ISecurityDeclarationProvider self,
     ref Collection<SecurityDeclaration> variable,
     ModuleDefinition module)
 {
     return module.HasImage()
         ? module.Read(ref variable, self, (provider, reader) => reader.ReadSecurityDeclarations(provider))
         : variable = new Collection<SecurityDeclaration>();
 }
 public static bool GetHasSecurityDeclarations(
     this ISecurityDeclarationProvider self,
     ModuleDefinition module)
 {
     return module.HasImage() && module.Read(self, (provider, reader) => reader.HasSecurityDeclarations(provider));
 }
 internal SecurityDeclaration(SecurityAction action, uint signature, ModuleDefinition module)
 {
     this.action = action;
     this.signature = signature;
     this.module = module;
 }
        static TypeDefinition GetTypeDefinition(ModuleDefinition module, TypeReference type)
        {
            if (!type.IsNested)
                return module.GetType(type.Namespace, type.Name);

            var declaring_type = type.DeclaringType.Resolve();
            if (declaring_type == null)
                return null;

            return declaring_type.GetNestedType(type.TypeFullName());
        }
 public static bool GetHasGenericParameters(
     this IGenericParameterProvider self,
     ModuleDefinition module)
 {
     return module.HasImage() && module.Read(self, (provider, reader) => reader.HasGenericParameters(provider));
 }
Exemplo n.º 10
0
 public static void PatchAssemblyNames(ModuleDefinition module, string searchToken, Version searchVersion, string replaceToken, Version replaceVersion)
 {
     var references = SearchReferences(module, searchToken, searchVersion).ToList();
     PatchAssemblyNames(references, replaceToken, replaceVersion);
 }
 public static bool GetHasCustomAttributes(
     this ICustomAttributeProvider self,
     ModuleDefinition module)
 {
     return module.HasImage() && module.Read(self, (provider, reader) => reader.HasCustomAttributes(provider));
 }
Exemplo n.º 12
0
 public CoreTypeSystem(ModuleDefinition module)
     : base(module)
 {
 }
Exemplo n.º 13
0
        internal static TypeSystem CreateTypeSystem(ModuleDefinition module)
        {
            if (module.IsCorlib())
                return new CoreTypeSystem(module);

            return new CommonTypeSystem(module);
        }
Exemplo n.º 14
0
        private static TypeReference FixTypeImport(ModuleDefinition context, MethodDefinition source, MethodDefinition target,
            TypeReference type)
        {
            if (type.FullName == source.DeclaringType.FullName)
                return target.DeclaringType;

            return context.Import(type);
        }
Exemplo n.º 15
0
        private static MethodReference FixMethodImport(ModuleDefinition context, MethodDefinition source,
            MethodDefinition target, MethodReference method)
        {
            if (method.DeclaringType.FullName == source.DeclaringType.FullName)
                return FindMatchingMethod(target.DeclaringType, method);

            return context.Import(method);
        }
Exemplo n.º 16
0
        private static FieldReference FixFieldImport(ModuleDefinition context, MethodDefinition source,
            MethodDefinition target, FieldReference field)
        {
            if (field.DeclaringType.FullName == source.DeclaringType.FullName)
                return FindMatchingField(target.DeclaringType, field);

            return context.Import(field);
        }
Exemplo n.º 17
0
 public static IEnumerable<AssemblyNameReference> SearchReferences(ModuleDefinition module, string searchToken,
     Version searchVersion)
 {
     return module.AssemblyReferences.Where(aname => ByteHelper.ByteToString(aname.PublicKeyToken) == searchToken && aname.Version == searchVersion);
 }
Exemplo n.º 18
0
 public TypeReference(string @namespace, string name, ModuleDefinition module, IMetadataScope scope)
     : this(@namespace, name)
 {
     this.module = module;
     this.scope = scope;
 }
Exemplo n.º 19
0
 // HACK - Reflexil - Ends
 TypeSystem(ModuleDefinition module)
 {
     this.module = module;
 }
Exemplo n.º 20
0
 public static TypeDefinition FindMatchingType(ModuleDefinition mdef, string fulltypename)
 {
     return FindMatchingType(mdef.Types, fulltypename);
 }
Exemplo n.º 21
0
 internal static CustomAttribute Clone(CustomAttribute custattr, ModuleDefinition context)
 {
     var ca = new CustomAttribute(context.Import(custattr.Constructor));
     custattr.CopyTo(ca, context);
     return ca;
 }
        static TypeDefinition GetType(ModuleDefinition module, TypeReference reference)
        {
            var type = GetTypeDefinition(module, reference);
            if (type != null)
                return type;

            if (!module.HasExportedTypes)
                return null;

            var exported_types = module.ExportedTypes;

            for (int i = 0; i < exported_types.Count; i++)
            {
                var exported_type = exported_types[i];
                if (exported_type.Name != reference.Name)
                    continue;

                if (exported_type.Namespace != reference.Namespace)
                    continue;

                return exported_type.Resolve();
            }

            return null;
        }
Exemplo n.º 23
0
 public MetadataImporter(ModuleDefinition module)
 {
     this.module = module;
 }
 public static Collection<GenericParameter> GetGenericParameters(
     this IGenericParameterProvider self,
     ref Collection<GenericParameter> collection,
     ModuleDefinition module)
 {
     return module.HasImage()
         ? module.Read(ref collection, self, (provider, reader) => reader.ReadGenericParameters(provider))
         : collection = new GenericParameterCollection(self);
 }