public IEnumerable <WorkItem> VisitPointer(Pointer ptr) { Debug.Print("Iterating pointer at {0:X}", gOffset); var rdr = arch.CreateImageReader(image, (ulong)gOffset - image.BaseAddress.ToLinear()); if (!rdr.IsValid) { return(null); } var c = rdr.Read(PrimitiveType.Create(Domain.Pointer, ptr.Size)); int offset = c.ToInt32(); Debug.Print(" pointer value: {0:X}", offset); if (visited.Contains(offset) || !image.IsValidLinearAddress((uint)offset)) { return(Enumerable.Empty <WorkItem>()); } // We've successfully traversed a pointer to a valid destination! // The address must therefore be of type ptr.Pointee. visited.Add(offset); if (globalStr.Fields.AtOffset(offset) == null) { Debug.Print(" Discovery: {0:X} {1}", offset, ptr.Pointee); Discoveries.Add(new StructureField(offset, ptr.Pointee)); } return(Single(new WorkItem { DataType = ptr.Pointee, GlobalOffset = c.ToInt32() })); }
private Brush GetColorForOffset(int cbOffset) { ImageMapItem item; if (imageMap == null || image == null) { return(brBack); } var lin = (image.BaseAddress + cbOffset).ToLinear(); if (!image.IsValidLinearAddress(lin)) { return(brBack); } var address = imageMap.MapLinearAddressToAddress(lin); if (!imageMap.TryFindItem(address, out item)) { return(brBack); } if (item.DataType is UnknownType) { return(brBack); } if (item is ImageMapBlock) { return(brCode); } else { return(brData); } }