예제 #1
0
        protected override bool GetAddresses(byte[] original, out int rawAddr, out int virtAddr)
        {
            var space = SectionEditor.ReserveBufferSpace((uint)this.Length);

            rawAddr  = (int)space.RawAddress;
            virtAddr = (int)space.VirtualAddress + 0x400000;
            return(true);
        }
예제 #2
0
        static void DoChanges(string filePath, DirectoryInfo aivFolder, SetPercentHandler SetPercent)
        {
            List <Change> todo = new List <Change>(Version.Changes.Where(c => c.IsChecked));

            int    index = 0;
            double count = 4 + todo.Count; // +1 from folder backup above, +1 for read, +1 for version edit, +1 for writing data

            SetPercent?.Invoke(++index / count);


            // read original data & section preparation
            byte[] oriData = File.ReadAllBytes(filePath);
            byte[] data    = (byte[])oriData.Clone();
            SectionEditor.Init(data);

            ChangeArgs args = new ChangeArgs(data, oriData, aivFolder);

            SetPercent?.Invoke(++index / count);



            // change version display in main menu
            try
            {
                Version.MenuChange.Activate(args);
            }
            catch (Exception e)
            {
                Debug.Error(e);
            }
            SetPercent?.Invoke(++index / count);



            // change stuff
            foreach (Change change in todo)
            {
                change.Activate(args);
                SetPercent?.Invoke(++index / count);
            }

            data = SectionEditor.AttachSection(data);

            if (filePath.EndsWith(BackupFileEnding))
            {
                filePath = filePath.Remove(filePath.Length - BackupFileEnding.Length);
            }
            else
            {
                // create backup
                File.WriteAllBytes(filePath + BackupFileEnding, oriData);
            }

            File.WriteAllBytes(filePath, data);
        }
예제 #3
0
 public override void Activate(ChangeArgs args)
 {
     args.Data = SectionEditor.GetBuffer();
     base.Activate(args);
 }