Пример #1
0
        static ManagedDataOffsets()
        {
            NameMapping = TypeOffset.GetOffsets();

            FieldInfo[] fields = typeof(DataOffsets).GetFields(BindingFlags.Static | BindingFlags.Public);
            size = fields.Length * IntPtr.Size;
        }
Пример #2
0
        internal static void DumpType(BorrowedReference type)
        {
            IntPtr op   = Util.ReadIntPtr(type, TypeOffset.tp_name);
            string name = Marshal.PtrToStringAnsi(op);

            Console.WriteLine("Dump type: {0}", name);

            var objMember = Util.ReadRef(type, TypeOffset.ob_type);

            Print("  type: ", objMember);

            objMember = Util.ReadRef(type, TypeOffset.tp_base);
            Print("  base: ", objMember);

            objMember = Util.ReadRef(type, TypeOffset.tp_bases);
            Print("  bases: ", objMember);

            //op = Util.ReadIntPtr(type, TypeOffset.tp_mro);
            //DebugUtil.Print("  mro: ", op);


            var slots = TypeOffset.GetOffsets();
            int size  = IntPtr.Size;

            foreach (var entry in slots)
            {
                int offset = entry.Value;
                name = entry.Key;
                op   = Util.ReadIntPtr(type, offset);
                Console.WriteLine("  {0}: {1}", name, op);
            }

            Console.WriteLine("");
            Console.WriteLine("");

            objMember = Util.ReadRef(type, TypeOffset.tp_dict);
            if (objMember == null)
            {
                Console.WriteLine("  dict: null");
            }
            else
            {
                Print("  dict: ", objMember);
            }
        }