-
2007年03月29日
LoadRunner运行原理浅析(1)-启动应用程序
分类:Application: Mercury LoadRunner 8.1 x86
Environment: Windows+IE
Scenario:用LR调起IE
Tool: Process Explorer
Truth: LoadRunner 调用起IE的过程是, vugen.exe(虚拟用户生成器)传递先前设置好的iexplore.exe路径(Program to record中设置)、要测试的URL网址(URL Address中设置),把字符串参数传递给CreateProcessA函数,打开URL网页,录制过程。
Conclusion: LoadRunner启用系统的服务、进程,除了用CreateProcessA外,还用了ShellExecuteA。
通过反汇编工具查看Vugen.exe可以看到它调用BOOL __stdcall CreateProcessA(LPCSTR lpApplicationName, LPSTR lpCommandLine, LPSECURITY_ATTRIBUTES lpProcessAttributes, LPSECURITY_ATTRIBUTES lpThreadAttributes, BOOL bInheritHandles, DWORD dwCreationFlags, LPVOID lpEnvironment, LPCSTR lpCurrentDirectory, LPSTARTUPINFO lpStartupInfo, LPPROCESS_INFORMATION lpProcessInformation)来启动应用程序,比如Internet Explorer。
注:Win下shell命令来启动系统资源,如HINSTANCE __stdcall ShellExecuteA(HWND hwnd, LPCSTR lpOperation, LPCSTR lpFile, LPCSTR lpParameters, LPCSTR lpDirectory, INT nShowCmd)有潜在的风险。实际上Win下Shell执行一个程序是调用CreateProcess激活程序产生进程。
Case:
1.LoadRunner能支持Standalone的IE7脚本录制,在XPSP2+IE7上验证通过;
2.LoadRunner不兼容Windows Vista,vugen.exe(Mercury Virtual User Generator)启动失败,错误提示"Action",跟UAC安全特性无关,初步分析跟当前用户的Temp路径改变有关;
3.Windows 2003 SP2上无法录制IE6/7,导致IE Crash,iedw.exe(IE Crash Detection)报告错误事件,错误代码0xc0000005,ie在地址00CD4548 push 1Ah段中断。初步分析原因是Windows Server默认对IE加载DEP(数据执行保护)特性,而Vugen.exe刚好又跟DEP冲突。
原因是:
Windows 2003 & XP SP2 have a DEP (Data Execution Prevention) feature which prevents VuGen recording.
解决方案:
Control Panel->System -> "Advanced" tab->Performance section "Settings" button ->"Data Execution Prevention" tab->add the client program(vugen.exe) in "Turn on DEP for all programs and services except those I select" or choose "Turn on DEP for essential windows programs and services only." and a reboot is required.
Appendix:
2. 文件的长路径转换为短路径(dos格式)
[C#]
using System.Runtime.InteropServices;
定义:
[DllImport("kernel32.dll", CharSet = CharSet.Auto)]
public static extern int GetShortPathName(
[MarshalAs(UnmanagedType.LPTStr)] string path,
[MarshalAs(UnmanagedType.LPTStr)] StringBuilder shortPath, int shortPathLength);引用:
StringBuilder shortPath = new StringBuilder(80);
int result = GetShortPathName(@"F:\Program Files\Internet Explorer\iexplore.exe", shortPath, shortPath.Capacity);
string s = shortPath.ToString();
MessageBox.Show(s.ToString());
结果:
F:\PROGRA~1\INTERN~1\iexplore.exeBatch File(仅对已存路径有效)
set JAVA_HOME=C:\Program Files\Java\jdk1.5.0_12
for %%x in ("%JAVA_HOME%") do set JAVA_HOME=%%~sx
echo %JAVA_HOME%
3. Internet Explorer 7 (IE 7) support for LoadRunner 8.1 Feature Pack 4,必须先安装LoadRunner 8.1 Feature Pack 4
Patch Installation
To install this patch, run LR81FP4P125.exe, available from the Patches database.
Limitations· Some versions of JInitiator may cause IE to crash when recording the Oracle NCA protocol on IE 7 platforms.
· Cannot record the FTP protocol upload or download operations on IE 7 platforms.
· Does not support tabbed browsing.
If you record using VuGen on IE 7 platforms, then Internet Explorer will open with this feature disabled.· The current version of Mercury Diagnostics does not support IE 7. Diagnostics version 6.5 will support IE 7.
4.Linux Shell基本工作原理系统初启后,核心为每个终端用户建立一个进程去执行Shell解释程序。它的执行过程基本上按如下步骤:
(1)读取用户由键盘输入的命令行。
(2)分析命令,以命令名作为文件名,并将其它参数改造为系统调用execve( )内部处理所要求的形式。
execve()函数将执行一个程序。execve()用来执行参数filename字符串所代表的文件路径,第二个参数系利用数组指针来传递给执行文件,最后一个参数则为传递给执行文件的新环境变量数组。
#include<unistd.h>
int execve (const char *filename, const char *argv [], const char *envp[]);
(3)终端进程调用fork( )建立一个当前进程的子进程。
#include<sys/types.h> /*包含了pid_t的定义*/
#include<unistd.h> /*包含系统调用fork的说明*/
unisigned int pid_t fork(void);
(4)终端进程本身用系统调用wait4( )来等待子进程完成(如果是后台命令,则不等待)。当子进程运行时调用execve( ),子进程根据文件名(即命令名)到目录中查找有关文件(这是命令解释程序构成的文件),将它调入内存,执行这个程序(解释这条命令)。
#include <sys/types.h>
#include <sys/time.h>
#include <sys/resource.h>
#include <sys/wait.h>
pid_t wait4(pid_t pid, int *status, int options,struct rusage *rusage);
(5)如果命令末尾有&号(后台命令符号),则终端进程不用系统调用wait4( )等待,立即发提示符,让用户输入下一个命令,转⑴。如果命令末尾没有&号,则终端进程要一直等待,当子进程(即运行命令的进程)完成处理后终止,向父进程(终端进程)报告,此时终端进程醒来,在做必要的判别等工作后,终端进程发提示符,让用户输入新的命令,重复上述处理过程。
5. Responsibilities of the Shell
The shell is ultimately responsible for making sure that any commands typed at the prompt get executed properly. Included in those responsibilities are:
1. Reading input and parsing the command line
2. Evaluating special characters, such as wildcards and the history character
3. Setting up pipes, redirection, and background processing
4. Handling signals
5. Setting up programs for execution
随机文章:
Loadrunner中以进程或线程创建Vuser解析 2009年06月12日LoadRunner Virtual User FootPrints 2009年06月08日LoadRunner运行原理浅析(5)-IP欺骗 2008年04月07日LoadRunner运行原理浅析(4)-网络通讯端口 2007年07月23日LoadRunner运行原理浅析(3)-监听(下) 2007年06月07日
收藏到:Del.icio.us

评论