【问题标题】:executing command after breakpoint with Windbg doesn't work?在 Windbg 断点后执行命令不起作用?
【发布时间】:2020-07-06 03:18:53
【问题描述】:

我正在使用这样的简单命令:

bp KernelFunctionAddress "dd esp L1;g"

但是当断点被击中时,我得到了这个:

休息

instruction exception - code 80000003 (first chance)
nt!KernelFunction:
87975cd0 8bff            mov     edi,edi

为什么会这样?为什么在断点被命中后命令没有被执行?我只是想转储 esp 的值并执行 g 命令,这样它就不会停止,但它不起作用?

假设 KernelFunction 是内核中的一个函数,不管是什么函数。我也在用windbg预览

当我也输入 .sxcmds 时,什么也没有发生:

0: kd> .sxcmds 

0: kd> bl
     0 e Disable Clear  86c20615     0001 (0001)  "dd esp L1;g"

0: kd> g
Break instruction exception - code 80000003 (first chance)
storport!RaDriverScsiIrp:
86c20615 8bff            mov     edi,edi

【问题讨论】:

  • 如果你只使用像bp KernelFunctionAddress ".echotime;gc"这样的东西会发生什么
  • 在用户模式下,它会说“Breakpoint 2 hit”,而不是“code 80000003”,但在内核模式下可能会有所不同。你确定断点真的被命中还是可能是别的什么?
  • @ThomasWeller 是的,它在函数开始时遇到断点,但没有打印任何内容,也没有执行 g 命令,所以我的命令的语法正确吗?
  • @LievenKeersmaekers 同样的事情,没有什么特别的被打印出来并且它不会继续执行它在地址处停止:中断指令异常 - 代码 80000003(第一次机会)89623e62 8bff mov edi,edi
  • 键入 .sxcmds 并查看是否为 bp 处理了任何第一次机会

标签: window kernel windbg


【解决方案1】:

不知道为什么?
如果你在 x86 目标上混合了 x64 windbg 或者反之亦然,它应该可以工作哇开始发挥作用

编辑
添加了一个带有 windbg 预览 winx 主机和目标(所有 x64)的内核会话

宿主windows和windbg预览版

PS C:\> Get-ComputerInfo -Property WindowsBuildLabEx,OsVersion,OsBuildNumber  
WindowsBuildLabEx                         OsVersion  OsBuildNumber
-----------------                         ---------  -------------
18362.1.amd64fre.19h1_release.190318-1202 10.0.18363 18363

PS C:\> (Get-AppPackage -Name Microsoft.windbg ).Version  
1.2001.2001.0

目标和运输

0: kd> vertarget
Windows 10 Kernel Version 17763 MP (2 procs) Free x64
17763.1.amd64fre.rs5_release.180914-1434

0: kd> dx Debugger.Sessions
Debugger.Sessions                
    [0x0]            : Remote KD: KdSrv:Server=@{<Local>},Trans=@{COM:Port=\\.\pipe\vmwpipe,Baud=115200,Pipe,Timeout=4000,Resets=2}

任意核函数上的断点

0: kd> bl
     0 e Disable Clear  fffff801`3ecea760     0001 (0001) nt!NtQueryDirectoryFile "dpp @rsp+50 l1;dt nt!_unicode_string poi(@rsp+50);.echo ===========;gc" 

血压及病情说明

NtQueryDirectoryFile 的原型为

__kernel_entry NTSYSCALLAPI NTSTATUS NtQueryDirectoryFile(
  HANDLE                 FileHandle,            == @rcx
  HANDLE                 Event,                 == @rdx
  PIO_APC_ROUTINE        ApcRoutine,            == @r8
  PVOID                  ApcContext,            == @r9
  PIO_STATUS_BLOCK       IoStatusBlock,         == [rsp+28]
  PVOID                  FileInformation,       == [rsp+30]
  ULONG                  Length,                == [rsp+38]
  FILE_INFORMATION_CLASS FileInformationClass,  == [rsp+40]
  BOOLEAN                ReturnSingleEntry,     == [rsp+48]
  PUNICODE_STRING        FileName,              == [rsp+50]  <==>  printing this
  BOOLEAN                RestartScan            == [rsp+58]
);

结果

0: kd> g
fffffd0e`2ca835d8  ffff8e07`848f9628 00000000`00160016
 "diagwrn.xml"
   +0x000 Length           : 0x16
   +0x002 MaximumLength    : 0x16
   +0x008 Buffer           : 0xffff8e07`849d37f6  "diagwrn.xml"
===========
fffffd0e`2c0c05d8  ffff8e07`848f9628 00000000`00140014
 "SRUtmp.log"
   +0x000 Length           : 0x14
   +0x002 MaximumLength    : 0x14
   +0x008 Buffer           : 0xffff8e07`849d37ea  "SRUtmp.log"
===========
fffffd0e`2ca835d8  ffff8e07`848fc528 00000000`001a001a
 "EventStore.db"
   +0x000 Length           : 0x1a
   +0x002 MaximumLength    : 0x1a
   +0x008 Buffer           : 0xffff8e07`84a6ca60  "EventStore.db"
===========
fffffd0e`2c1df5d8  ffff8e07`848fc528 00000000`00100010
 "data.dat"
   +0x000 Length           : 0x10
   +0x002 MaximumLength    : 0x10
   +0x008 Buffer           : 0xffff8e07`7f0877fe  "data.dat"
===========
fffffd0e`2c66f898  ffff8e07`82f81548 00000000`006c006c
 "ScreenOnPowerStudyTraceSession-2020-07-05-12-01-44.etl"
   +0x000 Length           : 0x6c
   +0x002 MaximumLength    : 0x6c
   +0x008 Buffer           : 0xffff8e07`7f6cdb9a  "ScreenOnPowerStudyTraceSession-2020-07-05-12-01-44.etl"
===========

编辑结束

我刚刚在经典 x64 windbg 18362 winx 上使用 x64 上的任意函数对用户模式 ​​x64 二进制文件进行了任意测试,它似乎可以正常工作

DispatchMessage windows 消息结构 __TAGMSG 包含 WM_xxx #defines

0:005> bl
     0 e Disable Clear  00007ffe`2e4f5410     0001 (0001)  0:**** USER32!DispatchMessageW ".echotime;.echo====================;dd @rcx l4;gc"
0:005> g
Debugger (not debuggee) time: Sat Jul  4 00:26:34.254 2020 
====================
0000001d`7675d6b0  00140494 00000000 00000113 00000000
Debugger (not debuggee) time: Sat Jul  4 00:26:35.004 2020 
====================
0000001d`7675d6b0  001c0628 00000000 00000060 00000000
Debugger (not debuggee) time: Sat Jul  4 00:26:49.047 2020 
====================
0000001d`7675d6b0  001606ac 00000000 0000000f 00000000
Debugger (not debuggee) time: Sat Jul  4 00:26:49.063 2020 
====================
0000001d`7675d6b0  000d06a6 00000000 00000118 00000000
Debugger (not debuggee) time: Sat Jul  4 00:26:50.047 2020 
====================
0000001d`7675d6b0  000d06a6 00000000 00000118 00000000
Debugger (not debuggee) time: Sat Jul  4 00:26:51.047 2020 
====================
0000001d`7675d6b0  001c0628 00000000 00000060 00000000
Debugger (not debuggee) time: Sat Jul  4 00:26:51.094 2020 
====================
0000001d`7675d6b0  001c0628 00000000 00000060 00000000
Debugger (not debuggee) time: Sat Jul  4 00:26:51.094 2020 
====================
0000001d`7675d6b0  001606ac 00000000 0000000f 00000000
Debugger (not debuggee) time: Sat Jul  4 00:26:51.188 2020 
====================
(2070.20e0): Break instruction exception - code 80000003 (first chance)
ntdll!DbgBreakPoint:    00007ffe`2fd3faa0 cc              int     3

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-08
    • 2014-02-11
    • 1970-01-01
    • 2016-11-13
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多