Boot sequence when booting to a W7 VHD from bootmgr on HDD
#1
Posted 06 March 2012 - 04:18 AM
What I want to know is where does the bootmgr+bcd on the hard disk transfer control to when I choose "boot to vhd" from the boot menu. Since the VHD is a "hard disk" it has a MBR, one or more PBRs, and may have one or more bootmgr or ntldr on the various partitions in the VHD, and a partition could have a winload too.
What I'm looking for is for control to be transfered to one (say the active partition on the VHD) PBR. Or to the MBR of the VHD since it should boot the active partition (right ?).
#2
Posted 06 March 2012 - 06:19 AM
BCD entry tells bootmgr to load Windowssystem32winload.exe from a partition inside VHD and transfer control to winload.exe.
MBR code and PBR code inside VHD are not used.
#3
Posted 06 March 2012 - 06:36 AM
I see you left wimb alone for now and moved to the next target. You can also boot a native boot VHD from a drive without Windows installed on it. In both cases Win7 BCD boot record (store) for the VHD contains active partition offset and winload.exe path, and once the VHD is mounted (presumably by Bootmgr in real mode), Bootmgr transfers control to winload.exe on that VHD partition, and from their to kernel and protected mode drivers.
Why your style reminds me someone else though? What do you actually want to accomplish?
Would be interesting to find out, how exactly Bootmgr mounts the VHD and what code is used instead of Windows native Virtual Disk Driver and at what stage of the process. The VHD should be mounted, since winload.exe address in BCD is given as a file path, not as offset.
Once you are all set, try solving this challenge.
#4
Posted 06 March 2012 - 12:13 PM
just giving him a break ;-) . and Olof Lagerkvist too ;-) ;-) .gbrao
I see you left wimb alone for now and moved to the next target.
i more or less understood that. now. so if a vhd has multiple partitions, all but the first cannot be booted to ?In both cases Win7 BCD boot record for the VHD contains active partition offset and winload.exe address, and once the VHD is mounted by a Virtual Disk Driver, Bootmgr transfers control to winload.exe on that VHD partition.
Why your style reminds me someone else though?
that i did not understand.
i created a w7 vhd using wimbs tools. i moved it to another partition, used easybcd to make a new boor menu entry, when i booted the vhd i got a message saying windows not activated. even though it said activated before. that's when i realised even though i had used vhd boot before i never really understood the 'mechanics' involved.What do you actually want to accomplish?
thanks everyone, i'll try to hold back the Qs for a while.
#5
Posted 06 March 2012 - 12:30 PM
#6
Posted 06 March 2012 - 03:47 PM
MS didn't disclose details about BCD, Bootmgr and Virtual Disk Driver interaction during native OS boot from VHD. Presumable EasyBCD should write offset of an active partition to BCD, but this tool is more suited for beginners, and may not handle well multi-partition VHDs, as well as some other complex tasks despite having them in GUI due to diversity of OSs and approaches to boot various images. So you can use Visual BCD Editor or native BCD tools to edit Win BCD. The bootable partition still needs to be marked active.that's when i realised even though i had used vhd boot before i never really understood the 'mechanics' involved.
As to copying a VHD to a different HD volume, you didn't give enough details. If that volume is on a different HD placed into another PC, it may result in sufficient hardware differences to trigger re-activation prompt. One may still reactivate Win7 Ultimate without much problems, but some WES7 versions is harder to re-activate.
#7
Posted 08 March 2012 - 08:57 PM
The Windows NT 6 boot process and details of relevant BCD Store content and work are described in more particulars in that article. Of course, it doesn't address VHD boot, since their native boot was introduced in Win7, and wasn't supported in Vista. But the difference appears to be mostly in that Bootmgr now able to mount in real mode the VHD selected by a user from Windows Boot Menu (thus acting similar to G4D), and then transfer control to Winload.exe on its active partition, followed by loading NT kernel and protected mode Windows Virtual Disk Driver from that partition, which hot swaps the VHD mounted by the Bootmgr, thus allowing the boot process to proceed further.What I want to know is where does the bootmgr+bcd on the hard disk transfer control to when I choose "boot to vhd" from the boot menu.
Some more details are found in this thread When does Windows/bootmgr stop using BIOS INTterrupts, where the guy RulerOf inspired by karyonix and Sha0 wanted to make his own driver facing similar complexities and knowledge gaps hidden behind the familiar driver names.
#8
Posted 08 March 2012 - 09:49 PM
I suppose you could do something similar to what I did with the wimpatched (bootmgr) I did some time ago. That involved patching the bootmgr to behave differently and boot any index number (image) in a wim. If this patch is as "easy" as the wim one, I don't know. So the answer is like karyonix said, the sequence is hardcoded in bootmgr.i more or less understood that. now. so if a vhd has multiple partitions, all but the first cannot be booted to ?
#9
Posted 09 March 2012 - 03:51 AM
bcdboot v:windows /s c:
Then using Bcdedit command, one can add Boot Entries for each bootable volume on the same VHD to the common BCD Store and Windows Boot Menu - just follow Create Native Boot VHDs Tutorial linked below. The volume one wants to boot from next time must be marked Active for boot to succeed - one can do it from WinPE or running Diskpart before reboot, or possibly by other means. Any BCD Store Record can be edited later via Visual BCD Editor, or by running bcdboot & bcdedit commands again. Would be interesting to find out, if its possible to make a VHD volume active during boot process, but its hard to envision scenarios that mandate such requirement.
#10
Posted 09 March 2012 - 07:13 AM
#11
Posted 28 March 2012 - 02:31 AM
I need your help very badly. Some mft code, written by StCroixskipper. Please help........
Renee
Edited by renee, 28 March 2012 - 02:31 AM.
#12
Posted 28 March 2012 - 05:22 PM
If I can be of any help, I'll answer what I can. Do you have a more specific question regarding any particular issue you're facing right now? What exactly are you creating?Joakim,
I need your help very badly. Some mft code, written by StCroixskipper. Please help........
Renee
Perhaps you would like to start a new thread.
#13
Posted 28 March 2012 - 05:37 PM
It will list files...but get's an Access Violation when it goes to list the directory. Identical code works on 32 bit xp and does not work on Win7. Once again it has a file listing but does not have a directory with it as it gets a protection violation. It must be run with aministrators privilege.
Do you care to take a look at it?
Renee
Edited by renee, 28 March 2012 - 05:45 PM.
#14
Posted 28 March 2012 - 05:53 PM
Private Function PathFromFrn(ByVal Id As Long) As String
Dim fOk As Integer
Dim FileName As String = String.Empty
Dim UnicodeString As UNICODE_STRING
Dim ObjAttributes As OBJECT_ATTRIBUTES
Dim IoStatusBlock As IO_STATUS_BLOCK
Dim hFile As IntPtr ' out handle
Dim Buffer As IntPtr = Marshal.AllocHGlobal(4096) ' Raw buffer
Dim Refptr As IntPtr = Marshal.AllocHGlobal(8) ' 8 byte FileID - allocate 8 bytes of unmanaged memory
Dim ObjAtt As IntPtr = Marshal.AllocHGlobal(Marshal.SizeOf(ObjAttributes)) 'pointer to the unicode string struct
Static i As UInt32 : i += 1 ' If i = 100 Then Debugger.Break()
' pointer>>fileid
Marshal.WriteInt64(Refptr, 0, Id)
' 8 byte file id
UnicodeString.Length = 8
UnicodeString.MaximumLength = 8
UnicodeString.Buffer = Refptr
' copy unicode structure to pointer
Marshal.StructureToPtr(UnicodeString, ObjAtt, True)
' InitializeObjectAttributes Macro
ObjAttributes.Length = Marshal.SizeOf(ObjAttributes)
ObjAttributes.ObjectName = ObjAtt ' Or OBJ_KERNEL_HANDLE
ObjAttributes.RootDirectory = m_hCJ
ObjAttributes.Attributes = OBJ_CASE_INSENSITIVE
fOk = NtCreateFile(hFile, 0, ObjAttributes, IoStatusBlock, 0, 0, _ '<---- This routine get's an Access vilation here and fails to get a directory listing on 64 bit Win7, C0000022(?) here. It works normally on 32 bit XP.
FILE_SHARE_READ Or FILE_SHARE_WRITE, _
FILE_OPEN, FILE_OPEN_BY_FILE_ID Or FILE_OPEN_FOR_BACKUP_INTENT, 0, 0)
' If Not fOk Then Debugger.Break()
If fOk <> INVALID_HANDLE_VALUE Then
fOk = NtQueryInformationFile(hFile, IoStatusBlock, Buffer, 4096, FileNameInformationClass)
If fOk = 0 Then
' The first 4 bytes is the length
Dim FileLength As Integer = Marshal.ReadInt32(Buffer, 0)
' The filename is just after the first 4 bytes.
FileName = Marshal.PtrToStringUni(New IntPtr(Buffer.ToInt32() + 4), FileLength / 2)
End If
End If
' free allocated memory and handles
CloseHandle(hFile)
Marshal.FreeHGlobal(Buffer)
Marshal.FreeHGlobal(ObjAtt)
Marshal.FreeHGlobal(Refptr)
Return FileName
End Function
Actually I think this has something to do with it lackin OBJ_KERNEL_HANDLE BUT I dont know how to add it to the attributes.
Renee
Edited by renee, 28 March 2012 - 06:15 PM.
#15
Posted 28 March 2012 - 07:25 PM
#16
Posted 28 March 2012 - 07:46 PM
Renee
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users