Esempio n. 1
0
        public static object IsInstanceOfInterfaceType(int interfaceSlot, object obj)
        {
            if (obj == null)
            {
                return(null);
            }

            var o = Intrinsic.GetObjectAddress(obj);
            var objTypeDefinition = new TypeDefinition(o.LoadPointer());

            var bitmap = objTypeDefinition.Bitmap;

            if (bitmap.IsNull)
            {
                return(null);
            }

            int index = interfaceSlot / 32;
            int bit   = interfaceSlot % 32;

            uint value  = bitmap.Load32(index * 4);
            uint result = value & (uint)(1 << bit);

            if (result == 0)
            {
                return(null);
            }

            return(obj);
        }
Esempio n. 2
0
        public static Pointer IsInstanceOfType(RuntimeTypeHandle handle, object obj)
        {
            if (obj == null)
            {
                return(Pointer.Zero);
            }

            var o = Intrinsic.GetObjectAddress(obj);
            var objTypeDefinition = new TypeDefinition(o.LoadPointer());
            var typeDefinition    = new TypeDefinition(new Pointer(handle.Value));

            if (IsTypeInInheritanceChain(typeDefinition, objTypeDefinition))
            {
                return(o);
            }

            return(Pointer.Zero);
        }
        private static RuntimeTypeHandle GetTypeHandle(object obj)
        {
            var o = Intrinsic.GetObjectAddress(obj);

            return(new RuntimeTypeHandle(Intrinsic.LoadPointer(o)));
        }
Esempio n. 4
0
        public static Pointer GetObjectHashValue(object obj)
        {
            var address = Intrinsic.GetObjectAddress(obj);

            return(address - Pointer.Size - 4 - 4);
        }
Esempio n. 5
0
        public static Pointer GetObjectLockAndStatus(object obj)
        {
            var address = Intrinsic.GetObjectAddress(obj);

            return(address - Pointer.Size - 4);
        }
Esempio n. 6
0
        public static Pointer GetTypeDefinition(object obj)
        {
            var address = Intrinsic.GetObjectAddress(obj);

            return(address.LoadPointer(-Pointer.Size));
        }