├── .gitignore
├── About.Designer.cs
├── About.cs
├── About.resx
├── HTMLBuilder.cs
├── HiiPackage.cs
├── HpkFile.cs
├── HpkParser.cs
├── IfrStructures.cs
├── IfrViewer.csproj
├── IfrViewer.csproj.user
├── IfrViewer.sln
├── Images
├── OutlineIcon.ico
├── icons8-outline-96.png
└── icons8-outline-96_mod-icon.png
├── LICENSE
├── MainForm.Designer.cs
├── MainForm.cs
├── MainForm.resx
├── ParseLogical.cs
├── PrepareRelease.bat
├── Properties
├── AssemblyInfo.cs
├── Resources.Designer.cs
├── Resources.resx
├── Settings.Designer.cs
└── Settings.settings
├── README.md
├── THIRDPARTYLICENSEREADME
└── test_files
├── BootManagerUiLib.uni
├── BootManagerUiLibStrDefs.hpk
├── BootManagerVfr.Vfr
├── BootManagerVfr.hpk
├── BootManagerVfr.i
├── BootManagerVfr.lst
├── edk2
├── Guid
│ └── HiiFormMapMethodGuid.h
└── Uefi
│ └── UefiInternalFormRepresentation.h
└── vfrcomp.bat
/.gitignore:
--------------------------------------------------------------------------------
1 | /.vs
2 | /bin
3 | /obj
4 | /*.sdf
5 | /FinalFiles
6 |
--------------------------------------------------------------------------------
/About.Designer.cs:
--------------------------------------------------------------------------------
1 | namespace IfrViewer
2 | {
3 | partial class About
4 | {
5 | ///
6 | /// Erforderliche Designervariable.
7 | ///
8 | private System.ComponentModel.IContainer components = null;
9 |
10 | ///
11 | /// Verwendete Ressourcen bereinigen.
12 | ///
13 | protected override void Dispose(bool disposing)
14 | {
15 | if (disposing && (components != null))
16 | {
17 | components.Dispose();
18 | }
19 | base.Dispose(disposing);
20 | }
21 |
22 | #region Vom Windows Form-Designer generierter Code
23 |
24 | ///
25 | /// Erforderliche Methode für die Designerunterstützung.
26 | /// Der Inhalt der Methode darf nicht mit dem Code-Editor geändert werden.
27 | ///
28 | private void InitializeComponent()
29 | {
30 | System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(About));
31 | this.tableLayoutPanel = new System.Windows.Forms.TableLayoutPanel();
32 | this.logoPictureBox = new System.Windows.Forms.PictureBox();
33 | this.labelProductName = new System.Windows.Forms.Label();
34 | this.labelVersion = new System.Windows.Forms.Label();
35 | this.labelCopyright = new System.Windows.Forms.Label();
36 | this.labelCompanyName = new System.Windows.Forms.Label();
37 | this.textBoxDescription = new System.Windows.Forms.TextBox();
38 | this.okButton = new System.Windows.Forms.Button();
39 | this.tableLayoutPanel.SuspendLayout();
40 | ((System.ComponentModel.ISupportInitialize)(this.logoPictureBox)).BeginInit();
41 | this.SuspendLayout();
42 | //
43 | // tableLayoutPanel
44 | //
45 | this.tableLayoutPanel.ColumnCount = 2;
46 | this.tableLayoutPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 200F));
47 | this.tableLayoutPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F));
48 | this.tableLayoutPanel.Controls.Add(this.logoPictureBox, 0, 0);
49 | this.tableLayoutPanel.Controls.Add(this.labelProductName, 1, 0);
50 | this.tableLayoutPanel.Controls.Add(this.labelVersion, 1, 1);
51 | this.tableLayoutPanel.Controls.Add(this.labelCopyright, 1, 2);
52 | this.tableLayoutPanel.Controls.Add(this.labelCompanyName, 1, 3);
53 | this.tableLayoutPanel.Controls.Add(this.textBoxDescription, 1, 4);
54 | this.tableLayoutPanel.Controls.Add(this.okButton, 1, 5);
55 | this.tableLayoutPanel.Dock = System.Windows.Forms.DockStyle.Fill;
56 | this.tableLayoutPanel.Location = new System.Drawing.Point(9, 9);
57 | this.tableLayoutPanel.Name = "tableLayoutPanel";
58 | this.tableLayoutPanel.RowCount = 6;
59 | this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 30F));
60 | this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 30F));
61 | this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 30F));
62 | this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 30F));
63 | this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F));
64 | this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 50F));
65 | this.tableLayoutPanel.Size = new System.Drawing.Size(780, 443);
66 | this.tableLayoutPanel.TabIndex = 0;
67 | //
68 | // logoPictureBox
69 | //
70 | this.logoPictureBox.BackColor = System.Drawing.Color.White;
71 | this.logoPictureBox.Dock = System.Windows.Forms.DockStyle.Fill;
72 | this.logoPictureBox.Location = new System.Drawing.Point(3, 3);
73 | this.logoPictureBox.Name = "logoPictureBox";
74 | this.tableLayoutPanel.SetRowSpan(this.logoPictureBox, 6);
75 | this.logoPictureBox.Size = new System.Drawing.Size(194, 437);
76 | this.logoPictureBox.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
77 | this.logoPictureBox.TabIndex = 12;
78 | this.logoPictureBox.TabStop = false;
79 | //
80 | // labelProductName
81 | //
82 | this.labelProductName.Dock = System.Windows.Forms.DockStyle.Fill;
83 | this.labelProductName.Location = new System.Drawing.Point(206, 0);
84 | this.labelProductName.Margin = new System.Windows.Forms.Padding(6, 0, 3, 0);
85 | this.labelProductName.MaximumSize = new System.Drawing.Size(0, 17);
86 | this.labelProductName.Name = "labelProductName";
87 | this.labelProductName.Size = new System.Drawing.Size(571, 17);
88 | this.labelProductName.TabIndex = 19;
89 | this.labelProductName.Text = "Product";
90 | this.labelProductName.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
91 | //
92 | // labelVersion
93 | //
94 | this.labelVersion.Dock = System.Windows.Forms.DockStyle.Fill;
95 | this.labelVersion.Location = new System.Drawing.Point(206, 30);
96 | this.labelVersion.Margin = new System.Windows.Forms.Padding(6, 0, 3, 0);
97 | this.labelVersion.MaximumSize = new System.Drawing.Size(0, 17);
98 | this.labelVersion.Name = "labelVersion";
99 | this.labelVersion.Size = new System.Drawing.Size(571, 17);
100 | this.labelVersion.TabIndex = 0;
101 | this.labelVersion.Text = "Version";
102 | this.labelVersion.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
103 | //
104 | // labelCopyright
105 | //
106 | this.labelCopyright.Dock = System.Windows.Forms.DockStyle.Fill;
107 | this.labelCopyright.Location = new System.Drawing.Point(206, 60);
108 | this.labelCopyright.Margin = new System.Windows.Forms.Padding(6, 0, 3, 0);
109 | this.labelCopyright.MaximumSize = new System.Drawing.Size(0, 17);
110 | this.labelCopyright.Name = "labelCopyright";
111 | this.labelCopyright.Size = new System.Drawing.Size(571, 17);
112 | this.labelCopyright.TabIndex = 21;
113 | this.labelCopyright.Text = "Copyright";
114 | this.labelCopyright.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
115 | //
116 | // labelCompanyName
117 | //
118 | this.labelCompanyName.Dock = System.Windows.Forms.DockStyle.Fill;
119 | this.labelCompanyName.Location = new System.Drawing.Point(206, 90);
120 | this.labelCompanyName.Margin = new System.Windows.Forms.Padding(6, 0, 3, 0);
121 | this.labelCompanyName.MaximumSize = new System.Drawing.Size(0, 17);
122 | this.labelCompanyName.Name = "labelCompanyName";
123 | this.labelCompanyName.Size = new System.Drawing.Size(571, 17);
124 | this.labelCompanyName.TabIndex = 22;
125 | this.labelCompanyName.Text = "Company";
126 | this.labelCompanyName.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
127 | //
128 | // textBoxDescription
129 | //
130 | this.textBoxDescription.Dock = System.Windows.Forms.DockStyle.Fill;
131 | this.textBoxDescription.Location = new System.Drawing.Point(206, 123);
132 | this.textBoxDescription.Margin = new System.Windows.Forms.Padding(6, 3, 3, 3);
133 | this.textBoxDescription.Multiline = true;
134 | this.textBoxDescription.Name = "textBoxDescription";
135 | this.textBoxDescription.ReadOnly = true;
136 | this.textBoxDescription.ScrollBars = System.Windows.Forms.ScrollBars.Both;
137 | this.textBoxDescription.Size = new System.Drawing.Size(571, 267);
138 | this.textBoxDescription.TabIndex = 23;
139 | this.textBoxDescription.TabStop = false;
140 | this.textBoxDescription.Text = resources.GetString("textBoxDescription.Text");
141 | //
142 | // okButton
143 | //
144 | this.okButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
145 | this.okButton.DialogResult = System.Windows.Forms.DialogResult.Cancel;
146 | this.okButton.Location = new System.Drawing.Point(702, 417);
147 | this.okButton.Name = "okButton";
148 | this.okButton.Size = new System.Drawing.Size(75, 23);
149 | this.okButton.TabIndex = 24;
150 | this.okButton.Text = "&OK";
151 | //
152 | // About
153 | //
154 | this.AcceptButton = this.okButton;
155 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
156 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
157 | this.ClientSize = new System.Drawing.Size(798, 461);
158 | this.Controls.Add(this.tableLayoutPanel);
159 | this.MaximizeBox = false;
160 | this.MinimizeBox = false;
161 | this.MinimumSize = new System.Drawing.Size(500, 500);
162 | this.Name = "About";
163 | this.Padding = new System.Windows.Forms.Padding(9);
164 | this.ShowIcon = false;
165 | this.ShowInTaskbar = false;
166 | this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
167 | this.Text = "About";
168 | this.tableLayoutPanel.ResumeLayout(false);
169 | this.tableLayoutPanel.PerformLayout();
170 | ((System.ComponentModel.ISupportInitialize)(this.logoPictureBox)).EndInit();
171 | this.ResumeLayout(false);
172 |
173 | }
174 |
175 | #endregion
176 |
177 | private System.Windows.Forms.TableLayoutPanel tableLayoutPanel;
178 | private System.Windows.Forms.PictureBox logoPictureBox;
179 | private System.Windows.Forms.Label labelProductName;
180 | private System.Windows.Forms.Label labelVersion;
181 | private System.Windows.Forms.Label labelCopyright;
182 | private System.Windows.Forms.Label labelCompanyName;
183 | private System.Windows.Forms.TextBox textBoxDescription;
184 | private System.Windows.Forms.Button okButton;
185 | }
186 | }
187 |
--------------------------------------------------------------------------------
/About.cs:
--------------------------------------------------------------------------------
1 | //MIT License
2 | //
3 | //Copyright(c) 2017-2017 Peter Kirmeier
4 | //
5 | //Permission Is hereby granted, free Of charge, to any person obtaining a copy
6 | //of this software And associated documentation files (the "Software"), to deal
7 | //in the Software without restriction, including without limitation the rights
8 | //to use, copy, modify, merge, publish, distribute, sublicense, And/Or sell
9 | //copies of the Software, And to permit persons to whom the Software Is
10 | //furnished to do so, subject to the following conditions:
11 | //
12 | //The above copyright notice And this permission notice shall be included In all
13 | //copies Or substantial portions of the Software.
14 | //
15 | //THE SOFTWARE Is PROVIDED "AS IS", WITHOUT WARRANTY Of ANY KIND, EXPRESS Or
16 | //IMPLIED, INCLUDING BUT Not LIMITED To THE WARRANTIES Of MERCHANTABILITY,
17 | //FITNESS FOR A PARTICULAR PURPOSE And NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | //AUTHORS Or COPYRIGHT HOLDERS BE LIABLE For ANY CLAIM, DAMAGES Or OTHER
19 | //LIABILITY, WHETHER In AN ACTION Of CONTRACT, TORT Or OTHERWISE, ARISING FROM,
20 | //OUT OF Or IN CONNECTION WITH THE SOFTWARE Or THE USE Or OTHER DEALINGS IN THE
21 | //SOFTWARE.
22 |
23 | using System;
24 | using System.Reflection;
25 | using System.Windows.Forms;
26 |
27 | namespace IfrViewer
28 | {
29 | partial class About : Form
30 | {
31 | public About()
32 | {
33 | InitializeComponent();
34 | Text = String.Format("About {0}", AssemblyTitle);
35 | labelProductName.Text = AssemblyProduct;
36 | labelVersion.Text = String.Format("Version {0}", AssemblyVersion);
37 | labelCopyright.Text = AssemblyCopyright;
38 | labelCompanyName.Text = AssemblyCompany;
39 | textBoxDescription.Text = AssemblyDescription + Environment.NewLine + Environment.NewLine + this.textBoxDescription.Text;
40 | }
41 |
42 | #region Assemblyattributaccessoren
43 |
44 | public string AssemblyTitle
45 | {
46 | get
47 | {
48 | object[] attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyTitleAttribute), false);
49 | if (attributes.Length > 0)
50 | {
51 | AssemblyTitleAttribute titleAttribute = (AssemblyTitleAttribute)attributes[0];
52 | if (titleAttribute.Title != "")
53 | {
54 | return titleAttribute.Title;
55 | }
56 | }
57 | return System.IO.Path.GetFileNameWithoutExtension(Assembly.GetExecutingAssembly().CodeBase);
58 | }
59 | }
60 |
61 | public string AssemblyVersion
62 | {
63 | get
64 | {
65 | return Assembly.GetExecutingAssembly().GetName().Version.ToString();
66 | }
67 | }
68 |
69 | public string AssemblyDescription
70 | {
71 | get
72 | {
73 | object[] attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyDescriptionAttribute), false);
74 | if (attributes.Length == 0)
75 | {
76 | return "";
77 | }
78 | return ((AssemblyDescriptionAttribute)attributes[0]).Description;
79 | }
80 | }
81 |
82 | public string AssemblyProduct
83 | {
84 | get
85 | {
86 | object[] attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyProductAttribute), false);
87 | if (attributes.Length == 0)
88 | {
89 | return "";
90 | }
91 | return ((AssemblyProductAttribute)attributes[0]).Product;
92 | }
93 | }
94 |
95 | public string AssemblyCopyright
96 | {
97 | get
98 | {
99 | object[] attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyCopyrightAttribute), false);
100 | if (attributes.Length == 0)
101 | {
102 | return "";
103 | }
104 | return ((AssemblyCopyrightAttribute)attributes[0]).Copyright;
105 | }
106 | }
107 |
108 | public string AssemblyCompany
109 | {
110 | get
111 | {
112 | object[] attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyCompanyAttribute), false);
113 | if (attributes.Length == 0)
114 | {
115 | return "";
116 | }
117 | return ((AssemblyCompanyAttribute)attributes[0]).Company;
118 | }
119 | }
120 | #endregion
121 | }
122 | }
123 |
--------------------------------------------------------------------------------
/About.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 | text/microsoft-resx
110 |
111 |
112 | 2.0
113 |
114 |
115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
119 |
120 |
121 | MIT License
122 |
123 | Copyright (c) 2017-2019 Peter Kirmeier
124 |
125 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
126 |
127 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
128 |
129 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
130 | ==============================================================================
131 | Application
132 |
133 | Title: IfrViewer
134 | Author: Peter Kirmeier <topeterk@freenet.de>
135 | Source: https://github.com/topeterk/IfrViewer
136 | Licence: MIT https://opensource.org/licenses/MIT
137 |
138 | ==============================================================================
139 | Application Icon
140 |
141 | Title: -
142 | Author: icons8.com
143 | Source: https://icons8.com/
144 | Licence: CC BY-ND 3.0 https://creativecommons.org/licenses/by-nd/3.0/
145 |
146 |
--------------------------------------------------------------------------------
/HpkFile.cs:
--------------------------------------------------------------------------------
1 | //MIT License
2 | //
3 | //Copyright(c) 2016-2017 Peter Kirmeier
4 | //
5 | //Permission Is hereby granted, free Of charge, to any person obtaining a copy
6 | //of this software And associated documentation files (the "Software"), to deal
7 | //in the Software without restriction, including without limitation the rights
8 | //to use, copy, modify, merge, publish, distribute, sublicense, And/Or sell
9 | //copies of the Software, And to permit persons to whom the Software Is
10 | //furnished to do so, subject to the following conditions:
11 | //
12 | //The above copyright notice And this permission notice shall be included In all
13 | //copies Or substantial portions of the Software.
14 | //
15 | //THE SOFTWARE Is PROVIDED "AS IS", WITHOUT WARRANTY Of ANY KIND, EXPRESS Or
16 | //IMPLIED, INCLUDING BUT Not LIMITED To THE WARRANTIES Of MERCHANTABILITY,
17 | //FITNESS FOR A PARTICULAR PURPOSE And NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | //AUTHORS Or COPYRIGHT HOLDERS BE LIABLE For ANY CLAIM, DAMAGES Or OTHER
19 | //LIABILITY, WHETHER In AN ACTION Of CONTRACT, TORT Or OTHERWISE, ARISING FROM,
20 | //OUT OF Or IN CONNECTION WITH THE SOFTWARE Or THE USE Or OTHER DEALINGS IN THE
21 | //SOFTWARE.
22 |
23 | using System;
24 | using System.Collections;
25 | using System.Collections.Generic;
26 | using System.IO;
27 | using static IFR.IFRHelper;
28 |
29 | namespace IFR
30 | {
31 | ///
32 | /// Used as a core element that enables iterating through the HPK file tree
33 | /// and providing some generic information about the object.
34 | ///
35 | public class HPKElement
36 | {
37 | #region UniqueID
38 | ///
39 | /// Holds last unique ID of HPKElement instances
40 | ///
41 | private static int GlobalLastUniqueID = 0;
42 | ///
43 | /// Unique ID of instance
44 | ///
45 | public readonly int UniqueID;
46 | #endregion
47 |
48 | #region Raw Data Blocks
49 | ///
50 | /// Raw data representation of this object
51 | ///
52 | protected IfrRawDataBlock data;
53 | ///
54 | /// Raw data representation of this object's payload
55 | ///
56 | protected IfrRawDataBlock data_payload;
57 | ///
58 | /// Physical size of header and payload
59 | ///
60 | public uint PhysicalSize { get { return data.Length; } }
61 | #endregion
62 |
63 | #region Header specific
64 | ///
65 | /// Managed structure payload (raw)
66 | ///
67 | public byte[] HeaderRaw
68 | {
69 | get
70 | {
71 | byte[] result;
72 | // There is no payload? Then everything is header..
73 | if (data_payload == null)
74 | result = data.CopyOfSelectedBytes;
75 | else
76 | {
77 | // Otherwise, the header is from data start till payload begin..
78 | IfrRawDataBlock hdr_data = new IfrRawDataBlock(data);
79 | hdr_data.Length = data_payload.Offset - data.Offset;
80 | result = hdr_data.CopyOfSelectedBytes;
81 | }
82 | return result.Length > 0 ? result : null;
83 | }
84 | }
85 |
86 | ///
87 | /// Managed structure header
88 | ///
89 | public virtual object Header { get { return null; } }
90 |
91 | ///
92 | /// Gets name/value pairs of all managed header's data
93 | ///
94 | /// list of name/value pairs
95 | public List> GetPrintableHeader(uint BytesPerLine = 16)
96 | {
97 | List> result = new List>();
98 |
99 | if (Header != null) GetPrintableStructureElements(result, Header, BytesPerLine);
100 |
101 | return result;
102 | }
103 | #endregion
104 |
105 | #region Payload specfic
106 | ///
107 | /// Managed structure payload (raw)
108 | ///
109 | public byte[] PayloadRaw { get { return (data_payload == null ? null : (data_payload.Length == 0 ? null : data_payload.CopyOfSelectedBytes)); } }
110 |
111 | ///
112 | /// Managed structure payload
113 | ///
114 | public virtual object Payload { get { return null; } }
115 |
116 | ///
117 | /// Gets name/value pairs of all managed payloads's data
118 | ///
119 | /// list of name/value pairs
120 | public List> GetPrintablePayload(uint BytesPerLine = 16)
121 | {
122 | List> result = new List>();
123 |
124 | if (Payload != null) GetPrintableStructureElements(result, Payload, BytesPerLine);
125 |
126 | return result;
127 | }
128 | #endregion
129 |
130 | #region Private helper methods
131 | private void GetPrintableStructureElements(List> list, object obj, uint BytesPerLine)
132 | {
133 | Type type = obj.GetType();
134 | bool IsList = obj is IEnumerable;
135 |
136 | foreach (System.Reflection.PropertyInfo pi in type.GetProperties())
137 | {
138 | if (pi.CanRead)
139 | {
140 | if (IsList)
141 | {
142 | if (type.FullName == "System.Byte[]")
143 | {
144 | list.Add(new KeyValuePair("Raw Bytes", (obj as System.Byte[]).HexDump(BytesPerLine)));
145 | }
146 | else if (type.FullName == "System.String")
147 | {
148 | string value = obj as System.String;
149 | list.Add(new KeyValuePair("String", "\"" + value + "\""));
150 | }
151 | else
152 | {
153 | foreach (var obj_elem in obj as IEnumerable)
154 | GetPrintableStructureElements(list, obj_elem, BytesPerLine);
155 | }
156 | break; // skip list internal data (means: all other properties of this type)
157 | }
158 | else if ((pi.PropertyType.IsEnum) || (pi.PropertyType.FullName.StartsWith("System.")))
159 | list.Add(new KeyValuePair(pi.Name, pi.GetValue(obj)));
160 | else
161 | GetPrintableStructureElements(list, pi.GetValue(obj), BytesPerLine);
162 | }
163 | }
164 | foreach (System.Reflection.MemberInfo mi in type.GetMembers())
165 | {
166 | if (mi is System.Reflection.FieldInfo)
167 | {
168 | System.Reflection.FieldInfo fi = (System.Reflection.FieldInfo)mi;
169 | if (fi.IsPublic)
170 | {
171 | if (fi.FieldType.FullName == "System.Char[]")
172 | {
173 | string value = new string(fi.GetValue(obj) as System.Char[]).Replace("\0", "");
174 | list.Add(new KeyValuePair(fi.Name, "\"" + value + "\""));
175 | }
176 | else if (fi.FieldType.FullName == "System.String")
177 | {
178 | if (fi.Name != "Empty") // filter Empty member of basic string class
179 | {
180 | string value = fi.GetValue(obj) as System.String;
181 | list.Add(new KeyValuePair(fi.Name, "\"" + value + "\""));
182 | }
183 | }
184 | else if ((fi.FieldType.IsEnum) || (fi.FieldType.FullName.StartsWith("System.")))
185 | list.Add(new KeyValuePair(fi.Name, fi.GetValue(obj)));
186 | else
187 | GetPrintableStructureElements(list, fi.GetValue(obj), BytesPerLine);
188 | }
189 | }
190 | }
191 | }
192 | #endregion
193 |
194 | #region Name, Childs, Debug and Constructor
195 | ///
196 | /// Friendly name of this object
197 | ///
198 | public virtual string Name { get { return this.ToString(); } }
199 | ///
200 | /// List of all childs
201 | ///
202 | public readonly List Childs;
203 |
204 | public HPKElement(IfrRawDataBlock raw)
205 | {
206 | UniqueID = GlobalLastUniqueID++;
207 | data = raw;
208 | Childs = new List();
209 | }
210 | ///
211 | /// Generates a logged message
212 | ///
213 | /// Severity of message
214 | /// Message string
215 | protected void LogMessage(LogSeverity severity, string msg)
216 | {
217 | CreateLogEntry(severity, this.ToString() + " [" + this.UniqueID + "]", msg);
218 | }
219 | #endregion
220 | }
221 |
222 | ///
223 | /// Represents a whole file including multiple packages
224 | ///
225 | public class HPKfile : HPKElement
226 | {
227 | ///
228 | /// Filename of the parsed file
229 | ///
230 | public readonly string Filename;
231 | ///
232 | /// Friendly name of this object
233 | ///
234 | public override string Name { get { return Filename; } }
235 |
236 | public HPKfile(string filename) : base(null)
237 | {
238 | this.Filename = filename;
239 |
240 | // Load file into memory
241 | StreamReader stream = new StreamReader(Filename);
242 | BinaryReader file = new BinaryReader(stream.BaseStream);
243 | data = new IfrRawDataBlock(file.ReadBytes((int)file.BaseStream.Length));
244 | data_payload = new IfrRawDataBlock(data);
245 | stream.Close();
246 |
247 | // Parse all HII packages..
248 | uint offset = 0;
249 | while (offset < data_payload.Length)
250 | {
251 | EFI_HII_PACKAGE_HEADER hdr = data_payload.ToIfrType(offset);
252 | if (data_payload.Length < hdr.Length + offset)
253 | throw new Exception("Payload length invalid");
254 |
255 | IfrRawDataBlock raw_data = new IfrRawDataBlock(data_payload.Bytes, data_payload.Offset + offset, hdr.Length);
256 | HPKElement hpk_element;
257 |
258 | switch (hdr.Type)
259 | {
260 | case EFI_HII_PACKAGE_e.EFI_HII_PACKAGE_FORMS: hpk_element = new HiiPackageForm(raw_data); break;
261 | case EFI_HII_PACKAGE_e.EFI_HII_PACKAGE_STRINGS: hpk_element = new HiiPackageString(raw_data); break;
262 | default:
263 | //raw_data.GenerateAndLogDump(hdr.Type.ToString());
264 | LogMessage(LogSeverity.UNIMPLEMENTED, hdr.Type.ToString());
265 | hpk_element = new HiiPackage(raw_data);
266 | break;
267 | }
268 | Childs.Add(hpk_element);
269 |
270 | offset += hdr.Length;
271 | }
272 | }
273 | }
274 | }
275 |
--------------------------------------------------------------------------------
/HpkParser.cs:
--------------------------------------------------------------------------------
1 | //MIT License
2 | //
3 | //Copyright(c) 2017-2017 Peter Kirmeier
4 | //
5 | //Permission Is hereby granted, free Of charge, to any person obtaining a copy
6 | //of this software And associated documentation files (the "Software"), to deal
7 | //in the Software without restriction, including without limitation the rights
8 | //to use, copy, modify, merge, publish, distribute, sublicense, And/Or sell
9 | //copies of the Software, And to permit persons to whom the Software Is
10 | //furnished to do so, subject to the following conditions:
11 | //
12 | //The above copyright notice And this permission notice shall be included In all
13 | //copies Or substantial portions of the Software.
14 | //
15 | //THE SOFTWARE Is PROVIDED "AS IS", WITHOUT WARRANTY Of ANY KIND, EXPRESS Or
16 | //IMPLIED, INCLUDING BUT Not LIMITED To THE WARRANTIES Of MERCHANTABILITY,
17 | //FITNESS FOR A PARTICULAR PURPOSE And NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | //AUTHORS Or COPYRIGHT HOLDERS BE LIABLE For ANY CLAIM, DAMAGES Or OTHER
19 | //LIABILITY, WHETHER In AN ACTION Of CONTRACT, TORT Or OTHERWISE, ARISING FROM,
20 | //OUT OF Or IN CONNECTION WITH THE SOFTWARE Or THE USE Or OTHER DEALINGS IN THE
21 | //SOFTWARE.
22 |
23 | using IFR;
24 | using System;
25 | using System.Collections.Generic;
26 | using static IFR.IFRHelper;
27 | using static IfrViewer.HpkParser;
28 |
29 | namespace IfrViewer
30 | {
31 | public static class HpkParser
32 | {
33 | ///
34 | /// Creates a log entry for the "Parser" module
35 | ///
36 | /// Severity of message
37 | /// Message string
38 | /// Shows message box when true
39 | public static void CreateLogEntryParser(LogSeverity severity, string msg, bool bShowMsgBox = false)
40 | {
41 | CreateLogEntry(severity, "Parser", msg, bShowMsgBox);
42 | }
43 |
44 | ///
45 | /// Performs ToString() on the object with a fixed amount of characters
46 | ///
47 | /// Obj to be converted
48 | /// Amount of characters of resulting string
49 | /// String with fixed size
50 | public static string ToDecimalString(this object Obj, int TotalWith = 0)
51 | {
52 | return Obj.ToString().PadLeft(TotalWith);
53 | }
54 | }
55 |
56 | ///
57 | /// Parsed HPK tree
58 | ///
59 | public struct ParsedHpkNode
60 | {
61 | public readonly HPKElement Origin;
62 | public string Name;
63 | public List Childs;
64 |
65 | public ParsedHpkNode(HPKElement Origin, string Name)
66 | {
67 | this.Origin = Origin;
68 | this.Name = Name;
69 | Childs = new List();
70 | }
71 | };
72 |
73 | ///
74 | /// Parses HPK packages and gives access to the parsed strings
75 | ///
76 | public class ParsedHpkStringContainer
77 | {
78 | ///
79 | /// Language which is used for parsing
80 | ///
81 | private readonly string Language;
82 |
83 | ///
84 | /// Holds the StringID - String pairs for a language
85 | ///
86 | public struct StringDataBase
87 | {
88 | public string Language;
89 | public List> Strings;
90 | }
91 |
92 | ///
93 | /// Parsed HPK tree
94 | ///
95 | public readonly List HpkPackages;
96 | ///
97 | /// String database
98 | ///
99 | public readonly List StringDB;
100 |
101 | ///
102 | /// Parses a set of packages
103 | ///
104 | /// List of packages that will be parsed
105 | /// Language which is used for parsing
106 | public ParsedHpkStringContainer(List Packages, string Language)
107 | {
108 | this.Language = Language;
109 | StringDB = new List();
110 | HpkPackages = new List();
111 |
112 | // Parsing strings first..
113 | foreach (HiiPackageBase pkg in Packages)
114 | {
115 | if (pkg.PackageType == EFI_HII_PACKAGE_e.EFI_HII_PACKAGE_STRINGS)
116 | {
117 | try
118 | {
119 | ParsedHpkNode root = new ParsedHpkNode(pkg, pkg.Name);
120 | UInt16 StringID = 0; // First ID is 1 (will be increased later)
121 | StringDataBase db;
122 | db.Language = ((HiiPackageString.Payload_t)pkg.Payload).Language;
123 | db.Strings = new List>();
124 | StringDB.Add(db);
125 |
126 | root.Name = "Strings Package \"" + db.Language + "\"";
127 | HpkPackages.Add(root);
128 | foreach (HPKElement child in root.Origin.Childs)
129 | ParsePackageSibt(child, root, ref StringID, db);
130 | }
131 | catch (Exception ex)
132 | {
133 | Console.WriteLine(ex.ToString());
134 | CreateLogEntryParser(LogSeverity.ERROR, "Parsing failed!" + Environment.NewLine + ex.ToString());
135 | }
136 | }
137 | }
138 | }
139 |
140 | ///
141 | /// Parses String Information Blocks and add them to a parsed HPK tree
142 | ///
143 | /// HPK element holding the input data
144 | /// Tree node which new nodes will be added to
145 | /// Last used string ID (increased when string found)
146 | /// String database where new strings will be added to
147 | private void ParsePackageSibt(HPKElement hpkelem, ParsedHpkNode root, ref UInt16 StringID, StringDataBase db)
148 | {
149 | ParsedHpkNode branch = new ParsedHpkNode(hpkelem, hpkelem.Name);
150 | HiiSibtBlockBase elem = (HiiSibtBlockBase)hpkelem;
151 |
152 | switch (elem.BlockType)
153 | {
154 | case EFI_HII_SIBT_e.EFI_HII_SIBT_STRING_UCS2:
155 | string StringText = ((HiiSibtBlockStringUcs2.Payload_t)elem.Payload).StringText;
156 | StringID++;
157 | branch.Name = StringID.ToDecimalString(5) + " " + StringText;
158 | db.Strings.Add(new KeyValuePair(StringID, StringText));
159 | break;
160 | case EFI_HII_SIBT_e.EFI_HII_SIBT_SKIP1: StringID += ((EFI_HII_SIBT_SKIP1_BLOCK)elem.Header).SkipCount; return; // Skip
161 | case EFI_HII_SIBT_e.EFI_HII_SIBT_SKIP2: StringID += ((EFI_HII_SIBT_SKIP2_BLOCK)elem.Header).SkipCount; return; // Skip
162 | case EFI_HII_SIBT_e.EFI_HII_SIBT_END: return; // Skip
163 | default:
164 | foreach (HiiSibtBlockBase child in elem.Childs)
165 | ParsePackageSibt(child, branch, ref StringID, db);
166 | break; // simply add all others 1:1 when no specific handler exists
167 | }
168 |
169 | root.Childs.Add(branch);
170 | }
171 |
172 | ///
173 | /// Returns a string from the database
174 | ///
175 | /// ID of the requested string
176 | /// ID of the requesting HPK element (for reference on errors)
177 | /// When true: In case StringID equals 0 then return "" instead of rising an error
178 | /// String from database
179 | public string GetString(UInt16 StringID, int UniqueID, bool bZeroIsEmpty = true)
180 | {
181 | if (StringID == 0 && bZeroIsEmpty)
182 | return "";
183 |
184 | foreach (string lang in new string[] { Language, "en-US" }) // try current first and english as fallback
185 | {
186 | foreach (StringDataBase db in StringDB)
187 | {
188 | if (db.Language != lang) continue;
189 |
190 | foreach (KeyValuePair entry in db.Strings)
191 | {
192 | if (entry.Key == StringID)
193 | {
194 | return entry.Value;
195 | }
196 | }
197 | }
198 | }
199 |
200 | //CreateLogEntryParser(LogSeverity.WARNING, "StringID " + StringID + " could not be translated [" + UniqueID + "]!"); // this may occur pretty often, so keep line inactive by default
201 | return "UNKNOWN_STRING_ID(" + StringID + ")";
202 | }
203 |
204 | ///
205 | /// Builds humand readable string of an IFR typed values including its type and value
206 | ///
207 | /// The IFR type of the value
208 | /// Input value
209 | /// ID of the requesting HPK element (for reference on errors)
210 | /// Humand readable string
211 | public string GetValueString(EFI_IFR_TYPE_e type, object Value, int UniqueID, ref object RawValue)
212 | {
213 | string TypeStr;
214 | string ValueStr;
215 | switch (type)
216 | {
217 | case EFI_IFR_TYPE_e.EFI_IFR_TYPE_NUM_SIZE_8: TypeStr = "UINT8"; RawValue = ((IfrTypeUINT8)Value).u8; ValueStr = RawValue.ToString(); break;
218 | case EFI_IFR_TYPE_e.EFI_IFR_TYPE_NUM_SIZE_16: TypeStr = "UINT16"; RawValue = ((IfrTypeUINT16)Value).u16; ValueStr = RawValue.ToString(); break;
219 | case EFI_IFR_TYPE_e.EFI_IFR_TYPE_NUM_SIZE_32: TypeStr = "UINT32"; RawValue = ((IfrTypeUINT32)Value).u32; ValueStr = RawValue.ToString(); break;
220 | case EFI_IFR_TYPE_e.EFI_IFR_TYPE_NUM_SIZE_64: TypeStr = "UINT64"; RawValue = ((IfrTypeUINT64)Value).u64; ValueStr = RawValue.ToString(); break;
221 | case EFI_IFR_TYPE_e.EFI_IFR_TYPE_BOOLEAN: TypeStr = "BOOLEAN"; RawValue = (((IfrTypeBOOLEAN)Value).b == 0 ? "FALSE" : "TRUE"); ValueStr = RawValue.ToString(); break;
222 | case EFI_IFR_TYPE_e.EFI_IFR_TYPE_TIME: TypeStr = "TIME"; RawValue = ((EFI_HII_TIME)Value).Hour.ToString("D2") + ":" + ((EFI_HII_TIME)Value).Minute.ToString("D2") + ":" + ((EFI_HII_TIME)Value).Second.ToString("D2"); ValueStr = RawValue.ToString(); break;
223 | case EFI_IFR_TYPE_e.EFI_IFR_TYPE_DATE: TypeStr = "DATE"; RawValue = ((EFI_HII_DATE)Value).Year.ToString("D4") + "-" + ((EFI_HII_DATE)Value).Month.ToString("D2") + "-" + ((EFI_HII_DATE)Value).Day.ToString("D2"); ValueStr = RawValue.ToString(); break;
224 | case EFI_IFR_TYPE_e.EFI_IFR_TYPE_STRING: TypeStr = "STRING"; RawValue = GetString(((IfrTypeEFI_STRING_ID)Value).stringid, UniqueID); ValueStr = ((IfrTypeEFI_STRING_ID)Value).stringid.ToDecimalString(5) + " [\"" + RawValue.ToString() + "\"]"; break;
225 | case EFI_IFR_TYPE_e.EFI_IFR_TYPE_OTHER: TypeStr = "OTHER"; RawValue = ValueStr = ""; ValueStr = RawValue.ToString(); break; // There is no value. It is nested and part of next IFR OpCode object
226 | case EFI_IFR_TYPE_e.EFI_IFR_TYPE_UNDEFINED: TypeStr = "UNDEFINED"; RawValue = "UNDEFINED"; ValueStr = RawValue.ToString(); CreateLogEntryParser(LogSeverity.WARNING, "Data type not speficied [" + UniqueID + "]!"); break;
227 | case EFI_IFR_TYPE_e.EFI_IFR_TYPE_ACTION: TypeStr = "ACTION"; RawValue = GetString(((IfrTypeEFI_STRING_ID)Value).stringid, UniqueID); ValueStr = ((IfrTypeEFI_STRING_ID)Value).stringid.ToDecimalString(5) + " [\"" + RawValue.ToString() + "\"]"; break;
228 | case EFI_IFR_TYPE_e.EFI_IFR_TYPE_BUFFER: TypeStr = "BUFFER"; RawValue = ""; ValueStr = RawValue.ToString(); break;
229 | case EFI_IFR_TYPE_e.EFI_IFR_TYPE_REF: TypeStr = "REF"; RawValue = ""; ValueStr = RawValue.ToString(); break;
230 | default: TypeStr = "?"; RawValue = "?"; ValueStr = "?"; CreateLogEntryParser(LogSeverity.WARNING, "Unknown data type of [" + UniqueID + "]!"); break;
231 | }
232 | return "Type = " + TypeStr + ", Value = " + ValueStr;
233 | }
234 |
235 | #region Parser - IFR Logic
236 |
237 | ///
238 | /// Translates IFR logic Opcodes into human readable string
239 | ///
240 | /// IFR element holding the input data
241 | /// Human readable string
242 | public string GetIfrLogicString(HiiIfrOpCode ifrelem)
243 | {
244 | IfrLogicStack Stack = new IfrLogicStack();
245 | string LogicString;
246 |
247 | ParseIfrLogicStack(ifrelem, Stack);
248 |
249 | if (Stack.Elements.Count != 1)
250 | {
251 | string StackElements = "";
252 | foreach (string element in Stack.Elements) StackElements += Environment.NewLine + " " + element;
253 | CreateLogEntryParser(LogSeverity.WARNING, "Logic stack has " + Stack.Elements.Count + " elements but must have 1 only [" + ifrelem.UniqueID + "]!" + StackElements);
254 |
255 | StackElements = "INVALIDSTACK(";
256 | foreach (string element in Stack.Elements) StackElements += element + ",";
257 | LogicString = StackElements + ")";
258 | }
259 | else LogicString = Stack.Elements[0];
260 |
261 | return LogicString;
262 | }
263 |
264 | ///
265 | /// Parses IFR logic Opcodes and returns the remaining IFR logic stack
266 | ///
267 | /// IFR element holding the input data
268 | /// Input: Current stack, Output: Remaining stack
269 | private void ParseIfrLogicStack(HiiIfrOpCode ifrelem, IfrLogicStack Stack)
270 | {
271 | switch (ifrelem.OpCode)
272 | {
273 | #region Logic OpCodes
274 | // Built-in functions:
275 | // EFI_IFR_DUP // Unclear what it does, therefore no implementation by now. If you know it, let me know ;)
276 | case EFI_IFR_OPCODE_e.EFI_IFR_EQ_ID_VAL_OP:
277 | {
278 | EFI_IFR_EQ_ID_VAL ifr_hdr = (EFI_IFR_EQ_ID_VAL)ifrelem.Header;
279 | Stack.Push("(ValueOfId(" + ifr_hdr.QuestionId.ToDecimalString(5) + ") == " + ifr_hdr.Value.ToString() + ")");
280 | }
281 | break;
282 | case EFI_IFR_OPCODE_e.EFI_IFR_EQ_ID_ID_OP:
283 | {
284 | EFI_IFR_EQ_ID_ID ifr_hdr = (EFI_IFR_EQ_ID_ID)ifrelem.Header;
285 | Stack.Push("(ValueOfId(" + ifr_hdr.QuestionId1.ToDecimalString(5) + ") == ValueOfId(" + ifr_hdr.QuestionId2.ToString("#####") + "))");
286 | }
287 | break;
288 | case EFI_IFR_OPCODE_e.EFI_IFR_EQ_ID_VAL_LIST_OP:
289 | {
290 | string ValueListStr = "";
291 | foreach (IfrTypeUINT16 value in (List)ifrelem.Payload) ValueListStr += value.u16.ToString() + ",";
292 | Stack.Push("(ValueOfId(" + ((EFI_IFR_EQ_ID_VAL_LIST)ifrelem.Header).QuestionId.ToDecimalString(5) + ") is in [" + ValueListStr + "])");
293 | }
294 | break;
295 | case EFI_IFR_OPCODE_e.EFI_IFR_GET_OP:
296 | {
297 | EFI_IFR_GET ifr_hdr = (EFI_IFR_GET)ifrelem.Header;
298 | Stack.Push("GetVarValue(Id = " + ifr_hdr.VarStoreId.ToDecimalString(5)
299 | + ", Offset/Name = " + ifr_hdr.VarStoreInfo.VarOffset.ToDecimalString(5)
300 | + ", Type = " + ifr_hdr.VarStoreType.ToString() + ")");
301 | }
302 | break;
303 | case EFI_IFR_OPCODE_e.EFI_IFR_QUESTION_REF1_OP: Stack.Push("ValueOfId(" + ((EFI_IFR_QUESTION_REF1)ifrelem.Header).QuestionId.ToDecimalString(5) + ")"); break;
304 | case EFI_IFR_OPCODE_e.EFI_IFR_QUESTION_REF3_OP:
305 | {
306 | switch (ifrelem.Header.GetType().Name)
307 | {
308 | case "EFI_IFR_QUESTION_REF3": Stack.Push("ValueOfId(" + Stack.Pop() + ")"); break;
309 | case "EFI_IFR_QUESTION_REF3_2":
310 | {
311 | EFI_IFR_QUESTION_REF3_2 ifr_hdr = (EFI_IFR_QUESTION_REF3_2)ifrelem.Header;
312 | Stack.Push("ValueOfId(" + Stack.Pop() + (ifr_hdr.DevicePath == 0 ? "" : ", DevicePath = \"" + GetString(ifr_hdr.DevicePath, ifrelem.UniqueID) + "\"") + ")");
313 | }
314 | break;
315 | case "EFI_IFR_QUESTION_REF3_3":
316 | {
317 | EFI_IFR_QUESTION_REF3_3 ifr_hdr = (EFI_IFR_QUESTION_REF3_3)ifrelem.Header;
318 | Stack.Push("ValueOfId(" + Stack.Pop() + ", Guid = " + ifr_hdr.Guid.Guid.ToString() + (ifr_hdr.DevicePath == 0 ? "" : ", DevicePath = \"" + GetString(ifr_hdr.DevicePath, ifrelem.UniqueID) + "\"") + ")");
319 | }
320 | break;
321 | default:
322 | Stack.Push("UNKNWONOPCODE(" + ifrelem.OpCode.ToString() + ")");
323 | CreateLogEntryParser(LogSeverity.UNIMPLEMENTED, "Logic reference type " + ifrelem.OpCode.ToString() + " [" + ifrelem.UniqueID + "]!");
324 | break;
325 | }
326 | }
327 | break;
328 | case EFI_IFR_OPCODE_e.EFI_IFR_RULE_REF_OP: Stack.Push(((EFI_IFR_RULE_REF)ifrelem.Header).RuleId.ToString()); break;
329 | case EFI_IFR_OPCODE_e.EFI_IFR_STRING_REF1_OP:
330 | {
331 | UInt16 StringID = ((EFI_IFR_STRING_REF1)ifrelem.Header).StringId;
332 | Stack.Push("GetString(Id = " + StringID.ToDecimalString(5) + " [\"" + GetString(StringID, ifrelem.UniqueID) + "\"])");
333 | }
334 | break;
335 | case EFI_IFR_OPCODE_e.EFI_IFR_THIS_OP: Stack.Push("THIS"); break;
336 | case EFI_IFR_OPCODE_e.EFI_IFR_SECURITY_OP: Stack.Push(((EFI_IFR_SECURITY)ifrelem.Header).Permissions.Guid.ToString()); break;
337 | // Constants
338 | case EFI_IFR_OPCODE_e.EFI_IFR_FALSE_OP: Stack.Push("FALSE"); break;
339 | case EFI_IFR_OPCODE_e.EFI_IFR_ONE_OP: Stack.Push("1"); break;
340 | case EFI_IFR_OPCODE_e.EFI_IFR_ONES_OP: Stack.Push("0xFFFFFFFFFFFFFFFF"); break;
341 | case EFI_IFR_OPCODE_e.EFI_IFR_TRUE_OP: Stack.Push("TRUE"); break;
342 | case EFI_IFR_OPCODE_e.EFI_IFR_UINT8_OP: Stack.Push("0x" + ((EFI_IFR_UINT8)ifrelem.Header).Value.ToString("X2")); break;
343 | case EFI_IFR_OPCODE_e.EFI_IFR_UINT16_OP: Stack.Push("0x" + ((EFI_IFR_UINT16)ifrelem.Header).Value.ToString("X4")); break;
344 | case EFI_IFR_OPCODE_e.EFI_IFR_UINT32_OP: Stack.Push("0x" + ((EFI_IFR_UINT32)ifrelem.Header).Value.ToString("X8")); break;
345 | case EFI_IFR_OPCODE_e.EFI_IFR_UINT64_OP: Stack.Push("0x" + ((EFI_IFR_UINT64)ifrelem.Header).Value.ToString("X16")); break;
346 | case EFI_IFR_OPCODE_e.EFI_IFR_UNDEFINED_OP: Stack.Push("Undefined"); break;
347 | case EFI_IFR_OPCODE_e.EFI_IFR_VERSION_OP: Stack.Push("GetUefiVersion()"); break;
348 | case EFI_IFR_OPCODE_e.EFI_IFR_ZERO_OP: Stack.Push("0"); break;
349 | // Binary operations
350 | case EFI_IFR_OPCODE_e.EFI_IFR_ADD_OP: Stack.Op21("+"); break;
351 | case EFI_IFR_OPCODE_e.EFI_IFR_AND_OP: Stack.Op12("&&"); break;
352 | case EFI_IFR_OPCODE_e.EFI_IFR_BITWISE_AND_OP: Stack.Op12("&"); break;
353 | case EFI_IFR_OPCODE_e.EFI_IFR_BITWISE_OR_OP: Stack.Op12("|"); break;
354 | case EFI_IFR_OPCODE_e.EFI_IFR_CATENATE_OP:
355 | {
356 | string str1 = Stack.Pop();
357 | string str2 = Stack.Pop();
358 | Stack.Push("Concat(" + str1 + " , " + str2 + ")");
359 | }
360 | break;
361 | case EFI_IFR_OPCODE_e.EFI_IFR_DIVIDE_OP: Stack.Op21("/"); break;
362 | case EFI_IFR_OPCODE_e.EFI_IFR_EQUAL_OP: Stack.Op12("=="); break;
363 | case EFI_IFR_OPCODE_e.EFI_IFR_GREATER_EQUAL_OP: Stack.Op12(">="); break;
364 | case EFI_IFR_OPCODE_e.EFI_IFR_GREATER_THAN_OP: Stack.Op12(">"); break;
365 | case EFI_IFR_OPCODE_e.EFI_IFR_LESS_EQUAL_OP: Stack.Op12("<="); break;
366 | case EFI_IFR_OPCODE_e.EFI_IFR_LESS_THAN_OP: Stack.Op12("<"); break;
367 | case EFI_IFR_OPCODE_e.EFI_IFR_MATCH_OP:
368 | {
369 | string str1 = Stack.Pop();
370 | string str2 = Stack.Pop();
371 | Stack.Push("Match(" + str1 + " /w pattern " + str2 + ")");
372 | }
373 | break;
374 | case EFI_IFR_OPCODE_e.EFI_IFR_MATCH2_OP:
375 | {
376 | string str1 = Stack.Pop();
377 | string str2 = Stack.Pop();
378 | Stack.Push("Match(" + str1 + " /w regex " + str2 + " syntax " + ((EFI_IFR_MATCH2)ifrelem.Header).SyntaxType.Guid.ToString() + ")");
379 | }
380 | break;
381 | case EFI_IFR_OPCODE_e.EFI_IFR_MODULO_OP: Stack.Op21("%"); break;
382 | case EFI_IFR_OPCODE_e.EFI_IFR_MULTIPLY_OP: Stack.Op21("*"); break;
383 | case EFI_IFR_OPCODE_e.EFI_IFR_NOT_EQUAL_OP: Stack.Op12("!="); break;
384 | case EFI_IFR_OPCODE_e.EFI_IFR_OR_OP: Stack.Op12("||"); break;
385 | case EFI_IFR_OPCODE_e.EFI_IFR_SHIFT_LEFT_OP: Stack.Op21("<<"); break;
386 | case EFI_IFR_OPCODE_e.EFI_IFR_SHIFT_RIGHT_OP: Stack.Op21("<<"); break;
387 | case EFI_IFR_OPCODE_e.EFI_IFR_SUBTRACT_OP: Stack.Op21("-"); break;
388 | // Unary operations
389 | case EFI_IFR_OPCODE_e.EFI_IFR_LENGTH_OP: Stack.Push("Length(" + Stack.Pop() + ")"); break;
390 | case EFI_IFR_OPCODE_e.EFI_IFR_NOT_OP: Stack.Push("!" + Stack.Pop()); break;
391 | case EFI_IFR_OPCODE_e.EFI_IFR_BITWISE_NOT_OP: Stack.Push("~" + Stack.Pop()); break;
392 | case EFI_IFR_OPCODE_e.EFI_IFR_QUESTION_REF2_OP: Stack.Push("ValueOfId(" + Stack.Pop() + ")"); break;
393 | case EFI_IFR_OPCODE_e.EFI_IFR_SET_OP:
394 | {
395 | EFI_IFR_SET ifr_hdr = (EFI_IFR_SET)ifrelem.Header;
396 | Stack.Push("SetVarValue(Id = " + ifr_hdr.VarStoreId.ToDecimalString(5)
397 | + ", Offset/Name = " + ifr_hdr.VarStoreInfo.VarOffset.ToDecimalString(5)
398 | + ", Type = " + ifr_hdr.VarStoreType.ToString()
399 | + ", Value = (" + Stack.Pop() + "))");
400 | }
401 | break;
402 | case EFI_IFR_OPCODE_e.EFI_IFR_STRING_REF2_OP:
403 | {
404 | UInt16 StringID;
405 | string expr = Stack.Pop();
406 | if (UInt16.TryParse(expr, out StringID))
407 | Stack.Push("GetString(Id = " + StringID.ToDecimalString(5) + " [\"" + GetString(StringID, ifrelem.UniqueID) + "\"])");
408 | else
409 | Stack.Push("GetString(Id = (" + expr + "))");
410 | }
411 | break;
412 | case EFI_IFR_OPCODE_e.EFI_IFR_TO_BOOLEAN_OP: Stack.Push("ToBoolen(" + Stack.Pop() + ")"); break;
413 | case EFI_IFR_OPCODE_e.EFI_IFR_TO_STRING_OP: Stack.Push("ToString((" + Stack.Pop() + ")), Format = 0x" + ((EFI_IFR_TO_STRING)ifrelem.Header).Format.ToString("X2") + ")"); break;
414 | case EFI_IFR_OPCODE_e.EFI_IFR_TO_UINT_OP: Stack.Push("ToUint(" + Stack.Pop() + ")"); break;
415 | case EFI_IFR_OPCODE_e.EFI_IFR_TO_UPPER_OP: Stack.Push("ToUpper(" + Stack.Pop() + ")"); break;
416 | case EFI_IFR_OPCODE_e.EFI_IFR_TO_LOWER_OP: Stack.Push("ToLower(" + Stack.Pop() + ")"); break;
417 | // -- ternary-op
418 | case EFI_IFR_OPCODE_e.EFI_IFR_CONDITIONAL_OP:
419 | {
420 | string expr1 = Stack.Pop();
421 | string expr2 = Stack.Pop();
422 | string expr3 = Stack.Pop();
423 | Stack.Push("(" + expr3 + " ? " + expr1 + " : " + expr2 + ")");
424 | }
425 | break;
426 | case EFI_IFR_OPCODE_e.EFI_IFR_FIND_OP:
427 | {
428 | string expr1 = Stack.Pop();
429 | string expr2 = Stack.Pop();
430 | string expr3 = Stack.Pop();
431 | Stack.Push("Find(" + expr3 + " in " + expr2 + ", Start = " + expr1 + ", Format = " + ((EFI_IFR_FIND)ifrelem.Header).Format.ToString() + ")");
432 | }
433 | break;
434 | case EFI_IFR_OPCODE_e.EFI_IFR_MID_OP:
435 | {
436 | string expr1 = Stack.Pop();
437 | string expr2 = Stack.Pop();
438 | string expr3 = Stack.Pop();
439 | Stack.Push("Mid(" + expr3 + ", Start = " + expr2 + ", Length = " + expr1 + ")");
440 | }
441 | break;
442 | case EFI_IFR_OPCODE_e.EFI_IFR_TOKEN_OP:
443 | {
444 | string expr1 = Stack.Pop();
445 | string expr2 = Stack.Pop();
446 | string expr3 = Stack.Pop();
447 | Stack.Push("Token(" + expr3 + ", Delimiters = " + expr2 + ", return #" + expr1 + ")");
448 | }
449 | break;
450 | case EFI_IFR_OPCODE_e.EFI_IFR_SPAN_OP:
451 | {
452 | string expr1 = Stack.Pop();
453 | string expr2 = Stack.Pop();
454 | string expr3 = Stack.Pop();
455 | Stack.Push("Span(" + expr3 + ", FromToCharPairs = " + expr2 + ", Start = " + expr1 + ", Flags = " + ((EFI_IFR_SPAN)ifrelem.Header).Flags.ToString() + ")");
456 | }
457 | break;
458 | case EFI_IFR_OPCODE_e.EFI_IFR_MAP_OP:
459 | {
460 | string expr = Stack.Pop();
461 | if ((ifrelem.Childs.Count % 2) != 0)
462 | {
463 | Stack.Push("INVALIDOPCODEPARAMETERS(" + ifrelem.OpCode.ToString() + ", Value = " + expr + ")");
464 | CreateLogEntryParser(LogSeverity.WARNING, "Map has invalid expression pairs [" + ifrelem.UniqueID + "]!");
465 | }
466 | else
467 | {
468 | string result = "Switch(" + expr;
469 | for (int i = 0; i < ifrelem.Childs.Count; i += 2) // for each expression pair
470 | {
471 | result += ", {" + GetIfrLogicString((HiiIfrOpCode)ifrelem.Childs[i]) // Match expression
472 | + ", " + GetIfrLogicString((HiiIfrOpCode)ifrelem.Childs[i + 1]) + "}"; // Result expression
473 | }
474 | result += ")";
475 | Stack.Push(result);
476 | }
477 | }
478 | break;
479 | #endregion
480 | case EFI_IFR_OPCODE_e.EFI_IFR_VALUE_OP: break; // Nothing to show, the value is nested..
481 | case EFI_IFR_OPCODE_e.EFI_IFR_END_OP: return;
482 | default:
483 | Stack.Push("UNKNWONOPCODE(" + ifrelem.OpCode.ToString() + ")");
484 | CreateLogEntryParser(LogSeverity.UNIMPLEMENTED, "Logic OpCode " + ifrelem.OpCode.ToString() + " [" + ifrelem.UniqueID + "]!");
485 | break;
486 | }
487 |
488 | if (ifrelem.HasOwnScope)
489 | {
490 | foreach (HiiIfrOpCode child in ifrelem.Childs)
491 | ParseIfrLogicStack(child, Stack);
492 | }
493 | }
494 |
495 | #endregion
496 | }
497 |
498 | ///
499 | /// Structure for IFR logic stack implementation
500 | ///
501 | public class IfrLogicStack
502 | {
503 | public List Elements;
504 |
505 | public IfrLogicStack()
506 | {
507 | Elements = new List();
508 | }
509 |
510 | ///
511 | /// Adds a value ontop of the stack
512 | ///
513 | /// Value to add
514 | public void Push(string ExpressionString)
515 | {
516 | Elements.Add(ExpressionString);
517 | }
518 |
519 | ///
520 | /// Retrieves top value on stack and removes it from stack
521 | ///
522 | /// Top stack value
523 | public string Pop()
524 | {
525 | if (Elements.Count == 0)
526 | {
527 | CreateLogEntryParser(LogSeverity.WARNING, "Logic stack empty!");
528 | return "EMPTYSTACK";
529 | }
530 | string LogicStr = Elements[Elements.Count - 1];
531 | Elements.RemoveAt(Elements.Count - 1);
532 | return LogicStr;
533 | }
534 |
535 | ///
536 | /// Performs an operation with 2 operands (first left, second right)
537 | ///
538 | /// Operation name/sign
539 | public void Op12(string Operation)
540 | {
541 | string expr1 = Pop();
542 | string expr2 = Pop();
543 | Push("(" + expr1 + " " + Operation + " " + expr2 + ")");
544 | }
545 |
546 | ///
547 | /// Performs an operation with 2 operands (first right, second left)
548 | ///
549 | /// Operation name/sign
550 | public void Op21(string Operation)
551 | {
552 | string expr1 = Pop();
553 | string expr2 = Pop();
554 | Push("(" + expr2 + " " + Operation + " " + expr1 + ")");
555 | }
556 | }
557 | }
558 |
--------------------------------------------------------------------------------
/IfrViewer.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {3EB0141D-BBAF-489C-812C-2411AE0C0183}
8 | WinExe
9 | Properties
10 | IfrViewer
11 | IfrViewer
12 | v4.5
13 | 512
14 | true
15 |
16 |
17 |
18 | AnyCPU
19 | true
20 | full
21 | false
22 | bin\Debug\
23 | DEBUG;TRACE
24 | prompt
25 | 4
26 |
27 |
28 | AnyCPU
29 | pdbonly
30 | true
31 | bin\Release\
32 | TRACE
33 | prompt
34 | 4
35 |
36 |
37 | IfrViewer.IfrViewer
38 |
39 |
40 | Images\OutlineIcon.ico
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 | Form
58 |
59 |
60 | About.cs
61 |
62 |
63 |
64 |
65 |
66 | Form
67 |
68 |
69 | MainForm.cs
70 |
71 |
72 |
73 |
74 |
75 |
76 | About.cs
77 |
78 |
79 | MainForm.cs
80 |
81 |
82 | ResXFileCodeGenerator
83 | Resources.Designer.cs
84 | Designer
85 |
86 |
87 | True
88 | Resources.resx
89 | True
90 |
91 |
92 | SettingsSingleFileGenerator
93 | Settings.Designer.cs
94 |
95 |
96 | True
97 | Settings.settings
98 | True
99 |
100 |
101 |
102 |
103 |
104 |
105 |
112 |
--------------------------------------------------------------------------------
/IfrViewer.csproj.user:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | -P -L=en-US ..\..\test_files\BootManagerUiLibStrDefs.hpk ..\..\test_files\BootManagerVfr.hpk -P -L=fr-FR ..\..\test_files\BootManagerUiLibStrDefs.hpk ..\..\test_files\BootManagerVfr.hpk
5 |
6 |
--------------------------------------------------------------------------------
/IfrViewer.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio 14
4 | VisualStudioVersion = 14.0.24720.0
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IfrViewer", "IfrViewer.csproj", "{3EB0141D-BBAF-489C-812C-2411AE0C0183}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|Any CPU = Debug|Any CPU
11 | Release|Any CPU = Release|Any CPU
12 | EndGlobalSection
13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
14 | {3EB0141D-BBAF-489C-812C-2411AE0C0183}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15 | {3EB0141D-BBAF-489C-812C-2411AE0C0183}.Debug|Any CPU.Build.0 = Debug|Any CPU
16 | {3EB0141D-BBAF-489C-812C-2411AE0C0183}.Release|Any CPU.ActiveCfg = Release|Any CPU
17 | {3EB0141D-BBAF-489C-812C-2411AE0C0183}.Release|Any CPU.Build.0 = Release|Any CPU
18 | EndGlobalSection
19 | GlobalSection(SolutionProperties) = preSolution
20 | HideSolutionNode = FALSE
21 | EndGlobalSection
22 | EndGlobal
23 |
--------------------------------------------------------------------------------
/Images/OutlineIcon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/topeterk/IfrViewer/3a2f39275161d2a03f99d6ca78f73e93cf91aa1f/Images/OutlineIcon.ico
--------------------------------------------------------------------------------
/Images/icons8-outline-96.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/topeterk/IfrViewer/3a2f39275161d2a03f99d6ca78f73e93cf91aa1f/Images/icons8-outline-96.png
--------------------------------------------------------------------------------
/Images/icons8-outline-96_mod-icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/topeterk/IfrViewer/3a2f39275161d2a03f99d6ca78f73e93cf91aa1f/Images/icons8-outline-96_mod-icon.png
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2016-2019 Peter Kirmeier
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
--------------------------------------------------------------------------------
/MainForm.Designer.cs:
--------------------------------------------------------------------------------
1 | //MIT License
2 | //
3 | //Copyright(c) 2016-2017 Peter Kirmeier
4 | //
5 | //Permission Is hereby granted, free Of charge, to any person obtaining a copy
6 | //of this software And associated documentation files (the "Software"), to deal
7 | //in the Software without restriction, including without limitation the rights
8 | //to use, copy, modify, merge, publish, distribute, sublicense, And/Or sell
9 | //copies of the Software, And to permit persons to whom the Software Is
10 | //furnished to do so, subject to the following conditions:
11 | //
12 | //The above copyright notice And this permission notice shall be included In all
13 | //copies Or substantial portions of the Software.
14 | //
15 | //THE SOFTWARE Is PROVIDED "AS IS", WITHOUT WARRANTY Of ANY KIND, EXPRESS Or
16 | //IMPLIED, INCLUDING BUT Not LIMITED To THE WARRANTIES Of MERCHANTABILITY,
17 | //FITNESS FOR A PARTICULAR PURPOSE And NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | //AUTHORS Or COPYRIGHT HOLDERS BE LIABLE For ANY CLAIM, DAMAGES Or OTHER
19 | //LIABILITY, WHETHER In AN ACTION Of CONTRACT, TORT Or OTHERWISE, ARISING FROM,
20 | //OUT OF Or IN CONNECTION WITH THE SOFTWARE Or THE USE Or OTHER DEALINGS IN THE
21 | //SOFTWARE.
22 |
23 | namespace IfrViewer
24 | {
25 | partial class MainForm
26 | {
27 | ///
28 | /// Erforderliche Designervariable.
29 | ///
30 | private System.ComponentModel.IContainer components = null;
31 |
32 | ///
33 | /// Verwendete Ressourcen bereinigen.
34 | ///
35 | /// True, wenn verwaltete Ressourcen gelöscht werden sollen; andernfalls False.
36 | protected override void Dispose(bool disposing)
37 | {
38 | if (disposing && (components != null))
39 | {
40 | components.Dispose();
41 | }
42 | base.Dispose(disposing);
43 | }
44 |
45 | #region Vom Windows Form-Designer generierter Code
46 |
47 | ///
48 | /// Erforderliche Methode für die Designerunterstützung.
49 | /// Der Inhalt der Methode darf nicht mit dem Code-Editor geändert werden.
50 | ///
51 | private void InitializeComponent()
52 | {
53 | System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle();
54 | System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MainForm));
55 | this.tv_tree = new System.Windows.Forms.TreeView();
56 | this.splitContainer1 = new System.Windows.Forms.SplitContainer();
57 | this.tabControl1 = new System.Windows.Forms.TabControl();
58 | this.tabrawtree = new System.Windows.Forms.TabPage();
59 | this.tablogicaltree = new System.Windows.Forms.TabPage();
60 | this.tv_logical = new System.Windows.Forms.TreeView();
61 | this.splitContainer2 = new System.Windows.Forms.SplitContainer();
62 | this.tv_details = new System.Windows.Forms.TreeView();
63 | this.log = new System.Windows.Forms.DataGridView();
64 | this.Type = new System.Windows.Forms.DataGridViewTextBoxColumn();
65 | this.Origin = new System.Windows.Forms.DataGridViewTextBoxColumn();
66 | this.Message = new System.Windows.Forms.DataGridViewTextBoxColumn();
67 | this.menuStrip1 = new System.Windows.Forms.MenuStrip();
68 | this.fileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
69 | this.exitToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
70 | this.optionsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
71 | this.showRawInDetailsWindowToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
72 | this.toolStripSeparator3 = new System.Windows.Forms.ToolStripSeparator();
73 | this.printCompactHtmlToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
74 | this.printDetailsIntoHtmlToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
75 | this.toolStripSeparator2 = new System.Windows.Forms.ToolStripSeparator();
76 | this.ts_parse_lang = new System.Windows.Forms.ToolStripTextBox();
77 | this.helpToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
78 | this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator();
79 | this.parseLogicalViewToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
80 | this.createHTMLToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
81 | ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit();
82 | this.splitContainer1.Panel1.SuspendLayout();
83 | this.splitContainer1.Panel2.SuspendLayout();
84 | this.splitContainer1.SuspendLayout();
85 | this.tabControl1.SuspendLayout();
86 | this.tabrawtree.SuspendLayout();
87 | this.tablogicaltree.SuspendLayout();
88 | ((System.ComponentModel.ISupportInitialize)(this.splitContainer2)).BeginInit();
89 | this.splitContainer2.Panel1.SuspendLayout();
90 | this.splitContainer2.Panel2.SuspendLayout();
91 | this.splitContainer2.SuspendLayout();
92 | ((System.ComponentModel.ISupportInitialize)(this.log)).BeginInit();
93 | this.menuStrip1.SuspendLayout();
94 | this.SuspendLayout();
95 | //
96 | // tv_tree
97 | //
98 | this.tv_tree.AllowDrop = true;
99 | this.tv_tree.Font = new System.Drawing.Font("Courier New", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
100 | this.tv_tree.FullRowSelect = true;
101 | this.tv_tree.Location = new System.Drawing.Point(0, 0);
102 | this.tv_tree.Name = "tv_tree";
103 | this.tv_tree.Size = new System.Drawing.Size(743, 240);
104 | this.tv_tree.TabIndex = 0;
105 | this.tv_tree.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(this.tv_tree_AfterSelect);
106 | this.tv_tree.DragDrop += new System.Windows.Forms.DragEventHandler(this.MainForm_DragDrop);
107 | this.tv_tree.DragEnter += new System.Windows.Forms.DragEventHandler(this.MainForm_DragEnter);
108 | this.tv_tree.DragOver += new System.Windows.Forms.DragEventHandler(this.tv_tree_DragOver);
109 | this.tv_tree.KeyDown += new System.Windows.Forms.KeyEventHandler(this.tv_KeyDown);
110 | //
111 | // splitContainer1
112 | //
113 | this.splitContainer1.Location = new System.Drawing.Point(12, 27);
114 | this.splitContainer1.Name = "splitContainer1";
115 | this.splitContainer1.Orientation = System.Windows.Forms.Orientation.Horizontal;
116 | //
117 | // splitContainer1.Panel1
118 | //
119 | this.splitContainer1.Panel1.Controls.Add(this.tabControl1);
120 | //
121 | // splitContainer1.Panel2
122 | //
123 | this.splitContainer1.Panel2.Controls.Add(this.splitContainer2);
124 | this.splitContainer1.Size = new System.Drawing.Size(760, 449);
125 | this.splitContainer1.SplitterDistance = 272;
126 | this.splitContainer1.SplitterIncrement = 14;
127 | this.splitContainer1.SplitterWidth = 8;
128 | this.splitContainer1.TabIndex = 2;
129 | this.splitContainer1.SplitterMoved += new System.Windows.Forms.SplitterEventHandler(this.splitContainer1_SplitterMoved);
130 | //
131 | // tabControl1
132 | //
133 | this.tabControl1.Controls.Add(this.tabrawtree);
134 | this.tabControl1.Controls.Add(this.tablogicaltree);
135 | this.tabControl1.Location = new System.Drawing.Point(6, 3);
136 | this.tabControl1.Name = "tabControl1";
137 | this.tabControl1.SelectedIndex = 0;
138 | this.tabControl1.Size = new System.Drawing.Size(751, 266);
139 | this.tabControl1.TabIndex = 1;
140 | this.tabControl1.SizeChanged += new System.EventHandler(this.tabControl1_SizeChanged);
141 | //
142 | // tabrawtree
143 | //
144 | this.tabrawtree.Controls.Add(this.tv_tree);
145 | this.tabrawtree.Location = new System.Drawing.Point(4, 22);
146 | this.tabrawtree.Name = "tabrawtree";
147 | this.tabrawtree.Padding = new System.Windows.Forms.Padding(3);
148 | this.tabrawtree.Size = new System.Drawing.Size(743, 240);
149 | this.tabrawtree.TabIndex = 0;
150 | this.tabrawtree.Text = "Raw Tree";
151 | this.tabrawtree.UseVisualStyleBackColor = true;
152 | //
153 | // tablogicaltree
154 | //
155 | this.tablogicaltree.Controls.Add(this.tv_logical);
156 | this.tablogicaltree.Location = new System.Drawing.Point(4, 22);
157 | this.tablogicaltree.Name = "tablogicaltree";
158 | this.tablogicaltree.Padding = new System.Windows.Forms.Padding(3);
159 | this.tablogicaltree.Size = new System.Drawing.Size(743, 240);
160 | this.tablogicaltree.TabIndex = 1;
161 | this.tablogicaltree.Text = "Logical Tree";
162 | this.tablogicaltree.UseVisualStyleBackColor = true;
163 | //
164 | // tv_logical
165 | //
166 | this.tv_logical.Font = new System.Drawing.Font("Courier New", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
167 | this.tv_logical.FullRowSelect = true;
168 | this.tv_logical.Location = new System.Drawing.Point(0, 0);
169 | this.tv_logical.Name = "tv_logical";
170 | this.tv_logical.Size = new System.Drawing.Size(743, 240);
171 | this.tv_logical.TabIndex = 1;
172 | this.tv_logical.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(this.tv_tree_AfterSelect);
173 | this.tv_logical.KeyDown += new System.Windows.Forms.KeyEventHandler(this.tv_KeyDown);
174 | //
175 | // splitContainer2
176 | //
177 | this.splitContainer2.Location = new System.Drawing.Point(3, 3);
178 | this.splitContainer2.Name = "splitContainer2";
179 | //
180 | // splitContainer2.Panel1
181 | //
182 | this.splitContainer2.Panel1.Controls.Add(this.tv_details);
183 | //
184 | // splitContainer2.Panel2
185 | //
186 | this.splitContainer2.Panel2.Controls.Add(this.log);
187 | this.splitContainer2.Size = new System.Drawing.Size(754, 168);
188 | this.splitContainer2.SplitterDistance = 323;
189 | this.splitContainer2.SplitterWidth = 8;
190 | this.splitContainer2.TabIndex = 1;
191 | this.splitContainer2.SplitterMoved += new System.Windows.Forms.SplitterEventHandler(this.splitContainer2_SplitterMoved);
192 | //
193 | // tv_details
194 | //
195 | this.tv_details.Font = new System.Drawing.Font("Courier New", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
196 | this.tv_details.FullRowSelect = true;
197 | this.tv_details.Location = new System.Drawing.Point(3, 3);
198 | this.tv_details.Name = "tv_details";
199 | this.tv_details.ShowLines = false;
200 | this.tv_details.ShowRootLines = false;
201 | this.tv_details.Size = new System.Drawing.Size(317, 162);
202 | this.tv_details.TabIndex = 1;
203 | this.tv_details.KeyDown += new System.Windows.Forms.KeyEventHandler(this.tv_KeyDown);
204 | //
205 | // log
206 | //
207 | this.log.AllowUserToAddRows = false;
208 | this.log.AllowUserToDeleteRows = false;
209 | this.log.AllowUserToResizeColumns = false;
210 | this.log.AllowUserToResizeRows = false;
211 | this.log.CellBorderStyle = System.Windows.Forms.DataGridViewCellBorderStyle.None;
212 | this.log.ClipboardCopyMode = System.Windows.Forms.DataGridViewClipboardCopyMode.EnableWithoutHeaderText;
213 | this.log.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
214 | this.log.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
215 | this.Type,
216 | this.Origin,
217 | this.Message});
218 | dataGridViewCellStyle1.Alignment = System.Windows.Forms.DataGridViewContentAlignment.TopLeft;
219 | dataGridViewCellStyle1.BackColor = System.Drawing.SystemColors.Window;
220 | dataGridViewCellStyle1.Font = new System.Drawing.Font("Courier New", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
221 | dataGridViewCellStyle1.ForeColor = System.Drawing.SystemColors.ControlText;
222 | dataGridViewCellStyle1.SelectionBackColor = System.Drawing.SystemColors.Highlight;
223 | dataGridViewCellStyle1.SelectionForeColor = System.Drawing.SystemColors.HighlightText;
224 | dataGridViewCellStyle1.WrapMode = System.Windows.Forms.DataGridViewTriState.True;
225 | this.log.DefaultCellStyle = dataGridViewCellStyle1;
226 | this.log.EnableHeadersVisualStyles = false;
227 | this.log.Location = new System.Drawing.Point(3, 3);
228 | this.log.Name = "log";
229 | this.log.ReadOnly = true;
230 | this.log.RowHeadersVisible = false;
231 | this.log.ShowEditingIcon = false;
232 | this.log.Size = new System.Drawing.Size(417, 162);
233 | this.log.TabIndex = 0;
234 | //
235 | // Type
236 | //
237 | this.Type.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.None;
238 | this.Type.HeaderText = "Type";
239 | this.Type.Name = "Type";
240 | this.Type.ReadOnly = true;
241 | this.Type.Width = 56;
242 | //
243 | // Origin
244 | //
245 | this.Origin.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.None;
246 | this.Origin.HeaderText = "Origin";
247 | this.Origin.Name = "Origin";
248 | this.Origin.ReadOnly = true;
249 | this.Origin.Width = 59;
250 | //
251 | // Message
252 | //
253 | this.Message.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.None;
254 | this.Message.HeaderText = "Message";
255 | this.Message.Name = "Message";
256 | this.Message.ReadOnly = true;
257 | this.Message.Width = 200;
258 | //
259 | // menuStrip1
260 | //
261 | this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
262 | this.fileToolStripMenuItem,
263 | this.optionsToolStripMenuItem,
264 | this.helpToolStripMenuItem,
265 | this.toolStripSeparator1,
266 | this.parseLogicalViewToolStripMenuItem,
267 | this.createHTMLToolStripMenuItem});
268 | this.menuStrip1.Location = new System.Drawing.Point(0, 0);
269 | this.menuStrip1.Name = "menuStrip1";
270 | this.menuStrip1.Size = new System.Drawing.Size(784, 27);
271 | this.menuStrip1.TabIndex = 3;
272 | this.menuStrip1.Text = "menuStrip1";
273 | //
274 | // fileToolStripMenuItem
275 | //
276 | this.fileToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
277 | this.exitToolStripMenuItem});
278 | this.fileToolStripMenuItem.Name = "fileToolStripMenuItem";
279 | this.fileToolStripMenuItem.Size = new System.Drawing.Size(37, 23);
280 | this.fileToolStripMenuItem.Text = "File";
281 | //
282 | // exitToolStripMenuItem
283 | //
284 | this.exitToolStripMenuItem.Name = "exitToolStripMenuItem";
285 | this.exitToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
286 | this.exitToolStripMenuItem.Text = "Exit";
287 | this.exitToolStripMenuItem.Click += new System.EventHandler(this.exitToolStripMenuItem_Click);
288 | //
289 | // optionsToolStripMenuItem
290 | //
291 | this.optionsToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
292 | this.showRawInDetailsWindowToolStripMenuItem,
293 | this.toolStripSeparator3,
294 | this.printCompactHtmlToolStripMenuItem,
295 | this.printDetailsIntoHtmlToolStripMenuItem,
296 | this.toolStripSeparator2,
297 | this.ts_parse_lang});
298 | this.optionsToolStripMenuItem.Name = "optionsToolStripMenuItem";
299 | this.optionsToolStripMenuItem.Size = new System.Drawing.Size(61, 23);
300 | this.optionsToolStripMenuItem.Text = "Options";
301 | //
302 | // showRawInDetailsWindowToolStripMenuItem
303 | //
304 | this.showRawInDetailsWindowToolStripMenuItem.Checked = true;
305 | this.showRawInDetailsWindowToolStripMenuItem.CheckOnClick = true;
306 | this.showRawInDetailsWindowToolStripMenuItem.CheckState = System.Windows.Forms.CheckState.Checked;
307 | this.showRawInDetailsWindowToolStripMenuItem.Name = "showRawInDetailsWindowToolStripMenuItem";
308 | this.showRawInDetailsWindowToolStripMenuItem.Size = new System.Drawing.Size(227, 22);
309 | this.showRawInDetailsWindowToolStripMenuItem.Text = "Raw data in details window";
310 | this.showRawInDetailsWindowToolStripMenuItem.ToolTipText = "When enabled shows raw binary data in details window.";
311 | //
312 | // toolStripSeparator3
313 | //
314 | this.toolStripSeparator3.Name = "toolStripSeparator3";
315 | this.toolStripSeparator3.Size = new System.Drawing.Size(224, 6);
316 | //
317 | // printCompactHtmlToolStripMenuItem
318 | //
319 | this.printCompactHtmlToolStripMenuItem.Checked = true;
320 | this.printCompactHtmlToolStripMenuItem.CheckOnClick = true;
321 | this.printCompactHtmlToolStripMenuItem.CheckState = System.Windows.Forms.CheckState.Checked;
322 | this.printCompactHtmlToolStripMenuItem.Name = "printCompactHtmlToolStripMenuItem";
323 | this.printCompactHtmlToolStripMenuItem.Size = new System.Drawing.Size(227, 22);
324 | this.printCompactHtmlToolStripMenuItem.Text = "Print HTML in compact form";
325 | this.printCompactHtmlToolStripMenuItem.ToolTipText = "Checked: One file per formet; Unchecked: One file per formset and form";
326 | //
327 | // printDetailsIntoHtmlToolStripMenuItem
328 | //
329 | this.printDetailsIntoHtmlToolStripMenuItem.CheckOnClick = true;
330 | this.printDetailsIntoHtmlToolStripMenuItem.Name = "printDetailsIntoHtmlToolStripMenuItem";
331 | this.printDetailsIntoHtmlToolStripMenuItem.Size = new System.Drawing.Size(227, 22);
332 | this.printDetailsIntoHtmlToolStripMenuItem.Text = "Print details into HTML";
333 | this.printDetailsIntoHtmlToolStripMenuItem.ToolTipText = "Shows IFR details within the generated HTML document.";
334 | //
335 | // toolStripSeparator2
336 | //
337 | this.toolStripSeparator2.Name = "toolStripSeparator2";
338 | this.toolStripSeparator2.Size = new System.Drawing.Size(224, 6);
339 | //
340 | // ts_parse_lang
341 | //
342 | this.ts_parse_lang.Name = "ts_parse_lang";
343 | this.ts_parse_lang.Size = new System.Drawing.Size(100, 23);
344 | this.ts_parse_lang.Text = "en-US";
345 | this.ts_parse_lang.ToolTipText = "Preferred language code.";
346 | //
347 | // helpToolStripMenuItem
348 | //
349 | this.helpToolStripMenuItem.Name = "helpToolStripMenuItem";
350 | this.helpToolStripMenuItem.Size = new System.Drawing.Size(52, 23);
351 | this.helpToolStripMenuItem.Text = "About";
352 | this.helpToolStripMenuItem.Click += new System.EventHandler(this.helpToolStripMenuItem_Click);
353 | //
354 | // toolStripSeparator1
355 | //
356 | this.toolStripSeparator1.Name = "toolStripSeparator1";
357 | this.toolStripSeparator1.Size = new System.Drawing.Size(6, 23);
358 | //
359 | // parseLogicalViewToolStripMenuItem
360 | //
361 | this.parseLogicalViewToolStripMenuItem.Name = "parseLogicalViewToolStripMenuItem";
362 | this.parseLogicalViewToolStripMenuItem.Size = new System.Drawing.Size(113, 23);
363 | this.parseLogicalViewToolStripMenuItem.Text = "Parse Logical Tree";
364 | this.parseLogicalViewToolStripMenuItem.Click += new System.EventHandler(this.parseLogicalViewToolStripMenuItem_Click);
365 | //
366 | // createHTMLToolStripMenuItem
367 | //
368 | this.createHTMLToolStripMenuItem.Name = "createHTMLToolStripMenuItem";
369 | this.createHTMLToolStripMenuItem.Size = new System.Drawing.Size(89, 23);
370 | this.createHTMLToolStripMenuItem.Text = "Create HTML";
371 | this.createHTMLToolStripMenuItem.Click += new System.EventHandler(this.createHTMLToolStripMenuItem_Click);
372 | //
373 | // MainForm
374 | //
375 | this.AllowDrop = true;
376 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
377 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
378 | this.ClientSize = new System.Drawing.Size(784, 488);
379 | this.Controls.Add(this.splitContainer1);
380 | this.Controls.Add(this.menuStrip1);
381 | this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
382 | this.MainMenuStrip = this.menuStrip1;
383 | this.MinimumSize = new System.Drawing.Size(800, 400);
384 | this.Name = "MainForm";
385 | this.Text = "IfrViewer";
386 | this.Load += new System.EventHandler(this.MainForm_Load);
387 | this.SizeChanged += new System.EventHandler(this.MainForm_SizeChanged);
388 | this.DragDrop += new System.Windows.Forms.DragEventHandler(this.MainForm_DragDrop);
389 | this.DragEnter += new System.Windows.Forms.DragEventHandler(this.MainForm_DragEnter);
390 | this.splitContainer1.Panel1.ResumeLayout(false);
391 | this.splitContainer1.Panel2.ResumeLayout(false);
392 | ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).EndInit();
393 | this.splitContainer1.ResumeLayout(false);
394 | this.tabControl1.ResumeLayout(false);
395 | this.tabrawtree.ResumeLayout(false);
396 | this.tablogicaltree.ResumeLayout(false);
397 | this.splitContainer2.Panel1.ResumeLayout(false);
398 | this.splitContainer2.Panel2.ResumeLayout(false);
399 | ((System.ComponentModel.ISupportInitialize)(this.splitContainer2)).EndInit();
400 | this.splitContainer2.ResumeLayout(false);
401 | ((System.ComponentModel.ISupportInitialize)(this.log)).EndInit();
402 | this.menuStrip1.ResumeLayout(false);
403 | this.menuStrip1.PerformLayout();
404 | this.ResumeLayout(false);
405 | this.PerformLayout();
406 |
407 | }
408 |
409 | #endregion
410 |
411 | private System.Windows.Forms.TreeView tv_tree;
412 | private System.Windows.Forms.SplitContainer splitContainer1;
413 | private System.Windows.Forms.DataGridView log;
414 | private System.Windows.Forms.DataGridViewTextBoxColumn Message;
415 | private System.Windows.Forms.DataGridViewTextBoxColumn Origin;
416 | private System.Windows.Forms.DataGridViewTextBoxColumn Type;
417 | private System.Windows.Forms.SplitContainer splitContainer2;
418 | private System.Windows.Forms.TreeView tv_details;
419 | private System.Windows.Forms.TabControl tabControl1;
420 | private System.Windows.Forms.TabPage tabrawtree;
421 | private System.Windows.Forms.TabPage tablogicaltree;
422 | private System.Windows.Forms.TreeView tv_logical;
423 | private System.Windows.Forms.MenuStrip menuStrip1;
424 | private System.Windows.Forms.ToolStripMenuItem fileToolStripMenuItem;
425 | private System.Windows.Forms.ToolStripMenuItem exitToolStripMenuItem;
426 | private System.Windows.Forms.ToolStripMenuItem parseLogicalViewToolStripMenuItem;
427 | private System.Windows.Forms.ToolStripSeparator toolStripSeparator1;
428 | private System.Windows.Forms.ToolStripMenuItem helpToolStripMenuItem;
429 | private System.Windows.Forms.ToolStripMenuItem createHTMLToolStripMenuItem;
430 | private System.Windows.Forms.ToolStripMenuItem optionsToolStripMenuItem;
431 | private System.Windows.Forms.ToolStripMenuItem showRawInDetailsWindowToolStripMenuItem;
432 | private System.Windows.Forms.ToolStripMenuItem printDetailsIntoHtmlToolStripMenuItem;
433 | private System.Windows.Forms.ToolStripTextBox ts_parse_lang;
434 | private System.Windows.Forms.ToolStripSeparator toolStripSeparator2;
435 | private System.Windows.Forms.ToolStripSeparator toolStripSeparator3;
436 | private System.Windows.Forms.ToolStripMenuItem printCompactHtmlToolStripMenuItem;
437 | }
438 | }
439 |
440 |
--------------------------------------------------------------------------------
/MainForm.cs:
--------------------------------------------------------------------------------
1 | //MIT License
2 | //
3 | //Copyright(c) 2016-2019 Peter Kirmeier
4 | //
5 | //Permission Is hereby granted, free Of charge, to any person obtaining a copy
6 | //of this software And associated documentation files (the "Software"), to deal
7 | //in the Software without restriction, including without limitation the rights
8 | //to use, copy, modify, merge, publish, distribute, sublicense, And/Or sell
9 | //copies of the Software, And to permit persons to whom the Software Is
10 | //furnished to do so, subject to the following conditions:
11 | //
12 | //The above copyright notice And this permission notice shall be included In all
13 | //copies Or substantial portions of the Software.
14 | //
15 | //THE SOFTWARE Is PROVIDED "AS IS", WITHOUT WARRANTY Of ANY KIND, EXPRESS Or
16 | //IMPLIED, INCLUDING BUT Not LIMITED To THE WARRANTIES Of MERCHANTABILITY,
17 | //FITNESS FOR A PARTICULAR PURPOSE And NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | //AUTHORS Or COPYRIGHT HOLDERS BE LIABLE For ANY CLAIM, DAMAGES Or OTHER
19 | //LIABILITY, WHETHER In AN ACTION Of CONTRACT, TORT Or OTHERWISE, ARISING FROM,
20 | //OUT OF Or IN CONNECTION WITH THE SOFTWARE Or THE USE Or OTHER DEALINGS IN THE
21 | //SOFTWARE.
22 |
23 | using IFR;
24 | using System;
25 | using System.Collections.Generic;
26 | using System.ComponentModel;
27 | using System.Drawing;
28 | using System.IO;
29 | using System.Windows.Forms;
30 | using static IFR.IFRHelper;
31 |
32 | namespace IfrViewer
33 | {
34 | public partial class MainForm : Form
35 | {
36 | private const string EmptyDetails = "No data available";
37 | private readonly BackgroundWorker DragDropWorker;
38 |
39 | public MainForm()
40 | {
41 | InitializeComponent();
42 | IFRHelper.log = log; // Use local window as logging window
43 | DragDropWorker = new BackgroundWorker();
44 | DragDropWorker.DoWork += DragDropWorker_DoWork;
45 | }
46 |
47 | #region GUI
48 |
49 | private void MainForm_Load(object sender, EventArgs e)
50 | {
51 | // Update Version
52 | Text += " - v" + Application.ProductVersion + " (UEFI 2.6)";
53 |
54 | // Set size of window to 80 percent by default
55 | MainForm_SizeChanged(sender, e);
56 | Width = (int)(Screen.GetWorkingArea(DesktopLocation).Width * 0.80);
57 | Height = (int)(Screen.GetWorkingArea(DesktopLocation).Height * 0.80);
58 | CenterToScreen();
59 | Show();
60 |
61 | // Load project from command line argument (when available)
62 | List Files = new List();
63 | Boolean DoTranslate = false;
64 | Boolean DoHTML = false;
65 | foreach (string arg in Environment.GetCommandLineArgs().SubArray(1, Environment.GetCommandLineArgs().Length-1))
66 | {
67 | if (arg.StartsWith("-")) // is option?
68 | {
69 | if (arg.Equals("-P")) // Start package
70 | {
71 | if (0 < Files.Count) // Parse previous package before loading next one..
72 | {
73 | LoadFiles(Files.ToArray()); // Load files of current package
74 | Files.Clear();
75 | }
76 | }
77 | else if (arg.StartsWith("-L=")) // Set display language
78 | {
79 | ts_parse_lang.Text = arg.Substring(3);
80 | }
81 | else if (arg.Equals("-T")) // Do Translation (Parsing logical tree)
82 | {
83 | DoTranslate = true;
84 | }
85 | else if (arg.Equals("-H")) // Do HTML output
86 | {
87 | DoHTML = true;
88 | }
89 | else CreateLogEntry(LogSeverity.WARNING, "Main", "Argument unkown \"" + arg + "\"");
90 | }
91 | else Files.Add(arg); // argument is a file
92 | }
93 | LoadFiles(Files.ToArray()); // Load last package
94 |
95 | if (0 == tv_tree.Nodes.Count)
96 | tv_details.Nodes.Add(EmptyDetails);
97 |
98 | TreeNode EmptyTree = tv_logical.Nodes.Add("No parsed packages available");
99 | EmptyTree.Tag = EmptyDetails;
100 |
101 | if (DoTranslate) // Parse logical tree
102 | parseLogicalViewToolStripMenuItem_Click(null, null);
103 |
104 | if (DoHTML) // Create HTML output
105 | createHTMLToolStripMenuItem_Click(null, null);
106 | }
107 |
108 | ///
109 | /// Creates a log entry for the "Main" module
110 | ///
111 | /// Severity of message
112 | /// Message string
113 | private void CreateLogEntryMain(LogSeverity severity, string msg)
114 | {
115 | CreateLogEntry(severity, "Main", msg);
116 |
117 | log.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
118 | log.AutoResizeRows(DataGridViewAutoSizeRowsMode.AllCells);
119 | log.FirstDisplayedScrollingRowIndex = log.Rows[log.RowCount - 1].Index; // Scroll to bottom
120 |
121 | Update();
122 | }
123 |
124 | private void MainForm_SizeChanged(object sender, EventArgs e)
125 | {
126 | // Check if window got minimized then stop changing sizes!
127 | // When form gets maximized (means ClientSize changes back to normal) then SizeChanged event doesn't get fired (;゚︵゚;)
128 | if ((ClientSize.Width == 0) || (ClientSize.Height == 0))
129 | return;
130 |
131 | splitContainer1.Width = ClientSize.Width - 24;
132 | splitContainer1.Height = ClientSize.Height - 24;
133 | splitContainer1_SplitterMoved(sender, null);
134 | }
135 |
136 | private void splitContainer1_SplitterMoved(object sender, SplitterEventArgs e)
137 | {
138 | tabControl1.Width = splitContainer1.Panel1.Width - 9;
139 | tabControl1.Height = splitContainer1.Panel1.Height - 6;
140 | tabControl1_SizeChanged(sender, null);
141 | splitContainer2.Width = splitContainer1.Panel2.Width - 6;
142 | splitContainer2.Height = splitContainer1.Panel2.Height - 6;
143 | splitContainer2_SplitterMoved(sender, null);
144 | }
145 |
146 | private void splitContainer2_SplitterMoved(object sender, SplitterEventArgs e)
147 | {
148 | tv_details.Width = splitContainer2.Panel1.Width - 6;
149 | tv_details.Height = splitContainer2.Panel1.Height - 6;
150 | log.Width = splitContainer2.Panel2.Width - 6;
151 | log.Height = splitContainer2.Panel2.Height - 6;
152 | }
153 |
154 | private void tabControl1_SizeChanged(object sender, EventArgs e)
155 | {
156 | Control ActiveParent = tabControl1.SelectedTab;
157 | tv_tree.Width = ActiveParent.Width;
158 | tv_tree.Height = ActiveParent.Height;
159 | tv_logical.Width = ActiveParent.Width;
160 | tv_logical.Height = ActiveParent.Height;
161 | }
162 |
163 | ///
164 | /// Adds a text-object pair to a tree
165 | ///
166 | /// Node which the new node is added to
167 | /// Displayed text of new node
168 | /// Object added to node for reference
169 | /// New created tree node
170 | private TreeNode AddTreeNode(TreeNode root, string text, object obj)
171 | {
172 | TreeNode leaf = root.Nodes.Add(text);
173 | leaf.Tag = obj;
174 | return leaf;
175 | }
176 |
177 | ///
178 | /// Updates the details window when a tree node gets selected by user
179 | ///
180 | private void tv_tree_AfterSelect(object sender, TreeViewEventArgs e)
181 | {
182 | ShowAtDetails(e.Node.Tag, e.Node.Name);
183 | }
184 |
185 | ///
186 | /// Handles drag and drop operation in order to load further files
187 | ///
188 | /// Argument must contain DragEventArgs
189 | void DragDropWorker_DoWork(object sender, DoWorkEventArgs e)
190 | {
191 | DragEventArgs drag_args = (DragEventArgs)e.Argument;
192 | string[] DroppedPathList = (string[])drag_args.Data.GetData(DataFormats.FileDrop);
193 | List DroppedFiles = new List();
194 |
195 | // get all files of the dropped object(s) and add them..
196 | foreach (string path in DroppedPathList)
197 | {
198 | if (Directory.Exists(path))
199 | DroppedFiles.AddRange(Directory.GetFiles(path, "*.*", SearchOption.AllDirectories));
200 | else if (File.Exists(path))
201 | DroppedFiles.Add(path);
202 | }
203 |
204 | Invoke(Delegate.CreateDelegate(typeof(DragDropFilesFunc), this, "DragDropFiles"), DroppedFiles.ToArray(), drag_args);
205 | }
206 |
207 | private void MainForm_DragDrop(object sender, DragEventArgs e)
208 | {
209 | DragDropWorker.RunWorkerAsync(e);
210 | }
211 |
212 | private void tv_tree_DragOver(object sender, DragEventArgs e)
213 | {
214 | if (null != GetTreeNodeAtPoint(sender, e.X, e.Y)) // Is draging onto a tree node?
215 | e.Effect = DragDropEffects.Link; // Allow dropping files into existing package
216 | else
217 | e.Effect = DragDropEffects.Copy; // Allow dropping files into separate package
218 | }
219 |
220 | private void MainForm_DragEnter(object sender, DragEventArgs e)
221 | {
222 | if (e.Data.GetDataPresent(DataFormats.FileDrop)) e.Effect = DragDropEffects.Copy; // Allow dopping files
223 | }
224 |
225 | private void parseLogicalViewToolStripMenuItem_Click(object sender, EventArgs e)
226 | {
227 | ParseAllFiles(ts_parse_lang.Text);
228 | tabControl1.SelectedIndex = 1;
229 | }
230 |
231 | private void createHTMLToolStripMenuItem_Click(object sender, EventArgs e)
232 | {
233 | CreateHTMLFiles(ts_parse_lang.Text, printDetailsIntoHtmlToolStripMenuItem.Checked);
234 | }
235 |
236 | private void exitToolStripMenuItem_Click(object sender, EventArgs e)
237 | {
238 | Application.Exit();
239 | }
240 |
241 | private void helpToolStripMenuItem_Click(object sender, EventArgs e)
242 | {
243 | (new About()).ShowDialog(this);
244 | }
245 |
246 | ///
247 | /// Retrieves the TreeNode object of a TreeView at a given position
248 | ///
249 | /// TreeView object to search
250 | /// Position X
251 | /// Position Y
252 | private TreeNode GetTreeNodeAtPoint(object sender, int x, int y)
253 | {
254 | if (!(sender is TreeView))
255 | return null;
256 |
257 | TreeView tv_sender = (TreeView)sender;
258 | Point pt = tv_sender.PointToClient(new Point(x, y));
259 | return tv_sender.GetNodeAt(pt);
260 | }
261 |
262 | private delegate void DragDropFilesFunc(string[] filepaths, DragEventArgs e);
263 | ///
264 | /// Loads a bunch of files via drag and drop
265 | ///
266 | /// List of files to load
267 | /// Drag and drop event arguments
268 | private void DragDropFiles(string[] filepaths, DragEventArgs e)
269 | {
270 | TreeNode RootNode = null;
271 | if (DragDropEffects.Link == e.Effect) // object needs to be linked with an existing node?
272 | {
273 | RootNode = GetTreeNodeAtPoint(tv_tree, e.X, e.Y);
274 | while (null != RootNode.Parent) RootNode = RootNode.Parent;
275 | }
276 | LoadFiles(filepaths, RootNode);
277 | }
278 | #endregion
279 |
280 | ///
281 | /// Loads a bunch of files which are referring the same "package"
282 | ///
283 | /// List of files to load
284 | /// Optional node the loaded packages are added to
285 | private void LoadFiles(string[] filepaths, TreeNode ParentNode = null)
286 | {
287 | Cursor previousCursor = Cursor.Current;
288 | Cursor.Current = Cursors.WaitCursor;
289 |
290 | List Packages = new List();
291 |
292 | TreeNode PkgNodeRaw = ParentNode;
293 | if (null == PkgNodeRaw) // use given parent or create it
294 | {
295 | PkgNodeRaw = tv_tree.Nodes.Add("Package");
296 | PkgNodeRaw.Tag = EmptyDetails;
297 | }
298 |
299 | CreateLogEntryMain(LogSeverity.INFO, "Loading files...");
300 |
301 | // Load HPKs into memory and build tree view
302 | foreach (string filename in filepaths)
303 | {
304 | CreateLogEntryMain(LogSeverity.INFO, "Loading file \"" + filename + "\" ...");
305 |
306 | HPKfile hpk = null;
307 | try
308 | {
309 | hpk = new HPKfile(filename);
310 | }
311 | catch (Exception ex)
312 | {
313 | Console.WriteLine(ex.ToString());
314 | CreateLogEntryMain(LogSeverity.ERROR, "Loading file failed!" + Environment.NewLine + ex.ToString());
315 | MessageBox.Show("Loading file failed!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
316 | }
317 |
318 | if (null != hpk) // Loaded successfully?
319 | {
320 | tv_tree.BeginUpdate();
321 | TreeNode root = PkgNodeRaw.Nodes.Add(hpk.Name);
322 | root.Tag = hpk;
323 | ShowAtRawTree(hpk, root);
324 | root.Expand();
325 | tv_tree.EndUpdate();
326 |
327 | // Collect all new packages of this file
328 | foreach (HiiPackageBase hpkpkg in hpk.Childs)
329 | Packages.Add(hpkpkg);
330 | }
331 | }
332 |
333 | CreateLogEntryMain(LogSeverity.SUCCESS, "Loading files completed!");
334 |
335 | Cursor.Current = previousCursor;
336 | }
337 |
338 | ///
339 | /// Parses a bunch of files which are referring the same "package" using a given default language
340 | ///
341 | /// Primary language
342 | private void ParseAllFiles(string Language)
343 | {
344 | Cursor previousCursor = Cursor.Current;
345 | Cursor.Current = Cursors.WaitCursor;
346 |
347 | CreateLogEntryMain(LogSeverity.INFO, "Parsing packages...");
348 |
349 | tv_logical.Parent.Text = "Logical Tree (\"" + Language + "\")";
350 | tv_logical.Nodes.Clear();
351 |
352 | foreach (TreeNode node_files in tv_tree.Nodes)
353 | {
354 | List Packages = new List();
355 |
356 | TreeNode PkgNodeLogical = tv_logical.Nodes.Add("Package");
357 | PkgNodeLogical.Tag = EmptyDetails;
358 |
359 | // Collect all HII packages of the files that are building a logical package
360 | foreach (TreeNode node_pkg in node_files.Nodes)
361 | foreach (HiiPackageBase hpk in (node_pkg.Tag as HPKfile).Childs)
362 | Packages.Add(hpk);
363 |
364 | ParsedHpkStringContainer HpkStrings = new ParsedHpkStringContainer(Packages, Language);
365 | ParsedHpkContainer ParsedHpkContainer = new ParsedHpkContainer(Packages, HpkStrings);
366 |
367 | // Since HPKs interact with each other, build logical tree after loading is completely done
368 | foreach (ParsedHpkNode pkg in ParsedHpkContainer.HpkPackages)
369 | {
370 | CreateLogEntryMain(LogSeverity.INFO, "Parsing \"" + pkg.Name + "\" ...");
371 |
372 | tv_logical.BeginUpdate();
373 | TreeNode root = PkgNodeLogical.Nodes.Add(pkg.Name);
374 | root.Tag = pkg.Origin;
375 | ShowAtLogicalTree(pkg, root);
376 | root.Expand();
377 | tv_logical.EndUpdate();
378 | }
379 |
380 | PkgNodeLogical.Expand();
381 | }
382 |
383 | if (0 == tv_logical.Nodes.Count)
384 | {
385 | TreeNode EmptyTree = tv_logical.Nodes.Add("No parsed packages available");
386 | EmptyTree.Tag = EmptyDetails;
387 | }
388 |
389 | CreateLogEntryMain(LogSeverity.SUCCESS, "Parsing packages completed!");
390 |
391 | Cursor.Current = previousCursor;
392 | }
393 |
394 | ///
395 | /// Creates HTML files foreach formset including all their forms
396 | ///
397 | /// Primary language
398 | /// Printing details into HTML
399 | private void CreateHTMLFiles(string Language, bool bShowDetails)
400 | {
401 | Cursor previousCursor = Cursor.Current;
402 | Cursor.Current = Cursors.WaitCursor;
403 |
404 | CreateLogEntryMain(LogSeverity.INFO, "Creating HTML output...");
405 |
406 | foreach (TreeNode node_files in tv_tree.Nodes)
407 | {
408 | List Packages = new List();
409 |
410 | // Collect all HII packages of the files that are building a logical package
411 | foreach (TreeNode node_pkg in node_files.Nodes)
412 | foreach (HiiPackageBase hpk in (node_pkg.Tag as HPKfile).Childs)
413 | Packages.Add(hpk);
414 |
415 | ParsedHpkStringContainer HpkStrings = new ParsedHpkStringContainer(Packages, Language);
416 | HtmlBuilder HtmlBuilder = new HtmlBuilder(Packages, HpkStrings, bShowDetails, printCompactHtmlToolStripMenuItem.Checked);
417 | }
418 |
419 | // TODO!
420 | //if (0 == tv_logical.Nodes[0].Nodes.Count)
421 | // CreateLogEntryMain(LogSeverity.ERROR, "Creating HTML output failed!\nNo parsed package available");
422 | //else
423 | CreateLogEntryMain(LogSeverity.SUCCESS, "Creating HTML output completed!");
424 |
425 | Cursor.Current = previousCursor;
426 | }
427 |
428 | ///
429 | /// Adds a subtree according to the given HPK tree
430 | ///
431 | /// Root node of HPK tree
432 | /// Root node of target tree
433 | private void ShowAtRawTree(HPKElement elem, TreeNode root)
434 | {
435 | // add all child elements to the tree..
436 | if (elem.Childs.Count > 0)
437 | {
438 | foreach (HPKElement child in elem.Childs)
439 | {
440 | ShowAtRawTree(child, AddTreeNode(root, child.Name + " [" + child.UniqueID + "]", child));
441 | }
442 | root.Expand();
443 | }
444 | }
445 |
446 | ///
447 | /// Adds a subtree according to the given parsed HPK tree
448 | ///
449 | /// Root node of parsed HPK tree
450 | /// Root node of target tree
451 | private void ShowAtLogicalTree(ParsedHpkNode node, TreeNode root)
452 | {
453 | // add all child elements to the tree..
454 | if (node.Childs.Count > 0)
455 | {
456 | foreach (ParsedHpkNode child in node.Childs)
457 | {
458 | ShowAtLogicalTree(child, AddTreeNode(root, child.Name, child.Origin));
459 | }
460 | root.Expand();
461 | }
462 | }
463 |
464 | ///
465 | /// Shows object's data at details window
466 | ///
467 | /// Object to be displayed
468 | /// Name of the displayed object (in case of error)
469 | private void ShowAtDetails(object obj, string name)
470 | {
471 | Cursor previousCursor = Cursor.Current;
472 | Cursor.Current = Cursors.WaitCursor;
473 | tv_details.BeginUpdate();
474 |
475 | tv_details.Nodes.Clear();
476 | if (obj == null)
477 | {
478 | // should not happen because every node should have an object!
479 | tv_details.Nodes.Add(EmptyDetails);
480 | CreateLogEntryMain(LogSeverity.WARNING, "No data found for \"" + name + "\"!");
481 | }
482 | else if (obj is HPKElement)
483 | {
484 | HPKElement elem = (HPKElement)obj;
485 | const uint BytesPerLine = 16;
486 |
487 | // add common elements..
488 | tv_details.Nodes.Add("UniqueID = " + elem.UniqueID);
489 |
490 | // add all header fields to the tree..
491 | byte[] HeaderRaw = elem.HeaderRaw;
492 | if ((elem.Header != null) || (HeaderRaw != null))
493 | {
494 | TreeNode branch = tv_details.Nodes.Add("Header");
495 | // handle raw..
496 | if ((HeaderRaw != null) && (showRawInDetailsWindowToolStripMenuItem.Checked))
497 | {
498 | TreeNode leaf = branch.Nodes.Add("__RAW");
499 | foreach (string line in HeaderRaw.HexDump(BytesPerLine).Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries))
500 | leaf.Nodes.Add(line);
501 | }
502 | // handle managed..
503 | if (elem.Header != null)
504 | {
505 | foreach (System.Collections.Generic.KeyValuePair pair in elem.GetPrintableHeader(BytesPerLine))
506 | {
507 | branch.Nodes.Add(pair.Key + " = " + pair.Value.ToString());
508 | }
509 | }
510 | //branch.Expand();
511 | }
512 | // add all payload fields to the tree..
513 | byte[] PayloadRaw = elem.PayloadRaw;
514 | if ((elem.Payload != null) || (PayloadRaw != null))
515 | {
516 | TreeNode branch = tv_details.Nodes.Add("Payload");
517 | // handle raw..
518 | if ((PayloadRaw != null) && (showRawInDetailsWindowToolStripMenuItem.Checked))
519 | {
520 | TreeNode leaf = branch.Nodes.Add("__RAW");
521 | foreach (string line in PayloadRaw.HexDump(BytesPerLine).Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries))
522 | leaf.Nodes.Add(line);
523 | }
524 | // handle managed..
525 | if (elem.Payload != null)
526 | {
527 | foreach (System.Collections.Generic.KeyValuePair pair in elem.GetPrintablePayload(BytesPerLine))
528 | {
529 | branch.Nodes.Add(pair.Key + " = " + pair.Value.ToString());
530 | }
531 | }
532 | //branch.Expand();
533 | }
534 | tv_details.ExpandAll();
535 | }
536 | else if (obj is String)
537 | {
538 | tv_details.Nodes.Add((string)obj);
539 | }
540 | else // Unknown data type
541 | {
542 | tv_details.Nodes.Add(EmptyDetails);
543 | CreateLogEntryMain(LogSeverity.UNIMPLEMENTED, "Unkown data found for \"" + name + "\"!");
544 | }
545 |
546 | tv_details.EndUpdate();
547 | Cursor.Current = previousCursor;
548 | }
549 |
550 | ///
551 | /// Handler for CTRL+C copy shortcut on tree view nodes
552 | /// Copies the tree node's text to clipboard
553 | ///
554 | private void tv_KeyDown(object sender, KeyEventArgs e)
555 | {
556 | if (sender is TreeView)
557 | {
558 | TreeView tv = (TreeView)sender;
559 | if (e.KeyData == (Keys.Control | Keys.C))
560 | {
561 | if (tv.SelectedNode != null)
562 | {
563 | Clipboard.SetText(tv.SelectedNode.Text);
564 | }
565 | e.SuppressKeyPress = true;
566 | }
567 | }
568 | }
569 |
570 | }
571 |
572 | static class IfrViewer
573 | {
574 | [STAThread]
575 | static void Main()
576 | {
577 | Application.EnableVisualStyles();
578 | Application.SetCompatibleTextRenderingDefault(false);
579 | Application.Run(new MainForm());
580 | }
581 | }
582 | }
583 |
--------------------------------------------------------------------------------
/ParseLogical.cs:
--------------------------------------------------------------------------------
1 | //MIT License
2 | //
3 | //Copyright(c) 2017-2017 Peter Kirmeier
4 | //
5 | //Permission Is hereby granted, free Of charge, to any person obtaining a copy
6 | //of this software And associated documentation files (the "Software"), to deal
7 | //in the Software without restriction, including without limitation the rights
8 | //to use, copy, modify, merge, publish, distribute, sublicense, And/Or sell
9 | //copies of the Software, And to permit persons to whom the Software Is
10 | //furnished to do so, subject to the following conditions:
11 | //
12 | //The above copyright notice And this permission notice shall be included In all
13 | //copies Or substantial portions of the Software.
14 | //
15 | //THE SOFTWARE Is PROVIDED "AS IS", WITHOUT WARRANTY Of ANY KIND, EXPRESS Or
16 | //IMPLIED, INCLUDING BUT Not LIMITED To THE WARRANTIES Of MERCHANTABILITY,
17 | //FITNESS FOR A PARTICULAR PURPOSE And NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | //AUTHORS Or COPYRIGHT HOLDERS BE LIABLE For ANY CLAIM, DAMAGES Or OTHER
19 | //LIABILITY, WHETHER In AN ACTION Of CONTRACT, TORT Or OTHERWISE, ARISING FROM,
20 | //OUT OF Or IN CONNECTION WITH THE SOFTWARE Or THE USE Or OTHER DEALINGS IN THE
21 | //SOFTWARE.
22 |
23 | using IFR;
24 | using System;
25 | using System.Collections.Generic;
26 | using static IfrViewer.HpkParser;
27 |
28 | namespace IfrViewer
29 | {
30 |
31 | ///
32 | /// Parses HPK packages and gives access to a parsed HPK tree
33 | ///
34 | public class ParsedHpkContainer
35 | {
36 | ///
37 | /// Parsed HPK tree
38 | ///
39 | public readonly List HpkPackages;
40 |
41 | ///
42 | /// Parsed HPK strings
43 | ///
44 | private readonly ParsedHpkStringContainer HpkStrings;
45 |
46 | ///
47 | /// Parses a set of packages
48 | ///
49 | /// List of packages that will be parsed
50 | /// Parsed HPK strings used for translations
51 | public ParsedHpkContainer(List Packages, ParsedHpkStringContainer HpkStrings)
52 | {
53 | this.HpkStrings = HpkStrings;
54 | HpkPackages = new List();
55 |
56 | // Copy HPK strings to HPK packages to be shown in logical view, too..
57 | foreach (ParsedHpkNode pkg in HpkStrings.HpkPackages)
58 | HpkPackages.Add(pkg);
59 |
60 | foreach (HiiPackageBase pkg in Packages)
61 | {
62 | try
63 | {
64 | ParsedHpkNode root = new ParsedHpkNode(pkg, pkg.Name);
65 | switch (pkg.PackageType)
66 | {
67 | case EFI_HII_PACKAGE_e.EFI_HII_PACKAGE_FORMS:
68 | root.Name = "Form Package";
69 | HpkPackages.Add(root);
70 | foreach (HPKElement child in root.Origin.Childs)
71 | ParsePackageIfr(child, root);
72 | break;
73 | case EFI_HII_PACKAGE_e.EFI_HII_PACKAGE_STRINGS: break; // Already done
74 | default:
75 | CreateLogEntryParser(LogSeverity.UNIMPLEMENTED, root.Name);
76 | break;
77 | }
78 | }
79 | catch (Exception ex)
80 | {
81 | Console.WriteLine(ex.ToString());
82 | CreateLogEntryParser(LogSeverity.ERROR, "Parsing failed!" + Environment.NewLine + ex.ToString());
83 | }
84 | }
85 | }
86 |
87 | ///
88 | /// Parses IFR elements and add them to a parsed HPK tree
89 | ///
90 | /// HPK element holding the input data
91 | /// Tree node which new nodes will be added to
92 | private void ParsePackageIfr(HPKElement hpkelem, ParsedHpkNode root)
93 | {
94 | ParsedHpkNode branch = new ParsedHpkNode(hpkelem, hpkelem.Name);
95 | HiiIfrOpCode elem = (HiiIfrOpCode)hpkelem;
96 | bool bProcessChilds = true;
97 |
98 | switch (elem.OpCode)
99 | {
100 | #region Forms
101 | case EFI_IFR_OPCODE_e.EFI_IFR_FORM_SET_OP:
102 | {
103 | EFI_IFR_FORM_SET hdr = (EFI_IFR_FORM_SET)elem.Header;
104 | ParsedHpkNode leaf = new ParsedHpkNode(hpkelem, "");
105 | string prefix = "FormSet";
106 | branch.Name = prefix + " \"" + HpkStrings.GetString(hdr.FormSetTitle, hpkelem.UniqueID) + "\"";
107 | leaf.Name = prefix + "-Help = " + HpkStrings.GetString(hdr.Help, hpkelem.UniqueID);
108 | branch.Childs.Add(leaf);
109 | leaf.Name = prefix + "-Guid = " + hdr.Guid.Guid.ToString();
110 | branch.Childs.Add(leaf);
111 | foreach (EFI_GUID classguid in (List)elem.Payload)
112 | {
113 | leaf.Name = prefix + "-ClassGuid = " + classguid.Guid.ToString();
114 | branch.Childs.Add(leaf);
115 | }
116 |
117 | ParsedHpkNode varstores = new ParsedHpkNode(hpkelem, prefix + "-Varstores");
118 | branch.Childs.Add(varstores);
119 | foreach (HiiIfrOpCode child in elem.Childs)
120 | {
121 | switch (child.OpCode)
122 | {
123 | case EFI_IFR_OPCODE_e.EFI_IFR_DEFAULTSTORE_OP:
124 | case EFI_IFR_OPCODE_e.EFI_IFR_VARSTORE_OP:
125 | case EFI_IFR_OPCODE_e.EFI_IFR_VARSTORE_EFI_OP:
126 | case EFI_IFR_OPCODE_e.EFI_IFR_VARSTORE_NAME_VALUE_OP:
127 | case EFI_IFR_OPCODE_e.EFI_IFR_VARSTORE_DEVICE_OP:
128 | ParsePackageIfr(child, varstores); break;
129 | default:
130 | ParsePackageIfr(child, branch); break;
131 | }
132 | }
133 | bProcessChilds = false;
134 | }
135 | break;
136 | case EFI_IFR_OPCODE_e.EFI_IFR_FORM_OP:
137 | {
138 | EFI_IFR_FORM ifr_hdr = (EFI_IFR_FORM)hpkelem.Header;
139 | branch.Name = "Form"
140 | + " [Id = " + ifr_hdr.FormId.ToDecimalString(5) + "]"
141 | + " \"" + HpkStrings.GetString(ifr_hdr.FormTitle, hpkelem.UniqueID) + "\"";
142 | }
143 | break;
144 | case EFI_IFR_OPCODE_e.EFI_IFR_REF_OP:
145 | {
146 | string FormIdString = "FormId = ";
147 | string FormSetIdString = "FormSetId = ";
148 | string QuestionId = "QuestionId = ";
149 | string InfoString = "";
150 | string RefName = null;
151 | switch (hpkelem.Header.GetType().Name)
152 | {
153 | case "EFI_IFR_REF":
154 | {
155 | EFI_IFR_REF ifr_hdr = (EFI_IFR_REF)hpkelem.Header;
156 | FormIdString += ifr_hdr.FormId == 0 ? "Current" : ifr_hdr.FormId.ToDecimalString(5);
157 | InfoString = FormIdString;
158 | RefName = HpkStrings.GetString(ifr_hdr.Question.Header.Prompt, hpkelem.UniqueID);
159 | }
160 | break;
161 | case "EFI_IFR_REF2":
162 | {
163 | EFI_IFR_REF2 ifr_hdr = (EFI_IFR_REF2)hpkelem.Header;
164 | FormIdString += ifr_hdr.FormId == 0 ? "Current" : ifr_hdr.FormId.ToDecimalString(5);
165 | if (0 == ifr_hdr.QuestionId)
166 | QuestionId = "";
167 | else
168 | QuestionId += ifr_hdr.QuestionId.ToDecimalString(5);
169 | InfoString = FormIdString + ", " + QuestionId;
170 | RefName = HpkStrings.GetString(ifr_hdr.Question.Header.Prompt, hpkelem.UniqueID);
171 | }
172 | break;
173 | case "EFI_IFR_REF3":
174 | {
175 | EFI_IFR_REF3 ifr_hdr = (EFI_IFR_REF3)hpkelem.Header;
176 | FormIdString += ifr_hdr.FormId == 0 ? "Current" : ifr_hdr.FormId.ToDecimalString(5);
177 | if (0 == ifr_hdr.QuestionId)
178 | QuestionId = "";
179 | else
180 | QuestionId += ifr_hdr.QuestionId.ToDecimalString(5);
181 | InfoString = FormIdString + ", " + QuestionId;
182 | FormSetIdString += ifr_hdr.FormSetId.Guid.ToString();
183 | InfoString = FormIdString + ", " + FormSetIdString;
184 | RefName = HpkStrings.GetString(ifr_hdr.Question.Header.Prompt, hpkelem.UniqueID);
185 | }
186 | break;
187 | case "EFI_IFR_REF4":
188 | {
189 | EFI_IFR_REF4 ifr_hdr = (EFI_IFR_REF4)hpkelem.Header;
190 | FormIdString += ifr_hdr.FormId == 0 ? "Current" : ifr_hdr.FormId.ToDecimalString(5);
191 | if (0 == ifr_hdr.QuestionId)
192 | QuestionId = "";
193 | else
194 | QuestionId += ifr_hdr.QuestionId.ToDecimalString(5);
195 | InfoString = FormIdString + ", " + QuestionId;
196 | FormSetIdString += ifr_hdr.FormSetId.Guid.ToString();
197 | InfoString = FormIdString + ", " + FormSetIdString + ", DevicePath = \"" + HpkStrings.GetString(ifr_hdr.DevicePath, hpkelem.UniqueID) + "\"";
198 | RefName = HpkStrings.GetString(ifr_hdr.Question.Header.Prompt, hpkelem.UniqueID);
199 | }
200 | break;
201 | case "EFI_IFR_REF5":
202 | {
203 | EFI_IFR_REF5 ifr_hdr = (EFI_IFR_REF5)hpkelem.Header;
204 | FormIdString += "Nested";
205 | InfoString = FormIdString;
206 | }
207 | break;
208 | default:
209 | InfoString = "?";
210 | CreateLogEntryParser(LogSeverity.WARNING, "Unknown reference type [" + hpkelem.UniqueID + "]!");
211 | break;
212 | }
213 | branch.Name = "Reference to [" + InfoString + "]" + (RefName != null ? " \"" + RefName + "\"" : "");
214 | }
215 | break;
216 | case EFI_IFR_OPCODE_e.EFI_IFR_GUID_OP: branch.Name = "GuidOp = " + ((EFI_IFR_GUID)hpkelem.Header).Guid.Guid.ToString(); break;
217 | case EFI_IFR_OPCODE_e.EFI_IFR_FORM_MAP_OP:
218 | {
219 | EFI_IFR_FORM_MAP hdr = (EFI_IFR_FORM_MAP)elem.Header;
220 | ParsedHpkNode leaf = new ParsedHpkNode(hpkelem, "");
221 | string prefix = "FormMap";
222 | branch.Name = prefix + " Id = " + hdr.FormId.ToDecimalString(5);
223 | foreach (EFI_IFR_FORM_MAP_METHOD method in (List)elem.Payload)
224 | {
225 | leaf.Name = prefix + "-Method = " + method.MethodIdentifier.Guid.ToString()
226 | + " " + method.MethodTitle.ToDecimalString(5) + " [\"" + HpkStrings.GetString(method.MethodTitle, hpkelem.UniqueID) + "\"]";
227 | branch.Childs.Add(leaf);
228 | }
229 | }
230 | break;
231 | case EFI_IFR_OPCODE_e.EFI_IFR_MODAL_TAG_OP: branch.Name = "ModalTag"; break;
232 | case EFI_IFR_OPCODE_e.EFI_IFR_REFRESH_ID_OP: branch.Name = "RefreshId = " + ((EFI_IFR_REFRESH_ID)hpkelem.Header).RefreshEventGroupId.Guid.ToString(); break;
233 | #endregion
234 |
235 | #region Varstores
236 | case EFI_IFR_OPCODE_e.EFI_IFR_DEFAULTSTORE_OP:
237 | {
238 | EFI_IFR_DEFAULTSTORE ifr_hdr = (EFI_IFR_DEFAULTSTORE)hpkelem.Header;
239 | branch.Name = "DefaultStore = " + ifr_hdr.DefaultName + " [" + ifr_hdr.DefaultId.ToString() + "]";
240 | }
241 | break;
242 | case EFI_IFR_OPCODE_e.EFI_IFR_VARSTORE_OP:
243 | {
244 | EFI_IFR_VARSTORE ifr_hdr = (EFI_IFR_VARSTORE)hpkelem.Header;
245 | branch.Name = "VarStore"
246 | + " [Id = " + ifr_hdr.VarStoreId.ToDecimalString(5) + ", Guid = " + ifr_hdr.Guid.Guid.ToString() + "]"
247 | + " \"" + ((HiiIfrOpCodeWithAsciiNullTerminatedString.NamedPayload_t)hpkelem.Payload).Name + "\"";
248 | }
249 | break;
250 | case EFI_IFR_OPCODE_e.EFI_IFR_VARSTORE_EFI_OP:
251 | {
252 | EFI_IFR_VARSTORE_EFI ifr_hdr = (EFI_IFR_VARSTORE_EFI)hpkelem.Header;
253 | branch.Name = "VarStore"
254 | + " [Id = " + ifr_hdr.VarStoreId.ToDecimalString(5) + ", Guid = " + ifr_hdr.Guid.Guid.ToString() + "]"
255 | + " \"" + ((HiiIfrOpCodeWithAsciiNullTerminatedString.NamedPayload_t)hpkelem.Payload).Name + "\"";
256 | }
257 | break;
258 | case EFI_IFR_OPCODE_e.EFI_IFR_VARSTORE_NAME_VALUE_OP:
259 | {
260 | EFI_IFR_VARSTORE_NAME_VALUE ifr_hdr = (EFI_IFR_VARSTORE_NAME_VALUE)hpkelem.Header;
261 | branch.Name = "VarStore" + " [Id = " + ifr_hdr.VarStoreId.ToDecimalString(5) + ", Guid = " + ifr_hdr.Guid.Guid.ToString() + "]";
262 | }
263 | break;
264 | case EFI_IFR_OPCODE_e.EFI_IFR_VARSTORE_DEVICE_OP:
265 | {
266 | EFI_IFR_VARSTORE_DEVICE ifr_hdr = (EFI_IFR_VARSTORE_DEVICE)hpkelem.Header;
267 | branch.Name = "VarStore" + " \"" + HpkStrings.GetString(ifr_hdr.DevicePath, hpkelem.UniqueID) + "\"";
268 | }
269 | break;
270 | #endregion
271 |
272 | #region Logic
273 | case EFI_IFR_OPCODE_e.EFI_IFR_SUPPRESS_IF_OP:
274 | case EFI_IFR_OPCODE_e.EFI_IFR_GRAY_OUT_IF_OP:
275 | case EFI_IFR_OPCODE_e.EFI_IFR_DISABLE_IF_OP:
276 | case EFI_IFR_OPCODE_e.EFI_IFR_WARNING_IF_OP:
277 | case EFI_IFR_OPCODE_e.EFI_IFR_NO_SUBMIT_IF_OP:
278 | case EFI_IFR_OPCODE_e.EFI_IFR_INCONSISTENT_IF_OP:
279 | {
280 | switch (elem.OpCode)
281 | {
282 | case EFI_IFR_OPCODE_e.EFI_IFR_SUPPRESS_IF_OP: branch.Name = "SupressIf "; break;
283 | case EFI_IFR_OPCODE_e.EFI_IFR_GRAY_OUT_IF_OP: branch.Name = "GrayOutIf "; break;
284 | case EFI_IFR_OPCODE_e.EFI_IFR_DISABLE_IF_OP: branch.Name = "DisableIf "; break;
285 | case EFI_IFR_OPCODE_e.EFI_IFR_WARNING_IF_OP: branch.Name = "WarningIf "; break;
286 | case EFI_IFR_OPCODE_e.EFI_IFR_NO_SUBMIT_IF_OP: branch.Name = "NoSubmitIf "; break;
287 | case EFI_IFR_OPCODE_e.EFI_IFR_INCONSISTENT_IF_OP: branch.Name = "InconsistendIf "; break;
288 | default: break;
289 | }
290 | if (elem.Childs.Count < 1)
291 | CreateLogEntryParser(LogSeverity.WARNING, "Too few logic elements [" + hpkelem.UniqueID + "]!");
292 | else
293 | {
294 | branch.Name += HpkStrings.GetIfrLogicString((HiiIfrOpCode)elem.Childs[0]);
295 | for (int i = 1; i < elem.Childs.Count; i++) // skip first element, because it contains the (nested) logic
296 | ParsePackageIfr(elem.Childs[i], branch);
297 | bProcessChilds = false;
298 | }
299 | }
300 | break;
301 | #endregion
302 |
303 | #region Visuals
304 | case EFI_IFR_OPCODE_e.EFI_IFR_SUBTITLE_OP:
305 | {
306 | EFI_IFR_SUBTITLE ifr_hdr = (EFI_IFR_SUBTITLE)hpkelem.Header;
307 | branch.Name = "Subtitle" + " \"" + HpkStrings.GetString(ifr_hdr.Statement.Prompt, hpkelem.UniqueID) + "\"";
308 | }
309 | break;
310 | case EFI_IFR_OPCODE_e.EFI_IFR_TEXT_OP:
311 | {
312 | EFI_IFR_TEXT ifr_hdr = (EFI_IFR_TEXT)hpkelem.Header;
313 | branch.Name = "Text"
314 | + " \"" + HpkStrings.GetString(ifr_hdr.Statement.Prompt, hpkelem.UniqueID) + "\""
315 | + " , \"" + HpkStrings.GetString(ifr_hdr.TextTwo, hpkelem.UniqueID) + "\""
316 | + " , Help = \"" + HpkStrings.GetString(ifr_hdr.Statement.Help, hpkelem.UniqueID) + "\"";
317 | }
318 | break;
319 | case EFI_IFR_OPCODE_e.EFI_IFR_IMAGE_OP: branch.Name = "Image Id = " + ((EFI_IFR_IMAGE)hpkelem.Header).Id; break;
320 | case EFI_IFR_OPCODE_e.EFI_IFR_ONE_OF_OP:
321 | {
322 | EFI_IFR_ONE_OF ifr_hdr = (EFI_IFR_ONE_OF)hpkelem.Header;
323 | branch.Name = "OneOf Flags = 0x" + ifr_hdr.Flags.ToString("X2");
324 | switch (ifr_hdr.Flags_DataSize)
325 | {
326 | case EFI_IFR_NUMERIC_SIZE_e.EFI_IFR_NUMERIC_SIZE_1:
327 | {
328 | EFI_IFR_NUMERIC_MINMAXSTEP_DATA_8 data = (EFI_IFR_NUMERIC_MINMAXSTEP_DATA_8)hpkelem.Payload;
329 | branch.Name += ", Min = " + data.MinValue.ToString() + ", Max = " + data.MaxValue.ToString() + ", Step = " + data.Step.ToString();
330 | }
331 | break;
332 | case EFI_IFR_NUMERIC_SIZE_e.EFI_IFR_NUMERIC_SIZE_2:
333 | {
334 | EFI_IFR_NUMERIC_MINMAXSTEP_DATA_16 data = (EFI_IFR_NUMERIC_MINMAXSTEP_DATA_16)hpkelem.Payload;
335 | branch.Name += ", Min = " + data.MinValue.ToString() + ", Max = " + data.MaxValue.ToString() + ", Step = " + data.Step.ToString();
336 | }
337 | break;
338 | case EFI_IFR_NUMERIC_SIZE_e.EFI_IFR_NUMERIC_SIZE_4:
339 | {
340 | EFI_IFR_NUMERIC_MINMAXSTEP_DATA_32 data = (EFI_IFR_NUMERIC_MINMAXSTEP_DATA_32)hpkelem.Payload;
341 | branch.Name += ", Min = " + data.MinValue.ToString() + ", Max = " + data.MaxValue.ToString() + ", Step = " + data.Step.ToString();
342 | }
343 | break;
344 | case EFI_IFR_NUMERIC_SIZE_e.EFI_IFR_NUMERIC_SIZE_8:
345 | {
346 | EFI_IFR_NUMERIC_MINMAXSTEP_DATA_64 data = (EFI_IFR_NUMERIC_MINMAXSTEP_DATA_64)hpkelem.Payload;
347 | branch.Name += ", Min = " + data.MinValue.ToString() + ", Max = " + data.MaxValue.ToString() + ", Step = " + data.Step.ToString();
348 | }
349 | break;
350 | default:
351 | branch.Name += ", Min = ?, Max = ?, Step = ?";
352 | CreateLogEntryParser(LogSeverity.WARNING, "Unknown numeric type [" + hpkelem.UniqueID + "]!");
353 | break;
354 | }
355 | branch.Childs.Add(new ParsedHpkNode(hpkelem, "OneOf-Question " + GetIfrQuestionInfoString(ifr_hdr.Question, hpkelem.UniqueID)));
356 | }
357 | break;
358 | case EFI_IFR_OPCODE_e.EFI_IFR_CHECKBOX_OP:
359 | {
360 | EFI_IFR_CHECKBOX ifr_hdr = (EFI_IFR_CHECKBOX)hpkelem.Header;
361 | branch.Name = "Checkbox Flags = " + ifr_hdr.Flags.ToString();
362 | branch.Childs.Add(new ParsedHpkNode(hpkelem, "Checkbox-Question " + GetIfrQuestionInfoString(ifr_hdr.Question, hpkelem.UniqueID)));
363 | }
364 | break;
365 | case EFI_IFR_OPCODE_e.EFI_IFR_NUMERIC_OP:
366 | {
367 | EFI_IFR_NUMERIC ifr_hdr = (EFI_IFR_NUMERIC)hpkelem.Header;
368 | branch.Name = "Numeric Flags = 0x" + ifr_hdr.Flags.ToString("X2");
369 | switch (ifr_hdr.Flags_DataSize)
370 | {
371 | case EFI_IFR_NUMERIC_SIZE_e.EFI_IFR_NUMERIC_SIZE_1:
372 | {
373 | EFI_IFR_NUMERIC_MINMAXSTEP_DATA_8 data = (EFI_IFR_NUMERIC_MINMAXSTEP_DATA_8)hpkelem.Payload;
374 | branch.Name += ", Min = " + data.MinValue.ToString() + ", Max = " + data.MaxValue.ToString() + ", Step = " + data.Step.ToString();
375 | }
376 | break;
377 | case EFI_IFR_NUMERIC_SIZE_e.EFI_IFR_NUMERIC_SIZE_2:
378 | {
379 | EFI_IFR_NUMERIC_MINMAXSTEP_DATA_16 data = (EFI_IFR_NUMERIC_MINMAXSTEP_DATA_16)hpkelem.Payload;
380 | branch.Name += ", Min = " + data.MinValue.ToString() + ", Max = " + data.MaxValue.ToString() + ", Step = " + data.Step.ToString();
381 | }
382 | break;
383 | case EFI_IFR_NUMERIC_SIZE_e.EFI_IFR_NUMERIC_SIZE_4:
384 | {
385 | EFI_IFR_NUMERIC_MINMAXSTEP_DATA_32 data = (EFI_IFR_NUMERIC_MINMAXSTEP_DATA_32)hpkelem.Payload;
386 | branch.Name += ", Min = " + data.MinValue.ToString() + ", Max = " + data.MaxValue.ToString() + ", Step = " + data.Step.ToString();
387 | }
388 | break;
389 | case EFI_IFR_NUMERIC_SIZE_e.EFI_IFR_NUMERIC_SIZE_8:
390 | {
391 | EFI_IFR_NUMERIC_MINMAXSTEP_DATA_64 data = (EFI_IFR_NUMERIC_MINMAXSTEP_DATA_64)hpkelem.Payload;
392 | branch.Name += ", Min = " + data.MinValue.ToString() + ", Max = " + data.MaxValue.ToString() + ", Step = " + data.Step.ToString();
393 | }
394 | break;
395 | default:
396 | branch.Name += ", Min = ?, Max = ?, Step = ?";
397 | CreateLogEntryParser(LogSeverity.WARNING, "Unknown numeric type [" + hpkelem.UniqueID + "]!");
398 | break;
399 | }
400 | branch.Childs.Add(new ParsedHpkNode(hpkelem, "Numeric-Question " + GetIfrQuestionInfoString(ifr_hdr.Question, hpkelem.UniqueID)));
401 | }
402 | break;
403 | case EFI_IFR_OPCODE_e.EFI_IFR_PASSWORD_OP:
404 | {
405 | EFI_IFR_PASSWORD ifr_hdr = (EFI_IFR_PASSWORD)hpkelem.Header;
406 | branch.Name = "Password "
407 | + "Min = " + ifr_hdr.MinSize.ToString()
408 | + ", Max = " + ifr_hdr.MaxSize.ToString();
409 | branch.Childs.Add(new ParsedHpkNode(hpkelem, "Password-Question " + GetIfrQuestionInfoString(ifr_hdr.Question, hpkelem.UniqueID)));
410 | }
411 | break;
412 | case EFI_IFR_OPCODE_e.EFI_IFR_ONE_OF_OPTION_OP:
413 | {
414 | EFI_IFR_ONE_OF_OPTION ifr_hdr = (EFI_IFR_ONE_OF_OPTION)hpkelem.Header;
415 | object dummy = null;
416 | branch.Name = "OneOf Option = " + ifr_hdr.Option.ToDecimalString(5) + " [\"" + HpkStrings.GetString(ifr_hdr.Option, hpkelem.UniqueID) + "\"]"
417 | + ", Flags = " + ifr_hdr.Flags.ToString()
418 | + ", " + HpkStrings.GetValueString(ifr_hdr.Type, hpkelem.Payload, hpkelem.UniqueID, ref dummy);
419 |
420 | // Parse nested value logic..
421 | if (ifr_hdr.Type == EFI_IFR_TYPE_e.EFI_IFR_TYPE_OTHER)
422 | {
423 | if (elem.Childs.Count < 2)
424 | CreateLogEntryParser(LogSeverity.WARNING, "Too few value opcodes [" + hpkelem.UniqueID + "]!");
425 | if (2 < elem.Childs.Count)
426 | CreateLogEntryParser(LogSeverity.WARNING, "Too many value opcodes [" + hpkelem.UniqueID + "]!");
427 | else
428 | {
429 | // Child index: 0 = Value opcode, 1 = END opcode
430 | ParsedHpkNode leaf = new ParsedHpkNode(elem.Childs[0], "Nested value = " + HpkStrings.GetIfrLogicString((HiiIfrOpCode)elem.Childs[0]));
431 | branch.Childs.Add(leaf);
432 | bProcessChilds = false;
433 | }
434 | }
435 | }
436 | break;
437 | case EFI_IFR_OPCODE_e.EFI_IFR_LOCKED_OP: branch.Name = "Locked"; break;
438 | case EFI_IFR_OPCODE_e.EFI_IFR_ACTION_OP:
439 | {
440 | branch.Name = "ActionButton";
441 | switch (hpkelem.Header.GetType().Name)
442 | {
443 | case "EFI_IFR_ACTION":
444 | {
445 | EFI_IFR_ACTION ifr_hdr = (EFI_IFR_ACTION)hpkelem.Header;
446 | if (ifr_hdr.QuestionConfig != 0)
447 | branch.Name += " Config = \"" + HpkStrings.GetString(ifr_hdr.QuestionConfig, hpkelem.UniqueID) + "\" ";
448 | branch.Childs.Add(new ParsedHpkNode(hpkelem, "ActionButton-Question " + GetIfrQuestionInfoString(ifr_hdr.Question, hpkelem.UniqueID)));
449 | }
450 | break;
451 | case "EFI_IFR_ACTION_1":
452 | {
453 | EFI_IFR_ACTION_1 ifr_hdr = (EFI_IFR_ACTION_1)hpkelem.Header;
454 | branch.Childs.Add(new ParsedHpkNode(hpkelem, "ActionButton-Question " + GetIfrQuestionInfoString(ifr_hdr.Question, hpkelem.UniqueID)));
455 | }
456 | break;
457 | default:
458 | branch.Name += "UNKNOWNTYPE";
459 | CreateLogEntryParser(LogSeverity.WARNING, "Unknown action type [" + hpkelem.UniqueID + "]!");
460 | break;
461 | }
462 | }
463 | break;
464 | case EFI_IFR_OPCODE_e.EFI_IFR_RESET_BUTTON_OP:
465 | {
466 | EFI_IFR_RESET_BUTTON ifr_hdr = (EFI_IFR_RESET_BUTTON)hpkelem.Header;
467 | branch.Name = "ResetButton "
468 | + ", Prompt = " + ifr_hdr.Statement.Prompt.ToDecimalString(5) + " [\"" + HpkStrings.GetString(ifr_hdr.Statement.Prompt, hpkelem.UniqueID) + "\"]"
469 | + ", Help = " + ifr_hdr.Statement.Help.ToDecimalString(5) + " [\"" + HpkStrings.GetString(ifr_hdr.Statement.Help, hpkelem.UniqueID) + "\"]"
470 | + ", DefaultId = " + ifr_hdr.DefaultId.ToDecimalString(5);
471 | }
472 | break;
473 | case EFI_IFR_OPCODE_e.EFI_IFR_DATE_OP:
474 | {
475 | EFI_IFR_DATE ifr_hdr = (EFI_IFR_DATE)hpkelem.Header;
476 | branch.Name = "Date Flags = 0x" + ifr_hdr.Flags.ToString("X2");
477 | branch.Childs.Add(new ParsedHpkNode(hpkelem, "Date-Question " + GetIfrQuestionInfoString(ifr_hdr.Question, hpkelem.UniqueID)));
478 | }
479 | break;
480 | case EFI_IFR_OPCODE_e.EFI_IFR_TIME_OP:
481 | {
482 | EFI_IFR_TIME ifr_hdr = (EFI_IFR_TIME)hpkelem.Header;
483 | branch.Name = "Time Flags = 0x" + ifr_hdr.Flags.ToString("X2");
484 | branch.Childs.Add(new ParsedHpkNode(hpkelem, "Time-Question " + GetIfrQuestionInfoString(ifr_hdr.Question, hpkelem.UniqueID)));
485 | }
486 | break;
487 | case EFI_IFR_OPCODE_e.EFI_IFR_STRING_OP:
488 | {
489 | EFI_IFR_STRING ifr_hdr = (EFI_IFR_STRING)hpkelem.Header;
490 | branch.Name = "String "
491 | + "Min = " + ifr_hdr.MinSize.ToString()
492 | + ", Max = " + ifr_hdr.MaxSize.ToString()
493 | + ", Flags = " + ifr_hdr.Flags.ToString();
494 | branch.Childs.Add(new ParsedHpkNode(hpkelem, "String-Question " + GetIfrQuestionInfoString(ifr_hdr.Question, hpkelem.UniqueID)));
495 | }
496 | break;
497 | case EFI_IFR_OPCODE_e.EFI_IFR_REFRESH_OP: branch.Name = "Refresh Interval = " + ((EFI_IFR_REFRESH)hpkelem.Header).RefreshInterval.ToString(); break;
498 | case EFI_IFR_OPCODE_e.EFI_IFR_ANIMATION_OP: branch.Name = "Animation Id = " + ((EFI_IFR_ANIMATION)hpkelem.Header).Id.ToString(); break;
499 | case EFI_IFR_OPCODE_e.EFI_IFR_ORDERED_LIST_OP:
500 | {
501 | EFI_IFR_ORDERED_LIST ifr_hdr = (EFI_IFR_ORDERED_LIST)hpkelem.Header;
502 | branch.Name = "OrderedList "
503 | + "MaxContainers = " + ifr_hdr.MaxContainers.ToString()
504 | + ", Flags = " + ifr_hdr.Flags.ToString();
505 | branch.Childs.Add(new ParsedHpkNode(hpkelem, "OrderedList-Question " + GetIfrQuestionInfoString(ifr_hdr.Question, hpkelem.UniqueID)));
506 | }
507 | break;
508 | //EFI_IFR_READ_OP // Unclear what it does, therefore no implementation by now. If you know it, let me know ;)
509 | //EFI_IFR_WRITE_OP, // Unclear what it does, therefore no implementation by now. If you know it, let me know ;)
510 | #endregion
511 |
512 | #region Values
513 | case EFI_IFR_OPCODE_e.EFI_IFR_UINT8_OP: branch.Name = "UINT8 Value = 0x" + ((EFI_IFR_UINT8)hpkelem.Header).Value.ToString("X2"); break;
514 | case EFI_IFR_OPCODE_e.EFI_IFR_UINT16_OP: branch.Name = "UINT16 Value = 0x" + ((EFI_IFR_UINT16)hpkelem.Header).Value.ToString("X4"); break;
515 | case EFI_IFR_OPCODE_e.EFI_IFR_UINT32_OP: branch.Name = "UINT32 Value = 0x" + ((EFI_IFR_UINT32)hpkelem.Header).Value.ToString("X8"); break;
516 | case EFI_IFR_OPCODE_e.EFI_IFR_UINT64_OP: branch.Name = "UINT64 Value = 0x" + ((EFI_IFR_UINT64)hpkelem.Header).Value.ToString("X16"); break;
517 | case EFI_IFR_OPCODE_e.EFI_IFR_VALUE_OP: branch.Name = "Value"; break;
518 | case EFI_IFR_OPCODE_e.EFI_IFR_DEFAULT_OP:
519 | {
520 | EFI_IFR_DEFAULT ifr_hdr = (EFI_IFR_DEFAULT)hpkelem.Header;
521 | object dummy = null;
522 | branch.Name = "Default Id = " + ifr_hdr.DefaultId.ToDecimalString(5)
523 | + ", " + HpkStrings.GetValueString(ifr_hdr.Type, hpkelem.Payload, hpkelem.UniqueID, ref dummy);
524 |
525 | // Parse nested value logic..
526 | if (ifr_hdr.Type == EFI_IFR_TYPE_e.EFI_IFR_TYPE_OTHER)
527 | {
528 | if (elem.Childs.Count < 2)
529 | CreateLogEntryParser(LogSeverity.WARNING, "Too few value opcodes [" + hpkelem.UniqueID + "]!");
530 | if (2 < elem.Childs.Count)
531 | CreateLogEntryParser(LogSeverity.WARNING, "Too many value opcodes [" + hpkelem.UniqueID + "]!");
532 | else
533 | {
534 | // Child index: 0 = Value opcode, 1 = END opcode
535 | ParsedHpkNode leaf = new ParsedHpkNode(elem.Childs[0], "Nested value = " + HpkStrings.GetIfrLogicString((HiiIfrOpCode)elem.Childs[0]));
536 | branch.Childs.Add(leaf);
537 | bProcessChilds = false;
538 | }
539 | }
540 | }
541 | break;
542 | #endregion
543 |
544 | case EFI_IFR_OPCODE_e.EFI_IFR_END_OP: return; // Skip
545 | default: break; // simply add all others 1:1 when no specific handler exists
546 | }
547 |
548 | if (bProcessChilds)
549 | foreach (HiiIfrOpCode child in elem.Childs)
550 | ParsePackageIfr(child, branch);
551 |
552 | root.Childs.Add(branch);
553 | }
554 |
555 | ///
556 | /// Builds humand readable string of an IFR question header
557 | ///
558 | /// Input IFR question header
559 | /// ID of the requesting HPK element (for reference on errors)
560 | /// Humand readable string
561 | private string GetIfrQuestionInfoString(EFI_IFR_QUESTION_HEADER Question, int UniqueID)
562 | {
563 | return "Id = " + Question.QuestionId.ToDecimalString(5)
564 | + ", Prompt = " + Question.Header.Prompt.ToDecimalString(5) + " [\"" + HpkStrings.GetString(Question.Header.Prompt, UniqueID) + "\"]"
565 | + ", Help = " + Question.Header.Help.ToDecimalString(5) + " [\"" + HpkStrings.GetString(Question.Header.Help, UniqueID) + "\"]"
566 | + ", Flags = " + Question.Flags
567 | + ", VarId = " + Question.VarStoreId.ToDecimalString(5)
568 | + ", Offset/Name = " + Question.VarStoreInfo.VarOffset.ToDecimalString(5);
569 | }
570 | }
571 | }
572 |
--------------------------------------------------------------------------------
/PrepareRelease.bat:
--------------------------------------------------------------------------------
1 | @echo off
2 |
3 | REM MIT License
4 |
5 | REM Copyright(c) 2019 Peter Kirmeier
6 |
7 | REM Permission is hereby granted, free of charge, to any person obtaining a copy
8 | REM of this software and associated documentation files (the "Software"), to deal
9 | REM in the Software without restriction, including without limitation the rights
10 | REM to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 | REM copies of the Software, and to permit persons to whom the Software is
12 | REM furnished to do so, subject to the following conditions:
13 |
14 | REM The above copyright notice and this permission notice shall be included in all
15 | REM copies or substantial portions of the Software.
16 |
17 | REM THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 | REM IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 | REM FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 | REM AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 | REM LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 | REM OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23 | REM SOFTWARE.
24 |
25 | echo PrepareRelease.bat START ===========
26 |
27 | REM To run this script you need to have 7zip installed at the default path
28 | REM or you have to update the path:
29 |
30 | set PATH=%PATH%;C:\Program Files\7-Zip
31 | set PR_FINAL=FinalFiles
32 | if not exist %PR_FINAL% mkdir %PR_FINAL%
33 |
34 | echo Packing Portable Release:
35 | set PR_BASE=bin\Release
36 | set PR_TARGET=%PR_FINAL%\ReleasePortable
37 | set PR_OUTPUT=%PR_FINAL%\IfrViewer_Portable_v1.x.y.z.zip
38 | rmdir /S /Q %PR_TARGET% 2>nul
39 | mkdir %PR_TARGET%
40 |
41 | echo ^ ^ Copy files from %PR_BASE%
42 | FOR %%G IN (IfrViewer.exe) DO copy %PR_BASE%\%%G %PR_TARGET%
43 |
44 | del %PR_OUTPUT% 2>nul
45 | 7z a %PR_OUTPUT% .\%PR_TARGET%\*
46 |
47 | echo PrepareRelease.bat END ===========
48 |
--------------------------------------------------------------------------------
/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // Allgemeine Informationen über eine Assembly werden über die folgenden
6 | // Attribute gesteuert. Ändern Sie diese Attributwerte, um die Informationen zu ändern,
7 | // die einer Assembly zugeordnet sind.
8 | [assembly: AssemblyTitle("IfrViewer")]
9 | [assembly: AssemblyDescription("Viewer for IFR structures")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("Peter Kirmeier")]
12 | [assembly: AssemblyProduct("IfrViewer")]
13 | [assembly: AssemblyCopyright("Copyright © Peter Kirmeier 2019")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Durch Festlegen von ComVisible auf "false" werden die Typen in dieser Assembly unsichtbar
18 | // für COM-Komponenten. Wenn Sie auf einen Typ in dieser Assembly von
19 | // COM aus zugreifen müssen, sollten Sie das ComVisible-Attribut für diesen Typ auf "True" festlegen.
20 | [assembly: ComVisible(false)]
21 |
22 | // Die folgende GUID bestimmt die ID der Typbibliothek, wenn dieses Projekt für COM verfügbar gemacht wird
23 | [assembly: Guid("3eb0141d-bbaf-489c-812c-2411ae0c0183")]
24 |
25 | // Versionsinformationen für eine Assembly bestehen aus den folgenden vier Werten:
26 | //
27 | // Hauptversion
28 | // Nebenversion
29 | // Buildnummer
30 | // Revision
31 | //
32 | // Sie können alle Werte angeben oder die standardmäßigen Build- und Revisionsnummern
33 | // übernehmen, indem Sie "*" eingeben:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("0.8.0.0")]
36 | [assembly: AssemblyFileVersion("0.8.0.0")]
37 |
--------------------------------------------------------------------------------
/Properties/Resources.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // Dieser Code wurde von einem Tool generiert.
4 | // Laufzeitversion:4.0.30319.42000
5 | //
6 | // Änderungen an dieser Datei können falsches Verhalten verursachen und gehen verloren, wenn
7 | // der Code erneut generiert wird.
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | namespace IfrViewer.Properties {
12 | using System;
13 |
14 |
15 | ///
16 | /// Eine stark typisierte Ressourcenklasse zum Suchen von lokalisierten Zeichenfolgen usw.
17 | ///
18 | // Diese Klasse wurde von der StronglyTypedResourceBuilder automatisch generiert
19 | // -Klasse über ein Tool wie ResGen oder Visual Studio automatisch generiert.
20 | // Um einen Member hinzuzufügen oder zu entfernen, bearbeiten Sie die .ResX-Datei und führen dann ResGen
21 | // mit der /str-Option erneut aus, oder Sie erstellen Ihr VS-Projekt neu.
22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
25 | internal class Resources {
26 |
27 | private static global::System.Resources.ResourceManager resourceMan;
28 |
29 | private static global::System.Globalization.CultureInfo resourceCulture;
30 |
31 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
32 | internal Resources() {
33 | }
34 |
35 | ///
36 | /// Gibt die zwischengespeicherte ResourceManager-Instanz zurück, die von dieser Klasse verwendet wird.
37 | ///
38 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
39 | internal static global::System.Resources.ResourceManager ResourceManager {
40 | get {
41 | if (object.ReferenceEquals(resourceMan, null)) {
42 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("IfrViewer.Properties.Resources", typeof(Resources).Assembly);
43 | resourceMan = temp;
44 | }
45 | return resourceMan;
46 | }
47 | }
48 |
49 | ///
50 | /// Überschreibt die CurrentUICulture-Eigenschaft des aktuellen Threads für alle
51 | /// Ressourcenzuordnungen, die diese stark typisierte Ressourcenklasse verwenden.
52 | ///
53 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
54 | internal static global::System.Globalization.CultureInfo Culture {
55 | get {
56 | return resourceCulture;
57 | }
58 | set {
59 | resourceCulture = value;
60 | }
61 | }
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/Properties/Resources.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 | text/microsoft-resx
107 |
108 |
109 | 2.0
110 |
111 |
112 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
113 |
114 |
115 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
--------------------------------------------------------------------------------
/Properties/Settings.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // Dieser Code wurde von einem Tool generiert.
4 | // Laufzeitversion:4.0.30319.42000
5 | //
6 | // Änderungen an dieser Datei können falsches Verhalten verursachen und gehen verloren, wenn
7 | // der Code erneut generiert wird.
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | namespace IfrViewer.Properties {
12 |
13 |
14 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
15 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "14.0.0.0")]
16 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
17 |
18 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
19 |
20 | public static Settings Default {
21 | get {
22 | return defaultInstance;
23 | }
24 | }
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/Properties/Settings.settings:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # IfrViewer
2 |
3 | **IN DEVELOPMENT - Subject to change!**
4 |
5 |
6 | Tool that is able to read a binary HPK package and most (hopefully all in future) of its HII and IFR structures.
7 | > A HPK file (used by [EDKII](https://github.com/tianocore/edk2)) holds so called HII packages (__Human Interface Infrastructure__).
8 | > The content of such a file follows the kind of file structure definition from [UEFI specification](http://uefi.org/specifications).
9 | > It can consist of many various things but in most cases it consists of strings for different languages
10 | > and IFR structures (__Internal Forms Representation__) to be able to build the SETUP menu for UEFI capable systems.
11 |
12 | [](../../releases/latest)
13 | [](../../releases)
14 | [](LICENSE)
15 |
16 | ## Goals
17 | 1. List all IFR structures in order to view a HPK's content
18 | 2. Improve GUI to handle this data more efficient
19 | 3. Create HTML pages which can be viewed by standard web browser showing the skeleton of the HPK's forms
20 |
21 | ## Get the software
22 | All available releases can be found at the [Releases page](../../releases) on GitHub.
23 |
24 | ## Systemrequirements
25 | .Net Framework 4.5
26 |
27 | ## Front-End
28 | > Please visit the **[Wiki pages](../../wiki)** for some screenshots.
29 |
30 | ## Anything is missing, something is annoying/can be improved or you just found a bug?
31 | Message me via GitHub / e-mail or simply open an issue and I will try to help you out.
32 |
33 |
34 |
35 | > Praise the sun! :sunny: . . . :fire: . . . :running: :dash:
36 |
--------------------------------------------------------------------------------
/THIRDPARTYLICENSEREADME:
--------------------------------------------------------------------------------
1 | Licence information:
2 |
3 | The software aims to only use licenses that allow commercial and non-commercial use.
4 | Moreover it aims to use the whole software without any charge.
5 | Therefore it should be free for everyone to use it without any costs.
6 | DISCLAIMER: Above notice comes without warranty, so please refer to the explicit licenses below.
7 |
8 | ==============================================================================
9 | Application
10 |
11 | Title: IfrViewer
12 | Author: Peter Kirmeier
13 | Source: https://github.com/topeterk/IfrViewer
14 | Licence: MIT https://opensource.org/licenses/MIT
15 |
16 | ==============================================================================
17 | Application Icon
18 |
19 | Title: -
20 | Author: icons8.com
21 | Source: https://icons8.com/
22 | Licence: CC BY-ND 3.0 https://creativecommons.org/licenses/by-nd/3.0/
23 |
--------------------------------------------------------------------------------
/test_files/BootManagerUiLib.uni:
--------------------------------------------------------------------------------
1 | // /** @file
2 | // Boot Manager Library used by UiApp.
3 | //
4 | // Boot Manager Library used by UiApp.
5 | //
6 | // Copyright (c) 2015, Intel Corporation. All rights reserved.
7 | //
8 | // This program and the accompanying materials are licensed and made available under
9 | // the terms and conditions of the BSD License that accompanies this distribution.
10 | // The full text of the license may be found at
11 | // http://opensource.org/licenses/bsd-license.php.
12 | //
13 | // THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
14 | // WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
15 | //
16 | // **/
17 |
18 | #string STR_MODULE_ABSTRACT
19 | #language en-US
20 | "Boot Manager Library used by UiApp."
21 |
22 | #string STR_MODULE_DESCRIPTION
23 | #language en-US
24 | "Boot Manager Library used by UiApp."
25 |
26 |
27 |
--------------------------------------------------------------------------------
/test_files/BootManagerUiLibStrDefs.hpk:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/topeterk/IfrViewer/3a2f39275161d2a03f99d6ca78f73e93cf91aa1f/test_files/BootManagerUiLibStrDefs.hpk
--------------------------------------------------------------------------------
/test_files/BootManagerVfr.Vfr:
--------------------------------------------------------------------------------
1 | ///** @file
2 | //
3 | // Boot Manager formset.
4 | //
5 | // Copyright (c) 2004 - 2015, Intel Corporation. All rights reserved.
6 | // This program and the accompanying materials
7 | // are licensed and made available under the terms and conditions of the BSD License
8 | // which accompanies this distribution. The full text of the license may be found at
9 | // http://opensource.org/licenses/bsd-license.php
10 | //
11 | // THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12 | // WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
13 | //
14 | //**/
15 | #define FORMSET_GUID { 0x847bc3fe, 0xb974, 0x446d, 0x94, 0x49, 0x5a, 0xd5, 0x41, 0x2e, 0x99, 0x3b }
16 |
17 | #define BOOT_MANAGER_FORM_ID 0x1000
18 |
19 | #define LABEL_BOOT_OPTION 0x00
20 | #define LABEL_BOOT_OPTION_END 0x01
21 |
22 | formset
23 | guid = FORMSET_GUID,
24 | title = STRING_TOKEN(STR_BM_BANNER),
25 | help = STRING_TOKEN(STR_BOOT_MANAGER_HELP),
26 | classguid = gEfiIfrFrontPageGuid,
27 |
28 | form formid = BOOT_MANAGER_FORM_ID,
29 | title = STRING_TOKEN(STR_BM_BANNER);
30 |
31 | subtitle text = STRING_TOKEN(STR_LAST_STRING);
32 | subtitle text = STRING_TOKEN(STR_BOOT_OPTION_BANNER);
33 | subtitle text = STRING_TOKEN(STR_LAST_STRING);
34 |
35 | //
36 | //Add this invisable text in order to indicate enter Boot Manager form.
37 | //
38 | suppressif TRUE;
39 | text
40 | help = STRING_TOKEN(STR_LAST_STRING ),
41 | text = STRING_TOKEN(STR_LAST_STRING ),
42 | flags = INTERACTIVE,
43 | key = 0x1212;
44 | endif;
45 |
46 | //
47 | // This is where we will dynamically add choices for the Boot Manager
48 | //
49 | label LABEL_BOOT_OPTION;
50 | label LABEL_BOOT_OPTION_END;
51 |
52 | subtitle text = STRING_TOKEN(STR_LAST_STRING);
53 | subtitle text = STRING_TOKEN(STR_HELP_FOOTER);
54 |
55 | endform;
56 |
57 | endformset;
58 |
--------------------------------------------------------------------------------
/test_files/BootManagerVfr.hpk:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/topeterk/IfrViewer/3a2f39275161d2a03f99d6ca78f73e93cf91aa1f/test_files/BootManagerVfr.hpk
--------------------------------------------------------------------------------
/test_files/BootManagerVfr.i:
--------------------------------------------------------------------------------
1 | #line 1 "c:\\uefi\\edk2\\MdeModulePkg\\Library\\BootManagerUiLib\\BootManagerVfr.Vfr"
2 | #line 1 "c:\\uefi\\edk2\\Build\\NT32IA32\\DEBUG_VS2015x86\\IA32\\MdeModulePkg\\Library\\BootManagerUiLib\\BootManagerUiLib\\DEBUG\\BootManagerUiLibStrDefs.h"
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 | extern unsigned char BootManagerUiLibStrings[];
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 | #line 37 "c:\\uefi\\edk2\\Build\\NT32IA32\\DEBUG_VS2015x86\\IA32\\MdeModulePkg\\Library\\BootManagerUiLib\\BootManagerUiLib\\DEBUG\\BootManagerUiLibStrDefs.h"
39 |
40 | #line 39 "c:\\uefi\\edk2\\Build\\NT32IA32\\DEBUG_VS2015x86\\IA32\\MdeModulePkg\\Library\\BootManagerUiLib\\BootManagerUiLib\\DEBUG\\BootManagerUiLibStrDefs.h"
41 | #line 1 "c:\\uefi\\edk2\\MdeModulePkg\\Library\\BootManagerUiLib\\BootManagerVfr.Vfr"
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 | formset
64 | guid = { 0x847bc3fe, 0xb974, 0x446d, 0x94, 0x49, 0x5a, 0xd5, 0x41, 0x2e, 0x99, 0x3b },
65 | title = STRING_TOKEN(0x0002),
66 | help = STRING_TOKEN(0x0003),
67 | classguid = { 0xe58809f8, 0xfbc1, 0x48e2, { 0x88, 0x3a, 0xa3, 0x0f, 0xdc, 0x4b, 0x44, 0x1e } },
68 |
69 | form formid = 0x1000,
70 | title = STRING_TOKEN(0x0002);
71 |
72 | subtitle text = STRING_TOKEN(0x0007);
73 | subtitle text = STRING_TOKEN(0x0005);
74 | subtitle text = STRING_TOKEN(0x0007);
75 |
76 |
77 |
78 |
79 | suppressif TRUE;
80 | text
81 | help = STRING_TOKEN(0x0007 ),
82 | text = STRING_TOKEN(0x0007 ),
83 | flags = INTERACTIVE,
84 | key = 0x1212;
85 | endif;
86 |
87 |
88 |
89 |
90 | label 0x00;
91 | label 0x01;
92 |
93 | subtitle text = STRING_TOKEN(0x0007);
94 | subtitle text = STRING_TOKEN(0x0004);
95 |
96 | endform;
97 |
98 | endformset;
99 |
--------------------------------------------------------------------------------
/test_files/BootManagerVfr.lst:
--------------------------------------------------------------------------------
1 | //
2 | // VFR compiler version 2.01 (UEFI 2.4)
3 | //
4 | #line 1 "c:\\uefi\\edk2\\MdeModulePkg\\Library\\BootManagerUiLib\\BootManagerVfr.Vfr"
5 | #line 1 "c:\\uefi\\edk2\\Build\\NT32IA32\\DEBUG_VS2015x86\\IA32\\MdeModulePkg\\Library\\BootManagerUiLib\\BootManagerUiLib\\DEBUG\\BootManagerUiLibStrDefs.h"
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 | extern unsigned char BootManagerUiLibStrings[];
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 | #line 37 "c:\\uefi\\edk2\\Build\\NT32IA32\\DEBUG_VS2015x86\\IA32\\MdeModulePkg\\Library\\BootManagerUiLib\\BootManagerUiLib\\DEBUG\\BootManagerUiLibStrDefs.h"
42 |
43 | #line 39 "c:\\uefi\\edk2\\Build\\NT32IA32\\DEBUG_VS2015x86\\IA32\\MdeModulePkg\\Library\\BootManagerUiLib\\BootManagerUiLib\\DEBUG\\BootManagerUiLibStrDefs.h"
44 | #line 1 "c:\\uefi\\edk2\\MdeModulePkg\\Library\\BootManagerUiLib\\BootManagerVfr.Vfr"
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 | formset
67 | >00000000: 0E A7 FE C3 7B 84 74 B9 6D 44 94 49 5A D5 41 2E 99 3B 02 00 03 00 01 F8 09 88 E5 C1 FB E2 48 88 3A A3 0F DC 4B 44 1E
68 | >00000027: 5C 06 00 00 00 00
69 | >0000002D: 5C 06 00 00 01 00
70 | guid = { 0x847bc3fe, 0xb974, 0x446d, 0x94, 0x49, 0x5a, 0xd5, 0x41, 0x2e, 0x99, 0x3b },
71 | title = STRING_TOKEN(0x0002),
72 | help = STRING_TOKEN(0x0003),
73 | classguid = { 0xe58809f8, 0xfbc1, 0x48e2, { 0x88, 0x3a, 0xa3, 0x0f, 0xdc, 0x4b, 0x44, 0x1e } },
74 |
75 | form formid = 0x1000,
76 | >00000033: 01 86 00 10 02 00
77 | title = STRING_TOKEN(0x0002);
78 |
79 | subtitle text = STRING_TOKEN(0x0007);
80 | >00000039: 02 87 07 00 00 00 00
81 | >00000040: 29 02
82 | subtitle text = STRING_TOKEN(0x0005);
83 | >00000042: 02 87 05 00 00 00 00
84 | >00000049: 29 02
85 | subtitle text = STRING_TOKEN(0x0007);
86 | >0000004B: 02 87 07 00 00 00 00
87 | >00000052: 29 02
88 |
89 |
90 |
91 |
92 | suppressif TRUE;
93 | >00000054: 0A 82
94 | >00000056: 46 02
95 | text
96 | help = STRING_TOKEN(0x0007 ),
97 | text = STRING_TOKEN(0x0007 ),
98 | flags = INTERACTIVE,
99 | >00000058: 0C 8F 07 00 07 00 12 12 00 00 FF FF 04 00 00
100 | key = 0x1212;
101 | >00000067: 29 02
102 | endif;
103 | >00000069: 29 02
104 |
105 |
106 |
107 |
108 | label 0x00;
109 | >0000006B: 5F 15 35 17 0B 0F A0 87 93 41 B2 66 53 8C 38 AF 48 CE 00 00 00
110 | label 0x01;
111 | >00000080: 5F 15 35 17 0B 0F A0 87 93 41 B2 66 53 8C 38 AF 48 CE 00 01 00
112 |
113 | subtitle text = STRING_TOKEN(0x0007);
114 | >00000095: 02 87 07 00 00 00 00
115 | >0000009C: 29 02
116 | subtitle text = STRING_TOKEN(0x0004);
117 | >0000009E: 02 87 04 00 00 00 00
118 | >000000A5: 29 02
119 |
120 | endform;
121 | >000000A7: 29 02
122 |
123 | endformset;
124 | >000000A9: 29 02
125 |
126 | //
127 | // All Opcode Record List
128 | //
129 | >00000000: 0E A7 FE C3 7B 84 74 B9 6D 44 94 49 5A D5 41 2E 99 3B 02 00 03 00 01 F8 09 88 E5 C1 FB E2 48 88 3A A3 0F DC 4B 44 1E
130 | >00000027: 5C 06 00 00 00 00
131 | >0000002D: 5C 06 00 00 01 00
132 | >00000033: 01 86 00 10 02 00
133 | >00000039: 02 87 07 00 00 00 00
134 | >00000040: 29 02
135 | >00000042: 02 87 05 00 00 00 00
136 | >00000049: 29 02
137 | >0000004B: 02 87 07 00 00 00 00
138 | >00000052: 29 02
139 | >00000054: 0A 82
140 | >00000056: 46 02
141 | >00000058: 0C 8F 07 00 07 00 12 12 00 00 FF FF 04 00 00
142 | >00000067: 29 02
143 | >00000069: 29 02
144 | >0000006B: 5F 15 35 17 0B 0F A0 87 93 41 B2 66 53 8C 38 AF 48 CE 00 00 00
145 | >00000080: 5F 15 35 17 0B 0F A0 87 93 41 B2 66 53 8C 38 AF 48 CE 00 01 00
146 | >00000095: 02 87 07 00 00 00 00
147 | >0000009C: 29 02
148 | >0000009E: 02 87 04 00 00 00 00
149 | >000000A5: 29 02
150 | >000000A7: 29 02
151 | >000000A9: 29 02
152 |
153 | Total Size of all record is 0x000000AB
154 |
155 |
156 | ***************************************************************
157 | mPackAlign = 8
158 | struct EFI_HII_REF : mAlign [16] mTotalSize [0x16]
159 |
160 | struct EFI_HII_REF {
161 | +00000000[00000000] QuestionId
162 | +00000002[00000002] FormId
163 | +00000004[00000004] FormSetGuid <(null)>
164 | +00000020[00000014] DevicePath
165 | };
166 | ---------------------------------------------------------------
167 | struct EFI_HII_TIME : mAlign [1] mTotalSize [0x3]
168 |
169 | struct EFI_HII_TIME {
170 | +00000000[00000000] Hours
171 | +00000001[00000001] Minutes
172 | +00000002[00000002] Seconds
173 | };
174 | ---------------------------------------------------------------
175 | struct EFI_STRING_ID : mAlign [2] mTotalSize [0x2]
176 |
177 | struct EFI_STRING_ID {
178 | };
179 | ---------------------------------------------------------------
180 | struct EFI_HII_DATE : mAlign [2] mTotalSize [0x4]
181 |
182 | struct EFI_HII_DATE {
183 | +00000000[00000000] Year
184 | +00000002[00000002] Month
185 | +00000003[00000003] Day
186 | };
187 | ---------------------------------------------------------------
188 | struct BOOLEAN : mAlign [1] mTotalSize [0x1]
189 |
190 | struct BOOLEAN {
191 | };
192 | ---------------------------------------------------------------
193 | struct UINT8 : mAlign [1] mTotalSize [0x1]
194 |
195 | struct UINT8 {
196 | };
197 | ---------------------------------------------------------------
198 | struct UINT16 : mAlign [2] mTotalSize [0x2]
199 |
200 | struct UINT16 {
201 | };
202 | ---------------------------------------------------------------
203 | struct UINT32 : mAlign [4] mTotalSize [0x4]
204 |
205 | struct UINT32 {
206 | };
207 | ---------------------------------------------------------------
208 | struct UINT64 : mAlign [8] mTotalSize [0x8]
209 |
210 | struct UINT64 {
211 | };
212 | ---------------------------------------------------------------
213 | ***************************************************************
214 |
--------------------------------------------------------------------------------
/test_files/edk2/Guid/HiiFormMapMethodGuid.h:
--------------------------------------------------------------------------------
1 | /** @file
2 | Guid used to identify HII FormMap configuration method.
3 | Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.
4 | SPDX-License-Identifier: BSD-2-Clause-Patent
5 | @par Revision Reference:
6 | GUID defined in UEFI 2.2 spec.
7 | **/
8 |
9 | #ifndef __EFI_HII_FORMMAP_GUID_H__
10 | #define __EFI_HII_FORMMAP_GUID_H__
11 |
12 | #define EFI_HII_STANDARD_FORM_GUID \
13 | { 0x3bd2f4ec, 0xe524, 0x46e4, { 0xa9, 0xd8, 0x51, 0x1, 0x17, 0x42, 0x55, 0x62 } }
14 |
15 | extern EFI_GUID gEfiHiiStandardFormGuid;
16 |
17 | #endif
--------------------------------------------------------------------------------
/test_files/vfrcomp.bat:
--------------------------------------------------------------------------------
1 | C:\UEFI\edk2\BaseTools\Bin\Win32\VfrCompile.exe -l -b -s BootManagerUiLibStrDefs.hpk BootManagerVfr.i
2 |
--------------------------------------------------------------------------------