Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "xmlcli"
version = "2.0.5"
version = "2.0.6"
description = "UFFAF - UEFI Firmware Foundational Automation Framework (formerly Xml-Cli)"
authors = ["Gahan Saraya <[email protected]>"]
maintainers = ["Intel <[email protected]>"]
Expand Down Expand Up @@ -55,3 +55,4 @@ indent-size = 2

[tool.poetry.scripts]
xmlcli = { reference = "xmlcli.start_xmlcli:cli", type = "console" }
uefi-analyze = { reference = "xmlcli.modules.uefi_analyzer.cli:main", type = "console" }
2 changes: 1 addition & 1 deletion src/xmlcli/_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def __str__(self):
# MINOR ------------
MINOR = 0
# BUILD ------
BUILD = 5 # or __revision__
BUILD = 6 # or __revision__
# TAG -------
TAG = ""

Expand Down
5 changes: 3 additions & 2 deletions src/xmlcli/common/bios_fw_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -710,9 +710,10 @@ def write_result_to_file(self, file_path, **kwargs):
}
try:
import xmlcli
output_dict["module_version"] = xmlcli._version.__version__.vstring
ver = xmlcli._version.__version__
output_dict["module_version"] = ver.vstring if hasattr(ver, 'vstring') else str(ver)
del xmlcli
except ImportError or AttributeError:
except (ImportError, AttributeError):
pass

with open(file_path, "w") as f:
Expand Down
48 changes: 48 additions & 0 deletions src/xmlcli/modules/uefi_analyzer/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# UEFI Firmware Analyzer

The UEFI Firmware Analyzer is a comprehensive tool within the `xml-cli` framework designed to parse, analyze, and visualize the structure and space utilization of UEFI firmware binaries.

## Features

- **Physical Flash Analysis**: Calculates space occupancy based on the actual flash layout (32MB/16MB/etc).
- **Deep Analysis Mode**: Visualizes decompressed components, providing a "logical" view of the firmware (often exceeding the physical size due to decompression).
- **Interactive Dashboard**: A self-contained HTML report with dynamic charts, progress bars for every level of hierarchy, and real-time search.
- **Smart Search**: Search by Driver Name, GUID, or `FileNameString`. Matching items are automatically expanded for easy discovery.
- **Address Mapping**: Displays absolute hexadecimal start and end address ranges for every component in the hierarchy.

## Quick Start

### 1. Command Line (Unified Flow)
You can analyze a **binary firmware** or an **existing JSON report** in one command:
```powershell
# Run the analysis (if installed in environment)
uefi-analyze "C:\path\to\bios.bin"
```
*Note: This generates the JSON, calculates metrics, and automatically opens your browser.*

### 2. Windows Context Menu
Analyze any `.bin`, `.rom`, `.fd`, or `.json` file directly from Windows Explorer:
1. **Install Menu**: Run `python src/xmlcli/modules/winContextMenu/install_context_menu.py`.
2. **Right-Click**: Select `XmlCli Menu` > `Analyze UEFI Firmware and View`.
3. **Result**: The tool detects the file type and opens the interactive dashboard immediately.

## Advanced Workflow

If you need to perform steps manually:

### Step 1: Parse the Binary to JSON
```python
from xmlcli.common.bios_fw_parser import UefiParser
parser = UefiParser(bin_file="path/to/bios.bin")
output_dict = parser.parse_binary()
parser.write_result_to_file("output.json", output_dict=output_dict)
```

### Step 2: Generate the Analysis Dashboard
```powershell
uefi-analyze "C:\path\to\output.json"
```

## Output Locations
Results (JSON and HTML) are saved to:
- `C:\Users\<user>\AppData\Local\Temp\XmlCliOut\logs\result\analytic_view\`
4 changes: 4 additions & 0 deletions src/xmlcli/modules/uefi_analyzer/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# coding=utf-8
"""
UEFI Analyzer Module
"""
50 changes: 50 additions & 0 deletions src/xmlcli/modules/uefi_analyzer/analyze_view.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# coding=utf-8
"""
Entry point for BIOS Analysis and View Generation
"""
import os
import sys
import argparse
import tempfile
from xmlcli.modules.uefi_analyzer import bios_analyzer
from xmlcli.modules.uefi_analyzer import report_generator
from xmlcli.common import configurations

def main():
parser = argparse.ArgumentParser(description="BIOS Analysis View Generator")
parser.add_argument("json_files", nargs="+", help="JSON files produced by UefiParser")
parser.add_argument("--output-dir", help="Directory to store analysis results")
args = parser.parse_args()

# Determine output directory
# User requested temp workspace in LOG_FILE_LOCATION as directory result analytic_view
# Based on configurations.py and logger.py, we can construct this.

log_dir = os.path.join(configurations.OUT_DIR, "logs")
default_output_dir = os.path.join(log_dir, "result", "analytic_view")

# Also consider the temp workspace as requested
temp_workspace = os.path.join(tempfile.gettempdir(), "XmlCliOut", "logs", "result", "analytic_view")

output_dir = args.output_dir or temp_workspace

if not os.path.exists(output_dir):
os.makedirs(output_dir)

print(f"Analyzing {len(args.json_files)} files...")
analyzer = bios_analyzer.BiosAnalyzer(args.json_files)
analysis_results = analyzer.analyze_all()

# Save the raw analysis JSONs
analyzer.save_analysis(output_dir)

# Generate the HTML dashboard
report_file = os.path.join(output_dir, "dashboard.html")
report_generator.generate_report(analysis_results, report_file)

print(f"Analysis complete.")
print(f"Results saved to: {output_dir}")
print(f"Dashboard available at: {report_file}")

if __name__ == "__main__":
main()
Loading