posts - 36,  comments - 28,  trackbacks - 0


AppVerifier的用法
This section discusses how to test an application using AppVerfier.

The first thing to note about AppVerifier is that it is not an automated test program for your applications. AppVerifier attaches to a program and performs tests whenever you run the program. It is possible to use AppVerifier and an automated test procedure simultaneously. AppVerifier attaches a "stub" or small piece of code to the executable program you are testing so that AppVerifier will be engaged every time the program is run.

To test an application with AppVerifier

To open AppVerifier, click Start, and then click Programs.

Under Programs, click Application Verifier.

Right click the mouse in the Application section of the main page and click Add Application to display the Add Application dialog box shown in Figure 2.

Figure 2: Using the Add Application dialog box to select an executable file to test
Browse to your application, and select the executable file to test. Double-click to open the file. Repeat Steps 3 and 4 for any additional executables to be tested.

In the test settings pane, see Figure 3, select the tests you want to perform from the following list:

 

Figure 3: Using the Tests area, click the checkbox next to the test to run.
Memory

Ensures APIs for virtual space manipulations are used correctly.

TLS

Ensures that Thread Local Storage APIs are used correctly

Low Resource Simulation

This simulates an environment under low resources for example, out of memory.

Limited User Account Predictor

This test simulates an environment running as a user with a limited user account and has two primary goals: predictive and diagnostic. The predictive element determines whether an application that is running in an administrative environment would also run well in an environment with less privilege, as a limited user, for example. The diagnostic element evaluates an application when it is running as a limited user and identifies potential problems.

Miscellaneous

Consists of Dirty stacks and Dangerous APIs.

Save the settings within Application Verifier

To start testing, simply use the application. Try to use all of the program's functions to generate the best data for the AppVerifier logs. Close the application when finished.

View the test results in the AppVerifier log file by clicking View Logs in AppVerifier.

The test settings you specify for a particular application will remain active every time you run the program until the program is removed from the list of applications in AppVerifier. You can run programs repeatedly while working out problems.

 

 

“Bug”中最头痛的是那么一类:野指针、无效句柄,访问冲突,跟Windows内核打交道比较多的那些,它们发现难,调试难,定位难。不过AppVerifier就是解决这些问题的工具,实际上,以微软为首的大的Windows软件开发商都在使用这个软件作辅助测试。我在这里推荐它的原因,除了它善于抓这些比较内核的、底层的Bug之外,是微软出品,可以免费使用和非常简单是另外几个因素。

AppVerifier的客观介绍
AppVerifier 可以免费下载,特别用于检测和帮助调试内存损坏、危险的安全漏洞以及受限的用户帐户特权问题。AppVerifier 有助于创建可靠且安全的应用程序,方法是监视应用程序与 Microsoft? Windows? 操作系统的交互,并配置应用程序使用的对象、注册表、文件系统和 Win32 API(包括堆、句柄和锁)。AppVerifier 还包括检查,以便预测应用程序在非管理员环境中的执行情况。

上面是微软MSDN中对它的介绍原文。MSDN在“C++安全性最佳做法”中推荐使用它来验证软件安全性。MSDN甚至还提倡在整个开发生命周期中使用这个软件:“在整个软件开发生命周期中使用时,AppVerifier可节约开发工作的成本,因为它能方便地在早期就识别出问题,而在早期修复错误是比较容易且成本较低的。”

AppVerifier能识别的问题
AppVerifier 有助于确定: (Copy于MSDN)
? 应用程序正确地使用 API 的时刻:
? 不安全的 TerminateThread API。
? 正确使用线程本地存储(Thread Local Storage,TLS)API。
? 正确使用虚拟空间操作(例如,VirtualAlloc 和 MapViewOfFile)。
? 应用程序是否使用结构化的异常处理隐藏访问冲突。 
? 应用程序是否试图使用无效的句柄。 
? 堆中是否有内存损坏或存在内存问题。 
? 应用程序是否在资源不足的情况下用尽了内存。 
? 是否正确使用了临界区。 
? 运行在管理员环境中的应用程序在具有较低特权的环境中是否能良好运行。 
? 当应用程序作为受限用户运行时是否会存在潜在的问题。 
? 在线程的上下文中,是否在将来的函数调用中会存在未初始化的变量。

AppVerifier的使用
下面结合自己的应用介绍一下它的使用方法(非常简单)。
1。下载AppVerifier
在微软网站下载,并安装软件
http://www.microsoft.com/downloads/details.aspx?FamilyID=bd02c19c-1250-433c-8c1b-2619bd93b3a2&DisplayLang=en

2。运行AppVerifier
在AppVerifier中增加需要验证的应用程序,对于开发人员,直接选择工程中输出的Debug版的可执行文件,可以添加多个文件,也可以添加动态库DLL。

3。配置需要验证的项目
AppVerifier大致可以验证异常、句柄、堆栈、内存、未初始化参数等18个方面(3.3版)的隐患,选择需要进行测试的项目,并保存设置。

4。在IDE中调试程序
这些跟以前是一样的,只是在调试过程中AppVerifier会向你报告它检测到的问题,以异常的方式,或者输出信息到输出框中,一般的情况,程序停在发生问题的地方不远处。

5。取消验证
在AppVerifier中取消要验证的程序,否则,验证代码一直挂在程序中。


好了,先拿手上的软件试试法吧,以前没有任何错误,现在,多出来了不少的异常,赶紧看看。。。。

与它是同一个系列的另一个软件:Driver Verifier,专门来测试驱动的安全。

参考文献:
感兴趣的同事google一下“Application Verifier”,看看简介。
想学习的同事请阅读MSDN:
《在软件开发生命周期中使用应用程序验证器》
http://www.microsoft.com/china/MSDN/library/enterprisedevelopment/softwaredev/WDdnclinicscripting.mspx?mfr=true

《使用应用程序验证程序排除 Windows XP中的程序问题》
http://support.microsoft.com/default.aspx/kb/286568/zh-cn

《C++ 安全性最佳做法》
http://msdn2.microsoft.com/zh-cn/library/k3a3hzw7(VS.80).aspx
 


本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/91program/archive/2008/09/03/2871277.aspx

posted on 2009-11-03 17:36 Hali 阅读(1129) 评论(0)  编辑 收藏 引用
只有注册用户登录后才能发表评论。

<2009年11月>
25262728293031
1234567
891011121314
15161718192021
22232425262728
293012345

常用链接

留言簿

随笔分类

随笔档案

休闲链接

学习链接

牛人博客

搜索

  •  

最新评论

阅读排行榜

评论排行榜