在vista之前,windows操作系统的引导程序是ntldr,它负责将cpu从实模式转换到保护模式,加载内核文件以及启动类型的驱动程序,并最终将控制权传递给内核文件的入口函数kisystemstartup。
从任务角度来看,NTLDR内部可分为两个部分:一部分负责接收控制权、进行模式转换和硬件检查,通常称为boot;另一部分负责加载内核文件并为其运行做准备,通常称为OsLoader。
到了Vista,boot和OsLoader被分成两个独立的程序文件,即BootMgr和WinLoad.exe。下图展示了BootMgr和WinLoad之间的关系及其在启动过程中的作用。

与调试NTLDR需要替换check版本的NTLDR不同,BootMgr和WinLoad内部已经集成了调试引擎,这与内核的做法一致。因此,要调试BootMgr和WinLoad,只需启动其内部的调试引擎,而无需替换这些程序文件。
要启用BOOTMGR调试,可以在具有管理员权限的控制台窗口中执行以下命令:
<pre class="brush:php;toolbar:false;">bcdedit /set {bootmgr} bootdebug on
bcdedit /set {bootmgr} debugtype serial
bcdedit /set {bootmgr} debugport 1
bcdedit /set {bootmgr} baudrate 115200如果使用1394连接,则应设置为:
<pre class="brush:php;toolbar:false;">bcdedit /set {bootmgr} debugtype 1394
bcdedit /set {bootmgr} channel 22完成这些设置后,重启系统。在BIOS阶段之后,屏幕会保持黑色,看起来无法继续启动,实际上这是BootMgr在等待与调试器建立连接。连接好电缆后,启动WinDBG调试器,连接建立后会显示类似以下信息:
<pre class="brush:php;toolbar:false;">Microsoft (R) Windows Debugger Version 6.9.0003.113 X86 Copyright (c) Microsoft Corporation. All rights reserved. <p>Opened \.com1 Waiting to reconnect… BD: Boot Debugger Initialized Connected to Windows Boot Debugger 6000 x86 compatible target, ptr64 FALSE Kernel Debugger connection established. Symbol search path is: SRV<em>d:symbols</em><a href="https://www.php.cn/link/f3a45758fe1e808fd1d41b62d7784a93">https://www.php.cn/link/f3a45758fe1e808fd1d41b62d7784a93</a> Executable search path is: Windows Boot Debugger Kernel Version 6000 UP Free x86 compatible Product: unknown <ffffffff>, suite: SmallBusiness Enterprise BackOffice CommunicationServer TerminalServer SmallBusinessRestricted EmbeddedNT DataCenter SingleUserTS Personal Blade EmbeddedRestricted SecurityAppliance StorageServer ComputeServer Primary image base = 0x00400000 Loaded module list = 0x004ffff8 System Uptime: not available</ffffffff>
其中,0x00400000是BootMgr模块的基地址。BootMgr的主要代码是32位的,仅有一小部分16位代码用于从固件那里接管控制权。此外,BootMgr在保护模式下工作,但未启用分页机制,仅使用分页机制。通过观察CR0和CR3寄存器的值可以验证这一点:
<pre class="brush:php;toolbar:false;">kd> r cr0 cr0=00000011 kd> r cr3 cr3=00000000
连接建立后,WinDBG会让BootMgr继续运行,通常BootMgr会显示启动菜单。此时按下Ctrl+Break键,BootMgr会中断到调试器中,可以执行各种内核调试命令,例如:
<pre class="brush:php;toolbar:false;">kd> lm start end module name 00400000 00514000 bootmgr (pdb symbols) d:symbolsootmgr.pdb819F5A93195D47E3857ED729B0D341191ootmgr.pdb
微软的符号服务器提供了BootMgr的公开符号文件,因此设置好符号服务器路径后,WinDBG可以自动下载合适的符号文件。
<pre class="brush:php;toolbar:false;">kd> x bootmgr!* 0042b3fd bootmgr!TpmApiAuthSessCreateOSAP = <no information type=""> 0044c4da bootmgr!CmpGetIndexElementSize = <no information type=""> 00452d54 bootmgr!RcConsoleBaudRates = <no information type=""> 0042f56f bootmgr!OsxmlBrowser::~OsxmlBrowser = <no information type=""> 00431b10 bootmgr!XslStylesheet::getContents = <no information type=""> ...
也可以使用栈回溯命令来观察函数调用情况:
<pre class="brush:php;toolbar:false;">kd> kv ChildEBP RetAddr Args to Child 00061e34 00430c7e 001b6380 00000001 00061e90 bootmgr!DbgBreakPoint 00061e44 0043024f 00061e8c 001b63b8 00061e88 bootmgr!BlXmlConsole::getInput+0xe 00061e90 004024c1 00000002 004021f3 00000000 bootmgr!OsxmlBrowser::browse+0xe0 00061e98 004021f3 00000000 00000000 00061f8f bootmgr!BmDisplayGetBootMenuStatus+0x13 (FPO: [0,0,1]) 00061f10 004017a4 00104f9c 001f4280 00000002 bootmgr!BmDisplayBootMenu+0x174 00061f6c 00401261 00104f9c 00061f9c 00000002 bootmgr!BmpGetSelectedBootEntry+0xf8 00061ff0 000209ea 000249a8 7d8b697c 74ff8514 bootmgr!BmMain+0x261 WARNING: Frame IP not in any known module. Following frames may be wrong. 00000000 f000ff53 f000e2c3 f000ff53 f000ff53 0x209ea 00000000 00000000 f000e2c3 f000ff53 f000ff53 0xf000ff53
通过上述栈回溯可以看出,BmMain是BootMgr的32位代码入口函数;BmDisplayBootMenu负责显示和管理启动菜单。BmMain下方的几个栈帧可能是16位代码执行时留下的痕迹。
在BmpGetSelectedBootEntry函数的返回地址00401261设置断点后,按F5让目标系统继续执行。此时目标系统的菜单可以活动,选择引导Vista的一项后,断点立即命中,单步跟踪可以看到BootMgr加载WinLoad的过程,其中的主要函数有:
<pre class="brush:php;toolbar:false;">bootmgr!BmpLaunchBootEntry bootmgr!ImgArchPcatStartBootApplication
在将执行权交给WinLoad之前,BootMgr会调用BlBdStop与调试器断开连接。
如果要继续调试WinLoad,需先启用其调试引擎,命令为:
<pre class="brush:php;toolbar:false;">bcdedit /set {GUID} bootdebug onWinLoad启动后,如果调试引擎已启用,它也会与调试器建立连接,并显示类似的连接信息。以下是WinLoad中的几个重要函数:
<pre class="brush:php;toolbar:false;">winload!MmArchInitialize winload!ArchBuildKernelGdt winload!OslArchpKernelSetupPhase0 winload!OslArchTransferToKernel
其中最后一个函数负责将执行权转交给内核。在移交执行权之前,WinLoad也会调用BlBdStop函数来断开调试会话。如果要继续调试内核,应先启用内核调试,然后在内核阶段再与其建立连接。
如果系统是从休眠中恢复,BootMgr会加载WinResume,WinResume也集成了调试引擎,因此也可以对其进行跟踪和调试。例如,以下是WinResume程序初始化的栈回溯:
<pre class="brush:php;toolbar:false;">kd> kPL ChildEBP RetAddr 00120ad8 0059da7f winresume!RtlpBreakWithStatusInstruction 00120cf0 0059d97d winresume!vDbgPrintExWithPrefixInternal+0x100 00120d00 0059641a winresume!DbgPrint+0x11 00120d28 00587550 winresume!BlStatusPrint+0x60 00120d6c 00585524 winresume!ConsoleFirmwareOpen+0x64 00120d88 0058373d winresume!ConsoleOpen+0x58 00120da8 00583242 winresume!BlpDeviceOpen+0x13c 00120dc4 0058bd5b winresume!BlDeviceOpen+0x16 00120ed8 0058bcc7 winresume!DsppRegisterConsole+0x56 00120f6c 0058b999 winresume!DsppInitialize+0xfd 00120f78 005950a2 winresume!BlpDisplayInitialize+0x26 00120f94 0057c0c6 winresume!InitializeLibrary+0x176 00120fe8 004444fa winresume!HbMain+0xc6 WARNING: Frame IP not in any known module. Following frames may be wrong. 00000000 f000eef3 0x4444fa 00000000 00000000 0xf000eef3
总之,在安装好的Vista系统中,已内建四个调试引擎,分别位于BootMgr、WinLoad、WinResume和NTOSKRNL.exe中,可以同时启用这些调试引擎,也可以根据需要启用其中某一个。前三个调试引擎是基于内核中的内核调试引擎(KD)克隆的,它们使用与KD兼容的协议。对于调试器(WinDBG)来说,它并不区分对方是真正的KD还是KD的克隆。因此在BootMgr中断调试会话时,WinDBG提示的信息与内核退出时的信息相同。
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容,请发送邮件至举报,一经查实,本站将立刻删除。
发布者:全栈程序员栈长,转载请注明出处:https://www.php.cn/link/030114f8f0e921e7b452349373998ecf
以上就是vista开机启动项怎么设置_windows7/vista with slic loader的详细内容,更多请关注php中文网其它相关文章!
Windows激活工具是正版认证的激活工具,永久激活,一键解决windows许可证即将过期。可激活win7系统、win8.1系统、win10系统、win11系统。下载后先看完视频激活教程,再进行操作,100%激活成功。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号