windbg命令补充

//重置本地符号路径
0:015> .sympath d:\ddlxsyms1;
Symbol search path is: d:\ddlxsyms1
Expanded Symbol search path is: d:\ddlxsyms1
//增加一个本地符号路径
0:015> .sympath+ d:\ddlxsyms2;
Symbol search path is: d:\ddlxsyms1;d:\ddlxsyms2
Expanded Symbol search path is: d:\ddlxsyms1;d:\ddlxsyms2


//重置一个指向微软符号服务器的路径
0:015> .symfix c:\symbols;
0:015> .sympath
Symbol search path is: srv*
Expanded Symbol search path is: SRV*c:\symbols;*http://msdl.microsoft.com/download/symbols


0:000> .frame 1
01 0012ede4 00414839 PEViewer!CPeListCtrl::ShowList+0xd8 [c:\documents and settings\administrator\桌面\peviewer0.9\peviewer\pelistctrl.cpp @ 77]
0:000> dv /i /t /v
prv local  0012eddc class CPeListCtrl * this = 0x0012fbb0
prv param  0012edec int flag = 0n5
prv param  0012edf0 int index = 0n0
prv param  0012edf4 int isDblclick = 0n1
/i 显示变量是局部的、全局的、参数、还是函数等信息
/v 显示变量所在地址
/t 显示变量的类型


如只想让某个线程激活断点,可以使用
~ 1 bp CPeListCtrl::ShowExportFuncs 对一号线程下断点



0:000> version
Windows XP Version 2600 (Service Pack 3) MP (2 procs) Free x86 compatible
Product: WinNt, suite: SingleUserTS
kernel32.dll version: 5.1.2600.5512 (xpsp.080413-2111)
Machine Name:
Debug session time: Sun Sep 15 01:15:25.871 2013 (UTC + 8:00)
System Uptime: 0 days 4:42:50.824
Process Uptime: 0 days 3:46:38.188
  Kernel time: 0 days 0:00:03.296
  User time: 0 days 0:00:01.078
Live user mode: <Local>

Microsoft (R) Windows Debugger Version 6.12.0002.633 X86
Copyright (c) Microsoft Corporation. All rights reserved.

command line: '"C:\Program Files\Debugging Tools for Windows (x86)\windbg.exe" '  Debugger Process 0xB68 
dbgeng:  image 6.12.0002.633, built Tue Feb 02 04:08:31 2010
        [path: C:\Program Files\Debugging Tools for Windows (x86)\dbgeng.dll]




生成DMP命令: .dump
生成mini dmp
代码:
0:001> .dump /m c:\dump3.dmp
Creating c:\dump3.dmp - mini user dump
Dump successfully written
生成full dmp
代码:
0:001> .dump /f c:\dump1.dmp
Creating c:\dump1.dmp - user full dump
Dump successfully written





0:000> bm peviewer!CPeListCtrl::Show*
  1: 004221b0 @!"PEViewer!CPeListCtrl::ShowImportDir"
  2: 004226e0 @!"PEViewer!CPeListCtrl::ShowSectionHeader"
  3: 00423a00 @!"PEViewer!CPeListCtrl::ShowImportFuncs"
  4: 0041eb50 @!"PEViewer!CPeListCtrl::ShowList"
  5: 0041f840 @!"PEViewer!CPeListCtrl::ShowFileHeader"
  6: 00423f00 @!"PEViewer!CPeListCtrl::ShowExportFuncs"
  7: 0041eef0 @!"PEViewer!CPeListCtrl::ShowDosHeader"
  8: 00420700 @!"PEViewer!CPeListCtrl::ShowOptionalHeader"
  9: 00423270 @!"PEViewer!CPeListCtrl::ShowExportDir"


我想知道每次breakdll!GetRandom执行完的返回值是多少,这个时候的写法为:

代码:
ntdll!DbgBreakPoint:
7c92120e cc              int     3
0:000> bu breakdll!GetRandom "gu;.printf \"GetRandom ret: %d\\n\", @eax;g;"




//ascii字符串条件断点设置方法

代码:
0:000> bp kernel32!LoadLibraryA "as /ma ${/v:dllname} poi(esp+4); .if($sicmp(\"${dllname}\",\"breakdll.dll\")==0){.echo ${dllname};}.else{gc;}"
0:000> g
*** WARNING: Unable to verify checksum for break.exe
breakdll.dll
eax=cccccccc ebx=7ffd8000 ecx=00000000 edx=00000001 esi=0012fe78 edi=0012ff68
eip=7c801d7b esp=0012fe70 ebp=0012ff68 iopl=0         nv up ei pl nz na pe nc
cs=001b  ss=0023  ds=0023  es=0023  fs=003b  gs=0000             efl=00000206
kernel32!LoadLibraryA:
7c801d7b 8bff            mov     edi,edi
//Unicode字符串条件断点设置方法(和ascii不同是/mu和ma
代码:
0:000> bp kernel32!LoadLibraryExW "as /mu ${/v:dllname} poi(esp+4); .if($sicmp(\"${dllname}\",\"breakdll.dll\")==0){.echo ${dllname};}.else{gc;}"
0:000> g


0:000> .dvalloc 1000 //分配内存
Allocated 1000 bytes starting at 00390000
//把内存类型设置成MEM_RESERVE状态
0:000> .dvfree /d 00390000 1000
Freed 1000 bytes starting at 00390000
//查看内存属性
0:000> !vprot 00390000 
BaseAddress:       00390000
AllocationBase:    00390000
AllocationProtect: 00000040  PAGE_EXECUTE_READWRITE
RegionSize:        00001000
State:             00002000  MEM_RESERVE
Type:              00020000  MEM_PRIVATE
//完全释放内存
0:000> .dvfree 00390000 0
Freed 0 bytes starting at 00390000
//查看内存属性
0:000> !vprot 00390000 
BaseAddress:       00390000
AllocationBase:    00000000
RegionSize:        00070000
State:             00010000  MEM_FREE
Protect:           00000001  PAGE_NOACCESS





//查看进程列表详细信息
0:001> .tlist -v
  0n0 System Process
  0n4 System
0n572 smss.exe
     Session: 0  User: NT AUTHORITY\SYSTEM  Command Line: \SystemRoot\System32\smss.exe



//查看类型为Directory的句柄详细信息
0:000> !handle 0 3 Directory



//查看进程所有的堆
0:000> !heap
NtGlobalFlag enables following debugging aids for new heaps:    tail checking
    free checking
    validate parameters
    //发现有4个堆,第一个是默认堆,其他的是由C运行时库等创建的
Index   Address  Name      Debugging options enabled
  1:   00150000                 tail checking free checking validate parameters
  2:   00250000                 tail checking free checking validate parameters
  3:   00260000                 tail checking free checking validate parameters
  4:   00390000                 tail checking free checking validate parameters
//查看默认堆信息
0:000> !heap 00150000  
//总共有一个堆段               
Index   Address  Name      Debugging options enabled
  1:   00150000 
    Segment at 00150000 to 00250000 (00004000 bytes committed)
//查看默认堆的详细信息
0:000> !heap -a 00150000       


!vprot指令类似与VirtualQuery 函数。可以获取一个内存块的各种属性。

代码:
0:000> !vprot 400000
BaseAddress:       00400000
AllocationBase:    00400000
AllocationProtect: 00000080  PAGE_EXECUTE_WRITECOPY
RegionSize:        00001000
State:             00001000  MEM_COMMIT
Protect:           00000002  PAGE_READONLY
Type:              01000000  MEM_IMAGE


//查看400000地址信息,类似!vprot
0:000> !address 400000
Usage:                  Image
Allocation Base:        00400000
Base Address:           00400000
End Address:            00401000
Region Size:            00001000
Type:                   01000000    MEM_IMAGE
State:                  00001000    MEM_COMMIT
Protect:                00000002    PAGE_READONLY
More info:              lmv m PEViewer
More info:              !lmi PEViewer
More info:              ln 0x400000

//查看属于Image,Heap,Stack 性质的内存信息
0:000> !address /f:Image,Heap,Stack 

  BaseAddr EndAddr+1 RgnSize     Type       State                 Protect             Usage
-------------------------------------------------------------------------------------------
   30000   12d000    fd000 MEM_PRIVATE MEM_RESERVE                                    Stack [a38.d98; ~0]
  12d000   12e000     1000 MEM_PRIVATE MEM_COMMIT  PAGE_READWRITE|PAGE_GUARD          Stack [a38.d98; ~0]
  12e000   130000     2000 MEM_PRIVATE MEM_COMMIT  PAGE_READWRITE                     Stack [a38.d98; ~0]
  400000   401000     1000 MEM_IMAGE   MEM_COMMIT  PAGE_READONLY     




//显示字符串数组,或者dpa(对应ansi字符串)
0:000> dpu 003a0000 l8
003a0000  003a0020 "ustring1"
003a0004  003a0040 "ustring2"
003a0008  003a0060 "ustring3"
003a000c  003a0080 "ustring4"
003a0010  003a00a0 "ustring5"


posted @ 2013-12-15 16:25  kkindof  阅读(215)  评论(0)    收藏  举报