Ejemplo 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);
        }
Ejemplo 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);
        }
Ejemplo n.º 3
0
        private static RuntimeTypeHandle GetTypeHandle(object obj)
        {
            var o = Intrinsic.GetObjectAddress(obj);

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

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

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

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