Jump to content











Photo
* * * * * 1 votes

Hack Bootmgr to boot Windows in BIOS to GPT

bios gpt bootmgr winload

  • Please log in to reply
355 replies to this topic

#151 steve6375

steve6375

    Platinum Member

  • Developer
  • 6629 posts
  • Location:UK
  • Interests:computers, programming (masm,vb6,C,vbs), photography,TV,films,guitars
  •  
    United Kingdom

Posted 25 May 2015 - 02:53 PM

2MB free??? Is that enough for hyberfil.sys ??



#152 gyurman

gyurman
  • Members
  • 9 posts
  •  
    Hungary

Posted 25 May 2015 - 05:20 PM

Dear steve6375, I think the hyberfil.sys is created when hibernate the computer. I have enough space in C: drive but this space is in vhd file.

I think problem is with bcd boot values. But I don't know what. I copyed missing lines from working windows.

Windows Boot Manager
--------------------
identifier              {bootmgr}
device                  boot
description             Windows Boot Manager
locale                  hu-HU
inherit                 {globalsettings}
integrityservices       Enable
default                 {default}
resumeobject            {c634f09b-fe5e-11e4-8268-50e549b40f24}
displayorder            {default}
toolsdisplayorder       {memdiag}
timeout                 30

Windows Boot Loader
-------------------
identifier              {default}
device                  partition=C:
path                    \windows\system32\winload.exe
description             Windows 8.1
locale                  hu-HU
inherit                 {bootloadersettings}
recoverysequence        {c634f09b-fe5e-11e4-8268-50e549b40f24}
integrityservices       Enable
recoveryenabled         Yes
allowedinmemorysettings 0x15000075
osdevice                partition=C:
systemroot              \windows
resumeobject            {c634f09b-fe5e-11e4-8268-50e549b40f24}
nx                      OptIn
bootmenupolicy          Standard
detecthal               Yes
useplatformclock        Yes

I have same values in C: drive and in vhd file. But I don't understood. Do you have anybody who have same problem with sleep?


Edited by gyurman, 25 May 2015 - 05:23 PM.


#153 cdob

cdob

    Gold Member

  • Expert
  • 1343 posts

Posted 26 May 2015 - 09:59 PM

But before I did bcdboot etc.
Than after mine windows Not going to sleep the windows 8.1?

The referenced article shows a two disks example.
How many disks do you use? Which hardware do you use?
 

I think problem is with bcd boot values.

I think the problem is with "SystemBootDevice" and "FirmwareBootDevice"
http://reboot.pro/to...e-6#entry192570
Which values do you get at running window 8?
Both values should match current disk configuration. Values can be changed at running windows.

Which partition layout do you use?

#154 cdob

cdob

    Gold Member

  • Expert
  • 1343 posts

Posted 27 May 2015 - 07:51 PM

Do you have anybody who have same problem with sleep?


Sleep does work at windows 8.1:

Given one hard disk with a 100 mb FAT32 EFI partition and a windows partition.

Copy boot files at 100 mb FAT32 EFI partition S:
bcdboot.exe c:\windows /s S: /f BIOS

BIOS GPT http://reboot.pro/to...e-4#entry186656

Adjust embedded menu.lst at GPT_GRLDR.ima
default 0
timeout 1

title find /boot/gpt.lst, /gpt.lst
	errorcheck off
	find --set-root --ignore-floppies --ignore-cd /boot/gpt.lst && configfile /boot/gpt.lst
	find --set-root --ignore-floppies --ignore-cd /gpt.lst && configfile /gpt.lst
	errorcheck on
	commandline

title commandline
	commandline

title reboot
	reboot

title halt
	halt
.

Create a file S:\gpt.lst
default 0
timeout 1

#this file is found at 'find --set-root'
title GPT BIOS (); fd0; /bootmgr
map ()+1 (fd0)
map --hook
root (fd0)
chainloader /bootmgr

title GPT BIOS /bootmgr /boot/bcd
cat --length=0 (,0)/bootmgr && cat --length=0 (,0)/boot/bcd && map (,0)+1 (fd0)
cat --length=0 (,1)/bootmgr && cat --length=0 (,1)/boot/bcd && map (,1)+1 (fd0)
cat --length=0 (,2)/bootmgr && cat --length=0 (,2)/boot/bcd && map (,2)+1 (fd0)
cat --length=0 (,3)/bootmgr && cat --length=0 (,3)/boot/bcd && map (,3)+1 (fd0)
map --hook
root (fd0)
ls (fd0)/
chainloader /bootmgr

title commandline
commandline

title reboot
reboot

title halt
halt
.

Boot windows 8.1 and adjust FirmwareBootDevice,
run
diskpart
sel disk 0
list par
exit
and remember 100 EFI partition.

Example, adjust partition(N)
reg.exe add HKLM\SYSTEM\CurrentControlSet\Control /v FirmwareBootDevice /d "multi(0)disk(0)rdisk(0)partition(2)" /f
.

Sleep adjust the file s:\boot\bcd and hiberfil.sys.
And shut down the machine.

#155 steve6375

steve6375

    Platinum Member

  • Developer
  • 6629 posts
  • Location:UK
  • Interests:computers, programming (masm,vb6,C,vbs), photography,TV,films,guitars
  •  
    United Kingdom

Posted 27 May 2015 - 09:04 PM

Dear steve6375, I think the hyberfil.sys is created when hibernate the computer. I have enough space in C: drive but this space is in vhd file.

I think problem is with bcd boot values. But I don't know what. I copyed missing lines from working windows.

 

Win7/8/8.1 uses Hybrid Sleep which is different from the old Standby/Sleep.  This means that it creates a hyberfil.sys file and then goes into Standby. If you turn off the system (or the battery goes flat on a laptop), you can switch it back on again and it will boot from the hybernate file with no data loss.



#156 cdob

cdob

    Gold Member

  • Expert
  • 1343 posts

Posted 28 May 2015 - 03:10 PM

that is grub2.

.
Chainload grub4dos grub.exe and open the file /boot/gpt.lst:
menuentry "Windows 8.1 loaded with grub4dos" {
  linux16 /boot/grub/grub.exe --config-file=find --set-root --ignore-floppies --ignore-cd /boot/gpt.lst\; configfile /boot/gpt.lst
}
.

And let's assume 48 bit LBA at a Windows 8.1 machine.
Another idea: include boot files to %SystemRoot% partition.
bcdboot.exe C:\windows /s C: /f BIOS
Read "SystemBootDevice" and write setting to "FirmwareBootDevice".
Or try to delete "FirmwareBootDevice".

#157 gyurman

gyurman
  • Members
  • 9 posts
  •  
    Hungary

Posted 28 May 2015 - 04:00 PM

Hello, thanks, Hpw can I do this with grub2?



#158 cdob

cdob

    Gold Member

  • Expert
  • 1343 posts

Posted 28 May 2015 - 04:09 PM

Hpw can I do this with grub2?

I don't know, I doubt grub2 mapping a GPT partiton to a floppy and working bootmgr.
Asks grub2 experts.

What's wrong chainloading grub.exe?

#159 gyurman

gyurman
  • Members
  • 9 posts
  •  
    Hungary

Posted 28 May 2015 - 07:56 PM

I did easily with grub2.

 

And 

I think the problem is with "SystemBootDevice" and "FirmwareBootDevice"
http://reboot.pro/to...e-6#entry192570

you are true. I changed the "SystemBootDevice" and "FirmwareBootDevice" to same, and I can sleep at now.

 

Thanks



#160 cdob

cdob

    Gold Member

  • Expert
  • 1343 posts

Posted 28 May 2015 - 08:57 PM

I did easily with grub2.

Well, to be picky: grub2 can't do the requested task: map a vhd file to satisfy bootmgr and /boot/bcd.
syslinux/memdisk does the interesting part.
Can memdisk map a gpt partition to a virtual hard disk?
 

I changed the "SystemBootDevice" and "FirmwareBootDevice" to same, and I can sleep at now.

Thanks for report.

Does windows writes file bcd to "SystemBootDevice"?
Windows reads bcd file from vhd file still, updates to bcd are lost.

Is it worth to change the behaviour?
let windows update the bcd file, write to disk.
use this bcd file at next boot?
The suggested approach uses this.

#161 cdob

cdob

    Gold Member

  • Expert
  • 1343 posts

Posted 30 May 2015 - 05:40 PM

And let's assume 48 bit LBA at a Windows 8.1 machine.
Another idea: include boot files to %SystemRoot% partition.

bcdboot.exe C:\windows /s C: /f BIOS
Read "SystemBootDevice" and write setting to "FirmwareBootDevice".

.
Done: Registry changes survives reboot. :)

Load bcd at boot and adjust FirmwareBootDevice:
sleep works
bcdedit finds configuration
msconfig can configure start
Advanced options works http://www.howtogeek...t-options-menu/

Run a script every boot:
Assign Computer Startup Scripts https://technet.micr...y/cc770556.aspx
Windows 8.1 Logon Script Delay Group Policy Setting http://blogs.technet...cy-setting.aspx
 
rem adjust BIOS to GPT \boot\bcd - \boot\bcd at SystemDrive
rem created by cdob

reg.exe load HKLM\BCD00000000 %SystemDrive%\boot\bcd
reg.exe add  HKLM\BCD00000000\Description /v KeyName /t REG_SZ /d "BCD00000000" /f
reg.exe add  HKLM\BCD00000000\Description /v System /t REG_DWORD /d 0x1 /f
reg.exe add  HKLM\BCD00000000\Description /v TreatAsSystem /t REG_DWORD /d 0x1 /f

set SystemBootDevice=
for /f "tokens=3*" %%a in ('reg.exe query HKLM\SYSTEM\CurrentControlSet\Control /v SystemBootDevice') do set SystemBootDevice=%%a
if defined SystemBootDevice reg.exe add HKLM\SYSTEM\CurrentControlSet\Control /v FirmwareBootDevice /d "%SystemBootDevice%" /f
if not defined SystemBootDevice (echo error: FirmwareBootDevice not defined &pause)


#162 gyurman

gyurman
  • Members
  • 9 posts
  •  
    Hungary

Posted 31 May 2015 - 02:13 PM

Hello,

yes, I thought, how can I do, for can write back to the bcd. I have an MBR disk. I probed write bcd boot line for start the new windows. Starting, but this boot is longer time (15sec). I dont know why?

I'd like to write back, but how can I do without grub4dos. How could you start the windows partition? I did bios_grub partition for grub2.

If I use grub4dos after grub2 I grubbing again. Windows cannot map vhd after finished the boot?

Do you use WinVBlock driver or Firadisk driver? Which is have not compatibility issue?



#163 cdob

cdob

    Gold Member

  • Expert
  • 1343 posts

Posted 31 May 2015 - 05:48 PM

The boot layout is described in Post #154 http://reboot.pro/to...e-7#entry192864
\Boot\bcd is at hard disk files, acessable by windows default drivers.
No, I don't use a vhd. And neither winvblock or firadisk.

#164 cdob

cdob

    Gold Member

  • Expert
  • 1343 posts

Posted 31 May 2015 - 08:14 PM

another observation:
playing with bootmgr, boot\bcd and winload.exe

Boot\bcd at (hd0,0), Windows at (hd0,4)

map --read-only --in-situ (hd0,0)+1 (hd0,0)
map --read-only --in-situ (hd0,1)+1 (hd0,1)
map --read-only --in-situ (hd0,2)+1 (hd0,2)
map --read-only --in-situ (hd0,3)+1 (hd0,3)
map (hd0) (hd1)
map --hook
root (hd0,0)
chainloader /bootmgr
boot


Windows 8.1 does boot.
hd0 contains one protectice partiton entry still, not changed.
 

"SystemBootDevice"="multi(0)disk(0)rdisk(1)partition(4)"
"FirmwareBootDevice"="multi(0)disk(0)rdisk(0)partition(1)"

Sleep works after boot, no configuration required.
"SystemBootDevice" refers to hd1. Seems to works without error.

The file \Boot\bcd is not loaded to registry.

To be continued (locate winload.exe?).

edited:
'map --hook' added

Edited by cdob, 31 May 2015 - 09:36 PM.


#165 gyurman

gyurman
  • Members
  • 9 posts
  •  
    Hungary

Posted 31 May 2015 - 08:14 PM

Ahan, I will probing your settings with grub4dos. I probed with memdisk with raw option and withouth. With vhd and with img. Booting well, but I cannot get volume with boot\bcd. So If I understood you well if I do with grub4dos I will get mounted drive with boot\bcd?



#166 cdob

cdob

    Gold Member

  • Expert
  • 1343 posts

Posted 31 May 2015 - 09:35 PM

With vhd and with img. Booting well, but I cannot get volume with boot\bcd.

I suggest: no NOT use a vhd image.

#167 Wonko the Sane

Wonko the Sane

    The Finder

  • Advanced user
  • 13748 posts
  • Location:The Outside of the Asylum (gate is closed)
  •  
    Italy

Posted 01 June 2015 - 08:29 AM

another observation:
playing with bootmgr, boot\bcd and winload.exe

Boot\bcd at (hd0,0), Windows at (hd0,4)

map --read-only --in-situ (hd0,0)+1 (hd0,0)
map --read-only --in-situ (hd0,1)+1 (hd0,1)
map --read-only --in-situ (hd0,2)+1 (hd0,2)
map --read-only --in-situ (hd0,3)+1 (hd0,3)
map (hd0) (hd1)
map --hook
root (hd0,0)
chainloader /bootmgr
boot


Windows 8.1 does boot.
hd0 contains one protectice partiton entry still, not changed.


VERY nice :thumbsup:

I guess we can say that right now the map --in-situ implies a "--mbrstyle" switch.

:duff:
Wonko

#168 cdob

cdob

    Gold Member

  • Expert
  • 1343 posts

Posted 01 June 2015 - 02:44 PM

I guess we can say that right now the map --in-situ implies a "--mbrstyle" switch.

Yes, in-situ creates MBR partition entries.


Booting sequence:
grub4dos is loaded and
virtual map GPT partition hd0,0 to MBR partition hd0,0
map GPT partitioned disk hd0 to hd1

bootmgr reads \boot\bcd from MBR partition hd0,0
winload.exe device is connected to the GPT partition: bootmgr finds winload.exe at mapped hd1

#169 Wonko the Sane

Wonko the Sane

    The Finder

  • Advanced user
  • 13748 posts
  • Location:The Outside of the Asylum (gate is closed)
  •  
    Italy

Posted 01 June 2015 - 05:12 PM

Yes, in-situ creates MBR partition entries.


Booting sequence:
grub4dos is loaded and
virtual map GPT partition hd0,0 to MBR partition hd0,0
map GPT partitioned disk hd0 to hd1

bootmgr reads \boot\bcd from MBR partition hd0,0
winload.exe device is connected to the GPT partition: bootmgr finds winload.exe at mapped hd1

This should allow to further simplify the approach tested here:

http://reboot.pro/to...e-4#entry186471

http://reboot.pro/to...o-gpt/?p=186656

 

Question (to be tested) :unsure::

Can the Syslinux derived, modified makebootFAT MBR code allow to chainload a GPT style volume (hd0,0)  bootsector loading grldr (provided of course that the "shifted MBR entry in the MBR is pointing to it)?

 

I.e. can simply grldr and menu.lst be "installed" to the GPT style volume (the FAT32 one containing both the EFI bootloader and the "usual" BOOTMGR+\boot\BCD?

 

If this is possible, than we could greatly simplify the method getting rid of the (hidden or added to GPT) additional partition in sectors 63-2047.

 

Booting would go:

BIOS:

Modified MBR with GPT (hd0,0) mapped (in a shifted partition table) to MBR (hd0,0) ->bootsector of GPT hd0,0->grldr->menu.lst->in-situ remapping->BOOTMGR on of GPT hd0,0 which is also MBR hd0,0 at this point->Winload.exe from the (temporarily re-mapped) hd1,n

UEFI:

Normal, FAT32 EFI boot loader on GPT GPT hd0,0

 

:dubbio:

 

:duff:

Wonko



#170 cdob

cdob

    Gold Member

  • Expert
  • 1343 posts

Posted 01 June 2015 - 06:27 PM

Question (to be tested) :unsure::
Can the Syslinux derived, modified makebootFAT MBR code allow to chainload a GPT style volume (hd0,0)  bootsector loading grldr (provided of course that the "shifted MBR entry in the MBR is pointing to it)?
 
I.e. can simply grldr and menu.lst be "installed" to the GPT style volume (the FAT32 one containing both the EFI bootloader and the "usual" BOOTMGR+\boot\BCD?

.

I've to correct first: grub4dos_readme.txt:

Example:
map --in-situ (hd0,4)+1 (hd0)

Target (hd0,?) is not supported.
'map --read-only --in-situ (hd0,3)+1 (hd0,3)' writes a partition entry (hd0,0).
Random idea: in-situ first and partew next?

What about a simplified assumption:
Given a Vista and up default partiton layout: first partition start at LBA 2048
(hd0,0)\grldr
(hd0,0)\menu.lst
(hd0,0)\bootmgr
(hd0,0)\boot\bcd

Can you create a MkbootFatMOD jumping to sector 2048? (hd0,0)
Which format is appropiate? FAT16, FAT32 or NTFS? EFI request FAT32.
Define (hd0,0) as a fake EFI 100 mb FAT32 partiton?

#171 Wonko the Sane

Wonko the Sane

    The Finder

  • Advanced user
  • 13748 posts
  • Location:The Outside of the Asylum (gate is closed)
  •  
    Italy

Posted 01 June 2015 - 07:05 PM

Can you create a MkbootFatMOD jumping to sector 2048? (hd0,0)
Which format is appropiate? FAT16, FAT32 or NTFS? EFI request FAT32.
Define (hd0,0) as a fake EFI 100 mb FAT32 partiton?

 

Sure, no prob. :)

 

As I see it the "target" should be:

  1. First partition (aka GPT (hd0,0))
  2. 100 mb in size (or whatever is the default size for GPT install of the given Windows OS, I believe it is 300 Mb now for 8/8.1, but  I can most probably get it "on-the-fly" - as long as it is first partition - from the actual GPT partition table or from the FAT32 BPB, since it's position is "fixed" on LBA 2048)
  3. FAT32 formatted as in the UEFI requirements EFIsys or "EF00" or "C12A7328-F81F-11D2-BA4B-00A0C93EC93B" or "ESP"

 

In other words, let's take for the moment a "normal" install of Windows 8/8.1 on a GPT disk with UEFI.

 

The ONLY changes to it should be:

  • the handful of added bytes in the MBR (MkbootFatMOD)
  • changing the bootsector of the FAT32 EFIsys partition to one loading grldr
  • adding to the EFIsys volume grldr (and later also menu.lst)
  • adding to the EFIsys volume BOOTMGR and \boot\BCD

I.e. everything that will be perfectly transparent to EFI and meaningful only on BIOS.

 

With the above automated via batch/usual hex tools you should be able to easily experiment which commands are more suitable for the menu.lst.

 

Give me some time and I'll refresh my memory on the "previous attempt" and put together something.

 

:duff:

Wonko



#172 Wonko the Sane

Wonko the Sane

    The Finder

  • Advanced user
  • 13748 posts
  • Location:The Outside of the Asylum (gate is closed)
  •  
    Italy

Posted 03 June 2015 - 04:40 PM

The attached may do. :unsure:

 

There is no provision to copy to the root of the FAT32 GPT "EFIsys" partition the grldr (or the BOOTMGR+\boot\BCD) for the moment, and these files need to be copied manually.

 

The root of the loaded grldr - as is - should be the GPT (hd0,0) at booting time but if needed setting root also to (hd0) as "superfloppy" should be possible also.

 

The "usual bunch" of tools are needed (besides the files in the .zip):

dsfo.exe
dsfi.exe
dumphex.exe
hexalter.exe

 

Of course this is an early preliminary version, so that it's use is advised to cdob (and to anyone else that surely knows where his/her towel is)  ONLY, the usual bunch of leechers, headless chickens and similar are kindly requested to wait until the thingy has been tested by cdob and verified to be actually working.

 

NO Warranty, not even implied, that the batch will not mess with your disks.  :ph34r:

 

:duff:

Wonko

Attached Files



#173 milindsmart

milindsmart

    Frequent Member

  • Advanced user
  • 201 posts
  • Location:Bangalore
  •  
    India

Posted 11 June 2015 - 06:09 PM

There's some very interesting discussion happening here, regarding sleep functionality which I had not investigated... I'm watching with interest, moreso because I now have a regularly running physical machine, a BIOS desktop, running with the "Vista boot floppy" 2-disk configuration. I tried to convert it to the 1-disk configuration (due to necessity: the MBR disk is dying), but another problem has raised its head! Let us first refresh our memories
 

[...]
By the way, there're some BIOSes which actually want one of the MBR partition entries to have the bootable bit set before they'll load the sector and execute the code. These BIOSes can never boot a protective MBR (which is defined to have the bootable bit clear). There is some (U)EFI firmware which won't recognize a disk as a GPT disk if it doesn't contain a protective MBR. Unfortunately, this means that there is no way to satisfy both of these with the same MBR.

 

Sha0 described some BIOS behaviour at Pos #30
http://reboot.pro/to...e-2#entry182066

A "friendly" BIOS (as for a GPT disk) loads boot code despide a default protective MBR entry.
No validation check about active partition, or partition boot code.


This desktop has an "unfriendly" BIOS, in that it NEEDS the Protective MBR to be marked Active. That itself would not be an issue, if it were not for the discovery of the fact that bootmgr refuses to run winload.exe from a partition on such a GPT drive!

 

That is, 

  • If the protective 0xEE partition is not marked active, then it simply does not boot, saying "No bootable disk..."
  • If the protective 0xEE partition is marked active, then Grub2 can load, but when I try to boot windows on the GPT using the wimboot method, bootmgr starts up, but refuses to boot windows saying "0xc000000e : the file is missing or corrupt..."

For these BIOSes, it mandates memory mapping of the MBR and subsequent modification to clear the Active flag, on every boot. Can I do that with memdisk, or do I need Grub4Dos for this?



#174 Wonko the Sane

Wonko the Sane

    The Finder

  • Advanced user
  • 13748 posts
  • Location:The Outside of the Asylum (gate is closed)
  •  
    Italy

Posted 11 June 2015 - 07:54 PM

Well, wait until cdob has checked/verified the latest hinted approach, that needs not to make the Protective entry active.
 
It will boot to grub4dos and from it to *anything*.
 
Then I see no reason why the bootsector currently loading grub4dos cannot be modified into one directly loading GRUB2.
 
Allow me to doubt - however - that it is the BIOS that *needs* the protective MBR partition table entry to be marked as active, it is more likely that it is your BIOS in combination with the MBR code you are using for the hybridized MBR that poses this limitation. :dubbio:
Are you sure that the "No bootable disk..." comes from the BIOS (and not from the MBR code)?
And how does your BIOS behave with a second (fake/overlapping) active partition?
And how does it behave with a "superfloppy" approach?
What Sha0 reported:

By the way, there're some BIOSes which actually want one of the MBR partition entries to have the bootable bit set before they'll load the sector and execute the code. These BIOSes can never boot a protective MBR (which is defined to have the bootable bit clear). There is some (U)EFI firmware which won't recognize a disk as a GPT disk if it doesn't contain a protective MBR. Unfortunately, this means that there is no way to satisfy both of these with the same MBR.

seems to me slightly different. 
 
:duff:
Wonko

#175 milindsmart

milindsmart

    Frequent Member

  • Advanced user
  • 201 posts
  • Location:Bangalore
  •  
    India

Posted 12 June 2015 - 05:23 AM

Yeah I would have tried your technique myself except that my MBR-fiddling skills are a bit rusty, so its easier to screw up.

 

But it doesn't matter what code resides on the PMBR : I know that the message is from the BIOS, and not the MBR code itself. I will go back today and verify that however.

 

Fake/dummy partition marked active OTOH is a very good idea... Hopefully bootmgr doesn't balk at it. Is it standards compliant? IIRC some of your previous experiments were about semi-hybrid MBR with an MBR partition outside the GPT area.

 

By superfloppy approach do you mean a USB flash drive (which it is temporarily booting from currently)? Or one of your previous experiments where you completely disregard partitions and go for sector offsets? (again IIRC)







Also tagged with one or more of these keywords: bios, gpt, bootmgr, winload

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users