Ejemplo n.º 1
0
        public unsafe ServeyEnvelope()
        {
            Age     = ++CurrentAge;
            Counter = GcCounter.Create();

            fixed(int *ptr = &FixedPoint)
            {
                InitialAddress = ((UIntPtr)ptr).ToUInt64();
            }
        }
Ejemplo n.º 2
0
        public static unsafe void Check(ServeyEnvelope target)
        {
            var current = ((UIntPtr)Unsafe.AsPointer(ref target)).ToUInt64();

            if (current != target.InitialAddress)
            {
                Console.WriteLine("Detect moving!");
                Console.WriteLine($"AgeOffset:{CurrentAge-target.Age}");
                Console.WriteLine(GcCounter.Create().GetOffset(target.Counter));
                Console.WriteLine($"InitialAddress:{target.InitialAddress:X}");
                Console.WriteLine($"CurrentAddress:{current:X}");

                Console.WriteLine("press enter to continue.");
                Console.ReadLine();
            }
        }
Ejemplo n.º 3
0
        private static void BasicServey()
        {
            var array = new ServeyEnvelope[Size];

            for (int i = 0; i < Size; i++)
            {
                array[i] = new ServeyEnvelope();
            }

            while (true)
            {
                Console.WriteLine(ServeyEnvelope.CurrentAge);
                Console.WriteLine(GcCounter.Create());
                Console.WriteLine();
                for (var i = 0; i < Size; i++)
                {
                    array[i].Check();
                    array[i] = new ServeyEnvelope();
                }
            }
        }
Ejemplo n.º 4
0
        public unsafe bool Check()
        {
            ulong current;

            fixed(int *ptr = &FixedPoint)
            {
                current = ((UIntPtr)ptr).ToUInt64();
            }

            if (current != InitialAddress)
            {
                Console.WriteLine("Detect moving!");
                Console.WriteLine($"InitialAddr:0x{InitialAddress:x16}");
                Console.WriteLine($"CurrentAddr:0x{current:x16}");
                Console.WriteLine(GcCounter.Create().GetOffset(Counter));
                Console.WriteLine($"AgeOffset:{CurrentAge-Age}");

                //Console.WriteLine("Press enter to continue.");
                //   Console.ReadLine();

                return(false);
            }
            return(true);
        }
Ejemplo n.º 5
0
 public GcCounter GetOffset(GcCounter counter)
 {
     return(new GcCounter(Math.Abs(Generation0 - counter.Generation0),
                          Math.Abs(Generation1 - counter.Generation1), Math.Abs(Generation2 - counter.Generation2)));
 }