由windbg断kernel32下的函数

来源:互联网 发布:淘宝网网支付方式 编辑:程序博客网 时间:2024/05/16 11:17

由windbg断kernel32下的函数。
前提条件,假如windbg正在调试一台虚拟机,现在要查看一个kernel32函数的调用过程,
那么,ctl+break断下windbg,取得控制权;
此时,bp virtualAlloc等其他kernel32下的函数,是无法下断的,因为windbg现在处于内核态进程。

切换方法。

<1> !process -1 0 ;查看当前进程
PROCESS 80552b80 SessionId: none Cid: 0000    Peb: 00000000 ParentCid: 0000
    DirBase: 00a8f000 ObjectTable: e1000cc0 HandleCount: 186.
    Image: Idle


<2> !process 0 0 ;查看系统当前的所有进程,找到一个用户态进程,比如explorer.exe


PROCESS 81f4b510 SessionId: 0 Cid: 05d0    Peb: 7ffd4000 ParentCid: 05a0
    DirBase: 079c01c0 ObjectTable: e16de670 HandleCount: 261.
    Image: EXPLORER.EXE


<3> .process -i 81f4b510 (用户态进程eprocess地址)

提示如下:
You need to continue execution (press 'g' <enter>) for the context
to be switched. When the debugger breaks in again, you will be in
the new process context.

<4> g 输入命令:g,回车,切换到用户态进程

<5> .reload /f ;重新加载符号,这里主要是加载用户态符号

    lm ;查看加载的模块

然后对需要跟踪的函数下断

bp CreateFilew ;注意,不能对CreateFile下断,所有对CreateFile的调用,编译时根据工程类型替换成w,a型函数。
bp VirtualAlloc 等