Ejemplo n.º 1
0
        public static T Snapshot <T>(this T self, SnapshotBehavior behavior) where T : MemoryObject
        {
            var clone = self.Memory.Reader.Read <T>(self.Address);

            clone.TakeSnapshot(behavior);
            return(clone);
        }
Ejemplo n.º 2
0
        public void TakeSnapshot(SnapshotBehavior behavior)
        {
            if (behavior == SnapshotBehavior.PreserveExistingSnapshot && Snapshot != null)
            {
                return;
            }

            // Refresh snapshot only if we're in its root object (the object that created the snapshot).
            // A substruct is not allowed to update its parent snapshot and must instead create a new one.
            if (Snapshot?.IsRoot(this) == true)
            {
                Snapshot.Refresh();
                return;
            }

            int size   = GetType().SizeOf();
            var buffer = new byte[size];

            Memory.Reader.ReadBytes(Address, buffer, 0, size);
            SetSnapshot(buffer, 0, size);
        }