• Windbg Script---跟踪MessageBox调用


    在过去,我研究了一个支持案例,我需要找出C++应用程序中的一些消息框是否被显示,如果是肯定的,消息是什么。每次我问用户时得到的回答都不一致,所以我不知道是否出现了MessageBox或消息是什么。
    这听起来像是另一个完美的场景,脚本可能会有所帮助!事实上,这对我帮助很大,我希望对你也有帮助。这个脚本映射MessageBox调用,并将消息从MessageBox记录到Windbg屏幕上,也记录到一个文本文件中。
    调试应用程序后,应使用“.logclose”关闭日志。然后您可以搜索字符串“Text from MessageBox”,您将得到应用程序显示的所有MessageBox!
    你可以用DBMon.exe或者DebugView.exe查看来自MessageBox窗口的消息。我从来没有在.NET应用程序上测试过它,但它应该可以工作,因为MessageBox是在一些.NET Framework调用的幕后调用。

    截图如下:

     注意!在上面的命令后按两次回车键而不是一次。

     

     

     Source code for MSGBOX_TRACING.TXT:

    $$
    
    $$ =============================================================================
    
    $$ Log MessageBox messages in a log file.
    
    $$ The log file name starts with MessageBox string.
    
    $$
    
    $$ Compatibility: Win32.
    
    $$
    
    $$ Usage: $$>< to run the script.
    
    $$
    
    $$ Requirements: Public symbols.
    
    $$
    
    $$ Roberto Alexis Farah
    
    $$ Blog: http://blogs.msdn.com/debuggingtoolbox/
    
    $$
    
    $$ All my scripts are provided "AS IS" with no warranties, and confer no rights.
    
    $$ =============================================================================
    
    $$
    
    $$ This location 7EEEEEEE is difficult to be used but
    
    $$ it could be occupied!!!
    
    $$
    
    .dvalloc /b 0x7EEEEEEE 0x400
    
    r @$t0 = 0x7EEEEEEE
    
    eb 0x7EEEEEEE 50
    
    bp user32!MessageBoxExW "r @$t1 = @eip; r @eax = poi(@esp + 0x8); r @eip = @$t0;g"
    
    bp @$t0 + 0x6 ".echo <-- Text from MessageBox; r @$ip = @$t1;g"
    
    .logopen /t /u MessageBox.txt
    
    .printf /D "
    Type <b>call kernel32!OutputDebugStringW</b> then press Enter key two times then 'g' command after it.
    "
    
    a 0x7EEEEEEF
    
    $$
    
    $$ ATTENTION! Use .logclose after finishing the debugging session.
    
    $$
    
    $$ =========================
    
    Note: Some of my previous scripts were updated! Whenever I do that I write a small comment about it explaining the update.
    
  • 相关阅读:
    springmvc注意点
    MySQL修改约束
    MySQL事务(脏读、不可重复读、幻读)
    浅谈Python-IO多路复用(select、poll、epoll模式)
    浅析python-socket编程
    浅析python迭代器及生成器函数
    并发、并行、同步、异步、阻塞、非阻塞概念整理
    HTTP请求响应的过程
    浅析TCP三次握手及四次挥手
    浅谈python闭包及装饰器
  • 原文地址:https://www.cnblogs.com/yilang/p/13457771.html
Copyright © 2020-2023  润新知