Exemple #1
0
        internal TargetObject GetInstanceField(TargetMemoryAccess target,
                                               TargetStructObject instance,
                                               TargetFieldInfo field)
        {
            GetFields(target);

            int        offset = field_offsets [field.Position];
            TargetType type   = field_types [field.Position];

            if (!Type.IsByRef)
            {
                offset -= 2 * target.TargetMemoryInfo.TargetAddressSize;
            }
            TargetLocation field_loc = instance.Location.GetLocationAtOffset(offset);

            TargetAddress orig_addr = field_loc.GetAddress(target);

            if (type.IsByRef)
            {
                field_loc = field_loc.GetDereferencedLocation();
            }

            TargetAddress addr = field_loc.GetAddress(target);

            if (field_loc.HasAddress && field_loc.GetAddress(target).IsNull)
            {
                return(new TargetNullObject(type));
            }

            return(type.GetObject(target, field_loc));
        }
        internal override TargetObject GetElement(TargetMemoryAccess target, int[] indices)
        {
            int offset = GetArrayOffset(target, indices);

            TargetBlob     blob;
            TargetLocation dynamic_location;

            try {
                blob = Location.ReadMemory(target, Type.Size);
                GetDynamicSize(target, blob, Location, out dynamic_location);
            } catch (TargetException ex) {
                throw new LocationInvalidException(ex);
            }

            TargetLocation new_loc = dynamic_location.GetLocationAtOffset(offset);

            if (Type.ElementType.IsByRef)
            {
                new_loc = new_loc.GetDereferencedLocation();
            }

            if (new_loc.HasAddress && new_loc.GetAddress(target).IsNull)
            {
                return(new TargetNullObject(Type.ElementType));
            }

            return(Type.ElementType.GetObject(target, new_loc));
        }
        internal override TargetObject GetElement(TargetMemoryAccess target, int[] indices)
        {
            int offset = GetArrayOffset(target, indices);

            TargetLocation new_location = Location.GetLocationAtOffset(offset);

            if (Type.ElementType.IsByRef)
            {
                new_location = new_location.GetDereferencedLocation();
            }

            return(Type.ElementType.GetObject(target, new_location));
        }
        internal override TargetObject GetArrayElement(TargetMemoryAccess target, int index)
        {
            if (!Type.IsArray)
            {
                throw new InvalidOperationException();
            }

            int            size    = Type.Size;
            TargetLocation new_loc = Location.GetLocationAtOffset(index * size);

            if (Type.StaticType.IsByRef)
            {
                new_loc = new_loc.GetDereferencedLocation();
            }

            return(Type.StaticType.GetObject(target, new_loc));
        }
        internal TargetObject GetField(TargetMemoryAccess target, TargetLocation location,
                                       NativeFieldInfo field)
        {
            TargetLocation field_loc = location.GetLocationAtOffset(field.Offset);

            if (field.Type.IsByRef)
            {
                field_loc = field_loc.GetDereferencedLocation();
            }

            if (!field.Type.IsByRef && field.IsBitfield)
            {
                field_loc = new BitfieldTargetLocation(
                    field_loc, field.BitOffset, field.BitSize);
            }

            return(field.Type.GetObject(target, field_loc));
        }
Exemple #6
0
        internal void SetStaticField(TargetMemoryAccess target, TargetFieldInfo field,
                                     TargetAddress data_address, TargetObject obj)
        {
            GetFields(target);

            int        offset = field_offsets [field.Position];
            TargetType type   = field_types [field.Position];

            TargetLocation location  = new AbsoluteTargetLocation(data_address);
            TargetLocation field_loc = location.GetLocationAtOffset(offset);

            if (type.IsByRef)
            {
                field_loc = field_loc.GetDereferencedLocation();
            }

            type.SetObject(target, field_loc, obj);
        }
        internal void SetField(TargetMemoryAccess target, TargetLocation location,
                               NativeFieldInfo field, TargetObject obj)
        {
            TargetLocation field_loc = location.GetLocationAtOffset(field.Offset);

            if (field.Type.IsByRef)
            {
                field_loc = field_loc.GetDereferencedLocation();
            }

            if (!field.Type.IsByRef && field.IsBitfield)
            {
                field_loc = new BitfieldTargetLocation(
                    field_loc, field.BitOffset, field.BitSize);
            }

            // field.Type.SetObject (field_loc, obj);
            throw new NotImplementedException();
        }
        public override void SetField(Thread thread, TargetStructObject instance,
                                      TargetFieldInfo field, TargetObject value)
        {
            TargetLocation field_loc = instance.Location.GetLocationAtOffset(field.Offset);

            if (field.Type.IsByRef)
            {
                field_loc = field_loc.GetDereferencedLocation();
            }

            NativeFieldInfo nfield = (NativeFieldInfo)field;

            if (!field.Type.IsByRef && nfield.IsBitfield)
            {
                field_loc = new BitfieldTargetLocation(
                    field_loc, nfield.BitOffset, nfield.BitSize);
            }

            // field.Type.SetObject (field_loc, value);
            throw new NotImplementedException();
        }
        internal TargetObject GetField(TargetMemoryAccess target,
                                       TargetStructObject instance,
                                       TargetFieldInfo field)
        {
            TargetLocation field_loc = instance.Location.GetLocationAtOffset(field.Offset);

            if (field.Type.IsByRef)
            {
                field_loc = field_loc.GetDereferencedLocation();
            }

            NativeFieldInfo nfield = (NativeFieldInfo)field;

            if (!field.Type.IsByRef && nfield.IsBitfield)
            {
                field_loc = new BitfieldTargetLocation(
                    field_loc, nfield.BitOffset, nfield.BitSize);
            }

            return(field.Type.GetObject(target, field_loc));
        }
Exemple #10
0
        internal void SetInstanceField(TargetMemoryAccess target,
                                       TargetStructObject instance,
                                       TargetFieldInfo field, TargetObject obj)
        {
            GetFields(target);

            int        offset = field_offsets [field.Position];
            TargetType type   = field_types [field.Position];

            if (!Type.IsByRef)
            {
                offset -= 2 * target.TargetMemoryInfo.TargetAddressSize;
            }
            TargetLocation field_loc = instance.Location.GetLocationAtOffset(offset);

            if (type.IsByRef)
            {
                field_loc = field_loc.GetDereferencedLocation();
            }

            type.SetObject(target, field_loc, obj);
        }