private void buttonChooseStack_Click(object sender, EventArgs e)
        {
            if (Filenames.Count > 0)
            {
                Filenames.Clear();
            }

            openFileDialogStack.Filter           = _dialogFilterStack;
            openFileDialogStack.InitialDirectory = _initDir;
            openFileDialogStack.FileName         = "";
            DialogResult result = openFileDialogStack.ShowDialog();

            if (result == DialogResult.OK)
            {
                Stackname = openFileDialogStack.FileName;
                if (Stackname != null)
                {
                    textBox1.Text = Stackname;

                    WSIExtraction.Stack stack = ReadWriteUtils.DeserializeObjectFromJSON <WSIExtraction.Stack>(Stackname);
                    foreach (WSIExtraction.Slice slice in stack.Section)
                    {
                        Filenames.Add(Path.Combine(Path.GetDirectoryName(Stackname), slice.Path));
                    }
                }
                textBox1.Text = Stackname;
                EnableButtons();
            }
        }
        private void ParseFiles(CompareSets set)
        {
            // scan directories
            var files = ListFiles(set.Path);

            // set files
            set.FileList = files;
            totalFiles  += files.Count;

            int wt, cpt;

            ThreadPool.GetMaxThreads(out wt, out cpt);

            // files file comparision
            var tasks = new List <Task>();

            foreach (var file in set.FileList)
            {
                tasks.Add(Task.Run(() =>
                {
                    var data = FileCompareData.FromFile(file, set.Path);
                    lock (set)
                    {
                        set.AllFiles.Add(data);
                        set.Files[data.absolutePath] = data;
                        Filenames.Add(data.name);
                    }

                    ++fileScanIndex;
                }));
            }

            Task.WaitAll(tasks.ToArray());
        }
Exemple #3
0
 public static void Add(string filename)
 {
     if (!String.IsNullOrEmpty(filename))
     {
         Filenames.Add(filename.ToLower());
     }
 }
Exemple #4
0
        internal void ReadItems()
        {
            if (items.Any())
            {
                throw new InvalidOperationException();
            }

            using (var reader = cache.CreateReader(cache.MetadataTranslator))
            {
                reader.Seek(TagClassDataPointer.Address, SeekOrigin.Begin);
                Classes.AddRange(reader.ReadEnumerable <TagClass>(TagClassCount));

                reader.Seek(TagDataPointer.Address, SeekOrigin.Begin);
                for (int i = 0; i < TagCount; i++)
                {
                    //every Reach map has an empty tag
                    var item = reader.ReadObject(new IndexItem(cache, i));
                    if (item.ClassIndex < 0)
                    {
                        continue;
                    }

                    items.Add(i, item);

                    if (item.ClassCode != CacheFactory.ScenarioClass && CacheFactory.SystemClasses.Contains(item.ClassCode))
                    {
                        sysItems.Add(item.ClassCode, item);
                    }
                }

                reader.Seek(cache.Header.FileTableIndexPointer.Address, SeekOrigin.Begin);
                var indices = reader.ReadEnumerable <int>(TagCount).ToArray();

                reader.Seek(cache.Header.FileTablePointer.Address, SeekOrigin.Begin);
                var decrypted = reader.ReadAesBytes(cache.Header.FileTableSize, cache.CacheType == CacheType.HaloReachBeta ? CacheFile.BetaKey : CacheFile.FileNamesKey);
                using (var ms = new MemoryStream(decrypted))
                    using (var tempReader = new EndianReader(ms))
                    {
                        for (int i = 0; i < TagCount; i++)
                        {
                            if (indices[i] == -1)
                            {
                                Filenames.Add(i, null);
                                continue;
                            }

                            tempReader.Seek(indices[i], SeekOrigin.Begin);
                            Filenames.Add(i, tempReader.ReadNullTerminatedString());
                        }
                    }
            }

            try
            {
                sysItems[CacheFactory.ScenarioClass] = items.Values.Single(i => i.ClassCode == CacheFactory.ScenarioClass && i.FullPath == cache.Header.ScenarioName);
            }
            catch { throw Exceptions.AmbiguousScenarioReference(); }
        }
Exemple #5
0
        public void Read(byte[] data)
        {
            using BinaryReader reader = new(new MemoryStream(data));
            int size = data.Length;

            while (size > 0)
            {
                var filename = reader.ReadCString();
                Filenames.Add(filename.GetPlainName());
                size -= filename.Length + 1;
            }
        }
Exemple #6
0
        public NarcArchive(byte[] data)
        {
            var frames = ReadNitroFrames(data);

            if (!frames.ContainsKey("FATB") || !frames.ContainsKey("FNTB") || !frames.ContainsKey("FIMG"))
            {
                throw new IOException("Not a valid narc file");
            }

            var fatbframe = frames["FATB"];
            var fimgframe = frames["FIMG"];
            var fileCount = ReadLong(fatbframe, 0);

            for (var i = 0; i < fileCount; i++)
            {
                var startOffset = ReadLong(fatbframe, 4 + i * 8);
                var endOffset   = ReadLong(fatbframe, 8 + i * 8);
                var length      = endOffset - startOffset;

                Files.Add(fimgframe.Slice(length, startOffset));
            }

            var fntbframe = frames["FNTB"];
            var unk1      = ReadLong(fntbframe, 0);

            if (unk1 == 8)
            {
                var offset = 8;
                HasFilenames = true;

                for (var i = 0; i < fileCount; i++)
                {
                    var fnLength = fntbframe[offset] & 0xFF;
                    offset++;

                    var array = new byte[fntbframe.Length];
                    fntbframe.CopyTo(array, 0);
                    Filenames.Add(Encoding.ASCII.GetString(array, offset, fnLength));
                }
            }
            else
            {
                HasFilenames = false;

                for (var i = 0; i < fileCount; i++)
                {
                    Filenames.Add(null);
                }
            }
        }
        override public void Init()
        {
            DirectoryInfo d = new DirectoryInfo(Misc.Common.SaveFolder); // TODO specified directory

            if (d.Exists == false)
            {
                return;
            }
            ListBox box = FindName("Databases") as ListBox;

            foreach (FileInfo fi in d.GetFiles())
            {
                if (fi.Extension.Equals(Common.DbExt))
                {
                    Filenames.Add(fi);
                }
            }
            box.SelectedIndex = 0;
            OnInfo(string.Format("Found {0} records", Filenames.Count));
        }
Exemple #8
0
        internal void ReadItems()
        {
            if (items.Any())
            {
                throw new InvalidOperationException();
            }

            using (var reader = cache.CreateReader(cache.MetadataTranslator))
            {
                reader.Seek(TagDataAddress.Address, SeekOrigin.Begin);
                for (int i = 0; i < TagCount; i++)
                {
                    //Halo2Vista multiplayer maps have empty tags in them
                    var item = reader.ReadObject(new IndexItem(cache));
                    if (item.Id < 0)
                    {
                        continue;
                    }

                    items.Add(i, item);

                    //Halo2Vista multiplayer maps have two ugh! tags
                    if (CacheFactory.SystemClasses.Contains(item.ClassCode) && !sysItems.ContainsKey(item.ClassCode))
                    {
                        sysItems.Add(item.ClassCode, item);
                    }
                }

                reader.Seek(cache.Header.FileTableIndexOffset, SeekOrigin.Begin);
                var indices = reader.ReadEnumerable <int>(TagCount).ToArray();

                for (int i = 0; i < TagCount; i++)
                {
                    reader.Seek(cache.Header.FileTableAddress + indices[i], SeekOrigin.Begin);
                    Filenames.Add(i, reader.ReadNullTerminatedString());
                }
            }
        }
        private void buttonChoosePNGs_Click(object sender, EventArgs e)
        {
            if (Filenames.Count > 0)
            {
                Filenames.Clear();
            }

            openFileDialogImages.Multiselect      = true;
            openFileDialogImages.Filter           = _dialogFilterImages;
            openFileDialogImages.InitialDirectory = _initDir;
            openFileDialogImages.FileName         = "";
            DialogResult result = openFileDialogImages.ShowDialog();

            if (result == DialogResult.OK)
            {
                foreach (string path in openFileDialogImages.FileNames)
                {
                    Filenames.Add(path);
                }
            }
            textBox2.Text = string.Join("; ", Filenames);
            EnableButtons();
        }
Exemple #10
0
        internal void ReadItems(DependencyReader reader)
        {
            if (items.Any())
            {
                throw new InvalidOperationException();
            }

            for (int i = 0; i < TagCount; i++)
            {
                reader.Seek(cache.Header.IndexAddress + HeaderSize + i * 32, SeekOrigin.Begin);

                var item = reader.ReadObject(new IndexItem(cache));
                items.Add(item);

                if (CacheFactory.SystemClasses.Contains(item.ClassCode))
                {
                    sysItems.Add(item.ClassCode, item);
                }

                reader.Seek(item.FileNamePointer.Address, SeekOrigin.Begin);
                Filenames.Add(item.Id, reader.ReadNullTerminatedString());
            }
        }
Exemple #11
0
        internal void ReadItems()
        {
            if (items.Any())
            {
                throw new InvalidOperationException();
            }

            using (var reader = cache.CreateReader(cache.MetadataTranslator, cache.PointerExpander))
            {
                reader.Seek(TagClassDataPointer.Address, SeekOrigin.Begin);
                Classes.AddRange(reader.ReadEnumerable <TagClass>(TagClassCount));

                reader.Seek(TagDataPointer.Address, SeekOrigin.Begin);
                for (int i = 0; i < TagCount; i++)
                {
                    var item = reader.ReadObject(new IndexItem(cache, i));
                    if (item.ClassIndex < 0)
                    {
                        continue;
                    }

                    items.Add(i, item);

                    if (item.ClassCode != CacheFactory.ScenarioClass && CacheFactory.SystemClasses.Contains(item.ClassCode))
                    {
                        sysItems.Add(item.ClassCode, item);
                    }
                }

                var play = sysItems["play"];
                if (play.MetaPointer.Value == 0)
                {
                    play.MetaPointer = new Pointer(sysItems["zone"].MetaPointer.Value + 28, cache.MetadataTranslator);
                }

                reader.Seek(cache.Header.FileTableIndexPointer.Address, SeekOrigin.Begin);
                var indices = reader.ReadEnumerable <int>(TagCount).ToArray();

                reader.Seek(cache.Header.FileTablePointer.Address, SeekOrigin.Begin);
                using (var tempReader = reader.CreateVirtualReader())
                {
                    for (int i = 0; i < TagCount; i++)
                    {
                        if (indices[i] == -1)
                        {
                            Filenames.Add(i, null);
                            continue;
                        }

                        tempReader.Seek(indices[i], SeekOrigin.Begin);
                        Filenames.Add(i, tempReader.ReadNullTerminatedString());
                    }
                }
            }

            try
            {
                sysItems[CacheFactory.ScenarioClass] = items.Values.Single(i => i.ClassCode == CacheFactory.ScenarioClass && i.FullPath == cache.Header.ScenarioName);
            }
            catch { throw Exceptions.AmbiguousScenarioReference(); }
        }
Exemple #12
0
        internal void ReadItems()
        {
            if (items.Any())
            {
                throw new InvalidOperationException();
            }

            using (var reader = cache.CreateReader(cache.MetadataTranslator))
            {
                reader.Seek(TagClassDataPointer.Address, SeekOrigin.Begin);
                Classes.AddRange(reader.ReadEnumerable <TagClass>(TagClassCount));

                reader.Seek(TagDataPointer.Address, SeekOrigin.Begin);
                for (int i = 0; i < TagCount; i++)
                {
                    var item = reader.ReadObject(new IndexItem(cache, i));
                    if (item.ClassIndex < 0)
                    {
                        continue;
                    }

                    items.Add(i, item);

                    if (item.ClassCode != CacheFactory.ScenarioClass && CacheFactory.SystemClasses.Contains(item.ClassCode))
                    {
                        sysItems.Add(item.ClassCode, item);
                    }
                }

                // hack to redirect any play tag requests to the start of the zone tag when there is no play tag
                var play = sysItems["play"];
                if (play.MetaPointer.Value == 0)
                {
                    play.MetaPointer = new Pointer(sysItems["zone"].MetaPointer.Value + 28, cache.MetadataTranslator);
                }

                reader.Seek(cache.Header.FileTableIndexPointer.Address, SeekOrigin.Begin);
                var indices = reader.ReadEnumerable <int>(TagCount).ToArray();

                reader.Seek(cache.Header.FileTablePointer.Address, SeekOrigin.Begin);
                var decrypted = reader.ReadAesBytes(cache.Header.FileTableSize, CacheFile.FileNamesKey);
                using (var ms = new MemoryStream(decrypted))
                    using (var tempReader = new EndianReader(ms))
                    {
                        for (int i = 0; i < TagCount; i++)
                        {
                            if (indices[i] == -1)
                            {
                                Filenames.Add(i, null);
                                continue;
                            }

                            tempReader.Seek(indices[i], SeekOrigin.Begin);
                            Filenames.Add(i, tempReader.ReadNullTerminatedString());
                        }
                    }
            }

            try
            {
                sysItems[CacheFactory.ScenarioClass] = items.Values.Single(i => i.ClassCode == CacheFactory.ScenarioClass && i.FullPath == cache.Header.ScenarioName);
            }
            catch { throw Exceptions.AmbiguousScenarioReference(); }
        }
 public void AddFile(string path)
 {
     Filenames.Add(path);
 }