Esempio n. 1
0
        public void Constructor()
        {
            RELNode r = _resource as RELNode;

            if (r._prologSect != -1)
            {
                ModuleDataNode s = r._sections[r._prologSect];

                foreach (SectionEditor l in SectionEditor._openedSections)
                {
                    if (l._section == s)
                    {
                        l.Focus();
                        l.Position = r._prologIndex * 4;
                        l.hexBox1.Focus();
                        return;
                    }
                }

                SectionEditor e = new SectionEditor(s as ModuleSectionNode);
                e.Show();
                e.Position = r._prologIndex * 4;
                e.hexBox1.Focus();
            }
            else
            {
                MessageBox.Show("This module has no constructor function.");
            }
        }
Esempio n. 2
0
        public void Unresolved()
        {
            RELNode r = _resource as RELNode;

            if (r._unresReloc != null)
            {
                ModuleDataNode s = r._unresReloc._section;

                foreach (SectionEditor l in SectionEditor._openedSections)
                {
                    if (l._section == s)
                    {
                        l.Focus();
                        l.Position = r._unresReloc._index * 4;
                        l.hexBox1.Focus();
                        return;
                    }
                }

                SectionEditor e = new SectionEditor(s as ModuleSectionNode);
                e.Show();
                e.Position = r._unresReloc._index * 4;
                e.hexBox1.Focus();
            }
            else
            {
                MessageBox.Show("This module has no unresolved function.");
            }
        }
Esempio n. 3
0
        public SectionEditor(ModuleSectionNode section)
        {
            _startIndex = int.MaxValue;
            _endIndex   = int.MinValue;

            InitializeComponent();

            ppcDisassembler1._editor = this;
            ppcDisassembler1.ppcOpCodeEditControl1._canFollowBranch  = true;
            ppcDisassembler1.ppcOpCodeEditControl1.OnBranchFollowed += ppcOpCodeEditControl1_OnBranchFollowed;

            if ((_section = section) != null)
            {
                _section._linkedEditor = this;
                _manager = new RelocationManager(_section);
            }

            _openedSections.Add(this);

            Text = string.Format("Module Section Editor - {0}", _section.Name);

            hexBox1.SectionEditor  = this;
            chkCodeSection.Checked = _section._isCodeSection;
            chkBSSSection.Checked  = _section._isBSSSection;

            if (section.Root is RELNode)
            {
                RELNode r = (RELNode)section.Root;
                if (r.PrologSection == section.Index)
                {
                    _manager._constructorIndex = (int)r._prologOffset / 4;
                }

                if (r.EpilogSection == section.Index)
                {
                    _manager._destructorIndex = (int)r._epilogOffset / 4;
                }

                if (r.UnresolvedSection == section.Index)
                {
                    _manager._unresolvedIndex = (int)r._unresolvedOffset / 4;
                }

                //if (r._nameReloc != null && r._nameReloc._section == section)
                //    _nameReloc = r._nameReloc;
            }

            panel5.Enabled = true;
        }
Esempio n. 4
0
        public SectionEditor(ModuleSectionNode section)
        {
            InitializeComponent();

            ppcDisassembler1._editor = this;

            if ((_section = section) != null)
            {
                _section._linkedEditor = this;

                Relocation[] temp = new Relocation[_section._relocations.Count];
                _section._relocations.CopyTo(temp);
                _relocations  = temp.ToList();
                _firstCommand = _section._firstCommand;
            }
            _openedSections.Add(this);

            Text = String.Format("Module Section Editor - {0}", _section.Name);

            hexBox1.SectionEditor  = this;
            chkCodeSection.Checked = _section._isCodeSection;
            chkBSSSection.Checked  = _section._isBSSSection;

            if (section.Root is RELNode)
            {
                RELNode r = (RELNode)section.Root;
                if (r._prologReloc != null && r._prologReloc._section == section)
                {
                    _prologReloc = r._prologReloc;
                }
                if (r._epilogReloc != null && r._epilogReloc._section == section)
                {
                    _epilogReloc = r._epilogReloc;
                }
                if (r._unresReloc != null && r._unresReloc._section == section)
                {
                    _unresReloc = r._unresReloc;
                }
                //if (r._nameReloc != null && r._nameReloc._section == section)
                //    _nameReloc = r._nameReloc;
            }

            panel5.Enabled = true;
        }
Esempio n. 5
0
        public void Unresolved()
        {
            RELNode r = _resource as RELNode;

            ModuleDataNode s = r.Sections[r._unresolvedSection];

            foreach (SectionEditor l in SectionEditor._openedSections)
            {
                if (l._section == s)
                {
                    l.Focus();
                    l.Position = r._unresolvedOffset;
                    l.hexBox1.Focus();
                    return;
                }
            }

            SectionEditor e = new SectionEditor(s as ModuleSectionNode);

            e.Show();
            e.Position = r._unresolvedOffset;
            e.hexBox1.Focus();
        }
        private void Apply()
        {
            if (hexBox1.ByteProvider == null)
            {
                return;
            }

            try
            {
                if (_section._isBSSSection != chkBSSSection.Checked || _section._isCodeSection != chkCodeSection.Checked)
                {
                    _section._isBSSSection  = chkBSSSection.Checked;
                    _section._isCodeSection = chkCodeSection.Checked;
                    _section.SignalPropertyChange();
                }

                if (_section.Root is RELNode)
                {
                    RELNode r = _section.Root as RELNode;

                    if (r._prologSect == _section.Index && r._prologIndex != _manager._constructorIndex)
                    {
                        //if (r._prologReloc != null)
                        //    r._prologReloc._prolog = false;

                        r._prologIndex = _manager._constructorIndex;
                        r.SignalPropertyChange();
                    }

                    if (r._prologSect == _section.Index && r._epilogIndex != _manager._destructorIndex)
                    {
                        //if (r._epilogReloc != null)
                        //    r._epilogReloc._epilog = false;

                        r._epilogIndex = _manager._destructorIndex;
                        r.SignalPropertyChange();
                    }

                    if (r._prologSect == _section.Index && r._unresIndex != _manager._unresolvedIndex)
                    {
                        //if (r._unresReloc != null)
                        //    r._unresReloc._unresolved = false;

                        r._unresIndex = _manager._unresolvedIndex;
                        r.SignalPropertyChange();
                    }
                }

                DynamicFileByteProvider d = hexBox1.ByteProvider as DynamicFileByteProvider;
                if (!d.HasChanges())
                {
                    return;
                }

                UnsafeBuffer newBuffer = new UnsafeBuffer((int)d.Length);

                int amt = Math.Min(_section._dataBuffer.Length, newBuffer.Length);
                if (amt > 0)
                {
                    Memory.Move(newBuffer.Address, _section._dataBuffer.Address, (uint)amt);
                    if (newBuffer.Length - amt > 0)
                    {
                        Memory.Fill(newBuffer.Address + amt, (uint)(newBuffer.Length - amt), 0);
                    }
                }

                if (d._stream != null)
                {
                    d._stream.Dispose();
                }
                d._stream = new UnmanagedMemoryStream((byte *)newBuffer.Address, newBuffer.Length, newBuffer.Length, FileAccess.ReadWrite);

                d.ApplyChanges();

                _section._dataBuffer.Dispose();
                _section._dataBuffer = newBuffer;
                _section.SignalPropertyChange();

                //if (_relocationsChanged)
                //{
                //    Relocation[] temp = new Relocation[_relocations.Count];
                //    _relocations.CopyTo(temp);
                //    List<Relocation> temp2 = temp.ToList();

                //    _section._relocations = temp2;
                //    _section._firstCommand = _firstCommand;

                //    ResourceNode a = _section.Root;
                //    if (a != null && a != _section.Root)
                //        a.SignalPropertyChange();
                //}

                hexBox1.Invalidate();
                hexBox1.Focus();
            }
            catch (Exception e)
            {
                MessageBox.Show(e.ToString());
            }
            finally
            {
                EnableButtons();
            }
        }