Beispiel #1
0
 internal void applyZeroes()
 {
     flags          = 0;
     iflags         = 0;
     token          = 0;
     klass          = (MonoClass *)0;
     signature      = (MonoMethodSignature *)0;
     name           = (byte *)0;
     method_pointer = IntPtr.Zero;
     invoke_pointer = IntPtr.Zero;
     bitfield       = 0;
     slot           = 0;
 }
Beispiel #2
0
        unsafe static UnityInternals()
        {
            if (MelonUtils.IsGameIl2Cpp())
            {
                domain = il2cpp_domain_get();

                uint    assemblyCount = 0;
                IntPtr *assemblyArray = il2cpp_domain_get_assemblies(domain, ref assemblyCount);
                for (int i = 0; i < assemblyCount; ++i)
                {
                    assemblies.Add(new InternalAssembly(il2cpp_assembly_get_image(*(assemblyArray + i))));
                }
            }
            else
            {
                domain = mono_domain_get();

                string unityVersion = MelonUtils.GetUnityVersion();

                MonoClass *testclass = (MonoClass *)Marshal.AllocHGlobal(sizeof(MonoClass));
                testclass->applyZeroes();
                testclass->nested_in_0x04 = (IntPtr)0x1234;
                testclass->nested_in_0x08 = (IntPtr)0x5678;
                testclass->nested_in_0x0C = (IntPtr)0x9012;
                long returnedName = (long)mono_class_get_name((IntPtr)testclass);
                MelonDebug.Msg($"returnedName {returnedName:X}");
                Marshal.FreeHGlobal((IntPtr)testclass);
                if (returnedName == 0x1234)
                {
                    monoClassOffset = 0;
                }
                else if (returnedName == 0x5678)
                {
                    monoClassOffset = (uint)IntPtr.Size * 1;
                }
                else if (returnedName == 0x9012)
                {
                    monoClassOffset = (uint)IntPtr.Size * 2;
                }
                else
                {
                    throw new Exception("Failed to find MonoClass name offset");
                }

                MelonDebug.Msg("monoClassOffset? " + monoClassOffset);
            }
        }
Beispiel #3
0
            public IntPtr      nested_in_0x10; // 0x38 - 0x3C

            // ...

            internal void applyZeroes()
            {
                element_class  = (MonoClass *)0;
                cast_class     = (MonoClass *)0;
                supertypes     = (MonoClass **)0;
                idepth         = 0;
                rank           = 0;
                class_kind     = 0;
                instance_size  = 0;
                bitfield1      = 0;
                min_align      = 0;
                bitfield2      = 0;
                exception_type = 0;
                parent         = (MonoClass *)0;
                nested_in      = (MonoClass *)0;
                nested_in_0x04 = (IntPtr)0;
                nested_in_0x08 = (IntPtr)0;
                nested_in_0x0C = (IntPtr)0;
                nested_in_0x10 = (IntPtr)0;
            }