コード例 #1
0
 internal IL2CPP_Field(IntPtr ptr) : base(ptr)
 {
     Ptr        = ptr;
     Name       = Marshal.PtrToStringAnsi(IL2CPP.il2cpp_field_get_name(Ptr));
     Flags      = (IL2CPP_BindingFlags)IL2CPP.il2cpp_field_get_flags(Ptr);
     ReturnType = new IL2CPP_Type(IL2CPP.il2cpp_field_get_type(Ptr));
 }
コード例 #2
0
ファイル: IL2CPP_Class.cs プロジェクト: morag12/MelonLoader
        internal IL2CPP_Class(IntPtr ptr) : base(ptr)
        {
            // Setup Information
            Ptr       = ptr;
            Name      = Marshal.PtrToStringAnsi(IL2CPP.il2cpp_class_get_name(Ptr));
            Namespace = Marshal.PtrToStringAnsi(IL2CPP.il2cpp_class_get_namespace(Ptr));
            Flags     = (IL2CPP_BindingFlags)IL2CPP.il2cpp_class_get_flags(Ptr);

            // Map out Methods
            IntPtr method_iter = IntPtr.Zero;
            IntPtr method;
            List <IL2CPP_Method> methodsList = new List <IL2CPP_Method>();

            while ((method = IL2CPP.il2cpp_class_get_methods(Ptr, ref method_iter)) != IntPtr.Zero)
            {
                methodsList.Add(new IL2CPP_Method(method));
            }
            MethodList = methodsList.ToArray();

            // Map out Fields
            IntPtr field_iter = IntPtr.Zero;
            IntPtr field;
            List <IL2CPP_Field> fieldList = new List <IL2CPP_Field>();

            while ((field = IL2CPP.il2cpp_class_get_fields(Ptr, ref field_iter)) != IntPtr.Zero)
            {
                fieldList.Add(new IL2CPP_Field(field));
            }
            FieldList = fieldList.ToArray();

            // Map out Events
            IntPtr evt_iter = IntPtr.Zero;
            IntPtr evt;
            List <IL2CPP_Event> eventList = new List <IL2CPP_Event>();

            while ((evt = IL2CPP.il2cpp_class_get_events(Ptr, ref evt_iter)) != IntPtr.Zero)
            {
                eventList.Add(new IL2CPP_Event(evt));
            }
            EventList = eventList.ToArray();

            // Map out Nested Types
            //IntPtr nestedtype_iter = IntPtr.Zero;
            //IntPtr nestedtype;
            //List<IL2CPP_Class> nestedTypeList = new List<IL2CPP_Class>();
            //while ((nestedtype = IL2CPP.il2cpp_class_get_nested_types(Ptr, ref nestedtype_iter)) != IntPtr.Zero)
            //    nestedTypeList.Add(new IL2CPP_Class(nestedtype));
            //NestedTypeList = nestedTypeList.ToArray();

            // Map out Properties
            IntPtr property_iter = IntPtr.Zero;
            IntPtr property;
            List <IL2CPP_Property> propertyList = new List <IL2CPP_Property>();

            while ((property = IL2CPP.il2cpp_class_get_properties(Ptr, ref property_iter)) != IntPtr.Zero)
            {
                propertyList.Add(new IL2CPP_Property(property));
            }
            PropertyList = propertyList.ToArray();
        }
コード例 #3
0
        public IL2CPP_Class GetClass(string name, string name_space, IL2CPP_BindingFlags flags)
        {
            IL2CPP_Class returnval = null;

            for (int i = 0; i < ClassList.Length; i++)
            {
                IL2CPP_Class type = ClassList[i];
                if (type.Name.Equals(name) && (string.IsNullOrEmpty(type.Namespace) || type.Namespace.Equals(name_space)) && type.HasFlag(flags))
                {
                    returnval = type;
                    break;
                }
                else
                {
                    /*
                     * var nestedTypes = type.GetNestedTypes();
                     * if (nestedTypes.Length > 0)
                     * {
                     *  for (int l = 0; l < nestedTypes.Length; l++)
                     *  {
                     *      var nestedType = nestedTypes[l];
                     *      if (nestedType.Name.Equals(name) && (string.IsNullOrEmpty(nestedType.Namespace) || nestedType.Namespace.Equals(name_space)) && nestedType.HasFlag(flags))
                     *      {
                     *          returnval = nestedType;
                     *          break;
                     *      }
                     *  }
                     *  if (returnval != null)
                     *      break;
                     * }
                     */
                }
            }
            return(returnval);
        }
コード例 #4
0
ファイル: IL2CPP_Class.cs プロジェクト: morag12/MelonLoader
 public IL2CPP_Method GetMethod(string name, IL2CPP_BindingFlags flags, Func <IL2CPP_Method, bool> func)
 {
     for (int i = 0; i < MethodList.Length; i++)
     {
         var method = MethodList[i];
         if (method.Name.Equals(name) && method.HasFlag(flags) && (func == null || func(method)))
         {
             return(method);
         }
     }
     return(null);
 }
コード例 #5
0
ファイル: IL2CPP_Class.cs プロジェクト: morag12/MelonLoader
 public IL2CPP_Field GetField(string name, IL2CPP_BindingFlags flags, Func <IL2CPP_Field, bool> func)
 {
     for (int i = 0; i < FieldList.Length; i++)
     {
         var field = FieldList[i];
         if (field.Name.Equals(name) && field.HasFlag(flags) && (func == null || func(field)))
         {
             return(field);
         }
     }
     return(null);
 }
コード例 #6
0
ファイル: IL2CPP_Class.cs プロジェクト: morag12/MelonLoader
 public IL2CPP_Property GetProperty(string name, IL2CPP_BindingFlags flags)
 {
     for (int i = 0; i < PropertyList.Length; i++)
     {
         var property = PropertyList[i];
         if (property.Name.Equals(name) && property.HasFlag(flags))
         {
             return(property);
         }
     }
     return(null);
 }
コード例 #7
0
ファイル: IL2CPP_Class.cs プロジェクト: morag12/MelonLoader
 /// <summary>
 /// Gets the first method matching name and flags with the specified number of parameters
 /// </summary>
 /// <param name="name">The name to search for</param>
 /// <param name="flags">The <see cref="IL2CPP_BindingFlags"/> to match</param>
 /// <param name="argCount">The parameter count to match</param>
 /// <returns>The first matching <see cref="IL2CPP_Method"/></returns>
 public IL2CPP_Method GetMethod(string name, IL2CPP_BindingFlags flags, int argCount)
 {
     for (int i = 0; i < MethodList.Length; i++)
     {
         var method = MethodList[i];
         if (method.Name.Equals(name) && method.HasFlag(flags) && method.GetParameterCount() == argCount)
         {
             return(method);
         }
     }
     return(null);
 }
コード例 #8
0
ファイル: IL2CPP_Method.cs プロジェクト: morag12/MelonLoader
        internal IL2CPP_Method(IntPtr ptr) : base(ptr)
        {
            Ptr        = ptr;
            Name       = Marshal.PtrToStringAnsi(IL2CPP.il2cpp_method_get_name(Ptr));
            ReturnType = new IL2CPP_Type(IL2CPP.il2cpp_method_get_return_type(Ptr));
            uint flags = 0;

            Flags = (IL2CPP_BindingFlags)IL2CPP.il2cpp_method_get_flags(Ptr, ref flags);
            uint param_count = IL2CPP.il2cpp_method_get_param_count(Ptr);

            Parameters = new IL2CPP_Method_Parameter[param_count];
            for (uint i = 0; i < param_count; i++)
            {
                Parameters[i] = new IL2CPP_Method_Parameter(IL2CPP.il2cpp_method_get_param(Ptr, i), Marshal.PtrToStringAnsi(IL2CPP.il2cpp_method_get_param_name(Ptr, i)));
            }
        }
コード例 #9
0
        internal IL2CPP_Property(IntPtr ptr) : base(ptr)
        {
            Ptr   = ptr;
            Name  = Marshal.PtrToStringAnsi(IL2CPP.il2cpp_property_get_name(Ptr));
            Flags = (IL2CPP_BindingFlags)IL2CPP.il2cpp_property_get_flags(Ptr);

            IntPtr getMethodPtr = IL2CPP.il2cpp_property_get_get_method(Ptr);

            if (getMethodPtr != IntPtr.Zero)
            {
                getMethod = new IL2CPP_Method(getMethodPtr);
            }

            IntPtr setMethodPtr = IL2CPP.il2cpp_property_get_set_method(Ptr);

            if (setMethodPtr != IntPtr.Zero)
            {
                setMethod = new IL2CPP_Method(setMethodPtr);
            }
        }
コード例 #10
0
ファイル: IL2CPP_Class.cs プロジェクト: morag12/MelonLoader
 public IL2CPP_Field[] GetFields(IL2CPP_BindingFlags flags, Func <IL2CPP_Field, bool> func) => GetFields().Where(x => (((x.GetFlags() & flags) != 0) && func(x))).ToArray();
コード例 #11
0
 public IL2CPP_Class GetClass(string name, IL2CPP_BindingFlags flags) => GetClass(name, null, flags);
コード例 #12
0
 public IL2CPP_Class[] GetClasses(IL2CPP_BindingFlags flags) => GetClasses().Where(x => x.HasFlag(flags)).ToArray();
コード例 #13
0
ファイル: IL2CPP_Class.cs プロジェクト: morag12/MelonLoader
 public IL2CPP_Property[] GetProperties(IL2CPP_BindingFlags flags) => GetProperties().Where(x => ((x.GetFlags() & flags) != 0)).ToArray();
コード例 #14
0
ファイル: IL2CPP_Class.cs プロジェクト: morag12/MelonLoader
 public bool HasFlag(IL2CPP_BindingFlags flag) => ((GetFlags() & flag) != 0);
コード例 #15
0
ファイル: IL2CPP_Class.cs プロジェクト: morag12/MelonLoader
 public IL2CPP_Field GetField(string name, IL2CPP_BindingFlags flags) => GetField(name, flags, null);
コード例 #16
0
ファイル: IL2CPP_Class.cs プロジェクト: morag12/MelonLoader
 public IL2CPP_Method[] GetMethods(IL2CPP_BindingFlags flags) => GetMethods(flags, null);
コード例 #17
0
ファイル: IL2CPP_Class.cs プロジェクト: morag12/MelonLoader
 public IL2CPP_Method GetMethod(string name, IL2CPP_BindingFlags flags) => GetMethod(name, flags, null);
コード例 #18
0
ファイル: IL2CPP_Class.cs プロジェクト: morag12/MelonLoader
 public IL2CPP_Field[] GetFields(IL2CPP_BindingFlags flags) => GetFields(flags, null);