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)); }
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); }
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 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)); }
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; }
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(); }
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); }
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 (); }
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); }