Unable to debug the kernel driver using Serial cable

那年仲夏 提交于 2020-01-25 12:55:07

问题


I am new to driver stuff. I have tried to debug the kernel driver using serial COM port without success. Could someone show me proper direction how to fix the problem?

I am seeing the following messages on kd console.

ERROR: DavReadRegistryValues/RegQueryValueExW(4). WStatus = 127
ERROR: DavReadRegistryValues/RegQueryValueExW(5). WStatus = 127
ERROR: DavReadRegistryValues/RegQueryValueExW(6). WStatus = 127

At this time, I pressed Ctl^D and kd console and I am seeing
READ: Timeout.
READ: Wait for type 7 packet
READ: Timeout.
READ: Wait for type 7 packet
READ: Timeout.

EDIT: The problem is fixed with WinDbg. I changed the baud rate to 115200 and inserted break (Ctr ^ Break) before Target system completely boots up. I am able to debug the code now. If I insert break after the target system completely boots up then I am unable to debug. I don't know exact reason for it but Happy with current situation.

Here are the things I have done

1) Prepared Target system for debug mode by editing the boot.ini file. Added     “/debugport=com1 /baudrate=57600”  to boot.ini

2) On Host system, started kd.exe and seeing the following output

C:\Program Files\Debugging Tools for Windows>kd.exe -k com:port=1,baud=57600
Microsoft (R) Windows Debugger  Version 6.6.0007.5
Copyright (c) Microsoft Corporation. All rights reserved.
Opened \\.\com1
Waiting to reconnect...

3) Rebooted Target system, system boots slowly than normal boot and I am seeing some     messages <<below>> on Host system console

4) At this time, If I press Ctl-C on KD console then Target system freezes (hangs)         and proceeds if I enter "g" at kd prompt.  This means that Target system     is going to debug mode

5) However After some time I am seeing the following message on the host machine console

ERROR: DavReadRegistryValues/RegQueryValueExW(4). WStatus = 127  
ERROR: DavReadRegistryValues/RegQueryValueExW(5). WStatus = 127  
ERROR: DavReadRegistryValues/RegQueryValueExW(6). WStatus = 127  

After the above message there are no messages appearing on kd console.

I searched internet for "ERROR: DavReadRegistryValues/RegQueryValueExW(6). WStatus =     127" but didn't get proper reason for it.

I pressed Ctl^D and kd console and I am seeing 
READ: Timeout.  
READ: Wait for type 7 packet  
READ: Timeout.  
READ: Wait for type 7 packet  
READ: Timeout.  

I have tried above steps with following options ..but no luck

I disabled firewall & antivirus software on both Host and Target systems. 
I unplugged and re-plugged serial cable connection between each trail
I have logged-in with Domain account local account with Admin rights 


Can someone show some light on how to proceed? Both systems are running on XP 32bit     SP3 OS.

Thanks King


回答1:


Are you sure you have a good serial connection?

The cable must be a null modem cable - you should verify this using a terminal program (without kernel debugging enabled on the target). Run the program (HyperTerminal or whatever) on both the target and the host machines (remember, like I said before kernel debugging over that port must not be enabled on the target or the port can't be opened).

You can find some links to free terminal programs (I don't think Microsoft provides HyperTerminal anymore since Vista) here: http://www.lvr.com/serport.htm#software

Type some characters on one machine, and make sure they show up on the other side. Do the same on the other machine.

If you can't do this, then there's no serial connection and you'll have to get a null modem cable or adapter. There's no point in trying to get KD to work over that connection until you can do this.

Also, remember that the COM port used by kernel debugging on the target must be a standard 8250 family UART (usually a 16550 or better nowadays, and usually baked into the motherboard chipset). It can't be a USB serial port connector (although that kind will work fine on the host side, since on the host kd.exe is a regular Win32 program).

Edit:


If it's not a serial connection problem, the problem might be that your target doesn't support configuration using boot.ini. Since Vista, boot parameters have been specified using the "Boot Configuration Database" (BCD) which is manipulated with a program like bcdedit.exe. Unfortunately, configuring a system using BCDedit is much more complicated than just editing a simple text file like boot.ini.

You should read the debugger helpfile section "Configuring Software on the Target Computer"; in particular the "Using Boot Parameters" part. there are details there on how bcdedit can be used to enable debugging on Vista and later systems.




回答2:


The other thing you can test to see if debugging is working on the target is to invoke kd -kl on the target - if it tells you debugging isn't enabled, you haven't set up boot.ini correctly.



来源:https://stackoverflow.com/questions/1735455/unable-to-debug-the-kernel-driver-using-serial-cable

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!