Example #1
0
        internal TargetAddress ReadDynamicInfo(Inferior inferior)
        {
            Section section = GetSectionByName(".dynamic", false);

            if (section == null)
            {
                return(TargetAddress.Null);
            }

            TargetAddress vma = new TargetAddress(info.AddressDomain, section.vma);

            int size = (int)section.size;

            byte[] dynamic = inferior.ReadBuffer(vma, size);

            IntPtr data = IntPtr.Zero;

            try {
                data = Marshal.AllocHGlobal(size);
                Marshal.Copy(dynamic, 0, data, size);
                long base_ptr = bfd_glue_elfi386_locate_base(bfd, data, size);
                if (base_ptr == 0)
                {
                    return(TargetAddress.Null);
                }
                else
                {
                    return(new TargetAddress(info.AddressDomain, base_ptr));
                }
            } finally {
                if (data != IntPtr.Zero)
                {
                    Marshal.FreeHGlobal(data);
                }
            }
        }