Exemple #1
0
        internal override void SetObject(TargetMemoryAccess target, TargetLocation location,
                                         TargetObject obj)
        {
            TargetLocation flag_loc = location.GetLocationAtOffset(ElementType.Size);

            byte[] buffer = new byte [1];

            if (obj is TargetNullObject)
            {
                buffer [0] = 0;
                flag_loc.WriteBuffer(target, buffer);
                return;
            }

            MonoNullableObject nobj = obj as MonoNullableObject;

            if (nobj != null)
            {
                if (!nobj.HasValue(target))
                {
                    buffer [0] = 0;
                    flag_loc.WriteBuffer(target, buffer);
                    return;
                }
                else
                {
                    obj = nobj.GetValue(target);
                }
            }

            buffer [0] = 1;
            flag_loc.WriteBuffer(target, buffer);

            ElementType.SetObject(target, location, obj);
        }
        internal TargetClassObject GetCurrentObject(TargetMemoryAccess target,
                                                    TargetLocation location)
        {
            // location.Address resolves to the address of the MonoObject,
            // dereferencing it once gives us the vtable, dereferencing it
            // twice the class.
            TargetAddress address;

            address = target.ReadAddress(location.GetAddress(target));
            address = target.ReadAddress(address);

            TargetType current = File.MonoLanguage.ReadMonoClass(target, address);

            if (current == null)
            {
                return(null);
            }

            if (IsByRef && !current.IsByRef)             // Unbox
            {
                location = location.GetLocationAtOffset(
                    2 * target.TargetMemoryInfo.TargetAddressSize);
            }

            return((TargetClassObject)current.GetObject(target, location));
        }
Exemple #3
0
        internal override void SetObject(TargetMemoryAccess target, TargetLocation location,
						  TargetObject obj)
        {
            TargetLocation flag_loc = location.GetLocationAtOffset (ElementType.Size);
            byte[] buffer = new byte [1];

            if (obj is TargetNullObject) {
                buffer [0] = 0;
                flag_loc.WriteBuffer (target, buffer);
                return;
            }

            MonoNullableObject nobj = obj as MonoNullableObject;
            if (nobj != null) {
                if (!nobj.HasValue (target)) {
                    buffer [0] = 0;
                    flag_loc.WriteBuffer (target, buffer);
                    return;
                } else {
                    obj = nobj.GetValue (target);
                }
            }

            buffer [0] = 1;
            flag_loc.WriteBuffer (target, buffer);

            ElementType.SetObject (target, location, obj);
        }
Exemple #4
0
        protected string ReadString(TargetMemoryAccess target, TargetLocation start)
        {
            if (start.HasAddress && start.GetAddress(target).IsNull)
            {
                return("null");
            }

            StringBuilder sb   = new StringBuilder();
            bool          done = false;

            int offset = 0;

            while (!done && (offset < MaximumDynamicSize))
            {
                TargetLocation location = start.GetLocationAtOffset(offset);
                byte[]         buffer   = location.ReadBuffer(target, ChunkSize);

                int    pos         = 0;
                int    size        = buffer.Length;
                char[] char_buffer = new char [size * 3];
                for (int i = 0; i < size; i++)
                {
                    if (buffer [i] == 0)
                    {
                        done = true;
                        break;
                    }

                    char ch = (char)buffer [i];
                    if (Char.IsLetterOrDigit(ch) || Char.IsPunctuation(ch) ||
                        Char.IsWhiteSpace(ch) || (ch == '<') || (ch == '>'))
                    {
                        char_buffer [pos++] = ch;
                    }
                    else if (ch == '\\')
                    {
                        char_buffer [pos++] = '\\';
                        char_buffer [pos++] = '\\';
                    }
                    else if ((ch == '\'') || (ch == '`'))
                    {
                        char_buffer [pos++] = ch;
                    }
                    else
                    {
                        char_buffer [pos++] = '\\';
                        char_buffer [pos++] = hex_chars [(ch & 0xf0) >> 4];
                        char_buffer [pos++] = hex_chars [ch & 0x0f];
                    }
                }

                string str = new String(char_buffer, 0, pos);
                sb.Append(str);

                offset += size;
            }

            return(sb.ToString());
        }
Exemple #5
0
        internal override long GetDynamicSize(TargetMemoryAccess target, TargetBlob blob,
						       TargetLocation location,
						       out TargetLocation dynamic_location)
        {
            int element_size = Type.GetElementSize (target);
            dynamic_location = location.GetLocationAtOffset (Type.Size);
            return element_size * GetLength (target);
        }
        internal override long GetDynamicSize(TargetMemoryAccess target, TargetBlob blob,
                                              TargetLocation location,
                                              out TargetLocation dynamic_location)
        {
            int element_size = Type.GetElementSize(target);

            dynamic_location = location.GetLocationAtOffset(Type.Size);
            return(element_size * GetLength(target));
        }
Exemple #7
0
        internal override long GetDynamicSize(TargetMemoryAccess target, TargetBlob blob,
						       TargetLocation location,
						       out TargetLocation dynamic_location)
        {
            TargetBinaryReader reader = blob.GetReader ();
            reader.Position = Type.ObjectSize;
            dynamic_location = location.GetLocationAtOffset (Type.ObjectSize + 4);
            return reader.ReadInteger (4) * 2;
        }
Exemple #8
0
        internal override long GetDynamicSize(TargetMemoryAccess target, TargetBlob blob,
                                              TargetLocation location,
                                              out TargetLocation dynamic_location)
        {
            TargetBinaryReader reader = blob.GetReader();

            reader.Position  = Type.ObjectSize;
            dynamic_location = location.GetLocationAtOffset(Type.ObjectSize + 4);
            return(reader.ReadInteger(4) * 2);
        }
        protected string ReadString(TargetMemoryAccess target, TargetLocation start)
        {
            if (start.HasAddress && start.GetAddress (target).IsNull)
                return "null";

            StringBuilder sb = new StringBuilder ();
            bool done = false;

            int offset = 0;

            while (!done && (offset < MaximumDynamicSize)) {
                TargetLocation location = start.GetLocationAtOffset (offset);
                byte[] buffer = location.ReadBuffer (target, ChunkSize);

                int pos = 0;
                int size = buffer.Length;
                char[] char_buffer = new char [size * 3];
                for (int i = 0; i < size; i++) {
                    if (buffer [i] == 0) {
                        done = true;
                        break;
                    }

                    char ch = (char) buffer [i];
                    if (Char.IsLetterOrDigit (ch) || Char.IsPunctuation (ch) ||
                        Char.IsWhiteSpace (ch) || (ch == '<') || (ch == '>'))
                        char_buffer [pos++] = ch;
                    else if (ch == '\\') {
                        char_buffer [pos++] = '\\';
                        char_buffer [pos++] = '\\';
                    } else if ((ch == '\'') || (ch == '`')) {
                        char_buffer [pos++] = ch;
                    } else {
                        char_buffer [pos++] = '\\';
                        char_buffer [pos++] = hex_chars [(ch & 0xf0) >> 4];
                        char_buffer [pos++] = hex_chars [ch & 0x0f];
                    }
                }

                string str = new String (char_buffer, 0, pos);
                sb.Append (str);

                offset += size;
            }

            return sb.ToString ();
        }
        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));
        }
        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();
        }
Exemple #12
0
        internal TargetClassObject GetCurrentObject(TargetMemoryAccess target,
							      TargetLocation location)
        {
            // location.Address resolves to the address of the MonoObject,
            // dereferencing it once gives us the vtable, dereferencing it
            // twice the class.
            TargetAddress address;
            address = target.ReadAddress (location.GetAddress (target));
            address = target.ReadAddress (address);

            TargetType current = File.MonoLanguage.ReadMonoClass (target, address);
            if (current == null)
                return null;

            if (IsByRef && !current.IsByRef) // Unbox
                location = location.GetLocationAtOffset (
                    2 * target.TargetMemoryInfo.TargetAddressSize);

            return (TargetClassObject) current.GetObject (target, location);
        }
Exemple #13
0
        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 ();
        }
Exemple #14
0
        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);
        }