Beispiel #1
0
        // ReSharper restore MemberCanBePrivate.Global

        public static PESectionHeader Parse(BinaryReader reader)
        {
            var header = new PESectionHeader();

            header.Name                 = BinaryReaderUtils.ReadFixedLengthAsciiString(reader, 8);
            header.VirtualSize          = reader.ReadUInt32();
            header.VirtualAdress        = reader.ReadUInt32();
            header.SizeOfRawData        = reader.ReadUInt32();
            header.PointerToRawData     = reader.ReadUInt32();
            header.PointerToRelocations = reader.ReadUInt32();
            header.PointerToLineNumbers = reader.ReadUInt32();
            header.NumberOfRelocations  = reader.ReadUInt16();
            header.NumberOfLineNumbers  = reader.ReadUInt16();
            header.Flags                = (SectionFlags)reader.ReadUInt32();
            return(header);
        }
        public static List <string> GetDependencies(string path)
        {
            var result = new List <string>();
            var peInfo = new PortableExecutableInfo(path);

            var dir = peInfo.ImportDirectory;

            if (dir != null)
            {
                var reader = GetBinaryReader(path);
                foreach (var desc in dir.Descriptors)
                {
                    var fileNameOffset = peInfo.GetOffsetFromRVA(desc.NameRVA);
                    reader.BaseStream.Seek(fileNameOffset, SeekOrigin.Begin);
                    var fileName = BinaryReaderUtils.ReadNullTerminatedAsciiString(reader);
                    result.Add(fileName);
                }
                reader.Close();
            }
            return(result);
        }