判断程序是否在VMWare内运行
2016-05-30 05:39
435 查看
现在有许多用户都喜欢用虚拟机来测试他们的软件,以避免对真实机器环境造成损害。但是在虚拟机中,有些功能是受限,甚至不可能完成的,因此,需要在程序中判断虚拟机的环境,如果程序在虚拟机内运行,则就要把虚拟机下不能使用的功能屏蔽掉。
判断程序是否在VMWare虚拟机内,可以用以下代码来完成:
function IsRunInVMWare(out ErrMsg: string): Boolean;
begin
Result := False;
try
asm
push edx
push ecx
push ebx
mov eax, 'VMXh'
mov ecx, $0A
mov edx, 'VX'
in eax, dx
cmp ebx, 'VMXh'
setz [Result]
pop ebx
pop ecx
pop edx
end;
except
on E: Exception do
ErrMsg := E.Message;
end;
end;
本段代码在Delphi2009下编译通过,VMWare 5/6测试通过。
判断程序是否在VMWare虚拟机内,可以用以下代码来完成:
function IsRunInVMWare(out ErrMsg: string): Boolean;
begin
Result := False;
try
asm
push edx
push ecx
push ebx
mov eax, 'VMXh'
mov ecx, $0A
mov edx, 'VX'
in eax, dx
cmp ebx, 'VMXh'
setz [Result]
pop ebx
pop ecx
pop edx
end;
except
on E: Exception do
ErrMsg := E.Message;
end;
end;
本段代码在Delphi2009下编译通过,VMWare 5/6测试通过。
相关文章推荐
- 第二阶段个人博客总结3
- 在Delphi开发的服务中调用指定应用程序
- Spring学习笔记--Spring表达式语言SpEL
- 上周热点回顾(5.23-5.29)
- appium通过WiFi连接真机进行测试
- Erlang *.app文件构成
- JAVA之时间计算,键盘录入时间间隔得到未来时间
- BAT之简单java类启动器,通用执行当前目录java主程序
- Java 网络编程之 Socket
- burpsuite代理截取请求
- 测试新人工作想法
- [leetcode] 242. Valid Anagram
- 自编码器与堆叠自编码器简述
- [leetcode] 100. Same Tree
- [leetcode] 237. Delete Node in a Linked List
- 【CodeForces】[651C]Watchmen
- [leetcode] 283. Move Zeroes
- 欢迎使用CSDN-markdown编辑器
- 一个js爬虫
- 一个js爬虫