Пример #1
0
        public static object IsInstanceOfInterfaceType(int interfaceSlot, object obj)
        {
            if (obj == null)
            {
                return(null);
            }

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

            var bitmap = objTypeDefinition.Bitmap;

            if (bitmap == IntPtr.Zero)
            {
                return(null);
            }

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

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

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

            return(obj);
        }
Пример #2
0
        public static void Setup()
        {
            Assemblies = new LinkedList <RuntimeAssembly>();

            // Get AssemblyListTable and Assembly count
            var  assemblyListTable = Intrinsic.GetAssemblyListTable();
            uint assemblyCount     = Intrinsic.Load32(assemblyListTable);

            // Loop through and populate the array
            for (int i = 0; i < assemblyCount; i++)
            {
                // Get the pointer to the Assembly Metadata
                var ptr = Intrinsic.LoadPointer(assemblyListTable, IntPtr.Size + (IntPtr.Size * i));

                Assemblies.AddLast(new RuntimeAssembly(ptr));
            }
        }
Пример #3
0
        public static IntPtr IsInstanceOfType(RuntimeTypeHandle handle, object obj)
        {
            if (obj == null)
            {
                return(IntPtr.Zero);
            }

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

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

            return(IntPtr.Zero);
        }
Пример #4
0
 public Pointer LoadPointer(int offset)
 {
     return(Intrinsic.LoadPointer(this, offset));
 }
Пример #5
0
 public Pointer LoadPointer()
 {
     return(Intrinsic.LoadPointer(this));
 }
Пример #6
0
        private static RuntimeTypeHandle GetTypeHandle(object obj)
        {
            var o = Intrinsic.GetObjectAddress(obj);

            return(new RuntimeTypeHandle(Intrinsic.LoadPointer(o)));
        }