windbg命令笔记

断点部分

  • 命令帮助 .hh help_command
  • 设置断点 bp / bm(breakpoint set by symbol)

条件断点使用".if(){} .else{}"
如果说需要对[ebp-4]大于40 的时候停止,那么条件断点应该设置为:

//command intro:
// poi a == [a]
// {}   //means bp hit.
// gc   Go Continue 错误-update5.17   ×
//gc (Go from Conditional Breakpoint)  √
bp  bp_addr ".if(poi (ebp-4) > 28h) {} .else {gc}"

如果源码为:

#include <stdio.h>

void loop(int a,int b)
{
    int i;
    for ( i = 0; ;i++)
    {
        if (i == 100000)
        {
            break;
        }
        printf("%d\n",i);
    }
}

int main(int argc,char **argv)
{
    int a = 1;
    int b = 0;
    int sum = a+b;
    loop(a,b);
    return 0;
}

在windbg下条件断点

0:000> bp 401055 ".if(poi (ebp-4) >1025){} .else {gc}"
breakpoint 0 redefined
0:000> g
eax=00001026 ebx=7ffd7000 ecx=00424a60 edx=00424a60 esi=00baf770 edi=0012ff18
eip=00401055 esp=0012fec8 ebp=0012ff18 iopl=0         nv up ei ng nz na po cy
cs=001b  ss=0023  ds=0023  es=0023  fs=003b  gs=0000             efl=00000283
windbg_test!loop+0x35:
00401055 8b4dfc          mov     ecx,dword ptr [ebp-4] ss:0023:0012ff14=00001026

注意:1025 是十六进制,不是十进制。poi 的优先级比-高,所以应该加括号。

0:000> dd ebp-4 l1
0012ff14  00001026 
0:000> dd ebp l1
0012ff18  0012ff80 
0:000> dd 12ff80-4 l1
0012ff7c  00000001 
0:000>  dd poi ebp - 4 l1
0012ff7c  00000001 
0:000> dd poi (ebp-4) l1
00001026  ???????? 
------------------
result:
ebp = 12ff18   
[ebp-4]=poi(ebp-4) =[12ff14]=1026h
poi ebp -4 = (poi ebp) -4 = [ebp]-4 =[12ff18]- 4 = 12ff80 - 4 = 12ff7c

函数调用栈回朔

0:000> k
ChildEBP RetAddr  
0012ff18 004010cc windbg_test!loop+0x35 [C:\VC6\MyProjects\windbg_test\example.c @ 12]
0012ff80 004012a9 windbg_test!main+0x3c [C:\VC6\MyProjects\windbg_test\example.c @ 21]
0012ffc0 7c817067 windbg_test!mainCRTStartup+0xe9 [crt0.c @ 206]
0012fff0 00000000 kernel32!BaseProcessStart+0x23
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值