Force selection of load option in UEFI via C code

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
DeadBrother
Posts: 8
Joined: Sat Apr 29, 2023 9:29 am

Force selection of load option in UEFI via C code

Post by DeadBrother »

Hello, friends.

I am involved in a small project (in California).
We are developing a DXE-driver (by C-language).
We have a task - forced selection of a partition to boot the operating system (set boot option in stage before BDS).

Our current implementation forced sets the BootOrder variable with a single entry - with the necessary index of BootNNNN variable.
Also, we overload the SetVariable() function, and we do not allow changing the BootOrder variable in it.

But this implementation does not fully work - on VmWare everything works with bugs.
Also, for different motherboards, the implementation has different behavior, and it is also not always correct.

Please advise how best to solve the problem? Has anyone had a similar experience.

Thanks.
Octocontrabass
Member
Member
Posts: 5218
Joined: Mon Mar 25, 2013 7:01 pm

Re: Force selection of load option in UEFI via C code

Post by Octocontrabass »

EggHead wrote:We are developing a DXE-driver (by C-language).
We have a task - forced selection of a partition to boot the operating system (set boot option in stage before BDS).
That's a pretty unusual task for a DXE driver. Are you able to explain your situation in any more detail than that? I'm particularly interested in why you can't write a bootloader that chain-loads the appropriate operating system.
EggHead wrote:But this implementation does not fully work - on VmWare everything works with bugs.
Also, for different motherboards, the implementation has different behavior, and it is also not always correct.
What kind of bugs?

Some motherboards ignore the BootOrder variable.
DeadBrother
Posts: 8
Joined: Sat Apr 29, 2023 9:29 am

Re: Force selection of load option in UEFI via C code

Post by DeadBrother »

Octocontrabass, thanks to answer!
Octocontrabass wrote:That's a pretty unusual task for a DXE driver. Are you able to explain your situation in any more detail than that? I'm particularly interested in why you can't write a bootloader that chain-loads the appropriate operating system.
I am developing a trusted OS boot control tool with additional functionality (user login and password entry, checking the integrity of hardware, firmware, etc.). The tool itself is in the form of a DXE-module to run before the OS boots. Therefore, I have to allow the user to boot only the allowed OS.
EggHead wrote:What kind of bugs?
Very different bugs.
I tried to make the BootOrder with a single entry, overwrite SetVariable/GetVariable to return the correct BootOrder and Boot#### variables.
However, on different motherboards, entries in the BootOrder begin to be duplicated or disappear altogether, etc. That is, this approach does not work well.
DeadBrother
Posts: 8
Joined: Sat Apr 29, 2023 9:29 am

Re: Force selection of load option in UEFI via C code

Post by DeadBrother »

At the moment I'm trying to manually download efi-boot loader (\EFI\Boot\BOOTX64.efi etc.) using LoadImage/StartImage functions.

However, there are also a number of problems for which I will now create another post - viewtopic.php?f=1&t=56900 =)
Post Reply