예제 #1
0
 public HiiIfrOpCodeRef(IfrRawDataBlock raw) : base(raw)
 {
     if (_Header.Header.Length == typeof(EFI_IFR_REF).StructLayoutAttribute.Size)
     {
         _HeaderEx         = raw.ToIfrType <EFI_IFR_REF>();
         this.data_payload = null; // payload is part of header, now
     }
     else if (_Header.Header.Length == typeof(EFI_IFR_REF2).StructLayoutAttribute.Size)
     {
         _HeaderEx         = raw.ToIfrType <EFI_IFR_REF2>();
         this.data_payload = null; // payload is part of header, now
     }
     else if (_Header.Header.Length == typeof(EFI_IFR_REF3).StructLayoutAttribute.Size)
     {
         _HeaderEx         = raw.ToIfrType <EFI_IFR_REF3>();
         this.data_payload = null; // payload is part of header, now
     }
     else if (_Header.Header.Length == typeof(EFI_IFR_REF4).StructLayoutAttribute.Size)
     {
         _HeaderEx         = raw.ToIfrType <EFI_IFR_REF4>();
         this.data_payload = null; // payload is part of header, now
     }
     else if (_Header.Header.Length == typeof(EFI_IFR_REF5).StructLayoutAttribute.Size)
     {
         _HeaderEx         = raw.ToIfrType <EFI_IFR_REF5>();
         this.data_payload = null; // payload is part of header, now
     }
     else
     {
         LogMessage(LogSeverity.ERROR, Name + ": Unknown data size of EFI_IFR_REF");
     }
 }
예제 #2
0
 public HiiIfrOpCodeAction(IfrRawDataBlock raw) : base(raw)
 {
     if (_Header.Header.Length == typeof(EFI_IFR_ACTION).StructLayoutAttribute.Size)
     {
         _HeaderEx         = raw.ToIfrType <EFI_IFR_ACTION>();
         this.data_payload = null; // payload is part of header, now
     }
     else if (_Header.Header.Length == typeof(EFI_IFR_ACTION_1).StructLayoutAttribute.Size)
     {
         _HeaderEx         = raw.ToIfrType <EFI_IFR_ACTION_1>();
         this.data_payload = null; // payload is part of header, now
     }
     else
     {
         LogMessage(LogSeverity.ERROR, Name + ": Unknown data size of EFI_IFR_QUESTION_REF3");
     }
 }
예제 #3
0
        public HiiPackageString(IfrRawDataBlock raw) : base(raw)
        {
            data_payload = new IfrRawDataBlock(data);
            data_payload.IncreaseOffset(_Header.GetPhysSize());

            _Payload.Language = data_payload.CopyOfAsciiNullTerminatedString;

            // Parse all string information block types..
            uint offset = (uint)_Payload.Language.Length + 1;

            while (offset < data_payload.Length)
            {
                IfrRawDataBlock      raw_data  = new IfrRawDataBlock(data_payload.Bytes, data_payload.Offset + offset, data_payload.Length - offset);
                EFI_HII_STRING_BLOCK block_hdr = raw_data.ToIfrType <EFI_HII_STRING_BLOCK>();
                HPKElement           hpk_element;

                switch (block_hdr.BlockType)
                {
                case EFI_HII_SIBT_e.EFI_HII_SIBT_END: hpk_element = new HiiSibtBlockNoPayload <EFI_HII_STRING_BLOCK>(raw_data); break;

                /*case EFI_HII_SIBT_e.EFI_HII_SIBT_STRING_SCSU:
                 * case EFI_HII_SIBT_e.EFI_HII_SIBT_STRING_SCSU_FONT:
                 * case EFI_HII_SIBT_e.EFI_HII_SIBT_STRINGS_SCSU:
                 * case EFI_HII_SIBT_e.EFI_HII_SIBT_STRINGS_SCSU_FONT:*/
                case EFI_HII_SIBT_e.EFI_HII_SIBT_STRING_UCS2: hpk_element = new HiiSibtBlockStringUcs2(raw_data); break;

                /*case EFI_HII_SIBT_e.EFI_HII_SIBT_STRING_UCS2_FONT:
                 * case EFI_HII_SIBT_e.EFI_HII_SIBT_STRINGS_UCS2:
                 * case EFI_HII_SIBT_e.EFI_HII_SIBT_STRINGS_UCS2_FONT:
                 * case EFI_HII_SIBT_e.EFI_HII_SIBT_DUPLICATE:*/
                case EFI_HII_SIBT_e.EFI_HII_SIBT_SKIP2: hpk_element = new HiiSibtBlockNoPayload <EFI_HII_SIBT_SKIP2_BLOCK>(raw_data); break;

                case EFI_HII_SIBT_e.EFI_HII_SIBT_SKIP1: hpk_element = new HiiSibtBlockNoPayload <EFI_HII_SIBT_SKIP1_BLOCK>(raw_data); break;

                case EFI_HII_SIBT_e.EFI_HII_SIBT_EXT1: hpk_element = new HiiSibtBlockExt <EFI_HII_SIBT_EXT1_BLOCK>(raw_data); break;

                case EFI_HII_SIBT_e.EFI_HII_SIBT_EXT2: hpk_element = new HiiSibtBlockExt <EFI_HII_SIBT_EXT2_BLOCK>(raw_data); break;

                case EFI_HII_SIBT_e.EFI_HII_SIBT_EXT4: hpk_element = new HiiSibtBlockExt <EFI_HII_SIBT_EXT4_BLOCK>(raw_data); break;

                /*case EFI_HII_SIBT_e.EFI_HII_SIBT_FONT:*/
                default:
                    //raw_data.GenerateAndLogDump(ifr_hdr.OpCode.ToString());
                    LogMessage(LogSeverity.UNIMPLEMENTED, block_hdr.BlockType.ToString());
                    LogMessage(LogSeverity.ERROR, "Parsing aborted due to unimplemented type!");
                    return;
                }
                Childs.Add(hpk_element);

                offset += hpk_element.PhysicalSize;
            }
        }
예제 #4
0
        public HPKfile(string filename) : base(null)
        {
            this.Filename = filename;

            // Load file into memory
            StreamReader stream = new StreamReader(Filename);
            BinaryReader file   = new BinaryReader(stream.BaseStream);

            data         = new IfrRawDataBlock(file.ReadBytes((int)file.BaseStream.Length));
            data_payload = new IfrRawDataBlock(data);
            stream.Close();

            // Parse all HII packages..
            uint offset = 0;

            while (offset < data_payload.Length)
            {
                EFI_HII_PACKAGE_HEADER hdr = data_payload.ToIfrType <EFI_HII_PACKAGE_HEADER>(offset);
                if (data_payload.Length < hdr.Length + offset)
                {
                    throw new Exception("Payload length invalid");
                }

                IfrRawDataBlock raw_data = new IfrRawDataBlock(data_payload.Bytes, data_payload.Offset + offset, hdr.Length);
                HPKElement      hpk_element;

                switch (hdr.Type)
                {
                case EFI_HII_PACKAGE_e.EFI_HII_PACKAGE_FORMS: hpk_element = new HiiPackageForm(raw_data); break;

                case EFI_HII_PACKAGE_e.EFI_HII_PACKAGE_STRINGS: hpk_element = new HiiPackageString(raw_data); break;

                default:
                    //raw_data.GenerateAndLogDump(hdr.Type.ToString());
                    LogMessage(LogSeverity.UNIMPLEMENTED, hdr.Type.ToString());
                    hpk_element = new HiiPackage <EFI_HII_PACKAGE_HEADER>(raw_data);
                    break;
                }
                Childs.Add(hpk_element);

                offset += hdr.Length;
            }
        }