예제 #1
0
        private static BiosInformation ProcessBiosSystemInformation(BinaryReader br, BiosInformation biosInformation)
        {
            byte b        = br.ReadByte();
            long position = br.BaseStream.Position + b - 2;

            br.BaseStream.Position += 5L;
            byte b2 = br.ReadByte();

            biosInformation.UUID   = new Guid(br.ReadBytes(16));
            br.BaseStream.Position = position;
            IList <string> sringsFromStringsSection = GetSringsFromStringsSection(br);

            if (b2 == 0)
            {
                biosInformation.SerialNumber = "Not Provided in System Information Section";
            }
            else if (b2 > sringsFromStringsSection.Count)
            {
                biosInformation.Error = BiosFirmwareTableParserError.SerialNumberOrdinalIndexOutOfBound;
            }
            else
            {
                biosInformation.SerialNumber = sringsFromStringsSection[b2 - 1];
            }
            return(biosInformation);
        }
예제 #2
0
        /// <summary>
        /// Parses the supplied BIOS Firmware Table stream
        /// </summary>
        /// <param name="biosFirmwareTable"></param>
        /// <returns>a BiosInformation object</returns>
        internal static BiosInformation ParseBiosFirmwareTable(Stream biosFirmwareTable)
        {
            BiosInformation biosInformation = default(BiosInformation);

            biosInformation.Error        = BiosFirmwareTableParserError.Success;
            biosInformation.SerialNumber = "NotAvailable";
            BiosInformation biosInformation2 = biosInformation;

            biosInformation2.TableSize = biosFirmwareTable.Length;
            if (biosFirmwareTable.Length < 8)
            {
                biosInformation2.Error = BiosFirmwareTableParserError.TableTooSmall;
                return(biosInformation2);
            }
            using (BinaryReader binaryReader = new BinaryReader(biosFirmwareTable))
            {
                binaryReader.ReadByte();
                biosInformation2.SpecVersion = new Version($"{binaryReader.ReadByte()}.{binaryReader.ReadByte()}");
                if (!(biosInformation2.SpecVersion < MinimumSupportedBiosVersion))
                {
                    binaryReader.ReadByte();
                    binaryReader.ReadInt32();
                    int key;
                    if ((key = GoToNextSectionToParse(binaryReader)) > 0)
                    {
                        if (binaryReader.BaseStream.Position >= binaryReader.BaseStream.Length - 1)
                        {
                            biosInformation2.Error = BiosFirmwareTableParserError.RequiredSectionNotFound;
                        }
                        else
                        {
                            biosInformation2 = SectionProcessorLookup[key](binaryReader, biosInformation2);
                        }
                    }
                    biosInformation = biosInformation2;
                    return(biosInformation);
                }
                biosInformation2.Error = BiosFirmwareTableParserError.SpecVersionUnsupported;
                biosInformation        = biosInformation2;
                return(biosInformation);
            }
        }