Exemplo n.º 1
0
        public static void WrappTypeTest()
        {
            Console.WriteLine();
            var assembly   = new InternalAssembly();
            var stringType = new TypeBuilding.TypeWrapping.WrappedType <string>(assembly);
            var testType   = new TypeBuilding.TypeWrapping.WrappedType <TestToWrapp>(assembly);
            var intType    = new TypeBuilding.TypeWrapping.WrappedType <int>(assembly);
            var testString = stringType.ConstructInstance("Testing string");
            var testInt    = intType.ConstructInstance(4);
            var instance   = testType.ConstructInstance();

            int constructCount = 1000;
            var w = Stopwatch.StartNew();

            for (int i = 0; i < constructCount; ++i)
            {
                var testInst = testType.ConstructInstance();
            }
            w.Stop();
            Console.WriteLine("construct aprox time: {0:}ms", w.Elapsed.TotalSeconds / constructCount);


            int callCount = 1000000;

            w.Start();
            for (int i = 0; i < callCount; ++i)
            {
                var result = testType.Invoke(instance, "methodCall", testString, testInt);
            }
            w.Stop();
            Console.WriteLine("call aprox time: {0}ms", w.Elapsed.TotalSeconds / callCount);
        }
Exemplo n.º 2
0
        //protected ToOverride This;

        /// <summary>
        /// Register overriden type into assembly
        /// </summary>
        /// <param name="assembly"></param>
        public void RegisterInto(InternalAssembly assembly)
        {
            var toOverrideType  = typeof(ToOverride);
            var overrides       = collectMethods(toOverrideType, "_call_");
            var originalMethods = collectMethods(toOverrideType);

            var overridenMethods = getOverriden(originalMethods, overrides);
        }
Exemplo n.º 3
0
        internal static IntPtr GetClass(string assemblyname, string name_space, string classname)
        {
            MelonDebug.Msg($"GetClass {assemblyname} {name_space} {classname}");

            InternalAssembly assembly = assemblies.FirstOrDefault(a => a.name == assemblyname);

            if (assembly == null)
            {
                throw new Exception("Unable to find assembly " + assemblyname + " in il2cpp domain");
            }

            IntPtr clazz = il2cpp_class_from_name(assembly.ptr, name_space, classname);

            if (clazz == null)
            {
                throw new Exception("Unable to find class " + name_space + "." + classname + " in assembly " + assemblyname);
            }

            MelonDebug.Msg($" > 0x{(long)clazz:X}");
            return(clazz);
        }
Exemplo n.º 4
0
        private void SetEntryPointNoLock(
            MethodInfo entryMethod,         // entry method for the assembly. We use this to determine the entry module
            PEFileKinds fileKind)           // file kind for the assembly.
        {
            if (entryMethod == null)
            {
                throw new ArgumentNullException(nameof(entryMethod));
            }
            Contract.EndContractBlock();

            BCLDebug.Log("DYNIL", "## DYNIL LOGGING: AssemblyBuilder.SetEntryPoint");

            Module tmpModule = entryMethod.Module;

            if (tmpModule == null || !InternalAssembly.Equals(tmpModule.Assembly))
            {
                throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_EntryMethodNotDefinedInAssembly"));
            }

            m_assemblyData.m_entryPointMethod = entryMethod;
            m_assemblyData.m_peFileKind       = fileKind;
        }
Exemplo n.º 5
0
        internal static IntPtr GetClass(string assemblyname, string name_space, string classname)
        {
            MelonDebug.Msg($"GetClass {assemblyname} {name_space} {classname}");
            if (MelonUtils.IsGameIl2Cpp())
            {
                InternalAssembly assembly = assemblies.FirstOrDefault(a => a.name == assemblyname);
                if (assembly == null)
                {
                    throw new Exception("Unable to find assembly " + assemblyname + " in il2cpp domain");
                }

                IntPtr clazz = il2cpp_class_from_name(assembly.ptr, name_space, classname);
                if (clazz == null)
                {
                    throw new Exception("Unable to find class " + name_space + "." + classname + " in assembly " + assemblyname);
                }

                MelonDebug.Msg($" > 0x{(long)clazz:X}");
                return(clazz);
            }
            else
            {
                string   fullname = string.IsNullOrEmpty(name_space) ? "" : (name_space + ".") + classname;
                Assembly ass      = AppDomain.CurrentDomain.GetAssemblies().FirstOrDefault(a => a.GetName().Name + ".dll" == assemblyname);
                if (ass == null)
                {
                    throw new Exception("Unable to find assembly " + assemblyname + " in mono domain");
                }

                Type t = ass.GetType(fullname);
                if (t == null)
                {
                    throw new Exception("Unable to find class " + fullname + " in assembly " + assemblyname);
                }
                MelonDebug.Msg($" > 0x{(long)(*(IntPtr*)t.TypeHandle.Value):X}");
                return(*(IntPtr *)t.TypeHandle.Value);
            }
        }
Exemplo n.º 6
0
 public override AssemblyName[] GetReferencedAssemblies()
 {
     return(InternalAssembly.GetReferencedAssemblies());
 }
Exemplo n.º 7
0
 public override Type GetType(String name, bool throwOnError, bool ignoreCase)
 {
     return(InternalAssembly.GetType(name, throwOnError, ignoreCase));
 }
Exemplo n.º 8
0
 public override Module GetModule(String name)
 {
     return(InternalAssembly.GetModule(name));
 }
Exemplo n.º 9
0
 // Get an array of all the public types defined in this assembly
 public override Type[] GetExportedTypes()
 {
     return(InternalAssembly.GetExportedTypes());
 }
Exemplo n.º 10
0
 public override AssemblyName GetName(bool copiedName)
 {
     return(InternalAssembly.GetName(copiedName));
 }
Exemplo n.º 11
0
 public WrappedType(InternalAssembly originAssembly)
     : base(TypeName.From(typeof(Wrapped)), originAssembly)
 {
 }
Exemplo n.º 12
0
 public override bool Equals(object obj)
 {
     return(InternalAssembly.Equals(obj));
 }
Exemplo n.º 13
0
 public OverridenType(Dictionary <MethodInfo, MethodInfo> overrides, TypeName name, InternalAssembly assembly) : base(name, assembly)
 {
     _overrides = overrides;
     _name      = name;
 }
Exemplo n.º 14
0
 public override FileStream[] GetFiles(bool getResourceModules)
 {
     return(InternalAssembly.GetFiles(getResourceModules));
 }
Exemplo n.º 15
0
 public override IList <CustomAttributeData> GetCustomAttributesData()
 {
     return(InternalAssembly.GetCustomAttributesData());
 }
Exemplo n.º 16
0
 // Returns the names of all the resources
 public override String[] GetManifestResourceNames()
 {
     return(InternalAssembly.GetManifestResourceNames());
 }
Exemplo n.º 17
0
 public override bool IsDefined(Type attributeType, bool inherit)
 {
     return(InternalAssembly.IsDefined(attributeType, inherit));
 }
Exemplo n.º 18
0
 public override Object[] GetCustomAttributes(Type attributeType, bool inherit)
 {
     return(InternalAssembly.GetCustomAttributes(attributeType, inherit));
 }
Exemplo n.º 19
0
 // Need a dummy GetHashCode to pair with Equals
 public override int GetHashCode()
 {
     return(InternalAssembly.GetHashCode());
 }
Exemplo n.º 20
0
 public override Module[] GetLoadedModules(bool getResourceModules)
 {
     return(InternalAssembly.GetLoadedModules(getResourceModules));
 }
Exemplo n.º 21
0
 public override Stream GetManifestResourceStream(String name)
 {
     return(InternalAssembly.GetManifestResourceStream(name));
 }
Exemplo n.º 22
0
        [MethodImplAttribute(MethodImplOptions.NoInlining)] // Methods containing StackCrawlMark local var has to be marked non-inlineable
        public override Assembly GetSatelliteAssembly(CultureInfo culture, Version version)
        {
            StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller;

            return(InternalAssembly.InternalGetSatelliteAssembly(culture, version, ref stackMark));
        }
Exemplo n.º 23
0
 public override ManifestResourceInfo GetManifestResourceInfo(String resourceName)
 {
     return(InternalAssembly.GetManifestResourceInfo(resourceName));
 }
Exemplo n.º 24
0
 public override FileStream GetFile(String name)
 {
     return(InternalAssembly.GetFile(name));
 }
Exemplo n.º 25
0
 public InternalType Build(InternalAssembly assembly)
 {
     return(new OverridenType(_overrides, _name, assembly));
 }