news 2026/4/16 16:49:48

Boot Debugger Using的来源BlOsLoader函数中的BdInitDebugger和D:\srv03rtm\base\boot\loader_dbg.inc文件的关系----特别重要

作者头像

张小明

前端开发工程师

1.2k 24
文章封面图
Boot Debugger Using的来源BlOsLoader函数中的BdInitDebugger和D:\srv03rtm\base\boot\loader_dbg.inc文件的关系----特别重要

Boot Debugger Using的来源BlOsLoader函数中的BdInitDebugger和D:\srv03rtm\base\boot\loader_dbg.inc文件的关系----特别重要

ntldr改为ntldr_bak,然后ntldr_dbg改为ntldr

后可以调试NTLDR了!!!

第一部分:

第二部分:

D:\srv03rtm\base\boot>grep "Boot Debug" -nr D:\srv03rtm\base\boot
D:\srv03rtm\base\boot/bd/i386/port.c:58: TEXT("\nBoot Debugger Using: COM%d (Baud Rate %d)\n"),
D:\srv03rtm\base\boot/bd/ia64/miscc.c:11: This module contains utility functions used by IA-64 Boot Debugger.
D:\srv03rtm\base\boot/bd/ia64/port.c:60: TEXT("\r\nBoot Debugger Using: COM%d (Baud Rate %d)\r\n"),
D:\srv03rtm\base\boot/bd/init.c:156: DbgPrint("BD: Boot Debugger Initialized\n");


LOGICAL
BdPortInitialize(
IN ULONG BaudRate,
IN ULONG PortNumber,
OUT PULONG BdFileId
)

/*++

Routine Description:

This functions initializes the boot debugger com port.

Arguments:

BaudRate - Supplies an optional baud rate.

PortNumber - supplies an optinal port number.

Returned Value:

TRUE - If a debug port is found.

--*/

{
//
// Initialize the specified port.
//
if (!BlPortInitialize(BaudRate, PortNumber, NULL, FALSE, BdFileId)) {
return FALSE;
}
_stprintf(DebugMessage,
TEXT("\nBoot Debugger Using: COM%d (Baud Rate %d)\n"),
PortNumber,
BaudRate);

//
// We cannot use BlPrint() at this time because BlInitStdIo() has not been called, which is
// required to use the Arc emulator code.
//
TextStringOut(DebugMessage);
return TRUE;
}

D:\srv03rtm\base\boot>grep "BdPortInitialize" -nr D:\srv03rtm\base\boot
D:\srv03rtm\base\boot/bd/bd.h:161:BdPortInitialize(
D:\srv03rtm\base\boot/bd/i386/port.c:26:BdPortInitialize(
D:\srv03rtm\base\boot/bd/ia64/port.c:28:BdPortInitialize(
D:\srv03rtm\base\boot/bd/init.c:126: if (BdPortInitialize(BaudRate, PortNumber, &BdFileId) == FALSE) {

第三部分:

VOID
BdInitDebugger (
IN PCHAR LoaderName,
IN PVOID LoaderBase,
IN PCHAR Options
)

/*++

Routine Description:

This routine initializes the boot kernel debugger.

Arguments:

Options - Supplies a pointer to the the boot options.

Stop - Supplies a logical value that determines whether a debug message
and breakpoint are generated.

Return Value:

None.

--*/

{


//
// Attempt to initialize the debug port.
//
if (BdPortInitialize(BaudRate, PortNumber, &BdFileId)== FALSE) {
return;
}

第四部分:


D:\srv03rtm\base\boot>grep "BdInitDebugger" -nr D:\srv03rtm\base\boot
D:\srv03rtm\base\boot/bd/init.c:38:BdInitDebugger (
D:\srv03rtm\base\boot/bldr/i386/parsboot.c:579: // pass to BdInitDebugger to handle.
D:\srv03rtm\base\boot/bldr/i386/parsboot.c:592: BdInitDebugger((PCHAR)OsLoaderName, (PVOID)OsLoaderBase, pCurrent);
D:\srv03rtm\base\boot/bldr/osloader.c:1118: DBGTRACE( TEXT("About to BdInitDebugger. Base = %x\r\n"), LoaderBase );
D:\srv03rtm\base\boot/bldr/osloader.c:1120: BdInitDebugger((PCHAR)OsLoaderName, LoaderBase, ENABLE_LOADER_DEBUG);
D:\srv03rtm\base\boot/bldr/osloader.c:1122: DBGTRACE( TEXT("Back From BdInitDebugger.\r\n") );
D:\srv03rtm\base\boot/bldr/osloader.c:1126: BdInitDebugger((PCHAR)OsLoaderName, 0, NULL);
D:\srv03rtm\base\boot/inc/bldr.h:422:BdInitDebugger (
D:\srv03rtm\base\boot/lib/i386/memory.c:849: BdInitDebugger((PCHAR)OsLoaderName, (PVOID)OsLoaderBase, ENABLE_LOADER_DEBUG);
D:\srv03rtm\base\boot/lib/i386/memory.c:851: BdInitDebugger((PCHAR)OsLoaderName, (PVOID)OsLoaderBase, NULL);
D:\srv03rtm\base\boot/oschoice/oschoice.c:1254: BdInitDebugger("oschoice.exe", LoaderBase, ENABLE_LOADER_DEBUG);
D:\srv03rtm\base\boot/oschoice/oschoice.c:1258: BdInitDebugger("oschoice.exe", LoaderBase, NULL);
D:\srv03rtm\base\boot/setup/setup.c:565: BdInitDebugger((PCHAR)OsLoaderName, LoaderBase, ENABLE_LOADER_DEBUG);
D:\srv03rtm\base\boot/setup/setup.c:569: BdInitDebugger((PCHAR)OsLoaderName, 0, NULL);

ARC_STATUS
BlOsLoader (
IN ULONG Argc,
IN CHAR * FIRMWARE_PTR * FIRMWARE_PTR Argv,
IN CHAR * FIRMWARE_PTR * FIRMWARE_PTR Envp
)

/*++

Routine Description:

This is the main routine that controls the loading of the NT operating
system on an ARC compliant system. It opens the system partition,
the boot partition, the console input device, and the console output
device. The NT operating system and all its DLLs are loaded and bound
together. Control is then transfered to the loaded system.

Arguments:

Argc - Supplies the number of arguments that were provided on the
command that invoked this program.

Argv - Supplies a pointer to a vector of pointers to null terminated
argument strings.

Envp - Supplies a pointer to a vector of pointers to null terminated
environment variables.

Return Value:

EBADF is returned if the specified OS image cannot be loaded.

--*/

{

。。。

//
// Initialize the OS loader console input and output.
//
Status = BlInitStdio(Argc, Argv);

if (Status != ESUCCESS) {
return Status;
}


//
// Initialize the boot debugger for platforms that directly load the
// OS Loader.
//
// N.B. This must occur after the console input and output have been
// initialized so debug messages can be printed on the console
// output device.
//

#if defined(_ALPHA_) || defined(ARCI386) || defined(_IA64_)
//
// Locate the memory descriptor for the OS Loader.
//

ProgramDescriptor = NULL;
while ((ProgramDescriptor = ArcGetMemoryDescriptor(ProgramDescriptor)) != NULL) {
if (ProgramDescriptor->MemoryType == MemoryLoadedProgram) {
break;
}
}

//
// If the program memory descriptor was found, then compute the base
// address of the OS Loader for use by the debugger.
//

LoaderBase = &__ImageBase;

//
// Initialize traps and the boot debugger.
//
#if defined(ENABLE_LOADER_DEBUG)

#if defined(_ALPHA_)
BdInitializeTraps();
#endif

DBGTRACE( TEXT("About to BdInitDebugger. Base = %x\r\n"), LoaderBase );

BdInitDebugger((PCHAR)OsLoaderName, LoaderBase, ENABLE_LOADER_DEBUG);

DBGTRACE( TEXT("Back From BdInitDebugger.\r\n") );

#else

BdInitDebugger((PCHAR)OsLoaderName, 0, NULL);

#endif

#endif

第五部分:D:\srv03rtm\base\boot\loader_dbg.inc文件内容:

#
# set the flags necessary to build debug enabled boot loaders
#

#
# the ; is a temporary hack to make this compile until is made
# clear how to make the ##'s not get translated into CR's
#

ENABLE_LOADER_DEBUG=debugport=com1;debugbaudrate=115200

#
#
#

!include $(PROJECT_ROOT)\boot\loader.inc

版权声明: 本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若内容造成侵权/违法违规/事实不符,请联系邮箱:809451989@qq.com进行投诉反馈,一经查实,立即删除!
网站建设 2026/4/15 16:29:57

Linux文件目录权限

一 权限基本表示1. 权限位结构-rwxrwxrwx ↑ ↑↑↑ ↑↑↑ ↑↑↑ │ │││ │││ │││ │ │││ │││ │└─ 其他用户(others)执行权限 │ │││ │││ └── 其他用户写权限 │ │││ ││└─── 其他用户读权限 │ │││ ││ │ │││ │└── 所属组(gr…

作者头像 李华
网站建设 2026/4/16 11:08:27

CSDN大模型学习指南:小白程序员必备的8大原则,助你轻松掌握AI产品开发精髓!(收藏版)

本文介绍了AI产品经理的八大核心原则,涵盖STP市场细分、目标市场定位、精益产品开发、任务导向指标、构建持续上下文壁垒、量化评测体系、AI错误处理机制以及Token成本控制等关键要素。旨在帮助小白和程序员快速了解AI产品开发流程,掌握AI产品市场匹配、…

作者头像 李华
网站建设 2026/4/16 11:06:01

多号发圈终于不用来回切换了,3步搞定!

手里管着3个、5个甚至十几个微信号,每天要同步发产品资讯、活动预告、客户案例,光是来回切换账号、重复复制粘贴内容,就要花掉1-2个小时;节假日赶流量高峰,提前编辑好几十条文案,熬夜守到零点手动发送&…

作者头像 李华