当前位置:Gxlcms > 数据库问题 > windbg调试驱动程序

windbg调试驱动程序

时间:2021-07-01 10:21:17 帮助过:25人阅读

配置windbg路径

  1. Symbol <span style="color: #0000ff">path</span>:SRV*F:\Windows\symbolxp3*http://msdl.microsoft.com/download/symbols;C:\Users\bojay\Desktop\first\objchk_wxp_x86\<span style="color: #000000">i386
  2. Source </span><span style="color: #0000ff">path</span>:C:\Users\bojay\Desktop\<span style="color: #000000">first
  3. Image </span><span style="color: #0000ff">path</span>:C:\Users\bojay\Desktop\first\objchk_wxp_x86\i386

【注意】windbg路径要根据个人具体情况而定,不能复制!

进入实操?

0x00>>将first.sys安装到虚拟机Windows XP系统,启动windbg,虚拟机立刻不能动,点击windbg F5,回到虚拟机启动驱动程序,windbg马上跳到int3断点处,如下:

技术分享图片

 

0x01>>设置两个断点F9,开始单步调试,执行到打印输出那行代码后,查看windbg输出:

技术分享图片

 

0x02>>F5,回到虚拟机

技术分享图片

 

0x03>>停止,查看windbg输出

技术分享图片

 

  1. #include <ntddk.h>
  2. <span style="color: #008000">//</span><span style="color: #008000"> 提供一个Unload函数只是为了</span>
  3. <span style="color: #000000">VOID DriverUnload(PDRIVER_OBJECT driver)
  4. {
  5. </span><span style="color: #008000">//</span><span style="color: #008000"> 但是实际上我们什么都不做,只打印一句话:</span>
  6. DbgPrint(<span style="color: #800000">"</span><span style="color: #800000">first: Our driver is unloading…\r\n</span><span style="color: #800000">"</span><span style="color: #000000">);
  7. }
  8. </span><span style="color: #008000">//</span><span style="color: #008000"> DriverEntry,入口函数。相当于main。</span>
  9. <span style="color: #000000">NTSTATUS DriverEntry(PDRIVER_OBJECT driver, PUNICODE_STRING reg_path)
  10. {
  11. </span><span style="color: #0000ff">#if</span> DBG<span style="color: #000000">
  12. _asm </span><span style="color: #0000ff">int</span> <span style="color: #800080">3</span>
  13. <span style="color: #0000ff">#endif</span>
  14. <span style="color: #008000">//</span><span style="color: #008000"> 这是我们的内核模块的入口,可以在这里写入我们想写的东西。</span>
  15. DbgPrint(<span style="color: #800000">"</span><span style="color: #800000">first: Hello, my salary!</span><span style="color: #800000">"</span><span style="color: #000000">);
  16. </span><span style="color: #008000">//</span><span style="color: #008000"> 设置一个卸载函数便于这个函数能退出。</span>
  17. driver->DriverUnload =<span style="color: #000000"> DriverUnload;
  18. </span><span style="color: #0000ff">return</span><span style="color: #000000"> STATUS_SUCCESS;
  19. }</span>

 

参考书籍:

Windows内核安全与驱动开发

windbg调试驱动程序

标签:安装   x86   \n   turn   ret   不能   windbg   调试   des   

人气教程排行