Ejemplo n.º 1
0
        private void RepShim_Click(object sender, RoutedEventArgs e)
        {
            var path = IO.OpenFileDialog();

            if (!string.IsNullOrEmpty(path))
            {
                ShimEntry en = new ShimEntry(path, SelectedEntry.Name);
                LoadedShimFile?.ReplaceEntry(SelectedEntry, en);
            }
        }
Ejemplo n.º 2
0
        private void btnAddShimEntry_Click(object sender, RoutedEventArgs e)
        {
            var path = IO.OpenFileDialog();

            if (!string.IsNullOrEmpty(path))
            {
                ShimEntry entry = new ShimEntry(path);
                LoadedShimFile?.AddEntry(entry);
            }
        }
Ejemplo n.º 3
0
        public void DeleteEntry(ShimEntry entry)
        {
            int index = ShimEntries.IndexOf(entry);

            if (index != -1)
            {
                ShimEntries.Remove(entry);
                RebuildOffsets();
            }
        }
Ejemplo n.º 4
0
        public void ReplaceEntry(ShimEntry oldEntry, ShimEntry newEntry)
        {
            int index = ShimEntries.IndexOf(oldEntry);

            if (index != -1)
            {
                newEntry.Offset = oldEntry.Offset;
                newEntry.UnknownButImportant = oldEntry.UnknownButImportant;
                ShimEntries[index]           = newEntry;
                RebuildOffsets();
            }
        }
Ejemplo n.º 5
0
        public ShimFile(string file)
        {
            FullPath    = file;
            FileName    = Path.GetFileName(file).Replace("\\", "_").Replace("/", "_");
            ExtractDir  = Path.Combine(Path.GetTempPath(), "ShimEditor", FileName);
            ShimEntries = new ObservableCollection <ShimEntry>();
            using (BinaryReader reader = new BinaryReader(new FileStream(file, FileMode.Open)))
            {
                //I don't have any option to check if this is an correct file.
                //I'm trusting the user on this one.

                reader.BaseStream.Position = 4;
                var files = reader.ReadInt32();
                for (int i = 0; i < files; i++)
                {
                    ShimEntry shim = new ShimEntry();
                    reader.BaseStream.Position = 0x10 + i * 0x30;
                    shim.Name   = Encoding.UTF8.GetString(reader.ReadBytes(0x20)).Replace("\0", string.Empty) /*.Replace("\\", "_").Replace("/", "_")*/;
                    shim.Offset = reader.ReadInt32();
                    shim.UnknownButImportant = reader.ReadInt32();
                    shim.Size = reader.ReadInt32();

                    reader.BaseStream.Position = shim.Offset;
                    shim.Data = reader.ReadBytes(shim.Size);
                    ShimEntries.Add(shim);

                    //while we're at the first shim entry, let's grab the base file
                    if (i == 0)
                    {
                        var shimHeaderLen = 0x10 + files * 0x30;
                        reader.BaseStream.Position = shimHeaderLen;
                        BaseFile = reader.ReadBytes(shim.Offset - shimHeaderLen);
                    }
                }
            }
        }
Ejemplo n.º 6
0
 public void Extract(ShimEntry entry, string path)
 {
     File.WriteAllBytes(path, entry.Data);
 }
Ejemplo n.º 7
0
 public void AddEntry(ShimEntry en)
 {
     ShimEntries.Add(en);
     RebuildOffsets();
 }