コード例 #1
0
        private unsafe RELType ParseDeclaration(Relocation rel)
        {
            RELType type = null;

            if (_types.TryGetValue(rel, out type))
            {
                return(type);
            }

            if (rel.Command == null || rel.Command._targetRelocation._section != _objectSection)
            {
                return(null);
            }

            string name = new string((sbyte *)(rel._section.BaseAddress + rel.RelOffset));

            if (String.IsNullOrEmpty(name))
            {
                return(null);
            }

            type = new RELType(name);

            //Get inheritances, if any.
            if (rel.Next.Command != null)
            {
                for (Relocation r = rel.Next.Command._targetRelocation;
                     r != null && r.Command != null;
                     r = r.NextAt(2))
                {
                    RELType inheritance = ParseDeclaration(r.Command._targetRelocation);
                    if (inheritance != null)
                    {
                        type.Inheritance.Add(new InheritanceItemNode(inheritance, r.Next.RawValue));
                        inheritance.Inherited = true;
                    }
                    else
                    {
                        break;
                    }
                }
            }

            rel.Tags.Add(type.FormalName + " Declaration");
            rel.Next.Tags.Add(type.FormalName + "->Inheritances");

            _types.Add(rel, type);

            return(type);
        }
コード例 #2
0
        private unsafe RELType ParseDeclaration(Relocation rel)
        {
            RELType type = null;
            if (_types.TryGetValue(rel, out type))
                return type;

            if (rel.Command == null || rel.Command._targetRelocation._section != _objectSection)
                return null;

            string name = new string((sbyte*)(rel._section.BaseAddress + rel.RelOffset));

            if (String.IsNullOrEmpty(name))
                return null;

            type = new RELType(name);

            //Get inheritances, if any.
            if (rel.Next.Command != null)
                for (Relocation r = rel.Next.Command._targetRelocation;
                     r != null && r.Command != null;
                     r = r.NextAt(2))
                {
                    RELType inheritance = ParseDeclaration(r.Command._targetRelocation);
                    if (inheritance != null)
                    {
                        type.Inheritance.Add(new InheritanceItemNode(inheritance, r.Next.RawValue));
                        inheritance.Inherited = true;
                    }
                    else break;
                }

            rel.Tags.Add(type.FormalName + " Declaration");
            rel.Next.Tags.Add(type.FormalName + "->Inheritances");

            _types.Add(rel, type);

            return type;
        }
コード例 #3
0
 public RELObjectNode(RELType type)
 {
     _type = type;
     _name = _type.FullName;
 }
コード例 #4
0
 public InheritanceItemNode(RELType type, uint unknown)
 {
     _type    = type;
     _name    = _type.FullName;
     _unknown = unknown;
 }
コード例 #5
0
        private unsafe RELType ParseDeclaration(int index)
        {
            if (_types.TryGetValue(index, out RELType type))
            {
                return(type);
            }

            RelCommand cmd = Manager.GetCommand(index);

            RelocationTarget target = cmd?.GetTargetRelocation();

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

            uint relOffset = cmd.Apply(Manager.GetUint(index), 0);

            if (relOffset > _objectSection._dataOffset + _objectSection._dataSize)
            {
                return(null);
            }

            string name = new string((sbyte *)(_objectSection.Header + relOffset));

            if (string.IsNullOrWhiteSpace(name))
            {
                return(null);
            }

            type = new RELType(name);

            //Get inheritances, if any.
            cmd = Manager.GetCommand(index + 1);
            if (cmd != null)
            {
                for (RelocationTarget r = cmd.GetTargetRelocation();
                     r != null && (cmd = Manager.GetCommand(r._index)) != null;
                     r._index += 2)
                {
                    RelocationTarget inheritTarget = cmd.GetTargetRelocation();
                    RELType          inheritance   = ParseDeclaration(inheritTarget._index);
                    if (inheritance != null)
                    {
                        InheritanceItemNode typeNode =
                            new InheritanceItemNode(inheritance, Manager.GetUint(r._index + 1));
                        typeNode.Initialize(null, _objectSection.Header + r._index * 4, 0);
                        type.Inheritance.Add(typeNode);
                        inheritance.Inherited = true;
                    }
                    else
                    {
                        break;
                    }
                }
            }

            Manager.AddTag(index, type.FormalName + " Declaration");
            Manager.AddTag(index + 1, type.FormalName + "->Inheritances");

            _types.Add(index, type);

            return(type);
        }
コード例 #6
0
 public RELObjectNode(RELType type)
 {
     _type = type;
     _name = _type.FullName;
 }
コード例 #7
0
        private unsafe RELObjectNode ParseObject(ref int rel)
        {
            RelCommand cmd = Manager.GetCommand(rel);

            if (cmd == null)
            {
                return(null);
            }

            RelocationTarget target = cmd.GetTargetRelocation();

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

            RELType declaration = null;

            if (!_types.TryGetValue(target._index, 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;
            }

            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 = String.Format("Function[{0}][{1}]", 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);
        }
コード例 #8
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);
        }
コード例 #9
0
 public InheritanceItemNode(RELType type, uint unknown)
 {
     _type = type;
     _name = _type.FullName;
     _unknown = unknown;
 }