Installing Windows 7 on the pure UEFI systems without CSM

Discussion in 'Windows 7' started by PrimeExpert Software, Jan 2, 2020.

  1. PrimeExpert Software

    Dec 3, 2019
    3
    8
    0
    It's a well-known fact that Windows 7 works best in CSM mode, which, unfortunately, is not supported by the firmware of many modern motherboards and laptops.

    Contrary to popular belief, it's possible to install Windows 7 x64 to the pure UEFI systems without CSM support. For example, "bhyve" virtual machine manager in FreeBSD supports 64-bit editions of Windows 7 and Windows 2008 Server R2, despite the complete lack of CSM support.

    What is really important for Windows 7 is a VGA-compatible GPU with properly mapped I/O ports and INT 10H handler (the former depends mostly on the chipset and the latter is usually provided by firmware when CSM mode is enabled in the settings). By the way, Windows 7 and Windows 2008 Server R2 never directly run the INT 10H handler installed by BIOS/CSM, instead they contain an emulator in the VGA miniport driver (VIDEOPRT.SYS) which runs 16-bit BIOS code in a sandbox, without leaving 64-bit protected mode and without halting other CPU cores.

    Starting from Windows 8, everything has changed: INT 10H handler is no longer required by Windows to boot, BIOS emulator and entire VGA miniport driver both are gone, instead Windows basic display driver relies upon UEFI Graphics Output Protocol aka GOP.

    So, will it be enough to provide a custom INT 10H handler (by implementing a specialized UEFI preloader) to boot Windows 7 successfully on the modern pure UEFI systems? This custom INT 10H handler can rely on UEFI GOP to provide some sort of "mini CSM" (not a real thing, but just enough for VIDEOPRT.SYS to boot Windows 7).

    As our experiments demonstrated, this, unfortunately, is not enough. In addition to invoking VGA BIOS via INT 10H in VIDEOPRT.SYS, Windows 7 makes direct reads and writes to/from VGA I/O ports right from the OS kernel (NTOSKRNL.EXE). First of all, Windows 7 OS kernel has VgaIsPresent() function which may halt boot process indefinitely on the "glowing logo" phase if VGA-compatible GPU does not respond on the standard I/O ports (0x3C0-0x3DF). Also, Windows 7 OS kernel has several other functions, such as VidInitialize(), VgaInterpretCmdStream(), VidSolidColorFill(), SetPixel() etc, which perform direct I/O on VGA ports for drawing BSoD (blue screen of death).

    Therefore, we continued development of our preloader for Windows 7 by introducing a patch for NTOSKRNL.EXE to replace all instances of direct I/O via VGA ports with updates of framebuffer provided by UEFI GOP (in similar manner to Windows 8+). This patch is activated every time Windows boots, so NTOSKRNL.EXE is updated on the fly, only in the RAM, and on-disk version of this file is not affected (it may undergo any Windows 7 updates, it may be contained inside BOOT.WIM etc).

    Final result of our efforts: Windows 7 x64 with preloader boots fine on pure UEFI systems (without CSM and without properly mapped VGA I/O ports): we successfully tested it and confirmed to work on ASUS C8HM70-I, Dell Inspiron 3584, HP OMEN X 17-ap001ur, Atomic Pi, "bhyve" virtual machine with VGA emulation disabled, "VirtualBox" virtual machine configured in UEFI mode for Windows 8 guest OS. Thus, it is no longer necessary to disable Vga and VgaSave services in registry. It's no longer necessary to set "novesa on" option via bcdedit. Safe Mode and Windows Recovery work as expected. Last but not least: Windows 7 BSoD works as expected! :)

    The only drawback of this approach is that screen resolution is fixed at 1024x768 with black sidebars added as necessary to fill in for the native resolution of the LCD screen. But after installation of the native GPU drivers (from Intel, AMD or NVIDIA) everything goes back to normal. Black sidebars remain at boot time only, when animated OS logo is displayed by Windows 7 via standard VGA driver.

    `Windows 7 x64 preloader to provide VGA emulation on the pure UEFI systems' has become a feature of our software product (FlashBoot Pro). In addition to patching the loader, FlashBoot Pro provides a set of prepackages drivers for USB 3.x, NVMe and AHCI RAID controllers, which can be integrated to Windows 7 Setup just by a few checkboxes ticked on (driver integration is hardly a suprise for a seasoned Windows 7 installers from this forum, and was meant to simplify this matter for beginners).

    Right now we are running a giveaway of 10 licenses for FlashBoot Pro on MyDigitalLife forums, so if you are interested in this topic (installation of Windows 7 to modern motherboards and laptops without CSM support, in the pure UEFI mode), please feel free to enroll.
     
  2. wkeller

    wkeller MDL Member

    Nov 30, 2010
    102
    283
    10
    #2 wkeller, Jan 2, 2020
    Last edited: Jan 2, 2020
    Completely unnecessary.
    Just integrate vendor specific video drivers (Intel, nVidia or AMD) to Windows 7 install.wim file, then use Windows 10 installer in place of Windows 7 installer. In other words, just copy your modified install.wim from Windows 7 to Windows 10 installation DVD.

    It is also required to replace Windows 7 boot manager (bootmgr.efi) with that of Windows 10, either inside install.wim file or on an installed system (on EFI system partition).
    See my these 2 posts

    So, I see no reason to emulate INT 10h for Windows 7. As I have tested above solution on Lenovo ThinkCenter M82 with UEFI enabled and CSM disabled.
    Even Secure Boot enabled work as expected.
     
  3. PrimeExpert Software

    Dec 3, 2019
    3
    8
    0
    #3 PrimeExpert Software, Jan 2, 2020
    Last edited: Jan 2, 2020
    (OP)
    In your approach, Safe Mode / Windows Recovery won't work. And BSoDs won't be displayed (computer will just freeze). Also there may be early BSoDs like ACPI_BIOS_ERROR and INACCESSIBLE_BOOT_DEVICE which appear before video driver is loaded, so it's nice to have them as well (with all details included), instead of usual small frozen red dot above "Starting Windows".
     
  4. wkeller

    wkeller MDL Member

    Nov 30, 2010
    102
    283
    10
    AFAIK, vendor specific drivers could be added to Windows Recovery (winRE.wim) in the same way as it could be added to install.wim.
    Incidentally, winRE.wim resides inside install.wim

    You are right, but I haven't seen accidental BSoD for many, many years. It never happens on properly installed OS (at least never happened to me).
    If I see it, I will be almost sure about hardware failure.
     
  5. wkeller

    wkeller MDL Member

    Nov 30, 2010
    102
    283
    10
    You could use boot.wim from Windows 10 along with entire Windows 10 installation DVD, so you use its drivers.

    Only install.wim from Windows 7 is needed.
     
  6. PrimeExpert Software

    Dec 3, 2019
    3
    8
    0
    #8 PrimeExpert Software, Jan 3, 2020
    Last edited: Jan 3, 2020
    (OP)
    Last time I checked, Windows 7 UEFI loader was able to boot Windows 10 without any problems. Boot menu was presented in text mode (akin to "bootmenupolicy legacy" bcdedit option of Windows 8+), but otherwise it was fine, both in cold boot mode (via winload.efi) and dehibernation mode (via winresume.efi).

    It works fine because OS-specific boot logic is contained within \Windows\System32\winload.efi, and early bootloader bootmgfw.efi merely displays boot menu, activates recovery/dehibernation boot path if necessary, and transfers control to the next bootloader in chain.

    But, given Windows 10 bad habit to continuously update everything in sight, UEFI loader included, I'd rather moved patched Windows 7 UEFI loader along with its BCD hive to the small separate partition and added third-party boot manager like REFind to choose between Windows 7 and Windows 10 UEFI loaders in dual-boot configuration.
     
  7. nodnar

    nodnar MDL Expert

    Oct 15, 2011
    1,113
    859
    60
    :g: this thread looks to me like taking arms against a sea of trouble...
    at every occasion m$ is yelping about EOL of seven...they even invented a nagscreen/popup for it.
    i still have good hopes that 7 wil lbe as longlived as xp has proved to be, but i have no intention to
    continue to use it, seeing that 7 is a decently-stable os,-as opposed to the aggressively promoted/marketied of 10-
    there is absolutely no need for a new install of 7. [possibly a virusinfection or a bad harddisk could provoke that,]
    or the use of safe mode...[and i never had to use safe mode since 2012 or therabouts.
    while i can appreciate the giveaway very much, my machine will be on linux mint very soon. bye bye m$ malwaremakers....
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  8. Reducer

    Reducer MDL Novice

    Jul 30, 2014
    40
    59
    0
    Not sure what you mean in "use its (boot.wim) drivers". After deploying OS ("extracting" OS from WIM/ESD file to target storage media) via official Setup app from ISO or other means, user then boots the OS for 1st time. There is a "device configuration" stage (PnP stage) where devices like (i)VGA are detected and, if they exist in the deployed OS driver store, suitable drivers (native/OEM) are installed. They won't install (will be ignored/rejected, specially in Win x64 scenarios) if they don't meet the described properties.

    Actually I've never tried to boot full Win10 OS via Win7 efi bootloader, but I can't boot my custom Win10 PE with Win7 efi bootloader, so I'm using Win10 one. I will try again using untouched boot.wim from one of the recent Win10 releases, just to be sure it's not just my specific Win10 PE. In any case, that sounds great, you have it covered.

    Also, I like rEFInd :)

    Some users like to boot in Safe Mode to DDU VGA drivers. Other scenarios might be borderline, I have to agree here, but as I've said having it available is better than not.
     
  9. Atak_Snajpera

    Atak_Snajpera MDL Member

    Feb 2, 2018
    147
    187
    10
    Does this method also solve that annoying message saying that bios is not acpi compilant?

    The BIOS in this system is not fully ACPI compliant. Prease contact your system vendor for an updated BIOS.
    Technical information:
    Stop: 0x000000A5 (0x0000000000000011, 0x0000000000000008, 0xFFFFFA80074416E8, 0x0000000020160422)
     
  10. daniel_k

    daniel_k MDL Novice

    Jan 21, 2019
    35
    16
    0
    @Atak_Snajpera
    No.

    Happens with Ryzen APU, right?
    It's another issue, nothing to do with the UEFI booting subject of this topic.
     
  11. The Freeman

    The Freeman MDL Novice

    Dec 7, 2018
    9
    5
    0
    I wonder if there is a forum where people discuss their success or failure when using the FlashBoot software. I searched with Google but I wasn't able to find anything.
     
  12. daniel_k

    daniel_k MDL Novice

    Jan 21, 2019
    35
    16
    0
    That is really odd.

    @LostED, please let us know if the no CSM fix does really work.