Windows Vista 启动时已经不再使用 ntldr 了,取而代之的是 winload,启动项目也不再从 boot.ini 读取,而是从注册表。
我们需要实现一个功能,重启 Vista 然后让它进入带网络链接的安全模式,这样使得我们可以从远端控制计算机进入安全模式进行一些维护和修复工作。以前这个工作是在 boot.ini 相关的启动项中添加参数 /safeboot 来实现的。
微软定义了一套名为 Boot Config Data 的数据类型,帮助我们控制系统的启动。关于启动类型有一下定义
typedef enum BcdOSLoaderElementTypes
{
BcdOSLoaderDevice_OSDevice = 0x21000001,
BcdOSLoaderString_SystemRoot = 0x22000002,
BcdOSLoaderBoolean_DetectKernelAndHal = 0x26000010,
BcdOSLoaderString_KernelPath = 0x22000011,
BcdOSLoaderString_HalPath = 0x22000012,
BcdOSLoaderString_DbgTransportPath = 0x22000013,
BcdOSLoaderInteger_NxPolicy = 0x25000020,
BcdOSLoaderInteger_PAEPolicy = 0x25000021,
BcdOSLoaderBoolean_WinPEMode = 0x26000022,
BcdOSLoaderBoolean_DisableVerifier = 0x26000023,
BcdOSLoaderBoolean_DisableCrashAutoReboot = 0x26000024,
BcdOSLoaderBoolean_UseLastGoodSettings = 0x26000025,
BcdOSLoaderBoolean_NoLowMemory = 0x26000030,
BcdOSLoaderInteger_RemoveMemory = 0x25000031,
BcdOSLoaderInteger_IncreaseUserVa = 0x25000032,
BcdOSLoaderBoolean_UseVgaDriver = 0x26000040,
BcdOSLoaderBoolean_DisableBootDisplay = 0x26000041,
BcdOSLoaderBoolean_DisableVesaBios = 0x26000042,
BcdOSLoaderInteger_ClusterModeAddressing = 0x25000050,
BcdOSLoaderBoolean_UsePhysicalDestination = 0x26000051,
BcdOSLoaderInteger_RestrictApicCluster = 0x25000052,
BcdOSLoaderBoolean_UseBootProcessorOnly = 0x26000060,
BcdOSLoaderInteger_NumberOfProcessors = 0x25000061,
BcdOSLoaderBoolean_ForceMaximumProcessors = 0x26000062,
BcdOSLoaderInteger_UseFirmwarePciSettings = 0x26000070,
BcdOSLoaderInteger_SafeBoot = 0x25000080,
BcdOSLoaderBoolean_SafeBootAlternateShell = 0x26000081,
BcdOSLoaderBoolean_BootLogInitialization = 0x26000090,
BcdOSLoaderBoolean_VerboseObjectLoadMode = 0x26000091,
BcdOSLoaderBoolean_KernelDebuggerEnabled = 0x260000A0,
BcdOSLoaderBoolean_DebuggerHalBreakpoint = 0x260000A1,
BcdOSLoaderBoolean_EmsEnabled = 0x260000B0
}BcdOSLoaderElementTypes;
看来安全模式启动是解决了,还有个小问题,我们是需要带网络的安全模式
typedef enum BcdLibrary_SafeBoot
{
SafemodeMinimal = 0,
SafemodeNetwork = 1,
SafemodeDsRepair = 2
}BcdLibrary_SafeBoot;
至于具体如何使用这些结构,看看
HKLM/BCD00000000/Objects 下的内容,你就清楚了。