public static bool CombineMemorySectorsIntoImage(IEnumerable <byte[]> sectorData, MemoryLayout layout, out MemoryImage combinedData)
        {
            bool success = true;

            combinedData = new MemoryImage(layout.Size, layout.BaseAddress);

            int curIndex = 0;

            foreach (var curSector in sectorData)
            {
                if ((curSector == null) || (curIndex + curSector.Length > layout.Size))
                {
                    success = false;
                    break;
                }

                Buffer.BlockCopy(curSector, 0, combinedData.RawData, curIndex, curSector.Length);
                curIndex += curSector.Length;
            }

            return(success);
        }
Esempio n. 2
0
        public void CopyFrom(MemoryImage otherImage)
        {
            StartAddress = otherImage.StartAddress;

            if ((otherImage.RawData != null) && (otherImage.RawData.Length > 0))
            {
                if (RawData == null)
                {
                    RawData = new byte[otherImage.RawData.Length];
                }

                if (RawData.Length != otherImage.RawData.Length)
                {
                    Array.Resize <byte>(ref mRawData, otherImage.RawData.Length);
                }

                Buffer.BlockCopy(otherImage.RawData, 0, RawData, 0, RawData.Length);
            }
            else
            {
                RawData = null;
            }
        }
Esempio n. 3
0
 public MemoryImage(MemoryImage other)
 {
     CopyFrom(other);
 }