Example #1
0
        private unsafe RELObjectNode ParseObject(ref int rel)
        {
            RelCommand cmd = Manager.GetCommand(rel);

            RelocationTarget target = cmd?.GetTargetRelocation();

            if (target == null || target._sectionID != _objectSection.Index)
            {
                return(null);
            }


            if (!_types.TryGetValue(target._index, out RELType declaration) || declaration.Inherited)
            {
                return(null);
            }

            RELObjectNode obj = null;

            foreach (RELObjectNode node in _objects)
            {
                if (node._name == declaration.FullName)
                {
                    obj = node;
                    break;
                }
            }

            if (obj == null)
            {
                obj = new RELObjectNode(declaration)
                {
                    _parent = _objectSection
                };
                _objectSection._children.Add(obj);
                new RELGroupNode {
                    _name = "Inheritance"
                }.Parent = obj;
                foreach (InheritanceItemNode n in declaration.Inheritance)
                {
                    n.Parent = obj.Children[0];
                }

                new RELGroupNode {
                    _name = "Functions"
                }.Parent = obj;
            }

            int        baseRel = rel;
            RelCommand baseCmd = Manager.GetCommand(baseRel);

            int methodIndex = 0;
            int setIndex    = 0;

            //Read object methods.
            while ((cmd = Manager.GetCommand(rel)) != null)
            {
                RelocationTarget t = cmd.GetTargetRelocation();
                if (cmd.Apply(Manager.GetUint(rel), 0) != baseCmd.Apply(Manager.GetUint(baseRel), 0))
                {
                    string  methodName = $"Function[{setIndex}][{methodIndex}]";
                    VoidPtr addr       = null;
                    if (t != null && t._moduleID == (_objectSection.Root as ModuleNode).ID)
                    {
                        addr = _objectSection.Root.Children[t._sectionID].WorkingUncompressed.Address + t._index * 4;
                    }

                    new RELMethodNode
                    {
                        _name = methodName,
                        _cmd  = cmd
                    }
                    .Initialize(obj.Children[1], addr, 0);

                    methodIndex++;
                }
                else
                {
                    if (Manager.GetUint(rel + 1) != 0)
                    {
                        setIndex++;
                    }

                    methodIndex = 0;
                    rel++;
                }

                rel++;
            }

            Manager.AddTag(baseRel, obj.Type.FullName);

            _objects.Add(obj);
            return(obj);
        }
        private unsafe RELObjectNode ParseObject(ref Relocation rel)
        {
            if (rel.Command == null || rel.Command._targetRelocation._section != _objectSection)
                return null;

            RELType declaration = null;

            if (!_types.TryGetValue(rel.Command.TargetRelocation, out declaration) || declaration.Inherited)
                return null;

            RELObjectNode obj = null;
            foreach (RELObjectNode node in _objects)
                if (node._name == declaration.FullName)
                {
                    obj = node;
                    break;
                }

            if (obj == null)
            {
                obj = new RELObjectNode(declaration);
                obj._parent = _objectSection;
                _objectSection._children.Add(obj);
                new RELGroupNode() { _name = "Inheritance" }.Parent = obj;
                foreach (InheritanceItemNode n in declaration.Inheritance)
                    n.Parent = obj.Children[0];
                new RELGroupNode() { _name = "Functions" }.Parent = obj;
            }

            Relocation baseRel = rel;

            int methodIndex = 0;
            int setIndex = 0;

            // Read object methods.
            while (rel.Command != null && (rel.Command._targetRelocation._section != _objectSection || rel.SectionOffset == baseRel.SectionOffset))
            {
                if (rel.SectionOffset != baseRel.SectionOffset)
                {
                    new RELMethodNode() { _name = String.Format("Function[{0}][{1}]", setIndex, methodIndex) }.Initialize(obj.Children[1], rel.Target.Address, 0);
                    methodIndex++;
                }
                else
                {
                    if (rel.Next.RawValue != 0)
                        setIndex++;

                    methodIndex = 0;
                    rel = rel.Next;
                }
                rel = rel.Next;
            }

            baseRel.Tags.Add(obj.Type.FullName);

            _objects.Add(obj);
            return obj;
        }
Example #3
0
        private unsafe RELObjectNode ParseObject(ref Relocation rel)
        {
            if (rel.Command == null || rel.Command._targetRelocation._section != _objectSection)
            {
                return(null);
            }

            RELType declaration = null;

            if (!_types.TryGetValue(rel.Command.TargetRelocation, out declaration) || declaration.Inherited)
            {
                return(null);
            }

            RELObjectNode obj = null;

            foreach (RELObjectNode node in _objects)
            {
                if (node._name == declaration.FullName)
                {
                    obj = node;
                    break;
                }
            }

            if (obj == null)
            {
                obj         = new RELObjectNode(declaration);
                obj._parent = _objectSection;
                _objectSection._children.Add(obj);
                new RELGroupNode()
                {
                    _name = "Inheritance"
                }.Parent = obj;
                foreach (InheritanceItemNode n in declaration.Inheritance)
                {
                    n.Parent = obj.Children[0];
                }
                new RELGroupNode()
                {
                    _name = "Functions"
                }.Parent = obj;
            }

            Relocation baseRel = rel;

            int methodIndex = 0;
            int setIndex    = 0;

            // Read object methods.
            while (rel.Command != null && (rel.Command._targetRelocation._section != _objectSection || rel.SectionOffset == baseRel.SectionOffset))
            {
                if (rel.SectionOffset != baseRel.SectionOffset)
                {
                    new RELMethodNode()
                    {
                        _name = String.Format("Function[{0}][{1}]", setIndex, methodIndex)
                    }.Initialize(obj.Children[1], rel.Target.Address, 0);
                    methodIndex++;
                }
                else
                {
                    if (rel.Next.RawValue != 0)
                    {
                        setIndex++;
                    }

                    methodIndex = 0;
                    rel         = rel.Next;
                }
                rel = rel.Next;
            }

            baseRel.Tags.Add(obj.Type.FullName);

            _objects.Add(obj);
            return(obj);
        }