示例#1
0
        public MList <DiskString> FindBytes(byte[] bytes)
        {
            int last = Data.Length - bytes.Length;
            MList <DiskString> result = new MList <DiskString>();

            for (int i = 0; i < last; i++)
            {
                for (int j = 0; j < bytes.Length; j++)
                {
                    if (bytes[j] != Data[i + j])
                    {
                        goto noMatch;
                    }
                }
                DiskString ds = new DiskString();
                ds.Image  = this;
                ds.Track  = i / SectorSize / SectorsOnTrack;
                ds.Sector = i / SectorSize - ds.Track * SectorsOnTrack;
                ds.Offset = i - ds.Track * SectorsOnTrack * SectorSize - ds.Sector * SectorSize;
                ds.File   = GetFileByDiskAddress(ds.Track, ds.Sector);
                result.Add(ds);
                noMatch :;
            }
            return(result);
        }
示例#2
0
        public MList <DiskString> FindString(string str, int xor, int extendBy)
        {
            int last = Data.Length - str.Length;

            byte[]             clip   = new byte[str.Length];
            byte[]             clip1  = new byte[str.Length + extendBy * 2];
            MList <DiskString> result = new MList <DiskString>();

            for (int i = 0; i < last; i++)
            {
                for (int j = 0; j < str.Length; j++)
                {
                    clip[j] = (byte)(Data[i + j] ^ xor);
                }
                string s0 = Encoding.ASCII.GetString(clip, 0, str.Length);
                if (s0.Equals(str, StringComparison.OrdinalIgnoreCase))
                {
                    DiskString ds = new DiskString();
                    ds.Image  = this;
                    ds.Track  = i / SectorSize / SectorsOnTrack;
                    ds.Sector = i / SectorSize - ds.Track * SectorsOnTrack;
                    ds.Offset = i - ds.Track * SectorsOnTrack * SectorSize - ds.Sector * SectorSize;
                    ds.Xor    = xor;
                    ds.File   = GetFileByDiskAddress(ds.Track, ds.Sector);
                    int start = Math.Max(0, i - extendBy);
                    int end   = Math.Min(i + str.Length + extendBy, Data.Length);
                    for (int j = start, k = 0; j < end; j++, k++)
                    {
                        clip1[k] = (byte)(Data[j] ^ xor);
                    }
                    ds.Value = Encoding.ASCII.GetString(clip1, 0, end - start);
                    result.Add(ds);
                }
            }
            return(result);
        }