您的位置:首页 > 博客中心 > 数据库 >

windbg kp kb 命令测试

时间:2022-03-14 04:50


为了熟悉windbg kb,kp命令,写一段简单的程序调试观察,程序如下:

#include <stdio.h>
#include <Windows.h>

void printstr(char *str, int b)
{
	printf("xxx b is :%d\n",b);
}
int kbtest(int a)
{
	char str[] = "xxxxxxxxxx";
	printstr(str, a);
	return 1;
}
int main()
{
	kbtest(1);
	system("pause");
	return 1;
}

设置好windbg符号表路径(编译生成的符号表路径),

1、使用windbg加载程序

2、bp windbg_k!printstr 在函数出下断点

3、g 运行程序,程序暂停如下图:

 技术分享

调用函数时,一般是先参数入栈,然后函数下一条指令地址入栈,然后还有ebp

call fun(arg1, arg2)

push arg2
push arg1
push ret  //  参数压栈完后,调用 call fun ,然后将 call fun 下一天指令地址入栈,即函数的返回地址
push ebp
mov ebp, esp

可以得知,kb 显示的参数 从左到右分别为 ebp, ret ,arg1, arg2


通过 r 命令查看寄存器值,可知ebp 为003df7e0  

热门排行

今日推荐

热门手游