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 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 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)); }
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()); }
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 TargetObject GetObject(StackFrame frame, TargetMemoryAccess target) { TargetLocation location = GetLocation(frame, target); if (location == null) { throw new LocationInvalidException(); } if (location.HasAddress && location.GetAddress(target).IsNull) { TargetLocation null_loc = new AbsoluteTargetLocation(TargetAddress.Null); return(new TargetNullObject(type)); } return(type.GetObject(target, location)); }
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); }