Exemplo n.º 1
0
        private void ValidateTagBlock(ElementArray info, BlamPointer pointer, BinaryReader reader, ref int address)
        {
            using (reader.BaseStream.Pin())
            {
                // If owned by tag and memory has not been allocated yet*
                var allocated = from item in PointersList
                                where item.Item1.Equals(pointer)
                                select item;
                var partiallyAllocated = from item in PointersList
                                         where item.Item1.Intersects(pointer)
                                         select item;
                if (OwnedByTag(pointer))
                {
                    if (!allocated.Any())
                    {
                        var alignedAddress = (address - startOffset) + Padding.GetCount(address - startOffset, info.Alignment);
                        if (pointer.Address - startOffset != alignedAddress)
                        {
                            MapStream mapStream = reader.BaseStream as MapStream;
                            if (mapStream != null)
                            {
                                OnWriteMessage(string.Format("{2}: Expected address \"{0}\"  - actually was \"{1}\"", address - startOffset, pointer.Address - startOffset, info.Name));
                            }
                        }
                        address = pointer.Address + pointer.PointedSize;
                    }
                    if (allocated.Any())
                    {
                    }
                    else if (partiallyAllocated.Any())
                    {
                        foreach (var overlappingItem in partiallyAllocated)
                        {
                            var overlap = pointer.Address - overlappingItem.Item1.Address - overlappingItem.Item1.PointedSize;
                            OnWriteMessage(string.Format("Overlap of ({0})[{3}] with ({1}) by ({2}) bytes", overlappingItem.Item2.ToHierarchyString(), info.ToHierarchyString(), overlap, overlappingItem.Item1.Count));
                        }
                    }
                }
                else if (!IsValid(pointer))
                {
                    OnWriteMessage(string.Format("INVALID POINTER"));
                    return;
                }
                else
                {
                    OnWriteMessage(string.Format("WILLLLLSOOON SHARE"));
                }

                PointersList.Add(new Tuple <BlamPointer, ElementArray>(pointer, info));

                foreach (var elementAddress in pointer)
                {
                    reader.BaseStream.Position = elementAddress;
                    ValidateChildren(info, reader, ref address);
                }
            }
        }
Exemplo n.º 2
0
        private void ValidateTagBlock(ElementArray info, BlamPointer pointer, BinaryReader reader, ref int address)
        {
            using (reader.BaseStream.Pin())
            {
                // If owned by tag and memory has not been allocated yet*
                var allocated = from item in _pointersList
                                where item.Item1.Equals(pointer)
                                select item;
                var partiallyAllocated = from item in _pointersList
                                         where item.Item1.Intersects(pointer)
                                         select item;
                if (IsOwnedByTag(pointer))
                {
                    var enumerable = allocated as IList <Tuple <BlamPointer, ElementArray> > ?? allocated.ToList();
                    if (!enumerable.Any())
                    {
                        var alignedAddress = (address) +
                                             Padding.GetCount(address, info.alignment);
                        if (pointer.StartAddress != alignedAddress)
                        {
                            var mapStream = reader.BaseStream as CacheStream;
                            if (mapStream != null)
                            {
                                error = true;
                                OnWriteMessage(string.Format("{2}: Expected address \"{0}\"  - actually was \"{1}\" delta \"{3}\"",
                                                             (uint)alignedAddress, (uint)pointer.StartAddress, info.name, alignedAddress - pointer.StartAddress));
                            }
                        }
                        address = pointer.StartAddress + pointer.PointedSize;
                    }
                    if (enumerable.Any())
                    {
                    }
                    else
                    {
                        var overlappingItems = partiallyAllocated as IList <Tuple <BlamPointer, ElementArray> > ??
                                               partiallyAllocated.ToList();
                        if (overlappingItems.Any())
                        {
                            foreach (var overlappingItem in overlappingItems)
                            {
                                error = true;
                                var overlap = pointer.StartAddress - overlappingItem.Item1.StartAddress -
                                              overlappingItem.Item1.PointedSize;

                                OnWriteMessage(
                                    string.Format(
                                        "Overlap of ({0})\n{3} elements sized '{5}' at '{4}'\nwith ({1})\n{6} elements sized '{8}' at '{7}'\nby ({2}) bytes",
                                        overlappingItem.Item2.ToHierarchyString(), info.ToHierarchyString(), overlap,
                                        overlappingItem.Item1.ElementCount, overlappingItem.Item1.StartAddress,
                                        overlappingItem.Item1.ElementSize,
                                        pointer.ElementCount, pointer.StartAddress, pointer.ElementSize));
                            }
                        }
                    }
                }
                else if (!IsValid(pointer))
                {
                    //error = true;
                    //OnWriteMessage(string.Format("INVALID POINTER {1} -> {0}", info.name, pointer));
                    return;
                }
                else
                {
                    // OnWriteMessage( string.Format( "EXTERNAL SHARE" ) );
                }

                _pointersList.Add(new Tuple <BlamPointer, ElementArray>(pointer, info));

                foreach (var elementAddress in pointer)
                {
                    reader.BaseStream.Position = elementAddress;
                    ValidateChildren(info, reader, ref address);
                }
            }
        }