Beispiel #1
0
        public static PESectionHeader Parse(BinaryReader reader)
        {
            PESectionHeader 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);
        }
Beispiel #2
0
        public static List <string> GetDependencies(string path)
        {
            List <string>          result = new List <string>();
            PortableExecutableInfo peInfo = new PortableExecutableInfo(path);

            ImportDirectory dir = peInfo.ImportDirectory;

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