Mr. Alex Ionescu created, and has been maintaining for several years now, a wonderful tool called VisualUefi.  A synopsis, from its home on GitHub:

VisualUEFI is

  • A Solution and set of Visual Studio Project Files to allow building the official EDK-II (including OpenSSL 1.1.0e) without the use of inf files, python and 50 other build tools, a custom dependency tracker and build system, and twenty other custom pieces of code. The EDK-II and OpenSSL are present as submodules, directly from the official TianoCore Tree, and no changes are done to them.

  • A Solution and couple of Visual Studio Project Files to show four UEFI sample components: An UEFI Application and associated UEFI Boot Driver, the EDK-II Sample FtdiUsbSerialDxe Driver, and the EDK-II Sample Cryptest Application which uses OpenSSL 1.1.0e. The code is 100% EDK-II compatible, but built with VisualUEFI instead.

  • A working and FAST copy of QEMU64 2.10 for Windows, with a fairly recent UEFI 2.6 OVMF Secure Boot ROM which includes SMM support and an actual protected flash for enrolling PK/KEK/DB/DBX keys. These will updated on an ongoing basis as needed. This is integrated with the Visual Studio Sample Solution so that pressing F5 will spin up the instance for testing.

Recently, I took this remarkable tool for a test drive—and loved it!  If you appreciate the power and sophistication of Visual Studio, or if you’re currently searching for a new text editor to do BIOS development, read on.

Walk-through

If anything, the installation can be characterized by its sheer simplicity.  Here’s how it went for me:

  1. I used Microsoft Visual Studio Enterprise 2017, v15.8.7
  2. I did git clone on the repo from GitHub.  Note: you MUST do a recursive git clone in order to get the edk2 and openssl source checked out; otherwise, these directories will be empty.
  3. I tried to build EDK-II.sln, but I didn’t have the older Windows SDK referenced in the .sln file.  So, I right-clicked the solution, clicked “Retarget solution”, and selected v10.0.17134.0, the latest Windows SDK on my system.
  4. I successfully built EDK-II.sln, and then samples.sln
  5. I hit F5 to start the debugger; QEMU launched immediately
  6. I typed in fs1: and found the sample app and drivers
  7. I ran UefiApplication—it worked the first time!

clip_image001

Honestly, I think this makes BIOS development easier than Win32 development!  Seriously, try writing a Hello, world application in Win32 or .NET and you’ll see how marvelous Alex’s EDK-II development system really is.  Plus, to be able to immediately test your code in QEMU is astounding.  Try it—it’s nothing like the often painful NT32 build target that comes with the EDK.

Motivation

Again from GitHub:

Although EDK-II's build subsystem supports Visual Studio, it doesn't work with "in-IDE" building. Instead, special .inf files and other templates are used to define projects, and a custom build composed of multiple 3rd party tools must be ran -- including dependencies on Python, Ruby, and Perl. For developers already familiar with Visual Studio's project files/MSBUILD, as well as the IDE it offers, this can be cumbersome and limiting, slowing down the ability to quickly jump into UEFI development. Additionally, the EDK-II's default "test" environment is to build a Windows "NT32" layer around your application and running it as a command line executable. While this might work for very simple applications, it doesn't reliably provide an environment for testing DXE drivers, runtime services, and more.

VisualUefi aims to bridge these gaps by compiling 100% unmodified EDK-II libraries with a proper Visual Studio build environment, adding some VisualUefi-specific glue to support building within Visual Studio without 3rd party tools, and includes the latest QEMU and OVMF w/ SecureBoot packages for bare-metal testing of UEFI, without relying on Windows emulation.

Screenshots

Here’s what this looks like in Visual Studio:

image

image

All the great features (e.g. Intellisense, Peek Definition, Go To Definition, etc.) you’ve come to expect from Visual Studio work with this project.  Once you perform the quick installation process, you can write your own UEFI projects in the samples.sln and test them out in QEMU.

Conclusion

VisualUefi is so easy to install and get started with that you might as well try it out—you have nothing to lose.  It is a delight to use; it gives a BIOS developer all the same powerful, easy to use tools that Windows developers have enjoyed and take for granted.

Alex is a security researcher and Windows guru. (he wrote the book on Windows! Smile)  He is a regular speaker at Blackhat, and has also contributed significantly to ReactOS.

Twitter: https://twitter.com/aionescu

blog:  http://www.alex-ionescu.com/

Thanks for VisualUefi, Alex!

Post a Comment

Be sure to select an account profile (e.g. Google, OpenID, etc.) before typing your comment!