WinDBG 使用教学(二)

本文介绍了如何利用WinDBG的扩展命令进行调试,包括加载扩展DLL、查看结构体信息及使用帮助命令快速了解各DLL功能。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

一. WinDBG 内建许多指令供你应用, 但其他指令是怎麽来的呢?

    其实是 DLL 档案的 export function, 你也可以称这些 DLL file 是 WinDBG 的外挂(plugin)

    (你可别说每个 DLL 档案的 export function 都可拿来当 WinDBG 的指令呢)

    e文对这些扩充指令的正式称呼是 Extension Command

    我们先来实做一个实验

    先在 WinDBG 命令列输入 !strct _EPROCESS

    你得到什麽回应呢?

    不卖关子

    因为你还没有 load 该指令的 DLL 档案, 所以没有得到你想要的答案

    先用 explorer 浏览到 C:\Program Files\Debugging Tools for Windows (x86)\w2kfre 这目录

    里面有个 kdex2x86.dll 档案

    将它拷贝到 C:\Program Files\Debugging Tools for Windows (x86) 底下

    (也就你WinDBG的安装目录)

    然後在 WinDBG 指令列输入 .load kdex2x86.dll

    是的, .load 指令就是装载 DLL, 完毕後你再输入 !strct _EPROCESS

    现在你应该看到 _EPROCESS 这结构的面貌了吧

    strct 只是 kdex2x86.dll 的 export function 的其中之一, 功能是用来看结构的

    这小段的介绍, 只是想告诉你 Extension Command 是怎麽来的


二. 善用 help 指令, 快速的了解每个 Dll 的 export function 的功能

    (也就是 Extension Command)

    在安装 WinDBG 後, 里面好几个目录, 每个目录里面都有众多的 Dll files,

    我们不知道这些 Dll File 是做什麽用的, 但如何快速了解它的功能呢

    嗯~, 是的, 每个 Dll file 里面都有一个 help function, 

    好让我们快速的了解每个 Extension Command 的功能和使用方法

    首先, 让我们用 IDA 来看看 kdex2x86.dll 它的 export function

    ExtensionApiVersion    4B405920 1 
    WinDbgExtensionDllInit 4B405840 2 
    apc                    4B409070 3 
    dpc                    4B409390 4 
    ethread                4B408E00 5 
    help                   4B40D980 6 
    idt                    4B4095B0 7 
    ip                     4B403FE0 8 
    kqueue                 4B408FA0 9 
    kthread                4B408ED0 10
    lastlivetime           4B410D70 11
    list                   4B408540 12
    s                      4B4033A0 13
    singlelist             4B4087B0 14
    smb                    4B407F30 15
    stack                  4B4115F0 16
    strct                  4B409B20 17
    version                4B405930 18
    xpool                  4B40A210 19
    DllEntryPoint          4B447370   

    虽然不多, 但一个一个摸索也很浪费时间

    现在让我们在 WinDBG 的命令列输入

    !kdex2x86.help

    你将得到下面列表的讯息, 

    lkd> !kdex2x86.help

    help                       - Display this message
    version                    - Display extension dll version
    apc [-?h] [expression]     - Dump APC or all APCs
    dpc [-?h] [expression]     - Dump DPC or all DPCs
    ethread [-?h] [expression] - Display ETHREAD structure
    kthread [-?h] [expression] - Display KTHREAD structure
    idt [-?h] [processornumber [interruptnumber]]
                               - Dump information about IDT and handlers
    kqueue [-?h] [expression]  - Display queue of worker thread
    [single]list [-?h] <expression> [count] [structname[.listnodemembername]]
                               - Chain display of LIST_ENTRY and SINGLE_LIST_ENTRY
    smb [-?hd] <expression>    - Display SMB structure from header
    strct [-?h] <structname/"load"/"unload"> [fieldname] [expression]
                               - Display member offset and structure data
    xpool [-?h] [address] | [modulename[tag][-flag]]
          -fill modulename
          -log [[recent] [modulename] | [address]]
          -map [flag]
                               - Dump information about managed pool blocks
    lastlivetime               - Display the last time of system activity
    stack                      - Do stack trace for specified thread
    s [-?h] [StartAddress] [EndAddress | [l Size]] [Value]
                               - Pattern search.
    ip [-?h] [Address]         - Display IPPacket information.


    疑~ 有 IDT 指令耶, 很好奇它能让我们知道哪些资讯吧

    记的在使用这些 Extension Command 时前面要加个惊叹号 "!" 来开头唷

    而 WinDBG 的内建指令 (Meta-Command) 要加上句号 "." 来开头, 也有人称它为点符号


    如有错误,请各位大侠帮忙指正一下, thx
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值