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 "\nType <b>call kernel32!OutputDebugStringW</b> then press Enter key two times then 'g' command after it.\n"

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.

 

posted on 2020-08-18 08:31  活着的虫子  阅读(465)  评论(0编辑  收藏  举报

导航