Windows System Software -- Consulting, Training, Development -- Unique Expertise, Guaranteed Results

Home NTDEV
Before Posting...
Please check out the Community Guidelines in the Announcements and Administration Category.

More Info on Driver Writing and Debugging


The free OSR Learning Library has more than 50 articles on a wide variety of topics about writing and debugging device drivers and Minifilters. From introductory level to advanced. All the articles have been recently reviewed and updated, and are written using the clear and definitive style you've come to expect from OSR over the years.


Check out The OSR Learning Library at: https://www.osr.com/osr-learning-library/


Windows BIOS Setup Reboot

rafael_Machadorafael_Machado Member - All Emails Posts: 12

Hi Everyone

We have a tasks to be done, where we need to reboot systems on the Bios Setup Screen.

We understand that what Windows does is to work with some UEFIVariable (OSIndications), to manage the next boot of the system.
We have started to try to use the uefi var, OSIndications, that can be accessed using the windows apis like this:

https://docs.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-getfirmwareenvironmentvariablea
https://docs.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-setfirmwareenvironmentvariablea

The problem is that at some systems this does not work. When the system is working with CSM enabled at the BIOS the var is not available, since the BIOS works on a "legacy" compatible mode, having no UEFIVars available to windows.

We also got the same problem with the command:

shutdown /r /fw

(When trying to do it on a CSM enabled system we got the same error code as mentioned above)

Another possible way we discovered was using the bcd.exe, by passing as argument the firmware guid, as below:

bcdedit /set {fwbootmgr} bootsequence {e5fed296-00d1-11ea-9dfa-806e6f6e6963}

But this can't be done on some systems, because there is no guid to be used at the bcdedit command.
(when using bcdedit /enum firmware or all to check for the firmware Setup we cant find anything)

Also even on the systems that do have the firmware setup with guid avaiable for bcdedit to use, we stil need a reliable way to get to this GUID.
This GUID is unique in every system and to get it to later pass it as a parameter to bcdedit there are two ways.

  • First would be to read the bcdedit enum command result and try to get the GUID by the description. That is not a good way because for start the description is localized. (and also if there is an added extra item with the same description we would not be able to differentiate between the two).
  • The second one is to access it via windows register on HKEY_LOCAL_MACHINE\BCD00000000\Objects{objectGuid}. While acessing this register key we can find the GUID we need but to get to it we need something to seach for. Checking inside this key we find a FirmwareVariable value that I think its what we can use on our search. The problem is there is no documentation on this and this byte array (binary data) its actually not the same on diferent systems. (but its pretty close).

So the questions are.
Is there a way to manage the system's next boot on a reliable way? (that would work on all windows versions with uefi and legacy mode)
Why some systems do not have a firmware Setup that enables us to do this via BCDEdit?
Is there any documentation on the windows register FirmwareVariable for bcd? Something that tells us witch part of it can be checked for and would be equal on all systems.

Important note: We have tested it on several Windows 10 systems and while Setfirmwareenvironmentvariablea and the shutdown /r /fw command seems to work the same way (both didn't work when on a CSM enabled system), the BCDEdit does work on CSM enabled systems but we still have the problem that not all systems seems to have the GUID for it to work and even on the ones that do we dont have a documentation on that to seach for it the right way.

Comments

  • Tim_RobertsTim_Roberts Member - All Emails Posts: 13,395

    If you will allow me to take a side trip for a moment, this seems like an odd request. If you are a BIOS vendor, then surely you have your own magic commands that can trigger BIOS actions during the next boot. If you are not a BIOS vendor, then you don't have any idea what jumping into the BIOS is going to do. Until UEFI, there has never been any standardized BIOS interface at all.

    Tim Roberts, [email protected]
    Providenza & Boekelheide, Inc.

  • rafael_Machadorafael_Machado Member - All Emails Posts: 12

    Hi Tim
    Thanks for the answer.

    Got your point and agree. Now that the UEFI/PI Spec tried to organize the BIOS behavior, things should be easier and more clear.
    Just to give more information, this kind of request can be applied to different scenarios.
    For example manufacturing automation, system remote management and probably others I am not able to think right now.

    But is strange that some systems are not working as expected, and it is not clear to us why this is happening.
    Any help on uderstanding how this works would be well received.

  • Tim_RobertsTim_Roberts Member - All Emails Posts: 13,395

    But you already said it, right? If these systems are in UEFI mode, then all is great. If they are not in UEFI mode, then there are no standards. There's nothing to be done.

    Tim Roberts, [email protected]
    Providenza & Boekelheide, Inc.

  • rafael_Machadorafael_Machado Member - All Emails Posts: 12

    Yes, you are right!
    We would like to understand better how the BCDEdit tool gets the firmware information.
    Because there is some difference between UEFI systems with CSM and their bcd returned information.

    So, from my first message:

    "Another possible way we discovered was using the bcd.exe, by passing as argument the firmware guid, as below:

    bcdedit /set {fwbootmgr} bootsequence {e5fed296-00d1-11ea-9dfa-806e6f6e6963}

    But this can't be done on some systems, because there is no guid to be used at the bcdedit command.
    (when using bcdedit /enum firmware or all to check for the firmware Setup we cant find anything)
    ....
    Important note: We have tested it on several Windows 10 systems and while Setfirmwareenvironmentvariablea and the shutdown /r /fw command seems to work the same way (both didn't work when on a CSM enabled system),_ the BCDEdit does work on CSM enabled systems but we still have the problem that not all systems seems to have the GUID for it to work_ and even on the ones that do we dont have a documentation on that to seach for it the right way.
    "

    So the problem is that on CSM enabled systems, the BCDEdit work, but in a kind of magical way, since on some of them the GUID related to the Setup firmware is not available.

    We would like to know two things in fact.
    How to fill the Setup firmware var that is returned by "bcdedit /enum firmware" ? (this Setup GUID is not present at some systems)
    How to find this GUID via software ? This prabably can be done using a windows register, as below:

    "The second one is to access it via windows register on HKEY_LOCAL_MACHINE\BCD00000000\Objects{objectGuid}. While acessing this register key we can find the GUID we need but to get to it we need something to seach for. Checking inside this key we find a FirmwareVariable value that I think its what we can use on our search. The problem is there is no documentation on this and this byte array (binary data) its actually not the same on diferent systems. (but its pretty close)."

    But we woud like some documentation about this register to avoid problems in the field.

    Thanks for helping on the discussion and keeping this post alive.

  • MBond2MBond2 Member Posts: 92

    I'm too old to read all of this nonsense, but can you please answer the question - what are you trying to do?

  • rafael_Machadorafael_Machado Member - All Emails Posts: 12

    In simple words:

    Find a way to reboot sthe system on the BIOS setup screen, considering systems that have UEFI BIOS (with and without CSM), and systems that have Legacy BIOS.

  • Tim_RobertsTim_Roberts Member - All Emails Posts: 13,395

    Find a way to reboot sthe system on the BIOS setup screen, ...

    I don't know what that means. Are you saying you want to force the computer to reboot into the BIOS? I do not believe there is any way to do that in a hardware-independent way. And why do you want to? What is your user going to do once he gets there?

    Tim Roberts, [email protected]
    Providenza & Boekelheide, Inc.

  • rafael_Machadorafael_Machado Member - All Emails Posts: 12

    The understand is corret.
    I want to force the computer to reboot into the BIOS.
    After being there the user can do some management tasks.
    Like changing devices settings, enablind and disabling parts of the hardware, disable AMT, and other things that are more easily done at pre-OS, without the need of external tools.

  • Tim_RobertsTim_Roberts Member - All Emails Posts: 13,395
    edited April 1

    But don't you see, you are looking for a general solution to a specific problem. If you know enough about the computer to know whether it even has the ABILITY in the BIOS to manipulate those things, then surely you know enough to use the right technique.

    And let's be quite honest. You're talking about something that needs to be done EXACTLY ONCE on any given system. It is an utter waste of time to try to come up with an automated solution. Just supply a PDF that says "OK, now we will reboot and you need to press F2/F12/Del to enter the BIOS, after which you need to go to X screen and turn off the Y feature". Any user that isn't competent enough to follow those directions is certainly not competent enough to be let loose flipping settings in a BIOS.

    Some things do not need to be automated, like soap dispensers, water faucets, and this reboot.

    Tim Roberts, [email protected]
    Providenza & Boekelheide, Inc.

  • rafael_Machadorafael_Machado Member - All Emails Posts: 12

    Got your point.
    For some scenarios this is applicable, for example remote management systems. The network admin is totally capable of letting a system reboot on BIOS and manage the settings using AMT for example.
    This is my case in fact, that is related to remote management without using windows tools, like RemoteDeskop, and adding specific security requirements at the communication.
    But I agree probably there is no generic solution for this case.
    Would just like to hear windows specialists to confirm this windows limitation

  • MBond2MBond2 Member Posts: 92

    The generic solution is that systems that implement the UEFI standard work. Others that don't won't because they do not implement any kind of standard. Lecacy BIOS has to be dealt with on a case by case basis - which was one of the key motivating factors in the development of UEFI

    Whether there is any good reason to do this or not is another matter as Tim has pointed out

  • SweetLowSweetLow Member Posts: 40

    Would just like to hear windows specialists to confirm this windows limitation

    It is not Windows nor any other software limitation.

    But I agree probably there is no generic solution for this case.

    Well, there is quite common solution how to force enter to BIOS but i think your users will be angry on its applying. But who knows, may be you will make them read that f. manual!

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Upcoming OSR Seminars
OSR has suspended in-person seminars due to the Covid-19 outbreak. But, don't miss your training! Attend via the internet instead!
Kernel Debugging 30 Mar 2020 OSR Seminar Space
Developing Minifilters 15 Jun 2020 LIVE ONLINE
Writing WDF Drivers 22 June 2020 LIVE ONLINE
Internals & Software Drivers 28 Sept 2020 Dulles, VA