Skip to content

link1nk/BadUefi

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

BadUefi 🍎

BadUefi is a UEFI application designed to decode and render MPEG-1 video directly in the pre-boot environment (before the operating system even loads). Utilizing the Graphics Output Protocol (GOP) playing Bad Apple!!.

🚀 Key Features

  • Bare-Metal Playback: Video decoding and rendering without relying on any OS-level APIs.
  • High-Precision Synchronization (Master Clock): Uses CPU cycles via AsmReadTsc() to calibrate execution time and dynamically compensate for VRAM latency, maintaining a rock-solid framerate (FPS) and preventing video drift.
  • High VRAM Performance: Sends decoded frames directly to video memory using highly optimized block copying (Fast Memcpy), bypassing the speed limitations of uncached VRAM access.

🛠️ C++ Wrappers for UEFI

Developing in pure C for UEFI can be cumbersome. This project implements several ready-to-use, object-oriented C++ wrappers to easily interact with the firmware:

  • Graphics: Abstracts the complexity of the GOP (Graphics Output Protocol). Makes it easy to clear the screen, draw pixels, render rectangles, and display frames directly to the FrameBuffer with automatic scaling and centering.
  • UefiFile: A clean and safe wrapper around EFI_FILE_PROTOCOL to easily handle file system operations (read, write, get sizes, and seek) from the boot drive.

⚙️ Porting pl_mpeg to UEFI

The core of this media engine is pl_mpeg. However, since the original library depends heavily on the C standard library (libc), it was completely rewritten and ported to run natively within the EDK II ecosystem.

  • All dependencies on <stdio.h>, <stdlib.h>, and <string.h> were removed.
  • Memory allocations (malloc, free, realloc) were replaced with UEFI APIs (AllocatePool, FreePool, ReallocatePool).
  • Memory operations (memcpy, memset) were adapted to native firmware functions (CopyMem, ZeroMem).
  • Primitive types were converted to UEFI architecture standards (UINTN, UINT8, INT32, etc.).

🎥 Demonstration

Want to see it in action before compiling? Check out the showcase on YouTube: ▶️ Watch the BadUefi Demo

🛠️ Build Environment & How to Run

To compile BadUefi correctly and fully leverage its C++ wrappers and debugger integration, it is required to use the VisualUefiEx development environment.

Created by me (based on the excellent original VisualUefi project by ionescu007), VisualUefiEx solves the biggest headaches of modern EDK-II development in Visual Studio 2022. It automates the EDK-II libraries compilation, sets up the necessary system environment variables, and provides a ready-to-use, modern C++ UEFI Project template for Visual Studio.

Step-by-Step Instructions

  1. Set up the Environment: First, go to the VisualUefiEx repository and follow its installation guide to properly configure your Visual Studio 2022 with the EDK-II tools.
  2. Clone this Project: Clone the BadUefi repository and open it using your newly configured Visual Studio.
  3. Compile: Build the project for the x64 architecture.
  4. Prepare the Media File: You must copy the BadApple.mpg file from the Video folder of this repository and paste it into your build output folder (e.g., x64\Release\).
  5. Deploy & Enjoy

🏆 Credits

This project was only made possible thanks to the following open-source projects:

  • pl_mpeg by Dominic Szablewski (phoboslab): MPEG1 Video and MP2 Audio decoder in a single C file (rewritten in this project for UEFI support).
  • FastMemcpy by skywind3000: Used for aggressive optimization in memory block copying, ensuring high framerates when rendering to the FrameBuffer.
  • VisualUefi by ionescu007: The VisualUefiEx development environment used to build this project is based on the incredible original work by Alex Ionescu, which greatly simplified UEFI development in Visual Studio.

Developed by Lincoln Dias

About

A UEFI application and media engine that plays Bad Apple video, capable of decoding and rendering MPEG-1 video directly in the pre-boot environment using GOP.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors